define(["./when-4bbc8319","./RuntimeError-346a3079","./WebGLConstants-1c8239cc","./createTaskProcessorWorker"],function(s,S,t,R){"use strict";var _,A,e,T,O,n,B,G,M,C={UNSIGNED_BYTE:t.WebGLConstants.UNSIGNED_BYTE,UNSIGNED_SHORT:t.WebGLConstants.UNSIGNED_SHORT,UNSIGNED_INT:t.WebGLConstants.UNSIGNED_INT,FLOAT:t.WebGLConstants.FLOAT,HALF_FLOAT:t.WebGLConstants.HALF_FLOAT_OES,UNSIGNED_INT_24_8:t.WebGLConstants.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:t.WebGLConstants.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:t.WebGLConstants.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:t.WebGLConstants.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(_,R){switch(_){case C.UNSIGNED_BYTE:return t.WebGLConstants.UNSIGNED_BYTE;case C.UNSIGNED_SHORT:return t.WebGLConstants.UNSIGNED_SHORT;case C.UNSIGNED_INT:return t.WebGLConstants.UNSIGNED_INT;case C.FLOAT:return t.WebGLConstants.FLOAT;case C.HALF_FLOAT:return R.webgl2?t.WebGLConstants.HALF_FLOAT:t.WebGLConstants.HALF_FLOAT_OES;case C.UNSIGNED_INT_24_8:return t.WebGLConstants.UNSIGNED_INT_24_8;case C.UNSIGNED_SHORT_4_4_4_4:return t.WebGLConstants.UNSIGNED_SHORT_4_4_4_4;case C.UNSIGNED_SHORT_5_5_5_1:return t.WebGLConstants.UNSIGNED_SHORT_5_5_5_1;case C.UNSIGNED_SHORT_5_6_5:return C.UNSIGNED_SHORT_5_6_5}},isPacked:function(_){return _===C.UNSIGNED_INT_24_8||_===C.UNSIGNED_SHORT_4_4_4_4||_===C.UNSIGNED_SHORT_5_5_5_1||_===C.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(_){switch(_){case C.UNSIGNED_BYTE:return 1;case C.UNSIGNED_SHORT:case C.UNSIGNED_SHORT_4_4_4_4:case C.UNSIGNED_SHORT_5_5_5_1:case C.UNSIGNED_SHORT_5_6_5:case C.HALF_FLOAT:return 2;case C.UNSIGNED_INT:case C.FLOAT:case C.UNSIGNED_INT_24_8:return 4}},validate:function(_){return _===C.UNSIGNED_BYTE||_===C.UNSIGNED_SHORT||_===C.UNSIGNED_INT||_===C.FLOAT||_===C.HALF_FLOAT||_===C.UNSIGNED_INT_24_8||_===C.UNSIGNED_SHORT_4_4_4_4||_===C.UNSIGNED_SHORT_5_5_5_1||_===C.UNSIGNED_SHORT_5_6_5}},K=Object.freeze(C),r={DEPTH_COMPONENT:t.WebGLConstants.DEPTH_COMPONENT,DEPTH_STENCIL:t.WebGLConstants.DEPTH_STENCIL,ALPHA:t.WebGLConstants.ALPHA,RGB:t.WebGLConstants.RGB,RGBA:t.WebGLConstants.RGBA,LUMINANCE:t.WebGLConstants.LUMINANCE,LUMINANCE_ALPHA:t.WebGLConstants.LUMINANCE_ALPHA,RGB_DXT1:t.WebGLConstants.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:t.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:t.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:t.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:t.WebGLConstants.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:t.WebGLConstants.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:t.WebGLConstants.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:t.WebGLConstants.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:t.WebGLConstants.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:t.WebGLConstants.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:t.WebGLConstants.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:t.WebGLConstants.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:t.WebGLConstants.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(_){switch(_){case r.RGB:return 3;case r.RGBA:return 4;case r.LUMINANCE_ALPHA:return 2;case r.ALPHA:case r.LUMINANCE:default:return 1}},validate:function(_){return _===r.DEPTH_COMPONENT||_===r.DEPTH_STENCIL||_===r.ALPHA||_===r.RGB||_===r.RGBA||_===r.LUMINANCE||_===r.LUMINANCE_ALPHA||_===r.RGB_DXT1||_===r.RGBA_DXT1||_===r.RGBA_DXT3||_===r.RGBA_DXT5||_===r.RGB_PVRTC_4BPPV1||_===r.RGB_PVRTC_2BPPV1||_===r.RGBA_PVRTC_4BPPV1||_===r.RGBA_PVRTC_2BPPV1||_===r.RGBA_ASTC||_===r.RGB_ETC1||_===r.RGB8_ETC2||_===r.RGBA8_ETC2_EAC||_===r.RGBA_BC7},isColorFormat:function(_){return _===r.ALPHA||_===r.RGB||_===r.RGBA||_===r.LUMINANCE||_===r.LUMINANCE_ALPHA},isDepthFormat:function(_){return _===r.DEPTH_COMPONENT||_===r.DEPTH_STENCIL},isCompressedFormat:function(_){return _===r.RGB_DXT1||_===r.RGBA_DXT1||_===r.RGBA_DXT3||_===r.RGBA_DXT5||_===r.RGB_PVRTC_4BPPV1||_===r.RGB_PVRTC_2BPPV1||_===r.RGBA_PVRTC_4BPPV1||_===r.RGBA_PVRTC_2BPPV1||_===r.RGBA_ASTC||_===r.RGB_ETC1||_===r.RGB8_ETC2||_===r.RGBA8_ETC2_EAC||_===r.RGBA_BC7},isDXTFormat:function(_){return _===r.RGB_DXT1||_===r.RGBA_DXT1||_===r.RGBA_DXT3||_===r.RGBA_DXT5},isPVRTCFormat:function(_){return _===r.RGB_PVRTC_4BPPV1||_===r.RGB_PVRTC_2BPPV1||_===r.RGBA_PVRTC_4BPPV1||_===r.RGBA_PVRTC_2BPPV1},isASTCFormat:function(_){return _===r.RGBA_ASTC},isETC1Format:function(_){return _===r.RGB_ETC1},isETC2Format:function(_){return _===r.RGB8_ETC2||_===r.RGBA8_ETC2_EAC},isBC7Format:function(_){return _===r.RGBA_BC7},compressedTextureSizeInBytes:function(_,R,A){switch(_){case r.RGB_DXT1:case r.RGBA_DXT1:case r.RGB_ETC1:case r.RGB8_ETC2:return Math.floor((R+3)/4)*Math.floor((A+3)/4)*8;case r.RGBA_DXT3:case r.RGBA_DXT5:case r.RGBA_ASTC:case r.RGBA8_ETC2_EAC:return Math.floor((R+3)/4)*Math.floor((A+3)/4)*16;case r.RGB_PVRTC_4BPPV1:case r.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(R,8)*Math.max(A,8)*4+7)/8);case r.RGB_PVRTC_2BPPV1:case r.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(R,16)*Math.max(A,8)*2+7)/8);case r.RGBA_BC7:return Math.ceil(R/4)*Math.ceil(A/4)*16;default:return 0}},textureSizeInBytes:function(_,R,A,t){_=r.componentsLength(_);return(_=K.isPacked(R)?1:_)*K.sizeInBytes(R)*A*t},alignmentInBytes:function(_,R,A){A=r.textureSizeInBytes(_,R,A,1)%4;return 0==A?4:2==A?2:1},createTypedArray:function(_,R,A,t){var e=K.sizeInBytes(R),R=e===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:e===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:e===Float32Array.BYTES_PER_ELEMENT&&R===K.FLOAT?Float32Array:Uint32Array;return new R(r.componentsLength(_)*A*t)},flipY:function(_,R,A,t,e){if(1===e)return _;for(var T=r.createTypedArray(R,A,t,e),O=r.componentsLength(R),n=t*O,B=0;B>e,B=_.pixelHeight>>e,G=n*B*i.componentsLength(t),M=0;M<_.faceCount;++M){var C=O.byteOffset+G*_.typeSize*M;C=new(s.defined(A)&&1!==K.sizeInBytes(A)?2===K.sizeInBytes(A)?Uint16Array:Float32Array:Uint8Array)(O.buffer,C,G),T[V[M]]={internalFormat:t,datatype:A,width:n,height:B,levelBuffer:C}}}}(A,_)):function(_,R,A,t,e,T){var O,n,B=new t.KTX2File(_),G=B.getWidth(),M=B.getHeight(),C=B.getLevels(),_=B.getHasAlpha();if(!(0>K,M=R.pixelHeight>>K;var F=B.getImageTranscodedSizeInBytes(K,0,0,n.value),N=new Uint8Array(F),F=B.transcodeImage(N,K,0,0,n.value,0,-1,-1);if(!s.defined(F))throw new S.RuntimeError("transcodeImage() failed.");e.push(N.buffer),r[V[0]]={internalFormat:O,width:G,height:M,levelBuffer:N}}B.close(),B.delete()}(t,A,e,N,R,_),_}function L(_){(N=_).initializeBasis(),self.onmessage=R(E),self.postMessage(!0)}return function(_){var R=_.data.webAssemblyConfig;if(s.defined(R))return require([R.modulePath],function(_){return s.defined(R.wasmBinaryFile)?void(_=!s.defined(_)?self.MSC_TRANSCODER:_)(R).then(function(_){L(_)}):_().then(function(_){L(_)})})}});