@gjsify/example-dom-webrtc-loopback 0.4.37 → 0.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/gjs.js +1 -1
  2. package/package.json +6 -6
package/dist/gjs.js CHANGED
@@ -2,7 +2,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,globalThis.process===void 0){l
2
2
  `)}else if(m){let n=` `.repeat(this._groupDepth*this._groupIndentation)+_formatArgs(...t);e===`stderr`?printerr(n):print(n)}else{let n=globalThis.console;e===`stderr`?n.error(...t):n.log(...t)}}log(...e){this._write(`stdout`,...e)}info(...e){this._write(`stdout`,...e)}debug(...e){this._write(`stdout`,...e)}warn(...e){this._write(`stderr`,...e)}error(...e){this._write(`stderr`,...e)}dir(e,t){this._write(`stdout`,e)}dirxml(...e){this.log(...e)}assert(e,...t){e||this.error(`Assertion failed:`,...t)}clear(){this._stdout?this._stdout.write(`\x1Bc`):m?print(`\x1Bc`):globalThis.console.clear()}count(e=`default`){let t=(this._counters.get(e)||0)+1;this._counters.set(e,t),this.log(`${e}: ${t}`)}countReset(e=`default`){this._counters.delete(e)}group(...e){e.length>0&&this.log(...e),this._groupDepth++}groupCollapsed(...e){this.group(...e)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(e,t){this._stdout?this._write(`stdout`,e):m?print(JSON.stringify(e,null,2)):globalThis.console.table(e,t)}time(e=`default`){this._timers.set(e,Date.now())}timeEnd(e=`default`){let t=this._timers.get(e);t===void 0?this.warn(`Warning: No such label '${e}' for console.timeEnd()`):(this.log(`${e}: ${Date.now()-t}ms`),this._timers.delete(e))}timeLog(e=`default`,...t){let n=this._timers.get(e);n===void 0?this.warn(`Warning: No such label '${e}' for console.timeLog()`):this.log(`${e}: ${Date.now()-n}ms`,...t)}trace(...e){let t=Error().stack?.split(`
3
3
  `).slice(1).join(`
4
4
  `)||``;this._write(`stderr`,`Trace:`,...e,`
5
- `+t)}profile(e){}profileEnd(e){}timeStamp(e){}};const h=new Console,ee=__name((...e)=>h.log(...e),`log`),info=(...e)=>h.info(...e),debug=(...e)=>h.debug(...e),warn=(...e)=>h.warn(...e),error=(...e)=>h.error(...e),dir=(e,t)=>h.dir(e,t),dirxml=(...e)=>h.dirxml(...e),table=(e,t)=>h.table(e,t),clear=()=>h.clear(),assert=(e,...t)=>h.assert(e,...t),trace=(...e)=>h.trace(...e),time=e=>h.time(e),timeEnd=e=>h.timeEnd(e),timeLog=(e,...t)=>h.timeLog(e,...t),count=e=>h.count(e),countReset=e=>h.countReset(e),group=(...e)=>h.group(...e),groupCollapsed=(...e)=>h.groupCollapsed(...e),groupEnd=()=>h.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{},g={log:ee,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp},_=__name(e=>{Promise.resolve().then(e)},`queueMicrotask`),{File:te}=p,{toString:ne}=Object.prototype;function classOf(e){return ne.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}const re={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},ie=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]);function internalClone(e,t,n){if(e==null)return e;let r=typeof e;if(r===`boolean`||r===`number`||r===`string`||r===`bigint`)return e;r===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),r===`function`&&throwDataCloneError(`Function cannot be cloned`);let i=e;if(t.has(i))return t.get(i);let a=classOf(i);if(a===`Date`)return new Date(i.getTime());if(a===`RegExp`)return new RegExp(i.source,i.flags);if(a===`Boolean`||a===`Number`||a===`String`)return Object(i.valueOf());if(a===`BigInt`)return Object(BigInt.prototype.valueOf.call(i));if(i instanceof Error){let e=i,r=e.constructor?.name,a=new(r&&re[r]||re[e.name]||Error)(e.message);return a.name=e.name,`cause`in e&&Object.defineProperty(a,"cause",{value:internalClone(e.cause,t,n),writable:!0,enumerable:!1,configurable:!0}),a}if(a===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=i;return new e(t.message,t.name)}}if(a===`ArrayBuffer`){let e=i;if(n&&n.transferred.has(e)){let r=n.transferred.get(e);return t.set(i,r),r}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let r=e.slice(0);return t.set(i,r),r}if(a===`SharedArrayBuffer`||i&&typeof i==`object`&&i.constructor?.name===`SharedBuffer`)return i;if(a===`DataView`){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=r?r.byteOffset:e.byteOffset,s=r?r.byteLength:e.byteLength,c=new DataView(a,o,s);return t.set(i,c),c}if(ie.has(a)){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=e.constructor,s=new o(a,r?r.byteOffset:e.byteOffset,r?r.length:e.length);return t.set(i,s),s}if(a===`Map`){let e=new Map;t.set(i,e);for(let[r,a]of i)e.set(internalClone(r,t,n),internalClone(a,t,n));return e}if(a===`Set`){let e=new Set;t.set(i,e);for(let r of i)e.add(internalClone(r,t,n));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&i instanceof n){let e=i;return new n([i],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&i instanceof t)return new t([i],{type:i.type})}if(i instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),i instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),i instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&i instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),a===`Array`){let e=i,r=[];t.set(i,r);for(let i=0;i<e.length;i++)i in e&&(r[i]=internalClone(e[i],t,n));return r}if(a===`Object`||typeof i==`object`){let e={};t.set(i,e);for(let r of Object.keys(i))e[r]=internalClone(i[r],t,n);return e}throwDataCloneError(`${a} cannot be cloned`)}function structuredClone$1(e,t){let n=t?.transfer;if(!n||n.length===0)return internalClone(e,new Map);let r=new Set;for(let e of n)if(classOf(e)===`ArrayBuffer`){let t=e;t.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),r.add(t)}let i=new Map;r.size>0&&snapshotViewsBackedByTransferredBuffers(e,r,i,new Set);let a=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),a.set(e,t.transfer())}return internalClone(e,new Map,{transferred:a,viewSnapshots:i})}__name(structuredClone$1,`structuredClone`);function snapshotViewsBackedByTransferredBuffers(e,t,n,r){if(typeof e!=`object`||!e)return;let i=e;if(r.has(i))return;r.add(i);let a=classOf(i);if(a===`DataView`){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(ie.has(a)){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(i)){for(let e=0;e<i.length;e++)e in i&&snapshotViewsBackedByTransferredBuffers(i[e],t,n,r);return}if(a===`Map`){for(let[e,a]of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r),snapshotViewsBackedByTransferredBuffers(a,t,n,r);return}if(a===`Set`){for(let e of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r);return}if(a===`Object`)for(let e of Object.keys(i))snapshotViewsBackedByTransferredBuffers(i[e],t,n,r)}let ae=!1,v=null;function ensureMainLoop(){let e=globalThis.imports;if(!e)return;if(ae)return v;let t=e.gi?.GLib;if(t){if(v=new t.MainLoop(null,!1),ae=!0,t.main_depth()===0)try{v.runAsync()}catch{}return v}}function quitMainLoop(){v&&=(v.quit(),ae=!1,null)}registerGlobal(`Blob`,u),registerGlobal(`File`,d);const y=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,oe=new Uint8Array(256);for(let e=0;e<64;e++)oe[y.charCodeAt(e)]=e;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+=y[r>>18&63]+y[r>>12&63]+y[r>>6&63]+y[r&63]}if(n+1===e.length){let r=e.charCodeAt(n)<<16;t+=y[r>>18&63]+y[r>>12&63]+`==`}else if(n+2===e.length){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8;t+=y[r>>18&63]+y[r>>12&63]+y[r>>6&63]+`=`}return t}function base64Decode(e){let t=e.replace(/[=\s]/g,``),n=new Uint8Array(t.length*3>>2),r=0,i=0,a=0;for(let e=0;e<t.length;e++)r=r<<6|oe[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n[a++]=r>>i&255);return n.subarray(0,a)}const se=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`];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(!se.includes(t))throw TypeError(`Unknown encoding: ${e}`)}let ce,le;const textEncoder=()=>ce??=new TextEncoder,textDecoder=()=>le??=new TextDecoder;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`)}const ue=typeof SharedArrayBuffer<`u`;var de=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;return new Buffer(e,r,n===void 0?e.byteLength-r:n)}if(ue&&e instanceof SharedArrayBuffer){let r=t||0,i=n===void 0?e.byteLength-r:n;return new Buffer(new Uint8Array(e,r,i))}if(typeof e==`object`&&e&&typeof e.viewBytes==`function`&&typeof e.byteLength==`number`&&e.constructor?.name===`SharedBuffer`){let r=e,i=t||0,a=n===void 0?r.byteLength-i:n,o=r.viewBytes(i,a);return new Buffer(o.buffer,o.byteOffset,o.byteLength)}if(Array.isArray(e)){let t=new Buffer(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]&255;return t}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(e){return e instanceof Buffer}static isEncoding(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(t)}static byteLength(e,t){if(typeof e!=`string`){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||ue&&e instanceof SharedArrayBuffer)return e.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(t)){case`utf8`:return new TextEncoder().encode(e).byteLength;case`ascii`:case`latin1`:return e.length;case`base64`:case`base64url`:{let t=e.length;for(;t>0&&(e[t-1]===`=`||e[t-1]===` `);)t--;return t*3>>>2}case`hex`:return e.length>>>1;case`utf16le`:return e.length*2;default:return new TextEncoder().encode(e).byteLength}}static compare(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return e.length<t.length?-1:+(e.length>t.length)}static concat(e,t){if(e.length===0)return Buffer.alloc(0);if(t===void 0){t=0;for(let n=0;n<e.length;n++)t+=e[n].length}let n=Buffer.alloc(t),r=0;for(let i=0;i<e.length;i++){let a=e[i],o=Math.min(a.length,t-r);o<=0||(n.set(a.subarray(0,o),r),r+=o)}return n}static poolSize=8192;toString(e,t,n){let r=normalizeEncoding(e);return decodeString(this,r,t,n)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(e){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==e.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==e[t])return!1;return!0}compare(e,t,n,r,i){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let a=r!==void 0||i!==void 0?this.subarray(r??0,i??this.length):this,o=t!==void 0||n!==void 0?e.subarray(t??0,n??e.length):e;return Buffer.compare(a,o)}copy(e,t=0,n=0,r){let i=r??this.length,a=Math.min(i-n,e.length-t);return a<=0?0:(e.set(this.subarray(n,n+a),t),a)}slice(e,t){let n=e??0,r=t??this.length,i=super.subarray(n,r);return new Buffer(i.buffer,i.byteOffset,i.byteLength)}subarray(e,t){let n=super.subarray(e,t);return new Buffer(n.buffer,n.byteOffset,n.byteLength)}write(e,t,n,r){t??=0;let i=encodeString(e,normalizeEncoding(r||(typeof n==`string`?n:void 0))),a=n!==void 0&&typeof n==`number`?Math.min(n,this.length-t):this.length-t,o=Math.min(i.length,a);return this.set(i.subarray(0,o),t),o}fill(e,t,n,r){let i=t??0,a=n??this.length;if(typeof e==`number`)super.fill(e&255,i,a);else if(typeof e==`string`){let t=encodeString(e,normalizeEncoding(r));if(t.length===0)super.fill(0,i,a);else if(t.length===1)super.fill(t[0],i,a);else for(let e=i;e<a;e++)this[e]=t[(e-i)%t.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,i,a);else for(let t=i;t<a;t++)this[t]=e[(t-i)%e.length];return this}indexOf(e,t,n){if(typeof e==`number`)return super.indexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t??0;outer:for(let e=i;e<=this.length-r.length;e++){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}lastIndexOf(e,t,n){if(typeof e==`number`)return t===void 0?super.lastIndexOf(e&255):super.lastIndexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t===void 0?this.length-r.length:Math.min(t,this.length-r.length);outer:for(let e=i;e>=0;e--){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}includes(e,t,n){return this.indexOf(e,t,n)!==-1}readUInt8(e=0){return checkOffset(e,1,this.length),this[e]}readUInt16BE(e=0){return checkOffset(e,2,this.length),this[e]<<8|this[e+1]}readUInt16LE(e=0){return checkOffset(e,2,this.length),this[e]|this[e+1]<<8}readUInt32BE(e=0){return checkOffset(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])}readUInt32LE(e=0){return checkOffset(e,4,this.length),this[e+3]*16777216+(this[e+2]<<16|this[e+1]<<8|this[e])>>>0}readInt8(e=0){return checkOffset(e,1,this.length),this[e]|(this[e]&128?4294967040:0)}readInt16BE(e=0){checkOffset(e,2,this.length);let t=this[e]<<8|this[e+1];return t&32768?t|4294901760:t}readInt16LE(e=0){checkOffset(e,2,this.length);let t=this[e]|this[e+1]<<8;return t&32768?t|4294901760:t}readInt32BE(e=0){return checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]}readInt32LE(e=0){return checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24}readFloatBE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!1)}readFloatLE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!0)}readDoubleBE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!1)}readDoubleLE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!0)}readBigInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!1)}readBigInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!0)}readBigUInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!1)}readBigUInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!0)}readUIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n}readUIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n}readIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n>=2**(8*t-1)&&(n-=2**(8*t)),n}readIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n>=2**(8*t-1)&&(n-=2**(8*t)),n}writeUInt8(e,t=0){return checkOffset(t,1,this.length),this[t]=e&255,t+1}writeUInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeUInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeUInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeUInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeInt8(e,t=0){return checkOffset(t,1,this.length),e<0&&(e=255+e+1),this[t]=e&255,t+1}writeInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeFloatBE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!1),t+4}writeFloatLE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!0),t+4}writeDoubleBE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!1),t+8}writeDoubleLE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!0),t+8}writeBigInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!1),t+8}writeBigInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!0),t+8}writeBigUInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!1),t+8}writeBigUInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!0),t+8}swap16(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2){let e=this[t];this[t]=this[t+1],this[t+1]=e}return this}swap32(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4){let e=this[t],n=this[t+1];this[t]=this[t+3],this[t+1]=this[t+2],this[t+2]=n,this[t+3]=e}return this}swap64(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8){let e=this[t],n=this[t+1],r=this[t+2],i=this[t+3];this[t]=this[t+7],this[t+1]=this[t+6],this[t+2]=this[t+5],this[t+3]=this[t+4],this[t+4]=i,this[t+5]=r,this[t+6]=n,this[t+7]=e}return this}};`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:de,enumerable:!1,writable:!0,configurable:!0}),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 f.base64_encode(t)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let t=f.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}),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:_,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let e=getGjsGlobal().imports?.gi;if(!e)return null;let t=null;try{t=e.GioUnix??null}catch{}if(!t)try{t=e.Gio??null}catch{}return t}function getMonotonicTime(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_monotonic_time)return BigInt(e.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}const fe=getMonotonicTime();function hrtime(e){let t=getMonotonicTime()-fe,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()-fe}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(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/PPid:\s+(\d+)/);if(e)return parseInt(e[1],10)}}}catch{}return 0}function detectPlatform(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e&&e.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/stat`);if(t){let e=new TextDecoder().decode(t),n=parseInt(e,10);if(!isNaN(n))return n}}}catch{}return 0}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(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let e=getGjsGlobal().imports?.system;if(e?.programInvocationName)return e.programInvocationName}catch{}return`/usr/bin/gjs`}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`)}function exitProcess(e){let t=getGjsGlobal().imports,n=t?.gi?.GLib,r=t?.system,i=n?.idle_add,a=n?.SOURCE_REMOVE,o=n?.PRIORITY_DEFAULT;if(r?.exit&&i&&typeof o==`number`&&typeof a==`boolean`)return ensureMainLoop(),i(o,()=>(quitMainLoop(),r.exit(e),a)),new Promise(()=>{});try{r?.exit&&r.exit(e)}catch{}let s=globalThis.process;throw s&&typeof s.exit==`function`&&s.exit(e),Error(`process.exit(${e})`)}function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(e,t){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let r=typeof t==`number`?String(t):t||`SIGTERM`,i=r.startsWith(`SIG`)?`-${r.slice(3)}`:`-${r}`;return n.spawn_command_line_sync(`kill ${i} ${e}`),!0}}catch{}if(!isGjs()){let n=globalThis.process;if(n&&typeof n.kill==`function`)return n.kill(e,t)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/VmRSS:\s+(\d+)/),n=e?parseInt(e[1],10)*1024:0;return{rss:n,heapTotal:n,heapUsed:n,external:0,arrayBuffers:0}}}}catch{}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}}let pe=null;const me=globalThis.imports?.gi;if(me)try{pe=me.GjsifyTerminal}catch{}const b=pe,x=Symbol(`kCapture`),he=Symbol.for(`nodejs.rejection`);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()}var S=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=he;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;[x];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[x]=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[x]&&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[x]&&this._addCatch(r,e,t)}}return!0}_addCatch(e,t,n){typeof e?.then==`function`&&e.then(void 0,e=>{let r=this[he];if(typeof r==`function`)r.call(this,e,t,...n);else{let t=this[x];try{this[x]=!1,this.emit(`error`,e)}finally{this[x]=t}}})}addListener(e,t){return this._addListener(e,t,!1)}on(e,t){return this._addListener(e,t,!1)}prependListener(e,t){return this._addListener(e,t,!0)}_addListener(e,t,n){checkListener(t);let r=this._events;r===void 0?(r=this._events=Object.create(null),this._eventsCount=0):r.newListener!==void 0&&(this.emit(`newListener`,e,t.listener??t),r=this._events);let i=r[e];i===void 0?(r[e]=t,++this._eventsCount):typeof i==`function`?r[e]=n?[t,i]:[i,t]:n?i.unshift(t):i.push(t);let a=this.getMaxListeners();if(a>0){let t=typeof r[e]==`function`?1:r[e].length;if(t>a&&!r[e].warned){typeof r[e]!=`function`&&(r[e].warned=!0);let n=Error(`Possible EventEmitter memory leak detected. ${t} ${String(e)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);n.name=`MaxListenersExceededWarning`,g.warn(n.message)}}return this}once(e,t){return checkListener(t),this.on(e,_onceWrap(this,e,t)),this}prependOnceListener(e,t){return checkListener(t),this.prependListener(e,_onceWrap(this,e,t)),this}removeListener(e,t){checkListener(t);let n=this._events;if(n===void 0)return this;let r=n[e];if(r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit(`removeListener`,e,r.listener??t));else if(typeof r!=`function`){let i=-1;for(let e=r.length-1;e>=0;e--)if(r[e]===t||r[e].listener===t){i=e;break}if(i<0)return this;i===0?r.shift():spliceOne(r,i),r.length===1&&(n[e]=r[0]),n.removeListener!==void 0&&this.emit(`removeListener`,e,t.listener??t)}return this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){let t=this._events;if(t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){let e=Object.keys(t);for(let t=0;t<e.length;++t){let n=e[t];n!==`removeListener`&&this.removeAllListeners(n)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let n=t[e];if(typeof n==`function`)this.removeListener(e,n);else if(n!==void 0)for(let t=n.length-1;t>=0;t--)this.removeListener(e,n[t]);return this}listeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n.listener??n]:unwrapListeners(n)}rawListeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n]:arrayClone(n)}listenerCount(e){let t=this._events;if(t===void 0)return 0;let n=t[e];return n===void 0?0:typeof n==`function`?1:n.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(e,t,n){return new Promise((r,i)=>{let a=n?.signal;if(a?.aborted){i(createAbortError$1(a));return}if(typeof e.addEventListener==`function`){let n=e,handler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),r(e)},errorHandler=e=>{a&&a.removeEventListener(`abort`,abortHandler),n.removeEventListener(`error`,errorHandler),i(e)},abortHandler=()=>{n.removeEventListener(t,handler),n.removeEventListener(`error`,errorHandler),i(createAbortError$1(a))};n.addEventListener(t,handler,{once:!0}),t!==`error`&&n.addEventListener(`error`,errorHandler,{once:!0}),a&&a.addEventListener(`abort`,abortHandler,{once:!0});return}let o=e,eventHandler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&o.removeListener(`error`,errorHandler),r(e)},errorHandler;t!==`error`&&(errorHandler=e=>{o.removeListener(t,eventHandler),a&&a.removeEventListener(`abort`,abortHandler),i(e)},o.once(`error`,errorHandler)),o.once(t,eventHandler);let abortHandler=()=>{o.removeListener(t,eventHandler),errorHandler&&o.removeListener(`error`,errorHandler),i(createAbortError$1(a))};a&&a.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,t,n){let r=n?.signal;if(r?.aborted)throw createAbortError$1(r);let i=n?.highWaterMark??2**53-1,a=n?.lowWaterMark??1;validateNumber(i,`highWaterMark`),validateNumber(a,`lowWaterMark`);let o=[],s=[],c=null,l=!1,u=!1,eventHandler=(...t)=>{if(s.length>0){let{resolve:e}=s.shift();e({value:t,done:!1})}else o.push(t),o.length>=i&&!u&&(u=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(c=e,s.length>0){let{reject:t}=s.shift();t(e)}d.return()},abortHandler=()=>{errorHandler(createAbortError$1(r))};e.on(t,eventHandler),t!==`error`&&e.on(`error`,errorHandler),r&&r.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{e.removeListener(t,eventHandler),e.removeListener(`error`,errorHandler),r&&r.removeEventListener(`abort`,abortHandler),l=!0;for(let{resolve:e}of s)e({value:void 0,done:!0});s.length=0,o.length=0},d={next(){if(o.length>0){let t=o.shift();return u&&o.length<a&&(u=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:t,done:!1})}if(c){let e=Promise.reject(c);return c=null,e}return l?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{s.push({resolve:e,reject:t})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return l||(c=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return d}static listenerCount(e,t){return e.listenerCount(t)}static getEventListeners(e,t){return typeof e.listeners==`function`?e.listeners(t):[]}static setMaxListeners(e,...t){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range.`);if(t.length===0)EventEmitter.defaultMaxListeners=e;else for(let n of t)typeof n.setMaxListeners==`function`&&n.setMaxListeners(e)}static getMaxListeners(e){return typeof e.getMaxListeners==`function`?e.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(e,t){e.aborted&&Promise.resolve().then(()=>t());let handler=()=>t();return e.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){e.removeEventListener(`abort`,handler)}}}};S.EventEmitter=S;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let t=S.prototype[e];typeof t==`function`&&Object.defineProperty(S.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}Object.defineProperty(S.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(S.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(S.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0});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$1(e){let t=Error(`The operation was aborted`);return t.name=`AbortError`,t.code=`ABORT_ERR`,e?.reason&&(t.cause=e.reason),t}__name(createAbortError$1,`createAbortError`);const C=makeCallable(S);C.EventEmitter=C,C.captureRejectionSymbol,C.errorMonitor,C.defaultMaxListeners,C.setMaxListeners,C.getMaxListeners,C.once,C.on,C.getEventListeners,C.listenerCount,C.addAbortListener;const ge=new TextEncoder;var ProcessWriteStream=class extends C{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`?ge.encode(e):e;return this._outGio.write_all(t,null),!0}catch{}return this.fd===2?g.error(e):g.log(e),!0}get isTTY(){if(b)return b.Terminal.is_tty(this.fd);try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(b){let[e,,t]=b.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`COLUMNS`)??`0`,10);if(t>0)return t}}catch{}return 80}end(){}destroy(){}get rows(){if(b){let[e,t]=b.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`LINES`)??`0`,10);if(t>0)return t}}catch{}return 24}},ProcessReadStream=class extends C{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return b?b.Terminal.is_tty(this.fd):!1}setRawMode(e){return b&&b.Terminal.set_raw_mode(this.fd,e)?(this.isRaw=e,this):(this._setRawModeViaStty(e),this.isRaw=e,this)}_setRawModeViaStty(e){try{let t=globalThis.imports?.gi,n=t?.Gio??t?.Gio;if(!n)return;let r=n.SubprocessFlags?.STDIN_INHERIT??2,i=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`];if(new n.SubprocessLauncher({flags:r}).spawnv(i).wait(null),e&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let e=globalThis.process;e?.once&&typeof e.once==`function`&&e.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(e){return this}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.emit(`data`,Buffer.from(n));else if(n!==null&&n.byteLength===0){this._reading=!1,this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}};const _e=Date.now();var Process=class extends C{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),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}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()-_e)/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){return 18}emitWarning(e,t){g.warn(typeof e==`string`?`(${t||`Warning`}): ${e}`:e.message)}};Process.prototype.hrtime.bigint=function(){return hrtimeBigint()};const w=new Process;if(b)try{let e=new b.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{w.stdout.emit(`resize`),w.stderr.emit(`resize`)}),e.start()}catch{}w.platform,w.arch,w.env,w.argv,w.argv0,w.execPath,w.pid,w.ppid,w.version,w.versions,w.cwd.bind(w),w.chdir.bind(w),w.exit.bind(w),w.nextTick.bind(w),Object.assign(w.hrtime.bind(w),{bigint:hrtimeBigint}),w.uptime.bind(w),w.memoryUsage.bind(w),w.cpuUsage.bind(w),w.kill.bind(w),w.abort.bind(w),w.umask.bind(w),w.emitWarning.bind(w),w.execArgv,w.config,w.stdout,w.stderr,w.stdin,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:w,enumerable:!1,writable:!0,configurable:!0}),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 ve=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(e,t,n,r){this._callback=e,this._delay=t,this._args=n,this._repeat=r,this._schedule()}_schedule(){let e=getGLib();if(!e)return;let t=e.timeout_add.bind(e);this._id=t(e.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(e){setTimeout(()=>{throw e},0)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){if(e instanceof GjsifyTimeout)e._cancel();else if(typeof e==`number`)try{getGLib()?.Source.remove(e)}catch{}}if(ve){let setT=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!1),setI=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!0),e=globalThis;e.setTimeout=setT,e.clearTimeout=removeById,e.setInterval=setI,e.clearInterval=removeById}function setImmediate(e,...t){return setTimeout(e,0,...t)}function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});let ye;if(globalThis.performance)ye=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();ye={timeOrigin:n,now:_now,mark(e){let n={name:e,entryType:`mark`,startTime:_now(),duration:0};return t.push(n),n},measure(e,n,r){let i=0,a=_now();if(n){let e=t.find(e=>e.entryType===`mark`&&e.name===n);e&&(i=e.startTime)}if(r){let e=t.find(e=>e.entryType===`mark`&&e.name===r);e&&(a=e.startTime)}let o={name:e,entryType:`measure`,startTime:i,duration:a-i};return t.push(o),o},getEntries(){return[...t]},getEntriesByName(e){return t.filter(t=>t.name===e)},getEntriesByType(e){return t.filter(t=>t.entryType===e)},clearMarks(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`mark`&&(!e||t[n].name===e)&&t.splice(n,1)},clearMeasures(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`measure`&&(!e||t[n].name===e)&&t.splice(n,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:n}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const T=globalThis,be=T.PerformanceObserver||PerformanceObserverStub;T.PerformanceEntry,T.PerformanceObserverEntryList,T.PerformanceMark,T.PerformanceMeasure;const xe=globalThis;globalThis.performance===void 0&&(xe.performance=ye),typeof xe.PerformanceObserver!=`function`&&(xe.PerformanceObserver=be);const Se={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(Se,this.name)?Se[this.name]:0}};const E=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;let Ce=!1;function ensureGstInit(){Ce||=(n.init(null),!0)}function ensureWebrtcbinAvailable(){ensureGstInit(),n.ElementFactory.find(`webrtcbin`)||throwNotSupported(`GStreamer element "webrtcbin" not available. Install gst-plugins-bad:
5
+ `+t)}profile(e){}profileEnd(e){}timeStamp(e){}};const h=new Console,ee=__name((...e)=>h.log(...e),`log`),info=(...e)=>h.info(...e),debug=(...e)=>h.debug(...e),warn=(...e)=>h.warn(...e),error=(...e)=>h.error(...e),dir=(e,t)=>h.dir(e,t),dirxml=(...e)=>h.dirxml(...e),table=(e,t)=>h.table(e,t),clear=()=>h.clear(),assert=(e,...t)=>h.assert(e,...t),trace=(...e)=>h.trace(...e),time=e=>h.time(e),timeEnd=e=>h.timeEnd(e),timeLog=(e,...t)=>h.timeLog(e,...t),count=e=>h.count(e),countReset=e=>h.countReset(e),group=(...e)=>h.group(...e),groupCollapsed=(...e)=>h.groupCollapsed(...e),groupEnd=()=>h.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{},g={log:ee,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp},_=__name(e=>{Promise.resolve().then(e)},`queueMicrotask`),{File:te}=p,{toString:ne}=Object.prototype;function classOf(e){return ne.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}const re={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},ie=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]);function internalClone(e,t,n){if(e==null)return e;let r=typeof e;if(r===`boolean`||r===`number`||r===`string`||r===`bigint`)return e;r===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),r===`function`&&throwDataCloneError(`Function cannot be cloned`);let i=e;if(t.has(i))return t.get(i);let a=classOf(i);if(a===`Date`)return new Date(i.getTime());if(a===`RegExp`)return new RegExp(i.source,i.flags);if(a===`Boolean`||a===`Number`||a===`String`)return Object(i.valueOf());if(a===`BigInt`)return Object(BigInt.prototype.valueOf.call(i));if(i instanceof Error){let e=i,r=e.constructor?.name,a=new(r&&re[r]||re[e.name]||Error)(e.message);return a.name=e.name,`cause`in e&&Object.defineProperty(a,"cause",{value:internalClone(e.cause,t,n),writable:!0,enumerable:!1,configurable:!0}),a}if(a===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=i;return new e(t.message,t.name)}}if(a===`ArrayBuffer`){let e=i;if(n&&n.transferred.has(e)){let r=n.transferred.get(e);return t.set(i,r),r}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let r=e.slice(0);return t.set(i,r),r}if(a===`SharedArrayBuffer`||i&&typeof i==`object`&&i.constructor?.name===`SharedBuffer`)return i;if(a===`DataView`){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=r?r.byteOffset:e.byteOffset,s=r?r.byteLength:e.byteLength,c=new DataView(a,o,s);return t.set(i,c),c}if(ie.has(a)){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=e.constructor,s=new o(a,r?r.byteOffset:e.byteOffset,r?r.length:e.length);return t.set(i,s),s}if(a===`Map`){let e=new Map;t.set(i,e);for(let[r,a]of i)e.set(internalClone(r,t,n),internalClone(a,t,n));return e}if(a===`Set`){let e=new Set;t.set(i,e);for(let r of i)e.add(internalClone(r,t,n));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&i instanceof n){let e=i;return new n([i],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&i instanceof t)return new t([i],{type:i.type})}if(i instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),i instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),i instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&i instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),a===`Array`){let e=i,r=[];t.set(i,r);for(let i=0;i<e.length;i++)i in e&&(r[i]=internalClone(e[i],t,n));return r}if(a===`Object`||typeof i==`object`){let e={};t.set(i,e);for(let r of Object.keys(i))e[r]=internalClone(i[r],t,n);return e}throwDataCloneError(`${a} cannot be cloned`)}function structuredClone$1(e,t){let n=t?.transfer;if(!n||n.length===0)return internalClone(e,new Map);let r=new Set;for(let e of n)if(classOf(e)===`ArrayBuffer`){let t=e;t.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),r.add(t)}let i=new Map;r.size>0&&snapshotViewsBackedByTransferredBuffers(e,r,i,new Set);let a=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),a.set(e,t.transfer())}return internalClone(e,new Map,{transferred:a,viewSnapshots:i})}__name(structuredClone$1,`structuredClone`);function snapshotViewsBackedByTransferredBuffers(e,t,n,r){if(typeof e!=`object`||!e)return;let i=e;if(r.has(i))return;r.add(i);let a=classOf(i);if(a===`DataView`){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(ie.has(a)){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(i)){for(let e=0;e<i.length;e++)e in i&&snapshotViewsBackedByTransferredBuffers(i[e],t,n,r);return}if(a===`Map`){for(let[e,a]of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r),snapshotViewsBackedByTransferredBuffers(a,t,n,r);return}if(a===`Set`){for(let e of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r);return}if(a===`Object`)for(let e of Object.keys(i))snapshotViewsBackedByTransferredBuffers(i[e],t,n,r)}let ae=!1,v=null;function ensureMainLoop(){let e=globalThis.imports;if(!e)return;if(ae)return v;let t=e.gi?.GLib;if(t){if(v=new t.MainLoop(null,!1),ae=!0,t.main_depth()===0)try{v.runAsync()}catch{}return v}}function quitMainLoop(){v&&=(v.quit(),ae=!1,null)}registerGlobal(`Blob`,u),registerGlobal(`File`,d);const y=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,oe=new Uint8Array(256);for(let e=0;e<64;e++)oe[y.charCodeAt(e)]=e;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+=y[r>>18&63]+y[r>>12&63]+y[r>>6&63]+y[r&63]}if(n+1===e.length){let r=e.charCodeAt(n)<<16;t+=y[r>>18&63]+y[r>>12&63]+`==`}else if(n+2===e.length){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8;t+=y[r>>18&63]+y[r>>12&63]+y[r>>6&63]+`=`}return t}function base64Decode(e){let t=e.replace(/[=\s]/g,``),n=new Uint8Array(t.length*3>>2),r=0,i=0,a=0;for(let e=0;e<t.length;e++)r=r<<6|oe[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n[a++]=r>>i&255);return n.subarray(0,a)}let se,ce;const textEncoder=()=>se??=new TextEncoder,textDecoder=()=>ce??=new TextDecoder;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`)}const le=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`];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(!le.includes(t))throw TypeError(`Unknown encoding: ${e}`)}const ue=typeof SharedArrayBuffer<`u`;var de=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;return new Buffer(e,r,n===void 0?e.byteLength-r:n)}if(ue&&e instanceof SharedArrayBuffer){let r=t||0,i=n===void 0?e.byteLength-r:n;return new Buffer(new Uint8Array(e,r,i))}if(typeof e==`object`&&e&&typeof e.viewBytes==`function`&&typeof e.byteLength==`number`&&e.constructor?.name===`SharedBuffer`){let r=e,i=t||0,a=n===void 0?r.byteLength-i:n,o=r.viewBytes(i,a);return new Buffer(o.buffer,o.byteOffset,o.byteLength)}if(Array.isArray(e)){let t=new Buffer(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]&255;return t}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(e){return e instanceof Buffer}static isEncoding(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(t)}static byteLength(e,t){if(typeof e!=`string`){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||ue&&e instanceof SharedArrayBuffer)return e.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(t)){case`utf8`:return new TextEncoder().encode(e).byteLength;case`ascii`:case`latin1`:return e.length;case`base64`:case`base64url`:{let t=e.length;for(;t>0&&(e[t-1]===`=`||e[t-1]===` `);)t--;return t*3>>>2}case`hex`:return e.length>>>1;case`utf16le`:return e.length*2;default:return new TextEncoder().encode(e).byteLength}}static compare(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return e.length<t.length?-1:+(e.length>t.length)}static concat(e,t){if(e.length===0)return Buffer.alloc(0);if(t===void 0){t=0;for(let n=0;n<e.length;n++)t+=e[n].length}let n=Buffer.alloc(t),r=0;for(let i=0;i<e.length;i++){let a=e[i],o=Math.min(a.length,t-r);o<=0||(n.set(a.subarray(0,o),r),r+=o)}return n}static poolSize=8192;toString(e,t,n){let r=normalizeEncoding(e);return decodeString(this,r,t,n)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(e){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==e.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==e[t])return!1;return!0}compare(e,t,n,r,i){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let a=r!==void 0||i!==void 0?this.subarray(r??0,i??this.length):this,o=t!==void 0||n!==void 0?e.subarray(t??0,n??e.length):e;return Buffer.compare(a,o)}copy(e,t=0,n=0,r){let i=r??this.length,a=Math.min(i-n,e.length-t);return a<=0?0:(e.set(this.subarray(n,n+a),t),a)}slice(e,t){let n=e??0,r=t??this.length,i=super.subarray(n,r);return new Buffer(i.buffer,i.byteOffset,i.byteLength)}subarray(e,t){let n=super.subarray(e,t);return new Buffer(n.buffer,n.byteOffset,n.byteLength)}write(e,t,n,r){t??=0;let i=encodeString(e,normalizeEncoding(r||(typeof n==`string`?n:void 0))),a=n!==void 0&&typeof n==`number`?Math.min(n,this.length-t):this.length-t,o=Math.min(i.length,a);return this.set(i.subarray(0,o),t),o}fill(e,t,n,r){let i=t??0,a=n??this.length;if(typeof e==`number`)super.fill(e&255,i,a);else if(typeof e==`string`){let t=encodeString(e,normalizeEncoding(r));if(t.length===0)super.fill(0,i,a);else if(t.length===1)super.fill(t[0],i,a);else for(let e=i;e<a;e++)this[e]=t[(e-i)%t.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,i,a);else for(let t=i;t<a;t++)this[t]=e[(t-i)%e.length];return this}indexOf(e,t,n){if(typeof e==`number`)return super.indexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t??0;outer:for(let e=i;e<=this.length-r.length;e++){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}lastIndexOf(e,t,n){if(typeof e==`number`)return t===void 0?super.lastIndexOf(e&255):super.lastIndexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t===void 0?this.length-r.length:Math.min(t,this.length-r.length);outer:for(let e=i;e>=0;e--){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}includes(e,t,n){return this.indexOf(e,t,n)!==-1}readUInt8(e=0){return checkOffset(e,1,this.length),this[e]}readUInt16BE(e=0){return checkOffset(e,2,this.length),this[e]<<8|this[e+1]}readUInt16LE(e=0){return checkOffset(e,2,this.length),this[e]|this[e+1]<<8}readUInt32BE(e=0){return checkOffset(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])}readUInt32LE(e=0){return checkOffset(e,4,this.length),this[e+3]*16777216+(this[e+2]<<16|this[e+1]<<8|this[e])>>>0}readInt8(e=0){return checkOffset(e,1,this.length),this[e]|(this[e]&128?4294967040:0)}readInt16BE(e=0){checkOffset(e,2,this.length);let t=this[e]<<8|this[e+1];return t&32768?t|4294901760:t}readInt16LE(e=0){checkOffset(e,2,this.length);let t=this[e]|this[e+1]<<8;return t&32768?t|4294901760:t}readInt32BE(e=0){return checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]}readInt32LE(e=0){return checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24}readFloatBE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!1)}readFloatLE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!0)}readDoubleBE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!1)}readDoubleLE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!0)}readBigInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!1)}readBigInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!0)}readBigUInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!1)}readBigUInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!0)}readUIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n}readUIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n}readIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n>=2**(8*t-1)&&(n-=2**(8*t)),n}readIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n>=2**(8*t-1)&&(n-=2**(8*t)),n}writeUInt8(e,t=0){return checkOffset(t,1,this.length),this[t]=e&255,t+1}writeUInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeUInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeUInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeUInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeInt8(e,t=0){return checkOffset(t,1,this.length),e<0&&(e=255+e+1),this[t]=e&255,t+1}writeInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeFloatBE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!1),t+4}writeFloatLE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!0),t+4}writeDoubleBE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!1),t+8}writeDoubleLE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!0),t+8}writeBigInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!1),t+8}writeBigInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!0),t+8}writeBigUInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!1),t+8}writeBigUInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!0),t+8}swap16(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2){let e=this[t];this[t]=this[t+1],this[t+1]=e}return this}swap32(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4){let e=this[t],n=this[t+1];this[t]=this[t+3],this[t+1]=this[t+2],this[t+2]=n,this[t+3]=e}return this}swap64(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8){let e=this[t],n=this[t+1],r=this[t+2],i=this[t+3];this[t]=this[t+7],this[t+1]=this[t+6],this[t+2]=this[t+5],this[t+3]=this[t+4],this[t+4]=i,this[t+5]=r,this[t+6]=n,this[t+7]=e}return this}};`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:de,enumerable:!1,writable:!0,configurable:!0}),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 f.base64_encode(t)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let t=f.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}),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:_,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let e=getGjsGlobal().imports?.gi;if(!e)return null;let t=null;try{t=e.GioUnix??null}catch{}if(!t)try{t=e.Gio??null}catch{}return t}function getMonotonicTime(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_monotonic_time)return BigInt(e.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}const fe=getMonotonicTime();function hrtime(e){let t=getMonotonicTime()-fe,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()-fe}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(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/PPid:\s+(\d+)/);if(e)return parseInt(e[1],10)}}}catch{}return 0}function detectPlatform(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e&&e.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/stat`);if(t){let e=new TextDecoder().decode(t),n=parseInt(e,10);if(!isNaN(n))return n}}}catch{}return 0}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(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let e=getGjsGlobal().imports?.system;if(e?.programInvocationName)return e.programInvocationName}catch{}return`/usr/bin/gjs`}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`)}function exitProcess(e){let t=getGjsGlobal().imports,n=t?.gi?.GLib,r=t?.system,i=n?.idle_add,a=n?.SOURCE_REMOVE,o=n?.PRIORITY_DEFAULT;if(r?.exit&&i&&typeof o==`number`&&typeof a==`boolean`)return ensureMainLoop(),i(o,()=>(quitMainLoop(),r.exit(e),a)),new Promise(()=>{});try{r?.exit&&r.exit(e)}catch{}let s=globalThis.process;throw s&&typeof s.exit==`function`&&s.exit(e),Error(`process.exit(${e})`)}function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(e,t){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let r=typeof t==`number`?String(t):t||`SIGTERM`,i=r.startsWith(`SIG`)?`-${r.slice(3)}`:`-${r}`;return n.spawn_command_line_sync(`kill ${i} ${e}`),!0}}catch{}if(!isGjs()){let n=globalThis.process;if(n&&typeof n.kill==`function`)return n.kill(e,t)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/VmRSS:\s+(\d+)/),n=e?parseInt(e[1],10)*1024:0;return{rss:n,heapTotal:n,heapUsed:n,external:0,arrayBuffers:0}}}}catch{}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}}let pe=null;const me=globalThis.imports?.gi;if(me)try{pe=me.GjsifyTerminal}catch{}const b=pe,x=Symbol(`kCapture`),he=Symbol.for(`nodejs.rejection`);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()}var S=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=he;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;[x];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[x]=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[x]&&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[x]&&this._addCatch(r,e,t)}}return!0}_addCatch(e,t,n){typeof e?.then==`function`&&e.then(void 0,e=>{let r=this[he];if(typeof r==`function`)r.call(this,e,t,...n);else{let t=this[x];try{this[x]=!1,this.emit(`error`,e)}finally{this[x]=t}}})}addListener(e,t){return this._addListener(e,t,!1)}on(e,t){return this._addListener(e,t,!1)}prependListener(e,t){return this._addListener(e,t,!0)}_addListener(e,t,n){checkListener(t);let r=this._events;r===void 0?(r=this._events=Object.create(null),this._eventsCount=0):r.newListener!==void 0&&(this.emit(`newListener`,e,t.listener??t),r=this._events);let i=r[e];i===void 0?(r[e]=t,++this._eventsCount):typeof i==`function`?r[e]=n?[t,i]:[i,t]:n?i.unshift(t):i.push(t);let a=this.getMaxListeners();if(a>0){let t=typeof r[e]==`function`?1:r[e].length;if(t>a&&!r[e].warned){typeof r[e]!=`function`&&(r[e].warned=!0);let n=Error(`Possible EventEmitter memory leak detected. ${t} ${String(e)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);n.name=`MaxListenersExceededWarning`,g.warn(n.message)}}return this}once(e,t){return checkListener(t),this.on(e,_onceWrap(this,e,t)),this}prependOnceListener(e,t){return checkListener(t),this.prependListener(e,_onceWrap(this,e,t)),this}removeListener(e,t){checkListener(t);let n=this._events;if(n===void 0)return this;let r=n[e];if(r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit(`removeListener`,e,r.listener??t));else if(typeof r!=`function`){let i=-1;for(let e=r.length-1;e>=0;e--)if(r[e]===t||r[e].listener===t){i=e;break}if(i<0)return this;i===0?r.shift():spliceOne(r,i),r.length===1&&(n[e]=r[0]),n.removeListener!==void 0&&this.emit(`removeListener`,e,t.listener??t)}return this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){let t=this._events;if(t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){let e=Object.keys(t);for(let t=0;t<e.length;++t){let n=e[t];n!==`removeListener`&&this.removeAllListeners(n)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let n=t[e];if(typeof n==`function`)this.removeListener(e,n);else if(n!==void 0)for(let t=n.length-1;t>=0;t--)this.removeListener(e,n[t]);return this}listeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n.listener??n]:unwrapListeners(n)}rawListeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n]:arrayClone(n)}listenerCount(e){let t=this._events;if(t===void 0)return 0;let n=t[e];return n===void 0?0:typeof n==`function`?1:n.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(e,t,n){return new Promise((r,i)=>{let a=n?.signal;if(a?.aborted){i(createAbortError$1(a));return}if(typeof e.addEventListener==`function`){let n=e,handler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),r(e)},errorHandler=e=>{a&&a.removeEventListener(`abort`,abortHandler),n.removeEventListener(`error`,errorHandler),i(e)},abortHandler=()=>{n.removeEventListener(t,handler),n.removeEventListener(`error`,errorHandler),i(createAbortError$1(a))};n.addEventListener(t,handler,{once:!0}),t!==`error`&&n.addEventListener(`error`,errorHandler,{once:!0}),a&&a.addEventListener(`abort`,abortHandler,{once:!0});return}let o=e,eventHandler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&o.removeListener(`error`,errorHandler),r(e)},errorHandler;t!==`error`&&(errorHandler=e=>{o.removeListener(t,eventHandler),a&&a.removeEventListener(`abort`,abortHandler),i(e)},o.once(`error`,errorHandler)),o.once(t,eventHandler);let abortHandler=()=>{o.removeListener(t,eventHandler),errorHandler&&o.removeListener(`error`,errorHandler),i(createAbortError$1(a))};a&&a.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,t,n){let r=n?.signal;if(r?.aborted)throw createAbortError$1(r);let i=n?.highWaterMark??2**53-1,a=n?.lowWaterMark??1;validateNumber(i,`highWaterMark`),validateNumber(a,`lowWaterMark`);let o=[],s=[],c=null,l=!1,u=!1,eventHandler=(...t)=>{if(s.length>0){let{resolve:e}=s.shift();e({value:t,done:!1})}else o.push(t),o.length>=i&&!u&&(u=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(c=e,s.length>0){let{reject:t}=s.shift();t(e)}d.return()},abortHandler=()=>{errorHandler(createAbortError$1(r))};e.on(t,eventHandler),t!==`error`&&e.on(`error`,errorHandler),r&&r.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{e.removeListener(t,eventHandler),e.removeListener(`error`,errorHandler),r&&r.removeEventListener(`abort`,abortHandler),l=!0;for(let{resolve:e}of s)e({value:void 0,done:!0});s.length=0,o.length=0},d={next(){if(o.length>0){let t=o.shift();return u&&o.length<a&&(u=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:t,done:!1})}if(c){let e=Promise.reject(c);return c=null,e}return l?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{s.push({resolve:e,reject:t})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return l||(c=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return d}static listenerCount(e,t){return e.listenerCount(t)}static getEventListeners(e,t){return typeof e.listeners==`function`?e.listeners(t):[]}static setMaxListeners(e,...t){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range.`);if(t.length===0)EventEmitter.defaultMaxListeners=e;else for(let n of t)typeof n.setMaxListeners==`function`&&n.setMaxListeners(e)}static getMaxListeners(e){return typeof e.getMaxListeners==`function`?e.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(e,t){e.aborted&&Promise.resolve().then(()=>t());let handler=()=>t();return e.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){e.removeEventListener(`abort`,handler)}}}};S.EventEmitter=S;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let t=S.prototype[e];typeof t==`function`&&Object.defineProperty(S.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}Object.defineProperty(S.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(S.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(S.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0});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$1(e){let t=Error(`The operation was aborted`);return t.name=`AbortError`,t.code=`ABORT_ERR`,e?.reason&&(t.cause=e.reason),t}__name(createAbortError$1,`createAbortError`);const C=makeCallable(S);C.EventEmitter=C,C.captureRejectionSymbol,C.errorMonitor,C.defaultMaxListeners,C.setMaxListeners,C.getMaxListeners,C.once,C.on,C.getEventListeners,C.listenerCount,C.addAbortListener;const ge=new TextEncoder;var ProcessWriteStream=class extends C{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`?ge.encode(e):e;return this._outGio.write_all(t,null),!0}catch{}return this.fd===2?g.error(e):g.log(e),!0}get isTTY(){if(b)return b.Terminal.is_tty(this.fd);try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(b){let[e,,t]=b.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`COLUMNS`)??`0`,10);if(t>0)return t}}catch{}return 80}end(){}destroy(){}get rows(){if(b){let[e,t]=b.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`LINES`)??`0`,10);if(t>0)return t}}catch{}return 24}},ProcessReadStream=class extends C{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return b?b.Terminal.is_tty(this.fd):!1}setRawMode(e){return b&&b.Terminal.set_raw_mode(this.fd,e)?(this.isRaw=e,this):(this._setRawModeViaStty(e),this.isRaw=e,this)}_setRawModeViaStty(e){try{let t=globalThis.imports?.gi,n=t?.Gio??t?.Gio;if(!n)return;let r=n.SubprocessFlags?.STDIN_INHERIT??2,i=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`];if(new n.SubprocessLauncher({flags:r}).spawnv(i).wait(null),e&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let e=globalThis.process;e?.once&&typeof e.once==`function`&&e.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(e){return this}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.emit(`data`,Buffer.from(n));else if(n!==null&&n.byteLength===0){this._reading=!1,this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}};const _e=Date.now();var Process=class extends C{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),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}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()-_e)/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){return 18}emitWarning(e,t){g.warn(typeof e==`string`?`(${t||`Warning`}): ${e}`:e.message)}};Process.prototype.hrtime.bigint=function(){return hrtimeBigint()};const w=new Process;if(b)try{let e=new b.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{w.stdout.emit(`resize`),w.stderr.emit(`resize`)}),e.start()}catch{}w.platform,w.arch,w.env,w.argv,w.argv0,w.execPath,w.pid,w.ppid,w.version,w.versions,w.cwd.bind(w),w.chdir.bind(w),w.exit.bind(w),w.nextTick.bind(w),Object.assign(w.hrtime.bind(w),{bigint:hrtimeBigint}),w.uptime.bind(w),w.memoryUsage.bind(w),w.cpuUsage.bind(w),w.kill.bind(w),w.abort.bind(w),w.umask.bind(w),w.emitWarning.bind(w),w.execArgv,w.config,w.stdout,w.stderr,w.stdin,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:w,enumerable:!1,writable:!0,configurable:!0}),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 ve=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(e,t,n,r){this._callback=e,this._delay=t,this._args=n,this._repeat=r,this._schedule()}_schedule(){let e=getGLib();if(!e)return;let t=e.timeout_add.bind(e);this._id=t(e.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(e){setTimeout(()=>{throw e},0)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){if(e instanceof GjsifyTimeout)e._cancel();else if(typeof e==`number`)try{getGLib()?.Source.remove(e)}catch{}}if(ve){let setT=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!1),setI=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!0),e=globalThis;e.setTimeout=setT,e.clearTimeout=removeById,e.setInterval=setI,e.clearInterval=removeById}function setImmediate(e,...t){return setTimeout(e,0,...t)}function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});let ye;if(globalThis.performance)ye=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();ye={timeOrigin:n,now:_now,mark(e){let n={name:e,entryType:`mark`,startTime:_now(),duration:0};return t.push(n),n},measure(e,n,r){let i=0,a=_now();if(n){let e=t.find(e=>e.entryType===`mark`&&e.name===n);e&&(i=e.startTime)}if(r){let e=t.find(e=>e.entryType===`mark`&&e.name===r);e&&(a=e.startTime)}let o={name:e,entryType:`measure`,startTime:i,duration:a-i};return t.push(o),o},getEntries(){return[...t]},getEntriesByName(e){return t.filter(t=>t.name===e)},getEntriesByType(e){return t.filter(t=>t.entryType===e)},clearMarks(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`mark`&&(!e||t[n].name===e)&&t.splice(n,1)},clearMeasures(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`measure`&&(!e||t[n].name===e)&&t.splice(n,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:n}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const T=globalThis,be=T.PerformanceObserver||PerformanceObserverStub;T.PerformanceEntry,T.PerformanceObserverEntryList,T.PerformanceMark,T.PerformanceMeasure;const xe=globalThis;globalThis.performance===void 0&&(xe.performance=ye),typeof xe.PerformanceObserver!=`function`&&(xe.PerformanceObserver=be);const Se={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(Se,this.name)?Se[this.name]:0}};const E=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;let Ce=!1;function ensureGstInit(){Ce||=(n.init(null),!0)}function ensureWebrtcbinAvailable(){ensureGstInit(),n.ElementFactory.find(`webrtcbin`)||throwNotSupported(`GStreamer element "webrtcbin" not available. Install gst-plugins-bad:
6
6
  Fedora: dnf install gstreamer1-plugins-bad-free gstreamer1-plugins-bad-free-extras
7
7
  Ubuntu/Debian: apt install gstreamer1.0-plugins-bad`),n.ElementFactory.find(`nicesrc`)||throwNotSupported(`GStreamer "nice" plugin (libnice-gstreamer) not available — required by webrtcbin.
8
8
  Fedora: dnf install libnice-gstreamer1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/example-dom-webrtc-loopback",
3
- "version": "0.4.37",
3
+ "version": "0.4.38",
4
4
  "description": "WebRTC data-channel loopback demo (two local peers) for GJS and browser",
5
5
  "main": "dist/gjs.js",
6
6
  "type": "module",
@@ -27,17 +27,17 @@
27
27
  "build:assets": "mkdir -p dist && cp -f src/browser/index.html dist/index.html"
28
28
  },
29
29
  "dependencies": {
30
- "@gjsify/webrtc": "^0.4.37"
30
+ "@gjsify/webrtc": "^0.4.38"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@girs/gjs": "4.0.4",
34
34
  "@girs/glib-2.0": "2.88.0-4.0.4",
35
- "@gjsify/cli": "^0.4.37",
36
- "@gjsify/node-globals": "^0.4.37",
37
- "@gjsify/runtime": "^0.4.37",
35
+ "@gjsify/cli": "^0.4.38",
36
+ "@gjsify/node-globals": "^0.4.38",
37
+ "@gjsify/runtime": "^0.4.38",
38
38
  "@types/node": "^25.9.1",
39
39
  "http-server": "^14.1.1",
40
- "typescript": "^5.9.3"
40
+ "typescript": "^6.0.3"
41
41
  },
42
42
  "author": "Pascal Garber <pascal@artandcode.studio>",
43
43
  "license": "MIT",