define(["./defaultValue-f6d5e6da","./WebGLConstants-7f557f93","./RuntimeError-9b4ce3fb","./createTaskProcessorWorker"],(function(_,R,t,e){"use strict";const A={UNSIGNED_BYTE:R.WebGLConstants.UNSIGNED_BYTE,UNSIGNED_SHORT:R.WebGLConstants.UNSIGNED_SHORT,UNSIGNED_INT:R.WebGLConstants.UNSIGNED_INT,FLOAT:R.WebGLConstants.FLOAT,HALF_FLOAT:R.WebGLConstants.HALF_FLOAT_OES,UNSIGNED_INT_24_8:R.WebGLConstants.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:R.WebGLConstants.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:R.WebGLConstants.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:R.WebGLConstants.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(_,t){switch(_){case A.UNSIGNED_BYTE:return R.WebGLConstants.UNSIGNED_BYTE;case A.UNSIGNED_SHORT:return R.WebGLConstants.UNSIGNED_SHORT;case A.UNSIGNED_INT:return R.WebGLConstants.UNSIGNED_INT;case A.FLOAT:return R.WebGLConstants.FLOAT;case A.HALF_FLOAT:return t.webgl2?R.WebGLConstants.HALF_FLOAT:R.WebGLConstants.HALF_FLOAT_OES;case A.UNSIGNED_INT_24_8:return R.WebGLConstants.UNSIGNED_INT_24_8;case A.UNSIGNED_SHORT_4_4_4_4:return R.WebGLConstants.UNSIGNED_SHORT_4_4_4_4;case A.UNSIGNED_SHORT_5_5_5_1:return R.WebGLConstants.UNSIGNED_SHORT_5_5_5_1;case A.UNSIGNED_SHORT_5_6_5:return A.UNSIGNED_SHORT_5_6_5}},isPacked:function(_){return _===A.UNSIGNED_INT_24_8||_===A.UNSIGNED_SHORT_4_4_4_4||_===A.UNSIGNED_SHORT_5_5_5_1||_===A.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(_){switch(_){case A.UNSIGNED_BYTE:return 1;case A.UNSIGNED_SHORT:case A.UNSIGNED_SHORT_4_4_4_4:case A.UNSIGNED_SHORT_5_5_5_1:case A.UNSIGNED_SHORT_5_6_5:case A.HALF_FLOAT:return 2;case A.UNSIGNED_INT:case A.FLOAT:case A.UNSIGNED_INT_24_8:return 4}},validate:function(_){return _===A.UNSIGNED_BYTE||_===A.UNSIGNED_SHORT||_===A.UNSIGNED_INT||_===A.FLOAT||_===A.HALF_FLOAT||_===A.UNSIGNED_INT_24_8||_===A.UNSIGNED_SHORT_4_4_4_4||_===A.UNSIGNED_SHORT_5_5_5_1||_===A.UNSIGNED_SHORT_5_6_5}};var T=Object.freeze(A);const O={DEPTH_COMPONENT:R.WebGLConstants.DEPTH_COMPONENT,DEPTH_STENCIL:R.WebGLConstants.DEPTH_STENCIL,ALPHA:R.WebGLConstants.ALPHA,RED:R.WebGLConstants.RED,RG:R.WebGLConstants.RG,RGB:R.WebGLConstants.RGB,RGBA:R.WebGLConstants.RGBA,LUMINANCE:R.WebGLConstants.LUMINANCE,LUMINANCE_ALPHA:R.WebGLConstants.LUMINANCE_ALPHA,RGB_DXT1:R.WebGLConstants.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:R.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:R.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:R.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:R.WebGLConstants.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:R.WebGLConstants.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:R.WebGLConstants.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:R.WebGLConstants.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:R.WebGLConstants.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:R.WebGLConstants.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:R.WebGLConstants.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:R.WebGLConstants.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:R.WebGLConstants.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(_){switch(_){case O.RGB:return 3;case O.RGBA:return 4;case O.LUMINANCE_ALPHA:case O.RG:return 2;case O.ALPHA:case O.RED:case O.LUMINANCE:default:return 1}},validate:function(_){return _===O.DEPTH_COMPONENT||_===O.DEPTH_STENCIL||_===O.ALPHA||_===O.RED||_===O.RG||_===O.RGB||_===O.RGBA||_===O.LUMINANCE||_===O.LUMINANCE_ALPHA||_===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5||_===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1||_===O.RGBA_ASTC||_===O.RGB_ETC1||_===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC||_===O.RGBA_BC7},isColorFormat:function(_){return _===O.ALPHA||_===O.RGB||_===O.RGBA||_===O.LUMINANCE||_===O.LUMINANCE_ALPHA},isDepthFormat:function(_){return _===O.DEPTH_COMPONENT||_===O.DEPTH_STENCIL},isCompressedFormat:function(_){return _===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5||_===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1||_===O.RGBA_ASTC||_===O.RGB_ETC1||_===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC||_===O.RGBA_BC7},isDXTFormat:function(_){return _===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5},isPVRTCFormat:function(_){return _===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1},isASTCFormat:function(_){return _===O.RGBA_ASTC},isETC1Format:function(_){return _===O.RGB_ETC1},isETC2Format:function(_){return _===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC},isBC7Format:function(_){return _===O.RGBA_BC7},compressedTextureSizeInBytes:function(_,R,t){switch(_){case O.RGB_DXT1:case O.RGBA_DXT1:case O.RGB_ETC1:case O.RGB8_ETC2:return Math.floor((R+3)/4)*Math.floor((t+3)/4)*8;case O.RGBA_DXT3:case O.RGBA_DXT5:case O.RGBA_ASTC:case O.RGBA8_ETC2_EAC:return Math.floor((R+3)/4)*Math.floor((t+3)/4)*16;case O.RGB_PVRTC_4BPPV1:case O.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(R,8)*Math.max(t,8)*4+7)/8);case O.RGB_PVRTC_2BPPV1:case O.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(R,16)*Math.max(t,8)*2+7)/8);case O.RGBA_BC7:return Math.ceil(R/4)*Math.ceil(t/4)*16;default:return 0}},textureSizeInBytes:function(_,R,t,e){let A=O.componentsLength(_);return T.isPacked(R)&&(A=1),A*T.sizeInBytes(R)*t*e},alignmentInBytes:function(_,R,t){const e=O.textureSizeInBytes(_,R,t,1)%4;return 0===e?4:2===e?2:1},createTypedArray:function(_,R,t,e){let A;const n=T.sizeInBytes(R);A=n===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:n===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:n===Float32Array.BYTES_PER_ELEMENT&&R===T.FLOAT?Float32Array:Uint32Array;return new A(O.componentsLength(_)*t*e)},flipY:function(_,R,t,e,A){if(1===A)return _;const T=O.createTypedArray(R,t,e,A),n=O.componentsLength(R),B=e*n;for(let R=0;R>O,K=R.pixelHeight>>O,s=M*K*n.componentsLength(e);for(let t=0;t0&&K>0&&s>0))throw G.close(),G.delete(),new t.RuntimeError("Invalid KTX2 file");let N,V;const a=e.dataFormatDescriptor[0],o=T.transcoder_texture_format;if(a.colorModel===F)if(A.etc)N=C?n.RGBA8_ETC2_EAC:n.RGB8_ETC2,V=C?o.cTFETC2_RGBA:o.cTFETC1_RGB;else if(A.etc1&&!C)N=n.RGB_ETC1,V=o.cTFETC1_RGB;else if(A.s3tc)N=C?n.RGBA_DXT5:n.RGB_DXT1,V=C?o.cTFBC3_RGBA:o.cTFBC1_RGB;else if(A.pvrtc)N=C?n.RGBA_PVRTC_4BPPV1:n.RGB_PVRTC_4BPPV1,V=C?o.cTFPVRTC1_4_RGBA:o.cTFPVRTC1_4_RGB;else if(A.astc)N=n.RGBA_ASTC,V=o.cTFASTC_4x4_RGBA;else{if(!A.bc7)throw new t.RuntimeError("No transcoding format target available for ETC1S compressed ktx2.");N=n.RGBA_BC7,V=o.cTFBC7_RGBA}else if(a.colorModel===i)if(A.astc)N=n.RGBA_ASTC,V=o.cTFASTC_4x4_RGBA;else if(A.bc7)N=n.RGBA_BC7,V=o.cTFBC7_RGBA;else if(A.s3tc)N=C?n.RGBA_DXT5:n.RGB_DXT1,V=C?o.cTFBC3_RGBA:o.cTFBC1_RGB;else if(A.etc)N=C?n.RGBA8_ETC2_EAC:n.RGB8_ETC2,V=C?o.cTFETC2_RGBA:o.cTFETC1_RGB;else if(A.etc1&&!C)N=n.RGB_ETC1,V=o.cTFETC1_RGB;else{if(!A.pvrtc)throw new t.RuntimeError("No transcoding format target available for UASTC compressed ktx2.");N=C?n.RGBA_PVRTC_4BPPV1:n.RGB_PVRTC_4BPPV1,V=C?o.cTFPVRTC1_4_RGBA:o.cTFPVRTC1_4_RGB}if(!G.startTranscoding())throw G.close(),G.delete(),new t.RuntimeError("startTranscoding() failed");for(let R=0;R>R,K=e.pixelHeight>>R;const T=G.getImageTranscodedSizeInBytes(R,0,0,V.value),n=new Uint8Array(T),s=G.transcodeImage(n,R,0,0,V.value,0,-1,-1);if(!_.defined(s))throw new t.RuntimeError("transcodeImage() failed.");O.push(n.buffer),A[r[0]]={internalFormat:N,width:M,height:K,levelBuffer:n}}G.close(),G.delete()}(A,V,O,N,e,o),o}function a(_){N=_,N.initializeBasis(),self.onmessage=e(V),self.postMessage(!0)}return function(R){const t=R.data.webAssemblyConfig;if(_.defined(t))return require([t.modulePath],(function(R){if(!_.defined(t.wasmBinaryFile))return R().then((function(_){a(_)}));_.defined(R)||(R=self.MSC_TRANSCODER),R(t).then((function(_){a(_)}))}))}}));