@gjsify/example-node-express-webserver 0.54.0 → 0.56.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/index.gjs.js +29 -29
- package/package.json +5 -5
package/dist/index.gjs.js
CHANGED
|
@@ -8,7 +8,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,Symbol.dispose||(Symbol.dispos
|
|
|
8
8
|
`+t)}profile(e){}profileEnd(e){}timeStamp(e){}},j=new Console,log=(...e)=>j.log(...e),info=(...e)=>j.info(...e),debug=(...e)=>j.debug(...e),warn=(...e)=>j.warn(...e),error=(...e)=>j.error(...e),dir=(e,t)=>j.dir(e,t),dirxml=(...e)=>j.dirxml(...e),table=(e,t)=>j.table(e,t),clear=()=>j.clear(),assert=(e,...t)=>j.assert(e,...t),trace=(...e)=>j.trace(...e),time=e=>j.time(e),timeEnd=e=>j.timeEnd(e),timeLog=(e,...t)=>j.timeLog(e,...t),count=e=>j.count(e),countReset=e=>j.countReset(e),group=(...e)=>j.group(...e),groupCollapsed=(...e)=>j.groupCollapsed(...e),groupEnd=()=>j.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{}}),M,N=__esmMin(()=>{ae(),M={log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),oe,se=__esmMin(()=>{oe=__name(e=>{Promise.resolve().then(e)},`queueMicrotask`)});function isWindowsPath(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function splitPathComponents(e){return isWindowsPath(e)?e.split(/[\\/]/):e.split(`/`)}function pathToFileUrlHref(e,t){let n=t?.windows??isWindowsPath(e),r=n?e.replace(/\\/g,`/`):e;if(n&&r.startsWith(`//`)){let e=r.indexOf(`/`,2);return`file://${e===-1?r.slice(2):r.slice(2,e)}${encodePathForFileUrl(e===-1?``:r.slice(e))}`}return`${r.startsWith(`/`)?`file://`:`file:///`}${encodePathForFileUrl(r)}`}function encodePathForFileUrl(e){let t=``;for(let n of e)t+=ce.test(n)?n:percentEncode$1(n);return t}function percentEncode$1(e){let t=``;for(let n of new TextEncoder().encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}var ce,le=__esmMin(()=>{ce=/^[A-Za-z0-9!$&'()*+,\-./:;=@_]$/,__name(percentEncode$1,`percentEncode`)});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 ue=__esmMin(()=>{});function classOf(e){return de.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 o=classOf(i);if(o===`Date`)return new Date(i.getTime());if(o===`RegExp`)return new RegExp(i.source,i.flags);if(o===`Boolean`||o===`Number`||o===`String`)return Object(i.valueOf());if(o===`BigInt`)return Object(BigInt.prototype.valueOf.call(i));if(i instanceof Error){let e=i,r=e.constructor?.name,o=new(r&&fe[r]||fe[e.name]||Error)(e.message);return o.name=e.name,`cause`in e&&Object.defineProperty(o,"cause",{value:internalClone(e.cause,t,n),writable:!0,enumerable:!1,configurable:!0}),o}if(o===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=i;return new e(t.message,t.name)}}if(o===`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(o===`SharedArrayBuffer`||i&&typeof i==`object`&&i.constructor?.name===`SharedBuffer`)return i;if(o===`DataView`){let e=i,r=n?.viewSnapshots.get(i),o=internalClone(e.buffer,t,n),s=r?r.byteOffset:e.byteOffset,c=r?r.byteLength:e.byteLength,l=new DataView(o,s,c);return t.set(i,l),l}if(pe.has(o)){let e=i,r=n?.viewSnapshots.get(i),o=internalClone(e.buffer,t,n),s=e.constructor,c=new s(o,r?r.byteOffset:e.byteOffset,r?r.length:e.length);return t.set(i,c),c}if(o===`Map`){let e=new Map;t.set(i,e);for(let[r,o]of i)e.set(internalClone(r,t,n),internalClone(o,t,n));return e}if(o===`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`),o===`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(o===`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(`${o} 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 o=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),o.set(e,t.transfer())}return internalClone(e,new Map,{transferred:o,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 o=classOf(i);if(o===`DataView`){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(pe.has(o)){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(o===`Map`){for(let[e,o]of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r),snapshotViewsBackedByTransferredBuffers(o,t,n,r);return}if(o===`Set`){for(let e of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r);return}if(o===`Object`)for(let e of Object.keys(i))snapshotViewsBackedByTransferredBuffers(i[e],t,n,r)}var de,fe,pe,me=__esmMin(()=>{({toString:de}=Object.prototype),fe={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},pe=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(he!==null)return he>0?he: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 he=Number.isInteger(t)&&t>0?t:0,he>0?he: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(`
|
|
9
9
|
`)){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 he,ge=__esmMin(()=>{he=null});function glib(){let e=globalThis;if(typeof e.process?.versions?.gjs==`string`||e.process===void 0)return e.imports?.gi?.GLib}function arm(e){ye||(ye=!0,e.runAsync().catch(()=>{}))}function ensureMainLoop(){let e=glib();if(e)return ve?_e:(_e=new e.MainLoop(null,!1),ve=!0,e.main_depth()===0&&arm(_e),_e)}function quitMainLoop(){_e&&=(_e.quit(),ve=!1,ye=!1,null)}var _e,ve,ye,be=__esmMin(()=>{_e=null,ve=!1,ye=!1});function hostGi(){return globalThis.imports?.gi}function directoryOf(e){return/^(.*)[\\/][^\\/]*$/.exec(e)?.[1]}function colocateNativeLibrary(e,t=hostGi()){try{let n=t?.GIRepository?.Repository?.dup_default?.(),r=n?.get_typelib_path(e),i=r?directoryOf(r):void 0;return!n||!i?!1:(n.prepend_library_path(i),!0)}catch{return!1}}function probeNativeLibrary(e,t=hostGi()){try{let n=t?.GIRepository?.Repository?.dup_default?.(),r=n?.get_typelib_path(e);if(!t||!n||!r)return null;let i=firstSymbol(n,e);if(!i||(t.GModule?.module_error(),i.info.get_typelib().symbol(i.name)[0]))return null;let o=directoryOf(r)??`.`,s=r.includes(`\\`)&&!r.includes(`/`)?`\\`:`/`;for(let c of n.get_shared_libraries(e)??[]){let n=`${o}${s}${c}`,l=t.GLib?.file_test(n,t.GLib.FileTest.EXISTS)?n:c,u=loaderError(t,e,r,l,i.name);if(u!==void 0)return{namespace:e,library:l,reason:u,missingDependency:missingLibraryDependency(u,l)}}let c=(n.get_shared_libraries(e)??[]).join(`, `)||`(none named)`;return{namespace:e,library:c,reason:`symbol ${i.name} not found in ${c}, and the loader reported no error`}}catch{return null}}function firstSymbol(e,t){let n=e.get_n_infos(t),r=null;for(let i=0;i<n;i++){let n=e.get_info(t,i),o=n.get_type_init_function_name?.();if(o)return{info:n,name:o};let s=n.get_symbol?.();s&&!r&&(r={info:n,name:s})}return r}function loaderError(e,t,n,r,i){let{GIRepository:o,GLib:s,GModule:c}=e;if(!o?.Repository||!o.Typelib||!s||!c)return;let[,l]=s.file_get_contents(n),u=new TextEncoder().encode(`${r}\0`),d=new Uint8Array(l.length+u.length);d.set(l),d.set(u,l.length);let p=new DataView(d.buffer);p.setUint32(40,d.length,!0),p.setUint32(52,l.length,!0);let m=new o.Repository,h=firstSymbol(m,m.load_typelib(o.Typelib.new_from_bytes(new s.Bytes(d)),0));if(h&&(c.module_error(),!h.info.get_typelib().symbol(i)[0]))return c.module_error()??`${t}: ${r} could not be opened (the loader reported no error)`}function missingLibraryDependency(e,t){let n=/Library not loaded: (\S+)/.exec(e)?.[1]??/Error loading shared library ([^\s:]+): .*\(needed by /.exec(e)?.[1]??/(?:^|\s)([^\s:]+): cannot open shared object file/.exec(e)?.[1];if(!n)return;let r=n.replace(/^.*[\\/]/,``);if(!(t&&r===t.replace(/^.*[\\/]/,``)))return r}function openNativeLibrary(e,t=hostGi()){colocateNativeLibrary(e,t);let n=probeNativeLibrary(e,t);return n?new NativeLibraryLoadError(n):null}function loadOptionalNativeModule(e,t,n=hostGi()){if(!n)return{module:null,error:Error(`${e}: imports.gi is not available (not running on GJS)`)};try{let r=n[e];if(!r)return{module:null,error:Error(`${e}: typelib not found`)};let i=openNativeLibrary(e,n);if(i)return M.debug(i.message),{module:null,error:i};for(let e of t)r[e];return{module:r,error:null}}catch(e){return{module:null,error:e instanceof Error?e:Error(String(e))}}}var NativeLibraryLoadError,xe=__esmMin(()=>{N(),NativeLibraryLoadError=class extends Error{failure;constructor(e,t){let n=e.missingDependency?`It needs ${e.missingDependency}, which the loader could not find: not installed, or not on its search path.`:`The loader could not open it.`;super(`${e.namespace}: the native library ${e.library} could not be loaded. ${n}\nLoader: ${e.reason.trim()}\n`+(t??"`gjsify system-check` lists the system libraries the installed @gjsify packages need, with the install command for this host.")),this.name=`NativeLibraryLoadError`,this.failure=e}}});function drainOnce(e){let t=Math.min(64,Se.length);for(let n=0;n<t;n++){let t=Se.shift();try{t()}catch(t){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(t?.stack||t),null)}catch{}}}Se.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):Ce=!1}function tryGLibTimeout(e){let t=globalThis.imports?.gi?.GLib;return t?.timeout_add?(Se.push(e),Ce||(Ce=!0,t.timeout_add(t.PRIORITY_DEFAULT,0,()=>(drainOnce(t),!1))),!0):!1}var Se,Ce,nextTick,we=__esmMin(()=>{Se=[],Ce=!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)}}}),P=__esmMin(()=>{E(),D(),ee(),k(),te(),ne(),se(),le(),ue(),me(),ge(),be(),xe(),we()});T(),P(),registerGlobal(`Blob`,S),registerGlobal(`File`,w);const Te={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`,transparent:`#00000000`};function parseColor(e){if(!e||typeof e!=`string`)return null;let t=e.trim().toLowerCase(),n=Te[t];if(n)return parseHex(n);if(t.startsWith(`#`))return parseHex(t);let r=t.match(/^rgba?\(\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(r)return{r:parseComponent(r[1],255)/255,g:parseComponent(r[2],255)/255,b:parseComponent(r[3],255)/255,a:r[4]===void 0?1:parseComponent(r[4],1)};let i=t.match(/^hsla?\(\s*(\d+(?:\.\d+)?)\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(i){let e=parseFloat(i[1]),t=parseFloat(i[2]),n=i[3]===`%`,r=parseFloat(i[4]),o=i[5]===`%`,s=i[6]===void 0?1:parseComponent(i[6],1);return e>1&&(e/=360),(n||t>1)&&(t/=100),(o||r>1)&&(r/=100),hslToRGBA(e,t,r,Math.max(0,Math.min(1,s)))}return null}function parseHex(e){let t=e.slice(1),n,r,i,o=1;if(t.length===3)n=parseInt(t[0]+t[0],16)/255,r=parseInt(t[1]+t[1],16)/255,i=parseInt(t[2]+t[2],16)/255;else if(t.length===4)n=parseInt(t[0]+t[0],16)/255,r=parseInt(t[1]+t[1],16)/255,i=parseInt(t[2]+t[2],16)/255,o=parseInt(t[3]+t[3],16)/255;else if(t.length===6)n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255;else if(t.length===8)n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255,o=parseInt(t.slice(6,8),16)/255;else return null;return{r:n,g:r,b:i,a:o}}function parseComponent(e,t){return e.endsWith(`%`)?parseFloat(e)/100*t:parseFloat(e)}function hue2rgb(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function hslToRGBA(e,t,n,r){let i,o,s;if(t===0)i=o=s=n;else{let r=n<.5?n*(1+t):n+t-n*t,c=2*n-r;i=hue2rgb(c,r,e+1/3),o=hue2rgb(c,r,e),s=hue2rgb(c,r,e-1/3)}return{r:i,g:o,b:s,a:r}}const Ee={r:0,g:0,b:0,a:1};var CanvasGradient=class{constructor(t,n,r,i,o,s,c){t===`radial`?this._pattern=new e.RadialGradient(n,r,s,i,o,c):this._pattern=new e.LinearGradient(n,r,i,o)}addColorStop(e,t){let n=parseColor(t);n&&this._pattern.addColorStopRGBA(e,n.r,n.g,n.b,n.a)}_getCairoPattern(){return this._pattern}};function quadraticToCubic(e,t,n,r,i,o){return{cp1x:e+2/3*(n-e),cp1y:t+2/3*(r-t),cp2x:i+2/3*(n-i),cp2y:o+2/3*(r-o)}}function computeArcTo(e,t,n,r,i,o,s){let c=e-n,l=t-r,u=i-n,d=o-r,p=Math.sqrt(c*c+l*l),m=Math.sqrt(u*u+d*d);if(p===0||m===0)return null;let h=c/p,g=l/p,_=u/m,v=d/m,y=h*v-g*_;if(Math.abs(y)<1e-10)return null;let b=h*_+g*v,x=Math.acos(Math.max(-1,Math.min(1,b)))/2,S=s/Math.tan(x),w=n+h*S,T=r+g*S,E=n+_*S,D=r+v*S,ee=s/Math.sin(x),O=(h+_)/2,k=(g+v)/2,te=Math.sqrt(O*O+k*k),A=n+O/te*ee,ne=r+k/te*ee;return{tx0:w,ty0:T,tx1:E,ty1:D,cx:A,cy:ne,startAngle:Math.atan2(T-ne,w-A),endAngle:Math.atan2(D-ne,E-A),counterclockwise:y>0}}function cairoArcTo(e,t,n,r,i,o,s,c){let l=computeArcTo(t,n,r,i,o,s,c);if(!l){e.lineTo(r,i);return}let{tx0:u,ty0:d,cx:p,cy:m,startAngle:h,endAngle:g,counterclockwise:_}=l;e.lineTo(u,d),_?e.arcNegative(p,m,c,h,g):e.arc(p,m,c,h,g)}function cairoEllipse(e,t,n,r,i,o,s,c,l){e.save(),e.translate(t,n),e.rotate(o),e.scale(r,i),l?e.arcNegative(0,0,1,s,c):e.arc(0,0,1,s,c),e.restore()}function cairoRoundRect(e,t,n,r,i,o){let s,c,l,u;typeof o==`number`?s=c=l=u=o:o.length===1?s=c=l=u=o[0]:o.length===2?(s=l=o[0],c=u=o[1]):o.length===3?(s=o[0],c=u=o[1],l=o[2]):(s=o[0],c=o[1],l=o[2],u=o[3]);let d=Math.min(r/2,i/2);s=Math.min(s,d),c=Math.min(c,d),l=Math.min(l,d),u=Math.min(u,d);let p=Math.PI/2;e.newSubPath(),e.arc(t+s,n+s,s,Math.PI,Math.PI+p),e.arc(t+r-c,n+c,c,-p,0),e.arc(t+r-l,n+i-l,l,0,p),e.arc(t+u,n+i-u,u,p,Math.PI),e.closePath()}const De={"source-over":2,"source-in":3,"source-out":4,"source-atop":5,"destination-over":7,"destination-in":8,"destination-out":9,"destination-atop":10,lighter:12,copy:1,xor:11,multiply:14,screen:15,overlay:16,darken:17,lighten:18,"color-dodge":19,"color-burn":20,"hard-light":21,"soft-light":22,difference:23,exclusion:24,hue:25,saturation:26,color:27,luminosity:28},Oe={butt:0,round:1,square:2},ke={miter:0,round:1,bevel:2};var Ae=class Path2D{constructor(e){this._ops=[],e instanceof Path2D&&(this._ops=[...e._ops])}addPath(e){this._ops.push(...e._ops)}moveTo(e,t){this._ops.push({type:`moveTo`,x:e,y:t})}lineTo(e,t){this._ops.push({type:`lineTo`,x:e,y:t})}closePath(){this._ops.push({type:`closePath`})}bezierCurveTo(e,t,n,r,i,o){this._ops.push({type:`bezierCurveTo`,cp1x:e,cp1y:t,cp2x:n,cp2y:r,x:i,y:o})}quadraticCurveTo(e,t,n,r){this._ops.push({type:`quadraticCurveTo`,cpx:e,cpy:t,x:n,y:r})}arc(e,t,n,r,i,o=!1){this._ops.push({type:`arc`,x:e,y:t,radius:n,startAngle:r,endAngle:i,ccw:o})}ellipse(e,t,n,r,i,o,s,c=!1){if(n<0||r<0)throw RangeError(`The radii provided are negative`);this._ops.push({type:`ellipse`,x:e,y:t,rx:n,ry:r,rotation:i,startAngle:o,endAngle:s,ccw:c})}rect(e,t,n,r){this._ops.push({type:`rect`,x:e,y:t,w:n,h:r})}roundRect(e,t,n,r,i=0){this._ops.push({type:`roundRect`,x:e,y:t,w:n,h:r,radii:i})}_replayOnCairo(e){let t=0,n=0;for(let r of this._ops)switch(r.type){case`moveTo`:e.moveTo(r.x,r.y),t=r.x,n=r.y;break;case`lineTo`:e.lineTo(r.x,r.y),t=r.x,n=r.y;break;case`closePath`:e.closePath();break;case`bezierCurveTo`:e.curveTo(r.cp1x,r.cp1y,r.cp2x,r.cp2y,r.x,r.y),t=r.x,n=r.y;break;case`quadraticCurveTo`:{let{cp1x:i,cp1y:o,cp2x:s,cp2y:c}=quadraticToCubic(t,n,r.cpx,r.cpy,r.x,r.y);e.curveTo(i,o,s,c,r.x,r.y),t=r.x,n=r.y;break}case`arc`:r.ccw?e.arcNegative(r.x,r.y,r.radius,r.startAngle,r.endAngle):e.arc(r.x,r.y,r.radius,r.startAngle,r.endAngle);break;case`ellipse`:e.save(),e.translate(r.x,r.y),e.rotate(r.rotation),e.scale(r.rx,r.ry),r.ccw?e.arcNegative(0,0,1,r.startAngle,r.endAngle):e.arc(0,0,1,r.startAngle,r.endAngle),e.restore();break;case`rect`:e.rectangle(r.x,r.y,r.w,r.h);break;case`roundRect`:cairoRoundRect(e,r.x,r.y,r.w,r.h,r.radii);break}}};function asCairoPattern(e){if(!e)return null;let t=e;return typeof t.setFilter!=`function`||typeof t.setExtend!=`function`?null:t}function isPixbufImageSource(e){return typeof e!=`object`||!e?!1:typeof e.isPixbuf==`function`&&e.isPixbuf()}function isCanvasImageSource(e){return typeof e!=`object`||!e?!1:typeof e.getContext==`function`}let je=null;function setCanvasPixelBridge(e){je=e}function getCanvasPixelBridge(){if(!je)throw TypeError(`@gjsify/canvas2d-core: no pixel bridge registered — pixel operations (getImageData / putImageData / drawImage / createPattern) need a platform backend. On GJS, import '@gjsify/canvas2d-core/gdk' (or use '@gjsify/dom-elements' / '@gjsify/canvas2d', which register it for you).`);return je}var Me=class CanvasPattern{constructor(t,n){let r=asCairoPattern(new e.SurfacePattern(t));if(!r)throw TypeError(`CanvasPattern: cairo SurfacePattern is missing setExtend at runtime — incompatible Cairo binding`);switch(this._pattern=r,n){case`repeat`:case``:case null:r.setExtend(e.Extend.REPEAT);break;case`repeat-x`:case`repeat-y`:r.setExtend(e.Extend.REPEAT);break;case`no-repeat`:r.setExtend(e.Extend.NONE);break}}static create(t,n){if(isPixbufImageSource(t)){let r=t._pixbuf,i=r.get_width(),o=r.get_height(),s=new e.ImageSurface(e.Format.ARGB32,i,o),c=new e.Context(s);return getCanvasPixelBridge().setSourceImage(c,r,0,0),c.paint(),c.$dispose(),new CanvasPattern(s,n)}if(isCanvasImageSource(t)){let r=t.getContext(`2d`);if(r&&typeof r._getSurface==`function`){let t=r._getSurface(),i=t.getWidth(),o=t.getHeight(),s=new e.ImageSurface(e.Format.ARGB32,i,o),c=new e.Context(s);return c.setSourceSurface(t,0,0),c.paint(),c.$dispose(),new CanvasPattern(s,n)}}return null}_getCairoPattern(){return this._pattern}},OurImageData=class{constructor(e,t,n){if(this.colorSpace=`srgb`,typeof e==`number`)this.width=e,this.height=t,this.data=new Uint8ClampedArray(this.width*this.height*4);else if(this.data=e,this.width=t,this.height=n??this.data.length/(4*this.width),this.data.length!==this.width*this.height*4)throw RangeError(`Source data length ${this.data.length} is not a multiple of (4 * width=${this.width})`)}};const Ne={translate(e,t){this._ensureSurface(),!(!Number.isFinite(e)||!Number.isFinite(t))&&this._ctx.translate(e,t)},rotate(e){this._ensureSurface(),Number.isFinite(e)&&this._ctx.rotate(e)},scale(e,t){if(this._ensureSurface(),!(!Number.isFinite(e)||!Number.isFinite(t))){if(e===0||t===0){this._state.transformIsSingular=!0;return}this._ctx.scale(e,t)}},transform(e,t,n,r,i,o){if(this._ensureSurface(),!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(o))return;if(e*r-t*n===0){this._state.transformIsSingular=!0;return}let s=i,c=o,l=Math.hypot(e,t),u=Math.hypot(n,r),d=Math.atan2(t,e);this._ctx.translate(s,c),d!==0&&this._ctx.rotate(d),(l!==1||u!==1)&&this._ctx.scale(l,u)},setTransform(e,t,n,r,i,o){if(this._ensureSurface(),this._state.transformIsSingular=!1,typeof e==`object`&&e){let t=e;this._ctx.identityMatrix(),this.transform(t.a??t.m11??1,t.b??t.m12??0,t.c??t.m21??0,t.d??t.m22??1,t.e??t.m41??0,t.f??t.m42??0)}else typeof e==`number`?(this._ctx.identityMatrix(),this.transform(e,t,n,r,i,o)):this._ctx.identityMatrix()},getTransform(){if(this._state.transformIsSingular){let e=this._ctx.userToDevice(0,0);return makeMatrix(0,0,0,0,e[0]??0,e[1]??0)}let e=this._ctx.userToDevice(0,0),t=this._ctx.userToDevice(1,0),n=this._ctx.userToDevice(0,1),r=e[0]??0,i=e[1]??0;return makeMatrix((t[0]??0)-r,(t[1]??0)-i,(n[0]??0)-r,(n[1]??0)-i,r,i)},resetTransform(){this._ensureSurface(),this._state.transformIsSingular=!1,this._ctx.identityMatrix()}};function makeMatrix(e,t,n,r,i,o){let s=globalThis.DOMMatrix;return typeof s==`function`?new s([e,t,n,r,i,o]):{a:e,b:t,c:n,d:r,e:i,f:o,m11:e,m12:t,m13:0,m14:0,m21:n,m22:r,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:i,m42:o,m43:0,m44:1,is2D:!0,isIdentity:e===1&&t===0&&n===0&&r===1&&i===0&&o===0}}function installTransformMethods(e){Object.assign(e,Ne)}const Pe={beginPath(){this._ensureSurface(),this._ctx.newPath()},moveTo(e,t){this._ensureSurface(),this._ctx.moveTo(e,t)},lineTo(e,t){this._ensureSurface(),this._ctx.lineTo(e,t)},closePath(){this._ensureSurface(),this._ctx.closePath()},bezierCurveTo(e,t,n,r,i,o){this._ensureSurface(),this._ctx.curveTo(e,t,n,r,i,o)},quadraticCurveTo(e,t,n,r){this._ensureSurface();let i,o;this._ctx.hasCurrentPoint()?[i,o]=this._ctx.getCurrentPoint():(i=e,o=t);let{cp1x:s,cp1y:c,cp2x:l,cp2y:u}=quadraticToCubic(i,o,e,t,n,r);this._ctx.curveTo(s,c,l,u,n,r)},arc(e,t,n,r,i,o=!1){if(this._ensureSurface(),Math.abs(i-r)>=2*Math.PI){this._ctx.arc(e,t,n,0,2*Math.PI);return}o?this._ctx.arcNegative(e,t,n,r,i):this._ctx.arc(e,t,n,r,i)},arcTo(e,t,n,r,i){this._ensureSurface();let o,s;this._ctx.hasCurrentPoint()?[o,s]=this._ctx.getCurrentPoint():(o=e,s=t,this._ctx.moveTo(e,t)),cairoArcTo(this._ctx,o,s,e,t,n,r,i)},ellipse(e,t,n,r,i,o,s,c=!1){if(this._ensureSurface(),n<0||r<0)throw RangeError(`The radii provided are negative`);cairoEllipse(this._ctx,e,t,n,r,i,o,s,c)},rect(e,t,n,r){this._ensureSurface(),this._ctx.rectangle(e,t,n,r)},roundRect(e,t,n,r,i=0){this._ensureSurface(),cairoRoundRect(this._ctx,e,t,n,r,i)}};function installPathMethods(e){Object.assign(e,Pe)}function getDrawImageSource(e){if(isPixbufImageSource(e)){let t=e._pixbuf;return{pixbuf:t,imgWidth:t.get_width(),imgHeight:t.get_height()}}if(isCanvasImageSource(e)){let t=e.width??0,n=e.height??0;if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return null;let r=e.getContext(`2d`);if(r&&typeof r._getSurface==`function`){let e=r._getSurface();e.flush();let i=getCanvasPixelBridge().imageFromSurface(e,0,0,t,n);if(i)return{pixbuf:i,imgWidth:t,imgHeight:n}}}return null}const Fe={fill(t,n){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing(),this._applyFillStyle();let r;t instanceof Ae?(this._ctx.newPath(),t._replayOnCairo(this._ctx),r=n):r=t,this._ctx.setFillRule(r===`evenodd`?e.FillRule.EVEN_ODD:e.FillRule.WINDING),this._ctx.fillPreserve()},stroke(e){this._ensureSurface(),!this._state.transformIsSingular&&(this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle(),e instanceof Ae&&(this._ctx.newPath(),e._replayOnCairo(this._ctx)),this._ctx.strokePreserve())},fillRect(e,t,n,r){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing();let i=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.fill()}),this._applyFillStyle(),this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.fill(),this._ctx.newPath(),this._ctx.appendPath(i)},strokeRect(e,t,n,r){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing();let i=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.stroke()}),this._applyStrokeStyle(),this._applyLineStyle(),this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.stroke(),this._ctx.newPath(),this._ctx.appendPath(i)},clearRect(t,n,r,i){if(this._ensureSurface(),this._state.transformIsSingular)return;let o=this._ctx.copyPath();this._ctx.save(),this._ctx.setOperator(e.Operator.CLEAR),this._ctx.newPath(),this._ctx.rectangle(t,n,r,i),this._ctx.fill(),this._ctx.restore(),this._ctx.newPath(),this._ctx.appendPath(o)},clip(t,n){if(this._ensureSurface(),this._state.transformIsSingular)return;let r;t instanceof Ae?(this._ctx.newPath(),t._replayOnCairo(this._ctx),r=n):r=t,this._ctx.setFillRule(r===`evenodd`?e.FillRule.EVEN_ODD:e.FillRule.WINDING),this._ctx.clip()},isPointInPath(t,n,r,i){this._ensureSurface();let o,s,c;return t instanceof Ae?(this._ctx.newPath(),t._replayOnCairo(this._ctx),o=n,s=r,c=i):(o=t,s=n,c=r),this._ctx.setFillRule(c===`evenodd`?e.FillRule.EVEN_ODD:e.FillRule.WINDING),this._ctx.inFill(o,s)},isPointInStroke(e,t,n){return this._ensureSurface(),this._applyLineStyle(),e instanceof Ae?(this._ctx.newPath(),e._replayOnCairo(this._ctx),this._ctx.inStroke(t,n)):this._ctx.inStroke(e,t)},drawImage(t,n,r,i,o,s,c,l,u){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing();let d,p,m,h,g,_,v,y,b=getDrawImageSource(t);if(!b)return;let{pixbuf:x,imgWidth:S,imgHeight:w}=b;if(i===void 0?(d=0,p=0,m=S,h=w,g=n,_=r,v=S,y=w):s===void 0?(d=0,p=0,m=S,h=w,g=n,_=r,v=i,y=o):(d=n,p=r,m=i,h=o,g=s,_=c,v=l,y=u),!Number.isFinite(d)||!Number.isFinite(p)||!Number.isFinite(m)||!Number.isFinite(h)||!Number.isFinite(g)||!Number.isFinite(_)||!Number.isFinite(v)||!Number.isFinite(y)||m===0||h===0||v===0||y===0)return;this._ctx.save(),this._ctx.rectangle(g,_,v,y),this._ctx.clip(),this._ctx.translate(g,_),this._ctx.scale(v/m,y/h),this._ctx.translate(-d,-p),getCanvasPixelBridge().setSourceImage(this._ctx,x,0,0);let T=asCairoPattern(this._ctx.getSource?.());if(T){let t;t=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?e.Filter.BEST:e.Filter.BILINEAR:e.Filter.NEAREST,T.setFilter(t)}this._state.globalAlpha<1?this._ctx.paintWithAlpha(this._state.globalAlpha):this._ctx.paint(),this._ctx.restore()}};function installDrawingMethods(e){Object.assign(e,Fe)}const Ie={createImageData(e,t){return typeof e==`number`?new OurImageData(Math.abs(e),Math.abs(t)):new OurImageData(e.width,e.height)},getImageData(e,t,n,r){this._ensureSurface(),this._surface.flush();let i=getCanvasPixelBridge().imageFromSurface(this._surface,e,t,n,r);if(!i)return new OurImageData(n,r);let o=i.get_pixels(),s=i.get_has_alpha(),c=i.get_rowstride(),l=i.get_n_channels(),u=new Uint8ClampedArray(n*r*4);for(let e=0;e<r;e++)for(let t=0;t<n;t++){let r=e*c+t*l,i=(e*n+t)*4;u[i]=o[r],u[i+1]=o[r+1],u[i+2]=o[r+2],u[i+3]=s?o[r+3]:255}return new OurImageData(u,n,r)},putImageData(t,n,r,i,o,s,c){this._ensureSurface();let l=i??0,u=o??0,d=s??t.width,p=c??t.height,m=t.data,h=t.width,g=new Uint8Array(d*p*4);for(let e=0;e<p;e++)for(let t=0;t<d;t++){let n=((u+e)*h+(l+t))*4,r=(e*d+t)*4;g[r]=m[n],g[r+1]=m[n+1],g[r+2]=m[n+2],g[r+3]=m[n+3]}this._ctx.save(),this._ctx.setOperator(e.Operator.SOURCE),getCanvasPixelBridge().setSourcePixels(this._ctx,g,d,p,n+l,r+u),this._ctx.rectangle(n+l,r+u,d,p),this._ctx.fill(),this._ctx.restore()}};function installPixelMethods(e){Object.assign(e,Ie)}function parseFontToDescription(e){let n=e.match(/^\s*(italic|oblique|normal)?\s*(small-caps|normal)?\s*(bold|bolder|lighter|[1-9]00|normal)?\s*(\d+(?:\.\d+)?)(px|pt|em|rem|%)?\s*(?:\/\S+)?\s*(.+)?$/i);if(!n)return t.font_description_from_string(e);let r=n[1]||``,i=n[3]||``,o=parseFloat(n[4])||10,s=(n[5]||`px`).toLowerCase(),c=(n[6]||`sans-serif`).replace(/['"]/g,``).trim();s===`pt`?o=o*96/72:s===`em`||s===`rem`?o*=16:s===`%`&&(o=o/100*16);let l=c;r===`italic`?l+=` Italic`:r===`oblique`&&(l+=` Oblique`),i===`bold`||i===`bolder`||parseInt(i)>=600?l+=` Bold`:(i===`lighter`||parseInt(i)>0&&parseInt(i)<=300)&&(l+=` Light`);let u=t.font_description_from_string(l);return u.set_absolute_size(o*t.SCALE),u}function createTextLayout(e,r){let i=n.create_layout(e._ctx);i.set_text(r,-1),i.get_context().set_base_dir(t.Direction.LTR),i.context_changed();let o=parseFontToDescription(e._state.font);return i.set_font_description(o),i}function getTextAlignOffset(e,t){let[,n]=t.get_pixel_extents(),r=n.width;switch(e._state.textAlign){case`center`:return-r/2;case`right`:case`end`:return-r;default:return 0}}function getTextBaselineOffset(e,n){let r=n.get_font_description()||parseFontToDescription(e._state.font),i=n.get_context().get_metrics(r,null),o=i.get_ascent()/t.SCALE,s=i.get_descent()/t.SCALE,c=o+s;switch(e._state.textBaseline){case`top`:return 0;case`hanging`:return-(o*.2);case`middle`:return-(c/2);case`alphabetic`:return-o;case`ideographic`:return-(o+s*.5);case`bottom`:return-c;default:return-o}}const Le={fillText(t,r,i,o){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing();let s=createTextLayout(this,t),c=getTextAlignOffset(this,s),l=getTextBaselineOffset(this,s);if(this._hasShadow()){let t=parseColor(this._state.shadowColor);if(t){let[o,u]=this._deviceToUserDistance(this._state.shadowOffsetX,this._state.shadowOffsetY),d=this._state.shadowBlur,p;if(d>0){let[e]=this._deviceToUserDistance(d,0),[,n]=this._deviceToUserDistance(0,d);p=[[o,u,t.a],[o+e,u,t.a*.5],[o-e,u,t.a*.5],[o,u+n,t.a*.5],[o,u-n,t.a*.5]]}else p=[[o,u,t.a]];let m=this._state.imageSmoothingEnabled?e.Antialias.DEFAULT:e.Antialias.NONE;for(let[e,o,u]of p)this._ctx.save(),this._ctx.setAntialias(m),this._ctx.setSourceRGBA(t.r,t.g,t.b,u),this._ctx.moveTo(r+c+e,i+l+o),n.show_layout(this._ctx,s),this._ctx.restore()}}this._applyFillStyle(),this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?e.Antialias.DEFAULT:e.Antialias.NONE),this._ctx.moveTo(r+c,i+l),n.show_layout(this._ctx,s),this._ctx.restore()},strokeText(t,r,i,o){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle();let s=createTextLayout(this,t),c=getTextAlignOffset(this,s),l=getTextBaselineOffset(this,s);this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?e.Antialias.DEFAULT:e.Antialias.NONE),this._ctx.moveTo(r+c,i+l),n.layout_path(this._ctx,s),this._ctx.stroke(),this._ctx.restore()},measureText(e){this._ensureSurface();let n=createTextLayout(this,e),[r,i]=n.get_pixel_extents(),o=n.get_baseline()/t.SCALE,s=Math.max(0,o-r.y),c=Math.max(0,r.y+r.height-o),l=n.get_font_description()||parseFontToDescription(this._state.font),u=n.get_context().get_metrics(l,null),d=u.get_ascent()/t.SCALE,p=u.get_descent()/t.SCALE;return{width:i.width,actualBoundingBoxAscent:s,actualBoundingBoxDescent:c,actualBoundingBoxLeft:Math.max(0,-r.x),actualBoundingBoxRight:r.x+r.width,fontBoundingBoxAscent:d,fontBoundingBoxDescent:p,alphabeticBaseline:0,emHeightAscent:d,emHeightDescent:p,hangingBaseline:d*.8,ideographicBaseline:-p}}};function installTextMethods(e){Object.assign(e,Le)}const Re={createLinearGradient(e,t,n,r){return new CanvasGradient(`linear`,e,t,n,r)},createRadialGradient(e,t,n,r,i,o){return new CanvasGradient(`radial`,e,t,r,i,n,o)},createPattern(e,t){return Me.create(e,t)}};function installFactoryMethods(e){Object.assign(e,Re)}function installAllContextMethods(e){installTransformMethods(e),installPathMethods(e),installDrawingMethods(e),installPixelMethods(e),installTextMethods(e),installFactoryMethods(e)}function createDefaultState(){return{fillStyle:`#000000`,fillColor:{...Ee},strokeStyle:`#000000`,strokeColor:{...Ee},lineWidth:1,lineCap:`butt`,lineJoin:`miter`,miterLimit:10,lineDash:[],lineDashOffset:0,globalAlpha:1,globalCompositeOperation:`source-over`,shadowColor:`rgba(0, 0, 0, 0)`,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,font:`10px sans-serif`,textAlign:`start`,textBaseline:`alphabetic`,direction:`ltr`,imageSmoothingEnabled:!0,imageSmoothingQuality:`low`,transformIsSingular:!1}}function cloneState(e){return{...e,fillColor:{...e.fillColor},strokeColor:{...e.strokeColor},lineDash:[...e.lineDash]}}var CanvasRenderingContext2D=class{constructor(t,n){this._stateStack=[],this.canvas=t,this._surfaceWidth=t.width||300,this._surfaceHeight=t.height||150,this._surface=new e.ImageSurface(e.Format.ARGB32,this._surfaceWidth,this._surfaceHeight),this._ctx=new e.Context(this._surface),this._state=createDefaultState()}_ensureSurface(){let t=this.canvas.width||300,n=this.canvas.height||150;(t!==this._surfaceWidth||n!==this._surfaceHeight)&&(this._ctx.$dispose(),this._surface.finish(),this._surfaceWidth=t,this._surfaceHeight=n,this._surface=new e.ImageSurface(e.Format.ARGB32,t,n),this._ctx=new e.Context(this._surface),this._stateStack=[])}_resetState(){this._state=createDefaultState(),this._stateStack=[]}_applyFillStyle(){let e=this._state.fillStyle;if(typeof e==`string`){let e=this._state.fillColor,t=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,t)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof Me&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyStrokeStyle(){let e=this._state.strokeStyle;if(typeof e==`string`){let e=this._state.strokeColor,t=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,t)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof Me&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyPatternFilter(){let t=asCairoPattern(this._ctx.getSource?.());if(!t)return;let n;n=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?e.Filter.BEST:e.Filter.BILINEAR:e.Filter.NEAREST,t.setFilter(n)}_applyLineStyle(){this._ctx.setLineWidth(this._state.lineWidth),this._ctx.setLineCap(Oe[this._state.lineCap]),this._ctx.setLineJoin(ke[this._state.lineJoin]),this._ctx.setMiterLimit(this._state.miterLimit),this._ctx.setDash(this._state.lineDash,this._state.lineDashOffset)}_applyCompositing(){let e=De[this._state.globalCompositeOperation];e!==void 0&&this._ctx.setOperator(e)}_getSurface(){return this._surface}_hasShadow(){if(this._state.shadowBlur===0&&this._state.shadowOffsetX===0&&this._state.shadowOffsetY===0)return!1;let e=parseColor(this._state.shadowColor);return e!==null&&e.a>0}_deviceToUserDistance(e,t){let n=this._ctx.userToDevice(0,0),r=this._ctx.userToDevice(1,0),i=this._ctx.userToDevice(0,1),o=(r[0]??0)-(n[0]??0),s=(r[1]??0)-(n[1]??0),c=(i[0]??0)-(n[0]??0),l=(i[1]??0)-(n[1]??0),u=o*l-s*c;return Math.abs(u)<1e-10?[e,t]:[(l*e-c*t)/u,(-s*e+o*t)/u]}_renderShadow(e){}save(){this._ensureSurface(),this._stateStack.push(cloneState(this._state)),this._ctx.save()}restore(){this._ensureSurface();let e=this._stateStack.pop();e&&(this._state=e,this._ctx.restore())}get fillStyle(){return this._state.fillStyle}set fillStyle(e){if(typeof e==`string`){let t=parseColor(e);t&&(this._state.fillStyle=e,this._state.fillColor=t)}else this._state.fillStyle=e}get strokeStyle(){return this._state.strokeStyle}set strokeStyle(e){if(typeof e==`string`){let t=parseColor(e);t&&(this._state.strokeStyle=e,this._state.strokeColor=t)}else this._state.strokeStyle=e}get lineWidth(){return this._state.lineWidth}set lineWidth(e){e>0&&isFinite(e)&&(this._state.lineWidth=e)}get lineCap(){return this._state.lineCap}set lineCap(e){(e===`butt`||e===`round`||e===`square`)&&(this._state.lineCap=e)}get lineJoin(){return this._state.lineJoin}set lineJoin(e){(e===`miter`||e===`round`||e===`bevel`)&&(this._state.lineJoin=e)}get miterLimit(){return this._state.miterLimit}set miterLimit(e){e>0&&isFinite(e)&&(this._state.miterLimit=e)}get globalAlpha(){return this._state.globalAlpha}set globalAlpha(e){e>=0&&e<=1&&isFinite(e)&&(this._state.globalAlpha=e)}get globalCompositeOperation(){return this._state.globalCompositeOperation}set globalCompositeOperation(e){De[e]!==void 0&&(this._state.globalCompositeOperation=e)}get imageSmoothingEnabled(){return this._state.imageSmoothingEnabled}set imageSmoothingEnabled(e){this._state.imageSmoothingEnabled=!!e}get imageSmoothingQuality(){return this._state.imageSmoothingQuality}set imageSmoothingQuality(e){(e===`low`||e===`medium`||e===`high`)&&(this._state.imageSmoothingQuality=e)}setLineDash(e){e.some(e=>e<0||!isFinite(e))||(this._state.lineDash=[...e])}getLineDash(){return[...this._state.lineDash]}get lineDashOffset(){return this._state.lineDashOffset}set lineDashOffset(e){isFinite(e)&&(this._state.lineDashOffset=e)}get shadowColor(){return this._state.shadowColor}set shadowColor(e){this._state.shadowColor=e}get shadowBlur(){return this._state.shadowBlur}set shadowBlur(e){e>=0&&isFinite(e)&&(this._state.shadowBlur=e)}get shadowOffsetX(){return this._state.shadowOffsetX}set shadowOffsetX(e){isFinite(e)&&(this._state.shadowOffsetX=e)}get shadowOffsetY(){return this._state.shadowOffsetY}set shadowOffsetY(e){isFinite(e)&&(this._state.shadowOffsetY=e)}get font(){return this._state.font}set font(e){this._state.font=e}get textAlign(){return this._state.textAlign}set textAlign(e){this._state.textAlign=e}get textBaseline(){return this._state.textBaseline}set textBaseline(e){this._state.textBaseline=e}get direction(){return this._state.direction}set direction(e){this._state.direction=e}_toDataURL(e,t){this._surface.flush();let[,n]=i.file_open_tmp(`canvas-XXXXXX.png`);try{this._surface.writeToPNG(n);let[,e]=r.File.new_for_path(n).load_contents(null);return`data:image/png;base64,${i.base64_encode(e)}`}finally{i.unlink(n)}}_dispose(){this._ctx.$dispose(),this._surface.finish()}};installAllContextMethods(CanvasRenderingContext2D.prototype);var ze=Object.defineProperty;__name((e,t)=>{let n={};for(var r in e)ze(n,r,{get:e[r],enumerable:!0});return t||ze(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)({attributes:()=>R,childNodesList:()=>L,elementChildren:()=>Be,isConnected:()=>Ve,localName:()=>Ue,name:()=>Ke,namespaceURI:()=>We,nodeType:()=>F,ownerElement:()=>Je,parentNode:()=>I,prefix:()=>Ge,propertyEventListeners:()=>z,tagName:()=>He,value:()=>qe});const F=Symbol(`nodeType`),I=Symbol(`parentNode`),L=Symbol(`childNodesList`),Be=Symbol(`elementChildren`),Ve=Symbol(`isConnected`),He=Symbol(`tagName`),Ue=Symbol(`localName`),We=Symbol(`namespaceURI`),Ge=Symbol(`prefix`),R=Symbol(`attributes`),z=Symbol(`propertyEventListeners`),Ke=Symbol(`name`),qe=Symbol(`value`),Je=Symbol(`ownerElement`),B={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11};var NodeList=class{constructor(e){this._items=e}get length(){return this._items.length}item(e){return this._items[e]??null}forEach(e,t){for(let n=0;n<this._items.length;n++)e.call(t,this._items[n],n,this)}entries(){return this._items.entries()}keys(){return this._items.keys()}values(){return this._items.values()}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NodeList`}};const Ye={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(Ye,this.name)?Ye[this.name]:0}};const V=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;N();const Xe=Symbol(`type`),Ze=Symbol(`bubbles`),Qe=Symbol(`cancelable`),$e=Symbol(`composed`),et=Symbol(`target`),tt=Symbol(`currentTarget`),nt=Symbol(`eventPhase`),rt=Symbol(`defaultPrevented`),it=Symbol(`isTrusted`),ot=Symbol(`timeStamp`),st=Symbol(`stop`),ct=Symbol(`immediateStop`),lt=Symbol(`dispatching`),ut=Symbol(`inPassiveListener`);var Event=class{[Xe];[Ze];[Qe];[$e];[et]=null;[tt]=null;[nt]=0;[rt]=!1;[it]=!1;[ot];[st]=!1;[ct]=!1;[lt]=!1;[ut]=!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[tt]}get eventPhase(){return this[nt]}get defaultPrevented(){return this[rt]}get timeStamp(){return this[ot]}get cancelBubble(){return this[st]}set cancelBubble(e){e&&this.stopPropagation()}get returnValue(){return!this[rt]}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[ot]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[it],enumerable:!0,configurable:!1})}composedPath(){return this[tt]?[this[tt]]:[]}preventDefault(){this[Qe]&&!this[ut]&&(this[rt]=!0)}stopPropagation(){this[st]=!0}stopImmediatePropagation(){this[st]=!0,this[ct]=!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,o=typeof n==`object`?n?.passive??!1:!1,s=this.#e.get(e);s||(s=[],this.#e.set(e,s));for(let e of s)if(e.listener===t&&e.capture===r)return;let c={listener:t,capture:r,once:i,passive:o,removed:!1};s.push(c),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 o=i.findIndex(e=>e.listener===t&&e.capture===r);o!==-1&&(i[o].removed=!0,i.splice(o,1),i.length===0&&this.#e.delete(e))}dispatchEvent(e){let t=e;if(t[lt])throw new V(`The event is already being dispatched.`,`InvalidStateError`);t[lt]=!0,t[et]=this,t[tt]=this,t[nt]=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[ct]||t[st])break;n.once&&this.removeEventListener(e.type,n.listener,{capture:n.capture});try{n.passive&&(t[ut]=!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[ut]=!1}}}}finally{t[nt]=Event.NONE,t[tt]=null,t[lt]=!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}`;M.error(e.stack?`${t}\n${e.stack}`:t)}else M.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});let dt,ft,pt,mt,ht;var gt=class Node extends EventTarget{constructor(...e){super(...e),this.ELEMENT_NODE=B.ELEMENT_NODE,this.ATTRIBUTE_NODE=B.ATTRIBUTE_NODE,this.TEXT_NODE=B.TEXT_NODE,this.CDATA_SECTION_NODE=B.CDATA_SECTION_NODE,this.PROCESSING_INSTRUCTION_NODE=B.PROCESSING_INSTRUCTION_NODE,this.COMMENT_NODE=B.COMMENT_NODE,this.DOCUMENT_NODE=B.DOCUMENT_NODE,this.DOCUMENT_TYPE_NODE=B.DOCUMENT_TYPE_NODE,this.DOCUMENT_FRAGMENT_NODE=B.DOCUMENT_FRAGMENT_NODE,this[dt]=B.ELEMENT_NODE,this[ft]=null,this[pt]=[],this[mt]=[],this[ht]=!1}static{this.ELEMENT_NODE=B.ELEMENT_NODE}static{this.ATTRIBUTE_NODE=B.ATTRIBUTE_NODE}static{this.TEXT_NODE=B.TEXT_NODE}static{this.CDATA_SECTION_NODE=B.CDATA_SECTION_NODE}static{this.PROCESSING_INSTRUCTION_NODE=B.PROCESSING_INSTRUCTION_NODE}static{this.COMMENT_NODE=B.COMMENT_NODE}static{this.DOCUMENT_NODE=B.DOCUMENT_NODE}static{this.DOCUMENT_TYPE_NODE=B.DOCUMENT_TYPE_NODE}static{this.DOCUMENT_FRAGMENT_NODE=B.DOCUMENT_FRAGMENT_NODE}static{this.DOCUMENT_POSITION_DISCONNECTED=1}static{this.DOCUMENT_POSITION_PRECEDING=2}static{this.DOCUMENT_POSITION_FOLLOWING=4}static{this.DOCUMENT_POSITION_CONTAINS=8}static{this.DOCUMENT_POSITION_CONTAINED_BY=16}static{this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32}get nodeType(){return this[F]}get nodeName(){return``}get parentNode(){return this[I]}get parentElement(){let e=this[I];return e&&e[F]===B.ELEMENT_NODE?e:null}get childNodes(){return new NodeList(this[L])}get firstChild(){return this[L][0]??null}get lastChild(){let e=this[L];return e[e.length-1]??null}get previousSibling(){let e=this[I];if(!e)return null;let t=e[L],n=t.indexOf(this);return n>0?t[n-1]:null}get nextSibling(){let e=this[I];if(!e)return null;let t=e[L],n=t.indexOf(this);return n!==-1&&n<t.length-1?t[n+1]:null}get textContent(){return null}set textContent(e){}get nodeValue(){return null}set nodeValue(e){}get ownerDocument(){let e=this;for(;e[I];)e=e[I];let t=globalThis.document;return e===t?t:null}get isConnected(){return this[Ve]}hasChildNodes(){return this[L].length>0}contains(e){if(e===null)return!1;if(e===this)return!0;let t=e;for(;t;){if(t===this)return!0;t=t[I]}return!1}getRootNode(){let e=this;for(;e[I];)e=e[I];return e}appendChild(e){return e[I]&&e[I].removeChild(e),e[I]=this,this[L].push(e),e[F]===B.ELEMENT_NODE&&this[Be].push(e),e}removeChild(e){let t=this[L],n=t.indexOf(e);if(n===-1)throw new DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`,`NotFoundError`);if(t.splice(n,1),e[I]=null,e[F]===B.ELEMENT_NODE){let t=this[Be].indexOf(e);t!==-1&&this[Be].splice(t,1)}return e}insertBefore(e,t){if(t===null)return this.appendChild(e);let n=this[L],r=n.indexOf(t);if(r===-1)throw new DOMException(`Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`,`NotFoundError`);if(e[I]&&e[I].removeChild(e),e[I]=this,n.splice(r,0,e),e[F]===B.ELEMENT_NODE){let t=this[Be],i=t.length;for(let o=r;o<n.length;o++)if(n[o][F]===B.ELEMENT_NODE&&n[o]!==e){i=t.indexOf(n[o]);break}t.splice(i,0,e)}return e}replaceChild(e,t){return this.insertBefore(e,t),this.removeChild(t),t}_createCloneTarget(){return new this.constructor}cloneNode(e=!1){let t=this._createCloneTarget();if(t[F]=this[F],e)for(let e of this[L])t.appendChild(e.cloneNode(!0));return t}dispatchEvent(e){let t=super.dispatchEvent(e);if(e.bubbles&&!e.cancelBubble){let t=this[I];for(;t&&(Object.getPrototypeOf(Node.prototype).dispatchEvent.call(t,e),!e.cancelBubble);)t=t[I]}return t}get[(dt=F,ft=I,pt=L,mt=Be,ht=Ve,Symbol.toStringTag)](){return`Node`}};const _t={isTag(e){return e[F]===B.ELEMENT_NODE},getName(e){return e[Ue]??``},getParent(e){return e.parentNode},getChildren(e){return e[L]},getSiblings(e){let t=e.parentNode;return t?t[L]:[e]},getAttributeValue(e,t){return e[F]===B.ELEMENT_NODE?e.getAttribute(t):null},getText(e){return e.textContent??``},caseSensitive:!1},vt={html:`http://www.w3.org/1999/xhtml`,svg:`http://www.w3.org/2000/svg`,mathML:`http://www.w3.org/1998/Math/MathML`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};var Attr=class{constructor(e,t,n=null,r=null,i=null){this.specified=!0,this[Ke]=e,this[qe]=t,this[Je]=i,this.namespaceURI=n,this.prefix=r;let o=e.indexOf(`:`);this.localName=o===-1?e:e.slice(o+1)}get name(){return this[Ke]}get value(){return this[qe]}set value(e){this[qe]=e}get ownerElement(){return this[Je]}get[Symbol.toStringTag](){return`Attr`}},NamedNodeMap=class{constructor(e){this._items=[],this._ownerElement=e}get length(){return this._items.length}item(e){return this._items[e]??null}getNamedItem(e){return this._findByName(e)}getNamedItemNS(e,t){let n=e===``?null:e;for(let e of this._items)if(e.namespaceURI===n&&e.localName===t)return e;return null}setNamedItem(e){return this._setAttr(e)}setNamedItemNS(e){return this._setAttr(e)}removeNamedItem(e){let t=this._findByName(e);if(!t)throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${e}' was found.`,`NotFoundError`);return this._removeAttr(t),t}removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);if(!n)throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${e}' and localName '${t}' was found.`,`NotFoundError`);return this._removeAttr(n),n}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NamedNodeMap`}_setNamedItem(e,t,n=null,r=null){let i=n===null?this._findByName(e):this.getNamedItemNS(n,e.includes(`:`)?e.split(`:`)[1]:e);if(i)i.value=t;else{let i=new Attr(e,t,n,r,this._ownerElement);this._items.push(i)}}_removeNamedItem(e){let t=this._findByName(e);return t?(this._removeAttr(t),!0):!1}_removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);return n?(this._removeAttr(n),!0):!1}_findByName(e){let t=this._ownerElement.namespaceURI===vt.html,n=t?e.toLowerCase():e;for(let e of this._items)if((t?e.name.toLowerCase():e.name)===n)return e;return null}_setAttr(e){let t=null;if(t=e.namespaceURI===null?this._findByName(e.name):this.getNamedItemNS(e.namespaceURI,e.localName),t){let n=new Attr(t.name,t.value,t.namespaceURI,t.prefix,t.ownerElement);return t.value=e.value,n}return this._items.push(e),null}_removeAttr(e){let t=this._items.indexOf(e);t!==-1&&this._items.splice(t,1)}};const yt=/^([+-]?\d*)n\s*(?:([+-])\s*(\d+))?$/,bt=/^[+-]?\d+$/;function parseNth(e){let t=e.trim().toLowerCase();if(t===`odd`)return{a:2,b:1};if(t===`even`)return{a:2,b:0};let n=yt.exec(t);if(n!==null){let e=n[1];return{a:e===``||e===`+`?1:e===`-`?-1:Number(e),b:n[3]===void 0?0:Number(n[2]+n[3])}}if(bt.test(t))return{a:0,b:Number(t)};throw SyntaxError(`'`+e+`' is not a valid An+B argument`)}function matchesNth(e,t){if(e.a===0)return t===e.b;let n=t-e.b;return e.a>0?n>=0&&n%e.a===0:n<=0&&n%e.a===0}const xt=new Set([` `,` `,`
|
|
10
10
|
`,`\r`,`\f`]),St={"~":`element`,"|":`hyphen`,"^":`start`,$:`end`,"*":`any`,"!":`not`},Ct={"nth-child":`child`,"nth-last-child":`last-child`,"nth-of-type":`of-type`,"nth-last-of-type":`last-of-type`},wt={"any-link":`:is(a, area, link)[href]`,disabled:`:is(:is(button, input, select, textarea, optgroup, option, fieldset)[disabled], optgroup[disabled] > option, fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *))`,enabled:`:is(button, input, select, textarea, optgroup, option, fieldset):not(:disabled)`,checked:`:is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)`,required:`:is(input, select, textarea)[required]`,optional:`:is(input, select, textarea):not([required])`,selected:`option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)`},Tt=new Set([`before`,`after`,`first-line`,`first-letter`,`selection`,`placeholder`]),Et=new Set([`hover`,`active`,`focus`,`focus-visible`,`focus-within`,`visited`,`link`,`target`,`target-within`,`playing`,`paused`,`current`,`past`,`future`]);function isNameChar(e){if(e===``)return!1;let t=e.codePointAt(0);return e===`-`||e===`_`||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t>127}function isNameStart(e){return e===`\\`||e!==`-`&&isNameChar(e)&&!(e>=`0`&&e<=`9`)}function isHexDigit$1(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}__name(isHexDigit$1,`isHexDigit`);function isNthChar(e){return e>=`0`&&e<=`9`||e===`n`||e===`N`||e===`+`||e===`-`||xt.has(e)}var SelectorParser=class{input;pos=0;constructor(e){this.input=e}parseSelectorList(e){let t=[this.parseComplex(e)];for(;this.peek()===`,`;)this.pos++,t.push(this.parseComplex(e));return t}atEnd(){return this.pos>=this.input.length}fail(e){throw SyntaxError(`Failed to parse selector '`+this.input+`': `+e)}peek(e=0){return this.input[this.pos+e]??``}skipWhitespace(){let e=this.pos;for(;xt.has(this.peek());)this.pos++;return this.pos>e}expect(e){this.peek()!==e&&this.fail(`expected '`+e+`' at offset `+this.pos),this.pos++}parseComplex(e){this.skipWhitespace();let t=e?this.readLeadingCombinator():null,n=[this.parseCompound()],r=[];for(;;){let e=this.readCombinator();if(e===null)break;r.push(e),n.push(this.parseCompound())}return{compounds:n,combinators:r,leading:t}}readLeadingCombinator(){let e=this.peek();return e!==`>`&&e!==`+`&&e!==`~`?`descendant`:(this.pos++,this.skipWhitespace(),e===`>`?`child`:e===`+`?`adjacent`:`sibling`)}readCombinator(){let e=this.skipWhitespace(),t=this.peek();if(t===`>`||t===`+`||t===`~`)return this.pos++,this.skipWhitespace(),t===`>`?`child`:t===`+`?`adjacent`:`sibling`;if(t===`|`&&this.peek(1)===`|`&&this.fail(`the column combinator '||' needs a table layout`),t===``||t===`,`||t===`)`)return null;if(e)return`descendant`;this.fail(`unexpected '`+t+`' at offset `+this.pos)}parseCompound(){let e=[];for(;;){let t=this.peek();if(t===`*`)this.pos++,this.rejectNamespace(),e.push({kind:`universal`});else if(t===`#`)this.pos++,e.push({kind:`attribute`,name:`id`,action:`equals`,value:this.readName(),ignoreCase:!1});else if(t===`.`)this.pos++,e.push({kind:`attribute`,name:`class`,action:`element`,value:this.readName(),ignoreCase:!1});else if(t===`[`)e.push(this.parseAttribute());else if(t===`:`)for(let t of this.parsePseudo())e.push(t);else if(t===`|`)this.fail(`namespace selectors need a namespace map this parser is not given`);else if(isNameStart(t)){let t=this.readName();this.rejectNamespace(),e.push({kind:`type`,name:t})}else break}return e.length===0&&this.fail(`expected a selector at offset `+this.pos),e}rejectNamespace(){this.peek()===`|`&&this.peek(1)!==`=`&&this.fail(`namespace selectors need a namespace map this parser is not given`)}readName(){let e=``;for(;;){let t=this.peek();if(t===`\\`){e+=this.readEscape();continue}if(!isNameChar(t))break;e+=t,this.pos++}return e===``&&this.fail(`expected an identifier at offset `+this.pos),e}readEscape(){this.pos++;let e=``;for(;e.length<6&&isHexDigit$1(this.peek());)e+=this.peek(),this.pos++;if(e===``){let e=this.peek();return e===``&&this.fail(`a trailing backslash escapes nothing`),this.pos++,e}xt.has(this.peek())&&this.pos++;let t=Number.parseInt(e,16);return t===0||t>1114111||t>=55296&&t<=57343?`�`:String.fromCodePoint(t)}readString(e){this.pos++;let t=``;for(;;){let n=this.peek();if(n===``&&this.fail(`unterminated string`),n===e)return this.pos++,t;if(n===`\\`){t+=this.readEscape();continue}t+=n,this.pos++}}parseAttribute(){this.expect(`[`),this.skipWhitespace(),(this.peek()===`|`||this.peek()===`*`)&&this.fail(`namespace selectors need a namespace map this parser is not given`);let e=this.readName();if(this.rejectNamespace(),this.skipWhitespace(),this.peek()===`]`)return this.pos++,{kind:`attribute`,name:e,action:`exists`,value:``,ignoreCase:null};let t;this.peek()===`=`?(t=`equals`,this.pos++):this.peek(1)===`=`&&Object.hasOwn(St,this.peek())?(t=St[this.peek()],this.pos+=2):this.fail(`'`+this.peek()+`' is not an attribute operator`),this.skipWhitespace();let n=this.peek(),r=n===`"`||n===`'`?this.readString(n):this.readName();this.skipWhitespace();let i=null,o=this.peek().toLowerCase();return(o===`i`||o===`s`)&&(i=o===`i`,this.pos++,this.skipWhitespace()),this.expect(`]`),{kind:`attribute`,name:e,action:t,value:r,ignoreCase:i}}parsePseudo(){this.pos++,this.peek()===`:`&&(this.pos++,this.fail(`pseudo-element '::`+this.readName()+`' has no meaning without rendering`));let e=this.readName().toLowerCase();if(e===`not`||e===`is`||e===`where`||e===`matches`||e===`has`){this.expect(`(`);let t=this.parseSelectorList(e===`has`);return this.expect(`)`),[{kind:e===`not`?`not`:e===`has`?`has`:`is`,selectors:t}]}if(Object.hasOwn(Ct,e))return[this.parseNthPseudo(Ct[e])];if(e===`first-child`)return[positional(`child`,1)];if(e===`last-child`)return[positional(`last-child`,1)];if(e===`only-child`)return[positional(`child`,1),positional(`last-child`,1)];if(e===`first-of-type`)return[positional(`of-type`,1)];if(e===`last-of-type`)return[positional(`last-of-type`,1)];if(e===`only-of-type`)return[positional(`of-type`,1),positional(`last-of-type`,1)];if(e===`empty`)return[{kind:`empty`}];if(e===`root`)return[{kind:`root`}];if(e===`scope`)return[{kind:`scope`}];if(Object.hasOwn(wt,e))return[{kind:`is`,selectors:parseSelectorList(wt[e])}];Et.has(e)&&this.fail(`':`+e+`' is a user-state pseudo-class and needs a live document`),Tt.has(e)&&this.fail(`pseudo-element ':`+e+`' has no meaning without rendering`),this.fail(`unknown pseudo-class ':`+e+`'`)}parseNthPseudo(e){this.expect(`(`);let t=parseNth(this.readNthArgument()),n=null;return this.readKeyword(`of`)&&(n=this.parseSelectorList(!1)),this.expect(`)`),{kind:`nth`,axis:e,formula:t,of:n}}readNthArgument(){if(this.skipWhitespace(),this.readKeyword(`odd`))return`odd`;if(this.readKeyword(`even`))return`even`;let e=this.pos;for(;isNthChar(this.peek());)this.pos++;return this.input.slice(e,this.pos)}readKeyword(e){return this.input.slice(this.pos,this.pos+e.length).toLowerCase()!==e||isNameChar(this.peek(e.length))?!1:(this.pos+=e.length,this.skipWhitespace(),!0)}};function positional(e,t){return{kind:`nth`,axis:e,formula:{a:0,b:t},of:null}}function parseSelectorList(e){let t=new SelectorParser(e),n=t.parseSelectorList(!1);return t.atEnd()||t.fail(`unexpected trailing input`),n}const Dt=new Set(`accept.accept-charset.align.alink.axis.bgcolor.charset.checked.clear.codetype.color.compact.declare.defer.dir.direction.disabled.enctype.face.frame.hreflang.http-equiv.lang.language.link.media.method.multiple.nohref.noresize.noshade.nowrap.readonly.rel.rev.rules.scope.scrolling.selected.shape.target.text.type.valign.valuetype.vlink`.split(`.`)),Ot=/\s+/,kt={universal:0,attribute:1,type:2,nth:3,empty:3,root:3,scope:3,is:4,not:4,has:5};function cost(e){return e.kind===`attribute`?e.name===`id`&&e.action===`equals`?0:e.action===`exists`?2:1:kt[e.kind]}function compileAttribute(e,t){let n=t.caseSensitive?e.name:e.name.toLowerCase(),r=e.ignoreCase===null?!t.caseSensitive&&Dt.has(n):e.ignoreCase,i=r?e.value.toLowerCase():e.value,read=e=>{let i=t.getAttributeValue(e,n);return i===null||!r?i:i.toLowerCase()},noMatch=()=>!1;switch(e.action){case`exists`:return e=>t.getAttributeValue(e,n)!==null;case`equals`:return e=>read(e)===i;case`not`:return i===``?e=>(read(e)??``)!==``:e=>read(e)!==i;case`start`:return i===``?noMatch:e=>read(e)?.startsWith(i)===!0;case`end`:return i===``?noMatch:e=>read(e)?.endsWith(i)===!0;case`any`:return i===``?noMatch:e=>read(e)?.includes(i)===!0;case`hyphen`:return e=>{let t=read(e);return t!==null&&(t===i||t.startsWith(i+`-`))};default:return i===``||Ot.test(i)?noMatch:e=>read(e)?.split(Ot).includes(i)===!0}}function compileNth(e,t){let n=e.axis===`last-child`||e.axis===`last-of-type`,r=e.axis===`of-type`||e.axis===`last-of-type`,i=e.of===null?null:compileList(e.of,t);return(o,s)=>{let c=t.getSiblings(o),l=r?t.getName(o):``,u=n?-1:1,d=0;for(let p=n?c.length-1:0;p>=0&&p<c.length;p+=u){let n=c[p];if(t.isTag(n)&&!(r&&t.getName(n)!==l)&&!(i!==null&&!i(n,s))&&(d++,n===o))return matchesNth(e.formula,d)}return!1}}function collectDescendants(e,t,n){for(let r of t.getChildren(e))t.isTag(r)&&n.push(r),collectDescendants(r,t,n)}function followingSiblings(e,t){let n=t.getSiblings(e),r=n.indexOf(e);return r===-1?[]:n.slice(r+1).filter(e=>t.isTag(e))}function compileHas(e,t){let n=e.selectors.map(e=>compileComplex(e,t)),r=e.selectors.some(e=>e.leading===`adjacent`||e.leading===`sibling`),i=new Map;return(e,o)=>{let s=i.get(e);if(s!==void 0)return s;let c=[];if(collectDescendants(e,t,c),r)for(let n of followingSiblings(e,t))c.push(n);let l=o.scope;o.scope=e;let u=!1;for(let e of c)if(n.some(t=>t(e,o))){u=!0;break}return o.scope=l,i.set(e,u),u}}function compileSimple(e,t){switch(e.kind){case`universal`:return()=>!0;case`type`:{let n=t.caseSensitive?e.name:e.name.toLowerCase();return e=>t.getName(e)===n}case`attribute`:return compileAttribute(e,t);case`nth`:return compileNth(e,t);case`empty`:return e=>!t.getChildren(e).some(e=>t.isTag(e)||t.getText(e)!==``);case`root`:return e=>{let n=t.getParent(e);return n===null||!t.isTag(n)};case`scope`:return(e,t)=>e===t.scope;case`is`:return compileList(e.selectors,t);case`not`:{let n=compileList(e.selectors,t);return(e,t)=>!n(e,t)}default:return compileHas(e,t)}}function compileCompound(e,t){let n=e.slice().sort((e,t)=>cost(e)-cost(t)).map(e=>compileSimple(e,t));return n.length===1?n[0]:(e,t)=>{for(let r of n)if(!r(e,t))return!1;return!0}}function compileCombinator(e,t,n){switch(e){case`child`:return(e,r)=>{let i=n.getParent(e);return i!==null&&t(i,r)};case`descendant`:return(e,r)=>{let i=n.getParent(e);for(;i!==null;){if(t(i,r))return!0;i=n.getParent(i)}return!1};case`adjacent`:return(e,r)=>{let i=n.getSiblings(e);for(let o=i.indexOf(e)-1;o>=0;o--)if(n.isTag(i[o]))return t(i[o],r);return!1};default:return(e,r)=>{let i=n.getSiblings(e);for(let o=i.indexOf(e)-1;o>=0;o--)if(n.isTag(i[o])&&t(i[o],r))return!0;return!1}}}function compileComplex(e,t){let next=e.leading===null?()=>!0:compileCombinator(e.leading,(e,t)=>e===t.scope,t);for(let n=0;n<e.compounds.length;n++){n>0&&(next=compileCombinator(e.combinators[n-1],next,t));let r=compileCompound(e.compounds[n],t),i=next;next=(e,t)=>r(e,t)&&i(e,t)}return next}function compileList(e,t){let n=e.map(e=>compileComplex(e,t));return n.length===1?n[0]:(e,t)=>n.some(n=>n(e,t))}function compile(e,t){return compileList(parseSelectorList(e),t)}function walk(e,t,n){for(let r of t.getChildren(e))if(t.isTag(r)&&n(r)||walk(r,t,n))return!0;return!1}function selectAll(e,t,n){let r=compile(e,n),i={scope:t},o=[];return walk(t,n,e=>(r(e,i)&&o.push(e),!1)),o}function selectOne(e,t,n){let r=compile(e,n),i={scope:t},o=null;return walk(t,n,e=>r(e,i)?(o=e,!0):!1),o}function matchesSelector(e,t,n){return compile(e,n)(t,{scope:t})}function closestSelector(e,t,n){let r=compile(e,n),i={scope:t},o=t;for(;o!==null&&n.isTag(o);){if(r(o,i))return o;o=n.getParent(o)}return null}N();let At,jt,Mt,Nt,Pt,Ft;var Element=class extends gt{constructor(){super(),this[At]=``,this[jt]=``,this[Mt]=vt.html,this[Nt]=null,this[Pt]=new NamedNodeMap(this),this[Ft]=new Map,this._resizeSubscribers=null,this._allocatedClientWidth=0,this._allocatedClientHeight=0,this._pointerCaptures=new Set,this[F]=B.ELEMENT_NODE}get tagName(){return this[He]}get localName(){return this[Ue]}get namespaceURI(){return this[We]}get prefix(){return this[Ge]}get nodeName(){return this[He]}get attributes(){return this[R]}get id(){return this.getAttribute(`id`)??``}set id(e){this.setAttribute(`id`,e)}get className(){return this.getAttribute(`class`)??``}set className(e){this.setAttribute(`class`,e)}get children(){return this[Be]}get childElementCount(){return this[Be].length}get firstElementChild(){return this[Be][0]??null}get lastElementChild(){let e=this[Be];return e[e.length-1]??null}get previousElementSibling(){let e=this[I];if(!e)return null;let t=e[Be],n=t.indexOf(this);return n>0?t[n-1]:null}get nextElementSibling(){let e=this[I];if(!e)return null;let t=e[Be],n=t.indexOf(this);return n!==-1&&n<t.length-1?t[n+1]:null}get textContent(){let e=``;for(let t of this[L])t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){let t=this[L];for(;t.length>0;)this.removeChild(t[0])}getAttribute(e){let t=this[R].getNamedItem(e);return t?t.value:null}getAttributeNS(e,t){let n=this[R].getNamedItemNS(e,t);return n?n.value:null}setAttribute(e,t){this[R]._setNamedItem(e,String(t))}setAttributeNS(e,t,n){let r=e===``?null:e,i=t.split(`:`),o=i.length>1?i[0]:null;this[R]._setNamedItem(t,String(n),r,o)}removeAttribute(e){this[R]._removeNamedItem(e)}removeAttributeNS(e,t){let n=e===``?null:e;this[R]._removeNamedItemNS(n,t)}hasAttribute(e){return this[R].getNamedItem(e)!==null}hasAttributeNS(e,t){return this[R].getNamedItemNS(e,t)!==null}getAttributeNode(e){return this[R].getNamedItem(e)}setAttributeNode(e){return this[R].setNamedItem(e)}removeAttributeNode(e){let t=this[R].getNamedItem(e.name);if(!t)throw new DOMException(`Failed to execute 'removeAttributeNode' on 'Element': The attribute is not owned by this element.`,`NotFoundError`);return this[R].removeNamedItem(t.name),t}toggleAttribute(e,t){return t===void 0?this.hasAttribute(e)?(this.removeAttribute(e),!1):(this.setAttribute(e,``),!0):t?(this.setAttribute(e,``),!0):(this.removeAttribute(e),!1)}hasAttributes(){return this[R].length>0}dispatchEvent(e){let t=super.dispatchEvent(e),n=this[z].get(`on`+e.type);return typeof n==`function`&&n.call(this,e),t}querySelector(e){return selectOne(e,this,_t)}querySelectorAll(e){return selectAll(e,this,_t)}matches(e){return matchesSelector(e,this,_t)}closest(e){return closestSelector(e,this,_t)}getElementsByTagName(e){let t=[],n=e.toUpperCase(),walk=r=>{for(let i of r[L])if(i[F]===B.ELEMENT_NODE){let r=i;(e===`*`||r[He]===n)&&t.push(r),walk(r)}};return walk(this),t}getElementsByClassName(e){let t=[],n=e.split(/\s+/).filter(Boolean),walk=e=>{for(let r of e[L])if(r[F]===B.ELEMENT_NODE){let e=r,i=e.className.split(/\s+/);n.every(e=>i.includes(e))&&t.push(e),walk(e)}};return walk(this),t}cloneNode(e=!1){let t=super.cloneNode(!1);t[He]=this[He],t[Ue]=this[Ue],t[We]=this[We],t[Ge]=this[Ge];for(let e of this[R])t.setAttributeNS(e.namespaceURI,e.name,e.value);if(e)for(let e of this[L])t.appendChild(e.cloneNode(!0));return t}_onResize(e){let t=this._resizeSubscribers??=new Set;return t.add(e),()=>{t.delete(e),t.size===0&&(this._resizeSubscribers=null)}}_fireResizeSubscribers(e,t){let n=this._resizeSubscribers;if(!(!n||n.size===0))for(let r of[...n])try{r(e,t)}catch(e){M.error(`ResizeObserver subscriber threw:`,e)}}setPointerCapture(e){this._pointerCaptures.add(e)}releasePointerCapture(e){this._pointerCaptures.delete(e)}hasPointerCapture(e){return this._pointerCaptures.has(e)}get[(At=He,jt=Ue,Mt=We,Nt=Ge,Pt=R,Ft=z,Symbol.toStringTag)](){return`Element`}},CSSStyleDeclaration=class{constructor(){this._cssText=``}get cssText(){return this._cssText}set cssText(e){this._cssText=e;for(let t of e.split(`;`)){let e=t.indexOf(`:`);if(e===-1)continue;let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)continue;let i=n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());this[i]=r}}setProperty(e,t,n){this[e]=t}getPropertyValue(e){let t=this[e];return typeof t==`string`?t:``}removeProperty(e){let t=this[e];return delete this[e],typeof t==`string`?t:``}getPropertyPriority(e){return``}},HTMLElement$1=class extends Element{static{__name(this,`HTMLElement`)}constructor(...e){super(...e),this.style=new CSSStyleDeclaration}get dataset(){let e=this;return new Proxy({},{get(t,n){if(typeof n!=`string`)return;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.getAttribute(r)??void 0},set(t,n,r){if(typeof n!=`string`)return!1;let i=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.setAttribute(i,String(r)),!0},deleteProperty(t,n){if(typeof n!=`string`)return!1;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.removeAttribute(r),!0},has(t,n){if(typeof n!=`string`)return!1;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.hasAttribute(r)}})}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get lang(){return this.getAttribute(`lang`)??``}set lang(e){this.setAttribute(`lang`,e)}get dir(){return this.getAttribute(`dir`)??``}set dir(e){this.setAttribute(`dir`,e)}get accessKey(){return this.getAttribute(`accesskey`)??``}set accessKey(e){this.setAttribute(`accesskey`,e)}get accessKeyLabel(){return this.getAttribute(`accesskey`)??``}get hidden(){return this.hasAttribute(`hidden`)}set hidden(e){e?this.setAttribute(`hidden`,``):this.removeAttribute(`hidden`)}get draggable(){return this.getAttribute(`draggable`)===`true`}set draggable(e){this.setAttribute(`draggable`,String(e))}get spellcheck(){let e=this.getAttribute(`spellcheck`);return e===`false`?!1:e!==null}set spellcheck(e){this.setAttribute(`spellcheck`,String(e))}get translate(){return this.getAttribute(`translate`)!==`no`}set translate(e){this.setAttribute(`translate`,e?`yes`:`no`)}get tabIndex(){let e=this.getAttribute(`tabindex`);return e===null?-1:Number(e)}set tabIndex(e){this.setAttribute(`tabindex`,String(e))}get contentEditable(){let e=this.getAttribute(`contenteditable`);return e===``||e===`true`?`true`:e===`false`?`false`:`inherit`}set contentEditable(e){e===`inherit`?this.removeAttribute(`contenteditable`):this.setAttribute(`contenteditable`,e)}get isContentEditable(){return this.contentEditable===`true`}get offsetHeight(){return this._allocatedClientHeight}get offsetWidth(){return this._allocatedClientWidth}get offsetLeft(){return 0}get offsetTop(){return 0}get offsetParent(){return null}get clientHeight(){return this._allocatedClientHeight}get clientWidth(){return this._allocatedClientWidth}get clientLeft(){return 0}get clientTop(){return 0}get scrollHeight(){return this._allocatedClientHeight}get scrollWidth(){return this._allocatedClientWidth}get scrollTop(){return 0}set scrollTop(e){}get scrollLeft(){return 0}set scrollLeft(e){}getBoundingClientRect(){let e=this.clientWidth,t=this.clientHeight;return{x:0,y:0,top:0,left:0,right:e,bottom:t,width:e,height:t,toJSON(){return this}}}click(){this.dispatchEvent(new Event(`click`,{bubbles:!0,cancelable:!0}))}blur(){this.dispatchEvent(new Event(`blur`))}focus(){this.dispatchEvent(new Event(`focus`))}get onclick(){return this[z].get(`onclick`)??null}set onclick(e){this[z].set(`onclick`,e)}get ondblclick(){return this[z].get(`ondblclick`)??null}set ondblclick(e){this[z].set(`ondblclick`,e)}get onload(){return this[z].get(`onload`)??null}set onload(e){this[z].set(`onload`,e)}get onerror(){return this[z].get(`onerror`)??null}set onerror(e){this[z].set(`onerror`,e)}get onabort(){return this[z].get(`onabort`)??null}set onabort(e){this[z].set(`onabort`,e)}get onfocus(){return this[z].get(`onfocus`)??null}set onfocus(e){this[z].set(`onfocus`,e)}get onblur(){return this[z].get(`onblur`)??null}set onblur(e){this[z].set(`onblur`,e)}get onchange(){return this[z].get(`onchange`)??null}set onchange(e){this[z].set(`onchange`,e)}get oninput(){return this[z].get(`oninput`)??null}set oninput(e){this[z].set(`oninput`,e)}get onsubmit(){return this[z].get(`onsubmit`)??null}get onreset(){return this[z].get(`onreset`)??null}set onreset(e){this[z].set(`onreset`,e)}get onscroll(){return this[z].get(`onscroll`)??null}set onscroll(e){this[z].set(`onscroll`,e)}get onresize(){return this[z].get(`onresize`)??null}set onresize(e){this[z].set(`onresize`,e)}get onmousedown(){return this[z].get(`onmousedown`)??null}set onmousedown(e){this[z].set(`onmousedown`,e)}get onmouseup(){return this[z].get(`onmouseup`)??null}set onmouseup(e){this[z].set(`onmouseup`,e)}get onmousemove(){return this[z].get(`onmousemove`)??null}set onmousemove(e){this[z].set(`onmousemove`,e)}get onmouseover(){return this[z].get(`onmouseover`)??null}set onmouseover(e){this[z].set(`onmouseover`,e)}get onmouseout(){return this[z].get(`onmouseout`)??null}set onmouseout(e){this[z].set(`onmouseout`,e)}get onmouseenter(){return this[z].get(`onmouseenter`)??null}set onmouseenter(e){this[z].set(`onmouseenter`,e)}get onmouseleave(){return this[z].get(`onmouseleave`)??null}set onmouseleave(e){this[z].set(`onmouseleave`,e)}get oncontextmenu(){return this[z].get(`oncontextmenu`)??null}set oncontextmenu(e){this[z].set(`oncontextmenu`,e)}get onwheel(){return this[z].get(`onwheel`)??null}set onwheel(e){this[z].set(`onwheel`,e)}get onkeydown(){return this[z].get(`onkeydown`)??null}set onkeydown(e){this[z].set(`onkeydown`,e)}get onkeyup(){return this[z].get(`onkeyup`)??null}set onkeyup(e){this[z].set(`onkeyup`,e)}get ontouchstart(){return this[z].get(`ontouchstart`)??null}set ontouchstart(e){this[z].set(`ontouchstart`,e)}get ontouchend(){return this[z].get(`ontouchend`)??null}set ontouchend(e){this[z].set(`ontouchend`,e)}get ontouchmove(){return this[z].get(`ontouchmove`)??null}set ontouchmove(e){this[z].set(`ontouchmove`,e)}get onpointerdown(){return this[z].get(`onpointerdown`)??null}set onpointerdown(e){this[z].set(`onpointerdown`,e)}get onpointerup(){return this[z].get(`onpointerup`)??null}set onpointerup(e){this[z].set(`onpointerup`,e)}get onpointermove(){return this[z].get(`onpointermove`)??null}set onpointermove(e){this[z].set(`onpointermove`,e)}cloneNode(e=!1){return super.cloneNode(e)}get[Symbol.toStringTag](){return`HTMLElement`}},It=class HTMLCanvasElement extends HTMLElement$1{constructor(...e){super(...e),this.oncontextlost=null,this.oncontextrestored=null,this.onwebglcontextcreationerror=null,this.onwebglcontextlost=null,this.onwebglcontextrestored=null}static{this._contextFactories=new Map}static registerContextFactory(e,t){HTMLCanvasElement._contextFactories.set(e,t)}get width(){let e=this.getAttribute(`width`);return e===null?300:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get height(){let e=this.getAttribute(`height`);return e===null?150:Number(e)}set height(e){this.setAttribute(`height`,String(e))}getContext(e,t){let n=HTMLCanvasElement._contextFactories.get(e);return n?n(this,t):null}toDataURL(e,t){let n=this.getContext(`2d`);return n&&typeof n._toDataURL==`function`?n._toDataURL(e,t):``}toBlob(e,t,n){let r=this.toDataURL(t,n);if(!r){e(null);return}let[i,o]=r.split(`,`),s=i.split(`:`)[1].split(`;`)[0],c=atob(o),l=new Uint8Array(c.length);for(let e=0;e<c.length;e++)l[e]=c.charCodeAt(e);e(new Blob([l],{type:s}))}captureStream(e){return{}}},Lt=class DOMMatrix{constructor(e){this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,this.is2D=!0,this.isIdentity=!0,Array.isArray(e)&&(e.length===6?(this.a=this.m11=e[0],this.b=this.m12=e[1],this.c=this.m21=e[2],this.d=this.m22=e[3],this.e=this.m41=e[4],this.f=this.m42=e[5],this.is2D=!0):e.length===16&&(this.m11=e[0],this.m12=e[1],this.m13=e[2],this.m14=e[3],this.m21=e[4],this.m22=e[5],this.m23=e[6],this.m24=e[7],this.m31=e[8],this.m32=e[9],this.m33=e[10],this.m34=e[11],this.m41=e[12],this.m42=e[13],this.m43=e[14],this.m44=e[15],this.a=this.m11,this.b=this.m12,this.c=this.m21,this.d=this.m22,this.e=this.m41,this.f=this.m42,this.is2D=!1),this.isIdentity=this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0)}multiply(e){let t=this.a*e.a+this.c*e.b,n=this.b*e.a+this.d*e.b,r=this.a*e.c+this.c*e.d,i=this.b*e.c+this.d*e.d,o=this.a*e.e+this.c*e.f+this.e,s=this.b*e.e+this.d*e.f+this.f;return new DOMMatrix([t,n,r,i,o,s])}multiplySelf(e){let t=this.multiply(e);return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.e=t.e,this.f=t.f,this.m11=this.a,this.m12=this.b,this.m21=this.c,this.m22=this.d,this.m41=this.e,this.m42=this.f,this.isIdentity=!1,this}inverse(){let e=this.a*this.d-this.b*this.c;if(e===0)return new DOMMatrix([1,0,0,1,0,0]);let t=1/e;return new DOMMatrix([this.d*t,-this.b*t,-this.c*t,this.a*t,(this.c*this.f-this.d*this.e)*t,(this.b*this.e-this.a*this.f)*t])}translate(e=0,t=0){return this.multiply({a:1,b:0,c:0,d:1,e,f:t})}scale(e=1,t=e){return this.multiply({a:e,b:0,c:0,d:t,e:0,f:0})}};const Rt=Lt;function defineGlobal(e,t){Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}function defineGlobalIfMissing$1(e,t){globalThis[e]===void 0&&defineGlobal(e,t)}__name(defineGlobalIfMissing$1,`defineGlobalIfMissing`),setCanvasPixelBridge({imageFromSurface(e,t,n,r,i){return o.pixbuf_get_from_surface(e,t,n,r,i)},setSourceImage(e,t,n,r){o.cairo_set_source_pixbuf(e,t,n,r)},setSourcePixels(e,t,n,r,i,c){let l=s.Pixbuf.new_from_bytes(t,s.Colorspace.RGB,!0,8,n,r,n*4);o.cairo_set_source_pixbuf(e,l,i,c)}}),defineGlobal(`HTMLCanvasElement`,It),defineGlobal(`CanvasRenderingContext2D`,CanvasRenderingContext2D),defineGlobal(`DOMMatrix`,Lt),defineGlobal(`DOMMatrixReadOnly`,Rt);const zt=Symbol.for(`gjsify_canvas2d_context`);It.registerContextFactory(`2d`,(e,t)=>{let n=e,r=n[zt];if(r)return r;let i=new CanvasRenderingContext2D(e,t);return n[zt]=i,i});function defineGlobalIfMissing(e,t){globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}defineGlobalIfMissing(`ImageData`,OurImageData),defineGlobalIfMissing(`Path2D`,Ae);var CharacterData=class extends gt{constructor(e=``){super(),this[F]=B.TEXT_NODE,this._data=e}get data(){return this._data}set data(e){this._data=e}get textContent(){return this._data}set textContent(e){this._data=e}get nodeValue(){return this._data}set nodeValue(e){this._data=e}get length(){return this._data.length}appendData(e){this._data+=e}deleteData(e,t){this._data=this._data.substring(0,e)+this._data.substring(e+t)}insertData(e,t){this._data=this._data.substring(0,e)+t+this._data.substring(e)}replaceData(e,t,n){this._data=this._data.substring(0,e)+n+this._data.substring(e+t)}substringData(e,t){return this._data.substring(e,e+t)}cloneNode(e=!1){return new this.constructor(this._data)}get[Symbol.toStringTag](){return`CharacterData`}},Bt=class Comment extends CharacterData{constructor(e=``){super(e),this[F]=B.COMMENT_NODE}get nodeName(){return`#comment`}cloneNode(e=!1){return new Comment(this.data)}get[Symbol.toStringTag](){return`Comment`}},Vt=class Text extends CharacterData{constructor(e=``){super(e),this[F]=B.TEXT_NODE}get nodeName(){return`#text`}get wholeText(){let e=this.data,t=this.previousSibling;for(;t&&t instanceof Text;)e=t.data+e,t=t.previousSibling;let n=this.nextSibling;for(;n&&n instanceof Text;)e+=n.data,n=n.nextSibling;return e}splitText(e){let t=this.data.substring(e);this.data=this.data.substring(0,e);let n=new Text(t);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}cloneNode(e=!1){return new Text(this.data)}get[Symbol.toStringTag](){return`Text`}},Ht=class DocumentFragment extends gt{constructor(){super(),this[F]=B.DOCUMENT_FRAGMENT_NODE}get nodeName(){return`#document-fragment`}get children(){return this[Be]}get childElementCount(){return this[Be].length}get firstElementChild(){return this[Be][0]??null}get lastElementChild(){let e=this[Be];return e[e.length-1]??null}get textContent(){let e=``;for(let t of this.childNodes)t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){for(;this.firstChild;)this.removeChild(this.firstChild);e&&this.appendChild(new Vt(e))}append(...e){for(let t of e)typeof t==`string`?this.appendChild(new Vt(t)):this.appendChild(t)}prepend(...e){let t=this.firstChild;for(let n of e)typeof n==`string`?this.insertBefore(new Vt(n),t):this.insertBefore(n,t)}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}getElementById(e){for(let t of this.children){if(t.id===e)return t;let n=this._findById(t,e);if(n)return n}return null}_findById(e,t){for(let n of e.children){if(n.id===t)return n;let e=this._findById(n,t);if(e)return e}return null}cloneNode(e=!1){let t=new DocumentFragment;if(e)for(let e of this.childNodes)t.appendChild(e.cloneNode(!0));return t}get[Symbol.toStringTag](){return`DocumentFragment`}};N();var HTMLImageElement=class extends HTMLElement$1{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[He]=`IMG`,this[Ue]=`img`,this[We]=vt.html}get complete(){return this._complete}get naturalHeight(){return this._naturalHeight}get naturalWidth(){return this._naturalWidth}get currentSrc(){return this.src}get x(){return 0}get y(){return 0}get alt(){return this.getAttribute(`alt`)??``}set alt(e){this.setAttribute(`alt`,e)}get crossOrigin(){return this.getAttribute(`crossorigin`)}set crossOrigin(e){e===null?this.removeAttribute(`crossorigin`):this.setAttribute(`crossorigin`,e)}get decoding(){return this.getAttribute(`decoding`)??`auto`}set decoding(e){this.setAttribute(`decoding`,e)}get loading(){let e=this.getAttribute(`loading`);return e===`lazy`||e===`eager`?e:`auto`}set loading(e){this.setAttribute(`loading`,e)}get referrerPolicy(){return this.getAttribute(`referrerpolicy`)??``}set referrerPolicy(e){this.setAttribute(`referrerpolicy`,e)}get sizes(){return this.getAttribute(`sizes`)??``}set sizes(e){this.setAttribute(`sizes`,e)}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,e);let t=globalThis.__GJSIFY_DEBUG_IMG===!0;if(e.startsWith(`data:`)){let n=e.indexOf(`,`);if(n===-1){this._complete=!0,this.dispatchEvent(new Event(`error`));return}let o=e.slice(5,n),c=e.slice(n+1),l=o.includes(`;base64`);try{let e;e=l?i.base64_decode(c):new TextEncoder().encode(decodeURIComponent(c));let n=i.Bytes.new(e),o=r.MemoryInputStream.new_from_bytes(n);this._pixbuf=s.Pixbuf.new_from_stream(o,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&M.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&M.warn(`[img] error data:: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event(`error`))}return}let n;if(e.startsWith(`file://`))n=i.filename_from_uri(e)[0];else if(e.startsWith(`http://`)||e.startsWith(`https://`)){this._complete=!0,this.dispatchEvent(new Event(`error`));return}else{let t=i.path_get_dirname(c.programInvocationName);n=i.build_filenamev([t,e])}try{t&&M.log(`[img] load ${n}`),this._pixbuf=s.Pixbuf.new_from_file(n),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&M.log(`[img] ok ${n} (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&M.warn(`[img] error ${n}: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event(`error`))}}get srcset(){return this.getAttribute(`srcset`)??``}set srcset(e){this.setAttribute(`srcset`,e)}get useMap(){return this.getAttribute(`usemap`)??``}set useMap(e){this.setAttribute(`usemap`,e)}get height(){if(this._pixbuf)return this._pixbuf.get_height();let e=this.getAttribute(`height`);return e===null?0:Number(e)}set height(e){this.setAttribute(`height`,String(e))}get width(){if(this._pixbuf)return this._pixbuf.get_width();let e=this.getAttribute(`width`);return e===null?0:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get isMap(){return this.hasAttribute(`ismap`)}set isMap(e){e?this.setAttribute(`ismap`,``):this.removeAttribute(`ismap`)}decode(){return Promise.resolve()}cloneNode(e=!1){return super.cloneNode(e)}getImageData(){if(!this._pixbuf)return null;let e=this._pixbuf.get_has_alpha()?this._pixbuf:this._pixbuf.add_alpha(!1,0,0,0)??this._pixbuf;return{colorSpace:`srgb`,data:new Uint8ClampedArray(e.get_pixels()),height:e.get_height(),width:e.get_width()}}isPixbuf(){return!!this._pixbuf}get[Symbol.toStringTag](){return`HTMLImageElement`}},HTMLMediaElement=class extends HTMLElement$1{constructor(...e){super(...e),this._src=``,this._srcObject=null,this.currentTime=0,this.duration=NaN,this.paused=!0,this.ended=!1,this.volume=1,this.muted=!1,this.defaultMuted=!1,this.loop=!1,this.autoplay=!1,this.preload=``,this.playbackRate=1,this.defaultPlaybackRate=1,this.readyState=0,this.networkState=0}get buffered(){return{length:0,start:()=>0,end:()=>0}}get seekable(){return{length:0,start:()=>0,end:()=>0}}get played(){return{length:0,start:()=>0,end:()=>0}}get src(){return this._src}set src(e){this._src=e,this._srcObject=null,this.dispatchEvent(new Event(`srcchange`))}get srcObject(){return this._srcObject}set srcObject(e){this._srcObject=e,this._src=``,this.dispatchEvent(new Event(`srcobjectchange`))}play(){return this.paused=!1,this.ended=!1,this.dispatchEvent(new Event(`play`)),Promise.resolve()}pause(){this.paused=!0,this.dispatchEvent(new Event(`pause`))}load(){this.readyState=0,this.networkState=2,this.dispatchEvent(new Event(`loadstart`))}canPlayType(e){return``}static{this.HAVE_NOTHING=0}static{this.HAVE_METADATA=1}static{this.HAVE_CURRENT_DATA=2}static{this.HAVE_FUTURE_DATA=3}static{this.HAVE_ENOUGH_DATA=4}static{this.NETWORK_EMPTY=0}static{this.NETWORK_IDLE=1}static{this.NETWORK_LOADING=2}static{this.NETWORK_NO_SOURCE=3}get[Symbol.toStringTag](){return`HTMLMediaElement`}};const Ut=1e9;function secondsToGstTime(e){return BigInt(Math.round(e*Ut))}function gstTimeToSeconds(e){return Number(e)/Ut}var HTMLVideoElement=class extends HTMLMediaElement{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[He]=`VIDEO`,this[Ue]=`video`,this[We]=vt.html;let e=this;Object.defineProperty(this,"paused",{get(){if(!e._pipeline)return!0;let[,t]=e._pipeline.get_state(0n);return t!==4},configurable:!0,enumerable:!0}),Object.defineProperty(this,"currentTime",{get(){if(!e._pipeline)return 0;let[t,n]=e._pipeline.query_position(3);return t?gstTimeToSeconds(n):0},set(t){e._pipeline?.seek(1,3,5,1,secondsToGstTime(t),0,-1n)},configurable:!0,enumerable:!0}),Object.defineProperty(this,"duration",{get(){if(!e._pipeline)return NaN;let[t,n]=e._pipeline.query_duration(3);return t&&Number(n)>0?gstTimeToSeconds(n):NaN},configurable:!0,enumerable:!0}),Object.defineProperty(this,"volume",{get(){return e._playbin()?.volume??1},set(t){let n=e._playbin();n&&(n.volume=Math.max(0,Math.min(1,t)))},configurable:!0,enumerable:!0}),Object.defineProperty(this,"muted",{get(){return e._playbin()?.mute??!1},set(t){let n=e._playbin();n&&(n.mute=t)},configurable:!0,enumerable:!0})}async play(){this._pipeline?.set_state(4),this.dispatchEvent(new Event(`play`)),this.dispatchEvent(new Event(`playing`))}pause(){this._pipeline?.set_state(3),this.dispatchEvent(new Event(`pause`))}get videoWidth(){return this._videoWidth}set videoWidth(e){this._videoWidth=e}get videoHeight(){return this._videoHeight}set videoHeight(e){this._videoHeight=e}get[Symbol.toStringTag](){return`HTMLVideoElement`}_playbin(){return this._pipeline?.get_by_name(`playbin`)??null}};const Wt=new class Document extends gt{static{this._elementFactories=new Map}constructor(){super(),this.body=new HTMLElement$1,this.head=new HTMLElement$1,this.documentElement=new HTMLElement$1,this.appendChild(this.documentElement),this.documentElement.appendChild(this.body)}static registerElementFactory(e,t){Document._elementFactories.set(e.toLowerCase(),t)}createElementNS(e,t){let n=t.toLowerCase(),r=(()=>{switch(n){case`img`:return new HTMLImageElement;case`video`:return new HTMLVideoElement;case`canvas`:return new It;default:{let e=Document._elementFactories.get(n);return e?e():new HTMLElement$1}}})();return r[Ue]=n,r[He]=n.toUpperCase(),r[We]=e??vt.html,r}createElement(e){return this.createElementNS(`http://www.w3.org/1999/xhtml`,e)}createTextNode(e){return new Vt(e)}createComment(e){return new Bt(e)}createDocumentFragment(){return new Ht}createEvent(e){return new Event(e)}getElementById(e){return this._findById(this.body,e)}_findById(e,t){if(e.id===t)return e;for(let n of e.children){let e=this._findById(n,t);if(e)return e}return null}get[Symbol.toStringTag](){return`Document`}};var DOMTokenList=class{constructor(e,t){this._ownerElement=e,this._attributeName=t}_getTokens(){let e=this._ownerElement.getAttribute(this._attributeName);return e?e.split(/\s+/).filter(e=>e.length>0):[]}_setTokens(e){let t=e.join(` `);t?this._ownerElement.setAttribute(this._attributeName,t):this._ownerElement.removeAttribute(this._attributeName)}get length(){return this._getTokens().length}get value(){return this._ownerElement.getAttribute(this._attributeName)??``}set value(e){e?this._ownerElement.setAttribute(this._attributeName,e):this._ownerElement.removeAttribute(this._attributeName)}item(e){let t=this._getTokens();return e>=0&&e<t.length?t[e]:null}contains(e){return this._getTokens().includes(e)}add(...e){let t=this._getTokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._setTokens(t)}remove(...e){let t=this._getTokens().filter(t=>!e.includes(t));this._setTokens(t)}toggle(e,t){let n=this.contains(e);return t===void 0?n?(this.remove(e),!1):(this.add(e),!0):t?(this.add(e),!0):(this.remove(e),!1)}replace(e,t){let n=this._getTokens(),r=n.indexOf(e);return r===-1?!1:(n[r]=t,this._setTokens(n),!0)}supports(e){return!0}forEach(e){let t=this._getTokens();for(let n=0;n<t.length;n++)e(t[n],n,this)}keys(){return this._getTokens().keys()}values(){return this._getTokens().values()}entries(){return this._getTokens().entries()}[Symbol.iterator](){return this._getTokens().values()}toString(){return this.value}get[Symbol.toStringTag](){return`DOMTokenList`}};function installWindowEventBus(e){if(e.__gjsify_globalEventTarget)return e.__gjsify_globalEventTarget;let t=new EventTarget,n=typeof e.addEventListener==`function`?e.addEventListener.bind(e):null,r=typeof e.removeEventListener==`function`?e.removeEventListener.bind(e):null;e.__gjsify_globalEventTarget=t;let define=(t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return define(`addEventListener`,(e,r,i)=>{t.addEventListener(e,r,i),n?.(e,r,i)}),define(`removeEventListener`,(e,n,i)=>{t.removeEventListener(e,n,i),r?.(e,n,i)}),define(`dispatchEvent`,e=>t.dispatchEvent(e)),t}installWindowEventBus(globalThis),N(),defineGlobal(`Text`,Vt),defineGlobal(`Comment`,Bt),defineGlobal(`DocumentFragment`,Ht),defineGlobal(`DOMTokenList`,DOMTokenList),defineGlobal(`document`,Wt),defineGlobalIfMissing$1(`self`,globalThis);var Window=class{static[Symbol.hasInstance](e){return e===globalThis}};defineGlobalIfMissing$1(`Window`,Window),defineGlobalIfMissing$1(`window`,globalThis),defineGlobalIfMissing$1(`focus`,()=>{}),defineGlobalIfMissing$1(`blur`,()=>{}),defineGlobalIfMissing$1(`devicePixelRatio`,1),defineGlobalIfMissing$1(`scrollX`,0),defineGlobalIfMissing$1(`scrollY`,0),defineGlobalIfMissing$1(`pageXOffset`,0),defineGlobalIfMissing$1(`pageYOffset`,0),defineGlobalIfMissing$1(`alert`,(...e)=>M.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0});function atobPolyfill(e){if(typeof globalThis.atob==`function`)return globalThis.atob(e);let t=e.replace(/[=\s]/g,``),n=``,r=0,i=0;for(let e=0;e<t.length;e++)r=r<<6|Kt[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n+=String.fromCharCode(r>>i&255));return n}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+=Gt[r>>18&63]+Gt[r>>12&63]+Gt[r>>6&63]+Gt[r&63]}if(n+1===e.length){let r=e.charCodeAt(n)<<16;t+=Gt[r>>18&63]+Gt[r>>12&63]+`==`}else if(n+2===e.length){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8;t+=Gt[r>>18&63]+Gt[r>>12&63]+Gt[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,o=0;for(let e=0;e<t.length;e++)r=r<<6|Kt[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n[o++]=r>>i&255);return n.subarray(0,o)}function base64Encode(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],o=r+1<n?e[r+1]:0,s=r+2<n?e[r+2]:0;t+=Gt[i>>2],t+=Gt[(i&3)<<4|o>>4],t+=r+1<n?Gt[(o&15)<<2|s>>6]:`=`,t+=r+2<n?Gt[s&63]:`=`}return t}var Gt,Kt,qt=__esmMin(()=>{Gt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Kt=new Uint8Array(256);for(let e=0;e<64;e++)Kt[Gt.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(!Jt.includes(t))throw TypeError(`Unknown encoding: ${e}`)}var Jt,Yt=__esmMin(()=>{Jt=[`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 Xt,Zt,textEncoder,textDecoder,Qt=__esmMin(()=>{qt(),textEncoder=()=>Xt??=new TextEncoder,textDecoder=()=>Zt??=new TextDecoder}),$t,H,en,tn,nn,SlowBuffer,rn=__esmMin(()=>{Qt(),Yt(),$t=typeof SharedArrayBuffer<`u`,H=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($t&&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,o=n===void 0?r.byteLength-i:n,s=r.viewBytes(i,o);return new Buffer(s.buffer,s.byteOffset,s.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||$t&&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 o=e[i],s=Math.min(o.length,t-r);s<=0||(n.set(o.subarray(0,s),r),r+=s)}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 o=r!==void 0||i!==void 0?this.subarray(r??0,i??this.length):this,s=t!==void 0||n!==void 0?e.subarray(t??0,n??e.length):e;return Buffer.compare(o,s)}copy(e,t=0,n=0,r){let i=r??this.length,o=Math.min(i-n,e.length-t);return o<=0?0:(e.set(this.subarray(n,n+o),t),o)}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))),o=n!==void 0&&typeof n==`number`?Math.min(n,this.length-t):this.length-t,s=Math.min(i.length,o);return this.set(i.subarray(0,s),t),s}fill(e,t,n,r){let i=t??0,o=n??this.length;if(typeof e==`number`)super.fill(e&255,i,o);else if(typeof e==`string`){let t=encodeString(e,normalizeEncoding(r));if(t.length===0)super.fill(0,i,o);else if(t.length===1)super.fill(t[0],i,o);else for(let e=i;e<o;e++)this[e]=t[(e-i)%t.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,i,o);else for(let t=i;t<o;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}},en=2**31-1,tn=2**28-16,nn={MAX_LENGTH:en,MAX_STRING_LENGTH:tn},SlowBuffer=class extends H{constructor(e){super(e)}}}),an=__exportAll$5({Blob:()=>S,Buffer:()=>H,File:()=>w,INSPECT_MAX_BYTES:()=>50,SlowBuffer:()=>SlowBuffer,atob:()=>on,atobPolyfill:()=>atobPolyfill,base64Decode:()=>base64Decode,base64Encode:()=>base64Encode,btoa:()=>sn,btoaPolyfill:()=>btoaPolyfill,checkEncoding:()=>checkEncoding,constants:()=>nn,default:()=>cn,kMaxLength:()=>en,kStringMaxLength:()=>tn,normalizeEncoding:()=>normalizeEncoding}),on,sn,cn,U=__esmMin(()=>{qt(),T(),Yt(),rn(),on=globalThis.atob,sn=globalThis.btoa,cn={Buffer:H,SlowBuffer,Blob:S,File:w,atob:on,btoa:sn,kMaxLength:en,kStringMaxLength:tn,constants:nn,INSPECT_MAX_BYTES:50}});U(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:H,enumerable:!1,writable:!0,configurable:!0});var ln,un=__esmMin(()=>{ln=i}),W,G=__esmMin(()=>{un(),W=ln});G(),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 W.base64_encode(t)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let t=W.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}),P(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:oe,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}var dn=__esmMin(()=>{});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}function hrtime(e){let t=getMonotonicTime()-fn,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()-fn}var fn,pn=__esmMin(()=>{dn(),fn=getMonotonicTime()});function probeUname(){if(mn!==void 0)return mn;mn=null;try{let e=getGjsGlobal().imports?.gi?.GLib;if(!e)return mn;let t=e.spawn_sync,n=e.SpawnFlags?.SEARCH_PATH;if(!t||n===void 0)return mn;let[r,i]=t(null,[`uname`,`-sm`],null,n,null);if(!r||!i)return mn;let o=new TextDecoder().decode(i).trim().split(/\s+/);if(o.length<2)return mn;let s=mapSysname(o[0]),c=mapMachine(o[o.length-1]);if(!s||!c)return mn;mn={platform:s,arch:c}}catch{}return mn}var mn,hn=__esmMin(()=>{dn(),P()});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(){let e=runtimeProcess();return e&&typeof e.ppid==`number`?e.ppid:hostPpid()??0}function runtimeProcess(){let e=globalThis.process;return typeof e?.release?.name==`string`?e:void 0}function onGjs(){try{return getGjsGlobal().imports?.gi!==void 0}catch{return!1}}function detectPlatform(){let e=runtimeProcess();if(e)return e.platform;if(onGjs()){let e=probeUname();if(e)return e.platform}return`linux`}function detectArch(){let e=runtimeProcess();if(e)return e.arch;if(onGjs()){let e=probeUname();if(e)return e.arch}return`x64`}function getPid(){let e=runtimeProcess();return e&&typeof e.pid==`number`?e.pid:hostPid()??0}var gn=__esmMin(()=>{dn(),hn(),P()});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`)}var _n=__esmMin(()=>{dn(),P()});function exitProcess(e){let t=getGjsGlobal().imports,n=t?.gi?.GLib,r=t?.system,i=n?.idle_add,o=n?.SOURCE_REMOVE,s=n?.PRIORITY_DEFAULT,c=n?.MainContext;if(r?.exit&&i&&typeof s==`number`&&typeof o==`boolean`&&typeof c?.default==`function`){i(s,()=>(r.exit(e),o));let t=c.default();for(;;)t.iteration(!0)}try{r?.exit&&r.exit(e)}catch{}let l=globalThis.process;throw l&&typeof l.exit==`function`&&l.exit(e),Error(`process.exit(${e})`)}var vn=__esmMin(()=>{dn()});function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function classifyKillFailure(e){if(/No such process/i.test(e))return`ESRCH`;if(/Operation not permitted/i.test(e))return`EPERM`}function killPid(e,t){let n=getGjsGlobal().imports?.gi?.GLib;if(n){let r=typeof t==`number`?String(t):t||`SIGTERM`,i=[`kill`,r.startsWith(`SIG`)?`-${r.slice(3)}`:`-${r}`,`--`,String(e)],o=n.environ_setenv(n.get_environ(),`LC_ALL`,`C`,!0),[,,s,c]=n.spawn_sync(null,i,o,4,null),l=!1;try{l=n.spawn_check_wait_status(c)}catch{l=!1}if(l)return!0;let u=s?new TextDecoder().decode(s).trim():``,d=classifyKillFailure(u),p=Error(d?`kill ${d}`:`kill failed${u?`: ${u}`:``}`);throw d&&(p.code=d,p.errno=d===`ESRCH`?-3:-1,p.syscall=`kill`),p}let r=globalThis.process;if(r&&typeof r.kill==`function`)return r.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}var yn=__esmMin(()=>{dn(),P()});function resolveSignalAdd(){let e=getGjsGlobal().imports?.gi;if(!e)return null;for(let[t,n]of[[`GLibUnix`,`signal_add`],[`GLib`,`unix_signal_add`]])try{let r=e[t]?.[n];if(typeof r==`function`)return r}catch{}return null}function isDeliverableSignal(e){return typeof e==`string`&&e in bn}function armSignal(e,t){if(xn.has(e))return;let n=bn[e],r=resolveSignalAdd(),i=getGjsGlobal().imports?.gi?.GLib;if(n===void 0||r===null||!i)return;let o=i.PRIORITY_DEFAULT,s=r(o,n,()=>(t(e),!0));xn.set(e,s)}function disarmSignal(e){let t=xn.get(e);if(t===void 0)return;xn.delete(e);let n=getGjsGlobal().imports?.gi?.GLib;n&&typeof n.source_remove==`function`&&n.source_remove(t)}var bn,xn,Sn=__esmMin(()=>{dn(),bn={SIGHUP:1,SIGINT:2,SIGTERM:15},xn=new Map});function claimRawMode(e,t){Tn.set(e,t)}function releaseRawMode(e){Tn.delete(e)}function noteRawMode(e,t,n){let r=n(t);return t?r&&claimRawMode(e,()=>{n(!1)}):releaseRawMode(e),r}function restoreClaimedRawModes(){let e=[...Tn.entries()];Tn.clear();let t=0,n;for(let[,r]of e)try{r(),t+=1}catch(e){n??=e}if(n!==void 0)throw n;return t}var Cn,wn,Tn,En=__esmMin(()=>{Cn=Symbol.for(`@gjsify/terminal-native:raw-mode-claims`),wn=globalThis,Tn=wn[Cn]??=new Map});function callableModule(){if(!On)return null;try{return On.Terminal.is_tty(2),On}catch{return null}}function nativeIsTty(e){try{return callableModule()?.Terminal.is_tty(e)??null}catch{return null}}function nativeTerminalSize(e){try{let[t,n,r]=callableModule()?.Terminal.get_size(e)??[!1,0,0];return!t||r<=0?null:{rows:n,columns:r}}catch{return null}}function nativeSetRawMode(e,t){try{return callableModule()?.Terminal.set_raw_mode(e,t)??null}catch{return null}}var Dn,On,kn,An=__esmMin(()=>{En(),P(),Dn=loadOptionalNativeModule(`GjsifyTerminal`,[`Terminal`,`ResizeWatcher`]),On=Dn.module,kn=On});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 jn,Mn,Nn,Pn=__esmMin(()=>{N(),jn=Symbol(`kCapture`),Mn=Symbol.for(`nodejs.rejection`),Nn=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=Mn;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;[jn];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[jn]=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[jn]&&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[jn]&&this._addCatch(r,e,t)}}return!0}_addCatch(e,t,n){typeof e?.then==`function`&&e.then(void 0,e=>{let r=this[Mn];if(typeof r==`function`)r.call(this,e,t,...n);else{let t=this[jn];try{this[jn]=!1,this.emit(`error`,e)}finally{this[jn]=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 o=this.getMaxListeners();if(o>0){let t=typeof r[e]==`function`?1:r[e].length;if(t>o&&!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`,M.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 o=n?.signal;if(o?.aborted){i(createAbortError$2(o));return}if(typeof e.addEventListener==`function`){let n=e,handler=(...e)=>{o&&o.removeEventListener(`abort`,abortHandler),r(e)},errorHandler=e=>{o&&o.removeEventListener(`abort`,abortHandler),n.removeEventListener(`error`,errorHandler),i(e)},abortHandler=()=>{n.removeEventListener(t,handler),n.removeEventListener(`error`,errorHandler),i(createAbortError$2(o))};n.addEventListener(t,handler,{once:!0}),t!==`error`&&n.addEventListener(`error`,errorHandler,{once:!0}),o&&o.addEventListener(`abort`,abortHandler,{once:!0});return}let s=e,eventHandler=(...e)=>{o&&o.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&s.removeListener(`error`,errorHandler),r(e)},errorHandler;t!==`error`&&(errorHandler=e=>{s.removeListener(t,eventHandler),o&&o.removeEventListener(`abort`,abortHandler),i(e)},s.once(`error`,errorHandler)),s.once(t,eventHandler);let abortHandler=()=>{s.removeListener(t,eventHandler),errorHandler&&s.removeListener(`error`,errorHandler),i(createAbortError$2(o))};o&&o.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,o=n?.lowWaterMark??1;validateNumber(i,`highWaterMark`),validateNumber(o,`lowWaterMark`);let s=[],c=[],l=null,u=!1,d=!1,eventHandler=(...t)=>{if(c.length>0){let{resolve:e}=c.shift();e({value:t,done:!1})}else s.push(t),s.length>=i&&!d&&(d=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(l=e,c.length>0){let{reject:t}=c.shift();t(e)}p.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),u=!0;for(let{resolve:e}of c)e({value:void 0,done:!0});c.length=0,s.length=0},p={next(){if(s.length>0){let t=s.shift();return d&&s.length<o&&(d=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:t,done:!1})}if(l){let e=Promise.reject(l);return l=null,e}return u?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{c.push({resolve:e,reject:t})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return u||(l=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return p}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)}}}},Nn.EventEmitter=Nn;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let t=Nn.prototype[e];typeof t==`function`&&Object.defineProperty(Nn.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}Object.defineProperty(Nn.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(Nn.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(Nn.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name(createAbortError$2,`createAbortError`)}),Fn=__exportAll$5({EventEmitter:()=>K,addAbortListener:()=>Gn,captureRejectionSymbol:()=>In,default:()=>K,defaultMaxListeners:()=>Rn,errorMonitor:()=>Ln,getEventListeners:()=>Un,getMaxListeners:()=>Bn,listenerCount:()=>Wn,"module.exports":()=>K,on:()=>Hn,once:()=>Vn,setMaxListeners:()=>zn}),K,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn=__esmMin(()=>{Pn(),P(),K=makeCallable(Nn),K.EventEmitter=K,In=K.captureRejectionSymbol,Ln=K.errorMonitor,Rn=K.defaultMaxListeners,zn=K.setMaxListeners,Bn=K.getMaxListeners,Vn=K.once,Hn=K.on,Un=K.getEventListeners,Wn=K.listenerCount,Gn=K.addAbortListener}),qn=__exportAll$5({StringDecoder:()=>Jn,default:()=>Yn});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 o,s;if(t===224?(o=160,s=191):t===237?(o=128,s=159):(o=128,s=191),i+1>=n){r+=`�`,i++;continue}let c=e[i+1];if(c<o||c>s){r+=`�`,i++;continue}if(i+2>=n){r+=`�`,i+=2;continue}let l=e[i+2];if(l<128||l>191){r+=`�`,i+=2;continue}let u=(t&15)<<12|(c&63)<<6|l&63;r+=String.fromCharCode(u),i+=3;continue}if(t>=240&&t<=244){let o,s;if(t===240?(o=144,s=191):t===244?(o=128,s=143):(o=128,s=191),i+1>=n){r+=`�`,i++;continue}let c=e[i+1];if(c<o||c>s){r+=`�`,i++;continue}if(i+2>=n){r+=`�`,i+=2;continue}let l=e[i+2];if(l<128||l>191){r+=`�`,i+=2;continue}if(i+3>=n){r+=`�`,i+=3;continue}let u=e[i+3];if(u<128||u>191){r+=`�`,i+=3;continue}let d=(t&7)<<18|(c&63)<<12|(l&63)<<6|u&63;r+=String.fromCharCode(55296+(d-65536>>10),56320+(d-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],o=e._lastTotal-e._lastNeed;if(isValidContinuation(e._lastLeadByte,e._lastTotal,o,i))e._lastChar[o]=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 o=t.length-1-r;if(o<n)break;let s=t[o];if((s&192)!=128){let n=utf8CharLength(s);if(n>0&&s>=128){let r=t.length-o;if(r<n){let c=!0;for(let e=1;e<r;e++)if(!isValidContinuation(s,n,e,t[o+e])){c=!1;break}if(c){i=o;for(let n=0;n<r;n++)e._lastChar[n]=t[o+n];e._lastNeed=n-r,e._lastTotal=n,e._lastLeadByte=s}}}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,o=Math.min(e._lastNeed,t.length);for(let n=0;n<o;n++)e._lastChar[i+n]=t[n];if(e._lastNeed-=o,r=o,e._lastNeed>0)return``;let s=e._lastTotal,c=0;for(;c+1<s;){let i=e._lastChar[c]|e._lastChar[c+1]<<8;if(c+=2,i>=55296&&i<=56319){if(c+1<s){let t=e._lastChar[c]|e._lastChar[c+1]<<8;if(t>=56320&&t<=57343){n+=String.fromCharCode(i,t),c+=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[c-2],e._lastChar[1]=e._lastChar[c-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,o=``;e._lastTotal>0&&e._lastNeed===0&&(o+=base64Encode(e._lastChar.subarray(0,e._lastTotal)),e._lastTotal=0),i>0&&(o+=base64Encode(t.subarray(n,n+i)));let s=r-i;if(s>0){for(let r=0;r<s;r++)e._lastChar[r]=t[n+i+r];e._lastNeed=3-s,e._lastTotal=3}return o}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 Jn,Yn,Xn=__esmMin(()=>{U(),Jn=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},Jn.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)}},Jn.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},Yn={StringDecoder:Jn}}),Zn,ProcessWriteStream,ProcessReadStream,Qn=__esmMin(()=>{N(),dn(),An(),Kn(),P(),Xn(),Zn=new TextEncoder,ProcessWriteStream=class extends K{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`?Zn.encode(e):e;return this._outGio.write_all(t,null),!0}catch{}return this.fd===2?M.error(e):M.log(e),!0}get isTTY(){let e=nativeIsTty(this.fd);if(e!==null)return e;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){let e=nativeTerminalSize(this.fd);if(e)return e.columns;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(){let e=nativeTerminalSize(this.fd);if(e)return e.rows;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 K{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_mainLoopHeld=!1;_pendingRead=!1;_decoder=null;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return nativeIsTty(this.fd)??!1}setRawMode(e){return noteRawMode(this.fd,e,e=>nativeSetRawMode(this.fd,e)===!0)?(this.isRaw=e,this):(noteRawMode(this.fd,e,e=>this._setRawModeViaStty(e)),this.isRaw=e,this)}_setRawModeViaStty(e){try{let t=globalThis.imports?.gi,n=t?.Gio??t?.Gio;if(!n)return!1;let r=n.SubprocessFlags?.STDIN_INHERIT??2,i=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`-isig`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`,`isig`],o=new n.SubprocessLauncher({flags:r}).spawnv(i);return o.wait(null),o.get_successful()}catch{return!1}}setEncoding(e){return this._decoder=new Jn(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()}}});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 $n,Process,er=__esmMin(()=>{N(),gn(),_n(),vn(),pn(),yn(),Sn(),Qn(),An(),Kn(),$n=Date.now(),Process=class extends K{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.on(`exit`,()=>{try{restoreClaimedRawModes()}catch(e){M.error(`@gjsify/process: raw mode could not be restored:`,e)}}),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(),this.ppid=detectPpid();let e=detectVersionInfo();this.version=e.version,this.versions=e.versions,this.title=e.title,this.on(`newListener`,e=>{isDeliverableSignal(e)&&armSignal(e,e=>this.emit(e,e))}),this.on(`removeListener`,e=>{isDeliverableSignal(e)&&this.listenerCount(e)===0&&disarmSignal(e)})}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()-$n)/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){M.warn(typeof e==`string`?`(${t||`Warning`}): ${e}`:e.message)}},Process.prototype.hrtime.bigint=function(){return hrtimeBigint()}}),q,tr=__esmMin(()=>{if(pn(),er(),An(),q=new Process,kn)try{let e=new kn.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{q.stdout.emit(`resize`),q.stderr.emit(`resize`)}),e.start()}catch{}q.platform,q.arch,q.env,q.argv,q.argv0,q.execPath,q.pid,q.ppid,q.version,q.versions,q.cwd.bind(q),q.chdir.bind(q),q.exit.bind(q),q.nextTick.bind(q),Object.assign(q.hrtime.bind(q),{bigint:hrtimeBigint}),q.uptime.bind(q),q.memoryUsage.bind(q),q.cpuUsage.bind(q),q.kill.bind(q),q.abort.bind(q),q.umask.bind(q),q.emitWarning.bind(q),q.execArgv,q.config,q.stdout,q.stderr,q.stdin});G(),tr();const nr=Symbol(`kInitialize`);function getNavigatorPlatform(e,t){return t===`darwin`?`MacIntel`:t===`win32`?`Win32`:t===`linux`?e===`ia32`?`Linux i686`:e===`x64`?`Linux x86_64`:`Linux ${e}`:t===`freebsd`?e===`ia32`?`FreeBSD i386`:e===`x64`?`FreeBSD amd64`:`FreeBSD ${e}`:t===`openbsd`?e===`ia32`?`OpenBSD i386`:e===`x64`?`OpenBSD amd64`:`OpenBSD ${e}`:t===`sunos`?e===`ia32`?`SunOS i86pc`:`SunOS ${e}`:t===`aix`?`AIX`:`${t[0].toUpperCase()}${t.slice(1)} ${e}`}function gjsUserAgent(){let e=q.versions.gjs;if(!e)return`GJS`;let[t,n]=e.split(`.`);return`GJS/${t}.${n}`}function illegalConstructor(){let e=TypeError(`Illegal constructor`);return e.code=`ERR_ILLEGAL_CONSTRUCTOR`,e}var Navigator=class{#e;#t;#n;#r;constructor(e){if(e!==nr)throw illegalConstructor()}get hardwareConcurrency(){return this.#e??=W.get_num_processors(),this.#e}get language(){return this.#r,new Intl.DateTimeFormat().resolvedOptions().locale||`en-US`}get languages(){return this.#r??=Object.freeze([this.language]),this.#r}get userAgent(){return this.#t??=gjsUserAgent(),this.#t}get platform(){return this.#n??=getNavigatorPlatform(q.arch,q.platform),this.#n}};for(let e of[`hardwareConcurrency`,`language`,`languages`,`userAgent`,`platform`])Object.defineProperty(Navigator.prototype,e,{enumerable:!0});const rr=new Navigator(nr);globalThis.navigator===void 0&&Object.defineProperty(globalThis,"navigator",{value:rr,enumerable:!0,writable:!0,configurable:!0}),globalThis.Navigator===void 0&&Object.defineProperty(globalThis,"Navigator",{value:Navigator,enumerable:!1,writable:!0,configurable:!0}),P(),tr(),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:q,enumerable:!1,writable:!0,configurable:!0}),P(),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 ir=getGLib()!==void 0;function reportTimerThrow(e,t){try{e.log_default_handler(`gjsify-timers`,e.LogLevelFlags.LEVEL_WARNING,`Uncaught exception in a timer callback: ${String(t)}\n${t?.stack??``}`,null)}catch{}}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(t){reportTimerThrow(e,t)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}unref(){return this._refed=!1,this}ref(){return this._refed=!0,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){this._id!==null&&(getGLib()?.Source.remove(this._id),this._id=null)}close(){return this._cancel(),this}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){e instanceof GjsifyTimeout||typeof e==`object`&&e&&`_cancel`in e?e._cancel():typeof e==`object`&&e&&typeof e.close==`function`?e.close():typeof e==`number`&&getGLib()?.Source.remove(e)}if(ir){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$1(e,...t){return setTimeout(e,0,...t)}__name(setImmediate$1,`setImmediate`);function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate$1,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});var ar,or,sr=__esmMin(()=>{ar=Object.defineProperty,or=__name((e,t)=>{let n={};for(var r in e)ar(n,r,{get:e[r],enumerable:!0});return t||ar(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=``,o=0,s=-1,c=0,l;for(let u=0;u<=e.length;++u){if(u<e.length)l=e.charCodeAt(u);else if(r(l))break;else l=47;if(r(l)){if(!(s===u-1||c===1))if(s!==u-1&&c===2){if(i.length<2||o!==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=``,o=0):(i=i.slice(0,e),o=i.length-1-i.lastIndexOf(n)),s=u,c=0;continue}else if(i.length===2||i.length===1){i=``,o=0,s=u,c=0;continue}}t&&(i.length>0?i+=`${n}..`:i=`..`,o=2)}else i.length>0?i+=n+e.slice(s+1,u):i=e.slice(s+1,u),o=u-s-1;s=u,c=0}else l===46&&c!==-1?++c:c=-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 cr=__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$2(...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$2(e),t=resolve$2(t),e===t))return``;let n=e.length,r=n-1,i=1,o=t.length-i,s=r<o?r:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(i+l)===47)return t.slice(i+l+1);if(l===0)return t.slice(i+l)}else r>s&&(e.charCodeAt(1+l)===47?c=l:l===0&&(c=0));break}let n=e.charCodeAt(1+l);if(n!==t.charCodeAt(i+l))break;n===47&&(c=l)}let u=``;for(l=1+c+1;l<=n;++l)(l===n||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(i+c):(i+=c,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 o=t.length-1,s=-1;for(let c=e.length-1;c>=0;--c){let l=e.charCodeAt(c);if(l===47){if(!i){n=c+1;break}}else s===-1&&(i=!1,s=c+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(r=c):(o=-1,r=s))}return n===r?r=s: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,o=0;for(let s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!i){n=s+1;break}continue}r===-1&&(i=!1,r=s+1),c===46?t===-1?t=s:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||r===-1||o===0||o===1&&t===r-1&&t===n+1?``:e.slice(t,r)}function format$3(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$3(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,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=r;--l){let t=e.charCodeAt(l);if(t===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),t===46?i===-1?i=l:u!==1&&(u=1):i!==-1&&(u=-1)}return i===-1||s===-1||u===0||u===1&&i===s-1&&i===o+1?s!==-1&&(o===0&&n?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,s)):(t.name=e.slice(o,i),t.base=e.slice(o,s)),t.ext=e.slice(i,s)),o>0?t.dir=e.slice(0,o-1):n&&(t.dir=`/`),t}var lr,ur=__esmMin(()=>{sr(),cr(),lr=or({basename:()=>basename$1,delimiter:()=>`:`,dirname:()=>dirname$1,extname:()=>extname$1,format:()=>format$3,isAbsolute:()=>isAbsolute$1,join:()=>join$1,normalize:()=>normalize$1,parse:()=>parse$3,relative:()=>relative$1,resolve:()=>resolve$2,sep:()=>`/`,toNamespacedPath:()=>toNamespacedPath$1}),__name(resolve$2,`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$3,`format`),__name(parse$3,`parse`)});function cwd(){return typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():`/`}function resolve$1(...e){let t=``,n=``,r=!1;for(let i=e.length-1;i>=-1;i--){let o;if(i>=0){if(o=e[i],assertPath(o),o.length===0)continue}else t.length===0?o=cwd():(o=globalThis.process?.env?.[`=${t}`]||cwd(),o.slice(0,2).toLowerCase()!==t.toLowerCase()&&o.charCodeAt(2)===92&&(o=`${t}\\`));let s=o.length,c=0,l=``,u=!1,d=o.charCodeAt(0);if(s===1)isPathSeparator(d)&&(c=1,u=!0);else if(isPathSeparator(d))if(u=!0,isPathSeparator(o.charCodeAt(1))){let e=matchUncRoot(o);e&&(l=e.device,c=e.rootEnd)}else c=1;else isWindowsDeviceRoot(d)&&o.charCodeAt(1)===58&&(l=o.slice(0,2),c=2,s>2&&isPathSeparator(o.charCodeAt(2))&&(u=!0,c=3));if(l.length>0)if(t.length>0){if(l.toLowerCase()!==t.toLowerCase())continue}else t=l;if(r){if(t.length>0)break}else if(n=`${o.slice(c)}\\${n}`,r=u,u&&t.length>0)break}return n=normalizeString(n,!r,`\\`,isPathSeparator),r?`${t}\\${n}`:`${t}${n}`||`.`}function matchUncRoot(e){let t=e.length,n=2,r=n;for(;n<t&&!isPathSeparator(e.charCodeAt(n));)n++;if(n>=t||n===r)return;let i=e.slice(r,n);for(r=n;n<t&&isPathSeparator(e.charCodeAt(n));)n++;if(!(n>=t||n===r)){for(r=n;n<t&&!isPathSeparator(e.charCodeAt(n));)n++;return i===`.`||i===`?`?{device:`\\\\${i}`,rootEnd:4,shareOnly:!1}:{device:`\\\\${i}\\${e.slice(r,n)}`,rootEnd:n,shareOnly:n===t}}}function normalize(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=e.charCodeAt(0);if(t===1)return isPosixPathSeparator(n)?`\\`:e;let r=0,i,o=!1;if(isPathSeparator(n))if(o=!0,isPathSeparator(e.charCodeAt(1))){let t=matchUncRoot(e);if(t?.shareOnly)return`${t.device}\\`;if(t&&(i=t.device,r=t.rootEnd,i.length===3)){let t=e.slice(4,e.indexOf(`:`)+1);isWindowsReservedName(t,t.length-1)&&(i=`\\\\?\\${t}`,r=4+t.length)}}else r=1;else{let s=e.indexOf(`:`);s>0&&(isWindowsDeviceRoot(n)&&s===1?(i=e.slice(0,2),r=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(o=!0,r=3)):isWindowsReservedName(e,s)&&(i=e.slice(0,s+1),r=s+1))}let s=r<t?normalizeString(e.slice(r),!o,`\\`,isPathSeparator):``;if(s.length===0&&!o&&(s=`.`),s.length>0&&isPathSeparator(e.charCodeAt(t-1))&&(s+=`\\`),!o&&i===void 0&&e.includes(`:`)){if(s.length>=2&&isWindowsDeviceRoot(s.charCodeAt(0))&&s.charCodeAt(1)===58)return`.\\${s}`;let n=e.indexOf(`:`);do if(n===t-1||isPathSeparator(e.charCodeAt(n+1)))return`.\\${s}`;while((n=e.indexOf(`:`,n+1))!==-1)}return isWindowsReservedName(e,e.indexOf(`:`))?`.\\${i??``}${s}`:i===void 0?o?`\\${s}`:s:o?`${i}\\${s}`:`${i}${s}`}function isWindowsReservedName(e,t){return fr.has(e.slice(0,t).toUpperCase())}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 t.split(/\\+/).some(e=>{let t=e.indexOf(`:`);return t!==-1&&isWindowsReservedName(e,t)})?t.replace(/\//g,`\\`):normalize(t)}function relative(e,t){if(assertPath(e),assertPath(t),e===t)return``;let n=resolve$1(e),r=resolve$1(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 o=e.length;for(;o-1>i&&e.charCodeAt(o-1)===92;--o);let s=o-i,c=0;for(;c<t.length&&t.charCodeAt(c)===92;++c);let l=t.length;for(;l-1>c&&t.charCodeAt(l-1)===92;--l);let u=l-c,d=s<u?s:u,p=-1,m=0;for(;m<=d;++m){if(m===d){if(u>d){if(t.charCodeAt(c+m)===92)return r.slice(c+m+1);if(m===2)return r.slice(c+m)}s>d&&(e.charCodeAt(i+m)===92?p=m:m===2&&(p=3));break}let n=e.charCodeAt(i+m);if(n!==t.charCodeAt(c+m))break;n===92&&(p=m)}if(m!==d&&p===-1)return r;let h=``;for(p===-1&&(p=0),m=i+p+1;m<=o;++m)(m===o||e.charCodeAt(m)===92)&&(h.length===0?h+=`..`:h+=`\\..`);return h.length>0?h+r.slice(c+p,l):(c+=p,r.charCodeAt(c)===92&&++c,r.slice(c,l))}function toNamespacedPath(e){if(typeof e!=`string`||e.length===0)return e;let t=resolve$1(e);if(t.length<=2)return e;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 t}function dirname(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=-1,r=-1,i=!0,o=0,s=e.charCodeAt(0);if(t>1)if(isPathSeparator(s)){if(n=o=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=o=r+1)}}}}else isWindowsDeviceRoot(s)&&e.charCodeAt(1)===58&&(n=o=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(n=o=3));else if(isPathSeparator(s))return e;for(let n=t-1;n>=o;--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 o=t.length-1,s=-1;for(let c=e.length-1;c>=n;--c){let l=e.charCodeAt(c);if(isPathSeparator(l)){if(!i){n=c+1;break}}else s===-1&&(i=!1,s=c+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(r=c):(o=-1,r=s))}return n===r?r=s: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,o=!0,s=0;e.length>=2&&e.charCodeAt(1)===58&&isWindowsDeviceRoot(e.charCodeAt(0))&&(t=r=2);for(let c=e.length-1;c>=t;--c){let t=e.charCodeAt(c);if(isPathSeparator(t)){if(!o){r=c+1;break}continue}i===-1&&(o=!1,i=c+1),t===46?n===-1?n=c:s!==1&&(s=1):n!==-1&&(s=-1)}return n===-1||i===-1||s===0||s===1&&n===i-1&&n===r+1?``:e.slice(n,i)}function format$2(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$2(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 o=-1,s=r,c=-1,l=!0,u=e.length-1,d=0;for(;u>=r;--u){if(i=e.charCodeAt(u),isPathSeparator(i)){if(!l){s=u+1;break}continue}c===-1&&(l=!1,c=u+1),i===46?o===-1?o=u:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===s+1?c!==-1&&(t.base=t.name=e.slice(s,c)):(t.name=e.slice(s,o),t.base=e.slice(s,c),t.ext=e.slice(o,c)),s>0&&s!==r?t.dir=e.slice(0,s-1):t.dir=t.root,t}var dr,fr,pr=__esmMin(()=>{sr(),cr(),dr=or({basename:()=>basename,delimiter:()=>`;`,dirname:()=>dirname,extname:()=>extname,format:()=>format$2,isAbsolute:()=>isAbsolute,join:()=>join,normalize:()=>normalize,parse:()=>parse$2,relative:()=>relative,resolve:()=>resolve$1,sep:()=>`\\`,toNamespacedPath:()=>toNamespacedPath}),__name(resolve$1,`resolve`),fr=new Set([`CON`,`PRN`,`AUX`,`NUL`,...[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`¹`,`²`,`³`].flatMap(e=>[`COM${e}`,`LPT${e}`])]),__name(format$2,`format`),__name(parse$2,`parse`)});function selectFlavour(e){return e===`win32`?dr:lr}var mr=__esmMin(()=>{ur(),pr()}),hr=__exportAll$5({basename:()=>wr,default:()=>Ar,delimiter:()=>kr,dirname:()=>Cr,extname:()=>Tr,format:()=>Er,isAbsolute:()=>yr,join:()=>br,normalize:()=>vr,parse:()=>Dr,posix:()=>lr,relative:()=>xr,resolve:()=>_r,sep:()=>Or,toNamespacedPath:()=>Sr,win32:()=>dr}),gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr=__esmMin(()=>{ur(),pr(),mr(),P(),gr=selectFlavour(hostOs()),{resolve:_r,normalize:vr,isAbsolute:yr,join:br,relative:xr,toNamespacedPath:Sr,dirname:Cr,basename:wr,extname:Tr,format:Er,parse:Dr,sep:Or,delimiter:kr}=gr,Ar={resolve:gr.resolve,normalize:gr.normalize,isAbsolute:gr.isAbsolute,join:gr.join,relative:gr.relative,toNamespacedPath:gr.toNamespacedPath,dirname:gr.dirname,basename:gr.basename,extname:gr.extname,format:gr.format,parse:gr.parse,sep:gr.sep,delimiter:gr.delimiter,posix:lr,win32:dr}}),Mr=__exportAll$5({URL:()=>J,URLSearchParams:()=>Fr,default:()=>Br,domainToASCII:()=>domainToASCII,domainToUnicode:()=>domainToUnicode,fileURLToPath:()=>fileURLToPath,format:()=>format$1,parse:()=>parse$1,pathToFileURL:()=>pathToFileURL,resolve:()=>resolve});function platformOrShapeIsWindows(e){return hostOs()===void 0?isWindowsPath(e):isWin32()}function parseFormUrlencoded(e){let t=[];if(!e)return t;for(let n of e.split(`&`)){if(n===``)continue;let e=n.indexOf(`=`);e===-1?t.push([decodeComponent(n),``]):t.push([decodeComponent(n.slice(0,e)),decodeComponent(n.slice(e+1))])}return t}function decodeComponent(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function percentEncodeUtf8(e){let t=``;for(let n of new TextEncoder().encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function encodeComponent(e){let t=``;for(let n of e)n===` `?t+=`+`:/^[A-Za-z0-9*\-._]$/.test(n)?t+=n:t+=percentEncodeUtf8(n);return t}function isSpecialScheme(e){return Ir.has(e)}function defaultPort(e){return Ir.get(e)??null}function percentEncode(e,t){let n=``;for(let r of e){let e=r.codePointAt(0);n+=e<=32||e>126||t.includes(r)?percentEncodeUtf8(r):r}return n}function encodeQuery(e,t){return percentEncode(e,t?`"#<>'`:`"#<>`)}function isSchemeChar(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`+`||e===`-`||e===`.`}function isAsciiDigit(e){return e!==void 0&&e>=`0`&&e<=`9`}function isHexDigit(e){return e!==void 0&&/^[0-9A-Fa-f]$/.test(e)}function digitPrefix(e){let t=``;for(let n of e){if(!isAsciiDigit(n))break;t+=n}return t}function hasForbiddenDomainCodePoint(e){for(let t of e){let e=t.codePointAt(0);if(e<=31||e===127||t===`%`||zr.has(t))return!0}return!1}function parseIPv6(e){let t=[0,0,0,0,0,0,0,0],n=0,r=null,i=0,at=()=>e[i];if(at()===`:`){if(e[i+1]!==`:`)return;i+=2,n++,r=n}for(;i<e.length;){if(n===8)return;if(at()===`:`){if(r!==null)return;i++,n++,r=n;continue}let o=0,s=0;for(;s<4&&isHexDigit(at());)o=o*16+Number.parseInt(at(),16),i++,s++;if(at()===`.`){if(s===0||(i-=s,n>6))return;let r=0;for(;i<e.length;){let e=null;if(r>0)if(at()===`.`&&r<4)i++;else return;if(!isAsciiDigit(at()))return;for(;isAsciiDigit(at());){let t=Number(at());if(e===null)e=t;else if(e===0)return;else e=e*10+t;if(e>255)return;i++}t[n]=t[n]*256+e,r++,(r===2||r===4)&&n++}if(r!==4)return;break}if(at()===`:`){if(i++,i>=e.length)return}else if(i<e.length)return;t[n]=o,n++}if(r!==null){let e=n-r;for(n=7;n!==0&&e>0;){let i=t[r+e-1];t[r+e-1]=t[n],t[n]=i,n--,e--}}else if(n!==8)return;return serializeIPv6(t)}function serializeIPv6(e){let t=null,n=1,r=-1,i=0;for(let o=0;o<8;o++){if(e[o]!==0){r=-1,i=0;continue}r===-1&&(r=o),i++,i>n&&(n=i,t=r)}let o=``,s=!1;for(let n=0;n<8;n++)if(!(s&&e[n]===0)){if(s=!1,t===n){o+=n===0?`::`:`:`,s=!0;continue}o+=e[n].toString(16),n!==7&&(o+=`:`)}return o}function parseHost(e,t){if(e.startsWith(`[`)){if(!e.endsWith(`]`))return;let t=parseIPv6(e.slice(1,-1));return t===void 0?void 0:`[${t}]`}if(t){for(let t of e)if(zr.has(t))return;return percentEncode(e,``)}if(!hasForbiddenDomainCodePoint(e))return e.toLowerCase()}function parseHostSetterValue(e,t,n,r,i){let o=e.replace(Rr,``),s=isSpecialScheme(t);if(t===`file`){let e=o.length;for(let t=0;t<o.length;t++){let n=o[t];if(n===`/`||n===`\\`||n===`?`||n===`#`){e=t;break}}let t=o.slice(0,e);if(t===``)return{host:``};let n=parseHost(t,!1);return n===void 0?void 0:{host:n===`localhost`?``:n}}let c=!1,l=``;for(let e=0;e<o.length;e++){let n=o[e];if(n===`:`&&!c){if(l===``||i)return;let n=parseHost(l,!s);if(n===void 0)return;let r=digitPrefix(o.slice(e+1));if(r===``)return{host:n};let c=Number(r);return c>65535?{host:n}:{host:n,port:c===defaultPort(t)?null:c}}if(n===`/`||n===`?`||n===`#`||s&&n===`\\`)break;n===`[`?c=!0:n===`]`&&(c=!1),l+=n}if(l===``&&(s||n||r))return;let u=parseHost(l,!s);return u===void 0?void 0:{host:u}}function isDoubleDotSegment(e){let t=e.toLowerCase();return t===`..`||t===`.%2e`||t===`%2e.`||t===`%2e%2e`}function isSingleDotSegment(e){let t=e.toLowerCase();return t===`.`||t===`%2e`}function parsePathSetterValue(e,t,n){let r=e.replace(Rr,``);if(t&&(r=r.replace(/\\/g,`/`)),r===``)return t||n?`/`:``;let i=[],o=(r.startsWith(`/`)?r.slice(1):r).split(`/`);for(let e=0;e<o.length;e++){let t=o[e],n=e===o.length-1;isDoubleDotSegment(t)?(i.pop(),n&&i.push(``)):isSingleDotSegment(t)?n&&i.push(``):i.push(percentEncode(t,'"#<>?^`{}'))}return`/`+i.join(`/`)}function bracketIPv6Host(e){return e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function parse$1(e,t,n){if(typeof e!=`string`)throw TypeError(`The "url" argument must be of type string. Received type `+typeof e);let r={protocol:null,slashes:null,auth:null,host:null,port:null,hostname:null,hash:null,search:null,query:null,pathname:null,path:null,href:e},i=e.trim(),o=i.indexOf(`#`);o!==-1&&(r.hash=i.slice(o),i=i.slice(0,o));let s=i.indexOf(`?`);s!==-1&&(r.search=i.slice(s),r.query=t?Object.fromEntries(new Fr(i.slice(s+1))):i.slice(s+1),i=i.slice(0,s));let c=/^([a-z][a-z0-9.+-]*:)/i.exec(i);if(c&&(r.protocol=c[1].toLowerCase(),i=i.slice(r.protocol.length)),(n||r.protocol)&&i.startsWith(`//`)&&(r.slashes=!0,i=i.slice(2)),r.slashes||r.protocol&&![`javascript:`,`data:`,`mailto:`].includes(r.protocol)){let e=-1;for(let t=0;t<i.length;t++){let n=i[t];if(n===`/`||n===`\\`){e=t;break}}let t=e===-1?i:i.slice(0,e);i=e===-1?``:i.slice(e);let n=t.lastIndexOf(`@`);n===-1?parseHostPort(t,r):(r.auth=decodeURIComponent(t.slice(0,n)),parseHostPort(t.slice(n+1),r))}return r.pathname=i||(r.slashes?`/`:null),(r.pathname!==null||r.search!==null)&&(r.path=(r.pathname||``)+(r.search||``)),r.href=format$1(r),r}function parseHostPort(e,t){if(!e)return;let n=e.indexOf(`[`);if(n!==-1){let r=e.indexOf(`]`,n);if(r!==-1){let i=e.slice(r+1);i.startsWith(`:`)&&(t.port=i.slice(1)),t.hostname=e.slice(n,r+1),t.host=t.hostname+(t.port?`:`+t.port:``);return}}let r=e.lastIndexOf(`:`);if(r!==-1){let n=e.slice(r+1);/^\d*$/.test(n)?(t.port=n||null,t.hostname=e.slice(0,r).toLowerCase()):t.hostname=e.toLowerCase()}else t.hostname=e.toLowerCase();t.host=t.hostname+(t.port?`:`+t.port:``)}function format$1(e){if(typeof e==`string`)return e;if(e instanceof J)return e.href;let t=e,n=``;if(t.protocol&&(n+=t.protocol),(t.slashes||t.protocol&&![`javascript:`,`data:`,`mailto:`].includes(t.protocol||``))&&(n+=`//`),t.auth&&(n+=encodeURIComponent(t.auth)+`@`),t.host?n+=t.host:(t.hostname&&(n+=t.hostname),t.port&&(n+=`:`+t.port)),t.pathname&&(n+=t.pathname),t.search)n+=t.search;else if(t.query&&typeof t.query==`object`){let e=new Fr(t.query).toString();e&&(n+=`?`+e)}return t.hash&&(n+=t.hash),n}function resolve(e,t){return new J(t,new J(e,`resolve://`)).href.replace(/^resolve:\/\//,``)}function fileURLToPath(e,t){if(typeof e==`string`&&(e=new J(e)),!(e instanceof J))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`);let n=e.pathname,r=t?.windows??platformOrShapeIsWindows(n.slice(1));for(let e=0;e<n.length;e++){if(n[e]!==`%`)continue;let t=n.codePointAt(e+2)|32,i=n[e+1]===`2`&&t===102,o=n[e+1]===`5`&&t===99;if(r&&(i||o))throw TypeError(`File URL path must not include encoded \\ or / characters`);if(i)throw TypeError(`File URL path must not include encoded / characters`)}if(e.hostname!==``&&e.hostname!==`localhost`){if(!r)throw TypeError(`File URL host must be "localhost" or empty on ${hostOs()??`this platform`}`);return`\\\\${e.hostname}${decodeURIComponent(n).replace(/\//g,`\\`)}`}if(r){let e=decodeURIComponent(n);return/^\/[A-Za-z]:/.test(e)?e.slice(1).replace(/\//g,`\\`):e.replace(/\//g,`\\`)}return decodeURIComponent(n)}function pathToFileURL(e,t){let n=t?.windows??platformOrShapeIsWindows(e),r=n&&e.startsWith(`\\\\`)?e:(n?dr:lr).resolve(currentDir(),e);if(n&&r.startsWith(`\\\\`))return uncPathToFileURL(r);let i=e.charCodeAt(e.length-1);return(i===47||n&&i===92)&&r[r.length-1]!==Or&&(r+=`/`),new J(pathToFileUrlHref(r,{windows:n}))}function currentDir(){return typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():W.get_current_dir()}function uncPathToFileURL(e){let t=e.startsWith(`\\\\?\\UNC\\`)?8:2,n=e.indexOf(`\\`,t);if(n===-1)throw invalidPathValue(e,`Missing UNC resource path`);if(n===2)throw invalidPathValue(e,`Empty UNC servername`);let r=e.slice(t,n);return new J(`file://${r===`?`?``:r}${encodePathForFileUrl(e.slice(n).replace(/\\/g,`/`))}`)}function invalidPathValue(e,t){let n=TypeError(`The argument 'path' ${t}. Received '${e}'`);return n.code=`ERR_INVALID_ARG_VALUE`,n}function domainToASCII(e){try{return new J(`http://${e}`).hostname}catch{return``}}function domainToUnicode(e){try{return new J(`http://${e}`).hostname}catch{return``}}var Nr,Pr,Fr,Ir,Lr,Rr,zr,J,Br,Vr=__esmMin(()=>{G(),P(),jr(),Nr=W.UriFlags.HAS_PASSWORD|W.UriFlags.ENCODED|W.UriFlags.SCHEME_NORMALIZE,Pr=new WeakMap,Fr=class URLSearchParams{_entries=[];constructor(e){if(e)if(typeof e==`string`)this._entries=parseFormUrlencoded(e.startsWith(`?`)?e.slice(1):e);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]);Pr.get(this)?.()}has(e,t){return t===void 0?this._entries.some(([t])=>t===e):this._entries.some(([n,r])=>n===e&&r===t)}delete(e,t){this._entries=t===void 0?this._entries.filter(([t])=>t!==e):this._entries.filter(([n,r])=>!(n===e&&r===t)),Pr.get(this)?.()}append(e,t){this._entries.push([e,t]),Pr.get(this)?.()}sort(){this._entries.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])),Pr.get(this)?.()}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}},Ir=new Map([[`ftp`,21],[`file`,null],[`http`,80],[`https`,443],[`ws`,80],[`wss`,443]]),Lr='"#/:;<=>?@[\\]^`{|}',Rr=/[\t\n\r]/g,zr=new Set([`\0`,` `,`
|
|
11
|
-
`,`\r`,` `,`#`,`/`,`:`,`<`,`>`,`?`,`@`,`[`,`\\`,`]`,`^`,`|`]),J=class URL{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;constructor(e,t){let n=e instanceof URL?e.href:String(e),r;try{if(t!==void 0){let e=t instanceof URL?t.href:String(t);r=W.Uri.parse(e,Nr).parse_relative(n,Nr)}else r=W.Uri.parse(n,Nr)}catch{throw TypeError(`Invalid URL: ${n}`)}if(!r)throw TypeError(`Invalid URL: ${n}`);this.#e=r.get_scheme();let i=isSpecialScheme(this.#e);this.#t=r.get_user()??``,this.#n=r.get_password()??``;let o=r.get_host(),s=o===null?null:bracketIPv6Host(o.toLowerCase());this.#r=s===null?i?``:null:this.#e===`file`&&s===`localhost`?``:s;let c=r.get_port();this.#i=c===-1||c===defaultPort(this.#e)?null:c,this.#a=r.get_path()??``,i&&this.#a===``&&(this.#a=`/`),this.#o=this.#r===null&&!this.#a.startsWith(`/`),this.#r===null&&!this.#o&&this.#a.startsWith(`/.//`)&&(this.#a=this.#a.slice(2)),this.#s=r.get_fragment()??null,this.#l=r.get_query()??null,this.#c=new Fr,this.#c._entries=parseFormUrlencoded(this.#l??``),Pr.set(this.#c,()=>{let e=this.#c.toString();this.#l=e===``?null:e})}get protocol(){return this.#e+`:`}set protocol(e){let t=String(e).replace(Rr,``)+`:`;if(!/^[A-Za-z]/.test(t))return;let n=``;for(let e of t){if(e===`:`)break;if(!isSchemeChar(e))return;n+=e.toLowerCase()}isSpecialScheme(this.#e)===isSpecialScheme(n)&&(n===`file`&&(this.#t!==``||this.#n!==``||this.#i!==null)||this.#e===`file`&&(this.#r===null||this.#r===``)||(this.#e=n,this.#i!==null&&this.#i===defaultPort(n)&&(this.#i=null)))}get hostname(){return this.#r??``}set hostname(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!0);t!==void 0&&(this.#r=t.host)}get port(){return this.#i===null?``:String(this.#i)}set port(e){if(this.#u())return;let t=String(e);if(t===``){this.#i=null;return}let n=digitPrefix(t.replace(Rr,``));if(n===``)return;let r=Number(n);r>65535||(this.#i=r===defaultPort(this.#e)?null:r)}get host(){let e=this.hostname,t=this.port;return t?`${e}:${t}`:e}set host(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!1);t!==void 0&&(this.#r=t.host,t.port!==void 0&&(this.#i=t.port))}get pathname(){return this.#a}set pathname(e){this.#o||(this.#a=parsePathSetterValue(String(e),isSpecialScheme(this.#e),this.#r===null))}get search(){return this.#l?`?`+this.#l:``}set search(e){let t=String(e);if(t===``){this.#l=null,this.#c._entries=[];return}let n=(t.startsWith(`?`)?t.slice(1):t).replace(Rr,``);this.#l=encodeQuery(n,isSpecialScheme(this.#e)),this.#c._entries=parseFormUrlencoded(n)}get hash(){return this.#s?`#`+this.#s:``}set hash(e){let t=String(e);if(t===``){this.#s=null;return}let n=(t.startsWith(`#`)?t.slice(1):t).replace(Rr,``);this.#s=percentEncode(n,'"<>`')}get origin(){return isSpecialScheme(this.#e)&&this.#e!==`file`?`${this.protocol}//${this.host}`:`null`}get username(){return this.#t}set username(e){this.#u()||(this.#t=percentEncode(String(e),Lr))}get password(){return this.#n}set password(e){this.#u()||(this.#n=percentEncode(String(e),Lr))}#u(){return this.#r===null||this.#r===``||this.#e===`file`}get href(){let e=this.#e+`:`;return this.#r===null?!this.#o&&this.#a.startsWith(`//`)&&(e+=`/.`):(e+=`//`,(this.#t!==``||this.#n!==``)&&(e+=this.#t,this.#n!==``&&(e+=`:`+this.#n),e+=`@`),e+=this.#r,this.#i!==null&&(e+=`:`+this.#i)),e+=this.#a,e+=this.#l===null?``:`?${this.#l}`,e+=this.#s===null?``:`#${this.#s}`,e}set href(e){let t=new URL(String(e));this.#e=t.#e,this.#t=t.#t,this.#n=t.#n,this.#r=t.#r,this.#i=t.#i,this.#a=t.#a,this.#o=t.#o,this.#l=t.#l,this.#s=t.#s,this.#c._entries=parseFormUrlencoded(this.#l??``)}get searchParams(){return this.#c}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&&(W.unlink(t),URL._objectURLPaths.delete(e))}},__name(parse$1,`parse`),__name(format$1,`format`),Br={URL:J,URLSearchParams:Fr,parse:parse$1,format:format$1,resolve,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});Vr(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:J,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:Fr,enumerable:!1,writable:!0,configurable:!0});let Hr;if(globalThis.performance)Hr=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();Hr={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,o=_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&&(o=e.startTime)}let s={name:e,entryType:`measure`,startTime:i,duration:o-i};return t.push(s),s},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}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const Ur=globalThis,Wr=Ur.PerformanceObserver||PerformanceObserverStub;Ur.PerformanceEntry,Ur.PerformanceObserverEntryList,Ur.PerformanceMark,Ur.PerformanceMeasure;const Gr=globalThis;globalThis.performance===void 0&&(Gr.performance=Hr),typeof Gr.PerformanceObserver!=`function`&&(Gr.PerformanceObserver=Wr);const Kr=Symbol(`abort`),qr=Symbol(`internal`);var Jr=class AbortSignal extends EventTarget{#e=!1;#t=void 0;onabort=null;constructor(e){if(super(),e!==qr)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}[Kr](e){if(this.#e)return;this.#e=!0,this.#t=e??new V(`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(qr);return t[Kr](e),t}static timeout(e){let t=new AbortSignal(qr);return setTimeout(()=>{t[Kr](new V(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(qr);for(let n of e)if(n.aborted)return t[Kr](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Kr](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},Yr=class AbortController{signal;constructor(){this.signal=new Jr(qr)}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[Kr](e)}};const Xr=globalThis;globalThis.AbortController===void 0&&(Xr.AbortController=Yr),globalThis.AbortSignal===void 0&&(Xr.AbortSignal=Jr);const Y=Symbol(`kState`),Zr=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[Y]!==void 0&&t[Zr]===e}function dequeueValue(e){let t=e[Y].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[Y].queueTotalSize=Math.max(0,e[Y].queueTotalSize-r),n}function resetQueue(e){e[Y].queue=[],e[Y].queueTotalSize=0}function peekQueueValue(e){return e[Y].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[Y].queue.push({value:t,size:n}),e[Y].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 Qr={__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 $r=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}},ei=Symbol(`kAbort`),ti=Symbol(`kCloseSentinel`),ni=Symbol(`kError`),ri=Symbol(`kSkipThrow`);var WritableStream=class{[Zr]=`WritableStream`;[Y];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[Y]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!ii(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return ii(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return ii(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(!ii(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[Zr]=`WritableStreamDefaultWriter`;[Y];constructor(e){if(!ii(e))throw TypeError(`Expected a WritableStream`);this[Y]={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 ai(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!ai(this))throw TypeError(`Invalid this`);if(this[Y].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return ai(this)?this[Y].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return ai(this)?this[Y].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!ai(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Y];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(!ai(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return ai(this)?this[Y].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{[Zr]=`WritableStreamDefaultController`;[Y];constructor(e){if(e!==ri)throw TypeError(`Illegal constructor`)}[ei](e){let t=this[Y].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[ni](){resetQueue(this)}get signal(){if(!oi(this))throw TypeError(`Invalid this`);return this[Y].abortController.signal}error(e){if(!oi(this))throw TypeError(`Invalid this`);this[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const ii=isBrandCheck(`WritableStream`),ai=isBrandCheck(`WritableStreamDefaultWriter`),oi=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[Y].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[Y].stream=t,t[Y].writer=e,t[Y].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[Y].backpressure?e[Y].ready=Promise.withResolvers():e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close=Promise.withResolvers();break;case`erroring`:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),setPromiseHandled(e[Y].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[Y];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[Y].abortController.abort(t),e[Y].pendingAbortRequest.abort.promise!==void 0)return e[Y].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let o=Promise.withResolvers();return e[Y].pendingAbortRequest={abort:o,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),o.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[Y];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Y].closeRequest=Promise.withResolvers();let{promise:o}=e[Y].closeRequest;return n!==void 0&&r&&t===`writable`&&n[Y].ready.resolve?.(),writableStreamDefaultControllerClose(i),o}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[Y];n!==void 0&&e[Y].backpressure!==t&&(t?n[Y].ready=Promise.withResolvers():n[Y].ready.resolve?.()),e[Y].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[Y];e[Y].state=`erroring`,e[Y].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[Y].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Y].closeRequest.promise!==void 0&&(e[Y].closeRequest.reject?.(e[Y].storedError),e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Y].close.promise),e[Y].close.reject?.(e[Y].storedError);let{writer:t}=e[Y];t!==void 0&&(setPromiseHandled(t[Y].close.promise),t[Y].close.reject?.(e[Y].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[Y].writeRequests.shift();e[Y].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[Y].inFlightCloseRequest=e[Y].closeRequest,e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Y].inFlightWriteRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[Y].inFlightWriteRequest.reject?.(t),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[Y].inFlightWriteRequest.resolve?.(),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[Y].inFlightCloseRequest.reject?.(t),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.reject?.(t),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[Y].inFlightCloseRequest.resolve?.(),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].state===`erroring`&&(e[Y].storedError=void 0,e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.resolve?.(),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Y].state=`closed`,e[Y].writer!==void 0&&e[Y].writer[Y].close.resolve?.(),e[Y].close.resolve?.()}function writableStreamFinishErroring(e){e[Y].state=`errored`,e[Y].controller[ni]();let t=e[Y].storedError;for(let n of e[Y].writeRequests)n.reject?.(t);if(e[Y].writeRequests=[],e[Y].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[Y].pendingAbortRequest;if(e[Y].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[Y].controller[ei](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[Y].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Y].closeRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[Y].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[Y],{controller:r}=n[Y],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[Y].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:o}=n[Y];if(o===`errored`)return Promise.reject(n[Y].storedError);if(writableStreamCloseQueuedOrInFlight(n)||o===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(o===`erroring`)return Promise.reject(n[Y].storedError);let s=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),s}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[Y],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[Y].writer=void 0,e[Y].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[Y];switch(t[Y].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[Y].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[Y].ready.reject?(e[Y].ready.reject(t),e[Y].ready.resolve=void 0,e[Y].ready.reject=void 0):e[Y].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[Y].close.reject?(e[Y].close.reject(t),e[Y].close.resolve=void 0,e[Y].close.reject=void 0):e[Y].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[Y],{state:n}=t[Y];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[Y].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Y].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[Y].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[Y];!writableStreamCloseQueuedOrInFlight(r)&&r[Y].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[Y];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[Y];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[Y].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[Y];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Y].highWaterMark-e[Y].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[Y];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Y].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,ti,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Y].writeAlgorithm=void 0,e[Y].closeAlgorithm=void 0,e[Y].abortAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[Y];if(!n||r[Y].inFlightWriteRequest.promise!==void 0)return;if(r[Y].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===ti?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(ri),o=t?.start,s=t?.write,c=t?.close,l=t?.abort;setupWritableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`sink.write`,s,t):nonOpWrite,c?createPromiseCallback(`sink.close`,c,t):nonOpCancel,l?createPromiseCallback(`sink.abort`,l,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,o,s,c){t[Y]={abortAlgorithm:o,closeAlgorithm:i,highWaterMark:s,queue:[],queueTotalSize:0,abortController:new $r,sizeAlgorithm:c,started:!1,stream:e,writeAlgorithm:r},e[Y].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let l=n();new Promise(e=>e(l)).then(()=>{t[Y].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[Y].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,o=()=>1){let s=Object.create(WritableStream.prototype);return s[Zr]=`WritableStream`,s[Y]=createWritableStreamState(),setupWritableStreamDefaultController(s,new WritableStreamDefaultController(ri),e,t,n,r,i,o),s}P();const si=Symbol(`kCancel`),ci=Symbol(`kClose`),li=Symbol(`kChunk`),ui=Symbol(`kError`),di=Symbol(`kPull`),fi=Symbol(`kRelease`),pi=Symbol(`kSkipThrow`);let mi,hi;function lazyReadableReleasedError(){return mi||(mi=TypeError(`Reader released`),mi)}function lazyReadableReleasingError(){return hi||(hi=TypeError(`Releasing reader`),hi)}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`)}[Zr]=`ReadableStream`;[Y];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[Y]=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(!gi(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return gi(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!gi(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(!gi(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!gi(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!ii(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,o=t?.preventCancel,s=t?.preventClose,c=t?.signal;if(c!==void 0&&!(c instanceof Object&&`aborted`in c))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,!!s,!!i,!!o,c)),n}pipeTo(e,t={}){try{if(!gi(this))throw TypeError(`Invalid this`);if(!ii(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,o=t?.signal;if(o!==void 0&&!(o instanceof Object&&`aborted`in o))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,o)}catch(e){return Promise.reject(e)}}tee(){if(!gi(this))throw TypeError(`Invalid this`);let e=this[Y].controller;return yi(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!gi(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[Y].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,{[li](e){r.current=void 0,t({value:e,done:!1})},[ci](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[ui](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[Y].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}},Qr)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](){this[Y].resolve?.({value:void 0,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamDefaultReader=class{[Zr]=`ReadableStreamDefaultReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!vi(this))return Promise.reject(TypeError(`Invalid this`));if(this[Y].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Y].stream,t=e[Y].controller;if(e[Y].state===`readable`&&_i(t)&&t[Y].queue.length>0){e[Y].disturbed=!0;let n=dequeueValue(t);return t[Y].closeRequested&&!t[Y].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(!vi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return vi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return vi(this)?this[Y].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{[Zr]=`ReadableStreamDefaultController`;[Y];constructor(e){if(e!==pi)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)}[si](e){return readableStreamDefaultControllerCancelSteps(this,e)}[di](e){readableStreamDefaultControllerPullSteps(this,e)}[fi](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const gi=isBrandCheck(`ReadableStream`),_i=isBrandCheck(`ReadableStreamDefaultController`),vi=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Y].reader!==void 0}function readableStreamCancel(e,t){switch(e[Y].disturbed=!0,e[Y].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Y].storedError)}readableStreamClose(e);let n=e[Y].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[Y].readIntoRequests;n[Y].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][ci](void 0)}return e[Y].controller[si](t).then(()=>{})}function readableStreamClose(e){e[Y].state=`closed`,e[Y].closedPromise.resolve();let{reader:t}=e[Y];if(t!==void 0&&(t[Y].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[Y].readRequests.length;e++)t[Y].readRequests[e][ci]();t[Y].readRequests=[]}}function readableStreamError(e,t){e[Y].state=`errored`,e[Y].storedError=t,setPromiseHandled(e[Y].closedPromise.promise),e[Y].closedPromise.reject(t);let{reader:n}=e[Y];if(n!==void 0){if(setPromiseHandled(n[Y].close.promise),n[Y].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[Y].readRequests.length;e++)n[Y].readRequests[e][ui](t);n[Y].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[Y].readIntoRequests.length;e++)n[Y].readIntoRequests[e][ui](t);n[Y].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Y].reader[Y].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readRequests.shift();n?i[ci]():i[li](t)}function readableStreamAddReadRequest(e,t){e[Y].reader[Y].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[Y];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[Y].stream=t,t[Y].reader=e,t[Y].state){case`readable`:e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[Y],n=lazyReadableReleasedError();t[Y].state===`readable`?e[Y].close.reject?.(n):e[Y].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise),t[Y].controller[fi](),t[Y].reader=void 0,e[Y].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[Y].readRequests.length;++n)e[Y].readRequests[n][ui](t);e[Y].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[Y];switch(n[Y].disturbed=!0,n[Y].state){case`closed`:t[ci]();break;case`errored`:t[ui](n[Y].storedError);break;case`readable`:n[Y].controller[di](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[Y].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Y].closeRequested=!0,e[Y].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[Y];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[Y].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[Y];return!e[Y].closeRequested&&t[Y].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[Y];switch(t[Y].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[Y];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[Y];if(r.length){let i=dequeueValue(e);e[Y].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[li](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:s,stream:e},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController(pi),o=t?.start,s=t?.pull,c=t?.cancel;setupReadableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`source.pull`,s,t):nonOpPull,c?createPromiseCallback(`source.cancel`,c,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let o=Object.create(ReadableStream$1.prototype);return o[Zr]=`ReadableStream`,o[Y]=createReadableStreamState(),setupReadableStreamDefaultController(o,new ReadableStreamDefaultController(pi),e,t,n,r,i),o}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[Y].controller):readableStreamDefaultControllerEnqueue(t[Y].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,o){let s,c;try{s=new ReadableStreamDefaultReader(e),c=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[Y].disturbed=!0;let l=!1,{promise:u,resolve:d,reject:p}=Promise.withResolvers(),m={currentWrite:Promise.resolve()},h;function finalize(e,t){writableStreamDefaultWriterRelease(c),readableStreamReaderGenericRelease(s),o!==void 0&&h&&(o.removeEventListener(`abort`,h),h=void 0),e?p(t):d()}async function waitForCurrentWrite(){let e=m.currentWrite;await e,e!==m.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(l)return;if(l=!0,t[Y].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(!l){if(l=!0,t[Y].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=o.reason&&o.reason.name===`AbortError`?createAbortError$1():o.reason;let s=[];r||s.push(()=>t[Y].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||s.push(()=>e[Y].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(s.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[Y].state===`errored`?n(e[Y].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[Y].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[li](e){oe(()=>{m.currentWrite=writableStreamDefaultWriterWrite(c,e),setPromiseHandled(m.currentWrite),g.resolve(!1)})}[ci](){g.resolve(!0)}[ui](e){g.reject(e)}}let g={resolve:null,reject:null};async function step(){if(l||t[Y].backpressure&&(await c[Y].ready.promise,l))return!0;let n=e[Y].controller;if(e[Y].state===`readable`&&_i(n)&&n[Y].queue.length>0){for(;n[Y].queue.length>0;){if(l)return!0;let r=dequeueValue(n);if(n[Y].closeRequested&&!n[Y].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),m.currentWrite=writableStreamDefaultWriterWrite(c,r),setPromiseHandled(m.currentWrite),t[Y].backpressure||t[Y].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[Y].state===`closed`}let{promise:r,resolve:i,reject:o}=Promise.withResolvers();return g={resolve:i,reject:o},readableStreamDefaultReaderRead(s,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(o!==void 0){if(o.aborted)return abortAlgorithm(),u;h=abortAlgorithm,o.addEventListener(`abort`,h,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,s[Y].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,c[Y].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,s[Y].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(c));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[Y].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return u}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,o=!1,s,c,l,u,d=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[li](e){oe(()=>{r=!1;let n=e,s=e;if(!o&&t)try{s=structuredClone(s)}catch{}i||readableStreamDefaultControllerEnqueue(l[Y].controller,n),o||readableStreamDefaultControllerEnqueue(u[Y].controller,s)})},[ci](){oe(()=>{r=!1,i||readableStreamDefaultControllerClose(l[Y].controller),o||readableStreamDefaultControllerClose(u[Y].controller),(!i||!o)&&d.resolve(void 0)})},[ui](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,s=t,o){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}function cancel2Algorithm(t){if(o=!0,c=t,i){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}return l=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),u=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[Y].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(l[Y].controller,e),readableStreamDefaultControllerError(u[Y].controller,e),(!i||!o)&&d.resolve(void 0)}),[l,u]}var BYOBReadIntoRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](e){this[Y].resolve?.({value:e,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamBYOBReader=class{[Zr]=`ReadableStreamBYOBReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!bi(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 o=e[Symbol.toStringTag];if(o!==void 0&&o!==`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[Y].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let s=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,s),s.promise}releaseLock(){if(!bi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return bi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return bi(this)?this[Y].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{[Zr]=`ReadableStreamBYOBRequest`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get view(){if(!xi(this))throw TypeError(`Invalid this`);return this[Y].view}respond(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Y].controller,e)}respondWithNewView(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[Zr]=`ReadableByteStreamController`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!yi(this))throw TypeError(`Invalid this`);if(this[Y].closeRequested)throw TypeError(`Close already requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!yi(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[Y].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!yi(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[si](e){return readableByteStreamControllerCancelSteps(this,e)}[di](e){readableByteStreamControllerPullSteps(this,e)}[fi](){if(this[Y].pendingPullIntos.length>0){let e=this[Y].pendingPullIntos[0];e.readerType=`none`,this[Y].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const yi=isBrandCheck(`ReadableByteStreamController`),bi=isBrandCheck(`ReadableStreamBYOBReader`),xi=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Y].reader[Y].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[Y].reader[Y].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readIntoRequests.shift();n?i[ci](t):i[li](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!yi(t[Y].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[Y].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[Y];i[Y].disturbed=!0,i[Y].state===`errored`?r[ui](i[Y].storedError):readableByteStreamControllerPullInto(i[Y].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[Y].readIntoRequests.length;n++)e[Y].readIntoRequests[n][ui](t);e[Y].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[Y].byobRequest;t!=null&&(t[Y].controller=void 0,t[Y].view=null,e[Y].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[Y].stream[Y].state;return t===`errored`?null:t===`closed`?0:e[Y].highWaterMark-e[Y].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[Y];if(t[Y].state!==`readable`||e[Y].closeRequested||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[Y].queueTotalSize===0&&e[Y].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[Y].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[Y].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[Y].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[Y].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[Y].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,o=!1,s=r-r%t.elementSize;s>=t.minimumFill&&(i=s-t.bytesFilled,o=!0);let c=e[Y].queue;for(;i>0;){let n=c[0],r=Math.min(i,n.byteLength),o=t.byteOffset+t.bytesFilled,s=new Uint8Array(t.buffer,o,r),l=new Uint8Array(n.buffer,n.byteOffset,r);s.set(l),n.byteLength===r?c.shift():(n.byteOffset+=r,n.byteLength-=r),e[Y].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return o}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[Y].queue.shift();e[Y].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[li](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[Y].stream[Y].reader;for(;t[Y].readRequests.length!==0;){if(e[Y].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[Y].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Y].pendingPullIntos.length!==0;){if(e[Y].queueTotalSize===0)return;let t=e[Y].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Y].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Y].byobRequest===null&&e[Y].pendingPullIntos.length!==0){let t=e[Y].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest(pi);r[Y]={controller:e,view:n},e[Y].byobRequest=r}return e[Y].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[Y];if(e[Y].closeRequested||n[Y].state!==`readable`)return;let r=t.buffer,i=t.byteLength,o=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let s=transferArrayBuffer(r);if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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,s,o,i):(e[Y].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(s,o,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[Y];if(!(e[Y].closeRequested||t[Y].state!==`readable`)){if(e[Y].queueTotalSize>0){e[Y].closeRequested=!0;return}if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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[Y].stream,o=t[Symbol.toStringTag],s,c;if(o===void 0||o===`DataView`)s=DataView,c=1;else{let e=typedArrayConstructorByTag(o);if(!e){r[ui](TypeError(`Unsupported typed array: ${o}`));return}s=e,c=elementSizeByTag(o)}let l=t.buffer,u=t.byteLength,d=t.byteOffset,p=n*c,m;try{m=transferArrayBuffer(l)}catch(e){r[ui](e);return}let h={buffer:m,bufferByteLength:m.byteLength,byteOffset:d,byteLength:u,bytesFilled:0,minimumFill:p,elementSize:c,viewConstructor:s,readerType:`byob`};if(e[Y].pendingPullIntos.length!==0){e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r);return}if(i[Y].state===`closed`){let e=new s(h.buffer,h.byteOffset,0);r[ci](e);return}if(e[Y].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,h)){let t=readableByteStreamControllerConvertPullIntoDescriptor(h);readableByteStreamControllerHandleQueueDrain(e),r[li](t);return}if(e[Y].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[ui](t);return}}e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[Y].pendingPullIntos[0];if(e[Y].stream[Y].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[Y].pendingPullIntos[0],r=e[Y].stream[Y].state,i=t.byteLength,o=t.byteOffset,s=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!==o)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==s.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(s),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[Y].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].stream[Y].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[Y].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[Y].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[Y].stream;if(e[Y].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[Y].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[ui](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Y].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:s},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController(pi),i=t?.start,o=t?.pull,s=t?.cancel,c=t?.autoAllocateChunkSize;if(c!==void 0&&(c===0||!Number.isInteger(c)||c<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,c)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,o,s,c=Promise.withResolvers(),l,u,d,p;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||d.close(),i||p.close();return}let t=e.value,o=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||d.enqueue(o),i||p.enqueue(new Uint8Array(o))},()=>{}),Promise.resolve())}return l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,o=t,i){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),u=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,s=t,r){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),d=l[Y].controller,p=u[Y].controller,t.closed.catch(e=>{d.error(e),p.error(e),(!r||!i)&&c.resolve()}),[l,u]}const Si=Symbol(`kSkipThrow`);var TransformStream=class{[Zr]=`TransformStream`;[Y];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,o=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let s=extractHighWaterMark(n?.highWaterMark,0),c=extractSizeAlgorithm(n?.size),l=extractHighWaterMark(t?.highWaterMark,1),u=extractSizeAlgorithm(t?.size),d=Promise.withResolvers();initializeTransformStream(this,d,l,u,s,c),setupTransformStreamDefaultControllerFromTransformer(this,e),o===void 0?d.resolve():d.resolve(o.call(e,this[Y].controller))}get readable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].readable}get writable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[Zr]=`TransformStreamDefaultController`;[Y];constructor(e){if(e!==Si)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!wi(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y],{readable:t}=e[Y],n=t[Y].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Ci=isBrandCheck(`TransformStream`),wi=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,o){let startAlgorithm=()=>t.promise,s=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[Y]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,o),writable:s,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[Y];readableStreamDefaultControllerError(n[Y].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[Y];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Y].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[Y].backpressureChange.promise!==void 0&&e[Y].backpressureChange.resolve?.(),e[Y].backpressureChange=Promise.withResolvers(),e[Y].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[Y]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[Y].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(Si),r=t?.transform,i=t?.flush,o=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,o?createPromiseCallback(`transformer.cancel`,o,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Y].transformAlgorithm=void 0,e[Y].flushAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[Y],{readable:r}=n[Y],i=r[Y].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[Y].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[Y].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[Y].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[Y].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[Y].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[Y],{readable:n}=t[Y];readableStreamDefaultControllerClose(n[Y].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[Y];return e[Y].backpressure?e[Y].backpressureChange.promise.then(()=>{let{writable:r}=e[Y];if(r[Y].state===`erroring`)throw r[Y].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(readableStreamDefaultControllerError(r[Y].controller,t),o())},e=>{readableStreamDefaultControllerError(r[Y].controller,e),s(e)}),n[Y].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:r,resolve:i,reject:o}=Promise.withResolvers();n[Y].finishPromise=r;let s=n[Y].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{t[Y].state===`errored`?o(t[Y].storedError):(readableStreamDefaultControllerClose(t[Y].controller),i())},e=>{readableStreamDefaultControllerError(t[Y].controller,e),o(e)}),n[Y].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Y].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),o())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),s(t)}),n[Y].finishPromise}const Ti=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),Ei=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 Ti}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 Ei}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 Di=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),Di)this.#t=new TransformStream({transform:(e,t)=>{let n=toUint8Array$3(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$3(t),i;e.length>0?(i=new Uint8Array(e.length+r.length),i.set(e,0),i.set(r,e.length)):i=r;let o=incompleteUtf8Tail$1(i),s;if(o>0?(s=i.slice(0,i.length-o),e=i.slice(i.length-o)):(s=i,e=new Uint8Array),s.length>0){let e=this.#e.decode(s);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$3(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$3,`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 Oi=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,ki=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Ai=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,ji=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Mi=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Ni=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,Pi=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Fi,Ii=__esmMin(()=>{Fi=r}),X,Z=__esmMin(()=>{Ii(),X=Fi});function getGioFormat(e){switch(e){case`gzip`:return X.ZlibCompressorFormat.GZIP;case`deflate`:return X.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return X.ZlibCompressorFormat.RAW}}function concat$2(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function assertLevel(e){if(!(e>=-1&&e<=9))throw RangeError(`The value of "level" is out of range. It must be >= -1 and <= 9. Received ${e}`)}function compressWithGio(e,t,n=-1){assertLevel(n);let r=new X.ZlibCompressor({format:getGioFormat(t),level:Math.trunc(n)}),i=new X.ConverterOutputStream({base_stream:X.MemoryOutputStream.new_resizable(),converter:r});i.write_bytes(new W.Bytes(e),null),i.close(null);let o=i.get_base_stream().steal_as_bytes();return new Uint8Array(o.get_data()??[])}function decompressStreamWithGio(e,t){let n=new X.ZlibDecompressor({format:getGioFormat(t)}),r=X.MemoryInputStream.new_from_bytes(new W.Bytes(e)),i=new X.ConverterInputStream({base_stream:r,converter:n}),o=[];for(;;){let e=i.read_bytes(Ri,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}return i.close(null),concat$2(o)}function findGzipMemberEnd(e){let t=new X.ZlibDecompressor({format:X.ZlibCompressorFormat.GZIP}),n=new Uint8Array(262144),r=0;for(;;){let i=e.subarray(r,r+Li);try{let[e,o,s]=t.convert(i,n,X.ConverterFlags.NONE);if(r+=o,e===X.ConverterResult.FINISHED||o===0&&s===0)return r}catch{return r}}}function gunzipWithGio(e){let t=[],n=0;for(;n<e.length&&!(e.length-n<2||e[n]!==31||e[n+1]!==139);){let r=e.subarray(n),i=findGzipMemberEnd(r);if(i<=0)break;t.push(decompressStreamWithGio(r.subarray(0,i),`gzip`)),n+=i}return t.length===0?decompressStreamWithGio(e,`gzip`):concat$2(t)}var Li,Ri,zi=__esmMin(()=>{Z(),G(),Li=256*1024,Ri=1024*1024,__name(concat$2,`concat`)}),Bi=__esmMin(()=>{P()}),Vi,Hi,Ui=__esmMin(()=>{Vi=Object.defineProperty,Hi=__name((e,t)=>{let n={};for(var r in e)Vi(n,r,{get:e[r],enumerable:!0});return t||Vi(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)});function _setPipeImpl(e){Wi=e}var Wi,Stream_,Gi=__esmMin(()=>{Kn(),Stream_=class extends K{constructor(e){super(e)}pipe(e,t){return Wi(this,e,t)}}});function finished$1(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 o=e,s=typeof e.write==`function`,c=typeof e.read==`function`,l=o.writableFinished===!0,u=o.readableEnded===!0;if(o.destroyed===!0){let e=o._err;oe(e?()=>done(e):s&&l||c&&u?()=>done():()=>done(Error(`premature close`)))}else(s&&!c&&l||!s&&c&&u||s&&c&&l&&u)&&oe(()=>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 Ki=__esmMin(()=>{Gi(),P(),__name(finished$1,`finished`)});function getDefaultHighWaterMark(e){return e?Ji:qi}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Ji=t:qi=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 qi,Ji,Yi=__esmMin(()=>{qi=16384,Ji=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$1(e,e=>{e&&e!==n?r(e):t()})})}var Xi,Zi=__esmMin(()=>{Ki(),Xi=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 Qi,$i,ea,ta=__esmMin(()=>{Gi(),Zi(),Yi(),P(),Qi=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;_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._destroy=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.listenerCount(`readable`)===0&&this.resume(),e===`readable`&&(this.readableFlowing=!1,this._buffer.length>0||this._readableState.ended?this._scheduleReadable():this._readableState.reading||nextTick(()=>{this.destroyed||this.read(0)})),this}removeListener(e,t){let n=super.removeListener(e,t);return e===`readable`&&nextTick(()=>this._updateReadableListening()),n}removeAllListeners(e){let t=e===void 0?super.removeAllListeners():super.removeAllListeners(e);return(e===`readable`||e===void 0)&&nextTick(()=>this._updateReadableListening()),t}_updateReadableListening(){this.listenerCount(`readable`)>0||(this.listenerCount(`data`)>0?this.resume():this.readableFlowing=null)}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){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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return 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,o=null;return e.on(`data`,e=>{if(i){let t=i;i=null,o=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,o=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,o){let t=o;i=null,o=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,o=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)}},Qi.prototype[Xi]=function(){return streamAsyncDispose(this,this.readableEnded)},$i=Object.getOwnPropertyDescriptor(Qi.prototype,`on`),ea=Object.getOwnPropertyDescriptor(Qi.prototype,`removeListener`),Object.defineProperty(Qi.prototype,"addListener",{...$i}),Object.defineProperty(Qi.prototype,"off",{...ea})});function writeAfterEndError(){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,e}var na=__esmMin(()=>{});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,ra=__esmMin(()=>{na(),Yi(),ta(),P(),Duplex_=class extends Qi{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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),o}_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.destroyed||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.destroyed||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,o=!1,ondrain=()=>{o=!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(),o||(o=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let s=!1,onend=()=>{s||(s=!0,i&&t.end())},onclose=()=>{if(!s&&(s=!0,i&&!(r instanceof Qi))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),o&&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 Qi&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var ia=__esmMin(()=>{Gi(),ta(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var aa,oa=__esmMin(()=>{na(),Gi(),Zi(),Yi(),P(),aa=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;_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._destroy=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){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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),o}_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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return this}},aa.prototype[Xi]=function(){return streamAsyncDispose(this,this.writableFinished)}}),sa,ca=__esmMin(()=>{ra(),P(),sa=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_,la=__esmMin(()=>{ca(),PassThrough_=class extends sa{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline$1(...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 o=r[0];for(let e=1;e<r.length;e++){let t=r[e];o.pipe(t),o.on(`error`,onError),o=t}let s=r[r.length-1];return s.on(`error`,onError),s.on(`finish`,()=>{n&&!i&&n(null)}),s}var ua=__esmMin(()=>{__name(pipeline$1,`pipeline`)});function pipeline(...e){return new Promise((t,n)=>{let cb=e=>{e?n(e):t()};pipeline$1(...e,cb)})}function finished(e,t){return new Promise((n,r)=>{t&&typeof t!=`function`?finished$1(e,t,e=>{e?r(e):n()}):finished$1(e,e=>{e?r(e):n()})})}var da,fa,pa=__esmMin(()=>{Ui(),Ki(),ua(),da=Hi({default:()=>fa,finished:()=>finished,pipeline:()=>pipeline}),fa={pipeline,finished}}),ma=__exportAll$5({Duplex:()=>va,PassThrough:()=>ba,Readable:()=>ga,Stream:()=>ha,Transform:()=>ya,Writable:()=>_a,addAbortSignal:()=>addAbortSignal,default:()=>xa,finished:()=>finished$1,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,"module.exports":()=>xa,pipeline:()=>pipeline$1,promises:()=>da,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),ha,ga,_a,va,ya,ba,xa,Sa=__esmMin(()=>{Bi(),Gi(),Ki(),Yi(),ta(),ra(),ia(),oa(),ca(),la(),ua(),pa(),ha=makeCallable(Stream_),ga=makeCallable(Qi),_a=makeCallable(aa),va=makeCallable(Duplex_),ya=makeCallable(sa),ba=makeCallable(PassThrough_),xa=Object.assign(ha,{Stream:ha,Readable:ga,Writable:_a,Duplex:va,Transform:ya,PassThrough:ba,pipeline:pipeline$1,finished:finished$1,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark,promises:da})});function toUint8Array$2(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function concat$1(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function createGzip(e){return new Gzip(e)}function createGunzip(e){return new Gunzip(e)}function createDeflate(e){return new Deflate(e)}function createInflate(e){return new Inflate(e)}function createDeflateRaw(e){return new DeflateRaw(e)}function createInflateRaw(e){return new InflateRaw(e)}function createUnzip(e){return new Unzip(e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}function createZstdCompress(e){let t=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}function createZstdDecompress(e){let t=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,Ca=__esmMin(()=>{zi(),Sa(),__name(toUint8Array$2,`toUint8Array`),__name(concat$1,`concat`),ZlibBase=class extends ya{_mode;_chunks=[];constructor(e,t){super(t),this._mode=e}_transform(e,t,n){this._chunks.push(toUint8Array$2(e)),n()}_flush(e){let t=concat$1(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(t))),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_run(e){let t=this._mode;switch(t.kind){case`compress`:return compressWithGio(e,t.format);case`decompress`:return decompressStreamWithGio(e,t.format);case`gunzip`:return gunzipWithGio(e);case`unzip`:return e.length>=2&&e[0]===31&&e[1]===139?gunzipWithGio(e):decompressStreamWithGio(e,`deflate`)}}},Gzip=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`gzip`},e)}},Gunzip=class extends ZlibBase{constructor(e){super({kind:`gunzip`},e)}},Deflate=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate`},e)}},Inflate=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate`},e)}},DeflateRaw=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate-raw`},e)}},InflateRaw=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate-raw`},e)}},Unzip=class extends ZlibBase{constructor(e){super({kind:`unzip`},e)}},BrotliCompress=class extends ya{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends ya{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends ya{constructor(){super();let e=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}},ZstdDecompress=class extends ya{constructor(){super();let e=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}}}),wa=__exportAll$5({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>Ea,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>Da,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function decompressWithGio(e,t){return t===`gzip`?gunzipWithGio(e):decompressStreamWithGio(e,t)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let o=r.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of r)s.set(e,c),c+=e.length;return s}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}function requestedLevel(e){let t=e?.level;if(!(t===void 0||t===-1))return assertLevel(t),t}async function compress(e,t,n){return n===void 0&&hasWebCompression()?compressWithWeb(e,t):compressWithGio(e,t,n)}async function decompress(e,t){if(hasWebCompression())try{return await decompressWithWeb(e,t)}catch(n){if(t!==`gzip`)throw n;return decompressWithGio(e,t)}return decompressWithGio(e,t)}function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`gzip`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate-raw`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array$1(e),`gzip`,t?.level??-1)}function gunzipSync(e,t){return decompressWithGio(toUint8Array$1(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate`,t?.level??-1)}function inflateSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate-raw`,t?.level??-1)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate-raw`)}function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),Ta)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),Ta)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}function zstdCompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdCompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdDecompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdDecompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdCompressSync(e,t){let n=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}function zstdDecompressSync(e,t){let n=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}var hasWebCompression,Ta,Ea,Da,Oa=__esmMin(()=>{zi(),Ca(),hasWebCompression=()=>globalThis.CompressionStream!==void 0,__name(toUint8Array$1,`toUint8Array`),Ta=new Uint8Array,Ea={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},Da={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:Ea}});const ka=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!ka.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const Aa=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let ja=!1,Ma,Na,Pa,Fa,Ia,La;async function loadZlib(){if(ja)return;let e=await Promise.resolve().then(()=>(Oa(),wa));Ma=e.gzipSync,Na=e.gunzipSync,Pa=e.deflateSync,Fa=e.inflateSync,Ia=e.deflateRawSync,La=e.inflateRawSync,ja=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Ma(e);case`deflate`:return e=>Pa(e);case`deflate-raw`:return e=>Ia(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Na(e);case`deflate`:return e=>Fa(e);case`deflate-raw`:return e=>La(e)}}function concatChunks(e){if(e.length===1)return e[0];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 n}let Ra,za;if(Aa)Ra=globalThis.CompressionStream,za=globalThis.DecompressionStream;else{let e=loadZlib();Ra=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getCompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}},za=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getDecompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}}}const Ba=globalThis;globalThis.CompressionStream===void 0&&(Ba.CompressionStream=Ra),globalThis.DecompressionStream===void 0&&(Ba.DecompressionStream=za);const Va=globalThis;globalThis.DOMException===void 0&&(Va.DOMException=V);const Ha=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(Ha.ByteLengthQueuingStrategy=ji),globalThis.CountQueuingStrategy===void 0&&(Ha.CountQueuingStrategy=Mi);const Ua=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`)||(Ua.ReadableStream=Oi),Ua.ReadableStreamBYOBReader===void 0&&(Ua.ReadableStreamBYOBReader=ReadableStreamBYOBReader),Ua.ReadableStreamBYOBRequest===void 0&&(Ua.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),Ua.ReadableByteStreamController===void 0&&(Ua.ReadableByteStreamController=ReadableByteStreamController),Ua.ReadableStreamDefaultController===void 0&&(Ua.ReadableStreamDefaultController=ReadableStreamDefaultController),Ua.ReadableStreamDefaultReader===void 0&&(Ua.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const Wa=globalThis;globalThis.TextEncoderStream===void 0&&(Wa.TextEncoderStream=Ni),globalThis.TextDecoderStream===void 0&&(Wa.TextDecoderStream=Pi);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=Ai}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=ki}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 Ga=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=Ga.slice(),i=[];for(let t=0;t<n;t++)i.push(e.slice(t*8,t*8+8));let o=new Uint8Array(16);for(let e=0;e<=5;e++)for(let s=1;s<=n;s++){o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),xorCounter(r,n*e+s),i[s-1]=c.slice(8,16)}let s=new Uint8Array((n+1)*8);s.set(r,0);for(let e=0;e<n;e++)s.set(i[e],(e+1)*8);return s}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 o=new Uint8Array(16);for(let e=5;e>=0;e--)for(let s=n;s>=1;s--){xorCounter(r,n*e+s),o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),i[s-1]=c.slice(8,16)}let s=!0;for(let e=0;e<8;e++)r[e]!==Ga[e]&&(s=!1);if(!s)throw new DOMException(`AES-KW: integrity check failed`,`OperationError`);let c=new Uint8Array(n*8);for(let e=0;e<n;e++)c.set(i[e],e*8);return c}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 Ka={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(e){let t=Ka[e.toUpperCase()]||Ka[e];if(!t)throw new V(`Unrecognized hash name: ${e}`,`NotSupportedError`);return t}const qa={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(e){let t=qa[e];if(!t)throw new V(`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 V(`Unsupported hash: ${e}`,`NotSupportedError`)}}__name(hashSize$1,`hashSize`);function validateUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Invalid key usage: ${n}`,`SyntaxError`);if(e.length===0)throw new V(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(e,t){if(!e.usages.includes(t))throw new V(`Key does not support the '${t}' usage`,`InvalidAccessError`)}const Ja=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ya=new Uint8Array(128);for(let e=0;e<64;e++)Ya[Ja.charCodeAt(e)]=e;function bytesToBase64(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],o=r+1<n?e[r+1]:0,s=r+2<n?e[r+2]:0;t+=Ja[i>>2&63],t+=Ja[(i<<4|o>>4)&63],t+=r+1<n?Ja[(o<<2|s>>6)&63]:`=`,t+=r+2<n?Ja[s&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|Ya[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`)}function checkAlgorithmMatch(e,t){if(e.algorithm.name.toUpperCase()!==t.toUpperCase())throw new V(`Key algorithm mismatch`,`InvalidAccessError`)}const Xa={Ed25519:{public:[`verify`],private:[`sign`]},X25519:{public:[],private:[`deriveKey`,`deriveBits`]}},Za={Ed25519:[48,42,48,5,6,3,43,101,112,3,33,0],X25519:[48,42,48,5,6,3,43,101,110,3,33,0]};function cfrgName(e){let t=e.toUpperCase();if(t===`ED25519`)return`Ed25519`;if(t===`X25519`)return`X25519`}function assertUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Unsupported key usage: ${n}`,`SyntaxError`)}function toArrayBuffer(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function keyObjectOf(e){return e._handle.keyObject}function cfrgGenerateKey(e,t,n,r){assertUsages(r,[...Xa[t].public,...Xa[t].private]);let i=r.filter(e=>Xa[t].private.includes(e));if(i.length===0)throw new V(`Usages cannot be empty when creating a key.`,`SyntaxError`);let o=r.filter(e=>Xa[t].public.includes(e)),{publicKey:s,privateKey:c}=e.generateKeyPairSync(t.toLowerCase());return{publicKey:new CryptoKey(`public`,!0,{name:t},o,{keyObject:s}),privateKey:new CryptoKey(`private`,n,{name:t},i,{keyObject:c})}}function validateJwk(e,t,n,r){if(typeof e!=`object`||!e)throw new V(`Invalid keyData`,`DataError`);if(e.kty!==`OKP`)throw new V(`Invalid JWK "kty" Parameter`,`DataError`);if(e.crv!==t)throw new V(`JWK "crv" Parameter and algorithm name mismatch`,`DataError`);if(t===`Ed25519`&&e.alg!==void 0&&e.alg!==`Ed25519`&&e.alg!==`EdDSA`)throw new V(`JWK "alg" does not match the requested algorithm`,`DataError`);let i=t===`X25519`?`enc`:`sig`;if(r.length>0&&e.use!==void 0&&e.use!==i)throw new V(`Invalid JWK "use" Parameter`,`DataError`);if(e.key_ops!==void 0){if(!Array.isArray(e.key_ops))throw new V(`Invalid JWK "key_ops" Parameter`,`DataError`);for(let t of r)if(!e.key_ops.includes(t))throw new V(`Key operations and usage mismatch`,`DataError`)}if(e.ext===!1&&n)throw new V(`JWK "ext" Parameter and extractable mismatch`,`DataError`);if(typeof e.x!=`string`||e.d!==void 0&&typeof e.d!=`string`)throw new V(`Invalid keyData`,`DataError`)}function cfrgImportKey(e,t,n,r,i,o){let s,c,importOrDataError=e=>{try{return e()}catch(e){throw new V(`Invalid keyData: ${e.message}`,`DataError`)}};switch(t){case`raw`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);if(t.length!==32)throw new V(`Invalid keyData`,`DataError`);let i=new Uint8Array(44);i.set(Za[r],0),i.set(t,12),s=importOrDataError(()=>e.createPublicKey({key:i,format:`der`,type:`spki`})),c=`public`;break}case`spki`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);s=importOrDataError(()=>e.createPublicKey({key:t,format:`der`,type:`spki`})),c=`public`;break}case`pkcs8`:{assertUsages(o,Xa[r].private);let t=toUint8Array(n);s=importOrDataError(()=>e.createPrivateKey({key:t,format:`der`,type:`pkcs8`})),c=`private`;break}case`jwk`:{let t=n;if(validateJwk(t,r,i,o),c=t.d===void 0?`public`:`private`,assertUsages(o,Xa[r][c]),c===`private`){if(s=importOrDataError(()=>e.createPrivateKey({key:t,format:`jwk`})),e.createPublicKey(s).export({format:`jwk`}).x!==t.x)throw new V(`Invalid JWK: "x" does not match "d"`,`DataError`)}else{if(base64urlDecode(t.x).length!==32)throw new V(`Invalid keyData`,`DataError`);s=importOrDataError(()=>e.createPublicKey({key:t,format:`jwk`}))}break}default:throw new V(`Unsupported format: ${t}`,`NotSupportedError`)}if(s.asymmetricKeyType!==r.toLowerCase())throw new V(`Invalid key type`,`DataError`);if(c===`private`&&o.length===0)throw new V(`Usages cannot be empty when importing a private key.`,`SyntaxError`);return new CryptoKey(c,i,{name:r},o,{keyObject:s})}function wrongKindForFormat(e,t){return new V(`Unable to export ${e.algorithm.name} ${e.type} key using ${t} format`,`InvalidAccessError`)}function cfrgExportKey(e,t){let n=keyObjectOf(t);switch(e){case`raw`:{if(t.type!==`public`)throw new V(`Unable to export ${t.algorithm.name} ${t.type} key using ${e} format`,`NotSupportedError`);let r=n.export({format:`jwk`}).x;return toArrayBuffer(base64urlDecode(r))}case`spki`:if(t.type!==`public`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`spki`}));case`pkcs8`:if(t.type!==`private`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`pkcs8`}));case`jwk`:{let e=n.export({format:`jwk`}),r={kty:`OKP`,crv:t.algorithm.name,x:e.x};return t.type===`private`&&(r.d=e.d),t.algorithm.name===`Ed25519`&&(r.alg=`Ed25519`),r.key_ops=[...t.usages],r.ext=t.extractable,r}default:throw new V(`Unsupported export format: ${e}`,`NotSupportedError`)}}function ed25519Sign$1(e,t,n){if(t.type!==`private`)throw new V(`Key must be a private key`,`InvalidAccessError`);return toArrayBuffer(e.sign(null,n,keyObjectOf(t)))}__name(ed25519Sign$1,`ed25519Sign`);function ed25519Verify$1(e,t,n,r){if(t.type!==`public`)throw new V(`Key must be a public key`,`InvalidAccessError`);return e.verify(null,r,keyObjectOf(t),n)}__name(ed25519Verify$1,`ed25519Verify`);function x25519DeriveBits(e,t,n,r){if(t.type!==`private`)throw new V(`baseKey must be a private key`,`InvalidAccessError`);if(!(n instanceof CryptoKey)||n.type!==`public`)throw new V(`algorithm.public must be a public key`,`InvalidAccessError`);if(n.algorithm.name!==t.algorithm.name)throw new V(`The public and private keys must be of the same type`,`InvalidAccessError`);let i;try{i=new Uint8Array(e.diffieHellman({privateKey:keyObjectOf(t),publicKey:keyObjectOf(n)}))}catch(e){throw new V(`Deriving bits failed: ${e.message}`,`OperationError`)}if(r==null)return toArrayBuffer(i);if(r>i.length*8)throw new V(`derived bit length is too small`,`OperationError`);let o=i.slice(0,Math.ceil(r/8));return r%8!=0&&(o[o.length-1]&=255<<8-r%8),toArrayBuffer(o)}var Qa,$a=__esmMin(()=>{Qa={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 eo=__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([to[n[1]]^ro[e/t-1],to[n[2]],to[n[3]],to[n[0]]]):t>6&&e%t===4&&(n=new Uint8Array([to[n[0]],to[n[1]],to[n[2]],to[n[3]]])),i[e]=new Uint8Array(4);for(let r=0;r<4;r++)i[e][r]=i[e-t][r]^n[r]}let o=[];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];o.push(t)}return o}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]=to[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],o=n[6];n[2]=n[10],n[6]=n[14],n[10]=i,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<4;e++){let t=e*4,r=n[t],i=n[t+1],o=n[t+2],s=n[t+3];n[t]=gmul(2,r)^gmul(3,i)^o^s,n[t+1]=r^gmul(2,i)^gmul(3,o)^s,n[t+2]=r^i^gmul(2,o)^gmul(3,s),n[t+3]=gmul(3,r)^i^o^gmul(2,s)}for(let r=0;r<16;r++)n[r]^=t[e][r]}for(let e=0;e<16;e++)n[e]=to[n[e]];let i=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=i;let o=n[2],s=n[6];n[2]=n[10],n[6]=n[14],n[10]=o,n[14]=s;let c=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=c;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],o=n[14];n[10]=n[2],n[14]=n[6],n[2]=i,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]=no[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],o=n[t+2],s=n[t+3];n[t]=gmul(14,r)^gmul(11,i)^gmul(13,o)^gmul(9,s),n[t+1]=gmul(9,r)^gmul(14,i)^gmul(11,o)^gmul(13,s),n[t+2]=gmul(13,r)^gmul(9,i)^gmul(14,o)^gmul(11,s),n[t+3]=gmul(11,r)^gmul(13,i)^gmul(9,o)^gmul(14,s)}}let i=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=i;let o=n[10],s=n[14];n[10]=n[2],n[14]=n[6],n[2]=o,n[6]=s;let c=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=c;for(let e=0;e<16;e++)n[e]=no[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,o=Math.min(i+16,t.length);for(let e=0;e<16;e++){let n=i+e;n<o&&(r[e]^=t[n])}let s=gfMul(r,e);r.set(s)}let o=Math.ceil(n.length/16)||0;for(let t=0;t<o;t++){let i=t*16,o=Math.min(i+16,n.length);for(let e=0;e<16;e++){let t=i+e;t<o&&(r[e]^=n[t])}let s=gfMul(r,e);r.set(s)}let s=new Uint8Array(16),c=t.length*8,l=n.length*8,u=Math.floor(c/4294967296),d=c>>>0;s[0]=u>>>24&255,s[1]=u>>>16&255,s[2]=u>>>8&255,s[3]=u&255,s[4]=d>>>24&255,s[5]=d>>>16&255,s[6]=d>>>8&255,s[7]=d&255;let p=Math.floor(l/4294967296),m=l>>>0;s[8]=p>>>24&255,s[9]=p>>>16&255,s[10]=p>>>8&255,s[11]=p&255,s[12]=m>>>24&255,s[13]=m>>>16&255,s[14]=m>>>8&255,s[15]=m&255;for(let e=0;e<16;e++)r[e]^=s[e];let h=gfMul(r,e);return r.set(h),r}var to,no,ro,io=__esmMin(()=>{to=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]),no=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]),ro=[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`?H.from(e,t||`utf8`):H.from(e)}function encodeOutput(e,t){return t?H.from(e).toString(t):H.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 ao=__esmMin(()=>{U(),__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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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,oo=__esmMin(()=>{io(),ao(),U(),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 H.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 o=Math.floor(i.length/16)*16,s=[];for(let e=0;e<o;e+=16){let t=i.slice(e,e+16);s.push(this._encryptBlock(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 encodeOutput(c,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];return this._gcmAuthTag=H.from(s),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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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=H.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 H.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 o=Math.floor(i.length/16);if(o===0)return this._buffer=i,this._encodeWithUtf8Handling(new Uint8Array,n,!1);let s=(this._autoPadding?o-1:o)*16,c=[];for(let e=0;e<s;e+=16){let t=i.slice(e,e+16);c.push(this._decryptBlock(t))}this._buffer=i.slice(s);let l=new Uint8Array(c.length*16);for(let e=0;e<c.length;e++)l.set(c[e],e*16);return this._encodeWithUtf8Handling(l,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];let c=this._gcmExpectedTag,l=Math.min(c.length,16),u=0;for(let e=0;e<l;e++)u|=s[e]^c[e];if(u!==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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];gcmIncrementCounter(this._counter)}return t}}});function pemToDer$1(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],o=t.findIndex((e,t)=>t>n&&e.startsWith(`-----END `));if(o===-1)throw Error(`Invalid PEM: no END line found`);let s=t.slice(n+1,o).join(``),c=H.from(s,`base64`);return{type:i,der:new Uint8Array(c.buffer,c.byteOffset,c.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 o=e.slice(t,t+r),s=t+r,c={tag:n,data:o};return n===48&&(c.children=parseSequenceChildren(o)),{value:c,next:s}}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 okpCurveForOid(e){if(oidsEqual(e,lo))return`ed25519`;if(oidsEqual(e,co))return`x25519`}function oidForOkpCurve(e){return e===`ed25519`?lo:co}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 algorithmOid(e){let t=e?.children?.[0];if(!t||t.tag!==6)throw Error(`Invalid AlgorithmIdentifier`);if(okpCurveForOid(t.data)&&(e?.children?.length??0)!==1)throw Error(`Invalid AlgorithmIdentifier: parameters must be absent (RFC 8410)`);return t.data}function parseSubjectPublicKeyInfo(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let n=algorithmOid(t[0]),r=t[1];if(r.tag!==3||r.data[0]!==0)throw Error(`Expected BIT STRING for public key data`);let i=r.data.slice(1),o=okpCurveForOid(n);if(o){if(i.length!==32)throw Error(`Invalid ${o} public key length: ${i.length}`);return{type:`okp-public`,curve:o,pub:i}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(parseDer(i))}}function parsePrivateKeyInfo(e){let t=e.children;if(!t||t.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let n=algorithmOid(t[1]),r=t[2];if(r.tag!==4)throw Error(`Expected OCTET STRING for private key data`);let i=okpCurveForOid(n);if(i){let e=parseDer(r.data);if(e.tag!==4||e.data.length!==32)throw Error(`Invalid ${i} private key`);return{type:`okp-private`,curve:i,priv:e.data}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(parseDer(r.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(so),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(e))])}function encodeRsaPrivateKeyPkcs1(e){let t=e.d%(e.p-1n),n=e.d%(e.q-1n),r=modInverse$2(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(so),encodeNull()]),n=encodeOctetString(encodeRsaPrivateKeyPkcs1(e));return encodeSequence([bigintToAsn1Integer(0n),t,n])}function encodeOkpSubjectPublicKeyInfo(e,t){return encodeSequence([encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeBitString(t)])}function encodeOkpPrivateKeyInfo(e,t){return encodeSequence([bigintToAsn1Integer(0n),encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeOctetString(encodeOctetString(t))])}function derToPem(e,t){let n=H.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(`
|
|
11
|
+
`,`\r`,` `,`#`,`/`,`:`,`<`,`>`,`?`,`@`,`[`,`\\`,`]`,`^`,`|`]),J=class URL{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;constructor(e,t){let n=e instanceof URL?e.href:String(e),r;try{if(t!==void 0){let e=t instanceof URL?t.href:String(t);r=W.Uri.parse(e,Nr).parse_relative(n,Nr)}else r=W.Uri.parse(n,Nr)}catch{throw TypeError(`Invalid URL: ${n}`)}if(!r)throw TypeError(`Invalid URL: ${n}`);this.#e=r.get_scheme();let i=isSpecialScheme(this.#e);this.#t=r.get_user()??``,this.#n=r.get_password()??``;let o=r.get_host(),s=o===null?null:bracketIPv6Host(o.toLowerCase());this.#r=s===null?i?``:null:this.#e===`file`&&s===`localhost`?``:s;let c=r.get_port();this.#i=c===-1||c===defaultPort(this.#e)?null:c,this.#a=r.get_path()??``,i&&this.#a===``&&(this.#a=`/`),this.#o=this.#r===null&&!this.#a.startsWith(`/`),this.#r===null&&!this.#o&&this.#a.startsWith(`/.//`)&&(this.#a=this.#a.slice(2)),this.#s=r.get_fragment()??null,this.#l=r.get_query()??null,this.#c=new Fr,this.#c._entries=parseFormUrlencoded(this.#l??``),Pr.set(this.#c,()=>{let e=this.#c.toString();this.#l=e===``?null:e})}get protocol(){return this.#e+`:`}set protocol(e){let t=String(e).replace(Rr,``)+`:`;if(!/^[A-Za-z]/.test(t))return;let n=``;for(let e of t){if(e===`:`)break;if(!isSchemeChar(e))return;n+=e.toLowerCase()}isSpecialScheme(this.#e)===isSpecialScheme(n)&&(n===`file`&&(this.#t!==``||this.#n!==``||this.#i!==null)||this.#e===`file`&&(this.#r===null||this.#r===``)||(this.#e=n,this.#i!==null&&this.#i===defaultPort(n)&&(this.#i=null)))}get hostname(){return this.#r??``}set hostname(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!0);t!==void 0&&(this.#r=t.host)}get port(){return this.#i===null?``:String(this.#i)}set port(e){if(this.#u())return;let t=String(e);if(t===``){this.#i=null;return}let n=digitPrefix(t.replace(Rr,``));if(n===``)return;let r=Number(n);r>65535||(this.#i=r===defaultPort(this.#e)?null:r)}get host(){let e=this.hostname,t=this.port;return t?`${e}:${t}`:e}set host(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!1);t!==void 0&&(this.#r=t.host,t.port!==void 0&&(this.#i=t.port))}get pathname(){return this.#a}set pathname(e){this.#o||(this.#a=parsePathSetterValue(String(e),isSpecialScheme(this.#e),this.#r===null))}get search(){return this.#l?`?`+this.#l:``}set search(e){let t=String(e);if(t===``){this.#l=null,this.#c._entries=[];return}let n=(t.startsWith(`?`)?t.slice(1):t).replace(Rr,``);this.#l=encodeQuery(n,isSpecialScheme(this.#e)),this.#c._entries=parseFormUrlencoded(n)}get hash(){return this.#s?`#`+this.#s:``}set hash(e){let t=String(e);if(t===``){this.#s=null;return}let n=(t.startsWith(`#`)?t.slice(1):t).replace(Rr,``);this.#s=percentEncode(n,'"<>`')}get origin(){return isSpecialScheme(this.#e)&&this.#e!==`file`?`${this.protocol}//${this.host}`:`null`}get username(){return this.#t}set username(e){this.#u()||(this.#t=percentEncode(String(e),Lr))}get password(){return this.#n}set password(e){this.#u()||(this.#n=percentEncode(String(e),Lr))}#u(){return this.#r===null||this.#r===``||this.#e===`file`}get href(){let e=this.#e+`:`;return this.#r===null?!this.#o&&this.#a.startsWith(`//`)&&(e+=`/.`):(e+=`//`,(this.#t!==``||this.#n!==``)&&(e+=this.#t,this.#n!==``&&(e+=`:`+this.#n),e+=`@`),e+=this.#r,this.#i!==null&&(e+=`:`+this.#i)),e+=this.#a,e+=this.#l===null?``:`?${this.#l}`,e+=this.#s===null?``:`#${this.#s}`,e}set href(e){let t=new URL(String(e));this.#e=t.#e,this.#t=t.#t,this.#n=t.#n,this.#r=t.#r,this.#i=t.#i,this.#a=t.#a,this.#o=t.#o,this.#l=t.#l,this.#s=t.#s,this.#c._entries=parseFormUrlencoded(this.#l??``)}get searchParams(){return this.#c}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&&(W.unlink(t),URL._objectURLPaths.delete(e))}},__name(parse$1,`parse`),__name(format$1,`format`),Br={URL:J,URLSearchParams:Fr,parse:parse$1,format:format$1,resolve,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});Vr(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:J,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:Fr,enumerable:!1,writable:!0,configurable:!0});let Hr;if(globalThis.performance)Hr=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();Hr={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,o=_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&&(o=e.startTime)}let s={name:e,entryType:`measure`,startTime:i,duration:o-i};return t.push(s),s},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}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const Ur=globalThis,Wr=Ur.PerformanceObserver||PerformanceObserverStub;Ur.PerformanceEntry,Ur.PerformanceObserverEntryList,Ur.PerformanceMark,Ur.PerformanceMeasure;const Gr=globalThis;globalThis.performance===void 0&&(Gr.performance=Hr),typeof Gr.PerformanceObserver!=`function`&&(Gr.PerformanceObserver=Wr);const Kr=Symbol(`abort`),qr=Symbol(`internal`);var Jr=class AbortSignal extends EventTarget{#e=!1;#t=void 0;onabort=null;constructor(e){if(super(),e!==qr)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}[Kr](e){if(this.#e)return;this.#e=!0,this.#t=e??new V(`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(qr);return t[Kr](e),t}static timeout(e){let t=new AbortSignal(qr);return setTimeout(()=>{t[Kr](new V(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(qr);for(let n of e)if(n.aborted)return t[Kr](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Kr](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},Yr=class AbortController{signal;constructor(){this.signal=new Jr(qr)}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[Kr](e)}};const Xr=globalThis;globalThis.AbortController===void 0&&(Xr.AbortController=Yr),globalThis.AbortSignal===void 0&&(Xr.AbortSignal=Jr);const Y=Symbol(`kState`),Zr=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[Y]!==void 0&&t[Zr]===e}function dequeueValue(e){let t=e[Y].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[Y].queueTotalSize=Math.max(0,e[Y].queueTotalSize-r),n}function resetQueue(e){e[Y].queue=[],e[Y].queueTotalSize=0}function peekQueueValue(e){return e[Y].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[Y].queue.push({value:t,size:n}),e[Y].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 Qr={__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 $r=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}},ei=Symbol(`kAbort`),ti=Symbol(`kCloseSentinel`),ni=Symbol(`kError`),ri=Symbol(`kSkipThrow`);var WritableStream=class{[Zr]=`WritableStream`;[Y];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[Y]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!ii(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return ii(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return ii(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(!ii(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[Zr]=`WritableStreamDefaultWriter`;[Y];constructor(e){if(!ii(e))throw TypeError(`Expected a WritableStream`);this[Y]={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 ai(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!ai(this))throw TypeError(`Invalid this`);if(this[Y].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return ai(this)?this[Y].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return ai(this)?this[Y].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!ai(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Y];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(!ai(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return ai(this)?this[Y].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{[Zr]=`WritableStreamDefaultController`;[Y];constructor(e){if(e!==ri)throw TypeError(`Illegal constructor`)}[ei](e){let t=this[Y].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[ni](){resetQueue(this)}get signal(){if(!oi(this))throw TypeError(`Invalid this`);return this[Y].abortController.signal}error(e){if(!oi(this))throw TypeError(`Invalid this`);this[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const ii=isBrandCheck(`WritableStream`),ai=isBrandCheck(`WritableStreamDefaultWriter`),oi=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[Y].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[Y].stream=t,t[Y].writer=e,t[Y].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[Y].backpressure?e[Y].ready=Promise.withResolvers():e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close=Promise.withResolvers();break;case`erroring`:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),setPromiseHandled(e[Y].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[Y];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[Y].abortController.abort(t),e[Y].pendingAbortRequest.abort.promise!==void 0)return e[Y].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let o=Promise.withResolvers();return e[Y].pendingAbortRequest={abort:o,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),o.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[Y];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Y].closeRequest=Promise.withResolvers();let{promise:o}=e[Y].closeRequest;return n!==void 0&&r&&t===`writable`&&n[Y].ready.resolve?.(),writableStreamDefaultControllerClose(i),o}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[Y];n!==void 0&&e[Y].backpressure!==t&&(t?n[Y].ready=Promise.withResolvers():n[Y].ready.resolve?.()),e[Y].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[Y];e[Y].state=`erroring`,e[Y].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[Y].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Y].closeRequest.promise!==void 0&&(e[Y].closeRequest.reject?.(e[Y].storedError),e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Y].close.promise),e[Y].close.reject?.(e[Y].storedError);let{writer:t}=e[Y];t!==void 0&&(setPromiseHandled(t[Y].close.promise),t[Y].close.reject?.(e[Y].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[Y].writeRequests.shift();e[Y].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[Y].inFlightCloseRequest=e[Y].closeRequest,e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Y].inFlightWriteRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[Y].inFlightWriteRequest.reject?.(t),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[Y].inFlightWriteRequest.resolve?.(),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[Y].inFlightCloseRequest.reject?.(t),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.reject?.(t),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[Y].inFlightCloseRequest.resolve?.(),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].state===`erroring`&&(e[Y].storedError=void 0,e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.resolve?.(),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Y].state=`closed`,e[Y].writer!==void 0&&e[Y].writer[Y].close.resolve?.(),e[Y].close.resolve?.()}function writableStreamFinishErroring(e){e[Y].state=`errored`,e[Y].controller[ni]();let t=e[Y].storedError;for(let n of e[Y].writeRequests)n.reject?.(t);if(e[Y].writeRequests=[],e[Y].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[Y].pendingAbortRequest;if(e[Y].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[Y].controller[ei](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[Y].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Y].closeRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[Y].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[Y],{controller:r}=n[Y],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[Y].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:o}=n[Y];if(o===`errored`)return Promise.reject(n[Y].storedError);if(writableStreamCloseQueuedOrInFlight(n)||o===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(o===`erroring`)return Promise.reject(n[Y].storedError);let s=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),s}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[Y],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[Y].writer=void 0,e[Y].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[Y];switch(t[Y].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[Y].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[Y].ready.reject?(e[Y].ready.reject(t),e[Y].ready.resolve=void 0,e[Y].ready.reject=void 0):e[Y].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[Y].close.reject?(e[Y].close.reject(t),e[Y].close.resolve=void 0,e[Y].close.reject=void 0):e[Y].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[Y],{state:n}=t[Y];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[Y].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Y].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[Y].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[Y];!writableStreamCloseQueuedOrInFlight(r)&&r[Y].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[Y];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[Y];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[Y].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[Y];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Y].highWaterMark-e[Y].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[Y];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Y].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,ti,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Y].writeAlgorithm=void 0,e[Y].closeAlgorithm=void 0,e[Y].abortAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[Y];if(!n||r[Y].inFlightWriteRequest.promise!==void 0)return;if(r[Y].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===ti?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(ri),o=t?.start,s=t?.write,c=t?.close,l=t?.abort;setupWritableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`sink.write`,s,t):nonOpWrite,c?createPromiseCallback(`sink.close`,c,t):nonOpCancel,l?createPromiseCallback(`sink.abort`,l,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,o,s,c){t[Y]={abortAlgorithm:o,closeAlgorithm:i,highWaterMark:s,queue:[],queueTotalSize:0,abortController:new $r,sizeAlgorithm:c,started:!1,stream:e,writeAlgorithm:r},e[Y].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let l=n();new Promise(e=>e(l)).then(()=>{t[Y].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[Y].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,o=()=>1){let s=Object.create(WritableStream.prototype);return s[Zr]=`WritableStream`,s[Y]=createWritableStreamState(),setupWritableStreamDefaultController(s,new WritableStreamDefaultController(ri),e,t,n,r,i,o),s}P();const si=Symbol(`kCancel`),ci=Symbol(`kClose`),li=Symbol(`kChunk`),ui=Symbol(`kError`),di=Symbol(`kPull`),fi=Symbol(`kRelease`),pi=Symbol(`kSkipThrow`);let mi,hi;function lazyReadableReleasedError(){return mi||(mi=TypeError(`Reader released`),mi)}function lazyReadableReleasingError(){return hi||(hi=TypeError(`Releasing reader`),hi)}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`)}[Zr]=`ReadableStream`;[Y];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[Y]=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(!gi(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return gi(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!gi(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(!gi(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!gi(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!ii(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,o=t?.preventCancel,s=t?.preventClose,c=t?.signal;if(c!==void 0&&!(c instanceof Object&&`aborted`in c))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,!!s,!!i,!!o,c)),n}pipeTo(e,t={}){try{if(!gi(this))throw TypeError(`Invalid this`);if(!ii(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,o=t?.signal;if(o!==void 0&&!(o instanceof Object&&`aborted`in o))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,o)}catch(e){return Promise.reject(e)}}tee(){if(!gi(this))throw TypeError(`Invalid this`);let e=this[Y].controller;return yi(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!gi(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[Y].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,{[li](e){r.current=void 0,t({value:e,done:!1})},[ci](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[ui](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[Y].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}},Qr)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](){this[Y].resolve?.({value:void 0,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamDefaultReader=class{[Zr]=`ReadableStreamDefaultReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!vi(this))return Promise.reject(TypeError(`Invalid this`));if(this[Y].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Y].stream,t=e[Y].controller;if(e[Y].state===`readable`&&_i(t)&&t[Y].queue.length>0){e[Y].disturbed=!0;let n=dequeueValue(t);return t[Y].closeRequested&&!t[Y].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(!vi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return vi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return vi(this)?this[Y].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{[Zr]=`ReadableStreamDefaultController`;[Y];constructor(e){if(e!==pi)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)}[si](e){return readableStreamDefaultControllerCancelSteps(this,e)}[di](e){readableStreamDefaultControllerPullSteps(this,e)}[fi](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const gi=isBrandCheck(`ReadableStream`),_i=isBrandCheck(`ReadableStreamDefaultController`),vi=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Y].reader!==void 0}function readableStreamCancel(e,t){switch(e[Y].disturbed=!0,e[Y].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Y].storedError)}readableStreamClose(e);let n=e[Y].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[Y].readIntoRequests;n[Y].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][ci](void 0)}return e[Y].controller[si](t).then(()=>{})}function readableStreamClose(e){e[Y].state=`closed`,e[Y].closedPromise.resolve();let{reader:t}=e[Y];if(t!==void 0&&(t[Y].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[Y].readRequests.length;e++)t[Y].readRequests[e][ci]();t[Y].readRequests=[]}}function readableStreamError(e,t){e[Y].state=`errored`,e[Y].storedError=t,setPromiseHandled(e[Y].closedPromise.promise),e[Y].closedPromise.reject(t);let{reader:n}=e[Y];if(n!==void 0){if(setPromiseHandled(n[Y].close.promise),n[Y].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[Y].readRequests.length;e++)n[Y].readRequests[e][ui](t);n[Y].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[Y].readIntoRequests.length;e++)n[Y].readIntoRequests[e][ui](t);n[Y].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Y].reader[Y].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readRequests.shift();n?i[ci]():i[li](t)}function readableStreamAddReadRequest(e,t){e[Y].reader[Y].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[Y];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[Y].stream=t,t[Y].reader=e,t[Y].state){case`readable`:e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[Y],n=lazyReadableReleasedError();t[Y].state===`readable`?e[Y].close.reject?.(n):e[Y].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise),t[Y].controller[fi](),t[Y].reader=void 0,e[Y].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[Y].readRequests.length;++n)e[Y].readRequests[n][ui](t);e[Y].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[Y];switch(n[Y].disturbed=!0,n[Y].state){case`closed`:t[ci]();break;case`errored`:t[ui](n[Y].storedError);break;case`readable`:n[Y].controller[di](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[Y].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Y].closeRequested=!0,e[Y].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[Y];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[Y].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[Y];return!e[Y].closeRequested&&t[Y].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[Y];switch(t[Y].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[Y];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[Y];if(r.length){let i=dequeueValue(e);e[Y].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[li](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:s,stream:e},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController(pi),o=t?.start,s=t?.pull,c=t?.cancel;setupReadableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`source.pull`,s,t):nonOpPull,c?createPromiseCallback(`source.cancel`,c,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let o=Object.create(ReadableStream$1.prototype);return o[Zr]=`ReadableStream`,o[Y]=createReadableStreamState(),setupReadableStreamDefaultController(o,new ReadableStreamDefaultController(pi),e,t,n,r,i),o}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[Y].controller):readableStreamDefaultControllerEnqueue(t[Y].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,o){let s,c;try{s=new ReadableStreamDefaultReader(e),c=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[Y].disturbed=!0;let l=!1,{promise:u,resolve:d,reject:p}=Promise.withResolvers(),m={currentWrite:Promise.resolve()},h;function finalize(e,t){writableStreamDefaultWriterRelease(c),readableStreamReaderGenericRelease(s),o!==void 0&&h&&(o.removeEventListener(`abort`,h),h=void 0),e?p(t):d()}async function waitForCurrentWrite(){let e=m.currentWrite;await e,e!==m.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(l)return;if(l=!0,t[Y].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(!l){if(l=!0,t[Y].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=o.reason&&o.reason.name===`AbortError`?createAbortError$1():o.reason;let s=[];r||s.push(()=>t[Y].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||s.push(()=>e[Y].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(s.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[Y].state===`errored`?n(e[Y].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[Y].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[li](e){oe(()=>{m.currentWrite=writableStreamDefaultWriterWrite(c,e),setPromiseHandled(m.currentWrite),g.resolve(!1)})}[ci](){g.resolve(!0)}[ui](e){g.reject(e)}}let g={resolve:null,reject:null};async function step(){if(l||t[Y].backpressure&&(await c[Y].ready.promise,l))return!0;let n=e[Y].controller;if(e[Y].state===`readable`&&_i(n)&&n[Y].queue.length>0){for(;n[Y].queue.length>0;){if(l)return!0;let r=dequeueValue(n);if(n[Y].closeRequested&&!n[Y].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),m.currentWrite=writableStreamDefaultWriterWrite(c,r),setPromiseHandled(m.currentWrite),t[Y].backpressure||t[Y].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[Y].state===`closed`}let{promise:r,resolve:i,reject:o}=Promise.withResolvers();return g={resolve:i,reject:o},readableStreamDefaultReaderRead(s,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(o!==void 0){if(o.aborted)return abortAlgorithm(),u;h=abortAlgorithm,o.addEventListener(`abort`,h,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,s[Y].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,c[Y].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,s[Y].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(c));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[Y].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return u}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,o=!1,s,c,l,u,d=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[li](e){oe(()=>{r=!1;let n=e,s=e;if(!o&&t)try{s=structuredClone(s)}catch{}i||readableStreamDefaultControllerEnqueue(l[Y].controller,n),o||readableStreamDefaultControllerEnqueue(u[Y].controller,s)})},[ci](){oe(()=>{r=!1,i||readableStreamDefaultControllerClose(l[Y].controller),o||readableStreamDefaultControllerClose(u[Y].controller),(!i||!o)&&d.resolve(void 0)})},[ui](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,s=t,o){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}function cancel2Algorithm(t){if(o=!0,c=t,i){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}return l=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),u=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[Y].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(l[Y].controller,e),readableStreamDefaultControllerError(u[Y].controller,e),(!i||!o)&&d.resolve(void 0)}),[l,u]}var BYOBReadIntoRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](e){this[Y].resolve?.({value:e,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamBYOBReader=class{[Zr]=`ReadableStreamBYOBReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!bi(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 o=e[Symbol.toStringTag];if(o!==void 0&&o!==`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[Y].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let s=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,s),s.promise}releaseLock(){if(!bi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return bi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return bi(this)?this[Y].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{[Zr]=`ReadableStreamBYOBRequest`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get view(){if(!xi(this))throw TypeError(`Invalid this`);return this[Y].view}respond(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Y].controller,e)}respondWithNewView(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[Zr]=`ReadableByteStreamController`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!yi(this))throw TypeError(`Invalid this`);if(this[Y].closeRequested)throw TypeError(`Close already requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!yi(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[Y].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!yi(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[si](e){return readableByteStreamControllerCancelSteps(this,e)}[di](e){readableByteStreamControllerPullSteps(this,e)}[fi](){if(this[Y].pendingPullIntos.length>0){let e=this[Y].pendingPullIntos[0];e.readerType=`none`,this[Y].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const yi=isBrandCheck(`ReadableByteStreamController`),bi=isBrandCheck(`ReadableStreamBYOBReader`),xi=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Y].reader[Y].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[Y].reader[Y].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readIntoRequests.shift();n?i[ci](t):i[li](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!yi(t[Y].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[Y].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[Y];i[Y].disturbed=!0,i[Y].state===`errored`?r[ui](i[Y].storedError):readableByteStreamControllerPullInto(i[Y].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[Y].readIntoRequests.length;n++)e[Y].readIntoRequests[n][ui](t);e[Y].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[Y].byobRequest;t!=null&&(t[Y].controller=void 0,t[Y].view=null,e[Y].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[Y].stream[Y].state;return t===`errored`?null:t===`closed`?0:e[Y].highWaterMark-e[Y].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[Y];if(t[Y].state!==`readable`||e[Y].closeRequested||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[Y].queueTotalSize===0&&e[Y].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[Y].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[Y].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[Y].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[Y].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[Y].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,o=!1,s=r-r%t.elementSize;s>=t.minimumFill&&(i=s-t.bytesFilled,o=!0);let c=e[Y].queue;for(;i>0;){let n=c[0],r=Math.min(i,n.byteLength),o=t.byteOffset+t.bytesFilled,s=new Uint8Array(t.buffer,o,r),l=new Uint8Array(n.buffer,n.byteOffset,r);s.set(l),n.byteLength===r?c.shift():(n.byteOffset+=r,n.byteLength-=r),e[Y].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return o}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[Y].queue.shift();e[Y].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[li](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[Y].stream[Y].reader;for(;t[Y].readRequests.length!==0;){if(e[Y].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[Y].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Y].pendingPullIntos.length!==0;){if(e[Y].queueTotalSize===0)return;let t=e[Y].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Y].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Y].byobRequest===null&&e[Y].pendingPullIntos.length!==0){let t=e[Y].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest(pi);r[Y]={controller:e,view:n},e[Y].byobRequest=r}return e[Y].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[Y];if(e[Y].closeRequested||n[Y].state!==`readable`)return;let r=t.buffer,i=t.byteLength,o=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let s=transferArrayBuffer(r);if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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,s,o,i):(e[Y].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(s,o,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[Y];if(!(e[Y].closeRequested||t[Y].state!==`readable`)){if(e[Y].queueTotalSize>0){e[Y].closeRequested=!0;return}if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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[Y].stream,o=t[Symbol.toStringTag],s,c;if(o===void 0||o===`DataView`)s=DataView,c=1;else{let e=typedArrayConstructorByTag(o);if(!e){r[ui](TypeError(`Unsupported typed array: ${o}`));return}s=e,c=elementSizeByTag(o)}let l=t.buffer,u=t.byteLength,d=t.byteOffset,p=n*c,m;try{m=transferArrayBuffer(l)}catch(e){r[ui](e);return}let h={buffer:m,bufferByteLength:m.byteLength,byteOffset:d,byteLength:u,bytesFilled:0,minimumFill:p,elementSize:c,viewConstructor:s,readerType:`byob`};if(e[Y].pendingPullIntos.length!==0){e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r);return}if(i[Y].state===`closed`){let e=new s(h.buffer,h.byteOffset,0);r[ci](e);return}if(e[Y].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,h)){let t=readableByteStreamControllerConvertPullIntoDescriptor(h);readableByteStreamControllerHandleQueueDrain(e),r[li](t);return}if(e[Y].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[ui](t);return}}e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[Y].pendingPullIntos[0];if(e[Y].stream[Y].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[Y].pendingPullIntos[0],r=e[Y].stream[Y].state,i=t.byteLength,o=t.byteOffset,s=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!==o)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==s.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(s),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[Y].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].stream[Y].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[Y].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[Y].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[Y].stream;if(e[Y].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[Y].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[ui](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Y].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:s},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController(pi),i=t?.start,o=t?.pull,s=t?.cancel,c=t?.autoAllocateChunkSize;if(c!==void 0&&(c===0||!Number.isInteger(c)||c<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,c)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,o,s,c=Promise.withResolvers(),l,u,d,p;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||d.close(),i||p.close();return}let t=e.value,o=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||d.enqueue(o),i||p.enqueue(new Uint8Array(o))},()=>{}),Promise.resolve())}return l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,o=t,i){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),u=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,s=t,r){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),d=l[Y].controller,p=u[Y].controller,t.closed.catch(e=>{d.error(e),p.error(e),(!r||!i)&&c.resolve()}),[l,u]}const Si=Symbol(`kSkipThrow`);var TransformStream=class{[Zr]=`TransformStream`;[Y];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,o=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let s=extractHighWaterMark(n?.highWaterMark,0),c=extractSizeAlgorithm(n?.size),l=extractHighWaterMark(t?.highWaterMark,1),u=extractSizeAlgorithm(t?.size),d=Promise.withResolvers();initializeTransformStream(this,d,l,u,s,c),setupTransformStreamDefaultControllerFromTransformer(this,e),o===void 0?d.resolve():d.resolve(o.call(e,this[Y].controller))}get readable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].readable}get writable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[Zr]=`TransformStreamDefaultController`;[Y];constructor(e){if(e!==Si)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!wi(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y],{readable:t}=e[Y],n=t[Y].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Ci=isBrandCheck(`TransformStream`),wi=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,o){let startAlgorithm=()=>t.promise,s=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[Y]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,o),writable:s,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[Y];readableStreamDefaultControllerError(n[Y].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[Y];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Y].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[Y].backpressureChange.promise!==void 0&&e[Y].backpressureChange.resolve?.(),e[Y].backpressureChange=Promise.withResolvers(),e[Y].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[Y]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[Y].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(Si),r=t?.transform,i=t?.flush,o=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,o?createPromiseCallback(`transformer.cancel`,o,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Y].transformAlgorithm=void 0,e[Y].flushAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[Y],{readable:r}=n[Y],i=r[Y].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[Y].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[Y].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[Y].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[Y].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[Y].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[Y],{readable:n}=t[Y];readableStreamDefaultControllerClose(n[Y].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[Y];return e[Y].backpressure?e[Y].backpressureChange.promise.then(()=>{let{writable:r}=e[Y];if(r[Y].state===`erroring`)throw r[Y].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(readableStreamDefaultControllerError(r[Y].controller,t),o())},e=>{readableStreamDefaultControllerError(r[Y].controller,e),s(e)}),n[Y].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:r,resolve:i,reject:o}=Promise.withResolvers();n[Y].finishPromise=r;let s=n[Y].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{t[Y].state===`errored`?o(t[Y].storedError):(readableStreamDefaultControllerClose(t[Y].controller),i())},e=>{readableStreamDefaultControllerError(t[Y].controller,e),o(e)}),n[Y].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Y].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),o())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),s(t)}),n[Y].finishPromise}const Ti=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),Ei=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 Ti}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 Ei}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 Di=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),Di)this.#t=new TransformStream({transform:(e,t)=>{let n=toUint8Array$3(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$3(t),i;e.length>0?(i=new Uint8Array(e.length+r.length),i.set(e,0),i.set(r,e.length)):i=r;let o=incompleteUtf8Tail$1(i),s;if(o>0?(s=i.slice(0,i.length-o),e=i.slice(i.length-o)):(s=i,e=new Uint8Array),s.length>0){let e=this.#e.decode(s);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$3(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$3,`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 Oi=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,ki=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Ai=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,ji=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Mi=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Ni=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,Pi=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Fi,Ii=__esmMin(()=>{Fi=r}),X,Z=__esmMin(()=>{Ii(),X=Fi});function getGioFormat(e){switch(e){case`gzip`:return X.ZlibCompressorFormat.GZIP;case`deflate`:return X.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return X.ZlibCompressorFormat.RAW}}function concat$2(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function assertLevel(e){if(!(e>=-1&&e<=9))throw RangeError(`The value of "level" is out of range. It must be >= -1 and <= 9. Received ${e}`)}function compressWithGio(e,t,n=-1){assertLevel(n);let r=new X.ZlibCompressor({format:getGioFormat(t),level:Math.trunc(n)}),i=new X.ConverterOutputStream({base_stream:X.MemoryOutputStream.new_resizable(),converter:r});i.write_bytes(new W.Bytes(e),null),i.close(null);let o=i.get_base_stream().steal_as_bytes();return new Uint8Array(o.get_data()??[])}function decompressStreamWithGio(e,t){let n=new X.ZlibDecompressor({format:getGioFormat(t)}),r=X.MemoryInputStream.new_from_bytes(new W.Bytes(e)),i=new X.ConverterInputStream({base_stream:r,converter:n}),o=[];for(;;){let e=i.read_bytes(Ri,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}return i.close(null),concat$2(o)}function findGzipMemberEnd(e){let t=new X.ZlibDecompressor({format:X.ZlibCompressorFormat.GZIP}),n=new Uint8Array(262144),r=0;for(;;){let i=e.subarray(r,r+Li);try{let[e,o,s]=t.convert(i,n,X.ConverterFlags.NONE);if(r+=o,e===X.ConverterResult.FINISHED||o===0&&s===0)return r}catch{return r}}}function gunzipWithGio(e){let t=[],n=0;for(;n<e.length&&!(e.length-n<2||e[n]!==31||e[n+1]!==139);){let r=e.subarray(n),i=findGzipMemberEnd(r);if(i<=0)break;t.push(decompressStreamWithGio(r.subarray(0,i),`gzip`)),n+=i}return t.length===0?decompressStreamWithGio(e,`gzip`):concat$2(t)}var Li,Ri,zi=__esmMin(()=>{Z(),G(),Li=256*1024,Ri=1024*1024,__name(concat$2,`concat`)}),Bi=__esmMin(()=>{P()}),Vi,Hi,Ui=__esmMin(()=>{Vi=Object.defineProperty,Hi=__name((e,t)=>{let n={};for(var r in e)Vi(n,r,{get:e[r],enumerable:!0});return t||Vi(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)});function _setPipeImpl(e){Wi=e}var Wi,Stream_,Gi=__esmMin(()=>{Kn(),Stream_=class extends K{constructor(e){super(e)}pipe(e,t){return Wi(this,e,t)}}});function finished$1(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 o=e,s=typeof e.write==`function`,c=typeof e.read==`function`,l=o.writableFinished===!0,u=o.readableEnded===!0;if(o.destroyed===!0){let e=o._err;oe(e?()=>done(e):s&&l||c&&u?()=>done():()=>done(Error(`premature close`)))}else(s&&!c&&l||!s&&c&&u||s&&c&&l&&u)&&oe(()=>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 Ki=__esmMin(()=>{Gi(),P(),__name(finished$1,`finished`)});function getDefaultHighWaterMark(e){return e?Ji:qi}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Ji=t:qi=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 qi,Ji,Yi=__esmMin(()=>{qi=16384,Ji=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$1(e,e=>{e&&e!==n?r(e):t()})})}var Xi,Zi=__esmMin(()=>{Ki(),Xi=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 Qi,$i,ea,ta=__esmMin(()=>{Gi(),Zi(),Yi(),P(),Qi=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;_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._destroy=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.listenerCount(`readable`)===0&&this.resume(),e===`readable`&&(this.readableFlowing=!1,this._buffer.length>0||this._readableState.ended?this._scheduleReadable():this._readableState.reading||nextTick(()=>{this.destroyed||this.read(0)})),this}removeListener(e,t){let n=super.removeListener(e,t);return e===`readable`&&nextTick(()=>this._updateReadableListening()),n}removeAllListeners(e){let t=e===void 0?super.removeAllListeners():super.removeAllListeners(e);return(e===`readable`||e===void 0)&&nextTick(()=>this._updateReadableListening()),t}_updateReadableListening(){this.listenerCount(`readable`)>0||(this.listenerCount(`data`)>0?this.resume():this.readableFlowing=null)}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){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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return 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,o=null;return e.on(`data`,e=>{if(i){let t=i;i=null,o=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,o=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,o){let t=o;i=null,o=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,o=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)}},Qi.prototype[Xi]=function(){return streamAsyncDispose(this,this.readableEnded)},$i=Object.getOwnPropertyDescriptor(Qi.prototype,`on`),ea=Object.getOwnPropertyDescriptor(Qi.prototype,`removeListener`),Object.defineProperty(Qi.prototype,"addListener",{...$i}),Object.defineProperty(Qi.prototype,"off",{...ea})});function writeAfterEndError(){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,e}var na=__esmMin(()=>{});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,ra=__esmMin(()=>{na(),Yi(),ta(),P(),Duplex_=class extends Qi{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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),o}_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.destroyed||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.destroyed||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,o=!1,ondrain=()=>{o=!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(),o||(o=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let s=!1,onend=()=>{s||(s=!0,i&&t.end())},onclose=()=>{if(!s&&(s=!0,i&&!(r instanceof Qi))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),o&&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 Qi&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var ia=__esmMin(()=>{Gi(),ta(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var aa,oa=__esmMin(()=>{na(),Gi(),Zi(),Yi(),P(),aa=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;_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._destroy=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){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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),o}_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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return this}},aa.prototype[Xi]=function(){return streamAsyncDispose(this,this.writableFinished)}}),sa,ca=__esmMin(()=>{ra(),P(),sa=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_,la=__esmMin(()=>{ca(),PassThrough_=class extends sa{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline$1(...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 o=r[0];for(let e=1;e<r.length;e++){let t=r[e];o.pipe(t),o.on(`error`,onError),o=t}let s=r[r.length-1];return s.on(`error`,onError),s.on(`finish`,()=>{n&&!i&&n(null)}),s}var ua=__esmMin(()=>{__name(pipeline$1,`pipeline`)});function pipeline(...e){return new Promise((t,n)=>{let cb=e=>{e?n(e):t()};pipeline$1(...e,cb)})}function finished(e,t){return new Promise((n,r)=>{t&&typeof t!=`function`?finished$1(e,t,e=>{e?r(e):n()}):finished$1(e,e=>{e?r(e):n()})})}var da,fa,pa=__esmMin(()=>{Ui(),Ki(),ua(),da=Hi({default:()=>fa,finished:()=>finished,pipeline:()=>pipeline}),fa={pipeline,finished}}),ma=__exportAll$5({Duplex:()=>va,PassThrough:()=>ba,Readable:()=>ga,Stream:()=>ha,Transform:()=>ya,Writable:()=>_a,addAbortSignal:()=>addAbortSignal,default:()=>xa,finished:()=>finished$1,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,"module.exports":()=>xa,pipeline:()=>pipeline$1,promises:()=>da,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),ha,ga,_a,va,ya,ba,xa,Sa=__esmMin(()=>{Bi(),Gi(),Ki(),Yi(),ta(),ra(),ia(),oa(),ca(),la(),ua(),pa(),ha=makeCallable(Stream_),ga=makeCallable(Qi),_a=makeCallable(aa),va=makeCallable(Duplex_),ya=makeCallable(sa),ba=makeCallable(PassThrough_),xa=Object.assign(ha,{Stream:ha,Readable:ga,Writable:_a,Duplex:va,Transform:ya,PassThrough:ba,pipeline:pipeline$1,finished:finished$1,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark,promises:da})});function toUint8Array$2(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function concat$1(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function createGzip(e){return new Gzip(e)}function createGunzip(e){return new Gunzip(e)}function createDeflate(e){return new Deflate(e)}function createInflate(e){return new Inflate(e)}function createDeflateRaw(e){return new DeflateRaw(e)}function createInflateRaw(e){return new InflateRaw(e)}function createUnzip(e){return new Unzip(e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}function createZstdCompress(e){let t=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}function createZstdDecompress(e){let t=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,Ca=__esmMin(()=>{zi(),Sa(),__name(toUint8Array$2,`toUint8Array`),__name(concat$1,`concat`),ZlibBase=class extends ya{_mode;_chunks=[];constructor(e,t){super(t),this._mode=e}_transform(e,t,n){this._chunks.push(toUint8Array$2(e)),n()}_flush(e){let t=concat$1(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(t))),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_run(e){let t=this._mode;switch(t.kind){case`compress`:return compressWithGio(e,t.format);case`decompress`:return decompressStreamWithGio(e,t.format);case`gunzip`:return gunzipWithGio(e);case`unzip`:return e.length>=2&&e[0]===31&&e[1]===139?gunzipWithGio(e):decompressStreamWithGio(e,`deflate`)}}},Gzip=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`gzip`},e)}},Gunzip=class extends ZlibBase{constructor(e){super({kind:`gunzip`},e)}},Deflate=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate`},e)}},Inflate=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate`},e)}},DeflateRaw=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate-raw`},e)}},InflateRaw=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate-raw`},e)}},Unzip=class extends ZlibBase{constructor(e){super({kind:`unzip`},e)}},BrotliCompress=class extends ya{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends ya{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends ya{constructor(){super();let e=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}},ZstdDecompress=class extends ya{constructor(){super();let e=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}}}),wa=__exportAll$5({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>Ea,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>Da,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function decompressWithGio(e,t){return t===`gzip`?gunzipWithGio(e):decompressStreamWithGio(e,t)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let o=r.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of r)s.set(e,c),c+=e.length;return s}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}function requestedLevel(e){let t=e?.level;if(!(t===void 0||t===-1))return assertLevel(t),t}async function compress(e,t,n){return n===void 0&&hasWebCompression()?compressWithWeb(e,t):compressWithGio(e,t,n)}async function decompress(e,t){if(hasWebCompression())try{return await decompressWithWeb(e,t)}catch(n){if(t!==`gzip`)throw n;return decompressWithGio(e,t)}return decompressWithGio(e,t)}function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`gzip`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate-raw`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array$1(e),`gzip`,t?.level??-1)}function gunzipSync(e,t){return decompressWithGio(toUint8Array$1(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate`,t?.level??-1)}function inflateSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate-raw`,t?.level??-1)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate-raw`)}function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),Ta)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),Ta)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}function zstdCompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdCompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdDecompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdDecompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdCompressSync(e,t){let n=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}function zstdDecompressSync(e,t){let n=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}var hasWebCompression,Ta,Ea,Da,Oa=__esmMin(()=>{zi(),Ca(),hasWebCompression=()=>globalThis.CompressionStream!==void 0,__name(toUint8Array$1,`toUint8Array`),Ta=new Uint8Array,Ea={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},Da={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:Ea}});const ka=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!ka.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const Aa=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let ja=!1,Ma,Na,Pa,Fa,Ia,La;async function loadZlib(){if(ja)return;let e=await Promise.resolve().then(()=>(Oa(),wa));Ma=e.gzipSync,Na=e.gunzipSync,Pa=e.deflateSync,Fa=e.inflateSync,Ia=e.deflateRawSync,La=e.inflateRawSync,ja=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Ma(e);case`deflate`:return e=>Pa(e);case`deflate-raw`:return e=>Ia(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Na(e);case`deflate`:return e=>Fa(e);case`deflate-raw`:return e=>La(e)}}function concatChunks(e){if(e.length===1)return e[0];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 n}let Ra,za;if(Aa)Ra=globalThis.CompressionStream,za=globalThis.DecompressionStream;else{let e=loadZlib();Ra=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getCompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}},za=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getDecompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}}}const Ba=globalThis;globalThis.CompressionStream===void 0&&(Ba.CompressionStream=Ra),globalThis.DecompressionStream===void 0&&(Ba.DecompressionStream=za);const Va=globalThis;globalThis.DOMException===void 0&&(Va.DOMException=V);const Ha=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(Ha.ByteLengthQueuingStrategy=ji),globalThis.CountQueuingStrategy===void 0&&(Ha.CountQueuingStrategy=Mi);const Ua=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`)||(Ua.ReadableStream=Oi),Ua.ReadableStreamBYOBReader===void 0&&(Ua.ReadableStreamBYOBReader=ReadableStreamBYOBReader),Ua.ReadableStreamBYOBRequest===void 0&&(Ua.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),Ua.ReadableByteStreamController===void 0&&(Ua.ReadableByteStreamController=ReadableByteStreamController),Ua.ReadableStreamDefaultController===void 0&&(Ua.ReadableStreamDefaultController=ReadableStreamDefaultController),Ua.ReadableStreamDefaultReader===void 0&&(Ua.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const Wa=globalThis;globalThis.TextEncoderStream===void 0&&(Wa.TextEncoderStream=Ni),globalThis.TextDecoderStream===void 0&&(Wa.TextDecoderStream=Pi);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=Ai}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=ki}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 Ga=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=Ga.slice(),i=[];for(let t=0;t<n;t++)i.push(e.slice(t*8,t*8+8));let o=new Uint8Array(16);for(let e=0;e<=5;e++)for(let s=1;s<=n;s++){o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),xorCounter(r,n*e+s),i[s-1]=c.slice(8,16)}let s=new Uint8Array((n+1)*8);s.set(r,0);for(let e=0;e<n;e++)s.set(i[e],(e+1)*8);return s}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 o=new Uint8Array(16);for(let e=5;e>=0;e--)for(let s=n;s>=1;s--){xorCounter(r,n*e+s),o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),i[s-1]=c.slice(8,16)}let s=!0;for(let e=0;e<8;e++)r[e]!==Ga[e]&&(s=!1);if(!s)throw new DOMException(`AES-KW: integrity check failed`,`OperationError`);let c=new Uint8Array(n*8);for(let e=0;e<n;e++)c.set(i[e],e*8);return c}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 Ka={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(e){let t=Ka[e.toUpperCase()]||Ka[e];if(!t)throw new V(`Unrecognized hash name: ${e}`,`NotSupportedError`);return t}const qa={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(e){let t=qa[e];if(!t)throw new V(`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 V(`Unsupported hash: ${e}`,`NotSupportedError`)}}__name(hashSize$1,`hashSize`);function validateUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Invalid key usage: ${n}`,`SyntaxError`);if(e.length===0)throw new V(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(e,t){if(!e.usages.includes(t))throw new V(`Key does not support the '${t}' usage`,`InvalidAccessError`)}const Ja=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ya=new Uint8Array(128);for(let e=0;e<64;e++)Ya[Ja.charCodeAt(e)]=e;function bytesToBase64(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],o=r+1<n?e[r+1]:0,s=r+2<n?e[r+2]:0;t+=Ja[i>>2&63],t+=Ja[(i<<4|o>>4)&63],t+=r+1<n?Ja[(o<<2|s>>6)&63]:`=`,t+=r+2<n?Ja[s&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|Ya[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`)}function checkAlgorithmMatch(e,t){if(e.algorithm.name.toUpperCase()!==t.toUpperCase())throw new V(`Key algorithm mismatch`,`InvalidAccessError`)}const Xa={Ed25519:{public:[`verify`],private:[`sign`]},X25519:{public:[],private:[`deriveKey`,`deriveBits`]}},Za={Ed25519:[48,42,48,5,6,3,43,101,112,3,33,0],X25519:[48,42,48,5,6,3,43,101,110,3,33,0]};function cfrgName(e){let t=e.toUpperCase();if(t===`ED25519`)return`Ed25519`;if(t===`X25519`)return`X25519`}function assertUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Unsupported key usage: ${n}`,`SyntaxError`)}function toArrayBuffer(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function keyObjectOf(e){return e._handle.keyObject}function cfrgGenerateKey(e,t,n,r){assertUsages(r,[...Xa[t].public,...Xa[t].private]);let i=r.filter(e=>Xa[t].private.includes(e));if(i.length===0)throw new V(`Usages cannot be empty when creating a key.`,`SyntaxError`);let o=r.filter(e=>Xa[t].public.includes(e)),{publicKey:s,privateKey:c}=e.generateKeyPairSync(t.toLowerCase());return{publicKey:new CryptoKey(`public`,!0,{name:t},o,{keyObject:s}),privateKey:new CryptoKey(`private`,n,{name:t},i,{keyObject:c})}}function validateJwk(e,t,n,r){if(typeof e!=`object`||!e)throw new V(`Invalid keyData`,`DataError`);if(e.kty!==`OKP`)throw new V(`Invalid JWK "kty" Parameter`,`DataError`);if(e.crv!==t)throw new V(`JWK "crv" Parameter and algorithm name mismatch`,`DataError`);if(t===`Ed25519`&&e.alg!==void 0&&e.alg!==`Ed25519`&&e.alg!==`EdDSA`)throw new V(`JWK "alg" does not match the requested algorithm`,`DataError`);let i=t===`X25519`?`enc`:`sig`;if(r.length>0&&e.use!==void 0&&e.use!==i)throw new V(`Invalid JWK "use" Parameter`,`DataError`);if(e.key_ops!==void 0){if(!Array.isArray(e.key_ops))throw new V(`Invalid JWK "key_ops" Parameter`,`DataError`);for(let t of r)if(!e.key_ops.includes(t))throw new V(`Key operations and usage mismatch`,`DataError`)}if(e.ext===!1&&n)throw new V(`JWK "ext" Parameter and extractable mismatch`,`DataError`);if(typeof e.x!=`string`||e.d!==void 0&&typeof e.d!=`string`)throw new V(`Invalid keyData`,`DataError`)}function cfrgImportKey(e,t,n,r,i,o){let s,c,importOrDataError=e=>{try{return e()}catch(e){throw new V(`Invalid keyData: ${e.message}`,`DataError`)}};switch(t){case`raw`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);if(t.length!==32)throw new V(`Invalid keyData`,`DataError`);let i=new Uint8Array(44);i.set(Za[r],0),i.set(t,12),s=importOrDataError(()=>e.createPublicKey({key:i,format:`der`,type:`spki`})),c=`public`;break}case`spki`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);s=importOrDataError(()=>e.createPublicKey({key:t,format:`der`,type:`spki`})),c=`public`;break}case`pkcs8`:{assertUsages(o,Xa[r].private);let t=toUint8Array(n);s=importOrDataError(()=>e.createPrivateKey({key:t,format:`der`,type:`pkcs8`})),c=`private`;break}case`jwk`:{let t=n;if(validateJwk(t,r,i,o),c=t.d===void 0?`public`:`private`,assertUsages(o,Xa[r][c]),c===`private`){if(s=importOrDataError(()=>e.createPrivateKey({key:t,format:`jwk`})),e.createPublicKey(s).export({format:`jwk`}).x!==t.x)throw new V(`Invalid JWK: "x" does not match "d"`,`DataError`)}else{if(base64urlDecode(t.x).length!==32)throw new V(`Invalid keyData`,`DataError`);s=importOrDataError(()=>e.createPublicKey({key:t,format:`jwk`}))}break}default:throw new V(`Unsupported format: ${t}`,`NotSupportedError`)}if(s.asymmetricKeyType!==r.toLowerCase())throw new V(`Invalid key type`,`DataError`);if(c===`private`&&o.length===0)throw new V(`Usages cannot be empty when importing a private key.`,`SyntaxError`);return new CryptoKey(c,i,{name:r},o,{keyObject:s})}function wrongKindForFormat(e,t){return new V(`Unable to export ${e.algorithm.name} ${e.type} key using ${t} format`,`InvalidAccessError`)}function cfrgExportKey(e,t){let n=keyObjectOf(t);switch(e){case`raw`:{if(t.type!==`public`)throw new V(`Unable to export ${t.algorithm.name} ${t.type} key using ${e} format`,`NotSupportedError`);let r=n.export({format:`jwk`}).x;return toArrayBuffer(base64urlDecode(r))}case`spki`:if(t.type!==`public`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`spki`}));case`pkcs8`:if(t.type!==`private`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`pkcs8`}));case`jwk`:{let e=n.export({format:`jwk`}),r={kty:`OKP`,crv:t.algorithm.name,x:e.x};return t.type===`private`&&(r.d=e.d),t.algorithm.name===`Ed25519`&&(r.alg=`Ed25519`),r.key_ops=[...t.usages],r.ext=t.extractable,r}default:throw new V(`Unsupported export format: ${e}`,`NotSupportedError`)}}function ed25519Sign$1(e,t,n){if(t.type!==`private`)throw new V(`Key must be a private key`,`InvalidAccessError`);return toArrayBuffer(e.sign(null,n,keyObjectOf(t)))}__name(ed25519Sign$1,`ed25519Sign`);function ed25519Verify$1(e,t,n,r){if(t.type!==`public`)throw new V(`Key must be a public key`,`InvalidAccessError`);return e.verify(null,r,keyObjectOf(t),n)}__name(ed25519Verify$1,`ed25519Verify`);function x25519DeriveBits(e,t,n,r){if(t.type!==`private`)throw new V(`baseKey must be a private key`,`InvalidAccessError`);if(!(n instanceof CryptoKey)||n.type!==`public`)throw new V(`algorithm.public must be a public key`,`InvalidAccessError`);if(n.algorithm.name!==t.algorithm.name)throw new V(`The public and private keys must be of the same type`,`InvalidAccessError`);let i;try{i=new Uint8Array(e.diffieHellman({privateKey:keyObjectOf(t),publicKey:keyObjectOf(n)}))}catch(e){throw new V(`Deriving bits failed: ${e.message}`,`OperationError`)}if(r==null)return toArrayBuffer(i);if(r>i.length*8)throw new V(`derived bit length is too small`,`OperationError`);let o=i.slice(0,Math.ceil(r/8));return r%8!=0&&(o[o.length-1]&=255<<8-r%8),toArrayBuffer(o)}var Qa,$a=__esmMin(()=>{Qa={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 eo=__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([to[n[1]]^ro[e/t-1],to[n[2]],to[n[3]],to[n[0]]]):t>6&&e%t===4&&(n=new Uint8Array([to[n[0]],to[n[1]],to[n[2]],to[n[3]]])),i[e]=new Uint8Array(4);for(let r=0;r<4;r++)i[e][r]=i[e-t][r]^n[r]}let o=[];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];o.push(t)}return o}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]=to[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],o=n[6];n[2]=n[10],n[6]=n[14],n[10]=i,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<4;e++){let t=e*4,r=n[t],i=n[t+1],o=n[t+2],s=n[t+3];n[t]=gmul(2,r)^gmul(3,i)^o^s,n[t+1]=r^gmul(2,i)^gmul(3,o)^s,n[t+2]=r^i^gmul(2,o)^gmul(3,s),n[t+3]=gmul(3,r)^i^o^gmul(2,s)}for(let r=0;r<16;r++)n[r]^=t[e][r]}for(let e=0;e<16;e++)n[e]=to[n[e]];let i=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=i;let o=n[2],s=n[6];n[2]=n[10],n[6]=n[14],n[10]=o,n[14]=s;let c=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=c;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],o=n[14];n[10]=n[2],n[14]=n[6],n[2]=i,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]=no[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],o=n[t+2],s=n[t+3];n[t]=gmul(14,r)^gmul(11,i)^gmul(13,o)^gmul(9,s),n[t+1]=gmul(9,r)^gmul(14,i)^gmul(11,o)^gmul(13,s),n[t+2]=gmul(13,r)^gmul(9,i)^gmul(14,o)^gmul(11,s),n[t+3]=gmul(11,r)^gmul(13,i)^gmul(9,o)^gmul(14,s)}}let i=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=i;let o=n[10],s=n[14];n[10]=n[2],n[14]=n[6],n[2]=o,n[6]=s;let c=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=c;for(let e=0;e<16;e++)n[e]=no[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]=e[t]+1&255,e[t]===0);t--);}function gcmIncrementCounter(e){for(let t=15;t>=12&&(e[t]=e[t]+1&255,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,o=Math.min(i+16,t.length);for(let e=0;e<16;e++){let n=i+e;n<o&&(r[e]^=t[n])}let s=gfMul(r,e);r.set(s)}let o=Math.ceil(n.length/16)||0;for(let t=0;t<o;t++){let i=t*16,o=Math.min(i+16,n.length);for(let e=0;e<16;e++){let t=i+e;t<o&&(r[e]^=n[t])}let s=gfMul(r,e);r.set(s)}let s=new Uint8Array(16),c=t.length*8,l=n.length*8,u=Math.floor(c/4294967296),d=c>>>0;s[0]=u>>>24&255,s[1]=u>>>16&255,s[2]=u>>>8&255,s[3]=u&255,s[4]=d>>>24&255,s[5]=d>>>16&255,s[6]=d>>>8&255,s[7]=d&255;let p=Math.floor(l/4294967296),m=l>>>0;s[8]=p>>>24&255,s[9]=p>>>16&255,s[10]=p>>>8&255,s[11]=p&255,s[12]=m>>>24&255,s[13]=m>>>16&255,s[14]=m>>>8&255,s[15]=m&255;for(let e=0;e<16;e++)r[e]^=s[e];let h=gfMul(r,e);return r.set(h),r}var to,no,ro,io=__esmMin(()=>{to=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]),no=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]),ro=[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`?H.from(e,t||`utf8`):H.from(e)}function encodeOutput(e,t){return t?H.from(e).toString(t):H.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 ao=__esmMin(()=>{U(),__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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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,oo=__esmMin(()=>{io(),ao(),U(),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 H.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 o=Math.floor(i.length/16)*16,s=[];for(let e=0;e<o;e+=16){let t=i.slice(e,e+16);s.push(this._encryptBlock(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 encodeOutput(c,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];return this._gcmAuthTag=H.from(s),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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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=H.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 H.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 o=Math.floor(i.length/16);if(o===0)return this._buffer=i,this._encodeWithUtf8Handling(new Uint8Array,n,!1);let s=(this._autoPadding?o-1:o)*16,c=[];for(let e=0;e<s;e+=16){let t=i.slice(e,e+16);c.push(this._decryptBlock(t))}this._buffer=i.slice(s);let l=new Uint8Array(c.length*16);for(let e=0;e<c.length;e++)l.set(c[e],e*16);return this._encodeWithUtf8Handling(l,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];let c=this._gcmExpectedTag,l=Math.min(c.length,16),u=0;for(let e=0;e<l;e++)u|=s[e]^c[e];if(u!==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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];gcmIncrementCounter(this._counter)}return t}}});function pemToDer$1(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],o=t.findIndex((e,t)=>t>n&&e.startsWith(`-----END `));if(o===-1)throw Error(`Invalid PEM: no END line found`);let s=t.slice(n+1,o).join(``),c=H.from(s,`base64`);return{type:i,der:new Uint8Array(c.buffer,c.byteOffset,c.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 o=e.slice(t,t+r),s=t+r,c={tag:n,data:o};return n===48&&(c.children=parseSequenceChildren(o)),{value:c,next:s}}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 okpCurveForOid(e){if(oidsEqual(e,lo))return`ed25519`;if(oidsEqual(e,co))return`x25519`}function oidForOkpCurve(e){return e===`ed25519`?lo:co}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 algorithmOid(e){let t=e?.children?.[0];if(!t||t.tag!==6)throw Error(`Invalid AlgorithmIdentifier`);if(okpCurveForOid(t.data)&&(e?.children?.length??0)!==1)throw Error(`Invalid AlgorithmIdentifier: parameters must be absent (RFC 8410)`);return t.data}function parseSubjectPublicKeyInfo(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let n=algorithmOid(t[0]),r=t[1];if(r.tag!==3||r.data[0]!==0)throw Error(`Expected BIT STRING for public key data`);let i=r.data.slice(1),o=okpCurveForOid(n);if(o){if(i.length!==32)throw Error(`Invalid ${o} public key length: ${i.length}`);return{type:`okp-public`,curve:o,pub:i}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(parseDer(i))}}function parsePrivateKeyInfo(e){let t=e.children;if(!t||t.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let n=algorithmOid(t[1]),r=t[2];if(r.tag!==4)throw Error(`Expected OCTET STRING for private key data`);let i=okpCurveForOid(n);if(i){let e=parseDer(r.data);if(e.tag!==4||e.data.length!==32)throw Error(`Invalid ${i} private key`);return{type:`okp-private`,curve:i,priv:e.data}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(parseDer(r.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(so),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(e))])}function encodeRsaPrivateKeyPkcs1(e){let t=e.d%(e.p-1n),n=e.d%(e.q-1n),r=modInverse$2(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(so),encodeNull()]),n=encodeOctetString(encodeRsaPrivateKeyPkcs1(e));return encodeSequence([bigintToAsn1Integer(0n),t,n])}function encodeOkpSubjectPublicKeyInfo(e,t){return encodeSequence([encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeBitString(t)])}function encodeOkpPrivateKeyInfo(e,t){return encodeSequence([bigintToAsn1Integer(0n),encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeOctetString(encodeOctetString(t))])}function derToPem(e,t){let n=H.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(`
|
|
12
12
|
`)}function modInverse$2(e,t){let[n,r]=[e%t,t],[i,o]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,o]=[o,i-e*o]}return(i%t+t)%t}function parseX509(e){let{der:t}=pemToDer$1(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 o=0;n.children[0].tag===160&&o++;let s=integerToBigInt(n.children[o].data);o++,o++;let c=parseDN(n.children[o]);o++;let l=n.children[o],u=parseAsn1Time(l.children[0]),d=parseAsn1Time(l.children[1]);o++;let p=parseDN(n.children[o]);o++;let m=null,h=`unknown`;if(o<n.children.length){let e=n.children[o];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,so)&&(h=`rsa`,m=parseSubjectPublicKeyInfo(e).components)}}}catch{}o++}let g,_;for(let e=o;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){_=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];g=parseSAN(e.data)}}}}}let v=`unknown`;r.children&&r.children.length>=1&&(v=oidToName(r.children[0].data));let y=i.tag===3?i.data.slice(1):i.data;return{raw:e,tbsCertificate:n.data,serialNumber:s,issuer:c,subject:p,validFrom:u,validTo:d,publicKey:m,publicKeyAlgorithm:h,signatureAlgorithm:v,signature:y,subjectAltName:g,extensions:_}}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 fo[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=uo[r]||r,o=n.children[1].data,s=new TextDecoder().decode(o);t.push(`${i}=${s}`)}}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),o=parseInt(t.substring(8,10),10),s=parseInt(t.substring(10,12),10);return new Date(Date.UTC(e,n,r,i,o,s))}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),o=parseInt(t.substring(10,12),10),s=parseInt(t.substring(12,14),10);return new Date(Date.UTC(e,n,r,i,o,s))}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$1(e);switch(t){case`RSA PUBLIC KEY`:return parseDerKey(n,`pkcs1`,`public`);case`PUBLIC KEY`:return parseDerKey(n,`spki`);case`RSA PRIVATE KEY`:return parseDerKey(n,`pkcs1`,`private`);case`PRIVATE KEY`:return parseDerKey(n,`pkcs8`);default:throw Error(`Unsupported PEM type: ${t}`)}}function parseDerKey(e,t,n){let r=parseDer(e);if(r.tag!==48)throw Error(`Invalid key format: expected top-level SEQUENCE`);switch(t){case`spki`:return parseSubjectPublicKeyInfo(r);case`pkcs8`:return parsePrivateKeyInfo(r);case`pkcs1`:return n===`public`?{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(r)}:{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(r)}}}function rsaKeySize(e){let t=0,n=e;for(;n>0n;)t++,n>>=1n;return Math.ceil(t/8)}var so,co,lo,uo,fo,po=__esmMin(()=>{U(),__name(pemToDer$1,`pemToDer`),so=new Uint8Array([42,134,72,134,247,13,1,1,1]),co=new Uint8Array([43,101,110]),lo=new Uint8Array([43,101,112]),__name(modInverse$2,`modInverse`),uo={"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`},fo={"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 normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function hashSize(e){let t=normalizeAlgorithm(e),n=mo[t];if(n===void 0)throw Error(`Unknown hash algorithm: ${e}`);return n}function toBuffer$1(e,t){return typeof e==`string`?H.from(e,t||`utf8`):e instanceof DataView?H.from(e.buffer,e.byteOffset,e.byteLength):(e instanceof ArrayBuffer,H.from(e))}function codedError(e,t,n=Error){let r=new n(t);return r.code=e,r}var mo,ho,go,_o=__esmMin(()=>{U(),mo={md5:16,sha1:20,sha256:32,sha384:48,sha512:64},ho={md5:64,sha1:64,sha256:64,sha384:128,sha512:128},go=new Set([`md5`,`sha1`,`sha256`,`sha384`,`sha512`]),__name(toBuffer$1,`toBuffer`)});function fromBig(e,t=!1){return t?{h:Number(e&vo),l:Number(e>>yo&vo)}:{h:Number(e>>yo&vo)|0,l:Number(e&vo)|0}}function split(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){let{h:n,l:s}=fromBig(e[o],t);[r[o],i[o]]=[n,s]}return[r,i]}function setU64FromNum(e,t,n,r){let i=fromNumH(n),o=fromNumL(n);e.setUint32(t,r?o:i,r),e.setUint32(t+4,r?i:o,r)}function add(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var vo,yo,fromNumH,fromNumL,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,add3L,add3H,add4L,add4H,add5L,add5H,bo=__esmMin(()=>{vo=BigInt(2**32-1),yo=BigInt(32),fromNumH=e=>e/2**32|0,fromNumL=e=>e>>>0,shrSH=(e,t,n)=>e>>>n,shrSL=(e,t,n)=>e<<32-n|t>>>n,rotrSH=(e,t,n)=>e>>>n|t<<32-n,rotrSL=(e,t,n)=>e<<32-n|t>>>n,rotrBH=(e,t,n)=>e<<64-n|t>>>n-32,rotrBL=(e,t,n)=>e>>>n-32|t<<64-n,add3L=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5L=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),add5H=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0});function isBytes$1(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function anumber$1(e,t=``){if(typeof e!=`number`)throw TypeError(xo(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(xo(t)+`expected integer >= 0, got `+e);return e}function abytes$1(e,t,n=``){if(isBytes$1(e)&&(t===void 0||e.length===t))return e;t!==void 0&&anumber$1(t,`length`);let r=isBytes$1(e),i=t===void 0?``:` of length ${t}`,o=r?`length=${e.length}`:`type=${typeof e}`,s=xo(n)+`expected Uint8Array`+i+`, got `+o;throw r?RangeError(s):TypeError(s)}function aexists(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function aoutput(e,t){abytes$1(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function clean(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function createView(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function bytesToHex$1(e){if(abytes$1(e),Co)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=wo[e[n]];return t}function asciiToBase16(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function hexToBytes$1(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(Co)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=asciiToBase16(e.charCodeAt(i)),o=asciiToBase16(e.charCodeAt(i+1));if(n===void 0||o===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+o}return r}function concatBytes$1(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];abytes$1(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function checkOpts(e,t,n=`opts`){return aopts(e,`defaults`),t!==void 0&&aopts(t,n),Object.assign(Object.create(null),e,t)}function createHasher(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=checkOpts({},t,`info`);let hashC=(t,n)=>e(n).update(t).digest(),n=e(void 0);return hashC.outputLen=n.outputLen,hashC.blockLen=n.blockLen,hashC.canXOF=n.canXOF,hashC.create=t=>e(t),Object.assign(hashC,t),Object.freeze(hashC)}function randomBytes$2(e=32){anumber$1(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var xo,So,aopts,Co,wo,oidNist,To=__esmMin(()=>{__name(isBytes$1,`isBytes`),xo=__name(e=>e?`"${e}" `:``,`atitle`),__name(anumber$1,`anumber`),__name(abytes$1,`abytes`),So=__name((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},`aobject`),aopts=(e,t)=>{So(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)},Co=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,wo=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),__name(bytesToHex$1,`bytesToHex`),__name(hexToBytes$1,`hexToBytes`),__name(concatBytes$1,`concatBytes`),__name(randomBytes$2,`randomBytes`),oidNist=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})}),HashMD,Eo,Do=__esmMin(()=>{bo(),To(),HashMD=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){aexists(this),abytes$1(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,o=!1;for(let s=0;s<i;){let c=Math.min(r-this.pos,i-s);if(c===r){let t=createView(e);for(;r<=i-s;s+=r)this.process(t,s);o=!0;continue}n.set(s===0&&c===i?e:e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===r&&(this.process(t,0),this.pos=0,o=!0)}return this.length+=e.length,o&&this.roundClean(),this}digestInto(e){aexists(this),aoutput(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:o}=this;t[o++]=128,t.fill(0,o),this.padOffset>r-o&&(this.process(n,0),t.fill(0)),setU64FromNum(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let s=e===t?n:createView(e),c=this.outputLen,l=c/4,u=this.get();if(c%4||l>u.length)throw Error(`invalid outputLen`);for(let e=0;e<l;e++)s.setUint32(4*e,u[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:o}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=o,o&&e.buffer.set(t),e}clone(){return this._cloneInto()}},Eo=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])}),Oo,ko,Ao,jo,Mo,SHA2_64B,_SHA512,No,Po=__esmMin(()=>{Do(),bo(),To(),Oo=split(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),ko=Oo[0],Ao=Oo[1],jo=new Uint32Array(80),Mo=new Uint32Array(80),SHA2_64B=class extends HashMD{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(e,t){super(128,e,16,!1),this.Ah=t[0]|0,this.Al=t[1]|0,this.Bh=t[2]|0,this.Bl=t[3]|0,this.Ch=t[4]|0,this.Cl=t[5]|0,this.Dh=t[6]|0,this.Dl=t[7]|0,this.Eh=t[8]|0,this.El=t[9]|0,this.Fh=t[10]|0,this.Fl=t[11]|0,this.Gh=t[12]|0,this.Gl=t[13]|0,this.Hh=t[14]|0,this.Hl=t[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:c,Eh:l,El:u,Fh:d,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;return[e,t,n,r,i,o,s,c,l,u,d,p,m,h,g,_]}set(e,t,n,r,i,o,s,c,l,u,d,p,m,h,g,_){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=o|0,this.Dh=s|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=p|0,this.Gh=m|0,this.Gl=h|0,this.Hh=g|0,this.Hl=_|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)jo[n]=e.getUint32(t),Mo[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=jo[e-15]|0,n=Mo[e-15]|0,r=rotrSH(t,n,1)^rotrSH(t,n,8)^shrSH(t,n,7),i=rotrSL(t,n,1)^rotrSL(t,n,8)^shrSL(t,n,7),o=jo[e-2]|0,s=Mo[e-2]|0,c=rotrSH(o,s,19)^rotrBH(o,s,61)^shrSH(o,s,6),l=rotrSL(o,s,19)^rotrBL(o,s,61)^shrSL(o,s,6),u=add4L(i,l,Mo[e-7],Mo[e-16]),d=add4H(u,r,c,jo[e-7],jo[e-16]);jo[e]=d|0,Mo[e]=u|0}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:c,Dh:l,Dl:u,Eh:d,El:p,Fh:m,Fl:h,Gh:g,Gl:_,Hh:v,Hl:y}=this;for(let e=0;e<80;e++){let t=rotrSH(d,p,14)^rotrSH(d,p,18)^rotrBH(d,p,41),b=rotrSL(d,p,14)^rotrSL(d,p,18)^rotrBL(d,p,41),x=d&m^~d&g,S=p&h^~p&_,w=add5L(y,b,S,Ao[e],Mo[e]),T=add5H(w,v,t,x,ko[e],jo[e]),E=w|0,D=rotrSH(n,r,28)^rotrBH(n,r,34)^rotrBH(n,r,39),ee=rotrSL(n,r,28)^rotrBL(n,r,34)^rotrBL(n,r,39),O=n&i^n&s^i&s,k=r&o^r&c^o&c;v=g|0,y=_|0,g=m|0,_=h|0,m=d|0,h=p|0,{h:d,l:p}=add(l|0,u|0,T|0,E|0),l=s|0,u=c|0,s=i|0,c=o|0,i=n|0,o=r|0;let te=add3L(E,ee,k);n=add3H(te,T,D,O),r=te|0}({h:n,l:r}=add(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:o}=add(this.Bh|0,this.Bl|0,i|0,o|0),{h:s,l:c}=add(this.Ch|0,this.Cl|0,s|0,c|0),{h:l,l:u}=add(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:p}=add(this.Eh|0,this.El|0,d|0,p|0),{h:m,l:h}=add(this.Fh|0,this.Fl|0,m|0,h|0),{h:g,l:_}=add(this.Gh|0,this.Gl|0,g|0,_|0),{h:v,l:y}=add(this.Hh|0,this.Hl|0,v|0,y|0),this.set(n,r,i,o,s,c,l,u,d,p,m,h,g,_,v,y)}roundClean(){clean(jo,Mo)}destroy(){this.destroyed=!0,clean(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},_SHA512=class extends SHA2_64B{constructor(){super(64,Eo)}},No=createHasher(()=>new _SHA512,oidNist(3))});
|
|
13
13
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14
14
|
function aarray(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}function aobject(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function afunction(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function abool(e,t=``){if(typeof e!=`boolean`)throw TypeError(atitle(t)+`expected boolean, got type=`+typeof e);return e}function abignumber(e){if(typeof e==`bigint`){if(!isPosBig(e))throw RangeError(`positive bigint expected, got `+e)}else Fo(e);return e}function asafenumber(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function hexToNumber(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?zo:BigInt(`0x`+e)}function bytesToNumberBE(e){return hexToNumber(bytesToHex$1(e))}function bytesToNumberLE(e){return hexToNumber(bytesToHex$1(copyBytes(abytes$1(e)).reverse()))}function numberToBytesBE(e,t){if(anumber$1(t),t===0)throw Error(`zero output length is invalid`);e=abignumber(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return hexToBytes$1(r.padStart(n,`0`))}function numberToBytesLE(e,t){return numberToBytesBE(e,t).reverse()}function copyBytes(e){return Uint8Array.from(abytes(e))}function asciiToBytes(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}function isPosBig(e){return typeof e==`bigint`&&zo<=e}function inRange(e,t,n){return isPosBig(e)&&isPosBig(t)&&isPosBig(n)&&t<=e&&e<n}function aInRange(e,t,n,r){if(!inRange(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function bitLen(e){if(e<zo)throw Error(`expected non-negative bigint, got `+e);return e===zo?0:e.toString(2).length}function validateObject(e,t={},n={},r=`object`){aobject(e,r),aobject(t,`fields`),aobject(n,`optFields`);function checkField(t,n,i){let o=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,s=e[t];if(!Object.hasOwn(e,t)&&(i?s!==void 0:n!==`function`))throw TypeError(`${o} is invalid: expected own property`);if(i&&s===void 0)return;let c=typeof s;if(c!==n||s===null)throw TypeError(`${o} is invalid: expected ${n}, got ${c}`)}let iter=(e,t)=>Object.entries(e).forEach(([e,n])=>checkField(e,n,t));iter(t,!1),iter(n,!0)}var abytes,Fo,Io,concatBytes,hexToBytes,Lo,Ro,zo,Bo,atitle,bitMask,Vo=__esmMin(()=>{To(),abytes=(e,t,n)=>abytes$1(e,t,n),Fo=anumber$1,Io=bytesToHex$1,concatBytes=(...e)=>concatBytes$1(...e),hexToBytes=e=>hexToBytes$1(e),Lo=isBytes$1,Ro=__name(e=>randomBytes$2(e),`randomBytes`),zo=BigInt(0),Bo=BigInt(1),atitle=e=>e?`"${e}" `:``,bitMask=e=>(asafenumber(e,`n`),(Bo<<BigInt(e))-Bo)});
|
|
@@ -229,54 +229,54 @@ var n=el()(`finalhandler`),r=Vd(),i=Hd(),o=Hl(),s=Ud(),c=il(),l=o.isFinished;fun
|
|
|
229
229
|
* MIT Licensed
|
|
230
230
|
*/
|
|
231
231
|
var n=el()(`express:view`),r=(jr(),__toCommonJS(hr)),i=(op(),__toCommonJS(rp)),o=r.dirname,s=r.basename,c=r.extname,l=r.join,u=r.resolve;t.exports=View;function View(e,t){var r=t||{};if(this.defaultEngine=r.defaultEngine,this.ext=c(e),this.name=e,this.root=r.root,!this.ext&&!this.defaultEngine)throw Error(`No default engine was specified and no extension was provided.`);var i=e;if(this.ext||(this.ext=this.defaultEngine[0]===`.`?this.defaultEngine:`.`+this.defaultEngine,i+=this.ext),!r.engines[this.ext]){var o=this.ext.slice(1);n(`require "%s"`,o);var s=y(o).__express;if(typeof s!=`function`)throw Error(`Module "`+o+`" does not provide a view engine.`);r.engines[this.ext]=s}this.engine=r.engines[this.ext],this.path=this.lookup(i)}View.prototype.lookup=function lookup(e){var t,r=[].concat(this.root);n(`lookup "%s"`,e);for(var i=0;i<r.length&&!t;i++){var c=r[i],l=u(c,e),d=o(l),p=s(l);t=this.resolve(d,p)}return t},View.prototype.render=function render(e,t){var r=!0;n(`render "%s"`,this.path),this.engine(this.path,e,function onRender(){if(!r)return t.apply(this,arguments);for(var e=Array(arguments.length),n=this,i=0;i<arguments.length;i++)e[i]=arguments[i];return process.nextTick(function renderTick(){return t.apply(n,e)})}),r=!1},View.prototype.resolve=function resolve(e,t){var n=this.ext,r=l(e,t),i=tryStat(r);if(i&&i.isFile()||(r=l(e,s(t,n),`index`+n),i=tryStat(r),i&&i.isFile()))return r};function tryStat(e){n(`stat "%s"`,e);try{return i.statSync(e)}catch{return}}}));function validateHeaderName(e){if(typeof e!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let t=TypeError(`Header name must be a valid HTTP token ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),t}}function validateHeaderValue(e,t){if(t===void 0){let t=TypeError(`Header "${e}" value must not be undefined`);throw Object.defineProperty(t,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),t}if(typeof t==`string`&&/[^\t -~-ÿ]/.test(t)){let t=TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_CHAR`}),t}}var lp=__esmMin(()=>{}),up,dp,fp=__esmMin(()=>{up={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,510:`Not Extended`,511:`Network Authentication Required`},dp=`ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PRI.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`)}),IncomingMessage,pp=__esmMin(()=>{U(),Sa(),IncomingMessage=class extends ga{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];method;url;statusCode;statusMessage;complete=!1;socket=null;aborted=!1;get connection(){return this.socket}_timeoutTimer=null;constructor(){super()}_read(e){}_autoClose(){}_pushBody(e){e&&e.length>0&&this.push(H.from(e)),this.push(null),this.complete=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null)}setTimeout(e,t){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}destroy(e){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this.aborted=!0,super.destroy(e)}}}),ServerRequestSocket,mp=__esmMin(()=>{Sa(),ServerRequestSocket=class extends va{remoteAddress;remotePort;localAddress;localPort;remoteFamily=`IPv4`;encrypted;connecting=!1;pending=!1;bytesRead=0;bytesWritten=0;_bridgeRes;_bridgePaused=!1;constructor(e,t,n,r,i,o=!1){super({allowHalfOpen:!0}),this.remoteAddress=e,this.remotePort=t,this.localAddress=n,this.localPort=r,this.encrypted=o,this._bridgeRes=i}pause(){return this._bridgePaused?this:(this._bridgePaused=!0,super.pause())}resume(){return this._bridgePaused&&=!1,super.resume()}_read(e){}_write(e,t,n){n()}destroySoon(){this.writableEnded||this.end(),this.writableFinished?this.destroy():this.once(`finish`,()=>this.destroy())}setTimeout(e,t){return t&&this.once(`timeout`,t),this}setNoDelay(e){return this}setKeepAlive(e,t){return this}ref(){return this}unref(){return this}address(){return{address:this.localAddress,family:`IPv4`,port:this.localPort}}}});function unfqdn(e){return e.endsWith(`.`)?e.slice(0,-1):e}function splitHost(e){return unfqdn(e).toLowerCase().split(`.`)}function isPrintableAscii(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<33||n>126)return!1}return!0}function checkHostMatch(e,t){if(!t)return!1;let n=splitHost(t);if(e.length!==n.length||n.includes(``)||!n.every(isPrintableAscii))return!1;for(let t=e.length-1;t>0;t--)if(e[t]!==n[t])return!1;let r=e[0],i=n[0],o=i.split(`*`,3);if(o.length===1||i.includes(`xn--`))return r===i;if(o.length>2||n.length<=2)return!1;let s=o[0],c=o[1];return!(s.length+c.length>r.length||!r.startsWith(s)||!r.endsWith(c))}function checkServerIdentity(e,t){let n=t.subject,r=t.subjectaltname,i=[],o=[];if(e=String(e),r){let e=r.split(`, `);for(let t of e)t.startsWith(`DNS:`)?i.push(t.slice(4)):t.startsWith(`IP Address:`)&&o.push(t.slice(11).trim())}let s=!1,c=`Unknown reason`;e=unfqdn(e);let l=/^(\d{1,3}\.){3}\d{1,3}$/.test(e),u=e.includes(`:`);if(l||u)s=o.some(t=>t.toLowerCase()===e.toLowerCase()),s||(c=`IP: ${e} is not in the cert's list: ${o.join(`, `)}`);else if(i.length>0||n?.CN){let t=splitHost(e);if(i.length>0)s=i.some(e=>checkHostMatch(t,e.trim())),s||(c=`Host: ${e}. is not in the cert's altnames: ${r}`);else{let r=n?.CN;Array.isArray(r)?s=r.some(e=>checkHostMatch(t,e)):r&&(s=checkHostMatch(t,r)),s||(c=`Host: ${e}. is not cert's CN: ${r}`)}}else c=`Cert does not contain a DNS name`;if(!s){let n=Error(`Hostname/IP does not match certificate's altnames: ${c}`);return n.reason=c,n.host=e,n.cert=t,n.code=`ERR_TLS_CERT_ALTNAME_INVALID`,n}}var hp=__esmMin(()=>{});function pemToString(e){return Array.isArray(e)?e.map(pemToString).join(`
|
|
232
|
-
`):typeof e==`string`?e:e instanceof Uint8Array?new TextDecoder(`utf-8`).decode(e):String(e)}function splitPemBlocks(e){let t=[],n=/-----BEGIN [^-]+-----[\s\S]*?-----END [^-]+-----/g,r;for(;(r=n.exec(e))!==null;)t.push(r[0]);return t}function buildGioCertificate(e,t){let n=pemToString(e),r=t?pemToString(t):``,i=r?`${n}\n${r}`:n;return X.TlsCertificate.new_from_pem(i,i.length)}function buildCaCertificates(e){let t=[];if(Array.isArray(e))for(let n of e)t.push(...splitPemBlocks(pemToString(n)));else t.push(...splitPemBlocks(pemToString(e)));let n=[];for(let e of t)try{n.push(X.TlsCertificate.new_from_pem(e,e.length))}catch{}return n}function pemToDer(e){let t=/-----BEGIN CERTIFICATE-----([\s\S]*?)-----END CERTIFICATE-----/.exec(e);if(!t)return new Uint8Array;let n=t[1].replace(/[\s\r\n]+/g,``);try{let e=globalThis.atob;if(!e)return new Uint8Array;let t=e(n),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r}catch{return new Uint8Array}}var gp=__esmMin(()=>{Z()});function createSecureContext(e){let t=e??{},n=null;if(t.cert)try{n=buildGioCertificate(t.cert,t.key)}catch{n=null}let r=t.ca?buildCaCertificates(t.ca):[],i={certificate:n,caCertificates:r,options:t};return i.context=i,i}var vp=__esmMin(()=>{gp()}),yp,bp=__esmMin(()=>{P(),yp=loadOptionalNativeModule(`GjsifyTls`,[`Tls`,`SessionAccess`]),yp.module}),xp=__esmMin(()=>{bp()});function parseDistinguishedName(e){if(!e)return{};let t={};for(let n of e.split(/,(?![^=]*=)/)){let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim(),o=t[r];o===void 0?t[r]=i:Array.isArray(o)?o.push(i):t[r]=[o,i]}return t}function formatCertDate(e){if(!e)return``;try{return e.format(`%b %d %H:%M:%S %Y GMT`)??``}catch{return``}}function formatAltNames(e){let t=[],n=e.get_dns_names();if(n)for(let e of n){let n=e.get_data();n&&t.push(`DNS:${new TextDecoder(`utf-8`).decode(n)}`)}let r=e.get_ip_addresses();if(r)for(let e of r)t.push(`IP Address:${e.to_string()}`);return t.join(`, `)}function fingerprintFromBytes(e,t){try{let n=new W.Checksum(t);n.update(e);let r=n.get_string();if(!r)return``;let i=[];for(let e=0;e<r.length;e+=2)i.push(r.slice(e,e+2).toUpperCase());return i.join(`:`)}catch{return``}}function tlsCertToPeerCert(e,t){let n={};try{n.subject=parseDistinguishedName(e.get_subject_name())}catch{}try{n.issuer=parseDistinguishedName(e.get_issuer_name())}catch{}n.subjectaltname=formatAltNames(e);try{n.valid_from=formatCertDate(e.get_not_valid_before()),n.valid_to=formatCertDate(e.get_not_valid_after())}catch{}try{let t=e,r=t.certificate_pem??t.certificatePem;if(r){let e=pemToDer(r);n.raw=e,n.fingerprint=fingerprintFromBytes(e,W.ChecksumType.SHA1),n.fingerprint256=fingerprintFromBytes(e,W.ChecksumType.SHA256)}}catch{}if(t)try{let t=e.get_issuer();t&&!t.is_same(e)?n.issuerCertificate=tlsCertToPeerCert(t,!0):t&&(n.issuerCertificate=n)}catch{}return n}var Sp=__esmMin(()=>{gp(),G()});function isIP(e){if(typeof e!=`string`)return 0;let t=e.includes(`%`)?e.slice(0,e.indexOf(`%`)):e,n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n)return n.slice(1).every(e=>(e.length===1||e[0]!==`0`)&&Number(e)<=255)?4:0;if(t.length===0||!t.includes(`:`))return 0;let r=/:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.exec(t),i=r?t.slice(0,t.length-r[0].length):t;if(r&&isIP(r[1])!==4)return 0;let o=i.split(`::`);if(o.length>2)return 0;let s=0;for(let e of o)if(e!==``)for(let t of e.split(`:`)){if(!/^[0-9a-fA-F]{1,4}$/.test(t))return 0;s++}let c=r?6:8;return o.length===2?s<c?6:0:s===c?6:0}function isIPv4(e){return isIP(e)===4}function isIPv6(e){return isIP(e)===6}var Cp=__esmMin(()=>{});function destroyedError(){let e=Error(`Cannot call write after a stream was destroyed`);return e.code=`ERR_STREAM_DESTROYED`,e}var Socket,wp=__esmMin(()=>{Z(),G(),Sa(),U(),kf(),Socket=class extends va{remoteAddress;remotePort;remoteFamily;localAddress;localPort;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!0;readyState=`closed`;_connection=null;_ioStream=null;_inputStream=null;_outputStream=null;_cancellable=new X.Cancellable;_readCancellable=new X.Cancellable;_reading=!1;_detaching=!1;_detachResolve=null;_pendingIo=0;_afterIo=null;_timeout=0;_timeoutId=null;constructor(e){super(e),this.allowHalfOpen=e?.allowHalfOpen??!1}_setConnection(e){this._connection=e}_setupFromIOStream(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===X.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),this._startReading()}_attachOutputOnly(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===X.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`)}_releaseIOStream(){let e=this._ioStream;return this._ioStream=null,this._inputStream=null,this._outputStream=null,this._connection=null,e}_claimConnection(){let e={connection:this._connection,ioStream:this._ioStream,inputStream:this._inputStream,outputStream:this._outputStream};return this._connection=null,this._ioStream=null,this._inputStream=null,this._outputStream=null,e}connect(e,t,n){let r;typeof e==`number`?(r={port:e,host:typeof t==`string`?t:`localhost`},typeof t==`function`&&(n=t)):(r=e,typeof t==`function`&&(n=t)),n&&this.once(`connect`,n),this.connecting=!0,this.readyState=`opening`,this.pending=!0;let i=r.host||`localhost`,o=r.port,s=new X.SocketClient;return r.timeout&&s.set_timeout(Math.ceil(r.timeout/1e3)),s.connect_to_host_async(i,o,this._cancellable,(e,t)=>{try{let e=s.connect_to_host_finish(t);if(this.destroyed){e.close(null);return}this._connection=e,this._setupConnection(r)}catch(e){this.connecting=!1,this.readyState=`closed`;let t=createNodeError$1(e,`connect`,{address:i,port:o});this.destroy(t)}}),this}_setupConnection(e,t=!0){if(!this._connection)return;let n=this._connection.get_socket();if(this._inputStream=this._connection.get_input_stream(),this._outputStream=this._connection.get_output_stream(),`keepAlive`in e&&e.keepAlive&&n.set_keepalive(!0),!(`noDelay`in e)||e.noDelay!==!1)try{n.set_option(6,1,1)}catch{}try{let e=this._connection.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===X.SocketFamily.IPV6?`IPv6`:`IPv4`}catch{}try{let e=this._connection.get_local_address();this.localAddress=e.get_address().to_string(),this.localPort=e.get_port()}catch{}this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),t&&this._startReading()}_startReading(){this._reading||!this._inputStream||(this._reading=!0,this._readLoop())}async _readLoop(){let e=this._inputStream;if(e)try{for(;this._reading&&e;){let t=await new Promise((t,n)=>{this._pendingIo++,e.read_bytes_async(16384,W.PRIORITY_DEFAULT,this._readCancellable,(r,i)=>{try{t(e.read_bytes_finish(i))}catch(e){n(e)}finally{this._ioSettled()}})});if(this._detaching){this._resolveDetach(t&&t.get_size()>0?H.from(gbytesToUint8Array(t)):null);return}if(!t||t.get_size()===0){this._reading=!1,this.allowHalfOpen?this.readyState=this.writable?`writeOnly`:`closed`:this.once(`end`,()=>{this.end(),this.readyState=`closed`}),this.push(null),this.read(0);break}let n=gbytesToUint8Array(t);if(this.bytesRead+=n.length,this._resetTimeout(),!this.push(H.from(n))){this._reading=!1;break}}}catch(e){if(this._detaching){this._resolveDetach(null);return}this._readCancellable.is_cancelled()||this.destroy(createNodeError$1(e,`read`,{address:this.remoteAddress}))}}_detachReader(){return this._reading?(this._detaching=!0,this._reading=!1,this._readCancellable.cancel(),new Promise(e=>{this._detachResolve=e})):Promise.resolve(null)}_resolveDetach(e){this._detaching=!1;let t=this._detachResolve;this._detachResolve=null,t&&t(e)}_read(e){!this._reading&&this._inputStream&&this._startReading()}_write(e,t,n){if(!this._outputStream){n(Error(`Socket is not connected`));return}let r=H.isBuffer(e)?e:typeof e==`string`?H.from(e,t):H.from(e),i=this._outputStream;this._pendingIo++,i.write_bytes_async(new W.Bytes(r),W.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{let r=null;try{let e=i.write_bytes_finish(t);this.bytesWritten+=e,this._resetTimeout()}catch(e){r=this._cancellable.is_cancelled()?destroyedError():createNodeError$1(e,`write`,{address:this.remoteAddress})}this._ioSettled(),n(r)})}_final(e){if(this._connection)try{this._connection.get_socket().shutdown(!1,!0),this.readyState=this.readable?`readOnly`:`closed`}catch{}else if(this._ioStream){try{this._ioStream.close(null),this.readyState=`closed`}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null}e()}_destroy(e,t){this._reading=!1,this._clearTimeout(),this._cancellable.cancel(),this._readCancellable.cancel();let release=()=>this._release(e,t);this._pendingIo===0?release():this._afterIo=release}_ioSettled(){if(this._pendingIo--,this._pendingIo===0&&this._afterIo){let e=this._afterIo;this._afterIo=null,e()}}_release(e,t){if(this._connection){try{this._connection.close(null)}catch{}this._connection=null}else if(this._ioStream)try{this._ioStream.close(null)}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null,this.readyState=`closed`,this.destroyed=!0,t(e)}setTimeout(e,t){return this._timeout=e,this._clearTimeout(),t&&this.once(`timeout`,t),e>0&&this._resetTimeout(),this}_resetTimeout(){this._clearTimeout(),this._timeout>0&&(this._timeoutId=setTimeout(()=>{this.emit(`timeout`)},this._timeout))}_clearTimeout(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}setKeepAlive(e,t){return this._connection?.get_socket().set_keepalive(e??!1),this}setNoDelay(e){if(this._connection)try{this._connection.get_socket().set_option(6,1,e===!1?0:1)}catch{}return this}destroySoon(){this.writable&&this.end(),this.writableFinished?this.destroy():this.once(`finish`,this.destroy.bind(this))}address(){return this.localAddress&&this.localPort?{port:this.localPort,family:this.remoteFamily||`IPv4`,address:this.localAddress}:{}}ref(){return this}unref(){return this}}}),Tp,Server$1,Ep=__esmMin(()=>{wp(),Z(),kf(),Kn(),P(),Tp=new Set,Server$1=class extends K{static{__name(this,`Server`)}listening=!1;maxConnections;allowHalfOpen;_service=null;_connections=new Set;_closingService=null;_address=null;constructor(e,t){super(),typeof e==`function`?(t=e,this.allowHalfOpen=!1):this.allowHalfOpen=e?.allowHalfOpen??!1,t&&this.on(`connection`,t)}listen(...e){let t=0,n=`0.0.0.0`,r=511,i;if(typeof e[0]==`object`&&e[0]!==null&&!Array.isArray(e[0])){let o=e[0];t=o.port??0,n=o.host??`0.0.0.0`,r=o.backlog??511,i=e[1]}else{typeof e[0]==`number`&&(t=e[0]);for(let t=1;t<e.length;t++)typeof e[t]==`string`?n=e[t]:typeof e[t]==`number`?r=e[t]:typeof e[t]==`function`&&(i=e[t])}i&&this.once(`listening`,i);try{releaseListenPort(t),this._service=new X.SocketService,this._service.set_backlog(r);let e;t===0?e=this._service.add_any_inet_port(null):(this._service.add_inet_port(t,null),e=t),this._service.connect(`incoming`,(e,t)=>(this._handleConnection(t),!0)),this._service.start(),ensureMainLoop(),this.listening=!0,Tp.add(this);let i=n.includes(`:`)?`IPv6`:`IPv4`;this._address={port:e,family:i,address:n},deferEmit(this,`listening`)}catch(e){this._service=null;let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_handleConnection(e){if(this.maxConnections&&this._connections.size>=this.maxConnections){try{e.close(null)}catch{}return}let t=new Socket({allowHalfOpen:this.allowHalfOpen});t._setConnection(e),t._setupConnection({},!1),this._connections.add(t),t.on(`close`,()=>{this._connections.delete(t),this._emitCloseIfDrained()}),this.emit(`connection`,t),t._startReading()}address(){return this._address}close(e){let t=this._service;return e&&this.once(`close`,t?e:()=>{let t=Error(`Server is not running.`);t.code=`ERR_SERVER_NOT_RUNNING`,e(t)}),t&&(this._service=null,this.listening=!1,this._closingService=t,closeSocketService(t,this._address?[this._address.port]:[],()=>{this._closingService===t&&(this._closingService=null),this._emitCloseIfDrained()})),this._emitCloseIfDrained(),this}_emitCloseIfDrained(){this._service||this._closingService||this._connections.size>0||(Tp.delete(this),nextTick(()=>this.emit(`close`)))}getConnections(e){e(null,this._connections.size)}ref(){return this}unref(){return this}}}),Dp=__exportAll$5({Server:()=>Server$1,Socket:()=>Socket,connect:()=>Op,createConnection:()=>createConnection,createServer:()=>createServer$1,default:()=>kp,isIP:()=>isIP,isIPv4:()=>isIPv4,isIPv6:()=>isIPv6});function createConnection(e,t,n){return new Socket().connect(e,t,n)}function createServer$1(e,t){return typeof e==`function`?new Server$1(e):new Server$1(e,t)}var Op,kp,Ap=__esmMin(()=>{Cp(),wp(),Ep(),Op=createConnection,__name(createServer$1,`createServer`),kp={Socket,Server:Server$1,isIP,isIPv4,isIPv6,createConnection,connect:Op,createServer:createServer$1}}),jp=__esmMin(()=>{N(),Sp(),vp(),xp(),Z(),G(),Ap()}),Mp=__esmMin(()=>{jp()}),Np=__esmMin(()=>{vp(),jp(),Z(),G(),Ap()}),Pp=__esmMin(()=>{bp()}),Fp=__esmMin(()=>{vp(),xp(),jp(),Mp(),Np(),Pp()});function resolveServerTls(e){let t=createSecureContext(e);if(e.cert&&!t.certificate)throw Error(`https.Server: cannot parse the key/cert pair as PEM`);if(!t.certificate)return null;let n=X.TlsAuthenticationMode.NONE;return e.requestCert&&(n=e.rejectUnauthorized===!1?X.TlsAuthenticationMode.REQUESTED:X.TlsAuthenticationMode.REQUIRED),{certificate:t.certificate,authenticationMode:n,clientCa:e.requestCert?t.caCertificates:[]}}function createTrustDatabase(e){let[t,n]=X.File.new_tmp(`gjsify-https-ca-XXXXXX.pem`);try{let r=e.map(e=>e.certificate_pem).join(`
|
|
233
|
-
`);return n.get_output_stream().write_all(new TextEncoder().encode(r),null),n.close(null),{database:X.TlsFileDatabase.new(t.get_path()),file:t}}catch(e){throw removeFile(t),e}}function removeFile(e){try{e.delete(null)}catch{}}var Ip=__esmMin(()=>{Z(),Fp()}),Lp,Rp=__esmMin(()=>{Lp=u}),zp,Bp=__esmMin(()=>{Rp(),zp=Lp}),Vp,Hp,Up=__esmMin(()=>{if(P(),Vp=openNativeLibrary(`GjsifyHttpSoupBridge`),Vp)throw Vp;Hp=d.Server,d.Request,d.Response}),OutgoingMessage,ServerResponse,Wp,Server,Gp=__esmMin(()=>{N(),mp(),fp(),pp(),Ip(),Bp(),Z(),U(),Kn(),Sa(),wp(),Up(),P(),OutgoingMessage=class extends _a{headersSent=!1;sendDate=!0;finished=!1;socket=null;_headers=new Map;setHeader(e,t){return this._headers.set(e.toLowerCase(),typeof t==`number`?String(t):t),this}getHeader(e){return this._headers.get(e.toLowerCase())}removeHeader(e){this._headers.delete(e.toLowerCase())}hasHeader(e){return this._headers.has(e.toLowerCase())}getHeaderNames(){return Array.from(this._headers.keys())}getHeaders(){let e={};for(let[t,n]of this._headers)e[t]=n;return e}appendHeader(e,t){let n=e.toLowerCase(),r=this._headers.get(n);return r===void 0?this._headers.set(n,t):Array.isArray(r)?Array.isArray(t)?r.push(...t):r.push(t):Array.isArray(t)?this._headers.set(n,[r,...t]):this._headers.set(n,[r,t]),this}flushHeaders(){this.headersSent=!0}_write(e,t,n){n()}},ServerResponse=class extends OutgoingMessage{statusCode=200;statusMessage=``;_streaming=!1;_bridge;_timeoutTimer=null;constructor(e){super(),this._bridge=e,e.connect(`close`,()=>{this.emit(`close`)})}setTimeout(e,t){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}writeHead(e,t,n){if(this.statusCode=e,typeof t==`object`&&(n=t,t=void 0),this.statusMessage=t||up[e]||``,n)for(let[e,t]of Object.entries(n))this.setHeader(e,t);return this}writeContinue(e){e&&Promise.resolve().then(e)}writeProcessing(e){e&&Promise.resolve().then(e)}flushHeaders(){this.headersSent||=!0}addTrailers(e){for(let[t,n]of Object.entries(e))this._headers.set(`trailer-`+t.toLowerCase(),n)}_startStreaming(){if(!this._streaming){this._streaming=!0,this.headersSent=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null);for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}}_write(e,t,n){let r=H.isBuffer(e)?e:typeof e==`string`?H.from(e,t):H.from(e);this._startStreaming(),this._bridge.write_chunk(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n()}_final(e){if(!this._streaming){for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}this._bridge.end(),this.finished=!0,e()}end(e,t,n){return typeof e==`function`?(n=e,e=void 0):typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),super.end(n),this}},Wp=new Set,Server=class extends K{listening=!1;maxHeadersCount=2e3;timeout=0;keepAliveTimeout=5e3;headersTimeout=6e4;requestTimeout=3e5;_bridge=null;_tls=null;_tlsRequested=!1;_trustFile=null;_address=null;get soupServer(){return this._bridge?.soup_server??null}constructor(e,t){super();let n=typeof e==`function`?e:t;n&&this.on(`request`,n)}_useTls(e){this._tlsRequested=!0,this._tls=resolveServerTls(e)}listen(...e){let t=0,n=`0.0.0.0`,r;for(let i of e)typeof i==`number`?t=i:typeof i==`string`?n=i:typeof i==`function`&&(r=i);if(this._tlsRequested&&!this._tls)return deferEmit(this,`error`,Error(`https.Server: no certificate — pass key and cert (PEM)`)),this;r&&this.once(`listening`,r);try{this._bridge=new Hp,this._bridge.connect(`request-received`,(e,t,n)=>{this._handleRequest(t,n)}),this._bridge.connect(`upgrade`,(e,t,n,r)=>{this._handleUpgrade(t,n)}),this._bridge.connect(`error-occurred`,(e,t)=>{this.emit(`error`,Error(t))});let e=this._tls?this._listenTls(this._bridge,t):this._listenPlain(this._bridge,t,n);ensureMainLoop(),this.listening=!0,this._address={port:e,family:`IPv4`,address:this._bridge.address||n},Wp.add(this),deferEmit(this,`listening`)}catch(e){let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_listenPlain(e,t,n){return e.listen(t,n),e.port}_listenTls(e,t){let n=this._tls,r=e.soup_server;if(r.tls_certificate=n.certificate,r.tls_auth_mode=n.authenticationMode,n.clientCa.length>0){let e=createTrustDatabase(n.clientCa);r.tls_database=e.database,this._trustFile&&removeFile(this._trustFile),this._trustFile=e.file}if(n.authenticationMode!==X.TlsAuthenticationMode.NONE){let e=n.authenticationMode===X.TlsAuthenticationMode.REQUIRED;r.connect(`request-started`,(t,n)=>{n.connect(`accept-certificate`,(t,n,r)=>!e||r===X.TlsCertificateFlags.NO_FLAGS)})}try{r.listen_local(t,zp.ServerListenOptions.IPV4_ONLY|zp.ServerListenOptions.HTTPS)}catch(e){throw this._trustFile&&removeFile(this._trustFile),this._trustFile=null,e}return(r.get_listeners()[0]?.get_local_address())?.get_port()??t}_handleRequest(e,t){let n=new IncomingMessage,r=new ServerResponse(t);n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let i=e.header_pairs??[];for(let e=0;e+1<i.length;e+=2){let t=i[e],r=i[e+1],o=t.toLowerCase();if(n.rawHeaders.push(t,r),o in n.headers){let e=n.headers[o];Array.isArray(e)?e.push(r):n.headers[o]=[e,r]}else n.headers[o]=r}n.socket=new ServerRequestSocket(e.remote_address??`127.0.0.1`,e.remote_port??0,this._address?.address??`127.0.0.1`,this._address?.port??0,t,this._tls!==null);let o=e.get_body();o.length>0?n._pushBody(o):n._pushBody(null),e.connect(`aborted_signal`,()=>{n.aborted||(n.aborted=!0,n.emit(`aborted`))}),e.connect(`close`,()=>{n.emit(`close`)});try{let e=this.emit(`request`,n,r);(e instanceof Promise||typeof e==`object`&&e&&typeof e.then==`function`)&&e.catch(e=>{if(M.error(`[HTTP] Unhandled error in async request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}})}catch(e){if(M.error(`[HTTP] Unhandled error in request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}}}_handleUpgrade(e,t){let n=new IncomingMessage;n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let r=e.header_pairs??[];for(let e=0;e+1<r.length;e+=2){let t=r[e],i=r[e+1],o=t.toLowerCase();n.rawHeaders.push(t,i),n.headers[o]=i}if(this.listenerCount(`upgrade`)>0){let r=new Socket;r._attachOutputOnly(t),n.socket=r,r.remoteAddress??=e.remote_address||void 0,r.remotePort??=e.remote_port??void 0,r.remoteFamily??=r.remoteAddress?.includes(`:`)?`IPv6`:`IPv4`,r.localAddress??=this._address?.address,r.localPort??=this._address?.port,this.emit(`upgrade`,n,r,H.alloc(0))}}address(){return this._address}addWebSocketHandler(e,t){if(!this._bridge)throw Error(`Server must be listening before adding WebSocket handlers. Call listen() first.`);this._bridge.soup_server.add_websocket_handler(e,null,null,(e,n,r,i)=>{t(i)})}close(e){return e&&this.once(`close`,e),this._bridge&&=(this._tls?this._bridge.soup_server.disconnect():this._bridge.close(),null),this._trustFile&&=(removeFile(this._trustFile),null),this.listening=!1,Wp.delete(this),deferEmit(this,`close`),this}setTimeout(e,t){return this.timeout=e,t&&this.on(`timeout`,t),this}}});function resolveRejectUnauthorized(e){return e===void 0?W.getenv(`NODE_TLS_REJECT_UNAUTHORIZED`)!==`0`:e!==!1}function createPeerVerifier(e){let t=resolveRejectUnauthorized(e.rejectUnauthorized),n=e.checkServerIdentity??checkServerIdentity,r=e.caCertificates??[],i=null;return{accept(o){return i=chainError(o,r)??n(e.host,tlsCertToPeerCert(o,!0))??null,i===null||!t},get error(){return i},get authorized(){return i===null},get authorizationError(){if(i)return i.code??i.message}}}function chainFlags(e,t){if(t.length===0)return X.TlsBackend.get_default().get_default_database().verify_chain(e,X.TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER,null,null,X.TlsDatabaseVerifyFlags.NONE,null);let n=X.TlsCertificateFlags.UNKNOWN_CA;for(let r of t){let t=e.verify(null,r)&Kp;if(t===X.TlsCertificateFlags.NO_FLAGS)return t;t&X.TlsCertificateFlags.UNKNOWN_CA||(n=t)}return n}function isSelfSigned(e){return e.get_subject_name()===e.get_issuer_name()}function verifyError(e,t){let n=Error(t);return n.code=e,n}function chainError(e,t=[]){let n=chainFlags(e,t)&Kp,r=X.TlsCertificateFlags;if(n===r.NO_FLAGS)return null;if(n&r.UNKNOWN_CA){if(isSelfSigned(e))return verifyError(`DEPTH_ZERO_SELF_SIGNED_CERT`,`self-signed certificate`);let t=e;for(let e=t.get_issuer();e&&!e.is_same(t);e=t.get_issuer())t=e;return t===e?verifyError(`UNABLE_TO_VERIFY_LEAF_SIGNATURE`,`unable to verify the first certificate`):isSelfSigned(t)?verifyError(`SELF_SIGNED_CERT_IN_CHAIN`,`self-signed certificate in certificate chain`):verifyError(`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`,`unable to get local issuer certificate`)}return n&r.REVOKED?verifyError(`CERT_REVOKED`,`certificate revoked`):n&r.EXPIRED?verifyError(`CERT_HAS_EXPIRED`,`certificate has expired`):n&r.NOT_ACTIVATED?verifyError(`CERT_NOT_YET_VALID`,`certificate is not yet valid`):n&r.INSECURE?verifyError(`CA_MD_TOO_WEAK`,`CA signature digest algorithm too weak`):verifyError(`CERT_REJECTED`,`certificate rejected`)}var Kp,qp=__esmMin(()=>{hp(),Sp(),vp(),Z(),G(),Kp=X.TlsCertificateFlags.VALIDATE_ALL&~X.TlsCertificateFlags.BAD_IDENTITY}),ClientRequest,Jp=__esmMin(()=>{pp(),Gp(),G(),Bp(),Z(),U(),Vr(),kf(),qp(),ClientRequest=class extends OutgoingMessage{method;path;protocol;host;hostname;port;aborted=!1;reusedSocket=!1;maxHeadersCount=2e3;_chunks=[];_session;_message;_cancellable;_timeout=0;_timeoutTimer=null;_responseCallback;_tlsRejection=null;constructor(e,t,n){super();let r;if(typeof e==`string`||e instanceof J){let i=typeof e==`string`?new J(e):e;r={protocol:i.protocol,hostname:i.hostname,port:i.port?Number(i.port):void 0,path:i.pathname+i.search,...typeof t==`object`?t:{}},typeof t==`function`&&(n=t)}else r=e,typeof t==`function`&&(n=t);if(this.method=(r.method||`GET`).toUpperCase(),this.protocol=r.protocol||`http:`,this.hostname=r.hostname||r.host?.split(`:`)[0]||`localhost`,this.port=Number(r.port)||(this.protocol===`https:`?443:80),this.path=r.path||`/`,this.host=r.host||`${this.hostname}:${this.port}`,this._timeout=r.timeout||0,n&&(this._responseCallback=n,this.once(`response`,n)),r.headers)for(let[e,t]of Object.entries(r.headers))this.setHeader(e,t);if(r.setHost!==!1&&!this._headers.has(`host`)){let e=this.protocol===`https:`?443:80,t=this.port===e?this.hostname:`${this.hostname}:${this.port}`;this.setHeader(`Host`,t)}r.auth&&!this._headers.has(`authorization`)&&this.setHeader(`Authorization`,`Basic `+H.from(r.auth).toString(`base64`)),r.signal&&(r.signal.aborted?this.abort():r.signal.addEventListener(`abort`,()=>this.abort(),{once:!0}));let i=W.Uri.parse(this._buildUrl(),W.UriFlags.NONE);this._session=new zp.Session,this._message=new zp.Message({method:this.method,uri:i}),this._cancellable=new X.Cancellable,this.protocol===`https:`&&this._setupTls(r),this._timeout>0&&(this._session.timeout=Math.ceil(this._timeout/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},this._timeout))}_setupTls(e){let t=e.agent===void 0?e._defaultAgent:e.agent,n=t&&typeof t==`object`?t.options:void 0,r={...e,...n},i=r.secureContext??createSecureContext(r),o=createPeerVerifier({caCertificates:i.caCertificates,rejectUnauthorized:r.rejectUnauthorized,host:r.servername||this.hostname,checkServerIdentity:r.checkServerIdentity});this._session.set_tls_database(null),this._message.connect(`accept-certificate`,(e,t,n)=>{let r=o.accept(t);return this._tlsRejection=r?null:o.error,r}),i.certificate&&this._message.set_tls_client_certificate(i.certificate)}_buildUrl(){let e=this.protocol.endsWith(`:`)?this.protocol:this.protocol+`:`,t=e===`https:`?443:80,n=this.port===t?``:`:${this.port}`;return`${e}//${this.hostname}${n}${this.path}`}getRawHeaderNames(){return Array.from(this._headers.keys())}flushHeaders(){this.headersSent||this._applyHeaders()}setTimeout(e,t){return this._timeout=e,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._session.timeout=Math.ceil(e/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}abort(){this.aborted||(this.aborted=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this._cancellable.cancel(),this.emit(`abort`),this.destroy())}_write(e,t,n){let r=H.isBuffer(e)?e:typeof e==`string`?H.from(e,t):H.from(e);this._chunks.push(r),n()}_final(e){this._sendRequest().then(()=>e()).catch(t=>e(t))}_applyHeaders(){if(this.headersSent)return;this.headersSent=!0;let e=this._message.get_request_headers();for(let[t,n]of this._headers)if(Array.isArray(n))for(let r of n)e.append(t,r);else e.replace(t,n)}async _sendRequest(){this._applyHeaders();let e=H.concat(this._chunks);if(e.length>0){let t=this._headers.get(`content-type`)||`application/octet-stream`;this._message.set_request_body_from_bytes(t,new W.Bytes(e))}try{let e=await new Promise((e,t)=>{this._session.send_async(this._message,W.PRIORITY_DEFAULT,this._cancellable,(n,r)=>{try{e(this._session.send_finish(r))}catch(e){t(e)}})}),t=[];try{let n;for(;(n=await readBytesAsync(e,4096,W.PRIORITY_DEFAULT,this._cancellable))!==null;)t.push(H.from(n))}catch{}let n=new IncomingMessage;n.statusCode=this._message.status_code,n.statusMessage=this._message.get_reason_phrase(),n.httpVersion=`1.1`,this._message.get_response_headers().foreach((e,t)=>{let r=e.toLowerCase();if(n.rawHeaders.push(e,t),r in n.headers){let e=n.headers[r];Array.isArray(e)?e.push(t):n.headers[r]=[e,t]}else n.headers[r]=t}),this.finished=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this.emit(`response`,n),setTimeout(()=>{for(let e of t)n.push(e);n.push(null),n.complete=!0},0)}catch(e){this.aborted?this.emit(`abort`):this._tlsRejection?this.emit(`error`,this._tlsRejection):this.emit(`error`,e instanceof Error?e:Error(String(e)))}}}}),Yp=__exportAll$5({Agent:()=>Agent,ClientRequest:()=>ClientRequest,IncomingMessage:()=>IncomingMessage,METHODS:()=>dp,OutgoingMessage:()=>OutgoingMessage,STATUS_CODES:()=>up,Server:()=>Server,ServerResponse:()=>ServerResponse,createServer:()=>createServer,default:()=>Qp,get:()=>get,globalAgent:()=>Xp,maxHeaderSize:()=>Zp,request:()=>request,setMaxIdleHTTPParsers:()=>setMaxIdleHTTPParsers,validateHeaderName:()=>validateHeaderName,validateHeaderValue:()=>validateHeaderValue});function createServer(e,t){return typeof e==`function`?new Server(e):new Server(t)}function request(e,t,n){return new ClientRequest(e,t,n)}function get(e,t,n){let r,i=n;typeof e==`string`||e instanceof J?(r=typeof t==`object`?{...t,method:`GET`}:{method:`GET`},typeof t==`function`&&(i=t)):(r={...e,method:`GET`},typeof t==`function`&&(i=t),e=r);let o=typeof e==`string`||e instanceof J?new ClientRequest(e,{...r,method:`GET`},i):new ClientRequest({...r,method:`GET`},i);return o.end(),o}function setMaxIdleHTTPParsers(e){}var Agent,Xp,Zp,Qp,$p=__esmMin(()=>{lp(),fp(),pp(),Gp(),Jp(),Vr(),Agent=class{defaultPort=80;protocol=`http:`;maxSockets;maxTotalSockets;maxFreeSockets;keepAliveMsecs;keepAlive;scheduling;requests={};sockets={};freeSockets={};options;constructor(e){this.options={...e},this.keepAlive=e?.keepAlive??!1,this.keepAliveMsecs=e?.keepAliveMsecs??1e3,this.maxSockets=e?.maxSockets??1/0,this.maxTotalSockets=e?.maxTotalSockets??1/0,this.maxFreeSockets=e?.maxFreeSockets??256,this.scheduling=e?.scheduling??`lifo`}destroy(){}getName(e){let t=e.host||`localhost`;return e.port&&(t+=`:`+e.port),e.localAddress&&(t+=`:`+e.localAddress),(e.family===4||e.family===6)&&(t+=`:`+e.family),t}},Xp=new Agent,Zp=16384,Qp={STATUS_CODES:up,METHODS:dp,Server,IncomingMessage,OutgoingMessage,ServerResponse,ClientRequest,Agent,globalAgent:Xp,createServer,request,get,validateHeaderName,validateHeaderValue,maxHeaderSize:Zp,setMaxIdleHTTPParsers}}),em=__commonJSMin(((e,t)=>{
|
|
232
|
+
`):typeof e==`string`?e:e instanceof Uint8Array?new TextDecoder(`utf-8`).decode(e):String(e)}function splitPemBlocks(e){let t=[],n=/-----BEGIN [^-]+-----[\s\S]*?-----END [^-]+-----/g,r;for(;(r=n.exec(e))!==null;)t.push(r[0]);return t}function buildGioCertificate(e,t){let n=pemToString(e),r=t?pemToString(t):``,i=r?`${n}\n${r}`:n;return X.TlsCertificate.new_from_pem(i,i.length)}function buildCaCertificates(e){let t=[];if(Array.isArray(e))for(let n of e)t.push(...splitPemBlocks(pemToString(n)));else t.push(...splitPemBlocks(pemToString(e)));let n=[];for(let e of t)try{n.push(X.TlsCertificate.new_from_pem(e,e.length))}catch{}return n}function pemToDer(e){let t=/-----BEGIN CERTIFICATE-----([\s\S]*?)-----END CERTIFICATE-----/.exec(e);if(!t)return new Uint8Array;let n=t[1].replace(/[\s\r\n]+/g,``);try{let e=globalThis.atob;if(!e)return new Uint8Array;let t=e(n),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r}catch{return new Uint8Array}}var gp=__esmMin(()=>{Z()});function createSecureContext(e){let t=e??{},n=null;if(t.cert)try{n=buildGioCertificate(t.cert,t.key)}catch{n=null}let r=t.ca?buildCaCertificates(t.ca):[],i={certificate:n,caCertificates:r,options:t};return i.context=i,i}var vp=__esmMin(()=>{gp()}),yp,bp=__esmMin(()=>{P(),yp=loadOptionalNativeModule(`GjsifyTls`,[`Tls`,`SessionAccess`]),yp.module}),xp=__esmMin(()=>{bp()});function parseDistinguishedName(e){if(!e)return{};let t={};for(let n of e.split(/,(?![^=]*=)/)){let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim(),o=t[r];o===void 0?t[r]=i:Array.isArray(o)?o.push(i):t[r]=[o,i]}return t}function formatCertDate(e){if(!e)return``;try{return e.format(`%b %d %H:%M:%S %Y GMT`)??``}catch{return``}}function formatAltNames(e){let t=[],n=e.get_dns_names();if(n)for(let e of n){let n=e.get_data();n&&t.push(`DNS:${new TextDecoder(`utf-8`).decode(n)}`)}let r=e.get_ip_addresses();if(r)for(let e of r)t.push(`IP Address:${e.to_string()}`);return t.join(`, `)}function fingerprintFromBytes(e,t){try{let n=new W.Checksum(t);n.update(e);let r=n.get_string();if(!r)return``;let i=[];for(let e=0;e<r.length;e+=2)i.push(r.slice(e,e+2).toUpperCase());return i.join(`:`)}catch{return``}}function tlsCertToPeerCert(e,t){let n={};try{n.subject=parseDistinguishedName(e.get_subject_name())}catch{}try{n.issuer=parseDistinguishedName(e.get_issuer_name())}catch{}n.subjectaltname=formatAltNames(e);try{n.valid_from=formatCertDate(e.get_not_valid_before()),n.valid_to=formatCertDate(e.get_not_valid_after())}catch{}try{let t=e,r=t.certificate_pem??t.certificatePem;if(r){let e=pemToDer(r);n.raw=e,n.fingerprint=fingerprintFromBytes(e,W.ChecksumType.SHA1),n.fingerprint256=fingerprintFromBytes(e,W.ChecksumType.SHA256)}}catch{}if(t)try{let t=e.get_issuer();t&&!t.is_same(e)?n.issuerCertificate=tlsCertToPeerCert(t,!0):t&&(n.issuerCertificate=n)}catch{}return n}var Sp=__esmMin(()=>{gp(),G()});function resolveRejectUnauthorized(e){return e===void 0?W.getenv(`NODE_TLS_REJECT_UNAUTHORIZED`)!==`0`:e!==!1}function createPeerVerifier(e){let t=resolveRejectUnauthorized(e.rejectUnauthorized),n=e.checkServerIdentity??checkServerIdentity,r=e.caCertificates??[],i=null;return{accept(o){return i=chainError(o,r)??n(e.host,tlsCertToPeerCert(o,!0))??null,i===null||!t},get error(){return i},get authorized(){return i===null},get authorizationError(){if(i)return i.code??i.message}}}function chainFlags(e,t){if(t.length===0)return X.TlsBackend.get_default().get_default_database().verify_chain(e,X.TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER,null,null,X.TlsDatabaseVerifyFlags.NONE,null);let n=X.TlsCertificateFlags.UNKNOWN_CA;for(let r of t){let t=e.verify(null,r)&chainFlagsMask();if(t===X.TlsCertificateFlags.NO_FLAGS)return t;t&X.TlsCertificateFlags.UNKNOWN_CA||(n=t)}return n}function isSelfSigned(e){return e.get_subject_name()===e.get_issuer_name()}function verifyError(e,t){let n=Error(t);return n.code=e,n}function chainError(e,t=[]){let n=chainFlags(e,t)&chainFlagsMask(),r=X.TlsCertificateFlags;if(n===r.NO_FLAGS)return null;if(n&r.UNKNOWN_CA){if(isSelfSigned(e))return verifyError(`DEPTH_ZERO_SELF_SIGNED_CERT`,`self-signed certificate`);let t=e;for(let e=t.get_issuer();e&&!e.is_same(t);e=t.get_issuer())t=e;return t===e?verifyError(`UNABLE_TO_VERIFY_LEAF_SIGNATURE`,`unable to verify the first certificate`):isSelfSigned(t)?verifyError(`SELF_SIGNED_CERT_IN_CHAIN`,`self-signed certificate in certificate chain`):verifyError(`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`,`unable to get local issuer certificate`)}return n&r.REVOKED?verifyError(`CERT_REVOKED`,`certificate revoked`):n&r.EXPIRED?verifyError(`CERT_HAS_EXPIRED`,`certificate has expired`):n&r.NOT_ACTIVATED?verifyError(`CERT_NOT_YET_VALID`,`certificate is not yet valid`):n&r.INSECURE?verifyError(`CA_MD_TOO_WEAK`,`CA signature digest algorithm too weak`):verifyError(`CERT_REJECTED`,`certificate rejected`)}var chainFlagsMask,Cp=__esmMin(()=>{hp(),Sp(),vp(),Z(),G(),chainFlagsMask=()=>X.TlsCertificateFlags.VALIDATE_ALL&~X.TlsCertificateFlags.BAD_IDENTITY});function isIP(e){if(typeof e!=`string`)return 0;let t=e.includes(`%`)?e.slice(0,e.indexOf(`%`)):e,n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n)return n.slice(1).every(e=>(e.length===1||e[0]!==`0`)&&Number(e)<=255)?4:0;if(t.length===0||!t.includes(`:`))return 0;let r=/:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.exec(t),i=r?t.slice(0,t.length-r[0].length):t;if(r&&isIP(r[1])!==4)return 0;let o=i.split(`::`);if(o.length>2)return 0;let s=0;for(let e of o)if(e!==``)for(let t of e.split(`:`)){if(!/^[0-9a-fA-F]{1,4}$/.test(t))return 0;s++}let c=r?6:8;return o.length===2?s<c?6:0:s===c?6:0}function isIPv4(e){return isIP(e)===4}function isIPv6(e){return isIP(e)===6}var wp=__esmMin(()=>{});function destroyedError(){let e=Error(`Cannot call write after a stream was destroyed`);return e.code=`ERR_STREAM_DESTROYED`,e}var Socket,Tp=__esmMin(()=>{Z(),G(),Sa(),U(),kf(),Socket=class extends va{remoteAddress;remotePort;remoteFamily;localAddress;localPort;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!0;readyState=`closed`;_connection=null;_ioStream=null;_inputStream=null;_outputStream=null;_cancellable=new X.Cancellable;_readCancellable=new X.Cancellable;_reading=!1;_detaching=!1;_detachResolve=null;_pendingIo=0;_afterIo=null;_timeout=0;_timeoutId=null;constructor(e){super(e),this.allowHalfOpen=e?.allowHalfOpen??!1}_setConnection(e){this._connection=e}_setupFromIOStream(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===X.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),this._startReading()}_attachOutputOnly(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===X.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`)}_releaseIOStream(){let e=this._ioStream;return this._ioStream=null,this._inputStream=null,this._outputStream=null,this._connection=null,e}_claimConnection(){let e={connection:this._connection,ioStream:this._ioStream,inputStream:this._inputStream,outputStream:this._outputStream};return this._connection=null,this._ioStream=null,this._inputStream=null,this._outputStream=null,e}connect(e,t,n){let r;typeof e==`number`?(r={port:e,host:typeof t==`string`?t:`localhost`},typeof t==`function`&&(n=t)):(r=e,typeof t==`function`&&(n=t)),n&&this.once(`connect`,n),this.connecting=!0,this.readyState=`opening`,this.pending=!0;let i=r.host||`localhost`,o=r.port,s=new X.SocketClient;return r.timeout&&s.set_timeout(Math.ceil(r.timeout/1e3)),s.connect_to_host_async(i,o,this._cancellable,(e,t)=>{try{let e=s.connect_to_host_finish(t);if(this.destroyed){e.close(null);return}this._connection=e,this._setupConnection(r)}catch(e){this.connecting=!1,this.readyState=`closed`;let t=createNodeError$1(e,`connect`,{address:i,port:o});this.destroy(t)}}),this}_setupConnection(e,t=!0){if(!this._connection)return;let n=this._connection.get_socket();if(this._inputStream=this._connection.get_input_stream(),this._outputStream=this._connection.get_output_stream(),`keepAlive`in e&&e.keepAlive&&n.set_keepalive(!0),!(`noDelay`in e)||e.noDelay!==!1)try{n.set_option(6,1,1)}catch{}try{let e=this._connection.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===X.SocketFamily.IPV6?`IPv6`:`IPv4`}catch{}try{let e=this._connection.get_local_address();this.localAddress=e.get_address().to_string(),this.localPort=e.get_port()}catch{}this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),t&&this._startReading()}_startReading(){this._reading||!this._inputStream||(this._reading=!0,this._readLoop())}async _readLoop(){let e=this._inputStream;if(e)try{for(;this._reading&&e;){let t=await new Promise((t,n)=>{this._pendingIo++,e.read_bytes_async(16384,W.PRIORITY_DEFAULT,this._readCancellable,(r,i)=>{try{t(e.read_bytes_finish(i))}catch(e){n(e)}finally{this._ioSettled()}})});if(this._detaching){this._resolveDetach(t&&t.get_size()>0?H.from(gbytesToUint8Array(t)):null);return}if(!t||t.get_size()===0){this._reading=!1,this.allowHalfOpen?this.readyState=this.writable?`writeOnly`:`closed`:this.once(`end`,()=>{this.end(),this.readyState=`closed`}),this.push(null),this.read(0);break}let n=gbytesToUint8Array(t);if(this.bytesRead+=n.length,this._resetTimeout(),!this.push(H.from(n))){this._reading=!1;break}}}catch(e){if(this._detaching){this._resolveDetach(null);return}this._readCancellable.is_cancelled()||this.destroy(createNodeError$1(e,`read`,{address:this.remoteAddress}))}}_detachReader(){return this._reading?(this._detaching=!0,this._reading=!1,this._readCancellable.cancel(),new Promise(e=>{this._detachResolve=e})):Promise.resolve(null)}_resolveDetach(e){this._detaching=!1;let t=this._detachResolve;this._detachResolve=null,t&&t(e)}_read(e){!this._reading&&this._inputStream&&this._startReading()}_write(e,t,n){if(!this._outputStream){n(Error(`Socket is not connected`));return}let r=H.isBuffer(e)?e:typeof e==`string`?H.from(e,t):H.from(e),i=this._outputStream;this._pendingIo++,i.write_bytes_async(new W.Bytes(r),W.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{let r=null;try{let e=i.write_bytes_finish(t);this.bytesWritten+=e,this._resetTimeout()}catch(e){r=this._cancellable.is_cancelled()?destroyedError():createNodeError$1(e,`write`,{address:this.remoteAddress})}this._ioSettled(),n(r)})}_final(e){if(this._connection)try{this._connection.get_socket().shutdown(!1,!0),this.readyState=this.readable?`readOnly`:`closed`}catch{}else if(this._ioStream){try{this._ioStream.close(null),this.readyState=`closed`}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null}e()}_destroy(e,t){this._reading=!1,this._clearTimeout(),this._cancellable.cancel(),this._readCancellable.cancel();let release=()=>this._release(e,t);this._pendingIo===0?release():this._afterIo=release}_ioSettled(){if(this._pendingIo--,this._pendingIo===0&&this._afterIo){let e=this._afterIo;this._afterIo=null,e()}}_release(e,t){if(this._connection){try{this._connection.close(null)}catch{}this._connection=null}else if(this._ioStream)try{this._ioStream.close(null)}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null,this.readyState=`closed`,this.destroyed=!0,t(e)}setTimeout(e,t){return this._timeout=e,this._clearTimeout(),t&&this.once(`timeout`,t),e>0&&this._resetTimeout(),this}_resetTimeout(){this._clearTimeout(),this._timeout>0&&(this._timeoutId=setTimeout(()=>{this.emit(`timeout`)},this._timeout))}_clearTimeout(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_gioSocket(){let e=this._connection;for(;e instanceof X.TlsConnection;)e=e.base_io_stream;return e instanceof X.SocketConnection?e.get_socket():null}setKeepAlive(e,t){return this._gioSocket()?.set_keepalive(e??!1),this}setNoDelay(e){try{this._gioSocket()?.set_option(6,1,e===!1?0:1)}catch{}return this}destroySoon(){this.writable&&this.end(),this.writableFinished?this.destroy():this.once(`finish`,this.destroy.bind(this))}address(){return this.localAddress&&this.localPort?{port:this.localPort,family:this.remoteFamily||`IPv4`,address:this.localAddress}:{}}ref(){return this}unref(){return this}}}),Ep,Server$1,Dp=__esmMin(()=>{Tp(),Z(),kf(),Kn(),P(),Ep=new Set,Server$1=class extends K{static{__name(this,`Server`)}listening=!1;maxConnections;allowHalfOpen;_service=null;_connections=new Set;_closingService=null;_address=null;constructor(e,t){super(),typeof e==`function`?(t=e,this.allowHalfOpen=!1):this.allowHalfOpen=e?.allowHalfOpen??!1,t&&this.on(`connection`,t)}listen(...e){let t=0,n=`0.0.0.0`,r=511,i;if(typeof e[0]==`object`&&e[0]!==null&&!Array.isArray(e[0])){let o=e[0];t=o.port??0,n=o.host??`0.0.0.0`,r=o.backlog??511,i=e[1]}else{typeof e[0]==`number`&&(t=e[0]);for(let t=1;t<e.length;t++)typeof e[t]==`string`?n=e[t]:typeof e[t]==`number`?r=e[t]:typeof e[t]==`function`&&(i=e[t])}i&&this.once(`listening`,i);try{releaseListenPort(t),this._service=new X.SocketService,this._service.set_backlog(r);let e;t===0?e=this._service.add_any_inet_port(null):(this._service.add_inet_port(t,null),e=t),this._service.connect(`incoming`,(e,t)=>(this._handleConnection(t),!0)),this._service.start(),ensureMainLoop(),this.listening=!0,Ep.add(this);let i=n.includes(`:`)?`IPv6`:`IPv4`;this._address={port:e,family:i,address:n},deferEmit(this,`listening`)}catch(e){this._service=null;let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_handleConnection(e){if(this.maxConnections&&this._connections.size>=this.maxConnections){try{e.close(null)}catch{}return}let t=new Socket({allowHalfOpen:this.allowHalfOpen});t._setConnection(e),t._setupConnection({},!1),this._connections.add(t),t.on(`close`,()=>{this._connections.delete(t),this._emitCloseIfDrained()}),this.emit(`connection`,t),t._startReading()}address(){return this._address}close(e){let t=this._service;return e&&this.once(`close`,t?e:()=>{let t=Error(`Server is not running.`);t.code=`ERR_SERVER_NOT_RUNNING`,e(t)}),t&&(this._service=null,this.listening=!1,this._closingService=t,closeSocketService(t,this._address?[this._address.port]:[],()=>{this._closingService===t&&(this._closingService=null),this._emitCloseIfDrained()})),this._emitCloseIfDrained(),this}_emitCloseIfDrained(){this._service||this._closingService||this._connections.size>0||(Ep.delete(this),nextTick(()=>this.emit(`close`)))}getConnections(e){e(null,this._connections.size)}ref(){return this}unref(){return this}}}),Op=__exportAll$5({Server:()=>Server$1,Socket:()=>Socket,connect:()=>kp,createConnection:()=>createConnection,createServer:()=>createServer$1,default:()=>Ap,isIP:()=>isIP,isIPv4:()=>isIPv4,isIPv6:()=>isIPv6});function createConnection(e,t,n){return new Socket().connect(e,t,n)}function createServer$1(e,t){return typeof e==`function`?new Server$1(e):new Server$1(e,t)}var kp,Ap,jp=__esmMin(()=>{wp(),Tp(),Dp(),kp=createConnection,__name(createServer$1,`createServer`),Ap={Socket,Server:Server$1,isIP,isIPv4,isIPv6,createConnection,connect:kp,createServer:createServer$1}}),Mp=__esmMin(()=>{N(),Sp(),vp(),xp(),Cp(),Z(),G(),jp()}),Np=__esmMin(()=>{Mp()}),Pp=__esmMin(()=>{vp(),Mp(),Z(),G(),jp()}),Fp=__esmMin(()=>{bp()}),Ip=__esmMin(()=>{vp(),xp(),Mp(),Np(),Pp(),Fp()});function resolveServerTls(e){let t=createSecureContext(e);if(e.cert&&!t.certificate)throw Error(`https.Server: cannot parse the key/cert pair as PEM`);if(!t.certificate)return null;let n=X.TlsAuthenticationMode.NONE;return e.requestCert&&(n=e.rejectUnauthorized===!1?X.TlsAuthenticationMode.REQUESTED:X.TlsAuthenticationMode.REQUIRED),{certificate:t.certificate,authenticationMode:n,clientCa:e.requestCert?t.caCertificates:[]}}function createTrustDatabase(e){let[t,n]=X.File.new_tmp(`gjsify-https-ca-XXXXXX.pem`);try{let r=e.map(e=>e.certificate_pem).join(`
|
|
233
|
+
`);return n.get_output_stream().write_all(new TextEncoder().encode(r),null),n.close(null),{database:X.TlsFileDatabase.new(t.get_path()),file:t}}catch(e){throw removeFile(t),e}}function removeFile(e){try{e.delete(null)}catch{}}var Lp=__esmMin(()=>{Z(),Ip()}),Rp,zp=__esmMin(()=>{Rp=u}),Bp,Vp=__esmMin(()=>{zp(),Bp=Rp}),Hp,Up,Wp=__esmMin(()=>{if(P(),Hp=openNativeLibrary(`GjsifyHttpSoupBridge`),Hp)throw Hp;Up=d.Server,d.Request,d.Response}),OutgoingMessage,ServerResponse,Gp,Server,Kp=__esmMin(()=>{N(),mp(),fp(),pp(),Lp(),Vp(),Z(),U(),Kn(),Sa(),Tp(),Wp(),P(),OutgoingMessage=class extends _a{headersSent=!1;sendDate=!0;finished=!1;socket=null;_headers=new Map;setHeader(e,t){return this._headers.set(e.toLowerCase(),typeof t==`number`?String(t):t),this}getHeader(e){return this._headers.get(e.toLowerCase())}removeHeader(e){this._headers.delete(e.toLowerCase())}hasHeader(e){return this._headers.has(e.toLowerCase())}getHeaderNames(){return Array.from(this._headers.keys())}getHeaders(){let e={};for(let[t,n]of this._headers)e[t]=n;return e}appendHeader(e,t){let n=e.toLowerCase(),r=this._headers.get(n);return r===void 0?this._headers.set(n,t):Array.isArray(r)?Array.isArray(t)?r.push(...t):r.push(t):Array.isArray(t)?this._headers.set(n,[r,...t]):this._headers.set(n,[r,t]),this}flushHeaders(){this.headersSent=!0}_write(e,t,n){n()}},ServerResponse=class extends OutgoingMessage{statusCode=200;statusMessage=``;_streaming=!1;_bridge;_timeoutTimer=null;constructor(e){super(),this._bridge=e,e.connect(`close`,()=>{this.emit(`close`)})}setTimeout(e,t){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}writeHead(e,t,n){if(this.statusCode=e,typeof t==`object`&&(n=t,t=void 0),this.statusMessage=t||up[e]||``,n)for(let[e,t]of Object.entries(n))this.setHeader(e,t);return this}writeContinue(e){e&&Promise.resolve().then(e)}writeProcessing(e){e&&Promise.resolve().then(e)}flushHeaders(){this.headersSent||=!0}addTrailers(e){for(let[t,n]of Object.entries(e))this._headers.set(`trailer-`+t.toLowerCase(),n)}_startStreaming(){if(!this._streaming){this._streaming=!0,this.headersSent=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null);for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}}_write(e,t,n){let r=H.isBuffer(e)?e:typeof e==`string`?H.from(e,t):H.from(e);this._startStreaming(),this._bridge.write_chunk(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n()}_final(e){if(!this._streaming){for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}this._bridge.end(),this.finished=!0,e()}end(e,t,n){return typeof e==`function`?(n=e,e=void 0):typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),super.end(n),this}},Gp=new Set,Server=class extends K{listening=!1;maxHeadersCount=2e3;timeout=0;keepAliveTimeout=5e3;headersTimeout=6e4;requestTimeout=3e5;_bridge=null;_tls=null;_tlsRequested=!1;_trustFile=null;_address=null;get soupServer(){return this._bridge?.soup_server??null}constructor(e,t){super();let n=typeof e==`function`?e:t;n&&this.on(`request`,n)}_useTls(e){this._tlsRequested=!0,this._tls=resolveServerTls(e)}listen(...e){let t=0,n=`0.0.0.0`,r;for(let i of e)typeof i==`number`?t=i:typeof i==`string`?n=i:typeof i==`function`&&(r=i);if(this._tlsRequested&&!this._tls)return deferEmit(this,`error`,Error(`https.Server: no certificate — pass key and cert (PEM)`)),this;r&&this.once(`listening`,r);try{this._bridge=new Up,this._bridge.connect(`request-received`,(e,t,n)=>{this._handleRequest(t,n)}),this._bridge.connect(`upgrade`,(e,t,n,r)=>{this._handleUpgrade(t,n)}),this._bridge.connect(`error-occurred`,(e,t)=>{this.emit(`error`,Error(t))});let e=this._tls?this._listenTls(this._bridge,t):this._listenPlain(this._bridge,t,n);ensureMainLoop(),this.listening=!0,this._address={port:e,family:`IPv4`,address:this._bridge.address||n},Gp.add(this),deferEmit(this,`listening`)}catch(e){let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_listenPlain(e,t,n){return e.listen(t,n),e.port}_listenTls(e,t){let n=this._tls,r=e.soup_server;if(r.tls_certificate=n.certificate,r.tls_auth_mode=n.authenticationMode,n.clientCa.length>0){let e=createTrustDatabase(n.clientCa);r.tls_database=e.database,this._trustFile&&removeFile(this._trustFile),this._trustFile=e.file}if(n.authenticationMode!==X.TlsAuthenticationMode.NONE){let e=n.authenticationMode===X.TlsAuthenticationMode.REQUIRED;r.connect(`request-started`,(t,n)=>{n.connect(`accept-certificate`,(t,n,r)=>!e||r===X.TlsCertificateFlags.NO_FLAGS)})}try{r.listen_local(t,Bp.ServerListenOptions.IPV4_ONLY|Bp.ServerListenOptions.HTTPS)}catch(e){throw this._trustFile&&removeFile(this._trustFile),this._trustFile=null,e}return(r.get_listeners()[0]?.get_local_address())?.get_port()??t}_handleRequest(e,t){let n=new IncomingMessage,r=new ServerResponse(t);n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let i=e.header_pairs??[];for(let e=0;e+1<i.length;e+=2){let t=i[e],r=i[e+1],o=t.toLowerCase();if(n.rawHeaders.push(t,r),o in n.headers){let e=n.headers[o];Array.isArray(e)?e.push(r):n.headers[o]=[e,r]}else n.headers[o]=r}n.socket=new ServerRequestSocket(e.remote_address??`127.0.0.1`,e.remote_port??0,this._address?.address??`127.0.0.1`,this._address?.port??0,t,this._tls!==null);let o=e.get_body();o.length>0?n._pushBody(o):n._pushBody(null),e.connect(`aborted_signal`,()=>{n.aborted||(n.aborted=!0,n.emit(`aborted`))}),e.connect(`close`,()=>{n.emit(`close`)});try{let e=this.emit(`request`,n,r);(e instanceof Promise||typeof e==`object`&&e&&typeof e.then==`function`)&&e.catch(e=>{if(M.error(`[HTTP] Unhandled error in async request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}})}catch(e){if(M.error(`[HTTP] Unhandled error in request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}}}_handleUpgrade(e,t){let n=new IncomingMessage;n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let r=e.header_pairs??[];for(let e=0;e+1<r.length;e+=2){let t=r[e],i=r[e+1],o=t.toLowerCase();n.rawHeaders.push(t,i),n.headers[o]=i}if(this.listenerCount(`upgrade`)>0){let r=new Socket;r._attachOutputOnly(t),n.socket=r,r.remoteAddress??=e.remote_address||void 0,r.remotePort??=e.remote_port??void 0,r.remoteFamily??=r.remoteAddress?.includes(`:`)?`IPv6`:`IPv4`,r.localAddress??=this._address?.address,r.localPort??=this._address?.port,this.emit(`upgrade`,n,r,H.alloc(0))}}address(){return this._address}addWebSocketHandler(e,t){if(!this._bridge)throw Error(`Server must be listening before adding WebSocket handlers. Call listen() first.`);this._bridge.soup_server.add_websocket_handler(e,null,null,(e,n,r,i)=>{t(i)})}close(e){return e&&this.once(`close`,e),this._bridge&&=(this._tls?this._bridge.soup_server.disconnect():this._bridge.close(),null),this._trustFile&&=(removeFile(this._trustFile),null),this.listening=!1,Gp.delete(this),deferEmit(this,`close`),this}setTimeout(e,t){return this.timeout=e,t&&this.on(`timeout`,t),this}}}),ClientRequest,qp=__esmMin(()=>{pp(),Kp(),G(),Vp(),Z(),U(),Vr(),kf(),Cp(),ClientRequest=class extends OutgoingMessage{method;path;protocol;host;hostname;port;aborted=!1;reusedSocket=!1;maxHeadersCount=2e3;_chunks=[];_session;_message;_cancellable;_timeout=0;_timeoutTimer=null;_responseCallback;_tlsRejection=null;constructor(e,t,n){super();let r;if(typeof e==`string`||e instanceof J){let i=typeof e==`string`?new J(e):e;r={protocol:i.protocol,hostname:i.hostname,port:i.port?Number(i.port):void 0,path:i.pathname+i.search,...typeof t==`object`?t:{}},typeof t==`function`&&(n=t)}else r=e,typeof t==`function`&&(n=t);if(this.method=(r.method||`GET`).toUpperCase(),this.protocol=r.protocol||`http:`,this.hostname=r.hostname||r.host?.split(`:`)[0]||`localhost`,this.port=Number(r.port)||(this.protocol===`https:`?443:80),this.path=r.path||`/`,this.host=r.host||`${this.hostname}:${this.port}`,this._timeout=r.timeout||0,n&&(this._responseCallback=n,this.once(`response`,n)),r.headers)for(let[e,t]of Object.entries(r.headers))this.setHeader(e,t);if(r.setHost!==!1&&!this._headers.has(`host`)){let e=this.protocol===`https:`?443:80,t=this.port===e?this.hostname:`${this.hostname}:${this.port}`;this.setHeader(`Host`,t)}r.auth&&!this._headers.has(`authorization`)&&this.setHeader(`Authorization`,`Basic `+H.from(r.auth).toString(`base64`)),r.signal&&(r.signal.aborted?this.abort():r.signal.addEventListener(`abort`,()=>this.abort(),{once:!0}));let i=W.Uri.parse(this._buildUrl(),W.UriFlags.NONE);this._session=new Bp.Session,this._message=new Bp.Message({method:this.method,uri:i}),this._cancellable=new X.Cancellable,this.protocol===`https:`&&this._setupTls(r),this._timeout>0&&(this._session.timeout=Math.ceil(this._timeout/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},this._timeout))}_setupTls(e){let t=e.agent===void 0?e._defaultAgent:e.agent,n=t&&typeof t==`object`?t.options:void 0,r={...e,...n},i=r.secureContext??createSecureContext(r),o=createPeerVerifier({caCertificates:i.caCertificates,rejectUnauthorized:r.rejectUnauthorized,host:r.servername||this.hostname,checkServerIdentity:r.checkServerIdentity});this._session.set_tls_database(null),this._message.connect(`accept-certificate`,(e,t,n)=>{let r=o.accept(t);return this._tlsRejection=r?null:o.error,r}),i.certificate&&this._message.set_tls_client_certificate(i.certificate)}_buildUrl(){let e=this.protocol.endsWith(`:`)?this.protocol:this.protocol+`:`,t=e===`https:`?443:80,n=this.port===t?``:`:${this.port}`;return`${e}//${this.hostname}${n}${this.path}`}getRawHeaderNames(){return Array.from(this._headers.keys())}flushHeaders(){this.headersSent||this._applyHeaders()}setTimeout(e,t){return this._timeout=e,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._session.timeout=Math.ceil(e/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}abort(){this.aborted||(this.aborted=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this._cancellable.cancel(),this.emit(`abort`),this.destroy())}_write(e,t,n){let r=H.isBuffer(e)?e:typeof e==`string`?H.from(e,t):H.from(e);this._chunks.push(r),n()}_final(e){this._sendRequest().then(()=>e()).catch(t=>e(t))}_applyHeaders(){if(this.headersSent)return;this.headersSent=!0;let e=this._message.get_request_headers();for(let[t,n]of this._headers)if(Array.isArray(n))for(let r of n)e.append(t,r);else e.replace(t,n)}async _sendRequest(){this._applyHeaders();let e=H.concat(this._chunks);if(e.length>0){let t=this._headers.get(`content-type`)||`application/octet-stream`;this._message.set_request_body_from_bytes(t,new W.Bytes(e))}try{let e=await new Promise((e,t)=>{this._session.send_async(this._message,W.PRIORITY_DEFAULT,this._cancellable,(n,r)=>{try{e(this._session.send_finish(r))}catch(e){t(e)}})}),t=[];try{let n;for(;(n=await readBytesAsync(e,4096,W.PRIORITY_DEFAULT,this._cancellable))!==null;)t.push(H.from(n))}catch{}let n=new IncomingMessage;n.statusCode=this._message.status_code,n.statusMessage=this._message.get_reason_phrase(),n.httpVersion=`1.1`,this._message.get_response_headers().foreach((e,t)=>{let r=e.toLowerCase();if(n.rawHeaders.push(e,t),r in n.headers){let e=n.headers[r];Array.isArray(e)?e.push(t):n.headers[r]=[e,t]}else n.headers[r]=t}),this.finished=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this.emit(`response`,n),setTimeout(()=>{for(let e of t)n.push(e);n.push(null),n.complete=!0},0)}catch(e){this.aborted?this.emit(`abort`):this._tlsRejection?this.emit(`error`,this._tlsRejection):this.emit(`error`,e instanceof Error?e:Error(String(e)))}}}}),Jp=__exportAll$5({Agent:()=>Agent,ClientRequest:()=>ClientRequest,IncomingMessage:()=>IncomingMessage,METHODS:()=>dp,OutgoingMessage:()=>OutgoingMessage,STATUS_CODES:()=>up,Server:()=>Server,ServerResponse:()=>ServerResponse,createServer:()=>createServer,default:()=>Zp,get:()=>get,globalAgent:()=>Yp,maxHeaderSize:()=>Xp,request:()=>request,setMaxIdleHTTPParsers:()=>setMaxIdleHTTPParsers,validateHeaderName:()=>validateHeaderName,validateHeaderValue:()=>validateHeaderValue});function createServer(e,t){return typeof e==`function`?new Server(e):new Server(t)}function request(e,t,n){return new ClientRequest(e,t,n)}function get(e,t,n){let r,i=n;typeof e==`string`||e instanceof J?(r=typeof t==`object`?{...t,method:`GET`}:{method:`GET`},typeof t==`function`&&(i=t)):(r={...e,method:`GET`},typeof t==`function`&&(i=t),e=r);let o=typeof e==`string`||e instanceof J?new ClientRequest(e,{...r,method:`GET`},i):new ClientRequest({...r,method:`GET`},i);return o.end(),o}function setMaxIdleHTTPParsers(e){}var Agent,Yp,Xp,Zp,Qp=__esmMin(()=>{lp(),fp(),pp(),Kp(),qp(),Vr(),Agent=class{defaultPort=80;protocol=`http:`;maxSockets;maxTotalSockets;maxFreeSockets;keepAliveMsecs;keepAlive;scheduling;requests={};sockets={};freeSockets={};options;constructor(e){this.options={...e},this.keepAlive=e?.keepAlive??!1,this.keepAliveMsecs=e?.keepAliveMsecs??1e3,this.maxSockets=e?.maxSockets??1/0,this.maxTotalSockets=e?.maxTotalSockets??1/0,this.maxFreeSockets=e?.maxFreeSockets??256,this.scheduling=e?.scheduling??`lifo`}destroy(){}getName(e){let t=e.host||`localhost`;return e.port&&(t+=`:`+e.port),e.localAddress&&(t+=`:`+e.localAddress),(e.family===4||e.family===6)&&(t+=`:`+e.family),t}},Yp=new Agent,Xp=16384,Zp={STATUS_CODES:up,METHODS:dp,Server,IncomingMessage,OutgoingMessage,ServerResponse,ClientRequest,Agent,globalAgent:Yp,createServer,request,get,validateHeaderName,validateHeaderValue,maxHeaderSize:Xp,setMaxIdleHTTPParsers}}),$p=__commonJSMin(((e,t)=>{
|
|
234
234
|
/*!
|
|
235
235
|
* etag
|
|
236
236
|
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
237
237
|
* MIT Licensed
|
|
238
238
|
*/
|
|
239
|
-
t.exports=etag;var n=(Tc(),__toCommonJS(Cc)),r=(op(),__toCommonJS(rp)).Stats,i=Object.prototype.toString;function entitytag(e){if(e.length===0)return`"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"`;var t=n.createHash(`sha1`).update(e,`utf8`).digest(`base64`).substring(0,27);return`"`+(typeof e==`string`?Buffer.byteLength(e,`utf8`):e.length).toString(16)+`-`+t+`"`}function etag(e,t){if(e==null)throw TypeError(`argument entity is required`);var n=isstats(e),r=t&&typeof t.weak==`boolean`?t.weak:n;if(!n&&typeof e!=`string`&&!Buffer.isBuffer(e))throw TypeError(`argument entity must be string, Buffer, or fs.Stats`);var i=n?stattag(e):entitytag(e);return r?`W/`+i:i}function isstats(e){return typeof r==`function`&&e instanceof r?!0:e&&typeof e==`object`&&`ctime`in e&&i.call(e.ctime)===`[object Date]`&&`mtime`in e&&i.call(e.mtime)===`[object Date]`&&`ino`in e&&typeof e.ino==`number`&&`size`in e&&typeof e.size==`number`}function stattag(e){var t=e.mtime.getTime().toString(16);return`"`+e.size.toString(16)+`-`+t+`"`}})),
|
|
239
|
+
t.exports=etag;var n=(Tc(),__toCommonJS(Cc)),r=(op(),__toCommonJS(rp)).Stats,i=Object.prototype.toString;function entitytag(e){if(e.length===0)return`"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"`;var t=n.createHash(`sha1`).update(e,`utf8`).digest(`base64`).substring(0,27);return`"`+(typeof e==`string`?Buffer.byteLength(e,`utf8`):e.length).toString(16)+`-`+t+`"`}function etag(e,t){if(e==null)throw TypeError(`argument entity is required`);var n=isstats(e),r=t&&typeof t.weak==`boolean`?t.weak:n;if(!n&&typeof e!=`string`&&!Buffer.isBuffer(e))throw TypeError(`argument entity must be string, Buffer, or fs.Stats`);var i=n?stattag(e):entitytag(e);return r?`W/`+i:i}function isstats(e){return typeof r==`function`&&e instanceof r?!0:e&&typeof e==`object`&&`ctime`in e&&i.call(e.ctime)===`[object Date]`&&`mtime`in e&&i.call(e.mtime)===`[object Date]`&&`ino`in e&&typeof e.ino==`number`&&`size`in e&&typeof e.size==`number`}function stattag(e){var t=e.mtime.getTime().toString(16);return`"`+e.size.toString(16)+`-`+t+`"`}})),em=__commonJSMin(((e,t)=>{
|
|
240
240
|
/*!
|
|
241
241
|
* forwarded
|
|
242
242
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
243
243
|
* MIT Licensed
|
|
244
244
|
*/
|
|
245
|
-
t.exports=forwarded;function forwarded(e){if(!e)throw TypeError(`argument req is required`);var t=parse(e.headers[`x-forwarded-for`]||``);return[getSocketAddr(e)].concat(t)}function getSocketAddr(e){return e.socket?e.socket.remoteAddress:e.connection.remoteAddress}function parse(e){for(var t=e.length,n=[],r=e.length,i=e.length-1;i>=0;i--)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i);break;case 44:r!==t&&n.push(e.substring(r,t)),r=t=i;break;default:r=i;break}return r!==t&&n.push(e.substring(r,t)),n}})),nm=__commonJSMin(((e,t)=>{(function(){var expandIPv6,e={},n,r,i,o,matchCIDR,s=this,c;t!=null&&t.exports?t.exports=e:s.ipaddr=e,matchCIDR=function(e,t,n,r){var i,o;if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);for(i=0;r>0;){if(o=n-r,o<0&&(o=0),e[i]>>o!==t[i]>>o)return!1;r-=n,i+=1}return!0},e.subnetMatch=function(e,t,n){var r,i,o,s,c;for(o in n??=`unicast`,t)for(s=t[o],s[0]&&!(s[0]instanceof Array)&&(s=[s]),r=0,i=s.length;r<i;r++)if(c=s[r],e.kind()===c[0].kind()&&e.match.apply(e,c))return o;return n},e.IPv4=(function(){function IPv4(e){var t,n,r;if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);for(t=0,n=e.length;t<n;t++)if(r=e[t],!(0<=r&&r<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return IPv4.prototype.kind=function(){return`ipv4`},IPv4.prototype.toString=function(){return this.octets.join(`.`)},IPv4.prototype.toNormalizedString=function(){return this.toString()},IPv4.prototype.toByteArray=function(){return this.octets.slice(0)},IPv4.prototype.match=function(e,t){var n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return matchCIDR(this.octets,e.octets,8,t)},IPv4.prototype.SpecialRanges={unspecified:[[new IPv4([0,0,0,0]),8]],broadcast:[[new IPv4([255,255,255,255]),32]],multicast:[[new IPv4([224,0,0,0]),4]],linkLocal:[[new IPv4([169,254,0,0]),16]],loopback:[[new IPv4([127,0,0,0]),8]],carrierGradeNat:[[new IPv4([100,64,0,0]),10]],private:[[new IPv4([10,0,0,0]),8],[new IPv4([172,16,0,0]),12],[new IPv4([192,168,0,0]),16]],reserved:[[new IPv4([192,0,0,0]),24],[new IPv4([192,0,2,0]),24],[new IPv4([192,88,99,0]),24],[new IPv4([198,51,100,0]),24],[new IPv4([203,0,113,0]),24],[new IPv4([240,0,0,0]),4]]},IPv4.prototype.range=function(){return e.subnetMatch(this,this.SpecialRanges)},IPv4.prototype.toIPv4MappedAddress=function(){return e.IPv6.parse(`::ffff:`+this.toString())},IPv4.prototype.prefixLengthFromSubnetMask=function(){var e,t,n,r,i,o,s={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};for(e=0,i=!1,t=n=3;n>=0;t=n+=-1)if(r=this.octets[t],r in s){if(o=s[r],i&&o!==0)return null;o!==8&&(i=!0),e+=o}else return null;return 32-e},IPv4})(),n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^`+n+`\\.`+n+`\\.`+n+`\\.`+n+`$`,`i`),longValue:RegExp(`^`+n+`$`,`i`)},e.IPv4.parser=function(e){var t,parseIntAuto=function(e){return e[0]===`0`&&e[1]!==`x`?parseInt(e,8):parseInt(e)},n,i,o;if(t=e.match(r.fourOctet))return(function(){var e,r,i=t.slice(1,6),o=[];for(e=0,r=i.length;e<r;e++)n=i[e],o.push(parseIntAuto(n));return o})();if(t=e.match(r.longValue)){if(o=parseIntAuto(t[1]),o>4294967295||o<0)throw Error(`ipaddr: address outside defined range`);return(function(){var e,t=[];for(i=e=0;e<=24;i=e+=8)t.push(o>>i&255);return t})().reverse()}else return null},e.IPv6=(function(){function IPv6(e,t){var n,r,i,o,s,c;if(e.length===16)for(this.parts=[],n=r=0;r<=14;n=r+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(c=this.parts,i=0,o=c.length;i<o;i++)if(s=c[i],!(0<=s&&s<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return IPv6.prototype.kind=function(){return`ipv6`},IPv6.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,`::`)},IPv6.prototype.toRFC5952String=function(){var e,t,n,r=/((^|:)(0(:|$)){2,})/g,i=this.toNormalizedString();for(e=0,t=-1;n=r.exec(i);)n[0].length>t&&(e=n.index,t=n[0].length);return t<0?i:i.substring(0,e)+`::`+i.substring(e+t)},IPv6.prototype.toByteArray=function(){var e=[],t,n,r,i=this.parts;for(t=0,n=i.length;t<n;t++)r=i[t],e.push(r>>8),e.push(r&255);return e},IPv6.prototype.toNormalizedString=function(){var e=(function(){var e,n,r=this.parts,i=[];for(e=0,n=r.length;e<n;e++)t=r[e],i.push(t.toString(16));return i}).call(this).join(`:`),t,n=``;return this.zoneId&&(n=`%`+this.zoneId),e+n},IPv6.prototype.toFixedLengthString=function(){var e=(function(){var e,n,r=this.parts,i=[];for(e=0,n=r.length;e<n;e++)t=r[e],i.push(t.toString(16).padStart(4,`0`));return i}).call(this).join(`:`),t,n=``;return this.zoneId&&(n=`%`+this.zoneId),e+n},IPv6.prototype.match=function(e,t){var n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return matchCIDR(this.parts,e.parts,16,t)},IPv6.prototype.SpecialRanges={unspecified:[new IPv6([0,0,0,0,0,0,0,0]),128],linkLocal:[new IPv6([65152,0,0,0,0,0,0,0]),10],multicast:[new IPv6([65280,0,0,0,0,0,0,0]),8],loopback:[new IPv6([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new IPv6([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new IPv6([0,0,0,0,0,65535,0,0]),96],rfc6145:[new IPv6([0,0,0,0,65535,0,0,0]),96],rfc6052:[new IPv6([100,65435,0,0,0,0,0,0]),96],"6to4":[new IPv6([8194,0,0,0,0,0,0,0]),16],teredo:[new IPv6([8193,0,0,0,0,0,0,0]),32],reserved:[[new IPv6([8193,3512,0,0,0,0,0,0]),32]]},IPv6.prototype.range=function(){return e.subnetMatch(this,this.SpecialRanges)},IPv6.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},IPv6.prototype.toIPv4Address=function(){var t,n,r;if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);return r=this.parts.slice(-2),t=r[0],n=r[1],new e.IPv4([t>>8,t&255,n>>8,n&255])},IPv6.prototype.prefixLengthFromSubnetMask=function(){var e,t,n,r,i,o,s={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};for(e=0,i=!1,t=n=7;n>=0;t=n+=-1)if(r=this.parts[t],r in s){if(o=s[r],i&&o!==0)return null;o!==16&&(i=!0),e+=o}else return null;return 128-e},IPv6})(),i=`(?:[0-9a-f]+::?)+`,c=`%[0-9a-z]{1,}`,o={zoneIndex:new RegExp(c,`i`),native:RegExp(`^(::)?(`+i+`)?([0-9a-f]+)?(::)?(`+c+`)?$`,`i`),transitional:RegExp(`^((?:`+i+`)|(?:::)(?:`+i+`)?)`+(n+`\\.`+n+`\\.`+n+`\\.`+n)+(`(`+c+`)?$`),`i`)},expandIPv6=function(e,t){var n,r,i,s,c,l;if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;for(l=(e.match(o.zoneIndex)||[])[0],l&&(l=l.substring(1),e=e.replace(/%.+$/,``)),n=0,r=-1;(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>t)return null;for(c=t-n,s=`:`;c--;)s+=`0:`;return e=e.replace(`::`,s),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){var t,n,r=e.split(`:`),o=[];for(t=0,n=r.length;t<n;t++)i=r[t],o.push(parseInt(i,16));return o})(),{parts:t,zoneId:l}},e.IPv6.parser=function(e){var t,n,r,i,s,c,l;if(o.native.test(e))return expandIPv6(e,8);if((i=e.match(o.transitional))&&(l=i[6]||``,t=expandIPv6(i[1].slice(0,-1)+l,6),t.parts)){for(c=[parseInt(i[2]),parseInt(i[3]),parseInt(i[4]),parseInt(i[5])],n=0,r=c.length;n<r;n++)if(s=c[n],!(0<=s&&s<=255))return null;return t.parts.push(c[0]<<8|c[1]),t.parts.push(c[2]<<8|c[3]),{parts:t.parts,zoneId:t.zoneId}}return null},e.IPv4.isIPv4=e.IPv6.isIPv6=function(e){return this.parser(e)!==null},e.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},e.IPv4.isValidFourPartDecimal=function(t){return!!(e.IPv4.isValid(t)&&t.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},e.IPv6.isValid=function(e){var t;if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return t=this.parser(e),new this(t.parts,t.zoneId),!0}catch{return!1}},e.IPv4.parse=function(e){var t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like ip address`);return new this(t)},e.IPv6.parse=function(e){var t=this.parser(e);if(t.parts===null)throw Error(`ipaddr: string is not formatted like ip address`);return new this(t.parts,t.zoneId)},e.IPv4.parseCIDR=function(e){var t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=32))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},e.IPv4.subnetMaskFromPrefixLength=function(e){var t,n,r;if(e=parseInt(e),e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);for(r=[0,0,0,0],n=0,t=Math.floor(e/8);n<t;)r[n]=255,n++;return t<4&&(r[t]=2**(e%8)-1<<8-e%8),new this(r)},e.IPv4.broadcastAddressFromCIDR=function(e){var t,n,r,i,o;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)|parseInt(o[n],10)^255),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},e.IPv4.networkAddressFromCIDR=function(e){var t,n,r,i,o;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(o[n],10)),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},e.IPv6.parseCIDR=function(e){var t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},e.isValid=function(t){return e.IPv6.isValid(t)||e.IPv4.isValid(t)},e.parse=function(t){if(e.IPv6.isValid(t))return e.IPv6.parse(t);if(e.IPv4.isValid(t))return e.IPv4.parse(t);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},e.parseCIDR=function(t){try{return e.IPv6.parseCIDR(t)}catch{try{return e.IPv4.parseCIDR(t)}catch{throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`)}}},e.fromByteArray=function(t){var n=t.length;if(n===4)return new e.IPv4(t);if(n===16)return new e.IPv6(t);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},e.process=function(e){var t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t}}).call(e)})),im=__commonJSMin(((e,t)=>{
|
|
245
|
+
t.exports=forwarded;function forwarded(e){if(!e)throw TypeError(`argument req is required`);var t=parse(e.headers[`x-forwarded-for`]||``);return[getSocketAddr(e)].concat(t)}function getSocketAddr(e){return e.socket?e.socket.remoteAddress:e.connection.remoteAddress}function parse(e){for(var t=e.length,n=[],r=e.length,i=e.length-1;i>=0;i--)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i);break;case 44:r!==t&&n.push(e.substring(r,t)),r=t=i;break;default:r=i;break}return r!==t&&n.push(e.substring(r,t)),n}})),tm=__commonJSMin(((e,t)=>{(function(){var expandIPv6,e={},n,r,i,o,matchCIDR,s=this,c;t!=null&&t.exports?t.exports=e:s.ipaddr=e,matchCIDR=function(e,t,n,r){var i,o;if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);for(i=0;r>0;){if(o=n-r,o<0&&(o=0),e[i]>>o!==t[i]>>o)return!1;r-=n,i+=1}return!0},e.subnetMatch=function(e,t,n){var r,i,o,s,c;for(o in n??=`unicast`,t)for(s=t[o],s[0]&&!(s[0]instanceof Array)&&(s=[s]),r=0,i=s.length;r<i;r++)if(c=s[r],e.kind()===c[0].kind()&&e.match.apply(e,c))return o;return n},e.IPv4=(function(){function IPv4(e){var t,n,r;if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);for(t=0,n=e.length;t<n;t++)if(r=e[t],!(0<=r&&r<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return IPv4.prototype.kind=function(){return`ipv4`},IPv4.prototype.toString=function(){return this.octets.join(`.`)},IPv4.prototype.toNormalizedString=function(){return this.toString()},IPv4.prototype.toByteArray=function(){return this.octets.slice(0)},IPv4.prototype.match=function(e,t){var n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return matchCIDR(this.octets,e.octets,8,t)},IPv4.prototype.SpecialRanges={unspecified:[[new IPv4([0,0,0,0]),8]],broadcast:[[new IPv4([255,255,255,255]),32]],multicast:[[new IPv4([224,0,0,0]),4]],linkLocal:[[new IPv4([169,254,0,0]),16]],loopback:[[new IPv4([127,0,0,0]),8]],carrierGradeNat:[[new IPv4([100,64,0,0]),10]],private:[[new IPv4([10,0,0,0]),8],[new IPv4([172,16,0,0]),12],[new IPv4([192,168,0,0]),16]],reserved:[[new IPv4([192,0,0,0]),24],[new IPv4([192,0,2,0]),24],[new IPv4([192,88,99,0]),24],[new IPv4([198,51,100,0]),24],[new IPv4([203,0,113,0]),24],[new IPv4([240,0,0,0]),4]]},IPv4.prototype.range=function(){return e.subnetMatch(this,this.SpecialRanges)},IPv4.prototype.toIPv4MappedAddress=function(){return e.IPv6.parse(`::ffff:`+this.toString())},IPv4.prototype.prefixLengthFromSubnetMask=function(){var e,t,n,r,i,o,s={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};for(e=0,i=!1,t=n=3;n>=0;t=n+=-1)if(r=this.octets[t],r in s){if(o=s[r],i&&o!==0)return null;o!==8&&(i=!0),e+=o}else return null;return 32-e},IPv4})(),n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^`+n+`\\.`+n+`\\.`+n+`\\.`+n+`$`,`i`),longValue:RegExp(`^`+n+`$`,`i`)},e.IPv4.parser=function(e){var t,parseIntAuto=function(e){return e[0]===`0`&&e[1]!==`x`?parseInt(e,8):parseInt(e)},n,i,o;if(t=e.match(r.fourOctet))return(function(){var e,r,i=t.slice(1,6),o=[];for(e=0,r=i.length;e<r;e++)n=i[e],o.push(parseIntAuto(n));return o})();if(t=e.match(r.longValue)){if(o=parseIntAuto(t[1]),o>4294967295||o<0)throw Error(`ipaddr: address outside defined range`);return(function(){var e,t=[];for(i=e=0;e<=24;i=e+=8)t.push(o>>i&255);return t})().reverse()}else return null},e.IPv6=(function(){function IPv6(e,t){var n,r,i,o,s,c;if(e.length===16)for(this.parts=[],n=r=0;r<=14;n=r+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(c=this.parts,i=0,o=c.length;i<o;i++)if(s=c[i],!(0<=s&&s<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return IPv6.prototype.kind=function(){return`ipv6`},IPv6.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,`::`)},IPv6.prototype.toRFC5952String=function(){var e,t,n,r=/((^|:)(0(:|$)){2,})/g,i=this.toNormalizedString();for(e=0,t=-1;n=r.exec(i);)n[0].length>t&&(e=n.index,t=n[0].length);return t<0?i:i.substring(0,e)+`::`+i.substring(e+t)},IPv6.prototype.toByteArray=function(){var e=[],t,n,r,i=this.parts;for(t=0,n=i.length;t<n;t++)r=i[t],e.push(r>>8),e.push(r&255);return e},IPv6.prototype.toNormalizedString=function(){var e=(function(){var e,n,r=this.parts,i=[];for(e=0,n=r.length;e<n;e++)t=r[e],i.push(t.toString(16));return i}).call(this).join(`:`),t,n=``;return this.zoneId&&(n=`%`+this.zoneId),e+n},IPv6.prototype.toFixedLengthString=function(){var e=(function(){var e,n,r=this.parts,i=[];for(e=0,n=r.length;e<n;e++)t=r[e],i.push(t.toString(16).padStart(4,`0`));return i}).call(this).join(`:`),t,n=``;return this.zoneId&&(n=`%`+this.zoneId),e+n},IPv6.prototype.match=function(e,t){var n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return matchCIDR(this.parts,e.parts,16,t)},IPv6.prototype.SpecialRanges={unspecified:[new IPv6([0,0,0,0,0,0,0,0]),128],linkLocal:[new IPv6([65152,0,0,0,0,0,0,0]),10],multicast:[new IPv6([65280,0,0,0,0,0,0,0]),8],loopback:[new IPv6([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new IPv6([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new IPv6([0,0,0,0,0,65535,0,0]),96],rfc6145:[new IPv6([0,0,0,0,65535,0,0,0]),96],rfc6052:[new IPv6([100,65435,0,0,0,0,0,0]),96],"6to4":[new IPv6([8194,0,0,0,0,0,0,0]),16],teredo:[new IPv6([8193,0,0,0,0,0,0,0]),32],reserved:[[new IPv6([8193,3512,0,0,0,0,0,0]),32]]},IPv6.prototype.range=function(){return e.subnetMatch(this,this.SpecialRanges)},IPv6.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},IPv6.prototype.toIPv4Address=function(){var t,n,r;if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);return r=this.parts.slice(-2),t=r[0],n=r[1],new e.IPv4([t>>8,t&255,n>>8,n&255])},IPv6.prototype.prefixLengthFromSubnetMask=function(){var e,t,n,r,i,o,s={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};for(e=0,i=!1,t=n=7;n>=0;t=n+=-1)if(r=this.parts[t],r in s){if(o=s[r],i&&o!==0)return null;o!==16&&(i=!0),e+=o}else return null;return 128-e},IPv6})(),i=`(?:[0-9a-f]+::?)+`,c=`%[0-9a-z]{1,}`,o={zoneIndex:new RegExp(c,`i`),native:RegExp(`^(::)?(`+i+`)?([0-9a-f]+)?(::)?(`+c+`)?$`,`i`),transitional:RegExp(`^((?:`+i+`)|(?:::)(?:`+i+`)?)`+(n+`\\.`+n+`\\.`+n+`\\.`+n)+(`(`+c+`)?$`),`i`)},expandIPv6=function(e,t){var n,r,i,s,c,l;if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;for(l=(e.match(o.zoneIndex)||[])[0],l&&(l=l.substring(1),e=e.replace(/%.+$/,``)),n=0,r=-1;(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>t)return null;for(c=t-n,s=`:`;c--;)s+=`0:`;return e=e.replace(`::`,s),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){var t,n,r=e.split(`:`),o=[];for(t=0,n=r.length;t<n;t++)i=r[t],o.push(parseInt(i,16));return o})(),{parts:t,zoneId:l}},e.IPv6.parser=function(e){var t,n,r,i,s,c,l;if(o.native.test(e))return expandIPv6(e,8);if((i=e.match(o.transitional))&&(l=i[6]||``,t=expandIPv6(i[1].slice(0,-1)+l,6),t.parts)){for(c=[parseInt(i[2]),parseInt(i[3]),parseInt(i[4]),parseInt(i[5])],n=0,r=c.length;n<r;n++)if(s=c[n],!(0<=s&&s<=255))return null;return t.parts.push(c[0]<<8|c[1]),t.parts.push(c[2]<<8|c[3]),{parts:t.parts,zoneId:t.zoneId}}return null},e.IPv4.isIPv4=e.IPv6.isIPv6=function(e){return this.parser(e)!==null},e.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},e.IPv4.isValidFourPartDecimal=function(t){return!!(e.IPv4.isValid(t)&&t.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},e.IPv6.isValid=function(e){var t;if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return t=this.parser(e),new this(t.parts,t.zoneId),!0}catch{return!1}},e.IPv4.parse=function(e){var t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like ip address`);return new this(t)},e.IPv6.parse=function(e){var t=this.parser(e);if(t.parts===null)throw Error(`ipaddr: string is not formatted like ip address`);return new this(t.parts,t.zoneId)},e.IPv4.parseCIDR=function(e){var t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=32))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},e.IPv4.subnetMaskFromPrefixLength=function(e){var t,n,r;if(e=parseInt(e),e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);for(r=[0,0,0,0],n=0,t=Math.floor(e/8);n<t;)r[n]=255,n++;return t<4&&(r[t]=2**(e%8)-1<<8-e%8),new this(r)},e.IPv4.broadcastAddressFromCIDR=function(e){var t,n,r,i,o;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)|parseInt(o[n],10)^255),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},e.IPv4.networkAddressFromCIDR=function(e){var t,n,r,i,o;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(o[n],10)),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},e.IPv6.parseCIDR=function(e){var t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},e.isValid=function(t){return e.IPv6.isValid(t)||e.IPv4.isValid(t)},e.parse=function(t){if(e.IPv6.isValid(t))return e.IPv6.parse(t);if(e.IPv4.isValid(t))return e.IPv4.parse(t);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},e.parseCIDR=function(t){try{return e.IPv6.parseCIDR(t)}catch{try{return e.IPv4.parseCIDR(t)}catch{throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`)}}},e.fromByteArray=function(t){var n=t.length;if(n===4)return new e.IPv4(t);if(n===16)return new e.IPv6(t);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},e.process=function(e){var t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t}}).call(e)})),nm=__commonJSMin(((e,t)=>{
|
|
246
246
|
/*!
|
|
247
247
|
* proxy-addr
|
|
248
248
|
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
249
249
|
* MIT Licensed
|
|
250
250
|
*/
|
|
251
|
-
t.exports=proxyaddr,t.exports.all=alladdrs,t.exports.compile=compile;var n=
|
|
251
|
+
t.exports=proxyaddr,t.exports.all=alladdrs,t.exports.compile=compile;var n=em(),r=tm(),i=/^[0-9]+$/,o=r.isValid,s=r.parse,c={linklocal:[`169.254.0.0/16`,`fe80::/10`],loopback:[`127.0.0.1/8`,`::1/128`],uniquelocal:[`10.0.0.0/8`,`172.16.0.0/12`,`192.168.0.0/16`,`fc00::/7`]};function alladdrs(e,t){var r=n(e);if(!t)return r;typeof t!=`function`&&(t=compile(t));for(var i=0;i<r.length-1;i++)t(r[i],i)||(r.length=i+1);return r}function compile(e){if(!e)throw TypeError(`argument is required`);var t;if(typeof e==`string`)t=[e];else if(Array.isArray(e))t=e.slice();else throw TypeError(`unsupported trust argument`);for(var n=0;n<t.length;n++)e=t[n],Object.prototype.hasOwnProperty.call(c,e)&&(e=c[e],t.splice.apply(t,[n,1].concat(e)),n+=e.length-1);return compileTrust(compileRangeSubnets(t))}function compileRangeSubnets(e){for(var t=Array(e.length),n=0;n<e.length;n++)t[n]=parseipNotation(e[n]);return t}function compileTrust(e){var t=e.length;return t===0?trustNone:t===1?trustSingle(e[0]):trustMulti(e)}function parseipNotation(e){var t=e.lastIndexOf(`/`),n=t===-1?e:e.substring(0,t);if(!o(n))throw TypeError(`invalid IP address: `+n);var r=s(n);t===-1&&r.kind()===`ipv6`&&r.isIPv4MappedAddress()&&(r=r.toIPv4Address());var c=r.kind()===`ipv6`?128:32,l=t===-1?null:e.substring(t+1,e.length);if(l=l===null?c:i.test(l)?parseInt(l,10):r.kind()===`ipv4`&&o(l)?parseNetmask(l):null,l<=0||l>c)throw TypeError(`invalid range on address: `+e);return[r,l]}function parseNetmask(e){var t=s(e);return t.kind()===`ipv4`?t.prefixLengthFromSubnetMask():null}function proxyaddr(e,t){if(!e)throw TypeError(`req argument is required`);if(!t)throw TypeError(`trust argument is required`);var n=alladdrs(e,t);return n[n.length-1]}function trustNone(){return!1}function trustMulti(e){return function trust(t){if(!o(t))return!1;for(var n=s(t),r,i=n.kind(),c=0;c<e.length;c++){var l=e[c],u=l[0],d=u.kind(),p=l[1],m=n;if(i!==d){if(d===`ipv4`&&!n.isIPv4MappedAddress())continue;r||=d===`ipv4`?n.toIPv4Address():n.toIPv4MappedAddress(),m=r}if(m.match(u,p))return!0}return!1}}function trustSingle(e){var t=e[0],n=t.kind(),r=n===`ipv4`,i=e[1];return function trust(e){if(!o(e))return!1;var c=s(e);if(c.kind()!==n){if(r&&!c.isIPv4MappedAddress())return!1;c=r?c.toIPv4Address():c.toIPv4MappedAddress()}return c.match(t,i)}}})),NodeErrorAbstraction,NodeURIError,im=__esmMin(()=>{NodeErrorAbstraction=class extends Error{code;constructor(e,t,n){super(n),this.code=t,this.name=e,this.stack=this.stack&&`${e} [${this.code}]${this.stack.slice(20)}`}toString(){return`${this.name} [${this.code}]: ${this.message}`}},NodeURIError=class extends NodeErrorAbstraction{constructor(e,t){super(URIError.prototype.name,e,t),Object.setPrototypeOf(this,URIError.prototype),this.toString=function(){return`${this.name} [${this.code}]: ${this.message}`}}}}),am,om,sm,cm,lm=__esmMin(()=>{am=Array.from({length:256});for(let e=0;e<256;++e)am[e]=`%`+((e<16?`0`:``)+e.toString(16)).toUpperCase();om=new Int8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),sm=new Int8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0]),cm=new Int8Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])});function encodeStr(e,t,n){let r=e.length;if(r===0)return``;let i=``,o=0;for(let s=0;s<r;s++){let c=e.charCodeAt(s);if(c<128){if(t[c]===1)continue;o<s&&(i+=e.slice(o,s)),o=s+1,i+=n[c];continue}if(o<s&&(i+=e.slice(o,s)),c<2048){o=s+1,i+=n[192|c>>6]+n[128|c&63];continue}if(c<55296||c>=57344){o=s+1,i+=n[224|c>>12]+n[128|c>>6&63]+n[128|c&63];continue}if(++s,s>=r)throw new ERR_INVALID_URI;let l=e.charCodeAt(s)&1023;o=s+1,c=65536+((c&1023)<<10|l),i+=n[240|c>>18]+n[128|c>>12&63]+n[128|c>>6&63]+n[128|c&63]}return o===0?e:o<r?i+e.slice(o):i}function qsEscape(e){return typeof e!=`string`&&(typeof e==`object`?e=String(e):e+=``),encodeStr(e,sm,am)}var ERR_INVALID_URI,um=__esmMin(()=>{im(),lm(),ERR_INVALID_URI=class extends NodeURIError{constructor(){super(`ERR_INVALID_URI`,`URI malformed`)}}});function unescapeBuffer(e,t=!1){let n=new H(e.length),r=0,i=0,o,s,c,l,u=e.length-2,d=!1;for(;r<e.length;){if(o=e.charCodeAt(r),o===43&&t){n[i++]=32,r++;continue}if(o===37&&r<u)if(o=e.charCodeAt(++r),c=cm[o],c>=0)s=e.charCodeAt(++r),l=cm[s],l>=0?(d=!0,o=c*16+l):(n[i++]=37,r--);else{n[i++]=37;continue}n[i++]=o,r++}return d?n.slice(0,i):n}function qsUnescape(e){try{return decodeURIComponent(e)}catch{return unescapeBuffer(e).toString()}}var dm=__esmMin(()=>{lm(),U()});function charCodes(e){let t=Array.from({length:e.length});for(let n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t}function addKeyVal(e,t,n,r,i,o){if(t.length>0&&r)try{t=o(t)}catch{}if(n.length>0&&i)try{n=o(n)}catch{}if(e[t]===void 0)e[t]=n;else{let r=e[t];r.pop?r[r.length]=n:e[t]=[r,n]}}function parse(e,t=`&`,n=`=`,{decodeURIComponent:r=qsUnescape,maxKeys:i=1e3}={}){let o=Object.create(null);if(typeof e!=`string`||e.length===0)return o;let s=t?charCodes(String(t)):[38],c=n?charCodes(String(n)):[61],l=s.length,u=c.length,d=1e3;typeof i==`number`&&(d=i>0?i:-1);let p=qsUnescape;r&&(p=r);let m=p!==qsUnescape,h=0,g=0,_=0,v=``,y=``,b=m,x=m,S=m?`%20`:` `,w=0;for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n===s[g]){if(++g===l){let n=t-g+1;if(_<u){if(h<n)v+=e.slice(h,n);else if(v.length===0){if(--d===0)return o;h=t+1,g=_=0;continue}}else h<n&&(y+=e.slice(h,n));if(addKeyVal(o,v,y,b,x,p),--d===0)return o;v=y=``,w=0,h=t+1,g=_=0}}else{if(g=0,_<u){if(n===c[_]){if(++_===u){let n=t-_+1;h<n&&(v+=e.slice(h,n)),w=0,h=t+1}continue}else if(_=0,!b){if(n===37){w=1;continue}else if(w>0)if(om[n]===1){++w===3&&(b=!0);continue}else w=0}if(n===43){h<t&&(v+=e.slice(h,t)),v+=S,h=t+1;continue}}n===43?(h<t&&(y+=e.slice(h,t)),y+=S,h=t+1):x||(n===37?w=1:w>0&&(om[n]===1?++w===3&&(x=!0):w=0))}}if(h<e.length)_<u?v+=e.slice(h):g<l&&(y+=e.slice(h));else if(_===0&&v.length===0)return o;return addKeyVal(o,v,y,b,x,p),o}var fm=__esmMin(()=>{lm(),dm()});function stringifyPrimitive(e){return typeof e==`string`?e:typeof e==`number`&&isFinite(e)||typeof e==`bigint`?``+e:typeof e==`boolean`?e?`true`:`false`:``}function encodeStringifiedCustom(e,t){return t(stringifyPrimitive(e))}function encodeStringified(e,t){return typeof e==`string`?e.length?t(e):``:typeof e==`number`&&isFinite(e)?Math.abs(e)<1e21?``+e:t(``+e):typeof e==`bigint`?``+e:typeof e==`boolean`?e?`true`:`false`:``}function stringify(e,t,n,r){t||=`&`,n||=`=`;let i=r?r.encodeURIComponent:qsEscape,o=r?encodeStringifiedCustom:encodeStringified;if(typeof e==`object`&&e){let r=Object.keys(e),s=r.length,c=``;for(let l=0;l<s;++l){let s=r[l],u=e[s],d=o(s,i);if(d+=n,Array.isArray(u)){let e=u.length;if(e===0)continue;c&&(c+=t);for(let n=0;n<e;++n)n&&(c+=t),c+=d,c+=o(u[n],i)}else c&&(c+=t),c+=d,c+=o(u,i)}return c}return``}var pm=__esmMin(()=>{um()}),mm=__exportAll$5({ERR_INVALID_URI:()=>ERR_INVALID_URI,decode:()=>hm,default:()=>ym,encode:()=>gm,escape:()=>_m,parse:()=>parse,stringify:()=>stringify,unescape:()=>vm,unescapeBuffer:()=>unescapeBuffer}),hm,gm,_m,vm,ym,bm=__esmMin(()=>{um(),dm(),fm(),pm(),hm=parse,gm=stringify,_m=qsEscape,vm=qsUnescape,ym={parse,stringify,decode:hm,encode:gm,unescape:vm,escape:_m,unescapeBuffer}}),xm=__commonJSMin((e=>{
|
|
252
252
|
/*!
|
|
253
253
|
* express
|
|
254
254
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
|
255
255
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
256
256
|
* MIT Licensed
|
|
257
257
|
*/
|
|
258
|
-
var{METHODS:t}=(
|
|
258
|
+
var{METHODS:t}=(Qp(),__toCommonJS(Jp)),n=Xl(),r=$p(),i=ql(),o=nm(),s=Id(),c=(bm(),__toCommonJS(mm));let{Buffer:l}=(U(),__toCommonJS(an));e.methods=t.map(e=>e.toLowerCase()),e.etag=createETagGenerator({weak:!1}),e.wetag=createETagGenerator({weak:!0}),e.normalizeType=function(e){return~e.indexOf(`/`)?acceptParams(e):{value:i.lookup(e)||`application/octet-stream`,params:{}}},e.normalizeTypes=function(t){return t.map(e.normalizeType)};function acceptParams(e){for(var t=e.length,n=e.indexOf(`;`),r=n===-1?t:n,i={value:e.slice(0,r).trim(),quality:1,params:{}};r<t;){var o=e.indexOf(`=`,r);if(o===-1)break;var n=e.indexOf(`;`,r),s=n===-1?t:n;if(o>s){r=e.lastIndexOf(`;`,o-1)+1;continue}var c=e.slice(r,o).trim(),l=e.slice(o+1,s).trim();c===`q`?i.quality=parseFloat(l):i.params[c]=l,r=s+1}return i}e.compileETag=function(t){var n;if(typeof t==`function`)return t;switch(t){case!0:case`weak`:n=e.wetag;break;case!1:break;case`strong`:n=e.etag;break;default:throw TypeError(`unknown value for etag function: `+t)}return n},e.compileQueryParser=function compileQueryParser(e){var t;if(typeof e==`function`)return e;switch(e){case!0:case`simple`:t=c.parse;break;case!1:break;case`extended`:t=parseExtendedQueryString;break;default:throw TypeError(`unknown value for query parser function: `+e)}return t},e.compileTrust=function(e){return typeof e==`function`?e:e===!0?function(){return!0}:typeof e==`number`?function(t,n){return n<e}:(typeof e==`string`&&(e=e.split(`,`).map(function(e){return e.trim()})),o.compile(e||[]))},e.setCharset=function setCharset(e,t){if(!e||!t)return e;var r=n.parse(e);return r.parameters.charset=t,n.format(r)};function createETagGenerator(e){return function generateETag(t,n){return r(l.isBuffer(t)?t:l.from(t,n),e)}}function parseExtendedQueryString(e){return s.parse(e,{allowPrototypes:!0})}})),Sm=__commonJSMin(((e,t)=>{t.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=`function`)throw TypeError(`need wrapper function`);return Object.keys(e).forEach(function(t){wrapper[t]=e[t]}),wrapper;function wrapper(){for(var t=Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),i=t[t.length-1];return typeof r==`function`&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}}})),Cm=__commonJSMin(((e,t)=>{var n=Sm();t.exports=n(once),t.exports.strict=n(onceStrict),once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:!0})});function once(e){var f=function(){return f.called?f.value:(f.called=!0,f.value=e.apply(this,arguments))};return f.called=!1,f}function onceStrict(e){var f=function(){if(f.called)throw Error(f.onceError);return f.called=!0,f.value=e.apply(this,arguments)};return f.onceError=(e.name||"Function wrapped with `once`")+` shouldn't be called more than once`,f.called=!1,f}})),wm=__commonJSMin(((e,t)=>{t.exports=isPromise,t.exports.default=isPromise;function isPromise(e){return!!e&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`}})),Tm=__commonJSMin((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PathError=e.TokenData=void 0,e.parse=parse,e.compile=compile,e.match=match,e.pathToRegexp=pathToRegexp,e.stringify=stringify;let NOOP_VALUE=e=>e,t=/^[$_\p{ID_Start}]$/u,n=/^[$\u200c\u200d\p{ID_Continue}]$/u,r=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;function escapeText(e){return e.replace(/[{}()\[\]+?!:*\\]/g,`\\$&`)}function escape(e){return e.replace(/[.+*?^${}()[\]|/\\]/g,`\\$&`)}var TokenData=class{constructor(e,t){this.tokens=e,this.originalPath=t}};e.TokenData=TokenData;var PathError=class extends TypeError{constructor(e,t){let n=e;t&&(n+=`: ${t}`),n+=`; visit https://git.new/pathToRegexpError for info`,super(n),this.originalPath=t}};e.PathError=PathError;function parse(e,r={}){let{encodePath:i=NOOP_VALUE}=r,o=[...e],s=0;function consumeUntil(r){let c=[],l=``;function writePath(){l&&=(c.push({type:`text`,value:i(l)}),``)}for(;s<o.length;){let i=o[s++];if(i===r)return writePath(),c;if(i===`\\`){if(s===o.length)throw new PathError(`Unexpected end after \\ at index ${s}`,e);l+=o[s++];continue}if(i===`:`||i===`*`){let r=i===`:`?`param`:`wildcard`,l=``;if(t.test(o[s]))do l+=o[s++];while(n.test(o[s]));else if(o[s]===`"`){let t=s;for(;s<o.length;){if(o[++s]===`"`){s++,t=0;break}o[s]===`\\`&&s++,l+=o[s]}if(t)throw new PathError(`Unterminated quote at index ${t}`,e)}if(!l)throw new PathError(`Missing parameter name at index ${s}`,e);writePath(),c.push({type:r,name:l});continue}if(i===`{`){writePath(),c.push({type:`group`,tokens:consumeUntil(`}`)});continue}if(i===`}`||i===`(`||i===`)`||i===`[`||i===`]`||i===`+`||i===`?`||i===`!`)throw new PathError(`Unexpected ${i} at index ${s-1}`,e);l+=i}if(r)throw new PathError(`Unexpected end at index ${s}, expected ${r}`,e);return writePath(),c}return new TokenData(consumeUntil(``),e)}function compile(e,t={}){let{encode:n=encodeURIComponent,delimiter:r=`/`}=t,i=tokensToFunction((typeof e==`object`?e:parse(e,t)).tokens,r,n);return function path(e={}){let t=[],n=i(e,t);if(t.length)throw TypeError(`Missing parameters: ${t.join(`, `)}`);return n}}function tokensToFunction(e,t,n){let r=e.map(e=>tokenToFunction(e,t,n));return(e,t)=>{let n=``;for(let i of r)n+=i(e,t);return n}}function tokenToFunction(e,t,n){if(e.type===`text`)return()=>e.value;if(e.type===`group`){let r=tokensToFunction(e.tokens,t,n);return(e,t)=>{let n=t.length,i=r(e,t);return t.length===n?i:(t.length=n,``)}}let r=n||NOOP_VALUE;return e.type===`wildcard`&&n!==!1?(n,i)=>{let o=n[e.name];if(o==null)return i.push(e.name),``;if(!Array.isArray(o)||o.length===0)throw TypeError(`Expected "${e.name}" to be a non-empty array`);let s=``;for(let n=0;n<o.length;n++){if(typeof o[n]!=`string`)throw TypeError(`Expected "${e.name}/${n}" to be a string`);n>0&&(s+=t),s+=r(o[n])}return s}:(t,n)=>{let i=t[e.name];if(i==null)return n.push(e.name),``;if(typeof i!=`string`)throw TypeError(`Expected "${e.name}" to be a string`);return r(i)}}function match(e,t={}){let{decode:n=decodeURIComponent,delimiter:r=`/`}=t,{regexp:i,keys:o}=pathToRegexp(e,t),s=o.map(e=>n===!1?NOOP_VALUE:e.type===`param`?n:e=>e.split(r).map(n));return function match(e){let t=i.exec(e);if(!t)return!1;let n=t[0],r=Object.create(null);for(let e=1;e<t.length;e++){if(t[e]===void 0)continue;let n=o[e-1],i=s[e-1];r[n.name]=i(t[e])}return{path:n,params:r}}}function pathToRegexp(e,t={}){let{delimiter:n=`/`,end:r=!0,sensitive:i=!1,trailing:o=!0}=t,s=[],c=``,l=0;function process(e){if(Array.isArray(e)){for(let t of e)process(t);return}let r=typeof e==`object`?e:parse(e,t);flatten(r.tokens,0,[],e=>{if(l>=256)throw new PathError(`Too many path combinations`,r.originalPath);l>0&&(c+=`|`),c+=toRegExpSource(e,n,s,r.originalPath),l++})}process(e);let u=`^(?:${c})`;return o&&(u+=`(?:`+escape(n)+`$)?`),u+=r?`$`:`(?=`+escape(n)+`|$)`,{regexp:new RegExp(u,i?``:`i`),keys:s}}function flatten(e,t,n,r){for(;t<e.length;){let i=e[t++];if(i.type===`group`){let o=n.length;flatten(i.tokens,0,n,n=>flatten(e,t,n,r)),n.length=o;continue}n.push(i)}r(n)}function toRegExpSource(e,t,n,r){let i=``,o=``,s=``,c=0,l=0,u=0;function hasInSegment(n,r){for(;n<e.length;){let i=e[n++];if(i.type===r)return!0;if(i.type===`text`&&i.value.includes(t))break}return!1}function peekText(t){let n=``;for(;t<e.length;){let r=e[t++];if(r.type!==`text`)break;n+=r.value}return n}for(;u<e.length;){let d=e[u++];if(d.type===`text`){i+=escape(d.value),o+=d.value,c===2&&(s+=d.value),d.value.includes(t)&&(l=0);continue}if(d.type===`param`||d.type===`wildcard`){if(c&&!o)throw new PathError(`Missing text before "${d.name}" ${d.type}`,r);d.type===`param`?(i+=l&2?`(${negate(t,o)}+)`:hasInSegment(u,`wildcard`)?`(${negate(t,peekText(u))}+)`:l&1?`(${negate(t,o)}+|${escape(o)})`:`(${negate(t,``)}+)`,l|=c=1):(i+=l&2?`(${negate(o,``)}+)`:s?`(${negate(s,``)}+|${negate(t,``)}+)`:`([^]+)`,s=``,l|=c=2),n.push(d),o=``;continue}throw TypeError(`Unknown token type: ${d.type}`)}return i}function negate(e,t){return t.length>e.length?negate(t,e):(e===t&&(t=``),t.length>1?`(?:(?!${escape(e)}|${escape(t)})[^])`:e.length>1?`(?:(?!${escape(e)})[^${escape(t)}])`:`[^${escape(e+t)}]`)}function stringifyTokens(e,t){let n=``;for(;t<e.length;){let r=e[t++];if(r.type===`text`){n+=escapeText(r.value);continue}if(r.type===`group`){n+=`{`+stringifyTokens(r.tokens,0)+`}`;continue}if(r.type===`param`){n+=`:`+stringifyName(r.name,e[t]);continue}if(r.type===`wildcard`){n+=`*`+stringifyName(r.name,e[t]);continue}throw TypeError(`Unknown token type: ${r.type}`)}return n}function stringify(e){return stringifyTokens(e.tokens,0)}function stringifyName(e,t){return!r.test(e)||t?.type===`text`&&n.test(t.value[0])?JSON.stringify(e):e}})),Em=__commonJSMin(((e,t)=>{
|
|
259
259
|
/*!
|
|
260
260
|
* router
|
|
261
261
|
* Copyright(c) 2013 Roman Shtylman
|
|
262
262
|
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
263
263
|
* MIT Licensed
|
|
264
264
|
*/
|
|
265
|
-
let n=
|
|
265
|
+
let n=wm(),r=Tm(),i=el()(`router:layer`),o=tl()(`router`),s=/\/+$/,c=/\((?:\?<(.*?)>)?(?!\?)/g;t.exports=Layer;function Layer(e,t,n){if(!(this instanceof Layer))return new Layer(e,t,n);i(`new %o`,e);let o=t||{};this.handle=n,this.keys=[],this.name=n.name||`<anonymous>`,this.params=void 0,this.path=void 0,this.slash=e===`/`&&o.end===!1;function matcher(e){if(e instanceof RegExp){let t=[],n=0,r;for(;r=c.exec(e.source);)t.push({name:r[1]||n++,offset:r.index});return function regexpMatcher(n){let r=e.exec(n);if(!r)return!1;let i={};for(let e=1;e<r.length;e++){let n=t[e-1].name,o=decodeParam(r[e]);o!==void 0&&(i[n]=o)}return{params:i,path:r[0]}}}return r.match(o.strict?e:loosen(e),{sensitive:o.sensitive,end:o.end,trailing:!o.strict,decode:decodeParam})}this.matchers=Array.isArray(e)?e.map(matcher):[matcher(e)]}Layer.prototype.handleError=function handleError(e,t,r,i){let s=this.handle;if(s.length!==4)return i(e);try{let c=s(e,t,r,i);n(c)&&(c instanceof Promise||o(`handlers that are Promise-like are deprecated, use a native Promise instead`),c.then(null,function(e){i(e||Error(`Rejected promise`))}))}catch(e){i(e)}},Layer.prototype.handleRequest=function handleRequest(e,t,r){let i=this.handle;if(i.length>3)return r();try{let s=i(e,t,r);n(s)&&(s instanceof Promise||o(`handlers that are Promise-like are deprecated, use a native Promise instead`),s.then(null,function(e){r(e||Error(`Rejected promise`))}))}catch(e){r(e)}},Layer.prototype.match=function match(e){let t;if(e!=null){if(this.slash)return this.params={},this.path=``,!0;let n=0;for(;!t&&n<this.matchers.length;)t=this.matchers[n](e),n++}return t?(this.params=t.params,this.path=t.path,this.keys=Object.keys(t.params),!0):(this.params=void 0,this.path=void 0,!1)};function decodeParam(e){if(typeof e!=`string`||e.length===0)return e;try{return decodeURIComponent(e)}catch(t){throw t instanceof URIError&&(t.message=`Failed to decode param '`+e+`'`,t.status=400),t}}function loosen(e){return e instanceof RegExp||e===`/`?e:Array.isArray(e)?e.map(function(e){return loosen(e)}):String(e).replace(s,``)}})),Dm=__commonJSMin(((e,t)=>{
|
|
266
266
|
/*!
|
|
267
267
|
* router
|
|
268
268
|
* Copyright(c) 2013 Roman Shtylman
|
|
269
269
|
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
270
270
|
* MIT Licensed
|
|
271
271
|
*/
|
|
272
|
-
let n=el()(`router:route`),r=
|
|
272
|
+
let n=el()(`router:route`),r=Em(),{METHODS:i}=(Qp(),__toCommonJS(Jp)),o=Array.prototype.slice,s=Array.prototype.flat,c=i.map(e=>e.toLowerCase());t.exports=Route;function Route(e){n(`new %o`,e),this.path=e,this.stack=[],this.methods=Object.create(null)}Route.prototype._handlesMethod=function _handlesMethod(e){if(this.methods._all)return!0;let t=typeof e==`string`?e.toLowerCase():e;return t===`head`&&!this.methods.head&&(t=`get`),!!this.methods[t]},Route.prototype._methods=function _methods(){let e=Object.keys(this.methods);this.methods.get&&!this.methods.head&&e.push(`head`);for(let t=0;t<e.length;t++)e[t]=e[t].toUpperCase();return e},Route.prototype.dispatch=function dispatch(e,t,n){let r=0,i=this.stack,o=0;if(i.length===0)return n();let s=typeof e.method==`string`?e.method.toLowerCase():e.method;s===`head`&&!this.methods.head&&(s=`get`),e.route=this,next();function next(c){if(c&&c===`route`)return n();if(c&&c===`router`||r>=i.length)return n(c);if(++o>100)return setImmediate(next,c);let l,u;for(;u!==!0&&r<i.length;)l=i[r++],u=!l.method||l.method===s;if(u!==!0)return n(c);c?l.handleError(c,e,t,next):l.handleRequest(e,t,next),o=0}},Route.prototype.all=function all(e){let t=s.call(o.call(arguments),1/0);if(t.length===0)throw TypeError(`argument handler is required`);for(let e=0;e<t.length;e++){let n=t[e];if(typeof n!=`function`)throw TypeError(`argument handler must be a function`);let i=r(`/`,{},n);i.method=void 0,this.methods._all=!0,this.stack.push(i)}return this},c.forEach(function(e){Route.prototype[e]=function(t){let i=s.call(o.call(arguments),1/0);if(i.length===0)throw TypeError(`argument handler is required`);for(let t=0;t<i.length;t++){let o=i[t];if(typeof o!=`function`)throw TypeError(`argument handler must be a function`);n(`%s %s`,e,this.path);let s=r(`/`,{},o);s.method=e,this.methods[e]=!0,this.stack.push(s)}return this}})})),Om=__commonJSMin(((e,t)=>{
|
|
273
273
|
/*!
|
|
274
274
|
* router
|
|
275
275
|
* Copyright(c) 2013 Roman Shtylman
|
|
276
276
|
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
277
277
|
* MIT Licensed
|
|
278
278
|
*/
|
|
279
|
-
let n=
|
|
279
|
+
let n=wm(),r=Em(),{METHODS:i}=(Qp(),__toCommonJS(Jp)),o=Ud(),s=Dm(),c=el()(`router`),l=tl()(`router`),u=Array.prototype.slice,d=Array.prototype.flat,p=i.map(e=>e.toLowerCase());t.exports=Router,t.exports.Route=s;function Router(e){if(!(this instanceof Router))return new Router(e);let t=e||{};function router(e,t,n){router.handle(e,t,n)}return Object.setPrototypeOf(router,this),router.caseSensitive=t.caseSensitive,router.mergeParams=t.mergeParams,router.params={},router.strict=t.strict,router.stack=[],router}Router.prototype=function(){},Router.prototype.param=function param(e,t){if(!e)throw TypeError(`argument name is required`);if(typeof e!=`string`)throw TypeError(`argument name must be a string`);if(!t)throw TypeError(`argument fn is required`);if(typeof t!=`function`)throw TypeError(`argument fn must be a function`);let n=this.params[e];return n||=this.params[e]=[],n.push(t),this},Router.prototype.handle=function handle(e,t,n){if(!n)throw TypeError(`argument callback is required`);c(`dispatching %s %s`,e.method,e.url);let r=0,i,o=getProtohost(e.url)||``,s=``,l=this,u=!1,d=0,p={},m=this.stack,h=e.params,g=e.baseUrl||``,_=restore(n,e,`baseUrl`,`next`,`params`);e.next=next,e.method===`OPTIONS`&&(i=[],_=wrap(_,generateOptionsResponder(t,i))),e.baseUrl=g,e.originalUrl=e.originalUrl||e.url,next();function next(n){let c=n===`route`?null:n;if(u&&=(e.url=e.url.slice(1),!1),s.length!==0&&(e.baseUrl=g,e.url=o+s+e.url.slice(o.length),s=``),c===`router`){setImmediate(_,null);return}if(r>=m.length){setImmediate(_,c);return}if(++d>100)return setImmediate(next,n);let v=getPathname(e);if(v==null)return _(c);let y,b,x;for(;b!==!0&&r<m.length;){if(y=m[r++],b=matchLayer(y,v),x=y.route,typeof b!=`boolean`&&(c||=b),b!==!0||!x)continue;if(c){b=!1;continue}let t=e.method,n=x._handlesMethod(t);!n&&t===`OPTIONS`&&i&&i.push.apply(i,x._methods()),!n&&t!==`HEAD`&&(b=!1)}if(b!==!0)return _(c);x&&(e.route=x),e.params=l.mergeParams?mergeParams(y.params,h):y.params;let S=y.path;processParams(l.params,y,p,e,t,function(n){n?next(c||n):x?y.handleRequest(e,t,next):trimPrefix(y,c,S,v),d=0})}function trimPrefix(n,r,i,l){if(i.length!==0){if(i!==l.substring(0,i.length)){next(r);return}let t=l[i.length];if(t&&t!==`/`){next(r);return}c(`trim prefix (%s) from url %s`,i,e.url),s=i,e.url=o+e.url.slice(o.length+s.length),!o&&e.url[0]!==`/`&&(e.url=`/`+e.url,u=!0),e.baseUrl=g+(s[s.length-1]===`/`?s.substring(0,s.length-1):s)}c(`%s %s : %s`,n.name,i,e.originalUrl),r?n.handleError(r,e,t,next):n.handleRequest(e,t,next)}},Router.prototype.use=function use(e){let t=0,n=`/`;if(typeof e!=`function`){let r=e;for(;Array.isArray(r)&&r.length!==0;)r=r[0];typeof r!=`function`&&(t=1,n=e)}let i=d.call(u.call(arguments,t),1/0);if(i.length===0)throw TypeError(`argument handler is required`);for(let e=0;e<i.length;e++){let t=i[e];if(typeof t!=`function`)throw TypeError(`argument handler must be a function`);c(`use %o %s`,n,t.name||`<anonymous>`);let o=new r(n,{sensitive:this.caseSensitive,strict:!1,end:!1},t);o.route=void 0,this.stack.push(o)}return this},Router.prototype.route=function route(e){let t=new s(e),n=new r(e,{sensitive:this.caseSensitive,strict:this.strict,end:!0},handle);function handle(e,n,r){t.dispatch(e,n,r)}return n.route=t,this.stack.push(n),t},p.concat(`all`).forEach(function(e){Router.prototype[e]=function(t){let n=this.route(t);return n[e].apply(n,u.call(arguments,1)),this}});function generateOptionsResponder(e,t){return function onDone(n,r){if(r||t.length===0)return n(r);trySendOptionsResponse(e,t,n)}}function getPathname(e){try{return o(e).pathname}catch{return}}function getProtohost(e){if(typeof e!=`string`||e.length===0||e[0]===`/`)return;let t=e.indexOf(`?`),n=t===-1?e.length:t,r=e.substring(0,n).indexOf(`://`);return r===-1?void 0:e.substring(0,e.indexOf(`/`,3+r))}function matchLayer(e,t){try{return e.match(t)}catch(e){return e}}function mergeParams(e,t){if(typeof t!=`object`||!t)return e;let n=Object.assign({},t);if(!(0 in e)||!(0 in t))return Object.assign(n,e);let r=0,i=0;for(;r in e;)r++;for(;i in t;)i++;for(r--;r>=0;r--)e[r+i]=e[r],r<i&&delete e[r];return Object.assign(n,e)}function processParams(e,t,r,i,o,s){let c=t.keys;if(!c||c.length===0)return s();let u=0,d=0,p,m,h,g;function param(t){if(t)return s(t);if(u>=c.length)return s();if(d=0,p=c[u++],m=i.params[p],h=e[p],g=r[p],m===void 0||!h)return param();if(g&&(g.match===m||g.error&&g.error!==`route`))return i.params[p]=g.value,param(g.error);r[p]=g={error:null,match:m,value:m},paramCallback()}function paramCallback(e){let t=h[d++];if(g.value=i.params[p],e){g.error=e,param(e);return}if(!t)return param();try{let e=t(i,o,paramCallback,m,p);n(e)&&(e instanceof Promise||l(`parameters that are Promise-like are deprecated, use a native Promise instead`),e.then(null,function(e){paramCallback(e||Error(`Rejected promise`))}))}catch(e){paramCallback(e)}}param()}function restore(e,t){let n=Array(arguments.length-2),r=Array(arguments.length-2);for(let e=0;e<n.length;e++)n[e]=arguments[e+2],r[e]=t[n[e]];return function(){for(let e=0;e<n.length;e++)t[n[e]]=r[e];return e.apply(this,arguments)}}function sendOptionsResponse(e,t){let n=Object.create(null);for(let e=0;e<t.length;e++)n[t[e]]=!0;let r=Object.keys(n).sort().join(`, `);e.setHeader(`Allow`,r),e.setHeader(`Content-Length`,Buffer.byteLength(r)),e.setHeader(`Content-Type`,`text/plain`),e.setHeader(`X-Content-Type-Options`,`nosniff`),e.end(r)}function trySendOptionsResponse(e,t,n){try{sendOptionsResponse(e,t)}catch(e){n(e)}}function wrap(e,t){return function proxy(){let n=Array(arguments.length+1);n[0]=e;for(let e=0,t=arguments.length;e<t;e++)n[e+1]=arguments[e];t.apply(this,n)}}})),km=__commonJSMin(((e,t)=>{
|
|
280
280
|
/*!
|
|
281
281
|
* express
|
|
282
282
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
|
@@ -284,7 +284,7 @@ let n=Tm(),r=Dm(),{METHODS:i}=($p(),__toCommonJS(Yp)),o=Ud(),s=Om(),c=el()(`rout
|
|
|
284
284
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
285
285
|
* MIT Licensed
|
|
286
286
|
*/
|
|
287
|
-
N();var n=Wd(),r=el()(`express:application`),i=sp(),o=($p(),__toCommonJS(Yp)),s=Sm().methods,c=Sm().compileETag,l=Sm().compileQueryParser,u=Sm().compileTrust,d=(jr(),__toCommonJS(hr)).resolve,p=wm(),m=km(),h=Array.prototype.slice,g=Array.prototype.flat,_=e=t.exports={},v=`@@symbol:trust_proxy_default`;_.init=function init(){var e=null;this.cache=Object.create(null),this.engines=Object.create(null),this.settings=Object.create(null),this.defaultConfiguration(),Object.defineProperty(this,"router",{configurable:!0,enumerable:!0,get:function getrouter(){return e===null&&(e=new m({caseSensitive:this.enabled(`case sensitive routing`),strict:this.enabled(`strict routing`)})),e}})},_.defaultConfiguration=function defaultConfiguration(){var e=`production`;this.enable(`x-powered-by`),this.set(`etag`,`weak`),this.set(`env`,e),this.set(`query parser`,`simple`),this.set(`subdomain offset`,2),this.set(`trust proxy`,!1),Object.defineProperty(this.settings,v,{configurable:!0,value:!0}),r(`booting in %s mode`,e),this.on(`mount`,function onmount(e){this.settings[v]===!0&&typeof e.settings[`trust proxy fn`]==`function`&&(delete this.settings[`trust proxy`],delete this.settings[`trust proxy fn`]),Object.setPrototypeOf(this.request,e.request),Object.setPrototypeOf(this.response,e.response),Object.setPrototypeOf(this.engines,e.engines),Object.setPrototypeOf(this.settings,e.settings)}),this.locals=Object.create(null),this.mountpath=`/`,this.locals.settings=this.settings,this.set(`view`,i),this.set(`views`,d(`views`)),this.set(`jsonp callback name`,`callback`),e===`production`&&this.enable(`view cache`)},_.handle=function handle(e,t,r){var i=r||n(e,t,{env:this.get(`env`),onerror:logerror.bind(this)});this.enabled(`x-powered-by`)&&t.setHeader(`X-Powered-By`,`Express`),e.res=t,t.req=e,Object.setPrototypeOf(e,this.request),Object.setPrototypeOf(t,this.response),t.locals||=Object.create(null),this.router.handle(e,t,i)},_.use=function use(e){var t=0,n=`/`;if(typeof e!=`function`){for(var i=e;Array.isArray(i)&&i.length!==0;)i=i[0];typeof i!=`function`&&(t=1,n=e)}var o=g.call(h.call(arguments,t),1/0);if(o.length===0)throw TypeError(`app.use() requires a middleware function`);var s=this.router;return o.forEach(function(e){if(!e||!e.handle||!e.set)return s.use(n,e);r(`.use app under %s`,n),e.mountpath=n,e.parent=this,s.use(n,function mounted_app(t,n,r){var i=t.app;e.handle(t,n,function(e){Object.setPrototypeOf(t,i.request),Object.setPrototypeOf(n,i.response),r(e)})}),e.emit(`mount`,this)},this),this},_.route=function route(e){return this.router.route(e)},_.engine=function engine(e,t){if(typeof t!=`function`)throw Error(`callback function required`);var n=e[0]===`.`?e:`.`+e;return this.engines[n]=t,this},_.param=function param(e,t){if(Array.isArray(e)){for(var n=0;n<e.length;n++)this.param(e[n],t);return this}return this.router.param(e,t),this},_.set=function set(e,t){if(arguments.length===1)return this.settings[e];switch(r(`set "%s" to %o`,e,t),this.settings[e]=t,e){case`etag`:this.set(`etag fn`,c(t));break;case`query parser`:this.set(`query parser fn`,l(t));break;case`trust proxy`:this.set(`trust proxy fn`,u(t)),Object.defineProperty(this.settings,v,{configurable:!0,value:!1});break}return this},_.path=function path(){return this.parent?this.parent.path()+this.mountpath:``},_.enabled=function enabled(e){return!!this.set(e)},_.disabled=function disabled(e){return!this.set(e)},_.enable=function enable(e){return this.set(e,!0)},_.disable=function disable(e){return this.set(e,!1)},s.forEach(function(e){_[e]=function(t){if(e===`get`&&arguments.length===1)return this.set(t);var n=this.route(t);return n[e].apply(n,h.call(arguments,1)),this}}),_.all=function all(e){for(var t=this.route(e),n=h.call(arguments,1),r=0;r<s.length;r++)t[s[r]].apply(t,n);return this},_.render=function render(e,t,n){var r=this.cache,i=n,o=this.engines,s=t,c;typeof t==`function`&&(i=t,s={});var l={...this.locals,...s._locals,...s};if(l.cache??=this.enabled(`view cache`),l.cache&&(c=r[e]),!c){if(c=new(this.get(`view`))(e,{defaultEngine:this.get(`view engine`),root:this.get(`views`),engines:o}),!c.path){var u=Array.isArray(c.root)&&c.root.length>1?`directories "`+c.root.slice(0,-1).join(`", "`)+`" or "`+c.root[c.root.length-1]+`"`:`directory "`+c.root+`"`,d=Error(`Failed to lookup view "`+e+`" in views `+u);return d.view=c,i(d)}l.cache&&(r[e]=c)}tryRender(c,l,i)},_.listen=function listen(){var e=o.createServer(this),t=h.call(arguments);if(typeof t[t.length-1]==`function`){var n=t[t.length-1]=p(t[t.length-1]);e.once(`error`,n)}return e.listen.apply(e,t)};function logerror(e){this.get(`env`)!==`test`&&M.error(e.stack||e.toString())}function tryRender(e,t,n){try{e.render(t,n)}catch(e){n(e)}}})),jm=__commonJSMin(((e,t)=>{t.exports=preferredCharsets,t.exports.preferredCharsets=preferredCharsets;var n=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function parseAcceptCharset(e){for(var t=e.split(`,`),n=0,r=0;n<t.length;n++){var i=parseCharset(t[n].trim(),n);i&&(t[r++]=i)}return t.length=r,t}function parseCharset(e,t){var r=n.exec(e);if(!r)return null;var i=r[1],o=1;if(r[2])for(var s=r[2].split(`;`),c=0;c<s.length;c++){var l=s[c].trim().split(`=`);if(l[0]===`q`){o=parseFloat(l[1]);break}}return{charset:i,q:o,i:t}}function getCharsetPriority(e,t,n){for(var r={o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=0;if(t.charset.toLowerCase()===e.toLowerCase())r|=1;else if(t.charset!==`*`)return null;return{i:n,o:t.i,q:t.q,s:r}}function preferredCharsets(e,t){var n=parseAcceptCharset(e===void 0?`*`:e||``);if(!t)return n.filter(isQuality).sort(compareSpecs).map(getFullCharset);var r=t.map(function getPriority(e,t){return getCharsetPriority(e,n,t)});return r.filter(isQuality).sort(compareSpecs).map(function getCharset(e){return t[r.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i||0}function getFullCharset(e){return e.charset}function isQuality(e){return e.q>0}})),Mm=__commonJSMin(((e,t)=>{t.exports=preferredEncodings,t.exports.preferredEncodings=preferredEncodings;var n=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function parseAcceptEncoding(e){for(var t=e.split(`,`),n=!1,r=1,i=0,o=0;i<t.length;i++){var s=parseEncoding(t[i].trim(),i);s&&(t[o++]=s,n||=specify(`identity`,s),r=Math.min(r,s.q||1))}return n||(t[o++]={encoding:`identity`,q:r,i}),t.length=o,t}function parseEncoding(e,t){var r=n.exec(e);if(!r)return null;var i=r[1],o=1;if(r[2])for(var s=r[2].split(`;`),c=0;c<s.length;c++){var l=s[c].trim().split(`=`);if(l[0]===`q`){o=parseFloat(l[1]);break}}return{encoding:i,q:o,i:t}}function getEncodingPriority(e,t,n){for(var r={encoding:e,o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=0;if(t.encoding.toLowerCase()===e.toLowerCase())r|=1;else if(t.encoding!==`*`)return null;return{encoding:e,i:n,o:t.i,q:t.q,s:r}}function preferredEncodings(e,t,n){var r=parseAcceptEncoding(e||``),i=n?function comparator(e,t){if(e.q!==t.q)return t.q-e.q;var r=n.indexOf(e.encoding),i=n.indexOf(t.encoding);return r===-1&&i===-1?t.s-e.s||e.o-t.o||e.i-t.i:r!==-1&&i!==-1?r-i:r===-1?1:-1}:compareSpecs;if(!t)return r.filter(isQuality).sort(i).map(getFullEncoding);var o=t.map(function getPriority(e,t){return getEncodingPriority(e,r,t)});return o.filter(isQuality).sort(i).map(function getEncoding(e){return t[o.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i}function getFullEncoding(e){return e.encoding}function isQuality(e){return e.q>0}})),Nm=__commonJSMin(((e,t)=>{t.exports=preferredLanguages,t.exports.preferredLanguages=preferredLanguages;var n=/^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;function parseAcceptLanguage(e){for(var t=e.split(`,`),n=0,r=0;n<t.length;n++){var i=parseLanguage(t[n].trim(),n);i&&(t[r++]=i)}return t.length=r,t}function parseLanguage(e,t){var r=n.exec(e);if(!r)return null;var i=r[1],o=r[2],s=i;o&&(s+=`-`+o);var c=1;if(r[3])for(var l=r[3].split(`;`),u=0;u<l.length;u++){var d=l[u].split(`=`);d[0]===`q`&&(c=parseFloat(d[1]))}return{prefix:i,suffix:o,q:c,i:t,full:s}}function getLanguagePriority(e,t,n){for(var r={o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=parseLanguage(e);if(!r)return null;var i=0;if(t.full.toLowerCase()===r.full.toLowerCase())i|=4;else if(t.prefix.toLowerCase()===r.full.toLowerCase())i|=2;else if(t.full.toLowerCase()===r.prefix.toLowerCase())i|=1;else if(t.full!==`*`)return null;return{i:n,o:t.i,q:t.q,s:i}}function preferredLanguages(e,t){var n=parseAcceptLanguage(e===void 0?`*`:e||``);if(!t)return n.filter(isQuality).sort(compareSpecs).map(getFullLanguage);var r=t.map(function getPriority(e,t){return getLanguagePriority(e,n,t)});return r.filter(isQuality).sort(compareSpecs).map(function getLanguage(e){return t[r.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i||0}function getFullLanguage(e){return e.full}function isQuality(e){return e.q>0}})),Pm=__commonJSMin(((e,t)=>{t.exports=preferredMediaTypes,t.exports.preferredMediaTypes=preferredMediaTypes;var n=/^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;function parseAccept(e){for(var t=splitMediaTypes(e),n=0,r=0;n<t.length;n++){var i=parseMediaType(t[n].trim(),n);i&&(t[r++]=i)}return t.length=r,t}function parseMediaType(e,t){var r=n.exec(e);if(!r)return null;var i=Object.create(null),o=1,s=r[2],c=r[1];if(r[3])for(var l=splitParameters(r[3]).map(splitKeyValuePair),u=0;u<l.length;u++){var d=l[u],p=d[0].toLowerCase(),m=d[1],h=m&&m[0]===`"`&&m[m.length-1]===`"`?m.slice(1,-1):m;if(p===`q`){o=parseFloat(h);break}i[p]=h}return{type:c,subtype:s,params:i,q:o,i:t}}function getMediaTypePriority(e,t,n){for(var r={o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=parseMediaType(e),i=0;if(!r)return null;if(t.type.toLowerCase()==r.type.toLowerCase())i|=4;else if(t.type!=`*`)return null;if(t.subtype.toLowerCase()==r.subtype.toLowerCase())i|=2;else if(t.subtype!=`*`)return null;var o=Object.keys(t.params);if(o.length>0)if(o.every(function(e){return t.params[e]==`*`||(t.params[e]||``).toLowerCase()==(r.params[e]||``).toLowerCase()}))i|=1;else return null;return{i:n,o:t.i,q:t.q,s:i}}function preferredMediaTypes(e,t){var n=parseAccept(e===void 0?`*/*`:e||``);if(!t)return n.filter(isQuality).sort(compareSpecs).map(getFullType);var r=t.map(function getPriority(e,t){return getMediaTypePriority(e,n,t)});return r.filter(isQuality).sort(compareSpecs).map(function getType(e){return t[r.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i||0}function getFullType(e){return e.type+`/`+e.subtype}function isQuality(e){return e.q>0}function quoteCount(e){for(var t=0,n=0;(n=e.indexOf(`"`,n))!==-1;)t++,n++;return t}function splitKeyValuePair(e){var t=e.indexOf(`=`),n,r;return t===-1?n=e:(n=e.slice(0,t),r=e.slice(t+1)),[n,r]}function splitMediaTypes(e){for(var t=e.split(`,`),n=1,r=0;n<t.length;n++)quoteCount(t[r])%2==0?t[++r]=t[n]:t[r]+=`,`+t[n];return t.length=r+1,t}function splitParameters(e){for(var t=e.split(`;`),n=1,r=0;n<t.length;n++)quoteCount(t[r])%2==0?t[++r]=t[n]:t[r]+=`;`+t[n];t.length=r+1;for(var n=0;n<t.length;n++)t[n]=t[n].trim();return t}})),Fm=__commonJSMin(((e,t)=>{
|
|
287
|
+
N();var n=Wd(),r=el()(`express:application`),i=sp(),o=(Qp(),__toCommonJS(Jp)),s=xm().methods,c=xm().compileETag,l=xm().compileQueryParser,u=xm().compileTrust,d=(jr(),__toCommonJS(hr)).resolve,p=Cm(),m=Om(),h=Array.prototype.slice,g=Array.prototype.flat,_=e=t.exports={},v=`@@symbol:trust_proxy_default`;_.init=function init(){var e=null;this.cache=Object.create(null),this.engines=Object.create(null),this.settings=Object.create(null),this.defaultConfiguration(),Object.defineProperty(this,"router",{configurable:!0,enumerable:!0,get:function getrouter(){return e===null&&(e=new m({caseSensitive:this.enabled(`case sensitive routing`),strict:this.enabled(`strict routing`)})),e}})},_.defaultConfiguration=function defaultConfiguration(){var e=`production`;this.enable(`x-powered-by`),this.set(`etag`,`weak`),this.set(`env`,e),this.set(`query parser`,`simple`),this.set(`subdomain offset`,2),this.set(`trust proxy`,!1),Object.defineProperty(this.settings,v,{configurable:!0,value:!0}),r(`booting in %s mode`,e),this.on(`mount`,function onmount(e){this.settings[v]===!0&&typeof e.settings[`trust proxy fn`]==`function`&&(delete this.settings[`trust proxy`],delete this.settings[`trust proxy fn`]),Object.setPrototypeOf(this.request,e.request),Object.setPrototypeOf(this.response,e.response),Object.setPrototypeOf(this.engines,e.engines),Object.setPrototypeOf(this.settings,e.settings)}),this.locals=Object.create(null),this.mountpath=`/`,this.locals.settings=this.settings,this.set(`view`,i),this.set(`views`,d(`views`)),this.set(`jsonp callback name`,`callback`),e===`production`&&this.enable(`view cache`)},_.handle=function handle(e,t,r){var i=r||n(e,t,{env:this.get(`env`),onerror:logerror.bind(this)});this.enabled(`x-powered-by`)&&t.setHeader(`X-Powered-By`,`Express`),e.res=t,t.req=e,Object.setPrototypeOf(e,this.request),Object.setPrototypeOf(t,this.response),t.locals||=Object.create(null),this.router.handle(e,t,i)},_.use=function use(e){var t=0,n=`/`;if(typeof e!=`function`){for(var i=e;Array.isArray(i)&&i.length!==0;)i=i[0];typeof i!=`function`&&(t=1,n=e)}var o=g.call(h.call(arguments,t),1/0);if(o.length===0)throw TypeError(`app.use() requires a middleware function`);var s=this.router;return o.forEach(function(e){if(!e||!e.handle||!e.set)return s.use(n,e);r(`.use app under %s`,n),e.mountpath=n,e.parent=this,s.use(n,function mounted_app(t,n,r){var i=t.app;e.handle(t,n,function(e){Object.setPrototypeOf(t,i.request),Object.setPrototypeOf(n,i.response),r(e)})}),e.emit(`mount`,this)},this),this},_.route=function route(e){return this.router.route(e)},_.engine=function engine(e,t){if(typeof t!=`function`)throw Error(`callback function required`);var n=e[0]===`.`?e:`.`+e;return this.engines[n]=t,this},_.param=function param(e,t){if(Array.isArray(e)){for(var n=0;n<e.length;n++)this.param(e[n],t);return this}return this.router.param(e,t),this},_.set=function set(e,t){if(arguments.length===1)return this.settings[e];switch(r(`set "%s" to %o`,e,t),this.settings[e]=t,e){case`etag`:this.set(`etag fn`,c(t));break;case`query parser`:this.set(`query parser fn`,l(t));break;case`trust proxy`:this.set(`trust proxy fn`,u(t)),Object.defineProperty(this.settings,v,{configurable:!0,value:!1});break}return this},_.path=function path(){return this.parent?this.parent.path()+this.mountpath:``},_.enabled=function enabled(e){return!!this.set(e)},_.disabled=function disabled(e){return!this.set(e)},_.enable=function enable(e){return this.set(e,!0)},_.disable=function disable(e){return this.set(e,!1)},s.forEach(function(e){_[e]=function(t){if(e===`get`&&arguments.length===1)return this.set(t);var n=this.route(t);return n[e].apply(n,h.call(arguments,1)),this}}),_.all=function all(e){for(var t=this.route(e),n=h.call(arguments,1),r=0;r<s.length;r++)t[s[r]].apply(t,n);return this},_.render=function render(e,t,n){var r=this.cache,i=n,o=this.engines,s=t,c;typeof t==`function`&&(i=t,s={});var l={...this.locals,...s._locals,...s};if(l.cache??=this.enabled(`view cache`),l.cache&&(c=r[e]),!c){if(c=new(this.get(`view`))(e,{defaultEngine:this.get(`view engine`),root:this.get(`views`),engines:o}),!c.path){var u=Array.isArray(c.root)&&c.root.length>1?`directories "`+c.root.slice(0,-1).join(`", "`)+`" or "`+c.root[c.root.length-1]+`"`:`directory "`+c.root+`"`,d=Error(`Failed to lookup view "`+e+`" in views `+u);return d.view=c,i(d)}l.cache&&(r[e]=c)}tryRender(c,l,i)},_.listen=function listen(){var e=o.createServer(this),t=h.call(arguments);if(typeof t[t.length-1]==`function`){var n=t[t.length-1]=p(t[t.length-1]);e.once(`error`,n)}return e.listen.apply(e,t)};function logerror(e){this.get(`env`)!==`test`&&M.error(e.stack||e.toString())}function tryRender(e,t,n){try{e.render(t,n)}catch(e){n(e)}}})),Am=__commonJSMin(((e,t)=>{t.exports=preferredCharsets,t.exports.preferredCharsets=preferredCharsets;var n=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function parseAcceptCharset(e){for(var t=e.split(`,`),n=0,r=0;n<t.length;n++){var i=parseCharset(t[n].trim(),n);i&&(t[r++]=i)}return t.length=r,t}function parseCharset(e,t){var r=n.exec(e);if(!r)return null;var i=r[1],o=1;if(r[2])for(var s=r[2].split(`;`),c=0;c<s.length;c++){var l=s[c].trim().split(`=`);if(l[0]===`q`){o=parseFloat(l[1]);break}}return{charset:i,q:o,i:t}}function getCharsetPriority(e,t,n){for(var r={o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=0;if(t.charset.toLowerCase()===e.toLowerCase())r|=1;else if(t.charset!==`*`)return null;return{i:n,o:t.i,q:t.q,s:r}}function preferredCharsets(e,t){var n=parseAcceptCharset(e===void 0?`*`:e||``);if(!t)return n.filter(isQuality).sort(compareSpecs).map(getFullCharset);var r=t.map(function getPriority(e,t){return getCharsetPriority(e,n,t)});return r.filter(isQuality).sort(compareSpecs).map(function getCharset(e){return t[r.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i||0}function getFullCharset(e){return e.charset}function isQuality(e){return e.q>0}})),jm=__commonJSMin(((e,t)=>{t.exports=preferredEncodings,t.exports.preferredEncodings=preferredEncodings;var n=/^\s*([^\s;]+)\s*(?:;(.*))?$/;function parseAcceptEncoding(e){for(var t=e.split(`,`),n=!1,r=1,i=0,o=0;i<t.length;i++){var s=parseEncoding(t[i].trim(),i);s&&(t[o++]=s,n||=specify(`identity`,s),r=Math.min(r,s.q||1))}return n||(t[o++]={encoding:`identity`,q:r,i}),t.length=o,t}function parseEncoding(e,t){var r=n.exec(e);if(!r)return null;var i=r[1],o=1;if(r[2])for(var s=r[2].split(`;`),c=0;c<s.length;c++){var l=s[c].trim().split(`=`);if(l[0]===`q`){o=parseFloat(l[1]);break}}return{encoding:i,q:o,i:t}}function getEncodingPriority(e,t,n){for(var r={encoding:e,o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=0;if(t.encoding.toLowerCase()===e.toLowerCase())r|=1;else if(t.encoding!==`*`)return null;return{encoding:e,i:n,o:t.i,q:t.q,s:r}}function preferredEncodings(e,t,n){var r=parseAcceptEncoding(e||``),i=n?function comparator(e,t){if(e.q!==t.q)return t.q-e.q;var r=n.indexOf(e.encoding),i=n.indexOf(t.encoding);return r===-1&&i===-1?t.s-e.s||e.o-t.o||e.i-t.i:r!==-1&&i!==-1?r-i:r===-1?1:-1}:compareSpecs;if(!t)return r.filter(isQuality).sort(i).map(getFullEncoding);var o=t.map(function getPriority(e,t){return getEncodingPriority(e,r,t)});return o.filter(isQuality).sort(i).map(function getEncoding(e){return t[o.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i}function getFullEncoding(e){return e.encoding}function isQuality(e){return e.q>0}})),Mm=__commonJSMin(((e,t)=>{t.exports=preferredLanguages,t.exports.preferredLanguages=preferredLanguages;var n=/^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;function parseAcceptLanguage(e){for(var t=e.split(`,`),n=0,r=0;n<t.length;n++){var i=parseLanguage(t[n].trim(),n);i&&(t[r++]=i)}return t.length=r,t}function parseLanguage(e,t){var r=n.exec(e);if(!r)return null;var i=r[1],o=r[2],s=i;o&&(s+=`-`+o);var c=1;if(r[3])for(var l=r[3].split(`;`),u=0;u<l.length;u++){var d=l[u].split(`=`);d[0]===`q`&&(c=parseFloat(d[1]))}return{prefix:i,suffix:o,q:c,i:t,full:s}}function getLanguagePriority(e,t,n){for(var r={o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=parseLanguage(e);if(!r)return null;var i=0;if(t.full.toLowerCase()===r.full.toLowerCase())i|=4;else if(t.prefix.toLowerCase()===r.full.toLowerCase())i|=2;else if(t.full.toLowerCase()===r.prefix.toLowerCase())i|=1;else if(t.full!==`*`)return null;return{i:n,o:t.i,q:t.q,s:i}}function preferredLanguages(e,t){var n=parseAcceptLanguage(e===void 0?`*`:e||``);if(!t)return n.filter(isQuality).sort(compareSpecs).map(getFullLanguage);var r=t.map(function getPriority(e,t){return getLanguagePriority(e,n,t)});return r.filter(isQuality).sort(compareSpecs).map(function getLanguage(e){return t[r.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i||0}function getFullLanguage(e){return e.full}function isQuality(e){return e.q>0}})),Nm=__commonJSMin(((e,t)=>{t.exports=preferredMediaTypes,t.exports.preferredMediaTypes=preferredMediaTypes;var n=/^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;function parseAccept(e){for(var t=splitMediaTypes(e),n=0,r=0;n<t.length;n++){var i=parseMediaType(t[n].trim(),n);i&&(t[r++]=i)}return t.length=r,t}function parseMediaType(e,t){var r=n.exec(e);if(!r)return null;var i=Object.create(null),o=1,s=r[2],c=r[1];if(r[3])for(var l=splitParameters(r[3]).map(splitKeyValuePair),u=0;u<l.length;u++){var d=l[u],p=d[0].toLowerCase(),m=d[1],h=m&&m[0]===`"`&&m[m.length-1]===`"`?m.slice(1,-1):m;if(p===`q`){o=parseFloat(h);break}i[p]=h}return{type:c,subtype:s,params:i,q:o,i:t}}function getMediaTypePriority(e,t,n){for(var r={o:-1,q:0,s:0},i=0;i<t.length;i++){var o=specify(e,t[i],n);o&&(r.s-o.s||r.q-o.q||r.o-o.o)<0&&(r=o)}return r}function specify(e,t,n){var r=parseMediaType(e),i=0;if(!r)return null;if(t.type.toLowerCase()==r.type.toLowerCase())i|=4;else if(t.type!=`*`)return null;if(t.subtype.toLowerCase()==r.subtype.toLowerCase())i|=2;else if(t.subtype!=`*`)return null;var o=Object.keys(t.params);if(o.length>0)if(o.every(function(e){return t.params[e]==`*`||(t.params[e]||``).toLowerCase()==(r.params[e]||``).toLowerCase()}))i|=1;else return null;return{i:n,o:t.i,q:t.q,s:i}}function preferredMediaTypes(e,t){var n=parseAccept(e===void 0?`*/*`:e||``);if(!t)return n.filter(isQuality).sort(compareSpecs).map(getFullType);var r=t.map(function getPriority(e,t){return getMediaTypePriority(e,n,t)});return r.filter(isQuality).sort(compareSpecs).map(function getType(e){return t[r.indexOf(e)]})}function compareSpecs(e,t){return t.q-e.q||t.s-e.s||e.o-t.o||e.i-t.i||0}function getFullType(e){return e.type+`/`+e.subtype}function isQuality(e){return e.q>0}function quoteCount(e){for(var t=0,n=0;(n=e.indexOf(`"`,n))!==-1;)t++,n++;return t}function splitKeyValuePair(e){var t=e.indexOf(`=`),n,r;return t===-1?n=e:(n=e.slice(0,t),r=e.slice(t+1)),[n,r]}function splitMediaTypes(e){for(var t=e.split(`,`),n=1,r=0;n<t.length;n++)quoteCount(t[r])%2==0?t[++r]=t[n]:t[r]+=`,`+t[n];return t.length=r+1,t}function splitParameters(e){for(var t=e.split(`;`),n=1,r=0;n<t.length;n++)quoteCount(t[r])%2==0?t[++r]=t[n]:t[r]+=`;`+t[n];t.length=r+1;for(var n=0;n<t.length;n++)t[n]=t[n].trim();return t}})),Pm=__commonJSMin(((e,t)=>{
|
|
288
288
|
/*!
|
|
289
289
|
* negotiator
|
|
290
290
|
* Copyright(c) 2012 Federico Romero
|
|
@@ -292,28 +292,28 @@ N();var n=Wd(),r=el()(`express:application`),i=sp(),o=($p(),__toCommonJS(Yp)),s=
|
|
|
292
292
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
293
293
|
* MIT Licensed
|
|
294
294
|
*/
|
|
295
|
-
var n=
|
|
295
|
+
var n=Am(),r=jm(),i=Mm(),o=Nm();t.exports=Negotiator,t.exports.Negotiator=Negotiator;function Negotiator(e){if(!(this instanceof Negotiator))return new Negotiator(e);this.request=e}Negotiator.prototype.charset=function charset(e){var t=this.charsets(e);return t&&t[0]},Negotiator.prototype.charsets=function charsets(e){return n(this.request.headers[`accept-charset`],e)},Negotiator.prototype.encoding=function encoding(e,t){var n=this.encodings(e,t);return n&&n[0]},Negotiator.prototype.encodings=function encodings(e,t){var n=t||{};return r(this.request.headers[`accept-encoding`],e,n.preferred)},Negotiator.prototype.language=function language(e){var t=this.languages(e);return t&&t[0]},Negotiator.prototype.languages=function languages(e){return i(this.request.headers[`accept-language`],e)},Negotiator.prototype.mediaType=function mediaType(e){var t=this.mediaTypes(e);return t&&t[0]},Negotiator.prototype.mediaTypes=function mediaTypes(e){return o(this.request.headers.accept,e)},Negotiator.prototype.preferredCharset=Negotiator.prototype.charset,Negotiator.prototype.preferredCharsets=Negotiator.prototype.charsets,Negotiator.prototype.preferredEncoding=Negotiator.prototype.encoding,Negotiator.prototype.preferredEncodings=Negotiator.prototype.encodings,Negotiator.prototype.preferredLanguage=Negotiator.prototype.language,Negotiator.prototype.preferredLanguages=Negotiator.prototype.languages,Negotiator.prototype.preferredMediaType=Negotiator.prototype.mediaType,Negotiator.prototype.preferredMediaTypes=Negotiator.prototype.mediaTypes})),Fm=__commonJSMin(((e,t)=>{
|
|
296
296
|
/*!
|
|
297
297
|
* accepts
|
|
298
298
|
* Copyright(c) 2014 Jonathan Ong
|
|
299
299
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
300
300
|
* MIT Licensed
|
|
301
301
|
*/
|
|
302
|
-
var n=
|
|
302
|
+
var n=Pm(),r=ql();t.exports=Accepts;function Accepts(e){if(!(this instanceof Accepts))return new Accepts(e);this.headers=e.headers,this.negotiator=new n(e)}Accepts.prototype.type=Accepts.prototype.types=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}if(!t||t.length===0)return this.negotiator.mediaTypes();if(!this.headers.accept)return t[0];var r=t.map(extToMime),i=this.negotiator.mediaTypes(r.filter(validMime))[0];return i?t[r.indexOf(i)]:!1},Accepts.prototype.encoding=Accepts.prototype.encodings=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.encodings():this.negotiator.encodings(t)[0]||!1},Accepts.prototype.charset=Accepts.prototype.charsets=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.charsets():this.negotiator.charsets(t)[0]||!1},Accepts.prototype.lang=Accepts.prototype.langs=Accepts.prototype.language=Accepts.prototype.languages=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.languages():this.negotiator.languages(t)[0]||!1};function extToMime(e){return e.indexOf(`/`)===-1?r.lookup(e):e}function validMime(e){return typeof e==`string`}})),Im=__commonJSMin(((e,t)=>{
|
|
303
303
|
/*!
|
|
304
304
|
* fresh
|
|
305
305
|
* Copyright(c) 2012 TJ Holowaychuk
|
|
306
306
|
* Copyright(c) 2016-2017 Douglas Christopher Wilson
|
|
307
307
|
* MIT Licensed
|
|
308
308
|
*/
|
|
309
|
-
var n=/(?:^|,)\s*?no-cache\s*?(?:,|$)/;t.exports=fresh;function fresh(e,t){var r=e[`if-modified-since`],i=e[`if-none-match`];if(!r&&!i)return!1;var o=e[`cache-control`];if(o&&n.test(o))return!1;if(i){if(i===`*`)return!0;var s=t.etag;if(!s)return!1;for(var c=parseTokenList(i),l=0;l<c.length;l++){var u=c[l];if(u===s||u===`W/`+s||`W/`+u===s)return!0}return!1}if(r){var d=t[`last-modified`];if(!d||!(parseHttpDate(d)<=parseHttpDate(r)))return!1}return!0}function parseHttpDate(e){var t=e&&Date.parse(e);return typeof t==`number`?t:NaN}function parseTokenList(e){for(var t=0,n=[],r=0,i=0,o=e.length;i<o;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1;break}return n.push(e.substring(r,t)),n}})),
|
|
309
|
+
var n=/(?:^|,)\s*?no-cache\s*?(?:,|$)/;t.exports=fresh;function fresh(e,t){var r=e[`if-modified-since`],i=e[`if-none-match`];if(!r&&!i)return!1;var o=e[`cache-control`];if(o&&n.test(o))return!1;if(i){if(i===`*`)return!0;var s=t.etag;if(!s)return!1;for(var c=parseTokenList(i),l=0;l<c.length;l++){var u=c[l];if(u===s||u===`W/`+s||`W/`+u===s)return!0}return!1}if(r){var d=t[`last-modified`];if(!d||!(parseHttpDate(d)<=parseHttpDate(r)))return!1}return!0}function parseHttpDate(e){var t=e&&Date.parse(e);return typeof t==`number`?t:NaN}function parseTokenList(e){for(var t=0,n=[],r=0,i=0,o=e.length;i<o;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1;break}return n.push(e.substring(r,t)),n}})),Lm=__commonJSMin(((e,t)=>{
|
|
310
310
|
/*!
|
|
311
311
|
* range-parser
|
|
312
312
|
* Copyright(c) 2012-2014 TJ Holowaychuk
|
|
313
313
|
* Copyright(c) 2015-2016 Douglas Christopher Wilson
|
|
314
314
|
* MIT Licensed
|
|
315
315
|
*/
|
|
316
|
-
t.exports=rangeParser;function rangeParser(e,t,n){if(typeof t!=`string`)throw TypeError(`argument str must be a string`);var r=t.indexOf(`=`);if(r===-1)return-2;var i=t.slice(r+1).split(`,`),o=[];o.type=t.slice(0,r);for(var s=0;s<i.length;s++){var c=i[s].split(`-`),l=parseInt(c[0],10),u=parseInt(c[1],10);isNaN(l)?(l=e-u,u=e-1):isNaN(u)&&(u=e-1),u>e-1&&(u=e-1),!(isNaN(l)||isNaN(u)||l>u||l<0)&&o.push({start:l,end:u})}return o.length<1?-1:n&&n.combine?combineRanges(o):o}function combineRanges(e){for(var t=e.map(mapWithIndex).sort(sortByRangeStart),n=0,r=1;r<t.length;r++){var i=t[r],o=t[n];i.start>o.end+1?t[++n]=i:i.end>o.end&&(o.end=i.end,o.index=Math.min(o.index,i.index))}t.length=n+1;var s=t.sort(sortByRangeIndex).map(mapWithoutIndex);return s.type=e.type,s}function mapWithIndex(e,t){return{start:e.start,end:e.end,index:t}}function mapWithoutIndex(e){return{start:e.start,end:e.end}}function sortByRangeIndex(e,t){return e.index-t.index}function sortByRangeStart(e,t){return e.start-t.start}})),
|
|
316
|
+
t.exports=rangeParser;function rangeParser(e,t,n){if(typeof t!=`string`)throw TypeError(`argument str must be a string`);var r=t.indexOf(`=`);if(r===-1)return-2;var i=t.slice(r+1).split(`,`),o=[];o.type=t.slice(0,r);for(var s=0;s<i.length;s++){var c=i[s].split(`-`),l=parseInt(c[0],10),u=parseInt(c[1],10);isNaN(l)?(l=e-u,u=e-1):isNaN(u)&&(u=e-1),u>e-1&&(u=e-1),!(isNaN(l)||isNaN(u)||l>u||l<0)&&o.push({start:l,end:u})}return o.length<1?-1:n&&n.combine?combineRanges(o):o}function combineRanges(e){for(var t=e.map(mapWithIndex).sort(sortByRangeStart),n=0,r=1;r<t.length;r++){var i=t[r],o=t[n];i.start>o.end+1?t[++n]=i:i.end>o.end&&(o.end=i.end,o.index=Math.min(o.index,i.index))}t.length=n+1;var s=t.sort(sortByRangeIndex).map(mapWithoutIndex);return s.type=e.type,s}function mapWithIndex(e,t){return{start:e.start,end:e.end,index:t}}function mapWithoutIndex(e){return{start:e.start,end:e.end}}function sortByRangeIndex(e,t){return e.index-t.index}function sortByRangeStart(e,t){return e.start-t.start}})),Rm=__commonJSMin(((e,t)=>{
|
|
317
317
|
/*!
|
|
318
318
|
* express
|
|
319
319
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
|
@@ -321,27 +321,27 @@ t.exports=rangeParser;function rangeParser(e,t,n){if(typeof t!=`string`)throw Ty
|
|
|
321
321
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
322
322
|
* MIT Licensed
|
|
323
323
|
*/
|
|
324
|
-
var n=
|
|
324
|
+
var n=Fm(),r=(jp(),__toCommonJS(Op)).isIP,i=Yl(),o=(Qp(),__toCommonJS(Jp)),s=Im(),c=Lm(),l=Ud(),u=nm(),d=Object.create(o.IncomingMessage.prototype);t.exports=d,d.get=d.header=function header(e){if(!e)throw TypeError(`name argument is required to req.get`);if(typeof e!=`string`)throw TypeError(`name must be a string to req.get`);var t=e.toLowerCase();switch(t){case`referer`:case`referrer`:return this.headers.referrer||this.headers.referer;default:return this.headers[t]}},d.accepts=function(){var e=n(this);return e.types.apply(e,arguments)},d.acceptsEncodings=function(){var e=n(this);return e.encodings.apply(e,arguments)},d.acceptsCharsets=function(){var e=n(this);return e.charsets.apply(e,arguments)},d.acceptsLanguages=function(...e){return n(this).languages(...e)},d.range=function range(e,t){var n=this.get(`Range`);if(n)return c(e,n,t)},defineGetter(d,`query`,function query(){var e=this.app.get(`query parser fn`);if(!e)return Object.create(null);var t=l(this).query;return e(t)}),d.is=function is(e){var t=e;if(!Array.isArray(e)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return i(this,t)},defineGetter(d,`protocol`,function protocol(){var e=this.socket.encrypted?`https`:`http`;if(!this.app.get(`trust proxy fn`)(this.socket.remoteAddress,0))return e;var t=this.get(`X-Forwarded-Proto`)||e,n=t.indexOf(`,`);return n===-1?t.trim():t.substring(0,n).trim()}),defineGetter(d,`secure`,function secure(){return this.protocol===`https`}),defineGetter(d,`ip`,function ip(){var e=this.app.get(`trust proxy fn`);return u(this,e)}),defineGetter(d,`ips`,function ips(){var e=this.app.get(`trust proxy fn`),t=u.all(this,e);return t.reverse().pop(),t}),defineGetter(d,`subdomains`,function subdomains(){var e=this.hostname;if(!e)return[];var t=this.app.get(`subdomain offset`);return(r(e)?[e]:e.split(`.`).reverse()).slice(t)}),defineGetter(d,`path`,function path(){return l(this).pathname}),defineGetter(d,`host`,function host(){var e=this.app.get(`trust proxy fn`),t=this.get(`X-Forwarded-Host`);return!t||!e(this.socket.remoteAddress,0)?t=this.get(`Host`):t.indexOf(`,`)!==-1&&(t=t.substring(0,t.indexOf(`,`)).trimRight()),t||void 0}),defineGetter(d,`hostname`,function hostname(){var e=this.host;if(e){var t=e[0]===`[`?e.indexOf(`]`)+1:0,n=e.indexOf(`:`,t);return n===-1?e:e.substring(0,n)}}),defineGetter(d,`fresh`,function(){var e=this.method,t=this.res,n=t.statusCode;return e!==`GET`&&e!==`HEAD`?!1:n>=200&&n<300||n===304?s(this.headers,{etag:t.get(`ETag`),"last-modified":t.get(`Last-Modified`)}):!1}),defineGetter(d,`stale`,function stale(){return!this.fresh}),defineGetter(d,`xhr`,function xhr(){return(this.get(`X-Requested-With`)||``).toLowerCase()===`xmlhttprequest`});function defineGetter(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:n})}})),zm=__commonJSMin(((e,t)=>{
|
|
325
325
|
/*!
|
|
326
326
|
* content-disposition
|
|
327
327
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
328
328
|
* MIT Licensed
|
|
329
329
|
*/
|
|
330
|
-
t.exports=contentDisposition,t.exports.parse=parse;let n=new TextDecoder(`utf-8`);var r=/[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g,i=/[^\x20-\x7e\xa0-\xff]/g,o=/\\([\u0000-\u007f])/g,s=/([\\"])/g,c=/;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g,l=/^[\x20-\x7e\x80-\xff]+$/,u=/^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/,d=/^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/,p=/^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/;function contentDisposition(e,t){var n=t||{};return format(new ContentDisposition(n.type||`attachment`,createparams(e,n.fallback)))}function createparams(e,t){if(e!==void 0){var n={};if(typeof e!=`string`)throw TypeError(`filename must be a string`);if(t===void 0&&(t=!0),typeof t!=`string`&&typeof t!=`boolean`)throw TypeError(`fallback must be a string or boolean`);if(typeof t==`string`&&i.test(t))throw TypeError(`fallback must be ISO-8859-1 string`);var r=basename(e),o=l.test(r),s=typeof t==`string`?basename(t):t&&getlatin1(r),c=typeof s==`string`&&s!==r;return(c||!o||hasHexEscape(r))&&(n[`filename*`]=r),(o||c)&&(n.filename=c?s:r),n}}function format(e){var t=e.parameters,n=e.type;if(!n||typeof n!=`string`||!u.test(n))throw TypeError(`invalid type`);var r=String(n).toLowerCase();if(t&&typeof t==`object`)for(var i,o=Object.keys(t).sort(),s=0;s<o.length;s++){i=o[s];var c=i.slice(-1)===`*`?ustring(t[i]):qstring(t[i]);r+=`; `+i+`=`+c}return r}function decodefield(e){let t=d.exec(e);if(!t)throw TypeError(`invalid extended field value`);let r=t[1].toLowerCase(),i=t[2];switch(r){case`iso-8859-1`:return getlatin1(decodeHexEscapes(i));case`utf-8`:case`utf8`:try{return decodeURIComponent(i)}catch{let e=decodeHexEscapes(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return n.decode(t)}}throw TypeError(`unsupported charset in extended field`)}function getlatin1(e){return String(e).replace(i,`?`)}function parse(e){if(!e||typeof e!=`string`)throw TypeError(`argument string is required`);var t=p.exec(e);if(!t)throw TypeError(`invalid type format`);var n=t[0].length,r=t[1].toLowerCase(),i,s=[],l={},u;for(n=c.lastIndex=t[0].slice(-1)===`;`?n-1:n;t=c.exec(e);){if(t.index!==n)throw TypeError(`invalid parameter format`);if(n+=t[0].length,i=t[1].toLowerCase(),u=t[2],s.indexOf(i)!==-1)throw TypeError(`invalid duplicate parameter`);if(s.push(i),i.indexOf(`*`)+1===i.length){i=i.slice(0,-1),u=decodefield(u),l[i]=u;continue}typeof l[i]!=`string`&&(u[0]===`"`&&(u=u.slice(1,-1).replace(o,`$1`)),l[i]=u)}if(n!==-1&&n!==e.length)throw TypeError(`invalid parameter format`);return new ContentDisposition(r,l)}function pencode(e){return`%`+String(e).charCodeAt(0).toString(16).toUpperCase()}function qstring(e){return`"`+String(e).replace(s,`\\$1`)+`"`}function ustring(e){return`UTF-8''`+encodeURIComponent(String(e)).replace(r,pencode)}function ContentDisposition(e,t){this.type=e,this.parameters=t}function basename(e){let t=e.replaceAll(`\\`,`/`),n=t.length;for(;n>0&&t[n-1]===`/`;)n--;if(n===0)return``;let r=n-1;for(;r>=0&&t[r]!==`/`;)r--;return t.slice(r+1,n)}function isHexDigit(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function hasHexEscape(e){let t=e.length-3,n=-1;for(;(n=e.indexOf(`%`,n+1))!==-1&&n<=t;)if(isHexDigit(e[n+1])&&isHexDigit(e[n+2]))return!0;return!1}function decodeHexEscapes(e){let t=e.indexOf(`%`);if(t===-1)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++)e[r]===`%`&&r+2<e.length&&isHexDigit(e[r+1])&&isHexDigit(e[r+2])?(n+=String.fromCharCode(Number.parseInt(e[r+1]+e[r+2],16)),r+=2):n+=e[r];return n}})),
|
|
330
|
+
t.exports=contentDisposition,t.exports.parse=parse;let n=new TextDecoder(`utf-8`);var r=/[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g,i=/[^\x20-\x7e\xa0-\xff]/g,o=/\\([\u0000-\u007f])/g,s=/([\\"])/g,c=/;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g,l=/^[\x20-\x7e\x80-\xff]+$/,u=/^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/,d=/^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/,p=/^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/;function contentDisposition(e,t){var n=t||{};return format(new ContentDisposition(n.type||`attachment`,createparams(e,n.fallback)))}function createparams(e,t){if(e!==void 0){var n={};if(typeof e!=`string`)throw TypeError(`filename must be a string`);if(t===void 0&&(t=!0),typeof t!=`string`&&typeof t!=`boolean`)throw TypeError(`fallback must be a string or boolean`);if(typeof t==`string`&&i.test(t))throw TypeError(`fallback must be ISO-8859-1 string`);var r=basename(e),o=l.test(r),s=typeof t==`string`?basename(t):t&&getlatin1(r),c=typeof s==`string`&&s!==r;return(c||!o||hasHexEscape(r))&&(n[`filename*`]=r),(o||c)&&(n.filename=c?s:r),n}}function format(e){var t=e.parameters,n=e.type;if(!n||typeof n!=`string`||!u.test(n))throw TypeError(`invalid type`);var r=String(n).toLowerCase();if(t&&typeof t==`object`)for(var i,o=Object.keys(t).sort(),s=0;s<o.length;s++){i=o[s];var c=i.slice(-1)===`*`?ustring(t[i]):qstring(t[i]);r+=`; `+i+`=`+c}return r}function decodefield(e){let t=d.exec(e);if(!t)throw TypeError(`invalid extended field value`);let r=t[1].toLowerCase(),i=t[2];switch(r){case`iso-8859-1`:return getlatin1(decodeHexEscapes(i));case`utf-8`:case`utf8`:try{return decodeURIComponent(i)}catch{let e=decodeHexEscapes(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return n.decode(t)}}throw TypeError(`unsupported charset in extended field`)}function getlatin1(e){return String(e).replace(i,`?`)}function parse(e){if(!e||typeof e!=`string`)throw TypeError(`argument string is required`);var t=p.exec(e);if(!t)throw TypeError(`invalid type format`);var n=t[0].length,r=t[1].toLowerCase(),i,s=[],l={},u;for(n=c.lastIndex=t[0].slice(-1)===`;`?n-1:n;t=c.exec(e);){if(t.index!==n)throw TypeError(`invalid parameter format`);if(n+=t[0].length,i=t[1].toLowerCase(),u=t[2],s.indexOf(i)!==-1)throw TypeError(`invalid duplicate parameter`);if(s.push(i),i.indexOf(`*`)+1===i.length){i=i.slice(0,-1),u=decodefield(u),l[i]=u;continue}typeof l[i]!=`string`&&(u[0]===`"`&&(u=u.slice(1,-1).replace(o,`$1`)),l[i]=u)}if(n!==-1&&n!==e.length)throw TypeError(`invalid parameter format`);return new ContentDisposition(r,l)}function pencode(e){return`%`+String(e).charCodeAt(0).toString(16).toUpperCase()}function qstring(e){return`"`+String(e).replace(s,`\\$1`)+`"`}function ustring(e){return`UTF-8''`+encodeURIComponent(String(e)).replace(r,pencode)}function ContentDisposition(e,t){this.type=e,this.parameters=t}function basename(e){let t=e.replaceAll(`\\`,`/`),n=t.length;for(;n>0&&t[n-1]===`/`;)n--;if(n===0)return``;let r=n-1;for(;r>=0&&t[r]!==`/`;)r--;return t.slice(r+1,n)}function isHexDigit(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function hasHexEscape(e){let t=e.length-3,n=-1;for(;(n=e.indexOf(`%`,n+1))!==-1&&n<=t;)if(isHexDigit(e[n+1])&&isHexDigit(e[n+2]))return!0;return!1}function decodeHexEscapes(e){let t=e.indexOf(`%`);if(t===-1)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++)e[r]===`%`&&r+2<e.length&&isHexDigit(e[r+1])&&isHexDigit(e[r+2])?(n+=String.fromCharCode(Number.parseInt(e[r+1]+e[r+2],16)),r+=2):n+=e[r];return n}})),Bm=__commonJSMin((e=>{var t=(Tc(),__toCommonJS(Cc));e.sign=function(e,n){if(typeof e!=`string`)throw TypeError(`Cookie value must be provided as a string.`);if(n==null)throw TypeError(`Secret key must be provided.`);return e+`.`+t.createHmac(`sha256`,n).update(e).digest(`base64`).replace(/\=+$/,``)},e.unsign=function(n,r){if(typeof n!=`string`)throw TypeError(`Signed cookie string must be provided.`);if(r==null)throw TypeError(`Secret key must be provided.`);var i=n.slice(0,n.lastIndexOf(`.`)),o=e.sign(i,r),s=Buffer.from(o),c=Buffer.from(n);return s.length===c.length&&t.timingSafeEqual(s,c)?i:!1}})),Vm=__commonJSMin((e=>{
|
|
331
331
|
/*!
|
|
332
332
|
* cookie
|
|
333
333
|
* Copyright(c) 2012-2014 Roman Shtylman
|
|
334
334
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
335
335
|
* MIT Licensed
|
|
336
336
|
*/
|
|
337
|
-
e.parse=parse,e.serialize=serialize;var t=Object.prototype.toString,n=Object.prototype.hasOwnProperty,r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,i=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,o=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,s=/^[\u0020-\u003A\u003D-\u007E]*$/;function parse(e,t){if(typeof e!=`string`)throw TypeError(`argument str must be a string`);var r={},i=e.length;if(i<2)return r;var o=t&&t.decode||decode,s=0,c=0,l=0;do{if(c=e.indexOf(`=`,s),c===-1)break;if(l=e.indexOf(`;`,s),l===-1)l=i;else if(c>l){s=e.lastIndexOf(`;`,c-1)+1;continue}var u=startIndex(e,s,c),d=endIndex(e,c,u),p=e.slice(u,d);if(!n.call(r,p)){var m=startIndex(e,c+1,l),h=endIndex(e,l,m);e.charCodeAt(m)===34&&e.charCodeAt(h-1)===34&&(m++,h--),r[p]=tryDecode(e.slice(m,h),o)}s=l+1}while(s<i);return r}function startIndex(e,t,n){do{var r=e.charCodeAt(t);if(r!==32&&r!==9)return t}while(++t<n);return n}function endIndex(e,t,n){for(;t>n;){var r=e.charCodeAt(--t);if(r!==32&&r!==9)return t+1}return n}function serialize(e,t,n){var c=n&&n.encode||encodeURIComponent;if(typeof c!=`function`)throw TypeError(`option encode is invalid`);if(!r.test(e))throw TypeError(`argument name is invalid`);var l=c(t);if(!i.test(l))throw TypeError(`argument val is invalid`);var u=e+`=`+l;if(!n)return u;if(n.maxAge!=null){var d=Math.floor(n.maxAge);if(!isFinite(d))throw TypeError(`option maxAge is invalid`);u+=`; Max-Age=`+d}if(n.domain){if(!o.test(n.domain))throw TypeError(`option domain is invalid`);u+=`; Domain=`+n.domain}if(n.path){if(!s.test(n.path))throw TypeError(`option path is invalid`);u+=`; Path=`+n.path}if(n.expires){var p=n.expires;if(!isDate(p)||isNaN(p.valueOf()))throw TypeError(`option expires is invalid`);u+=`; Expires=`+p.toUTCString()}if(n.httpOnly&&(u+=`; HttpOnly`),n.secure&&(u+=`; Secure`),n.partitioned&&(u+=`; Partitioned`),n.priority)switch(typeof n.priority==`string`?n.priority.toLowerCase():n.priority){case`low`:u+=`; Priority=Low`;break;case`medium`:u+=`; Priority=Medium`;break;case`high`:u+=`; Priority=High`;break;default:throw TypeError(`option priority is invalid`)}if(n.sameSite)switch(typeof n.sameSite==`string`?n.sameSite.toLowerCase():n.sameSite){case!0:u+=`; SameSite=Strict`;break;case`lax`:u+=`; SameSite=Lax`;break;case`strict`:u+=`; SameSite=Strict`;break;case`none`:u+=`; SameSite=None`;break;default:throw TypeError(`option sameSite is invalid`)}return u}function decode(e){return e.indexOf(`%`)===-1?e:decodeURIComponent(e)}function isDate(e){return t.call(e)===`[object Date]`}function tryDecode(e,t){try{return t(e)}catch{return e}}})),
|
|
337
|
+
e.parse=parse,e.serialize=serialize;var t=Object.prototype.toString,n=Object.prototype.hasOwnProperty,r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,i=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,o=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,s=/^[\u0020-\u003A\u003D-\u007E]*$/;function parse(e,t){if(typeof e!=`string`)throw TypeError(`argument str must be a string`);var r={},i=e.length;if(i<2)return r;var o=t&&t.decode||decode,s=0,c=0,l=0;do{if(c=e.indexOf(`=`,s),c===-1)break;if(l=e.indexOf(`;`,s),l===-1)l=i;else if(c>l){s=e.lastIndexOf(`;`,c-1)+1;continue}var u=startIndex(e,s,c),d=endIndex(e,c,u),p=e.slice(u,d);if(!n.call(r,p)){var m=startIndex(e,c+1,l),h=endIndex(e,l,m);e.charCodeAt(m)===34&&e.charCodeAt(h-1)===34&&(m++,h--),r[p]=tryDecode(e.slice(m,h),o)}s=l+1}while(s<i);return r}function startIndex(e,t,n){do{var r=e.charCodeAt(t);if(r!==32&&r!==9)return t}while(++t<n);return n}function endIndex(e,t,n){for(;t>n;){var r=e.charCodeAt(--t);if(r!==32&&r!==9)return t+1}return n}function serialize(e,t,n){var c=n&&n.encode||encodeURIComponent;if(typeof c!=`function`)throw TypeError(`option encode is invalid`);if(!r.test(e))throw TypeError(`argument name is invalid`);var l=c(t);if(!i.test(l))throw TypeError(`argument val is invalid`);var u=e+`=`+l;if(!n)return u;if(n.maxAge!=null){var d=Math.floor(n.maxAge);if(!isFinite(d))throw TypeError(`option maxAge is invalid`);u+=`; Max-Age=`+d}if(n.domain){if(!o.test(n.domain))throw TypeError(`option domain is invalid`);u+=`; Domain=`+n.domain}if(n.path){if(!s.test(n.path))throw TypeError(`option path is invalid`);u+=`; Path=`+n.path}if(n.expires){var p=n.expires;if(!isDate(p)||isNaN(p.valueOf()))throw TypeError(`option expires is invalid`);u+=`; Expires=`+p.toUTCString()}if(n.httpOnly&&(u+=`; HttpOnly`),n.secure&&(u+=`; Secure`),n.partitioned&&(u+=`; Partitioned`),n.priority)switch(typeof n.priority==`string`?n.priority.toLowerCase():n.priority){case`low`:u+=`; Priority=Low`;break;case`medium`:u+=`; Priority=Medium`;break;case`high`:u+=`; Priority=High`;break;default:throw TypeError(`option priority is invalid`)}if(n.sameSite)switch(typeof n.sameSite==`string`?n.sameSite.toLowerCase():n.sameSite){case!0:u+=`; SameSite=Strict`;break;case`lax`:u+=`; SameSite=Lax`;break;case`strict`:u+=`; SameSite=Strict`;break;case`none`:u+=`; SameSite=None`;break;default:throw TypeError(`option sameSite is invalid`)}return u}function decode(e){return e.indexOf(`%`)===-1?e:decodeURIComponent(e)}function isDate(e){return t.call(e)===`[object Date]`}function tryDecode(e,t){try{return t(e)}catch{return e}}})),Hm=__commonJSMin(((e,t)=>{
|
|
338
338
|
/*!
|
|
339
339
|
* send
|
|
340
340
|
* Copyright(c) 2012 TJ Holowaychuk
|
|
341
341
|
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
342
342
|
* MIT Licensed
|
|
343
343
|
*/
|
|
344
|
-
var n=sl(),r=el()(`send`),i=Vd(),o=Hd(),s
|
|
344
|
+
var n=sl(),r=el()(`send`),i=Vd(),o=Hd(),s=$p(),c=Im(),l=(op(),__toCommonJS(rp)),u=ql(),d=Qc(),p=Hl(),m=Lm(),h=(jr(),__toCommonJS(hr)),g=il(),_=jl(),v=(Vu(),__toCommonJS(Lu)),y=h.extname,b=h.join,x=h.normalize,S=h.resolve,w=h.sep,T=/^ *bytes=/,E=3600*24*365*1e3,D=/(?:^|[\\/])\.\.(?:[\\/]|$)/;t.exports=send;function send(e,t,n){return new SendStream(e,t,n)}function SendStream(e,t,n){_.call(this);var r=n||{};if(this.options=r,this.path=t,this.req=e,this._acceptRanges=r.acceptRanges===void 0?!0:!!r.acceptRanges,this._cacheControl=r.cacheControl===void 0?!0:!!r.cacheControl,this._etag=r.etag===void 0?!0:!!r.etag,this._dotfiles=r.dotfiles===void 0?`ignore`:r.dotfiles,this._dotfiles!==`ignore`&&this._dotfiles!==`allow`&&this._dotfiles!==`deny`)throw TypeError(`dotfiles option must be "allow", "deny", or "ignore"`);this._extensions=r.extensions===void 0?[]:normalizeList(r.extensions,`extensions option`),this._immutable=r.immutable===void 0?!1:!!r.immutable,this._index=r.index===void 0?[`index.html`]:normalizeList(r.index,`index option`),this._lastModified=r.lastModified===void 0?!0:!!r.lastModified,this._maxage=r.maxAge||r.maxage,this._maxage=typeof this._maxage==`string`?d(this._maxage):Number(this._maxage),this._maxage=isNaN(this._maxage)?0:Math.min(Math.max(0,this._maxage),E),this._root=r.root?S(r.root):null}v.inherits(SendStream,_),SendStream.prototype.error=function error(e,t){if(hasListeners(this,`error`))return this.emit(`error`,createHttpError(e,t));var n=this.res,r=createHtmlDocument(`Error`,o(g.message[e]||String(e)));clearHeaders(n),t&&t.headers&&setHeaders(n,t.headers),n.statusCode=e,n.setHeader(`Content-Type`,`text/html; charset=UTF-8`),n.setHeader(`Content-Length`,Buffer.byteLength(r)),n.setHeader(`Content-Security-Policy`,`default-src 'none'`),n.setHeader(`X-Content-Type-Options`,`nosniff`),n.end(r)},SendStream.prototype.hasTrailingSlash=function hasTrailingSlash(){return this.path[this.path.length-1]===`/`},SendStream.prototype.isConditionalGET=function isConditionalGET(){return this.req.headers[`if-match`]||this.req.headers[`if-unmodified-since`]||this.req.headers[`if-none-match`]||this.req.headers[`if-modified-since`]},SendStream.prototype.isPreconditionFailure=function isPreconditionFailure(){var e=this.req,t=this.res,n=e.headers[`if-match`];if(n){var r=t.getHeader(`ETag`);return!r||n!==`*`&&parseTokenList(n).every(function(e){return e!==r&&e!==`W/`+r&&`W/`+e!==r})}var i=parseHttpDate(e.headers[`if-unmodified-since`]);if(!isNaN(i)){var o=parseHttpDate(t.getHeader(`Last-Modified`));return isNaN(o)||o>i}return!1},SendStream.prototype.removeContentHeaderFields=function removeContentHeaderFields(){var e=this.res;e.removeHeader(`Content-Encoding`),e.removeHeader(`Content-Language`),e.removeHeader(`Content-Length`),e.removeHeader(`Content-Range`),e.removeHeader(`Content-Type`)},SendStream.prototype.notModified=function notModified(){var e=this.res;r(`not modified`),this.removeContentHeaderFields(),e.statusCode=304,e.end()},SendStream.prototype.headersAlreadySent=function headersAlreadySent(){var e=Error(`Can't set headers after they are sent.`);r(`headers already sent`),this.error(500,e)},SendStream.prototype.isCachable=function isCachable(){var e=this.res.statusCode;return e>=200&&e<300||e===304},SendStream.prototype.onStatError=function onStatError(e){switch(e.code){case`ENAMETOOLONG`:case`ENOENT`:case`ENOTDIR`:this.error(404,e);break;default:this.error(500,e);break}},SendStream.prototype.isFresh=function isFresh(){return c(this.req.headers,{etag:this.res.getHeader(`ETag`),"last-modified":this.res.getHeader(`Last-Modified`)})},SendStream.prototype.isRangeFresh=function isRangeFresh(){var e=this.req.headers[`if-range`];if(!e)return!0;if(e.indexOf(`"`)!==-1){var t=this.res.getHeader(`ETag`);return!!(t&&e.indexOf(t)!==-1)}return parseHttpDate(this.res.getHeader(`Last-Modified`))<=parseHttpDate(e)},SendStream.prototype.redirect=function redirect(e){var t=this.res;if(hasListeners(this,`directory`)){this.emit(`directory`,t,e);return}if(this.hasTrailingSlash()){this.error(403);return}var n=i(collapseLeadingSlashes(this.path+`/`)),r=createHtmlDocument(`Redirecting`,`Redirecting to `+o(n));t.statusCode=301,t.setHeader(`Content-Type`,`text/html; charset=UTF-8`),t.setHeader(`Content-Length`,Buffer.byteLength(r)),t.setHeader(`Content-Security-Policy`,`default-src 'none'`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.setHeader(`Location`,n),t.end(r)},SendStream.prototype.pipe=function pipe(e){var t=this._root;this.res=e;var n=decode(this.path);if(n===-1||~n.indexOf(`\0`))return this.error(400),e;var i;if(t!==null){if(n&&=x(`.`+w+n),D.test(n))return r(`malicious path "%s"`,n),this.error(403),e;i=n.split(w),n=x(b(t,n))}else{if(D.test(n))return r(`malicious path "%s"`,n),this.error(403),e;i=x(n).split(w),n=S(n)}if(containsDotFile(i))switch(r(`%s dotfile "%s"`,this._dotfiles,n),this._dotfiles){case`allow`:break;case`deny`:return this.error(403),e;default:return this.error(404),e}return this._index.length&&this.hasTrailingSlash()?(this.sendIndex(n),e):(this.sendFile(n),e)},SendStream.prototype.send=function send(e,t){var n=t.size,i=this.options,o={},s=this.res,c=this.req,l=c.headers.range,u=i.start||0;if(s.headersSent){this.headersAlreadySent();return}if(r(`pipe "%s"`,e),this.setHeader(e,t),this.type(e),this.isConditionalGET()){if(this.isPreconditionFailure()){this.error(412);return}if(this.isCachable()&&this.isFresh()){this.notModified();return}}if(n=Math.max(0,n-u),i.end!==void 0){var d=i.end-u+1;n>d&&(n=d)}if(this._acceptRanges&&T.test(l)){if(l=m(n,l,{combine:!0}),this.isRangeFresh()||(r(`range stale`),l=-2),l===-1)return r(`range unsatisfiable`),s.setHeader(`Content-Range`,contentRange(`bytes`,n)),this.error(416,{headers:{"Content-Range":s.getHeader(`Content-Range`)}});l!==-2&&l.length===1&&(r(`range %j`,l),s.statusCode=206,s.setHeader(`Content-Range`,contentRange(`bytes`,n,l[0])),u+=l[0].start,n=l[0].end-l[0].start+1)}for(var p in i)o[p]=i[p];if(o.start=u,o.end=Math.max(u,u+n-1),s.setHeader(`Content-Length`,n),c.method===`HEAD`){s.end();return}this.stream(e,o)},SendStream.prototype.sendFile=function sendFile(e){var t=0,n=this;r(`stat "%s"`,e),l.stat(e,function onstat(t,r){var i=e[e.length-1]===w;if(t&&t.code===`ENOENT`&&!y(e)&&!i)return next(t);if(t)return n.onStatError(t);if(r.isDirectory())return n.redirect(e);if(i)return n.error(404);n.emit(`file`,e,r),n.send(e,r)});function next(i){if(n._extensions.length<=t)return i?n.onStatError(i):n.error(404);var o=e+`.`+n._extensions[t++];r(`stat "%s"`,o),l.stat(o,function(e,t){if(e)return next(e);if(t.isDirectory())return next();n.emit(`file`,o,t),n.send(o,t)})}},SendStream.prototype.sendIndex=function sendIndex(e){var t=-1,n=this;function next(i){if(++t>=n._index.length)return i?n.onStatError(i):n.error(404);var o=b(e,n._index[t]);r(`stat "%s"`,o),l.stat(o,function(e,t){if(e)return next(e);if(t.isDirectory())return next();n.emit(`file`,o,t),n.send(o,t)})}next()},SendStream.prototype.stream=function stream(e,t){var n=this,r=this.res,i=l.createReadStream(e,t);this.emit(`stream`,i),i.pipe(r);function cleanup(){i.destroy()}p(r,cleanup),i.on(`error`,function onerror(e){cleanup(),n.onStatError(e)}),i.on(`end`,function onend(){n.emit(`end`)})},SendStream.prototype.type=function type(e){var t=this.res;if(!t.getHeader(`Content-Type`)){var n=y(e),i=u.contentType(n)||`application/octet-stream`;r(`content-type %s`,i),t.setHeader(`Content-Type`,i)}},SendStream.prototype.setHeader=function setHeader(e,t){var n=this.res;if(this.emit(`headers`,n,e,t),this._acceptRanges&&!n.getHeader(`Accept-Ranges`)&&(r(`accept ranges`),n.setHeader(`Accept-Ranges`,`bytes`)),this._cacheControl&&!n.getHeader(`Cache-Control`)){var i=`public, max-age=`+Math.floor(this._maxage/1e3);this._immutable&&(i+=`, immutable`),r(`cache-control %s`,i),n.setHeader(`Cache-Control`,i)}if(this._lastModified&&!n.getHeader(`Last-Modified`)){var o=t.mtime.toUTCString();r(`modified %s`,o),n.setHeader(`Last-Modified`,o)}if(this._etag&&!n.getHeader(`ETag`)){var c=s(t);r(`etag %s`,c),n.setHeader(`ETag`,c)}};function clearHeaders(e){for(let t of e.getHeaderNames())e.removeHeader(t)}function collapseLeadingSlashes(e){for(var t=0;t<e.length&&e[t]===`/`;t++);return t>1?`/`+e.substr(t):e}function containsDotFile(e){for(var t=0;t<e.length;t++){var n=e[t];if(n.length>1&&n[0]===`.`)return!0}return!1}function contentRange(e,t,n){return e+` `+(n?n.start+`-`+n.end:`*`)+`/`+t}function createHtmlDocument(e,t){return`<!DOCTYPE html>
|
|
345
345
|
<html lang="en">
|
|
346
346
|
<head>
|
|
347
347
|
<meta charset="utf-8">
|
|
@@ -351,20 +351,20 @@ var n=sl(),r=el()(`send`),i=Vd(),o=Hd(),s=em(),c=Lm(),l=(op(),__toCommonJS(rp)),
|
|
|
351
351
|
<pre>`+t+`</pre>
|
|
352
352
|
</body>
|
|
353
353
|
</html>
|
|
354
|
-
`}function createHttpError(e,t){return t?t instanceof Error?n(e,t,{expose:!1}):n(e,t):n(e)}function decode(e){try{return decodeURIComponent(e)}catch{return-1}}function hasListeners(e,t){return(typeof e.listenerCount==`function`?e.listenerCount(t):e.listeners(t).length)>0}function normalizeList(e,t){for(var n=[].concat(e||[]),r=0;r<n.length;r++)if(typeof n[r]!=`string`)throw TypeError(t+` must be array of strings or false`);return n}function parseHttpDate(e){var t=e&&Date.parse(e);return typeof t==`number`?t:NaN}function parseTokenList(e){for(var t=0,n=[],r=0,i=0,o=e.length;i<o;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:r!==t&&n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1;break}return r!==t&&n.push(e.substring(r,t)),n}function setHeaders(e,t){for(var n=Object.keys(t),r=0;r<n.length;r++){var i=n[r];e.setHeader(i,t[i])}}})),
|
|
354
|
+
`}function createHttpError(e,t){return t?t instanceof Error?n(e,t,{expose:!1}):n(e,t):n(e)}function decode(e){try{return decodeURIComponent(e)}catch{return-1}}function hasListeners(e,t){return(typeof e.listenerCount==`function`?e.listenerCount(t):e.listeners(t).length)>0}function normalizeList(e,t){for(var n=[].concat(e||[]),r=0;r<n.length;r++)if(typeof n[r]!=`string`)throw TypeError(t+` must be array of strings or false`);return n}function parseHttpDate(e){var t=e&&Date.parse(e);return typeof t==`number`?t:NaN}function parseTokenList(e){for(var t=0,n=[],r=0,i=0,o=e.length;i<o;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:r!==t&&n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1;break}return r!==t&&n.push(e.substring(r,t)),n}function setHeaders(e,t){for(var n=Object.keys(t),r=0;r<n.length;r++){var i=n[r];e.setHeader(i,t[i])}}})),Um=__commonJSMin(((e,t)=>{
|
|
355
355
|
/*!
|
|
356
356
|
* vary
|
|
357
357
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
358
358
|
* MIT Licensed
|
|
359
359
|
*/
|
|
360
|
-
t.exports=vary,t.exports.append=append;var n=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function append(e,t){if(typeof e!=`string`)throw TypeError(`header argument is required`);if(!t)throw TypeError(`field argument is required`);for(var r=Array.isArray(t)?t:parse(String(t)),i=0;i<r.length;i++)if(!n.test(r[i]))throw TypeError(`field argument contains an invalid header name`);if(e===`*`)return e;var o=e,s=parse(e.toLowerCase());if(r.indexOf(`*`)!==-1||s.indexOf(`*`)!==-1)return`*`;for(var c=0;c<r.length;c++){var l=r[c].toLowerCase();s.indexOf(l)===-1&&(s.push(l),o=o?o+`, `+r[c]:r[c])}return o}function parse(e){for(var t=0,n=[],r=0,i=0,o=e.length;i<o;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1;break}return n.push(e.substring(r,t)),n}function vary(e,t){if(!e||!e.getHeader||!e.setHeader)throw TypeError(`res argument is required`);var n=e.getHeader(`Vary`)||``;(n=append(Array.isArray(n)?n.join(`, `):String(n),t))&&e.setHeader(`Vary`,n)}})),
|
|
360
|
+
t.exports=vary,t.exports.append=append;var n=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function append(e,t){if(typeof e!=`string`)throw TypeError(`header argument is required`);if(!t)throw TypeError(`field argument is required`);for(var r=Array.isArray(t)?t:parse(String(t)),i=0;i<r.length;i++)if(!n.test(r[i]))throw TypeError(`field argument contains an invalid header name`);if(e===`*`)return e;var o=e,s=parse(e.toLowerCase());if(r.indexOf(`*`)!==-1||s.indexOf(`*`)!==-1)return`*`;for(var c=0;c<r.length;c++){var l=r[c].toLowerCase();s.indexOf(l)===-1&&(s.push(l),o=o?o+`, `+r[c]:r[c])}return o}function parse(e){for(var t=0,n=[],r=0,i=0,o=e.length;i<o;i++)switch(e.charCodeAt(i)){case 32:r===t&&(r=t=i+1);break;case 44:n.push(e.substring(r,t)),r=t=i+1;break;default:t=i+1;break}return n.push(e.substring(r,t)),n}function vary(e,t){if(!e||!e.getHeader||!e.setHeader)throw TypeError(`res argument is required`);var n=e.getHeader(`Vary`)||``;(n=append(Array.isArray(n)?n.join(`, `):String(n),t))&&e.setHeader(`Vary`,n)}})),Wm=__commonJSMin(((e,t)=>{
|
|
361
361
|
/*!
|
|
362
362
|
* express
|
|
363
363
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
|
364
364
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
365
365
|
* MIT Licensed
|
|
366
366
|
*/
|
|
367
|
-
var n=
|
|
367
|
+
var n=zm(),r=sl(),i=tl()(`express`),o=Vd(),s=Hd(),c=(Qp(),__toCommonJS(Jp)),l=Hl(),u=ql(),d=(jr(),__toCommonJS(hr)),p=(jr(),__toCommonJS(hr)).isAbsolute,m=il(),h=Bm().sign,g=xm().normalizeType,_=xm().normalizeTypes,v=xm().setCharset,y=Vm(),b=Hm(),x=d.extname,S=d.resolve,w=Um();let{Buffer:T}=(U(),__toCommonJS(an));var E=Object.create(c.ServerResponse.prototype);t.exports=E,E.status=function status(e){if(!Number.isInteger(e))throw TypeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be an integer.`);if(e<100||e>999)throw RangeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be greater than 99 and less than 1000.`);return this.statusCode=e,this},E.links=function(e){var t=this.get(`Link`)||``;return t&&(t+=`, `),this.set(`Link`,t+Object.keys(e).map(function(t){return Array.isArray(e[t])?e[t].map(function(e){return`<${e}>; rel="${t}"`}).join(`, `):`<${e[t]}>; rel="${t}"`}).join(`, `))},E.send=function send(e){var t=e,n,r=this.req,i,o=this.app;switch(typeof t){case`string`:this.get(`Content-Type`)||this.type(`html`);break;case`boolean`:case`number`:case`object`:if(t===null)t=``;else if(ArrayBuffer.isView(t))this.get(`Content-Type`)||this.type(`bin`);else return this.json(t);break}typeof t==`string`&&(n=`utf8`,i=this.get(`Content-Type`),typeof i==`string`&&this.set(`Content-Type`,v(i,`utf-8`)));var s=o.get(`etag fn`),c=!this.get(`ETag`)&&typeof s==`function`,l;t!==void 0&&(T.isBuffer(t)?l=t.length:!c&&t.length<1e3?l=T.byteLength(t,n):(t=T.from(t,n),n=void 0,l=t.length),this.set(`Content-Length`,l));var u;return c&&l!==void 0&&(u=s(t,n))&&this.set(`ETag`,u),r.fresh&&this.status(304),(this.statusCode===204||this.statusCode===304)&&(this.removeHeader(`Content-Type`),this.removeHeader(`Content-Length`),this.removeHeader(`Transfer-Encoding`),t=``),this.statusCode===205&&(this.set(`Content-Length`,`0`),this.removeHeader(`Transfer-Encoding`),t=``),r.method===`HEAD`?this.end():this.end(t,n),this},E.json=function json(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n);return this.get(`Content-Type`)||this.set(`Content-Type`,`application/json`),this.send(r)},E.jsonp=function jsonp(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n),i=this.req.query[t.get(`jsonp callback name`)];return this.get(`Content-Type`)||(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`application/json`)),Array.isArray(i)&&(i=i[0]),typeof i==`string`&&i.length!==0&&(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`text/javascript`),i=i.replace(/[^\[\]\w$.]/g,``),r===void 0?r=``:typeof r==`string`&&(r=r.replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)),r=`/**/ typeof `+i+` === 'function' && `+i+`(`+r+`);`),this.send(r)},E.sendStatus=function sendStatus(e){var t=m.message[e]||String(e);return this.status(e),this.type(`txt`),this.send(t)},E.sendFile=function sendFile(e,t,n){var r=n,i=this.req,o=this,s=i.next,c=t||{};if(!e)throw TypeError(`path argument is required to res.sendFile`);if(typeof e!=`string`)throw TypeError(`path must be a string to res.sendFile`);if(typeof t==`function`&&(r=t,c={}),!c.root&&!p(e))throw TypeError(`path must be absolute or specify root to res.sendFile`);var l=encodeURI(e);c.etag=this.app.enabled(`etag`),sendfile(o,b(i,l,c),c,function(e){if(r)return r(e);if(e&&e.code===`EISDIR`)return s();e&&e.code!==`ECONNABORTED`&&e.syscall!==`write`&&s(e)})},E.download=function download(e,t,r,i){var o=i,s=t,c=r||null;typeof t==`function`?(o=t,s=null,c=null):typeof r==`function`&&(o=r,c=null),typeof t==`object`&&(typeof r==`function`||r===void 0)&&(s=null,c=t);var l={"Content-Disposition":n(s||e)};if(c&&c.headers)for(var u=Object.keys(c.headers),d=0;d<u.length;d++){var p=u[d];p.toLowerCase()!==`content-disposition`&&(l[p]=c.headers[p])}c=Object.create(c),c.headers=l;var m=c.root?e:S(e);return this.sendFile(m,c,o)},E.contentType=E.type=function contentType(e){var t=e.indexOf(`/`)===-1?u.contentType(e)||`application/octet-stream`:e;return this.set(`Content-Type`,t)},E.format=function(e){var t=this.req,n=t.next,i=Object.keys(e).filter(function(e){return e!=="default"}),o=i.length>0?t.accepts(i):!1;return this.vary(`Accept`),o?(this.set(`Content-Type`,g(o).value),e[o](t,this,n)):e.default?e.default(t,this,n):n(r(406,{types:_(i).map(function(e){return e.value})})),this},E.attachment=function attachment(e){return e&&this.type(x(e)),this.set(`Content-Disposition`,n(e)),this},E.append=function append(e,t){var n=this.get(e),r=t;return n&&(r=Array.isArray(n)?n.concat(t):Array.isArray(t)?[n].concat(t):[n,t]),this.set(e,r)},E.set=E.header=function header(e,t){if(arguments.length===2){var n=Array.isArray(t)?t.map(String):String(t);if(e.toLowerCase()===`content-type`){if(Array.isArray(n))throw TypeError(`Content-Type cannot be set to an Array`);n=u.contentType(n)}this.setHeader(e,n)}else for(var r in e)this.set(r,e[r]);return this},E.get=function(e){return this.getHeader(e)},E.clearCookie=function clearCookie(e,t){let n={path:`/`,...t,expires:new Date(1)};return delete n.maxAge,this.cookie(e,``,n)},E.cookie=function(e,t,n){var r={...n},i=this.req.secret,o=r.signed;if(o&&!i)throw Error(`cookieParser("secret") required for signed cookies`);var s=typeof t==`object`?`j:`+JSON.stringify(t):String(t);if(o&&(s=`s:`+h(s,i)),r.maxAge!=null){var c=r.maxAge-0;isNaN(c)||(r.expires=new Date(Date.now()+c),r.maxAge=Math.floor(c/1e3))}return r.path??=`/`,this.append(`Set-Cookie`,y.serialize(e,String(s),r)),this},E.location=function location(e){return this.set(`Location`,o(e))},E.redirect=function redirect(e){var t=e,n,r=302;arguments.length===2&&(r=arguments[0],t=arguments[1]),t||i(`Provide a url argument`),typeof t!=`string`&&i(`Url must be a string`),typeof r!=`number`&&i(`Status must be a number`),t=this.location(t).get(`Location`),this.format({text:function(){n=m.message[r]+`. Redirecting to `+t},html:function(){var e=s(t);n=`<p>`+m.message[r]+`. Redirecting to `+e+`</p>`},default:function(){n=``}}),this.status(r),this.set(`Content-Length`,T.byteLength(n)),this.req.method===`HEAD`?this.end():this.end(n)},E.vary=function(e){return w(this,e),this},E.render=function render(e,t,n){var r=this.req.app,done=n,i=t||{},o=this.req,s=this;typeof t==`function`&&(done=t,i={}),i._locals=s.locals,done||=function(e,t){if(e)return o.next(e);s.send(t)},r.render(e,i,done)};function sendfile(e,t,n,r){var i=!1,o;function onaborted(){if(!i){i=!0;var e=Error(`Request aborted`);e.code=`ECONNABORTED`,r(e)}}function ondirectory(){if(!i){i=!0;var e=Error(`EISDIR, read`);e.code=`EISDIR`,r(e)}}function onerror(e){i||(i=!0,r(e))}function onend(){i||(i=!0,r())}function onfile(){o=!1}function onfinish(e){if(e&&e.code===`ECONNRESET`)return onaborted();if(e)return onerror(e);i||setImmediate(function(){if(o!==!1&&!i){onaborted();return}i||(i=!0,r())})}function onstream(){o=!0}t.on(`directory`,ondirectory),t.on(`end`,onend),t.on(`error`,onerror),t.on(`file`,onfile),t.on(`stream`,onstream),l(e,onfinish),n.headers&&t.on(`headers`,function headers(e){for(var t=n.headers,r=Object.keys(t),i=0;i<r.length;i++){var o=r[i];e.setHeader(o,t[o])}}),t.pipe(e)}function stringify(e,t,n,r){var i=t||n?JSON.stringify(e,t,n):JSON.stringify(e);return r&&typeof i==`string`&&(i=i.replace(/[<>&]/g,function(e){switch(e.charCodeAt(0)){case 60:return`\\u003c`;case 62:return`\\u003e`;case 38:return`\\u0026`;default:return e}})),i}})),Gm=__commonJSMin(((e,t)=>{
|
|
368
368
|
/*!
|
|
369
369
|
* serve-static
|
|
370
370
|
* Copyright(c) 2010 Sencha Inc.
|
|
@@ -372,7 +372,7 @@ var n=Bm(),r=sl(),i=tl()(`express`),o=Vd(),s=Hd(),c=($p(),__toCommonJS(Yp)),l=Hl
|
|
|
372
372
|
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
373
373
|
* MIT Licensed
|
|
374
374
|
*/
|
|
375
|
-
var n=Vd(),r=Hd(),i=Ud(),o=(jr(),__toCommonJS(hr)).resolve,s=
|
|
375
|
+
var n=Vd(),r=Hd(),i=Ud(),o=(jr(),__toCommonJS(hr)).resolve,s=Hm(),c=(Vr(),__toCommonJS(Mr));t.exports=serveStatic;function serveStatic(e,t){if(!e)throw TypeError(`root path required`);if(typeof e!=`string`)throw TypeError(`root path must be a string`);var n=Object.create(t||null),r=n.fallthrough!==!1,c=n.redirect!==!1,l=n.setHeaders;if(l&&typeof l!=`function`)throw TypeError(`option setHeaders must be function`);n.maxage=n.maxage||n.maxAge||0,n.root=o(e);var u=c?createRedirectDirectoryListener():createNotFoundDirectoryListener();return function serveStatic(e,t,o){if(e.method!==`GET`&&e.method!==`HEAD`){if(r)return o();t.statusCode=405,t.setHeader(`Allow`,`GET, HEAD`),t.setHeader(`Content-Length`,`0`),t.end();return}var c=!r,d=i.original(e),p=i(e).pathname;p===`/`&&d.pathname.substr(-1)!==`/`&&(p=``);var m=s(e,p,n);m.on(`directory`,u),l&&m.on(`headers`,l),r&&m.on(`file`,function onFile(){c=!0}),m.on(`error`,function error(e){if(c||!(e.statusCode<500)){o(e);return}o()}),m.pipe(t)}}function collapseLeadingSlashes(e){for(var t=0;t<e.length&&e.charCodeAt(t)===47;t++);return t>1?`/`+e.substr(t):e}function createHtmlDocument(e,t){return`<!DOCTYPE html>
|
|
376
376
|
<html lang="en">
|
|
377
377
|
<head>
|
|
378
378
|
<meta charset="utf-8">
|
|
@@ -382,7 +382,7 @@ var n=Vd(),r=Hd(),i=Ud(),o=(jr(),__toCommonJS(hr)).resolve,s=Um(),c=(Vr(),__toCo
|
|
|
382
382
|
<pre>`+t+`</pre>
|
|
383
383
|
</body>
|
|
384
384
|
</html>
|
|
385
|
-
`}function createNotFoundDirectoryListener(){return function notFound(){this.error(404)}}function createRedirectDirectoryListener(){return function redirect(e){if(this.hasTrailingSlash()){this.error(404);return}var t=i.original(this.req);t.path=null,t.pathname=collapseLeadingSlashes(t.pathname+`/`);var o=n(c.format(t)),s=createHtmlDocument(`Redirecting`,`Redirecting to `+r(o));e.statusCode=301,e.setHeader(`Content-Type`,`text/html; charset=UTF-8`),e.setHeader(`Content-Length`,Buffer.byteLength(s)),e.setHeader(`Content-Security-Policy`,`default-src 'none'`),e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Location`,o),e.end(s)}}})),
|
|
385
|
+
`}function createNotFoundDirectoryListener(){return function notFound(){this.error(404)}}function createRedirectDirectoryListener(){return function redirect(e){if(this.hasTrailingSlash()){this.error(404);return}var t=i.original(this.req);t.path=null,t.pathname=collapseLeadingSlashes(t.pathname+`/`);var o=n(c.format(t)),s=createHtmlDocument(`Redirecting`,`Redirecting to `+r(o));e.statusCode=301,e.setHeader(`Content-Type`,`text/html; charset=UTF-8`),e.setHeader(`Content-Length`,Buffer.byteLength(s)),e.setHeader(`Content-Security-Policy`,`default-src 'none'`),e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Location`,o),e.end(s)}}})),Km=__commonJSMin(((e,t)=>{
|
|
386
386
|
/*!
|
|
387
387
|
* express
|
|
388
388
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
|
@@ -390,7 +390,7 @@ var n=Vd(),r=Hd(),i=Ud(),o=(jr(),__toCommonJS(hr)).resolve,s=Um(),c=(Vr(),__toCo
|
|
|
390
390
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
391
391
|
* MIT Licensed
|
|
392
392
|
*/
|
|
393
|
-
var n=Rd(),r=zd().EventEmitter,i=Bd(),o=
|
|
393
|
+
var n=Rd(),r=zd().EventEmitter,i=Bd(),o=km(),s=Om(),c=Rm(),l=Wm();e=t.exports=createApplication;function createApplication(){var app=function(e,t,n){app.handle(e,t,n)};return i(app,r.prototype,!1),i(app,o,!1),app.request=Object.create(c,{app:{configurable:!0,enumerable:!0,writable:!0,value:app}}),app.response=Object.create(l,{app:{configurable:!0,enumerable:!0,writable:!0,value:app}}),app.init(),app}e.application=o,e.request=c,e.response=l,e.Route=s.Route,e.Router=s,e.json=n.json,e.raw=n.raw,e.static=Gm(),e.text=n.text,e.urlencoded=n.urlencoded})),qm=__toESM(__commonJSMin(((e,t)=>{
|
|
394
394
|
/*!
|
|
395
395
|
* express
|
|
396
396
|
* Copyright(c) 2009-2013 TJ Holowaychuk
|
|
@@ -398,14 +398,14 @@ var n=Rd(),r=zd().EventEmitter,i=Bd(),o=Am(),s=km(),c=zm(),l=Gm();e=t.exports=cr
|
|
|
398
398
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
399
399
|
* MIT Licensed
|
|
400
400
|
*/
|
|
401
|
-
t.exports=
|
|
401
|
+
t.exports=Km()}))());const Jm=[{id:1,slug:`hello-gjs`,title:`Hello, GJS!`,author:`Pascal`,date:`2026-04-01`,excerpt:`Running Express.js natively on Linux via GJS — no Node.js required.`,content:"This blog is served by a real Express.js application — the same code you would\nwrite for Node.js. The difference: it's running inside GJS, the GNOME JavaScript\nruntime, backed by GLib, Gio and Soup. No Node binary, no V8 — just SpiderMonkey\nand native Linux libraries.\n\nWith `@gjsify/node-globals` and the `@gjsify/*` package set, the full Node.js\nAPI surface is available: `fs`, `net`, `http`, `crypto`, `stream`, `events`,\nand many more. That means your existing npm ecosystem works out of the box."},{id:2,slug:`why-gjsify`,title:`Why GJSify?`,author:`Pascal`,date:`2026-04-03`,excerpt:`Bringing the full TypeScript ecosystem to the GNOME JavaScript runtime.`,content:`GJS is fantastic for writing GNOME applications, but historically you had to
|
|
402
402
|
choose between the GObject world and the rich npm ecosystem. GJSify bridges
|
|
403
403
|
that gap by implementing the Node.js and Web APIs on top of native GNOME
|
|
404
404
|
libraries — so a package like Express, Koa or Hono Just Works, and you can
|
|
405
405
|
still reach into GTK, Cairo or WebKit whenever you need to.
|
|
406
406
|
|
|
407
407
|
The trade-off is no longer "Node.js or GNOME" — you can have both in the
|
|
408
|
-
same application.`},{id:3,slug:`express-on-soup`,title:`Express on Soup 3.0`,author:`Pascal`,date:`2026-04-05`,excerpt:`How Express listens on a port when there is no V8 event loop.`,content:"The magic trick is `@gjsify/http`: it implements Node's `http` module on top\nof `Soup.Server`. When Express calls `app.listen(3000)`, GJSify starts a\nGLib MainLoop under the hood and wires Soup's request signals into Node-style\n`IncomingMessage` / `ServerResponse` objects.\n\nThe result: Express middleware, routing, template engines and the rest of the\necosystem simply work — on the GNOME stack."}];N(),jr(),Vr();const
|
|
408
|
+
same application.`},{id:3,slug:`express-on-soup`,title:`Express on Soup 3.0`,author:`Pascal`,date:`2026-04-05`,excerpt:`How Express listens on a port when there is no V8 event loop.`,content:"The magic trick is `@gjsify/http`: it implements Node's `http` module on top\nof `Soup.Server`. When Express calls `app.listen(3000)`, GJSify starts a\nGLib MainLoop under the hood and wires Soup's request signals into Node-style\n`IncomingMessage` / `ServerResponse` objects.\n\nThe result: Express middleware, routing, template engines and the rest of the\necosystem simply work — on the GNOME stack."}];N(),jr(),Vr();const Ym=br(Cr(fileURLToPath(import.meta.url)),`public`),Xm=parseInt(process.env.PORT||`3000`,10),Zm=(0,qm.default)();function escapeHtml(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function renderContent(e){return e.split(/\n\n+/).map(e=>`<p>${escapeHtml(e.trim()).replace(/\n/g,`<br />`)}</p>`).join(`
|
|
409
409
|
`)}function renderPage(e,t){return`<!DOCTYPE html>
|
|
410
410
|
<html lang="en">
|
|
411
411
|
<head>
|
|
@@ -431,7 +431,7 @@ ${t}
|
|
|
431
431
|
</footer>
|
|
432
432
|
<script src="/app.js" defer><\/script>
|
|
433
433
|
</body>
|
|
434
|
-
</html>`}
|
|
434
|
+
</html>`}Zm.use(qm.json()),Zm.use((e,t,n)=>{let r=new Date().toISOString().slice(11,19);M.log(`[${r}] ${e.method} ${e.url}`),n()}),Zm.get(`/api/posts`,(e,t)=>{t.json({count:Jm.length,posts:Jm.map(({id:e,slug:t,title:n,author:r,date:i,excerpt:o})=>({id:e,slug:t,title:n,author:r,date:i,excerpt:o}))})}),Zm.get(`/api/posts/:slug`,(e,t)=>{let n=Jm.find(t=>t.slug===e.params.slug);if(!n){t.status(404).json({error:`Post not found`});return}t.json(n)}),Zm.get(`/api/runtime`,(e,t)=>{t.json({runtime:Zc,platform:process.platform,version:process.version,time:new Date().toISOString()})}),Zm.get(`/posts/:slug`,(e,t)=>{let n=Jm.find(t=>t.slug===e.params.slug);if(!n){t.status(404).send(renderPage(`Post not found`,`
|
|
435
435
|
<main class="post-detail">
|
|
436
436
|
<a href="/" class="back-link">← Back to posts</a>
|
|
437
437
|
<p class="loading">Post not found.</p>
|
|
@@ -448,4 +448,4 @@ ${t}
|
|
|
448
448
|
${renderContent(n.content)}
|
|
449
449
|
</div>
|
|
450
450
|
</article>
|
|
451
|
-
</main>`))}),
|
|
451
|
+
</main>`))}),Zm.use(qm.static(Ym)),Zm.listen(Xm,()=>{M.log(``),M.log(` Express.js blog running on ${Zc}`),M.log(``),M.log(` ➜ Local: http://localhost:${Xm}/`),M.log(` ➜ API: http://localhost:${Xm}/api/posts`),M.log(``),M.log(` Press Ctrl+C to stop`),M.log(``)});const Qm=globalThis.process,$m=Number(Qm?.exitCode);Number.isInteger($m)&&$m!==0&&Qm.exit($m);
|