@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +128 -71
  3. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  4. package/dist/adapter/converters/sampler-parameters.js +20 -19
  5. package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
  6. package/dist/adapter/converters/shader-formats.js +40 -20
  7. package/dist/adapter/converters/texture-formats.d.ts +16 -11
  8. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  9. package/dist/adapter/converters/texture-formats.js +224 -205
  10. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  11. package/dist/adapter/converters/vertex-formats.js +22 -21
  12. package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
  13. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  14. package/dist/adapter/device-helpers/webgl-device-features.js +89 -43
  15. package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
  16. package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
  17. package/dist/adapter/device-helpers/webgl-device-info.js +22 -19
  18. package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
  19. package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
  20. package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
  21. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
  22. package/dist/adapter/helpers/decode-webgl-types.js +47 -46
  23. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  24. package/dist/adapter/helpers/get-shader-layout.js +35 -34
  25. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  26. package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
  27. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  28. package/dist/adapter/helpers/set-uniform.js +42 -41
  29. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  30. package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
  31. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  32. package/dist/adapter/objects/constants-to-keys.js +2 -1
  33. package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
  34. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  35. package/dist/adapter/objects/webgl-renderbuffer.js +30 -17
  36. package/dist/adapter/objects/webgl-resource.d.ts +2 -24
  37. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  38. package/dist/adapter/objects/webgl-resource.js +6 -101
  39. package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
  40. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  41. package/dist/adapter/resources/webgl-buffer.js +16 -15
  42. package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
  43. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  44. package/dist/adapter/resources/webgl-command-buffer.js +32 -31
  45. package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
  46. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  47. package/dist/adapter/resources/webgl-command-encoder.js +4 -2
  48. package/dist/adapter/resources/webgl-external-texture.js +6 -5
  49. package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
  50. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  51. package/dist/adapter/resources/webgl-framebuffer.js +60 -53
  52. package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
  53. package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
  54. package/dist/adapter/resources/webgl-query-set.js +136 -0
  55. package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
  56. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgl-render-pass.js +20 -12
  58. package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
  59. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  60. package/dist/adapter/resources/webgl-render-pipeline.js +52 -61
  61. package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
  62. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  63. package/dist/adapter/resources/webgl-sampler.js +5 -4
  64. package/dist/adapter/resources/webgl-shader.d.ts +3 -2
  65. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  66. package/dist/adapter/resources/webgl-shader.js +15 -9
  67. package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
  68. package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
  69. package/dist/adapter/resources/webgl-texture-view.js +18 -0
  70. package/dist/adapter/resources/webgl-texture.d.ts +6 -4
  71. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  72. package/dist/adapter/resources/webgl-texture.js +39 -32
  73. package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
  74. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
  75. package/dist/adapter/resources/webgl-transform-feedback.js +10 -10
  76. package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
  77. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  78. package/dist/adapter/resources/webgl-vertex-array.js +10 -9
  79. package/dist/adapter/webgl-canvas-context.d.ts +2 -2
  80. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  81. package/dist/adapter/webgl-canvas-context.js +3 -2
  82. package/dist/adapter/webgl-device.d.ts +35 -30
  83. package/dist/adapter/webgl-device.d.ts.map +1 -1
  84. package/dist/adapter/webgl-device.js +110 -109
  85. package/dist/classic/accessor.d.ts.map +1 -1
  86. package/dist/classic/accessor.js +8 -7
  87. package/dist/classic/clear.d.ts.map +1 -1
  88. package/dist/classic/clear.js +5 -4
  89. package/dist/classic/copy-and-blit.d.ts +1 -1
  90. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  91. package/dist/classic/copy-and-blit.js +19 -19
  92. package/dist/classic/format-utils.d.ts.map +1 -1
  93. package/dist/classic/format-utils.js +16 -15
  94. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  95. package/dist/classic/typed-array-utils.js +20 -19
  96. package/dist/context/debug/spector.d.ts.map +1 -1
  97. package/dist/context/debug/spector.js +2 -1
  98. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  99. package/dist/context/debug/webgl-developer-tools.js +7 -6
  100. package/dist/context/{context → helpers}/create-browser-context.d.ts.map +1 -1
  101. package/dist/context/{context → helpers}/create-browser-context.js +2 -1
  102. package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
  103. package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
  104. package/dist/context/helpers/webgl-context-data.js +21 -0
  105. package/dist/context/helpers/webgl-extensions.d.ts +4 -0
  106. package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
  107. package/dist/context/helpers/webgl-extensions.js +10 -0
  108. package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
  109. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  110. package/dist/context/parameters/unified-parameter-api.js +7 -11
  111. package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
  112. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  113. package/dist/context/parameters/webgl-parameter-tables.js +302 -295
  114. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  115. package/dist/context/state-tracker/deep-array-equal.js +2 -1
  116. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  117. package/dist/context/state-tracker/track-context-state.js +5 -4
  118. package/dist/context/state-tracker/with-parameters.d.ts +2 -3
  119. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  120. package/dist/context/state-tracker/with-parameters.js +6 -8
  121. package/dist/dist.dev.js +1635 -1387
  122. package/dist/index.cjs +1766 -1534
  123. package/dist/index.cjs.map +4 -4
  124. package/dist/index.d.ts +25 -25
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +24 -23
  127. package/dist/types.d.ts.map +1 -1
  128. package/dist/types.js +2 -1
  129. package/dist.min.js +6 -6
  130. package/package.json +4 -4
  131. package/src/adapter/converters/device-parameters.ts +114 -27
  132. package/src/adapter/converters/sampler-parameters.ts +12 -3
  133. package/src/adapter/converters/shader-formats.ts +47 -22
  134. package/src/adapter/converters/texture-formats.ts +138 -114
  135. package/src/adapter/converters/vertex-formats.ts +3 -3
  136. package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
  137. package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
  138. package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
  139. package/src/adapter/helpers/decode-webgl-types.ts +13 -7
  140. package/src/adapter/helpers/get-shader-layout.ts +4 -3
  141. package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
  142. package/src/adapter/helpers/set-uniform.ts +2 -1
  143. package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
  144. package/src/adapter/objects/constants-to-keys.ts +2 -1
  145. package/src/adapter/objects/webgl-renderbuffer.ts +36 -14
  146. package/src/adapter/objects/webgl-resource.ts +7 -125
  147. package/src/adapter/resources/webgl-buffer.ts +4 -3
  148. package/src/adapter/resources/webgl-command-buffer.ts +5 -5
  149. package/src/adapter/resources/webgl-command-encoder.ts +14 -11
  150. package/src/adapter/resources/webgl-external-texture.ts +6 -5
  151. package/src/adapter/resources/webgl-framebuffer.ts +61 -53
  152. package/src/adapter/resources/webgl-query-set.ts +171 -0
  153. package/src/adapter/resources/webgl-render-pass.ts +20 -11
  154. package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
  155. package/src/adapter/resources/webgl-sampler.ts +2 -1
  156. package/src/adapter/resources/webgl-shader.ts +12 -5
  157. package/src/adapter/resources/webgl-texture-view.ts +28 -0
  158. package/src/adapter/resources/webgl-texture.ts +14 -3
  159. package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
  160. package/src/adapter/resources/webgl-vertex-array.ts +4 -3
  161. package/src/adapter/webgl-canvas-context.ts +6 -4
  162. package/src/adapter/webgl-device.ts +116 -107
  163. package/src/classic/accessor.ts +5 -4
  164. package/src/classic/clear.ts +14 -8
  165. package/src/classic/copy-and-blit.ts +11 -4
  166. package/src/classic/format-utils.ts +2 -1
  167. package/src/classic/typed-array-utils.ts +3 -7
  168. package/src/context/debug/spector.ts +9 -6
  169. package/src/context/debug/webgl-developer-tools.ts +27 -14
  170. package/src/context/{context → helpers}/create-browser-context.ts +3 -2
  171. package/src/context/helpers/webgl-context-data.ts +31 -0
  172. package/src/context/helpers/webgl-extensions.ts +17 -0
  173. package/src/context/parameters/unified-parameter-api.ts +6 -17
  174. package/src/context/parameters/webgl-parameter-tables.ts +69 -32
  175. package/src/context/state-tracker/deep-array-equal.ts +2 -1
  176. package/src/context/state-tracker/track-context-state.ts +11 -6
  177. package/src/context/state-tracker/with-parameters.ts +8 -8
  178. package/src/index.ts +7 -6
  179. package/src/types.ts +2 -1
  180. package/dist/adapter/device-helpers/device-features.d.ts +0 -6
  181. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  182. package/dist/adapter/device-helpers/device-features.js +0 -65
  183. package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
  184. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  185. package/dist/adapter/device-helpers/device-limits.js +0 -92
  186. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  187. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  188. package/dist/adapter/device-helpers/get-device-info.js +0 -87
  189. package/dist/context/context/context-data.d.ts.map +0 -1
  190. package/dist/context/context/context-data.js +0 -33
  191. package/src/context/context/context-data.ts +0 -44
  192. /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
package/dist.min.js CHANGED
@@ -4,16 +4,16 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- var __exports__=(()=>{var Kn=Object.create;var tt=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var zn=Object.getPrototypeOf,jn=Object.prototype.hasOwnProperty;var Zn=(r,e,t)=>e in r?tt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var qn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Qn=(r,e)=>{for(var t in e)tt(r,t,{get:e[t],enumerable:!0})},Sr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $n(e))!jn.call(r,i)&&i!==t&&tt(r,i,{get:()=>e[i],enumerable:!(n=Yn(e,i))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?Kn(zn(r)):{},Sr(e||!r||!r.__esModule?tt(t,"default",{value:r,enumerable:!0}):t,r)),Jn=r=>Sr(tt({},"__esModule",{value:!0}),r);var g=(r,e,t)=>(Zn(r,typeof e!="symbol"?e+"":e,t),t);var C=qn((ic,$r)=>{$r.exports=globalThis.luma});var ns={};Qn(ns,{Accessor:()=>se,WEBGLBuffer:()=>X,WEBGLCommandEncoder:()=>qe,WEBGLFramebuffer:()=>J,WEBGLRenderPass:()=>ze,WEBGLRenderPipeline:()=>Ze,WEBGLRenderbuffer:()=>_e,WEBGLResource:()=>Le,WEBGLSampler:()=>ce,WEBGLShader:()=>$e,WEBGLTexture:()=>U,WEBGLTransformFeedback:()=>Je,WEBGLVertexArray:()=>pe,WebGLCanvasContext:()=>Ye,WebGLDevice:()=>K,WebGLResource:()=>Le,_TEXTURE_FORMATS:()=>Re,convertGLToTextureFormat:()=>Se,getGLParameters:()=>we,getShaderLayout:()=>vt,popContextState:()=>Q,pushContextState:()=>te,resetGLParameters:()=>Jr,setDeviceParameters:()=>Bt,setGLParameters:()=>k,trackContextState:()=>ut,withDeviceParameters:()=>gn,withGLParameters:()=>Y});function rt(r){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,t=r||e;return!!(t&&t.indexOf("Electron")>=0)}function I(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||rt()}var ei=globalThis.self||globalThis.window||globalThis.global,Ce=globalThis.window||globalThis.self||globalThis.global,ti=globalThis.document||{},ge=globalThis.process||{},ri=globalThis.console,Lr=globalThis.navigator||{};var bt=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",ls=I();var wt=globalThis;function Tt(r){if(!r&&!I())return"Node";if(rt(r))return"Electron";let e=r||Lr.userAgent||"";if(e.indexOf("Edge")>-1)return"Edge";let t=e.indexOf("MSIE ")!==-1,n=e.indexOf("Trident/")!==-1;return t||n?"IE":wt.chrome?"Chrome":wt.safari?"Safari":wt.mozInnerScreenX?"Firefox":"Unknown"}function ni(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var At=class{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=ni(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function xr(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function Cr(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}function Rt(r,e,t){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,i=r.src.replace(/\(/g,"%28").replace(/\)/g,"%29");r.width>n&&(t=Math.min(t,n/r.width));let s=r.width*t,a=r.height*t,u=["font-size:1px;",`padding:${Math.floor(a/2)}px ${Math.floor(s/2)}px;`,`line-height:${a}px;`,`background:url(${i});`,`background-size:${s}px ${a}px;`,"color:transparent;"].join("");return[`${e} %c+`,u]}var St;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(St||(St={}));var ii=10;function Fr(r){return typeof r!="string"?r:(r=r.toUpperCase(),St[r]||St.WHITE)}function yr(r,e,t){return!I&&typeof r=="string"&&(e&&(r=`\x1B[${Fr(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${Fr(t)+ii}m${r}\x1B[49m`)),r}function Gr(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],t=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(t),i=r;for(let s of n){let a=i[s];typeof a=="function"&&(e.find(u=>s===u)||(i[s]=a.bind(r)))}}function Fe(r,e){if(!r)throw new Error(e||"Assertion failed")}function be(){let r;if(I()&&Ce.performance){var e,t;r=Ce===null||Ce===void 0||(e=Ce.performance)===null||e===void 0||(t=e.now)===null||t===void 0?void 0:t.call(e)}else if("hrtime"in ge){var n;let i=ge===null||ge===void 0||(n=ge.hrtime)===null||n===void 0?void 0:n.call(ge);r=i[0]*1e3+i[1]/1e6}else r=Date.now();return r}var ye={debug:I()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},oi={enabled:!0,level:0};function q(){}var Nr={},Pr={once:!0},de=class{constructor(){let{id:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=bt,this._startTs=be(),this._deltaTs=be(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new At(`__probe-${this.id}__`,oi),this.timeStamp(`${this.id} started`),Gr(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((be()-this._startTs).toPrecision(10))}getDelta(){return Number((be()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){Fe(e,t)}warn(e){return this._getLogFunction(0,e,ye.warn,arguments,Pr)}error(e){return this._getLogFunction(0,e,ye.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,ye.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,ye.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,ye.debug||ye.info,arguments,Pr)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||q,n&&[n],{tag:ci(t)}):q}image(e){let{logLevel:t,priority:n,image:i,message:s="",scale:a=1}=e;return this._shouldLog(t||n)?I()?ui({image:i,message:s,scale:a}):ai({image:i,message:s,scale:a}):q}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||q)}group(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},i=Ir({logLevel:e,message:t,opts:n}),{collapsed:s}=n;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||q)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Br(e)}_getLogFunction(e,t,n,i,s){if(this._shouldLog(e)){s=Ir({logLevel:e,message:t,args:i,opts:s}),n=n||s.method,Fe(n),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=be();let a=s.tag||s.message;if(s.once&&a)if(!Nr[a])Nr[a]=be();else return q;return t=si(this.id,s.message,s),n.bind(console,t,...s.args)}return q}};de.VERSION=bt;function Br(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return Fe(Number.isFinite(e)&&e>=0),e}function Ir(r){let{logLevel:e,message:t}=r;r.logLevel=Br(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let i=typeof r.message;return Fe(i==="string"||i==="object"),Object.assign(r,{args:n},r.opts)}function si(r,e,t){if(typeof e=="string"){let n=t.time?Cr(xr(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=yr(e,t.color,t.background)}return e}function ai(r){let{image:e,message:t="",scale:n=1}=r;return console.warn("removed"),q}function ui(r){let{image:e,message:t="",scale:n=1}=r;if(typeof e=="string"){let s=new Image;return s.onload=()=>{let a=Rt(s,t,n);console.log(...a)},s.src=e,q}let i=e.nodeName||"";if(i.toLowerCase()==="img")return console.log(...Rt(e,t,n)),q;if(i.toLowerCase()==="canvas"){let s=new Image;return s.onload=()=>console.log(...Rt(s,t,n)),s.src=e.toDataURL(),q}return q}function ci(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var Xs=new de({id:"@probe.gl/log"});var h=new de({id:"luma.gl"});function nt(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var Te=class{constructor(e,t){this.name=void 0,this.type=void 0,this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=nt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(nt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Ge=class{constructor(e){this.id=void 0,this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"count";return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:n}=e,i=this.stats[t];return i||(e instanceof Te?i=e:i=new Te(t,n),this.stats[t]=i),i}};var Wt=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Ge({id:e})),this.stats.get(e)}},Lt=new Wt;function li(){let r=typeof __VERSION__<"u"?__VERSION__:"running from source",e="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==r)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${r}`);return globalThis.luma||(I()&&h.log(1,`${r} - ${e}`)(),globalThis.luma=globalThis.luma||{VERSION:r,version:r,log:h,stats:Lt}),r}var Dr=li();function fi(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)?r:null}function Mr(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number"?r:null:fi(r)}var Xt={};function ee(r="id"){Xt[r]=Xt[r]||1;let e=Xt[r]++;return`${r}-${e}`}function Ne(r){let e=!0;for(let t in r){e=!1;break}return e}var A=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=di(t,n);let i=this.props.id!=="undefined"?this.props.id:ee(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}};g(A,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function di(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}var it=class extends A{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;constructor(e,t){let n={...t};(t.usage||0)&it.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),super(e,n,it.defaultProps),this.usage=t.usage||0,this.indexType=n.indexType}readSyncWebGL(e,t){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,t,n){let i=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:n,it.DEBUG_DATA_MAX_LENGTH);e===null?this.debugData=new ArrayBuffer(s):t===0&&n===e.byteLength?this.debugData=i.slice(0,s):this.debugData=i.slice(t,t+s)}},N=it;g(N,"defaultProps",{...A.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),g(N,"MAP_READ",1),g(N,"MAP_WRITE",2),g(N,"COPY_SRC",4),g(N,"COPY_DST",8),g(N,"INDEX",16),g(N,"VERTEX",32),g(N,"UNIFORM",64),g(N,"STORAGE",128),g(N,"INDIRECT",256),g(N,"QUERY_RESOLVE",512),g(N,"DEBUG_DATA_MAX_LENGTH",32);var Ht=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...Ht.defaultProps,...e},this.id=this.props.id||ee(this[Symbol.toStringTag].toLowerCase())}id;statsManager=Lt;props;userData={};_lumaData={};loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};return(e.usage||0)&N.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":h.warn("indices buffer content must be of integer type")()),t}},me=Ht;g(me,"defaultProps",{id:null,type:"best-available",canvas:null,container:null,manageState:!0,width:800,height:600,debug:Boolean(h.get("debug")),break:[],gl:null}),g(me,"VERSION",Dr);function S(r,e){if(!r)throw new Error(e||"luma.gl: assertion failed.")}var mi=I()&&typeof document<"u",xt=()=>mi&&document.readyState==="complete",hi={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},he=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return xt()}constructor(e){if(this.props={...hi,...e},e=this.props,!I()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=pi(e.canvas):this.canvas=e.canvas;else{let t=gi(e),n=_i(e?.container||null);n.insertBefore(t,n.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(t=>{for(let n of t)n.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:t}=this._canvasSizeInfo;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[i,s]=this.getDrawingBufferSize();return bi(e,n,i,s,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let n="width"in t?t.width:this.htmlCanvas.clientWidth,i="height"in t?t.height:this.htmlCanvas.clientHeight;(!n||!i)&&(h.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==i||s.devicePixelRatio!==e){let a=e,u=Math.floor(n*a),l=Math.floor(i*a);this.htmlCanvas.width=u,this.htmlCanvas.height=l;let[m,d]=this.getDrawingBufferSize();(m!==u||d!==l)&&(a=Math.min(m/n,d/i),this.htmlCanvas.width=Math.floor(n*a),this.htmlCanvas.height=Math.floor(i*a),h.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};g(he,"pageLoaded",Ei());function Ei(){return xt()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}function _i(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e&&!xt())throw new Error(`Accessing '${r}' before page was loaded`);if(!e)throw new Error(`${r} is not an HTML element`);return e}else if(r)return r;return document.body}function pi(r){let e=document.getElementById(r);if(!e&&!xt())throw new Error(`Accessing '${r}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function gi(r){let{width:e,height:t}=r,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=e||1,n.height=t||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(t)?`${t}px`:"100%",n}function bi(r,e,t,n,i){let s=r,a=Or(s[0],e,t),u=vr(s[1],e,n,i),l=Or(s[0]+1,e,t),m=l===t-1?l:l-1;l=vr(s[1]+1,e,n,i);let d;return i?(l=l===0?l:l+1,d=u,u=l):d=l===n-1?l:l-1,{x:a,y:u,width:Math.max(m-a+1,1),height:Math.max(d-u+1,1)}}function Or(r,e,t){return Math.min(Math.round(r*e),t-1)}function vr(r,e,t,n){return n?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var Vt=class extends A{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;constructor(e,t,n=Vt.defaultProps){super(e,t,n),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth}},v=Vt;g(v,"defaultProps",{...A.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,sampler:{},compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0}),g(v,"COPY_SRC",1),g(v,"COPY_DST",2),g(v,"TEXTURE_BINDING",4),g(v,"STORAGE_BINDING",8),g(v,"RENDER_ATTACHMENT",16);function wr(r,e,t){let n="",i=e.split(/\r?\n/),s=r.slice().sort((a,u)=>a.lineNum-u.lineNum);switch(t?.showSourceCode||"no"){case"all":let a=0;for(let u=1;u<=i.length;u++)for(n+=Wr(i[u-1],u,t);s.length>a&&s[a].lineNum===u;){let l=s[a++];n+=Ur(l,i,l.lineNum,{...t,inlineSource:!1})}return n;case"issues":case"no":for(let u of r)n+=Ur(u,i,u.lineNum,{inlineSource:t?.showSourceCode!=="no"});return n}}function Ur(r,e,t,n){if(n?.inlineSource){let i=Ti(e,t),s=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
7
+ var __exports__=(()=>{var ci=Object.create;var tt=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var di=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var hi=(t,e,r)=>e in t?tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gi=(t,e)=>{for(var r in e)tt(t,r,{get:e[r],enumerable:!0})},Mr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fi(e))!mi.call(t,i)&&i!==r&&tt(t,i,{get:()=>e[i],enumerable:!(n=li(e,i))||n.enumerable});return t};var y=(t,e,r)=>(r=t!=null?ci(di(t)):{},Mr(e||!t||!t.__esModule?tt(r,"default",{value:t,enumerable:!0}):r,t)),Ei=t=>Mr(tt({},"__esModule",{value:!0}),t);var E=(t,e,r)=>(hi(t,typeof e!="symbol"?e+"":e,r),r);var S=pi((Fc,fn)=>{fn.exports=globalThis.luma});var Ts={};gi(Ts,{Accessor:()=>ae,WEBGLBuffer:()=>H,WEBGLCommandEncoder:()=>je,WEBGLFramebuffer:()=>J,WEBGLRenderPass:()=>$e,WEBGLRenderPipeline:()=>ze,WEBGLResource:()=>Se,WEBGLSampler:()=>ce,WEBGLShader:()=>Ke,WEBGLTexture:()=>U,WEBGLTransformFeedback:()=>qe,WEBGLVertexArray:()=>Ee,WebGLCanvasContext:()=>Xe,WebGLDevice:()=>At,WebGLResource:()=>Se,_TEXTURE_FORMATS:()=>ge,_WEBGLRenderbuffer:()=>Rt,convertGLToTextureFormat:()=>Pn,getGLParameters:()=>Me,getShaderLayout:()=>Yt,popContextState:()=>q,pushContextState:()=>te,resetGLParameters:()=>En,setDeviceParameters:()=>Xt,setGLParameters:()=>X,trackContextState:()=>lt,withDeviceParameters:()=>wn,withGLParameters:()=>K});function rt(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function v(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||rt()}var bi=globalThis.self||globalThis.window||globalThis.global,St=globalThis.window||globalThis.self||globalThis.global,_i=globalThis.document||{},xt=globalThis.process||{},Ti=globalThis.console,Wr=globalThis.navigator||{};var yt="4.0.6",Cs=v();var Qt=globalThis;function Ct(t){if(!t&&!v())return"Node";if(rt(t))return"Electron";let e=t||Wr.userAgent||"";if(e.indexOf("Edge")>-1)return"Edge";let r=e.indexOf("MSIE ")!==-1,n=e.indexOf("Trident/")!==-1;return r||n?"IE":Qt.chrome?"Chrome":Qt.safari?"Safari":Qt.mozInnerScreenX?"Firefox":"Unknown"}function Li(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Gt=class{constructor(e,r,n="sessionStorage"){this.storage=Li(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function Hr(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function kr(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}function Pt(t,e,r,n=600){let i=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>n&&(r=Math.min(r,n/t.width));let s=t.width*r,a=t.height*r,c=["font-size:1px;",`padding:${Math.floor(a/2)}px ${Math.floor(s/2)}px;`,`line-height:${a}px;`,`background:url(${i});`,`background-size:${s}px ${a}px;`,"color:transparent;"].join("");return[`${e} %c+`,c]}var Ft;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ft||(Ft={}));var Ai=10;function Vr(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ft[t]||Ft.WHITE)}function Xr(t,e,r){return!v&&typeof t=="string"&&(e&&(t=`\x1B[${Vr(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Vr(r)+Ai}m${t}\x1B[49m`)),t}function Kr(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),i=t;for(let s of n){let a=i[s];typeof a=="function"&&(e.find(c=>s===c)||(i[s]=a.bind(t)))}}function xe(t,e){if(!t)throw new Error(e||"Assertion failed")}function _e(){let t;if(v()&&St.performance)t=St?.performance?.now?.();else if("hrtime"in xt){let e=xt?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var ye={debug:v()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ri={enabled:!0,level:0};function Q(){}var $r={},Yr={once:!0},de=class{constructor({id:e}={id:""}){this.VERSION=yt,this._startTs=_e(),this._deltaTs=_e(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Gt(`__probe-${this.id}__`,Ri),this.timeStamp(`${this.id} started`),Kr(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((_e()-this._startTs).toPrecision(10))}getDelta(){return Number((_e()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){xe(e,r)}warn(e){return this._getLogFunction(0,e,ye.warn,arguments,Yr)}error(e){return this._getLogFunction(0,e,ye.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,ye.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,ye.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,ye.debug||ye.info,arguments,Yr)}table(e,r,n){return r?this._getLogFunction(e,r,console.table||Q,n&&[n],{tag:Ci(r)}):Q}image({logLevel:e,priority:r,image:n,message:i="",scale:s=1}){return this._shouldLog(e||r)?v()?yi({image:n,message:i,scale:s}):xi({image:n,message:i,scale:s}):Q}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||Q)}group(e,r,n={collapsed:!1}){let i=zr({logLevel:e,message:r,opts:n}),{collapsed:s}=n;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Q)}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=jr(e)}_getLogFunction(e,r,n,i,s){if(this._shouldLog(e)){s=zr({logLevel:e,message:r,args:i,opts:s}),n=n||s.method,xe(n),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=_e();let a=s.tag||s.message;if(s.once&&a)if(!$r[a])$r[a]=_e();else return Q;return r=Si(this.id,s.message,s),n.bind(console,r,...s.args)}return Q}};de.VERSION=yt;function jr(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return xe(Number.isFinite(e)&&e>=0),e}function zr(t){let{logLevel:e,message:r}=t;t.logLevel=jr(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let i=typeof t.message;return xe(i==="string"||i==="object"),Object.assign(t,{args:n},t.opts)}function Si(t,e,r){if(typeof e=="string"){let n=r.time?kr(Hr(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=Xr(e,r.color,r.background)}return e}function xi({image:t,message:e="",scale:r=1}){return console.warn("removed"),Q}function yi({image:t,message:e="",scale:r=1}){if(typeof t=="string"){let i=new Image;return i.onload=()=>{let s=Pt(i,e,r);console.log(...s)},i.src=t,Q}let n=t.nodeName||"";if(n.toLowerCase()==="img")return console.log(...Pt(t,e,r)),Q;if(n.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...Pt(i,e,r)),i.src=t.toDataURL(),Q}return Q}function Ci(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var ia=new de({id:"@probe.gl/log"});var f=new de({id:"luma.gl"});function nt(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Te=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=nt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(nt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Ce=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,i=this.stats[r];return i||(e instanceof Te?i=e:i=new Te(r,n),this.stats[r]=i),i}};var qt=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Ce({id:e})),this.stats.get(e)}},Bt=new qt;function Gi(){let t="9.0.0-beta.6",e="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${t}`);return globalThis.luma||(v()&&f.log(1,`${t} - ${e}`)(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:f,stats:Bt}),t}var Qr=Gi();function Pi(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)?t:null}function qr(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number"?t:null:Pi(t)}var Zt={};function ee(t="id"){Zt[t]=Zt[t]||1;let e=Zt[t]++;return`${t}-${e}`}function Ge(t){let e=!0;for(let r in t){e=!1;break}return e}var _=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,r,n){if(!e)throw new Error("no device");this._device=e,this.props=Fi(r,n);let i=this.props.id!=="undefined"?this.props.id:ee(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(e,r=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${r} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${r}s Created`).incrementCount(),e.get(`${r}s Active`).incrementCount()}};E(_,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Fi(t,e){let r={...e};for(let n in t)t[n]!==void 0&&(r[n]=t[n]);return r}var it=class extends _{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let n={...r};(r.usage||0)&it.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?n.indexType="uint32":r.data instanceof Uint16Array&&(n.indexType="uint16")),super(e,n,it.defaultProps),this.usage=r.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}readSyncWebGL(e,r){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,r,n){let i=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:n,it.DEBUG_DATA_MAX_LENGTH);e===null?this.debugData=new ArrayBuffer(s):r===0&&n===e.byteLength?this.debugData=i.slice(0,s):this.debugData=i.slice(r,r+s)}},P=it;E(P,"defaultProps",{..._.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),E(P,"MAP_READ",1),E(P,"MAP_WRITE",2),E(P,"COPY_SRC",4),E(P,"COPY_DST",8),E(P,"INDEX",16),E(P,"VERTEX",32),E(P,"UNIFORM",64),E(P,"STORAGE",128),E(P,"INDIRECT",256),E(P,"QUERY_RESOLVE",512),E(P,"DEBUG_DATA_MAX_LENGTH",32);function It(t){let e=Zr[t],r=Bi(e),n=t.includes("norm"),i=!n&&!t.startsWith("float"),s=t.startsWith("s");return{dataType:Zr[t],byteLength:r,integer:i,signed:s,normalized:n}}function Bi(t){return Ii[t]}var Zr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Ii={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Ni=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Di=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function Jr(t){return Ni.some(e=>t.startsWith(e))}function Nt(t){let e=Di.exec(t);if(e){let[,r,n,i,s,a]=e;if(r){let c=`${i}${n}`,l=It(c);return{format:r,components:r.length,srgb:s==="-srgb",unsized:a==="-unsized",webgl:a==="-webgl",...l}}}return wi(t)}var vi={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function wi(t){let e=vi[t];if(!e)throw new Error(`Unknown format ${t}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var ot=class{},st=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures[e]&&this.features.has(e)}},Jt=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...Jt.defaultProps,...e},this.id=this.props.id||ee(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Bt;_lumaData={};isTextureFormatCompressed(e){return Jr(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};return(e.usage||0)&P.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":f.warn("indices buffer content must be of integer type")()),r}},me=Jt;E(me,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(f.get("debug")),spector:Boolean(f.get("spector")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:e=>f.error(e.message)}),E(me,"VERSION",Qr);function R(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}var Oi=v()&&typeof document<"u",Dt=()=>Oi&&document.readyState==="complete",Ui={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},he=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return Dt()}constructor(e){if(this.props={...Ui,...e},e=this.props,!v()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=Hi(e.canvas):this.canvas=e.canvas;else{let r=ki(e),n=Wi(e?.container||null);n.insertBefore(r,n.firstChild),this.canvas=r,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let n of r)n.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,r]=this.getPixelSize();return e/r}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?e/r:1}catch{return 1}}cssToDevicePixels(e,r=!0){let n=this.cssToDeviceRatio(),[i,s]=this.getDrawingBufferSize();return Vi(e,n,i,s,r)}setDevicePixelRatio(e,r={}){if(!this.htmlCanvas)return;let n="width"in r?r.width:this.htmlCanvas.clientWidth,i="height"in r?r.height:this.htmlCanvas.clientHeight;(!n||!i)&&(f.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==i||s.devicePixelRatio!==e){let a=e,c=Math.floor(n*a),l=Math.floor(i*a);this.htmlCanvas.width=c,this.htmlCanvas.height=l;let[d,m]=this.getDrawingBufferSize();(d!==c||m!==l)&&(a=Math.min(d/n,m/i),this.htmlCanvas.width=Math.floor(n*a),this.htmlCanvas.height=Math.floor(i*a),f.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};E(he,"pageLoaded",Mi());function Mi(){return Dt()||typeof window>"u"?Promise.resolve():new Promise(t=>{window.addEventListener("load",()=>t())})}function Wi(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e&&!Dt())throw new Error(`Accessing '${t}' before page was loaded`);if(!e)throw new Error(`${t} is not an HTML element`);return e}else if(t)return t;return document.body}function Hi(t){let e=document.getElementById(t);if(!e&&!Dt())throw new Error(`Accessing '${t}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function ki(t){let{width:e,height:r}=t,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=e||1,n.height=r||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(r)?`${r}px`:"100%",n}function Vi(t,e,r,n,i){let s=t,a=en(s[0],e,r),c=tn(s[1],e,n,i),l=en(s[0]+1,e,r),d=l===r-1?l:l-1;l=tn(s[1]+1,e,n,i);let m;return i?(l=l===0?l:l+1,m=c,c=l):m=l===n-1?l:l-1,{x:a,y:c,width:Math.max(d-a+1,1),height:Math.max(m-c+1,1)}}function en(t,e,r){return Math.min(Math.round(t*e),r-1)}function tn(t,e,r,n){return n?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var er=class extends _{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,r,n=er.defaultProps){super(e,r,n),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}},I=er;E(I,"defaultProps",{..._.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0}),E(I,"COPY_SRC",1),E(I,"COPY_DST",2),E(I,"TEXTURE_BINDING",4),E(I,"STORAGE_BINDING",8),E(I,"RENDER_ATTACHMENT",16);var tr=class extends _{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,tr.defaultProps)}},Pe=tr;E(Pe,"defaultProps",{..._.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});function nn(t,e,r){let n="",i=e.split(/\r?\n/),s=t.slice().sort((a,c)=>a.lineNum-c.lineNum);switch(r?.showSourceCode||"no"){case"all":let a=0;for(let c=1;c<=i.length;c++)for(n+=on(i[c-1],c,r);s.length>a&&s[a].lineNum===c;){let l=s[a++];n+=rn(l,i,l.lineNum,{...r,inlineSource:!1})}return n;case"issues":case"no":for(let c of t)n+=rn(c,i,c.lineNum,{inlineSource:r?.showSourceCode!=="no"});return n}}function rn(t,e,r,n){if(n?.inlineSource){let i=Xi(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
8
8
  `:"";return`
9
- ${i}${s}${r.type.toUpperCase()}: ${r.message}
9
+ ${i}${s}${t.type.toUpperCase()}: ${t.message}
10
10
 
11
- `}return n?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function Ti(r,e,t){let n="";for(let i=e-2;i<=e;i++){let s=r[i-1];s!==void 0&&(n+=Wr(s,e,t))}return n}function Wr(r,e,t){let n=t?.html?Ri(r):r;return`${Ai(String(e),4)}: ${n}${t?.html?"<br/>":`
12
- `}`}function Ai(r,e){let t="";for(let n=r.length;n<e;++n)t+=" ";return t+r}function Ri(r){return r.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function kt(r,e){return{name:Si(r,e),language:"glsl",version:Li(r)}}function Si(r,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:e}function Li(r){let e=100,t=r.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let n=parseInt(t[1],10);Number.isFinite(n)&&(e=n)}return e}var Kt=class extends A{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:xi(t),...t},Kt.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}async debugShader(){switch(this.props.debug){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let e=await this.getCompilationInfo();this.props.debug==="warnings"&&e?.length===0||this._displayShaderLog(e)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let t=kt(this.source).name,n=`${this.stage} ${t}`,i=wr(e,this.source,{showSourceCode:"all",html:!0}),s=document.createElement("Button");s.innerHTML=`
11
+ `}return n?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function Xi(t,e,r){let n="";for(let i=e-2;i<=e;i++){let s=t[i-1];s!==void 0&&(n+=on(s,e,r))}return n}function on(t,e,r){let n=r?.html?$i(t):t;return`${Ki(String(e),4)}: ${n}${r?.html?"<br/>":`
12
+ `}`}function Ki(t,e){let r="";for(let n=t.length;n<e;++n)r+=" ";return r+t}function $i(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function rr(t,e){return{name:Yi(t,e),language:"glsl",version:zi(t)}}function Yi(t,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return n?n[1]:e}function zi(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let n=parseInt(r[1],10);Number.isFinite(n)&&(e=n)}return e}var nr=class extends _{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){super(e,{id:ji(r),...r},nr.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();this.props.debug==="warnings"&&r?.length===0||this._displayShaderLog(r)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let r=rr(this.source).name,n=`${this.stage} ${r}`,i=nn(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource();s&&(i+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${s}</pre></code>`);let a=document.createElement("Button");a.innerHTML=`
13
13
  <h1>Shader Compilation Error in ${n}</h1><br /><br />
14
14
  <code style="user-select:text;"><pre>
15
15
  ${i}
16
- </pre></code>`,s.style.top="10px",s.style.left="10px",s.style.position="absolute",s.style.zIndex="9999",s.style.width="100%",s.style.textAlign="left",document.body.appendChild(s);let a=document.getElementsByClassName("luma-compiler-log-error");a[0]?.scrollIntoView&&a[0].scrollIntoView(),s.onclick=()=>{let u=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(u)}}},Pe=Kt;g(Pe,"defaultProps",{...A.defaultProps,language:"auto",stage:"vertex",source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function xi(r){return kt(r.source).name||r.id||ee(`unnamed ${r.stage}-shader`)}var Yt=class extends A{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,Yt.defaultProps)}},Ie=Yt;g(Ie,"defaultProps",{...A.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var $t=class extends A{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,t={}){super(e,t,$t.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let t=!e;if(e){let[n,i]=Array.isArray(e)?e:[e.width,e.height];t=t||i!==this.height||n!==this.width,this.width=n,this.height=i}t&&(h.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.colorAttachments=this.props.colorAttachments.map(e=>{if(typeof e=="string"){let t=this.createColorTexture(e);return this.attachResource(t),t}return e}),this.props.depthStencilAttachment)if(typeof this.props.depthStencilAttachment=="string"){let e=this.createDepthStencilTexture(this.props.depthStencilAttachment);this.attachResource(e),this.depthStencilAttachment=e}else this.depthStencilAttachment=this.props.depthStencilAttachment}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:v.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:v.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let i=this.device._createTexture({...this.colorAttachments[n].props,width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=i,this.attachResource(i)}if(this.depthStencilAttachment){let n=this.device._createTexture({...this.depthStencilAttachment.props,width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n,this.attachResource(n)}}},Ee=$t;g(Ee,"defaultProps",{...A.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var zt=class extends A{get[Symbol.toStringTag](){return"RenderPipeline"}hash="";shaderLayout;bufferLayout;linkStatus="pending";constructor(e,t){super(e,t,zt.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}},Be=zt;g(Be,"defaultProps",{...A.defaultProps,vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}});var jt=class extends A{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){super(e,t,jt.defaultProps)}},De=jt;g(De,"defaultProps",{...A.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1});var Zt=class extends A{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Zt.defaultProps)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}},Me=Zt;g(Me,"defaultProps",{...A.defaultProps,measureExecutionTime:void 0});var qt=class extends A{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,qt.defaultProps)}},Oe=qt;g(Oe,"defaultProps",{...A.defaultProps});function Xr(r){let[e,t]=Fi[r],n=e==="i32"||e==="u32",i=e!=="u32",s=yi[e]*t,a=Ci(e,t);return{dataType:e,components:t,defaultVertexFormat:a,byteLength:s,integer:n,signed:i}}function Ci(r,e){let t;switch(r){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?t:`${t}x${e}`}var Fi={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},yi={f32:4,f16:2,i32:4,u32:4};function Ct(r){let e=Hr[r],t=Gi(e),n=r.includes("norm"),i=!n&&!r.startsWith("float"),s=r.startsWith("s");return{dataType:Hr[r],byteLength:t,integer:i,signed:s,normalized:n}}function Gi(r){return Ni[r]}var Hr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Ni={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Qt(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,n]=r.split("x"),i=t,s=n?parseInt(n):1,a=Ct(i),u={type:i,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return e&&(u.webglOnly=!0),u}function Vr(r,e){let t={};for(let n of r.attributes)t[n.name]=Pi(r,e,n.name);return t}function kr(r,e,t=16){let n=Vr(r,e),i=new Array(t).fill(null);for(let s of Object.values(n))i[s.location]=s;return i}function Pi(r,e,t){let n=Ii(r,t),i=Bi(e,t);if(!n)return null;let s=Xr(n.type),a=i?.vertexFormat||s.defaultVertexFormat,u=Qt(a);return{attributeName:i?.attributeName||n.name,bufferName:i?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:a,bufferDataType:u.type,bufferComponents:u.components,normalized:u.normalized,integer:s.integer,stepMode:i?.stepMode||n.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function Ii(r,e){let t=r.attributes.find(n=>n.name===e);return t||h.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Bi(r,e){Di(r);let t=Mi(r,e);return t||(t=Oi(r,e),t)?t:(h.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Di(r){for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&h.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Mi(r,e){for(let t of r)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function Oi(r,e){for(let t of r){let n=t.byteStride;if(typeof t.byteStride!="number")for(let s of t.attributes||[]){let a=Qt(s.format);n+=a.byteLength}let i=t.attributes?.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}function Jt(r,e){let t={...r,attributes:r.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let i=t.attributes.find(s=>s.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):h.warn(`shader layout attribute ${n.name} not present in shader`)}return t}var er=class extends A{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,er.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=kr(t.renderPipeline.shaderLayout,t.renderPipeline.bufferLayout,this.maxVertexAttributes)}},ve=er;g(ve,"defaultProps",{...A.defaultProps,renderPipeline:null});var tr=class extends A{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,tr.defaultProps)}},Ue=tr;g(Ue,"defaultProps",{...A.defaultProps,layout:void 0,buffers:{}});var Ft;function Kr(r){return(!Ft||Ft.byteLength<r)&&(Ft=new ArrayBuffer(r)),Ft}function rr(r,e){let t=Kr(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function nr(r){let{target:e,source:t,start:n=0,count:i=1}=r,s=t.length,a=i*s,u=0;for(let l=n;u<s;u++)e[l++]=t[u];for(;u<a;)u<a-u?(e.copyWithin(n+u,n,n+u),u*=2):(e.copyWithin(n+u,n,n+a-u),u=a);return r.target}var vi=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function yt(r){let e=vi.exec(r);if(e){let[,t,n,i,s,a]=e;if(t){let u=`${i}${n}`,l=Ct(u);return{format:t,components:t.length,srgb:s==="-srgb",unsized:a==="-unsized",webgl:a==="-webgl",...l}}}return wi(r)}var Ui={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2unorm-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function wi(r){let e=Ui[r];if(!e)throw new Error(`Unknown format ${r}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}function Yr(r){return Mr(r)!==null||typeof r=="number"||typeof r=="boolean"}function ir(r){let e={bindings:{},uniforms:{}};return Object.keys(r).forEach(t=>{let n=r[t];Yr(n)?e.uniforms[t]=n:e.bindings[t]=n}),e}function or(r,e,t,n){let i=`See luma.gl ${t} Upgrade Guide at https://luma.gl/docs/upgrade-guide`,s=Object.getPrototypeOf(r);n.forEach(a=>{s.methodName||(s[a]=()=>{throw h.removed(`Calling removed method ${e}.${a}: `,i)(),new Error(a)})})}function sr(r,e,t){let{removedProps:n={},deprecatedProps:i={},replacedProps:s={}}=t;for(let u in n)if(u in e){let m=n[u]?`${r}.${n[u]}`:"N/A";h.removed(`${r}.${u}`,m)()}for(let u in i)if(u in e){let l=i[u];h.deprecated(`${r}.${u}`,`${r}.${l}`)()}let a=null;for(let[u,l]of Object.entries(s))u in e&&(h.deprecated(`${r}.${u}`,`${r}.${l}`)(),a=a||Object.assign({},e),a[l]=e[u],delete a[u]);return a||e}var Wi="";async function ar(r,e){return new Promise((t,n)=>{try{let i=new Image;i.onload=()=>t(i),i.onerror=()=>n(new Error(`Could not load image ${r}.`)),i.crossOrigin=e?.crossOrigin||"anonymous",i.src=r.startsWith("http")?r:Wi+r}catch(i){n(i)}})}async function ot(r,e){let t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",r),e&&(n.id=e),new Promise((i,s)=>{n.onload=i,n.onerror=a=>s(new Error(`Unable to load script '${r}': ${a}`)),t.appendChild(n)})}var o=y(C(),1),at={[o.GL.BLEND]:!1,[o.GL.BLEND_COLOR]:new Float32Array([0,0,0,0]),[o.GL.BLEND_EQUATION_RGB]:o.GL.FUNC_ADD,[o.GL.BLEND_EQUATION_ALPHA]:o.GL.FUNC_ADD,[o.GL.BLEND_SRC_RGB]:o.GL.ONE,[o.GL.BLEND_DST_RGB]:o.GL.ZERO,[o.GL.BLEND_SRC_ALPHA]:o.GL.ONE,[o.GL.BLEND_DST_ALPHA]:o.GL.ZERO,[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([0,0,0,0]),[o.GL.COLOR_WRITEMASK]:[!0,!0,!0,!0],[o.GL.CULL_FACE]:!1,[o.GL.CULL_FACE_MODE]:o.GL.BACK,[o.GL.DEPTH_TEST]:!1,[o.GL.DEPTH_CLEAR_VALUE]:1,[o.GL.DEPTH_FUNC]:o.GL.LESS,[o.GL.DEPTH_RANGE]:new Float32Array([0,1]),[o.GL.DEPTH_WRITEMASK]:!0,[o.GL.DITHER]:!0,[o.GL.CURRENT_PROGRAM]:null,[o.GL.FRAMEBUFFER_BINDING]:null,[o.GL.RENDERBUFFER_BINDING]:null,[o.GL.VERTEX_ARRAY_BINDING]:null,[o.GL.ARRAY_BUFFER_BINDING]:null,[o.GL.FRONT_FACE]:o.GL.CCW,[o.GL.GENERATE_MIPMAP_HINT]:o.GL.DONT_CARE,[o.GL.LINE_WIDTH]:1,[o.GL.POLYGON_OFFSET_FILL]:!1,[o.GL.POLYGON_OFFSET_FACTOR]:0,[o.GL.POLYGON_OFFSET_UNITS]:0,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE_VALUE]:1,[o.GL.SAMPLE_COVERAGE_INVERT]:!1,[o.GL.SCISSOR_TEST]:!1,[o.GL.SCISSOR_BOX]:new Int32Array([0,0,1024,1024]),[o.GL.STENCIL_TEST]:!1,[o.GL.STENCIL_CLEAR_VALUE]:0,[o.GL.STENCIL_WRITEMASK]:4294967295,[o.GL.STENCIL_BACK_WRITEMASK]:4294967295,[o.GL.STENCIL_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_REF]:0,[o.GL.STENCIL_VALUE_MASK]:4294967295,[o.GL.STENCIL_BACK_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_BACK_REF]:0,[o.GL.STENCIL_BACK_VALUE_MASK]:4294967295,[o.GL.STENCIL_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.STENCIL_BACK_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.VIEWPORT]:[0,0,1024,1024],[o.GL.PACK_ALIGNMENT]:4,[o.GL.UNPACK_ALIGNMENT]:4,[o.GL.UNPACK_FLIP_Y_WEBGL]:!1,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:!1,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:o.GL.BROWSER_DEFAULT_WEBGL,[o.GL.TRANSFORM_FEEDBACK_BINDING]:null,[o.GL.COPY_READ_BUFFER_BINDING]:null,[o.GL.COPY_WRITE_BUFFER_BINDING]:null,[o.GL.PIXEL_PACK_BUFFER_BINDING]:null,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:null,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:o.GL.DONT_CARE,[o.GL.READ_FRAMEBUFFER_BINDING]:null,[o.GL.RASTERIZER_DISCARD]:!1,[o.GL.PACK_ROW_LENGTH]:0,[o.GL.PACK_SKIP_PIXELS]:0,[o.GL.PACK_SKIP_ROWS]:0,[o.GL.UNPACK_ROW_LENGTH]:0,[o.GL.UNPACK_IMAGE_HEIGHT]:0,[o.GL.UNPACK_SKIP_PIXELS]:0,[o.GL.UNPACK_SKIP_ROWS]:0,[o.GL.UNPACK_SKIP_IMAGES]:0},ne=(r,e,t)=>e?r.enable(t):r.disable(t),zr=(r,e,t)=>r.hint(t,e),z=(r,e,t)=>r.pixelStorei(t,e),jr=(r,e,t)=>{let n=t===o.GL.FRAMEBUFFER_BINDING?o.GL.DRAW_FRAMEBUFFER:o.GL.READ_FRAMEBUFFER;return r.bindFramebuffer(n,e)},st=(r,e,t)=>{let i={[o.GL.ARRAY_BUFFER_BINDING]:o.GL.ARRAY_BUFFER,[o.GL.COPY_READ_BUFFER_BINDING]:o.GL.COPY_READ_BUFFER,[o.GL.COPY_WRITE_BUFFER_BINDING]:o.GL.COPY_WRITE_BUFFER,[o.GL.PIXEL_PACK_BUFFER_BINDING]:o.GL.PIXEL_PACK_BUFFER,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:o.GL.PIXEL_UNPACK_BUFFER}[t];r.bindBuffer(i,e)};function ur(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}var Zr={[o.GL.BLEND]:ne,[o.GL.BLEND_COLOR]:(r,e)=>r.blendColor(...e),[o.GL.BLEND_EQUATION_RGB]:"blendEquation",[o.GL.BLEND_EQUATION_ALPHA]:"blendEquation",[o.GL.BLEND_SRC_RGB]:"blendFunc",[o.GL.BLEND_DST_RGB]:"blendFunc",[o.GL.BLEND_SRC_ALPHA]:"blendFunc",[o.GL.BLEND_DST_ALPHA]:"blendFunc",[o.GL.COLOR_CLEAR_VALUE]:(r,e)=>r.clearColor(...e),[o.GL.COLOR_WRITEMASK]:(r,e)=>r.colorMask(...e),[o.GL.CULL_FACE]:ne,[o.GL.CULL_FACE_MODE]:(r,e)=>r.cullFace(e),[o.GL.DEPTH_TEST]:ne,[o.GL.DEPTH_CLEAR_VALUE]:(r,e)=>r.clearDepth(e),[o.GL.DEPTH_FUNC]:(r,e)=>r.depthFunc(e),[o.GL.DEPTH_RANGE]:(r,e)=>r.depthRange(...e),[o.GL.DEPTH_WRITEMASK]:(r,e)=>r.depthMask(e),[o.GL.DITHER]:ne,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:zr,[o.GL.CURRENT_PROGRAM]:(r,e)=>r.useProgram(e),[o.GL.RENDERBUFFER_BINDING]:(r,e)=>r.bindRenderbuffer(o.GL.RENDERBUFFER,e),[o.GL.TRANSFORM_FEEDBACK_BINDING]:(r,e)=>r.bindTransformFeedback?.(o.GL.TRANSFORM_FEEDBACK,e),[o.GL.VERTEX_ARRAY_BINDING]:(r,e)=>r.bindVertexArray(e),[o.GL.FRAMEBUFFER_BINDING]:jr,[o.GL.READ_FRAMEBUFFER_BINDING]:jr,[o.GL.ARRAY_BUFFER_BINDING]:st,[o.GL.COPY_READ_BUFFER_BINDING]:st,[o.GL.COPY_WRITE_BUFFER_BINDING]:st,[o.GL.PIXEL_PACK_BUFFER_BINDING]:st,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:st,[o.GL.FRONT_FACE]:(r,e)=>r.frontFace(e),[o.GL.GENERATE_MIPMAP_HINT]:zr,[o.GL.LINE_WIDTH]:(r,e)=>r.lineWidth(e),[o.GL.POLYGON_OFFSET_FILL]:ne,[o.GL.POLYGON_OFFSET_FACTOR]:"polygonOffset",[o.GL.POLYGON_OFFSET_UNITS]:"polygonOffset",[o.GL.RASTERIZER_DISCARD]:ne,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:ne,[o.GL.SAMPLE_COVERAGE]:ne,[o.GL.SAMPLE_COVERAGE_VALUE]:"sampleCoverage",[o.GL.SAMPLE_COVERAGE_INVERT]:"sampleCoverage",[o.GL.SCISSOR_TEST]:ne,[o.GL.SCISSOR_BOX]:(r,e)=>r.scissor(...e),[o.GL.STENCIL_TEST]:ne,[o.GL.STENCIL_CLEAR_VALUE]:(r,e)=>r.clearStencil(e),[o.GL.STENCIL_WRITEMASK]:(r,e)=>r.stencilMaskSeparate(o.GL.FRONT,e),[o.GL.STENCIL_BACK_WRITEMASK]:(r,e)=>r.stencilMaskSeparate(o.GL.BACK,e),[o.GL.STENCIL_FUNC]:"stencilFuncFront",[o.GL.STENCIL_REF]:"stencilFuncFront",[o.GL.STENCIL_VALUE_MASK]:"stencilFuncFront",[o.GL.STENCIL_BACK_FUNC]:"stencilFuncBack",[o.GL.STENCIL_BACK_REF]:"stencilFuncBack",[o.GL.STENCIL_BACK_VALUE_MASK]:"stencilFuncBack",[o.GL.STENCIL_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_PASS]:"stencilOpFront",[o.GL.STENCIL_BACK_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:"stencilOpBack",[o.GL.VIEWPORT]:(r,e)=>r.viewport(...e),[o.GL.PACK_ALIGNMENT]:z,[o.GL.UNPACK_ALIGNMENT]:z,[o.GL.UNPACK_FLIP_Y_WEBGL]:z,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:z,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:z,[o.GL.PACK_ROW_LENGTH]:z,[o.GL.PACK_SKIP_PIXELS]:z,[o.GL.PACK_SKIP_ROWS]:z,[o.GL.UNPACK_ROW_LENGTH]:z,[o.GL.UNPACK_IMAGE_HEIGHT]:z,[o.GL.UNPACK_SKIP_PIXELS]:z,[o.GL.UNPACK_SKIP_ROWS]:z,[o.GL.UNPACK_SKIP_IMAGES]:z,framebuffer:(r,e)=>{let t=e&&"handle"in e?e.handle:e;return r.bindFramebuffer(o.GL.FRAMEBUFFER,t)},blend:(r,e)=>e?r.enable(o.GL.BLEND):r.disable(o.GL.BLEND),blendColor:(r,e)=>r.blendColor(...e),blendEquation:(r,e)=>{let t=typeof e=="number"?[e,e]:e;r.blendEquationSeparate(...t)},blendFunc:(r,e)=>{let t=e?.length===2?[...e,...e]:e;r.blendFuncSeparate(...t)},clearColor:(r,e)=>r.clearColor(...e),clearDepth:(r,e)=>r.clearDepth(e),clearStencil:(r,e)=>r.clearStencil(e),colorMask:(r,e)=>r.colorMask(...e),cull:(r,e)=>e?r.enable(o.GL.CULL_FACE):r.disable(o.GL.CULL_FACE),cullFace:(r,e)=>r.cullFace(e),depthTest:(r,e)=>e?r.enable(o.GL.DEPTH_TEST):r.disable(o.GL.DEPTH_TEST),depthFunc:(r,e)=>r.depthFunc(e),depthMask:(r,e)=>r.depthMask(e),depthRange:(r,e)=>r.depthRange(...e),dither:(r,e)=>e?r.enable(o.GL.DITHER):r.disable(o.GL.DITHER),derivativeHint:(r,e)=>{r.hint(o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT,e)},frontFace:(r,e)=>r.frontFace(e),mipmapHint:(r,e)=>r.hint(o.GL.GENERATE_MIPMAP_HINT,e),lineWidth:(r,e)=>r.lineWidth(e),polygonOffsetFill:(r,e)=>e?r.enable(o.GL.POLYGON_OFFSET_FILL):r.disable(o.GL.POLYGON_OFFSET_FILL),polygonOffset:(r,e)=>r.polygonOffset(...e),sampleCoverage:(r,e)=>r.sampleCoverage(...e),scissorTest:(r,e)=>e?r.enable(o.GL.SCISSOR_TEST):r.disable(o.GL.SCISSOR_TEST),scissor:(r,e)=>r.scissor(...e),stencilTest:(r,e)=>e?r.enable(o.GL.STENCIL_TEST):r.disable(o.GL.STENCIL_TEST),stencilMask:(r,e)=>{e=ur(e)?e:[e,e];let[t,n]=e;r.stencilMaskSeparate(o.GL.FRONT,t),r.stencilMaskSeparate(o.GL.BACK,n)},stencilFunc:(r,e)=>{e=ur(e)&&e.length===3?[...e,...e]:e;let[t,n,i,s,a,u]=e;r.stencilFuncSeparate(o.GL.FRONT,t,n,i),r.stencilFuncSeparate(o.GL.BACK,s,a,u)},stencilOp:(r,e)=>{e=ur(e)&&e.length===3?[...e,...e]:e;let[t,n,i,s,a,u]=e;r.stencilOpSeparate(o.GL.FRONT,t,n,i),r.stencilOpSeparate(o.GL.BACK,s,a,u)},viewport:(r,e)=>r.viewport(...e)};function B(r,e,t){return e[r]!==void 0?e[r]:t[r]}var qr={blendEquation:(r,e,t)=>r.blendEquationSeparate(B(o.GL.BLEND_EQUATION_RGB,e,t),B(o.GL.BLEND_EQUATION_ALPHA,e,t)),blendFunc:(r,e,t)=>r.blendFuncSeparate(B(o.GL.BLEND_SRC_RGB,e,t),B(o.GL.BLEND_DST_RGB,e,t),B(o.GL.BLEND_SRC_ALPHA,e,t),B(o.GL.BLEND_DST_ALPHA,e,t)),polygonOffset:(r,e,t)=>r.polygonOffset(B(o.GL.POLYGON_OFFSET_FACTOR,e,t),B(o.GL.POLYGON_OFFSET_UNITS,e,t)),sampleCoverage:(r,e,t)=>r.sampleCoverage(B(o.GL.SAMPLE_COVERAGE_VALUE,e,t),B(o.GL.SAMPLE_COVERAGE_INVERT,e,t)),stencilFuncFront:(r,e,t)=>r.stencilFuncSeparate(o.GL.FRONT,B(o.GL.STENCIL_FUNC,e,t),B(o.GL.STENCIL_REF,e,t),B(o.GL.STENCIL_VALUE_MASK,e,t)),stencilFuncBack:(r,e,t)=>r.stencilFuncSeparate(o.GL.BACK,B(o.GL.STENCIL_BACK_FUNC,e,t),B(o.GL.STENCIL_BACK_REF,e,t),B(o.GL.STENCIL_BACK_VALUE_MASK,e,t)),stencilOpFront:(r,e,t)=>r.stencilOpSeparate(o.GL.FRONT,B(o.GL.STENCIL_FAIL,e,t),B(o.GL.STENCIL_PASS_DEPTH_FAIL,e,t),B(o.GL.STENCIL_PASS_DEPTH_PASS,e,t)),stencilOpBack:(r,e,t)=>r.stencilOpSeparate(o.GL.BACK,B(o.GL.STENCIL_BACK_FAIL,e,t),B(o.GL.STENCIL_BACK_PASS_DEPTH_FAIL,e,t),B(o.GL.STENCIL_BACK_PASS_DEPTH_PASS,e,t))},cr={enable:(r,e)=>r({[e]:!0}),disable:(r,e)=>r({[e]:!1}),pixelStorei:(r,e,t)=>r({[e]:t}),hint:(r,e,t)=>r({[e]:t}),useProgram:(r,e)=>r({[o.GL.CURRENT_PROGRAM]:e}),bindRenderbuffer:(r,e,t)=>r({[o.GL.RENDERBUFFER_BINDING]:t}),bindTransformFeedback:(r,e,t)=>r({[o.GL.TRANSFORM_FEEDBACK_BINDING]:t}),bindVertexArray:(r,e)=>r({[o.GL.VERTEX_ARRAY_BINDING]:e}),bindFramebuffer:(r,e,t)=>{switch(e){case o.GL.FRAMEBUFFER:return r({[o.GL.DRAW_FRAMEBUFFER_BINDING]:t,[o.GL.READ_FRAMEBUFFER_BINDING]:t});case o.GL.DRAW_FRAMEBUFFER:return r({[o.GL.DRAW_FRAMEBUFFER_BINDING]:t});case o.GL.READ_FRAMEBUFFER:return r({[o.GL.READ_FRAMEBUFFER_BINDING]:t});default:return null}},bindBuffer:(r,e,t)=>{let n={[o.GL.ARRAY_BUFFER]:[o.GL.ARRAY_BUFFER_BINDING],[o.GL.COPY_READ_BUFFER]:[o.GL.COPY_READ_BUFFER_BINDING],[o.GL.COPY_WRITE_BUFFER]:[o.GL.COPY_WRITE_BUFFER_BINDING],[o.GL.PIXEL_PACK_BUFFER]:[o.GL.PIXEL_PACK_BUFFER_BINDING],[o.GL.PIXEL_UNPACK_BUFFER]:[o.GL.PIXEL_UNPACK_BUFFER_BINDING]}[e];return n?r({[n]:t}):{valueChanged:!0}},blendColor:(r,e,t,n,i)=>r({[o.GL.BLEND_COLOR]:new Float32Array([e,t,n,i])}),blendEquation:(r,e)=>r({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:e}),blendEquationSeparate:(r,e,t)=>r({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:t}),blendFunc:(r,e,t)=>r({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:t,[o.GL.BLEND_SRC_ALPHA]:e,[o.GL.BLEND_DST_ALPHA]:t}),blendFuncSeparate:(r,e,t,n,i)=>r({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:t,[o.GL.BLEND_SRC_ALPHA]:n,[o.GL.BLEND_DST_ALPHA]:i}),clearColor:(r,e,t,n,i)=>r({[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([e,t,n,i])}),clearDepth:(r,e)=>r({[o.GL.DEPTH_CLEAR_VALUE]:e}),clearStencil:(r,e)=>r({[o.GL.STENCIL_CLEAR_VALUE]:e}),colorMask:(r,e,t,n,i)=>r({[o.GL.COLOR_WRITEMASK]:[e,t,n,i]}),cullFace:(r,e)=>r({[o.GL.CULL_FACE_MODE]:e}),depthFunc:(r,e)=>r({[o.GL.DEPTH_FUNC]:e}),depthRange:(r,e,t)=>r({[o.GL.DEPTH_RANGE]:new Float32Array([e,t])}),depthMask:(r,e)=>r({[o.GL.DEPTH_WRITEMASK]:e}),frontFace:(r,e)=>r({[o.GL.FRONT_FACE]:e}),lineWidth:(r,e)=>r({[o.GL.LINE_WIDTH]:e}),polygonOffset:(r,e,t)=>r({[o.GL.POLYGON_OFFSET_FACTOR]:e,[o.GL.POLYGON_OFFSET_UNITS]:t}),sampleCoverage:(r,e,t)=>r({[o.GL.SAMPLE_COVERAGE_VALUE]:e,[o.GL.SAMPLE_COVERAGE_INVERT]:t}),scissor:(r,e,t,n,i)=>r({[o.GL.SCISSOR_BOX]:new Int32Array([e,t,n,i])}),stencilMask:(r,e)=>r({[o.GL.STENCIL_WRITEMASK]:e,[o.GL.STENCIL_BACK_WRITEMASK]:e}),stencilMaskSeparate:(r,e,t)=>r({[e===o.GL.FRONT?o.GL.STENCIL_WRITEMASK:o.GL.STENCIL_BACK_WRITEMASK]:t}),stencilFunc:(r,e,t,n)=>r({[o.GL.STENCIL_FUNC]:e,[o.GL.STENCIL_REF]:t,[o.GL.STENCIL_VALUE_MASK]:n,[o.GL.STENCIL_BACK_FUNC]:e,[o.GL.STENCIL_BACK_REF]:t,[o.GL.STENCIL_BACK_VALUE_MASK]:n}),stencilFuncSeparate:(r,e,t,n,i)=>r({[e===o.GL.FRONT?o.GL.STENCIL_FUNC:o.GL.STENCIL_BACK_FUNC]:t,[e===o.GL.FRONT?o.GL.STENCIL_REF:o.GL.STENCIL_BACK_REF]:n,[e===o.GL.FRONT?o.GL.STENCIL_VALUE_MASK:o.GL.STENCIL_BACK_VALUE_MASK]:i}),stencilOp:(r,e,t,n)=>r({[o.GL.STENCIL_FAIL]:e,[o.GL.STENCIL_PASS_DEPTH_FAIL]:t,[o.GL.STENCIL_PASS_DEPTH_PASS]:n,[o.GL.STENCIL_BACK_FAIL]:e,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:t,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:n}),stencilOpSeparate:(r,e,t,n,i)=>r({[e===o.GL.FRONT?o.GL.STENCIL_FAIL:o.GL.STENCIL_BACK_FAIL]:t,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_FAIL:o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:n,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_PASS:o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:i}),viewport:(r,e,t,n,i)=>r({[o.GL.VIEWPORT]:[e,t,n,i]})},ie=(r,e)=>r.isEnabled(e),lr={[o.GL.BLEND]:ie,[o.GL.CULL_FACE]:ie,[o.GL.DEPTH_TEST]:ie,[o.GL.DITHER]:ie,[o.GL.POLYGON_OFFSET_FILL]:ie,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:ie,[o.GL.SAMPLE_COVERAGE]:ie,[o.GL.SCISSOR_TEST]:ie,[o.GL.STENCIL_TEST]:ie,[o.GL.RASTERIZER_DISCARD]:ie},Qr=new Set([o.GL.ACTIVE_TEXTURE,o.GL.TRANSFORM_FEEDBACK_ACTIVE,o.GL.TRANSFORM_FEEDBACK_PAUSED,o.GL.TRANSFORM_FEEDBACK_BUFFER_BINDING,o.GL.UNIFORM_BUFFER_BINDING,o.GL.ELEMENT_ARRAY_BUFFER_BINDING,o.GL.IMPLEMENTATION_COLOR_READ_FORMAT,o.GL.IMPLEMENTATION_COLOR_READ_TYPE,o.GL.READ_BUFFER,o.GL.DRAW_BUFFER0,o.GL.DRAW_BUFFER1,o.GL.DRAW_BUFFER2,o.GL.DRAW_BUFFER3,o.GL.DRAW_BUFFER4,o.GL.DRAW_BUFFER5,o.GL.DRAW_BUFFER6,o.GL.DRAW_BUFFER7,o.GL.DRAW_BUFFER8,o.GL.DRAW_BUFFER9,o.GL.DRAW_BUFFER10,o.GL.DRAW_BUFFER11,o.GL.DRAW_BUFFER12,o.GL.DRAW_BUFFER13,o.GL.DRAW_BUFFER14,o.GL.DRAW_BUFFER15,o.GL.SAMPLER_BINDING,o.GL.TEXTURE_BINDING_2D,o.GL.TEXTURE_BINDING_2D_ARRAY,o.GL.TEXTURE_BINDING_3D,o.GL.TEXTURE_BINDING_CUBE_MAP]);function k(r,e){let n=K.attach(r).gl;if(Xi(e))return;let i={};for(let a in e){let u=Number(a),l=Zr[a];l&&(typeof l=="string"?i[l]=!0:l(n,e[a],u))}let s=n.state&&n.state.cache;if(s)for(let a in i){let u=qr[a];u(n,e,s)}}function we(r,e=at){let n=K.attach(r).gl;if(typeof e=="number"){let a=e,u=lr[a];return u?u(n,a):n.getParameter(a)}let i=Array.isArray(e)?e:Object.keys(e),s={};for(let a of i){let u=lr[a];s[a]=u?u(n,Number(a)):n.getParameter(Number(a))}return s}function Jr(r){k(r,at)}function Xi(r){for(let e in r)return!1;return!0}function en(r,e){if(r===e)return!0;let t=Array.isArray(r)||ArrayBuffer.isView(r),n=Array.isArray(e)||ArrayBuffer.isView(e);if(t&&n&&r.length===e.length){for(let i=0;i<r.length;++i)if(r[i]!==e[i])return!1;return!0}return!1}var fr=class{gl;program=null;stateStack=[];enable=!0;cache;log;constructor(e,{copyState:t=!1,log:n=()=>{}}={}){this.gl=e,this.cache=t?we(e):Object.assign({},at),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){S(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];k(this.gl,e),this.stateStack.pop()}_updateCache(e){let t=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){S(s!==void 0);let a=e[s],u=this.cache[s];en(a,u)||(t=!0,n=u,i&&!(s in i)&&(i[s]=u),this.cache[s]=a)}return{valueChanged:t,oldValue:n}}};function Ae(r){return r.state}function ut(r,e){let{enable:t=!0,copyState:n}=e;if(S(n!==void 0),!r.state){r.state=new fr(r,{copyState:n}),Vi(r);for(let s in cr){let a=cr[s];Hi(r,s,a)}tn(r,"getParameter"),tn(r,"isEnabled")}let i=Ae(r);return i.enable=t,r}function te(r){let e=Ae(r);e||(ut(r,{copyState:!1}),e=Ae(r)),e.push()}function Q(r){let e=Ae(r);S(e),e.pop()}function tn(r,e){let t=r[e].bind(r);r[e]=function(i){if(i===void 0||Qr.has(i))return t(i);let s=Ae(r);return i in s.cache||(s.cache[i]=t(i)),s.enable?s.cache[i]:t(i)},Object.defineProperty(r[e],"name",{value:`${e}-from-cache`,configurable:!1})}function Hi(r,e,t){if(!r[e])return;let n=r[e].bind(r);r[e]=function(...s){let a=Ae(r),{valueChanged:u,oldValue:l}=t(a._updateCache,...s);return u&&n(...s),l},Object.defineProperty(r[e],"name",{value:`${e}-to-cache`,configurable:!1})}function Vi(r){let e=r.useProgram.bind(r);r.useProgram=function(n){let i=Ae(r);i.program!==n&&(e(n),i.program=n)}}var ki={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function rn(r,e){e={...ki,...e};let t=null,n=s=>t=s.statusMessage||t;r.addEventListener("webglcontextcreationerror",n,!1);let i=null;if(i||=r.getContext("webgl2",e),r.removeEventListener("webglcontextcreationerror",n,!1),!i)throw new Error(`Failed to create WebGL context: ${t||"Unknown error"}`);if(e.onContextLost){let{onContextLost:s}=e;r.addEventListener("webglcontextlost",a=>s(a),!1)}if(e.onContextRestored){let{onContextRestored:s}=e;r.addEventListener("webglcontextrestored",a=>s(a),!1)}return i}var We=y(C(),1);function nn(r){let e=r.getParameter(We.GL.VENDOR),t=r.getParameter(We.GL.RENDERER),n=r.getExtension("WEBGL_debug_renderer_info"),i=r.getParameter(n?n.UNMASKED_VENDOR_WEBGL:We.GL.VENDOR),s=r.getParameter(n?n.UNMASKED_RENDERER_WEBGL:We.GL.RENDERER),a=i||e,u=s||t,l=r.getParameter(We.GL.VERSION),m=on(a,u),d=Ki(a,u),p=Yi(a,u);return{type:"webgl",gpu:m,gpuType:p,gpuBackend:d,vendor:a,renderer:u,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function on(r,e){return/NVIDIA/i.exec(r)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(r)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(r)||/Apple/i.exec(e)?"apple":/AMD/i.exec(r)||/AMD/i.exec(e)||/ATI/i.exec(r)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e)?"software":"unknown"}function Ki(r,e){return/Metal/i.exec(r)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(e)?"opengl":"unknown"}function Yi(r,e){if(/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e))return"cpu";switch(on(r,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var c=y(C(),1);var j=y(C(),1);function Gt(r){switch(r){case"uint8":return j.GL.UNSIGNED_BYTE;case"sint8":return j.GL.BYTE;case"unorm8":return j.GL.UNSIGNED_BYTE;case"snorm8":return j.GL.BYTE;case"uint16":return j.GL.UNSIGNED_SHORT;case"sint16":return j.GL.SHORT;case"unorm16":return j.GL.UNSIGNED_SHORT;case"snorm16":return j.GL.SHORT;case"uint32":return j.GL.UNSIGNED_INT;case"sint32":return j.GL.INT;case"float16":return j.GL.HALF_FLOAT;case"float32":return j.GL.FLOAT}throw new Error(String(r))}var w="texture-compression-bc",F="texture-compression-astc",oe="texture-compression-etc2",$i="texture-compression-etc1-webgl",Nt="texture-compression-pvrtc-webgl",dr="texture-compression-atc-webgl",ct="WEBGL_compressed_texture_s3tc",lt="WEBGL_compressed_texture_s3tc_srgb",Xe="EXT_texture_compression_rgtc",He="EXT_texture_compression_bptc",zi="WEBGL_compressed_texture_etc",ji="WEBGL_compressed_texture_astc",Zi="WEBGL_compressed_texture_etc1",qi="WEBGL_compressed_texture_pvrtc",Qi="WEBGL_compressed_texture_atc",ue="EXT_texture_norm16",Ji="EXT_color_buffer_float",sn={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"norm16-renderable-webgl":[ue],"float32-filterable-linear-webgl":["OES_texture_float_linear"],"float16-filterable-linear-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[ct,lt,Xe,He],"texture-compression-bc5-webgl":[Xe],"texture-compression-bc7-webgl":[He],"texture-compression-etc2":[zi],"texture-compression-astc":[ji],"texture-compression-etc1-webgl":[Zi],"texture-compression-pvrtc-webgl":[qi],"texture-compression-atc-webgl":[Qi]};function eo(r,e){return(sn[e]||[]).every(n=>r.getExtension(n))}function an(r){return Object.keys(sn).filter(t=>eo(r,t))}var Re={"rgb8unorm-unsized":{gl:c.GL.RGB,b:4,c:2,bpp:4,dataFormat:c.GL.RGB,types:[c.GL.UNSIGNED_BYTE,c.GL.UNSIGNED_SHORT_5_6_5]},"rgba8unorm-unsized":{gl:c.GL.RGBA,b:4,c:2,bpp:4,dataFormat:c.GL.RGBA,types:[c.GL.UNSIGNED_BYTE,c.GL.UNSIGNED_SHORT_4_4_4_4,c.GL.UNSIGNED_SHORT_5_5_5_1]},r8unorm:{gl:c.GL.R8,b:1,c:1,renderbuffer:!0},r8snorm:{gl:c.GL.R8_SNORM,b:1,c:1},r8uint:{gl:c.GL.R8UI,b:1,c:1,renderbuffer:!0},r8sint:{gl:c.GL.R8I,b:1,c:1,renderbuffer:!0},rg8unorm:{gl:c.GL.RG8,b:2,c:2,renderbuffer:!0},rg8snorm:{gl:c.GL.RG8_SNORM,b:2,c:2},rg8uint:{gl:c.GL.RG8UI,b:2,c:2,renderbuffer:!0},rg8sint:{gl:c.GL.RG8I,b:2,c:2,renderbuffer:!0},r16uint:{gl:c.GL.R16UI,b:2,c:1,renderbuffer:!0},r16sint:{gl:c.GL.R16I,b:2,c:1,renderbuffer:!0},r16float:{gl:c.GL.R16F,b:2,c:1,render:"float16-renderable-webgl",filter:"float16-filterable-linear-webgl",renderbuffer:!0},"r16unorm-webgl":{gl:c.GL.R16_EXT,b:2,c:1,f:"norm16-renderable-webgl",renderbuffer:!0,x:ue},"r16snorm-webgl":{gl:c.GL.R16_SNORM_EXT,b:2,c:1,f:"norm16-renderable-webgl",x:ue},"rgba4unorm-webgl":{gl:c.GL.RGBA4,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb565unorm-webgl":{gl:c.GL.RGB565,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb5a1unorm-webgl":{gl:c.GL.RGB5_A1,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb8unorm-webgl":{gl:c.GL.RGB8,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:c.GL.RGB8_SNORM,b:3,c:3,wgpu:!1},rgba8unorm:{gl:c.GL.RGBA8,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:c.GL.SRGB8_ALPHA8,b:4,c:4,bpp:4},rgba8snorm:{gl:c.GL.RGBA8_SNORM,b:4,c:4},rgba8uint:{gl:c.GL.RGBA8UI,b:4,c:4,bpp:4},rgba8sint:{gl:c.GL.RGBA8I,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:c.GL.RG16UI,b:4,c:1,bpp:4},rg16sint:{gl:c.GL.RG16I,b:4,c:2,bpp:4},rg16float:{gl:c.GL.RG16F,bpp:4,b:4,c:2,render:"float16-renderable-webgl",filter:"float16-filterable-linear-webgl",renderbuffer:!0},"rg16unorm-webgl":{gl:c.GL.RG16_EXT,b:2,c:2,f:"norm16-renderable-webgl",x:ue},"rg16snorm-webgl":{gl:c.GL.RG16_SNORM_EXT,b:2,c:2,f:"norm16-renderable-webgl",x:ue},r32uint:{gl:c.GL.R32UI,b:4,c:1,bpp:4,renderbuffer:!0},r32sint:{gl:c.GL.R32I,b:4,c:1,bpp:4,renderbuffer:!0},r32float:{gl:c.GL.R32F,bpp:4,b:4,c:1,render:"float32-renderable-webgl",filter:"float32-filterable-linear-webgl"},rgb9e5ufloat:{gl:c.GL.RGB9_E5,b:4,c:3,p:1,render:"float16-renderable-webgl",filter:"float16-filterable-linear-webgl"},rg11b10ufloat:{gl:c.GL.R11F_G11F_B10F,b:4,c:3,p:1,render:"float32-renderable-webgl",renderbuffer:!0},rgb10a2unorm:{gl:c.GL.RGB10_A2,b:4,c:4,p:1,renderbuffer:!0},"rgb10a2unorm-webgl":{b:4,c:4,gl:c.GL.RGB10_A2UI,p:1,wgpu:!1,bpp:4,renderbuffer:!0},"rgb16unorm-webgl":{gl:c.GL.RGB16_EXT,b:2,c:3,f:"norm16-renderable-webgl",x:ue},"rgb16snorm-webgl":{gl:c.GL.RGB16_SNORM_EXT,b:2,c:3,f:"norm16-renderable-webgl",x:ue},rg32uint:{gl:c.GL.RG32UI,b:8,c:2,renderbuffer:!0},rg32sint:{gl:c.GL.RG32I,b:8,c:2,renderbuffer:!0},rg32float:{gl:c.GL.RG32F,b:8,c:2,render:"float32-renderable-webgl",filter:"float32-filterable-linear-webgl",renderbuffer:!0},rgba16uint:{gl:c.GL.RGBA16UI,b:8,c:4,renderbuffer:!0},rgba16sint:{gl:c.GL.RGBA16I,b:8,c:4,renderbuffer:!0},rgba16float:{gl:c.GL.RGBA16F,b:8,c:4,render:"float16-renderable-webgl",filter:"float16-filterable-linear-webgl"},"rgba16unorm-webgl":{gl:c.GL.RGBA16_EXT,b:2,c:4,f:"norm16-renderable-webgl",renderbuffer:!0,x:ue},"rgba16snorm-webgl":{gl:c.GL.RGBA16_SNORM_EXT,b:2,c:4,f:"norm16-renderable-webgl",x:ue},"rgb32float-webgl":{gl:c.GL.RGB32F,render:"float32-renderable-webgl",filter:"float32-filterable-linear-webgl",gl2ext:Ji,dataFormat:c.GL.RGB,types:[c.GL.FLOAT]},rgba32uint:{gl:c.GL.RGBA32UI,b:16,c:4,renderbuffer:!0},rgba32sint:{gl:c.GL.RGBA32I,b:16,c:4,renderbuffer:!0},rgba32float:{gl:c.GL.RGBA32F,b:16,c:4,render:"float32-renderable-webgl",filter:"float32-filterable-linear-webgl",renderbuffer:!0},stencil8:{gl:c.GL.STENCIL_INDEX8,b:1,c:1,attachment:c.GL.STENCIL_ATTACHMENT,renderbuffer:!0},depth16unorm:{gl:c.GL.DEPTH_COMPONENT16,b:2,c:1,attachment:c.GL.DEPTH_ATTACHMENT,renderbuffer:!0},depth24plus:{gl:c.GL.DEPTH_COMPONENT24,b:3,c:1,attachment:c.GL.DEPTH_ATTACHMENT},depth32float:{gl:c.GL.DEPTH_COMPONENT32F,b:4,c:1,attachment:c.GL.DEPTH_ATTACHMENT,renderbuffer:!0},"depth24plus-stencil8":{gl:c.GL.DEPTH_STENCIL,b:4,c:2,p:1,attachment:c.GL.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0,depthTexture:!0},"depth24unorm-stencil8":{gl:c.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:c.GL.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0},"depth32float-stencil8":{gl:c.GL.DEPTH32F_STENCIL8,b:5,c:2,p:1,attachment:c.GL.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0},"bc1-rgb-unorm-webgl":{gl:c.GL.COMPRESSED_RGB_S3TC_DXT1_EXT,x:ct,f:w},"bc1-rgb-unorm-srgb-webgl":{gl:c.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:lt,f:w},"bc1-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_S3TC_DXT1_EXT,x:ct,f:w},"bc1-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:lt,f:w},"bc2-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_S3TC_DXT3_EXT,x:ct,f:w},"bc2-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,x:lt,f:w},"bc3-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_S3TC_DXT5_EXT,x:ct,f:w},"bc3-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,x:lt,f:w},"bc4-r-unorm":{gl:c.GL.COMPRESSED_RED_RGTC1_EXT,x:Xe,f:w},"bc4-r-snorm":{gl:c.GL.COMPRESSED_SIGNED_RED_RGTC1_EXT,x:Xe,f:w},"bc5-rg-unorm":{gl:c.GL.COMPRESSED_RED_GREEN_RGTC2_EXT,x:Xe,f:w},"bc5-rg-snorm":{gl:c.GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,x:Xe,f:w},"bc6h-rgb-ufloat":{gl:c.GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,x:He,f:w},"bc6h-rgb-float":{gl:c.GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,x:He,f:w},"bc7-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_BPTC_UNORM_EXT,x:He,f:w},"bc7-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,x:He,f:w},"etc2-rgb8unorm":{gl:c.GL.COMPRESSED_RGB8_ETC2,f:oe},"etc2-rgb8unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ETC2,f:oe},"etc2-rgb8a1unorm":{gl:c.GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgb8a1unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgba8unorm":{gl:c.GL.COMPRESSED_RGBA8_ETC2_EAC,f:oe},"etc2-rgba8unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,f:oe},"eac-r11unorm":{gl:c.GL.COMPRESSED_R11_EAC,f:oe},"eac-r11snorm":{gl:c.GL.COMPRESSED_SIGNED_R11_EAC,f:oe},"eac-rg11unorm":{gl:c.GL.COMPRESSED_RG11_EAC,f:oe},"eac-rg11snorm":{gl:c.GL.COMPRESSED_SIGNED_RG11_EAC,f:oe},"astc-4x4-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_4x4_KHR,f:F},"astc-4x4-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,f:F},"astc-5x4-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_5x4_KHR,f:F},"astc-5x4-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,f:F},"astc-5x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_5x5_KHR,f:F},"astc-5x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,f:F},"astc-6x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_6x5_KHR,f:F},"astc-6x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,f:F},"astc-6x6-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_6x6_KHR,f:F},"astc-6x6-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,f:F},"astc-8x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_8x5_KHR,f:F},"astc-8x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,f:F},"astc-8x6-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_8x6_KHR,f:F},"astc-8x6-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,f:F},"astc-8x8-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_8x8_KHR,f:F},"astc-8x8-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,f:F},"astc-10x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:F},"astc-10x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:F},"astc-10x6-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x6_KHR,f:F},"astc-10x6-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,f:F},"astc-10x8-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x8_KHR,f:F},"astc-10x8-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,f:F},"astc-10x10-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:F},"astc-10x10-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:F},"astc-12x10-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_12x10_KHR,f:F},"astc-12x10-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,f:F},"astc-12x12-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_12x12_KHR,f:F},"astc-12x12-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,f:F},"pvrtc-rgb4unorm-webgl":{gl:c.GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,f:Nt},"pvrtc-rgba4unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,f:Nt},"pvrtc-rbg2unorm-webgl":{gl:c.GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,f:Nt},"pvrtc-rgba2unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,f:Nt},"etc1-rbg-unorm-webgl":{gl:c.GL.COMPRESSED_RGB_ETC1_WEBGL,f:$i},"atc-rgb-unorm-webgl":{gl:c.GL.COMPRESSED_RGB_ATC_WEBGL,f:dr},"atc-rgba-unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,f:dr},"atc-rgbai-unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,f:dr}},to={[c.GL.RED]:1,[c.GL.RED_INTEGER]:1,[c.GL.RG]:2,[c.GL.RG_INTEGER]:2,[c.GL.RGB]:3,[c.GL.RGB_INTEGER]:3,[c.GL.RGBA]:4,[c.GL.RGBA_INTEGER]:4,[c.GL.DEPTH_COMPONENT]:1,[c.GL.DEPTH_STENCIL]:1,[c.GL.ALPHA]:1,[c.GL.LUMINANCE]:1,[c.GL.LUMINANCE_ALPHA]:2},ro={[c.GL.FLOAT]:4,[c.GL.UNSIGNED_INT]:4,[c.GL.INT]:4,[c.GL.UNSIGNED_SHORT]:2,[c.GL.SHORT]:2,[c.GL.HALF_FLOAT]:2,[c.GL.BYTE]:1,[c.GL.UNSIGNED_BYTE]:1};function ft(r,e){let t=Se(e),n=Re[t];if(!n||n.gl===void 0)return!1;let i=n.x||n.gl2ext;return i?Boolean(r.getExtension(i)):!0}function un(r,e){return ft(r,e)&&Re[e]?.renderbuffer}function Se(r){if(typeof r=="string")return r;let e=Object.entries(Re).find(([,t])=>t.gl===r);if(!e)throw new Error(`Unknown texture format ${r}`);return e[0]}function dt(r){let t=Re[r]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${r}`);return t}function cn(r,e){let t=Se(e);if(!ft(r,t))return!1;try{if(yt(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(r.getExtension("OES_texture_float_linear")):t.endsWith("16float")?Boolean(r.getExtension("OES_texture_half_float_linear")):!0}function ln(r,e){let t=Se(e);return!(!ft(r,t)||typeof t=="number")}function Ve(r){let e=Se(r),t=dt(e),n=yt(e);return{format:t,dataFormat:no(n.format,n.integer,n.normalized,t),type:n.dataType?Gt(n.dataType):c.GL.UNSIGNED_BYTE,compressed:n.compressed}}function fn(r){let e=Re[r];if(!e?.attachment)throw new Error(`${r} is not a depth stencil format`);return e.attachment}function mt(r){let e=Se(r),t=Ve(e),n=to[t.dataFormat]||4,i=ro[t.type]||1;return n*i}function no(r,e,t,n){if(n===c.GL.RGBA||n===c.GL.RGB)return n;switch(r){case"r":return e&&!t?c.GL.RED_INTEGER:c.GL.RED;case"rg":return e&&!t?c.GL.RG_INTEGER:c.GL.RG;case"rgb":return e&&!t?c.GL.RGB_INTEGER:c.GL.RGB;case"rgba":return e&&!t?c.GL.RGBA_INTEGER:c.GL.RGBA;default:return c.GL.RGBA}}function dn(r){let e=io(r);for(let t of an(r))e.add(t);return e}function io(r){r.getExtension("EXT_color_buffer_float");let e=new Set;for(let t of Object.keys(mn))oo(r,t)&&e.add(t);return e}function oo(r,e){let t=mn[e];return Boolean(typeof t=="string"?r.getExtension(t):t)}var mn={webgl:!0,glsl:!0,"uniforms-webgl":!0,"transform-feedback-webgl":!0,"constant-attributes-webgl":!0,"timer-query-webgl":"EXT_disjoint_timer_query_webgl2","shader-status-async-webgl":"KHR_parallel_shader_compile"};var f=y(C(),1);function hn(r){return{maxTextureDimension1D:0,maxTextureDimension2D:r.getParameter(f.GL.MAX_TEXTURE_SIZE),maxTextureDimension3D:r.getParameter(f.GL.MAX_3D_TEXTURE_SIZE),maxTextureArrayLayers:r.getParameter(f.GL.MAX_ARRAY_TEXTURE_LAYERS),maxBindGroups:1,maxDynamicUniformBuffersPerPipelineLayout:0,maxDynamicStorageBuffersPerPipelineLayout:0,maxSampledTexturesPerShaderStage:r.getParameter(f.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxSamplersPerShaderStage:r.getParameter(f.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxStorageBuffersPerShaderStage:0,maxStorageTexturesPerShaderStage:0,maxUniformBuffersPerShaderStage:r.getParameter(f.GL.MAX_UNIFORM_BUFFER_BINDINGS),maxUniformBufferBindingSize:r.getParameter(f.GL.MAX_UNIFORM_BLOCK_SIZE),maxStorageBufferBindingSize:0,minUniformBufferOffsetAlignment:r.getParameter(f.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT),minStorageBufferOffsetAlignment:0,maxVertexBuffers:0,maxVertexAttributes:r.getParameter(f.GL.MAX_VERTEX_ATTRIBS),maxVertexBufferArrayStride:2048,maxInterStageShaderComponents:r.getParameter(f.GL.MAX_VARYING_COMPONENTS),maxComputeWorkgroupStorageSize:0,maxComputeInvocationsPerWorkgroup:0,maxComputeWorkgroupSizeX:0,maxComputeWorkgroupSizeY:0,maxComputeWorkgroupSizeZ:0,maxComputeWorkgroupsPerDimension:0}}function En(r){function e(n){return r.getParameter(n)}function t(n,i){return r.getParameter(n)||i}return{[f.GL.ALIASED_LINE_WIDTH_RANGE]:e(f.GL.ALIASED_LINE_WIDTH_RANGE),[f.GL.ALIASED_POINT_SIZE_RANGE]:e(f.GL.ALIASED_POINT_SIZE_RANGE),[f.GL.MAX_TEXTURE_SIZE]:e(f.GL.MAX_TEXTURE_SIZE),[f.GL.MAX_CUBE_MAP_TEXTURE_SIZE]:e(f.GL.MAX_CUBE_MAP_TEXTURE_SIZE),[f.GL.MAX_TEXTURE_IMAGE_UNITS]:e(f.GL.MAX_TEXTURE_IMAGE_UNITS),[f.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]:e(f.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),[f.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]:e(f.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),[f.GL.MAX_RENDERBUFFER_SIZE]:e(f.GL.MAX_RENDERBUFFER_SIZE),[f.GL.MAX_VARYING_VECTORS]:e(f.GL.MAX_VARYING_VECTORS),[f.GL.MAX_VERTEX_ATTRIBS]:e(f.GL.MAX_VERTEX_ATTRIBS),[f.GL.MAX_VERTEX_UNIFORM_VECTORS]:e(f.GL.MAX_VERTEX_UNIFORM_VECTORS),[f.GL.MAX_FRAGMENT_UNIFORM_VECTORS]:e(f.GL.MAX_FRAGMENT_UNIFORM_VECTORS),[f.GL.MAX_VIEWPORT_DIMS]:e(f.GL.MAX_VIEWPORT_DIMS),[f.GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]:e(f.GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT),[f.GL.MAX_3D_TEXTURE_SIZE]:t(f.GL.MAX_3D_TEXTURE_SIZE),[f.GL.MAX_ARRAY_TEXTURE_LAYERS]:t(f.GL.MAX_ARRAY_TEXTURE_LAYERS),[f.GL.MAX_COLOR_ATTACHMENTS]:t(f.GL.MAX_COLOR_ATTACHMENTS),[f.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]:t(f.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS),[f.GL.MAX_COMBINED_UNIFORM_BLOCKS]:t(f.GL.MAX_COMBINED_UNIFORM_BLOCKS),[f.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]:t(f.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS),[f.GL.MAX_DRAW_BUFFERS]:t(f.GL.MAX_DRAW_BUFFERS),[f.GL.MAX_ELEMENT_INDEX]:t(f.GL.MAX_ELEMENT_INDEX),[f.GL.MAX_ELEMENTS_INDICES]:t(f.GL.MAX_ELEMENTS_INDICES),[f.GL.MAX_ELEMENTS_VERTICES]:t(f.GL.MAX_ELEMENTS_VERTICES),[f.GL.MAX_FRAGMENT_INPUT_COMPONENTS]:t(f.GL.MAX_FRAGMENT_INPUT_COMPONENTS),[f.GL.MAX_FRAGMENT_UNIFORM_BLOCKS]:t(f.GL.MAX_FRAGMENT_UNIFORM_BLOCKS),[f.GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]:t(f.GL.MAX_FRAGMENT_UNIFORM_COMPONENTS),[f.GL.MAX_SAMPLES]:t(f.GL.MAX_SAMPLES),[f.GL.MAX_TEXTURE_LOD_BIAS]:t(f.GL.MAX_TEXTURE_LOD_BIAS),[f.GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]:t(f.GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS),[f.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]:t(f.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS),[f.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]:t(f.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS),[f.GL.MAX_UNIFORM_BLOCK_SIZE]:t(f.GL.MAX_UNIFORM_BLOCK_SIZE),[f.GL.MAX_UNIFORM_BUFFER_BINDINGS]:t(f.GL.MAX_UNIFORM_BUFFER_BINDINGS),[f.GL.MAX_VARYING_COMPONENTS]:t(f.GL.MAX_VARYING_COMPONENTS),[f.GL.MAX_VERTEX_OUTPUT_COMPONENTS]:t(f.GL.MAX_VERTEX_OUTPUT_COMPONENTS),[f.GL.MAX_VERTEX_UNIFORM_BLOCKS]:t(f.GL.MAX_VERTEX_UNIFORM_BLOCKS),[f.GL.MAX_VERTEX_UNIFORM_COMPONENTS]:t(f.GL.MAX_VERTEX_UNIFORM_COMPONENTS),[f.GL.MIN_PROGRAM_TEXEL_OFFSET]:t(f.GL.MIN_PROGRAM_TEXEL_OFFSET),[f.GL.MAX_PROGRAM_TEXEL_OFFSET]:t(f.GL.MAX_PROGRAM_TEXEL_OFFSET),[f.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]:t(f.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT)}}var P=y(C(),1);var G=y(C(),1);function Y(r,e,t){let i=K.attach(r).gl;if(so(e))return t(r);let{nocatch:s=!0}=e;te(i),k(i,e);let a;if(s)a=t(i),Q(i);else try{a=t(i)}finally{Q(i)}return a}function so(r){for(let e in r)return!1;return!0}var D=y(C(),1);var b=y(C(),1);function pn(r,e,t,n){if(Ne(e))return n(r);te(r.gl);try{return Bt(r,e),k(r,t),n(r)}finally{Q(r.gl)}}function gn(r,e,t){if(Ne(e))return t(r);te(r.gl);try{return Bt(r,e),t(r)}finally{Q(r.gl)}}function Bt(r,e){let t=K.attach(r),{gl:n}=t;if(e.cullMode)switch(e.cullMode){case"none":n.disable(b.GL.CULL_FACE);break;case"front":n.enable(b.GL.CULL_FACE),n.cullFace(b.GL.FRONT);break;case"back":n.enable(b.GL.CULL_FACE),n.cullFace(b.GL.BACK);break}if(e.frontFace&&n.frontFace(ht("frontFace",e.frontFace,{ccw:b.GL.CCW,cw:b.GL.CW})),e.depthBias!==void 0&&n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0),e.depthWriteEnabled!==void 0&&n.depthMask(uo("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(b.GL.DEPTH_TEST):n.disable(b.GL.DEPTH_TEST),n.depthFunc(It("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;n.stencilMaskSeparate(b.GL.FRONT,i),n.stencilMaskSeparate(b.GL.BACK,i)}if(e.stencilReadMask&&h.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,s=It("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(b.GL.STENCIL_TEST):n.disable(b.GL.STENCIL_TEST),n.stencilFuncSeparate(b.GL.FRONT,s,0,i),n.stencilFuncSeparate(b.GL.BACK,s,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=mr("stencilPassOperation",e.stencilPassOperation),s=mr("stencilFailOperation",e.stencilFailOperation),a=mr("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(b.GL.FRONT,s,a,i),n.stencilOpSeparate(b.GL.BACK,s,a,i)}if(e.blendColorOperation||e.blendAlphaOperation){n.enable(b.GL.BLEND);let i=_n("blendColorOperation",e.blendColorOperation||"add"),s=_n("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let a=Pt("blendColorSrcFactor",e.blendColorSrcFactor||"one"),u=Pt("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=Pt("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),m=Pt("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(a,u,l,m)}}function It(r,e){return ht(r,e,{never:b.GL.NEVER,less:b.GL.LESS,equal:b.GL.EQUAL,"less-equal":b.GL.LEQUAL,greater:b.GL.GREATER,"not-equal":b.GL.NOTEQUAL,"greater-equal":b.GL.GEQUAL,always:b.GL.ALWAYS})}function mr(r,e){return ht(r,e,{keep:b.GL.KEEP,zero:b.GL.ZERO,replace:b.GL.REPLACE,invert:b.GL.INVERT,"increment-clamp":b.GL.INCR,"decrement-clamp":b.GL.DECR,"increment-wrap":b.GL.INCR_WRAP,"decrement-wrap":b.GL.DECR_WRAP})}function _n(r,e){return ht(r,e,{add:b.GL.FUNC_ADD,subtract:b.GL.FUNC_SUBTRACT,"reverse-subtract":b.GL.FUNC_REVERSE_SUBTRACT,min:b.GL.MIN,max:b.GL.MAX})}function Pt(r,e){return ht(r,e,{one:b.GL.ONE,zero:b.GL.ZERO,"src-color":b.GL.SRC_COLOR,"one-minus-src-color":b.GL.ONE_MINUS_SRC_COLOR,"dst-color":b.GL.DST_COLOR,"one-minus-dst-color":b.GL.ONE_MINUS_DST_COLOR,"src-alpha":b.GL.SRC_ALPHA,"one-minus-src-alpha":b.GL.ONE_MINUS_SRC_ALPHA,"dst-alpha":b.GL.DST_ALPHA,"one-minus-dst-alpha":b.GL.ONE_MINUS_DST_ALPHA})}function ao(r,e){return`Illegal parameter ${e} for ${r}`}function ht(r,e,t){if(!(e in t))throw new Error(ao(r,e));return t[e]}function uo(r,e){return e}function Dt(r){let e={};return r.addressModeU&&(e[D.GL.TEXTURE_WRAP_S]=hr(r.addressModeU)),r.addressModeV&&(e[D.GL.TEXTURE_WRAP_T]=hr(r.addressModeV)),r.addressModeW&&(e[D.GL.TEXTURE_WRAP_R]=hr(r.addressModeW)),r.magFilter&&(e[D.GL.TEXTURE_MAG_FILTER]=bn(r.magFilter)),(r.minFilter||r.mipmapFilter)&&(e[D.GL.TEXTURE_MIN_FILTER]=co(r.minFilter||"linear",r.mipmapFilter)),r.lodMinClamp!==void 0&&(e[D.GL.TEXTURE_MIN_LOD]=r.lodMinClamp),r.lodMaxClamp!==void 0&&(e[D.GL.TEXTURE_MAX_LOD]=r.lodMaxClamp),r.type==="comparison-sampler"&&(e[D.GL.TEXTURE_COMPARE_MODE]=D.GL.COMPARE_REF_TO_TEXTURE),r.compare&&(e[D.GL.TEXTURE_COMPARE_FUNC]=It("compare",r.compare)),r.maxAnisotropy&&(e[D.GL.TEXTURE_MAX_ANISOTROPY_EXT]=r.maxAnisotropy),e}function hr(r){switch(r){case"clamp-to-edge":return D.GL.CLAMP_TO_EDGE;case"repeat":return D.GL.REPEAT;case"mirror-repeat":return D.GL.MIRRORED_REPEAT}}function bn(r){switch(r){case"nearest":return D.GL.NEAREST;case"linear":return D.GL.LINEAR}}function co(r,e){if(!e)return bn(r);switch(r){case"nearest":return e==="nearest"?D.GL.NEAREST_MIPMAP_NEAREST:D.GL.NEAREST_MIPMAP_LINEAR;case"linear":return e==="nearest"?D.GL.LINEAR_MIPMAP_NEAREST:D.GL.LINEAR_MIPMAP_LINEAR}}var W=y(C(),1),X=class extends N{device;gl;handle;glTarget;glUsage;glIndexType=W.GL.UNSIGNED_SHORT;byteLength;bytesUsed;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let n=typeof t=="object"?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=lo(this.props.usage),this.glUsage=fo(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?W.GL.UNSIGNED_INT:W.GL.UNSIGNED_SHORT,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}_initWithData(e,t=0,n=e.byteLength+t){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){S(e>=0);let t=e;e===0&&(t=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,t=0){let s=W.GL.COPY_WRITE_BUFFER;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,t,e),this.gl.bindBuffer(s,null),this._setDebugData(e,t,e.byteLength)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let n=new Uint8Array(t),i=0;return this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,this.handle),this.gl.getBufferSubData(W.GL.COPY_READ_BUFFER,e,n,i,t),this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,null),this._setDebugData(n,e,t),n}};function lo(r){return r&N.INDEX?W.GL.ELEMENT_ARRAY_BUFFER:r&N.VERTEX?W.GL.ARRAY_BUFFER:r&N.UNIFORM?W.GL.UNIFORM_BUFFER:W.GL.ARRAY_BUFFER}function fo(r){return r&N.INDEX?W.GL.STATIC_DRAW:r&N.VERTEX?W.GL.STATIC_DRAW:r&N.UNIFORM?W.GL.DYNAMIC_DRAW:W.GL.STATIC_DRAW}var Er=y(C(),1);var ce=class extends Ie{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=Dt(t),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,n]of Object.entries(e)){let i=Number(t);switch(i){case Er.GL.TEXTURE_MIN_LOD:case Er.GL.TEXTURE_MAX_LOD:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}};var mo={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},Mt=class extends v{MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,t){super(e,{...mo,format:"rgba8unorm",...t}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=G.GL.RGBA,this.target=ho(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:ar(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let t=e.data;if(t instanceof Promise)return t.then(re=>this.initialize(Object.assign({},e,{pixels:re,data:re}))),this;let n=typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement;if(n&&t.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,t.addEventListener("loadeddata",()=>this.initialize(e)),this;let{parameters:i={}}=e,{pixels:s=null,pixelStore:a={},textureUnit:u=void 0,mipmaps:l=!0}=e;t||(t=s);let{width:m,height:d,dataFormat:p,type:_,compressed:R=!1}=e,{depth:L=0}=e,M=dt(e.format);return{width:m,height:d,compressed:R,dataFormat:p,type:_}=this._deduceParameters({format:e.format,type:_,dataFormat:p,compressed:R,data:t,width:m,height:d}),this.width=m,this.height=d,this.glFormat=M,this.type=_,this.dataFormat=p,this.textureUnit=u,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(G.GL.TEXTURE0+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=l,this.setImageData({data:t,width:m,height:d,depth:L,format:M,type:_,dataFormat:p,parameters:a,compressed:R}),this.setSampler(e.sampler),this._setSamplerParameters(i),l&&this.generateMipmap(),n&&(this._video={video:t,parameters:i,lastTime:t.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?t.currentTime:-1}),this}initializeCube(e){let{mipmaps:t=!0,parameters:n={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,t&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(n)}),this}setSampler(e={}){let t;e instanceof ce?(this.sampler=e,t=e.props):(this.sampler=new ce(this.device,e),t=e);let n=Dt(t);return this._setSamplerParameters(n),this}resize(e){let{height:t,width:n,mipmaps:i=!1}=e;return n!==this.width||t!==this.height?this.initialize({width:n,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:i}):this}update(){if(this._video){let{video:e,parameters:t,lastTime:n}=this._video;if(n===e.currentTime||e.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:e,parameters:t}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=e.currentTime}}generateMipmap(e={}){return this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Y(this.gl,e,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:t=this.target,pixels:n=null,level:i=0,glFormat:s=this.glFormat,offset:a=0,parameters:u={}}=e,{data:l=null,type:m=this.type,width:d=this.width,height:p=this.height,dataFormat:_=this.dataFormat,compressed:R=!1}=e;l||(l=n),{type:m,dataFormat:_,compressed:R,width:d,height:p}=this._deduceParameters({format:this.props.format,type:m,dataFormat:_,compressed:R,data:l,width:d,height:p});let{gl:L}=this;L.bindTexture(this.target,this.handle);let M=null;if({data:l,dataType:M}=this._getDataType({data:l,compressed:R}),Y(this.gl,u,()=>{switch(M){case"null":L.texImage2D(t,i,s,d,p,0,_,m,l);break;case"typed-array":L.texImage2D(t,i,s,d,p,0,_,m,l,a);break;case"buffer":this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,l.handle||l),this.device.gl.texImage2D(t,i,s,d,p,0,_,m,a),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null);break;case"browser-object":L.texImage2D(t,i,s,d,p,0,_,m,l);break;case"compressed":for(let[re,fe]of l.entries())L.compressedTexImage2D(t,re,fe.format,fe.width,fe.height,0,fe.data);break;default:S(!1,"Unknown image data type")}}),l&&l.byteLength)this.trackAllocatedMemory(l.byteLength,"Texture");else{let re=mt(this.props.format);this.trackAllocatedMemory(this.width*this.height*re,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:t=null,data:n=null,x:i=0,y:s=0,width:a=this.width,height:u=this.height,level:l=0,glFormat:m=this.glFormat,type:d=this.type,dataFormat:p=this.dataFormat,compressed:_=!1,offset:R=0,parameters:L={}}){if({type:d,dataFormat:p,compressed:_,width:a,height:u}=this._deduceParameters({format:this.props.format,type:d,dataFormat:p,compressed:_,data:n,width:a,height:u}),S(this.depth===1,"texSubImage not supported for 3D textures"),n||(n=t),n&&n.data){let M=n;n=M.data,a=M.shape[0],u=M.shape[1]}n instanceof X&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),Y(this.gl,L,()=>{_?this.gl.compressedTexSubImage2D(e,l,i,s,a,u,m,n):n===null?this.gl.texSubImage2D(e,l,i,s,a,u,p,d,null):ArrayBuffer.isView(n)?this.gl.texSubImage2D(e,l,i,s,a,u,p,d,n,R):typeof WebGLBuffer<"u"&&n instanceof WebGLBuffer?(this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,n),this.device.gl.texSubImage2D(e,l,i,s,a,u,p,d,R),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null)):this.device.gl.texSubImage2D(e,l,i,s,a,u,p,d,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return h.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(G.GL.ACTIVE_TEXTURE)-G.GL.TEXTURE0}bind(e=this.textureUnit){let{gl:t}=this;return e!==void 0&&(this.textureUnit=e,t.activeTexture(t.TEXTURE0+e)),t.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:t}=this;return e!==void 0&&(this.textureUnit=e,t.activeTexture(t.TEXTURE0+e)),t.bindTexture(this.target,null),e}_getDataType({data:e,compressed:t=!1}){return t?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof X?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:t,data:n}=e,{width:i,height:s,dataFormat:a,type:u,compressed:l}=e,m=Ve(t);return a=a||m.dataFormat,u=u||m.type,l=l||m.compressed,{width:i,height:s}=this._deduceImageSize(n,i,s),{dataFormat:a,type:u,compressed:l,width:i,height:s,format:t,data:n}}_deduceImageSize(e,t,n){let i;return typeof ImageData<"u"&&e instanceof ImageData?i={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?i={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?i={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?i={width:e.videoWidth,height:e.videoHeight}:e?i={width:t,height:n}:i={width:t>=0?t:1,height:n>=0?n:1},S(i,"Could not deduced texture size"),S(t===void 0||i.width===t,"Deduced texture width does not match supplied width"),S(n===void 0||i.height===n,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(e){let{gl:t}=this,{width:n,height:i,pixels:s,data:a,format:u=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,m=s||a,d=await Promise.all(Mt.FACES.map(p=>{let _=m[p];return Promise.all(Array.isArray(_)?_:[_])}));this.bind(),Mt.FACES.forEach((p,_)=>{d[_].length>1&&this.props.mipmaps!==!1&&h.warn(`${this.id} has mipmap and multiple LODs.`)(),d[_].forEach((R,L)=>{n&&i?t.texImage2D(p,L,u,n,i,0,u,l,R):t.texImage2D(p,L,u,u,l,R)})}),this.unbind()}setImageDataForFace(e){let{face:t,width:n,height:i,pixels:s,data:a,format:u=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,{gl:m}=this,d=s||a;return this.bind(),d instanceof Promise?d.then(p=>this.setImageDataForFace(Object.assign({},e,{face:t,data:p,pixels:p}))):this.width||this.height?m.texImage2D(t,0,u,n,i,0,u,l,d):m.texImage2D(t,0,u,u,l,d),this}setImageData3D(e){let{level:t=0,dataFormat:n,format:i,type:s,width:a,height:u,depth:l=1,offset:m=0,data:d,parameters:p={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let _=Ve(i);if(Y(this.gl,p,()=>{ArrayBuffer.isView(d)&&this.gl.texImage3D(this.target,t,_.format,a,u,l,0,_.dataFormat,_.type,d),d instanceof X&&(this.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,d.handle),this.gl.texImage3D(this.target,t,n,a,u,l,0,i,s,m))}),d&&d.byteLength)this.trackAllocatedMemory(d.byteLength,"Texture");else{let R=mt(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*R,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Ne(e)){Eo(e),this.gl.bindTexture(this.target,this.handle);for(let[t,n]of Object.entries(e)){let i=Number(t),s=n;switch(i){case G.GL.TEXTURE_MIN_LOD:case G.GL.TEXTURE_MAX_LOD:this.gl.texParameterf(this.target,i,s);break;default:this.gl.texParameteri(this.target,i,s);break}}this.gl.bindTexture(this.target,null)}}},U=Mt;g(U,"FACES",[G.GL.TEXTURE_CUBE_MAP_POSITIVE_X,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_X,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Y,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Y,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Z,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Z]);function ho(r){switch(r.dimension){case"2d":return G.GL.TEXTURE_2D;case"cube":return G.GL.TEXTURE_CUBE_MAP;case"2d-array":return G.GL.TEXTURE_2D_ARRAY;case"3d":return G.GL.TEXTURE_3D;case"1d":case"cube-array":default:throw new Error(r.dimension)}}function Eo(r){h.log(1,"texture sampler parameters",r)()}var Ke=y(C(),1);function Ot(r,e){if(typeof e!="string")return e;let t=Number(e);if(!isNaN(t))return t;e=e.replace(/^.*\./,"");let n=r[e];return S(n!==void 0,`Accessing undefined constant GL.${e}`),n}var ke="Resource subclass must define virtual methods",Le=class extends A{device;gl;gl2;_handle;_bound=!1;byteLength=0;constructor(e,t,n){super(e,t,n),this.device=K.attach(e);let i=this.device.gl,{id:s}=t||{};this.gl=i,this.gl2=i,this.id=s||ee(this.constructor.name),this._handle=t?.handle,this._handle===void 0&&(this._handle=this._createHandle()),this.byteLength=0}toString(){return`${this.constructor.name}(${this.id})`}get handle(){return this._handle}delete({deleteChildren:e=!1}={}){let t=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,t&&e&&t.filter(Boolean).forEach(n=>n.destroy()),this}bind(e=this.handle){if(typeof e!="function")return this._bindHandle(e),this;let t;return this._bound?t=e():(this._bindHandle(this.handle),this._bound=!0,t=e(),this._bound=!1,this._bindHandle(null)),t}unbind(){this.bind(null)}getParameter(e,t={}){e=Ot(this.gl,e),S(e);let i=(this.constructor.PARAMETERS||{})[e];return i&&!(!("extension"in i)||this.gl.getExtension(i.extension))?i.webgl2:this._getParameter(e,t)}getParameters(e={}){let{parameters:t,keys:n}=e,i=this.constructor.PARAMETERS||{},s={},a=t||Object.keys(i);for(let u of a){let l=i[u];if(l&&(!("extension"in l)||this.gl.getExtension(l.extension))){let d=n?this.device.getGLKey(u):u;s[d]=this.getParameter(u,e),n&&l.type==="GLenum"&&(s[d]=this.device.getGLKey(s[d]))}}return s}setParameter(e,t){e=Ot(this.gl,e),S(e);let i=(this.constructor.PARAMETERS||{})[e];if(i){if(!(!("extension"in i)||this.gl.getExtension(i.extension)))throw new Error("Parameter not available on this platform");i.type==="GLenum"&&(t=Ot(t))}return this._setParameter(e,t),this}setParameters(e){for(let t in e)this.setParameter(t,e[t]);return this}stubRemovedMethods(e,t,n){return or(this,e,t,n)}initialize(e){}_createHandle(){throw new Error(ke)}_deleteHandle(){throw new Error(ke)}_bindHandle(e){throw new Error(ke)}_getOptsFromHandle(){throw new Error(ke)}_getParameter(e,t){throw new Error(ke)}_setParameter(e,t){throw new Error(ke)}};var _r=class extends Le{get[Symbol.toStringTag](){return"Renderbuffer"}get width(){return this.props.width}get height(){return this.props.height}get format(){return this.props.format}get samples(){return this.props.samples}get attachment(){}glFormat;static isTextureFormatSupported(e,t){return un(e.gl,t)}constructor(e,t){if(typeof t.format=="number")throw new Error("Renderbuffer");super(e,t,_r.defaultProps),this.glFormat=dt(this.props.format),this._initialize(this.props)}resize(e){(e.width!==this.width||e.height!==this.height)&&(Object.assign(this.props,{...e,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(e){let{format:t,width:n,height:i,samples:s}=e;S(t,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(Ke.GL.RENDERBUFFER,this.handle),s!==0?this.gl.renderbufferStorageMultisample(Ke.GL.RENDERBUFFER,s,this.glFormat,n,i):this.gl.renderbufferStorage(Ke.GL.RENDERBUFFER,this.glFormat,n,i),this.gl.bindRenderbuffer(Ke.GL.RENDERBUFFER,null),this.trackAllocatedMemory(n*i*(s||1)*mt(this.glFormat))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(e){this.gl.bindRenderbuffer(Ke.GL.RENDERBUFFER,e)}},_e=_r;g(_e,"defaultProps",{id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0});var J=class extends Ee{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,t){super(e,t);let n=t.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),!n){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(P.GL.FRAMEBUFFER,this.handle);for(let i=0;i<this.colorAttachments.length;++i){let s=this.colorAttachments[i],a=P.GL.COLOR_ATTACHMENT0+i;s&&this._attachOne(a,s)}this.depthStencilAttachment&&this._attachOne(fn(this.depthStencilAttachment.format),this.depthStencilAttachment),this.gl.bindFramebuffer(P.GL.FRAMEBUFFER,null)}t.check!==!1&&this._checkStatus()}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}_checkStatus(){let{gl:e}=this,t=e.bindFramebuffer(P.GL.FRAMEBUFFER,this.handle),n=e.checkFramebufferStatus(P.GL.FRAMEBUFFER);if(e.bindFramebuffer(P.GL.FRAMEBUFFER,t||null),n!==e.FRAMEBUFFER_COMPLETE)throw new Error(`Framebuffer ${po(n)}`)}createDepthStencilTexture(e){return new _e(this.device,{id:`${this.id}-depth-stencil`,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;e===void 0&&(e=this.gl.drawingBufferWidth),t===void 0&&(t=this.gl.drawingBufferHeight);for(let n of this.colorAttachments)n.resize({width:e,height:t});return this.depthStencilAttachment&&this.depthStencilAttachment.resize({width:e,height:t}),this}_attachOne(e,t){if(t instanceof _e)return this._attachWEBGLRenderbuffer(e,t),t;if(Array.isArray(t)){let[n,i=0,s=0]=t;return this._attachTexture(e,n,i,s),n}else if(t instanceof U)return this._attachTexture(e,t,0,0),t;throw new Error("attach")}_attachWEBGLRenderbuffer(e,t){this.gl.framebufferRenderbuffer(P.GL.FRAMEBUFFER,e,P.GL.RENDERBUFFER,t.handle)}_attachTexture(e,t,n,i){let{gl:s}=this.device;switch(s.bindTexture(t.target,t.handle),t.target){case P.GL.TEXTURE_2D_ARRAY:case P.GL.TEXTURE_3D:s.framebufferTextureLayer(P.GL.FRAMEBUFFER,e,t.target,i,n);break;case P.GL.TEXTURE_CUBE_MAP:let a=_o(n);s.framebufferTexture2D(P.GL.FRAMEBUFFER,e,a,t.handle,i);break;case P.GL.TEXTURE_2D:s.framebufferTexture2D(P.GL.FRAMEBUFFER,e,P.GL.TEXTURE_2D,t.handle,i);break;default:S(!1,"Illegal texture type")}s.bindTexture(t.target,null)}};function _o(r){return r<P.GL.TEXTURE_CUBE_MAP_POSITIVE_X?r+P.GL.TEXTURE_CUBE_MAP_POSITIVE_X:r}function po(r){switch(r){case P.GL.FRAMEBUFFER_COMPLETE:return"success";case P.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"Mismatched attachments";case P.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"No attachments";case P.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"Height/width mismatch";case P.GL.FRAMEBUFFER_UNSUPPORTED:return"Unsupported or split attachments";case P.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:return"Samples mismatch";default:return`${r}`}}var Ye=class extends he{device;presentationSize;_framebuffer=null;constructor(e,t){super(t),this.device=e,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new J(this.device,{handle:null}),this._framebuffer}update(){let e=this.getPixelSize();(e[0]!==this.presentationSize[0]||e[1]!==this.presentationSize[1])&&(this.presentationSize=e,this.resize())}resize(e){if(this.device.gl&&this.canvas){let t=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(t,e);return}}commit(){}};var go={spector:h.get("spector")||h.get("inspect")},bo="https://spectorcdn.babylonjs.com/spector.bundle.js",To=1,$=null,Tn=!1;async function An(r){if(!globalThis.SPECTOR)try{await ot(bo)}catch(e){h.warn(String(e))}}function Rn(r){if(r={...go,...r},!r?.spector||(!$&&globalThis.SPECTOR&&(h.probe(To,"SPECTOR found and initialized")(),$=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=$)),!$))return null;if(Tn||(Tn=!0,$.spyCanvases(),$?.onCaptureStarted.add(e=>h.info("Spector capture started:",e)()),$?.onCapture.add(e=>{h.info("Spector capture complete:",e)(),$?.getResultUI(),$?.resultView.display(),$?.resultView.addCapture(e)})),r?.canvas){if(typeof r.spector=="string"&&r.spector!==r.canvas.id)return $;$?.startCapture(r?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{h.info("Spector capture stopped after 2 seconds")(),$?.stopCapture()})}return $}var Et=y(C(),1);var Ao="https://unpkg.com/webgl-debug@2.0.1/index.js";function Sn(r){return r.luma=r.luma||{},r.luma}async function Ln(){I()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await ot(Ao))}function xn(r,e={}){return r?e.debug?So(r,e):Ro(r):null}function Ro(r){let e=Sn(r);return e.realContext?e.realContext:r}function So(r,e){if(!globalThis.WebGLDebugUtils)return h.warn("webgl-debug not loaded")(),r;let t=Sn(r);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Et.GL,...r});let n=globalThis.WebGLDebugUtils.makeDebugContext(r,Lo.bind(null,e),xo.bind(null,e));for(let a in Et.GL)!(a in n)&&typeof Et.GL[a]=="number"&&(n[a]=Et.GL[a]);class i{}Object.setPrototypeOf(n,Object.getPrototypeOf(r)),Object.setPrototypeOf(i,n);let s=Object.create(i);return t.realContext=r,t.debugContext=s,s.debug=!0,s}function pr(r,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${r}(${t})`}function Lo(r,e,t,n){n=Array.from(n).map(u=>u===void 0?"undefined":u);let i=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),a=`${i} in gl.${t}(${s})`;h.error(a)();debugger;if(r.throwOnError)throw new Error(a)}function xo(r,e,t){let n="";if(h.level>=1&&(n=pr(e,t),h.log(1,n)()),r.break&&r.break.length>0&&(n=n||pr(e,t),r.break.every(s=>n.indexOf(s)!==-1)))debugger;for(let i of t)if(i===void 0){if(n=n||pr(e,t),r.throwOnError)throw new Error(`Undefined argument: ${n}`);h.error(`Undefined argument: ${n}`)();debugger}}var _t=y(C(),1);function Fn(r){let e=r.split(/\r?\n/),t=[];for(let n of e){if(n.length<=1)continue;let i=n.split(":");if(i.length===2){let[p,_]=i;t.push({message:_.trim(),type:Cn(p),lineNum:0,linePos:0});continue}let[s,a,u,...l]=i,m=parseInt(u,10);isNaN(m)&&(m=0);let d=parseInt(a,10);isNaN(d)&&(d=0),t.push({message:l.join(":").trim(),type:Cn(s),lineNum:m,linePos:d})}return t}function Cn(r){let e=["warning","error","info"],t=r.toLowerCase();return e.includes(t)?t:"info"}var $e=class extends Pe{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.VERTEX_SHADER);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.FRAGMENT_SHADER);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return Fn(e)}async _compile(e){e=(i=>i.startsWith("#version ")?i:`#version 100
17
- ${i}`)(e);let{gl:n}=this.device;if(n.shaderSource(this.handle,e),n.compileShader(this.handle),h.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("shader-status-async-webgl")){if(this._getCompilationStatus(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);this.debugShader();return}h.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),h.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("shader-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,_t.GL.COMPLETION_STATUS))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,_t.GL.COMPILE_STATUS)?"success":"error"}};var br=y(C(),1);var Co=256,Fo=1024,yo=16384,gr=6144,ze=class extends De{device;glParameters;constructor(e,t){super(e,t),this.device=e,te(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Q(this.device.gl),this.props.framebuffer&&k(this.device,{framebuffer:null})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let t={};this.props.framebuffer&&(t.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[br.GL.RASTERIZER_DISCARD]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),t.scissorTest=Boolean(e.scissorRect),e.scissorRect&&(t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[br.GL.STENCIL_REF]=e.stencilReference),this.glParameters=t,k(this.device,t)}clear(){let e={...this.glParameters},t=0;this.props.clearColor!==!1&&(t|=yo,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=Co,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=Fo,e.clearStencil=this.props.clearStencil),t!==0&&Y(this.device,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Y(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int32Array:this.device.gl.clearBufferiv(gr,e,t);break;case Uint32Array:this.device.gl.clearBufferuiv(gr,e,t);break;case Float32Array:default:this.device.gl.clearBufferfv(gr,e,t);break}})}};var xe=y(C(),1);var x=y(C(),1);var je=y(C(),1);var O=y(C(),1),Go="Failed to deduce GL constant from typed array";function yn(r){switch(ArrayBuffer.isView(r)?r.constructor:r){case Float32Array:return O.GL.FLOAT;case Uint16Array:return O.GL.UNSIGNED_SHORT;case Uint32Array:return O.GL.UNSIGNED_INT;case Uint8Array:return O.GL.UNSIGNED_BYTE;case Uint8ClampedArray:return O.GL.UNSIGNED_BYTE;case Int8Array:return O.GL.BYTE;case Int16Array:return O.GL.SHORT;case Int32Array:return O.GL.INT;default:throw new Error(Go)}}function pt(r,e){let{clamped:t=!0}=e||{};switch(r){case O.GL.FLOAT:return Float32Array;case O.GL.UNSIGNED_SHORT:case O.GL.UNSIGNED_SHORT_5_6_5:case O.GL.UNSIGNED_SHORT_4_4_4_4:case O.GL.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;case O.GL.UNSIGNED_INT:return Uint32Array;case O.GL.UNSIGNED_BYTE:return t?Uint8ClampedArray:Uint8Array;case O.GL.BYTE:return Int8Array;case O.GL.SHORT:return Int16Array;case O.GL.INT:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var No={offset:0,stride:0,type:je.GL.FLOAT,size:1,divisor:0,normalized:!1,integer:!1},Po={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},se=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return pt(e.type||je.GL.FLOAT).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return S(e.size),pt(e.type||je.GL.FLOAT).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new se(No,...e)}constructor(...e){e.forEach(t=>this._assign(t)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return se.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return se.getBytesPerVertex(this)}_assign(e={}){return e=sr("Accessor",e,Po),e.type!==void 0&&(this.type=e.type,(e.type===je.GL.INT||e.type===je.GL.UNSIGNED_INT)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};var E=y(C(),1);function Gn(r){return Io.includes(r)}var Io=[E.GL.SAMPLER_2D,E.GL.SAMPLER_CUBE,E.GL.SAMPLER_3D,E.GL.SAMPLER_2D_SHADOW,E.GL.SAMPLER_2D_ARRAY,E.GL.SAMPLER_2D_ARRAY_SHADOW,E.GL.SAMPLER_CUBE_SHADOW,E.GL.INT_SAMPLER_2D,E.GL.INT_SAMPLER_3D,E.GL.INT_SAMPLER_CUBE,E.GL.INT_SAMPLER_2D_ARRAY,E.GL.UNSIGNED_INT_SAMPLER_2D,E.GL.UNSIGNED_INT_SAMPLER_3D,E.GL.UNSIGNED_INT_SAMPLER_CUBE,E.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY],Nn={[E.GL.FLOAT]:[E.GL.FLOAT,1,"float","f32","float32"],[E.GL.FLOAT_VEC2]:[E.GL.FLOAT,2,"vec2","vec2<f32>","float32x2"],[E.GL.FLOAT_VEC3]:[E.GL.FLOAT,3,"vec3","vec3<f32>","float32x3"],[E.GL.FLOAT_VEC4]:[E.GL.FLOAT,4,"vec4","vec4<f32>","float32x4"],[E.GL.INT]:[E.GL.INT,1,"int","i32","sint32"],[E.GL.INT_VEC2]:[E.GL.INT,2,"ivec2","vec2<i32>","sint32x2"],[E.GL.INT_VEC3]:[E.GL.INT,3,"ivec3","vec3<i32>","sint32x3"],[E.GL.INT_VEC4]:[E.GL.INT,4,"ivec4","vec4<i32>","sint32x4"],[E.GL.UNSIGNED_INT]:[E.GL.UNSIGNED_INT,1,"uint","u32","uint32"],[E.GL.UNSIGNED_INT_VEC2]:[E.GL.UNSIGNED_INT,2,"uvec2","vec2<u32>","uint32x2"],[E.GL.UNSIGNED_INT_VEC3]:[E.GL.UNSIGNED_INT,3,"uvec3","vec3<u32>","uint32x3"],[E.GL.UNSIGNED_INT_VEC4]:[E.GL.UNSIGNED_INT,4,"uvec4","vec4<u32>","uint32x4"],[E.GL.BOOL]:[E.GL.FLOAT,1,"bool","f32","float32"],[E.GL.BOOL_VEC2]:[E.GL.FLOAT,2,"bvec2","vec2<f32>","float32x2"],[E.GL.BOOL_VEC3]:[E.GL.FLOAT,3,"bvec3","vec3<f32>","float32x3"],[E.GL.BOOL_VEC4]:[E.GL.FLOAT,4,"bvec4","vec4<f32>","float32x4"],[E.GL.FLOAT_MAT2]:[E.GL.FLOAT,8,"mat2","mat2x2<f32>"],[E.GL.FLOAT_MAT2x3]:[E.GL.FLOAT,8,"mat2x3","mat2x3<f32>"],[E.GL.FLOAT_MAT2x4]:[E.GL.FLOAT,8,"mat2x4","mat2x4<f32>"],[E.GL.FLOAT_MAT3x2]:[E.GL.FLOAT,12,"mat3x2","mat3x2<f32>"],[E.GL.FLOAT_MAT3]:[E.GL.FLOAT,12,"mat3","mat3x3<f32>"],[E.GL.FLOAT_MAT3x4]:[E.GL.FLOAT,12,"mat3x4","mat3x4<f32>"],[E.GL.FLOAT_MAT4x2]:[E.GL.FLOAT,16,"mat4x2","mat4x2<f32>"],[E.GL.FLOAT_MAT4x3]:[E.GL.FLOAT,16,"mat4x3","mat4x3<f32>"],[E.GL.FLOAT_MAT4]:[E.GL.FLOAT,16,"mat4","mat4x4<f32>"]};function Tr(r){let e=Nn[r];if(!e)throw new Error("uniform");let[t,n,,i]=e;return{format:i,components:n,glType:t}}function Pn(r){let e=Nn[r];if(!e)throw new Error("attribute");let[,t,,n,i]=e;return{attributeType:n,vertexFormat:i,components:t}}function vt(r,e){let t={attributes:[],bindings:[]};t.attributes=Bo(r,e);let n=Oo(r,e);for(let u of n){let l=u.uniforms.map(m=>({name:m.name,format:m.format,byteOffset:m.byteOffset,byteStride:m.byteStride,arrayLength:m.arrayLength}));t.bindings.push({type:"uniform",name:u.name,location:u.location,visibility:(u.vertex?1:0)&(u.fragment?2:0),minBindingSize:u.byteLength,uniforms:l})}let i=Mo(r,e),s=0;for(let u of i)if(Gn(u.type)){let{viewDimension:l,sampleType:m}=Uo(u.type);t.bindings.push({type:"texture",name:u.name,location:s,viewDimension:l,sampleType:m}),u.textureUnit=s,s+=1}i.length&&(t.uniforms=i);let a=Do(r,e);return a?.length&&(t.varyings=a),t}function Bo(r,e){let t=[],n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let s=r.getActiveAttrib(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:u}=s,l=r.getAttribLocation(e,a);if(l>=0){let{attributeType:m}=Pn(u),d=/instance/i.test(a)?"instance":"vertex";t.push({name:a,location:l,stepMode:d,type:m})}}return t.sort((i,s)=>i.location-s.location),t}function Do(r,e){let t=[],n=r.getProgramParameter(e,x.GL.TRANSFORM_FEEDBACK_VARYINGS);for(let i=0;i<n;i++){let s=r.getTransformFeedbackVarying(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:u,size:l}=s,{glType:m,components:d}=Tr(u),p=new se({type:m,size:l*d}),_={location:i,name:a,accessor:p};t.push(_)}return t.sort((i,s)=>i.location-s.location),t}function Mo(r,e){let t=[],n=r.getProgramParameter(e,x.GL.ACTIVE_UNIFORMS);for(let i=0;i<n;i++){let s=r.getActiveUniform(e,i);if(!s)throw new Error("activeInfo");let{name:a,size:u,type:l}=s,{name:m,isArray:d}=wo(a),p=r.getUniformLocation(e,m),_={location:p,name:m,size:u,type:l,isArray:d};if(t.push(_),_.size>1)for(let R=0;R<_.size;R++){let L=`${m}[${R}]`;p=r.getUniformLocation(e,L);let M={..._,name:L,location:p};t.push(M)}}return t}function Oo(r,e){let t=(s,a)=>r.getActiveUniformBlockParameter(e,s,a),n=[],i=r.getProgramParameter(e,x.GL.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){let a={name:r.getActiveUniformBlockName(e,s)||"",location:t(s,x.GL.UNIFORM_BLOCK_BINDING),byteLength:t(s,x.GL.UNIFORM_BLOCK_DATA_SIZE),vertex:t(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),fragment:t(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),uniformCount:t(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),uniforms:[]},u=t(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)||[],l=r.getActiveUniforms(e,u,x.GL.UNIFORM_TYPE),m=r.getActiveUniforms(e,u,x.GL.UNIFORM_SIZE),d=r.getActiveUniforms(e,u,x.GL.UNIFORM_OFFSET),p=r.getActiveUniforms(e,u,x.GL.UNIFORM_ARRAY_STRIDE);for(let _=0;_<a.uniformCount;++_){let R=r.getActiveUniform(e,u[_]);if(!R)throw new Error("activeInfo");a.uniforms.push({name:R.name,format:Tr(l[_]).format,type:l[_],arrayLength:m[_],byteOffset:d[_],byteStride:p[_]})}n.push(a)}return n.sort((s,a)=>s.location-a.location),n}var vo={[x.GL.SAMPLER_2D]:["2d","float"],[x.GL.SAMPLER_CUBE]:["cube","float"],[x.GL.SAMPLER_3D]:["3d","float"],[x.GL.SAMPLER_2D_SHADOW]:["3d","depth"],[x.GL.SAMPLER_2D_ARRAY]:["2d-array","float"],[x.GL.SAMPLER_2D_ARRAY_SHADOW]:["2d-array","depth"],[x.GL.SAMPLER_CUBE_SHADOW]:["cube","float"],[x.GL.INT_SAMPLER_2D]:["2d","sint"],[x.GL.INT_SAMPLER_3D]:["3d","sint"],[x.GL.INT_SAMPLER_CUBE]:["cube","sint"],[x.GL.INT_SAMPLER_2D_ARRAY]:["2d-array","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D]:["2d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_3D]:["3d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_CUBE]:["cube","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]:["2d-array","uint"]};function Uo(r){let e=vo[r];if(!e)throw new Error("sampler");let[t,n]=e;return{viewDimension:t,sampleType:n}}function wo(r){if(r[r.length-1]!=="]")return{name:r,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(r);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${r}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}var T=y(C(),1);function In(r,e,t,n){let i=r,s=n;s===!0&&(s=1),s===!1&&(s=0);let a=typeof s=="number"?[s]:s;switch(t){case T.GL.SAMPLER_2D:case T.GL.SAMPLER_CUBE:case T.GL.SAMPLER_3D:case T.GL.SAMPLER_2D_SHADOW:case T.GL.SAMPLER_2D_ARRAY:case T.GL.SAMPLER_2D_ARRAY_SHADOW:case T.GL.SAMPLER_CUBE_SHADOW:case T.GL.INT_SAMPLER_2D:case T.GL.INT_SAMPLER_3D:case T.GL.INT_SAMPLER_CUBE:case T.GL.INT_SAMPLER_2D_ARRAY:case T.GL.UNSIGNED_INT_SAMPLER_2D:case T.GL.UNSIGNED_INT_SAMPLER_3D:case T.GL.UNSIGNED_INT_SAMPLER_CUBE:case T.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:if(typeof n!="number")throw new Error("samplers must be set to integers");return r.uniform1i(e,n);case T.GL.FLOAT:return r.uniform1fv(e,a);case T.GL.FLOAT_VEC2:return r.uniform2fv(e,a);case T.GL.FLOAT_VEC3:return r.uniform3fv(e,a);case T.GL.FLOAT_VEC4:return r.uniform4fv(e,a);case T.GL.INT:return r.uniform1iv(e,a);case T.GL.INT_VEC2:return r.uniform2iv(e,a);case T.GL.INT_VEC3:return r.uniform3iv(e,a);case T.GL.INT_VEC4:return r.uniform4iv(e,a);case T.GL.BOOL:return r.uniform1iv(e,a);case T.GL.BOOL_VEC2:return r.uniform2iv(e,a);case T.GL.BOOL_VEC3:return r.uniform3iv(e,a);case T.GL.BOOL_VEC4:return r.uniform4iv(e,a);case T.GL.UNSIGNED_INT:return i.uniform1uiv(e,a,1);case T.GL.UNSIGNED_INT_VEC2:return i.uniform2uiv(e,a,2);case T.GL.UNSIGNED_INT_VEC3:return i.uniform3uiv(e,a,3);case T.GL.UNSIGNED_INT_VEC4:return i.uniform4uiv(e,a,4);case T.GL.FLOAT_MAT2:return r.uniformMatrix2fv(e,!1,a);case T.GL.FLOAT_MAT3:return r.uniformMatrix3fv(e,!1,a);case T.GL.FLOAT_MAT4:return r.uniformMatrix4fv(e,!1,a);case T.GL.FLOAT_MAT2x3:return i.uniformMatrix2x3fv(e,!1,a);case T.GL.FLOAT_MAT2x4:return i.uniformMatrix2x4fv(e,!1,a);case T.GL.FLOAT_MAT3x2:return i.uniformMatrix3x2fv(e,!1,a);case T.GL.FLOAT_MAT3x4:return i.uniformMatrix3x4fv(e,!1,a);case T.GL.FLOAT_MAT4x2:return i.uniformMatrix4x2fv(e,!1,a);case T.GL.FLOAT_MAT4x3:return i.uniformMatrix4x3fv(e,!1,a)}throw new Error("Illegal uniform")}var H=y(C(),1);function Bn(r){switch(r){case"point-list":return H.GL.POINTS;case"line-list":return H.GL.LINES;case"line-strip":return H.GL.LINE_STRIP;case"line-loop-webgl":return H.GL.LINE_LOOP;case"triangle-list":return H.GL.TRIANGLES;case"triangle-strip":return H.GL.TRIANGLE_STRIP;case"triangle-fan-webgl":return H.GL.TRIANGLE_FAN;default:throw new Error(r)}}function Dn(r){switch(r){case"point-list":return H.GL.POINTS;case"line-list":return H.GL.LINES;case"line-strip":return H.GL.LINES;case"line-loop-webgl":return H.GL.LINES;case"triangle-list":return H.GL.TRIANGLES;case"triangle-strip":return H.GL.TRIANGLES;case"triangle-fan-webgl":return H.GL.TRIANGLES;default:throw new Error(r)}}var Mn=4,Ze=class extends Be{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=t.vs,this.fs=t.fs;let{varyings:n,bufferMode:i=xe.GL.SEPARATE_ATTRIBS}=t;switch(n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),this.introspectedLayout=vt(this.device.gl,this.handle),this.shaderLayout=Jt(this.introspectedLayout,t.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":h.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e){for(let[t,n]of Object.entries(e)){let i=this.shaderLayout.bindings.find(s=>s.name===t)||this.shaderLayout.bindings.find(s=>s.name===`${t}Uniforms`);if(!i){let s=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");h.warn(`Unknown binding "${t}" in render pipeline "${this.id}", expected one of ${s}`)();continue}switch(n||h.warn(`Unsetting binding "${t}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(n instanceof X)&&!(n.buffer instanceof X))throw new Error("buffer value");break;case"texture":if(!(n instanceof U||n instanceof J))throw new Error("texture value");break;case"sampler":h.warn(`Ignoring sampler ${t}`)();break;default:throw new Error(i.type)}this.bindings[t]=n}}setUniforms(e){let{bindings:t}=ir(e);Object.keys(t).forEach(n=>{h.warn(`Unsupported value "${JSON.stringify(t[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}draw(e){if(this.linkStatus!=="success")return!1;let{renderPass:t,vertexArray:n,vertexCount:i,instanceCount:s,firstVertex:a=0,transformFeedback:u}=e,l=Bn(this.props.topology),m=Boolean(n.indexBuffer),d=n.indexBuffer?.glIndexType,p=Number(s)>0;if(!this._areTexturesRenderable()||i===0)return!1;this.device.gl.useProgram(this.handle),n.bindBeforeRender(t),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let _=t;return pn(this.device,this.props.parameters,_.glParameters,()=>{m&&p?this.device.gl.drawElementsInstanced(l,i||0,d,a,s||0):m?this.device.gl.drawElements(l,i||0,d,a):p?this.device.gl.drawArraysInstanced(l,a,i||0,s||0):this.device.gl.drawArrays(l,a,i||0),u&&u.end()}),n.unbindAfterRender(t),!0}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),h.time(Mn,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),h.timeEnd(Mn,`linkProgram for ${this.id}`)(),h.level,!this.device.features.has("shader-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}h.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),h.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,e.LINK_STATUS)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,e.VALIDATE_STATUS)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("shader-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,xe.GL.COMPLETION_STATUS))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,t]of Object.entries(this.bindings))t instanceof U&&(t.update(),e=e&&t.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let t=0,n=0;for(let i of this.shaderLayout.bindings){let s=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!s)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:a}=i,u=e.getUniformBlockIndex(this.handle,a);if(u===xe.GL.INVALID_INDEX)throw new Error(`Invalid uniform block name ${a}`);e.uniformBlockBinding(this.handle,n,u),s instanceof X?e.bindBufferBase(xe.GL.UNIFORM_BUFFER,n,s.handle):e.bindBufferRange(xe.GL.UNIFORM_BUFFER,n,s.buffer.handle,s.offset||0,s.size||s.buffer.byteLength-s.offset),n+=1;break;case"texture":if(!(s instanceof U||s instanceof J))throw new Error("texture");let l;if(s instanceof U)l=s;else if(s instanceof J&&s.colorAttachments[0]instanceof U)h.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=s.colorAttachments[0];else throw new Error("No texture");e.activeTexture(xe.GL.TEXTURE0+t),e.bindTexture(l.target,l.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:t,location:n,type:i,textureUnit:s}=e,a=this.uniforms[t]??s;a!==void 0&&In(this.device.gl,n,i,a)}}};var Z=y(C(),1);var Ut=class extends Oe{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":Wo(this.device,t.options);break;case"copy-buffer-to-texture":Xo(this.device,t.options);break;case"copy-texture-to-buffer":Ho(this.device,t.options);break;case"copy-texture-to-texture":Vo(this.device,t.options);break}}};function Wo(r,e){let t=e.source,n=e.destination;r.gl.bindBuffer(Z.GL.COPY_READ_BUFFER,t.handle),r.gl.bindBuffer(Z.GL.COPY_WRITE_BUFFER,n.handle),r.gl.copyBufferSubData(Z.GL.COPY_READ_BUFFER,Z.GL.COPY_WRITE_BUFFER,e.sourceOffset??0,e.destinationOffset??0,e.size),r.gl.bindBuffer(Z.GL.COPY_READ_BUFFER,null),r.gl.bindBuffer(Z.GL.COPY_WRITE_BUFFER,null)}function Xo(r,e){throw new Error("Not implemented")}function Ho(r,e){let{source:t,mipLevel:n=0,aspect:i="all",width:s=e.source.width,height:a=e.source.height,depthOrArrayLayers:u=0,origin:l=[0,0],destination:m,byteOffset:d=0,bytesPerRow:p,rowsPerImage:_}=e;if(i!=="all")throw new Error("not supported");if(n!==0||u!==0||p||_)throw new Error("not implemented");let{framebuffer:R,destroyFramebuffer:L}=On(t);try{let M=m,re=s||R.width,fe=a||R.height,Rr=Ve(R.texture.format),Vn=Rr.dataFormat,kn=Rr.type;r.gl.bindBuffer(Z.GL.PIXEL_PACK_BUFFER,M.handle),r.gl.bindFramebuffer(Z.GL.FRAMEBUFFER,R.handle),r.gl.readPixels(l[0],l[1],re,fe,Vn,kn,d)}finally{r.gl.bindBuffer(Z.GL.PIXEL_PACK_BUFFER,null),r.gl.bindFramebuffer(Z.GL.FRAMEBUFFER,null),L&&R.destroy()}}function Vo(r,e){let{source:t,origin:n=[0,0],destination:i}=e,{width:s=e.destination.width,height:a=e.destination.width}=e,u=0,l=Z.GL.RGBA,{framebuffer:m,destroyFramebuffer:d}=On(t),[p,_]=n,R=!1;r.gl.bindFramebuffer(Z.GL.FRAMEBUFFER,m.handle);let L=null,M;if(i instanceof U)L=i,s=Number.isFinite(s)?s:L.width,a=Number.isFinite(a)?a:L.height,L.bind(0),M=L.destination;else throw new Error("whoops");return R||r.gl.copyTexImage2D(M,u,l,p,_,s,a,0),L&&L.unbind(),d&&m.destroy(),L}function On(r){if(r instanceof v){let{width:e,height:t,id:n}=r;return{framebuffer:r.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:t,colorAttachments:[r]}),destroyFramebuffer:!0}}return{framebuffer:r,destroyFramebuffer:!1}}var qe=class extends Me{device;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new Ut(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}};var Qe=y(C(),1);var pe=class extends ve{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Tt()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,t?t.handle:null),this.indexBuffer=t}setBuffer(e,t){let n=t;if(n.glTarget===Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:a,offset:u,normalized:l,integer:m,divisor:d}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ARRAY_BUFFER,n.handle),m?this.device.gl.vertexAttribIPointer(e,i,s,a,u):this.device.gl.vertexAttribPointer(e,i,s,l,a,u),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,d||0),this.attributes[e]=n}setConstant(e,t){this._enable(e,!1),this.attributes[e]=t}init=!1;bindBeforeRender(){if(this.device.gl.bindVertexArray(this.handle),!this.init){let e=this.indexBuffer;this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,e?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttribute(e,t)}}_getAccessor(e){let t=this.attributeInfos[e];if(!t)throw new Error(`Unknown attribute location ${e}`);let n=Gt(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:t.stepMode==="instance"?1:0}}_enable(e,t=!0){let i=pe.isConstantAttributeZeroSupported(this.device)||e!==0;(t||i)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),t?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){let n=ko(t),i=n.byteLength*e,s=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),a=a||!Ko(n,this.bufferValue),a){let u=rr(t.constructor,s);nr({target:u,source:n,start:0,count:s}),this.buffer.write(u),this.bufferValue=t}return this.buffer}};function ko(r){return Array.isArray(r)?new Float32Array(r):r}function Ko(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}var le=y(C(),1);var Je=class extends Ue{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Dn(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse||this._unbindBuffers(),this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){let n=this._getVaryingIndex(e),{buffer:i,byteLength:s,byteOffset:a}=this._getBufferRange(t);if(n<0){this.unusedBuffers[e]=i,h.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:a},this.bindOnUse||this._bindBuffer(n,i,a,s)}getBuffer(e){if(vn(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof X)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(vn(e))return Number(e);for(let t of this.layout.varyings)if(e===t.name)return t.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:t,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,Number(e),null)}_bindBuffer(e,t,n=0,i){let s=t&&t.handle;!s||i===void 0?this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s):this.gl.bindBufferRange(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s,n,i)}};function vn(r){return typeof r=="number"?Number.isInteger(r):/^\d+$/.test(r)}var ae=y(C(),1);var V=y(C(),1);function Ar(r){switch(r){case V.GL.ALPHA:case V.GL.R32F:case V.GL.RED:return 1;case V.GL.RG32F:case V.GL.RG:return 2;case V.GL.RGB:case V.GL.RGB32F:return 3;case V.GL.RGBA:case V.GL.RGBA32F:return 4;default:return S(!1),0}}function Un(r){switch(r){case V.GL.UNSIGNED_BYTE:return 1;case V.GL.UNSIGNED_SHORT_5_6_5:case V.GL.UNSIGNED_SHORT_4_4_4_4:case V.GL.UNSIGNED_SHORT_5_5_5_1:return 2;case V.GL.FLOAT:return 4;default:return S(!1),0}}function wn(r,e){let{sourceX:t=0,sourceY:n=0,sourceFormat:i=ae.GL.RGBA,sourceAttachment:s=ae.GL.COLOR_ATTACHMENT0}=e||{},{target:a=null,sourceWidth:u,sourceHeight:l,sourceType:m}=e||{},{framebuffer:d,deleteFramebuffer:p}=Xn(r);S(d);let{gl:_,handle:R}=d;u=u||d.width,l=l||d.height;let L=s-ae.GL.COLOR_ATTACHMENT0;m=m||d.colorAttachments[L]?.type||ae.GL.UNSIGNED_BYTE,a=$o(a,m,i,u,l),m=m||yn(a);let M=_.bindFramebuffer(ae.GL.FRAMEBUFFER,R);return _.readPixels(t,n,u,l,i,m,a),_.bindFramebuffer(ae.GL.FRAMEBUFFER,M||null),p&&d.destroy(),a}function Wn(r,e){let{target:t,sourceX:n=0,sourceY:i=0,sourceFormat:s=ae.GL.RGBA,targetByteOffset:a=0}=e||{},{sourceWidth:u,sourceHeight:l,sourceType:m}=e||{},{framebuffer:d,deleteFramebuffer:p}=Xn(r);S(d),u=u||d.width,l=l||d.height;let _=d;m=m||ae.GL.UNSIGNED_BYTE;let R=t;if(!R){let M=Ar(s),re=Un(m),fe=a+u*l*M*re;R=_.device.createBuffer({byteLength:fe})}let L=r.device.createCommandEncoder();return L.copyTextureToBuffer({source:r,width:u,height:l,origin:[n,i],destination:R,byteOffset:a}),L.destroy(),p&&d.destroy(),R}function Xn(r){return r instanceof Ee?{framebuffer:r,deleteFramebuffer:!1}:{framebuffer:Yo(r),deleteFramebuffer:!0}}function Yo(r,e){let{device:t,width:n,height:i,id:s}=r;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[r]})}function $o(r,e,t,n,i){if(r)return r;e=e||ae.GL.UNSIGNED_BYTE;let s=pt(e,{clamped:!1}),a=Ar(t);return new s(n*i*a)}var zo=256,jo=1024,Zo=16384;var qo="clear: bad arguments";function Hn(r,e){let{framebuffer:t=null,color:n=null,depth:i=null,stencil:s=null}=e||{},a={};t&&(a.framebuffer=t);let u=0;n&&(u|=Zo,n!==!0&&(a.clearColor=n)),i&&(u|=zo,i!==!0&&(a.clearDepth=i)),s&&(u|=jo,i!==!0&&(a.clearStencil=i)),S(u!==0,qo),Y(r,a,()=>{r.gl.clear(u)})}var gt=1,et=class extends me{static isSupported(){return typeof WebGL2RenderingContext<"u"}info;canvasContext;handle;get features(){return this._features=this._features||dn(this.gl),this._features}get limits(){return this._limits=this._limits||hn(this.gl),this._limits}lost;_resolveContextLost;_features;_limits;static attach(e){if(e instanceof et)return e;if(e?.device instanceof me)return e.device;if(!Qo(e))throw new Error("Invalid WebGL2RenderingContext");return new et({gl:e})}static async create(e={}){h.groupCollapsed(gt,"WebGLDevice created")(),typeof e.canvas=="string"&&await he.pageLoaded,(h.get("debug")||e.debug)&&await Ln();let{spector:t}=e;if((h.get("spector")||t)&&await An(),h.probe(gt+1,"DOM is loaded")(),e.gl&&e.gl.device)return et.attach(e.gl);let n=new et(e),i=`Created ${n.info.type}${n.debug?" debug":""} context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return h.probe(gt,i)(),h.table(gt,n.info)(),h.groupEnd(gt)(),n}constructor(e){super({...e,id:e.id||ee("webgl-device")});let t=e.gl?.device;if(t)throw new Error(`WebGL context already attached to device ${t.id}`);let n=e.canvas||e.gl?.canvas;this.canvasContext=new Ye(this,{...e,canvas:n}),this.lost=new Promise(l=>{this._resolveContextLost=l});let i=l=>this._resolveContextLost?.({reason:"destroyed",message:"Computer entered sleep mode, or too many apps or browser tabs are using the GPU."}),s=e.gl||null;if(s=s||(I()?rn(this.canvasContext.canvas,{...e,onContextLost:i}):null),!s)throw new Error("WebGL context creation failed");this.handle=s,this.gl=this.handle,this.canvasContext.resize(),this.info=nn(this.gl),this.gl.device=this,this.gl._version=this.isWebGL2?2:1;let{enable:a=!0,copyState:u=!1}=e;if(ut(this.gl,{enable:a,copyState:u,log:(...l)=>h.log(1,...l)()}),I()&&e.debug&&(this.gl=xn(this.gl,{...e,throwOnError:!0}),this.debug=!0,h.level=Math.max(h.level,1),h.warn("WebGL debug mode activated. Performance reduced.")()),I()&&e.spector){let l=this.handle.canvas||e.canvas;this.spector=Rn({...this.props,canvas:l})}}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return ft(this.gl,e)}isTextureFormatFilterable(e){return cn(this.gl,e)}isTextureFormatRenderable(e){return ln(this.gl,e)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let t=this._getBufferProps(e);return new X(this,t)}_createTexture(e){return new U(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new ce(this,e)}createShader(e){return new $e(this,e)}createFramebuffer(e){return new J(this,e)}createRenderPipeline(e){return new Ze(this,e)}createVertexArray(e){return new pe(this,e)}beginRenderPass(e){return new ze(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}createTransformFeedback(e){return new Je(this,e)}renderPass=null;getDefaultRenderPass(){return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:this.canvasContext.getCurrentFramebuffer()}),this.renderPass}createCommandEncoder(e){return new qe(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,t){return wn(e,t)}readPixelsToBufferWebGL(e,t){return Wn(e,t)}setParametersWebGL(e){k(this,e)}getParametersWebGL(e){return we(this,e)}withParametersWebGL(e,t){Y(this,e,t)}clearWebGL(e){Hn(this,e)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spector;_webglLimits;get webglLimits(){return this._webglLimits=this._webglLimits||En(this.gl),this._webglLimits}loseDevice(){let e=!1,t=this.gl.getExtension("WEBGL_lose_context");return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){te(this.gl)}popState(){Q(this.gl)}setSpectorMetadata(e,t){e.__SPECTOR_Metadata=t}getGLKey(e,t){t=t||this.gl2||this.gl;let n=Number(e);for(let i in t)if(t[i]===n)return`GL.${i}`;return String(e)}_constants;setConstantAttribute(e,t){this._constants=this._constants||new Array(this.limits.maxVertexAttributes).fill(null);let n=this._constants[e];switch(n&&rs(n,t)&&h.info(1,`setConstantAttribute(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:Jo(this,e,t);break;case Int32Array:es(this,e,t);break;case Uint32Array:ts(this,e,t);break;default:S(!1)}}},K=et;g(K,"type","webgl");function Qo(r){return typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext?!0:Boolean(r&&Number.isFinite(r._version))}function Jo(r,e,t){switch(t.length){case 1:r.gl.vertexAttrib1fv(e,t);break;case 2:r.gl.vertexAttrib2fv(e,t);break;case 3:r.gl.vertexAttrib3fv(e,t);break;case 4:r.gl.vertexAttrib4fv(e,t);break;default:S(!1)}}function es(r,e,t){r.gl.vertexAttribI4iv(e,t)}function ts(r,e,t){r.gl.vertexAttribI4uiv(e,t)}function rs(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}return Jn(ns);})();
16
+ </pre></code>`,a.style.top="10px",a.style.left="10px",a.style.position="absolute",a.style.zIndex="9999",a.style.width="100%",a.style.textAlign="left",document.body.appendChild(a);let c=document.getElementsByClassName("luma-compiler-log-error");c[0]?.scrollIntoView&&c[0].scrollIntoView(),a.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},Fe=nr;E(Fe,"defaultProps",{..._.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function ji(t){return rr(t.source).name||t.id||ee(`unnamed ${t.stage}-shader`)}var ir=class extends _{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){super(e,r,ir.defaultProps)}},Be=ir;E(Be,"defaultProps",{..._.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var or=class extends _{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,r={}){super(e,r,or.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let r=!e;if(e){let[n,i]=Array.isArray(e)?e:[e.width,e.height];r=r||i!==this.height||n!==this.width,this.width=n,this.height=i}r&&(f.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(r=>{if(typeof r=="string"){let n=this.createColorTexture(r);return this.attachResource(n),n.view}return r instanceof I?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof I?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let i=this.device._createTexture({...this.colorAttachments[n].props,width:e,height:r});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=i.view,this.attachResource(i.view)}if(this.depthStencilAttachment){let n=this.device._createTexture({...this.depthStencilAttachment.props,width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}}},pe=or;E(pe,"defaultProps",{..._.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var sr=class extends _{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,r){super(e,r,sr.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},Ie=sr;E(Ie,"defaultProps",{..._.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}});var ar=class extends _{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){super(e,r,ar.defaultProps)}},Ne=ar;E(Ne,"defaultProps",{..._.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var ur=class extends _{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,r){super(e,r,ur.defaultProps)}},De=ur;E(De,"defaultProps",{..._.defaultProps,measureExecutionTime:void 0});var cr=class extends _{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,cr.defaultProps)}},ve=cr;E(ve,"defaultProps",{..._.defaultProps});function sn(t){let[e,r]=qi[t],n=e==="i32"||e==="u32",i=e!=="u32",s=Zi[e]*r,a=Qi(e,r);return{dataType:e,components:r,defaultVertexFormat:a,byteLength:s,integer:n,signed:i}}function Qi(t,e){let r;switch(t){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?r:`${r}x${e}`}var qi={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Zi={f32:4,f16:2,i32:4,u32:4};function lr(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,n]=t.split("x"),i=r,s=n?parseInt(n):1,a=It(i),c={type:i,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return e&&(c.webglOnly=!0),c}function an(t,e){let r={};for(let n of t.attributes)r[n.name]=Ji(t,e,n.name);return r}function un(t,e,r=16){let n=an(t,e),i=new Array(r).fill(null);for(let s of Object.values(n))i[s.location]=s;return i}function Ji(t,e,r){let n=eo(t,r),i=to(e,r);if(!n)return null;let s=sn(n.type),a=i?.vertexFormat||s.defaultVertexFormat,c=lr(a);return{attributeName:i?.attributeName||n.name,bufferName:i?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:s.integer,stepMode:i?.stepMode||n.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function eo(t,e){let r=t.attributes.find(n=>n.name===e);return r||f.warn(`shader layout attribute "${e}" not present in shader`),r||null}function to(t,e){ro(t);let r=no(t,e);return r||(r=io(t,e),r)?r:(f.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function ro(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&f.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function no(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function io(t,e){for(let r of t){let n=r.byteStride;if(typeof r.byteStride!="number")for(let s of r.attributes||[]){let a=lr(s.format);n+=a.byteLength}let i=r.attributes?.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}function fr(t,e){let r={...t,attributes:t.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let i=r.attributes.find(s=>s.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):f.warn(`shader layout attribute ${n.name} not present in shader`)}return r}var dr=class extends _{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,dr.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=un(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){throw new Error("constant attributes not supported")}},we=dr;E(we,"defaultProps",{..._.defaultProps,renderPipeline:null});var mr=class extends _{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,mr.defaultProps)}},Oe=mr;E(Oe,"defaultProps",{..._.defaultProps,layout:void 0,buffers:{}});var hr=class extends _{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,hr.defaultProps)}},Ue=hr;E(Ue,"defaultProps",{..._.defaultProps,type:void 0,count:void 0});var vt;function cn(t){return(!vt||vt.byteLength<t)&&(vt=new ArrayBuffer(t)),vt}function pr(t,e){let r=cn(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}function gr(t){let{target:e,source:r,start:n=0,count:i=1}=t,s=r.length,a=i*s,c=0;for(let l=n;c<s;c++)e[l++]=r[c];for(;c<a;)c<a-c?(e.copyWithin(n+c,n,n+c),c*=2):(e.copyWithin(n+c,n,n+a-c),c=a);return t.target}function ln(t){return qr(t)!==null||typeof t=="number"||typeof t=="boolean"}function Er(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let n=t[r];ln(n)?e.uniforms[r]=n:e.bindings[r]=n}),e}function br(t,e,r,n){let i=`See luma.gl ${r} Upgrade Guide at https://luma.gl/docs/upgrade-guide`,s=Object.getPrototypeOf(t);n.forEach(a=>{s.methodName||(s[a]=()=>{throw f.removed(`Calling removed method ${e}.${a}: `,i)(),new Error(a)})})}function _r(t,e,r){let{removedProps:n={},deprecatedProps:i={},replacedProps:s={}}=r;for(let c in n)if(c in e){let d=n[c]?`${t}.${n[c]}`:"N/A";f.removed(`${t}.${c}`,d)()}for(let c in i)if(c in e){let l=i[c];f.deprecated(`${t}.${c}`,`${t}.${l}`)()}let a=null;for(let[c,l]of Object.entries(s))c in e&&(f.deprecated(`${t}.${c}`,`${t}.${l}`)(),a=a||Object.assign({},e),a[l]=e[c],delete a[c]);return a||e}var oo="";async function Tr(t,e){return await new Promise((r,n)=>{try{let i=new Image;i.onload=()=>r(i),i.onerror=()=>n(new Error(`Could not load image ${t}.`)),i.crossOrigin=e?.crossOrigin||"anonymous",i.src=t.startsWith("http")?t:oo+t}catch(i){n(i)}})}async function at(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),e&&(n.id=e),new Promise((i,s)=>{n.onload=i,n.onerror=a=>s(new Error(`Unable to load script '${t}': ${a}`)),r.appendChild(n)})}var o=y(S(),1),ct={[o.GL.BLEND]:!1,[o.GL.BLEND_COLOR]:new Float32Array([0,0,0,0]),[o.GL.BLEND_EQUATION_RGB]:o.GL.FUNC_ADD,[o.GL.BLEND_EQUATION_ALPHA]:o.GL.FUNC_ADD,[o.GL.BLEND_SRC_RGB]:o.GL.ONE,[o.GL.BLEND_DST_RGB]:o.GL.ZERO,[o.GL.BLEND_SRC_ALPHA]:o.GL.ONE,[o.GL.BLEND_DST_ALPHA]:o.GL.ZERO,[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([0,0,0,0]),[o.GL.COLOR_WRITEMASK]:[!0,!0,!0,!0],[o.GL.CULL_FACE]:!1,[o.GL.CULL_FACE_MODE]:o.GL.BACK,[o.GL.DEPTH_TEST]:!1,[o.GL.DEPTH_CLEAR_VALUE]:1,[o.GL.DEPTH_FUNC]:o.GL.LESS,[o.GL.DEPTH_RANGE]:new Float32Array([0,1]),[o.GL.DEPTH_WRITEMASK]:!0,[o.GL.DITHER]:!0,[o.GL.CURRENT_PROGRAM]:null,[o.GL.FRAMEBUFFER_BINDING]:null,[o.GL.RENDERBUFFER_BINDING]:null,[o.GL.VERTEX_ARRAY_BINDING]:null,[o.GL.ARRAY_BUFFER_BINDING]:null,[o.GL.FRONT_FACE]:o.GL.CCW,[o.GL.GENERATE_MIPMAP_HINT]:o.GL.DONT_CARE,[o.GL.LINE_WIDTH]:1,[o.GL.POLYGON_OFFSET_FILL]:!1,[o.GL.POLYGON_OFFSET_FACTOR]:0,[o.GL.POLYGON_OFFSET_UNITS]:0,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE_VALUE]:1,[o.GL.SAMPLE_COVERAGE_INVERT]:!1,[o.GL.SCISSOR_TEST]:!1,[o.GL.SCISSOR_BOX]:new Int32Array([0,0,1024,1024]),[o.GL.STENCIL_TEST]:!1,[o.GL.STENCIL_CLEAR_VALUE]:0,[o.GL.STENCIL_WRITEMASK]:4294967295,[o.GL.STENCIL_BACK_WRITEMASK]:4294967295,[o.GL.STENCIL_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_REF]:0,[o.GL.STENCIL_VALUE_MASK]:4294967295,[o.GL.STENCIL_BACK_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_BACK_REF]:0,[o.GL.STENCIL_BACK_VALUE_MASK]:4294967295,[o.GL.STENCIL_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.STENCIL_BACK_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.VIEWPORT]:[0,0,1024,1024],[o.GL.TRANSFORM_FEEDBACK_BINDING]:null,[o.GL.COPY_READ_BUFFER_BINDING]:null,[o.GL.COPY_WRITE_BUFFER_BINDING]:null,[o.GL.PIXEL_PACK_BUFFER_BINDING]:null,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:null,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:o.GL.DONT_CARE,[o.GL.READ_FRAMEBUFFER_BINDING]:null,[o.GL.RASTERIZER_DISCARD]:!1,[o.GL.PACK_ALIGNMENT]:4,[o.GL.UNPACK_ALIGNMENT]:4,[o.GL.UNPACK_FLIP_Y_WEBGL]:!1,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:!1,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:o.GL.BROWSER_DEFAULT_WEBGL,[o.GL.PACK_ROW_LENGTH]:0,[o.GL.PACK_SKIP_PIXELS]:0,[o.GL.PACK_SKIP_ROWS]:0,[o.GL.UNPACK_ROW_LENGTH]:0,[o.GL.UNPACK_IMAGE_HEIGHT]:0,[o.GL.UNPACK_SKIP_PIXELS]:0,[o.GL.UNPACK_SKIP_ROWS]:0,[o.GL.UNPACK_SKIP_IMAGES]:0},w=(t,e,r)=>e?t.enable(r):t.disable(r),dn=(t,e,r)=>t.hint(r,e),Y=(t,e,r)=>t.pixelStorei(r,e),mn=(t,e,r)=>{let n=r===o.GL.FRAMEBUFFER_BINDING?o.GL.DRAW_FRAMEBUFFER:o.GL.READ_FRAMEBUFFER;return t.bindFramebuffer(n,e)},ut=(t,e,r)=>{let i={[o.GL.ARRAY_BUFFER_BINDING]:o.GL.ARRAY_BUFFER,[o.GL.COPY_READ_BUFFER_BINDING]:o.GL.COPY_READ_BUFFER,[o.GL.COPY_WRITE_BUFFER_BINDING]:o.GL.COPY_WRITE_BUFFER,[o.GL.PIXEL_PACK_BUFFER_BINDING]:o.GL.PIXEL_PACK_BUFFER,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:o.GL.PIXEL_UNPACK_BUFFER}[r];t.bindBuffer(i,e)};function Lr(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var hn={[o.GL.BLEND]:w,[o.GL.BLEND_COLOR]:(t,e)=>t.blendColor(...e),[o.GL.BLEND_EQUATION_RGB]:"blendEquation",[o.GL.BLEND_EQUATION_ALPHA]:"blendEquation",[o.GL.BLEND_SRC_RGB]:"blendFunc",[o.GL.BLEND_DST_RGB]:"blendFunc",[o.GL.BLEND_SRC_ALPHA]:"blendFunc",[o.GL.BLEND_DST_ALPHA]:"blendFunc",[o.GL.COLOR_CLEAR_VALUE]:(t,e)=>t.clearColor(...e),[o.GL.COLOR_WRITEMASK]:(t,e)=>t.colorMask(...e),[o.GL.CULL_FACE]:w,[o.GL.CULL_FACE_MODE]:(t,e)=>t.cullFace(e),[o.GL.DEPTH_TEST]:w,[o.GL.DEPTH_CLEAR_VALUE]:(t,e)=>t.clearDepth(e),[o.GL.DEPTH_FUNC]:(t,e)=>t.depthFunc(e),[o.GL.DEPTH_RANGE]:(t,e)=>t.depthRange(...e),[o.GL.DEPTH_WRITEMASK]:(t,e)=>t.depthMask(e),[o.GL.DITHER]:w,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:dn,[o.GL.CURRENT_PROGRAM]:(t,e)=>t.useProgram(e),[o.GL.RENDERBUFFER_BINDING]:(t,e)=>t.bindRenderbuffer(o.GL.RENDERBUFFER,e),[o.GL.TRANSFORM_FEEDBACK_BINDING]:(t,e)=>t.bindTransformFeedback?.(o.GL.TRANSFORM_FEEDBACK,e),[o.GL.VERTEX_ARRAY_BINDING]:(t,e)=>t.bindVertexArray(e),[o.GL.FRAMEBUFFER_BINDING]:mn,[o.GL.READ_FRAMEBUFFER_BINDING]:mn,[o.GL.ARRAY_BUFFER_BINDING]:ut,[o.GL.COPY_READ_BUFFER_BINDING]:ut,[o.GL.COPY_WRITE_BUFFER_BINDING]:ut,[o.GL.PIXEL_PACK_BUFFER_BINDING]:ut,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:ut,[o.GL.FRONT_FACE]:(t,e)=>t.frontFace(e),[o.GL.GENERATE_MIPMAP_HINT]:dn,[o.GL.LINE_WIDTH]:(t,e)=>t.lineWidth(e),[o.GL.POLYGON_OFFSET_FILL]:w,[o.GL.POLYGON_OFFSET_FACTOR]:"polygonOffset",[o.GL.POLYGON_OFFSET_UNITS]:"polygonOffset",[o.GL.RASTERIZER_DISCARD]:w,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE_VALUE]:"sampleCoverage",[o.GL.SAMPLE_COVERAGE_INVERT]:"sampleCoverage",[o.GL.SCISSOR_TEST]:w,[o.GL.SCISSOR_BOX]:(t,e)=>t.scissor(...e),[o.GL.STENCIL_TEST]:w,[o.GL.STENCIL_CLEAR_VALUE]:(t,e)=>t.clearStencil(e),[o.GL.STENCIL_WRITEMASK]:(t,e)=>t.stencilMaskSeparate(o.GL.FRONT,e),[o.GL.STENCIL_BACK_WRITEMASK]:(t,e)=>t.stencilMaskSeparate(o.GL.BACK,e),[o.GL.STENCIL_FUNC]:"stencilFuncFront",[o.GL.STENCIL_REF]:"stencilFuncFront",[o.GL.STENCIL_VALUE_MASK]:"stencilFuncFront",[o.GL.STENCIL_BACK_FUNC]:"stencilFuncBack",[o.GL.STENCIL_BACK_REF]:"stencilFuncBack",[o.GL.STENCIL_BACK_VALUE_MASK]:"stencilFuncBack",[o.GL.STENCIL_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_PASS]:"stencilOpFront",[o.GL.STENCIL_BACK_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:"stencilOpBack",[o.GL.VIEWPORT]:(t,e)=>t.viewport(...e),[o.GL.DEPTH_CLAMP_EXT]:w,[o.GL.POLYGON_OFFSET_LINE_WEBGL]:w,[o.GL.CLIP_DISTANCE0_WEBGL]:w,[o.GL.CLIP_DISTANCE1_WEBGL]:w,[o.GL.CLIP_DISTANCE2_WEBGL]:w,[o.GL.CLIP_DISTANCE3_WEBGL]:w,[o.GL.CLIP_DISTANCE4_WEBGL]:w,[o.GL.CLIP_DISTANCE5_WEBGL]:w,[o.GL.CLIP_DISTANCE6_WEBGL]:w,[o.GL.CLIP_DISTANCE7_WEBGL]:w,[o.GL.PACK_ALIGNMENT]:Y,[o.GL.UNPACK_ALIGNMENT]:Y,[o.GL.UNPACK_FLIP_Y_WEBGL]:Y,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:Y,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:Y,[o.GL.PACK_ROW_LENGTH]:Y,[o.GL.PACK_SKIP_PIXELS]:Y,[o.GL.PACK_SKIP_ROWS]:Y,[o.GL.UNPACK_ROW_LENGTH]:Y,[o.GL.UNPACK_IMAGE_HEIGHT]:Y,[o.GL.UNPACK_SKIP_PIXELS]:Y,[o.GL.UNPACK_SKIP_ROWS]:Y,[o.GL.UNPACK_SKIP_IMAGES]:Y,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(o.GL.FRAMEBUFFER,r)},blend:(t,e)=>e?t.enable(o.GL.BLEND):t.disable(o.GL.BLEND),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(o.GL.CULL_FACE):t.disable(o.GL.CULL_FACE),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(o.GL.DEPTH_TEST):t.disable(o.GL.DEPTH_TEST),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(o.GL.DITHER):t.disable(o.GL.DITHER),derivativeHint:(t,e)=>{t.hint(o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(o.GL.GENERATE_MIPMAP_HINT,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(o.GL.POLYGON_OFFSET_FILL):t.disable(o.GL.POLYGON_OFFSET_FILL),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(o.GL.SCISSOR_TEST):t.disable(o.GL.SCISSOR_TEST),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(o.GL.STENCIL_TEST):t.disable(o.GL.STENCIL_TEST),stencilMask:(t,e)=>{e=Lr(e)?e:[e,e];let[r,n]=e;t.stencilMaskSeparate(o.GL.FRONT,r),t.stencilMaskSeparate(o.GL.BACK,n)},stencilFunc:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;let[r,n,i,s,a,c]=e;t.stencilFuncSeparate(o.GL.FRONT,r,n,i),t.stencilFuncSeparate(o.GL.BACK,s,a,c)},stencilOp:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;let[r,n,i,s,a,c]=e;t.stencilOpSeparate(o.GL.FRONT,r,n,i),t.stencilOpSeparate(o.GL.BACK,s,a,c)},viewport:(t,e)=>t.viewport(...e)};function F(t,e,r){return e[t]!==void 0?e[t]:r[t]}var pn={blendEquation:(t,e,r)=>t.blendEquationSeparate(F(o.GL.BLEND_EQUATION_RGB,e,r),F(o.GL.BLEND_EQUATION_ALPHA,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(F(o.GL.BLEND_SRC_RGB,e,r),F(o.GL.BLEND_DST_RGB,e,r),F(o.GL.BLEND_SRC_ALPHA,e,r),F(o.GL.BLEND_DST_ALPHA,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(F(o.GL.POLYGON_OFFSET_FACTOR,e,r),F(o.GL.POLYGON_OFFSET_UNITS,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(F(o.GL.SAMPLE_COVERAGE_VALUE,e,r),F(o.GL.SAMPLE_COVERAGE_INVERT,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(o.GL.FRONT,F(o.GL.STENCIL_FUNC,e,r),F(o.GL.STENCIL_REF,e,r),F(o.GL.STENCIL_VALUE_MASK,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(o.GL.BACK,F(o.GL.STENCIL_BACK_FUNC,e,r),F(o.GL.STENCIL_BACK_REF,e,r),F(o.GL.STENCIL_BACK_VALUE_MASK,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(o.GL.FRONT,F(o.GL.STENCIL_FAIL,e,r),F(o.GL.STENCIL_PASS_DEPTH_FAIL,e,r),F(o.GL.STENCIL_PASS_DEPTH_PASS,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(o.GL.BACK,F(o.GL.STENCIL_BACK_FAIL,e,r),F(o.GL.STENCIL_BACK_PASS_DEPTH_FAIL,e,r),F(o.GL.STENCIL_BACK_PASS_DEPTH_PASS,e,r))},Ar={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[o.GL.CURRENT_PROGRAM]:e}),bindRenderbuffer:(t,e,r)=>t({[o.GL.RENDERBUFFER_BINDING]:r}),bindTransformFeedback:(t,e,r)=>t({[o.GL.TRANSFORM_FEEDBACK_BINDING]:r}),bindVertexArray:(t,e)=>t({[o.GL.VERTEX_ARRAY_BINDING]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case o.GL.FRAMEBUFFER:return t({[o.GL.DRAW_FRAMEBUFFER_BINDING]:r,[o.GL.READ_FRAMEBUFFER_BINDING]:r});case o.GL.DRAW_FRAMEBUFFER:return t({[o.GL.DRAW_FRAMEBUFFER_BINDING]:r});case o.GL.READ_FRAMEBUFFER:return t({[o.GL.READ_FRAMEBUFFER_BINDING]:r});default:return null}},bindBuffer:(t,e,r)=>{let n={[o.GL.ARRAY_BUFFER]:[o.GL.ARRAY_BUFFER_BINDING],[o.GL.COPY_READ_BUFFER]:[o.GL.COPY_READ_BUFFER_BINDING],[o.GL.COPY_WRITE_BUFFER]:[o.GL.COPY_WRITE_BUFFER_BINDING],[o.GL.PIXEL_PACK_BUFFER]:[o.GL.PIXEL_PACK_BUFFER_BINDING],[o.GL.PIXEL_UNPACK_BUFFER]:[o.GL.PIXEL_UNPACK_BUFFER_BINDING]}[e];return n?t({[n]:r}):{valueChanged:!0}},blendColor:(t,e,r,n,i)=>t({[o.GL.BLEND_COLOR]:new Float32Array([e,r,n,i])}),blendEquation:(t,e)=>t({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:e}),blendEquationSeparate:(t,e,r)=>t({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:r}),blendFunc:(t,e,r)=>t({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:r,[o.GL.BLEND_SRC_ALPHA]:e,[o.GL.BLEND_DST_ALPHA]:r}),blendFuncSeparate:(t,e,r,n,i)=>t({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:r,[o.GL.BLEND_SRC_ALPHA]:n,[o.GL.BLEND_DST_ALPHA]:i}),clearColor:(t,e,r,n,i)=>t({[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([e,r,n,i])}),clearDepth:(t,e)=>t({[o.GL.DEPTH_CLEAR_VALUE]:e}),clearStencil:(t,e)=>t({[o.GL.STENCIL_CLEAR_VALUE]:e}),colorMask:(t,e,r,n,i)=>t({[o.GL.COLOR_WRITEMASK]:[e,r,n,i]}),cullFace:(t,e)=>t({[o.GL.CULL_FACE_MODE]:e}),depthFunc:(t,e)=>t({[o.GL.DEPTH_FUNC]:e}),depthRange:(t,e,r)=>t({[o.GL.DEPTH_RANGE]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[o.GL.DEPTH_WRITEMASK]:e}),frontFace:(t,e)=>t({[o.GL.FRONT_FACE]:e}),lineWidth:(t,e)=>t({[o.GL.LINE_WIDTH]:e}),polygonOffset:(t,e,r)=>t({[o.GL.POLYGON_OFFSET_FACTOR]:e,[o.GL.POLYGON_OFFSET_UNITS]:r}),sampleCoverage:(t,e,r)=>t({[o.GL.SAMPLE_COVERAGE_VALUE]:e,[o.GL.SAMPLE_COVERAGE_INVERT]:r}),scissor:(t,e,r,n,i)=>t({[o.GL.SCISSOR_BOX]:new Int32Array([e,r,n,i])}),stencilMask:(t,e)=>t({[o.GL.STENCIL_WRITEMASK]:e,[o.GL.STENCIL_BACK_WRITEMASK]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===o.GL.FRONT?o.GL.STENCIL_WRITEMASK:o.GL.STENCIL_BACK_WRITEMASK]:r}),stencilFunc:(t,e,r,n)=>t({[o.GL.STENCIL_FUNC]:e,[o.GL.STENCIL_REF]:r,[o.GL.STENCIL_VALUE_MASK]:n,[o.GL.STENCIL_BACK_FUNC]:e,[o.GL.STENCIL_BACK_REF]:r,[o.GL.STENCIL_BACK_VALUE_MASK]:n}),stencilFuncSeparate:(t,e,r,n,i)=>t({[e===o.GL.FRONT?o.GL.STENCIL_FUNC:o.GL.STENCIL_BACK_FUNC]:r,[e===o.GL.FRONT?o.GL.STENCIL_REF:o.GL.STENCIL_BACK_REF]:n,[e===o.GL.FRONT?o.GL.STENCIL_VALUE_MASK:o.GL.STENCIL_BACK_VALUE_MASK]:i}),stencilOp:(t,e,r,n)=>t({[o.GL.STENCIL_FAIL]:e,[o.GL.STENCIL_PASS_DEPTH_FAIL]:r,[o.GL.STENCIL_PASS_DEPTH_PASS]:n,[o.GL.STENCIL_BACK_FAIL]:e,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:r,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:n}),stencilOpSeparate:(t,e,r,n,i)=>t({[e===o.GL.FRONT?o.GL.STENCIL_FAIL:o.GL.STENCIL_BACK_FAIL]:r,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_FAIL:o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:n,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_PASS:o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:i}),viewport:(t,e,r,n,i)=>t({[o.GL.VIEWPORT]:[e,r,n,i]})},ie=(t,e)=>t.isEnabled(e),Rr={[o.GL.BLEND]:ie,[o.GL.CULL_FACE]:ie,[o.GL.DEPTH_TEST]:ie,[o.GL.DITHER]:ie,[o.GL.POLYGON_OFFSET_FILL]:ie,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:ie,[o.GL.SAMPLE_COVERAGE]:ie,[o.GL.SCISSOR_TEST]:ie,[o.GL.STENCIL_TEST]:ie,[o.GL.RASTERIZER_DISCARD]:ie},gn=new Set([o.GL.ACTIVE_TEXTURE,o.GL.TRANSFORM_FEEDBACK_ACTIVE,o.GL.TRANSFORM_FEEDBACK_PAUSED,o.GL.TRANSFORM_FEEDBACK_BUFFER_BINDING,o.GL.UNIFORM_BUFFER_BINDING,o.GL.ELEMENT_ARRAY_BUFFER_BINDING,o.GL.IMPLEMENTATION_COLOR_READ_FORMAT,o.GL.IMPLEMENTATION_COLOR_READ_TYPE,o.GL.READ_BUFFER,o.GL.DRAW_BUFFER0,o.GL.DRAW_BUFFER1,o.GL.DRAW_BUFFER2,o.GL.DRAW_BUFFER3,o.GL.DRAW_BUFFER4,o.GL.DRAW_BUFFER5,o.GL.DRAW_BUFFER6,o.GL.DRAW_BUFFER7,o.GL.DRAW_BUFFER8,o.GL.DRAW_BUFFER9,o.GL.DRAW_BUFFER10,o.GL.DRAW_BUFFER11,o.GL.DRAW_BUFFER12,o.GL.DRAW_BUFFER13,o.GL.DRAW_BUFFER14,o.GL.DRAW_BUFFER15,o.GL.SAMPLER_BINDING,o.GL.TEXTURE_BINDING_2D,o.GL.TEXTURE_BINDING_2D_ARRAY,o.GL.TEXTURE_BINDING_3D,o.GL.TEXTURE_BINDING_CUBE_MAP]);function X(t,e){if(so(e))return;let r={};for(let i in e){let s=Number(i),a=hn[i];a&&(typeof a=="string"?r[a]=!0:a(t,e[i],s))}let n=t.state&&t.state.cache;if(n)for(let i in r){let s=pn[i];s(t,e,n)}}function Me(t,e=ct){if(typeof e=="number"){let i=e,s=Rr[i];return s?s(t,i):t.getParameter(i)}let r=Array.isArray(e)?e:Object.keys(e),n={};for(let i of r){let s=Rr[i];n[i]=s?s(t,Number(i)):t.getParameter(Number(i))}return n}function En(t){X(t,ct)}function so(t){for(let e in t)return!1;return!0}function bn(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),n=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&n&&t.length===e.length){for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0}return!1}var Sr=class{gl;program=null;stateStack=[];enable=!0;cache;log;constructor(e,{copyState:r=!1,log:n=()=>{}}={}){this.gl=e,this.cache=r?Me(e):Object.assign({},ct),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){R(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];X(this.gl,e),this.stateStack.pop()}_updateCache(e){let r=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){R(s!==void 0);let a=e[s],c=this.cache[s];bn(a,c)||(r=!0,n=c,i&&!(s in i)&&(i[s]=c),this.cache[s]=a)}return{valueChanged:r,oldValue:n}}};function Le(t){return t.state}function lt(t,e){let{enable:r=!0,copyState:n}=e;if(R(n!==void 0),!t.state){t.state=new Sr(t,{copyState:n}),uo(t);for(let s in Ar){let a=Ar[s];ao(t,s,a)}_n(t,"getParameter"),_n(t,"isEnabled")}let i=Le(t);return i.enable=r,t}function te(t){let e=Le(t);e||(lt(t,{copyState:!1}),e=Le(t)),e.push()}function q(t){let e=Le(t);R(e),e.pop()}function _n(t,e){let r=t[e].bind(t);t[e]=function(i){if(i===void 0||gn.has(i))return r(i);let s=Le(t);return i in s.cache||(s.cache[i]=r(i)),s.enable?s.cache[i]:r(i)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function ao(t,e,r){if(!t[e])return;let n=t[e].bind(t);t[e]=function(...s){let a=Le(t),{valueChanged:c,oldValue:l}=r(a._updateCache,...s);return c&&n(...s),l},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function uo(t){let e=t.useProgram.bind(t);t.useProgram=function(n){let i=Le(t);i.program!==n&&(e(n),i.program=n)}}var co={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Tn(t,e){e={...co,...e};let r=null,n=s=>r=s.statusMessage||r;t.addEventListener("webglcontextcreationerror",n,!1);let i=null;if(i||=t.getContext("webgl2",e),t.removeEventListener("webglcontextcreationerror",n,!1),!i)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(e.onContextLost){let{onContextLost:s}=e;t.addEventListener("webglcontextlost",a=>s(a),!1)}if(e.onContextRestored){let{onContextRestored:s}=e;t.addEventListener("webglcontextrestored",a=>s(a),!1)}return i}var We=y(S(),1);function Z(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function Ln(t,e){let r=t.getParameter(We.GL.VENDOR),n=t.getParameter(We.GL.RENDERER);Z(t,"WEBGL_debug_renderer_info",e);let i=e.WEBGL_debug_renderer_info,s=t.getParameter(i?i.UNMASKED_VENDOR_WEBGL:We.GL.VENDOR),a=t.getParameter(i?i.UNMASKED_RENDERER_WEBGL:We.GL.RENDERER),c=s||r,l=a||n,d=t.getParameter(We.GL.VERSION),m=An(c,l),b=lo(c,l),g=fo(c,l);return{type:"webgl",gpu:m,gpuType:g,gpuBackend:b,vendor:c,renderer:l,version:d,shadingLanguage:"glsl",shadingLanguageVersion:300}}function An(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function lo(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function fo(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(An(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var u=y(S(),1);var z=y(S(),1);function wt(t){switch(t){case"uint8":return z.GL.UNSIGNED_BYTE;case"sint8":return z.GL.BYTE;case"unorm8":return z.GL.UNSIGNED_BYTE;case"snorm8":return z.GL.BYTE;case"uint16":return z.GL.UNSIGNED_SHORT;case"sint16":return z.GL.SHORT;case"unorm16":return z.GL.UNSIGNED_SHORT;case"snorm16":return z.GL.SHORT;case"uint32":return z.GL.UNSIGNED_INT;case"sint32":return z.GL.INT;case"float16":return z.GL.HALF_FLOAT;case"float32":return z.GL.FLOAT}throw new Error(String(t))}var M="texture-compression-bc",C="texture-compression-astc",oe="texture-compression-etc2",mo="texture-compression-etc1-webgl",Ot="texture-compression-pvrtc-webgl",xr="texture-compression-atc-webgl",ft="float32-renderable-webgl",yr="float16-renderable-webgl",ho="rgb9e5ufloat_renderable-webgl",Cr="snorm8-renderable-webgl",dt="norm16-renderable-webgl",Gr="snorm16-renderable-webgl",Ut="float32-filterable",Rn="float16-filterable-webgl",mt="WEBGL_compressed_texture_s3tc",ht="WEBGL_compressed_texture_s3tc_srgb",He="EXT_texture_compression_rgtc",ke="EXT_texture_compression_bptc",po="WEBGL_compressed_texture_etc",go="WEBGL_compressed_texture_astc",Eo="WEBGL_compressed_texture_etc1",bo="WEBGL_compressed_texture_pvrtc",_o="WEBGL_compressed_texture_atc",Sn="EXT_texture_norm16",xn="EXT_render_snorm",To="EXT_color_buffer_float",Mt={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[xn],"norm16-renderable-webgl":[Sn],"snorm16-renderable-webgl":[Sn,xn],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[mt,ht,He,ke],"texture-compression-bc5-webgl":[He],"texture-compression-bc7-webgl":[ke],"texture-compression-etc2":[po],"texture-compression-astc":[go],"texture-compression-etc1-webgl":[Eo],"texture-compression-pvrtc-webgl":[bo],"texture-compression-atc-webgl":[_o]};function yn(t){return t in Mt}function Cn(t,e,r){return(Mt[e]||[]).every(i=>Z(t,i,r))}var ge={"rgb8unorm-unsized":{gl:u.GL.RGB,b:4,c:2,bpp:4,dataFormat:u.GL.RGB,types:[u.GL.UNSIGNED_BYTE,u.GL.UNSIGNED_SHORT_5_6_5]},"rgba8unorm-unsized":{gl:u.GL.RGBA,b:4,c:2,bpp:4,dataFormat:u.GL.RGBA,types:[u.GL.UNSIGNED_BYTE,u.GL.UNSIGNED_SHORT_4_4_4_4,u.GL.UNSIGNED_SHORT_5_5_5_1]},r8unorm:{gl:u.GL.R8,b:1,c:1,rb:!0},r8snorm:{gl:u.GL.R8_SNORM,b:1,c:1,render:Cr},r8uint:{gl:u.GL.R8UI,b:1,c:1,rb:!0},r8sint:{gl:u.GL.R8I,b:1,c:1,rb:!0},rg8unorm:{gl:u.GL.RG8,b:2,c:2,rb:!0},rg8snorm:{gl:u.GL.RG8_SNORM,b:2,c:2,render:Cr},rg8uint:{gl:u.GL.RG8UI,b:2,c:2,rb:!0},rg8sint:{gl:u.GL.RG8I,b:2,c:2,rb:!0},r16uint:{gl:u.GL.R16UI,b:2,c:1,rb:!0},r16sint:{gl:u.GL.R16I,b:2,c:1,rb:!0},r16float:{gl:u.GL.R16F,b:2,c:1,render:yr,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:u.GL.R16_EXT,b:2,c:1,f:dt,rb:!0},"r16snorm-webgl":{gl:u.GL.R16_SNORM_EXT,b:2,c:1,f:Gr},"rgba4unorm-webgl":{gl:u.GL.RGBA4,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:u.GL.RGB565,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:u.GL.RGB5_A1,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:u.GL.RGB8,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:u.GL.RGB8_SNORM,b:3,c:3,wgpu:!1},rgba8unorm:{gl:u.GL.RGBA8,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:u.GL.SRGB8_ALPHA8,b:4,c:4,bpp:4},rgba8snorm:{gl:u.GL.RGBA8_SNORM,b:4,c:4,render:Cr},rgba8uint:{gl:u.GL.RGBA8UI,b:4,c:4,bpp:4},rgba8sint:{gl:u.GL.RGBA8I,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:u.GL.RG16UI,b:4,c:1,bpp:4},rg16sint:{gl:u.GL.RG16I,b:4,c:2,bpp:4},rg16float:{gl:u.GL.RG16F,bpp:4,b:4,c:2,render:yr,filter:Rn,rb:!0},"rg16unorm-webgl":{gl:u.GL.RG16_EXT,b:2,c:2,render:dt},"rg16snorm-webgl":{gl:u.GL.RG16_SNORM_EXT,b:2,c:2,render:Gr},r32uint:{gl:u.GL.R32UI,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:u.GL.R32I,b:4,c:1,bpp:4,rb:!0},r32float:{gl:u.GL.R32F,bpp:4,b:4,c:1,render:ft,filter:Ut},rgb9e5ufloat:{gl:u.GL.RGB9_E5,b:4,c:3,p:1,render:ho},rg11b10ufloat:{gl:u.GL.R11F_G11F_B10F,b:4,c:3,p:1,render:ft,rb:!0},rgb10a2unorm:{gl:u.GL.RGB10_A2,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:u.GL.RGB10_A2UI,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:u.GL.RGB16_EXT,b:2,c:3,f:dt},"rgb16snorm-webgl":{gl:u.GL.RGB16_SNORM_EXT,b:2,c:3,f:dt},rg32uint:{gl:u.GL.RG32UI,b:8,c:2,rb:!0},rg32sint:{gl:u.GL.RG32I,b:8,c:2,rb:!0},rg32float:{gl:u.GL.RG32F,b:8,c:2,render:ft,filter:Ut,rb:!0},rgba16uint:{gl:u.GL.RGBA16UI,b:8,c:4,rb:!0},rgba16sint:{gl:u.GL.RGBA16I,b:8,c:4,rb:!0},rgba16float:{gl:u.GL.RGBA16F,b:8,c:4,render:yr,filter:Rn},"rgba16unorm-webgl":{gl:u.GL.RGBA16_EXT,b:2,c:4,render:dt,rb:!0},"rgba16snorm-webgl":{gl:u.GL.RGBA16_SNORM_EXT,b:2,c:4,render:Gr},"rgb32float-webgl":{gl:u.GL.RGB32F,render:ft,filter:Ut,gl2ext:To,dataFormat:u.GL.RGB,types:[u.GL.FLOAT]},rgba32uint:{gl:u.GL.RGBA32UI,b:16,c:4,rb:!0},rgba32sint:{gl:u.GL.RGBA32I,b:16,c:4,rb:!0},rgba32float:{gl:u.GL.RGBA32F,b:16,c:4,render:ft,filter:Ut,rb:!0},stencil8:{gl:u.GL.STENCIL_INDEX8,b:1,c:1,attachment:u.GL.STENCIL_ATTACHMENT,rb:!0},depth16unorm:{gl:u.GL.DEPTH_COMPONENT16,b:2,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.UNSIGNED_SHORT],rb:!0},depth24plus:{gl:u.GL.DEPTH_COMPONENT24,b:3,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.UNSIGNED_INT]},depth32float:{gl:u.GL.DEPTH_COMPONENT32F,b:4,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.FLOAT],rb:!0},"depth24plus-stencil8":{gl:u.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,rb:!0,depthTexture:!0,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.UNSIGNED_INT_24_8]},"depth24unorm-stencil8":{gl:u.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.UNSIGNED_INT_24_8],rb:!0},"depth32float-stencil8":{gl:u.GL.DEPTH32F_STENCIL8,b:5,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.FLOAT_32_UNSIGNED_INT_24_8_REV],rb:!0},"bc1-rgb-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_S3TC_DXT1_EXT,x:mt,f:M},"bc1-rgb-unorm-srgb-webgl":{gl:u.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:ht,f:M},"bc1-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT1_EXT,x:mt,f:M},"bc1-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:ht,f:M},"bc2-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT3_EXT,x:mt,f:M},"bc2-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,x:ht,f:M},"bc3-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT5_EXT,x:mt,f:M},"bc3-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,x:ht,f:M},"bc4-r-unorm":{gl:u.GL.COMPRESSED_RED_RGTC1_EXT,x:He,f:M},"bc4-r-snorm":{gl:u.GL.COMPRESSED_SIGNED_RED_RGTC1_EXT,x:He,f:M},"bc5-rg-unorm":{gl:u.GL.COMPRESSED_RED_GREEN_RGTC2_EXT,x:He,f:M},"bc5-rg-snorm":{gl:u.GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,x:He,f:M},"bc6h-rgb-ufloat":{gl:u.GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,x:ke,f:M},"bc6h-rgb-float":{gl:u.GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,x:ke,f:M},"bc7-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_BPTC_UNORM_EXT,x:ke,f:M},"bc7-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,x:ke,f:M},"etc2-rgb8unorm":{gl:u.GL.COMPRESSED_RGB8_ETC2,f:oe},"etc2-rgb8unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ETC2,f:oe},"etc2-rgb8a1unorm":{gl:u.GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgb8a1unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgba8unorm":{gl:u.GL.COMPRESSED_RGBA8_ETC2_EAC,f:oe},"etc2-rgba8unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,f:oe},"eac-r11unorm":{gl:u.GL.COMPRESSED_R11_EAC,f:oe},"eac-r11snorm":{gl:u.GL.COMPRESSED_SIGNED_R11_EAC,f:oe},"eac-rg11unorm":{gl:u.GL.COMPRESSED_RG11_EAC,f:oe},"eac-rg11snorm":{gl:u.GL.COMPRESSED_SIGNED_RG11_EAC,f:oe},"astc-4x4-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_4x4_KHR,f:C},"astc-4x4-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,f:C},"astc-5x4-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_5x4_KHR,f:C},"astc-5x4-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,f:C},"astc-5x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_5x5_KHR,f:C},"astc-5x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,f:C},"astc-6x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_6x5_KHR,f:C},"astc-6x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,f:C},"astc-6x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_6x6_KHR,f:C},"astc-6x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,f:C},"astc-8x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x5_KHR,f:C},"astc-8x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,f:C},"astc-8x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x6_KHR,f:C},"astc-8x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,f:C},"astc-8x8-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x8_KHR,f:C},"astc-8x8-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,f:C},"astc-10x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-10x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x6_KHR,f:C},"astc-10x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,f:C},"astc-10x8-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x8_KHR,f:C},"astc-10x8-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,f:C},"astc-10x10-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x10-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-12x10-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_12x10_KHR,f:C},"astc-12x10-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,f:C},"astc-12x12-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_12x12_KHR,f:C},"astc-12x12-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,f:C},"pvrtc-rgb4unorm-webgl":{gl:u.GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,f:Ot},"pvrtc-rgba4unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,f:Ot},"pvrtc-rbg2unorm-webgl":{gl:u.GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,f:Ot},"pvrtc-rgba2unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,f:Ot},"etc1-rbg-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_ETC1_WEBGL,f:mo},"atc-rgb-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_ATC_WEBGL,f:xr},"atc-rgba-unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,f:xr},"atc-rgbai-unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,f:xr}},Lo={[u.GL.RED]:1,[u.GL.RED_INTEGER]:1,[u.GL.RG]:2,[u.GL.RG_INTEGER]:2,[u.GL.RGB]:3,[u.GL.RGB_INTEGER]:3,[u.GL.RGBA]:4,[u.GL.RGBA_INTEGER]:4,[u.GL.DEPTH_COMPONENT]:1,[u.GL.DEPTH_STENCIL]:1,[u.GL.ALPHA]:1,[u.GL.LUMINANCE]:1,[u.GL.LUMINANCE_ALPHA]:2},Ao={[u.GL.FLOAT]:4,[u.GL.UNSIGNED_INT]:4,[u.GL.INT]:4,[u.GL.UNSIGNED_SHORT]:2,[u.GL.SHORT]:2,[u.GL.HALF_FLOAT]:2,[u.GL.BYTE]:1,[u.GL.UNSIGNED_BYTE]:1};function pt(t,e,r){let n=ge[e];if(!n||n.gl===void 0)return!1;let i=n.x||n.gl2ext;return i?Boolean(Z(t,i,r)):!0}function Gn(t,e,r){return pt(t,e,r)&&ge[e]?.rb}function Pn(t){if(typeof t=="string")return t;let e=Object.entries(ge).find(([,r])=>r.gl===t);if(!e)throw new Error(`Unknown texture format ${t}`);return e[0]}function gt(t){let r=ge[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}function Fn(t,e,r){if(!pt(t,e,r)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(Nt(e).signed)return!1}catch{return!1}return e.endsWith("32float")?Boolean(Z(t,"OES_texture_float_linear, extensions",r)):e.endsWith("16float")?Boolean(Z(t,"OES_texture_half_float_linear, extensions",r)):!0}function Bn(t,e,r){return!(!pt(t,e,r)||typeof e=="number")}function Ve(t){let e=ge[t],r=gt(t),n=Nt(t);return{format:r,dataFormat:e?.dataFormat||Ro(n.format,n.integer,n.normalized,r),type:n.dataType?wt(n.dataType):e?.types?.[0]||u.GL.UNSIGNED_BYTE,compressed:n.compressed}}function In(t){let e=ge[t];if(!e?.attachment)throw new Error(`${t} is not a depth stencil format`);return e.attachment}function Et(t){let e=Ve(t),r=Lo[e.dataFormat]||4,n=Ao[e.type]||1;return r*n}function Ro(t,e,r,n){if(n===u.GL.RGBA||n===u.GL.RGB)return n;switch(t){case"r":return e&&!r?u.GL.RED_INTEGER:u.GL.RED;case"rg":return e&&!r?u.GL.RG_INTEGER:u.GL.RG;case"rgb":return e&&!r?u.GL.RGB_INTEGER:u.GL.RGB;case"rgba":return e&&!r?u.GL.RGBA_INTEGER:u.GL.RGBA;default:return u.GL.RGBA}}var Nn={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Wt=class extends st{gl;extensions;testedFeatures=new Set;constructor(e,r,n){super([],n),this.gl=e,this.extensions=r,Z(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){for(let e of Object.keys(Nn))this.has(e)&&(yield e);for(let e of Object.keys(Mt))this.has(e)&&(yield e);return[]}has(e){return this.disabledFeatures[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),yn(e)&&Cn(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){for(let e of this);}getWebGLFeature(e){let r=Nn[e];return Boolean(typeof r=="string"?Z(this.gl,r,this.extensions):r)}};var re=y(S(),1),Ht=class extends ot{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(re.GL.MAX_TEXTURE_SIZE)}get maxTextureDimension3D(){return this.getParameter(re.GL.MAX_3D_TEXTURE_SIZE)}get maxTextureArrayLayers(){return this.getParameter(re.GL.MAX_ARRAY_TEXTURE_LAYERS)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(re.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS)}get maxSamplersPerShaderStage(){return this.getParameter(re.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(re.GL.MAX_UNIFORM_BUFFER_BINDINGS)}get maxUniformBufferBindingSize(){return this.getParameter(re.GL.MAX_UNIFORM_BLOCK_SIZE)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(re.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(re.GL.MAX_VERTEX_ATTRIBS)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(re.GL.MAX_VARYING_COMPONENTS)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};var B=y(S(),1);var G=y(S(),1);function K(t,e,r){if(So(e))return r(t);let{nocatch:n=!0}=e;te(t),X(t,e);let i;if(n)i=r(t),q(t);else try{i=r(t)}finally{q(t)}return i}function So(t){for(let e in t)return!1;return!0}var N=y(S(),1);var h=y(S(),1);function vn(t,e,r,n){if(Ge(e))return n(t);let i=t;te(i.gl);try{return Xt(t,e),X(i.gl,r),n(t)}finally{q(i.gl)}}function wn(t,e,r){if(Ge(e))return r(t);te(t.gl);try{return Xt(t,e),r(t)}finally{q(t.gl)}}function Xt(t,e){let r=t,{gl:n}=r;if(e.cullMode)switch(e.cullMode){case"none":n.disable(h.GL.CULL_FACE);break;case"front":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.FRONT);break;case"back":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.BACK);break}if(e.frontFace&&n.frontFace(Ae("frontFace",e.frontFace,{ccw:h.GL.CCW,cw:h.GL.CW})),e.unclippedDepth&&t.features.has("depth-clip-control")&&n.enable(h.GL.DEPTH_CLAMP_EXT),e.depthBias!==void 0&&n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0),t.features.has("provoking-vertex-webgl")){let s=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex;if(e.provokingVertex){let a=Ae("provokingVertex",e.provokingVertex,{first:h.GL.FIRST_VERTEX_CONVENTION_WEBGL,last:h.GL.LAST_VERTEX_CONVENTION_WEBGL});s?.provokingVertexWEBGL(a)}}if(t.features.has("polygon-mode-webgl")){let s=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode;if(e.polygonMode){let a=Ae("polygonMode",e.provokingVertex,{fill:h.GL.FILL_WEBGL,lint:h.GL.LINE_WEBGL});s?.polygonModeWEBGL(h.GL.FRONT,a),s?.polygonModeWEBGL(h.GL.BACK,a)}e.polygonOffsetLine&&n.enable(h.GL.POLYGON_OFFSET_LINE_WEBGL)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(h.GL.CLIP_DISTANCE0_WEBGL),e.clipDistance1&&n.enable(h.GL.CLIP_DISTANCE1_WEBGL),e.clipDistance2&&n.enable(h.GL.CLIP_DISTANCE2_WEBGL),e.clipDistance3&&n.enable(h.GL.CLIP_DISTANCE3_WEBGL),e.clipDistance4&&n.enable(h.GL.CLIP_DISTANCE4_WEBGL),e.clipDistance5&&n.enable(h.GL.CLIP_DISTANCE5_WEBGL),e.clipDistance6&&n.enable(h.GL.CLIP_DISTANCE6_WEBGL),e.clipDistance7&&n.enable(h.GL.CLIP_DISTANCE7_WEBGL)),e.depthWriteEnabled!==void 0&&n.depthMask(yo("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(h.GL.DEPTH_TEST):n.disable(h.GL.DEPTH_TEST),n.depthFunc(Vt("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;n.stencilMaskSeparate(h.GL.FRONT,i),n.stencilMaskSeparate(h.GL.BACK,i)}if(e.stencilReadMask&&f.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,s=Vt("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(h.GL.STENCIL_TEST):n.disable(h.GL.STENCIL_TEST),n.stencilFuncSeparate(h.GL.FRONT,s,0,i),n.stencilFuncSeparate(h.GL.BACK,s,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=Pr("stencilPassOperation",e.stencilPassOperation),s=Pr("stencilFailOperation",e.stencilFailOperation),a=Pr("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(h.GL.FRONT,s,a,i),n.stencilOpSeparate(h.GL.BACK,s,a,i)}if(e.blendColorOperation||e.blendAlphaOperation){n.enable(h.GL.BLEND);let i=Dn("blendColorOperation",e.blendColorOperation||"add"),s=Dn("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let a=kt("blendColorSrcFactor",e.blendColorSrcFactor||"one"),c=kt("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=kt("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),d=kt("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(a,c,l,d)}}function Vt(t,e){return Ae(t,e,{never:h.GL.NEVER,less:h.GL.LESS,equal:h.GL.EQUAL,"less-equal":h.GL.LEQUAL,greater:h.GL.GREATER,"not-equal":h.GL.NOTEQUAL,"greater-equal":h.GL.GEQUAL,always:h.GL.ALWAYS})}function Pr(t,e){return Ae(t,e,{keep:h.GL.KEEP,zero:h.GL.ZERO,replace:h.GL.REPLACE,invert:h.GL.INVERT,"increment-clamp":h.GL.INCR,"decrement-clamp":h.GL.DECR,"increment-wrap":h.GL.INCR_WRAP,"decrement-wrap":h.GL.DECR_WRAP})}function Dn(t,e){return Ae(t,e,{add:h.GL.FUNC_ADD,subtract:h.GL.FUNC_SUBTRACT,"reverse-subtract":h.GL.FUNC_REVERSE_SUBTRACT,min:h.GL.MIN,max:h.GL.MAX})}function kt(t,e){return Ae(t,e,{one:h.GL.ONE,zero:h.GL.ZERO,"src-color":h.GL.SRC_COLOR,"one-minus-src-color":h.GL.ONE_MINUS_SRC_COLOR,"dst-color":h.GL.DST_COLOR,"one-minus-dst-color":h.GL.ONE_MINUS_DST_COLOR,"src-alpha":h.GL.SRC_ALPHA,"one-minus-src-alpha":h.GL.ONE_MINUS_SRC_ALPHA,"dst-alpha":h.GL.DST_ALPHA,"one-minus-dst-alpha":h.GL.ONE_MINUS_DST_ALPHA})}function xo(t,e){return`Illegal parameter ${e} for ${t}`}function Ae(t,e,r){if(!(e in r))throw new Error(xo(t,e));return r[e]}function yo(t,e){return e}function Kt(t){let e={};return t.addressModeU&&(e[N.GL.TEXTURE_WRAP_S]=Fr(t.addressModeU)),t.addressModeV&&(e[N.GL.TEXTURE_WRAP_T]=Fr(t.addressModeV)),t.addressModeW&&(e[N.GL.TEXTURE_WRAP_R]=Fr(t.addressModeW)),t.magFilter&&(e[N.GL.TEXTURE_MAG_FILTER]=On(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[N.GL.TEXTURE_MIN_FILTER]=Co(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[N.GL.TEXTURE_MIN_LOD]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[N.GL.TEXTURE_MAX_LOD]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[N.GL.TEXTURE_COMPARE_MODE]=N.GL.COMPARE_REF_TO_TEXTURE),t.compare&&(e[N.GL.TEXTURE_COMPARE_FUNC]=Vt("compare",t.compare)),t.maxAnisotropy&&(e[N.GL.TEXTURE_MAX_ANISOTROPY_EXT]=t.maxAnisotropy),e}function Fr(t){switch(t){case"clamp-to-edge":return N.GL.CLAMP_TO_EDGE;case"repeat":return N.GL.REPEAT;case"mirror-repeat":return N.GL.MIRRORED_REPEAT}}function On(t){switch(t){case"nearest":return N.GL.NEAREST;case"linear":return N.GL.LINEAR}}function Co(t,e){if(!e)return On(t);switch(t){case"nearest":return e==="nearest"?N.GL.NEAREST_MIPMAP_NEAREST:N.GL.NEAREST_MIPMAP_LINEAR;case"linear":return e==="nearest"?N.GL.LINEAR_MIPMAP_NEAREST:N.GL.LINEAR_MIPMAP_LINEAR}}var W=y(S(),1),H=class extends P{device;gl;handle;glTarget;glUsage;glIndexType=W.GL.UNSIGNED_SHORT;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=Go(this.props.usage),this.glUsage=Po(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?W.GL.UNSIGNED_INT:W.GL.UNSIGNED_SHORT,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,n=e.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,r,e),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,r,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){R(e>=0);let r=e;e===0&&(r=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){let s=W.GL.COPY_WRITE_BUFFER;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,r,e),this.gl.bindBuffer(s,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let n=new Uint8Array(r),i=0;return this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,this.handle),this.gl.getBufferSubData(W.GL.COPY_READ_BUFFER,e,n,i,r),this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,null),this._setDebugData(n,e,r),n}};function Go(t){return t&P.INDEX?W.GL.ELEMENT_ARRAY_BUFFER:t&P.VERTEX?W.GL.ARRAY_BUFFER:t&P.UNIFORM?W.GL.UNIFORM_BUFFER:W.GL.ARRAY_BUFFER}function Po(t){return t&P.INDEX?W.GL.STATIC_DRAW:t&P.VERTEX?W.GL.STATIC_DRAW:t&P.UNIFORM?W.GL.DYNAMIC_DRAW:W.GL.STATIC_DRAW}var Br=y(S(),1);var ce=class extends Be{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=Kt(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,n]of Object.entries(e)){let i=Number(r);switch(i){case Br.GL.TEXTURE_MIN_LOD:case Br.GL.TEXTURE_MAX_LOD:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}};var se=class extends Pe{device;gl;handle;texture;constructor(e,r){super(e,{...I.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var Fo={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},$t=class extends I{MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,r){super(e,{...Fo,format:"rgba8unorm",...r}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=G.GL.RGBA,this.target=Bo(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:Tr(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new se(this.device,{...e,texture:this})}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let r=e.data;if(r instanceof Promise)return r.then(ne=>this.initialize(Object.assign({},e,{pixels:ne,data:ne}))),this;let n=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(n&&r.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,r.addEventListener("loadeddata",()=>this.initialize(e)),this;let{parameters:i={}}=e,{pixels:s=null,pixelStore:a={},textureUnit:c=void 0,mipmaps:l=!0}=e;r||(r=s);let{width:d,height:m,dataFormat:b,type:g,compressed:L=!1}=e,{depth:A=0}=e,D=gt(e.format);return{width:d,height:m,compressed:L,dataFormat:b,type:g}=this._deduceParameters({format:e.format,type:g,dataFormat:b,compressed:L,data:r,width:d,height:m}),this.width=d,this.height=m,this.glFormat=D,this.type=g,this.dataFormat=b,this.textureUnit=c,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(G.GL.TEXTURE0+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=l,this.setImageData({data:r,width:d,height:m,depth:A,format:D,type:g,dataFormat:b,parameters:a,compressed:L}),this.setSampler(e.sampler),this._setSamplerParameters(i),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),l&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),n&&(this._video={video:r,parameters:i,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(e){let{mipmaps:r=!0,parameters:n={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,r&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(n)}),this}setSampler(e={}){let r;e instanceof ce?(this.sampler=e,r=e.props):(this.sampler=new ce(this.device,e),r=e);let n=Kt(r);return this._setSamplerParameters(n),this}resize(e){let{height:r,width:n,mipmaps:i=!1}=e;return n!==this.width||r!==this.height?this.initialize({width:n,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:i}):this}update(){if(this._video){let{video:e,parameters:r,lastTime:n}=this._video;if(n===e.currentTime||e.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:e,parameters:r}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=e.currentTime}}generateMipmap(e={}){return this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),K(this.gl,e,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:n=null,level:i=0,glFormat:s=this.glFormat,offset:a=0,parameters:c={}}=e,{data:l=null,type:d=this.type,width:m=this.width,height:b=this.height,dataFormat:g=this.dataFormat,compressed:L=!1}=e;l||(l=n),{type:d,dataFormat:g,compressed:L,width:m,height:b}=this._deduceParameters({format:this.props.format,type:d,dataFormat:g,compressed:L,data:l,width:m,height:b});let{gl:A}=this;A.bindTexture(this.target,this.handle);let D=null;if({data:l,dataType:D}=this._getDataType({data:l,compressed:L}),K(this.gl,c,()=>{switch(D){case"null":A.texImage2D(r,i,s,m,b,0,g,d,l);break;case"typed-array":A.texImage2D(r,i,s,m,b,0,g,d,l,a);break;case"buffer":this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,l.handle||l),this.device.gl.texImage2D(r,i,s,m,b,0,g,d,a),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null);break;case"browser-object":A.texImage2D(r,i,s,m,b,0,g,d,l);break;case"compressed":for(let[ne,fe]of l.entries())A.compressedTexImage2D(r,ne,fe.format,fe.width,fe.height,0,fe.data);break;default:R(!1,"Unknown image data type")}}),l&&l.byteLength)this.trackAllocatedMemory(l.byteLength,"Texture");else{let ne=Et(this.props.format);this.trackAllocatedMemory(this.width*this.height*ne,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:r=null,data:n=null,x:i=0,y:s=0,width:a=this.width,height:c=this.height,level:l=0,glFormat:d=this.glFormat,type:m=this.type,dataFormat:b=this.dataFormat,compressed:g=!1,offset:L=0,parameters:A={}}){if({type:m,dataFormat:b,compressed:g,width:a,height:c}=this._deduceParameters({format:this.props.format,type:m,dataFormat:b,compressed:g,data:n,width:a,height:c}),R(this.depth===1,"texSubImage not supported for 3D textures"),n||(n=r),n&&n.data){let D=n;n=D.data,a=D.shape[0],c=D.shape[1]}n instanceof H&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),K(this.gl,A,()=>{g?this.gl.compressedTexSubImage2D(e,l,i,s,a,c,d,n):n===null?this.gl.texSubImage2D(e,l,i,s,a,c,b,m,null):ArrayBuffer.isView(n)?this.gl.texSubImage2D(e,l,i,s,a,c,b,m,n,L):typeof WebGLBuffer<"u"&&n instanceof WebGLBuffer?(this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,n),this.device.gl.texSubImage2D(e,l,i,s,a,c,b,m,L),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null)):this.device.gl.texSubImage2D(e,l,i,s,a,c,b,m,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return f.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(G.GL.ACTIVE_TEXTURE)-G.GL.TEXTURE0}bind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(this.target,null),e}_getDataType({data:e,compressed:r=!1}){return r?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof H?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:r,data:n}=e,{width:i,height:s,dataFormat:a,type:c,compressed:l}=e,d=Ve(r);return a=a||d.dataFormat,c=c||d.type,l=l||d.compressed,{width:i,height:s}=this._deduceImageSize(n,i,s),{dataFormat:a,type:c,compressed:l,width:i,height:s,format:r,data:n}}_deduceImageSize(e,r,n){let i;return typeof ImageData<"u"&&e instanceof ImageData?i={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?i={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?i={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?i={width:e.videoWidth,height:e.videoHeight}:e?i={width:r,height:n}:i={width:r>=0?r:1,height:n>=0?n:1},R(i,"Could not deduced texture size"),R(r===void 0||i.width===r,"Deduced texture width does not match supplied width"),R(n===void 0||i.height===n,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(e){let{gl:r}=this,{width:n,height:i,pixels:s,data:a,format:c=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,d=s||a,m=await Promise.all($t.FACES.map(b=>{let g=d[b];return Promise.all(Array.isArray(g)?g:[g])}));this.bind(),$t.FACES.forEach((b,g)=>{m[g].length>1&&this.props.mipmaps!==!1&&f.warn(`${this.id} has mipmap and multiple LODs.`)(),m[g].forEach((L,A)=>{n&&i?r.texImage2D(b,A,c,n,i,0,c,l,L):r.texImage2D(b,A,c,c,l,L)})}),this.unbind()}setImageDataForFace(e){let{face:r,width:n,height:i,pixels:s,data:a,format:c=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,{gl:d}=this,m=s||a;return this.bind(),m instanceof Promise?m.then(b=>this.setImageDataForFace(Object.assign({},e,{face:r,data:b,pixels:b}))):this.width||this.height?d.texImage2D(r,0,c,n,i,0,c,l,m):d.texImage2D(r,0,c,c,l,m),this}setImageData3D(e){let{level:r=0,dataFormat:n,format:i,type:s,width:a,height:c,depth:l=1,offset:d=0,data:m,parameters:b={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let g=Ve(i);if(K(this.gl,b,()=>{ArrayBuffer.isView(m)&&this.gl.texImage3D(this.target,r,g.format,a,c,l,0,g.dataFormat,g.type,m),m instanceof H&&(this.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,m.handle),this.gl.texImage3D(this.target,r,n,a,c,l,0,i,s,d))}),m&&m.byteLength)this.trackAllocatedMemory(m.byteLength,"Texture");else{let L=Et(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*L,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Ge(e)){Io(e),this.gl.bindTexture(this.target,this.handle);for(let[r,n]of Object.entries(e)){let i=Number(r),s=n;switch(i){case G.GL.TEXTURE_MIN_LOD:case G.GL.TEXTURE_MAX_LOD:this.gl.texParameterf(this.target,i,s);break;default:this.gl.texParameteri(this.target,i,s);break}}this.gl.bindTexture(this.target,null)}}},U=$t;E(U,"FACES",[G.GL.TEXTURE_CUBE_MAP_POSITIVE_X,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_X,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Y,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Y,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Z,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Z]);function Bo(t){switch(t.dimension){case"2d":return G.GL.TEXTURE_2D;case"cube":return G.GL.TEXTURE_CUBE_MAP;case"2d-array":return G.GL.TEXTURE_2D_ARRAY;case"3d":return G.GL.TEXTURE_3D;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function Io(t){f.log(1,"texture sampler parameters",t)()}var J=class extends pe{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,r){super(e,r);let n=r.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),!n){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(B.GL.FRAMEBUFFER,this.handle);for(let i=0;i<this.colorAttachments.length;++i){let s=this.colorAttachments[i],a=B.GL.COLOR_ATTACHMENT0+i;s&&this._attachOne(a,s)}if(this.depthStencilAttachment&&this._attachOne(In(this.depthStencilAttachment.props.format),this.depthStencilAttachment),r.check!==!1){let i=this.gl.checkFramebufferStatus(B.GL.FRAMEBUFFER);if(i!==B.GL.FRAMEBUFFER_COMPLETE)throw new Error(`Framebuffer ${Do(i)}`)}this.gl.bindFramebuffer(B.GL.FRAMEBUFFER,null)}}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}createDepthStencilTexture(e){return new U(this.device,{id:`${this.id}-depth-stencil`,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,r){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;e===void 0&&(e=this.gl.drawingBufferWidth),r===void 0&&(r=this.gl.drawingBufferHeight);for(let n of this.colorAttachments)n.texture.resize({width:e,height:r});return this.depthStencilAttachment&&this.depthStencilAttachment.texture.resize({width:e,height:r}),this}_attachOne(e,r){if(Array.isArray(r)){let[n,i=0,s=0]=r;return this._attachTexture(e,n,i,s),n}if(r instanceof U)return this._attachTexture(e,r,0,0),r;if(r instanceof se){let n=r;return this._attachTexture(e,n.texture,n.props.baseMipLevel,n.props.baseArrayLayer),r.texture}throw new Error("attach")}_attachTexture(e,r,n,i){let{gl:s}=this.device;switch(s.bindTexture(r.target,r.handle),r.target){case B.GL.TEXTURE_2D_ARRAY:case B.GL.TEXTURE_3D:s.framebufferTextureLayer(B.GL.FRAMEBUFFER,e,r.target,i,n);break;case B.GL.TEXTURE_CUBE_MAP:let a=No(n);s.framebufferTexture2D(B.GL.FRAMEBUFFER,e,a,r.handle,i);break;case B.GL.TEXTURE_2D:s.framebufferTexture2D(B.GL.FRAMEBUFFER,e,B.GL.TEXTURE_2D,r.handle,i);break;default:R(!1,"Illegal texture type")}s.bindTexture(r.target,null)}};function No(t){return t<B.GL.TEXTURE_CUBE_MAP_POSITIVE_X?t+B.GL.TEXTURE_CUBE_MAP_POSITIVE_X:t}function Do(t){switch(t){case B.GL.FRAMEBUFFER_COMPLETE:return"success";case B.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"Mismatched attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"No attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"Height/width mismatch";case B.GL.FRAMEBUFFER_UNSUPPORTED:return"Unsupported or split attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:return"Samples mismatch";default:return`${t}`}}var Xe=class extends he{device;presentationSize;_framebuffer=null;constructor(e,r){super(r),this.device=e,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new J(this.device,{handle:null}),this._framebuffer}update(){let e=this.getPixelSize();(e[0]!==this.presentationSize[0]||e[1]!==this.presentationSize[1])&&(this.presentationSize=e,this.resize())}resize(e){if(this.device.gl&&this.canvas){let r=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(r,e);return}}commit(){}};var vo={spector:f.get("spector")||f.get("inspect")},wo="https://spectorcdn.babylonjs.com/spector.bundle.js",Oo=1,$=null,Un=!1;async function Mn(t){if(!globalThis.SPECTOR)try{await at(wo)}catch(e){f.warn(String(e))}}function Wn(t){if(t={...vo,...t},!t?.spector||(!$&&globalThis.SPECTOR&&(f.probe(Oo,"SPECTOR found and initialized")(),$=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=$)),!$))return null;if(Un||(Un=!0,$.spyCanvases(),$?.onCaptureStarted.add(e=>f.info("Spector capture started:",e)()),$?.onCapture.add(e=>{f.info("Spector capture complete:",e)(),$?.getResultUI(),$?.resultView.display(),$?.resultView.addCapture(e)})),t?.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return $;$?.startCapture(t?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{f.info("Spector capture stopped after 2 seconds")(),$?.stopCapture()})}return $}var bt=y(S(),1);var Uo="https://unpkg.com/webgl-debug@2.0.1/index.js";function Hn(t){return t.luma=t.luma||{},t.luma}async function kn(){v()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await at(Uo))}function Vn(t,e={}){return t?e.debug?Wo(t,e):Mo(t):null}function Mo(t){let e=Hn(t);return e.realContext?e.realContext:t}function Wo(t,e){if(!globalThis.WebGLDebugUtils)return f.warn("webgl-debug not loaded")(),t;let r=Hn(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...bt.GL,...t});let n=globalThis.WebGLDebugUtils.makeDebugContext(t,Ho.bind(null,e),ko.bind(null,e));for(let a in bt.GL)!(a in n)&&typeof bt.GL[a]=="number"&&(n[a]=bt.GL[a]);class i{}Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.setPrototypeOf(i,n);let s=Object.create(i);return r.realContext=t,r.debugContext=s,s.debug=!0,s}function Ir(t,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Ho(t,e,r,n){n=Array.from(n).map(c=>c===void 0?"undefined":c);let i=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,n),a=`${i} in gl.${r}(${s})`;f.error(a)();debugger;if(t.throwOnError)throw new Error(a)}function ko(t,e,r){let n="";if(f.level>=1&&(n=Ir(e,r),f.log(1,n)()),t.break&&t.break.length>0&&(n=n||Ir(e,r),t.break.every(s=>n.indexOf(s)!==-1)))debugger;for(let i of r)if(i===void 0){if(n=n||Ir(e,r),t.throwOnError)throw new Error(`Undefined argument: ${n}`);f.error(`Undefined argument: ${n}`)();debugger}}var _t=y(S(),1);function Kn(t){let e=t.split(/\r?\n/),r=[];for(let n of e){if(n.length<=1)continue;let i=n.split(":");if(i.length===2){let[b,g]=i;r.push({message:g.trim(),type:Xn(b),lineNum:0,linePos:0});continue}let[s,a,c,...l]=i,d=parseInt(c,10);isNaN(d)&&(d=0);let m=parseInt(a,10);isNaN(m)&&(m=0),r.push({message:l.join(":").trim(),type:Xn(s),lineNum:d,linePos:m})}return r}function Xn(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var Ke=class extends Fe{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.VERTEX_SHADER);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.FRAGMENT_SHADER);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return Kn(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(i=>i.startsWith("#version ")?i:`#version 100
17
+ ${i}`)(e);let{gl:n}=this.device;if(n.shaderSource(this.handle,e),n.compileShader(this.handle),f.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);this.debugShader();return}f.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),f.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,_t.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,_t.GL.COMPILE_STATUS)?"success":"error"}};var Dr=y(S(),1);var Vo=256,Xo=1024,Ko=16384,Nr=6144,$e=class extends Ne{device;glParameters;constructor(e,r){super(e,r),this.device=e,te(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){q(this.device.gl),this.props.framebuffer&&X(this.device.gl,{framebuffer:null})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[Dr.GL.RASTERIZER_DISCARD]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),r.scissorTest=Boolean(e.scissorRect),e.scissorRect&&(r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[Dr.GL.STENCIL_REF]=e.stencilReference),this.glParameters=r,X(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=Ko,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=Vo,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=Xo,e.clearStencil=this.props.clearStencil),r!==0&&K(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){K(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(Nr,e,r);break;case Uint32Array:this.device.gl.clearBufferuiv(Nr,e,r);break;case Float32Array:default:this.device.gl.clearBufferfv(Nr,e,r);break}})}};var Re=y(S(),1);var x=y(S(),1);var Ye=y(S(),1);var O=y(S(),1),$o="Failed to deduce GL constant from typed array";function $n(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return O.GL.FLOAT;case Uint16Array:return O.GL.UNSIGNED_SHORT;case Uint32Array:return O.GL.UNSIGNED_INT;case Uint8Array:return O.GL.UNSIGNED_BYTE;case Uint8ClampedArray:return O.GL.UNSIGNED_BYTE;case Int8Array:return O.GL.BYTE;case Int16Array:return O.GL.SHORT;case Int32Array:return O.GL.INT;default:throw new Error($o)}}function Tt(t,e){let{clamped:r=!0}=e||{};switch(t){case O.GL.FLOAT:return Float32Array;case O.GL.UNSIGNED_SHORT:case O.GL.UNSIGNED_SHORT_5_6_5:case O.GL.UNSIGNED_SHORT_4_4_4_4:case O.GL.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;case O.GL.UNSIGNED_INT:return Uint32Array;case O.GL.UNSIGNED_BYTE:return r?Uint8ClampedArray:Uint8Array;case O.GL.BYTE:return Int8Array;case O.GL.SHORT:return Int16Array;case O.GL.INT:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var Yo={offset:0,stride:0,type:Ye.GL.FLOAT,size:1,divisor:0,normalized:!1,integer:!1},zo={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},ae=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return Tt(e.type||Ye.GL.FLOAT).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return R(e.size),Tt(e.type||Ye.GL.FLOAT).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new ae(Yo,...e)}constructor(...e){e.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return ae.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return ae.getBytesPerVertex(this)}_assign(e={}){return e=_r("Accessor",e,zo),e.type!==void 0&&(this.type=e.type,(e.type===Ye.GL.INT||e.type===Ye.GL.UNSIGNED_INT)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};var p=y(S(),1);function Yn(t){return jo.includes(t)}var jo=[p.GL.SAMPLER_2D,p.GL.SAMPLER_CUBE,p.GL.SAMPLER_3D,p.GL.SAMPLER_2D_SHADOW,p.GL.SAMPLER_2D_ARRAY,p.GL.SAMPLER_2D_ARRAY_SHADOW,p.GL.SAMPLER_CUBE_SHADOW,p.GL.INT_SAMPLER_2D,p.GL.INT_SAMPLER_3D,p.GL.INT_SAMPLER_CUBE,p.GL.INT_SAMPLER_2D_ARRAY,p.GL.UNSIGNED_INT_SAMPLER_2D,p.GL.UNSIGNED_INT_SAMPLER_3D,p.GL.UNSIGNED_INT_SAMPLER_CUBE,p.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY],zn={[p.GL.FLOAT]:[p.GL.FLOAT,1,"float","f32","float32"],[p.GL.FLOAT_VEC2]:[p.GL.FLOAT,2,"vec2","vec2<f32>","float32x2"],[p.GL.FLOAT_VEC3]:[p.GL.FLOAT,3,"vec3","vec3<f32>","float32x3"],[p.GL.FLOAT_VEC4]:[p.GL.FLOAT,4,"vec4","vec4<f32>","float32x4"],[p.GL.INT]:[p.GL.INT,1,"int","i32","sint32"],[p.GL.INT_VEC2]:[p.GL.INT,2,"ivec2","vec2<i32>","sint32x2"],[p.GL.INT_VEC3]:[p.GL.INT,3,"ivec3","vec3<i32>","sint32x3"],[p.GL.INT_VEC4]:[p.GL.INT,4,"ivec4","vec4<i32>","sint32x4"],[p.GL.UNSIGNED_INT]:[p.GL.UNSIGNED_INT,1,"uint","u32","uint32"],[p.GL.UNSIGNED_INT_VEC2]:[p.GL.UNSIGNED_INT,2,"uvec2","vec2<u32>","uint32x2"],[p.GL.UNSIGNED_INT_VEC3]:[p.GL.UNSIGNED_INT,3,"uvec3","vec3<u32>","uint32x3"],[p.GL.UNSIGNED_INT_VEC4]:[p.GL.UNSIGNED_INT,4,"uvec4","vec4<u32>","uint32x4"],[p.GL.BOOL]:[p.GL.FLOAT,1,"bool","f32","float32"],[p.GL.BOOL_VEC2]:[p.GL.FLOAT,2,"bvec2","vec2<f32>","float32x2"],[p.GL.BOOL_VEC3]:[p.GL.FLOAT,3,"bvec3","vec3<f32>","float32x3"],[p.GL.BOOL_VEC4]:[p.GL.FLOAT,4,"bvec4","vec4<f32>","float32x4"],[p.GL.FLOAT_MAT2]:[p.GL.FLOAT,8,"mat2","mat2x2<f32>"],[p.GL.FLOAT_MAT2x3]:[p.GL.FLOAT,8,"mat2x3","mat2x3<f32>"],[p.GL.FLOAT_MAT2x4]:[p.GL.FLOAT,8,"mat2x4","mat2x4<f32>"],[p.GL.FLOAT_MAT3x2]:[p.GL.FLOAT,12,"mat3x2","mat3x2<f32>"],[p.GL.FLOAT_MAT3]:[p.GL.FLOAT,12,"mat3","mat3x3<f32>"],[p.GL.FLOAT_MAT3x4]:[p.GL.FLOAT,12,"mat3x4","mat3x4<f32>"],[p.GL.FLOAT_MAT4x2]:[p.GL.FLOAT,16,"mat4x2","mat4x2<f32>"],[p.GL.FLOAT_MAT4x3]:[p.GL.FLOAT,16,"mat4x3","mat4x3<f32>"],[p.GL.FLOAT_MAT4]:[p.GL.FLOAT,16,"mat4","mat4x4<f32>"]};function vr(t){let e=zn[t];if(!e)throw new Error("uniform");let[r,n,,i]=e;return{format:i,components:n,glType:r}}function jn(t){let e=zn[t];if(!e)throw new Error("attribute");let[,r,,n,i]=e;return{attributeType:n,vertexFormat:i,components:r}}function Yt(t,e){let r={attributes:[],bindings:[]};r.attributes=Qo(t,e);let n=Jo(t,e);for(let c of n){let l=c.uniforms.map(d=>({name:d.name,format:d.format,byteOffset:d.byteOffset,byteStride:d.byteStride,arrayLength:d.arrayLength}));r.bindings.push({type:"uniform",name:c.name,location:c.location,visibility:(c.vertex?1:0)&(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let i=Zo(t,e),s=0;for(let c of i)if(Yn(c.type)){let{viewDimension:l,sampleType:d}=ts(c.type);r.bindings.push({type:"texture",name:c.name,location:s,viewDimension:l,sampleType:d}),c.textureUnit=s,s+=1}i.length&&(r.uniforms=i);let a=qo(t,e);return a?.length&&(r.varyings=a),r}function Qo(t,e){let r=[],n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let s=t.getActiveAttrib(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:c}=s,l=t.getAttribLocation(e,a);if(l>=0){let{attributeType:d}=jn(c),m=/instance/i.test(a)?"instance":"vertex";r.push({name:a,location:l,stepMode:m,type:d})}}return r.sort((i,s)=>i.location-s.location),r}function qo(t,e){let r=[],n=t.getProgramParameter(e,x.GL.TRANSFORM_FEEDBACK_VARYINGS);for(let i=0;i<n;i++){let s=t.getTransformFeedbackVarying(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:c,size:l}=s,{glType:d,components:m}=vr(c),b=new ae({type:d,size:l*m}),g={location:i,name:a,accessor:b};r.push(g)}return r.sort((i,s)=>i.location-s.location),r}function Zo(t,e){let r=[],n=t.getProgramParameter(e,x.GL.ACTIVE_UNIFORMS);for(let i=0;i<n;i++){let s=t.getActiveUniform(e,i);if(!s)throw new Error("activeInfo");let{name:a,size:c,type:l}=s,{name:d,isArray:m}=rs(a),b=t.getUniformLocation(e,d),g={location:b,name:d,size:c,type:l,isArray:m};if(r.push(g),g.size>1)for(let L=0;L<g.size;L++){let A=`${d}[${L}]`;b=t.getUniformLocation(e,A);let D={...g,name:A,location:b};r.push(D)}}return r}function Jo(t,e){let r=(s,a)=>t.getActiveUniformBlockParameter(e,s,a),n=[],i=t.getProgramParameter(e,x.GL.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){let a={name:t.getActiveUniformBlockName(e,s)||"",location:r(s,x.GL.UNIFORM_BLOCK_BINDING),byteLength:r(s,x.GL.UNIFORM_BLOCK_DATA_SIZE),vertex:r(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),fragment:r(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),uniformCount:r(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),uniforms:[]},c=r(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)||[],l=t.getActiveUniforms(e,c,x.GL.UNIFORM_TYPE),d=t.getActiveUniforms(e,c,x.GL.UNIFORM_SIZE),m=t.getActiveUniforms(e,c,x.GL.UNIFORM_OFFSET),b=t.getActiveUniforms(e,c,x.GL.UNIFORM_ARRAY_STRIDE);for(let g=0;g<a.uniformCount;++g){let L=t.getActiveUniform(e,c[g]);if(!L)throw new Error("activeInfo");a.uniforms.push({name:L.name,format:vr(l[g]).format,type:l[g],arrayLength:d[g],byteOffset:m[g],byteStride:b[g]})}n.push(a)}return n.sort((s,a)=>s.location-a.location),n}var es={[x.GL.SAMPLER_2D]:["2d","float"],[x.GL.SAMPLER_CUBE]:["cube","float"],[x.GL.SAMPLER_3D]:["3d","float"],[x.GL.SAMPLER_2D_SHADOW]:["3d","depth"],[x.GL.SAMPLER_2D_ARRAY]:["2d-array","float"],[x.GL.SAMPLER_2D_ARRAY_SHADOW]:["2d-array","depth"],[x.GL.SAMPLER_CUBE_SHADOW]:["cube","float"],[x.GL.INT_SAMPLER_2D]:["2d","sint"],[x.GL.INT_SAMPLER_3D]:["3d","sint"],[x.GL.INT_SAMPLER_CUBE]:["cube","sint"],[x.GL.INT_SAMPLER_2D_ARRAY]:["2d-array","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D]:["2d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_3D]:["3d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_CUBE]:["cube","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]:["2d-array","uint"]};function ts(t){let e=es[t];if(!e)throw new Error("sampler");let[r,n]=e;return{viewDimension:r,sampleType:n}}function rs(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}var T=y(S(),1);function Qn(t,e,r,n){let i=t,s=n;s===!0&&(s=1),s===!1&&(s=0);let a=typeof s=="number"?[s]:s;switch(r){case T.GL.SAMPLER_2D:case T.GL.SAMPLER_CUBE:case T.GL.SAMPLER_3D:case T.GL.SAMPLER_2D_SHADOW:case T.GL.SAMPLER_2D_ARRAY:case T.GL.SAMPLER_2D_ARRAY_SHADOW:case T.GL.SAMPLER_CUBE_SHADOW:case T.GL.INT_SAMPLER_2D:case T.GL.INT_SAMPLER_3D:case T.GL.INT_SAMPLER_CUBE:case T.GL.INT_SAMPLER_2D_ARRAY:case T.GL.UNSIGNED_INT_SAMPLER_2D:case T.GL.UNSIGNED_INT_SAMPLER_3D:case T.GL.UNSIGNED_INT_SAMPLER_CUBE:case T.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:if(typeof n!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,n);case T.GL.FLOAT:return t.uniform1fv(e,a);case T.GL.FLOAT_VEC2:return t.uniform2fv(e,a);case T.GL.FLOAT_VEC3:return t.uniform3fv(e,a);case T.GL.FLOAT_VEC4:return t.uniform4fv(e,a);case T.GL.INT:return t.uniform1iv(e,a);case T.GL.INT_VEC2:return t.uniform2iv(e,a);case T.GL.INT_VEC3:return t.uniform3iv(e,a);case T.GL.INT_VEC4:return t.uniform4iv(e,a);case T.GL.BOOL:return t.uniform1iv(e,a);case T.GL.BOOL_VEC2:return t.uniform2iv(e,a);case T.GL.BOOL_VEC3:return t.uniform3iv(e,a);case T.GL.BOOL_VEC4:return t.uniform4iv(e,a);case T.GL.UNSIGNED_INT:return i.uniform1uiv(e,a,1);case T.GL.UNSIGNED_INT_VEC2:return i.uniform2uiv(e,a,2);case T.GL.UNSIGNED_INT_VEC3:return i.uniform3uiv(e,a,3);case T.GL.UNSIGNED_INT_VEC4:return i.uniform4uiv(e,a,4);case T.GL.FLOAT_MAT2:return t.uniformMatrix2fv(e,!1,a);case T.GL.FLOAT_MAT3:return t.uniformMatrix3fv(e,!1,a);case T.GL.FLOAT_MAT4:return t.uniformMatrix4fv(e,!1,a);case T.GL.FLOAT_MAT2x3:return i.uniformMatrix2x3fv(e,!1,a);case T.GL.FLOAT_MAT2x4:return i.uniformMatrix2x4fv(e,!1,a);case T.GL.FLOAT_MAT3x2:return i.uniformMatrix3x2fv(e,!1,a);case T.GL.FLOAT_MAT3x4:return i.uniformMatrix3x4fv(e,!1,a);case T.GL.FLOAT_MAT4x2:return i.uniformMatrix4x2fv(e,!1,a);case T.GL.FLOAT_MAT4x3:return i.uniformMatrix4x3fv(e,!1,a)}throw new Error("Illegal uniform")}var k=y(S(),1);function qn(t){switch(t){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINE_STRIP;case"line-loop-webgl":return k.GL.LINE_LOOP;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLE_STRIP;case"triangle-fan-webgl":return k.GL.TRIANGLE_FAN;default:throw new Error(t)}}function Zn(t){switch(t){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINES;case"line-loop-webgl":return k.GL.LINES;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLES;case"triangle-fan-webgl":return k.GL.TRIANGLES;default:throw new Error(t)}}var Jn=4,ze=class extends Ie{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:n,bufferMode:i=Re.GL.SEPARATE_ATTRIBS}=r;switch(n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),f.time(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Yt(this.device.gl,this.handle),f.timeEnd(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=fr(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":f.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e){for(let[r,n]of Object.entries(e)){let i=this.shaderLayout.bindings.find(s=>s.name===r)||this.shaderLayout.bindings.find(s=>s.name===`${r}Uniforms`);if(!i){let s=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");f.warn(`Unknown binding "${r}" in render pipeline "${this.id}", expected one of ${s}`)();continue}switch(n||f.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(n instanceof H)&&!(n.buffer instanceof H))throw new Error("buffer value");break;case"texture":if(!(n instanceof se||n instanceof U||n instanceof J))throw new Error("texture value");break;case"sampler":f.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(i.type)}this.bindings[r]=n}}draw(e){let{renderPass:r,vertexArray:n,vertexCount:i,instanceCount:s,firstVertex:a=0,transformFeedback:c}=e,l=qn(this.props.topology),d=Boolean(n.indexBuffer),m=n.indexBuffer?.glIndexType,b=Number(s)>0;if(this.linkStatus!=="success")return f.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||i===0)return f.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(i===0)return f.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let g=r;return vn(this.device,this.props.parameters,g.glParameters,()=>{d&&b?this.device.gl.drawElementsInstanced(l,i||0,m,a,s||0):d?this.device.gl.drawElements(l,i||0,m,a):b?this.device.gl.drawArraysInstanced(l,a,i||0,s||0):this.device.gl.drawArrays(l,a,i||0),c&&c.end()}),n.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=Er(e);Object.keys(r).forEach(n=>{f.warn(`Unsupported value "${JSON.stringify(r[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),f.time(Jn,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),f.timeEnd(Jn,`linkProgram for ${this.id}`)(),f.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}f.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),f.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,e.LINK_STATUS)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,e.VALIDATE_STATUS)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,Re.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,r]of Object.entries(this.bindings))r instanceof U&&(r.update(),e=e&&r.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,n=0;for(let i of this.shaderLayout.bindings){let s=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!s)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:a}=i,c=e.getUniformBlockIndex(this.handle,a);if(c===Re.GL.INVALID_INDEX)throw new Error(`Invalid uniform block name ${a}`);e.uniformBlockBinding(this.handle,n,c),s instanceof H?e.bindBufferBase(Re.GL.UNIFORM_BUFFER,n,s.handle):e.bindBufferRange(Re.GL.UNIFORM_BUFFER,n,s.buffer.handle,s.offset||0,s.size||s.buffer.byteLength-s.offset),n+=1;break;case"texture":if(!(s instanceof se||s instanceof U||s instanceof J))throw new Error("texture");let l;if(s instanceof se)l=s.texture;else if(s instanceof U)l=s;else if(s instanceof J&&s.colorAttachments[0]instanceof U)f.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=s.colorAttachments[0];else throw new Error("No texture");e.activeTexture(Re.GL.TEXTURE0+r),e.bindTexture(l.target,l.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:n,type:i,textureUnit:s}=e,a=this.uniforms[r]??s;a!==void 0&&Qn(this.device.gl,n,i,a)}}};var j=y(S(),1);var zt=class extends ve{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":ns(this.device,r.options);break;case"copy-buffer-to-texture":is(this.device,r.options);break;case"copy-texture-to-buffer":os(this.device,r.options);break;case"copy-texture-to-texture":ss(this.device,r.options);break}}};function ns(t,e){let r=e.source,n=e.destination;t.gl.bindBuffer(j.GL.COPY_READ_BUFFER,r.handle),t.gl.bindBuffer(j.GL.COPY_WRITE_BUFFER,n.handle),t.gl.copyBufferSubData(j.GL.COPY_READ_BUFFER,j.GL.COPY_WRITE_BUFFER,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(j.GL.COPY_READ_BUFFER,null),t.gl.bindBuffer(j.GL.COPY_WRITE_BUFFER,null)}function is(t,e){throw new Error("Not implemented")}function os(t,e){let{source:r,mipLevel:n=0,aspect:i="all",width:s=e.source.width,height:a=e.source.height,depthOrArrayLayers:c=0,origin:l=[0,0],destination:d,byteOffset:m=0,bytesPerRow:b,rowsPerImage:g}=e;if(i!=="all")throw new Error("not supported");if(n!==0||c!==0||b||g)throw new Error("not implemented");let{framebuffer:L,destroyFramebuffer:A}=ei(r);try{let D=d,ne=s||L.width,fe=a||L.height,Ur=Ve(L.texture.props.format),ai=Ur.dataFormat,ui=Ur.type;t.gl.bindBuffer(j.GL.PIXEL_PACK_BUFFER,D.handle),t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,L.handle),t.gl.readPixels(l[0],l[1],ne,fe,ai,ui,m)}finally{t.gl.bindBuffer(j.GL.PIXEL_PACK_BUFFER,null),t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,null),A&&L.destroy()}}function ss(t,e){let{source:r,origin:n=[0,0],destination:i}=e,{width:s=e.destination.width,height:a=e.destination.width}=e,c=0,l=j.GL.RGBA,{framebuffer:d,destroyFramebuffer:m}=ei(r),[b,g]=n,L=!1;t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,d.handle);let A=null,D;if(i instanceof U)A=i,s=Number.isFinite(s)?s:A.width,a=Number.isFinite(a)?a:A.height,A.bind(0),D=A.destination;else throw new Error("whoops");return L||t.gl.copyTexImage2D(D,c,l,b,g,s,a,0),A&&A.unbind(),m&&d.destroy(),A}function ei(t){if(t instanceof I){let{width:e,height:r,id:n}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var je=class extends De{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new zt(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,n){}};var Qe=y(S(),1);var Ee=class extends we{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Ct()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,r?r.handle:null),this.indexBuffer=r}setBuffer(e,r){let n=r;if(n.glTarget===Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:a,offset:c,normalized:l,integer:d,divisor:m}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ARRAY_BUFFER,n.handle),d?this.device.gl.vertexAttribIPointer(e,i,s,a,c):this.device.gl.vertexAttribPointer(e,i,s,l,a,c),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,m||0),this.attributes[e]=n}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}init=!1;bindBeforeRender(){if(this.device.gl.bindVertexArray(this.handle),!this.init){let e=this.indexBuffer;this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,e?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let n=wt(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let i=Ee.isConstantAttributeZeroSupported(this.device)||e!==0;(r||i)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let n=as(r),i=n.byteLength*e,s=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),a=a||!us(n,this.bufferValue),a){let c=pr(r.constructor,s);gr({target:c,source:n,start:0,count:s}),this.buffer.write(c),this.bufferValue=r}return this.buffer}};function as(t){return Array.isArray(t)?new Float32Array(t):t}function us(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var le=y(S(),1);var qe=class extends Oe{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zn(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse||this._unbindBuffers(),this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let r in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let n=this._getVaryingIndex(e),{buffer:i,byteLength:s,byteOffset:a}=this._getBufferRange(r);if(n<0){this.unusedBuffers[e]=i,f.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:a},this.bindOnUse||this._bindBuffer(n,i,a,s)}getBuffer(e){if(ti(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof H)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(ti(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,Number(e),null)}_bindBuffer(e,r,n=0,i){let s=r&&r.handle;!s||i===void 0?this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s):this.gl.bindBufferRange(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s,n,i)}};function ti(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var be=y(S(),1),jt=class extends Ue{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(be.GL.TIME_ELAPSED_EXT)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?be.GL.ANY_SAMPLES_PASSED_CONSERVATIVE:be.GL.ANY_SAMPLES_PASSED)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(be.GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,be.GL.QUERY_RESULT_AVAILABLE);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(be.GL.GPU_DISJOINT_EXT)}getResult(){return this.device.gl.getQueryParameter(this.handle,be.GL.QUERY_RESULT)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((n,i)=>{let s=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):r++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(s)};requestAnimationFrame(s)}),this._pollingPromise}};var ue=y(S(),1);var V=y(S(),1);function wr(t){switch(t){case V.GL.ALPHA:case V.GL.R32F:case V.GL.RED:return 1;case V.GL.RG32F:case V.GL.RG:return 2;case V.GL.RGB:case V.GL.RGB32F:return 3;case V.GL.RGBA:case V.GL.RGBA32F:return 4;default:return R(!1),0}}function ri(t){switch(t){case V.GL.UNSIGNED_BYTE:return 1;case V.GL.UNSIGNED_SHORT_5_6_5:case V.GL.UNSIGNED_SHORT_4_4_4_4:case V.GL.UNSIGNED_SHORT_5_5_5_1:return 2;case V.GL.FLOAT:return 4;default:return R(!1),0}}function ni(t,e){let{sourceX:r=0,sourceY:n=0,sourceFormat:i=ue.GL.RGBA,sourceAttachment:s=ue.GL.COLOR_ATTACHMENT0}=e||{},{target:a=null,sourceWidth:c,sourceHeight:l,sourceType:d}=e||{},{framebuffer:m,deleteFramebuffer:b}=oi(t);R(m);let{gl:g,handle:L}=m;c=c||m.width,l=l||m.height;let A=s-ue.GL.COLOR_ATTACHMENT0;d=d||m.colorAttachments[A]?.texture?.type||ue.GL.UNSIGNED_BYTE,a=ls(a,d,i,c,l),d=d||$n(a);let D=g.bindFramebuffer(ue.GL.FRAMEBUFFER,L);return g.readPixels(r,n,c,l,i,d,a),g.bindFramebuffer(ue.GL.FRAMEBUFFER,D||null),b&&m.destroy(),a}function ii(t,e){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:s=ue.GL.RGBA,targetByteOffset:a=0}=e||{},{sourceWidth:c,sourceHeight:l,sourceType:d}=e||{},{framebuffer:m,deleteFramebuffer:b}=oi(t);R(m),c=c||m.width,l=l||m.height;let g=m;d=d||ue.GL.UNSIGNED_BYTE;let L=r;if(!L){let D=wr(s),ne=ri(d),fe=a+c*l*D*ne;L=g.device.createBuffer({byteLength:fe})}let A=t.device.createCommandEncoder();return A.copyTextureToBuffer({source:t,width:c,height:l,origin:[n,i],destination:L,byteOffset:a}),A.destroy(),b&&m.destroy(),L}function oi(t){return t instanceof pe?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:cs(t),deleteFramebuffer:!0}}function cs(t,e){let{device:r,width:n,height:i,id:s}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[t]})}function ls(t,e,r,n,i){if(t)return t;e=e||ue.GL.UNSIGNED_BYTE;let s=Tt(e,{clamped:!1}),a=wr(r);return new s(n*i*a)}var fs=256,ds=1024,ms=16384;var hs="clear: bad arguments";function si(t,e){let{framebuffer:r=null,color:n=null,depth:i=null,stencil:s=null}=e||{},a={};r&&(a.framebuffer=r);let c=0;n&&(c|=ms,n!==!0&&(a.clearColor=n)),i&&(c|=fs,i!==!0&&(a.clearDepth=i)),s&&(c|=ds,i!==!0&&(a.clearStencil=i)),R(c!==0,hs);let l=t.gl;K(l,a,()=>{l.clear(c)})}var Lt=1,Ze=class extends me{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(e){if(e instanceof Ze)return e;if(e?.device instanceof me)return e.device;if(!ps(e))throw new Error("Invalid WebGL2RenderingContext");return new Ze({gl:e})}static async create(e={}){f.groupCollapsed(Lt,"WebGLDevice created")();let r=[];e.debug&&r.push(kn()),e.spector&&r.push(Mn()),typeof e.canvas=="string"&&r.push(he.pageLoaded);let n=await Promise.allSettled(r);for(let a of n)a.status==="rejected"&&f.error(`Failed to initialize debug libraries ${a.reason}`)();if(f.probe(Lt+1,"DOM is loaded")(),e.gl?.device)return f.warn("reattaching existing device")(),Ze.attach(e.gl);let i=new Ze(e),s=`Created ${i.type}${i.debug?" debug":""} context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return f.probe(Lt,s)(),f.table(Lt,i.info)(),f.groupEnd(Lt)(),i}constructor(e){super({...e,id:e.id||ee("webgl-device")});let r=e.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let n=e.gl?.canvas||e.canvas;this.canvasContext=new Xe(this,{...e,canvas:n}),this.lost=new Promise(c=>{this._resolveContextLost=c});let i=e.gl||null;if(i||=Tn(this.canvasContext.canvas,{...e,onContextLost:c=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!i)throw new Error("WebGL context creation failed");this.handle=i,this.gl=i,this.gl.device=this,this.gl._version=2,this.info=Ln(this.gl,this._extensions),this.limits=new Ht(this.gl),this.features=new Wt(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:s=!0,copyState:a=!1}=e;lt(this.gl,{enable:s,copyState:a,log:(...c)=>f.log(1,...c)()}),e.debug&&(this.gl=Vn(this.gl,{...e,throwOnError:!0}),this.debug=!0,f.level=Math.max(f.level,1),f.warn("WebGL debug mode activated. Performance reduced.")()),e.spector&&(this.spectorJS=Wn({...this.props,canvas:this.handle.canvas}))}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return pt(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return Fn(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return Bn(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._getBufferProps(e);return new H(this,r)}_createTexture(e){return new U(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new ce(this,e)}createShader(e){return new Ke(this,e)}createFramebuffer(e){return new J(this,e)}createVertexArray(e){return new Ee(this,e)}createTransformFeedback(e){return new qe(this,e)}createQuerySet(e){return new jt(this,e)}createRenderPipeline(e){return new ze(this,e)}beginRenderPass(e){return new $e(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new je(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return ni(e,r)}readPixelsToBufferWebGL(e,r){return ii(e,r)}setParametersWebGL(e){X(this.gl,e)}getParametersWebGL(e){return Me(this.gl,e)}withParametersWebGL(e,r){K(this.gl,e,r)}clearWebGL(e){si(this,e)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){te(this.gl)}popState(){q(this.gl)}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){r=r||this.gl2||this.gl;let n=Number(e);for(let i in r)if(r[i]===n)return`GL.${i}`;return String(e)}_constants;setConstantAttributeWebGL(e,r){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[e];switch(i&&_s(i,r)&&f.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:gs(this,e,r);break;case Int32Array:Es(this,e,r);break;case Uint32Array:bs(this,e,r);break;default:R(!1)}}getExtension(e){return Z(this.gl,e,this._extensions),this._extensions}},At=Ze;E(At,"type","webgl");function ps(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&Number.isFinite(t._version))}function gs(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:R(!1)}}function Es(t,e,r){t.gl.vertexAttribI4iv(e,r)}function bs(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function _s(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Je="Resource subclass must define virtual methods",Se=class extends _{device;gl;gl2;_handle;_bound=!1;byteLength=0;constructor(e,r,n){super(e,r,n),this.device=e;let i=this.device.gl,{id:s}=r||{};this.gl=i,this.gl2=i,this.id=s||ee(this.constructor.name),this._handle=r?.handle,this._handle===void 0&&(this._handle=this._createHandle()),this.byteLength=0}toString(){return`${this.constructor.name}(${this.id})`}get handle(){return this._handle}delete({deleteChildren:e=!1}={}){let r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,r&&e&&r.filter(Boolean).forEach(n=>n.destroy()),this}bind(e=this.handle){if(typeof e!="function")return this._bindHandle(e),this;let r;return this._bound?r=e():(this._bindHandle(this.handle),this._bound=!0,r=e(),this._bound=!1,this._bindHandle(null)),r}unbind(){this.bind(null)}stubRemovedMethods(e,r,n){return br(this,e,r,n)}initialize(e){}_createHandle(){throw new Error(Je)}_deleteHandle(){throw new Error(Je)}_bindHandle(e){throw new Error(Je)}_getOptsFromHandle(){throw new Error(Je)}_getParameter(e,r){throw new Error(Je)}_setParameter(e,r){throw new Error(Je)}};var et=y(S(),1);var Or=class extends Se{get[Symbol.toStringTag](){return"Renderbuffer"}get width(){return this.props.width}get height(){return this.props.height}get format(){return this.props.format}get samples(){return this.props.samples}get attachment(){}glFormat;static isTextureFormatSupported(e,r){return Gn(e.gl,r,e._extensions)}constructor(e,r){if(typeof r.format=="number")throw new Error("Renderbuffer");super(e,r,Or.defaultProps),this.glFormat=gt(this.props.format),this._initialize(this.props)}resize(e){(e.width!==this.width||e.height!==this.height)&&(Object.assign(this.props,{...e,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(e){let{format:r,width:n,height:i,samples:s}=e;R(r,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,this.handle),s!==0?this.gl.renderbufferStorageMultisample(et.GL.RENDERBUFFER,s,this.glFormat,n,i):this.gl.renderbufferStorage(et.GL.RENDERBUFFER,this.glFormat,n,i),this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,null),this.trackAllocatedMemory(n*i*(s||1)*Et(this.format))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(e){this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,e)}},Rt=Or;E(Rt,"defaultProps",{id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0});return Ei(Ts);})();
18
18
  return __exports__;
19
19
  });