@gjsify/example-dom-three-loader-ldraw 0.49.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/gjs.js CHANGED
@@ -22,7 +22,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,Symbol.dispose||(Symbol.dispos
22
22
  `),n){if(i){let e=t.indexOf(`
23
23
  `);t=e===-1?t+`
24
24
  `+i:t.slice(0,e+1)+i+t.slice(e+1)}}else if(this.canvas){let e=this.canvas.getGlArea().get_use_es(),n=r===`glsl1`?this._getGlsl1Version(e):this._getGlslVersion(e);n?t=`#version `+n+`
25
- `+i+t:i&&(t=i+t)}else i&&(t=i+t);return t}};function installShaderLifecycleMethods(e){Object.assign(e,Pr)}const Fr={createProgram(){let e=this._gl.createProgram();if(e<=0)return null;let t=new WebGLProgram$1(e,this);return this._programs[e]=t,t},deleteProgram(e){this._deleteLinkable(`deleteProgram`,e,WebGLProgram$1)},useProgram(e){if(!checkObject(e))throw TypeError(`useProgram(WebGLProgram)`);if(e)this._checkWrapper(e,WebGLProgram$1)&&(this._activeProgram!==e&&(this._switchActiveProgram(this._activeProgram),this._activeProgram=e,e._refCount+=1),this._gl.useProgram(e._|0));else{this._switchActiveProgram(this._activeProgram),this._activeProgram=null,this._gl.useProgram(0);return}},linkProgram(e){if(!checkObject(e))throw TypeError(`linkProgram(WebGLProgram)`);if(this._checkWrapper(e,WebGLProgram$1)){e._linkCount+=1,e._attributes=[];let t=this.getError();for(let t of e._references)t instanceof WebGLShader$1&&t._needsRecompile&&(this._gl.compileShader(t._|0),t._needsRecompile=!1);this._gl.linkProgram(e._|0);let n=this.getError();n===this.NO_ERROR&&(e._linkStatus=this._fixupLink(e)),this.getError(),this.setError(t||n)}},validateProgram(e){if(this._checkWrapper(e,WebGLProgram$1)){this._gl.validateProgram(e._|0);let t=this.getError();t===this.NO_ERROR&&(e._linkInfoLog=this._gl.getProgramInfoLog(e._|0)),this.getError(),this.setError(t)}},attachShader(e,t){if(!checkObject(e)||!checkObject(t))throw TypeError(`attachShader(WebGLProgram, WebGLShader)`);if(!e||!t){this.setError(this.INVALID_VALUE);return}else if(e instanceof WebGLProgram$1&&t instanceof WebGLShader$1&&this._checkOwns(e)&&this._checkOwns(t)&&!e._linked(t)){this._saveError(),this._gl.attachShader(e._|0,t._|0);let n=this.getError();this._restoreError(n),n===this.NO_ERROR&&e._link(t);return}this.setError(this.INVALID_OPERATION)},detachShader(e,t){if(!checkObject(e)||!checkObject(t))throw TypeError(`detachShader(WebGLProgram, WebGLShader)`);this._checkWrapper(e,WebGLProgram$1)&&this._checkWrapper(t,WebGLShader$1)&&(e._linked(t)?(this._gl.detachShader(e._,t._),e._unlink(t)):this.setError(this.INVALID_OPERATION))},bindAttribLocation(e,t,n){if(!checkObject(e)||typeof n!=`string`)throw TypeError(`bindAttribLocation(WebGLProgram, GLint, String)`);n+=``,!isValidString(n)||n.length>256?this.setError(this.INVALID_VALUE):/^_?webgl_a/.test(n)?this.setError(this.INVALID_OPERATION):this._checkWrapper(e,WebGLProgram$1)&&this._gl.bindAttribLocation(e._|0,t|0,n)},getAttachedShaders(e){if(!checkObject(e)||typeof e==`object`&&e&&!(e instanceof WebGLProgram$1))throw TypeError(`getAttachedShaders(WebGLProgram)`);if(!e)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram$1))return e._references.filter(e=>e instanceof WebGLShader$1);return null},getProgramInfoLog(e){if(!checkObject(e))throw TypeError(`getProgramInfoLog(WebGLProgram)`);return this._checkWrapper(e,WebGLProgram$1)?e._linkInfoLog:null},getProgramParameter(e,t=0){if(!checkObject(e))throw TypeError(`getProgramParameter(WebGLProgram, GLenum)`);if(this._checkWrapper(e,WebGLProgram$1)){switch(t){case this.DELETE_STATUS:return e._pendingDelete;case this.LINK_STATUS:return e._linkStatus;case this.VALIDATE_STATUS:return!!this._gl.getProgramParameter(e._,t);case this.ATTACHED_SHADERS:return this._gl.getProgramParameter(e._,t);case this.ACTIVE_ATTRIBUTES:return e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._,t);case this.ACTIVE_UNIFORMS:return e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._,t)}this.setError(this.INVALID_ENUM)}return null},_switchActiveProgram(e){e&&(--e._refCount,e._checkDelete())},_fixupLink(e){if(!this._gl.getProgramParameter(e._,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let t=this.getProgramParameter(e,this.ACTIVE_ATTRIBUTES),n=Array.from({length:t});e._attributes.length=t;for(let r=0;r<t;++r)n[r]=this.getActiveAttrib(e,r)?.name,e._attributes[r]=this.getAttribLocation(e,n[r])|0;for(let t=0;t<n.length;++t)if(n[t].length>256)return e._linkInfoLog=`attribute `+n[t]+` is too long`,!1;for(let r=0;r<t;++r)e._attributes[r]<0||this._gl.bindAttribLocation(e._|0,e._attributes[r],n[r]);if(this._gl.linkProgram(e._|0),!this._gl.getProgramParameter(e._|0,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let r=this.getProgramParameter(e,this.ACTIVE_UNIFORMS);e._uniforms.length=r;for(let t=0;t<r;++t){let n=this.getActiveUniform(e,t);n&&(e._uniforms[t]=n)}for(let t=0;t<e._uniforms.length;++t)if(e._uniforms[t].name.length>256)return e._linkInfoLog=`uniform `+e._uniforms[t].name+` is too long`,!1;return e._linkInfoLog=``,!0},_deleteLinkable(e,t,n){if(!checkObject(t))throw TypeError(e+`(`+n.name+`)`);if(t instanceof n&&this._checkOwns(t)){t._pendingDelete=!0,t._checkDelete();return}this.setError(this.INVALID_OPERATION)}};function installProgramLifecycleMethods(e){Object.assign(e,Fr)}var WebGLActiveInfo=class{constructor(e){this.size=e.size,this.type=e.type,this.name=e.name}};const Ir={getActiveAttrib(e,t){if(!checkObject(e))throw TypeError(`getActiveAttrib(WebGLProgram)`);if(!e)throw TypeError(`getActiveAttrib(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram$1)){if(t>=(e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_ATTRIBUTES)))return this._gl.getError(),this.setError(this.INVALID_VALUE),null;let n=this._gl.getActiveAttrib(e._|0,t|0);if(n)return new WebGLActiveInfo(n)}return null},getActiveUniform(e,t){if(!checkObject(e))throw TypeError(`getActiveUniform(WebGLProgram, GLint)`);if(!e)throw TypeError(`getActiveUniform(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram$1)){if(t>=(e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_UNIFORMS)))return this.setError(this.INVALID_VALUE),null;let n=this._gl.getActiveUniform(e._|0,t|0);if(n)return new WebGLActiveInfo(n)}return null},getAttribLocation(e,t){if(!checkObject(e))throw TypeError(`getAttribLocation(WebGLProgram, String)`);if(t+=``,!isValidString(t)||t.length>256)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram$1))return this._gl.getAttribLocation(e._|0,t+``);return-1},getUniform(e,t){if(!checkObject(e)||!checkObject(t))throw TypeError(`getUniform(WebGLProgram, WebGLUniformLocation)`);if(!e)return this.setError(this.INVALID_VALUE),null;if(!t)return null;if(this._checkWrapper(e,WebGLProgram$1)){if(!checkUniform(e,t))return this.setError(this.INVALID_OPERATION),null;let n=this._gl.getUniform(e._|0,t._|0);if(!n)return null;switch(t._activeInfo.type){case this.FLOAT:return n[0];case this.FLOAT_VEC2:return new Float32Array(n.slice(0,2));case this.FLOAT_VEC3:return new Float32Array(n.slice(0,3));case this.FLOAT_VEC4:return new Float32Array(n.slice(0,4));case this.INT:return n[0]|0;case this.INT_VEC2:return new Int32Array(n.slice(0,2));case this.INT_VEC3:return new Int32Array(n.slice(0,3));case this.INT_VEC4:return new Int32Array(n.slice(0,4));case this.BOOL:return!!n[0];case this.BOOL_VEC2:return[!!n[0],!!n[1]];case this.BOOL_VEC3:return[!!n[0],!!n[1],!!n[2]];case this.BOOL_VEC4:return[!!n[0],!!n[1],!!n[2],!!n[3]];case this.FLOAT_MAT2:return new Float32Array(n.slice(0,4));case this.FLOAT_MAT3:return new Float32Array(n.slice(0,9));case this.FLOAT_MAT4:return new Float32Array(n.slice(0,16));case this.SAMPLER_2D:case this.SAMPLER_CUBE:return n[0]|0;default:return null}}return null},getUniformLocation(e,t){if(!checkObject(e))throw TypeError(`getUniformLocation(WebGLProgram, String)`);if(t+=``,!isValidString(t))return this.setError(this.INVALID_VALUE),null;if(this._checkWrapper(e,WebGLProgram$1)){let n=this._gl.getUniformLocation(e._|0,t);if(n!==null&&n>=0){let r=t;/\[\d+\]$/.test(t)&&(r=t.replace(/\[\d+\]$/,`[0]`));let i=r+`[0]`,o=null;for(let t=0;t<e._uniforms.length;++t){let n=e._uniforms[t];if(n.name===r||n.name===i){o={size:n.size,type:n.type,name:n.name};break}}o||={name:r,type:0,size:1};let s=new WebGLUniformLocation(n,e,o),c=t.match(/\[(\d+)\]$/),l=c?+c[1]:-1;if(o.name.endsWith(`[0]`)&&(l===-1||l===0)){let t=o.name.replace(/\[0\]$/,``),n=[];this._saveError();for(let r=0;this.getError()===this.NO_ERROR;++r){let i=this._gl.getUniformLocation(e._|0,t+`[`+r+`]`);if(this.getError()!==this.NO_ERROR||i==null||i<0)break;n.push(i)}this._restoreError(this.NO_ERROR),s._array=n}else if(l>0&&l>=o.size)return null;return s}}return null}};function installIntrospectionMethods(e){Object.assign(e,Ir)}re();const Lr={uniform1f(e,t){this._checkUniformValid(e,t,`uniform1f`,1,`f`)&&this._gl.uniform1f(e?._||0,t)},uniform1i(e,t){this._gl.uniform1i(e?._||0,t)},uniform2f(e,t,n){this._checkUniformValid(e,t,`uniform2f`,2,`f`)&&this._gl.uniform2f(e?._||0,t,n)},uniform2i(e,t,n){this._checkUniformValid(e,t,`uniform2i`,2,`i`)&&this._gl.uniform2i(e?._||0,t,n)},uniform3f(e,t,n,r){this._checkUniformValid(e,t,`uniform3f`,3,`f`)&&this._gl.uniform3f(e?._||0,t,n,r)},uniform3i(e,t,n,r){this._checkUniformValid(e,t,`uniform3i`,3,`i`)&&this._gl.uniform3i(e?._||0,t,n,r)},uniform4f(e,t,n,r,i){if(!this._checkUniformValid(e,t,`uniform4f`,4,`f`)){M.error(`uniform4f is not valid!`);return}this._gl.uniform4f(e?._||0,t,n,r,i)},uniform4i(e,t,n,r,i){this._checkUniformValid(e,t,`uniform4i`,4,`i`)&&this._gl.uniform4i(e?._||0,t,n,r,i)},uniform1fv(e,t){if(!(!e||!this._checkUniformValueValid(e,t,`uniform1fv`,1,`f`))){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1f(r,t[e])}return}this._gl.uniform1f(e?._|0,t[0])}},uniform1iv(e,t){if(this._checkUniformValueValid(e,t,`uniform1iv`,1,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1i(r,t[e])}return}this.uniform1i(e,t[0])}},uniform2fv(e,t){if(this._checkUniformValueValid(e,t,`uniform2fv`,2,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2f(r,t[2*e],t[2*e+1])}return}this._gl.uniform2f(e?._||0,t[0],t[1])}},uniform2iv(e,t){if(this._checkUniformValueValid(e,t,`uniform2iv`,2,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2i(r,t[2*e],t[2*e+1])}return}this.uniform2i(e,t[0],t[1])}},uniform3fv(e,t){if(this._checkUniformValueValid(e,t,`uniform3fv`,3,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3f(r,t[3*e],t[3*e+1],t[3*e+2])}return}this._gl.uniform3f(e?._||0,t[0],t[1],t[2])}},uniform3iv(e,t){if(this._checkUniformValueValid(e,t,`uniform3iv`,3,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3i(r,t[3*e],t[3*e+1],t[3*e+2])}return}this.uniform3i(e,t[0],t[1],t[2])}},uniform4fv(e,t){if(this._checkUniformValueValid(e,t,`uniform4fv`,4,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4f(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this._gl.uniform4f(e?._||0,t[0],t[1],t[2],t[3])}},uniform4iv(e,t){if(this._checkUniformValueValid(e,t,`uniform4iv`,4,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4i(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this.uniform4i(e,t[0],t[1],t[2],t[3])}},uniformMatrix2fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix2fv`,2))return;let r=new Float32Array(n);this._gl.uniformMatrix2fv(e?._||0,!!t,listToArray(r))},uniformMatrix3fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix3fv`,3))return;let r=new Float32Array(n);this._gl.uniformMatrix3fv(e?._||0,!!t,listToArray(r))},uniformMatrix4fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix4fv`,4))return;let r=new Float32Array(n);this._gl.uniformMatrix4fv(e?._||0,!!t,listToArray(r))},_checkLocation(e){return e instanceof WebGLUniformLocation?e._program._ctx!==this||e._linkCount!==e._program._linkCount?(this.setError(this.INVALID_OPERATION),!1):!0:(this.setError(this.INVALID_VALUE),!1)},_checkLocationActive(e){return e&&this._checkLocation(e)?e._program===this._activeProgram?!0:(this.setError(this.INVALID_OPERATION),!1):!1},_checkUniformValid(e,t,n,r,i){if(!checkObject(e))throw TypeError(`${n}(WebGLUniformLocation, ...)`);if(!e)return!1;if(this._checkLocationActive(e)){let n=e._activeInfo.type;if(n===this.SAMPLER_2D||n===this.SAMPLER_CUBE){if(r!==1)return this.setError(this.INVALID_VALUE),!1;if(i!==`i`)return this.setError(this.INVALID_OPERATION),!1;if(t<0||t>=this._textureUnits.length)return this.setError(this.INVALID_VALUE),!1}return uniformTypeSize(this,n)>r?(this.setError(this.INVALID_OPERATION),!1):!0}return!1},_checkUniformValueValid(e,t,n,r,i){if(!checkObject(e)||!checkObject(t))throw TypeError(`${n}v(WebGLUniformLocation, Array)`);if(!e||!this._checkLocationActive(e))return!1;if(typeof t!=`object`||!t||typeof t.length!=`number`)throw TypeError(`Second argument to ${n} must be array`);return uniformTypeSize(this,e._activeInfo.type)>r?(this.setError(this.INVALID_OPERATION),!1):t.length>=r&&t.length%r===0?e._array||t.length===r?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)},_checkUniformMatrix(e,t,n,r,i){if(!checkObject(e)||typeof n!=`object`)throw TypeError(r+`(WebGLUniformLocation, Boolean, Array)`);return t||typeof n!=`object`||!n||!n.length||n.length%i*i!==0?(this.setError(this.INVALID_VALUE),!1):!e||!this._checkLocationActive(e)?!1:n.length===i*i||e._array?!0:(this.setError(this.INVALID_VALUE),!1)}};function installUniformsMethods(e){Object.assign(e,Lr)}function installShaderProgramMethods(e){installShaderLifecycleMethods(e),installProgramLifecycleMethods(e),installIntrospectionMethods(e),installUniformsMethods(e)}function installAllContextMethods(e){installStateMethods(e),installBufferBindingMethods(e),installTextureManagementMethods(e),installFramebufferMethods(e),installShaderProgramMethods(e),installDrawingMethods(e)}var EXTBlendMinMax=class{constructor(){this.MIN_EXT=32775,this.MAX_EXT=32776}};function getEXTBlendMinMax(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`EXT_blend_minmax`)>=0&&(t=new EXTBlendMinMax),t}var EXTColorBufferFloat=class{};function getEXTColorBufferFloat(e){let t=e.getSupportedExtensions();return t&&t.indexOf(`EXT_color_buffer_float`)>=0?new EXTColorBufferFloat:null}var EXTColorBufferHalfFloat=class{};function getEXTColorBufferHalfFloat(e){let t=e.getSupportedExtensions();return t&&t.indexOf(`EXT_color_buffer_half_float`)>=0?new EXTColorBufferHalfFloat:null}var EXTTextureFilterAnisotropic=class{constructor(){this.TEXTURE_MAX_ANISOTROPY_EXT=34046,this.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047}};function getEXTTextureFilterAnisotropic(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`EXT_texture_filter_anisotropic`)>=0&&(t=new EXTTextureFilterAnisotropic),t}var OESElementIndexUint=class{};function getOESElementIndexUint(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_element_index_uint`)>=0&&(t=new OESElementIndexUint),t}var OESStandardDerivatives=class{constructor(){this.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723}};function getOESStandardDerivatives(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_standard_derivatives`)>=0&&(t=new OESStandardDerivatives),t}var OESTextureFloatLinear=class{};function getOESTextureFloatLinear(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_texture_float_linear`)>=0&&(t=new OESTextureFloatLinear),t}var OESTextureFloat=class{};function getOESTextureFloat(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_texture_float`)>=0&&(t=new OESTextureFloat),t}var OESTextureHalfFloat=class{constructor(){this.HALF_FLOAT_OES=36193}};function getOESTextureHalfFloat(e){let t=e.getSupportedExtensions();return t&&t.indexOf(`OES_texture_half_float`)>=0||e._native2?new OESTextureHalfFloat:null}var STACKGLDestroyContext=class{constructor(e){this.destroy=e.destroy.bind(e)}};function getSTACKGLDestroyContext(e){return new STACKGLDestroyContext(e)}var STACKGLResizeDrawingBuffer=class{constructor(e){this.resize=e.resize.bind(e)}};function getSTACKGLResizeDrawingBuffer(e){return new STACKGLResizeDrawingBuffer(e)}var WEBGLDebugRendererInfo=class{constructor(){this.UNMASKED_VENDOR_WEBGL=37445,this.UNMASKED_RENDERER_WEBGL=37446}};function getWEBGLDebugRendererInfo(e){return new WEBGLDebugRendererInfo}var WebGLContextAttributes=class{constructor(e,t,n,r,i,o,s,c){this.alpha=e,this.depth=t,this.stencil=n,this.antialias=r,this.premultipliedAlpha=i,this.preserveDrawingBuffer=o,this.preferLowPowerToHighPerformance=s,this.failIfMajorPerformanceCaveat=c}},WebGLTextureUnit=class{constructor(e,t){this._mode=0,this._bind2D=null,this._bindCube=null,this._ctx=e,this._idx=t}},WebGLVertexArrayObjectAttribute=class{constructor(e,t){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=0,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0,this._ctx=e,this._idx=t,this._pointerType=e.FLOAT,this._clear()}_clear(){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=this._ctx.FLOAT,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0}},WebGLVertexArrayGlobalAttribute=class{constructor(e){this._idx=0,this._idx=e,this._data=new Float32Array([0,0,0,1])}},WebGLVertexArrayObjectState=class{constructor(e){this._elementArrayBufferBinding=null;let t=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:t});for(let n=0;n<t;++n)this._attribs[n]=new WebGLVertexArrayObjectAttribute(e,n);this._elementArrayBufferBinding=null}setElementArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setElementArrayBuffer(WebGLBuffer?)`);let t=this._elementArrayBufferBinding;t!==e&&(t&&(--t._refCount,t._checkDelete()),e&&(e._refCount+=1),this._elementArrayBufferBinding=e)}cleanUp(){let e=this._elementArrayBufferBinding;e&&(--e._refCount,e._checkDelete(),this._elementArrayBufferBinding=null);for(let e=0;e<this._attribs.length;++e){let t=this._attribs[e];t._pointerBuffer&&(--t._pointerBuffer._refCount,t._pointerBuffer._checkDelete()),t._clear()}}releaseArrayBuffer(e){if(e)for(let t=0;t<this._attribs.length;++t){let n=this._attribs[t];n._pointerBuffer===e&&(--n._pointerBuffer._refCount,n._pointerBuffer._checkDelete(),n._clear())}}setVertexAttribPointer(e,t,n,r,i,o,s,c,l){let u=this._attribs[t];e!==u._pointerBuffer&&(u._pointerBuffer&&(--u._pointerBuffer._refCount,u._pointerBuffer._checkDelete()),e&&(e._refCount+=1),u._pointerBuffer=e),u._pointerSize=n,u._pointerOffset=r,u._pointerStride=i,u._pointerType=o,u._pointerNormal=s,u._inputStride=c,u._inputSize=l}},WebGLVertexArrayGlobalState=class{constructor(e){this._arrayBufferBinding=null;let t=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:t});for(let e=0;e<t;++e)this._attribs[e]=new WebGLVertexArrayGlobalAttribute(e);this._arrayBufferBinding=null}setArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setArrayBuffer(WebGLBuffer?)`);let t=this._arrayBufferBinding;t!==e&&(t&&(--t._refCount,t._checkDelete()),e&&(e._refCount+=1),this._arrayBufferBinding=e)}},Rr=l;function gbytesToUint8Array(e){return e.toArray()}var zr,Br=__esmMin(()=>{zr=r}),Vr,Hr=__esmMin(()=>{Br(),Vr=zr});Vn(),Hr();async function readBytesAsync(e,t=4096,n=Bn.PRIORITY_DEFAULT,r=null){return new Promise((i,o)=>{e.read_bytes_async(t,n,r,(t,n)=>{try{let t=e.read_bytes_finish(n);return t.get_size()===0?i(null):i(gbytesToUint8Array(t))}catch(e){let t=e;if(typeof t.matches==`function`&&(t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.PARTIAL_INPUT)||t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.CONNECTION_CLOSED)||t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.BROKEN_PIPE)||t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.CLOSED)))return i(null);o(e)}})})}async function*inputStreamAsyncIterator(e,t=4096,n=Bn.PRIORITY_DEFAULT,r=null){let i;for(;(i=await readBytesAsync(e,t,n,r))!==null;)yield i}ie();let Ur=0;const Wr={oes_element_index_uint:getOESElementIndexUint,oes_texture_float:getOESTextureFloat,oes_texture_float_linear:getOESTextureFloatLinear,oes_standard_derivatives:getOESStandardDerivatives,stackgl_destroy_context:getSTACKGLDestroyContext,stackgl_resize_drawingbuffer:getSTACKGLResizeDrawingBuffer,ext_blend_minmax:getEXTBlendMinMax,ext_color_buffer_float:getEXTColorBufferFloat,ext_color_buffer_half_float:getEXTColorBufferHalfFloat,ext_texture_filter_anisotropic:getEXTTextureFilterAnisotropic,oes_texture_half_float:getOESTextureHalfFloat,webgl_debug_renderer_info:getWEBGLDebugRendererInfo};var WebGLContextBase=class{get drawingBufferHeight(){return this.canvas.height||0}get drawingBufferWidth(){return this.canvas.width||0}constructor(e,t={}){this.drawingBufferColorSpace=`srgb`,this.unpackColorSpace=`srgb`,this.RGBA8=32856,this.DEFAULT_ATTACHMENTS=[],this.DEFAULT_COLOR_ATTACHMENTS=[],this._=0,this._extensions={},this._programs={},this._shaders={},this._textures={},this._framebuffers={},this._renderbuffers={},this._buffers={},this._activeProgram=null,this._activeFramebuffer=null,this._activeRenderbuffer=null,this._checkStencil=!1,this._stencilState=!0,this._activeTextureUnit=0,this._errorStack=[],this._maxTextureSize=0,this._maxTextureLevel=0,this._maxCubeMapSize=0,this._maxCubeMapLevel=0,this._maxRenderbufferSize=0,this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this._viewport=new Int32Array([0,0,0,0]),this._scissorBox=new Int32Array([0,0,0,0]),this._gtkFboId=0,this._textureUnits=[],this._drawingBuffer=null,this.canvas=e,this._contextAttributes=new WebGLContextAttributes(flag(t,`alpha`,!0),flag(t,`depth`,!0),flag(t,`stencil`,!1),!1,flag(t,`premultipliedAlpha`,!0),flag(t,`preserveDrawingBuffer`,!1),flag(t,`preferLowPowerToHighPerformance`,!1),flag(t,`failIfMajorPerformanceCaveat`,!1)),this._contextAttributes.premultipliedAlpha=this._contextAttributes.premultipliedAlpha&&this._contextAttributes.alpha}_init(){let e=this._gl.getParameterx(36006);this._gtkFboId=e?.deepUnpack()|0,this._initGLConstants(),this.DEFAULT_ATTACHMENTS=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT],this.DEFAULT_COLOR_ATTACHMENTS=[this.COLOR_ATTACHMENT0];let t=this.drawingBufferWidth||0,n=this.drawingBufferHeight||0;this._=Ur++;let r=this.getParameter(this.MAX_COMBINED_TEXTURE_IMAGE_UNITS);this._textureUnits=Array.from({length:r});for(let e=0;e<r;++e)this._textureUnits[e]=new WebGLTextureUnit(this,e);this.activeTexture(this.TEXTURE0),this._defaultVertexObjectState=new WebGLVertexArrayObjectState(this),this._vertexObjectState=this._defaultVertexObjectState,this._vertexGlobalState=new WebGLVertexArrayGlobalState(this),this._maxTextureSize=this.getParameter(this.MAX_TEXTURE_SIZE),this._maxTextureLevel=xr.log2(xr.nextPow2(this._maxTextureSize)),this._maxCubeMapSize=this.getParameter(this.MAX_CUBE_MAP_TEXTURE_SIZE),this._maxCubeMapLevel=xr.log2(xr.nextPow2(this._maxCubeMapSize)),this._maxRenderbufferSize=this.getParameter(this.MAX_RENDERBUFFER_SIZE),this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this.bindBuffer(this.ARRAY_BUFFER,null),this.bindBuffer(this.ELEMENT_ARRAY_BUFFER,null),this.bindFramebuffer(this.FRAMEBUFFER,null),this.bindRenderbuffer(this.RENDERBUFFER,null),this.viewport(0,0,t,n),this.scissor(0,0,t,n),this.clearDepth(1),this.clearColor(0,0,0,0),this.clearStencil(0),this.clear(this.COLOR_BUFFER_BIT|this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),this.disable(this.DEPTH_TEST),this.disable(this.STENCIL_TEST),this.disable(this.BLEND),this.disable(this.CULL_FACE),this.disable(this.POLYGON_OFFSET_FILL),this.disable(this.SCISSOR_TEST),this._gl.colorMask(!0,!0,!0,!0)}_initGLConstants(){let e=new Rr.WebGLRenderingContextBase().get_webgl_constants();for(let[t,n]of Object.entries(e))Object.defineProperty(this,t,{value:n})}_getGlslVersion(e){return this._getGlsl1Version(e)}_getGlsl1Version(e){return e||this._atLeastGlVersion(4,1)?`100`:`120`}_desktopGlslVersion(){let e=this._gl.getString(35724);if(!e||e.startsWith(`OpenGL ES `))return`130`;let[t,n]=e.split(`.`,2).map(e=>Number.parseInt(e,10));return!Number.isFinite(t)||!Number.isFinite(n)?`130`:String(t*100+(n>=10?n:n*10))}_atLeastGlVersion(e,t){let n=this._gl.getString(7938);if(!n||n.startsWith(`OpenGL ES `))return!1;let[r,i]=n.split(`.`,2).map(e=>Number.parseInt(e,10));return!Number.isFinite(r)||!Number.isFinite(i)?!1:r>e||r===e&&i>=t}_checkOwns(e){return typeof e==`object`&&!!e&&e._ctx===this}_checkValid(e,t){return e instanceof t&&e._!==0}_checkWrapper(e,t){return this._checkValid(e,t)?this._checkOwns(e)?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)}_isObject(e,t,n){if(e!=null&&!(e instanceof n))throw TypeError(t+`(`+n.name+`)`);return!!(this._checkValid(e,n)&&this._checkOwns(e))}_checkStencilState(){return this._checkStencil?(this._checkStencil=!1,this._stencilState=!0,(this.getParameter(this.STENCIL_WRITEMASK)!==this.getParameter(this.STENCIL_BACK_WRITEMASK)||this.getParameter(this.STENCIL_VALUE_MASK)!==this.getParameter(this.STENCIL_BACK_VALUE_MASK)||this.getParameter(this.STENCIL_REF)!==this.getParameter(this.STENCIL_BACK_REF))&&(this.setError(this.INVALID_OPERATION),this._stencilState=!1),this._stencilState):this._stencilState}_validGLSLIdentifier(e){return!(e.indexOf(`webgl_`)===0||e.indexOf(`_webgl_`)===0||e.length>256)}_getParameterDirect(e){return this._gl.getParameterx(e)?.deepUnpack()}getContextAttributes(){return this._contextAttributes}getExtension(e){let t=e.toLowerCase();if(t in this._extensions)return this._extensions[t];let n=Wr[t]?Wr[t](this):null;return n&&(this._extensions[t]=n),n}getSupportedExtensions(){let e=[`ANGLE_instanced_arrays`,`STACKGL_resize_drawingbuffer`,`STACKGL_destroy_context`,`WEBGL_debug_renderer_info`],t=this._gl.getSupportedExtensions();return t?(t.indexOf(`GL_OES_element_index_uint`)>=0&&e.push(`OES_element_index_uint`),t.indexOf(`GL_OES_standard_derivatives`)>=0&&e.push(`OES_standard_derivatives`),t.indexOf(`GL_OES_texture_float`)>=0&&e.push(`OES_texture_float`),t.indexOf(`GL_OES_texture_float_linear`)>=0&&e.push(`OES_texture_float_linear`),(t.indexOf(`GL_OES_texture_half_float`)>=0||t.indexOf(`GL_ARB_half_float_pixel`)>=0)&&e.push(`OES_texture_half_float`),(t.indexOf(`GL_EXT_color_buffer_float`)>=0||t.indexOf(`GL_ARB_color_buffer_float`)>=0)&&e.push(`EXT_color_buffer_float`),t.indexOf(`GL_EXT_color_buffer_half_float`)>=0&&e.push(`EXT_color_buffer_half_float`),t.indexOf(`EXT_draw_buffers`)>=0&&e.push(`WEBGL_draw_buffers`),t.indexOf(`EXT_blend_minmax`)>=0&&e.push(`EXT_blend_minmax`),t.indexOf(`EXT_texture_filter_anisotropic`)>=0&&e.push(`EXT_texture_filter_anisotropic`),t.indexOf(`GL_OES_vertex_array_object`)>=0&&e.push(`OES_vertex_array_object`),e):e}getParameter(e=0){switch(e){case this.ARRAY_BUFFER_BINDING:return this._vertexGlobalState._arrayBufferBinding;case this.ELEMENT_ARRAY_BUFFER_BINDING:return this._vertexObjectState._elementArrayBufferBinding;case this.CURRENT_PROGRAM:return this._activeProgram;case this.FRAMEBUFFER_BINDING:return this._activeFramebuffer;case this.RENDERBUFFER_BINDING:return this._activeRenderbuffer;case this.TEXTURE_BINDING_2D:return this._getActiveTextureUnit()._bind2D;case this.TEXTURE_BINDING_CUBE_MAP:return this._getActiveTextureUnit()._bindCube;case this.VERSION:return`WebGL 1.0 0.0.1`;case this.VENDOR:return``;case this.RENDERER:return`ANGLE`;case 37445:return this._gl.getString(7936);case 37446:return this._gl.getString(7937);case this.SHADING_LANGUAGE_VERSION:return`WebGL GLSL ES 1.0 `;case this.COMPRESSED_TEXTURE_FORMATS:return new Uint32Array;case this.SCISSOR_BOX:return new Int32Array(this._scissorBox);case this.VIEWPORT:return new Int32Array(this._viewport);case this.MAX_VIEWPORT_DIMS:return new Int32Array([32767,32767]);case this.ALIASED_LINE_WIDTH_RANGE:case this.ALIASED_POINT_SIZE_RANGE:return new Float32Array([1,1]);case this.DEPTH_RANGE:return new Float32Array([0,1]);case this.BLEND_COLOR:case this.COLOR_CLEAR_VALUE:return new Float32Array(this._gl.getParameterfv(e,4));case this.COLOR_WRITEMASK:{let t=this._gl.getParameteriv(e,4);return[!!t[0],!!t[1],!!t[2],!!t[3]]}case this.DEPTH_CLEAR_VALUE:case this.LINE_WIDTH:case this.POLYGON_OFFSET_FACTOR:case this.POLYGON_OFFSET_UNITS:case this.SAMPLE_COVERAGE_VALUE:return this._gl.getParameterf(e);case this.BLEND:case this.CULL_FACE:case this.DEPTH_TEST:case this.DEPTH_WRITEMASK:case this.DITHER:case this.POLYGON_OFFSET_FILL:case this.SAMPLE_COVERAGE_INVERT:case this.SCISSOR_TEST:case this.STENCIL_TEST:case this.UNPACK_PREMULTIPLY_ALPHA_WEBGL:return!!this._gl.getParameteri(e);case this.UNPACK_FLIP_Y_WEBGL:return this._unpackFlipY;case this.ACTIVE_TEXTURE:case this.ALPHA_BITS:case this.BLEND_DST_ALPHA:case this.BLEND_DST_RGB:case this.BLEND_EQUATION_ALPHA:case this.BLEND_EQUATION_RGB:case this.BLEND_SRC_ALPHA:case this.BLEND_SRC_RGB:case this.BLUE_BITS:case this.CULL_FACE_MODE:case this.DEPTH_BITS:case this.DEPTH_FUNC:case this.FRONT_FACE:case this.GENERATE_MIPMAP_HINT:case this.GREEN_BITS:return this._gl.getParameteri(e);case this.MAX_RENDERBUFFER_SIZE:return this._maxRenderbufferSize;case this.MAX_COMBINED_TEXTURE_IMAGE_UNITS:case this.MAX_CUBE_MAP_TEXTURE_SIZE:case this.MAX_FRAGMENT_UNIFORM_VECTORS:case this.MAX_TEXTURE_IMAGE_UNITS:case this.MAX_TEXTURE_SIZE:case this.MAX_VARYING_VECTORS:case this.MAX_VERTEX_ATTRIBS:case this.MAX_VERTEX_TEXTURE_IMAGE_UNITS:case this.MAX_VERTEX_UNIFORM_VECTORS:case this.PACK_ALIGNMENT:case this.RED_BITS:case this.SAMPLE_BUFFERS:case this.SAMPLES:case this.STENCIL_BACK_FAIL:case this.STENCIL_BACK_FUNC:case this.STENCIL_BACK_PASS_DEPTH_FAIL:case this.STENCIL_BACK_PASS_DEPTH_PASS:case this.STENCIL_BACK_REF:case this.STENCIL_BACK_VALUE_MASK:case this.STENCIL_BACK_WRITEMASK:case this.STENCIL_BITS:case this.STENCIL_CLEAR_VALUE:case this.STENCIL_FAIL:case this.STENCIL_FUNC:case this.STENCIL_PASS_DEPTH_FAIL:case this.STENCIL_PASS_DEPTH_PASS:case this.STENCIL_REF:case this.STENCIL_VALUE_MASK:case this.STENCIL_WRITEMASK:case this.SUBPIXEL_BITS:case this.UNPACK_ALIGNMENT:case this.UNPACK_COLORSPACE_CONVERSION_WEBGL:return this._gl.getParameteri(e);case this.IMPLEMENTATION_COLOR_READ_FORMAT:case this.IMPLEMENTATION_COLOR_READ_TYPE:return this._getParameterDirect(e);default:if(this._extensions.webgl_draw_buffers){let t=this._extensions.webgl_draw_buffers;switch(e){case t.DRAW_BUFFER0_WEBGL:case t.DRAW_BUFFER1_WEBGL:case t.DRAW_BUFFER2_WEBGL:case t.DRAW_BUFFER3_WEBGL:case t.DRAW_BUFFER4_WEBGL:case t.DRAW_BUFFER5_WEBGL:case t.DRAW_BUFFER6_WEBGL:case t.DRAW_BUFFER7_WEBGL:case t.DRAW_BUFFER8_WEBGL:case t.DRAW_BUFFER9_WEBGL:case t.DRAW_BUFFER10_WEBGL:case t.DRAW_BUFFER11_WEBGL:case t.DRAW_BUFFER12_WEBGL:case t.DRAW_BUFFER13_WEBGL:case t.DRAW_BUFFER14_WEBGL:case t.DRAW_BUFFER15_WEBGL:return t._buffersState.length===1&&t._buffersState[0]===this.BACK?this.BACK:this._getParameterDirect(e);case t.MAX_DRAW_BUFFERS_WEBGL:case t.MAX_COLOR_ATTACHMENTS_WEBGL:return this._getParameterDirect(e)}}let t=this._extensions.oes_standard_derivatives;if(t&&e===t.FRAGMENT_SHADER_DERIVATIVE_HINT_OES)return this._getParameterDirect(e);let n=this._extensions.ext_texture_filter_anisotropic;if(n&&e===n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)return this._getParameterDirect(e);let r=this._extensions.oes_vertex_array_object;return r&&e===r.VERTEX_ARRAY_BINDING_OES?r._activeVertexArrayObject:(this.setError(this.INVALID_ENUM),null)}}destroy(){warnNotImplemented(`destroy`)}};installAllContextMethods(WebGLContextBase.prototype);var WebGLRenderingContext$1=class extends WebGLContextBase{static{__name$1(this,`WebGLRenderingContext`)}get _gl(){return this._native}constructor(e,t={}){super(e,t),this._attrib0Buffer=null,this._native=new Rr.WebGLRenderingContext({}),this._init();let n=this.createBuffer();this._attrib0Buffer=n}_beginAttrib0Hack(){this._native.bindBuffer(this.ARRAY_BUFFER,this._attrib0Buffer?._||0);let e=new Uint8Array(this._vertexGlobalState._attribs[0]._data.buffer);this._native.bufferData(this.ARRAY_BUFFER,Uint8ArrayToVariant(e),this.STREAM_DRAW),this._native.enableVertexAttribArray(0),this._native.vertexAttribPointer(0,4,this.FLOAT,!1,0,0),this._native._vertexAttribDivisor(0,1)}_endAttrib0Hack(){let e=this._vertexObjectState._attribs[0];e._pointerBuffer?this._native.bindBuffer(this.ARRAY_BUFFER,e._pointerBuffer._):this._native.bindBuffer(this.ARRAY_BUFFER,0),this._native.vertexAttribPointer(0,e._inputSize,e._pointerType,e._pointerNormal,e._inputStride,e._pointerOffset),this._native._vertexAttribDivisor(0,e._divisor),this._native.disableVertexAttribArray(0),this._vertexGlobalState._arrayBufferBinding?this._native.bindBuffer(this.ARRAY_BUFFER,this._vertexGlobalState._arrayBufferBinding._):this._native.bindBuffer(this.ARRAY_BUFFER,0)}drawArrays(e=0,t=0,n=0){if(t<0||n<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let r=vertexCount(this,e,n);if(r<0){this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||n===0)return;let i=t;if(n>0&&(i=n+t-1>>>0),this._checkVertexAttribState(i)){let n=this._extensions.webgl_draw_buffers;if(this._vertexObjectState._attribs[0]._isPointer||n&&n._buffersState&&n._buffersState.length>0)return this._native.drawArrays(e,t,r);this._beginAttrib0Hack(),this._native._drawArraysInstanced(e,t,r,1),this._endAttrib0Hack()}}drawElements(e=0,t=0,n=0,r=0){if(t<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=this._vertexObjectState._elementArrayBufferBinding;if(!i){this.setError(this.INVALID_OPERATION);return}let o=null,s=r;if(n===this.UNSIGNED_SHORT){if(s%2){this.setError(this.INVALID_OPERATION);return}s>>=1,o=new Uint16Array(i._elements.buffer)}else if(this._extensions.oes_element_index_uint&&n===this.UNSIGNED_INT){if(s%4){this.setError(this.INVALID_OPERATION);return}s>>=2,o=new Uint32Array(i._elements.buffer)}else if(n===this.UNSIGNED_BYTE)o=i._elements;else{this.setError(this.INVALID_ENUM);return}let c=t;switch(e){case this.TRIANGLES:t%3&&(c-=t%3);break;case this.LINES:t%2&&(c-=t%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(t<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(t<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(t===0){this._checkVertexAttribState(0);return}if(t+s>>>0>o.length){this.setError(this.INVALID_OPERATION);return}let l=-1;for(let e=s;e<s+t;++e)l=Math.max(l,o[e]);if(l<0){this._checkVertexAttribState(0);return}if(this._checkVertexAttribState(l)&&c>0){if(this._vertexObjectState._attribs[0]._isPointer)return this._native.drawElements(e,c,n,r);this._beginAttrib0Hack(),this._native._drawElementsInstanced(e,c,n,r,1),this._endAttrib0Hack()}}},WebGLQuery=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._queries[this._|0],e._native2.deleteQuery(this._|0)}},WebGLSampler=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._samplers[this._|0],e._native2.deleteSampler(this._|0)}},WebGLSync=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._syncs[this._|0],e._native2.deleteSync(this._|0)}},WebGLTransformFeedback=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._transformFeedbacks[this._|0],e._native2.deleteTransformFeedback(this._|0)}},WebGLVertexArrayObject=class extends Linkable{constructor(e,t){super(e),this._ctx=t,this._objectState=new WebGLVertexArrayObjectState(t)}_performDelete(){let e=this._ctx;e._vertexObjectState===this._objectState&&(e._vertexObjectState=e._defaultVertexObjectState),this._objectState.cleanUp(),delete e._vertexArrayObjects[this._|0],e._native2.deleteVertexArray(this._|0)}};ie();const Gr={createVertexArray(){let e=this._native2.createVertexArray();if(!e)return null;let t=new WebGLVertexArrayObject(e,this);return this._vertexArrayObjects[e]=t,t},deleteVertexArray(e){!e||!(e instanceof WebGLVertexArrayObject)||(e._pendingDelete=!0,e._checkDelete())},isVertexArray(e){return!e||!(e instanceof WebGLVertexArrayObject)?!1:this._native2.isVertexArray(e._)},bindVertexArray(e){e===null?(this._native2.bindVertexArray(0),this._vertexObjectState=this._defaultVertexObjectState):e instanceof WebGLVertexArrayObject?(this._native2.bindVertexArray(e._),this._vertexObjectState=e._objectState):this.setError(this.INVALID_OPERATION)},createQuery(){let e=this._native2.createQuery();if(!e)return null;let t=new WebGLQuery(e,this);return this._queries[e]=t,t},deleteQuery(e){!e||!(e instanceof WebGLQuery)||(e._pendingDelete=!0,e._checkDelete())},isQuery(e){return!e||!(e instanceof WebGLQuery)?!1:this._native2.isQuery(e._)},beginQuery(e,t){t instanceof WebGLQuery&&this._native2.beginQuery(e,t._)},endQuery(e){this._native2.endQuery(e)},getQuery(e,t){return warnNotImplemented(`WebGL2RenderingContext.getQuery`),null},getQueryParameter(e,t){return e instanceof WebGLQuery?this._native2.getQueryParameter(e._,t):null},createSampler(){let e=this._native2.createSampler();if(!e)return null;let t=new WebGLSampler(e,this);return this._samplers[e]=t,t},deleteSampler(e){!e||!(e instanceof WebGLSampler)||(e._pendingDelete=!0,e._checkDelete())},isSampler(e){return!e||!(e instanceof WebGLSampler)?!1:this._native2.isSampler(e._)},bindSampler(e,t){this._native2.bindSampler(e,t?t._:0)},samplerParameteri(e,t,n){e instanceof WebGLSampler&&this._native2.samplerParameteri(e._,t,n)},samplerParameterf(e,t,n){e instanceof WebGLSampler&&this._native2.samplerParameterf(e._,t,n)},getSamplerParameter(e,t){return e instanceof WebGLSampler?t===33082||t===33083?this._native2.getSamplerParameterf(e._,t):this._native2.getSamplerParameteri(e._,t):null},fenceSync(e,t){let n=this._native2.fenceSync(e,t);if(!n)return null;let r=new WebGLSync(n,this);return this._syncs[n]=r,r},isSync(e){return!e||!(e instanceof WebGLSync)?!1:this._native2.isSync(e._)},deleteSync(e){!e||!(e instanceof WebGLSync)||(e._pendingDelete=!0,e._checkDelete())},clientWaitSync(e,t,n){return e instanceof WebGLSync?this._native2.clientWaitSync(e._,t,n):37148},waitSync(e,t,n){e instanceof WebGLSync&&this._native2.waitSync(e._,t,n)},getSyncParameter(e,t){return e instanceof WebGLSync?this._native2.getSyncParameter(e._,t):null},createTransformFeedback(){let e=this._native2.createTransformFeedback();if(!e)return null;let t=new WebGLTransformFeedback(e,this);return this._transformFeedbacks[e]=t,t},deleteTransformFeedback(e){!e||!(e instanceof WebGLTransformFeedback)||(e._pendingDelete=!0,e._checkDelete())},isTransformFeedback(e){return!e||!(e instanceof WebGLTransformFeedback)?!1:this._native2.isTransformFeedback(e._)},bindTransformFeedback(e,t){this._native2.bindTransformFeedback(e,t?t._:0)},beginTransformFeedback(e){this._native2.beginTransformFeedback(e)},endTransformFeedback(){this._native2.endTransformFeedback()},pauseTransformFeedback(){this._native2.pauseTransformFeedback()},resumeTransformFeedback(){this._native2.resumeTransformFeedback()},transformFeedbackVaryings(e,t,n){this._native2.transformFeedbackVaryings(e._,t,n)},getTransformFeedbackVarying(e,t){let n=this._native2.getTransformFeedbackVarying(e._,t).deepUnpack();return new WebGLActiveInfo({size:n.size,type:n.type,name:n.name})}};function installObjectLifecycleMethods(e){Object.assign(e,Gr)}const Kr={texImage3D(e,t,n,r,i,o,s,c,l,u){u===null?this._native2.texImage3DNull(e,t,n,r,i,o,s,c,l):this._native2.texImage3D(e,t,n,r,i,o,s,c,l,Uint8ArrayToVariant(new Uint8Array(u.buffer,u.byteOffset,u.byteLength)))},texSubImage3D(e,t,n,r,i,o,s,c,l,u,d){d!==null&&this._native2.texSubImage3D(e,t,n,r,i,o,s,c,l,u,Uint8ArrayToVariant(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)))},compressedTexImage3D(e,t,n,r,i,o,s,c,l){this._native2.compressedTexImage3D(e,t,n,r,i,o,s,Uint8ArrayToVariant(new Uint8Array(l.buffer,l.byteOffset,l.byteLength)))},compressedTexSubImage3D(e,t,n,r,i,o,s,c,l,u,d){this._native2.compressedTexSubImage3D(e,t,n,r,i,o,s,c,l,Uint8ArrayToVariant(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)))},copyTexSubImage3D(e,t,n,r,i,o,s,c,l){this._native2.copyTexSubImage3D(e,t,n,r,i,o,s,c,l)},texStorage2D(e,t,n,r,i){this._native2.texStorage2D(e,t,n,r,i);let o=this._getTexImage(e);if(o){for(let e=0;e<t;e++)o._levelWidth[e]=Math.max(1,r>>e),o._levelHeight[e]=Math.max(1,i>>e);o._format=this.RGBA,o._type=this.UNSIGNED_BYTE}},texStorage3D(e,t,n,r,i,o){this._native2.texStorage3D(e,t,n,r,i,o)}};function installTexImage3DMethods(e){Object.assign(e,Kr)}const qr={uniform1ui(e,t){e&&this._native2.uniform1ui(e._,t)},uniform2ui(e,t,n){e&&this._native2.uniform2ui(e._,t,n)},uniform3ui(e,t,n,r){e&&this._native2.uniform3ui(e._,t,n,r)},uniform4ui(e,t,n,r,i){e&&this._native2.uniform4ui(e._,t,n,r,i)},uniform1uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform1uiv(e._,i.length,i)},uniform2uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform2uiv(e._,i.length/2,i)},uniform3uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform3uiv(e._,i.length/3,i)},uniform4uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform4uiv(e._,i.length/4,i)},uniformMatrix2x3fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix2x3fv(e._,t,o)},uniformMatrix3x2fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix3x2fv(e._,t,o)},uniformMatrix2x4fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix2x4fv(e._,t,o)},uniformMatrix4x2fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix4x2fv(e._,t,o)},uniformMatrix3x4fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix3x4fv(e._,t,o)},uniformMatrix4x3fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix4x3fv(e._,t,o)}};function installUniformMethods(e){Object.assign(e,qr)}const Jr={clearBufferfv(e,t,n,r){let i=this._native2;if(typeof i.clearBufferfv==`function`){i.clearBufferfv(e,t,Array.from(n));return}let o=n;if(e===6144){let e=this.getParameter(this.COLOR_CLEAR_VALUE);this.clearColor(o[0]??0,o[1]??0,o[2]??0,o[3]??0),this.clear(this.COLOR_BUFFER_BIT),e&&this.clearColor(e[0],e[1],e[2],e[3])}else if(e===6145){let e=this.getParameter(this.DEPTH_CLEAR_VALUE);this.clearDepth(o[0]??1),this.clear(this.DEPTH_BUFFER_BIT),e!==null&&this.clearDepth(e)}},clearBufferiv(e,t,n,r){let i=this._native2;if(typeof i.clearBufferiv==`function`){i.clearBufferiv(e,t,Array.from(n));return}if(e===6146){let e=n,t=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearStencil(e[0]??0),this.clear(this.STENCIL_BUFFER_BIT),t!==null&&this.clearStencil(t)}},clearBufferuiv(e,t,n,r){let i=this._native2;if(typeof i.clearBufferuiv==`function`){i.clearBufferuiv(e,t,Array.from(n));return}},clearBufferfi(e,t,n,r){let i=this._native2;if(typeof i.clearBufferfi==`function`){i.clearBufferfi(e,t,n,r);return}if(e===34041){let e=this.getParameter(this.DEPTH_CLEAR_VALUE),t=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearDepth(n),this.clearStencil(r),this.clear(this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),e!==null&&this.clearDepth(e),t!==null&&this.clearStencil(t)}}};function installClearBufferMethods(e){Object.assign(e,Jr)}re();function debugGlEnabled(){return globalThis.__GJSIFY_DEBUG_GL===!0}const Yr={drawArraysInstanced(e,t,n,r){if(t<0||n<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=vertexCount(this,e,n);if(i<0){this.setError(this.INVALID_ENUM);return}if(this._framebufferOk()&&!(n===0||r===0)&&this._checkVertexAttribState(n+t-1>>>0)){if(debugGlEnabled()){let e=this,t=e.__drawInstCount=(e.__drawInstCount|0)+1;(t<=5||t%100==0)&&M.log(`[WebGL] drawArraysInstanced #${t} count=${i} instances=${r} fbo=${this._activeFramebuffer?._??`_gtkFbo`}`)}this._native2.drawArraysInstanced(e,t,i,r)}},drawElementsInstanced(e,t,n,r,i){if(t<0||r<0||i<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let o=this._vertexObjectState._elementArrayBufferBinding;if(!o){this.setError(this.INVALID_OPERATION);return}let s=null,c=r;if(n===this.UNSIGNED_SHORT){if(c%2){this.setError(this.INVALID_OPERATION);return}c>>=1,s=new Uint16Array(o._elements.buffer)}else if(n===this.UNSIGNED_INT){if(c%4){this.setError(this.INVALID_OPERATION);return}c>>=2,s=new Uint32Array(o._elements.buffer)}else if(n===this.UNSIGNED_BYTE)s=o._elements;else{this.setError(this.INVALID_ENUM);return}let l=t;switch(e){case this.TRIANGLES:t%3&&(l-=t%3);break;case this.LINES:t%2&&(l-=t%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(t<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(t<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(l===0||i===0){this._checkVertexAttribState(0);return}if(l+c>>>0>s.length){this.setError(this.INVALID_OPERATION);return}let u=0;for(let e=c;e<c+l;++e)s[e]>u&&(u=s[e]);this._checkVertexAttribState(u)&&this._native2.drawElementsInstanced(e,l,n,r,i)},vertexAttribDivisor(e,t){this._checkVertexIndex(e)&&(this._native2.vertexAttribDivisor(e,t),this._vertexObjectState._attribs[e]._divisor=t)},vertexAttribIPointer(e,t,n,r,i){this._native2.vertexAttribIPointer(e,t,n,r,i)},drawBuffers(e){let t=!1;for(let n=0;n<e.length;n++)if(e[n]===1029){t=!0;break}if(!t){this._native2.drawBuffers(e);return}this._native2.drawBuffers(e.map(e=>e===1029?this.COLOR_ATTACHMENT0:e))},drawRangeElements(e,t,n,r,i,o){if(r<0||o<0){this.setError(this.INVALID_VALUE);return}if(n<t){this.setError(this.INVALID_VALUE);return}this.drawElements(e,r,i,o)},blitFramebuffer(e,t,n,r,i,o,s,c,l,u){if(debugGlEnabled()){let e=this._gl.getError();e!==0&&M.log(`[WebGL] blitFramebuffer PRE-ERROR 0x${e.toString(16)}`)}if(this._native2.blitFramebuffer(e,t,n,r,i,o,s,c,l,u),debugGlEnabled()){let i=this._gl.getError(),o=this,s=o.__blitCount=(o.__blitCount|0)+1;s<=5&&M.log(`[WebGL] blitFramebuffer #${s} src=(${e},${t},${n},${r}) readFbo=${this._activeReadFramebuffer?._??`_gtkFbo`} err=${i===0?`OK`:`0x`+i.toString(16)}`)}},framebufferTextureLayer(e,t,n,r,i){this._native2.framebufferTextureLayer(e,t,n?n._:0,r,i)},invalidateFramebuffer(e,t){this._native2.invalidateFramebuffer(e,t)},invalidateSubFramebuffer(e,t,n,r,i,o){this._native2.invalidateSubFramebuffer(e,t,n,r,i,o)},readBuffer(e){this._native2.readBuffer(e)},renderbufferStorageMultisample(e,t,n,r,i){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let o=this._activeRenderbuffer;if(!o){this.setError(this.INVALID_OPERATION);return}this._saveError(),this._native2.renderbufferStorageMultisample(e,t,n,r,i);let s=this.getError();this._restoreError(s),s===this.NO_ERROR&&(o._width=r,o._height=i,o._format=n)}};function installInstancedAndFramebufferOpsMethods(e){Object.assign(e,Yr)}ie();var Xr=class WebGL2RenderingContext extends WebGLContextBase{get _gl(){return this._native2}constructor(e,t={}){super(e,t),this._queries={},this._samplers={},this._transformFeedbacks={},this._vertexArrayObjects={},this._syncs={},this._activeReadFramebuffer=null,this._activeDrawFramebuffer=null,this._native2=new Rr.WebGL2RenderingContext({}),this._init()}_getGlslVersion(e){return e?`300 es`:this._desktopGlslVersion()}_validFramebufferAttachment(e){return super._validFramebufferAttachment(e)?!0:e>=36065&&e<=36079}static{this._WGL2_ALL_COLOR_ATTACHMENTS=[36064,36065,36066,36067,36068,36069,36070,36071,36072,36073,36074,36075,36076,36077,36078,36079]}_getColorAttachments(){return WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS}_preCheckFramebufferStatus(e){let t=e._attachments,n=0,r=0,i=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT,...WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS];for(let o of i){let i=t[o];if(i){if(i instanceof WebGLTexture){let t=e._attachmentLevel[o]??0,s=i._levelWidth[t]??0,c=i._levelHeight[t]??0;if(s>0&&c>0){n=s,r=c;break}}else if(i instanceof WebGLRenderbuffer&&i._width>0&&i._height>0){n=i._width,r=i._height;break}}}return n>0&&r>0?(e._width=n,e._height=r,this.FRAMEBUFFER_COMPLETE):this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT}_updateFramebufferAttachments(e){if(super._updateFramebufferAttachments(e),e)for(let t=1;t<=15;t++){let n=36064+t;if(!(n in e._attachments))continue;let r=e._attachments[n];if(r instanceof WebGLTexture){let t=e._attachmentFace[n]||this.TEXTURE_2D,i=e._attachmentLevel[n]??0;this._gl.framebufferTexture2D(this.FRAMEBUFFER,n,t,r._|0,i|0)}else r instanceof WebGLRenderbuffer?this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,n,this.RENDERBUFFER,r._|0):this._gl.framebufferTexture2D(this.FRAMEBUFFER,n,this.TEXTURE_2D,0,0)}}bindBuffer(e,t){if(e===35345||e===35982||e===36662||e===36663){let n=t?t._|0:0;this._gl.bindBuffer(e,n);return}super.bindBuffer(e,t)}bindFramebuffer(e,t){if(e===36008||e===36009){if(!checkObject(t))throw TypeError(`bindFramebuffer(GLenum, WebGLFramebuffer)`);if(t&&t._pendingDelete||t&&!this._checkWrapper(t,WebGLFramebuffer))return;let n=t?t._|0:this._gtkFboId;if(this._gl.bindFramebuffer(e,n),e===36008){let e=this._activeReadFramebuffer;e!==t&&(e&&(--e._refCount,e._checkDelete()),t&&(t._refCount+=1)),this._activeReadFramebuffer=t}else{let e=this._activeDrawFramebuffer;e!==t&&(e&&(--e._refCount,e._checkDelete()),t&&(t._refCount+=1)),this._activeDrawFramebuffer=t,this._activeFramebuffer=t}return}super.bindFramebuffer(this.FRAMEBUFFER,t),this._activeReadFramebuffer=t,this._activeDrawFramebuffer=t}deleteFramebuffer(e){this._activeReadFramebuffer===e&&this.bindFramebuffer(36008,null),this._activeDrawFramebuffer===e&&this.bindFramebuffer(36009,null),super.deleteFramebuffer(e)}bufferData(e,t,n){let r=e===35345||e===35982||e===36662||e===36663,i=n===35041||n===35043||n===35045||n===35042||n===35044||n===35046?this.STATIC_DRAW:n;if(r){if(typeof t==`number`)t>=0&&this._gl.bufferDataSizeOnly(e,t,i);else if(typeof t==`object`&&t){let n=arrayToUint8Array(t);this._gl.bufferData(e,Uint8ArrayToVariant(n),i)}return}super.bufferData(e,t,i)}bufferSubData(e,t,n){if(e===35345||e===35982||e===36662||e===36663){if(t<0){this.setError(this.INVALID_VALUE);return}if(!n){this.setError(this.INVALID_VALUE);return}let r=arrayToUint8Array(n);this._gl.bufferSubData(e,t,Uint8ArrayToVariant(r));return}super.bufferSubData(e,t,n)}bindTexture(e,t){if(e===32879||e===35866){let n=t,r=n?n._|0:0;this._gl.bindTexture(e,r),n&&(n._binding=e);return}super.bindTexture(e,t)}texParameteri(e,t,n){if(e===32879||e===35866){this._gl.texParameteri(e,t,n);return}if(t===32882||t===34892||t===34893||t===33084||t===33085||t===33083||t===33082){this._gl.texParameteri(e,t,n);return}super.texParameteri(e,t,n)}drawArrays(e,t,n){if(t<0||n<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let r=vertexCount(this,e,n);if(r<0){this.setError(this.INVALID_ENUM);return}this._framebufferOk()&&n!==0&&this._checkVertexAttribState(n+t-1>>>0)&&this._native2.drawArrays(e,t,r)}drawElements(e=0,t=0,n=0,r=0){if(t<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=this._vertexObjectState._elementArrayBufferBinding;if(!i){this.setError(this.INVALID_OPERATION);return}let o=null,s=r;if(n===this.UNSIGNED_SHORT){if(s%2){this.setError(this.INVALID_OPERATION);return}s>>=1,o=new Uint16Array(i._elements.buffer)}else if(n===this.UNSIGNED_INT){if(s%4){this.setError(this.INVALID_OPERATION);return}s>>=2,o=new Uint32Array(i._elements.buffer)}else if(n===this.UNSIGNED_BYTE)o=i._elements;else{this.setError(this.INVALID_ENUM);return}let c=t;switch(e){case this.TRIANGLES:t%3&&(c-=t%3);break;case this.LINES:t%2&&(c-=t%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(t<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(t<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||t===0)return;let l=0;for(let e=s;e<s+c;++e)e<o.length&&o[e]>l&&(l=o[e]);this._checkVertexAttribState(l)&&this._native2.drawElements(e,c,n,r)}bindBufferBase(e,t,n){this._native2.bindBufferBase(e,t,n?n._:0)}bindBufferRange(e,t,n,r,i){this._native2.bindBufferRange(e,t,n?n._:0,r,i)}copyBufferSubData(e,t,n,r,i){this._native2.copyBufferSubData(e,t,n,r,i)}getBufferSubData(e,t,n,r,i){let o=i===void 0?n.byteLength-(r??0):i,s=this._native2.getBufferSubData(e,t,o),c=new Uint8Array(n.buffer,n.byteOffset+(r??0)*(n instanceof Uint8Array?1:n.BYTES_PER_ELEMENT??1));c.set(s.subarray(0,c.byteLength))}texImage2D(e=0,t=0,n=0,r=0,i=0,o=0,c=0,l=0,u){let d=0,f=0,p=0,m=0;if(arguments.length===6)if(l=i,p=r,o instanceof s.Pixbuf){let e=o;d=e.get_width(),f=e.get_height(),u=e.get_pixels()}else{let e=extractImageData(o);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);d=e.width,f=e.height,u=e.data}else arguments.length>=9&&(d=r,f=i,m=o,p=c);let h=this._getTexImage(e);if(!h){this.setError(this.INVALID_OPERATION);return}let g=convertPixels(u);if(this._unpackPremultAlpha&&g&&p===this.RGBA&&(g=premultiplyAlpha(g)),this._unpackFlipY&&g&&d>0&&f>0){let e=this._computePixelSize(l,p);if(e>0){let t=this._computeRowStride(d,e),n=new Uint8Array(g.length);for(let e=0;e<f;e++){let r=e*t,i=(f-1-e)*t;n.set(g.subarray(r,r+t),i)}g=n}}this._saveError(),this._gl.texImage2D(e,t,n,d,f,m,p,l,Uint8ArrayToVariant(g));let _=this.getError();if(this._restoreError(_),_!==this.NO_ERROR)return;h._levelWidth[t]=d,h._levelHeight[t]=f,h._format=p,h._type=l;let v=this._activeFramebuffer;if(v){let e=!1,t=this._getAttachments();for(let n=0;n<t.length;++n)if(v._attachments[t[n]]===h){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}}texSubImage2D(e=0,t=0,n=0,r=0,i=0,o=0,c=0,l=0,u){let d=0,f=0,p=0;if(arguments.length===7)if(l=o,p=i,c instanceof s.Pixbuf){let e=c;d=e.get_width(),f=e.get_height(),u=e.get_pixels()}else{let e=extractImageData(c);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);d=e.width,f=e.height,u=e.data}else d=i,f=o,p=c;if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}let m=convertPixels(u);if(!m){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&m&&p===this.RGBA&&(m=premultiplyAlpha(m)),this._unpackFlipY&&m&&d>0&&f>0){let e=this._computePixelSize(l,p);if(e>0){let t=this._computeRowStride(d,e),n=new Uint8Array(m.length);for(let e=0;e<f;e++){let r=e*t,i=(f-1-e)*t;n.set(m.subarray(r,r+t),i)}m=n}}this._gl.texSubImage2D(e,t,n,r,d,f,p,l,Uint8ArrayToVariant(m))}getUniform(e,t){let n=t?._activeInfo?.type,r=5125,i=36294,o=36295,s=n===r||n===i||n===o||n===36296,c=e;if(!s)return super.getUniform(c,t);if(!e||!t)return null;let l=this._native2.getUniformi(c._|0,t._|0);return l?n===r?l[0]>>>0:n===i?new Uint32Array([l[0]>>>0,l[1]>>>0]):n===o?new Uint32Array([l[0]>>>0,l[1]>>>0,l[2]>>>0]):new Uint32Array([l[0]>>>0,l[1]>>>0,l[2]>>>0,l[3]>>>0]):null}getUniformBlockIndex(e,t){return this._native2.getUniformBlockIndex(e._,t)}uniformBlockBinding(e,t,n){this._native2.uniformBlockBinding(e._,t,n)}getActiveUniformBlockName(e,t){let n=this._native2.getActiveUniformBlockName(e._,t);return n.length>0?n:null}getActiveUniformBlockParameter(e,t,n){return this._native2.getActiveUniformBlockParameter(e._,t,n)}getActiveUniforms(e,t,n){return this._native2.getActiveUniforms(e._,t,n)}getFragDataLocation(e,t){return this._native2.getFragDataLocation(e._,t)}getIndexedParameter(e,t){return this._native2.getIndexedParameteri(e,t)}getInternalformatParameter(e,t,n){return this._native2.getInternalformatParameter(e,t,n)}getParameter(e){if(e===7938)return`WebGL 2.0`;if(e===35724)return`WebGL GLSL ES 3.00`;if(e===7939)return warnNotImplemented(`WebGL2RenderingContext.getParameter(GL_EXTENSIONS)`),``;if(e===36006)return this._activeDrawFramebuffer;if(e===36010)return this._activeReadFramebuffer;switch(e){case 36183:case 35071:case 32883:case 36063:case 34852:case 36203:case 33001:case 33e3:case 37157:case 35373:case 35657:case 35077:case 35978:case 35979:case 35968:case 35376:case 35375:case 35659:case 37154:case 35371:case 35658:case 35379:case 35374:case 35377:case 35076:case 3330:case 3332:case 3331:case 35053:case 35055:case 3074:case 32874:case 35869:case 36389:case 35983:case 35368:case 35380:case 32878:case 3314:case 32877:case 3316:case 3315:case 34045:return this._native2.getParameterx(e)?.deepUnpack()|0;case 35977:case 36388:case 36387:return!!this._native2.getParameterx(e)?.deepUnpack()}return super.getParameter(e)}getStringi(e,t){let n=this._native2.getStringi(e,t);return n.length>0?n:null}renderbufferStorage(e,t,n,r){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let i=this._activeRenderbuffer;if(!i){this.setError(this.INVALID_OPERATION);return}if(n<0||r<0){this.setError(this.INVALID_VALUE);return}for(;this._gl.getError()!==this.NO_ERROR;);if(this._gl.renderbufferStorage(e,t,n,r),this._gl.getError()!==this.NO_ERROR)return;i._width=n,i._height=r,i._format=t;let o=this._activeFramebuffer;if(o){let e=this._getAttachments(),t=!1;for(let n=0;n<e.length;++n)if(o._attachments[e[n]]===i){t=!0;break}t&&this._updateFramebufferAttachments(o)}}getSupportedExtensions(){let e=super.getSupportedExtensions();for(let t of[`EXT_color_buffer_float`,`EXT_color_buffer_half_float`,`OES_texture_half_float`])e.indexOf(t)===-1&&e.push(t);return e}readPixels(e,t,n,r,i,o,s){if(!s)return;if(n<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._framebufferOk())return;let c=i===6408||i===32856?4:i===6407?3:i===33319?2:1,l=o===5126?4:o===5131||o===36193?2:o===5125||o===5124?4:o===5123||o===5122?2:1,u=n*r*c*l,d=new Uint8Array(u);this._saveError();let f=this._gl.readPixels(e,t,n,r,i,o,Uint8ArrayToVariant(d)),p=this.getError();if(this._restoreError(p),p!==this.NO_ERROR)return;let m=f&&f.length>0?f:d;if(s instanceof Uint8Array)s.set(m);else if(s instanceof Float32Array){let e=new Float32Array(m.buffer,0,s.length);s.set(e)}}_framebufferOk(){return!0}};installObjectLifecycleMethods(Xr.prototype),installTexImage3DMethods(Xr.prototype),installUniformMethods(Xr.prototype),installClearBufferMethods(Xr.prototype),installInstancedAndFramebufferOpsMethods(Xr.prototype);function defineGlobalIfMissing(e,t){globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}defineGlobalIfMissing(`WebGLRenderingContext`,WebGLRenderingContext$1),defineGlobalIfMissing(`WebGL2RenderingContext`,Xr);const Zr=Symbol(`abort`),Qr=Symbol(`internal`);var $r=class AbortSignal extends EventTarget{#e=!1;#t=void 0;onabort=null;constructor(e){if(super(),e!==Qr)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get reason(){return this.#t}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.#t}[Zr](e){if(this.#e)return;this.#e=!0,this.#t=e??new Qe(`The operation was aborted.`,`AbortError`);let t=new Event(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,t),this.dispatchEvent(t)}static abort(e){let t=new AbortSignal(Qr);return t[Zr](e),t}static timeout(e){let t=new AbortSignal(Qr);return setTimeout(()=>{t[Zr](new Qe(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(Qr);for(let n of e)if(n.aborted)return t[Zr](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Zr](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},ei=class AbortController{signal;constructor(){this.signal=new $r(Qr)}get[Symbol.toStringTag](){return`AbortController`}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Zr](e)}};const ti=globalThis;globalThis.AbortController===void 0&&(ti.AbortController=ei),globalThis.AbortSignal===void 0&&(ti.AbortSignal=$r);const I=Symbol(`kState`),ni=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[I]!==void 0&&t[ni]===e}function dequeueValue(e){let t=e[I].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[I].queueTotalSize=Math.max(0,e[I].queueTotalSize-r),n}function resetQueue(e){e[I].queue=[],e[I].queueTotalSize=0}function peekQueueValue(e){return e[I].queue[0].value}function enqueueValueWithSize(e,t,n){if(n=+n,typeof n!=`number`||n<0||Number.isNaN(n)||n===1/0)throw RangeError(`Invalid size: ${n}`);e[I].queue.push({value:t,size:n}),e[I].queueTotalSize+=n}function extractHighWaterMark(e,t){if(e===void 0)return t;if(e=+e,typeof e!=`number`||Number.isNaN(e)||e<0)throw RangeError(`Invalid highWaterMark: ${e}`);return e}function extractSizeAlgorithm(e){if(e===void 0)return()=>1;if(typeof e!=`function`)throw TypeError(`strategy.size must be a function`);return e}function transferArrayBuffer(e){return typeof ArrayBuffer.prototype.transfer==`function`?e.transfer():e.slice(0)}function isDetachedBuffer(e){if(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e.byteLength!==0)return!1;try{return e.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(e){switch(e){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(e){switch(e){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(e){e.then(()=>{},()=>{})}function createPromiseCallback(e,t,n){if(typeof t!=`function`)throw TypeError(`${e} must be a function`);return async(...e)=>t.call(n,...e)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const ri={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(e){let t={[Symbol.iterator]:()=>e.iterator},n=(async function*(){return yield*t})();return{iterator:n,nextMethod:n.next,done:!1}}function getIterator(e,t=`sync`,n){if(n===void 0)if(t===`async`){if(n=e[Symbol.asyncIterator],n==null){let t=e[Symbol.iterator];if(t===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(e,`sync`,t))}}else n=e[Symbol.iterator];if(n===void 0)throw TypeError(`Object is not iterable`);let r=n.call(e);if(typeof r!=`object`||!r)throw TypeError(`The iterator method must return an object`);return{iterator:r,nextMethod:r.next,done:!1}}function iteratorNext(e,t){let n;if(n=t===void 0?e.nextMethod.call(e.iterator):e.nextMethod.call(e.iterator,t),typeof n!=`object`||!n)throw TypeError(`The iterator.next() method must return an object`);return n}const ii=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(e){this.signal.aborted=!0,this.signal.reason=e}},ai=Symbol(`kAbort`),oi=Symbol(`kCloseSentinel`),si=Symbol(`kError`),ci=Symbol(`kSkipThrow`);var WritableStream=class{[ni]=`WritableStream`;[I];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`sink must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);let n=e?.type;if(n!==void 0)throw RangeError(`Invalid type: ${n}`);this[I]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!li(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return li(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return li(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!li(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[ni]=`WritableStreamDefaultWriter`;[I];constructor(e){if(!li(e))throw TypeError(`Expected a WritableStream`);this[I]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,e)}get closed(){return ui(this)?this[I].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!ui(this))throw TypeError(`Invalid this`);if(this[I].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return ui(this)?this[I].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return ui(this)?this[I].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!ui(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[I];return e===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!ui(this))throw TypeError(`Invalid this`);let{stream:e}=this[I];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return ui(this)?this[I].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[ni]=`WritableStreamDefaultController`;[I];constructor(e){if(e!==ci)throw TypeError(`Illegal constructor`)}[ai](e){let t=this[I].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[si](){resetQueue(this)}get signal(){if(!di(this))throw TypeError(`Invalid this`);return this[I].abortController.signal}error(e){if(!di(this))throw TypeError(`Invalid this`);this[I].stream[I].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const li=isBrandCheck(`WritableStream`),ui=isBrandCheck(`WritableStreamDefaultWriter`),di=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(e){return e[I].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[I].stream=t,t[I].writer=e,t[I].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[I].backpressure?e[I].ready=Promise.withResolvers():e[I].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[I].close=Promise.withResolvers();break;case`erroring`:e[I].ready={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[I].ready.promise),e[I].close=Promise.withResolvers();break;case`closed`:e[I].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[I].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[I].ready={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},e[I].close={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[I].ready.promise),setPromiseHandled(e[I].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[I];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[I].abortController.abort(t),e[I].pendingAbortRequest.abort.promise!==void 0)return e[I].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let o=Promise.withResolvers();return e[I].pendingAbortRequest={abort:o,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),o.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[I];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[I].closeRequest=Promise.withResolvers();let{promise:o}=e[I].closeRequest;return n!==void 0&&r&&t===`writable`&&n[I].ready.resolve?.(),writableStreamDefaultControllerClose(i),o}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[I];n!==void 0&&e[I].backpressure!==t&&(t?n[I].ready=Promise.withResolvers():n[I].ready.resolve?.()),e[I].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[I];e[I].state=`erroring`,e[I].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[I].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[I].closeRequest.promise!==void 0&&(e[I].closeRequest.reject?.(e[I].storedError),e[I].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[I].close.promise),e[I].close.reject?.(e[I].storedError);let{writer:t}=e[I];t!==void 0&&(setPromiseHandled(t[I].close.promise),t[I].close.reject?.(e[I].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[I].writeRequests.shift();e[I].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[I].inFlightCloseRequest=e[I].closeRequest,e[I].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[I].inFlightWriteRequest.promise!==void 0||e[I].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[I].inFlightWriteRequest.reject?.(t),e[I].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[I].inFlightWriteRequest.resolve?.(),e[I].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[I].inFlightCloseRequest.reject?.(t),e[I].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[I].pendingAbortRequest.abort.promise!==void 0&&(e[I].pendingAbortRequest.abort.reject?.(t),e[I].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[I].inFlightCloseRequest.resolve?.(),e[I].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[I].state===`erroring`&&(e[I].storedError=void 0,e[I].pendingAbortRequest.abort.promise!==void 0&&(e[I].pendingAbortRequest.abort.resolve?.(),e[I].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[I].state=`closed`,e[I].writer!==void 0&&e[I].writer[I].close.resolve?.(),e[I].close.resolve?.()}function writableStreamFinishErroring(e){e[I].state=`errored`,e[I].controller[si]();let t=e[I].storedError;for(let n of e[I].writeRequests)n.reject?.(t);if(e[I].writeRequests=[],e[I].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[I].pendingAbortRequest;if(e[I].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},n.wasAlreadyErroring){n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}e[I].controller[ai](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[I].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[I].closeRequest.promise!==void 0||e[I].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[I].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[I],{controller:r}=n[I],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[I].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:o}=n[I];if(o===`errored`)return Promise.reject(n[I].storedError);if(writableStreamCloseQueuedOrInFlight(n)||o===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(o===`erroring`)return Promise.reject(n[I].storedError);let s=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),s}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[I],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[I].writer=void 0,e[I].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[I];switch(t[I].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[I].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[I].ready.reject?(e[I].ready.reject(t),e[I].ready.resolve=void 0,e[I].ready.reject=void 0):e[I].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[I].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[I].close.reject?(e[I].close.reject(t),e[I].close.resolve=void 0,e[I].close.reject=void 0):e[I].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[I].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[I],{state:n}=t[I];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[I].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[I].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[I].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[I];!writableStreamCloseQueuedOrInFlight(r)&&r[I].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[I];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[I];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[I].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[I];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[I].highWaterMark-e[I].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[I];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[I].stream[I].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[I].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,oi,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[I].writeAlgorithm=void 0,e[I].closeAlgorithm=void 0,e[I].abortAlgorithm=void 0,e[I].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[I];if(!n||r[I].inFlightWriteRequest.promise!==void 0)return;if(r[I].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===oi?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(ci),o=t?.start,s=t?.write,c=t?.close,l=t?.abort;setupWritableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`sink.write`,s,t):nonOpWrite,c?createPromiseCallback(`sink.close`,c,t):nonOpCancel,l?createPromiseCallback(`sink.abort`,l,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,o,s,c){t[I]={abortAlgorithm:o,closeAlgorithm:i,highWaterMark:s,queue:[],queueTotalSize:0,abortController:new ii,sizeAlgorithm:c,started:!1,stream:e,writeAlgorithm:r},e[I].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let l=n();new Promise(e=>e(l)).then(()=>{t[I].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[I].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,o=()=>1){let s=Object.create(WritableStream.prototype);return s[ni]=`WritableStream`,s[I]=createWritableStreamState(),setupWritableStreamDefaultController(s,new WritableStreamDefaultController(ci),e,t,n,r,i,o),s}Ce();const fi=Symbol(`kCancel`),pi=Symbol(`kClose`),mi=Symbol(`kChunk`),hi=Symbol(`kError`),gi=Symbol(`kPull`),_i=Symbol(`kRelease`),vi=Symbol(`kSkipThrow`);let yi,bi;function lazyReadableReleasedError(){return yi||(yi=TypeError(`Reader released`),yi)}function lazyReadableReleasingError(){return bi||(bi=TypeError(`Releasing reader`),bi)}function createAbortError$1(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let e=Error(`The operation was aborted`);return e.name=`AbortError`,e}__name$1(createAbortError$1,`createAbortError`);function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name$1(this,`ReadableStream`)}[ni]=`ReadableStream`;[I];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`source must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);this[I]=createReadableStreamState();let n=t?.size,r=t?.highWaterMark,i=e?.type;if(i!==void 0){if(`${i}`==`bytes`){if(n!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,e,extractHighWaterMark(r,0));return}throw RangeError(`Invalid type: ${i}`)}setupReadableStreamDefaultControllerFromSource(this,e,extractHighWaterMark(r,1),extractSizeAlgorithm(n))}get locked(){if(!xi(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return xi(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!xi(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=e?.mode;if(t===void 0)return new ReadableStreamDefaultReader(this);if(`${t}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${t}`)}pipeThrough(e,t={}){if(!xi(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!xi(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!li(r))throw TypeError(`transform.writable must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let i=t?.preventAbort,o=t?.preventCancel,s=t?.preventClose,c=t?.signal;if(c!==void 0&&!(c instanceof Object&&`aborted`in c))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(r))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,r,!!s,!!i,!!o,c)),n}pipeTo(e,t={}){try{if(!xi(this))throw TypeError(`Invalid this`);if(!li(e))throw TypeError(`destination must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let n=t?.preventAbort,r=t?.preventCancel,i=t?.preventClose,o=t?.signal;if(o!==void 0&&!(o instanceof Object&&`aborted`in o))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(e))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,e,!!i,!!n,!!r,o)}catch(e){return Promise.reject(e)}}tee(){if(!xi(this))throw TypeError(`Invalid this`);let e=this[I].controller;return wi(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!xi(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=!!e?.preventCancel,n=new ReadableStreamDefaultReader(this),r={done:!1,current:void 0},i=!1;function nextSteps(){if(r.done)return Promise.resolve({done:!0,value:void 0});if(n[I].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:e,resolve:t,reject:i}=Promise.withResolvers();return readableStreamDefaultReaderRead(n,{[mi](e){r.current=void 0,t({value:e,done:!1})},[pi](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[hi](e){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),i(e)}}),e}async function returnSteps(e){if(r.done)return{done:!0,value:e};if(r.done=!0,n[I].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!t){let t=readableStreamReaderGenericCancel(n,e);return readableStreamReaderGenericRelease(n),await t,{done:!0,value:e}}return readableStreamReaderGenericRelease(n),{done:!0,value:e}}return Object.setPrototypeOf({next(){return i||=(r.current=Promise.resolve(),!0),r.current=r.current===void 0?nextSteps():r.current.then(nextSteps,nextSteps),r.current},return(e){return i=!0,r.current=r.current===void 0?returnSteps(e):r.current.then(()=>returnSteps(e),()=>returnSteps(e)),r.current},[Symbol.asyncIterator](){return this}},ri)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[I];constructor(){this[I]=Promise.withResolvers()}[mi](e){this[I].resolve?.({value:e,done:!1})}[pi](){this[I].resolve?.({value:void 0,done:!0})}[hi](e){this[I].reject?.(e)}get promise(){return this[I].promise}},ReadableStreamDefaultReader=class{[ni]=`ReadableStreamDefaultReader`;[I];constructor(e){if(!xi(e))throw TypeError(`Expected a ReadableStream`);this[I]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!Ci(this))return Promise.reject(TypeError(`Invalid this`));if(this[I].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[I].stream,t=e[I].controller;if(e[I].state===`readable`&&Si(t)&&t[I].queue.length>0){e[I].disturbed=!0;let n=dequeueValue(t);return t[I].closeRequested&&!t[I].queue.length?(readableStreamDefaultControllerClearAlgorithms(t),readableStreamClose(e)):readableStreamDefaultControllerCallPullIfNeeded(t),Promise.resolve({value:n,done:!1})}let n=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,n),n.promise}releaseLock(){if(!Ci(this))throw TypeError(`Invalid this`);this[I].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return Ci(this)?this[I].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return Ci(this)?this[I].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[ni]=`ReadableStreamDefaultController`;[I];constructor(e){if(e!==vi)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(e=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,e)}error(e=void 0){readableStreamDefaultControllerError(this,e)}[fi](e){return readableStreamDefaultControllerCancelSteps(this,e)}[gi](e){readableStreamDefaultControllerPullSteps(this,e)}[_i](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const xi=isBrandCheck(`ReadableStream`),Si=isBrandCheck(`ReadableStreamDefaultController`),Ci=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[I].reader!==void 0}function readableStreamCancel(e,t){switch(e[I].disturbed=!0,e[I].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[I].storedError)}readableStreamClose(e);let n=e[I].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[I].readIntoRequests;n[I].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][pi](void 0)}return e[I].controller[fi](t).then(()=>{})}function readableStreamClose(e){e[I].state=`closed`,e[I].closedPromise.resolve();let{reader:t}=e[I];if(t!==void 0&&(t[I].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[I].readRequests.length;e++)t[I].readRequests[e][pi]();t[I].readRequests=[]}}function readableStreamError(e,t){e[I].state=`errored`,e[I].storedError=t,setPromiseHandled(e[I].closedPromise.promise),e[I].closedPromise.reject(t);let{reader:n}=e[I];if(n!==void 0){if(setPromiseHandled(n[I].close.promise),n[I].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[I].readRequests.length;e++)n[I].readRequests[e][hi](t);n[I].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[I].readIntoRequests.length;e++)n[I].readIntoRequests[e][hi](t);n[I].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[I];return t===void 0?!1:t[I]!==void 0&&t[ni]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[I].reader[I].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[I],i=r[I].readRequests.shift();n?i[pi]():i[mi](t)}function readableStreamAddReadRequest(e,t){e[I].reader[I].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[I];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[I].stream=t,t[I].reader=e,t[I].state){case`readable`:e[I].close=Promise.withResolvers();break;case`closed`:e[I].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[I].close={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[I].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[I],n=lazyReadableReleasedError();t[I].state===`readable`?e[I].close.reject?.(n):e[I].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[I].close.promise),t[I].controller[_i](),t[I].reader=void 0,e[I].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[I].readRequests.length;++n)e[I].readRequests[n][hi](t);e[I].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[I];switch(n[I].disturbed=!0,n[I].state){case`closed`:t[pi]();break;case`errored`:t[hi](n[I].storedError);break;case`readable`:n[I].controller[gi](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[I].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[I].closeRequested=!0,e[I].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[I].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[I];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[I].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[I];return!e[I].closeRequested&&t[I].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[I];switch(t[I].state){case`errored`:return null;case`closed`:return 0;default:return n-r}}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerShouldCallPull(e){let{stream:t}=e[I];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[I].started)return!1;if(isReadableStreamLocked(t)&&readableStreamGetNumReadRequests(t))return!0;let n=readableStreamDefaultControllerGetDesiredSize(e);return n!==null&&n>0}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e)){if(e[I].pulling){e[I].pullAgain=!0;return}e[I].pulling=!0,e[I].pullAlgorithm(e).then(()=>{e[I].pulling=!1,e[I].pullAgain&&(e[I].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[I].pullAlgorithm=void 0,e[I].cancelAlgorithm=void 0,e[I].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[I];n[I].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[I].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[I];if(r.length){let i=dequeueValue(e);e[I].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[mi](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,o,s){t[I]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:s,stream:e},e[I].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[I].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController(vi),o=t?.start,s=t?.pull,c=t?.cancel;setupReadableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`source.pull`,s,t):nonOpPull,c?createPromiseCallback(`source.cancel`,c,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let o=Object.create(ReadableStream$1.prototype);return o[ni]=`ReadableStream`,o[I]=createReadableStreamState(),setupReadableStreamDefaultController(o,new ReadableStreamDefaultController(vi),e,t,n,r,i),o}function readableStreamFromIterable(e){let t,n=getIterator(e,`async`),r=nonOpStart;async function pullAlgorithm(){let e=iteratorNext(n);return Promise.resolve(e).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);e.done?readableStreamDefaultControllerClose(t[I].controller):readableStreamDefaultControllerEnqueue(t[I].controller,e.value)})}async function cancelAlgorithm(e){let t=n.iterator,r=t.return;if(r===void 0)return Promise.resolve();let i=r.call(t,e);return Promise.resolve(i).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return t=createReadableStream(r,pullAlgorithm,cancelAlgorithm,0),t}function readableStreamPipeTo(e,t,n,r,i,o){let s,c;try{s=new ReadableStreamDefaultReader(e),c=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[I].disturbed=!0;let l=!1,{promise:u,resolve:d,reject:f}=Promise.withResolvers(),p={currentWrite:Promise.resolve()},m;function finalize(e,t){writableStreamDefaultWriterRelease(c),readableStreamReaderGenericRelease(s),o!==void 0&&m&&(o.removeEventListener(`abort`,m),m=void 0),e?f(t):d()}async function waitForCurrentWrite(){let e=p.currentWrite;await e,e!==p.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(l)return;if(l=!0,t[I].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(complete,e=>finalize(!0,e));return}complete();function complete(){e().then(()=>finalize(!!n,r),e=>finalize(!0,e))}}function shutdown(e,n){if(!l){if(l=!0,t[I].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=o.reason&&o.reason.name===`AbortError`?createAbortError$1():o.reason;let s=[];r||s.push(()=>t[I].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||s.push(()=>e[I].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(s.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[I].state===`errored`?n(e[I].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[I].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[mi](e){ae(()=>{p.currentWrite=writableStreamDefaultWriterWrite(c,e),setPromiseHandled(p.currentWrite),h.resolve(!1)})}[pi](){h.resolve(!0)}[hi](e){h.reject(e)}}let h={resolve:null,reject:null};async function step(){if(l||t[I].backpressure&&(await c[I].ready.promise,l))return!0;let n=e[I].controller;if(e[I].state===`readable`&&Si(n)&&n[I].queue.length>0){for(;n[I].queue.length>0;){if(l)return!0;let r=dequeueValue(n);if(n[I].closeRequested&&!n[I].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),p.currentWrite=writableStreamDefaultWriterWrite(c,r),setPromiseHandled(p.currentWrite),t[I].backpressure||t[I].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[I].state===`closed`}let{promise:r,resolve:i,reject:o}=Promise.withResolvers();return h={resolve:i,reject:o},readableStreamDefaultReaderRead(s,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(o!==void 0){if(o.aborted)return abortAlgorithm(),u;m=abortAlgorithm,o.addEventListener(`abort`,m,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,s[I].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,c[I].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,s[I].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(c));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[I].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return u}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,o=!1,s,c,l,u,d=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[mi](e){ae(()=>{r=!1;let n=e,s=e;if(!o&&t)try{s=structuredClone(s)}catch{}i||readableStreamDefaultControllerEnqueue(l[I].controller,n),o||readableStreamDefaultControllerEnqueue(u[I].controller,s)})},[pi](){ae(()=>{r=!1,i||readableStreamDefaultControllerClose(l[I].controller),o||readableStreamDefaultControllerClose(u[I].controller),(!i||!o)&&d.resolve(void 0)})},[hi](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,s=t,o){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}function cancel2Algorithm(t){if(o=!0,c=t,i){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}return l=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),u=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[I].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(l[I].controller,e),readableStreamDefaultControllerError(u[I].controller,e),(!i||!o)&&d.resolve(void 0)}),[l,u]}var BYOBReadIntoRequest=class{[I];constructor(){this[I]=Promise.withResolvers()}[mi](e){this[I].resolve?.({value:e,done:!1})}[pi](e){this[I].resolve?.({value:e,done:!0})}[hi](e){this[I].reject?.(e)}get promise(){return this[I].promise}},ReadableStreamBYOBReader=class{[ni]=`ReadableStreamBYOBReader`;[I];constructor(e){if(!xi(e))throw TypeError(`Expected a ReadableStream`);this[I]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!Ti(this))return Promise.reject(TypeError(`Invalid this`));if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let n=e.buffer,r=e.byteLength;if(r===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(n.byteLength===0)return isDetachedBuffer(n)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let i=t?.min??1;if(typeof i!=`number`||i<1||!Number.isInteger(i)||Number.isNaN(i))return Promise.reject(TypeError(`options.min must be a positive integer`));let o=e[Symbol.toStringTag];if(o!==void 0&&o!==`DataView`){if(i>e.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(i>r)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[I].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let s=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,s),s.promise}releaseLock(){if(!Ti(this))throw TypeError(`Invalid this`);this[I].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return Ti(this)?this[I].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return Ti(this)?this[I].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[ni]=`ReadableStreamBYOBRequest`;[I];constructor(e){if(e!==vi)throw TypeError(`Illegal constructor`)}get view(){if(!Ei(this))throw TypeError(`Invalid this`);return this[I].view}respond(e){if(!Ei(this))throw TypeError(`Invalid this`);if(this[I].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(e=+e,!Number.isInteger(e)||e<0||!Number.isFinite(e))throw RangeError(`bytesWritten must be a non-negative integer`);let t=this[I].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[I].controller,e)}respondWithNewView(e){if(!Ei(this))throw TypeError(`Invalid this`);if(this[I].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(e.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[I].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[ni]=`ReadableByteStreamController`;[I];constructor(e){if(e!==vi)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!wi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!wi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!wi(this))throw TypeError(`Invalid this`);if(this[I].closeRequested)throw TypeError(`Close already requested`);if(this[I].stream[I].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!wi(this))throw TypeError(`Invalid this`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`chunk must be an ArrayBufferView`);if(e.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(e.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[I].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[I].stream[I].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!wi(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[fi](e){return readableByteStreamControllerCancelSteps(this,e)}[gi](e){readableByteStreamControllerPullSteps(this,e)}[_i](){if(this[I].pendingPullIntos.length>0){let e=this[I].pendingPullIntos[0];e.readerType=`none`,this[I].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const wi=isBrandCheck(`ReadableByteStreamController`),Ti=isBrandCheck(`ReadableStreamBYOBReader`),Ei=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[I];return t===void 0?!1:t[I]!==void 0&&t[ni]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[I].reader[I].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[I].reader[I].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[I],i=r[I].readIntoRequests.shift();n?i[pi](t):i[mi](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!wi(t[I].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[I].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[I];i[I].disturbed=!0,i[I].state===`errored`?r[hi](i[I].storedError):readableByteStreamControllerPullInto(i[I].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[I].readIntoRequests.length;n++)e[I].readIntoRequests[n][hi](t);e[I].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[I].pullAlgorithm=void 0,e[I].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[I].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[I].byobRequest;t!=null&&(t[I].controller=void 0,t[I].view=null,e[I].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[I];n[I].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[I].stream[I].state;return t===`errored`?null:t===`closed`?0:e[I].highWaterMark-e[I].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[I];if(t[I].state!==`readable`||e[I].closeRequested||!e[I].started)return!1;if(readableStreamHasDefaultReader(t)&&readableStreamGetNumReadRequests(t)>0||readableStreamHasBYOBReader(t)&&readableStreamGetNumReadIntoRequests(t)>0)return!0;let n=readableByteStreamControllerGetDesiredSize(e);return n!==null&&n>0}function readableByteStreamControllerCallPullIfNeeded(e){if(readableByteStreamControllerShouldCallPull(e)){if(e[I].pulling){e[I].pullAgain=!0;return}e[I].pulling=!0,e[I].pullAlgorithm(e).then(()=>{e[I].pulling=!1,e[I].pullAgain&&(e[I].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[I].queueTotalSize===0&&e[I].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[I].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[I].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[I].queueTotalSize+=r}function readableByteStreamControllerEnqueueClonedChunkToQueue(e,t,n,r){let i;try{i=t.slice(n,n+r)}catch(t){readableByteStreamControllerError(e,t);return}readableByteStreamControllerEnqueueChunkToQueue(e,i,0,r)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t){t.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(e,t.buffer,t.byteOffset,t.bytesFilled),readableByteStreamControllerShiftPendingPullInto(e)}function readableByteStreamControllerShiftPendingPullInto(e){return e[I].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n){n.bytesFilled+=t}function readableByteStreamControllerConvertPullIntoDescriptor(e){let t=e.bytesFilled,n=e.elementSize,r=transferArrayBuffer(e.buffer);return e.buffer=r,new e.viewConstructor(r,e.byteOffset,t/n)}function readableByteStreamControllerCommitPullIntoDescriptor(e,t){let n=!1;e[I].state===`closed`&&(n=!0);let r=readableByteStreamControllerConvertPullIntoDescriptor(t);t.readerType==="default"?readableStreamFulfillReadRequest(e,r,n):readableStreamFulfillReadIntoRequest(e,r,n)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t){let n=Math.min(e[I].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,o=!1,s=r-r%t.elementSize;s>=t.minimumFill&&(i=s-t.bytesFilled,o=!0);let c=e[I].queue;for(;i>0;){let n=c[0],r=Math.min(i,n.byteLength),o=t.byteOffset+t.bytesFilled,s=new Uint8Array(t.buffer,o,r),l=new Uint8Array(n.buffer,n.byteOffset,r);s.set(l),n.byteLength===r?c.shift():(n.byteOffset+=r,n.byteLength-=r),e[I].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return o}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[I].queue.shift();e[I].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[mi](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[I].stream[I].reader;for(;t[I].readRequests.length!==0;){if(e[I].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[I].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[I].pendingPullIntos.length!==0;){if(e[I].queueTotalSize===0)return;let t=e[I].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[I].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[I].byobRequest===null&&e[I].pendingPullIntos.length!==0){let t=e[I].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest(vi);r[I]={controller:e,view:n},e[I].byobRequest=r}return e[I].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[I];if(e[I].closeRequested||n[I].state!==`readable`)return;let r=t.buffer,i=t.byteLength,o=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let s=transferArrayBuffer(r);if(e[I].pendingPullIntos.length!==0){let t=e[I].pendingPullIntos[0];if(isDetachedBuffer(t.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(e),t.buffer=transferArrayBuffer(t.buffer),t.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t)}readableStreamHasDefaultReader(n)?(readableByteStreamControllerProcessReadRequestsUsingQueue(e),readableStreamGetNumReadRequests(n)===0?readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i):(e[I].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(s,o,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[I];if(!(e[I].closeRequested||t[I].state!==`readable`)){if(e[I].queueTotalSize>0){e[I].closeRequested=!0;return}if(e[I].pendingPullIntos.length!==0){let t=e[I].pendingPullIntos[0];if(t.bytesFilled%t.elementSize!==0){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(e,t),t}}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(t)}}function readableByteStreamControllerPullInto(e,t,n,r){let i=e[I].stream,o=t[Symbol.toStringTag],s,c;if(o===void 0||o===`DataView`)s=DataView,c=1;else{let e=typedArrayConstructorByTag(o);if(!e){r[hi](TypeError(`Unsupported typed array: ${o}`));return}s=e,c=elementSizeByTag(o)}let l=t.buffer,u=t.byteLength,d=t.byteOffset,f=n*c,p;try{p=transferArrayBuffer(l)}catch(e){r[hi](e);return}let m={buffer:p,bufferByteLength:p.byteLength,byteOffset:d,byteLength:u,bytesFilled:0,minimumFill:f,elementSize:c,viewConstructor:s,readerType:`byob`};if(e[I].pendingPullIntos.length!==0){e[I].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r);return}if(i[I].state===`closed`){let e=new s(m.buffer,m.byteOffset,0);r[pi](e);return}if(e[I].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,m)){let t=readableByteStreamControllerConvertPullIntoDescriptor(m);readableByteStreamControllerHandleQueueDrain(e),r[mi](t);return}if(e[I].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[hi](t);return}}e[I].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[I].pendingPullIntos[0];if(e[I].stream[I].state===`closed`){if(t!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(t===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(n.bytesFilled+t>n.byteLength)throw RangeError(`bytesWritten out of range`)}n.buffer=transferArrayBuffer(n.buffer),readableByteStreamControllerRespondInternal(e,t)}function readableByteStreamControllerRespondWithNewView(e,t){let n=e[I].pendingPullIntos[0],r=e[I].stream[I].state,i=t.byteLength,o=t.byteOffset,s=t.buffer;if(r===`closed`){if(i!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(i===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(n.byteOffset+n.bytesFilled!==o)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==s.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(n.bytesFilled+i>n.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);n.buffer=transferArrayBuffer(s),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[I].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[I].stream[I].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[I].stream;if(readableStreamHasBYOBReader(n))for(;readableStreamGetNumReadIntoRequests(n)>0;)readableByteStreamControllerCommitPullIntoDescriptor(n,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,t,n){if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n),n.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e);return}if(n.bytesFilled<n.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(e);let r=n.bytesFilled%n.elementSize;if(r>0){let t=n.byteOffset+n.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(e,n.buffer,t-r,r)}n.bytesFilled-=r,readableByteStreamControllerCommitPullIntoDescriptor(e[I].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[I].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[I].stream;if(e[I].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[I].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[hi](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[I].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,o,s){t[I]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:s},e[I].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[I].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController(vi),i=t?.start,o=t?.pull,s=t?.cancel,c=t?.autoAllocateChunkSize;if(c!==void 0&&(c===0||!Number.isInteger(c)||c<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,c)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,o,s,c=Promise.withResolvers(),l,u,d,f;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||d.close(),i||f.close();return}let t=e.value,o=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||d.enqueue(o),i||f.enqueue(new Uint8Array(o))},()=>{}),Promise.resolve())}return l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,o=t,i){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),u=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,s=t,r){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),d=l[I].controller,f=u[I].controller,t.closed.catch(e=>{d.error(e),f.error(e),(!r||!i)&&c.resolve()}),[l,u]}const Di=Symbol(`kSkipThrow`);var TransformStream=class{[ni]=`TransformStream`;[I];constructor(e={},t={},n={}){if(e!=null&&typeof e!=`object`)throw TypeError(`transformer must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`writableStrategy must be an object`);if(n!=null&&typeof n!=`object`)throw TypeError(`readableStrategy must be an object`);let r=e?.readableType,i=e?.writableType,o=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let s=extractHighWaterMark(n?.highWaterMark,0),c=extractSizeAlgorithm(n?.size),l=extractHighWaterMark(t?.highWaterMark,1),u=extractSizeAlgorithm(t?.size),d=Promise.withResolvers();initializeTransformStream(this,d,l,u,s,c),setupTransformStreamDefaultControllerFromTransformer(this,e),o===void 0?d.resolve():d.resolve(o.call(e,this[I].controller))}get readable(){if(!Oi(this))throw TypeError(`Invalid this`);return this[I].readable}get writable(){if(!Oi(this))throw TypeError(`Invalid this`);return this[I].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[ni]=`TransformStreamDefaultController`;[I];constructor(e){if(e!==Di)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!ki(this))throw TypeError(`Invalid this`);let{stream:e}=this[I],{readable:t}=e[I],n=t[I].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!ki(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!ki(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!ki(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Oi=isBrandCheck(`TransformStream`),ki=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,o){let startAlgorithm=()=>t.promise,s=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[I]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,o),writable:s,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(e,!0)}function transformStreamError(e,t){let{readable:n}=e[I];readableStreamDefaultControllerError(n[I].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[I];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[I].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[I].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[I].backpressureChange.promise!==void 0&&e[I].backpressureChange.resolve?.(),e[I].backpressureChange=Promise.withResolvers(),e[I].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[I]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[I].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(Di),r=t?.transform,i=t?.flush,o=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,o?createPromiseCallback(`transformer.cancel`,o,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[I].transformAlgorithm=void 0,e[I].flushAlgorithm=void 0,e[I].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[I],{readable:r}=n[I],i=r[I].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[I].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[I].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[I].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[I].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[I].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[I],{readable:n}=t[I];readableStreamDefaultControllerClose(n[I].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[I];return e[I].backpressure?e[I].backpressureChange.promise.then(()=>{let{writable:r}=e[I];if(r[I].state===`erroring`)throw r[I].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[I];if(n[I].finishPromise!==void 0)return n[I].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[I].finishPromise=i;let c=n[I].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[I].state===`errored`?s(r[I].storedError):(readableStreamDefaultControllerError(r[I].controller,t),o())},e=>{readableStreamDefaultControllerError(r[I].controller,e),s(e)}),n[I].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[I];if(n[I].finishPromise!==void 0)return n[I].finishPromise;let{promise:r,resolve:i,reject:o}=Promise.withResolvers();n[I].finishPromise=r;let s=n[I].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{t[I].state===`errored`?o(t[I].storedError):(readableStreamDefaultControllerClose(t[I].controller),i())},e=>{readableStreamDefaultControllerError(t[I].controller,e),o(e)}),n[I].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[I].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[I];if(n[I].finishPromise!==void 0)return n[I].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[I].finishPromise=i;let c=n[I].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[I].state===`errored`?s(r[I].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[I].controller,t),transformStreamUnblockWrite(e),o())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[I].controller,t),transformStreamUnblockWrite(e),s(t)}),n[I].finishPromise}const Ai=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),ji=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return Ai}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return ji}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(e,t)=>{if(e=String(e),e===``)return;this.#e!==null&&(e=this.#e+e);let n=e.charCodeAt(e.length-1);55296<=n&&n<=56319?(this.#e=e.slice(-1),e=e.slice(0,-1)):this.#e=null,e&&t.enqueue(this.#t.encode(e))},flush:e=>{this.#e!==null&&e.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const Mi=hasStreamingSupport();function incompleteUtf8Tail(e){let t=e.length;if(t===0)return 0;for(let n=1;n<=Math.min(3,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)!=128){let e;if((r&224)==192)e=2;else if((r&240)==224)e=3;else if((r&248)==240)e=4;else return 0;return n<e?n:0}}return 0}var TextDecoderStream=class{#e;#t;constructor(e,t){if(this.#e=new TextDecoder(e,t),Mi)this.#t=new TransformStream({transform:(e,t)=>{let n=toUint8Array$2(e),r=this.#e.decode(n,{stream:!0});r&&t.enqueue(r)},flush:e=>{let t=this.#e.decode();t&&e.enqueue(t)},cancel:()=>{this.#e.decode()}});else{let e=new Uint8Array;this.#t=new TransformStream({transform:(t,n)=>{let r=toUint8Array$2(t),i;e.length>0?(i=new Uint8Array(e.length+r.length),i.set(e,0),i.set(r,e.length)):i=r;let o=incompleteUtf8Tail(i),s;if(o>0?(s=i.slice(0,i.length-o),e=i.slice(i.length-o)):(s=i,e=new Uint8Array),s.length>0){let e=this.#e.decode(s);e&&n.enqueue(e)}},flush:t=>{if(e.length>0){let n=this.#e.decode(e);n&&t.enqueue(n),e=new Uint8Array}},cancel:()=>{e=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$2(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name$1(toUint8Array$2,`toUint8Array`);function isNativeStreamUsable$3(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$3,`isNativeStreamUsable`);const Ni=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,Pi=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Fi=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,Ii=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Li=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Ri=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,zi=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;function getGioFormat(e){switch(e){case`gzip`:return Vr.ZlibCompressorFormat.GZIP;case`deflate`:return Vr.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return Vr.ZlibCompressorFormat.RAW}}function concat$1(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function compressWithGio(e,t){let n=new Vr.ZlibCompressor({format:getGioFormat(t)}),r=new Vr.ConverterOutputStream({base_stream:Vr.MemoryOutputStream.new_resizable(),converter:n});r.write_bytes(new Bn.Bytes(e),null),r.close(null);let i=r.get_base_stream().steal_as_bytes();return new Uint8Array(i.get_data()??[])}function decompressStreamWithGio(e,t){let n=new Vr.ZlibDecompressor({format:getGioFormat(t)}),r=Vr.MemoryInputStream.new_from_bytes(new Bn.Bytes(e)),i=new Vr.ConverterInputStream({base_stream:r,converter:n}),o=[];for(;;){let e=i.read_bytes(Vi,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}return i.close(null),concat$1(o)}function findGzipMemberEnd(e){let t=new Vr.ZlibDecompressor({format:Vr.ZlibCompressorFormat.GZIP}),n=new Uint8Array(262144),r=0;for(;;){let i=e.subarray(r,r+Bi);try{let[e,o,s]=t.convert(i,n,Vr.ConverterFlags.NONE);if(r+=o,e===Vr.ConverterResult.FINISHED||o===0&&s===0)return r}catch{return r}}}function gunzipWithGio(e){let t=[],n=0;for(;n<e.length&&!(e.length-n<2||e[n]!==31||e[n+1]!==139);){let r=e.subarray(n),i=findGzipMemberEnd(r);if(i<=0)break;t.push(decompressStreamWithGio(r.subarray(0,i),`gzip`)),n+=i}return t.length===0?decompressStreamWithGio(e,`gzip`):concat$1(t)}var Bi,Vi,Hi=__esmMin(()=>{Hr(),Vn(),Bi=256*1024,Vi=1024*1024,__name$1(concat$1,`concat`)}),Ui=__esmMin(()=>{Ce()});function _setPipeImpl(e){Wi=e}var Wi,Stream_,Gi=__esmMin(()=>{er(),Stream_=class extends $n{constructor(e){super(e)}pipe(e,t){return Wi(this,e,t)}}});function finished(e,t,n){let r;r=typeof t==`function`?t:n;let i=!1;function done(e){i||(i=!0,r(e))}let onFinish=()=>done(),onEnd=()=>done(),onError=e=>done(e),onClose=()=>{let t=e,n=e;!t.writableFinished&&!n.readableEnded&&done(Error(`premature close`))};e.on(`finish`,onFinish),e.on(`end`,onEnd),e.on(`error`,onError),e.on(`close`,onClose);let o=e,s=typeof e.write==`function`,c=typeof e.read==`function`,l=o.writableFinished===!0,u=o.readableEnded===!0;if(o.destroyed===!0){let e=o._err;ae(e?()=>done(e):s&&l||c&&u?()=>done():()=>done(Error(`premature close`)))}else(s&&!c&&l||!s&&c&&u||s&&c&&l&&u)&&ae(()=>done());return function cleanup(){e.removeListener(`finish`,onFinish),e.removeListener(`end`,onEnd),e.removeListener(`error`,onError),e.removeListener(`close`,onClose)}}function addAbortSignal(e,t){if(!(e instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(t instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let n=t;if(e.aborted)n.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{n.destroy(Error(`The operation was aborted`))};e.addEventListener(`abort`,onAbort,{once:!0}),t.once(`close`,()=>{e.removeEventListener(`abort`,onAbort)})}return t}function isReadable(e){if(e==null)return!1;let t=e;return typeof t.readable!=`boolean`||typeof t.read!=`function`||t.destroyed===!0||t.readableEnded===!0?!1:t.readable===!0}function isWritable(e){if(e==null)return!1;let t=e;return typeof t.writable!=`boolean`||typeof t.write!=`function`||t.destroyed===!0||t.writableEnded===!0?!1:t.writable===!0}function isDestroyed(e){return e==null?!1:e.destroyed===!0}function isDisturbed(e){if(e==null)return!1;let t=e;return t.readableDidRead===!0||t.readableFlowing!==null&&t.readableFlowing!==void 0}function isErrored(e){if(e==null)return!1;let t=e;return t.destroyed===!0&&typeof t.readable==`boolean`&&t.readable===!1||t.destroyed===!0&&typeof t.writable==`boolean`&&t.writable===!1}var Ki=__esmMin(()=>{Gi(),Ce()});function getDefaultHighWaterMark(e){return e?Ji:qi}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Ji=t:qi=t}function validateHighWaterMark(e,t){if(t!==void 0&&(typeof t!=`number`||Number.isNaN(t))){let n=TypeError(`The value of "${e}" is invalid. Received ${t}`);throw n.code=`ERR_INVALID_ARG_VALUE`,n}}var qi,Ji,Yi=__esmMin(()=>{qi=16384,Ji=16});function createAbortError(){let e=Error(`The operation was aborted`);return e.name=`AbortError`,e.code=`ABORT_ERR`,e}async function streamAsyncDispose(e,t){let n;e.destroyed||(n=t?void 0:createAbortError(),e.destroy(n)),await new Promise((t,r)=>{finished(e,e=>{e&&e!==n?r(e):t()})})}var Xi,Zi=__esmMin(()=>{Ki(),Xi=Symbol.asyncDispose??Symbol.for(`Symbol.asyncDispose`)});function chunkLength(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}function sliceChunk(e,t,n){if(typeof e==`string`)return n===void 0?e.slice(t):e.slice(t,n);let r=e.slice;return typeof r==`function`?r.call(e,t,n):e}var Qi,$i=__esmMin(()=>{Gi(),Zi(),Yi(),Ce(),Qi=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(e){super(e),this.readableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.readableEncoding=e?.encoding??null,this.readableObjectMode=e?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,e?.read&&(this._readImpl=e.read),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._readableState.constructed=!0,e?this.destroy(e):this.readableFlowing===!0&&this._flow()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_read(e){this._readImpl&&this._readImpl.call(this,e)}read(e){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(e??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||e===0)return null;if(this.readableObjectMode){if(e===void 0){let e=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),e}if(e>this.readableLength)return null;let t=this._buffer.shift();return--this.readableLength,t}if(e!=null)return e>this.readableLength?null:this._readBytes(e);let t=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),t.length===1)return t[0];if(t.length===0)return null;if(typeof t[0]==`string`)return t.join(``);let n=globalThis.Buffer;return n?.concat?n.concat(t):t}_readBytes(e){let t=0,n=[];for(;t<e&&this._buffer.length>0;){let r=this._buffer[0],i=chunkLength(r);if(t+i<=e)n.push(this._buffer.shift()),t+=i,this.readableLength-=i;else{let i=e-t;n.push(sliceChunk(r,0,i)),this._buffer[0]=sliceChunk(r,i),this.readableLength-=i,t+=i}}if(n.length===1)return n[0];let r=globalThis.Buffer;return r?.concat?r.concat(n):n}push(e,t){if(e===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof e==`string`||ArrayBuffer.isView(e))){let t=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof e}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,t)),!1}return this._buffer.push(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(e,t){return super.on(e,t),e===`data`&&this.readableFlowing!==!1&&this.resume(),e===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(e){this._buffer.unshift(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e)}setEncoding(e){return this.readableEncoding=e,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let e=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(e),this.readableEncoding&&typeof e!=`string`){let t=globalThis.Buffer;t?.isBuffer&&t.isBuffer(e)?e=e.toString(this.readableEncoding):e instanceof Uint8Array&&(e=new TextDecoder(this.readableEncoding).decode(e))}this.emit(`data`,e)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(e){if(e){let t=this._pipeDests.findIndex(t=>t.dest===e);if(t!==-1){this._pipeDests[t].cleanup(),this._pipeDests.splice(t,1);let n=this._readableState.pipes.indexOf(e);n!==-1&&this._readableState.pipes.splice(n,1),e.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let e of this._pipeDests)e.cleanup(),e.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e??void 0)}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(e??null,cb):this._destroyImpl?this._destroyImpl.call(this,e??null,cb):cb(e),this}static toWeb(e){return new ReadableStream({start(t){e.on(`data`,e=>{typeof e==`string`?t.enqueue(new TextEncoder().encode(e)):e instanceof Uint8Array?t.enqueue(e):e&&typeof e.length==`number`&&t.enqueue(new Uint8Array(e))}),e.on(`end`,()=>{t.close()}),e.on(`error`,e=>{t.error(e)})},cancel(){e.destroy()}})}static fromWeb(e,t){let n=e.getReader();return new Readable_({...t,read(){n.read().then(({done:e,value:t})=>{e?this.push(null):this.push(t)},e=>{this.destroy(e)})},destroy(e,t){n.cancel(e?.message).then(()=>t(null),t)}})}[Symbol.asyncIterator](){let e=this,t=[],n=!1,r=null,i=null,o=null;return e.on(`data`,e=>{if(i){let t=i;i=null,o=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,o=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,o){let t=o;i=null,o=null,t(e)}}),{next(){return r?Promise.reject(r):t.length>0?Promise.resolve({value:t.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{i=e,o=t})},return(){return e.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(e,t){let n=new Readable_({objectMode:!0,...t,read(){}});return typeof e==`string`||ArrayBuffer.isView(e)?(n.push(e),n.push(null),n):((async()=>{try{for await(let t of e)n.push(t)||await new Promise(e=>n.once(`drain`,e));n.push(null)}catch(e){n.destroy(e)}})(),n)}},Qi.prototype[Xi]=function(){return streamAsyncDispose(this,this.readableEnded)}});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,ea=__esmMin(()=>{Yi(),$i(),Ce(),Duplex_=class extends Qi{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(e){super(e),validateHighWaterMark(`writableHighWaterMark`,e?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,e?.readableHighWaterMark),this.writableObjectMode=e?.writableObjectMode??e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??e?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,e?.highWaterMark===void 0&&e?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=e.readableHighWaterMark,this._readableState.highWaterMark=e.readableHighWaterMark),e?.readableObjectMode!==void 0&&(this.readableObjectMode=e.readableObjectMode,this._readableState.objectMode=e.readableObjectMode,e?.readableHighWaterMark===void 0&&e?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(e.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=e?.allowHalfOpen!==!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.final&&(this._finalImpl=e.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}destroy(e){return this.destroyed?this:(this.writable=!1,super.destroy(e))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(e),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),o}_duplexDoWrite(e,t,n){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:e,encoding:t,callback:n});return}this._duplexWriting=!0,this._duplexStartWrite(e,t,n)}_duplexStartWrite(e,t,n){this._pendingWrites++,this._write(e,t,t=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(e),nextTick(t?()=>{if(n(t),this._duplexWriting=!1,this.emit(`error`,t),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(e.chunk,e.encoding,e.callback)}}:()=>{if(n(),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexStartWrite(e.chunk,e.encoding,e.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let e=this._pendingEndCb;this._pendingEndCb=null,e()}})})}end(e,t,n){typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),this.writableEnded=!0;let doFinal=()=>{this._final(e=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),n&&n()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(e){e()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let e=this._duplexCorkedBuffer.splice(0);for(let{chunk:t,encoding:n,callback:r}of e)this._write(t,n,e=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(t),e?(r(e),this.emit(`error`,e)):r()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(e){return this._defaultEncoding=e,this}},__name$1(chunkLen$1,`chunkLen`)});function pipe(e,t,n){let r=e,i=n?.end!==!1,o=!1,ondrain=()=>{o=!1,t.removeListener(`drain`,ondrain);let e=r;typeof e.resume==`function`&&e.resume()},ondata=e=>{if(t.writable){let n=r;t.write(e)===!1&&typeof n.pause==`function`&&(n.pause(),o||(o=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let s=!1,onend=()=>{s||(s=!0,i&&t.end())},onclose=()=>{if(!s&&(s=!0,i&&!(r instanceof Qi))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),o&&t.removeListener(`drain`,ondrain),r.removeListener(`end`,onend),r.removeListener(`close`,onclose),r.removeListener(`end`,cleanup),r.removeListener(`close`,cleanup),t.removeListener(`close`,cleanup)};return r.on(`end`,cleanup),r.on(`close`,cleanup),t.on(`close`,cleanup),r instanceof Qi&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var ta=__esmMin(()=>{Gi(),$i(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var na,ra=__esmMin(()=>{Gi(),Zi(),Yi(),Ce(),na=class Writable_ extends Stream_{static[Symbol.hasInstance](e){let t=this;return t.prototype!==void 0&&Object.prototype.isPrototypeOf.call(t.prototype,e)?!0:t.prototype!==Writable_.prototype||e==null?!1:typeof e.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;_autoDestroy;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,this._autoDestroy=e?.autoDestroy!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._writableState.constructed=!0,e?this.destroy(e):this._maybeFlush()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e)}_maybeFlush(){let e=this._pendingConstruct.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}if(this._pendingEnd){let{chunk:e,encoding:t,callback:n}=this._pendingEnd;this._pendingEnd=null,this._doEnd(e,t,n)}}_doWrite(e,t,n){this._writableState.writing=!0;let r=!0;this._write(e,t,t=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(e),r){nextTick(()=>{if(t){n(t),this.emit(`error`,t);return}n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),t||this._drainWriteBuffer();return}nextTick(t?()=>{n(t),this.emit(`error`,t),this._drainWriteBuffer()}:()=>{n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),r=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let e=this._writeBuffer.shift();this._doWrite(e.chunk,e.encoding,e.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(e=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),this._autoDestroy?this.destroy():nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(e),this.writableCorked>0)return this._corkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),o}_doEnd(e,t,n){e!=null&&this.write(e,t),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=n,this._maybeFinish()}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),this.writableEnded?(n&&nextTick(n),this):this._writableState.constructed?(this._doEnd(e,t,n),this):(this._pendingEnd={chunk:e,encoding:t,callback:n},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let e=this._corkedBuffer.splice(0),t=e.map(e=>({chunk:e.chunk,encoding:e.encoding}));this._writev.call(this,t,t=>{for(let t of e)this.writableLength-=this.writableObjectMode?1:chunkLen(t.chunk);if(t){for(let n of e)n.callback(t);this.emit(`error`,t)}else{for(let t of e)t.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let e=this._corkedBuffer.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}}}setDefaultEncoding(e){return this._defaultEncoding=e,this}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return this._destroy(e??null,cb),this}},na.prototype[Xi]=function(){return streamAsyncDispose(this,this.writableFinished)}}),ia,aa=__esmMin(()=>{ea(),Ce(),ia=class Transform_ extends Duplex_{constructor(e){super({...e,write:void 0,final:void 0});let t=this;e?.transform&&(t._transform=e.transform),e?.flush&&(t._flush=e.flush),e?.final&&(t._final=e.final)}_transform(e,t,n){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(e){e()}_write(e,t,n){let r=!1;try{this._transform(e,t,(e,t)=>{if(r){let e=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,e));return}if(r=!0,e){n(e);return}t!=null&&this.push(t),n()})}catch(e){if(e?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw e;n(e)}}_final(e){this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()})}_doPrefinishHooks(e){let t=Transform_.prototype._final;this._final===t?e():t.call(this,e)}}}),PassThrough_,oa=__esmMin(()=>{aa(),PassThrough_=class extends ia{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline(...e){let t=e,n=typeof t[t.length-1]==`function`?t.pop():void 0,r=t;if(r.length<2)throw Error(`pipeline requires at least 2 streams`);let i=null;function onError(e){if(!i){i=e;for(let e of r)typeof e.destroy==`function`&&e.destroy();n&&n(e)}}let o=r[0];for(let e=1;e<r.length;e++){let t=r[e];o.pipe(t),o.on(`error`,onError),o=t}let s=r[r.length-1];return s.on(`error`,onError),s.on(`finish`,()=>{n&&!i&&n(null)}),s}var sa=__esmMin(()=>{}),ca,la,ua,da,fa,pa,ma,ha=__esmMin(()=>{Ui(),Gi(),Ki(),Yi(),$i(),ea(),ta(),ra(),aa(),oa(),sa(),ca=makeCallable(Stream_),la=makeCallable(Qi),ua=makeCallable(na),da=makeCallable(Duplex_),fa=makeCallable(ia),pa=makeCallable(PassThrough_),ma=Object.assign(ca,{Stream:ca,Readable:la,Writable:ua,Duplex:da,Transform:fa,PassThrough:pa,pipeline,finished,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function concat(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function createGzip(e){return new Gzip(e)}function createGunzip(e){return new Gunzip(e)}function createDeflate(e){return new Deflate(e)}function createInflate(e){return new Inflate(e)}function createDeflateRaw(e){return new DeflateRaw(e)}function createInflateRaw(e){return new InflateRaw(e)}function createUnzip(e){return new Unzip(e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}function createZstdCompress(e){let t=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}function createZstdDecompress(e){let t=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,ga=__esmMin(()=>{Hi(),ha(),__name$1(toUint8Array$1,`toUint8Array`),ZlibBase=class extends fa{_mode;_chunks=[];constructor(e,t){super(t),this._mode=e}_transform(e,t,n){this._chunks.push(toUint8Array$1(e)),n()}_flush(e){let t=concat(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(t))),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_run(e){let t=this._mode;switch(t.kind){case`compress`:return compressWithGio(e,t.format);case`decompress`:return decompressStreamWithGio(e,t.format);case`gunzip`:return gunzipWithGio(e);case`unzip`:return e.length>=2&&e[0]===31&&e[1]===139?gunzipWithGio(e):decompressStreamWithGio(e,`deflate`)}}},Gzip=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`gzip`},e)}},Gunzip=class extends ZlibBase{constructor(e){super({kind:`gunzip`},e)}},Deflate=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate`},e)}},Inflate=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate`},e)}},DeflateRaw=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate-raw`},e)}},InflateRaw=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate-raw`},e)}},Unzip=class extends ZlibBase{constructor(e){super({kind:`unzip`},e)}},BrotliCompress=class extends fa{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends fa{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends fa{constructor(){super();let e=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}},ZstdDecompress=class extends fa{constructor(){super();let e=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}}}),_a=__exportAll$1({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>ya,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>ba,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function decompressWithGio(e,t){return t===`gzip`?gunzipWithGio(e):decompressStreamWithGio(e,t)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let o=r.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of r)s.set(e,c),c+=e.length;return s}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}async function compress(e,t){return hasWebCompression()?compressWithWeb(e,t):compressWithGio(e,t)}async function decompress(e,t){if(hasWebCompression())try{return await decompressWithWeb(e,t)}catch(n){if(t!==`gzip`)throw n;return decompressWithGio(e,t)}return decompressWithGio(e,t)}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array(e),`gzip`)}function gunzipSync(e,t){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array(e),`deflate`)}function inflateSync(e,t){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array(e),`deflate-raw`)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array(e),`deflate-raw`)}function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),va)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),va)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}function zstdCompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdCompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,va)}function zstdDecompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdDecompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,va)}function zstdCompressSync(e,t){let n=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}function zstdDecompressSync(e,t){let n=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}var hasWebCompression,va,ya,ba,xa=__esmMin(()=>{Hi(),ga(),hasWebCompression=()=>globalThis.CompressionStream!==void 0,va=new Uint8Array,ya={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},ba={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:ya}});const Sa=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!Sa.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const Ca=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let wa=!1,Ta,Ea,Da,Oa,ka,Aa;async function loadZlib(){if(wa)return;let e=await Promise.resolve().then(()=>(xa(),_a));Ta=e.gzipSync,Ea=e.gunzipSync,Da=e.deflateSync,Oa=e.inflateSync,ka=e.deflateRawSync,Aa=e.inflateRawSync,wa=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Ta(e);case`deflate`:return e=>Da(e);case`deflate-raw`:return e=>ka(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Ea(e);case`deflate`:return e=>Oa(e);case`deflate-raw`:return e=>Aa(e)}}function concatChunks(e){if(e.length===1)return e[0];let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let ja,Ma;if(Ca)ja=globalThis.CompressionStream,Ma=globalThis.DecompressionStream;else{let e=loadZlib();ja=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Fi({transform(e){r.push(e)},async flush(t){try{await e;let i=getCompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}},Ma=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Fi({transform(e){r.push(e)},async flush(t){try{await e;let i=getDecompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}}}const Na=globalThis;globalThis.CompressionStream===void 0&&(Na.CompressionStream=ja),globalThis.DecompressionStream===void 0&&(Na.DecompressionStream=Ma);const Pa={CustomEvent:CustomEvent$1,MessageEvent,ErrorEvent,CloseEvent,ProgressEvent:ProgressEvent$1};for(let[e,t]of Object.entries(Pa))globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0});const Fa=globalThis;globalThis.DOMException===void 0&&(Fa.DOMException=Qe);var Ia,__name,La=__esmMin(()=>{Ia=Object.defineProperty,__name=(e,t)=>Ia(e,`name`,{value:t,configurable:!0})});function validateHeaderName(e){if(typeof e!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let t=TypeError(`Header name must be a valid HTTP token ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),t}}function validateHeaderValue(e,t){if(t===void 0){let t=TypeError(`Header "${e}" value must not be undefined`);throw Object.defineProperty(t,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),t}if(typeof t==`string`&&/[^\t -~€-ÿ]/.test(t)){let t=TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_CHAR`}),t}}const Ra=Symbol(`Headers.headers`);function isBoxedPrimitive(e){return e instanceof String||e instanceof Number||e instanceof Boolean||typeof Symbol<`u`&&e instanceof Symbol||typeof BigInt<`u`&&e instanceof BigInt}var za=class Headers{[Ra];constructor(e){if(this[Ra]=new Map,e!=null){if(e instanceof Headers){for(let[t,n]of e[Ra])this[Ra].set(t,[...n]);return}if(typeof e==`object`&&!isBoxedPrimitive(e)){let t=e[Symbol.iterator];if(t==null)for(let[t,n]of Object.entries(e))validateHeaderName(t),validateHeaderValue(t,String(n)),this.append(t,String(n));else{if(typeof t!=`function`)throw TypeError(`Header pairs must be iterable`);for(let t of e){if(typeof t!=`object`||isBoxedPrimitive(t))throw TypeError(`Each header pair must be an iterable object`);let e=[...t];if(e.length!==2)throw TypeError(`Each header pair must be a name/value tuple`);validateHeaderName(e[0]),validateHeaderValue(e[0],String(e[1])),this.append(e[0],String(e[1]))}}}else throw TypeError(`Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)'`)}}append(e,t){validateHeaderName(e),validateHeaderValue(e,t);let n=String(e).toLowerCase(),r=String(t),i=this[Ra].get(n);i?i.push(r):this[Ra].set(n,[r])}set(e,t){validateHeaderName(e),validateHeaderValue(e,t);let n=String(e).toLowerCase();this[Ra].set(n,[String(t)])}delete(e){this[Ra].delete(String(e).toLowerCase())}has(e){return this[Ra].has(String(e).toLowerCase())}get(e){let t=this[Ra].get(String(e).toLowerCase());if(!t||t.length===0)return null;let n=t.join(`, `);return/^content-encoding$/i.test(e)&&(n=n.toLowerCase()),n}getAll(e){return this[Ra].get(String(e).toLowerCase())??[]}getSetCookie(){return this[Ra].get(`set-cookie`)??[]}forEach(e,t){for(let n of this.keys())Reflect.apply(e,t,[this.get(n),n,this])}*keys(){let e=[...this[Ra].keys()].sort(),t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}*values(){for(let e of this.keys())yield this.get(e)}*entries(){for(let e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`Headers`}toString(){return Object.prototype.toString.call(this)}raw(){let e={};for(let t of this.keys())e[t]=this.getAll(t);return e}_appendToSoupMessage(e,t,n=e.MessageHeadersType.REQUEST){let r=t?t.get_request_headers():new e.MessageHeaders(n);for(let[e,t]of this.entries())r.append(e,t);return r}static _newFromSoupMessage(e,t,n=e.MessageHeadersType.RESPONSE){let r=new Headers,i;return i=n===e.MessageHeadersType.RESPONSE?t.get_response_headers():t.get_request_headers(),i.foreach((e,t)=>{r.append(e,t)}),r}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};for(let t of this.keys()){let n=this.getAll(t);t===`host`?e[t]=n[0]:e[t]=n.length>1?n:n[0]}return e}};Object.defineProperties(za.prototype,[`get`,`entries`,`forEach`,`values`].reduce((e,t)=>(e[t]={enumerable:!0},e),{}));var Ba=__esmMin(()=>{Ln()});Ba();var FetchBaseError=class extends Error{type;constructor(e,t){super(e),typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,this.constructor),this.type=t}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}},FetchError=class extends FetchBaseError{code;errno;erroredSysCall;constructor(e,t,n){super(e,t),n&&(this.code=this.errno=n.code,this.erroredSysCall=n.syscall)}};const Va=Symbol.toStringTag,isURLSearchParameters=e=>typeof e==`object`&&typeof e.append==`function`&&typeof e.delete==`function`&&typeof e.get==`function`&&typeof e.getAll==`function`&&typeof e.has==`function`&&typeof e.set==`function`&&typeof e.sort==`function`&&e[Va]===`URLSearchParams`,isBlob=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.arrayBuffer==`function`&&typeof t.type==`string`&&typeof t.stream==`function`&&typeof t.constructor==`function`&&/^(Blob|File)$/.test(t[Va])},isAbortSignal=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return t[Va]===`AbortSignal`||t[Va]===`EventTarget`},isDomainOrSubdomain=(e,t)=>{let n=new ur(t).hostname,r=new ur(e).hostname;return n===r||n.endsWith(`.${r}`)},isSameProtocol=(e,t)=>new ur(t).protocol===new ur(e).protocol;var Ha,Ua,File,Wa=__esmMin(()=>{Ha=Symbol(`File.name`),Ua=Symbol(`File.lastModified`),File=class extends Blob{[Ha];[Ua];webkitRelativePath=``;constructor(e,t,n){super(e,n),this[Ha]=String(t),this[Ua]=n?.lastModified??Date.now()}get name(){return this[Ha]}get lastModified(){return this[Ua]}get[Symbol.toStringTag](){return`File`}}});function generateBoundary(){let e=`----formdata-`;for(let t=0;t<24;t++)e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return e}function escape(e){return e.replace(/\n/g,`%0A`).replace(/\r/g,`%0D`).replace(/"/g,`%22`)}function formDataToBlob(e,t){t??=generateBoundary();let n=[],r=`--${t}\r\nContent-Disposition: form-data; name="`;for(let[t,i]of e.entries())if(typeof i==`string`)n.push(`${r}${escape(t)}"\r\n\r\n${i.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
25
+ `+i+t:i&&(t=i+t)}else i&&(t=i+t);return t}};function installShaderLifecycleMethods(e){Object.assign(e,Pr)}const Fr={createProgram(){let e=this._gl.createProgram();if(e<=0)return null;let t=new WebGLProgram$1(e,this);return this._programs[e]=t,t},deleteProgram(e){this._deleteLinkable(`deleteProgram`,e,WebGLProgram$1)},useProgram(e){if(!checkObject(e))throw TypeError(`useProgram(WebGLProgram)`);if(e)this._checkWrapper(e,WebGLProgram$1)&&(this._activeProgram!==e&&(this._switchActiveProgram(this._activeProgram),this._activeProgram=e,e._refCount+=1),this._gl.useProgram(e._|0));else{this._switchActiveProgram(this._activeProgram),this._activeProgram=null,this._gl.useProgram(0);return}},linkProgram(e){if(!checkObject(e))throw TypeError(`linkProgram(WebGLProgram)`);if(this._checkWrapper(e,WebGLProgram$1)){e._linkCount+=1,e._attributes=[];let t=this.getError();for(let t of e._references)t instanceof WebGLShader$1&&t._needsRecompile&&(this._gl.compileShader(t._|0),t._needsRecompile=!1);this._gl.linkProgram(e._|0);let n=this.getError();n===this.NO_ERROR&&(e._linkStatus=this._fixupLink(e)),this.getError(),this.setError(t||n)}},validateProgram(e){if(this._checkWrapper(e,WebGLProgram$1)){this._gl.validateProgram(e._|0);let t=this.getError();t===this.NO_ERROR&&(e._linkInfoLog=this._gl.getProgramInfoLog(e._|0)),this.getError(),this.setError(t)}},attachShader(e,t){if(!checkObject(e)||!checkObject(t))throw TypeError(`attachShader(WebGLProgram, WebGLShader)`);if(!e||!t){this.setError(this.INVALID_VALUE);return}else if(e instanceof WebGLProgram$1&&t instanceof WebGLShader$1&&this._checkOwns(e)&&this._checkOwns(t)&&!e._linked(t)){this._saveError(),this._gl.attachShader(e._|0,t._|0);let n=this.getError();this._restoreError(n),n===this.NO_ERROR&&e._link(t);return}this.setError(this.INVALID_OPERATION)},detachShader(e,t){if(!checkObject(e)||!checkObject(t))throw TypeError(`detachShader(WebGLProgram, WebGLShader)`);this._checkWrapper(e,WebGLProgram$1)&&this._checkWrapper(t,WebGLShader$1)&&(e._linked(t)?(this._gl.detachShader(e._,t._),e._unlink(t)):this.setError(this.INVALID_OPERATION))},bindAttribLocation(e,t,n){if(!checkObject(e)||typeof n!=`string`)throw TypeError(`bindAttribLocation(WebGLProgram, GLint, String)`);n+=``,!isValidString(n)||n.length>256?this.setError(this.INVALID_VALUE):/^_?webgl_a/.test(n)?this.setError(this.INVALID_OPERATION):this._checkWrapper(e,WebGLProgram$1)&&this._gl.bindAttribLocation(e._|0,t|0,n)},getAttachedShaders(e){if(!checkObject(e)||typeof e==`object`&&e&&!(e instanceof WebGLProgram$1))throw TypeError(`getAttachedShaders(WebGLProgram)`);if(!e)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram$1))return e._references.filter(e=>e instanceof WebGLShader$1);return null},getProgramInfoLog(e){if(!checkObject(e))throw TypeError(`getProgramInfoLog(WebGLProgram)`);return this._checkWrapper(e,WebGLProgram$1)?e._linkInfoLog:null},getProgramParameter(e,t=0){if(!checkObject(e))throw TypeError(`getProgramParameter(WebGLProgram, GLenum)`);if(this._checkWrapper(e,WebGLProgram$1)){switch(t){case this.DELETE_STATUS:return e._pendingDelete;case this.LINK_STATUS:return e._linkStatus;case this.VALIDATE_STATUS:return!!this._gl.getProgramParameter(e._,t);case this.ATTACHED_SHADERS:return this._gl.getProgramParameter(e._,t);case this.ACTIVE_ATTRIBUTES:return e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._,t);case this.ACTIVE_UNIFORMS:return e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._,t)}this.setError(this.INVALID_ENUM)}return null},_switchActiveProgram(e){e&&(--e._refCount,e._checkDelete())},_fixupLink(e){if(!this._gl.getProgramParameter(e._,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let t=this.getProgramParameter(e,this.ACTIVE_ATTRIBUTES),n=Array.from({length:t});e._attributes.length=t;for(let r=0;r<t;++r)n[r]=this.getActiveAttrib(e,r)?.name,e._attributes[r]=this.getAttribLocation(e,n[r])|0;for(let t=0;t<n.length;++t)if(n[t].length>256)return e._linkInfoLog=`attribute `+n[t]+` is too long`,!1;for(let r=0;r<t;++r)e._attributes[r]<0||this._gl.bindAttribLocation(e._|0,e._attributes[r],n[r]);if(this._gl.linkProgram(e._|0),!this._gl.getProgramParameter(e._|0,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let r=this.getProgramParameter(e,this.ACTIVE_UNIFORMS);e._uniforms.length=r;for(let t=0;t<r;++t){let n=this.getActiveUniform(e,t);n&&(e._uniforms[t]=n)}for(let t=0;t<e._uniforms.length;++t)if(e._uniforms[t].name.length>256)return e._linkInfoLog=`uniform `+e._uniforms[t].name+` is too long`,!1;return e._linkInfoLog=``,!0},_deleteLinkable(e,t,n){if(!checkObject(t))throw TypeError(e+`(`+n.name+`)`);if(t instanceof n&&this._checkOwns(t)){t._pendingDelete=!0,t._checkDelete();return}this.setError(this.INVALID_OPERATION)}};function installProgramLifecycleMethods(e){Object.assign(e,Fr)}var WebGLActiveInfo=class{constructor(e){this.size=e.size,this.type=e.type,this.name=e.name}};const Ir={getActiveAttrib(e,t){if(!checkObject(e))throw TypeError(`getActiveAttrib(WebGLProgram)`);if(!e)throw TypeError(`getActiveAttrib(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram$1)){if(t>=(e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_ATTRIBUTES)))return this._gl.getError(),this.setError(this.INVALID_VALUE),null;let n=this._gl.getActiveAttrib(e._|0,t|0);if(n)return new WebGLActiveInfo(n)}return null},getActiveUniform(e,t){if(!checkObject(e))throw TypeError(`getActiveUniform(WebGLProgram, GLint)`);if(!e)throw TypeError(`getActiveUniform(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram$1)){if(t>=(e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_UNIFORMS)))return this.setError(this.INVALID_VALUE),null;let n=this._gl.getActiveUniform(e._|0,t|0);if(n)return new WebGLActiveInfo(n)}return null},getAttribLocation(e,t){if(!checkObject(e))throw TypeError(`getAttribLocation(WebGLProgram, String)`);if(t+=``,!isValidString(t)||t.length>256)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram$1))return this._gl.getAttribLocation(e._|0,t+``);return-1},getUniform(e,t){if(!checkObject(e)||!checkObject(t))throw TypeError(`getUniform(WebGLProgram, WebGLUniformLocation)`);if(!e)return this.setError(this.INVALID_VALUE),null;if(!t)return null;if(this._checkWrapper(e,WebGLProgram$1)){if(!checkUniform(e,t))return this.setError(this.INVALID_OPERATION),null;let n=this._gl.getUniform(e._|0,t._|0);if(!n)return null;switch(t._activeInfo.type){case this.FLOAT:return n[0];case this.FLOAT_VEC2:return new Float32Array(n.slice(0,2));case this.FLOAT_VEC3:return new Float32Array(n.slice(0,3));case this.FLOAT_VEC4:return new Float32Array(n.slice(0,4));case this.INT:return n[0]|0;case this.INT_VEC2:return new Int32Array(n.slice(0,2));case this.INT_VEC3:return new Int32Array(n.slice(0,3));case this.INT_VEC4:return new Int32Array(n.slice(0,4));case this.BOOL:return!!n[0];case this.BOOL_VEC2:return[!!n[0],!!n[1]];case this.BOOL_VEC3:return[!!n[0],!!n[1],!!n[2]];case this.BOOL_VEC4:return[!!n[0],!!n[1],!!n[2],!!n[3]];case this.FLOAT_MAT2:return new Float32Array(n.slice(0,4));case this.FLOAT_MAT3:return new Float32Array(n.slice(0,9));case this.FLOAT_MAT4:return new Float32Array(n.slice(0,16));case this.SAMPLER_2D:case this.SAMPLER_CUBE:return n[0]|0;default:return null}}return null},getUniformLocation(e,t){if(!checkObject(e))throw TypeError(`getUniformLocation(WebGLProgram, String)`);if(t+=``,!isValidString(t))return this.setError(this.INVALID_VALUE),null;if(this._checkWrapper(e,WebGLProgram$1)){let n=this._gl.getUniformLocation(e._|0,t);if(n!==null&&n>=0){let r=t;/\[\d+\]$/.test(t)&&(r=t.replace(/\[\d+\]$/,`[0]`));let i=r+`[0]`,o=null;for(let t=0;t<e._uniforms.length;++t){let n=e._uniforms[t];if(n.name===r||n.name===i){o={size:n.size,type:n.type,name:n.name};break}}o||={name:r,type:0,size:1};let s=new WebGLUniformLocation(n,e,o),c=t.match(/\[(\d+)\]$/),l=c?+c[1]:-1;if(o.name.endsWith(`[0]`)&&(l===-1||l===0)){let t=o.name.replace(/\[0\]$/,``),n=[];this._saveError();for(let r=0;this.getError()===this.NO_ERROR;++r){let i=this._gl.getUniformLocation(e._|0,t+`[`+r+`]`);if(this.getError()!==this.NO_ERROR||i==null||i<0)break;n.push(i)}this._restoreError(this.NO_ERROR),s._array=n}else if(l>0&&l>=o.size)return null;return s}}return null}};function installIntrospectionMethods(e){Object.assign(e,Ir)}re();const Lr={uniform1f(e,t){this._checkUniformValid(e,t,`uniform1f`,1,`f`)&&this._gl.uniform1f(e?._||0,t)},uniform1i(e,t){this._gl.uniform1i(e?._||0,t)},uniform2f(e,t,n){this._checkUniformValid(e,t,`uniform2f`,2,`f`)&&this._gl.uniform2f(e?._||0,t,n)},uniform2i(e,t,n){this._checkUniformValid(e,t,`uniform2i`,2,`i`)&&this._gl.uniform2i(e?._||0,t,n)},uniform3f(e,t,n,r){this._checkUniformValid(e,t,`uniform3f`,3,`f`)&&this._gl.uniform3f(e?._||0,t,n,r)},uniform3i(e,t,n,r){this._checkUniformValid(e,t,`uniform3i`,3,`i`)&&this._gl.uniform3i(e?._||0,t,n,r)},uniform4f(e,t,n,r,i){if(!this._checkUniformValid(e,t,`uniform4f`,4,`f`)){M.error(`uniform4f is not valid!`);return}this._gl.uniform4f(e?._||0,t,n,r,i)},uniform4i(e,t,n,r,i){this._checkUniformValid(e,t,`uniform4i`,4,`i`)&&this._gl.uniform4i(e?._||0,t,n,r,i)},uniform1fv(e,t){if(!(!e||!this._checkUniformValueValid(e,t,`uniform1fv`,1,`f`))){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1f(r,t[e])}return}this._gl.uniform1f(e?._|0,t[0])}},uniform1iv(e,t){if(this._checkUniformValueValid(e,t,`uniform1iv`,1,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1i(r,t[e])}return}this.uniform1i(e,t[0])}},uniform2fv(e,t){if(this._checkUniformValueValid(e,t,`uniform2fv`,2,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2f(r,t[2*e],t[2*e+1])}return}this._gl.uniform2f(e?._||0,t[0],t[1])}},uniform2iv(e,t){if(this._checkUniformValueValid(e,t,`uniform2iv`,2,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2i(r,t[2*e],t[2*e+1])}return}this.uniform2i(e,t[0],t[1])}},uniform3fv(e,t){if(this._checkUniformValueValid(e,t,`uniform3fv`,3,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3f(r,t[3*e],t[3*e+1],t[3*e+2])}return}this._gl.uniform3f(e?._||0,t[0],t[1],t[2])}},uniform3iv(e,t){if(this._checkUniformValueValid(e,t,`uniform3iv`,3,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3i(r,t[3*e],t[3*e+1],t[3*e+2])}return}this.uniform3i(e,t[0],t[1],t[2])}},uniform4fv(e,t){if(this._checkUniformValueValid(e,t,`uniform4fv`,4,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4f(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this._gl.uniform4f(e?._||0,t[0],t[1],t[2],t[3])}},uniform4iv(e,t){if(this._checkUniformValueValid(e,t,`uniform4iv`,4,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4i(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this.uniform4i(e,t[0],t[1],t[2],t[3])}},uniformMatrix2fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix2fv`,2))return;let r=new Float32Array(n);this._gl.uniformMatrix2fv(e?._||0,!!t,listToArray(r))},uniformMatrix3fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix3fv`,3))return;let r=new Float32Array(n);this._gl.uniformMatrix3fv(e?._||0,!!t,listToArray(r))},uniformMatrix4fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix4fv`,4))return;let r=new Float32Array(n);this._gl.uniformMatrix4fv(e?._||0,!!t,listToArray(r))},_checkLocation(e){return e instanceof WebGLUniformLocation?e._program._ctx!==this||e._linkCount!==e._program._linkCount?(this.setError(this.INVALID_OPERATION),!1):!0:(this.setError(this.INVALID_VALUE),!1)},_checkLocationActive(e){return e&&this._checkLocation(e)?e._program===this._activeProgram?!0:(this.setError(this.INVALID_OPERATION),!1):!1},_checkUniformValid(e,t,n,r,i){if(!checkObject(e))throw TypeError(`${n}(WebGLUniformLocation, ...)`);if(!e)return!1;if(this._checkLocationActive(e)){let n=e._activeInfo.type;if(n===this.SAMPLER_2D||n===this.SAMPLER_CUBE){if(r!==1)return this.setError(this.INVALID_VALUE),!1;if(i!==`i`)return this.setError(this.INVALID_OPERATION),!1;if(t<0||t>=this._textureUnits.length)return this.setError(this.INVALID_VALUE),!1}return uniformTypeSize(this,n)>r?(this.setError(this.INVALID_OPERATION),!1):!0}return!1},_checkUniformValueValid(e,t,n,r,i){if(!checkObject(e)||!checkObject(t))throw TypeError(`${n}v(WebGLUniformLocation, Array)`);if(!e||!this._checkLocationActive(e))return!1;if(typeof t!=`object`||!t||typeof t.length!=`number`)throw TypeError(`Second argument to ${n} must be array`);return uniformTypeSize(this,e._activeInfo.type)>r?(this.setError(this.INVALID_OPERATION),!1):t.length>=r&&t.length%r===0?e._array||t.length===r?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)},_checkUniformMatrix(e,t,n,r,i){if(!checkObject(e)||typeof n!=`object`)throw TypeError(r+`(WebGLUniformLocation, Boolean, Array)`);return t||typeof n!=`object`||!n||!n.length||n.length%i*i!==0?(this.setError(this.INVALID_VALUE),!1):!e||!this._checkLocationActive(e)?!1:n.length===i*i||e._array?!0:(this.setError(this.INVALID_VALUE),!1)}};function installUniformsMethods(e){Object.assign(e,Lr)}function installShaderProgramMethods(e){installShaderLifecycleMethods(e),installProgramLifecycleMethods(e),installIntrospectionMethods(e),installUniformsMethods(e)}function installAllContextMethods(e){installStateMethods(e),installBufferBindingMethods(e),installTextureManagementMethods(e),installFramebufferMethods(e),installShaderProgramMethods(e),installDrawingMethods(e)}var EXTBlendMinMax=class{constructor(){this.MIN_EXT=32775,this.MAX_EXT=32776}};function getEXTBlendMinMax(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`EXT_blend_minmax`)>=0&&(t=new EXTBlendMinMax),t}var EXTColorBufferFloat=class{};function getEXTColorBufferFloat(e){let t=e.getSupportedExtensions();return t&&t.indexOf(`EXT_color_buffer_float`)>=0?new EXTColorBufferFloat:null}var EXTColorBufferHalfFloat=class{};function getEXTColorBufferHalfFloat(e){let t=e.getSupportedExtensions();return t&&t.indexOf(`EXT_color_buffer_half_float`)>=0?new EXTColorBufferHalfFloat:null}var EXTTextureFilterAnisotropic=class{constructor(){this.TEXTURE_MAX_ANISOTROPY_EXT=34046,this.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047}};function getEXTTextureFilterAnisotropic(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`EXT_texture_filter_anisotropic`)>=0&&(t=new EXTTextureFilterAnisotropic),t}var OESElementIndexUint=class{};function getOESElementIndexUint(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_element_index_uint`)>=0&&(t=new OESElementIndexUint),t}var OESStandardDerivatives=class{constructor(){this.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723}};function getOESStandardDerivatives(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_standard_derivatives`)>=0&&(t=new OESStandardDerivatives),t}var OESTextureFloatLinear=class{};function getOESTextureFloatLinear(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_texture_float_linear`)>=0&&(t=new OESTextureFloatLinear),t}var OESTextureFloat=class{};function getOESTextureFloat(e){let t=null,n=e.getSupportedExtensions();return n&&n.indexOf(`OES_texture_float`)>=0&&(t=new OESTextureFloat),t}var OESTextureHalfFloat=class{constructor(){this.HALF_FLOAT_OES=36193}};function getOESTextureHalfFloat(e){let t=e.getSupportedExtensions();return t&&t.indexOf(`OES_texture_half_float`)>=0||e._native2?new OESTextureHalfFloat:null}var STACKGLDestroyContext=class{constructor(e){this.destroy=e.destroy.bind(e)}};function getSTACKGLDestroyContext(e){return new STACKGLDestroyContext(e)}var STACKGLResizeDrawingBuffer=class{constructor(e){this.resize=e.resize.bind(e)}};function getSTACKGLResizeDrawingBuffer(e){return new STACKGLResizeDrawingBuffer(e)}var WEBGLDebugRendererInfo=class{constructor(){this.UNMASKED_VENDOR_WEBGL=37445,this.UNMASKED_RENDERER_WEBGL=37446}};function getWEBGLDebugRendererInfo(e){return new WEBGLDebugRendererInfo}var WebGLContextAttributes=class{constructor(e,t,n,r,i,o,s,c){this.alpha=e,this.depth=t,this.stencil=n,this.antialias=r,this.premultipliedAlpha=i,this.preserveDrawingBuffer=o,this.preferLowPowerToHighPerformance=s,this.failIfMajorPerformanceCaveat=c}},WebGLTextureUnit=class{constructor(e,t){this._mode=0,this._bind2D=null,this._bindCube=null,this._ctx=e,this._idx=t}},WebGLVertexArrayObjectAttribute=class{constructor(e,t){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=0,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0,this._ctx=e,this._idx=t,this._pointerType=e.FLOAT,this._clear()}_clear(){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=this._ctx.FLOAT,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0}},WebGLVertexArrayGlobalAttribute=class{constructor(e){this._idx=0,this._idx=e,this._data=new Float32Array([0,0,0,1])}},WebGLVertexArrayObjectState=class{constructor(e){this._elementArrayBufferBinding=null;let t=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:t});for(let n=0;n<t;++n)this._attribs[n]=new WebGLVertexArrayObjectAttribute(e,n);this._elementArrayBufferBinding=null}setElementArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setElementArrayBuffer(WebGLBuffer?)`);let t=this._elementArrayBufferBinding;t!==e&&(t&&(--t._refCount,t._checkDelete()),e&&(e._refCount+=1),this._elementArrayBufferBinding=e)}cleanUp(){let e=this._elementArrayBufferBinding;e&&(--e._refCount,e._checkDelete(),this._elementArrayBufferBinding=null);for(let e=0;e<this._attribs.length;++e){let t=this._attribs[e];t._pointerBuffer&&(--t._pointerBuffer._refCount,t._pointerBuffer._checkDelete()),t._clear()}}releaseArrayBuffer(e){if(e)for(let t=0;t<this._attribs.length;++t){let n=this._attribs[t];n._pointerBuffer===e&&(--n._pointerBuffer._refCount,n._pointerBuffer._checkDelete(),n._clear())}}setVertexAttribPointer(e,t,n,r,i,o,s,c,l){let u=this._attribs[t];e!==u._pointerBuffer&&(u._pointerBuffer&&(--u._pointerBuffer._refCount,u._pointerBuffer._checkDelete()),e&&(e._refCount+=1),u._pointerBuffer=e),u._pointerSize=n,u._pointerOffset=r,u._pointerStride=i,u._pointerType=o,u._pointerNormal=s,u._inputStride=c,u._inputSize=l}},WebGLVertexArrayGlobalState=class{constructor(e){this._arrayBufferBinding=null;let t=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:t});for(let e=0;e<t;++e)this._attribs[e]=new WebGLVertexArrayGlobalAttribute(e);this._arrayBufferBinding=null}setArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setArrayBuffer(WebGLBuffer?)`);let t=this._arrayBufferBinding;t!==e&&(t&&(--t._refCount,t._checkDelete()),e&&(e._refCount+=1),this._arrayBufferBinding=e)}},Rr=l;function gbytesToUint8Array(e){return e.toArray()}var zr,Br=__esmMin(()=>{zr=r}),Vr,Hr=__esmMin(()=>{Br(),Vr=zr});Vn(),Hr();async function readBytesAsync(e,t=4096,n=Bn.PRIORITY_DEFAULT,r=null){return new Promise((i,o)=>{e.read_bytes_async(t,n,r,(t,n)=>{try{let t=e.read_bytes_finish(n);return t.get_size()===0?i(null):i(gbytesToUint8Array(t))}catch(e){let t=e;if(typeof t.matches==`function`&&(t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.PARTIAL_INPUT)||t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.CONNECTION_CLOSED)||t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.BROKEN_PIPE)||t.matches(Vr.IOErrorEnum,Vr.IOErrorEnum.CLOSED)))return i(null);o(e)}})})}async function*inputStreamAsyncIterator(e,t=4096,n=Bn.PRIORITY_DEFAULT,r=null){let i;for(;(i=await readBytesAsync(e,t,n,r))!==null;)yield i}ie();let Ur=0;const Wr={oes_element_index_uint:getOESElementIndexUint,oes_texture_float:getOESTextureFloat,oes_texture_float_linear:getOESTextureFloatLinear,oes_standard_derivatives:getOESStandardDerivatives,stackgl_destroy_context:getSTACKGLDestroyContext,stackgl_resize_drawingbuffer:getSTACKGLResizeDrawingBuffer,ext_blend_minmax:getEXTBlendMinMax,ext_color_buffer_float:getEXTColorBufferFloat,ext_color_buffer_half_float:getEXTColorBufferHalfFloat,ext_texture_filter_anisotropic:getEXTTextureFilterAnisotropic,oes_texture_half_float:getOESTextureHalfFloat,webgl_debug_renderer_info:getWEBGLDebugRendererInfo};var WebGLContextBase=class{get drawingBufferHeight(){return this.canvas.height||0}get drawingBufferWidth(){return this.canvas.width||0}constructor(e,t={}){this.drawingBufferColorSpace=`srgb`,this.unpackColorSpace=`srgb`,this.RGBA8=32856,this.DEFAULT_ATTACHMENTS=[],this.DEFAULT_COLOR_ATTACHMENTS=[],this._=0,this._extensions={},this._programs={},this._shaders={},this._textures={},this._framebuffers={},this._renderbuffers={},this._buffers={},this._activeProgram=null,this._activeFramebuffer=null,this._activeRenderbuffer=null,this._checkStencil=!1,this._stencilState=!0,this._activeTextureUnit=0,this._errorStack=[],this._maxTextureSize=0,this._maxTextureLevel=0,this._maxCubeMapSize=0,this._maxCubeMapLevel=0,this._maxRenderbufferSize=0,this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this._viewport=new Int32Array([0,0,0,0]),this._scissorBox=new Int32Array([0,0,0,0]),this._gtkFboId=0,this._textureUnits=[],this._drawingBuffer=null,this.canvas=e,this._contextAttributes=new WebGLContextAttributes(flag(t,`alpha`,!0),flag(t,`depth`,!0),flag(t,`stencil`,!1),!1,flag(t,`premultipliedAlpha`,!0),flag(t,`preserveDrawingBuffer`,!1),flag(t,`preferLowPowerToHighPerformance`,!1),flag(t,`failIfMajorPerformanceCaveat`,!1)),this._contextAttributes.premultipliedAlpha=this._contextAttributes.premultipliedAlpha&&this._contextAttributes.alpha}_init(){let e=this._gl.getParameterx(36006);this._gtkFboId=e?.deepUnpack()|0,this._initGLConstants(),this.DEFAULT_ATTACHMENTS=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT],this.DEFAULT_COLOR_ATTACHMENTS=[this.COLOR_ATTACHMENT0];let t=this.drawingBufferWidth||0,n=this.drawingBufferHeight||0;this._=Ur++;let r=this.getParameter(this.MAX_COMBINED_TEXTURE_IMAGE_UNITS);this._textureUnits=Array.from({length:r});for(let e=0;e<r;++e)this._textureUnits[e]=new WebGLTextureUnit(this,e);this.activeTexture(this.TEXTURE0),this._defaultVertexObjectState=new WebGLVertexArrayObjectState(this),this._vertexObjectState=this._defaultVertexObjectState,this._vertexGlobalState=new WebGLVertexArrayGlobalState(this),this._maxTextureSize=this.getParameter(this.MAX_TEXTURE_SIZE),this._maxTextureLevel=xr.log2(xr.nextPow2(this._maxTextureSize)),this._maxCubeMapSize=this.getParameter(this.MAX_CUBE_MAP_TEXTURE_SIZE),this._maxCubeMapLevel=xr.log2(xr.nextPow2(this._maxCubeMapSize)),this._maxRenderbufferSize=this.getParameter(this.MAX_RENDERBUFFER_SIZE),this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this.bindBuffer(this.ARRAY_BUFFER,null),this.bindBuffer(this.ELEMENT_ARRAY_BUFFER,null),this.bindFramebuffer(this.FRAMEBUFFER,null),this.bindRenderbuffer(this.RENDERBUFFER,null),this.viewport(0,0,t,n),this.scissor(0,0,t,n),this.clearDepth(1),this.clearColor(0,0,0,0),this.clearStencil(0),this.clear(this.COLOR_BUFFER_BIT|this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),this.disable(this.DEPTH_TEST),this.disable(this.STENCIL_TEST),this.disable(this.BLEND),this.disable(this.CULL_FACE),this.disable(this.POLYGON_OFFSET_FILL),this.disable(this.SCISSOR_TEST),this._gl.colorMask(!0,!0,!0,!0)}_initGLConstants(){let e=new Rr.WebGLRenderingContextBase().get_webgl_constants();for(let[t,n]of Object.entries(e))Object.defineProperty(this,t,{value:n})}_getGlslVersion(e){return this._getGlsl1Version(e)}_getGlsl1Version(e){return e||this._atLeastGlVersion(4,1)?`100`:`120`}_desktopGlslVersion(){let e=this._gl.getString(35724);if(!e||e.startsWith(`OpenGL ES `))return`130`;let[t,n]=e.split(`.`,2).map(e=>Number.parseInt(e,10));return!Number.isFinite(t)||!Number.isFinite(n)?`130`:String(t*100+(n>=10?n:n*10))}_atLeastGlVersion(e,t){let n=this._gl.getString(7938);if(!n||n.startsWith(`OpenGL ES `))return!1;let[r,i]=n.split(`.`,2).map(e=>Number.parseInt(e,10));return!Number.isFinite(r)||!Number.isFinite(i)?!1:r>e||r===e&&i>=t}_checkOwns(e){return typeof e==`object`&&!!e&&e._ctx===this}_checkValid(e,t){return e instanceof t&&e._!==0}_checkWrapper(e,t){return this._checkValid(e,t)?this._checkOwns(e)?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)}_isObject(e,t,n){if(e!=null&&!(e instanceof n))throw TypeError(t+`(`+n.name+`)`);return!!(this._checkValid(e,n)&&this._checkOwns(e))}_checkStencilState(){return this._checkStencil?(this._checkStencil=!1,this._stencilState=!0,(this.getParameter(this.STENCIL_WRITEMASK)!==this.getParameter(this.STENCIL_BACK_WRITEMASK)||this.getParameter(this.STENCIL_VALUE_MASK)!==this.getParameter(this.STENCIL_BACK_VALUE_MASK)||this.getParameter(this.STENCIL_REF)!==this.getParameter(this.STENCIL_BACK_REF))&&(this.setError(this.INVALID_OPERATION),this._stencilState=!1),this._stencilState):this._stencilState}_validGLSLIdentifier(e){return!(e.indexOf(`webgl_`)===0||e.indexOf(`_webgl_`)===0||e.length>256)}_getParameterDirect(e){return this._gl.getParameterx(e)?.deepUnpack()}getContextAttributes(){return this._contextAttributes}getExtension(e){let t=e.toLowerCase();if(t in this._extensions)return this._extensions[t];let n=Wr[t]?Wr[t](this):null;return n&&(this._extensions[t]=n),n}getSupportedExtensions(){let e=[`ANGLE_instanced_arrays`,`STACKGL_resize_drawingbuffer`,`STACKGL_destroy_context`,`WEBGL_debug_renderer_info`],t=this._gl.getSupportedExtensions();return t?(t.indexOf(`GL_OES_element_index_uint`)>=0&&e.push(`OES_element_index_uint`),t.indexOf(`GL_OES_standard_derivatives`)>=0&&e.push(`OES_standard_derivatives`),t.indexOf(`GL_OES_texture_float`)>=0&&e.push(`OES_texture_float`),t.indexOf(`GL_OES_texture_float_linear`)>=0&&e.push(`OES_texture_float_linear`),(t.indexOf(`GL_OES_texture_half_float`)>=0||t.indexOf(`GL_ARB_half_float_pixel`)>=0)&&e.push(`OES_texture_half_float`),(t.indexOf(`GL_EXT_color_buffer_float`)>=0||t.indexOf(`GL_ARB_color_buffer_float`)>=0)&&e.push(`EXT_color_buffer_float`),t.indexOf(`GL_EXT_color_buffer_half_float`)>=0&&e.push(`EXT_color_buffer_half_float`),t.indexOf(`EXT_draw_buffers`)>=0&&e.push(`WEBGL_draw_buffers`),t.indexOf(`EXT_blend_minmax`)>=0&&e.push(`EXT_blend_minmax`),t.indexOf(`EXT_texture_filter_anisotropic`)>=0&&e.push(`EXT_texture_filter_anisotropic`),t.indexOf(`GL_OES_vertex_array_object`)>=0&&e.push(`OES_vertex_array_object`),e):e}getParameter(e=0){switch(e){case this.ARRAY_BUFFER_BINDING:return this._vertexGlobalState._arrayBufferBinding;case this.ELEMENT_ARRAY_BUFFER_BINDING:return this._vertexObjectState._elementArrayBufferBinding;case this.CURRENT_PROGRAM:return this._activeProgram;case this.FRAMEBUFFER_BINDING:return this._activeFramebuffer;case this.RENDERBUFFER_BINDING:return this._activeRenderbuffer;case this.TEXTURE_BINDING_2D:return this._getActiveTextureUnit()._bind2D;case this.TEXTURE_BINDING_CUBE_MAP:return this._getActiveTextureUnit()._bindCube;case this.VERSION:return`WebGL 1.0 0.0.1`;case this.VENDOR:return``;case this.RENDERER:return`ANGLE`;case 37445:return this._gl.getString(7936);case 37446:return this._gl.getString(7937);case this.SHADING_LANGUAGE_VERSION:return`WebGL GLSL ES 1.0 `;case this.COMPRESSED_TEXTURE_FORMATS:return new Uint32Array;case this.SCISSOR_BOX:return new Int32Array(this._scissorBox);case this.VIEWPORT:return new Int32Array(this._viewport);case this.MAX_VIEWPORT_DIMS:return new Int32Array([32767,32767]);case this.ALIASED_LINE_WIDTH_RANGE:case this.ALIASED_POINT_SIZE_RANGE:return new Float32Array([1,1]);case this.DEPTH_RANGE:return new Float32Array([0,1]);case this.BLEND_COLOR:case this.COLOR_CLEAR_VALUE:return new Float32Array(this._gl.getParameterfv(e,4));case this.COLOR_WRITEMASK:{let t=this._gl.getParameteriv(e,4);return[!!t[0],!!t[1],!!t[2],!!t[3]]}case this.DEPTH_CLEAR_VALUE:case this.LINE_WIDTH:case this.POLYGON_OFFSET_FACTOR:case this.POLYGON_OFFSET_UNITS:case this.SAMPLE_COVERAGE_VALUE:return this._gl.getParameterf(e);case this.BLEND:case this.CULL_FACE:case this.DEPTH_TEST:case this.DEPTH_WRITEMASK:case this.DITHER:case this.POLYGON_OFFSET_FILL:case this.SAMPLE_COVERAGE_INVERT:case this.SCISSOR_TEST:case this.STENCIL_TEST:case this.UNPACK_PREMULTIPLY_ALPHA_WEBGL:return!!this._gl.getParameteri(e);case this.UNPACK_FLIP_Y_WEBGL:return this._unpackFlipY;case this.ACTIVE_TEXTURE:case this.ALPHA_BITS:case this.BLEND_DST_ALPHA:case this.BLEND_DST_RGB:case this.BLEND_EQUATION_ALPHA:case this.BLEND_EQUATION_RGB:case this.BLEND_SRC_ALPHA:case this.BLEND_SRC_RGB:case this.BLUE_BITS:case this.CULL_FACE_MODE:case this.DEPTH_BITS:case this.DEPTH_FUNC:case this.FRONT_FACE:case this.GENERATE_MIPMAP_HINT:case this.GREEN_BITS:return this._gl.getParameteri(e);case this.MAX_RENDERBUFFER_SIZE:return this._maxRenderbufferSize;case this.MAX_COMBINED_TEXTURE_IMAGE_UNITS:case this.MAX_CUBE_MAP_TEXTURE_SIZE:case this.MAX_FRAGMENT_UNIFORM_VECTORS:case this.MAX_TEXTURE_IMAGE_UNITS:case this.MAX_TEXTURE_SIZE:case this.MAX_VARYING_VECTORS:case this.MAX_VERTEX_ATTRIBS:case this.MAX_VERTEX_TEXTURE_IMAGE_UNITS:case this.MAX_VERTEX_UNIFORM_VECTORS:case this.PACK_ALIGNMENT:case this.RED_BITS:case this.SAMPLE_BUFFERS:case this.SAMPLES:case this.STENCIL_BACK_FAIL:case this.STENCIL_BACK_FUNC:case this.STENCIL_BACK_PASS_DEPTH_FAIL:case this.STENCIL_BACK_PASS_DEPTH_PASS:case this.STENCIL_BACK_REF:case this.STENCIL_BACK_VALUE_MASK:case this.STENCIL_BACK_WRITEMASK:case this.STENCIL_BITS:case this.STENCIL_CLEAR_VALUE:case this.STENCIL_FAIL:case this.STENCIL_FUNC:case this.STENCIL_PASS_DEPTH_FAIL:case this.STENCIL_PASS_DEPTH_PASS:case this.STENCIL_REF:case this.STENCIL_VALUE_MASK:case this.STENCIL_WRITEMASK:case this.SUBPIXEL_BITS:case this.UNPACK_ALIGNMENT:case this.UNPACK_COLORSPACE_CONVERSION_WEBGL:return this._gl.getParameteri(e);case this.IMPLEMENTATION_COLOR_READ_FORMAT:case this.IMPLEMENTATION_COLOR_READ_TYPE:return this._getParameterDirect(e);default:if(this._extensions.webgl_draw_buffers){let t=this._extensions.webgl_draw_buffers;switch(e){case t.DRAW_BUFFER0_WEBGL:case t.DRAW_BUFFER1_WEBGL:case t.DRAW_BUFFER2_WEBGL:case t.DRAW_BUFFER3_WEBGL:case t.DRAW_BUFFER4_WEBGL:case t.DRAW_BUFFER5_WEBGL:case t.DRAW_BUFFER6_WEBGL:case t.DRAW_BUFFER7_WEBGL:case t.DRAW_BUFFER8_WEBGL:case t.DRAW_BUFFER9_WEBGL:case t.DRAW_BUFFER10_WEBGL:case t.DRAW_BUFFER11_WEBGL:case t.DRAW_BUFFER12_WEBGL:case t.DRAW_BUFFER13_WEBGL:case t.DRAW_BUFFER14_WEBGL:case t.DRAW_BUFFER15_WEBGL:return t._buffersState.length===1&&t._buffersState[0]===this.BACK?this.BACK:this._getParameterDirect(e);case t.MAX_DRAW_BUFFERS_WEBGL:case t.MAX_COLOR_ATTACHMENTS_WEBGL:return this._getParameterDirect(e)}}let t=this._extensions.oes_standard_derivatives;if(t&&e===t.FRAGMENT_SHADER_DERIVATIVE_HINT_OES)return this._getParameterDirect(e);let n=this._extensions.ext_texture_filter_anisotropic;if(n&&e===n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)return this._getParameterDirect(e);let r=this._extensions.oes_vertex_array_object;return r&&e===r.VERTEX_ARRAY_BINDING_OES?r._activeVertexArrayObject:(this.setError(this.INVALID_ENUM),null)}}destroy(){warnNotImplemented(`destroy`)}};installAllContextMethods(WebGLContextBase.prototype);var WebGLRenderingContext$1=class extends WebGLContextBase{static{__name$1(this,`WebGLRenderingContext`)}get _gl(){return this._native}constructor(e,t={}){super(e,t),this._attrib0Buffer=null,this._native=new Rr.WebGLRenderingContext({}),this._init();let n=this.createBuffer();this._attrib0Buffer=n}_beginAttrib0Hack(){this._native.bindBuffer(this.ARRAY_BUFFER,this._attrib0Buffer?._||0);let e=new Uint8Array(this._vertexGlobalState._attribs[0]._data.buffer);this._native.bufferData(this.ARRAY_BUFFER,Uint8ArrayToVariant(e),this.STREAM_DRAW),this._native.enableVertexAttribArray(0),this._native.vertexAttribPointer(0,4,this.FLOAT,!1,0,0),this._native._vertexAttribDivisor(0,1)}_endAttrib0Hack(){let e=this._vertexObjectState._attribs[0];e._pointerBuffer?this._native.bindBuffer(this.ARRAY_BUFFER,e._pointerBuffer._):this._native.bindBuffer(this.ARRAY_BUFFER,0),this._native.vertexAttribPointer(0,e._inputSize,e._pointerType,e._pointerNormal,e._inputStride,e._pointerOffset),this._native._vertexAttribDivisor(0,e._divisor),this._native.disableVertexAttribArray(0),this._vertexGlobalState._arrayBufferBinding?this._native.bindBuffer(this.ARRAY_BUFFER,this._vertexGlobalState._arrayBufferBinding._):this._native.bindBuffer(this.ARRAY_BUFFER,0)}drawArrays(e=0,t=0,n=0){if(t<0||n<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let r=vertexCount(this,e,n);if(r<0){this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||n===0)return;let i=t;if(n>0&&(i=n+t-1>>>0),this._checkVertexAttribState(i)){let n=this._extensions.webgl_draw_buffers;if(this._vertexObjectState._attribs[0]._isPointer||n&&n._buffersState&&n._buffersState.length>0)return this._native.drawArrays(e,t,r);this._beginAttrib0Hack(),this._native._drawArraysInstanced(e,t,r,1),this._endAttrib0Hack()}}drawElements(e=0,t=0,n=0,r=0){if(t<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=this._vertexObjectState._elementArrayBufferBinding;if(!i){this.setError(this.INVALID_OPERATION);return}let o=null,s=r;if(n===this.UNSIGNED_SHORT){if(s%2){this.setError(this.INVALID_OPERATION);return}s>>=1,o=new Uint16Array(i._elements.buffer)}else if(this._extensions.oes_element_index_uint&&n===this.UNSIGNED_INT){if(s%4){this.setError(this.INVALID_OPERATION);return}s>>=2,o=new Uint32Array(i._elements.buffer)}else if(n===this.UNSIGNED_BYTE)o=i._elements;else{this.setError(this.INVALID_ENUM);return}let c=t;switch(e){case this.TRIANGLES:t%3&&(c-=t%3);break;case this.LINES:t%2&&(c-=t%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(t<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(t<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(t===0){this._checkVertexAttribState(0);return}if(t+s>>>0>o.length){this.setError(this.INVALID_OPERATION);return}let l=-1;for(let e=s;e<s+t;++e)l=Math.max(l,o[e]);if(l<0){this._checkVertexAttribState(0);return}if(this._checkVertexAttribState(l)&&c>0){if(this._vertexObjectState._attribs[0]._isPointer)return this._native.drawElements(e,c,n,r);this._beginAttrib0Hack(),this._native._drawElementsInstanced(e,c,n,r,1),this._endAttrib0Hack()}}},WebGLQuery=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._queries[this._|0],e._native2.deleteQuery(this._|0)}},WebGLSampler=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._samplers[this._|0],e._native2.deleteSampler(this._|0)}},WebGLSync=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._syncs[this._|0],e._native2.deleteSync(this._|0)}},WebGLTransformFeedback=class extends Linkable{constructor(e,t){super(e),this._ctx=t}_performDelete(){let e=this._ctx;delete e._transformFeedbacks[this._|0],e._native2.deleteTransformFeedback(this._|0)}},WebGLVertexArrayObject=class extends Linkable{constructor(e,t){super(e),this._ctx=t,this._objectState=new WebGLVertexArrayObjectState(t)}_performDelete(){let e=this._ctx;e._vertexObjectState===this._objectState&&(e._vertexObjectState=e._defaultVertexObjectState),this._objectState.cleanUp(),delete e._vertexArrayObjects[this._|0],e._native2.deleteVertexArray(this._|0)}};ie();const Gr={createVertexArray(){let e=this._native2.createVertexArray();if(!e)return null;let t=new WebGLVertexArrayObject(e,this);return this._vertexArrayObjects[e]=t,t},deleteVertexArray(e){!e||!(e instanceof WebGLVertexArrayObject)||(e._pendingDelete=!0,e._checkDelete())},isVertexArray(e){return!e||!(e instanceof WebGLVertexArrayObject)?!1:this._native2.isVertexArray(e._)},bindVertexArray(e){e===null?(this._native2.bindVertexArray(0),this._vertexObjectState=this._defaultVertexObjectState):e instanceof WebGLVertexArrayObject?(this._native2.bindVertexArray(e._),this._vertexObjectState=e._objectState):this.setError(this.INVALID_OPERATION)},createQuery(){let e=this._native2.createQuery();if(!e)return null;let t=new WebGLQuery(e,this);return this._queries[e]=t,t},deleteQuery(e){!e||!(e instanceof WebGLQuery)||(e._pendingDelete=!0,e._checkDelete())},isQuery(e){return!e||!(e instanceof WebGLQuery)?!1:this._native2.isQuery(e._)},beginQuery(e,t){t instanceof WebGLQuery&&this._native2.beginQuery(e,t._)},endQuery(e){this._native2.endQuery(e)},getQuery(e,t){return warnNotImplemented(`WebGL2RenderingContext.getQuery`),null},getQueryParameter(e,t){return e instanceof WebGLQuery?this._native2.getQueryParameter(e._,t):null},createSampler(){let e=this._native2.createSampler();if(!e)return null;let t=new WebGLSampler(e,this);return this._samplers[e]=t,t},deleteSampler(e){!e||!(e instanceof WebGLSampler)||(e._pendingDelete=!0,e._checkDelete())},isSampler(e){return!e||!(e instanceof WebGLSampler)?!1:this._native2.isSampler(e._)},bindSampler(e,t){this._native2.bindSampler(e,t?t._:0)},samplerParameteri(e,t,n){e instanceof WebGLSampler&&this._native2.samplerParameteri(e._,t,n)},samplerParameterf(e,t,n){e instanceof WebGLSampler&&this._native2.samplerParameterf(e._,t,n)},getSamplerParameter(e,t){return e instanceof WebGLSampler?t===33082||t===33083?this._native2.getSamplerParameterf(e._,t):this._native2.getSamplerParameteri(e._,t):null},fenceSync(e,t){let n=this._native2.fenceSync(e,t);if(!n)return null;let r=new WebGLSync(n,this);return this._syncs[n]=r,r},isSync(e){return!e||!(e instanceof WebGLSync)?!1:this._native2.isSync(e._)},deleteSync(e){!e||!(e instanceof WebGLSync)||(e._pendingDelete=!0,e._checkDelete())},clientWaitSync(e,t,n){return e instanceof WebGLSync?this._native2.clientWaitSync(e._,t,n):37148},waitSync(e,t,n){e instanceof WebGLSync&&this._native2.waitSync(e._,t,n)},getSyncParameter(e,t){return e instanceof WebGLSync?this._native2.getSyncParameter(e._,t):null},createTransformFeedback(){let e=this._native2.createTransformFeedback();if(!e)return null;let t=new WebGLTransformFeedback(e,this);return this._transformFeedbacks[e]=t,t},deleteTransformFeedback(e){!e||!(e instanceof WebGLTransformFeedback)||(e._pendingDelete=!0,e._checkDelete())},isTransformFeedback(e){return!e||!(e instanceof WebGLTransformFeedback)?!1:this._native2.isTransformFeedback(e._)},bindTransformFeedback(e,t){this._native2.bindTransformFeedback(e,t?t._:0)},beginTransformFeedback(e){this._native2.beginTransformFeedback(e)},endTransformFeedback(){this._native2.endTransformFeedback()},pauseTransformFeedback(){this._native2.pauseTransformFeedback()},resumeTransformFeedback(){this._native2.resumeTransformFeedback()},transformFeedbackVaryings(e,t,n){this._native2.transformFeedbackVaryings(e._,t,n)},getTransformFeedbackVarying(e,t){let n=this._native2.getTransformFeedbackVarying(e._,t).deepUnpack();return new WebGLActiveInfo({size:n.size,type:n.type,name:n.name})}};function installObjectLifecycleMethods(e){Object.assign(e,Gr)}const Kr={texImage3D(e,t,n,r,i,o,s,c,l,u){u===null?this._native2.texImage3DNull(e,t,n,r,i,o,s,c,l):this._native2.texImage3D(e,t,n,r,i,o,s,c,l,Uint8ArrayToVariant(new Uint8Array(u.buffer,u.byteOffset,u.byteLength)))},texSubImage3D(e,t,n,r,i,o,s,c,l,u,d){d!==null&&this._native2.texSubImage3D(e,t,n,r,i,o,s,c,l,u,Uint8ArrayToVariant(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)))},compressedTexImage3D(e,t,n,r,i,o,s,c,l){this._native2.compressedTexImage3D(e,t,n,r,i,o,s,Uint8ArrayToVariant(new Uint8Array(l.buffer,l.byteOffset,l.byteLength)))},compressedTexSubImage3D(e,t,n,r,i,o,s,c,l,u,d){this._native2.compressedTexSubImage3D(e,t,n,r,i,o,s,c,l,Uint8ArrayToVariant(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)))},copyTexSubImage3D(e,t,n,r,i,o,s,c,l){this._native2.copyTexSubImage3D(e,t,n,r,i,o,s,c,l)},texStorage2D(e,t,n,r,i){this._native2.texStorage2D(e,t,n,r,i);let o=this._getTexImage(e);if(o){for(let e=0;e<t;e++)o._levelWidth[e]=Math.max(1,r>>e),o._levelHeight[e]=Math.max(1,i>>e);o._format=this.RGBA,o._type=this.UNSIGNED_BYTE}},texStorage3D(e,t,n,r,i,o){this._native2.texStorage3D(e,t,n,r,i,o)}};function installTexImage3DMethods(e){Object.assign(e,Kr)}const qr={uniform1ui(e,t){e&&this._native2.uniform1ui(e._,t)},uniform2ui(e,t,n){e&&this._native2.uniform2ui(e._,t,n)},uniform3ui(e,t,n,r){e&&this._native2.uniform3ui(e._,t,n,r)},uniform4ui(e,t,n,r,i){e&&this._native2.uniform4ui(e._,t,n,r,i)},uniform1uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform1uiv(e._,i.length,i)},uniform2uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform2uiv(e._,i.length/2,i)},uniform3uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform3uiv(e._,i.length/3,i)},uniform4uiv(e,t,n,r){if(!e)return;let i=t instanceof Uint32Array?t:new Uint32Array(t);this._native2.uniform4uiv(e._,i.length/4,i)},uniformMatrix2x3fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix2x3fv(e._,t,o)},uniformMatrix3x2fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix3x2fv(e._,t,o)},uniformMatrix2x4fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix2x4fv(e._,t,o)},uniformMatrix4x2fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix4x2fv(e._,t,o)},uniformMatrix3x4fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix3x4fv(e._,t,o)},uniformMatrix4x3fv(e,t,n,r,i){if(!e)return;let o=n instanceof Float32Array?n:new Float32Array(n);this._native2.uniformMatrix4x3fv(e._,t,o)}};function installUniformMethods(e){Object.assign(e,qr)}const Jr={clearBufferfv(e,t,n,r){let i=this._native2;if(typeof i.clearBufferfv==`function`){i.clearBufferfv(e,t,Array.from(n));return}let o=n;if(e===6144){let e=this.getParameter(this.COLOR_CLEAR_VALUE);this.clearColor(o[0]??0,o[1]??0,o[2]??0,o[3]??0),this.clear(this.COLOR_BUFFER_BIT),e&&this.clearColor(e[0],e[1],e[2],e[3])}else if(e===6145){let e=this.getParameter(this.DEPTH_CLEAR_VALUE);this.clearDepth(o[0]??1),this.clear(this.DEPTH_BUFFER_BIT),e!==null&&this.clearDepth(e)}},clearBufferiv(e,t,n,r){let i=this._native2;if(typeof i.clearBufferiv==`function`){i.clearBufferiv(e,t,Array.from(n));return}if(e===6146){let e=n,t=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearStencil(e[0]??0),this.clear(this.STENCIL_BUFFER_BIT),t!==null&&this.clearStencil(t)}},clearBufferuiv(e,t,n,r){let i=this._native2;if(typeof i.clearBufferuiv==`function`){i.clearBufferuiv(e,t,Array.from(n));return}},clearBufferfi(e,t,n,r){let i=this._native2;if(typeof i.clearBufferfi==`function`){i.clearBufferfi(e,t,n,r);return}if(e===34041){let e=this.getParameter(this.DEPTH_CLEAR_VALUE),t=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearDepth(n),this.clearStencil(r),this.clear(this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),e!==null&&this.clearDepth(e),t!==null&&this.clearStencil(t)}}};function installClearBufferMethods(e){Object.assign(e,Jr)}re();function debugGlEnabled(){return globalThis.__GJSIFY_DEBUG_GL===!0}const Yr={drawArraysInstanced(e,t,n,r){if(t<0||n<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=vertexCount(this,e,n);if(i<0){this.setError(this.INVALID_ENUM);return}if(this._framebufferOk()&&!(n===0||r===0)&&this._checkVertexAttribState(n+t-1>>>0)){if(debugGlEnabled()){let e=this,t=e.__drawInstCount=(e.__drawInstCount|0)+1;(t<=5||t%100==0)&&M.log(`[WebGL] drawArraysInstanced #${t} count=${i} instances=${r} fbo=${this._activeFramebuffer?._??`_gtkFbo`}`)}this._native2.drawArraysInstanced(e,t,i,r)}},drawElementsInstanced(e,t,n,r,i){if(t<0||r<0||i<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let o=this._vertexObjectState._elementArrayBufferBinding;if(!o){this.setError(this.INVALID_OPERATION);return}let s=null,c=r;if(n===this.UNSIGNED_SHORT){if(c%2){this.setError(this.INVALID_OPERATION);return}c>>=1,s=new Uint16Array(o._elements.buffer)}else if(n===this.UNSIGNED_INT){if(c%4){this.setError(this.INVALID_OPERATION);return}c>>=2,s=new Uint32Array(o._elements.buffer)}else if(n===this.UNSIGNED_BYTE)s=o._elements;else{this.setError(this.INVALID_ENUM);return}let l=t;switch(e){case this.TRIANGLES:t%3&&(l-=t%3);break;case this.LINES:t%2&&(l-=t%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(t<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(t<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(l===0||i===0){this._checkVertexAttribState(0);return}if(l+c>>>0>s.length){this.setError(this.INVALID_OPERATION);return}let u=0;for(let e=c;e<c+l;++e)s[e]>u&&(u=s[e]);this._checkVertexAttribState(u)&&this._native2.drawElementsInstanced(e,l,n,r,i)},vertexAttribDivisor(e,t){this._checkVertexIndex(e)&&(this._native2.vertexAttribDivisor(e,t),this._vertexObjectState._attribs[e]._divisor=t)},vertexAttribIPointer(e,t,n,r,i){this._native2.vertexAttribIPointer(e,t,n,r,i)},drawBuffers(e){let t=!1;for(let n=0;n<e.length;n++)if(e[n]===1029){t=!0;break}if(!t){this._native2.drawBuffers(e);return}this._native2.drawBuffers(e.map(e=>e===1029?this.COLOR_ATTACHMENT0:e))},drawRangeElements(e,t,n,r,i,o){if(r<0||o<0){this.setError(this.INVALID_VALUE);return}if(n<t){this.setError(this.INVALID_VALUE);return}this.drawElements(e,r,i,o)},blitFramebuffer(e,t,n,r,i,o,s,c,l,u){if(debugGlEnabled()){let e=this._gl.getError();e!==0&&M.log(`[WebGL] blitFramebuffer PRE-ERROR 0x${e.toString(16)}`)}if(this._native2.blitFramebuffer(e,t,n,r,i,o,s,c,l,u),debugGlEnabled()){let i=this._gl.getError(),o=this,s=o.__blitCount=(o.__blitCount|0)+1;s<=5&&M.log(`[WebGL] blitFramebuffer #${s} src=(${e},${t},${n},${r}) readFbo=${this._activeReadFramebuffer?._??`_gtkFbo`} err=${i===0?`OK`:`0x`+i.toString(16)}`)}},framebufferTextureLayer(e,t,n,r,i){this._native2.framebufferTextureLayer(e,t,n?n._:0,r,i)},invalidateFramebuffer(e,t){this._native2.invalidateFramebuffer(e,t)},invalidateSubFramebuffer(e,t,n,r,i,o){this._native2.invalidateSubFramebuffer(e,t,n,r,i,o)},readBuffer(e){this._native2.readBuffer(e)},renderbufferStorageMultisample(e,t,n,r,i){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let o=this._activeRenderbuffer;if(!o){this.setError(this.INVALID_OPERATION);return}this._saveError(),this._native2.renderbufferStorageMultisample(e,t,n,r,i);let s=this.getError();this._restoreError(s),s===this.NO_ERROR&&(o._width=r,o._height=i,o._format=n)}};function installInstancedAndFramebufferOpsMethods(e){Object.assign(e,Yr)}ie();var Xr=class WebGL2RenderingContext extends WebGLContextBase{get _gl(){return this._native2}constructor(e,t={}){super(e,t),this._queries={},this._samplers={},this._transformFeedbacks={},this._vertexArrayObjects={},this._syncs={},this._activeReadFramebuffer=null,this._activeDrawFramebuffer=null,this._native2=new Rr.WebGL2RenderingContext({}),this._init()}_getGlslVersion(e){return e?`300 es`:this._desktopGlslVersion()}_validFramebufferAttachment(e){return super._validFramebufferAttachment(e)?!0:e>=36065&&e<=36079}static{this._WGL2_ALL_COLOR_ATTACHMENTS=[36064,36065,36066,36067,36068,36069,36070,36071,36072,36073,36074,36075,36076,36077,36078,36079]}_getColorAttachments(){return WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS}_preCheckFramebufferStatus(e){let t=e._attachments,n=0,r=0,i=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT,...WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS];for(let o of i){let i=t[o];if(i){if(i instanceof WebGLTexture){let t=e._attachmentLevel[o]??0,s=i._levelWidth[t]??0,c=i._levelHeight[t]??0;if(s>0&&c>0){n=s,r=c;break}}else if(i instanceof WebGLRenderbuffer&&i._width>0&&i._height>0){n=i._width,r=i._height;break}}}return n>0&&r>0?(e._width=n,e._height=r,this.FRAMEBUFFER_COMPLETE):this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT}_updateFramebufferAttachments(e){if(super._updateFramebufferAttachments(e),e)for(let t=1;t<=15;t++){let n=36064+t;if(!(n in e._attachments))continue;let r=e._attachments[n];if(r instanceof WebGLTexture){let t=e._attachmentFace[n]||this.TEXTURE_2D,i=e._attachmentLevel[n]??0;this._gl.framebufferTexture2D(this.FRAMEBUFFER,n,t,r._|0,i|0)}else r instanceof WebGLRenderbuffer?this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,n,this.RENDERBUFFER,r._|0):this._gl.framebufferTexture2D(this.FRAMEBUFFER,n,this.TEXTURE_2D,0,0)}}bindBuffer(e,t){if(e===35345||e===35982||e===36662||e===36663){let n=t?t._|0:0;this._gl.bindBuffer(e,n);return}super.bindBuffer(e,t)}bindFramebuffer(e,t){if(e===36008||e===36009){if(!checkObject(t))throw TypeError(`bindFramebuffer(GLenum, WebGLFramebuffer)`);if(t&&t._pendingDelete||t&&!this._checkWrapper(t,WebGLFramebuffer))return;let n=t?t._|0:this._gtkFboId;if(this._gl.bindFramebuffer(e,n),e===36008){let e=this._activeReadFramebuffer;e!==t&&(e&&(--e._refCount,e._checkDelete()),t&&(t._refCount+=1)),this._activeReadFramebuffer=t}else{let e=this._activeDrawFramebuffer;e!==t&&(e&&(--e._refCount,e._checkDelete()),t&&(t._refCount+=1)),this._activeDrawFramebuffer=t,this._activeFramebuffer=t}return}super.bindFramebuffer(this.FRAMEBUFFER,t),this._activeReadFramebuffer=t,this._activeDrawFramebuffer=t}deleteFramebuffer(e){this._activeReadFramebuffer===e&&this.bindFramebuffer(36008,null),this._activeDrawFramebuffer===e&&this.bindFramebuffer(36009,null),super.deleteFramebuffer(e)}bufferData(e,t,n){let r=e===35345||e===35982||e===36662||e===36663,i=n===35041||n===35043||n===35045||n===35042||n===35044||n===35046?this.STATIC_DRAW:n;if(r){if(typeof t==`number`)t>=0&&this._gl.bufferDataSizeOnly(e,t,i);else if(typeof t==`object`&&t){let n=arrayToUint8Array(t);this._gl.bufferData(e,Uint8ArrayToVariant(n),i)}return}super.bufferData(e,t,i)}bufferSubData(e,t,n){if(e===35345||e===35982||e===36662||e===36663){if(t<0){this.setError(this.INVALID_VALUE);return}if(!n){this.setError(this.INVALID_VALUE);return}let r=arrayToUint8Array(n);this._gl.bufferSubData(e,t,Uint8ArrayToVariant(r));return}super.bufferSubData(e,t,n)}bindTexture(e,t){if(e===32879||e===35866){let n=t,r=n?n._|0:0;this._gl.bindTexture(e,r),n&&(n._binding=e);return}super.bindTexture(e,t)}texParameteri(e,t,n){if(e===32879||e===35866){this._gl.texParameteri(e,t,n);return}if(t===32882||t===34892||t===34893||t===33084||t===33085||t===33083||t===33082){this._gl.texParameteri(e,t,n);return}super.texParameteri(e,t,n)}drawArrays(e,t,n){if(t<0||n<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let r=vertexCount(this,e,n);if(r<0){this.setError(this.INVALID_ENUM);return}this._framebufferOk()&&n!==0&&this._checkVertexAttribState(n+t-1>>>0)&&this._native2.drawArrays(e,t,r)}drawElements(e=0,t=0,n=0,r=0){if(t<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let i=this._vertexObjectState._elementArrayBufferBinding;if(!i){this.setError(this.INVALID_OPERATION);return}let o=null,s=r;if(n===this.UNSIGNED_SHORT){if(s%2){this.setError(this.INVALID_OPERATION);return}s>>=1,o=new Uint16Array(i._elements.buffer)}else if(n===this.UNSIGNED_INT){if(s%4){this.setError(this.INVALID_OPERATION);return}s>>=2,o=new Uint32Array(i._elements.buffer)}else if(n===this.UNSIGNED_BYTE)o=i._elements;else{this.setError(this.INVALID_ENUM);return}let c=t;switch(e){case this.TRIANGLES:t%3&&(c-=t%3);break;case this.LINES:t%2&&(c-=t%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(t<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(t<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||t===0)return;let l=0;for(let e=s;e<s+c;++e)e<o.length&&o[e]>l&&(l=o[e]);this._checkVertexAttribState(l)&&this._native2.drawElements(e,c,n,r)}bindBufferBase(e,t,n){this._native2.bindBufferBase(e,t,n?n._:0)}bindBufferRange(e,t,n,r,i){this._native2.bindBufferRange(e,t,n?n._:0,r,i)}copyBufferSubData(e,t,n,r,i){this._native2.copyBufferSubData(e,t,n,r,i)}getBufferSubData(e,t,n,r,i){let o=i===void 0?n.byteLength-(r??0):i,s=this._native2.getBufferSubData(e,t,o),c=new Uint8Array(n.buffer,n.byteOffset+(r??0)*(n instanceof Uint8Array?1:n.BYTES_PER_ELEMENT??1));c.set(s.subarray(0,c.byteLength))}texImage2D(e=0,t=0,n=0,r=0,i=0,o=0,c=0,l=0,u){let d=0,f=0,p=0,m=0;if(arguments.length===6)if(l=i,p=r,o instanceof s.Pixbuf){let e=o;d=e.get_width(),f=e.get_height(),u=e.get_pixels()}else{let e=extractImageData(o);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);d=e.width,f=e.height,u=e.data}else arguments.length>=9&&(d=r,f=i,m=o,p=c);let h=this._getTexImage(e);if(!h){this.setError(this.INVALID_OPERATION);return}let g=convertPixels(u);if(this._unpackPremultAlpha&&g&&p===this.RGBA&&(g=premultiplyAlpha(g)),this._unpackFlipY&&g&&d>0&&f>0){let e=this._computePixelSize(l,p);if(e>0){let t=this._computeRowStride(d,e),n=new Uint8Array(g.length);for(let e=0;e<f;e++){let r=e*t,i=(f-1-e)*t;n.set(g.subarray(r,r+t),i)}g=n}}this._saveError(),this._gl.texImage2D(e,t,n,d,f,m,p,l,Uint8ArrayToVariant(g));let _=this.getError();if(this._restoreError(_),_!==this.NO_ERROR)return;h._levelWidth[t]=d,h._levelHeight[t]=f,h._format=p,h._type=l;let v=this._activeFramebuffer;if(v){let e=!1,t=this._getAttachments();for(let n=0;n<t.length;++n)if(v._attachments[t[n]]===h){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}}texSubImage2D(e=0,t=0,n=0,r=0,i=0,o=0,c=0,l=0,u){let d=0,f=0,p=0;if(arguments.length===7)if(l=o,p=i,c instanceof s.Pixbuf){let e=c;d=e.get_width(),f=e.get_height(),u=e.get_pixels()}else{let e=extractImageData(c);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);d=e.width,f=e.height,u=e.data}else d=i,f=o,p=c;if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}let m=convertPixels(u);if(!m){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&m&&p===this.RGBA&&(m=premultiplyAlpha(m)),this._unpackFlipY&&m&&d>0&&f>0){let e=this._computePixelSize(l,p);if(e>0){let t=this._computeRowStride(d,e),n=new Uint8Array(m.length);for(let e=0;e<f;e++){let r=e*t,i=(f-1-e)*t;n.set(m.subarray(r,r+t),i)}m=n}}this._gl.texSubImage2D(e,t,n,r,d,f,p,l,Uint8ArrayToVariant(m))}getUniform(e,t){let n=t?._activeInfo?.type,r=5125,i=36294,o=36295,s=n===r||n===i||n===o||n===36296,c=e;if(!s)return super.getUniform(c,t);if(!e||!t)return null;let l=this._native2.getUniformi(c._|0,t._|0);return l?n===r?l[0]>>>0:n===i?new Uint32Array([l[0]>>>0,l[1]>>>0]):n===o?new Uint32Array([l[0]>>>0,l[1]>>>0,l[2]>>>0]):new Uint32Array([l[0]>>>0,l[1]>>>0,l[2]>>>0,l[3]>>>0]):null}getUniformBlockIndex(e,t){return this._native2.getUniformBlockIndex(e._,t)}uniformBlockBinding(e,t,n){this._native2.uniformBlockBinding(e._,t,n)}getActiveUniformBlockName(e,t){let n=this._native2.getActiveUniformBlockName(e._,t);return n.length>0?n:null}getActiveUniformBlockParameter(e,t,n){return this._native2.getActiveUniformBlockParameter(e._,t,n)}getActiveUniforms(e,t,n){return this._native2.getActiveUniforms(e._,t,n)}getFragDataLocation(e,t){return this._native2.getFragDataLocation(e._,t)}getIndexedParameter(e,t){return this._native2.getIndexedParameteri(e,t)}getInternalformatParameter(e,t,n){return this._native2.getInternalformatParameter(e,t,n)}getParameter(e){if(e===7938)return`WebGL 2.0`;if(e===35724)return`WebGL GLSL ES 3.00`;if(e===7939)return warnNotImplemented(`WebGL2RenderingContext.getParameter(GL_EXTENSIONS)`),``;if(e===36006)return this._activeDrawFramebuffer;if(e===36010)return this._activeReadFramebuffer;switch(e){case 36183:case 35071:case 32883:case 36063:case 34852:case 36203:case 33001:case 33e3:case 37157:case 35373:case 35657:case 35077:case 35978:case 35979:case 35968:case 35376:case 35375:case 35659:case 37154:case 35371:case 35658:case 35379:case 35374:case 35377:case 35076:case 3330:case 3332:case 3331:case 35053:case 35055:case 3074:case 32874:case 35869:case 36389:case 35983:case 35368:case 35380:case 32878:case 3314:case 32877:case 3316:case 3315:case 34045:return this._native2.getParameterx(e)?.deepUnpack()|0;case 35977:case 36388:case 36387:return!!this._native2.getParameterx(e)?.deepUnpack()}return super.getParameter(e)}getStringi(e,t){let n=this._native2.getStringi(e,t);return n.length>0?n:null}renderbufferStorage(e,t,n,r){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let i=this._activeRenderbuffer;if(!i){this.setError(this.INVALID_OPERATION);return}if(n<0||r<0){this.setError(this.INVALID_VALUE);return}for(;this._gl.getError()!==this.NO_ERROR;);if(this._gl.renderbufferStorage(e,t,n,r),this._gl.getError()!==this.NO_ERROR)return;i._width=n,i._height=r,i._format=t;let o=this._activeFramebuffer;if(o){let e=this._getAttachments(),t=!1;for(let n=0;n<e.length;++n)if(o._attachments[e[n]]===i){t=!0;break}t&&this._updateFramebufferAttachments(o)}}getSupportedExtensions(){let e=super.getSupportedExtensions();for(let t of[`EXT_color_buffer_float`,`EXT_color_buffer_half_float`,`OES_texture_half_float`])e.indexOf(t)===-1&&e.push(t);return e}readPixels(e,t,n,r,i,o,s){if(!s)return;if(n<0||r<0){this.setError(this.INVALID_VALUE);return}if(!this._framebufferOk())return;let c=i===6408||i===32856?4:i===6407?3:i===33319?2:1,l=o===5126?4:o===5131||o===36193?2:o===5125||o===5124?4:o===5123||o===5122?2:1,u=n*r*c*l,d=new Uint8Array(u);this._saveError();let f=this._gl.readPixels(e,t,n,r,i,o,Uint8ArrayToVariant(d)),p=this.getError();if(this._restoreError(p),p!==this.NO_ERROR)return;let m=f&&f.length>0?f:d;if(s instanceof Uint8Array)s.set(m);else if(s instanceof Float32Array){let e=new Float32Array(m.buffer,0,s.length);s.set(e)}}_framebufferOk(){return!0}};installObjectLifecycleMethods(Xr.prototype),installTexImage3DMethods(Xr.prototype),installUniformMethods(Xr.prototype),installClearBufferMethods(Xr.prototype),installInstancedAndFramebufferOpsMethods(Xr.prototype);function defineGlobalIfMissing(e,t){globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}defineGlobalIfMissing(`WebGLRenderingContext`,WebGLRenderingContext$1),defineGlobalIfMissing(`WebGL2RenderingContext`,Xr);const Zr=Symbol(`abort`),Qr=Symbol(`internal`);var $r=class AbortSignal extends EventTarget{#e=!1;#t=void 0;onabort=null;constructor(e){if(super(),e!==Qr)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get reason(){return this.#t}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.#t}[Zr](e){if(this.#e)return;this.#e=!0,this.#t=e??new Qe(`The operation was aborted.`,`AbortError`);let t=new Event(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,t),this.dispatchEvent(t)}static abort(e){let t=new AbortSignal(Qr);return t[Zr](e),t}static timeout(e){let t=new AbortSignal(Qr);return setTimeout(()=>{t[Zr](new Qe(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(Qr);for(let n of e)if(n.aborted)return t[Zr](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Zr](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},ei=class AbortController{signal;constructor(){this.signal=new $r(Qr)}get[Symbol.toStringTag](){return`AbortController`}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Zr](e)}};const ti=globalThis;globalThis.AbortController===void 0&&(ti.AbortController=ei),globalThis.AbortSignal===void 0&&(ti.AbortSignal=$r);const I=Symbol(`kState`),ni=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[I]!==void 0&&t[ni]===e}function dequeueValue(e){let t=e[I].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[I].queueTotalSize=Math.max(0,e[I].queueTotalSize-r),n}function resetQueue(e){e[I].queue=[],e[I].queueTotalSize=0}function peekQueueValue(e){return e[I].queue[0].value}function enqueueValueWithSize(e,t,n){if(n=+n,typeof n!=`number`||n<0||Number.isNaN(n)||n===1/0)throw RangeError(`Invalid size: ${n}`);e[I].queue.push({value:t,size:n}),e[I].queueTotalSize+=n}function extractHighWaterMark(e,t){if(e===void 0)return t;if(e=+e,typeof e!=`number`||Number.isNaN(e)||e<0)throw RangeError(`Invalid highWaterMark: ${e}`);return e}function extractSizeAlgorithm(e){if(e===void 0)return()=>1;if(typeof e!=`function`)throw TypeError(`strategy.size must be a function`);return e}function transferArrayBuffer(e){return typeof ArrayBuffer.prototype.transfer==`function`?e.transfer():e.slice(0)}function isDetachedBuffer(e){if(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e.byteLength!==0)return!1;try{return e.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(e){switch(e){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(e){switch(e){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(e){e.then(()=>{},()=>{})}function createPromiseCallback(e,t,n){if(typeof t!=`function`)throw TypeError(`${e} must be a function`);return async(...e)=>t.call(n,...e)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const ri={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(e){let t={[Symbol.iterator]:()=>e.iterator},n=(async function*(){return yield*t})();return{iterator:n,nextMethod:n.next,done:!1}}function getIterator(e,t=`sync`,n){if(n===void 0)if(t===`async`){if(n=e[Symbol.asyncIterator],n==null){let t=e[Symbol.iterator];if(t===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(e,`sync`,t))}}else n=e[Symbol.iterator];if(n===void 0)throw TypeError(`Object is not iterable`);let r=n.call(e);if(typeof r!=`object`||!r)throw TypeError(`The iterator method must return an object`);return{iterator:r,nextMethod:r.next,done:!1}}function iteratorNext(e,t){let n;if(n=t===void 0?e.nextMethod.call(e.iterator):e.nextMethod.call(e.iterator,t),typeof n!=`object`||!n)throw TypeError(`The iterator.next() method must return an object`);return n}const ii=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(e){this.signal.aborted=!0,this.signal.reason=e}},ai=Symbol(`kAbort`),oi=Symbol(`kCloseSentinel`),si=Symbol(`kError`),ci=Symbol(`kSkipThrow`);var WritableStream=class{[ni]=`WritableStream`;[I];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`sink must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);let n=e?.type;if(n!==void 0)throw RangeError(`Invalid type: ${n}`);this[I]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!li(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return li(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return li(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!li(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[ni]=`WritableStreamDefaultWriter`;[I];constructor(e){if(!li(e))throw TypeError(`Expected a WritableStream`);this[I]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,e)}get closed(){return ui(this)?this[I].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!ui(this))throw TypeError(`Invalid this`);if(this[I].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return ui(this)?this[I].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return ui(this)?this[I].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!ui(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[I];return e===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!ui(this))throw TypeError(`Invalid this`);let{stream:e}=this[I];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return ui(this)?this[I].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[ni]=`WritableStreamDefaultController`;[I];constructor(e){if(e!==ci)throw TypeError(`Illegal constructor`)}[ai](e){let t=this[I].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[si](){resetQueue(this)}get signal(){if(!di(this))throw TypeError(`Invalid this`);return this[I].abortController.signal}error(e){if(!di(this))throw TypeError(`Invalid this`);this[I].stream[I].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const li=isBrandCheck(`WritableStream`),ui=isBrandCheck(`WritableStreamDefaultWriter`),di=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(e){return e[I].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[I].stream=t,t[I].writer=e,t[I].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[I].backpressure?e[I].ready=Promise.withResolvers():e[I].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[I].close=Promise.withResolvers();break;case`erroring`:e[I].ready={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[I].ready.promise),e[I].close=Promise.withResolvers();break;case`closed`:e[I].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[I].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[I].ready={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},e[I].close={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[I].ready.promise),setPromiseHandled(e[I].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[I];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[I].abortController.abort(t),e[I].pendingAbortRequest.abort.promise!==void 0)return e[I].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let o=Promise.withResolvers();return e[I].pendingAbortRequest={abort:o,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),o.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[I];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[I].closeRequest=Promise.withResolvers();let{promise:o}=e[I].closeRequest;return n!==void 0&&r&&t===`writable`&&n[I].ready.resolve?.(),writableStreamDefaultControllerClose(i),o}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[I];n!==void 0&&e[I].backpressure!==t&&(t?n[I].ready=Promise.withResolvers():n[I].ready.resolve?.()),e[I].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[I];e[I].state=`erroring`,e[I].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[I].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[I].closeRequest.promise!==void 0&&(e[I].closeRequest.reject?.(e[I].storedError),e[I].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[I].close.promise),e[I].close.reject?.(e[I].storedError);let{writer:t}=e[I];t!==void 0&&(setPromiseHandled(t[I].close.promise),t[I].close.reject?.(e[I].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[I].writeRequests.shift();e[I].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[I].inFlightCloseRequest=e[I].closeRequest,e[I].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[I].inFlightWriteRequest.promise!==void 0||e[I].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[I].inFlightWriteRequest.reject?.(t),e[I].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[I].inFlightWriteRequest.resolve?.(),e[I].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[I].inFlightCloseRequest.reject?.(t),e[I].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[I].pendingAbortRequest.abort.promise!==void 0&&(e[I].pendingAbortRequest.abort.reject?.(t),e[I].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[I].inFlightCloseRequest.resolve?.(),e[I].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[I].state===`erroring`&&(e[I].storedError=void 0,e[I].pendingAbortRequest.abort.promise!==void 0&&(e[I].pendingAbortRequest.abort.resolve?.(),e[I].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[I].state=`closed`,e[I].writer!==void 0&&e[I].writer[I].close.resolve?.(),e[I].close.resolve?.()}function writableStreamFinishErroring(e){e[I].state=`errored`,e[I].controller[si]();let t=e[I].storedError;for(let n of e[I].writeRequests)n.reject?.(t);if(e[I].writeRequests=[],e[I].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[I].pendingAbortRequest;if(e[I].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},n.wasAlreadyErroring){n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}e[I].controller[ai](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[I].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[I].closeRequest.promise!==void 0||e[I].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[I].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[I],{controller:r}=n[I],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[I].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:o}=n[I];if(o===`errored`)return Promise.reject(n[I].storedError);if(writableStreamCloseQueuedOrInFlight(n)||o===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(o===`erroring`)return Promise.reject(n[I].storedError);let s=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),s}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[I],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[I].writer=void 0,e[I].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[I];switch(t[I].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[I].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[I].ready.reject?(e[I].ready.reject(t),e[I].ready.resolve=void 0,e[I].ready.reject=void 0):e[I].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[I].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[I].close.reject?(e[I].close.reject(t),e[I].close.resolve=void 0,e[I].close.reject=void 0):e[I].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[I].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[I],{state:n}=t[I];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[I].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[I].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[I].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[I];!writableStreamCloseQueuedOrInFlight(r)&&r[I].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[I];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[I];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[I].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[I];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[I].highWaterMark-e[I].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[I];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[I].stream[I].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[I].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,oi,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[I].writeAlgorithm=void 0,e[I].closeAlgorithm=void 0,e[I].abortAlgorithm=void 0,e[I].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[I];if(!n||r[I].inFlightWriteRequest.promise!==void 0)return;if(r[I].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===oi?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(ci),o=t?.start,s=t?.write,c=t?.close,l=t?.abort;setupWritableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`sink.write`,s,t):nonOpWrite,c?createPromiseCallback(`sink.close`,c,t):nonOpCancel,l?createPromiseCallback(`sink.abort`,l,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,o,s,c){t[I]={abortAlgorithm:o,closeAlgorithm:i,highWaterMark:s,queue:[],queueTotalSize:0,abortController:new ii,sizeAlgorithm:c,started:!1,stream:e,writeAlgorithm:r},e[I].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let l=n();new Promise(e=>e(l)).then(()=>{t[I].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[I].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,o=()=>1){let s=Object.create(WritableStream.prototype);return s[ni]=`WritableStream`,s[I]=createWritableStreamState(),setupWritableStreamDefaultController(s,new WritableStreamDefaultController(ci),e,t,n,r,i,o),s}Ce();const fi=Symbol(`kCancel`),pi=Symbol(`kClose`),mi=Symbol(`kChunk`),hi=Symbol(`kError`),gi=Symbol(`kPull`),_i=Symbol(`kRelease`),vi=Symbol(`kSkipThrow`);let yi,bi;function lazyReadableReleasedError(){return yi||(yi=TypeError(`Reader released`),yi)}function lazyReadableReleasingError(){return bi||(bi=TypeError(`Releasing reader`),bi)}function createAbortError$1(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let e=Error(`The operation was aborted`);return e.name=`AbortError`,e}__name$1(createAbortError$1,`createAbortError`);function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name$1(this,`ReadableStream`)}[ni]=`ReadableStream`;[I];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`source must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);this[I]=createReadableStreamState();let n=t?.size,r=t?.highWaterMark,i=e?.type;if(i!==void 0){if(`${i}`==`bytes`){if(n!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,e,extractHighWaterMark(r,0));return}throw RangeError(`Invalid type: ${i}`)}setupReadableStreamDefaultControllerFromSource(this,e,extractHighWaterMark(r,1),extractSizeAlgorithm(n))}get locked(){if(!xi(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return xi(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!xi(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=e?.mode;if(t===void 0)return new ReadableStreamDefaultReader(this);if(`${t}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${t}`)}pipeThrough(e,t={}){if(!xi(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!xi(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!li(r))throw TypeError(`transform.writable must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let i=t?.preventAbort,o=t?.preventCancel,s=t?.preventClose,c=t?.signal;if(c!==void 0&&!(c instanceof Object&&`aborted`in c))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(r))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,r,!!s,!!i,!!o,c)),n}pipeTo(e,t={}){try{if(!xi(this))throw TypeError(`Invalid this`);if(!li(e))throw TypeError(`destination must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let n=t?.preventAbort,r=t?.preventCancel,i=t?.preventClose,o=t?.signal;if(o!==void 0&&!(o instanceof Object&&`aborted`in o))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(e))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,e,!!i,!!n,!!r,o)}catch(e){return Promise.reject(e)}}tee(){if(!xi(this))throw TypeError(`Invalid this`);let e=this[I].controller;return wi(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!xi(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=!!e?.preventCancel,n=new ReadableStreamDefaultReader(this),r={done:!1,current:void 0},i=!1;function nextSteps(){if(r.done)return Promise.resolve({done:!0,value:void 0});if(n[I].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:e,resolve:t,reject:i}=Promise.withResolvers();return readableStreamDefaultReaderRead(n,{[mi](e){r.current=void 0,t({value:e,done:!1})},[pi](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[hi](e){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),i(e)}}),e}async function returnSteps(e){if(r.done)return{done:!0,value:e};if(r.done=!0,n[I].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!t){let t=readableStreamReaderGenericCancel(n,e);return readableStreamReaderGenericRelease(n),await t,{done:!0,value:e}}return readableStreamReaderGenericRelease(n),{done:!0,value:e}}return Object.setPrototypeOf({next(){return i||=(r.current=Promise.resolve(),!0),r.current=r.current===void 0?nextSteps():r.current.then(nextSteps,nextSteps),r.current},return(e){return i=!0,r.current=r.current===void 0?returnSteps(e):r.current.then(()=>returnSteps(e),()=>returnSteps(e)),r.current},[Symbol.asyncIterator](){return this}},ri)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[I];constructor(){this[I]=Promise.withResolvers()}[mi](e){this[I].resolve?.({value:e,done:!1})}[pi](){this[I].resolve?.({value:void 0,done:!0})}[hi](e){this[I].reject?.(e)}get promise(){return this[I].promise}},ReadableStreamDefaultReader=class{[ni]=`ReadableStreamDefaultReader`;[I];constructor(e){if(!xi(e))throw TypeError(`Expected a ReadableStream`);this[I]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!Ci(this))return Promise.reject(TypeError(`Invalid this`));if(this[I].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[I].stream,t=e[I].controller;if(e[I].state===`readable`&&Si(t)&&t[I].queue.length>0){e[I].disturbed=!0;let n=dequeueValue(t);return t[I].closeRequested&&!t[I].queue.length?(readableStreamDefaultControllerClearAlgorithms(t),readableStreamClose(e)):readableStreamDefaultControllerCallPullIfNeeded(t),Promise.resolve({value:n,done:!1})}let n=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,n),n.promise}releaseLock(){if(!Ci(this))throw TypeError(`Invalid this`);this[I].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return Ci(this)?this[I].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return Ci(this)?this[I].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[ni]=`ReadableStreamDefaultController`;[I];constructor(e){if(e!==vi)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(e=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,e)}error(e=void 0){readableStreamDefaultControllerError(this,e)}[fi](e){return readableStreamDefaultControllerCancelSteps(this,e)}[gi](e){readableStreamDefaultControllerPullSteps(this,e)}[_i](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const xi=isBrandCheck(`ReadableStream`),Si=isBrandCheck(`ReadableStreamDefaultController`),Ci=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[I].reader!==void 0}function readableStreamCancel(e,t){switch(e[I].disturbed=!0,e[I].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[I].storedError)}readableStreamClose(e);let n=e[I].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[I].readIntoRequests;n[I].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][pi](void 0)}return e[I].controller[fi](t).then(()=>{})}function readableStreamClose(e){e[I].state=`closed`,e[I].closedPromise.resolve();let{reader:t}=e[I];if(t!==void 0&&(t[I].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[I].readRequests.length;e++)t[I].readRequests[e][pi]();t[I].readRequests=[]}}function readableStreamError(e,t){e[I].state=`errored`,e[I].storedError=t,setPromiseHandled(e[I].closedPromise.promise),e[I].closedPromise.reject(t);let{reader:n}=e[I];if(n!==void 0){if(setPromiseHandled(n[I].close.promise),n[I].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[I].readRequests.length;e++)n[I].readRequests[e][hi](t);n[I].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[I].readIntoRequests.length;e++)n[I].readIntoRequests[e][hi](t);n[I].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[I];return t===void 0?!1:t[I]!==void 0&&t[ni]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[I].reader[I].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[I],i=r[I].readRequests.shift();n?i[pi]():i[mi](t)}function readableStreamAddReadRequest(e,t){e[I].reader[I].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[I];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[I].stream=t,t[I].reader=e,t[I].state){case`readable`:e[I].close=Promise.withResolvers();break;case`closed`:e[I].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[I].close={promise:Promise.reject(t[I].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[I].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[I],n=lazyReadableReleasedError();t[I].state===`readable`?e[I].close.reject?.(n):e[I].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[I].close.promise),t[I].controller[_i](),t[I].reader=void 0,e[I].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[I].readRequests.length;++n)e[I].readRequests[n][hi](t);e[I].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[I];switch(n[I].disturbed=!0,n[I].state){case`closed`:t[pi]();break;case`errored`:t[hi](n[I].storedError);break;case`readable`:n[I].controller[gi](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[I].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[I].closeRequested=!0,e[I].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[I].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[I];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[I].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[I];return!e[I].closeRequested&&t[I].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[I];switch(t[I].state){case`errored`:return null;case`closed`:return 0;default:return n-r}}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerShouldCallPull(e){let{stream:t}=e[I];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[I].started)return!1;if(isReadableStreamLocked(t)&&readableStreamGetNumReadRequests(t))return!0;let n=readableStreamDefaultControllerGetDesiredSize(e);return n!==null&&n>0}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e)){if(e[I].pulling){e[I].pullAgain=!0;return}e[I].pulling=!0,e[I].pullAlgorithm(e).then(()=>{e[I].pulling=!1,e[I].pullAgain&&(e[I].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[I].pullAlgorithm=void 0,e[I].cancelAlgorithm=void 0,e[I].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[I];n[I].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[I].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[I];if(r.length){let i=dequeueValue(e);e[I].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[mi](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,o,s){t[I]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:s,stream:e},e[I].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[I].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController(vi),o=t?.start,s=t?.pull,c=t?.cancel;setupReadableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`source.pull`,s,t):nonOpPull,c?createPromiseCallback(`source.cancel`,c,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let o=Object.create(ReadableStream$1.prototype);return o[ni]=`ReadableStream`,o[I]=createReadableStreamState(),setupReadableStreamDefaultController(o,new ReadableStreamDefaultController(vi),e,t,n,r,i),o}function readableStreamFromIterable(e){let t,n=getIterator(e,`async`),r=nonOpStart;async function pullAlgorithm(){let e=iteratorNext(n);return Promise.resolve(e).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);e.done?readableStreamDefaultControllerClose(t[I].controller):readableStreamDefaultControllerEnqueue(t[I].controller,e.value)})}async function cancelAlgorithm(e){let t=n.iterator,r=t.return;if(r===void 0)return Promise.resolve();let i=r.call(t,e);return Promise.resolve(i).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return t=createReadableStream(r,pullAlgorithm,cancelAlgorithm,0),t}function readableStreamPipeTo(e,t,n,r,i,o){let s,c;try{s=new ReadableStreamDefaultReader(e),c=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[I].disturbed=!0;let l=!1,{promise:u,resolve:d,reject:f}=Promise.withResolvers(),p={currentWrite:Promise.resolve()},m;function finalize(e,t){writableStreamDefaultWriterRelease(c),readableStreamReaderGenericRelease(s),o!==void 0&&m&&(o.removeEventListener(`abort`,m),m=void 0),e?f(t):d()}async function waitForCurrentWrite(){let e=p.currentWrite;await e,e!==p.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(l)return;if(l=!0,t[I].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(complete,e=>finalize(!0,e));return}complete();function complete(){e().then(()=>finalize(!!n,r),e=>finalize(!0,e))}}function shutdown(e,n){if(!l){if(l=!0,t[I].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=o.reason&&o.reason.name===`AbortError`?createAbortError$1():o.reason;let s=[];r||s.push(()=>t[I].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||s.push(()=>e[I].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(s.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[I].state===`errored`?n(e[I].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[I].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[mi](e){ae(()=>{p.currentWrite=writableStreamDefaultWriterWrite(c,e),setPromiseHandled(p.currentWrite),h.resolve(!1)})}[pi](){h.resolve(!0)}[hi](e){h.reject(e)}}let h={resolve:null,reject:null};async function step(){if(l||t[I].backpressure&&(await c[I].ready.promise,l))return!0;let n=e[I].controller;if(e[I].state===`readable`&&Si(n)&&n[I].queue.length>0){for(;n[I].queue.length>0;){if(l)return!0;let r=dequeueValue(n);if(n[I].closeRequested&&!n[I].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),p.currentWrite=writableStreamDefaultWriterWrite(c,r),setPromiseHandled(p.currentWrite),t[I].backpressure||t[I].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[I].state===`closed`}let{promise:r,resolve:i,reject:o}=Promise.withResolvers();return h={resolve:i,reject:o},readableStreamDefaultReaderRead(s,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(o!==void 0){if(o.aborted)return abortAlgorithm(),u;m=abortAlgorithm,o.addEventListener(`abort`,m,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,s[I].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,c[I].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,s[I].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(c));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[I].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return u}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,o=!1,s,c,l,u,d=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[mi](e){ae(()=>{r=!1;let n=e,s=e;if(!o&&t)try{s=structuredClone(s)}catch{}i||readableStreamDefaultControllerEnqueue(l[I].controller,n),o||readableStreamDefaultControllerEnqueue(u[I].controller,s)})},[pi](){ae(()=>{r=!1,i||readableStreamDefaultControllerClose(l[I].controller),o||readableStreamDefaultControllerClose(u[I].controller),(!i||!o)&&d.resolve(void 0)})},[hi](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,s=t,o){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}function cancel2Algorithm(t){if(o=!0,c=t,i){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}return l=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),u=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[I].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(l[I].controller,e),readableStreamDefaultControllerError(u[I].controller,e),(!i||!o)&&d.resolve(void 0)}),[l,u]}var BYOBReadIntoRequest=class{[I];constructor(){this[I]=Promise.withResolvers()}[mi](e){this[I].resolve?.({value:e,done:!1})}[pi](e){this[I].resolve?.({value:e,done:!0})}[hi](e){this[I].reject?.(e)}get promise(){return this[I].promise}},ReadableStreamBYOBReader=class{[ni]=`ReadableStreamBYOBReader`;[I];constructor(e){if(!xi(e))throw TypeError(`Expected a ReadableStream`);this[I]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!Ti(this))return Promise.reject(TypeError(`Invalid this`));if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let n=e.buffer,r=e.byteLength;if(r===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(n.byteLength===0)return isDetachedBuffer(n)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let i=t?.min??1;if(typeof i!=`number`||i<1||!Number.isInteger(i)||Number.isNaN(i))return Promise.reject(TypeError(`options.min must be a positive integer`));let o=e[Symbol.toStringTag];if(o!==void 0&&o!==`DataView`){if(i>e.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(i>r)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[I].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let s=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,s),s.promise}releaseLock(){if(!Ti(this))throw TypeError(`Invalid this`);this[I].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return Ti(this)?this[I].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return Ti(this)?this[I].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[ni]=`ReadableStreamBYOBRequest`;[I];constructor(e){if(e!==vi)throw TypeError(`Illegal constructor`)}get view(){if(!Ei(this))throw TypeError(`Invalid this`);return this[I].view}respond(e){if(!Ei(this))throw TypeError(`Invalid this`);if(this[I].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(e=+e,!Number.isInteger(e)||e<0||!Number.isFinite(e))throw RangeError(`bytesWritten must be a non-negative integer`);let t=this[I].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[I].controller,e)}respondWithNewView(e){if(!Ei(this))throw TypeError(`Invalid this`);if(this[I].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(e.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[I].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[ni]=`ReadableByteStreamController`;[I];constructor(e){if(e!==vi)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!wi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!wi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!wi(this))throw TypeError(`Invalid this`);if(this[I].closeRequested)throw TypeError(`Close already requested`);if(this[I].stream[I].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!wi(this))throw TypeError(`Invalid this`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`chunk must be an ArrayBufferView`);if(e.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(e.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[I].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[I].stream[I].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!wi(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[fi](e){return readableByteStreamControllerCancelSteps(this,e)}[gi](e){readableByteStreamControllerPullSteps(this,e)}[_i](){if(this[I].pendingPullIntos.length>0){let e=this[I].pendingPullIntos[0];e.readerType=`none`,this[I].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const wi=isBrandCheck(`ReadableByteStreamController`),Ti=isBrandCheck(`ReadableStreamBYOBReader`),Ei=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[I];return t===void 0?!1:t[I]!==void 0&&t[ni]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[I].reader[I].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[I].reader[I].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[I],i=r[I].readIntoRequests.shift();n?i[pi](t):i[mi](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!wi(t[I].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[I].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[I];i[I].disturbed=!0,i[I].state===`errored`?r[hi](i[I].storedError):readableByteStreamControllerPullInto(i[I].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[I].readIntoRequests.length;n++)e[I].readIntoRequests[n][hi](t);e[I].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[I].pullAlgorithm=void 0,e[I].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[I].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[I].byobRequest;t!=null&&(t[I].controller=void 0,t[I].view=null,e[I].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[I];n[I].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[I].stream[I].state;return t===`errored`?null:t===`closed`?0:e[I].highWaterMark-e[I].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[I];if(t[I].state!==`readable`||e[I].closeRequested||!e[I].started)return!1;if(readableStreamHasDefaultReader(t)&&readableStreamGetNumReadRequests(t)>0||readableStreamHasBYOBReader(t)&&readableStreamGetNumReadIntoRequests(t)>0)return!0;let n=readableByteStreamControllerGetDesiredSize(e);return n!==null&&n>0}function readableByteStreamControllerCallPullIfNeeded(e){if(readableByteStreamControllerShouldCallPull(e)){if(e[I].pulling){e[I].pullAgain=!0;return}e[I].pulling=!0,e[I].pullAlgorithm(e).then(()=>{e[I].pulling=!1,e[I].pullAgain&&(e[I].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[I].queueTotalSize===0&&e[I].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[I].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[I].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[I].queueTotalSize+=r}function readableByteStreamControllerEnqueueClonedChunkToQueue(e,t,n,r){let i;try{i=t.slice(n,n+r)}catch(t){readableByteStreamControllerError(e,t);return}readableByteStreamControllerEnqueueChunkToQueue(e,i,0,r)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t){t.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(e,t.buffer,t.byteOffset,t.bytesFilled),readableByteStreamControllerShiftPendingPullInto(e)}function readableByteStreamControllerShiftPendingPullInto(e){return e[I].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n){n.bytesFilled+=t}function readableByteStreamControllerConvertPullIntoDescriptor(e){let t=e.bytesFilled,n=e.elementSize,r=transferArrayBuffer(e.buffer);return e.buffer=r,new e.viewConstructor(r,e.byteOffset,t/n)}function readableByteStreamControllerCommitPullIntoDescriptor(e,t){let n=!1;e[I].state===`closed`&&(n=!0);let r=readableByteStreamControllerConvertPullIntoDescriptor(t);t.readerType==="default"?readableStreamFulfillReadRequest(e,r,n):readableStreamFulfillReadIntoRequest(e,r,n)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t){let n=Math.min(e[I].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,o=!1,s=r-r%t.elementSize;s>=t.minimumFill&&(i=s-t.bytesFilled,o=!0);let c=e[I].queue;for(;i>0;){let n=c[0],r=Math.min(i,n.byteLength),o=t.byteOffset+t.bytesFilled,s=new Uint8Array(t.buffer,o,r),l=new Uint8Array(n.buffer,n.byteOffset,r);s.set(l),n.byteLength===r?c.shift():(n.byteOffset+=r,n.byteLength-=r),e[I].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return o}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[I].queue.shift();e[I].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[mi](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[I].stream[I].reader;for(;t[I].readRequests.length!==0;){if(e[I].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[I].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[I].pendingPullIntos.length!==0;){if(e[I].queueTotalSize===0)return;let t=e[I].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[I].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[I].byobRequest===null&&e[I].pendingPullIntos.length!==0){let t=e[I].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest(vi);r[I]={controller:e,view:n},e[I].byobRequest=r}return e[I].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[I];if(e[I].closeRequested||n[I].state!==`readable`)return;let r=t.buffer,i=t.byteLength,o=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let s=transferArrayBuffer(r);if(e[I].pendingPullIntos.length!==0){let t=e[I].pendingPullIntos[0];if(isDetachedBuffer(t.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(e),t.buffer=transferArrayBuffer(t.buffer),t.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t)}readableStreamHasDefaultReader(n)?(readableByteStreamControllerProcessReadRequestsUsingQueue(e),readableStreamGetNumReadRequests(n)===0?readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i):(e[I].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(s,o,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[I];if(!(e[I].closeRequested||t[I].state!==`readable`)){if(e[I].queueTotalSize>0){e[I].closeRequested=!0;return}if(e[I].pendingPullIntos.length!==0){let t=e[I].pendingPullIntos[0];if(t.bytesFilled%t.elementSize!==0){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(e,t),t}}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(t)}}function readableByteStreamControllerPullInto(e,t,n,r){let i=e[I].stream,o=t[Symbol.toStringTag],s,c;if(o===void 0||o===`DataView`)s=DataView,c=1;else{let e=typedArrayConstructorByTag(o);if(!e){r[hi](TypeError(`Unsupported typed array: ${o}`));return}s=e,c=elementSizeByTag(o)}let l=t.buffer,u=t.byteLength,d=t.byteOffset,f=n*c,p;try{p=transferArrayBuffer(l)}catch(e){r[hi](e);return}let m={buffer:p,bufferByteLength:p.byteLength,byteOffset:d,byteLength:u,bytesFilled:0,minimumFill:f,elementSize:c,viewConstructor:s,readerType:`byob`};if(e[I].pendingPullIntos.length!==0){e[I].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r);return}if(i[I].state===`closed`){let e=new s(m.buffer,m.byteOffset,0);r[pi](e);return}if(e[I].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,m)){let t=readableByteStreamControllerConvertPullIntoDescriptor(m);readableByteStreamControllerHandleQueueDrain(e),r[mi](t);return}if(e[I].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[hi](t);return}}e[I].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[I].pendingPullIntos[0];if(e[I].stream[I].state===`closed`){if(t!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(t===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(n.bytesFilled+t>n.byteLength)throw RangeError(`bytesWritten out of range`)}n.buffer=transferArrayBuffer(n.buffer),readableByteStreamControllerRespondInternal(e,t)}function readableByteStreamControllerRespondWithNewView(e,t){let n=e[I].pendingPullIntos[0],r=e[I].stream[I].state,i=t.byteLength,o=t.byteOffset,s=t.buffer;if(r===`closed`){if(i!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(i===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(n.byteOffset+n.bytesFilled!==o)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==s.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(n.bytesFilled+i>n.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);n.buffer=transferArrayBuffer(s),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[I].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[I].stream[I].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[I].stream;if(readableStreamHasBYOBReader(n))for(;readableStreamGetNumReadIntoRequests(n)>0;)readableByteStreamControllerCommitPullIntoDescriptor(n,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,t,n){if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n),n.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e);return}if(n.bytesFilled<n.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(e);let r=n.bytesFilled%n.elementSize;if(r>0){let t=n.byteOffset+n.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(e,n.buffer,t-r,r)}n.bytesFilled-=r,readableByteStreamControllerCommitPullIntoDescriptor(e[I].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[I].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[I].stream;if(e[I].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[I].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[hi](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[I].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,o,s){t[I]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:s},e[I].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[I].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController(vi),i=t?.start,o=t?.pull,s=t?.cancel,c=t?.autoAllocateChunkSize;if(c!==void 0&&(c===0||!Number.isInteger(c)||c<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,c)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,o,s,c=Promise.withResolvers(),l,u,d,f;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||d.close(),i||f.close();return}let t=e.value,o=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||d.enqueue(o),i||f.enqueue(new Uint8Array(o))},()=>{}),Promise.resolve())}return l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,o=t,i){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),u=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,s=t,r){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),d=l[I].controller,f=u[I].controller,t.closed.catch(e=>{d.error(e),f.error(e),(!r||!i)&&c.resolve()}),[l,u]}const Di=Symbol(`kSkipThrow`);var TransformStream=class{[ni]=`TransformStream`;[I];constructor(e={},t={},n={}){if(e!=null&&typeof e!=`object`)throw TypeError(`transformer must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`writableStrategy must be an object`);if(n!=null&&typeof n!=`object`)throw TypeError(`readableStrategy must be an object`);let r=e?.readableType,i=e?.writableType,o=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let s=extractHighWaterMark(n?.highWaterMark,0),c=extractSizeAlgorithm(n?.size),l=extractHighWaterMark(t?.highWaterMark,1),u=extractSizeAlgorithm(t?.size),d=Promise.withResolvers();initializeTransformStream(this,d,l,u,s,c),setupTransformStreamDefaultControllerFromTransformer(this,e),o===void 0?d.resolve():d.resolve(o.call(e,this[I].controller))}get readable(){if(!Oi(this))throw TypeError(`Invalid this`);return this[I].readable}get writable(){if(!Oi(this))throw TypeError(`Invalid this`);return this[I].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[ni]=`TransformStreamDefaultController`;[I];constructor(e){if(e!==Di)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!ki(this))throw TypeError(`Invalid this`);let{stream:e}=this[I],{readable:t}=e[I],n=t[I].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!ki(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!ki(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!ki(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Oi=isBrandCheck(`TransformStream`),ki=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,o){let startAlgorithm=()=>t.promise,s=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[I]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,o),writable:s,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(e,!0)}function transformStreamError(e,t){let{readable:n}=e[I];readableStreamDefaultControllerError(n[I].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[I];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[I].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[I].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[I].backpressureChange.promise!==void 0&&e[I].backpressureChange.resolve?.(),e[I].backpressureChange=Promise.withResolvers(),e[I].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[I]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[I].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(Di),r=t?.transform,i=t?.flush,o=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,o?createPromiseCallback(`transformer.cancel`,o,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[I].transformAlgorithm=void 0,e[I].flushAlgorithm=void 0,e[I].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[I],{readable:r}=n[I],i=r[I].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[I].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[I].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[I].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[I].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[I].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[I],{readable:n}=t[I];readableStreamDefaultControllerClose(n[I].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[I];return e[I].backpressure?e[I].backpressureChange.promise.then(()=>{let{writable:r}=e[I];if(r[I].state===`erroring`)throw r[I].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[I];if(n[I].finishPromise!==void 0)return n[I].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[I].finishPromise=i;let c=n[I].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[I].state===`errored`?s(r[I].storedError):(readableStreamDefaultControllerError(r[I].controller,t),o())},e=>{readableStreamDefaultControllerError(r[I].controller,e),s(e)}),n[I].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[I];if(n[I].finishPromise!==void 0)return n[I].finishPromise;let{promise:r,resolve:i,reject:o}=Promise.withResolvers();n[I].finishPromise=r;let s=n[I].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{t[I].state===`errored`?o(t[I].storedError):(readableStreamDefaultControllerClose(t[I].controller),i())},e=>{readableStreamDefaultControllerError(t[I].controller,e),o(e)}),n[I].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[I].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[I];if(n[I].finishPromise!==void 0)return n[I].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[I].finishPromise=i;let c=n[I].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[I].state===`errored`?s(r[I].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[I].controller,t),transformStreamUnblockWrite(e),o())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[I].controller,t),transformStreamUnblockWrite(e),s(t)}),n[I].finishPromise}const Ai=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),ji=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return Ai}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return ji}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(e,t)=>{if(e=String(e),e===``)return;this.#e!==null&&(e=this.#e+e);let n=e.charCodeAt(e.length-1);55296<=n&&n<=56319?(this.#e=e.slice(-1),e=e.slice(0,-1)):this.#e=null,e&&t.enqueue(this.#t.encode(e))},flush:e=>{this.#e!==null&&e.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const Mi=hasStreamingSupport();function incompleteUtf8Tail(e){let t=e.length;if(t===0)return 0;for(let n=1;n<=Math.min(3,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)!=128){let e;if((r&224)==192)e=2;else if((r&240)==224)e=3;else if((r&248)==240)e=4;else return 0;return n<e?n:0}}return 0}var TextDecoderStream=class{#e;#t;constructor(e,t){if(this.#e=new TextDecoder(e,t),Mi)this.#t=new TransformStream({transform:(e,t)=>{let n=toUint8Array$2(e),r=this.#e.decode(n,{stream:!0});r&&t.enqueue(r)},flush:e=>{let t=this.#e.decode();t&&e.enqueue(t)},cancel:()=>{this.#e.decode()}});else{let e=new Uint8Array;this.#t=new TransformStream({transform:(t,n)=>{let r=toUint8Array$2(t),i;e.length>0?(i=new Uint8Array(e.length+r.length),i.set(e,0),i.set(r,e.length)):i=r;let o=incompleteUtf8Tail(i),s;if(o>0?(s=i.slice(0,i.length-o),e=i.slice(i.length-o)):(s=i,e=new Uint8Array),s.length>0){let e=this.#e.decode(s);e&&n.enqueue(e)}},flush:t=>{if(e.length>0){let n=this.#e.decode(e);n&&t.enqueue(n),e=new Uint8Array}},cancel:()=>{e=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$2(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name$1(toUint8Array$2,`toUint8Array`);function isNativeStreamUsable$3(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$3,`isNativeStreamUsable`);const Ni=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,Pi=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Fi=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,Ii=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Li=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Ri=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,zi=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;function getGioFormat(e){switch(e){case`gzip`:return Vr.ZlibCompressorFormat.GZIP;case`deflate`:return Vr.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return Vr.ZlibCompressorFormat.RAW}}function concat$1(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function assertLevel(e){if(!(e>=-1&&e<=9))throw RangeError(`The value of "level" is out of range. It must be >= -1 and <= 9. Received ${e}`)}function compressWithGio(e,t,n=-1){assertLevel(n);let r=new Vr.ZlibCompressor({format:getGioFormat(t),level:Math.trunc(n)}),i=new Vr.ConverterOutputStream({base_stream:Vr.MemoryOutputStream.new_resizable(),converter:r});i.write_bytes(new Bn.Bytes(e),null),i.close(null);let o=i.get_base_stream().steal_as_bytes();return new Uint8Array(o.get_data()??[])}function decompressStreamWithGio(e,t){let n=new Vr.ZlibDecompressor({format:getGioFormat(t)}),r=Vr.MemoryInputStream.new_from_bytes(new Bn.Bytes(e)),i=new Vr.ConverterInputStream({base_stream:r,converter:n}),o=[];for(;;){let e=i.read_bytes(Vi,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}return i.close(null),concat$1(o)}function findGzipMemberEnd(e){let t=new Vr.ZlibDecompressor({format:Vr.ZlibCompressorFormat.GZIP}),n=new Uint8Array(262144),r=0;for(;;){let i=e.subarray(r,r+Bi);try{let[e,o,s]=t.convert(i,n,Vr.ConverterFlags.NONE);if(r+=o,e===Vr.ConverterResult.FINISHED||o===0&&s===0)return r}catch{return r}}}function gunzipWithGio(e){let t=[],n=0;for(;n<e.length&&!(e.length-n<2||e[n]!==31||e[n+1]!==139);){let r=e.subarray(n),i=findGzipMemberEnd(r);if(i<=0)break;t.push(decompressStreamWithGio(r.subarray(0,i),`gzip`)),n+=i}return t.length===0?decompressStreamWithGio(e,`gzip`):concat$1(t)}var Bi,Vi,Hi=__esmMin(()=>{Hr(),Vn(),Bi=256*1024,Vi=1024*1024,__name$1(concat$1,`concat`)}),Ui=__esmMin(()=>{Ce()});function _setPipeImpl(e){Wi=e}var Wi,Stream_,Gi=__esmMin(()=>{er(),Stream_=class extends $n{constructor(e){super(e)}pipe(e,t){return Wi(this,e,t)}}});function finished(e,t,n){let r;r=typeof t==`function`?t:n;let i=!1;function done(e){i||(i=!0,r(e))}let onFinish=()=>done(),onEnd=()=>done(),onError=e=>done(e),onClose=()=>{let t=e,n=e;!t.writableFinished&&!n.readableEnded&&done(Error(`premature close`))};e.on(`finish`,onFinish),e.on(`end`,onEnd),e.on(`error`,onError),e.on(`close`,onClose);let o=e,s=typeof e.write==`function`,c=typeof e.read==`function`,l=o.writableFinished===!0,u=o.readableEnded===!0;if(o.destroyed===!0){let e=o._err;ae(e?()=>done(e):s&&l||c&&u?()=>done():()=>done(Error(`premature close`)))}else(s&&!c&&l||!s&&c&&u||s&&c&&l&&u)&&ae(()=>done());return function cleanup(){e.removeListener(`finish`,onFinish),e.removeListener(`end`,onEnd),e.removeListener(`error`,onError),e.removeListener(`close`,onClose)}}function addAbortSignal(e,t){if(!(e instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(t instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let n=t;if(e.aborted)n.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{n.destroy(Error(`The operation was aborted`))};e.addEventListener(`abort`,onAbort,{once:!0}),t.once(`close`,()=>{e.removeEventListener(`abort`,onAbort)})}return t}function isReadable(e){if(e==null)return!1;let t=e;return typeof t.readable!=`boolean`||typeof t.read!=`function`||t.destroyed===!0||t.readableEnded===!0?!1:t.readable===!0}function isWritable(e){if(e==null)return!1;let t=e;return typeof t.writable!=`boolean`||typeof t.write!=`function`||t.destroyed===!0||t.writableEnded===!0?!1:t.writable===!0}function isDestroyed(e){return e==null?!1:e.destroyed===!0}function isDisturbed(e){if(e==null)return!1;let t=e;return t.readableDidRead===!0||t.readableFlowing!==null&&t.readableFlowing!==void 0}function isErrored(e){if(e==null)return!1;let t=e;return t.destroyed===!0&&typeof t.readable==`boolean`&&t.readable===!1||t.destroyed===!0&&typeof t.writable==`boolean`&&t.writable===!1}var Ki=__esmMin(()=>{Gi(),Ce()});function getDefaultHighWaterMark(e){return e?Ji:qi}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Ji=t:qi=t}function validateHighWaterMark(e,t){if(t!==void 0&&(typeof t!=`number`||Number.isNaN(t))){let n=TypeError(`The value of "${e}" is invalid. Received ${t}`);throw n.code=`ERR_INVALID_ARG_VALUE`,n}}var qi,Ji,Yi=__esmMin(()=>{qi=16384,Ji=16});function createAbortError(){let e=Error(`The operation was aborted`);return e.name=`AbortError`,e.code=`ABORT_ERR`,e}async function streamAsyncDispose(e,t){let n;e.destroyed||(n=t?void 0:createAbortError(),e.destroy(n)),await new Promise((t,r)=>{finished(e,e=>{e&&e!==n?r(e):t()})})}var Xi,Zi=__esmMin(()=>{Ki(),Xi=Symbol.asyncDispose??Symbol.for(`Symbol.asyncDispose`)});function chunkLength(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}function sliceChunk(e,t,n){if(typeof e==`string`)return n===void 0?e.slice(t):e.slice(t,n);let r=e.slice;return typeof r==`function`?r.call(e,t,n):e}var Qi,$i=__esmMin(()=>{Gi(),Zi(),Yi(),Ce(),Qi=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(e){super(e),this.readableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.readableEncoding=e?.encoding??null,this.readableObjectMode=e?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,e?.read&&(this._readImpl=e.read),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._readableState.constructed=!0,e?this.destroy(e):this.readableFlowing===!0&&this._flow()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_read(e){this._readImpl&&this._readImpl.call(this,e)}read(e){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(e??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||e===0)return null;if(this.readableObjectMode){if(e===void 0){let e=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),e}if(e>this.readableLength)return null;let t=this._buffer.shift();return--this.readableLength,t}if(e!=null)return e>this.readableLength?null:this._readBytes(e);let t=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),t.length===1)return t[0];if(t.length===0)return null;if(typeof t[0]==`string`)return t.join(``);let n=globalThis.Buffer;return n?.concat?n.concat(t):t}_readBytes(e){let t=0,n=[];for(;t<e&&this._buffer.length>0;){let r=this._buffer[0],i=chunkLength(r);if(t+i<=e)n.push(this._buffer.shift()),t+=i,this.readableLength-=i;else{let i=e-t;n.push(sliceChunk(r,0,i)),this._buffer[0]=sliceChunk(r,i),this.readableLength-=i,t+=i}}if(n.length===1)return n[0];let r=globalThis.Buffer;return r?.concat?r.concat(n):n}push(e,t){if(e===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof e==`string`||ArrayBuffer.isView(e))){let t=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof e}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,t)),!1}return this._buffer.push(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(e,t){return super.on(e,t),e===`data`&&this.readableFlowing!==!1&&this.resume(),e===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(e){this._buffer.unshift(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e)}setEncoding(e){return this.readableEncoding=e,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let e=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(e),this.readableEncoding&&typeof e!=`string`){let t=globalThis.Buffer;t?.isBuffer&&t.isBuffer(e)?e=e.toString(this.readableEncoding):e instanceof Uint8Array&&(e=new TextDecoder(this.readableEncoding).decode(e))}this.emit(`data`,e)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(e){if(e){let t=this._pipeDests.findIndex(t=>t.dest===e);if(t!==-1){this._pipeDests[t].cleanup(),this._pipeDests.splice(t,1);let n=this._readableState.pipes.indexOf(e);n!==-1&&this._readableState.pipes.splice(n,1),e.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let e of this._pipeDests)e.cleanup(),e.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e??void 0)}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(e??null,cb):this._destroyImpl?this._destroyImpl.call(this,e??null,cb):cb(e),this}static toWeb(e){return new ReadableStream({start(t){e.on(`data`,e=>{typeof e==`string`?t.enqueue(new TextEncoder().encode(e)):e instanceof Uint8Array?t.enqueue(e):e&&typeof e.length==`number`&&t.enqueue(new Uint8Array(e))}),e.on(`end`,()=>{t.close()}),e.on(`error`,e=>{t.error(e)})},cancel(){e.destroy()}})}static fromWeb(e,t){let n=e.getReader();return new Readable_({...t,read(){n.read().then(({done:e,value:t})=>{e?this.push(null):this.push(t)},e=>{this.destroy(e)})},destroy(e,t){n.cancel(e?.message).then(()=>t(null),t)}})}[Symbol.asyncIterator](){let e=this,t=[],n=!1,r=null,i=null,o=null;return e.on(`data`,e=>{if(i){let t=i;i=null,o=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,o=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,o){let t=o;i=null,o=null,t(e)}}),{next(){return r?Promise.reject(r):t.length>0?Promise.resolve({value:t.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{i=e,o=t})},return(){return e.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(e,t){let n=new Readable_({objectMode:!0,...t,read(){}});return typeof e==`string`||ArrayBuffer.isView(e)?(n.push(e),n.push(null),n):((async()=>{try{for await(let t of e)n.push(t)||await new Promise(e=>n.once(`drain`,e));n.push(null)}catch(e){n.destroy(e)}})(),n)}},Qi.prototype[Xi]=function(){return streamAsyncDispose(this,this.readableEnded)}});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,ea=__esmMin(()=>{Yi(),$i(),Ce(),Duplex_=class extends Qi{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(e){super(e),validateHighWaterMark(`writableHighWaterMark`,e?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,e?.readableHighWaterMark),this.writableObjectMode=e?.writableObjectMode??e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??e?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,e?.highWaterMark===void 0&&e?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=e.readableHighWaterMark,this._readableState.highWaterMark=e.readableHighWaterMark),e?.readableObjectMode!==void 0&&(this.readableObjectMode=e.readableObjectMode,this._readableState.objectMode=e.readableObjectMode,e?.readableHighWaterMark===void 0&&e?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(e.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=e?.allowHalfOpen!==!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.final&&(this._finalImpl=e.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}destroy(e){return this.destroyed?this:(this.writable=!1,super.destroy(e))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(e),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),o}_duplexDoWrite(e,t,n){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:e,encoding:t,callback:n});return}this._duplexWriting=!0,this._duplexStartWrite(e,t,n)}_duplexStartWrite(e,t,n){this._pendingWrites++,this._write(e,t,t=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(e),nextTick(t?()=>{if(n(t),this._duplexWriting=!1,this.emit(`error`,t),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(e.chunk,e.encoding,e.callback)}}:()=>{if(n(),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexStartWrite(e.chunk,e.encoding,e.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let e=this._pendingEndCb;this._pendingEndCb=null,e()}})})}end(e,t,n){typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),this.writableEnded=!0;let doFinal=()=>{this._final(e=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),n&&n()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(e){e()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let e=this._duplexCorkedBuffer.splice(0);for(let{chunk:t,encoding:n,callback:r}of e)this._write(t,n,e=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(t),e?(r(e),this.emit(`error`,e)):r()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(e){return this._defaultEncoding=e,this}},__name$1(chunkLen$1,`chunkLen`)});function pipe(e,t,n){let r=e,i=n?.end!==!1,o=!1,ondrain=()=>{o=!1,t.removeListener(`drain`,ondrain);let e=r;typeof e.resume==`function`&&e.resume()},ondata=e=>{if(t.writable){let n=r;t.write(e)===!1&&typeof n.pause==`function`&&(n.pause(),o||(o=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let s=!1,onend=()=>{s||(s=!0,i&&t.end())},onclose=()=>{if(!s&&(s=!0,i&&!(r instanceof Qi))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),o&&t.removeListener(`drain`,ondrain),r.removeListener(`end`,onend),r.removeListener(`close`,onclose),r.removeListener(`end`,cleanup),r.removeListener(`close`,cleanup),t.removeListener(`close`,cleanup)};return r.on(`end`,cleanup),r.on(`close`,cleanup),t.on(`close`,cleanup),r instanceof Qi&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var ta=__esmMin(()=>{Gi(),$i(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var na,ra=__esmMin(()=>{Gi(),Zi(),Yi(),Ce(),na=class Writable_ extends Stream_{static[Symbol.hasInstance](e){let t=this;return t.prototype!==void 0&&Object.prototype.isPrototypeOf.call(t.prototype,e)?!0:t.prototype!==Writable_.prototype||e==null?!1:typeof e.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;_autoDestroy;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,this._autoDestroy=e?.autoDestroy!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._writableState.constructed=!0,e?this.destroy(e):this._maybeFlush()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e)}_maybeFlush(){let e=this._pendingConstruct.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}if(this._pendingEnd){let{chunk:e,encoding:t,callback:n}=this._pendingEnd;this._pendingEnd=null,this._doEnd(e,t,n)}}_doWrite(e,t,n){this._writableState.writing=!0;let r=!0;this._write(e,t,t=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(e),r){nextTick(()=>{if(t){n(t),this.emit(`error`,t);return}n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),t||this._drainWriteBuffer();return}nextTick(t?()=>{n(t),this.emit(`error`,t),this._drainWriteBuffer()}:()=>{n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),r=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let e=this._writeBuffer.shift();this._doWrite(e.chunk,e.encoding,e.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(e=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),this._autoDestroy?this.destroy():nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(e),this.writableCorked>0)return this._corkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),o}_doEnd(e,t,n){e!=null&&this.write(e,t),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=n,this._maybeFinish()}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),this.writableEnded?(n&&nextTick(n),this):this._writableState.constructed?(this._doEnd(e,t,n),this):(this._pendingEnd={chunk:e,encoding:t,callback:n},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let e=this._corkedBuffer.splice(0),t=e.map(e=>({chunk:e.chunk,encoding:e.encoding}));this._writev.call(this,t,t=>{for(let t of e)this.writableLength-=this.writableObjectMode?1:chunkLen(t.chunk);if(t){for(let n of e)n.callback(t);this.emit(`error`,t)}else{for(let t of e)t.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let e=this._corkedBuffer.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}}}setDefaultEncoding(e){return this._defaultEncoding=e,this}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return this._destroy(e??null,cb),this}},na.prototype[Xi]=function(){return streamAsyncDispose(this,this.writableFinished)}}),ia,aa=__esmMin(()=>{ea(),Ce(),ia=class Transform_ extends Duplex_{constructor(e){super({...e,write:void 0,final:void 0});let t=this;e?.transform&&(t._transform=e.transform),e?.flush&&(t._flush=e.flush),e?.final&&(t._final=e.final)}_transform(e,t,n){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(e){e()}_write(e,t,n){let r=!1;try{this._transform(e,t,(e,t)=>{if(r){let e=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,e));return}if(r=!0,e){n(e);return}t!=null&&this.push(t),n()})}catch(e){if(e?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw e;n(e)}}_final(e){this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()})}_doPrefinishHooks(e){let t=Transform_.prototype._final;this._final===t?e():t.call(this,e)}}}),PassThrough_,oa=__esmMin(()=>{aa(),PassThrough_=class extends ia{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline(...e){let t=e,n=typeof t[t.length-1]==`function`?t.pop():void 0,r=t;if(r.length<2)throw Error(`pipeline requires at least 2 streams`);let i=null;function onError(e){if(!i){i=e;for(let e of r)typeof e.destroy==`function`&&e.destroy();n&&n(e)}}let o=r[0];for(let e=1;e<r.length;e++){let t=r[e];o.pipe(t),o.on(`error`,onError),o=t}let s=r[r.length-1];return s.on(`error`,onError),s.on(`finish`,()=>{n&&!i&&n(null)}),s}var sa=__esmMin(()=>{}),ca,la,ua,da,fa,pa,ma,ha=__esmMin(()=>{Ui(),Gi(),Ki(),Yi(),$i(),ea(),ta(),ra(),aa(),oa(),sa(),ca=makeCallable(Stream_),la=makeCallable(Qi),ua=makeCallable(na),da=makeCallable(Duplex_),fa=makeCallable(ia),pa=makeCallable(PassThrough_),ma=Object.assign(ca,{Stream:ca,Readable:la,Writable:ua,Duplex:da,Transform:fa,PassThrough:pa,pipeline,finished,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function concat(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function createGzip(e){return new Gzip(e)}function createGunzip(e){return new Gunzip(e)}function createDeflate(e){return new Deflate(e)}function createInflate(e){return new Inflate(e)}function createDeflateRaw(e){return new DeflateRaw(e)}function createInflateRaw(e){return new InflateRaw(e)}function createUnzip(e){return new Unzip(e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}function createZstdCompress(e){let t=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}function createZstdDecompress(e){let t=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,ga=__esmMin(()=>{Hi(),ha(),__name$1(toUint8Array$1,`toUint8Array`),ZlibBase=class extends fa{_mode;_chunks=[];constructor(e,t){super(t),this._mode=e}_transform(e,t,n){this._chunks.push(toUint8Array$1(e)),n()}_flush(e){let t=concat(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(t))),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_run(e){let t=this._mode;switch(t.kind){case`compress`:return compressWithGio(e,t.format);case`decompress`:return decompressStreamWithGio(e,t.format);case`gunzip`:return gunzipWithGio(e);case`unzip`:return e.length>=2&&e[0]===31&&e[1]===139?gunzipWithGio(e):decompressStreamWithGio(e,`deflate`)}}},Gzip=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`gzip`},e)}},Gunzip=class extends ZlibBase{constructor(e){super({kind:`gunzip`},e)}},Deflate=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate`},e)}},Inflate=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate`},e)}},DeflateRaw=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate-raw`},e)}},InflateRaw=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate-raw`},e)}},Unzip=class extends ZlibBase{constructor(e){super({kind:`unzip`},e)}},BrotliCompress=class extends fa{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends fa{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends fa{constructor(){super();let e=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}},ZstdDecompress=class extends fa{constructor(){super();let e=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}}}),_a=__exportAll$1({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>ya,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>ba,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function decompressWithGio(e,t){return t===`gzip`?gunzipWithGio(e):decompressStreamWithGio(e,t)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let o=r.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of r)s.set(e,c),c+=e.length;return s}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}function requestedLevel(e){let t=e?.level;if(!(t===void 0||t===-1))return assertLevel(t),t}async function compress(e,t,n){return n===void 0&&hasWebCompression()?compressWithWeb(e,t):compressWithGio(e,t,n)}async function decompress(e,t){if(hasWebCompression())try{return await decompressWithWeb(e,t)}catch(n){if(t!==`gzip`)throw n;return decompressWithGio(e,t)}return decompressWithGio(e,t)}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array(e),`gzip`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array(e),`deflate`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;compress(toUint8Array(e),`deflate-raw`,requestedLevel(i)).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array(e),`gzip`,t?.level??-1)}function gunzipSync(e,t){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array(e),`deflate`,t?.level??-1)}function inflateSync(e,t){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array(e),`deflate-raw`,t?.level??-1)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array(e),`deflate-raw`)}function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),va)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),va)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}function zstdCompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdCompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,va)}function zstdDecompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdDecompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,va)}function zstdCompressSync(e,t){let n=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}function zstdDecompressSync(e,t){let n=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}var hasWebCompression,va,ya,ba,xa=__esmMin(()=>{Hi(),ga(),hasWebCompression=()=>globalThis.CompressionStream!==void 0,va=new Uint8Array,ya={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},ba={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:ya}});const Sa=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!Sa.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const Ca=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let wa=!1,Ta,Ea,Da,Oa,ka,Aa;async function loadZlib(){if(wa)return;let e=await Promise.resolve().then(()=>(xa(),_a));Ta=e.gzipSync,Ea=e.gunzipSync,Da=e.deflateSync,Oa=e.inflateSync,ka=e.deflateRawSync,Aa=e.inflateRawSync,wa=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Ta(e);case`deflate`:return e=>Da(e);case`deflate-raw`:return e=>ka(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Ea(e);case`deflate`:return e=>Oa(e);case`deflate-raw`:return e=>Aa(e)}}function concatChunks(e){if(e.length===1)return e[0];let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let ja,Ma;if(Ca)ja=globalThis.CompressionStream,Ma=globalThis.DecompressionStream;else{let e=loadZlib();ja=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Fi({transform(e){r.push(e)},async flush(t){try{await e;let i=getCompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}},Ma=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Fi({transform(e){r.push(e)},async flush(t){try{await e;let i=getDecompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}}}const Na=globalThis;globalThis.CompressionStream===void 0&&(Na.CompressionStream=ja),globalThis.DecompressionStream===void 0&&(Na.DecompressionStream=Ma);const Pa={CustomEvent:CustomEvent$1,MessageEvent,ErrorEvent,CloseEvent,ProgressEvent:ProgressEvent$1};for(let[e,t]of Object.entries(Pa))globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0});const Fa=globalThis;globalThis.DOMException===void 0&&(Fa.DOMException=Qe);var Ia,__name,La=__esmMin(()=>{Ia=Object.defineProperty,__name=(e,t)=>Ia(e,`name`,{value:t,configurable:!0})});function validateHeaderName(e){if(typeof e!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let t=TypeError(`Header name must be a valid HTTP token ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),t}}function validateHeaderValue(e,t){if(t===void 0){let t=TypeError(`Header "${e}" value must not be undefined`);throw Object.defineProperty(t,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),t}if(typeof t==`string`&&/[^\t -~€-ÿ]/.test(t)){let t=TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_CHAR`}),t}}const Ra=Symbol(`Headers.headers`);function isBoxedPrimitive(e){return e instanceof String||e instanceof Number||e instanceof Boolean||typeof Symbol<`u`&&e instanceof Symbol||typeof BigInt<`u`&&e instanceof BigInt}var za=class Headers{[Ra];constructor(e){if(this[Ra]=new Map,e!=null){if(e instanceof Headers){for(let[t,n]of e[Ra])this[Ra].set(t,[...n]);return}if(typeof e==`object`&&!isBoxedPrimitive(e)){let t=e[Symbol.iterator];if(t==null)for(let[t,n]of Object.entries(e))validateHeaderName(t),validateHeaderValue(t,String(n)),this.append(t,String(n));else{if(typeof t!=`function`)throw TypeError(`Header pairs must be iterable`);for(let t of e){if(typeof t!=`object`||isBoxedPrimitive(t))throw TypeError(`Each header pair must be an iterable object`);let e=[...t];if(e.length!==2)throw TypeError(`Each header pair must be a name/value tuple`);validateHeaderName(e[0]),validateHeaderValue(e[0],String(e[1])),this.append(e[0],String(e[1]))}}}else throw TypeError(`Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)'`)}}append(e,t){validateHeaderName(e),validateHeaderValue(e,t);let n=String(e).toLowerCase(),r=String(t),i=this[Ra].get(n);i?i.push(r):this[Ra].set(n,[r])}set(e,t){validateHeaderName(e),validateHeaderValue(e,t);let n=String(e).toLowerCase();this[Ra].set(n,[String(t)])}delete(e){this[Ra].delete(String(e).toLowerCase())}has(e){return this[Ra].has(String(e).toLowerCase())}get(e){let t=this[Ra].get(String(e).toLowerCase());if(!t||t.length===0)return null;let n=t.join(`, `);return/^content-encoding$/i.test(e)&&(n=n.toLowerCase()),n}getAll(e){return this[Ra].get(String(e).toLowerCase())??[]}getSetCookie(){return this[Ra].get(`set-cookie`)??[]}forEach(e,t){for(let n of this.keys())Reflect.apply(e,t,[this.get(n),n,this])}*keys(){let e=[...this[Ra].keys()].sort(),t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}*values(){for(let e of this.keys())yield this.get(e)}*entries(){for(let e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`Headers`}toString(){return Object.prototype.toString.call(this)}raw(){let e={};for(let t of this.keys())e[t]=this.getAll(t);return e}_appendToSoupMessage(e,t,n=e.MessageHeadersType.REQUEST){let r=t?t.get_request_headers():new e.MessageHeaders(n);for(let[e,t]of this.entries())r.append(e,t);return r}static _newFromSoupMessage(e,t,n=e.MessageHeadersType.RESPONSE){let r=new Headers,i;return i=n===e.MessageHeadersType.RESPONSE?t.get_response_headers():t.get_request_headers(),i.foreach((e,t)=>{r.append(e,t)}),r}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};for(let t of this.keys()){let n=this.getAll(t);t===`host`?e[t]=n[0]:e[t]=n.length>1?n:n[0]}return e}};Object.defineProperties(za.prototype,[`get`,`entries`,`forEach`,`values`].reduce((e,t)=>(e[t]={enumerable:!0},e),{}));var Ba=__esmMin(()=>{Ln()});Ba();var FetchBaseError=class extends Error{type;constructor(e,t){super(e),typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,this.constructor),this.type=t}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}},FetchError=class extends FetchBaseError{code;errno;erroredSysCall;constructor(e,t,n){super(e,t),n&&(this.code=this.errno=n.code,this.erroredSysCall=n.syscall)}};const Va=Symbol.toStringTag,isURLSearchParameters=e=>typeof e==`object`&&typeof e.append==`function`&&typeof e.delete==`function`&&typeof e.get==`function`&&typeof e.getAll==`function`&&typeof e.has==`function`&&typeof e.set==`function`&&typeof e.sort==`function`&&e[Va]===`URLSearchParams`,isBlob=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.arrayBuffer==`function`&&typeof t.type==`string`&&typeof t.stream==`function`&&typeof t.constructor==`function`&&/^(Blob|File)$/.test(t[Va])},isAbortSignal=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return t[Va]===`AbortSignal`||t[Va]===`EventTarget`},isDomainOrSubdomain=(e,t)=>{let n=new ur(t).hostname,r=new ur(e).hostname;return n===r||n.endsWith(`.${r}`)},isSameProtocol=(e,t)=>new ur(t).protocol===new ur(e).protocol;var Ha,Ua,File,Wa=__esmMin(()=>{Ha=Symbol(`File.name`),Ua=Symbol(`File.lastModified`),File=class extends Blob{[Ha];[Ua];webkitRelativePath=``;constructor(e,t,n){super(e,n),this[Ha]=String(t),this[Ua]=n?.lastModified??Date.now()}get name(){return this[Ha]}get lastModified(){return this[Ua]}get[Symbol.toStringTag](){return`File`}}});function generateBoundary(){let e=`----formdata-`;for(let t=0;t<24;t++)e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return e}function escape(e){return e.replace(/\n/g,`%0A`).replace(/\r/g,`%0D`).replace(/"/g,`%22`)}function formDataToBlob(e,t){t??=generateBoundary();let n=[],r=`--${t}\r\nContent-Disposition: form-data; name="`;for(let[t,i]of e.entries())if(typeof i==`string`)n.push(`${r}${escape(t)}"\r\n\r\n${i.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
26
26
  `)}\r\n`);else{let e=i instanceof File?i:new File([i],`blob`,{type:i.type});n.push(`${r}${escape(t)}"; filename="${escape(e.name)}"\r\nContent-Type: ${e.type||`application/octet-stream`}\r\n\r\n`),n.push(e),n.push(`\r
27
27
  `)}return n.push(`--${t}--`),new Blob(n,{type:`multipart/form-data; boundary=${t}`})}var Ga=__esmMin(()=>{Wa()});function normalizeValue(e,t,n){return typeof t==`string`?t:(t instanceof Blob&&!(t instanceof File)&&(t=new File([t],n??`blob`,{type:t.type})),t instanceof File&&n!==void 0&&(t=new File([t],n,{type:t.type,lastModified:t.lastModified})),t)}var Ka,FormData,qa=__esmMin(()=>{Wa(),Ka=Symbol(`FormData.entries`),FormData=class{[Ka]=[];constructor(){}append(e,t,n){this[Ka].push({name:String(e),value:normalizeValue(e,t,n)})}delete(e){let t=String(e);this[Ka]=this[Ka].filter(e=>e.name!==t)}get(e){let t=String(e),n=this[Ka].find(e=>e.name===t);return n?n.value:null}getAll(e){let t=String(e);return this[Ka].filter(e=>e.name===t).map(e=>e.value)}has(e){let t=String(e);return this[Ka].some(e=>e.name===t)}set(e,t,n){let r=String(e),i=normalizeValue(r,t,n),o=!1;this[Ka]=this[Ka].filter(e=>e.name===r?o?!1:(o=!0,e.value=i,!0):!0),o||this[Ka].push({name:r,value:i})}forEach(e,t){for(let n of this[Ka])e.call(t,n.value,n.name,this)}*entries(){for(let e of this[Ka])yield[e.name,e.value]}*keys(){for(let e of this[Ka])yield e.name}*values(){for(let e of this[Ka])yield e.value}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`FormData`}}}),Ja=__esmMin(()=>{Ga(),qa()}),Ya=__exportAll$1({toFormData:()=>toFormData});function _fileName(e){let t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;let n=t[2]||t[3]||``,r=n.slice(n.lastIndexOf(`\\`)+1);return r=r.replace(/%22/g,`"`),r=r.replace(/&#(\d{4});/g,(e,t)=>String.fromCharCode(t)),r}async function toFormData(e,t){if(!/multipart/i.test(t))throw TypeError(`Failed to fetch`);let n=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw TypeError(`no or bad content-type header, no multipart boundary`);let r=new MultipartParser(n[1]||n[2]),i,o,s,c,l,u,d=[],f=new FormData,onPartData=e=>{s+=p.decode(e,{stream:!0})},appendToFile=e=>{d.push(e)},appendFileToFormData=()=>{let e=new C(d,u,{type:l});f.append(c,e)},appendEntryToFormData=()=>{f.append(c,s)},p=new TextDecoder(`utf-8`);p.decode(),r.onPartBegin=function(){r.onPartData=onPartData,r.onPartEnd=appendEntryToFormData,i=``,o=``,s=``,c=``,l=``,u=null,d.length=0},r.onHeaderField=function(e){i+=p.decode(e,{stream:!0})},r.onHeaderValue=function(e){o+=p.decode(e,{stream:!0})},r.onHeaderEnd=function(){if(o+=p.decode(),i=i.toLowerCase(),i===`content-disposition`){let e=o.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(c=e[2]||e[3]||``),u=_fileName(o),u&&(r.onPartData=appendToFile,r.onPartEnd=appendFileToFormData)}else i===`content-type`&&(l=o);o=``,i=``};for await(let t of e)r.write(t);return r.end(),f}var Xa,Za,lower,noop,MultipartParser,Qa=__esmMin(()=>{Ja(),Xa=1,Za={PART_BOUNDARY:Xa,LAST_BOUNDARY:Xa*=2},lower=e=>e|32,noop=(...e)=>{},MultipartParser=class{index=0;flags=0;boundary;lookbehind;state=0;onHeaderEnd=noop;onHeaderField=noop;onHeadersEnd=noop;onHeaderValue=noop;onPartBegin=noop;onPartData=noop;onPartEnd=noop;boundaryChars={};constructor(e){e=`\r
28
28
  --`+e;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8)}write(e){let t=0,n=e.length,r=this.index,{lookbehind:i,boundary:o,boundaryChars:s,index:c,state:l,flags:u}=this,d=this.boundary.length,f=d-1,p=e.length,m,h,mark=e=>{this[e+`Mark`]=t},clear=e=>{delete this[e+`Mark`]},callback=(e,t,n,r)=>{(t===void 0||t!==n)&&this[e](r&&r.subarray(t,n))},dataCallback=(n,r=!1)=>{let i=n+`Mark`;i in this&&(r?(callback(n,this[i],t,e),delete this[i]):(callback(n,this[i],e.length,e),this[i]=0))};for(t=0;t<n;t++)switch(m=e[t],l){case 0:if(c===o.length-2){if(m===45)u|=Za.LAST_BOUNDARY;else if(m!==13)return;c++;break}else if(c-1==o.length-2){if(u&Za.LAST_BOUNDARY&&m===45)l=9,u=0;else if(!(u&Za.LAST_BOUNDARY)&&m===10)c=0,callback(`onPartBegin`),l=1;else return;break}m!==o[c+2]&&(c=-2),m===o[c+2]&&c++;break;case 1:l=2,mark(`onHeaderField`),c=0;case 2:if(m===13){clear(`onHeaderField`),l=6;break}if(c++,m===45)break;if(m===58){if(c===1)return;dataCallback(`onHeaderField`,!0),l=3;break}if(h=lower(m),h<97||h>122)return;break;case 3:if(m===32)break;mark(`onHeaderValue`),l=4;case 4:m===13&&(dataCallback(`onHeaderValue`,!0),callback(`onHeaderEnd`),l=5);break;case 5:if(m!==10)return;l=1;break;case 6:if(m!==10)return;callback(`onHeadersEnd`),l=7;break;case 7:l=8,mark(`onPartData`);case 8:if(r=c,c===0){for(t+=f;t<p&&!(e[t]in s);)t+=d;t-=f,m=e[t]}if(c<o.length)o[c]===m?(c===0&&dataCallback(`onPartData`,!0),c++):c=0;else if(c===o.length)c++,m===13?u|=Za.PART_BOUNDARY:m===45?u|=Za.LAST_BOUNDARY:c=0;else if(c-1===o.length)if(u&Za.PART_BOUNDARY){if(c=0,m===10){u&=~Za.PART_BOUNDARY,callback(`onPartEnd`),callback(`onPartBegin`),l=1;break}}else u&Za.LAST_BOUNDARY&&m===45?(callback(`onPartEnd`),l=9,u=0):c=0;if(c>0)i[c-1]=m;else if(r>0){let e=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);callback(`onPartData`,0,r,e),r=0,mark(`onPartData`),t--}break;case 9:break;default:throw Error(`Unexpected state entered: ${l}`)}dataCallback(`onHeaderField`),dataCallback(`onHeaderValue`),dataCallback(`onPartData`),this.index=c,this.state=l,this.flags=u}end(){if(this.state===1&&this.index===0||this.state===8&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==9)throw Error(`MultipartParser.end(): stream ended unexpectedly`)}}});re(),La(),Ba(),Ln(),ha(),Ja(),__name((e,t)=>new Promise((n,r)=>{pipeline(e,t,e=>{e?r(e):n()})}),`pipeline`);const $a=Symbol(`Body internals`);function isAnyArrayBuffer(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}var Body=class{[$a]={body:null,stream:null,webStream:null,boundary:``,disturbed:!1,error:null};size=0;constructor(e,t={size:0}){if(this.size=t.size||0,e==null)this[$a].body=null;else if(isURLSearchParameters(e))this[$a].body=Fn.from(e.toString());else if(isBlob(e))this[$a].body=e;else if(Fn.isBuffer(e))this[$a].body=e;else if(isAnyArrayBuffer(e))this[$a].body=Fn.from(e);else if(ArrayBuffer.isView(e))this[$a].body=Fn.from(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof la)this[$a].body=e;else if(typeof ReadableStream<`u`&&e instanceof ReadableStream)this[$a].body=readableStreamToReadable(e);else if(e instanceof FormData){let t=formDataToBlob(e);this[$a].body=t,this[$a].boundary=t.type?.split(`boundary=`)?.[1]??``}else typeof e==`string`?this[$a].body=Fn.from(e):e instanceof cr?this[$a].body=Fn.from(e.toString()):(M.warn(`Unknown body type "${typeof e}", try to parse the body to string!`),this[$a].body=Fn.from(String(e)));let n=this[$a].body;Fn.isBuffer(n)?this[$a].stream=la.from(n):isBlob(n)?this[$a].stream=la.from(blobToAsyncIterable(n)):n instanceof la&&(this[$a].stream=n),n instanceof ca&&n.on(`error`,e=>{let t=e instanceof FetchBaseError?e:new FetchError(`Invalid response body while trying to fetch ${this.url}: ${e.message}`,`system`,e);this[$a].error=t})}get body(){let e=this[$a].stream;if(!e)return null;let t=this[$a].webStream;if(t)return t;if(typeof ReadableStream<`u`){let t=!1,n=new ReadableStream({start(n){e.on(`data`,e=>{if(!t)try{n.enqueue(e instanceof Uint8Array?e:new Uint8Array(e))}catch{}}),e.on(`end`,()=>{if(!t){t=!0;try{n.close()}catch{}}}),e.on(`error`,e=>{if(!t){t=!0;try{n.error(e)}catch{}}})},cancel(){t=!0,e.destroy()}});return this[$a].webStream=n,n}return null}get _stream(){return this[$a].stream}get _rawBodyBuffer(){let e=this[$a].body;return e===null?null:Fn.isBuffer(e)?e:e instanceof Uint8Array?Fn.from(e.buffer,e.byteOffset,e.byteLength):null}get bodyUsed(){return this[$a].disturbed}async arrayBuffer(){let{buffer:e,byteOffset:t,byteLength:n}=await consumeBody(this);return e.slice(t,t+n)}async formData(){let e=this.headers?.get(`content-type`);if(e?.startsWith(`application/x-www-form-urlencoded`)){let e=new FormData,t=new cr(await this.text());for(let[n,r]of t)e.append(n,r);return e}let{toFormData:t}=await Promise.resolve().then(()=>(Qa(),Ya));return t(this.body,e)}async blob(){let e=this.headers?.get(`content-type`)||this[$a].body&&this[$a].body.type||``;return new S([await this.arrayBuffer()],{type:e})}async json(){let e=await this.text();return JSON.parse(e)}async text(){let e=await consumeBody(this);return new TextDecoder().decode(e)}};Object.defineProperties(Body.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}});async function consumeBody(e){if(e[$a].disturbed)throw TypeError(`body used already for: ${e.url}`);if(e[$a].disturbed=!0,e[$a].error)throw e[$a].error;let{_stream:t}=e;if(t===null||!(t instanceof ca))return Fn.alloc(0);let n=[],r=0;try{for await(let i of t){if(e.size>0&&r+i.length>e.size){let n=new FetchError(`content size at ${e.url} over limit: ${e.size}`,`max-size`);throw t.destroy(n),n}r+=i.length,n.push(i)}}catch(t){let n=t instanceof Error?t:Error(String(t));throw t instanceof FetchBaseError?t:new FetchError(`Invalid response body while trying to fetch ${e.url}: ${n.message}`,`system`,n)}try{return n.every(e=>typeof e==`string`)?Fn.from(n.join(``)):Fn.concat(n,r)}catch(t){let n=t instanceof Error?t:Error(String(t));throw new FetchError(`Could not create Buffer from response body for ${e.url}: ${n.message}`,`system`,n)}}const clone=(e,t)=>{let n,r,{body:i}=e[$a];if(e.bodyUsed)throw Error(`cannot clone body after it is used`);return i instanceof ca&&typeof i.getBoundary!=`function`&&(n=new pa({highWaterMark:t}),r=new pa({highWaterMark:t}),i.pipe(n),i.pipe(r),e[$a].stream=n,i=r),i},extractContentType=(e,t)=>e===null?null:typeof e==`string`?`text/plain;charset=UTF-8`:isURLSearchParameters(e)?`application/x-www-form-urlencoded;charset=UTF-8`:isBlob(e)?e.type||null:Fn.isBuffer(e)||isAnyArrayBuffer(e)||ArrayBuffer.isView(e)?null:e instanceof FormData?`multipart/form-data; boundary=${t[$a].boundary}`:e instanceof ca?null:`text/plain;charset=UTF-8`,getTotalBytes=e=>{let{body:t}=e[$a];if(t===null)return 0;if(isBlob(t))return t.size;if(Fn.isBuffer(t))return t.length;if(t&&typeof t.getLengthSync==`function`){let e=t;return e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null}return null};function readableStreamToReadable(e){let t=e.getReader();return new la({async read(){try{let{done:e,value:n}=await t.read();e?this.push(null):this.push(Fn.from(n))}catch(e){this.destroy(e)}},destroy(e,n){t.cancel().then(()=>n(null),n)}})}async function*blobToAsyncIterable(e){if(typeof e.stream==`function`){let t=e.stream().getReader();for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}else yield new Uint8Array(await e.arrayBuffer())}const eo=new Set([301,302,303,307,308]),isRedirect=e=>eo.has(e);Vn(),Hr();const to=Symbol(`Response internals`);var no=class Response extends Body{[to];_inputStream=null;constructor(e=null,t={}){super(e,t);let n=t.status==null?200:t.status,r=new za(t.headers);if(e!==null&&!r.has(`Content-Type`)){let t=extractContentType(e,this);t&&r.append(`Content-Type`,t)}this[to]={type:`default`,url:t.url,status:n,statusText:t.statusText||``,headers:r,counter:t.counter,highWaterMark:t.highWaterMark}}get type(){return this[to].type}get url(){return this[to].url||``}get status(){return this[to].status}get ok(){return this[to].status>=200&&this[to].status<300}get redirected(){return this[to].counter>0}get statusText(){return this[to].statusText}get headers(){return this[to].headers}get highWaterMark(){return this[to].highWaterMark}clone(){return new Response(clone(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,t=302){if(!isRedirect(t))throw RangeError(`Failed to execute "redirect" on "response": Invalid status code`);return new Response(null,{headers:{location:new ur(e).toString()},status:t})}static error(){let e=new Response(null,{status:0,statusText:``});return e[to].type=`error`,e}static json(e,t){let n=JSON.stringify(e),r={...t},i=new za(r.headers);return i.has(`content-type`)||i.set(`content-type`,`application/json`),r.headers=i,new Response(n,r)}get[Symbol.toStringTag](){return`Response`}async text(){if(!this._inputStream)return super.text();let e=Vr.MemoryOutputStream.new_resizable();await new Promise((t,n)=>{e.splice_async(this._inputStream,Vr.OutputStreamSpliceFlags.CLOSE_TARGET|Vr.OutputStreamSpliceFlags.CLOSE_SOURCE,Bn.PRIORITY_DEFAULT,null,(r,i)=>{try{t(e.splice_finish(i))}catch(e){n(e)}})});let t=e.steal_as_bytes();return new TextDecoder().decode(t.toArray())}};Object.defineProperties(no.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),ha(),Vn();async function soupSendAsync(e,t,n=Bn.PRIORITY_DEFAULT,r=null){return new Promise((i,o)=>{e.send_async(t,n,r,(t,n)=>{try{i(e.send_finish(n))}catch(e){o(e)}})})}function inputStreamToReadable(e,t={}){return la.from(inputStreamAsyncIterator(e),t)}let ro=null;async function loadSoup(){return ro??=(await import(`gi://Soup?version=3.0`)).default}function isIP(e){if(typeof e!=`string`)return 0;let t=e.includes(`%`)?e.slice(0,e.indexOf(`%`)):e,n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n)return n.slice(1).every(e=>(e.length===1||e[0]!==`0`)&&Number(e)<=255)?4:0;if(t.length===0||!t.includes(`:`))return 0;let r=/:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.exec(t),i=r?t.slice(0,t.length-r[0].length):t;if(r&&isIP(r[1])!==4)return 0;let o=i.split(`::`);if(o.length>2)return 0;let s=0;for(let e of o)if(e!==``)for(let t of e.split(`:`)){if(!/^[0-9a-fA-F]{1,4}$/.test(t))return 0;s++}let c=r?6:8;return o.length===2?s<c?6:0:s===c?6:0}Hr(),Vn(),ha(),Hr(),er();function stripURLForUseAsAReferrer(e,t=!1){if(e==null||e===`no-referrer`)return`no-referrer`;let n=new ur(e);return/^(about|blob|data):$/.test(n.protocol)?`no-referrer`:(n.username=``,n.password=``,n.hash=``,t&&(n.pathname=``,n.search=``),n)}const io=new Set([``,`no-referrer`,`no-referrer-when-downgrade`,`same-origin`,`origin`,`strict-origin`,`origin-when-cross-origin`,`strict-origin-when-cross-origin`,`unsafe-url`]);function validateReferrerPolicy(e){if(!io.has(e))throw TypeError(`Invalid referrerPolicy: ${e}`);return e}function isOriginPotentiallyTrustworthy(e){if(/^(http|ws)s:$/.test(e.protocol))return!0;let t=e.host.replace(/(^\[)|(]$)/g,``),n=isIP(t);return n===4&&t.startsWith(`127.`)||n===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(t)?!0:e.host===`localhost`||e.host.endsWith(`.localhost`)?!1:e.protocol===`file:`}function isUrlPotentiallyTrustworthy(e){return/^about:(blank|srcdoc)$/.test(e.toString())||(typeof e==`string`&&(e=new ur(e)),e.protocol===`data:`)||/^(blob|filesystem):$/.test(e.protocol)?!0:isOriginPotentiallyTrustworthy(e)}function determineRequestsReferrer(e,t={}){let{referrerURLCallback:n,referrerOriginCallback:r}=t;if(e.referrer===`no-referrer`||e.referrerPolicy===``)return null;let i=e.referrerPolicy;if(e.referrer===`about:client`)return`no-referrer`;let o=new ur(e.referrer),s=stripURLForUseAsAReferrer(o),c=stripURLForUseAsAReferrer(o,!0);s.toString().length>4096&&(s=c),n&&(s=n(s)),r&&(c=r(c));let l=new ur(e.url);switch(i){case`no-referrer`:return`no-referrer`;case`origin`:return c;case`unsafe-url`:return s;case`strict-origin`:return isUrlPotentiallyTrustworthy(s)&&!isUrlPotentiallyTrustworthy(l)?`no-referrer`:c.toString();case`strict-origin-when-cross-origin`:return s.origin===l.origin?s:isUrlPotentiallyTrustworthy(s)&&!isUrlPotentiallyTrustworthy(l)?`no-referrer`:c;case`same-origin`:return s.origin===l.origin?s:`no-referrer`;case`origin-when-cross-origin`:return s.origin===l.origin?s:c;case`no-referrer-when-downgrade`:return isUrlPotentiallyTrustworthy(s)&&!isUrlPotentiallyTrustworthy(l)?`no-referrer`:s;default:throw TypeError(`Invalid referrerPolicy: ${i}`)}}function parseReferrerPolicyFromHeader(e){let t=(e.get(`referrer-policy`)||``).split(/[,\s]+/),n=``;for(let e of t)e&&io.has(e)&&(n=e);return n}Vn(),Hr();const ao=Symbol(`Request internals`);let oo=null;function envPositiveInt(e,t){let n=Bn.getenv(e);if(!n)return t;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:t}function shouldAcceptAnyCert(e){return e===!1?!0:e===!0?!1:Bn.getenv(`NODE_TLS_REJECT_UNAUTHORIZED`)===`0`}function getSharedSession(e){if(oo===null){let t=envPositiveInt(`GJSIFY_FETCH_MAX_CONNS_PER_HOST`,16),n=Math.max(envPositiveInt(`GJSIFY_FETCH_MAX_CONNS`,64),t);oo=new e.Session({maxConns:n,maxConnsPerHost:t}),oo.remove_feature_by_type(e.ContentDecoder.$gtype)}return oo}const isRequest=e=>typeof e==`object`&&typeof e.url==`string`;var so=class Request extends Body{cache;credentials;destination;get headers(){return this[ao].headers}integrity;keepalive;get method(){return this[ao].method}mode;get redirect(){return this[ao].redirect}get referrer(){if(this[ao].referrer===`no-referrer`)return``;if(this[ao].referrer===`client`)return`about:client`;if(this[ao].referrer)return this[ao].referrer.toString()}get referrerPolicy(){return this[ao].referrerPolicy}set referrerPolicy(e){this[ao].referrerPolicy=validateReferrerPolicy(e)}get signal(){return this[ao].signal}get url(){return this[ao].parsedURL.toString()}get _uri(){return Bn.Uri.parse(this.url,Bn.UriFlags.ENCODED)}get _session(){return this[ao].session}get _message(){return this[ao].message}get _inputStream(){return this[ao].inputStream}get[Symbol.toStringTag](){return`Request`}[ao];follow;compress=!1;counter=0;agent=``;highWaterMark=16384;insecureHTTPParser=!1;rejectUnauthorized;constructor(e,t){let n=e,r=t||{},i,o={};if(isRequest(e)?(i=new ur(n.url),o=n):i=new ur(e),i.username!==``||i.password!==``)throw TypeError(`${i} is an url with embedded credentials.`);let s=r.method||o.method||`GET`;if(/^(delete|get|head|options|post|put)$/i.test(s)&&(s=s.toUpperCase()),(t?.body!=null||isRequest(e)&&n.body!==null)&&(s===`GET`||s===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body`);let c=t?.body?t.body:isRequest(e)&&n.body!==null?clone(e):null;super(c,{size:r.size||0});let l=new za(t?.headers||n.headers||{});if(c!==null&&!l.has(`Content-Type`)){let e=extractContentType(c,this);e&&l.set(`Content-Type`,e)}let u=isRequest(e)?n.signal:null;if(t&&`signal`in t&&(u=t.signal),u!=null&&!isAbortSignal(u))throw TypeError(`Expected signal to be an instanceof AbortSignal or EventTarget`);let d=t?.referrer==null?n.referrer:t.referrer;if(d===``)d=`no-referrer`;else if(d){let e=new ur(d);d=/^about:(\/\/)?client$/.test(e.toString())?`client`:e}else d=void 0;this[ao]={method:s,redirect:t?.redirect||n.redirect||`follow`,headers:l,parsedURL:i,signal:u,referrer:d,referrerPolicy:``,session:null,message:null},this.follow=r.follow===void 0?n.follow===void 0?20:n.follow:r.follow,this.compress=r.compress===void 0?n.compress===void 0?!0:n.compress:r.compress,this.counter=r.counter||n.counter||0,this.agent=r.agent||n.agent,this.highWaterMark=r.highWaterMark||n.highWaterMark||16384,this.insecureHTTPParser=r.insecureHTTPParser||n.insecureHTTPParser||!1,this.rejectUnauthorized=r.rejectUnauthorized??n.rejectUnauthorized,this.referrerPolicy=t?.referrerPolicy||n.referrerPolicy||``}async _send(e){let{signal:t,parsedURL:n}=this[ao],r=n.protocol;if(r!==`http:`&&r!==`https:`)throw Error(`Cannot send request: no Soup session (non-HTTP URL?)`);let i=await loadSoup(),o=getSharedSession(i),s=new i.Message({method:this[ao].method,uri:Bn.Uri.parse(n.toString(),Bn.UriFlags.ENCODED)});this[ao].session=o,this[ao].message=s,e.headers._appendToSoupMessage(i,s);let c=this._rawBodyBuffer;if(c!==null&&c.byteLength>0){let t=e.headers.get(`content-type`)||null;s.set_request_body_from_bytes(t,new Bn.Bytes(c))}n.protocol===`https:`&&shouldAcceptAnyCert(this.rejectUnauthorized)&&s.connect(`accept-certificate`,(e,t,n)=>!0);let l=new Vr.Cancellable;return t&&(t.aborted?l.cancel():t.addEventListener(`abort`,()=>l.cancel(),{once:!0})),this[ao].inputStream=await soupSendAsync(o,s,Bn.PRIORITY_DEFAULT,l),this[ao].readable=inputStreamToReadable(this[ao].inputStream),{inputStream:this[ao].inputStream,readable:this[ao].readable,cancellable:l}}clone(){return new Request(this)}async arrayBuffer(){return super.arrayBuffer()}async blob(){return super.blob()}async formData(){return super.formData()}async json(){return super.json()}async text(){return super.text()}};Object.defineProperties(so.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}});const getSoupRequestOptions=e=>{let{parsedURL:t}=e[ao],n=new za(e[ao].headers);n.has(`Accept`)||n.set(`Accept`,`*/*`);let r=null;if(e.body===null&&/^(post|put)$/i.test(e.method)&&(r=`0`),e.body!==null){let t=getTotalBytes(e);typeof t==`number`&&!Number.isNaN(t)&&(r=String(t))}r&&n.set(`Content-Length`,r),e.referrerPolicy===``&&(e.referrerPolicy=`strict-origin-when-cross-origin`),e.referrer&&e.referrer!==`no-referrer`?e[ao].referrer=determineRequestsReferrer(e):e[ao].referrer=`no-referrer`,e[ao].referrer instanceof ur&&n.set(`Referer`,e.referrer),n.has(`User-Agent`)||n.set(`User-Agent`,`gjsify-fetch`),e.compress&&!n.has(`Accept-Encoding`)&&n.set(`Accept-Encoding`,`gzip, deflate`);let{agent:i}=e;return typeof i==`function`&&(i=i(t)),!n.has(`Connection`)&&!i&&n.set(`Connection`,`close`),{parsedURL:t,options:{headers:n}}};var AbortError=class extends FetchBaseError{constructor(e,t=`aborted`){super(e,t)}};function parseDataUri(e){let t=e.match(/^data:([^,]*?)(;base64)?,(.*)$/s);if(!t)throw TypeError(`Invalid data URI: ${e.slice(0,50)}...`);let n=t[1]||`text/plain;charset=US-ASCII`,r=!!t[2],i=t[3],o;if(r){let e=atob(i);o=new Uint8Array(e.length);for(let t=0;t<e.length;t++)o[t]=e.charCodeAt(t)}else o=new TextEncoder().encode(decodeURIComponent(i));return{buffer:o,typeFull:n}}Ce();function rewriteRootRelativeUrl(e,t){if(!e.startsWith(`/`)||e.startsWith(`//`))return e;let n=lastPathSeparatorIndex(t);return n<=0?e:`${pathToFileUrlHref(t.slice(0,n))}${e}`}function resolveRootRelativeUrl(e){return rewriteRootRelativeUrl(e,c.programPath??c.programInvocationName??``)}re(),Ba(),ha(),Vn();const co=new Set([`data:`,`http:`,`https:`,`file:`]);function rewriteFetchInput(e){if(typeof e!=`string`)return e;let t=resolveRootRelativeUrl(e);return t!==e&&globalThis.__GJSIFY_DEBUG_FETCH===!0&&M.log(`[fetch] rewrite ${e} → ${t}`),t}async function fetch$1(e,t={}){e=rewriteFetchInput(e);let n=new so(e,t),{parsedURL:r,options:i}=getSoupRequestOptions(n);if(!co.has(r.protocol))throw TypeError(`@gjsify/fetch cannot load ${e}. URL scheme "${r.protocol.replace(/:$/,``)}" is not supported.`);if(r.protocol===`data:`){let{buffer:e,typeFull:t}=parseDataUri(n.url);return new no(Buffer.from(e),{headers:{"Content-Type":t}})}if(r.protocol===`file:`){let e=globalThis.__GJSIFY_DEBUG_FETCH===!0;e&&M.log(`[fetch] file:// ${n.url}`);try{let t=Bn.filename_from_uri(n.url)[0];e&&M.log(`[fetch] file:// path=${t}`);let[r,i]=Bn.file_get_contents(t);if(e&&M.log(`[fetch] file:// ok=${r} bytes=${i?.byteLength??`?`}`),!r)throw new FetchError(`Failed to read file: ${t}`,`system`);let o=i,s=new Uint8Array(o.byteLength);s.set(o);let c=new no(s);return e&&M.log(`[fetch] file:// response created`),c}catch(t){let r=t instanceof Error?t:Error(String(t));throw e&&M.warn(`[fetch] file:// FAIL: ${r.message}`),new FetchError(`request to ${n.url} failed, reason: ${r.message}`,`system`,r)}}let{signal:o}=n;if(o&&o.aborted)throw new AbortError(`The operation was aborted.`);let s,c;try{let e=await n._send(i);s=e.readable,c=e.cancellable}catch(e){if(o&&o.aborted)throw new AbortError(`The operation was aborted.`);let t=e instanceof Error?e:Error(String(e));throw new FetchError(`request to ${n.url} failed, reason: ${t.message}`,`system`,t)}let abortHandler=()=>{c.cancel()};o&&o.addEventListener(`abort`,abortHandler,{once:!0});let finalize=()=>{o&&o.removeEventListener(`abort`,abortHandler)};c.connect(()=>{s.destroy(new AbortError(`The operation was aborted.`))}),s.on(`error`,e=>{finalize()});let l=n._message,u=await loadSoup(),d=za._newFromSoupMessage(u,l),f=l.status_code,p=l.get_reason_phrase();if(isRedirect(f)){let e=d.get(`Location`),r=null;try{r=e===null?null:new ur(e,n.url)}catch{if(n.redirect!==`manual`)throw finalize(),new FetchError(`uri requested responds with an invalid redirect URL: ${e}`,`invalid-redirect`)}switch(n.redirect){case`error`:throw finalize(),new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${n.url}`,`no-redirect`);case`manual`:break;case`follow`:{if(r===null)break;if(n.counter>=n.follow)throw finalize(),new FetchError(`maximum redirect reached at: ${n.url}`,`max-redirect`);let e={headers:new za(n.headers),follow:n.follow,counter:n.counter+1,agent:n.agent,compress:n.compress,method:n.method,body:clone(n),signal:n.signal,size:n.size,referrer:n.referrer,referrerPolicy:n.referrerPolicy};if(!isDomainOrSubdomain(n.url,r)||!isSameProtocol(n.url,r))for(let t of[`authorization`,`www-authenticate`,`cookie`,`cookie2`])e.headers.delete(t);if(f!==303&&n.body&&t.body instanceof ma.Readable)throw finalize(),new FetchError(`Cannot follow redirect with body being a readable stream`,`unsupported-redirect`);(f===303||(f===301||f===302)&&n.method===`POST`)&&(e.method=`GET`,e.body=void 0,e.headers.delete(`content-length`));let i=parseReferrerPolicyFromHeader(d);return i&&(e.referrerPolicy=i),finalize(),fetch$1(new so(r,e))}default:throw TypeError(`Redirect option '${n.redirect}' is not a valid value of RequestRedirect`)}}let m={url:n.url,status:f,statusText:p,headers:d,size:n.size,counter:n.counter,highWaterMark:n.highWaterMark},h=d.get(`Content-Encoding`);if(!n.compress||n.method===`HEAD`||h===null||f===204||f===304)return finalize(),new no(s,m);if(typeof DecompressionStream<`u`){let e=null;if(h===`gzip`||h===`x-gzip`?e=`gzip`:(h===`deflate`||h===`x-deflate`)&&(e=`deflate`),e){let t=new S([await new no(s,m).arrayBuffer()]).stream().pipeThrough(new DecompressionStream(e));return finalize(),new no(t,m)}}return finalize(),new no(s,m)}__name$1(fetch$1,`fetch`);const lo=globalThis;globalThis.fetch===void 0&&(lo.fetch=fetch$1),globalThis.Headers===void 0&&(lo.Headers=za),globalThis.Request===void 0&&(lo.Request=so),globalThis.Response===void 0&&(lo.Response=no);const uo=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(uo.ByteLengthQueuingStrategy=Ii),globalThis.CountQueuingStrategy===void 0&&(uo.CountQueuingStrategy=Li);const fo=globalThis;function isNativeStreamUsable$2(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$2,`isNativeStreamUsable`),isNativeStreamUsable$2(globalThis.ReadableStream,`getReader`)||(fo.ReadableStream=Ni),fo.ReadableStreamBYOBReader===void 0&&(fo.ReadableStreamBYOBReader=ReadableStreamBYOBReader),fo.ReadableStreamBYOBRequest===void 0&&(fo.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),fo.ReadableByteStreamController===void 0&&(fo.ReadableByteStreamController=ReadableByteStreamController),fo.ReadableStreamDefaultController===void 0&&(fo.ReadableStreamDefaultController=ReadableStreamDefaultController),fo.ReadableStreamDefaultReader===void 0&&(fo.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const po=globalThis;globalThis.TextEncoderStream===void 0&&(po.TextEncoderStream=Ri),globalThis.TextDecoderStream===void 0&&(po.TextDecoderStream=zi);function isNativeStreamUsable$1(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(__name$1(isNativeStreamUsable$1,`isNativeStreamUsable`),!isNativeStreamUsable$1(globalThis.TransformStream,`readable`)){let e=globalThis;e.TransformStream=Fi}function isNativeStreamUsable(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(!isNativeStreamUsable(globalThis.WritableStream,`getWriter`)){let e=globalThis;e.WritableStream=Pi}function variantKindFor(e,t){switch(e){case`s`:case`b`:case`i`:case`u`:case`d`:return e}if(typeof t==`string`)return`s`;if(typeof t==`boolean`)return`b`;if(typeof t==`number`)return Number.isInteger(t)?`i`:`d`;throw Error(`Cannot build a GLib.Variant from ${typeof t}`)}function buildVariant(e,t){switch(variantKindFor(e?.dup_string()??null,t)){case`s`:return i.Variant.new_string(String(t));case`b`:return i.Variant.new_boolean(!!t);case`i`:return i.Variant.new_int32(Number(t));case`u`:return i.Variant.new_uint32(Number(t));case`d`:return i.Variant.new_double(Number(t))}}function describeActions(e){return e?e.list_actions().sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,enabled:e.get_action_enabled(t),parameterType:e.get_action_parameter_type(t)?.dup_string()??null,stateType:e.get_action_state_type(t)?.dup_string()??null})):[]}function activateAction(e,t,n){let r=e.get_action_parameter_type(t),i=n==null?null:buildVariant(r,n);e.activate_action(t,i)}function changeActionState(e,t,n){e.change_action_state(t,buildVariant(e.get_action_state_type(t),n))}const mo=new Map;function swapCss(e,t){let n=o.Display.get_default();if(!n)return!1;let r=mo.get(e);return r||(r=new d.CssProvider,d.StyleContext.add_provider_for_display(n,r,d.STYLE_PROVIDER_PRIORITY_USER+1),mo.set(e,r)),r.load_from_string(t),!0}function dumpCss(){return{providers:[...mo.keys()]}}const ho=`org.gjsify.Devtools`;function formatDbusErrorMessage(e,t){return`${e}: ${t}`}const go={GetStatus:`read-only`,Screenshot:`read-only`,ListActions:`read-only`,ActivateAction:`mutating`,ChangeActionState:`mutating`,PresentWindow:`read-only`,ResizeWindow:`mutating`,ListToplevels:`read-only`,DumpTree:`read-only`,GetProperty:`read-only`,GetFocused:`read-only`,FindWidget:`read-only`,SendKey:`mutating`,ActivateWidget:`mutating`,DumpGSettings:`read-only`,DumpCss:`read-only`,SwapCss:`mutating`};function sanitizeInstanceId(e){let t=e.toLowerCase().replace(/[^a-z0-9]/g,``);return/^[a-z]/.test(t)?t:`i${t||`0`}`}function appIdToObjectPath(e){return`/${e.replace(/\./g,`/`).replace(/-/g,`_`)}`}function resolveBusAddress(e,t){let n=appIdToObjectPath(e),r=t&&t!=="default"?sanitizeInstanceId(t):`default`;return r==="default"?{busName:e,objectPath:`${n}/devtools`,instance:`default`}:{busName:`${e}.${r}`,objectPath:`${n}/${r}/devtools`,instance:r}}const _o=`GJSIFY_DEVTOOLS_ADDRESS`;function isDevtoolsEnabledValue(e){if(e==null)return!1;let t=e.toLowerCase();return t!==``&&t!==`0`&&t!==`false`}function devtoolsAddressFilePath(e,t,n){let{busName:r}=resolveBusAddress(t,n);return`${e}/gjsify-devtools/${r}.address`}function buildDevtoolsIfaceXml(e=[]){return`<node>
@@ -97,7 +97,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,Symbol.dispose||(Symbol.dispos
97
97
  </method>${e.length>0?`\n${e.join(`
98
98
  `)}`:``}
99
99
  </interface>
100
- </node>`}re();function isWin32(){return i.DIR_SEPARATOR===92}function defaultListenAddress(){return isWin32()?`nonce-tcp:host=127.0.0.1`:`unix:tmpdir=${i.get_tmp_dir()}`}var DevtoolsPeerServerError=class extends Error{constructor(e,t,n,r){super(e),this.address=t,this.reason=n,this.name=`DevtoolsPeerServerError`,this.cause=r}};function isAddressInUse(e){return e instanceof i.Error&&e.matches(r.io_error_quark(),r.IOErrorEnum.ADDRESS_IN_USE)}function unixSocketPath(e){if(!e.startsWith(`unix:`))return null;for(let t of e.slice(5).split(`,`)){let e=t.indexOf(`=`);if(!(e<0||t.slice(0,e)!==`path`))try{return decodeURIComponent(t.slice(e+1))}catch{return null}}return null}function inspectExistingSocket(e){try{if((r.File.new_for_path(e).query_info(`unix::mode`,r.FileQueryInfoFlags.NONE,null).get_attribute_uint32(`unix::mode`)&61440)!=49152)return`not-a-socket`}catch{return`not-a-socket`}let t=new r.SocketClient;t.set_timeout(2);let n;try{n=t.connect(r.UnixSocketAddress.new(e),null)}catch{return`dead`}return n.close(null),`live`}function clearReclaimableSocket(e){let t=unixSocketPath(e);if(!t||!i.file_test(t,i.FileTest.EXISTS))return;let n=inspectExistingSocket(t);if(n===`live`)throw new DevtoolsPeerServerError(`cannot listen on ${e}: another process is already listening there. Stop it, or point ${_o} (or options.address) at a different socket — GJSIFY_DEVTOOLS_INSTANCE=<label> lets two devtools-enabled apps run side by side.`,e,`address-in-use`);if(n===`not-a-socket`)throw new DevtoolsPeerServerError(`cannot listen on ${e}: ${t} already exists and is not a socket, so it will NOT be removed. Point ${_o} (or options.address) at a free path.`,e,`occupied-by-other-file`);try{r.File.new_for_path(t).delete(null)}catch(n){throw new DevtoolsPeerServerError(`cannot listen on ${e}: ${t} is a socket nothing listens on, but removing it failed (${n}). Delete it by hand, or point ${_o} at a free path.`,e,`address-in-use`,n)}M.log(`[gjsify-devtools] reclaimed the stale socket ${t}: nothing was listening on it (an abnormal exit — Ctrl-C, SIGKILL, a crash — leaves the inode behind).`)}function flagsForAddress(e){return e.startsWith(`tcp:`)||e.startsWith(`nonce-tcp:`)?r.DBusServerFlags.NONE:r.DBusServerFlags.AUTHENTICATION_REQUIRE_SAME_USER}function startDevtoolsPeerServer(e,t,n){let i=n&&n!==``?n:defaultListenAddress();clearReclaimableSocket(i);let o;try{o=r.DBusServer.new_sync(i,flagsForAddress(i),r.dbus_generate_guid(),null,null)}catch(e){let t=isAddressInUse(e);throw new DevtoolsPeerServerError(t?`cannot listen on ${i}: the address is already in use (${e}). Stop whatever holds it, or point ${_o} (or options.address) at a different address.`:`cannot listen on ${i}: ${e}. Check the address form — \`unix:path=/tmp/app.sock\`, \`unix:tmpdir=/tmp\` or \`nonce-tcp:host=127.0.0.1\`.`,i,t?`address-in-use`:`listen-failed`,e)}let s=new Set;o.connect(`new-connection`,(n,r)=>(s.add(r),r.connect(`closed`,()=>{e.unexport(r),s.delete(r)}),e.export(r,t),!0)),o.start();let c=!1;return{address:o.get_client_address(),objectPath:t,get connectionCount(){return s.size},stop(){if(!c){c=!0,o.stop();for(let t of s)e.unexport(t),!t.is_closed()&&t.close(null,(e,t)=>{try{e.close_finish(t)}catch{}});s.clear()}}}}function writeDevtoolsAddressFile(e,t){try{if(i.mkdir_with_parents(i.path_get_dirname(e),448),!i.file_set_contents(e,`${t}\n`))return null}catch(t){return M.error(`[gjsify-devtools] could not publish the peer address to ${e}: ${t}`),null}try{r.File.new_for_path(e).set_attribute_uint32(`unix::mode`,384,r.FileQueryInfoFlags.NONE,null)}catch(t){M.error(`[gjsify-devtools] could not restrict ${e} to the current user: ${t}`)}return e}function removeDevtoolsAddressFile(e){try{r.File.new_for_path(e).delete(null)}catch{}}function captureWidget(e){let t=e.get_native()?.get_renderer();if(!t)return{png:null,blocker:`no-renderer`};let n=e.get_width(),r=e.get_height();if(n<=0||r<=0)return{png:null,blocker:`zero-size`};let i=d.WidgetPaintable.new(e),o=d.Snapshot.new();i.snapshot(o,n,r);let s=o.to_node();if(!s)return{png:null,blocker:`empty-snapshot`};let c=new f.Rect;c.init(0,0,n,r);let l=t.render_texture(s,c).save_to_png_bytes().get_data();return l?{png:new Uint8Array(l)}:{png:null,blocker:`empty-png`}}function dumpGSettings(e){let t=r.SettingsSchemaSource.get_default()?.lookup(e,!0);if(!t)throw Error(formatDbusErrorMessage(`not-found`,`GSettings schema '${e}' is not installed`));let n=new r.Settings({settings_schema:t}),i={};for(let e of t.list_keys())i[e]=n.get_value(e).recursiveUnpack();return i}function parseWidgetPath(e){let t=e.split(`/`).filter(e=>e.length>0);if(t.length===0)return null;let n=t[0].match(/^toplevel:(\d+)$/);if(!n)return null;let r=[];for(let e of t.slice(1)){let t=e.match(/^child:(\d+)$/);if(!t)return null;r.push(Number(t[1]))}return{toplevel:Number(n[1]),children:r}}function buildWidgetPath(e,t){return[`toplevel:${e}`,...t.map(e=>`child:${e}`)].join(`/`)}function widgetType(e){return gtypeName(e)??`GtkWidget`}function gtypeName(e){let t=e;return typeof t?.$typeName==`string`&&t.$typeName.length>0?t.$typeName:t?.constructor?.$gtype?.name??null}function activateWidget(e){let t=e;if(typeof t.activate==`function`&&t.activate()===!0)return!0;let n=typeof t.get_parent==`function`?t.get_parent():null;if(n&&widgetType(n)===`GtkListBox`){let t=n,r=!1;return typeof t.select_row==`function`&&(t.select_row(e),r=!0),typeof t.emit==`function`&&(t.emit(`row-activated`,e),r=!0),r}return!1}function sendKeyToWidget(e,t,n){let r=e.observe_controllers(),i=!1;for(let e=0;e<r.get_n_items();e++){let o=r.get_item(e);gtypeName(o)===`GtkEventControllerKey`&&(o.emit(`key-pressed`,t,0,n),i=!0)}return i}function nthChild(e,t){let n=e.get_first_child(),r=0;for(;n&&r<t;)n=n.get_next_sibling(),r++;return r===t?n:null}function listToplevels(){let e=d.Window.get_toplevels(),t=e.get_n_items(),n=[];for(let r=0;r<t;r++){let t=e.get_item(r);t&&n.push({path:`toplevel:${r}`,type:widgetType(t),title:t.get_title?.()??null,mapped:t.get_mapped(),focused:t.is_active??!1})}return n}function resolveWidgetPath(e){let t=parseWidgetPath(e);if(!t)return null;let n=d.Window.get_toplevels().get_item(t.toplevel);if(!n)return null;for(let e of t.children)if(n=nthChild(n,e),!n)return null;return n}function parseWidgetSelector(e){let t=e.indexOf(`:`),n=(t<0?e:e.slice(0,t)).trim(),r=(t<0?``:e.slice(t+1)).trim();return!n&&!r?null:{type:n,cssClass:r}}function findWidgetPath(e,t,n){if(!e.get_visible()||!e.get_mapped())return null;let r=!t.type||widgetType(e)===t.type,i=!t.cssClass||e.get_css_classes().includes(t.cssClass);if(r&&i)return n;let o=e.get_first_child(),s=0;for(;o;){let e=findWidgetPath(o,t,`${n}/child:${s}`);if(e)return e;o=o.get_next_sibling(),s++}return null}function geometryOf(e){if(!e.get_mapped())return;let t=e.get_allocation(),n=t.width+e.get_margin_start()+e.get_margin_end(),r=t.height+e.get_margin_top()+e.get_margin_bottom(),[i,o]=e.measure(d.Orientation.HORIZONTAL,-1),s=n>0?Math.max(n,i):-1,[c,l]=e.measure(d.Orientation.VERTICAL,s),u={width:n,height:r,widthRequest:[i,o],heightRequest:[c,l]};return(n<i||r<c)&&(u.short=!0),u}function dumpTree(e,t,n){let r={path:n,type:widgetType(e),name:e.get_name()||null,cssClasses:e.get_css_classes(),mapped:e.get_mapped(),visible:e.get_visible(),children:[]},i=geometryOf(e);if(i!==void 0&&(r.geometry=i),t<=0)return e.get_first_child()&&(r.truncated=!0),r;let o=e.get_first_child(),s=0;for(;o;)r.children.push(dumpTree(o,t-1,`${n}/child:${s}`)),o=o.get_next_sibling(),s++;return r}function jsonSafe(e){let t=typeof e;return e==null||t===`string`||t===`number`||t===`boolean`?e??null:`[${t}]`}function getWidgetProperty(e,t){let n=e,r=t.replace(/-/g,`_`),i=t.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase());for(let e of[t,r,i])if(e in n)return jsonSafe(n[e])}function childIndex(e,t){let n=e.get_first_child(),r=0;for(;n;){if(n===t)return r;n=n.get_next_sibling(),r++}return-1}function pathOfWidget(e){let t=[],n=e,r=n.get_parent();for(;r;){let e=childIndex(r,n);if(e<0)return null;t.unshift(e),n=r,r=n.get_parent()}let i=d.Window.get_toplevels(),o=i.get_n_items();for(let e=0;e<o;e++)if(i.get_item(e)===n)return buildWidgetPath(e,t);return null}re();function isActiveWindowScope(e){return!e||e===`window`||e===`active`}function frameDelay(e){return new Promise(t=>{i.timeout_add(i.PRIORITY_DEFAULT,e,()=>(t(),i.SOURCE_REMOVE))})}async function captureWidgetWhenRenderable(e,t=12,n=50){let r=null;for(let i=0;i<t;i++){let t=captureWidget(e);if(t.png)return{png:t.png,blocker:null};r=t.blocker,await frameDelay(n)}let i=captureWidget(e);return{png:i.png,blocker:i.png?null:i.blocker??r}}var DevtoolsService=class{constructor(e,t){this._app=e,this._options=t,this._exported=new Map,this._peer=null,this._addressFile=null,this._kinds=new Map,this._extensions=t.extend??[];for(let[e,t]of Object.entries(go))this._kinds.set(e,t);for(let e of this._extensions){for(let[t,n]of Object.entries(e.methodKinds))this._kinds.set(t,n);for(let[t,n]of Object.entries(e.handlers)){let e=n;this[t]=(...n)=>(this._guard(t),e(...n))}}}export(e,t){if(this._exported.has(e))return;let n=buildDevtoolsIfaceXml(this._extensions.flatMap(e=>e.methodsXml??[])),i=r.DBusExportedObject.wrapJSObject(n,this);i.export(e,t),this._exported.set(e,i)}unexport(e){if(e){this._exported.get(e)?.unexport(),this._exported.delete(e);return}for(let e of this._exported.values())e.unexport();this._exported.clear(),this._peer?.stop(),this._peer=null,this._addressFile&&=(removeDevtoolsAddressFile(this._addressFile),null)}attachPeerServer(e,t){this._peer=e,this._addressFile=t??null}get peerAddress(){return this._peer?.address??null}get addressFile(){return this._addressFile}GetStatus(){let e=this._app.get_active_window(),t={appId:this._app.get_application_id()??`unknown`,instance:this._options.instance??`default`,activeWindow:e?{id:e.get_name()||`window`,title:e.get_title()??``,mapped:e.get_mapped()}:null,toplevelCount:d.Window.get_toplevels().get_n_items(),focusedWidget:null,paused:this._isPaused()};for(let e of this._extensions){let n=e.contributeStatus?.();n&&Object.assign(t,n)}return JSON.stringify(t)}async ScreenshotAsync(e,t){try{let n=typeof e?.[0]==`string`?e[0]:``,r=await this._captureScopePng(n);t.return_value(new i.Variant(`(ay)`,[r]))}catch(e){t.return_dbus_error(`org.gjsify.Devtools.Error.Screenshot`,e instanceof Error?e.message:String(e))}}async _captureScopePng(e){let t=this._resolveRootWidget(e);if(!t){if(isActiveWindowScope(e))return new Uint8Array;throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e}'`))}let n=captureWidget(t.widget);if(n.png)return n.png;let r=t.widget.get_root();r instanceof d.Window&&r.present();let i=await captureWidgetWhenRenderable(t.widget);return i.png?i.png:(M.warn(`[devtools] Screenshot('${e}') has no image: ${i.blocker??`unknown`} after 12 tries. Empty bytes follow.`),new Uint8Array)}ListActions(){let e={app:describeActions(this._actionGroup(`app`)),win:describeActions(this._actionGroup(`win`))};return JSON.stringify(e)}ActivateAction(e,t,n){this._guard(`ActivateAction`);let r=this._scope(e);activateAction(this._requireGroup(r,t),t,this._parseValue(n))}ChangeActionState(e,t,n){this._guard(`ChangeActionState`);let r=this._scope(e);changeActionState(this._requireGroup(r,t),t,this._parseValue(n))}PresentWindow(){this._app.get_active_window()?.present()}ResizeWindow(e,t){this._guard(`ResizeWindow`);let n=this._app.get_active_window();if(!n)throw Error(formatDbusErrorMessage(`unavailable`,`no active window to resize`));let r=Math.max(1,Math.round(e)),i=Math.max(1,Math.round(t));return n.is_maximized()&&n.unmaximize(),n.is_fullscreen()&&n.unfullscreen(),n.set_default_size(r,i),[r,i]}ListToplevels(){return JSON.stringify(listToplevels())}DumpTree(e,t){let n=this._resolveRootWidget(e);if(!n)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e||`active window`}'`));return JSON.stringify(dumpTree(n.widget,t>0?t:40,n.path))}GetProperty(e,t){let n=this._resolveRootWidget(e);if(!n)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e}'`));let r=getWidgetProperty(n.widget,t);if(r===void 0)throw Error(formatDbusErrorMessage(`not-found`,`widget has no property '${t}'`));return JSON.stringify(r)}GetFocused(){let e=this._app.get_active_window(),t=e?e.get_focus():null;return JSON.stringify(t?{path:pathOfWidget(t),name:t.get_name()||null,type:widgetType(t)}:null)}ActivateWidget(e){this._guard(`ActivateWidget`);let t=this._resolveRootWidget(e);if(!t)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e}'`));return activateWidget(t.widget)}FindWidget(e){let t=parseWidgetSelector(e);if(!t)throw Error(formatDbusErrorMessage(`invalid-params`,`empty selector '${e}'`));let n=this._resolveRootWidget(``);return n?findWidgetPath(n.widget,t,n.path)??``:``}SendKey(e,t){this._guard(`SendKey`);let[n,r,i]=d.accelerator_parse(e);if(!n)throw Error(formatDbusErrorMessage(`invalid-params`,`cannot parse accelerator '${e}'`));let o;if(o=t?this._resolveRootWidget(t)?.widget??null:this._app.get_active_window()?.get_focus()??null,!o)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${t||`focus`}'`));return sendKeyToWidget(o,r,i??0)}DumpGSettings(e){return JSON.stringify(dumpGSettings(e))}DumpCss(){return JSON.stringify(dumpCss())}SwapCss(e,t){return this._guard(`SwapCss`),swapCss(e,t)}_resolveRootWidget(e){if(isActiveWindowScope(e)){let e=this._app.get_active_window();return e?{widget:e,path:pathOfWidget(e)??`toplevel:0`}:null}let t=resolveWidgetPath(e);return t?{widget:t,path:e}:null}_isPaused(){return this._options.paused?.()??!1}_guard(e){let t=this._kinds.get(e);if(!t)throw Error(formatDbusErrorMessage(`internal`,`unclassified devtools method '${e}'`));if(t===`mutating`&&this._isPaused())throw Error(formatDbusErrorMessage(`paused`,`${e} rejected — external control is paused. Read-only methods keep working.`))}_scope(e){return e===`app`?`app`:`win`}_actionGroup(e){if(e===`app`)return this._app;if(this._options.winActionGroup)return this._options.winActionGroup;let t=this._app.get_active_window();return t instanceof d.ApplicationWindow?t:null}_requireGroup(e,t){let n=this._actionGroup(e);if(!n)throw Error(formatDbusErrorMessage(`unavailable`,`no '${e}' action group`));if(!n.has_action(t))throw Error(formatDbusErrorMessage(`not-found`,`unknown action ${e}.${t}`));return n}_parseValue(e){if(!e||e===`null`)return null;try{return JSON.parse(e)}catch{throw Error(formatDbusErrorMessage(`invalid-params`,`value_json is not valid JSON: ${e}`))}}};re();const vo=`DBUS_SESSION_BUS_ADDRESS`,yo=new Set;function envEnabled(){return isDevtoolsEnabledValue(i.getenv(`GJSIFY_DEVTOOLS`))}function envValue(e){let t=i.getenv(e);return t&&t!==``?t:null}function sessionBusUsable(){if(!envValue(vo))return!1;try{return r.bus_get_sync(r.BusType.SESSION,null),!0}catch{return!1}}function chooseDevtoolsTransport(e){return e.requestedAddress?{kind:`peer`,address:e.requestedAddress,reason:`requested`}:e.hasAppConnection?{kind:`session-bus`}:e.sessionBusUsable?{kind:`unregistered`}:{kind:`peer`,address:null,reason:`no-session-bus`}}function describeMissingConnection(e,t){return e?t?`[gjsify-devtools] the session bus answers but this application is not registered on it yet — call installDevtools() from the GtkApplication "startup" handler (the bus connection and object path exist only after registration).`:`[gjsify-devtools] ${vo} is set (${e}) but no bus answers there — using the bus-less peer transport instead. On macOS this is the usual state: Homebrew's dbus listens on launchd, so the advertised address only works while that socket is live.`:`[gjsify-devtools] this machine has no session bus (${vo} is unset) — using the bus-less peer transport instead. Point the bridge at the address below, or set ${_o} on both the app and \`gjsify debug\` to pin it yourself.`}function installDevtools(e,t={}){if(!(t.enabled??envEnabled()))return null;let n=t.instance??envValue(`GJSIFY_DEVTOOLS_INSTANCE`)??void 0,r=new DevtoolsService(e,{...t,instance:n});try{return exportDevtools(e,r,t,n)}catch(e){return r.unexport(),M.error(`[gjsify-devtools] devtools stayed OFF, the app is unaffected — ${describeInstallFailure(e)}`),null}}function describeInstallFailure(e){return e instanceof DevtoolsPeerServerError||e instanceof Error?e.message:String(e)}function exportDevtools(e,t,n,r){let o=e.get_is_registered(),s=o?e.get_dbus_connection():null,c=o?e.get_dbus_object_path():null,l=envValue(vo),u=!!(s&&c),d=u||sessionBusUsable(),f=chooseDevtoolsTransport({requestedAddress:n.address??envValue(_o),hasAppConnection:u,sessionBusUsable:d}),p=e.get_application_id()??`unknown`,m=`${c??appIdToObjectPath(p)}/devtools`;if((f.kind===`unregistered`||f.kind===`peer`&&f.reason===`no-session-bus`)&&M.error(describeMissingConnection(l,d)),f.kind===`session-bus`&&s)t.export(s,m),M.log(`[gjsify-devtools] exported ${ho} at ${m} (dest ${p})`);else if(f.kind===`peer`){let n=startDevtoolsPeerServer(t,m,f.address??void 0),o=writeDevtoolsAddressFile(devtoolsAddressFilePath(i.get_user_runtime_dir(),p,r),n.address);t.attachPeerServer(n,o),M.log(`[gjsify-devtools] exported ${ho} at ${m} (peer address ${n.address}${o?`, published to ${o}`:``})`),o&&e.connect(`shutdown`,()=>removeDevtoolsAddressFile(o))}return yo.add(t),t}function notifyElementResize(e,t,n){e._allocatedClientWidth=t,e._allocatedClientHeight=n,e._fireResizeSubscribers(t,n);let r=e.parentNode;for(;r;)r instanceof Element&&(r._allocatedClientWidth=t,r._allocatedClientHeight=n,r._fireResizeSubscribers(t,n)),r=r.parentNode}var HTMLCanvasElement$1=class extends Rt{static{__name$1(this,`HTMLCanvasElement`)}constructor(e){super(),this.gtkGlArea=e}get width(){return this.gtkGlArea.get_allocated_width()*this.scaleFactor}set width(e){}get height(){return this.gtkGlArea.get_allocated_height()*this.scaleFactor}set height(e){}get scaleFactor(){return this.gtkGlArea.get_scale_factor()||1}get clientWidth(){return this.gtkGlArea.get_allocated_width()}get clientHeight(){return this.gtkGlArea.get_allocated_height()}get offsetWidth(){return this.clientWidth}get offsetHeight(){return this.clientHeight}getGlArea(){return this.gtkGlArea}_createCloneTarget(){let e=new Rt;return e.width=this.width,e.height=this.height,e}getContext(e,t){return e===`webgl`||e===`experimental-webgl`?(this._webgl||=(this.gtkGlArea.make_current(),new WebGLRenderingContext$1(this,t)),this._webgl):e===`webgl2`?(this._webgl2||=(this.gtkGlArea.make_current(),new Xr(this,t)),this._webgl2):super.getContext(e,t)}};const bo=[`apple software renderer`,`llvmpipe`,`softpipe`,`swrast`,`swiftshader`,`microsoft basic render driver`,`mesa offscreen`];function isSoftwareRenderer(e){if(!e)return!1;let t=e.toLowerCase();return bo.some(e=>t.includes(e))}const xo={Return:`Enter`,KP_Enter:`Enter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`Delete`,Insert:`Insert`,KP_Insert:`Insert`,Home:`Home`,KP_Home:`Home`,End:`End`,KP_End:`End`,Page_Up:`PageUp`,KP_Page_Up:`PageUp`,Page_Down:`PageDown`,KP_Page_Down:`PageDown`,Left:`ArrowLeft`,KP_Left:`ArrowLeft`,Up:`ArrowUp`,KP_Up:`ArrowUp`,Right:`ArrowRight`,KP_Right:`ArrowRight`,Down:`ArrowDown`,KP_Down:`ArrowDown`,Shift_L:`Shift`,Shift_R:`Shift`,Control_L:`Control`,Control_R:`Control`,Alt_L:`Alt`,Alt_R:`Alt`,Super_L:`Meta`,Super_R:`Meta`,Meta_L:`Meta`,Meta_R:`Meta`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:` `,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`+`,KP_Subtract:`-`,KP_Multiply:`*`,KP_Divide:`/`,KP_Decimal:`.`,KP_Separator:`,`,KP_0:`0`,KP_1:`1`,KP_2:`2`,KP_3:`3`,KP_4:`4`,KP_5:`5`,KP_6:`6`,KP_7:`7`,KP_8:`8`,KP_9:`9`},So={Return:`Enter`,KP_Enter:`NumpadEnter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`NumpadDecimal`,Insert:`Insert`,KP_Insert:`Numpad0`,Home:`Home`,KP_Home:`Numpad7`,End:`End`,KP_End:`Numpad1`,Page_Up:`PageUp`,KP_Page_Up:`Numpad9`,Page_Down:`PageDown`,KP_Page_Down:`Numpad3`,Left:`ArrowLeft`,KP_Left:`Numpad4`,Up:`ArrowUp`,KP_Up:`Numpad8`,Right:`ArrowRight`,KP_Right:`Numpad6`,Down:`ArrowDown`,KP_Down:`Numpad2`,Shift_L:`ShiftLeft`,Shift_R:`ShiftRight`,Control_L:`ControlLeft`,Control_R:`ControlRight`,Alt_L:`AltLeft`,Alt_R:`AltRight`,Super_L:`MetaLeft`,Super_R:`MetaRight`,Meta_L:`MetaLeft`,Meta_R:`MetaRight`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:`Space`,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`NumpadAdd`,KP_Subtract:`NumpadSubtract`,KP_Multiply:`NumpadMultiply`,KP_Divide:`NumpadDivide`,KP_Decimal:`NumpadDecimal`,KP_Separator:`NumpadComma`,KP_0:`Numpad0`,KP_1:`Numpad1`,KP_2:`Numpad2`,KP_3:`Numpad3`,KP_4:`Numpad4`,KP_5:`Numpad5`,KP_6:`Numpad6`,KP_7:`Numpad7`,KP_8:`Numpad8`,KP_9:`Numpad9`};function gdkKeyvalToKey(e){let t=o.keyval_name(e);if(t&&xo[t])return xo[t];let n=o.keyval_to_unicode(e);return n>0?String.fromCodePoint(n):t??`Unidentified`}function gdkKeyvalToCode(e){let t=o.keyval_name(e);if(t&&So[t])return So[t];let n=o.keyval_to_unicode(e);if(n>=97&&n<=122)return`Key`+String.fromCodePoint(n-32);if(n>=65&&n<=90)return`Key`+String.fromCodePoint(n);if(n>=48&&n<=57)return`Digit`+String.fromCodePoint(n);if(t){let e={minus:`Minus`,equal:`Equal`,bracketleft:`BracketLeft`,bracketright:`BracketRight`,backslash:`Backslash`,semicolon:`Semicolon`,apostrophe:`Quote`,grave:`Backquote`,comma:`Comma`,period:`Period`,slash:`Slash`};if(e[t])return e[t]}return t??`Unidentified`}function gdkKeyvalToLocation(e){let t=o.keyval_name(e);return t?t.startsWith(`KP_`)?3:t.endsWith(`_L`)?1:t.endsWith(`_R`)?2:0:0}const Co=.5;var TouchPointerTranslator=class{constructor(e,t){this.getElement=e,this.getWindowTarget=t,this.active=new Map,this.nextId=2}get activeCount(){return this.active.size}handle(e){switch(e.phase){case`begin`:this.begin(e);break;case`update`:this.update(e);break;case`end`:this.end(e);break;case`cancel`:this.cancel(e);break}}cancelAll(e){for(let[t,n]of this.active)this.cancel({...e,phase:`cancel`,key:t,x:n.lastX,y:n.lastY,isPrimary:n.isPrimary})}begin(e){this.active.has(e.key)&&this.cancel(e);let t=this.getElement();if(!t)return;let n={id:this.nextId++,isPrimary:e.isPrimary,lastX:e.x,lastY:e.y,preventMouse:!1};this.active.set(e.key,n);let r=this.pointerInit(e,n,-1,0,0),i=this.mouseInit(e,0,0);n.isPrimary&&t.dispatchEvent(new MouseEvent(`mousemove`,i)),t.dispatchEvent(new PointerEvent(`pointerover`,r)),t.dispatchEvent(new PointerEvent(`pointerenter`,{...r,bubbles:!1,cancelable:!1})),n.isPrimary&&(t.dispatchEvent(new MouseEvent(`mouseover`,i)),t.dispatchEvent(new MouseEvent(`mouseenter`,{...i,bubbles:!1,cancelable:!1})));let o=new PointerEvent(`pointerdown`,this.pointerInit(e,n,0,1,Co));t.dispatchEvent(o),n.isPrimary&&(n.preventMouse=o.defaultPrevented,n.preventMouse||t.dispatchEvent(new MouseEvent(`mousedown`,{...this.mouseInit(e,0,1),detail:1})))}update(e){let t=this.active.get(e.key);if(!t)return;let n=this.getElement();if(!n)return;let r=e.x-t.lastX,i=e.y-t.lastY;t.lastX=e.x,t.lastY=e.y,n.dispatchEvent(new PointerEvent(`pointermove`,{...this.pointerInit(e,t,-1,1,Co),movementX:r,movementY:i})),t.isPrimary&&!t.preventMouse&&n.dispatchEvent(new MouseEvent(`mousemove`,{...this.mouseInit(e,0,1),movementX:r,movementY:i}))}end(e){let t=this.active.get(e.key);if(!t)return;this.active.delete(e.key);let n=this.getElement();if(!n)return;let r=this.pointerInit(e,t,0,0,0),i=this.mouseInit(e,0,0),o=t.isPrimary&&!t.preventMouse;n.dispatchEvent(new PointerEvent(`pointerup`,r)),o&&n.dispatchEvent(new MouseEvent(`mouseup`,{...i,detail:1})),this.leave(n,t,{...r,button:-1},i),t.isPrimary&&n.dispatchEvent(new PointerEvent(`click`,{...r,detail:1}))}cancel(e){let t=this.active.get(e.key);if(!t)return;this.active.delete(e.key);let n=this.getElement();if(!n)return;let r={...e,x:t.lastX,y:t.lastY},i=this.pointerInit(r,t,-1,0,0),o=this.mouseInit(r,0,0);n.dispatchEvent(new PointerEvent(`pointercancel`,{...i,cancelable:!1})),t.isPrimary&&!t.preventMouse&&this.getWindowTarget()?.dispatchEvent(new MouseEvent(`mouseup`,{...o,detail:1})),this.leave(n,t,i,o)}leave(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointerout`,n)),e.dispatchEvent(new PointerEvent(`pointerleave`,{...n,bubbles:!1,cancelable:!1})),t.isPrimary&&(e.dispatchEvent(new MouseEvent(`mouseout`,r)),e.dispatchEvent(new MouseEvent(`mouseleave`,{...r,bubbles:!1,cancelable:!1})))}mouseInit(e,t,n){return{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,clientX:e.x,clientY:e.y,offsetX:e.x,offsetY:e.y,screenX:e.x,screenY:e.y,button:t,buttons:n,bubbles:!0,cancelable:!0}}pointerInit(e,t,n,r,i){return{...this.mouseInit(e,n,r),pointerId:t.id,pointerType:`touch`,isPrimary:t.isPrimary,pressure:i}}};re();const wo=new Map([[o.EventType.TOUCH_BEGIN,`begin`],[o.EventType.TOUCH_UPDATE,`update`],[o.EventType.TOUCH_END,`end`],[o.EventType.TOUCH_CANCEL,`cancel`]]);function isTouchEvent(e){return e!==null&&wo.has(e.get_event_type())}function pointerTypeOf(e){let t=e?.get_device()?.get_source();return t===o.InputSource.TOUCHSCREEN?`touch`:t===o.InputSource.PEN?`pen`:`mouse`}let To=!1;function sequenceKey(e,t){if(e===null)return t?`primary`:`secondary`;let n=String(e),r=n.lastIndexOf(`native@`);return r!==-1&&n.endsWith(`]`)?n.slice(r+7,-1):(To||(To=!0,M.warn(`@gjsify/event-bridge: GdkEventSequence identity is not readable on this runtime; touch pointers are keyed by the emulating-pointer flag, so a third concurrent contact merges with the second.`)),t?`primary`:`secondary`)}function surfaceToWidget(e,t,n){let r=e.get_native(),[i,o]=r.get_surface_transform(),s=t-i,c=n-o,[l,u]=r.compute_point(e,new f.Point({x:s,y:c}));return l?[u.x,u.y]:[s,c]}function getGlobalEventTarget(){return globalThis.__gjsify_globalEventTarget}const Eo={shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1};function modifiersFromState(e){return{shiftKey:!!(e&o.ModifierType.SHIFT_MASK),ctrlKey:!!(e&o.ModifierType.CONTROL_MASK),altKey:!!(e&o.ModifierType.ALT_MASK),metaKey:!!(e&o.ModifierType.SUPER_MASK)}}function extractModifiers(e){return modifiersFromState(e.get_current_event_state())}function gtkButtonToDom(e){return e===1?0:e===2?1:e===3?2:e-1}function buttonsFromModifiers(e){let t=e.get_current_event_state(),n=0;return t&o.ModifierType.BUTTON1_MASK&&(n|=1),t&o.ModifierType.BUTTON3_MASK&&(n|=2),t&o.ModifierType.BUTTON2_MASK&&(n|=4),n}function attachEventControllers(e,t,n){e.set_focusable(!0),e.set_can_focus(!0);let r={lastX:0,lastY:0,buttonsPressed:0,pressedKeys:new Set},i=new TouchPointerTranslator(t,()=>getGlobalEventTarget()),s=new d.EventControllerMotion;s.connect(`motion`,(n,i,o)=>{let c=t();if(!c)return;let l=e.get_allocated_width(),u=e.get_allocated_height(),d=Math.max(0,Math.min(i,l)),f=Math.max(0,Math.min(o,u)),p=d-r.lastX,m=f-r.lastY,h=extractModifiers(s),g=buttonsFromModifiers(s),_={...h,clientX:d,clientY:f,offsetX:d,offsetY:f,screenX:d,screenY:f,movementX:p,movementY:m,buttons:g,button:0,bubbles:!0,cancelable:!0};c.dispatchEvent(new PointerEvent(`pointermove`,{..._,pointerId:1,pointerType:pointerTypeOf(s.get_current_event()),isPrimary:!0})),c.dispatchEvent(new MouseEvent(`mousemove`,_)),r.lastX=d,r.lastY=f}),s.connect(`enter`,(e,n,i)=>{let o=t();if(!o)return;r.lastX=n,r.lastY=i;let c={...extractModifiers(s),clientX:n,clientY:i,offsetX:n,offsetY:i,screenX:n,screenY:i,bubbles:!1,cancelable:!1};o.dispatchEvent(new PointerEvent(`pointerenter`,{...c,pointerId:1,pointerType:pointerTypeOf(s.get_current_event()),isPrimary:!0})),o.dispatchEvent(new MouseEvent(`mouseenter`,c)),o.dispatchEvent(new MouseEvent(`mouseover`,{...c,bubbles:!0}))}),s.connect(`leave`,()=>{let e=t();if(!e)return;let n={...extractModifiers(s),clientX:r.lastX,clientY:r.lastY,bubbles:!1,cancelable:!1};e.dispatchEvent(new PointerEvent(`pointerleave`,{...n,pointerId:1,pointerType:pointerTypeOf(s.get_current_event()),isPrimary:!0})),e.dispatchEvent(new MouseEvent(`mouseleave`,n)),e.dispatchEvent(new MouseEvent(`mouseout`,{...n,bubbles:!0}))}),e.add_controller(s);let c=new d.GestureClick;c.set_button(0),c.connect(`pressed`,(n,i,o,s)=>{if(isTouchEvent(c.get_current_event()))return;let l=t();if(!l)return;let u=gtkButtonToDom(c.get_current_button()),d=extractModifiers(c);r.buttonsPressed|=1<<u;let f={...d,clientX:o,clientY:s,offsetX:o,offsetY:s,screenX:o,screenY:s,button:u,buttons:r.buttonsPressed,detail:i,bubbles:!0,cancelable:!0};l.dispatchEvent(new PointerEvent(`pointerdown`,{...f,pointerId:1,pointerType:pointerTypeOf(c.get_current_event()),isPrimary:!0})),l.dispatchEvent(new MouseEvent(`mousedown`,f)),e.grab_focus()}),c.connect(`released`,(e,n,i,o)=>{if(isTouchEvent(c.get_current_event()))return;let s=t();if(!s)return;let l=gtkButtonToDom(c.get_current_button()),u=extractModifiers(c);r.buttonsPressed&=~(1<<l);let d={...u,clientX:i,clientY:o,offsetX:i,offsetY:o,screenX:i,screenY:o,button:l,buttons:r.buttonsPressed,detail:n,bubbles:!0,cancelable:!0};s.dispatchEvent(new PointerEvent(`pointerup`,{...d,pointerId:1,pointerType:pointerTypeOf(c.get_current_event()),isPrimary:!0})),s.dispatchEvent(new MouseEvent(`mouseup`,d)),l===0&&(s.dispatchEvent(new MouseEvent(`click`,d)),n===2&&s.dispatchEvent(new MouseEvent(`dblclick`,d))),l===2&&s.dispatchEvent(new MouseEvent(`contextmenu`,{...d,cancelable:!0}))}),c.connect(`cancel`,(e,n)=>{let i=c.get_last_event(n);if(isTouchEvent(i)||r.buttonsPressed===0)return;r.buttonsPressed=0;let o=t();o&&o.dispatchEvent(new PointerEvent(`pointercancel`,{...extractModifiers(c),clientX:r.lastX,clientY:r.lastY,offsetX:r.lastX,offsetY:r.lastY,screenX:r.lastX,screenY:r.lastY,button:-1,buttons:0,pointerId:1,pointerType:pointerTypeOf(i),isPrimary:!0,bubbles:!0,cancelable:!1}))}),e.add_controller(c);let l=new d.EventControllerScroll({flags:d.EventControllerScrollFlags.BOTH_AXES});l.connect(`scroll`,(e,n,i)=>{let s=t();if(!s)return;let c=extractModifiers(l),u=l.get_unit()===o.ScrollUnit.WHEEL,d=u?3:1,f={...c,clientX:r.lastX,clientY:r.lastY,offsetX:r.lastX,offsetY:r.lastY,screenX:r.lastX,screenY:r.lastY,deltaX:n*d,deltaY:i*d,deltaZ:0,deltaMode:u?WheelEvent.DOM_DELTA_LINE:WheelEvent.DOM_DELTA_PIXEL,bubbles:!0,cancelable:!0};return s.dispatchEvent(new WheelEvent(`wheel`,f)),!1}),e.add_controller(l);let u=new d.EventControllerKey;u.connect(`key-pressed`,(e,i,s,c)=>{let l=t();if(!l)return!1;let u=r.pressedKeys.has(i);r.pressedKeys.add(i);let d=gdkKeyvalToKey(i),f={key:d,code:gdkKeyvalToCode(i),location:gdkKeyvalToLocation(i),repeat:u,altKey:!!(c&o.ModifierType.ALT_MASK),ctrlKey:!!(c&o.ModifierType.CONTROL_MASK),metaKey:!!(c&o.ModifierType.SUPER_MASK),shiftKey:!!(c&o.ModifierType.SHIFT_MASK),keyCode:d.length===1?d.toUpperCase().charCodeAt(0):0,which:d.length===1?d.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0},p=new KeyboardEvent(`keydown`,f);return l.dispatchEvent(p),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent(`keydown`,f)),n?.captureKeys===!0}),u.connect(`key-released`,(e,n,i,s)=>{let c=t();if(!c)return;r.pressedKeys.delete(n);let l=gdkKeyvalToKey(n),u={key:l,code:gdkKeyvalToCode(n),location:gdkKeyvalToLocation(n),repeat:!1,altKey:!!(s&o.ModifierType.ALT_MASK),ctrlKey:!!(s&o.ModifierType.CONTROL_MASK),metaKey:!!(s&o.ModifierType.SUPER_MASK),shiftKey:!!(s&o.ModifierType.SHIFT_MASK),keyCode:l.length===1?l.toUpperCase().charCodeAt(0):0,which:l.length===1?l.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0};c.dispatchEvent(new KeyboardEvent(`keyup`,u)),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent(`keyup`,u))}),e.add_controller(u);let f=new d.EventControllerFocus;f.connect(`enter`,()=>{let e=t();e&&(e.dispatchEvent(new FocusEvent(`focus`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusin`,{bubbles:!0,cancelable:!1})))}),f.connect(`leave`,()=>{let e=t();e&&(r.pressedKeys.clear(),e.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusout`,{bubbles:!0,cancelable:!1})),getGlobalEventTarget()?.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})))}),e.add_controller(f);let p=new d.EventControllerLegacy;p.connect(`event`,(t,n)=>{let r=n.get_event_type(),s=wo.get(r);if(s===void 0)return r===o.EventType.GRAB_BROKEN&&i.activeCount>0&&n.get_grab_surface()!==e.get_native().get_surface()&&i.cancelAll(modifiersFromState(n.get_modifier_state())),!1;let[,c,l]=n.get_position(),[u,d]=surfaceToWidget(e,c,l),f=n.get_emulating_pointer();return i.handle({...modifiersFromState(n.get_modifier_state()),phase:s,key:sequenceKey(n.get_event_sequence(),f),x:u,y:d,isPrimary:f}),s===`begin`&&e.grab_focus(),!1}),e.add_controller(p),e.connect(`unmap`,()=>i.cancelAll(Eo)),e.connect(`state-flags-changed`,(t,n)=>{let r=d.StateFlags.INSENSITIVE;e.get_state_flags()&r&&!(n&r)&&i.cancelAll(Eo)})}re();const Do=p.registerClass({GTypeName:`GjsifyWebGLBridge`},class WebGLBridge extends d.GLArea{constructor(e){super(e),this._canvas=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._renderTag=null,this._tickCallbackId=null,this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._frameCallbackId=0,this._nextFrameId=1,this._timeOrigin=i.get_monotonic_time(),this._rendererInfo=null,this.set_allowed_apis(o.GLAPI.GL|o.GLAPI.GLES),this.set_required_version(3,2),this.set_has_depth_buffer(!0),this.set_has_stencil_buffer(!0),attachEventControllers(this,()=>this._canvas,{captureKeys:!0}),this._tickCallbackId=this.add_tick_callback((e,t)=>(this._frameCallback!==null&&this.queue_render(),i.SOURCE_CONTINUE));let t=this.connect(`render`,()=>{this.disconnect(t),this.make_current(),this._canvas=new HTMLCanvasElement$1(this);{let e=globalThis;e.document?.body&&e.document.body.appendChild(this._canvas)}this._canvas.getContext(`webgl2`);let e=this._canvas.getContext(`webgl`);if(e){this._reportRenderer(e);for(let t of this._readyCallbacks)t(this._canvas,e);this._readyCallbacks=[]}return this._renderTag=this.connect(`render`,e=>{let t=(i.get_monotonic_time()-this._timeOrigin)/1e3;if(this._frameCallback!==null){globalThis.__GJSIFY_DEBUG_RAF===!0&&M.log(`[rAF] frame callback fires t=${t.toFixed(1)}`);let e=this._frameCallback;this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=e,this._lastFrameTime=t,e(t)}else if(this._lastFrameCallback!==null){this._replaying=!0;try{this._lastFrameCallback(this._lastFrameTime)}finally{this._replaying=!1}}return!0}),!0});this.connect(`resize`,()=>{let e=this.get_allocated_width(),t=this.get_allocated_height();this._canvas&&(this._canvas.dispatchEvent(new Event(`resize`)),notifyElementResize(this._canvas,e,t));for(let n of this._resizeCallbacks)n(e,t);this._frameCallback&&this.requestAnimationFrame(this._frameCallback)}),this.connect(`unrealize`,()=>{this._renderTag!==null&&(this.disconnect(this._renderTag),this._renderTag=null),this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._canvas=null})}get canvas(){return this._canvas}get rendererInfo(){return this._rendererInfo}onReady(e){if(this._canvas){let t=this._canvas.getContext(`webgl`);if(t){e(this._canvas,t);return}}this._readyCallbacks.push(e)}onWebGLReady(e){this.onReady(e)}_reportRenderer(e){let t=e.getExtension(`WEBGL_debug_renderer_info`),n=String(e.getParameter(t.UNMASKED_VENDOR_WEBGL)??``),r=String(e.getParameter(t.UNMASKED_RENDERER_WEBGL)??``);this._rendererInfo={vendor:n,renderer:r},isSoftwareRenderer(r)&&M.warn(`[@gjsify/webgl] GL is rasterised on the CPU by "${r}" (${n}) — this host exposes no usable GPU. Every draw call still works; fill-heavy or continuously animating content will be orders of magnitude slower than on hardware, which can look like a frozen window rather than a slow one. Read it yourself via WebGLBridge.rendererInfo or the WEBGL_debug_renderer_info extension.`)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(e){let t=this._nextFrameId++;return this._replaying?t:(this._frameCallback=e,this._frameCallbackId=t,this.queue_render(),t)}cancelAnimationFrame(e){e!==0&&e===this._frameCallbackId&&(this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=null,this._lastFrameTime=0)}installGlobals(){let e=globalThis;e.requestAnimationFrame=e=>this.requestAnimationFrame(e),e.cancelAnimationFrame=e=>this.cancelAnimationFrame(e),e.WebGLRenderingContext=WebGLRenderingContext$1,e.WebGL2RenderingContext=Xr,Object.defineProperty(globalThis,"devicePixelRatio",{get:()=>this.get_scale_factor()||1,configurable:!0});let t=this._timeOrigin;e.performance={now:()=>(i.get_monotonic_time()-t)/1e3,timeOrigin:Date.now()}}});re()
100
+ </node>`}re();function isWin32(){return i.DIR_SEPARATOR===92}function defaultListenAddress(){return isWin32()?`nonce-tcp:host=127.0.0.1`:`unix:tmpdir=${i.get_tmp_dir()}`}var DevtoolsPeerServerError=class extends Error{constructor(e,t,n,r){super(e),this.address=t,this.reason=n,this.name=`DevtoolsPeerServerError`,this.cause=r}};function isAddressInUse(e){return e instanceof i.Error&&e.matches(r.io_error_quark(),r.IOErrorEnum.ADDRESS_IN_USE)}function unixSocketPath(e){if(!e.startsWith(`unix:`))return null;for(let t of e.slice(5).split(`,`)){let e=t.indexOf(`=`);if(!(e<0||t.slice(0,e)!==`path`))try{return decodeURIComponent(t.slice(e+1))}catch{return null}}return null}function inspectExistingSocket(e){try{if((r.File.new_for_path(e).query_info(`unix::mode`,r.FileQueryInfoFlags.NONE,null).get_attribute_uint32(`unix::mode`)&61440)!=49152)return`not-a-socket`}catch{return`not-a-socket`}let t=new r.SocketClient;t.set_timeout(2);let n;try{n=t.connect(r.UnixSocketAddress.new(e),null)}catch{return`dead`}return n.close(null),`live`}function clearReclaimableSocket(e){let t=unixSocketPath(e);if(!t||!i.file_test(t,i.FileTest.EXISTS))return;let n=inspectExistingSocket(t);if(n===`live`)throw new DevtoolsPeerServerError(`cannot listen on ${e}: another process is already listening there. Stop it, or point ${_o} (or options.address) at a different socket — GJSIFY_DEVTOOLS_INSTANCE=<label> lets two devtools-enabled apps run side by side.`,e,`address-in-use`);if(n===`not-a-socket`)throw new DevtoolsPeerServerError(`cannot listen on ${e}: ${t} already exists and is not a socket, so it will NOT be removed. Point ${_o} (or options.address) at a free path.`,e,`occupied-by-other-file`);try{r.File.new_for_path(t).delete(null)}catch(n){throw new DevtoolsPeerServerError(`cannot listen on ${e}: ${t} is a socket nothing listens on, but removing it failed (${n}). Delete it by hand, or point ${_o} at a free path.`,e,`address-in-use`,n)}M.log(`[gjsify-devtools] reclaimed the stale socket ${t}: nothing was listening on it (an abnormal exit — Ctrl-C, SIGKILL, a crash — leaves the inode behind).`)}function flagsForAddress(e){return e.startsWith(`tcp:`)||e.startsWith(`nonce-tcp:`)?r.DBusServerFlags.NONE:r.DBusServerFlags.AUTHENTICATION_REQUIRE_SAME_USER}function startDevtoolsPeerServer(e,t,n){let i=n&&n!==``?n:defaultListenAddress();clearReclaimableSocket(i);let o;try{o=r.DBusServer.new_sync(i,flagsForAddress(i),r.dbus_generate_guid(),null,null)}catch(e){let t=isAddressInUse(e);throw new DevtoolsPeerServerError(t?`cannot listen on ${i}: the address is already in use (${e}). Stop whatever holds it, or point ${_o} (or options.address) at a different address.`:`cannot listen on ${i}: ${e}. Check the address form — \`unix:path=/tmp/app.sock\`, \`unix:tmpdir=/tmp\` or \`nonce-tcp:host=127.0.0.1\`.`,i,t?`address-in-use`:`listen-failed`,e)}let s=new Set;o.connect(`new-connection`,(n,r)=>(s.add(r),r.connect(`closed`,()=>{e.unexport(r),s.delete(r)}),e.export(r,t),!0)),o.start();let c=!1;return{address:o.get_client_address(),objectPath:t,get connectionCount(){return s.size},stop(){if(!c){c=!0,o.stop();for(let t of s)e.unexport(t),!t.is_closed()&&t.close(null,(e,t)=>{try{e.close_finish(t)}catch{}});s.clear()}}}}function writeDevtoolsAddressFile(e,t){try{if(i.mkdir_with_parents(i.path_get_dirname(e),448),!i.file_set_contents(e,`${t}\n`))return null}catch(t){return M.error(`[gjsify-devtools] could not publish the peer address to ${e}: ${t}`),null}try{r.File.new_for_path(e).set_attribute_uint32(`unix::mode`,384,r.FileQueryInfoFlags.NONE,null)}catch(t){M.error(`[gjsify-devtools] could not restrict ${e} to the current user: ${t}`)}return e}function removeDevtoolsAddressFile(e){try{r.File.new_for_path(e).delete(null)}catch{}}function captureWidget(e){let t=e.get_native()?.get_renderer();if(!t)return{png:null,blocker:`no-renderer`};let n=e.get_width(),r=e.get_height();if(n<=0||r<=0)return{png:null,blocker:`zero-size`};let i=d.WidgetPaintable.new(e),o=d.Snapshot.new();i.snapshot(o,n,r);let s=o.to_node();if(!s)return{png:null,blocker:`empty-snapshot`};let c=new f.Rect;c.init(0,0,n,r);let l=t.render_texture(s,c).save_to_png_bytes().get_data();return l?{png:new Uint8Array(l)}:{png:null,blocker:`empty-png`}}function dumpGSettings(e){let t=r.SettingsSchemaSource.get_default()?.lookup(e,!0);if(!t)throw Error(formatDbusErrorMessage(`not-found`,`GSettings schema '${e}' is not installed`));let n=new r.Settings({settings_schema:t}),i={};for(let e of t.list_keys())i[e]=n.get_value(e).recursiveUnpack();return i}function parseWidgetPath(e){let t=e.split(`/`).filter(e=>e.length>0);if(t.length===0)return null;let n=t[0].match(/^toplevel:(\d+)$/);if(!n)return null;let r=[];for(let e of t.slice(1)){let t=e.match(/^child:(\d+)$/);if(!t)return null;r.push(Number(t[1]))}return{toplevel:Number(n[1]),children:r}}function buildWidgetPath(e,t){return[`toplevel:${e}`,...t.map(e=>`child:${e}`)].join(`/`)}function widgetType(e){return gtypeName(e)??`GtkWidget`}function gtypeName(e){let t=e;return typeof t?.$typeName==`string`&&t.$typeName.length>0?t.$typeName:t?.constructor?.$gtype?.name??null}function widgetIsA(e,t){let n=gtypeName(e);if(n===null||!t)return!1;if(n===t)return!0;let r=p.type_from_name(n),i=p.type_from_name(t);return!r||!i?!1:p.type_is_a(r,i)}function activateWidget(e){let t=e;if(typeof t.activate==`function`&&t.activate()===!0)return!0;let n=typeof t.get_parent==`function`?t.get_parent():null;if(n&&widgetIsA(n,`GtkListBox`)){let t=n,r=!1;return typeof t.select_row==`function`&&(t.select_row(e),r=!0),typeof t.emit==`function`&&(t.emit(`row-activated`,e),r=!0),r}return!1}function sendKeyToWidget(e,t,n){let r=e.observe_controllers(),i=!1;for(let e=0;e<r.get_n_items();e++){let o=r.get_item(e);widgetIsA(o,`GtkEventControllerKey`)&&(o.emit(`key-pressed`,t,0,n),i=!0)}return i}function nthChild(e,t){let n=e.get_first_child(),r=0;for(;n&&r<t;)n=n.get_next_sibling(),r++;return r===t?n:null}function listToplevels(){let e=d.Window.get_toplevels(),t=e.get_n_items(),n=[];for(let r=0;r<t;r++){let t=e.get_item(r);t&&n.push({path:`toplevel:${r}`,type:widgetType(t),title:t.get_title?.()??null,mapped:t.get_mapped(),focused:t.is_active??!1})}return n}function resolveWidgetPath(e){let t=parseWidgetPath(e);if(!t)return null;let n=d.Window.get_toplevels().get_item(t.toplevel);if(!n)return null;for(let e of t.children)if(n=nthChild(n,e),!n)return null;return n}function parseWidgetSelector(e){let t=e.indexOf(`:`),n=(t<0?e:e.slice(0,t)).trim(),r=(t<0?``:e.slice(t+1)).trim();return!n&&!r?null:{type:n,cssClass:r}}function findWidgetPath(e,t,n){let r={path:null};return walkForSelector(e,t,n,r)??r.path}function walkForSelector(e,t,n,r){if(!e.get_visible()||!e.get_mapped())return null;if(!t.cssClass||e.get_css_classes().includes(t.cssClass)){if(!t.type||widgetType(e)===t.type)return n;r.path===null&&widgetIsA(e,t.type)&&(r.path=n)}let i=e.get_first_child(),o=0;for(;i;){let e=walkForSelector(i,t,`${n}/child:${o}`,r);if(e)return e;i=i.get_next_sibling(),o++}return null}function geometryOf(e){if(!e.get_mapped())return;let t=e.get_allocation(),n=t.width+e.get_margin_start()+e.get_margin_end(),r=t.height+e.get_margin_top()+e.get_margin_bottom(),[i,o]=e.measure(d.Orientation.HORIZONTAL,-1),s=n>0?Math.max(n,i):-1,[c,l]=e.measure(d.Orientation.VERTICAL,s),u={width:n,height:r,widthRequest:[i,o],heightRequest:[c,l]};return(n<i||r<c)&&(u.short=!0),u}function dumpTree(e,t,n){let r={path:n,type:widgetType(e),name:e.get_name()||null,cssClasses:e.get_css_classes(),mapped:e.get_mapped(),visible:e.get_visible(),children:[]},i=geometryOf(e);if(i!==void 0&&(r.geometry=i),t<=0)return e.get_first_child()&&(r.truncated=!0),r;let o=e.get_first_child(),s=0;for(;o;)r.children.push(dumpTree(o,t-1,`${n}/child:${s}`)),o=o.get_next_sibling(),s++;return r}function jsonSafe(e){let t=typeof e;return e==null||t===`string`||t===`number`||t===`boolean`?e??null:`[${t}]`}function getWidgetProperty(e,t){let n=e,r=t.replace(/-/g,`_`),i=t.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase());for(let e of[t,r,i])if(e in n)return jsonSafe(n[e])}function childIndex(e,t){let n=e.get_first_child(),r=0;for(;n;){if(n===t)return r;n=n.get_next_sibling(),r++}return-1}function pathOfWidget(e){let t=[],n=e,r=n.get_parent();for(;r;){let e=childIndex(r,n);if(e<0)return null;t.unshift(e),n=r,r=n.get_parent()}let i=d.Window.get_toplevels(),o=i.get_n_items();for(let e=0;e<o;e++)if(i.get_item(e)===n)return buildWidgetPath(e,t);return null}re();function isActiveWindowScope(e){return!e||e===`window`||e===`active`}function frameDelay(e){return new Promise(t=>{i.timeout_add(i.PRIORITY_DEFAULT,e,()=>(t(),i.SOURCE_REMOVE))})}async function captureWidgetWhenRenderable(e,t=12,n=50){let r=null;for(let i=0;i<t;i++){let t=captureWidget(e);if(t.png)return{png:t.png,blocker:null};r=t.blocker,await frameDelay(n)}let i=captureWidget(e);return{png:i.png,blocker:i.png?null:i.blocker??r}}var DevtoolsService=class{constructor(e,t){this._app=e,this._options=t,this._exported=new Map,this._peer=null,this._addressFile=null,this._kinds=new Map,this._extensions=t.extend??[];for(let[e,t]of Object.entries(go))this._kinds.set(e,t);for(let e of this._extensions){for(let[t,n]of Object.entries(e.methodKinds))this._kinds.set(t,n);for(let[t,n]of Object.entries(e.handlers)){let e=n;this[t]=(...n)=>(this._guard(t),e(...n))}}}export(e,t){if(this._exported.has(e))return;let n=buildDevtoolsIfaceXml(this._extensions.flatMap(e=>e.methodsXml??[])),i=r.DBusExportedObject.wrapJSObject(n,this);i.export(e,t),this._exported.set(e,i)}unexport(e){if(e){this._exported.get(e)?.unexport(),this._exported.delete(e);return}for(let e of this._exported.values())e.unexport();this._exported.clear(),this._peer?.stop(),this._peer=null,this._addressFile&&=(removeDevtoolsAddressFile(this._addressFile),null)}attachPeerServer(e,t){this._peer=e,this._addressFile=t??null}get peerAddress(){return this._peer?.address??null}get addressFile(){return this._addressFile}GetStatus(){let e=this._app.get_active_window(),t={appId:this._app.get_application_id()??`unknown`,instance:this._options.instance??`default`,activeWindow:e?{id:e.get_name()||`window`,title:e.get_title()??``,mapped:e.get_mapped()}:null,toplevelCount:d.Window.get_toplevels().get_n_items(),focusedWidget:null,paused:this._isPaused()};for(let e of this._extensions){let n=e.contributeStatus?.();n&&Object.assign(t,n)}return JSON.stringify(t)}async ScreenshotAsync(e,t){try{let n=typeof e?.[0]==`string`?e[0]:``,r=await this._captureScopePng(n);t.return_value(new i.Variant(`(ay)`,[r]))}catch(e){t.return_dbus_error(`org.gjsify.Devtools.Error.Screenshot`,e instanceof Error?e.message:String(e))}}async _captureScopePng(e){let t=this._resolveRootWidget(e);if(!t){if(isActiveWindowScope(e))return new Uint8Array;throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e}'`))}let n=captureWidget(t.widget);if(n.png)return n.png;let r=t.widget.get_root();r instanceof d.Window&&r.present();let i=await captureWidgetWhenRenderable(t.widget);return i.png?i.png:(M.warn(`[devtools] Screenshot('${e}') has no image: ${i.blocker??`unknown`} after 12 tries. Empty bytes follow.`),new Uint8Array)}ListActions(){let e={app:describeActions(this._actionGroup(`app`)),win:describeActions(this._actionGroup(`win`))};return JSON.stringify(e)}ActivateAction(e,t,n){this._guard(`ActivateAction`);let r=this._scope(e);activateAction(this._requireGroup(r,t),t,this._parseValue(n))}ChangeActionState(e,t,n){this._guard(`ChangeActionState`);let r=this._scope(e);changeActionState(this._requireGroup(r,t),t,this._parseValue(n))}PresentWindow(){this._app.get_active_window()?.present()}ResizeWindow(e,t){this._guard(`ResizeWindow`);let n=this._app.get_active_window();if(!n)throw Error(formatDbusErrorMessage(`unavailable`,`no active window to resize`));let r=Math.max(1,Math.round(e)),i=Math.max(1,Math.round(t));return n.is_maximized()&&n.unmaximize(),n.is_fullscreen()&&n.unfullscreen(),n.set_default_size(r,i),[r,i]}ListToplevels(){return JSON.stringify(listToplevels())}DumpTree(e,t){let n=this._resolveRootWidget(e);if(!n)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e||`active window`}'`));return JSON.stringify(dumpTree(n.widget,t>0?t:40,n.path))}GetProperty(e,t){let n=this._resolveRootWidget(e);if(!n)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e}'`));let r=getWidgetProperty(n.widget,t);if(r===void 0)throw Error(formatDbusErrorMessage(`not-found`,`widget has no property '${t}'`));return JSON.stringify(r)}GetFocused(){let e=this._app.get_active_window(),t=e?e.get_focus():null;return JSON.stringify(t?{path:pathOfWidget(t),name:t.get_name()||null,type:widgetType(t)}:null)}ActivateWidget(e){this._guard(`ActivateWidget`);let t=this._resolveRootWidget(e);if(!t)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${e}'`));return activateWidget(t.widget)}FindWidget(e){let t=parseWidgetSelector(e);if(!t)throw Error(formatDbusErrorMessage(`invalid-params`,`empty selector '${e}'`));let n=this._resolveRootWidget(``);return n?findWidgetPath(n.widget,t,n.path)??``:``}SendKey(e,t){this._guard(`SendKey`);let[n,r,i]=d.accelerator_parse(e);if(!n)throw Error(formatDbusErrorMessage(`invalid-params`,`cannot parse accelerator '${e}'`));let o;if(o=t?this._resolveRootWidget(t)?.widget??null:this._app.get_active_window()?.get_focus()??null,!o)throw Error(formatDbusErrorMessage(`not-found`,`no widget at '${t||`focus`}'`));return sendKeyToWidget(o,r,i??0)}DumpGSettings(e){return JSON.stringify(dumpGSettings(e))}DumpCss(){return JSON.stringify(dumpCss())}SwapCss(e,t){return this._guard(`SwapCss`),swapCss(e,t)}_resolveRootWidget(e){if(isActiveWindowScope(e)){let e=this._app.get_active_window();return e?{widget:e,path:pathOfWidget(e)??`toplevel:0`}:null}let t=resolveWidgetPath(e);return t?{widget:t,path:e}:null}_isPaused(){return this._options.paused?.()??!1}_guard(e){let t=this._kinds.get(e);if(!t)throw Error(formatDbusErrorMessage(`internal`,`unclassified devtools method '${e}'`));if(t===`mutating`&&this._isPaused())throw Error(formatDbusErrorMessage(`paused`,`${e} rejected — external control is paused. Read-only methods keep working.`))}_scope(e){return e===`app`?`app`:`win`}_actionGroup(e){if(e===`app`)return this._app;if(this._options.winActionGroup)return this._options.winActionGroup;let t=this._app.get_active_window();return t instanceof d.ApplicationWindow?t:null}_requireGroup(e,t){let n=this._actionGroup(e);if(!n)throw Error(formatDbusErrorMessage(`unavailable`,`no '${e}' action group`));if(!n.has_action(t))throw Error(formatDbusErrorMessage(`not-found`,`unknown action ${e}.${t}`));return n}_parseValue(e){if(!e||e===`null`)return null;try{return JSON.parse(e)}catch{throw Error(formatDbusErrorMessage(`invalid-params`,`value_json is not valid JSON: ${e}`))}}};re();const vo=`DBUS_SESSION_BUS_ADDRESS`,yo=new Set;function envEnabled(){return isDevtoolsEnabledValue(i.getenv(`GJSIFY_DEVTOOLS`))}function envValue(e){let t=i.getenv(e);return t&&t!==``?t:null}function sessionBusUsable(){if(!envValue(vo))return!1;try{return r.bus_get_sync(r.BusType.SESSION,null),!0}catch{return!1}}function chooseDevtoolsTransport(e){return e.requestedAddress?{kind:`peer`,address:e.requestedAddress,reason:`requested`}:e.hasAppConnection?{kind:`session-bus`}:e.sessionBusUsable?{kind:`unregistered`}:{kind:`peer`,address:null,reason:`no-session-bus`}}function describeMissingConnection(e,t){return e?t?`[gjsify-devtools] the session bus answers but this application is not registered on it yet — call installDevtools() from the GtkApplication "startup" handler (the bus connection and object path exist only after registration).`:`[gjsify-devtools] ${vo} is set (${e}) but no bus answers there — using the bus-less peer transport instead. On macOS this is the usual state: Homebrew's dbus listens on launchd, so the advertised address only works while that socket is live.`:`[gjsify-devtools] this machine has no session bus (${vo} is unset) — using the bus-less peer transport instead. Point the bridge at the address below, or set ${_o} on both the app and \`gjsify debug\` to pin it yourself.`}function installDevtools(e,t={}){if(!(t.enabled??envEnabled()))return null;let n=t.instance??envValue(`GJSIFY_DEVTOOLS_INSTANCE`)??void 0,r=new DevtoolsService(e,{...t,instance:n});try{return exportDevtools(e,r,t,n)}catch(e){return r.unexport(),M.error(`[gjsify-devtools] devtools stayed OFF, the app is unaffected — ${describeInstallFailure(e)}`),null}}function describeInstallFailure(e){return e instanceof DevtoolsPeerServerError||e instanceof Error?e.message:String(e)}function exportDevtools(e,t,n,r){let o=e.get_is_registered(),s=o?e.get_dbus_connection():null,c=o?e.get_dbus_object_path():null,l=envValue(vo),u=!!(s&&c),d=u||sessionBusUsable(),f=chooseDevtoolsTransport({requestedAddress:n.address??envValue(_o),hasAppConnection:u,sessionBusUsable:d}),p=e.get_application_id()??`unknown`,m=`${c??appIdToObjectPath(p)}/devtools`;if((f.kind===`unregistered`||f.kind===`peer`&&f.reason===`no-session-bus`)&&M.error(describeMissingConnection(l,d)),f.kind===`session-bus`&&s)t.export(s,m),M.log(`[gjsify-devtools] exported ${ho} at ${m} (dest ${p})`);else if(f.kind===`peer`){let n=startDevtoolsPeerServer(t,m,f.address??void 0),o=writeDevtoolsAddressFile(devtoolsAddressFilePath(i.get_user_runtime_dir(),p,r),n.address);t.attachPeerServer(n,o),M.log(`[gjsify-devtools] exported ${ho} at ${m} (peer address ${n.address}${o?`, published to ${o}`:``})`),o&&e.connect(`shutdown`,()=>removeDevtoolsAddressFile(o))}return yo.add(t),t}function notifyElementResize(e,t,n){e._allocatedClientWidth=t,e._allocatedClientHeight=n,e._fireResizeSubscribers(t,n);let r=e.parentNode;for(;r;)r instanceof Element&&(r._allocatedClientWidth=t,r._allocatedClientHeight=n,r._fireResizeSubscribers(t,n)),r=r.parentNode}var HTMLCanvasElement$1=class extends Rt{static{__name$1(this,`HTMLCanvasElement`)}constructor(e){super(),this.gtkGlArea=e}get width(){return this.gtkGlArea.get_allocated_width()*this.scaleFactor}set width(e){}get height(){return this.gtkGlArea.get_allocated_height()*this.scaleFactor}set height(e){}get scaleFactor(){return this.gtkGlArea.get_scale_factor()||1}get clientWidth(){return this.gtkGlArea.get_allocated_width()}get clientHeight(){return this.gtkGlArea.get_allocated_height()}get offsetWidth(){return this.clientWidth}get offsetHeight(){return this.clientHeight}getGlArea(){return this.gtkGlArea}_createCloneTarget(){let e=new Rt;return e.width=this.width,e.height=this.height,e}getContext(e,t){return e===`webgl`||e===`experimental-webgl`?(this._webgl||=(this.gtkGlArea.make_current(),new WebGLRenderingContext$1(this,t)),this._webgl):e===`webgl2`?(this._webgl2||=(this.gtkGlArea.make_current(),new Xr(this,t)),this._webgl2):super.getContext(e,t)}};const bo=[`apple software renderer`,`llvmpipe`,`softpipe`,`swrast`,`swiftshader`,`microsoft basic render driver`,`mesa offscreen`];function isSoftwareRenderer(e){if(!e)return!1;let t=e.toLowerCase();return bo.some(e=>t.includes(e))}const xo={Return:`Enter`,KP_Enter:`Enter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`Delete`,Insert:`Insert`,KP_Insert:`Insert`,Home:`Home`,KP_Home:`Home`,End:`End`,KP_End:`End`,Page_Up:`PageUp`,KP_Page_Up:`PageUp`,Page_Down:`PageDown`,KP_Page_Down:`PageDown`,Left:`ArrowLeft`,KP_Left:`ArrowLeft`,Up:`ArrowUp`,KP_Up:`ArrowUp`,Right:`ArrowRight`,KP_Right:`ArrowRight`,Down:`ArrowDown`,KP_Down:`ArrowDown`,Shift_L:`Shift`,Shift_R:`Shift`,Control_L:`Control`,Control_R:`Control`,Alt_L:`Alt`,Alt_R:`Alt`,Super_L:`Meta`,Super_R:`Meta`,Meta_L:`Meta`,Meta_R:`Meta`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:` `,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`+`,KP_Subtract:`-`,KP_Multiply:`*`,KP_Divide:`/`,KP_Decimal:`.`,KP_Separator:`,`,KP_0:`0`,KP_1:`1`,KP_2:`2`,KP_3:`3`,KP_4:`4`,KP_5:`5`,KP_6:`6`,KP_7:`7`,KP_8:`8`,KP_9:`9`},So={Return:`Enter`,KP_Enter:`NumpadEnter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`NumpadDecimal`,Insert:`Insert`,KP_Insert:`Numpad0`,Home:`Home`,KP_Home:`Numpad7`,End:`End`,KP_End:`Numpad1`,Page_Up:`PageUp`,KP_Page_Up:`Numpad9`,Page_Down:`PageDown`,KP_Page_Down:`Numpad3`,Left:`ArrowLeft`,KP_Left:`Numpad4`,Up:`ArrowUp`,KP_Up:`Numpad8`,Right:`ArrowRight`,KP_Right:`Numpad6`,Down:`ArrowDown`,KP_Down:`Numpad2`,Shift_L:`ShiftLeft`,Shift_R:`ShiftRight`,Control_L:`ControlLeft`,Control_R:`ControlRight`,Alt_L:`AltLeft`,Alt_R:`AltRight`,Super_L:`MetaLeft`,Super_R:`MetaRight`,Meta_L:`MetaLeft`,Meta_R:`MetaRight`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:`Space`,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`NumpadAdd`,KP_Subtract:`NumpadSubtract`,KP_Multiply:`NumpadMultiply`,KP_Divide:`NumpadDivide`,KP_Decimal:`NumpadDecimal`,KP_Separator:`NumpadComma`,KP_0:`Numpad0`,KP_1:`Numpad1`,KP_2:`Numpad2`,KP_3:`Numpad3`,KP_4:`Numpad4`,KP_5:`Numpad5`,KP_6:`Numpad6`,KP_7:`Numpad7`,KP_8:`Numpad8`,KP_9:`Numpad9`};function gdkKeyvalToKey(e){let t=o.keyval_name(e);if(t&&xo[t])return xo[t];let n=o.keyval_to_unicode(e);return n>0?String.fromCodePoint(n):t??`Unidentified`}function gdkKeyvalToCode(e){let t=o.keyval_name(e);if(t&&So[t])return So[t];let n=o.keyval_to_unicode(e);if(n>=97&&n<=122)return`Key`+String.fromCodePoint(n-32);if(n>=65&&n<=90)return`Key`+String.fromCodePoint(n);if(n>=48&&n<=57)return`Digit`+String.fromCodePoint(n);if(t){let e={minus:`Minus`,equal:`Equal`,bracketleft:`BracketLeft`,bracketright:`BracketRight`,backslash:`Backslash`,semicolon:`Semicolon`,apostrophe:`Quote`,grave:`Backquote`,comma:`Comma`,period:`Period`,slash:`Slash`};if(e[t])return e[t]}return t??`Unidentified`}function gdkKeyvalToLocation(e){let t=o.keyval_name(e);return t?t.startsWith(`KP_`)?3:t.endsWith(`_L`)?1:t.endsWith(`_R`)?2:0:0}const Co=.5;var TouchPointerTranslator=class{constructor(e,t){this.getElement=e,this.getWindowTarget=t,this.active=new Map,this.nextId=2}get activeCount(){return this.active.size}handle(e){switch(e.phase){case`begin`:this.begin(e);break;case`update`:this.update(e);break;case`end`:this.end(e);break;case`cancel`:this.cancel(e);break}}cancelAll(e){for(let[t,n]of this.active)this.cancel({...e,phase:`cancel`,key:t,x:n.lastX,y:n.lastY,isPrimary:n.isPrimary})}begin(e){this.active.has(e.key)&&this.cancel(e);let t=this.getElement();if(!t)return;let n={id:this.nextId++,isPrimary:e.isPrimary,lastX:e.x,lastY:e.y,preventMouse:!1};this.active.set(e.key,n);let r=this.pointerInit(e,n,-1,0,0),i=this.mouseInit(e,0,0);n.isPrimary&&t.dispatchEvent(new MouseEvent(`mousemove`,i)),t.dispatchEvent(new PointerEvent(`pointerover`,r)),t.dispatchEvent(new PointerEvent(`pointerenter`,{...r,bubbles:!1,cancelable:!1})),n.isPrimary&&(t.dispatchEvent(new MouseEvent(`mouseover`,i)),t.dispatchEvent(new MouseEvent(`mouseenter`,{...i,bubbles:!1,cancelable:!1})));let o=new PointerEvent(`pointerdown`,this.pointerInit(e,n,0,1,Co));t.dispatchEvent(o),n.isPrimary&&(n.preventMouse=o.defaultPrevented,n.preventMouse||t.dispatchEvent(new MouseEvent(`mousedown`,{...this.mouseInit(e,0,1),detail:1})))}update(e){let t=this.active.get(e.key);if(!t)return;let n=this.getElement();if(!n)return;let r=e.x-t.lastX,i=e.y-t.lastY;t.lastX=e.x,t.lastY=e.y,n.dispatchEvent(new PointerEvent(`pointermove`,{...this.pointerInit(e,t,-1,1,Co),movementX:r,movementY:i})),t.isPrimary&&!t.preventMouse&&n.dispatchEvent(new MouseEvent(`mousemove`,{...this.mouseInit(e,0,1),movementX:r,movementY:i}))}end(e){let t=this.active.get(e.key);if(!t)return;this.active.delete(e.key);let n=this.getElement();if(!n)return;let r=this.pointerInit(e,t,0,0,0),i=this.mouseInit(e,0,0),o=t.isPrimary&&!t.preventMouse;n.dispatchEvent(new PointerEvent(`pointerup`,r)),o&&n.dispatchEvent(new MouseEvent(`mouseup`,{...i,detail:1})),this.leave(n,t,{...r,button:-1},i),t.isPrimary&&n.dispatchEvent(new PointerEvent(`click`,{...r,detail:1}))}cancel(e){let t=this.active.get(e.key);if(!t)return;this.active.delete(e.key);let n=this.getElement();if(!n)return;let r={...e,x:t.lastX,y:t.lastY},i=this.pointerInit(r,t,-1,0,0),o=this.mouseInit(r,0,0);n.dispatchEvent(new PointerEvent(`pointercancel`,{...i,cancelable:!1})),t.isPrimary&&!t.preventMouse&&this.getWindowTarget()?.dispatchEvent(new MouseEvent(`mouseup`,{...o,detail:1})),this.leave(n,t,i,o)}leave(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointerout`,n)),e.dispatchEvent(new PointerEvent(`pointerleave`,{...n,bubbles:!1,cancelable:!1})),t.isPrimary&&(e.dispatchEvent(new MouseEvent(`mouseout`,r)),e.dispatchEvent(new MouseEvent(`mouseleave`,{...r,bubbles:!1,cancelable:!1})))}mouseInit(e,t,n){return{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,clientX:e.x,clientY:e.y,offsetX:e.x,offsetY:e.y,screenX:e.x,screenY:e.y,button:t,buttons:n,bubbles:!0,cancelable:!0}}pointerInit(e,t,n,r,i){return{...this.mouseInit(e,n,r),pointerId:t.id,pointerType:`touch`,isPrimary:t.isPrimary,pressure:i}}};re();const wo=new Map([[o.EventType.TOUCH_BEGIN,`begin`],[o.EventType.TOUCH_UPDATE,`update`],[o.EventType.TOUCH_END,`end`],[o.EventType.TOUCH_CANCEL,`cancel`]]);function isTouchEvent(e){return e!==null&&wo.has(e.get_event_type())}function pointerTypeOf(e){let t=e?.get_device()?.get_source();return t===o.InputSource.TOUCHSCREEN?`touch`:t===o.InputSource.PEN?`pen`:`mouse`}let To=!1;function sequenceKey(e,t){if(e===null)return t?`primary`:`secondary`;let n=String(e),r=n.lastIndexOf(`native@`);return r!==-1&&n.endsWith(`]`)?n.slice(r+7,-1):(To||(To=!0,M.warn(`@gjsify/event-bridge: GdkEventSequence identity is not readable on this runtime; touch pointers are keyed by the emulating-pointer flag, so a third concurrent contact merges with the second.`)),t?`primary`:`secondary`)}function surfaceToWidget(e,t,n){let r=e.get_native(),[i,o]=r.get_surface_transform(),s=t-i,c=n-o,[l,u]=r.compute_point(e,new f.Point({x:s,y:c}));return l?[u.x,u.y]:[s,c]}function getGlobalEventTarget(){return globalThis.__gjsify_globalEventTarget}const Eo={shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1};function modifiersFromState(e){return{shiftKey:!!(e&o.ModifierType.SHIFT_MASK),ctrlKey:!!(e&o.ModifierType.CONTROL_MASK),altKey:!!(e&o.ModifierType.ALT_MASK),metaKey:!!(e&o.ModifierType.SUPER_MASK)}}function extractModifiers(e){return modifiersFromState(e.get_current_event_state())}function gtkButtonToDom(e){return e===1?0:e===2?1:e===3?2:e-1}function buttonsFromModifiers(e){let t=e.get_current_event_state(),n=0;return t&o.ModifierType.BUTTON1_MASK&&(n|=1),t&o.ModifierType.BUTTON3_MASK&&(n|=2),t&o.ModifierType.BUTTON2_MASK&&(n|=4),n}function attachEventControllers(e,t,n){e.set_focusable(!0),e.set_can_focus(!0);let r={lastX:0,lastY:0,buttonsPressed:0,pressedKeys:new Set},i=new TouchPointerTranslator(t,()=>getGlobalEventTarget()),s=new d.EventControllerMotion;s.connect(`motion`,(n,i,o)=>{let c=t();if(!c)return;let l=e.get_allocated_width(),u=e.get_allocated_height(),d=Math.max(0,Math.min(i,l)),f=Math.max(0,Math.min(o,u)),p=d-r.lastX,m=f-r.lastY,h=extractModifiers(s),g=buttonsFromModifiers(s),_={...h,clientX:d,clientY:f,offsetX:d,offsetY:f,screenX:d,screenY:f,movementX:p,movementY:m,buttons:g,button:0,bubbles:!0,cancelable:!0};c.dispatchEvent(new PointerEvent(`pointermove`,{..._,pointerId:1,pointerType:pointerTypeOf(s.get_current_event()),isPrimary:!0})),c.dispatchEvent(new MouseEvent(`mousemove`,_)),r.lastX=d,r.lastY=f}),s.connect(`enter`,(e,n,i)=>{let o=t();if(!o)return;r.lastX=n,r.lastY=i;let c={...extractModifiers(s),clientX:n,clientY:i,offsetX:n,offsetY:i,screenX:n,screenY:i,bubbles:!1,cancelable:!1};o.dispatchEvent(new PointerEvent(`pointerenter`,{...c,pointerId:1,pointerType:pointerTypeOf(s.get_current_event()),isPrimary:!0})),o.dispatchEvent(new MouseEvent(`mouseenter`,c)),o.dispatchEvent(new MouseEvent(`mouseover`,{...c,bubbles:!0}))}),s.connect(`leave`,()=>{let e=t();if(!e)return;let n={...extractModifiers(s),clientX:r.lastX,clientY:r.lastY,bubbles:!1,cancelable:!1};e.dispatchEvent(new PointerEvent(`pointerleave`,{...n,pointerId:1,pointerType:pointerTypeOf(s.get_current_event()),isPrimary:!0})),e.dispatchEvent(new MouseEvent(`mouseleave`,n)),e.dispatchEvent(new MouseEvent(`mouseout`,{...n,bubbles:!0}))}),e.add_controller(s);let c=new d.GestureClick;c.set_button(0),c.connect(`pressed`,(n,i,o,s)=>{if(isTouchEvent(c.get_current_event()))return;let l=t();if(!l)return;let u=gtkButtonToDom(c.get_current_button()),d=extractModifiers(c);r.buttonsPressed|=1<<u;let f={...d,clientX:o,clientY:s,offsetX:o,offsetY:s,screenX:o,screenY:s,button:u,buttons:r.buttonsPressed,detail:i,bubbles:!0,cancelable:!0};l.dispatchEvent(new PointerEvent(`pointerdown`,{...f,pointerId:1,pointerType:pointerTypeOf(c.get_current_event()),isPrimary:!0})),l.dispatchEvent(new MouseEvent(`mousedown`,f)),e.grab_focus()}),c.connect(`released`,(e,n,i,o)=>{if(isTouchEvent(c.get_current_event()))return;let s=t();if(!s)return;let l=gtkButtonToDom(c.get_current_button()),u=extractModifiers(c);r.buttonsPressed&=~(1<<l);let d={...u,clientX:i,clientY:o,offsetX:i,offsetY:o,screenX:i,screenY:o,button:l,buttons:r.buttonsPressed,detail:n,bubbles:!0,cancelable:!0};s.dispatchEvent(new PointerEvent(`pointerup`,{...d,pointerId:1,pointerType:pointerTypeOf(c.get_current_event()),isPrimary:!0})),s.dispatchEvent(new MouseEvent(`mouseup`,d)),l===0&&(s.dispatchEvent(new MouseEvent(`click`,d)),n===2&&s.dispatchEvent(new MouseEvent(`dblclick`,d))),l===2&&s.dispatchEvent(new MouseEvent(`contextmenu`,{...d,cancelable:!0}))}),c.connect(`cancel`,(e,n)=>{let i=c.get_last_event(n);if(isTouchEvent(i)||r.buttonsPressed===0)return;r.buttonsPressed=0;let o=t();o&&o.dispatchEvent(new PointerEvent(`pointercancel`,{...extractModifiers(c),clientX:r.lastX,clientY:r.lastY,offsetX:r.lastX,offsetY:r.lastY,screenX:r.lastX,screenY:r.lastY,button:-1,buttons:0,pointerId:1,pointerType:pointerTypeOf(i),isPrimary:!0,bubbles:!0,cancelable:!1}))}),e.add_controller(c);let l=new d.EventControllerScroll({flags:d.EventControllerScrollFlags.BOTH_AXES});l.connect(`scroll`,(e,n,i)=>{let s=t();if(!s)return;let c=extractModifiers(l),u=l.get_unit()===o.ScrollUnit.WHEEL,d=u?3:1,f={...c,clientX:r.lastX,clientY:r.lastY,offsetX:r.lastX,offsetY:r.lastY,screenX:r.lastX,screenY:r.lastY,deltaX:n*d,deltaY:i*d,deltaZ:0,deltaMode:u?WheelEvent.DOM_DELTA_LINE:WheelEvent.DOM_DELTA_PIXEL,bubbles:!0,cancelable:!0};return s.dispatchEvent(new WheelEvent(`wheel`,f)),!1}),e.add_controller(l);let u=new d.EventControllerKey;u.connect(`key-pressed`,(e,i,s,c)=>{let l=t();if(!l)return!1;let u=r.pressedKeys.has(i);r.pressedKeys.add(i);let d=gdkKeyvalToKey(i),f={key:d,code:gdkKeyvalToCode(i),location:gdkKeyvalToLocation(i),repeat:u,altKey:!!(c&o.ModifierType.ALT_MASK),ctrlKey:!!(c&o.ModifierType.CONTROL_MASK),metaKey:!!(c&o.ModifierType.SUPER_MASK),shiftKey:!!(c&o.ModifierType.SHIFT_MASK),keyCode:d.length===1?d.toUpperCase().charCodeAt(0):0,which:d.length===1?d.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0},p=new KeyboardEvent(`keydown`,f);return l.dispatchEvent(p),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent(`keydown`,f)),n?.captureKeys===!0}),u.connect(`key-released`,(e,n,i,s)=>{let c=t();if(!c)return;r.pressedKeys.delete(n);let l=gdkKeyvalToKey(n),u={key:l,code:gdkKeyvalToCode(n),location:gdkKeyvalToLocation(n),repeat:!1,altKey:!!(s&o.ModifierType.ALT_MASK),ctrlKey:!!(s&o.ModifierType.CONTROL_MASK),metaKey:!!(s&o.ModifierType.SUPER_MASK),shiftKey:!!(s&o.ModifierType.SHIFT_MASK),keyCode:l.length===1?l.toUpperCase().charCodeAt(0):0,which:l.length===1?l.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0};c.dispatchEvent(new KeyboardEvent(`keyup`,u)),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent(`keyup`,u))}),e.add_controller(u);let f=new d.EventControllerFocus;f.connect(`enter`,()=>{let e=t();e&&(e.dispatchEvent(new FocusEvent(`focus`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusin`,{bubbles:!0,cancelable:!1})))}),f.connect(`leave`,()=>{let e=t();e&&(r.pressedKeys.clear(),e.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusout`,{bubbles:!0,cancelable:!1})),getGlobalEventTarget()?.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})))}),e.add_controller(f);let p=new d.EventControllerLegacy;p.connect(`event`,(t,n)=>{let r=n.get_event_type(),s=wo.get(r);if(s===void 0)return r===o.EventType.GRAB_BROKEN&&i.activeCount>0&&n.get_grab_surface()!==e.get_native().get_surface()&&i.cancelAll(modifiersFromState(n.get_modifier_state())),!1;let[,c,l]=n.get_position(),[u,d]=surfaceToWidget(e,c,l),f=n.get_emulating_pointer();return i.handle({...modifiersFromState(n.get_modifier_state()),phase:s,key:sequenceKey(n.get_event_sequence(),f),x:u,y:d,isPrimary:f}),s===`begin`&&e.grab_focus(),!1}),e.add_controller(p),e.connect(`unmap`,()=>i.cancelAll(Eo)),e.connect(`state-flags-changed`,(t,n)=>{let r=d.StateFlags.INSENSITIVE;e.get_state_flags()&r&&!(n&r)&&i.cancelAll(Eo)})}re();const Do=p.registerClass({GTypeName:`GjsifyWebGLBridge`},class WebGLBridge extends d.GLArea{constructor(e){super(e),this._canvas=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._renderTag=null,this._tickCallbackId=null,this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._frameCallbackId=0,this._nextFrameId=1,this._timeOrigin=i.get_monotonic_time(),this._rendererInfo=null,this.set_allowed_apis(o.GLAPI.GL|o.GLAPI.GLES),this.set_required_version(3,2),this.set_has_depth_buffer(!0),this.set_has_stencil_buffer(!0),attachEventControllers(this,()=>this._canvas,{captureKeys:!0}),this._tickCallbackId=this.add_tick_callback((e,t)=>(this._frameCallback!==null&&this.queue_render(),i.SOURCE_CONTINUE));let t=this.connect(`render`,()=>{this.disconnect(t),this.make_current(),this._canvas=new HTMLCanvasElement$1(this);{let e=globalThis;e.document?.body&&e.document.body.appendChild(this._canvas)}this._canvas.getContext(`webgl2`);let e=this._canvas.getContext(`webgl`);if(e){this._reportRenderer(e);for(let t of this._readyCallbacks)t(this._canvas,e);this._readyCallbacks=[]}return this._renderTag=this.connect(`render`,e=>{let t=(i.get_monotonic_time()-this._timeOrigin)/1e3;if(this._frameCallback!==null){globalThis.__GJSIFY_DEBUG_RAF===!0&&M.log(`[rAF] frame callback fires t=${t.toFixed(1)}`);let e=this._frameCallback;this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=e,this._lastFrameTime=t,e(t)}else if(this._lastFrameCallback!==null){this._replaying=!0;try{this._lastFrameCallback(this._lastFrameTime)}finally{this._replaying=!1}}return!0}),!0});this.connect(`resize`,()=>{let e=this.get_allocated_width(),t=this.get_allocated_height();this._canvas&&(this._canvas.dispatchEvent(new Event(`resize`)),notifyElementResize(this._canvas,e,t));for(let n of this._resizeCallbacks)n(e,t);this._frameCallback&&this.requestAnimationFrame(this._frameCallback)}),this.connect(`unrealize`,()=>{this._renderTag!==null&&(this.disconnect(this._renderTag),this._renderTag=null),this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._canvas=null})}get canvas(){return this._canvas}get rendererInfo(){return this._rendererInfo}onReady(e){if(this._canvas){let t=this._canvas.getContext(`webgl`);if(t){e(this._canvas,t);return}}this._readyCallbacks.push(e)}onWebGLReady(e){this.onReady(e)}_reportRenderer(e){let t=e.getExtension(`WEBGL_debug_renderer_info`),n=String(e.getParameter(t.UNMASKED_VENDOR_WEBGL)??``),r=String(e.getParameter(t.UNMASKED_RENDERER_WEBGL)??``);this._rendererInfo={vendor:n,renderer:r},isSoftwareRenderer(r)&&M.warn(`[@gjsify/webgl] GL is rasterised on the CPU by "${r}" (${n}) — this host exposes no usable GPU. Every draw call still works; fill-heavy or continuously animating content will be orders of magnitude slower than on hardware, which can look like a frozen window rather than a slow one. Read it yourself via WebGLBridge.rendererInfo or the WEBGL_debug_renderer_info extension.`)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(e){let t=this._nextFrameId++;return this._replaying?t:(this._frameCallback=e,this._frameCallbackId=t,this.queue_render(),t)}cancelAnimationFrame(e){e!==0&&e===this._frameCallbackId&&(this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=null,this._lastFrameTime=0)}installGlobals(){let e=globalThis;e.requestAnimationFrame=e=>this.requestAnimationFrame(e),e.cancelAnimationFrame=e=>this.cancelAnimationFrame(e),e.WebGLRenderingContext=WebGLRenderingContext$1,e.WebGL2RenderingContext=Xr,Object.defineProperty(globalThis,"devicePixelRatio",{get:()=>this.get_scale_factor()||1,configurable:!0});let t=this._timeOrigin;e.performance={now:()=>(i.get_monotonic_time()-t)/1e3,timeOrigin:Date.now()}}});re()
101
101
  /**
102
102
  * @license
103
103
  * Copyright 2010-2026 Three.js Authors