Files
lan-manager/web/node_modules/@antv/g-webgpu/dist/gwebgpu.js
openclaw 0a5f6a8047 Initial commit: Lan-manager project code
- Go backend (server/)
- Frontend (web/, server/static/)
- Database and deployment files
- Scripts and docs

Co-Authored-By: 狸花猫/Claude-Qwen3.6-Plus 🐾
2026-04-20 00:52:58 +08:00

1 line
165 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GWebGPU=t():e.GWebGPU=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=18)}([function(e,t,r){var n=r(9);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(9);function a(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,n(a.key),a)}}e.exports=function(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(29)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},function(e,t){function r(e,t,r,n,a,i,o){try{var u=e[i](o),f=u.value}catch(e){return void r(e)}u.done?t(f):Promise.resolve(f).then(n,a)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(a,i){var o=e.apply(t,n);function u(e){r(o,a,i,u,f,"next",e)}function f(e){r(o,a,i,u,f,"throw",e)}u(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(20),a=r(26),i=r(27),o=i&&i.isTypedArray,u=o?a(o):n;e.exports=u},function(e,t){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(10),a=r(23),i=r(24),o=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":o&&o in Object(e)?a(e):i(e)}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,r){var n=r(6).default,a=r(19);e.exports=function(e){var t=a(e,"string");return"symbol"===n(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(21).Symbol;e.exports=n},function(e,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;e.exports=r}).call(this,r(22))},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(7),a=r(8);e.exports=function(e){return"number"==typeof e||a(e)&&"[object Number]"==n(e)}},function(e,t){var r=Array.isArray;e.exports=r},function(e,t,r){e.exports=function(){"use strict";var e=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},t=function(e,t){for(var r=Object.keys(t),n=0;n<r.length;++n)e[r[n]]=t[r[n]];return e};function r(e){var t=new Error("(regl) "+e);throw console.error(t),t}function n(e,t){e||r(t)}function a(e){return e?": "+e:""}function i(e,t){switch(t){case"number":return"number"==typeof e;case"object":return"object"==typeof e;case"string":return"string"==typeof e;case"boolean":return"boolean"==typeof e;case"function":return"function"==typeof e;case"undefined":return void 0===e;case"symbol":return"symbol"==typeof e}}function o(e,t,n){t.indexOf(e)<0&&r("invalid value"+a(n)+". must be one of: "+t)}var u=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function f(e,t){for(e+="";e.length<t;)e=" "+e;return e}function s(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function c(e,t){this.number=e,this.line=t,this.errors=[]}function l(e,t,r){this.file=e,this.line=t,this.message=r}function d(){var e=new Error,t=(e.stack||e).toString(),r=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(t);if(r)return r[1];var n=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(t);return n?n[1]:"unknown"}function p(){var e=new Error,t=(e.stack||e).toString(),r=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(t);if(r)return r[1];var n=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(t);return n?n[1]:"unknown"}function m(e,t){var r,n=e.split("\n"),a=1,i=0,o={unknown:new s,0:new s};o.unknown.name=o[0].name=t||d(),o.unknown.lines.push(new c(0,""));for(var u=0;u<n.length;++u){var f=n[u],l=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(f);if(l)switch(l[1]){case"line":var p=/(\d+)(\s+\d+)?/.exec(l[2]);p&&(a=0|p[1],p[2]&&((i=0|p[2])in o||(o[i]=new s)));break;case"define":var m=/SHADER_NAME(_B64)?\s+(.*)$/.exec(l[2]);m&&(o[i].name=m[1]?(r=m[2],"undefined"!=typeof atob?atob(r):"base64:"+r):m[2])}o[i].lines.push(new c(a++,f))}return Object.keys(o).forEach((function(e){var t=o[e];t.lines.forEach((function(e){t.index[e.number]=e}))})),o}function h(e){e._commandRef=d()}function E(e,t){var n=p();r(e+" in command "+(t||d())+("unknown"===n?"":" called from "+n))}function b(e,t,r,n){i(e,t)||E("invalid parameter type"+a(r)+". expected "+t+", got "+typeof e,n||d())}var v={};function y(e,t){return 32820===e||32819===e||33635===e?2:34042===e?4:v[e]*t}function g(e){return!(e&e-1||!e)}v[5120]=v[5121]=1,v[5122]=v[5123]=v[36193]=v[33635]=v[32819]=v[32820]=2,v[5124]=v[5125]=v[5126]=v[34042]=4;var _=t(n,{optional:function(e){e()},raise:r,commandRaise:E,command:function(e,t,r){e||E(t,r||d())},parameter:function(e,t,n){e in t||r("unknown parameter ("+e+")"+a(n)+". possible values: "+Object.keys(t).join())},commandParameter:function(e,t,r,n){e in t||E("unknown parameter ("+e+")"+a(r)+". possible values: "+Object.keys(t).join(),n||d())},constructor:function(e){Object.keys(e).forEach((function(e){u.indexOf(e)<0&&r('invalid regl constructor argument "'+e+'". must be one of '+u)}))},type:function(e,t,n){i(e,t)||r("invalid parameter type"+a(n)+". expected "+t+", got "+typeof e)},commandType:b,isTypedArray:function(t,n){e(t)||r("invalid parameter type"+a(n)+". must be a typed array")},nni:function(e,t){e>=0&&(0|e)===e||r("invalid parameter type, ("+e+")"+a(t)+". must be a nonnegative integer")},oneOf:o,shaderError:function(e,t,r,a,i){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var o=e.getShaderInfoLog(t),u=a===e.FRAGMENT_SHADER?"fragment":"vertex";b(r,"string",u+" shader source must be a string",i);var s=m(r,i),c=function(e){var t=[];return e.split("\n").forEach((function(e){if(!(e.length<5)){var r=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(e);r?t.push(new l(0|r[1],0|r[2],r[3].trim())):e.length>0&&t.push(new l("unknown",0,e))}})),t}(o);!function(e,t){t.forEach((function(t){var r=e[t.file];if(r){var n=r.index[t.line];if(n)return n.errors.push(t),void(r.hasErrors=!0)}e.unknown.hasErrors=!0,e.unknown.lines[0].errors.push(t)}))}(s,c),Object.keys(s).forEach((function(e){var t=s[e];if(t.hasErrors){var r=[""],n=[""];a("file number "+e+": "+t.name+"\n","color:red;text-decoration:underline;font-weight:bold"),t.lines.forEach((function(e){if(e.errors.length>0){a(f(e.number,4)+"| ","background-color:yellow; font-weight:bold"),a(e.line+"\n","color:red; background-color:yellow; font-weight:bold");var t=0;e.errors.forEach((function(r){var n=r.message,i=/^\s*'(.*)'\s*:\s*(.*)$/.exec(n);if(i){var o=i[1];switch(n=i[2],o){case"assign":o="="}t=Math.max(e.line.indexOf(o,t),0)}else t=0;a(f("| ",6)),a(f("^^^",t+3)+"\n","font-weight:bold"),a(f("| ",6)),a(n+"\n","font-weight:bold")})),a(f("| ",6)+"\n")}else a(f(e.number,4)+"| "),a(e.line+"\n","color:red")})),"undefined"==typeof document||window.chrome?console.log(r.join("")):(n[0]=r.join("%c"),console.log.apply(console,n))}function a(e,t){r.push(e),n.push(t||"")}})),n.raise("Error compiling "+u+" shader, "+s[0].name)}},linkError:function(e,t,r,a,i){if(!e.getProgramParameter(t,e.LINK_STATUS)){var o=e.getProgramInfoLog(t),u=m(r,i),f='Error linking program with vertex shader, "'+m(a,i)[0].name+'", and fragment shader "'+u[0].name+'"';"undefined"!=typeof document?console.log("%c"+f+"\n%c"+o,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(f+"\n"+o),n.raise(f)}},callSite:p,saveCommandRef:h,saveDrawInfo:function(e,t,r,n){function a(e){return e?n.id(e):0}function i(e,t){Object.keys(t).forEach((function(t){e[n.id(t)]=!0}))}h(e),e._fragId=a(e.static.frag),e._vertId=a(e.static.vert);var o=e._uniformSet={};i(o,t.static),i(o,t.dynamic);var u=e._attributeSet={};i(u,r.static),i(u,r.dynamic),e._hasCount="count"in e.static||"count"in e.dynamic||"elements"in e.static||"elements"in e.dynamic},framebufferFormat:function(e,t,r){e.texture?o(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):o(e.renderbuffer._renderbuffer.format,r,"unsupported renderbuffer format for attachment")},guessCommand:d,texture2D:function(e,t,r){var a,i=t.width,o=t.height,u=t.channels;n(i>0&&i<=r.maxTextureSize&&o>0&&o<=r.maxTextureSize,"invalid texture shape"),33071===e.wrapS&&33071===e.wrapT||n(g(i)&&g(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==i&&1!==o&&n(9984!==e.minFilter&&9986!==e.minFilter&&9985!==e.minFilter&&9987!==e.minFilter,"min filter requires mipmap"):(n(g(i)&&g(o),"texture must be a square power of 2 to support mipmapping"),n(t.mipmask===(i<<1)-1,"missing or incomplete mipmap data")),5126===t.type&&(r.extensions.indexOf("oes_texture_float_linear")<0&&n(9728===e.minFilter&&9728===e.magFilter,"filter not supported, must enable oes_texture_float_linear"),n(!e.genMipmaps,"mipmap generation not supported with float textures"));var f=t.images;for(a=0;a<16;++a)if(f[a]){var s=i>>a,c=o>>a;n(t.mipmask&1<<a,"missing mipmap data");var l=f[a];if(n(l.width===s&&l.height===c,"invalid shape for mip images"),n(l.format===t.format&&l.internalformat===t.internalformat&&l.type===t.type,"incompatible type for mip image"),l.compressed);else if(l.data){var d=Math.ceil(y(l.type,u)*s/l.unpackAlignment)*l.unpackAlignment;n(l.data.byteLength===d*c,"invalid data for image, buffer size is inconsistent with image format")}else l.element||l.copy}else e.genMipmaps||n(0==(t.mipmask&1<<a),"extra mipmap data");t.compressed&&n(!e.genMipmaps,"mipmap generation for compressed images not supported")},textureCube:function(e,t,r,a){var i=e.width,o=e.height,u=e.channels;n(i>0&&i<=a.maxTextureSize&&o>0&&o<=a.maxTextureSize,"invalid texture shape"),n(i===o,"cube map must be square"),n(33071===t.wrapS&&33071===t.wrapT,"wrap mode not supported by cube map");for(var f=0;f<r.length;++f){var s=r[f];n(s.width===i&&s.height===o,"inconsistent cube map face shape"),t.genMipmaps&&(n(!s.compressed,"can not generate mipmap for compressed textures"),n(1===s.mipmask,"can not specify mipmaps and generate mipmaps"));for(var c=s.images,l=0;l<16;++l){var d=c[l];if(d){var p=i>>l,m=o>>l;n(s.mipmask&1<<l,"missing mipmap data"),n(d.width===p&&d.height===m,"invalid shape for mip images"),n(d.format===e.format&&d.internalformat===e.internalformat&&d.type===e.type,"incompatible type for mip image"),d.compressed||(d.data?n(d.data.byteLength===p*m*Math.max(y(d.type,u),d.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):d.element||d.copy)}}}}}),A=0;function T(e,t){this.id=A++,this.type=e,this.data=t}function x(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function R(e){return"["+function e(t){if(0===t.length)return[];var r=t.charAt(0),n=t.charAt(t.length-1);if(t.length>1&&r===n&&('"'===r||"'"===r))return['"'+x(t.substr(1,t.length-2))+'"'];var a=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(a)return e(t.substr(0,a.index)).concat(e(a[1])).concat(e(t.substr(a.index+a[0].length)));var i=t.split(".");if(1===i.length)return['"'+x(t)+'"'];for(var o=[],u=0;u<i.length;++u)o=o.concat(e(i[u]));return o}(e).join("][")+"]"}var S={DynamicVariable:T,define:function(e,t){return new T(e,R(t+""))},isDynamic:function(e){return"function"==typeof e&&!e._reglType||e instanceof T},unbox:function e(t,r){return"function"==typeof t?new T(0,t):"number"==typeof t||"boolean"==typeof t?new T(5,t):Array.isArray(t)?new T(6,t.map((t,n)=>e(t,r+"["+n+"]"))):t instanceof T?t:void _(!1,"invalid option type in uniform "+r)},accessor:R},O={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},w="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date};function N(e){return"string"==typeof e?e.split():(_(Array.isArray(e),"invalid extension array"),e)}function I(e){return"string"==typeof e?(_("undefined"!=typeof document,"not supported outside of DOM"),document.querySelector(e)):e}function C(e){var r,n,a,i,o,u=e||{},f={},s=[],c=[],l="undefined"==typeof window?1:window.devicePixelRatio,d=!1,p=function(e){e&&_.raise(e)},m=function(){};if("string"==typeof u?(_("undefined"!=typeof document,"selector queries only supported in DOM enviroments"),r=document.querySelector(u),_(r,"invalid query string for element")):"object"==typeof u?"string"==typeof(o=u).nodeName&&"function"==typeof o.appendChild&&"function"==typeof o.getBoundingClientRect?r=u:function(e){return"function"==typeof e.drawArrays||"function"==typeof e.drawElements}(u)?a=(i=u).canvas:(_.constructor(u),"gl"in u?i=u.gl:"canvas"in u?a=I(u.canvas):"container"in u&&(n=I(u.container)),"attributes"in u&&(f=u.attributes,_.type(f,"object","invalid context attributes")),"extensions"in u&&(s=N(u.extensions)),"optionalExtensions"in u&&(c=N(u.optionalExtensions)),"onDone"in u&&(_.type(u.onDone,"function","invalid or missing onDone callback"),p=u.onDone),"profile"in u&&(d=!!u.profile),"pixelRatio"in u&&(l=+u.pixelRatio,_(l>0,"invalid pixel ratio"))):_.raise("invalid arguments to regl"),r&&("canvas"===r.nodeName.toLowerCase()?a=r:n=r),!i){if(!a){_("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var h=function(e,r,n){var a,i=document.createElement("canvas");function o(){var r=window.innerWidth,a=window.innerHeight;if(e!==document.body){var o=e.getBoundingClientRect();r=o.right-o.left,a=o.bottom-o.top}i.width=n*r,i.height=n*a,t(i.style,{width:r+"px",height:a+"px"})}return t(i.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(i),e===document.body&&(i.style.position="absolute",t(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(a=new ResizeObserver((function(){setTimeout(o)}))).observe(e):window.addEventListener("resize",o,!1),o(),{canvas:i,onDestroy:function(){a?a.disconnect():window.removeEventListener("resize",o),e.removeChild(i)}}}(n||document.body,0,l);if(!h)return null;a=h.canvas,m=h.onDestroy}void 0===f.premultipliedAlpha&&(f.premultipliedAlpha=!0),i=function(e,t){function r(r){try{return e.getContext(r,t)}catch(e){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(a,f)}return i?{gl:i,canvas:a,container:n,extensions:s,optionalExtensions:c,pixelRatio:l,profile:d,onDone:p,onDestroy:m}:(m(),p("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function L(e,t){for(var r=Array(e),n=0;n<e;++n)r[n]=t(n);return r}function D(e){var t,r;return t=(e>65535)<<4,t|=r=((e>>>=t)>255)<<3,t|=r=((e>>>=r)>15)<<2,(t|=r=((e>>>=r)>3)<<1)|(e>>>=r)>>1}function P(){var e=L(8,(function(){return[]}));function t(t){var r=function(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}(t),n=e[D(r)>>2];return n.length>0?n.pop():new ArrayBuffer(r)}function r(t){e[D(t.byteLength)>>2].push(t)}return{alloc:t,free:r,allocType:function(e,r){var n=null;switch(e){case 5120:n=new Int8Array(t(r),0,r);break;case 5121:n=new Uint8Array(t(r),0,r);break;case 5122:n=new Int16Array(t(2*r),0,r);break;case 5123:n=new Uint16Array(t(2*r),0,r);break;case 5124:n=new Int32Array(t(4*r),0,r);break;case 5125:n=new Uint32Array(t(4*r),0,r);break;case 5126:n=new Float32Array(t(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(e){r(e.buffer)}}}var U=P();function F(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||e(t.data))}U.zero=P();var B=function(e){return Object.keys(e).map((function(t){return e[t]}))},M={shape:function(e){for(var t=[],r=e;r.length;r=r[0])t.push(r.length);return t},flatten:function(e,t,r,n){var a=1;if(t.length)for(var i=0;i<t.length;++i)a*=t[i];else a=0;var o=n||U.allocType(r,a);switch(t.length){case 0:break;case 1:!function(e,t,r){for(var n=0;n<t;++n)r[n]=e[n]}(e,t[0],o);break;case 2:!function(e,t,r,n){for(var a=0,i=0;i<t;++i)for(var o=e[i],u=0;u<r;++u)n[a++]=o[u]}(e,t[0],t[1],o);break;case 3:k(e,t[0],t[1],t[2],o,0);break;default:!function e(t,r,n,a,i){for(var o=1,u=n+1;u<r.length;++u)o*=r[u];var f=r[n];if(r.length-n==4){var s=r[n+1],c=r[n+2],l=r[n+3];for(u=0;u<f;++u)k(t[u],s,c,l,a,i),i+=o}else for(u=0;u<f;++u)e(t[u],r,n+1,a,i),i+=o}(e,t,0,o,0)}return o}};function k(e,t,r,n,a,i){for(var o=i,u=0;u<t;++u)for(var f=e[u],s=0;s<r;++s)for(var c=f[s],l=0;l<n;++l)a[o++]=c[l]}var j={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},G={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},V={dynamic:35048,stream:35040,static:35044},X=M.flatten,H=M.shape,z=[];function W(e){return 0|j[Object.prototype.toString.call(e)]}function Y(e,t){for(var r=0;r<t.length;++r)e[r]=t[r]}function K(e,t,r,n,a,i,o){for(var u=0,f=0;f<r;++f)for(var s=0;s<n;++s)e[u++]=t[a*f+i*s+o]}z[5120]=1,z[5122]=2,z[5124]=4,z[5121]=1,z[5123]=2,z[5125]=4,z[5126]=4;var Q={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},q=new Float32Array(1),Z=new Uint32Array(q.buffer);function $(e){for(var t=U.allocType(5123,e.length),r=0;r<e.length;++r)if(isNaN(e[r]))t[r]=65535;else if(e[r]===1/0)t[r]=31744;else if(e[r]===-1/0)t[r]=64512;else{q[0]=e[r];var n=Z[0],a=n>>>31<<15,i=(n<<1>>>24)-127,o=n>>13&1023;if(i<-24)t[r]=a;else if(i<-14){var u=-14-i;t[r]=a+(o+1024>>u)}else t[r]=i>15?a+31744:a+(i+15<<10)+o}return t}function J(t){return Array.isArray(t)||e(t)}var ee=function(e){return!(e&e-1||!e)},te=[9984,9986,9985,9987],re=[0,6409,6410,6407,6408],ne={};function ae(e){return"[object "+e+"]"}ne[6409]=ne[6406]=ne[6402]=1,ne[34041]=ne[6410]=2,ne[6407]=ne[35904]=3,ne[6408]=ne[35906]=4;var ie=ae("HTMLCanvasElement"),oe=ae("OffscreenCanvas"),ue=ae("CanvasRenderingContext2D"),fe=ae("ImageBitmap"),se=ae("HTMLImageElement"),ce=ae("HTMLVideoElement"),le=Object.keys(j).concat([ie,oe,ue,fe,se,ce]),de=[];de[5121]=1,de[5126]=4,de[36193]=2,de[5123]=2,de[5125]=4;var pe=[];function me(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function he(e){return!!Array.isArray(e)&&!(0===e.length||!J(e[0]))}function Ee(e){return Object.prototype.toString.call(e)}function be(e){return Ee(e)===ie}function ve(e){return Ee(e)===oe}function ye(e){if(!e)return!1;var t=Ee(e);return le.indexOf(t)>=0||me(e)||he(e)||F(e)}function ge(e){return 0|j[Object.prototype.toString.call(e)]}function _e(e,t){return U.allocType(36193===e.type?5126:e.type,t)}function Ae(e,t){36193===e.type?(e.data=$(t),U.freeType(t)):e.data=t}function Te(e,t,r,n,a,i){var o;if(o=void 0!==pe[e]?pe[e]:ne[e]*de[t],i&&(o*=6),a){for(var u=0,f=r;f>=1;)u+=o*f*f,f/=2;return u}return o*r*n}function xe(r,n,a,i,o,u,f){var s={"don't care":4352,"dont care":4352,nice:4354,fast:4353},c={repeat:10497,clamp:33071,mirror:33648},l={nearest:9728,linear:9729},d=t({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},l),p={none:0,browser:37444},m={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},h={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},E={};n.ext_srgb&&(h.srgb=35904,h.srgba=35906),n.oes_texture_float&&(m.float32=m.float=5126),n.oes_texture_half_float&&(m.float16=m["half float"]=36193),n.webgl_depth_texture&&(t(h,{depth:6402,"depth stencil":34041}),t(m,{uint16:5123,uint32:5125,"depth stencil":34042})),n.webgl_compressed_texture_s3tc&&t(E,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),n.webgl_compressed_texture_atc&&t(E,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),n.webgl_compressed_texture_pvrtc&&t(E,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),n.webgl_compressed_texture_etc1&&(E["rgb etc1"]=36196);var b=Array.prototype.slice.call(r.getParameter(34467));Object.keys(E).forEach((function(e){var t=E[e];b.indexOf(t)>=0&&(h[e]=t)}));var v=Object.keys(h);a.textureFormats=v;var y=[];Object.keys(h).forEach((function(e){var t=h[e];y[t]=e}));var g=[];Object.keys(m).forEach((function(e){var t=m[e];g[t]=e}));var A=[];Object.keys(l).forEach((function(e){A[l[e]]=e}));var T=[];Object.keys(d).forEach((function(e){var t=d[e];T[t]=e}));var x=[];Object.keys(c).forEach((function(e){x[c[e]]=e}));var R=v.reduce((function(e,t){var r=h[t];return 6409===r||6406===r||6409===r||6410===r||6402===r||34041===r||n.ext_srgb&&(35904===r||35906===r)?e[r]=r:32855===r||t.indexOf("rgba")>=0?e[r]=6408:e[r]=6407,e}),{});function S(){this.internalformat=6408,this.format=6408,this.type=5121,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=37444,this.width=0,this.height=0,this.channels=0}function O(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function w(e,t){if("object"==typeof t&&t){if("premultiplyAlpha"in t&&(_.type(t.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(_.type(t.flipY,"boolean","invalid texture flip"),e.flipY=t.flipY),"alignment"in t&&(_.oneOf(t.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=t.alignment),"colorSpace"in t&&(_.parameter(t.colorSpace,p,"invalid colorSpace"),e.colorSpace=p[t.colorSpace]),"type"in t){var r=t.type;_(n.oes_texture_float||!("float"===r||"float32"===r),"you must enable the OES_texture_float extension in order to use floating point textures."),_(n.oes_texture_half_float||!("half float"===r||"float16"===r),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),_(n.webgl_depth_texture||!("uint16"===r||"uint32"===r||"depth stencil"===r),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),_.parameter(r,m,"invalid texture type"),e.type=m[r]}var i=e.width,o=e.height,u=e.channels,f=!1;"shape"in t?(_(Array.isArray(t.shape)&&t.shape.length>=2,"shape must be an array"),i=t.shape[0],o=t.shape[1],3===t.shape.length&&(u=t.shape[2],_(u>0&&u<=4,"invalid number of channels"),f=!0),_(i>=0&&i<=a.maxTextureSize,"invalid width"),_(o>=0&&o<=a.maxTextureSize,"invalid height")):("radius"in t&&(i=o=t.radius,_(i>=0&&i<=a.maxTextureSize,"invalid radius")),"width"in t&&(i=t.width,_(i>=0&&i<=a.maxTextureSize,"invalid width")),"height"in t&&(o=t.height,_(o>=0&&o<=a.maxTextureSize,"invalid height")),"channels"in t&&(u=t.channels,_(u>0&&u<=4,"invalid number of channels"),f=!0)),e.width=0|i,e.height=0|o,e.channels=0|u;var s=!1;if("format"in t){var c=t.format;_(n.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),_.parameter(c,h,"invalid texture format");var l=e.internalformat=h[c];e.format=R[l],c in m&&("type"in t||(e.type=m[c])),c in E&&(e.compressed=!0),s=!0}!f&&s?e.channels=ne[e.format]:f&&!s?e.channels!==re[e.format]&&(e.format=e.internalformat=re[e.channels]):s&&f&&_(e.channels===ne[e.format],"number of channels inconsistent with specified format")}}function N(e){r.pixelStorei(37440,e.flipY),r.pixelStorei(37441,e.premultiplyAlpha),r.pixelStorei(37443,e.colorSpace),r.pixelStorei(3317,e.unpackAlignment)}function I(){S.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function C(t,r){var n=null;if(ye(r)?n=r:r&&(_.type(r,"object","invalid pixel data type"),w(t,r),"x"in r&&(t.xOffset=0|r.x),"y"in r&&(t.yOffset=0|r.y),ye(r.data)&&(n=r.data)),_(!t.compressed||n instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),r.copy){_(!n,"can not specify copy and data field for the same texture");var i=o.viewportWidth,u=o.viewportHeight;t.width=t.width||i-t.xOffset,t.height=t.height||u-t.yOffset,t.needsCopy=!0,_(t.xOffset>=0&&t.xOffset<i&&t.yOffset>=0&&t.yOffset<u&&t.width>0&&t.width<=i&&t.height>0&&t.height<=u,"copy texture read out of bounds")}else if(n){if(e(n))t.channels=t.channels||4,t.data=n,"type"in r||5121!==t.type||(t.type=ge(n));else if(me(n))t.channels=t.channels||4,function(e,t){var r=t.length;switch(e.type){case 5121:case 5123:case 5125:case 5126:var n=U.allocType(e.type,r);n.set(t),e.data=n;break;case 36193:e.data=$(t);break;default:_.raise("unsupported texture type, must specify a typed array")}}(t,n),t.alignment=1,t.needsFree=!0;else if(F(n)){var f=n.data;Array.isArray(f)||5121!==t.type||(t.type=ge(f));var s,c,l,d,p,m,h=n.shape,E=n.stride;3===h.length?(l=h[2],m=E[2]):(_(2===h.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,m=1),s=h[0],c=h[1],d=E[0],p=E[1],t.alignment=1,t.width=s,t.height=c,t.channels=l,t.format=t.internalformat=re[l],t.needsFree=!0,function(e,t,r,n,a,i){for(var o=e.width,u=e.height,f=e.channels,s=_e(e,o*u*f),c=0,l=0;l<u;++l)for(var d=0;d<o;++d)for(var p=0;p<f;++p)s[c++]=t[r*d+n*l+a*p+i];Ae(e,s)}(t,f,d,p,m,n.offset)}else if(be(n)||ve(n)||Ee(n)===ue)be(n)||ve(n)?t.element=n:t.element=n.canvas,t.width=t.element.width,t.height=t.element.height,t.channels=4;else if(function(e){return Ee(e)===fe}(n))t.element=n,t.width=n.width,t.height=n.height,t.channels=4;else if(function(e){return Ee(e)===se}(n))t.element=n,t.width=n.naturalWidth,t.height=n.naturalHeight,t.channels=4;else if(function(e){return Ee(e)===ce}(n))t.element=n,t.width=n.videoWidth,t.height=n.videoHeight,t.channels=4;else if(he(n)){var b=t.width||n[0].length,v=t.height||n.length,y=t.channels;y=J(n[0][0])?y||n[0][0].length:y||1;for(var g=M.shape(n),A=1,T=0;T<g.length;++T)A*=g[T];var x=_e(t,A);M.flatten(n,g,"",x),Ae(t,x),t.alignment=1,t.width=b,t.height=v,t.channels=y,t.format=t.internalformat=re[y],t.needsFree=!0}}else t.width=t.width||1,t.height=t.height||1,t.channels=t.channels||4;5126===t.type?_(a.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):36193===t.type&&_(a.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function L(e,t,n){var a=e.element,o=e.data,u=e.internalformat,f=e.format,s=e.type,c=e.width,l=e.height;N(e),a?r.texImage2D(t,n,f,f,s,a):e.compressed?r.compressedTexImage2D(t,n,u,c,l,0,o):e.needsCopy?(i(),r.copyTexImage2D(t,n,f,e.xOffset,e.yOffset,c,l,0)):r.texImage2D(t,n,f,c,l,0,f,s,o||null)}function D(e,t,n,a,o){var u=e.element,f=e.data,s=e.internalformat,c=e.format,l=e.type,d=e.width,p=e.height;N(e),u?r.texSubImage2D(t,o,n,a,c,l,u):e.compressed?r.compressedTexSubImage2D(t,o,n,a,s,d,p,f):e.needsCopy?(i(),r.copyTexSubImage2D(t,o,n,a,e.xOffset,e.yOffset,d,p)):r.texSubImage2D(t,o,n,a,d,p,c,l,f)}var P=[];function k(){return P.pop()||new I}function j(e){e.needsFree&&U.freeType(e.data),I.call(e),P.push(e)}function G(){S.call(this),this.genMipmaps=!1,this.mipmapHint=4352,this.mipmask=0,this.images=Array(16)}function V(e,t,r){var n=e.images[0]=k();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function X(e,t){var r=null;if(ye(t))O(r=e.images[0]=k(),e),C(r,t),e.mipmask=1;else if(w(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,a=0;a<n.length;++a)O(r=e.images[a]=k(),e),r.width>>=a,r.height>>=a,C(r,n[a]),e.mipmask|=1<<a;else O(r=e.images[0]=k(),e),C(r,t),e.mipmask=1;O(e,e.images[0]),!e.compressed||33776!==e.internalformat&&33777!==e.internalformat&&33778!==e.internalformat&&33779!==e.internalformat||_(e.width%4==0&&e.height%4==0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function H(e,t){for(var r=e.images,n=0;n<r.length;++n){if(!r[n])return;L(r[n],t,n)}}var z=[];function W(){var e=z.pop()||new G;S.call(e),e.mipmask=0;for(var t=0;t<16;++t)e.images[t]=null;return e}function Y(e){for(var t=e.images,r=0;r<t.length;++r)t[r]&&j(t[r]),t[r]=null;z.push(e)}function K(){this.minFilter=9728,this.magFilter=9728,this.wrapS=33071,this.wrapT=33071,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=4352}function Q(e,t){if("min"in t){var r=t.min;_.parameter(r,d),e.minFilter=d[r],te.indexOf(e.minFilter)>=0&&!("faces"in t)&&(e.genMipmaps=!0)}if("mag"in t){var n=t.mag;_.parameter(n,l),e.magFilter=l[n]}var i=e.wrapS,o=e.wrapT;if("wrap"in t){var u=t.wrap;"string"==typeof u?(_.parameter(u,c),i=o=c[u]):Array.isArray(u)&&(_.parameter(u[0],c),_.parameter(u[1],c),i=c[u[0]],o=c[u[1]])}else{if("wrapS"in t){var f=t.wrapS;_.parameter(f,c),i=c[f]}if("wrapT"in t){var p=t.wrapT;_.parameter(p,c),o=c[p]}}if(e.wrapS=i,e.wrapT=o,"anisotropic"in t){var m=t.anisotropic;_("number"==typeof m&&m>=1&&m<=a.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var h=!1;switch(typeof t.mipmap){case"string":_.parameter(t.mipmap,s,"invalid mipmap hint"),e.mipmapHint=s[t.mipmap],e.genMipmaps=!0,h=!0;break;case"boolean":h=e.genMipmaps=t.mipmap;break;case"object":_(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,h=!0;break;default:_.raise("invalid mipmap type")}h&&!("min"in t)&&(e.minFilter=9984)}}function q(e,t){r.texParameteri(t,10241,e.minFilter),r.texParameteri(t,10240,e.magFilter),r.texParameteri(t,10242,e.wrapS),r.texParameteri(t,10243,e.wrapT),n.ext_texture_filter_anisotropic&&r.texParameteri(t,34046,e.anisotropic),e.genMipmaps&&(r.hint(33170,e.mipmapHint),r.generateMipmap(t))}var Z=0,ae={},ie=a.maxTextureUnits,oe=Array(ie).map((function(){return null}));function le(e){S.call(this),this.mipmask=0,this.internalformat=6408,this.id=Z++,this.refCount=1,this.target=e,this.texture=r.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new K,f.profile&&(this.stats={size:0})}function de(e){r.activeTexture(33984),r.bindTexture(e.target,e.texture)}function pe(){var e=oe[0];e?r.bindTexture(e.target,e.texture):r.bindTexture(3553,null)}function xe(e){var t=e.texture;_(t,"must not double destroy texture");var n=e.unit,a=e.target;n>=0&&(r.activeTexture(33984+n),r.bindTexture(a,null),oe[n]=null),r.deleteTexture(t),e.texture=null,e.params=null,e.pixels=null,e.refCount=0,delete ae[e.id],u.textureCount--}return t(le.prototype,{bind:function(){this.bindCount+=1;var e=this.unit;if(e<0){for(var t=0;t<ie;++t){var n=oe[t];if(n){if(n.bindCount>0)continue;n.unit=-1}oe[t]=this,e=t;break}e>=ie&&_.raise("insufficient number of texture units"),f.profile&&u.maxTextureUnits<e+1&&(u.maxTextureUnits=e+1),this.unit=e,r.activeTexture(33984+e),r.bindTexture(this.target,this.texture)}return e},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&xe(this)}}),f.profile&&(u.getTotalTextureSize=function(){var e=0;return Object.keys(ae).forEach((function(t){e+=ae[t].stats.size})),e}),{create2D:function(e,t){var n=new le(3553);function i(e,t){var r=n.texInfo;K.call(r);var o=W();return"number"==typeof e?V(o,0|e,"number"==typeof t?0|t:0|e):e?(_.type(e,"object","invalid arguments to regl.texture"),Q(r,e),X(o,e)):V(o,1,1),r.genMipmaps&&(o.mipmask=(o.width<<1)-1),n.mipmask=o.mipmask,O(n,o),_.texture2D(r,o,a),n.internalformat=o.internalformat,i.width=o.width,i.height=o.height,de(n),H(o,3553),q(r,3553),pe(),Y(o),f.profile&&(n.stats.size=Te(n.internalformat,n.type,o.width,o.height,r.genMipmaps,!1)),i.format=y[n.internalformat],i.type=g[n.type],i.mag=A[r.magFilter],i.min=T[r.minFilter],i.wrapS=x[r.wrapS],i.wrapT=x[r.wrapT],i}return ae[n.id]=n,u.textureCount++,i(e,t),i.subimage=function(e,t,r,a){_(!!e,"must specify image data");var o=0|t,u=0|r,f=0|a,s=k();return O(s,n),s.width=0,s.height=0,C(s,e),s.width=s.width||(n.width>>f)-o,s.height=s.height||(n.height>>f)-u,_(n.type===s.type&&n.format===s.format&&n.internalformat===s.internalformat,"incompatible format for texture.subimage"),_(o>=0&&u>=0&&o+s.width<=n.width&&u+s.height<=n.height,"texture.subimage write out of bounds"),_(n.mipmask&1<<f,"missing mipmap data"),_(s.data||s.element||s.needsCopy,"missing image data"),de(n),D(s,3553,o,u,f),pe(),j(s),i},i.resize=function(e,t){var a=0|e,o=0|t||a;if(a===n.width&&o===n.height)return i;i.width=n.width=a,i.height=n.height=o,de(n);for(var u=0;n.mipmask>>u;++u){var s=a>>u,c=o>>u;if(!s||!c)break;r.texImage2D(3553,u,n.format,s,c,0,n.format,n.type,null)}return pe(),f.profile&&(n.stats.size=Te(n.internalformat,n.type,a,o,!1,!1)),i},i._reglType="texture2d",i._texture=n,f.profile&&(i.stats=n.stats),i.destroy=function(){n.decRef()},i},createCube:function(e,t,n,i,o,s){var c=new le(34067);ae[c.id]=c,u.cubeCount++;var l=new Array(6);function d(e,t,r,n,i,o){var u,s=c.texInfo;for(K.call(s),u=0;u<6;++u)l[u]=W();if("number"!=typeof e&&e)if("object"==typeof e)if(t)X(l[0],e),X(l[1],t),X(l[2],r),X(l[3],n),X(l[4],i),X(l[5],o);else if(Q(s,e),w(c,e),"faces"in e){var p=e.faces;for(_(Array.isArray(p)&&6===p.length,"cube faces must be a length 6 array"),u=0;u<6;++u)_("object"==typeof p[u]&&!!p[u],"invalid input for cube map face"),O(l[u],c),X(l[u],p[u])}else for(u=0;u<6;++u)X(l[u],e);else _.raise("invalid arguments to cube map");else{var m=0|e||1;for(u=0;u<6;++u)V(l[u],m,m)}for(O(c,l[0]),a.npotTextureCube||_(ee(c.width)&&ee(c.height),"your browser does not support non power or two texture dimensions"),s.genMipmaps?c.mipmask=(l[0].width<<1)-1:c.mipmask=l[0].mipmask,_.textureCube(c,s,l,a),c.internalformat=l[0].internalformat,d.width=l[0].width,d.height=l[0].height,de(c),u=0;u<6;++u)H(l[u],34069+u);for(q(s,34067),pe(),f.profile&&(c.stats.size=Te(c.internalformat,c.type,d.width,d.height,s.genMipmaps,!0)),d.format=y[c.internalformat],d.type=g[c.type],d.mag=A[s.magFilter],d.min=T[s.minFilter],d.wrapS=x[s.wrapS],d.wrapT=x[s.wrapT],u=0;u<6;++u)Y(l[u]);return d}return d(e,t,n,i,o,s),d.subimage=function(e,t,r,n,a){_(!!t,"must specify image data"),_("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var i=0|r,o=0|n,u=0|a,f=k();return O(f,c),f.width=0,f.height=0,C(f,t),f.width=f.width||(c.width>>u)-i,f.height=f.height||(c.height>>u)-o,_(c.type===f.type&&c.format===f.format&&c.internalformat===f.internalformat,"incompatible format for texture.subimage"),_(i>=0&&o>=0&&i+f.width<=c.width&&o+f.height<=c.height,"texture.subimage write out of bounds"),_(c.mipmask&1<<u,"missing mipmap data"),_(f.data||f.element||f.needsCopy,"missing image data"),de(c),D(f,34069+e,i,o,u),pe(),j(f),d},d.resize=function(e){var t=0|e;if(t!==c.width){d.width=c.width=t,d.height=c.height=t,de(c);for(var n=0;n<6;++n)for(var a=0;c.mipmask>>a;++a)r.texImage2D(34069+n,a,c.format,t>>a,t>>a,0,c.format,c.type,null);return pe(),f.profile&&(c.stats.size=Te(c.internalformat,c.type,d.width,d.height,!1,!0)),d}},d._reglType="textureCube",d._texture=c,f.profile&&(d.stats=c.stats),d.destroy=function(){c.decRef()},d},clear:function(){for(var e=0;e<ie;++e)r.activeTexture(33984+e),r.bindTexture(3553,null),oe[e]=null;B(ae).forEach(xe),u.cubeCount=0,u.textureCount=0},getTexture:function(e){return null},restore:function(){for(var e=0;e<ie;++e){var t=oe[e];t&&(t.bindCount=0,t.unit=-1,oe[e]=null)}B(ae).forEach((function(e){e.texture=r.createTexture(),r.bindTexture(e.target,e.texture);for(var t=0;t<32;++t)if(0!=(e.mipmask&1<<t))if(3553===e.target)r.texImage2D(3553,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);else for(var n=0;n<6;++n)r.texImage2D(34069+n,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);q(e.texInfo,e.target)}))},refresh:function(){for(var e=0;e<ie;++e){var t=oe[e];t&&(t.bindCount=0,t.unit=-1,oe[e]=null),r.activeTexture(33984+e),r.bindTexture(3553,null),r.bindTexture(34067,null)}}}}pe[32854]=2,pe[32855]=2,pe[36194]=2,pe[34041]=4,pe[33776]=.5,pe[33777]=.5,pe[33778]=1,pe[33779]=1,pe[35986]=.5,pe[35987]=1,pe[34798]=1,pe[35840]=.5,pe[35841]=.25,pe[35842]=.5,pe[35843]=.25,pe[36196]=.5;var Re=[];function Se(e,t,r){return Re[e]*t*r}Re[32854]=2,Re[32855]=2,Re[36194]=2,Re[33189]=2,Re[36168]=1,Re[34041]=4,Re[35907]=4,Re[34836]=16,Re[34842]=8,Re[34843]=6;var Oe=[6407,6408],we=[];we[6408]=4,we[6407]=3;var Ne=[];Ne[5121]=1,Ne[5126]=4,Ne[36193]=2;var Ie=[32854,32855,36194,35907,34842,34843,34836],Ce={};function Le(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.offset=0,this.stride=0,this.divisor=0}function De(t,r,n,a,i,o,u){function f(f){var s;null===r.next?(_(i.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),s=5121):(_(null!==r.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),s=r.next.colorAttachments[0].texture._texture.type,o.oes_texture_float?(_(5121===s||5126===s,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),5126===s&&_(u.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):_(5121===s,"Reading from a framebuffer is only allowed for the type 'uint8'"));var c=0,l=0,d=a.framebufferWidth,p=a.framebufferHeight,m=null;e(f)?m=f:f&&(_.type(f,"object","invalid arguments to regl.read()"),c=0|f.x,l=0|f.y,_(c>=0&&c<a.framebufferWidth,"invalid x offset for regl.read"),_(l>=0&&l<a.framebufferHeight,"invalid y offset for regl.read"),d=0|(f.width||a.framebufferWidth-c),p=0|(f.height||a.framebufferHeight-l),m=f.data||null),m&&(5121===s?_(m instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):5126===s&&_(m instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),_(d>0&&d+c<=a.framebufferWidth,"invalid width for read pixels"),_(p>0&&p+l<=a.framebufferHeight,"invalid height for read pixels"),n();var h=d*p*4;return m||(5121===s?m=new Uint8Array(h):5126===s&&(m=m||new Float32Array(h))),_.isTypedArray(m,"data buffer for regl.read() must be a typedarray"),_(m.byteLength>=h,"data buffer for regl.read() too small"),t.pixelStorei(3333,4),t.readPixels(c,l,d,p,6408,s,m),m}return function(e){return e&&"framebuffer"in e?function(e){var t;return r.setFBO({framebuffer:e.framebuffer},(function(){t=f(e)})),t}(e):f(e)}}function Pe(e){return Array.prototype.slice.call(e)}function Ue(e){return Pe(e).join("")}Ce[36053]="complete",Ce[36054]="incomplete attachment",Ce[36057]="incomplete dimensions",Ce[36055]="incomplete, missing attachment",Ce[36061]="unsupported";var Fe="xyzw".split(""),Be="profile",Me="framebuffer",ke="vert",je="frag",Ge="elements",Ve="primitive",Xe="count",He="offset",ze="instances",We="vao",Ye=Me+"Width",Ke=Me+"Height",Qe=["blend.func","blend.equation","stencil.func","stencil.opFront","stencil.opBack","sample.coverage","viewport","scissor.box","polygonOffset.offset"],qe={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Ze=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],$e={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Je={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},et={frag:35632,vert:35633},tt={cw:2304,ccw:2305};function rt(t){return Array.isArray(t)||e(t)||F(t)}function nt(e){return e.sort((function(e,t){return"viewport"===e?-1:"viewport"===t?1:e<t?-1:1}))}function at(e,t,r,n){this.thisDep=e,this.contextDep=t,this.propDep=r,this.append=n}function it(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function ot(e){return new at(!1,!1,!1,e)}function ut(e,t){var r=e.type;if(0===r){var n=e.data.length;return new at(!0,n>=1,n>=2,t)}if(4===r){var a=e.data;return new at(a.thisDep,a.contextDep,a.propDep,t)}if(5===r)return new at(!1,!1,!1,t);if(6===r){for(var i=!1,o=!1,u=!1,f=0;f<e.data.length;++f){var s=e.data[f];if(1===s.type)u=!0;else if(2===s.type)o=!0;else if(3===s.type)i=!0;else if(0===s.type){i=!0;var c=s.data;c>=1&&(o=!0),c>=2&&(u=!0)}else 4===s.type&&(i=i||s.data.thisDep,o=o||s.data.contextDep,u=u||s.data.propDep)}return new at(i,o,u,t)}return new at(3===r,2===r,1===r,t)}var ft=new at(!1,!1,!1,(function(){}));function st(e,r,n,a,i,o,u,f,s,c,l,d,p,m,h){var E=c.Record,b={add:32774,subtract:32778,"reverse subtract":32779};n.ext_blend_minmax&&(b.min=32775,b.max=32776);var v=n.angle_instanced_arrays,y=n.webgl_draw_buffers,g={dirty:!0,profile:h.profile},A={},T=[],x={},R={};function O(e){return e.replace(".","_")}function w(e,t,r){var n=O(e);T.push(e),A[n]=g[n]=!!r,x[n]=t}function N(e,t,r){var n=O(e);T.push(e),Array.isArray(r)?(g[n]=r.slice(),A[n]=r.slice()):g[n]=A[n]=r,R[n]=t}w("dither",3024),w("blend.enable",3042),N("blend.color","blendColor",[0,0,0,0]),N("blend.equation","blendEquationSeparate",[32774,32774]),N("blend.func","blendFuncSeparate",[1,0,1,0]),w("depth.enable",2929,!0),N("depth.func","depthFunc",513),N("depth.range","depthRange",[0,1]),N("depth.mask","depthMask",!0),N("colorMask","colorMask",[!0,!0,!0,!0]),w("cull.enable",2884),N("cull.face","cullFace",1029),N("frontFace","frontFace",2305),N("lineWidth","lineWidth",1),w("polygonOffset.enable",32823),N("polygonOffset.offset","polygonOffset",[0,0]),w("sample.alpha",32926),w("sample.enable",32928),N("sample.coverage","sampleCoverage",[1,!1]),w("stencil.enable",2960),N("stencil.mask","stencilMask",-1),N("stencil.func","stencilFunc",[519,0,-1]),N("stencil.opFront","stencilOpSeparate",[1028,7680,7680,7680]),N("stencil.opBack","stencilOpSeparate",[1029,7680,7680,7680]),w("scissor.enable",3089),N("scissor.box","scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),N("viewport","viewport",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var I={gl:e,context:p,strings:r,next:A,current:g,draw:d,elements:o,buffer:i,shader:l,attributes:c.state,vao:c,uniforms:s,framebuffer:f,extensions:n,timer:m,isBufferArgs:rt},C={primTypes:Q,compareFuncs:$e,blendFuncs:qe,blendEquations:b,stencilOps:Je,glTypes:G,orientationType:tt};_.optional((function(){I.isArrayLike=J})),y&&(C.backBuffer=[1029],C.drawBuffer=L(a.maxDrawbuffers,(function(e){return 0===e?[0]:L(e,(function(e){return 36064+e}))})));var D=0;function P(){var e=function(){var e=0,r=[],n=[];function a(){var r=[],n=[];return t((function(){r.push.apply(r,Pe(arguments))}),{def:function(){var t="v"+e++;return n.push(t),arguments.length>0&&(r.push(t,"="),r.push.apply(r,Pe(arguments)),r.push(";")),t},toString:function(){return Ue([n.length>0?"var "+n.join(",")+";":"",Ue(r)])}})}function i(){var e=a(),r=a(),n=e.toString,i=r.toString;function o(t,n){r(t,n,"=",e.def(t,n),";")}return t((function(){e.apply(e,Pe(arguments))}),{def:e.def,entry:e,exit:r,save:o,set:function(t,r,n){o(t,r),e(t,r,"=",n,";")},toString:function(){return n()+i()}})}var o=a(),u={};return{global:o,link:function(t){for(var a=0;a<n.length;++a)if(n[a]===t)return r[a];var i="g"+e++;return r.push(i),n.push(t),i},block:a,proc:function(e,r){var n=[];function a(){var e="a"+n.length;return n.push(e),e}r=r||0;for(var o=0;o<r;++o)a();var f=i(),s=f.toString;return u[e]=t(f,{arg:a,toString:function(){return Ue(["function(",n.join(),"){",s(),"}"])}})},scope:i,cond:function(){var e=Ue(arguments),r=i(),n=i(),a=r.toString,o=n.toString;return t(r,{then:function(){return r.apply(r,Pe(arguments)),this},else:function(){return n.apply(n,Pe(arguments)),this},toString:function(){var t=o();return t&&(t="else{"+t+"}"),Ue(["if(",e,"){",a(),"}",t])}})},compile:function(){var e=['"use strict";',o,"return {"];Object.keys(u).forEach((function(t){e.push('"',t,'":',u[t].toString(),",")})),e.push("}");var t=Ue(e).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,r.concat(t)).apply(null,n)}}}(),n=e.link,a=e.global;e.id=D++,e.batchId="0";var i=n(I),o=e.shared={props:"a0"};Object.keys(I).forEach((function(e){o[e]=a.def(i,".",e)})),_.optional((function(){e.CHECK=n(_),e.commandStr=_.guessCommand(),e.command=n(e.commandStr),e.assert=function(e,t,r){e("if(!(",t,"))",this.CHECK,".commandRaise(",n(r),",",this.command,");")},C.invalidBlendCombinations=Ze}));var u=e.next={},f=e.current={};Object.keys(R).forEach((function(e){Array.isArray(g[e])&&(u[e]=a.def(o.next,".",e),f[e]=a.def(o.current,".",e))}));var s=e.constants={};Object.keys(C).forEach((function(e){s[e]=a.def(JSON.stringify(C[e]))})),e.invoke=function(t,r){switch(r.type){case 0:var a=["this",o.context,o.props,e.batchId];return t.def(n(r.data),".call(",a.slice(0,Math.max(r.data.length+1,4)),")");case 1:return t.def(o.props,r.data);case 2:return t.def(o.context,r.data);case 3:return t.def("this",r.data);case 4:return r.data.append(e,t),r.data.ref;case 5:return r.data.toString();case 6:return r.data.map((function(r){return e.invoke(t,r)}))}},e.attribCache={};var l={};return e.scopeAttrib=function(e){var t=r.id(e);if(t in l)return l[t];var a=c.scope[t];return a||(a=c.scope[t]=new E),l[t]=n(a)},e}function U(e,t,u,s,d){var p=e.static,m=e.dynamic;_.optional((function(){var e=[Me,ke,je,Ge,Ve,He,Xe,ze,Be,We].concat(T);function t(t){Object.keys(t).forEach((function(t){_.command(e.indexOf(t)>=0,'unknown parameter "'+t+'"',d.commandStr)}))}t(p),t(m)}));var h=function(e,t){var r=e.static;if("string"==typeof r[je]&&"string"==typeof r[ke]){if(Object.keys(t.dynamic).length>0)return null;var n=t.static,a=Object.keys(n);if(a.length>0&&"number"==typeof n[a[0]]){for(var i=[],o=0;o<a.length;++o)_("number"==typeof n[a[o]],"must specify all vertex attribute locations when using vaos"),i.push([0|n[a[o]],a[o]]);return i}}return null}(e,t),y=function(e,t){var r=e.static,n=e.dynamic;if(Me in r){var a=r[Me];return a?(a=f.getFramebuffer(a),_.command(a,"invalid framebuffer object"),ot((function(e,t){var r=e.link(a),n=e.shared;t.set(n.framebuffer,".next",r);var i=n.context;return t.set(i,"."+Ye,r+".width"),t.set(i,"."+Ke,r+".height"),r}))):ot((function(e,t){var r=e.shared;t.set(r.framebuffer,".next","null");var n=r.context;return t.set(n,"."+Ye,n+".drawingBufferWidth"),t.set(n,"."+Ke,n+".drawingBufferHeight"),"null"}))}if(Me in n){var i=n[Me];return ut(i,(function(e,t){var r=e.invoke(t,i),n=e.shared,a=n.framebuffer,o=t.def(a,".getFramebuffer(",r,")");_.optional((function(){e.assert(t,"!"+r+"||"+o,"invalid framebuffer object")})),t.set(a,".next",o);var u=n.context;return t.set(u,"."+Ye,o+"?"+o+".width:"+u+".drawingBufferWidth"),t.set(u,"."+Ke,o+"?"+o+".height:"+u+".drawingBufferHeight"),o}))}return null}(e),g=function(e,t,r){var n=e.static,a=e.dynamic;function i(e){if(e in n){var i=n[e];_.commandType(i,"object","invalid "+e,r.commandStr);var o,u,f=!0,s=0|i.x,c=0|i.y;return"width"in i?(o=0|i.width,_.command(o>=0,"invalid "+e,r.commandStr)):f=!1,"height"in i?(u=0|i.height,_.command(u>=0,"invalid "+e,r.commandStr)):f=!1,new at(!f&&t&&t.thisDep,!f&&t&&t.contextDep,!f&&t&&t.propDep,(function(e,t){var r=e.shared.context,n=o;"width"in i||(n=t.def(r,".",Ye,"-",s));var a=u;return"height"in i||(a=t.def(r,".",Ke,"-",c)),[s,c,n,a]}))}if(e in a){var l=a[e],d=ut(l,(function(t,r){var n=t.invoke(r,l);_.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)}));var a=t.shared.context,i=r.def(n,".x|0"),o=r.def(n,".y|0"),u=r.def('"width" in ',n,"?",n,".width|0:","(",a,".",Ye,"-",i,")"),f=r.def('"height" in ',n,"?",n,".height|0:","(",a,".",Ke,"-",o,")");return _.optional((function(){t.assert(r,u+">=0&&"+f+">=0","invalid "+e)})),[i,o,u,f]}));return t&&(d.thisDep=d.thisDep||t.thisDep,d.contextDep=d.contextDep||t.contextDep,d.propDep=d.propDep||t.propDep),d}return t?new at(t.thisDep,t.contextDep,t.propDep,(function(e,t){var r=e.shared.context;return[0,0,t.def(r,".",Ye),t.def(r,".",Ke)]})):null}var o=i("viewport");if(o){var u=o;o=new at(o.thisDep,o.contextDep,o.propDep,(function(e,t){var r=u.append(e,t),n=e.shared.context;return t.set(n,".viewportWidth",r[2]),t.set(n,".viewportHeight",r[3]),r}))}return{viewport:o,scissor_box:i("scissor.box")}}(e,y,d),A=function(e,t){var r=e.static,n=e.dynamic,a=function(){if(Ge in r){var e=r[Ge];rt(e)?e=o.getElements(o.create(e,!0)):e&&(e=o.getElements(e),_.command(e,"invalid elements",t.commandStr));var a=ot((function(t,r){if(e){var n=t.link(e);return t.ELEMENTS=n,n}return t.ELEMENTS=null,null}));return a.value=e,a}if(Ge in n){var i=n[Ge];return ut(i,(function(e,t){var r=e.shared,n=r.isBufferArgs,a=r.elements,o=e.invoke(t,i),u=t.def("null"),f=t.def(n,"(",o,")"),s=e.cond(f).then(u,"=",a,".createStream(",o,");").else(u,"=",a,".getElements(",o,");");return _.optional((function(){e.assert(s.else,"!"+o+"||"+u,"invalid elements")})),t.entry(s),t.exit(e.cond(f).then(a,".destroyStream(",u,");")),e.ELEMENTS=u,u}))}return null}();function i(e,i){if(e in r){var o=0|r[e];return _.command(!i||o>=0,"invalid "+e,t.commandStr),ot((function(e,t){return i&&(e.OFFSET=o),o}))}if(e in n){var u=n[e];return ut(u,(function(t,r){var n=t.invoke(r,u);return i&&(t.OFFSET=n,_.optional((function(){t.assert(r,n+">=0","invalid "+e)}))),n}))}return i&&a?ot((function(e,t){return e.OFFSET="0",0})):null}var u=i(He,!0);return{elements:a,primitive:function(){if(Ve in r){var e=r[Ve];return _.commandParameter(e,Q,"invalid primitve",t.commandStr),ot((function(t,r){return Q[e]}))}if(Ve in n){var i=n[Ve];return ut(i,(function(e,t){var r=e.constants.primTypes,n=e.invoke(t,i);return _.optional((function(){e.assert(t,n+" in "+r,"invalid primitive, must be one of "+Object.keys(Q))})),t.def(r,"[",n,"]")}))}return a?it(a)?a.value?ot((function(e,t){return t.def(e.ELEMENTS,".primType")})):ot((function(){return 4})):new at(a.thisDep,a.contextDep,a.propDep,(function(e,t){var r=e.ELEMENTS;return t.def(r,"?",r,".primType:",4)})):null}(),count:function(){if(Xe in r){var e=0|r[Xe];return _.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),ot((function(){return e}))}if(Xe in n){var i=n[Xe];return ut(i,(function(e,t){var r=e.invoke(t,i);return _.optional((function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">=0&&"+r+"===("+r+"|0)","invalid vertex count")})),r}))}if(a){if(it(a)){if(a)return u?new at(u.thisDep,u.contextDep,u.propDep,(function(e,t){var r=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return _.optional((function(){e.assert(t,r+">=0","invalid vertex offset/element buffer too small")})),r})):ot((function(e,t){return t.def(e.ELEMENTS,".vertCount")}));var o=ot((function(){return-1}));return _.optional((function(){o.MISSING=!0})),o}var f=new at(a.thisDep||u.thisDep,a.contextDep||u.contextDep,a.propDep||u.propDep,(function(e,t){var r=e.ELEMENTS;return e.OFFSET?t.def(r,"?",r,".vertCount-",e.OFFSET,":-1"):t.def(r,"?",r,".vertCount:-1")}));return _.optional((function(){f.DYNAMIC=!0})),f}return null}(),instances:i(ze,!1),offset:u}}(e,d),x=function(e,t){var r=e.static,n=e.dynamic,i={};return T.forEach((function(e){var o=O(e);function u(t,a){if(e in r){var u=t(r[e]);i[o]=ot((function(){return u}))}else if(e in n){var f=n[e];i[o]=ut(f,(function(e,t){return a(e,t,e.invoke(t,f))}))}}switch(e){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return u((function(r){return _.commandType(r,"boolean",e,t.commandStr),r}),(function(t,r,n){return _.optional((function(){t.assert(r,"typeof "+n+'==="boolean"',"invalid flag "+e,t.commandStr)})),n}));case"depth.func":return u((function(r){return _.commandParameter(r,$e,"invalid "+e,t.commandStr),$e[r]}),(function(t,r,n){var a=t.constants.compareFuncs;return _.optional((function(){t.assert(r,n+" in "+a,"invalid "+e+", must be one of "+Object.keys($e))})),r.def(a,"[",n,"]")}));case"depth.range":return u((function(e){return _.command(J(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]&&e[0]<=e[1],"depth range is 2d array",t.commandStr),e}),(function(e,t,r){return _.optional((function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===2&&typeof "+r+'[0]==="number"&&typeof '+r+'[1]==="number"&&'+r+"[0]<="+r+"[1]","depth range must be a 2d array")})),[t.def("+",r,"[0]"),t.def("+",r,"[1]")]}));case"blend.func":return u((function(e){_.commandType(e,"object","blend.func",t.commandStr);var r="srcRGB"in e?e.srcRGB:e.src,n="srcAlpha"in e?e.srcAlpha:e.src,a="dstRGB"in e?e.dstRGB:e.dst,i="dstAlpha"in e?e.dstAlpha:e.dst;return _.commandParameter(r,qe,o+".srcRGB",t.commandStr),_.commandParameter(n,qe,o+".srcAlpha",t.commandStr),_.commandParameter(a,qe,o+".dstRGB",t.commandStr),_.commandParameter(i,qe,o+".dstAlpha",t.commandStr),_.command(-1===Ze.indexOf(r+", "+a),"unallowed blending combination (srcRGB, dstRGB) = ("+r+", "+a+")",t.commandStr),[qe[r],qe[a],qe[n],qe[i]]}),(function(t,r,n){var a=t.constants.blendFuncs;function i(i,o){var u=r.def('"',i,o,'" in ',n,"?",n,".",i,o,":",n,".",i);return _.optional((function(){t.assert(r,u+" in "+a,"invalid "+e+"."+i+o+", must be one of "+Object.keys(qe))})),u}_.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid blend func, must be an object")}));var o=i("src","RGB"),u=i("dst","RGB");_.optional((function(){var e=t.constants.invalidBlendCombinations;t.assert(r,e+".indexOf("+o+'+", "+'+u+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var f=r.def(a,"[",o,"]"),s=r.def(a,"[",i("src","Alpha"),"]");return[f,r.def(a,"[",u,"]"),s,r.def(a,"[",i("dst","Alpha"),"]")]}));case"blend.equation":return u((function(r){return"string"==typeof r?(_.commandParameter(r,b,"invalid "+e,t.commandStr),[b[r],b[r]]):"object"==typeof r?(_.commandParameter(r.rgb,b,e+".rgb",t.commandStr),_.commandParameter(r.alpha,b,e+".alpha",t.commandStr),[b[r.rgb],b[r.alpha]]):void _.commandRaise("invalid blend.equation",t.commandStr)}),(function(t,r,n){var a=t.constants.blendEquations,i=r.def(),o=r.def(),u=t.cond("typeof ",n,'==="string"');return _.optional((function(){function r(e,r,n){t.assert(e,n+" in "+a,"invalid "+r+", must be one of "+Object.keys(b))}r(u.then,e,n),t.assert(u.else,n+"&&typeof "+n+'==="object"',"invalid "+e),r(u.else,e+".rgb",n+".rgb"),r(u.else,e+".alpha",n+".alpha")})),u.then(i,"=",o,"=",a,"[",n,"];"),u.else(i,"=",a,"[",n,".rgb];",o,"=",a,"[",n,".alpha];"),r(u),[i,o]}));case"blend.color":return u((function(e){return _.command(J(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),L(4,(function(t){return+e[t]}))}),(function(e,t,r){return _.optional((function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","blend.color must be a 4d array")})),L(4,(function(e){return t.def("+",r,"[",e,"]")}))}));case"stencil.mask":return u((function(e){return _.commandType(e,"number",o,t.commandStr),0|e}),(function(e,t,r){return _.optional((function(){e.assert(t,"typeof "+r+'==="number"',"invalid stencil.mask")})),t.def(r,"|0")}));case"stencil.func":return u((function(r){_.commandType(r,"object",o,t.commandStr);var n=r.cmp||"keep",a=r.ref||0,i="mask"in r?r.mask:-1;return _.commandParameter(n,$e,e+".cmp",t.commandStr),_.commandType(a,"number",e+".ref",t.commandStr),_.commandType(i,"number",e+".mask",t.commandStr),[$e[n],a,i]}),(function(e,t,r){var n=e.constants.compareFuncs;return _.optional((function(){function a(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}a(r+"&&typeof ",r,'==="object"'),a('!("cmp" in ',r,")||(",r,".cmp in ",n,")")})),[t.def('"cmp" in ',r,"?",n,"[",r,".cmp]",":",7680),t.def(r,".ref|0"),t.def('"mask" in ',r,"?",r,".mask|0:-1")]}));case"stencil.opFront":case"stencil.opBack":return u((function(r){_.commandType(r,"object",o,t.commandStr);var n=r.fail||"keep",a=r.zfail||"keep",i=r.zpass||"keep";return _.commandParameter(n,Je,e+".fail",t.commandStr),_.commandParameter(a,Je,e+".zfail",t.commandStr),_.commandParameter(i,Je,e+".zpass",t.commandStr),["stencil.opBack"===e?1029:1028,Je[n],Je[a],Je[i]]}),(function(t,r,n){var a=t.constants.stencilOps;function i(i){return _.optional((function(){t.assert(r,'!("'+i+'" in '+n+")||("+n+"."+i+" in "+a+")","invalid "+e+"."+i+", must be one of "+Object.keys(Je))})),r.def('"',i,'" in ',n,"?",a,"[",n,".",i,"]:",7680)}return _.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)})),["stencil.opBack"===e?1029:1028,i("fail"),i("zfail"),i("zpass")]}));case"polygonOffset.offset":return u((function(e){_.commandType(e,"object",o,t.commandStr);var r=0|e.factor,n=0|e.units;return _.commandType(r,"number",o+".factor",t.commandStr),_.commandType(n,"number",o+".units",t.commandStr),[r,n]}),(function(t,r,n){return _.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)})),[r.def(n,".factor|0"),r.def(n,".units|0")]}));case"cull.face":return u((function(e){var r=0;return"front"===e?r=1028:"back"===e&&(r=1029),_.command(!!r,o,t.commandStr),r}),(function(e,t,r){return _.optional((function(){e.assert(t,r+'==="front"||'+r+'==="back"',"invalid cull.face")})),t.def(r,'==="front"?',1028,":",1029)}));case"lineWidth":return u((function(e){return _.command("number"==typeof e&&e>=a.lineWidthDims[0]&&e<=a.lineWidthDims[1],"invalid line width, must be a positive number between "+a.lineWidthDims[0]+" and "+a.lineWidthDims[1],t.commandStr),e}),(function(e,t,r){return _.optional((function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">="+a.lineWidthDims[0]+"&&"+r+"<="+a.lineWidthDims[1],"invalid line width")})),r}));case"frontFace":return u((function(e){return _.commandParameter(e,tt,o,t.commandStr),tt[e]}),(function(e,t,r){return _.optional((function(){e.assert(t,r+'==="cw"||'+r+'==="ccw"',"invalid frontFace, must be one of cw,ccw")})),t.def(r+'==="cw"?2304:2305')}));case"colorMask":return u((function(e){return _.command(J(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map((function(e){return!!e}))}),(function(e,t,r){return _.optional((function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","invalid color.mask")})),L(4,(function(e){return"!!"+r+"["+e+"]"}))}));case"sample.coverage":return u((function(e){_.command("object"==typeof e&&e,o,t.commandStr);var r="value"in e?e.value:1,n=!!e.invert;return _.command("number"==typeof r&&r>=0&&r<=1,"sample.coverage.value must be a number between 0 and 1",t.commandStr),[r,n]}),(function(e,t,r){return _.optional((function(){e.assert(t,r+"&&typeof "+r+'==="object"',"invalid sample.coverage")})),[t.def('"value" in ',r,"?+",r,".value:1"),t.def("!!",r,".invert")]}))}})),i}(e,d),R=function(e,t,n){var a=e.static,i=e.dynamic;function o(e){if(e in a){var t=r.id(a[e]);_.optional((function(){l.shader(et[e],t,_.guessCommand())}));var n=ot((function(){return t}));return n.id=t,n}if(e in i){var o=i[e];return ut(o,(function(t,r){var n=t.invoke(r,o),a=r.def(t.shared.strings,".id(",n,")");return _.optional((function(){r(t.shared.shader,".shader(",et[e],",",a,",",t.command,");")})),a}))}return null}var u,f=o(je),s=o(ke),c=null;return it(f)&&it(s)?(c=l.program(s.id,f.id,null,n),u=ot((function(e,t){return e.link(c)}))):u=new at(f&&f.thisDep||s&&s.thisDep,f&&f.contextDep||s&&s.contextDep,f&&f.propDep||s&&s.propDep,(function(e,t){var r,n=e.shared.shader;r=f?f.append(e,t):t.def(n,".",je);var a=n+".program("+(s?s.append(e,t):t.def(n,".",ke))+","+r;return _.optional((function(){a+=","+e.command})),t.def(a+")")})),{frag:f,vert:s,progVar:u,program:c}}(e,0,h);function S(e){var t=g[e];t&&(x[e]=t)}S("viewport"),S(O("scissor.box"));var w=Object.keys(x).length>0,N={framebuffer:y,draw:A,shader:R,state:x,dirty:w,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(N.profile=function(e){var t,r=e.static,n=e.dynamic;if(Be in r){var a=!!r[Be];(t=ot((function(e,t){return a}))).enable=a}else if(Be in n){var i=n[Be];t=ut(i,(function(e,t){return e.invoke(t,i)}))}return t}(e),N.uniforms=function(e,t){var r=e.static,n=e.dynamic,a={};return Object.keys(r).forEach((function(e){var n,i=r[e];if("number"==typeof i||"boolean"==typeof i)n=ot((function(){return i}));else if("function"==typeof i){var o=i._reglType;"texture2d"===o||"textureCube"===o?n=ot((function(e){return e.link(i)})):"framebuffer"===o||"framebufferCube"===o?(_.command(i.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),n=ot((function(e){return e.link(i.color[0])}))):_.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else J(i)?n=ot((function(t){return t.global.def("[",L(i.length,(function(r){return _.command("number"==typeof i[r]||"boolean"==typeof i[r],"invalid uniform "+e,t.commandStr),i[r]})),"]")})):_.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);n.value=i,a[e]=n})),Object.keys(n).forEach((function(e){var t=n[e];a[e]=ut(t,(function(e,r){return e.invoke(r,t)}))})),a}(u,d),N.drawVAO=N.scopeVAO=function(e,t){var r=e.static,n=e.dynamic;if(We in r){var a=r[We];return null!==a&&null===c.getVAO(a)&&(a=c.createVAO(a)),ot((function(e){return e.link(c.getVAO(a))}))}if(We in n){var i=n[We];return ut(i,(function(e,t){var r=e.invoke(t,i);return t.def(e.shared.vao+".getVAO("+r+")")}))}return null}(e),!N.drawVAO&&R.program&&!h&&n.angle_instanced_arrays){var I=!0,C=R.program.attributes.map((function(e){var r=t.static[e];return I=I&&!!r,r}));if(I&&C.length>0){var D=c.getVAO(c.createVAO(C));N.drawVAO=new at(null,null,null,(function(e,t){return e.link(D)})),N.useVAO=!0}}return h?N.useVAO=!0:N.attributes=function(e,t){var n=e.static,a=e.dynamic,o={};return Object.keys(n).forEach((function(e){var a=n[e],u=r.id(e),f=new E;if(rt(a))f.state=1,f.buffer=i.getBuffer(i.create(a,34962,!1,!0)),f.type=0;else{var s=i.getBuffer(a);if(s)f.state=1,f.buffer=s,f.type=0;else if(_.command("object"==typeof a&&a,"invalid data for attribute "+e,t.commandStr),"constant"in a){var c=a.constant;f.buffer="null",f.state=2,"number"==typeof c?f.x=c:(_.command(J(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,t.commandStr),Fe.forEach((function(e,t){t<c.length&&(f[e]=c[t])})))}else{s=rt(a.buffer)?i.getBuffer(i.create(a.buffer,34962,!1,!0)):i.getBuffer(a.buffer),_.command(!!s,'missing buffer for attribute "'+e+'"',t.commandStr);var l=0|a.offset;_.command(l>=0,'invalid offset for attribute "'+e+'"',t.commandStr);var d=0|a.stride;_.command(d>=0&&d<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',t.commandStr);var p=0|a.size;_.command(!("size"in a)||p>0&&p<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',t.commandStr);var m=!!a.normalized,h=0;"type"in a&&(_.commandParameter(a.type,G,"invalid type for attribute "+e,t.commandStr),h=G[a.type]);var b=0|a.divisor;"divisor"in a&&(_.command(0===b||v,'cannot specify divisor for attribute "'+e+'", instancing not supported',t.commandStr),_.command(b>=0,'invalid divisor for attribute "'+e+'"',t.commandStr)),_.optional((function(){var r=t.commandStr,n=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(a).forEach((function(t){_.command(n.indexOf(t)>=0,'unknown parameter "'+t+'" for attribute pointer "'+e+'" (valid parameters are '+n+")",r)}))})),f.buffer=s,f.state=1,f.size=p,f.normalized=m,f.type=h||s.dtype,f.offset=l,f.stride=d,f.divisor=b}}o[e]=ot((function(e,t){var r=e.attribCache;if(u in r)return r[u];var n={isStream:!1};return Object.keys(f).forEach((function(e){n[e]=f[e]})),f.buffer&&(n.buffer=e.link(f.buffer),n.type=n.type||n.buffer+".dtype"),r[u]=n,n}))})),Object.keys(a).forEach((function(e){var t=a[e];o[e]=ut(t,(function(r,n){var a=r.invoke(n,t),i=r.shared,o=r.constants,u=i.isBufferArgs,f=i.buffer;_.optional((function(){r.assert(n,a+"&&(typeof "+a+'==="object"||typeof '+a+'==="function")&&('+u+"("+a+")||"+f+".getBuffer("+a+")||"+f+".getBuffer("+a+".buffer)||"+u+"("+a+'.buffer)||("constant" in '+a+"&&(typeof "+a+'.constant==="number"||'+i.isArrayLike+"("+a+".constant))))",'invalid dynamic attribute "'+e+'"')}));var s={isStream:n.def(!1)},c=new E;c.state=1,Object.keys(c).forEach((function(e){s[e]=n.def(""+c[e])}));var l=s.buffer,d=s.type;function p(e){n(s[e],"=",a,".",e,"|0;")}return n("if(",u,"(",a,")){",s.isStream,"=true;",l,"=",f,".createStream(",34962,",",a,");",d,"=",l,".dtype;","}else{",l,"=",f,".getBuffer(",a,");","if(",l,"){",d,"=",l,".dtype;",'}else if("constant" in ',a,"){",s.state,"=",2,";","if(typeof "+a+'.constant === "number"){',s[Fe[0]],"=",a,".constant;",Fe.slice(1).map((function(e){return s[e]})).join("="),"=0;","}else{",Fe.map((function(e,t){return s[e]+"="+a+".constant.length>"+t+"?"+a+".constant["+t+"]:0;"})).join(""),"}}else{","if(",u,"(",a,".buffer)){",l,"=",f,".createStream(",34962,",",a,".buffer);","}else{",l,"=",f,".getBuffer(",a,".buffer);","}",d,'="type" in ',a,"?",o.glTypes,"[",a,".type]:",l,".dtype;",s.normalized,"=!!",a,".normalized;"),p("size"),p("offset"),p("stride"),p("divisor"),n("}}"),n.exit("if(",s.isStream,"){",f,".destroyStream(",l,");","}"),s}))})),o}(t,d),N.context=function(e){var t=e.static,r=e.dynamic,n={};return Object.keys(t).forEach((function(e){var r=t[e];n[e]=ot((function(e,t){return"number"==typeof r||"boolean"==typeof r?""+r:e.link(r)}))})),Object.keys(r).forEach((function(e){var t=r[e];n[e]=ut(t,(function(e,r){return e.invoke(r,t)}))})),n}(s),N}function F(e,t,r){var n=e.shared.context,a=e.scope();Object.keys(r).forEach((function(i){t.save(n,"."+i);var o=r[i].append(e,t);Array.isArray(o)?a(n,".",i,"=[",o.join(),"];"):a(n,".",i,"=",o,";")})),t(a)}function B(e,t,r,n){var a,i=e.shared,o=i.gl,u=i.framebuffer;y&&(a=t.def(i.extensions,".webgl_draw_buffers"));var f,s=e.constants,c=s.drawBuffer,l=s.backBuffer;f=r?r.append(e,t):t.def(u,".next"),n||t("if(",f,"!==",u,".cur){"),t("if(",f,"){",o,".bindFramebuffer(",36160,",",f,".framebuffer);"),y&&t(a,".drawBuffersWEBGL(",c,"[",f,".colorAttachments.length]);"),t("}else{",o,".bindFramebuffer(",36160,",null);"),y&&t(a,".drawBuffersWEBGL(",l,");"),t("}",u,".cur=",f,";"),n||t("}")}function M(e,t,r){var n=e.shared,a=n.gl,i=e.current,o=e.next,u=n.current,f=n.next,s=e.cond(u,".dirty");T.forEach((function(t){var n,c,l=O(t);if(!(l in r.state))if(l in o){n=o[l],c=i[l];var d=L(g[l].length,(function(e){return s.def(n,"[",e,"]")}));s(e.cond(d.map((function(e,t){return e+"!=="+c+"["+t+"]"})).join("||")).then(a,".",R[l],"(",d,");",d.map((function(e,t){return c+"["+t+"]="+e})).join(";"),";"))}else{n=s.def(f,".",l);var p=e.cond(n,"!==",u,".",l);s(p),l in x?p(e.cond(n).then(a,".enable(",x[l],");").else(a,".disable(",x[l],");"),u,".",l,"=",n,";"):p(a,".",R[l],"(",n,");",u,".",l,"=",n,";")}})),0===Object.keys(r.state).length&&s(u,".dirty=false;"),t(s)}function k(e,t,r,n){var a=e.shared,i=e.current,o=a.current,u=a.gl;nt(Object.keys(r)).forEach((function(a){var f=r[a];if(!n||n(f)){var s=f.append(e,t);if(x[a]){var c=x[a];it(f)?t(u,s?".enable(":".disable(",c,");"):t(e.cond(s).then(u,".enable(",c,");").else(u,".disable(",c,");")),t(o,".",a,"=",s,";")}else if(J(s)){var l=i[a];t(u,".",R[a],"(",s,");",s.map((function(e,t){return l+"["+t+"]="+e})).join(";"),";")}else t(u,".",R[a],"(",s,");",o,".",a,"=",s,";")}}))}function j(e,t){v&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function V(e,t,r,n,a){var i,o,u,f=e.shared,s=e.stats,c=f.current,l=f.timer,d=r.profile;function p(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function h(e){e(i=t.def(),"=",p(),";"),"string"==typeof a?e(s,".count+=",a,";"):e(s,".count++;"),m&&(n?e(o=t.def(),"=",l,".getNumPendingQueries();"):e(l,".beginQuery(",s,");"))}function E(e){e(s,".cpuTime+=",p(),"-",i,";"),m&&(n?e(l,".pushScopeStats(",o,",",l,".getNumPendingQueries(),",s,");"):e(l,".endQuery();"))}function b(e){var r=t.def(c,".profile");t(c,".profile=",e,";"),t.exit(c,".profile=",r,";")}if(d){if(it(d))return void(d.enable?(h(t),E(t.exit),b("true")):b("false"));b(u=d.append(e,t))}else u=t.def(c,".profile");var v=e.block();h(v),t("if(",u,"){",v,"}");var y=e.block();E(y),t.exit("if(",u,"){",y,"}")}function X(e,t,r,n,a){var i=e.shared;n.forEach((function(n){var o,u=n.name,f=r.attributes[u];if(f){if(!a(f))return;o=f.append(e,t)}else{if(!a(ft))return;var s=e.scopeAttrib(u);_.optional((function(){e.assert(t,s+".state","missing attribute "+u)})),o={},Object.keys(new E).forEach((function(e){o[e]=t.def(s,".",e)}))}!function(r,n,a){var o=i.gl,u=t.def(r,".location"),f=t.def(i.attributes,"[",u,"]"),s=a.state,c=a.buffer,l=[a.x,a.y,a.z,a.w],d=["buffer","normalized","offset","stride"];function p(){t("if(!",f,".buffer){",o,".enableVertexAttribArray(",u,");}");var r,i=a.type;if(r=a.size?t.def(a.size,"||",n):n,t("if(",f,".type!==",i,"||",f,".size!==",r,"||",d.map((function(e){return f+"."+e+"!=="+a[e]})).join("||"),"){",o,".bindBuffer(",34962,",",c,".buffer);",o,".vertexAttribPointer(",[u,r,i,a.normalized,a.stride,a.offset],");",f,".type=",i,";",f,".size=",r,";",d.map((function(e){return f+"."+e+"="+a[e]+";"})).join(""),"}"),v){var s=a.divisor;t("if(",f,".divisor!==",s,"){",e.instancing,".vertexAttribDivisorANGLE(",[u,s],");",f,".divisor=",s,";}")}}function m(){t("if(",f,".buffer){",o,".disableVertexAttribArray(",u,");",f,".buffer=null;","}if(",Fe.map((function(e,t){return f+"."+e+"!=="+l[t]})).join("||"),"){",o,".vertexAttrib4f(",u,",",l,");",Fe.map((function(e,t){return f+"."+e+"="+l[t]+";"})).join(""),"}")}1===s?p():2===s?m():(t("if(",s,"===",1,"){"),p(),t("}else{"),m(),t("}"))}(e.link(n),function(e){switch(e){case 35664:case 35667:case 35671:return 2;case 35665:case 35668:case 35672:return 3;case 35666:case 35669:case 35673:return 4;default:return 1}}(n.info.type),o)}))}function H(e,t,n,a,i){for(var o,u=e.shared,f=u.gl,s=0;s<a.length;++s){var c,l=a[s],d=l.name,p=l.info.type,m=n.uniforms[d],h=e.link(l)+".location";if(m){if(!i(m))continue;if(it(m)){var E=m.value;if(_.command(null!=E,'missing uniform "'+d+'"',e.commandStr),35678===p||35680===p){_.command("function"==typeof E&&(35678===p&&("texture2d"===E._reglType||"framebuffer"===E._reglType)||35680===p&&("textureCube"===E._reglType||"framebufferCube"===E._reglType)),"invalid texture for uniform "+d,e.commandStr);var b=e.link(E._texture||E.color[0]._texture);t(f,".uniform1i(",h,",",b+".bind());"),t.exit(b,".unbind();")}else if(35674===p||35675===p||35676===p){_.optional((function(){_.command(J(E),"invalid matrix for uniform "+d,e.commandStr),_.command(35674===p&&4===E.length||35675===p&&9===E.length||35676===p&&16===E.length,"invalid length for matrix uniform "+d,e.commandStr)}));var v=e.global.def("new Float32Array(["+Array.prototype.slice.call(E)+"])"),y=2;35675===p?y=3:35676===p&&(y=4),t(f,".uniformMatrix",y,"fv(",h,",false,",v,");")}else{switch(p){case 5126:_.commandType(E,"number","uniform "+d,e.commandStr),o="1f";break;case 35664:_.command(J(E)&&2===E.length,"uniform "+d,e.commandStr),o="2f";break;case 35665:_.command(J(E)&&3===E.length,"uniform "+d,e.commandStr),o="3f";break;case 35666:_.command(J(E)&&4===E.length,"uniform "+d,e.commandStr),o="4f";break;case 35670:_.commandType(E,"boolean","uniform "+d,e.commandStr),o="1i";break;case 5124:_.commandType(E,"number","uniform "+d,e.commandStr),o="1i";break;case 35671:case 35667:_.command(J(E)&&2===E.length,"uniform "+d,e.commandStr),o="2i";break;case 35672:case 35668:_.command(J(E)&&3===E.length,"uniform "+d,e.commandStr),o="3i";break;case 35673:case 35669:_.command(J(E)&&4===E.length,"uniform "+d,e.commandStr),o="4i"}t(f,".uniform",o,"(",h,",",J(E)?Array.prototype.slice.call(E):E,");")}continue}c=m.append(e,t)}else{if(!i(ft))continue;c=t.def(u.uniforms,"[",r.id(d),"]")}35678===p?(_(!Array.isArray(c),"must specify a scalar prop for textures"),t("if(",c,"&&",c,'._reglType==="framebuffer"){',c,"=",c,".color[0];","}")):35680===p&&(_(!Array.isArray(c),"must specify a scalar prop for cube maps"),t("if(",c,"&&",c,'._reglType==="framebufferCube"){',c,"=",c,".color[0];","}")),_.optional((function(){function r(r,n){e.assert(t,r,'bad data or missing for uniform "'+d+'". '+n)}function n(e){_(!Array.isArray(c),"must not specify an array type for uniform"),r("typeof "+c+'==="'+e+'"',"invalid type, expected "+e)}function a(t,n){Array.isArray(c)?_(c.length===t,"must have length "+t):r(u.isArrayLike+"("+c+")&&"+c+".length==="+t,"invalid vector, should have length "+t,e.commandStr)}function i(t){_(!Array.isArray(c),"must not specify a value type"),r("typeof "+c+'==="function"&&'+c+'._reglType==="texture'+(3553===t?"2d":"Cube")+'"',"invalid texture type",e.commandStr)}switch(p){case 5124:n("number");break;case 35667:a(2);break;case 35668:a(3);break;case 35669:a(4);break;case 5126:n("number");break;case 35664:a(2);break;case 35665:a(3);break;case 35666:a(4);break;case 35670:n("boolean");break;case 35671:a(2);break;case 35672:a(3);break;case 35673:case 35674:a(4);break;case 35675:a(9);break;case 35676:a(16);break;case 35678:i(3553);break;case 35680:i(34067)}}));var g=1;switch(p){case 35678:case 35680:var A=t.def(c,"._texture");t(f,".uniform1i(",h,",",A,".bind());"),t.exit(A,".unbind();");continue;case 5124:case 35670:o="1i";break;case 35667:case 35671:o="2i",g=2;break;case 35668:case 35672:o="3i",g=3;break;case 35669:case 35673:o="4i",g=4;break;case 5126:o="1f";break;case 35664:o="2f",g=2;break;case 35665:o="3f",g=3;break;case 35666:o="4f",g=4;break;case 35674:o="Matrix2fv";break;case 35675:o="Matrix3fv";break;case 35676:o="Matrix4fv"}if(t(f,".uniform",o,"(",h,","),"M"===o.charAt(0)){var T=Math.pow(p-35674+2,2),x=e.global.def("new Float32Array(",T,")");Array.isArray(c)?t("false,(",L(T,(function(e){return x+"["+e+"]="+c[e]})),",",x,")"):t("false,(Array.isArray(",c,")||",c," instanceof Float32Array)?",c,":(",L(T,(function(e){return x+"["+e+"]="+c+"["+e+"]"})),",",x,")")}else g>1?t(L(g,(function(e){return Array.isArray(c)?c[e]:c+"["+e+"]"}))):(_(!Array.isArray(c),"uniform value must not be an array"),t(c));t(");")}}function z(e,t,r,n){var a=e.shared,i=a.gl,o=a.draw,u=n.draw,f=function(){var a,f=u.elements,s=t;return f?((f.contextDep&&n.contextDynamic||f.propDep)&&(s=r),a=f.append(e,s)):a=s.def(o,".",Ge),a&&s("if("+a+")"+i+".bindBuffer(34963,"+a+".buffer.buffer);"),a}();function s(a){var i=u[a];return i?i.contextDep&&n.contextDynamic||i.propDep?i.append(e,r):i.append(e,t):t.def(o,".",a)}var c,l,d=s(Ve),p=s(He),m=function(){var a,i=u.count,f=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(f=r),a=i.append(e,f),_.optional((function(){i.MISSING&&e.assert(t,"false","missing vertex count"),i.DYNAMIC&&e.assert(f,a+">=0","missing vertex count")}))):(a=f.def(o,".",Xe),_.optional((function(){e.assert(f,a+">=0","missing vertex count")}))),a}();if("number"==typeof m){if(0===m)return}else r("if(",m,"){"),r.exit("}");v&&(c=s(ze),l=e.instancing);var h=f+".type",E=u.elements&&it(u.elements);function b(){function e(){r(l,".drawElementsInstancedANGLE(",[d,m,h,p+"<<(("+h+"-5121)>>1)",c],");")}function t(){r(l,".drawArraysInstancedANGLE(",[d,p,m,c],");")}f?E?e():(r("if(",f,"){"),e(),r("}else{"),t(),r("}")):t()}function y(){function e(){r(i+".drawElements("+[d,m,h,p+"<<(("+h+"-5121)>>1)"]+");")}function t(){r(i+".drawArrays("+[d,p,m]+");")}f?E?e():(r("if(",f,"){"),e(),r("}else{"),t(),r("}")):t()}v&&("number"!=typeof c||c>=0)?"string"==typeof c?(r("if(",c,">0){"),b(),r("}else if(",c,"<0){"),y(),r("}")):b():y()}function W(e,t,r,n,a){var i=P(),o=i.proc("body",a);return _.optional((function(){i.commandStr=t.commandStr,i.command=i.link(t.commandStr)})),v&&(i.instancing=o.def(i.shared.extensions,".angle_instanced_arrays")),e(i,o,r,n),i.compile().body}function Y(e,t,r,n){j(e,t),r.useVAO?r.drawVAO?t(e.shared.vao,".setVAO(",r.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),X(e,t,r,n.attributes,(function(){return!0}))),H(e,t,r,n.uniforms,(function(){return!0})),z(e,t,t,r)}function K(e,t,r,n){function a(){return!0}e.batchId="a1",j(e,t),X(e,t,r,n.attributes,a),H(e,t,r,n.uniforms,a),z(e,t,t,r)}function q(e,t,r,n){j(e,t);var a=r.contextDep,i=t.def(),o=t.def();e.shared.props=o,e.batchId=i;var u=e.scope(),f=e.scope();function s(e){return e.contextDep&&a||e.propDep}function c(e){return!s(e)}if(t(u.entry,"for(",i,"=0;",i,"<","a1",";++",i,"){",o,"=","a0","[",i,"];",f,"}",u.exit),r.needsContext&&F(e,f,r.context),r.needsFramebuffer&&B(e,f,r.framebuffer),k(e,f,r.state,s),r.profile&&s(r.profile)&&V(e,f,r,!1,!0),n)r.useVAO?r.drawVAO?s(r.drawVAO)?f(e.shared.vao,".setVAO(",r.drawVAO.append(e,f),");"):u(e.shared.vao,".setVAO(",r.drawVAO.append(e,u),");"):u(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(u(e.shared.vao,".setVAO(null);"),X(e,u,r,n.attributes,c),X(e,f,r,n.attributes,s)),H(e,u,r,n.uniforms,c),H(e,f,r,n.uniforms,s),z(e,u,f,r);else{var l=e.global.def("{}"),d=r.shader.progVar.append(e,f),p=f.def(d,".id"),m=f.def(l,"[",p,"]");f(e.shared.gl,".useProgram(",d,".program);","if(!",m,"){",m,"=",l,"[",p,"]=",e.link((function(t){return W(K,e,r,t,2)})),"(",d,");}",m,".call(this,a0[",i,"],",i,");")}}function Z(e,t,r){var n=t.static[r];if(n&&function(e){if("object"==typeof e&&!J(e)){for(var t=Object.keys(e),r=0;r<t.length;++r)if(S.isDynamic(e[t[r]]))return!0;return!1}}(n)){var a=e.global,i=Object.keys(n),o=!1,u=!1,f=!1,s=e.global.def("{}");i.forEach((function(t){var r=n[t];if(S.isDynamic(r)){"function"==typeof r&&(r=n[t]=S.unbox(r));var i=ut(r,null);o=o||i.thisDep,f=f||i.propDep,u=u||i.contextDep}else{switch(a(s,".",t,"="),typeof r){case"number":a(r);break;case"string":a('"',r,'"');break;case"object":Array.isArray(r)&&a("[",r.join(),"]");break;default:a(e.link(r))}a(";")}})),t.dynamic[r]=new S.DynamicVariable(4,{thisDep:o,contextDep:u,propDep:f,ref:s,append:function(e,t){i.forEach((function(r){var a=n[r];if(S.isDynamic(a)){var i=e.invoke(t,a);t(s,".",r,"=",i,";")}}))}}),delete t.static[r]}}return{next:A,current:g,procs:function(){var e=P(),t=e.proc("poll"),r=e.proc("refresh"),i=e.block();t(i),r(i);var o,u=e.shared,f=u.gl,s=u.next,c=u.current;i(c,".dirty=false;"),B(e,t),B(e,r,null,!0),v&&(o=e.link(v)),n.oes_vertex_array_object&&r(e.link(n.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var l=0;l<a.maxAttributes;++l){var d=r.def(u.attributes,"[",l,"]"),p=e.cond(d,".buffer");p.then(f,".enableVertexAttribArray(",l,");",f,".bindBuffer(",34962,",",d,".buffer.buffer);",f,".vertexAttribPointer(",l,",",d,".size,",d,".type,",d,".normalized,",d,".stride,",d,".offset);").else(f,".disableVertexAttribArray(",l,");",f,".vertexAttrib4f(",l,",",d,".x,",d,".y,",d,".z,",d,".w);",d,".buffer=null;"),r(p),v&&r(o,".vertexAttribDivisorANGLE(",l,",",d,".divisor);")}return r(e.shared.vao,".currentVAO=null;",e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"),Object.keys(x).forEach((function(n){var a=x[n],o=i.def(s,".",n),u=e.block();u("if(",o,"){",f,".enable(",a,")}else{",f,".disable(",a,")}",c,".",n,"=",o,";"),r(u),t("if(",o,"!==",c,".",n,"){",u,"}")})),Object.keys(R).forEach((function(n){var a,o,u=R[n],l=g[n],d=e.block();if(d(f,".",u,"("),J(l)){var p=l.length;a=e.global.def(s,".",n),o=e.global.def(c,".",n),d(L(p,(function(e){return a+"["+e+"]"})),");",L(p,(function(e){return o+"["+e+"]="+a+"["+e+"];"})).join("")),t("if(",L(p,(function(e){return a+"["+e+"]!=="+o+"["+e+"]"})).join("||"),"){",d,"}")}else a=i.def(s,".",n),o=i.def(c,".",n),d(a,");",c,".",n,"=",a,";"),t("if(",a,"!==",o,"){",d,"}");r(d)})),e.compile()}(),compile:function(e,n,a,i,o){var u=P();u.stats=u.link(o),Object.keys(n.static).forEach((function(e){Z(u,n,e)})),Qe.forEach((function(t){Z(u,e,t)}));var f=U(e,n,a,i,u);return function(e,t){var r=e.proc("draw",1);j(e,r),F(e,r,t.context),B(e,r,t.framebuffer),M(e,r,t),k(e,r,t.state),V(e,r,t,!1,!0);var n=t.shader.progVar.append(e,r);if(r(e.shared.gl,".useProgram(",n,".program);"),t.shader.program)Y(e,r,t,t.shader.program);else{r(e.shared.vao,".setVAO(null);");var a=e.global.def("{}"),i=r.def(n,".id"),o=r.def(a,"[",i,"]");r(e.cond(o).then(o,".call(this,a0);").else(o,"=",a,"[",i,"]=",e.link((function(r){return W(Y,e,t,r,1)})),"(",n,");",o,".call(this,a0);"))}Object.keys(t.state).length>0&&r(e.shared.current,".dirty=true;")}(u,f),function(e,t){var n=e.proc("scope",3);e.batchId="a2";var a=e.shared,i=a.current;function o(r){var i=t.shader[r];i&&n.set(a.shader,"."+r,i.append(e,n))}F(e,n,t.context),t.framebuffer&&t.framebuffer.append(e,n),nt(Object.keys(t.state)).forEach((function(r){var i=t.state[r].append(e,n);J(i)?i.forEach((function(t,a){n.set(e.next[r],"["+a+"]",t)})):n.set(a.next,"."+r,i)})),V(e,n,t,!0,!0),[Ge,He,Xe,ze,Ve].forEach((function(r){var i=t.draw[r];i&&n.set(a.draw,"."+r,""+i.append(e,n))})),Object.keys(t.uniforms).forEach((function(i){var o=t.uniforms[i].append(e,n);Array.isArray(o)&&(o="["+o.join()+"]"),n.set(a.uniforms,"["+r.id(i)+"]",o)})),Object.keys(t.attributes).forEach((function(r){var a=t.attributes[r].append(e,n),i=e.scopeAttrib(r);Object.keys(new E).forEach((function(e){n.set(i,"."+e,a[e])}))})),t.scopeVAO&&n.set(a.vao,".targetVAO",t.scopeVAO.append(e,n)),o(ke),o(je),Object.keys(t.state).length>0&&(n(i,".dirty=true;"),n.exit(i,".dirty=true;")),n("a1(",e.shared.context,",a0,",e.batchId,");")}(u,f),function(e,t){var r=e.proc("batch",2);e.batchId="0",j(e,r);var n=!1,a=!0;Object.keys(t.context).forEach((function(e){n=n||t.context[e].propDep})),n||(F(e,r,t.context),a=!1);var i=t.framebuffer,o=!1;function u(e){return e.contextDep&&n||e.propDep}i?(i.propDep?n=o=!0:i.contextDep&&n&&(o=!0),o||B(e,r,i)):B(e,r,null),t.state.viewport&&t.state.viewport.propDep&&(n=!0),M(e,r,t),k(e,r,t.state,(function(e){return!u(e)})),t.profile&&u(t.profile)||V(e,r,t,!1,"a1"),t.contextDep=n,t.needsContext=a,t.needsFramebuffer=o;var f=t.shader.progVar;if(f.contextDep&&n||f.propDep)q(e,r,t,null);else{var s=f.append(e,r);if(r(e.shared.gl,".useProgram(",s,".program);"),t.shader.program)q(e,r,t,t.shader.program);else{r(e.shared.vao,".setVAO(null);");var c=e.global.def("{}"),l=r.def(s,".id"),d=r.def(c,"[",l,"]");r(e.cond(d).then(d,".call(this,a0,a1);").else(d,"=",c,"[",l,"]=",e.link((function(r){return W(q,e,t,r,2)})),"(",s,");",d,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&r(e.shared.current,".dirty=true;")}(u,f),t(u.compile(),{destroy:function(){f.shader.program.destroy()}})}}}var ct=function(e,t){if(!t.ext_disjoint_timer_query)return null;var r=[];function n(e){r.push(e)}var a=[];function i(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var o=[];function u(e){o.push(e)}var f=[];function s(e,t,r){var n=o.pop()||new i;n.startQueryIndex=e,n.endQueryIndex=t,n.sum=0,n.stats=r,f.push(n)}var c=[],l=[];return{beginQuery:function(e){var n=r.pop()||t.ext_disjoint_timer_query.createQueryEXT();t.ext_disjoint_timer_query.beginQueryEXT(35007,n),a.push(n),s(a.length-1,a.length,e)},endQuery:function(){t.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:s,update:function(){var e,r,i=a.length;if(0!==i){l.length=Math.max(l.length,i+1),c.length=Math.max(c.length,i+1),c[0]=0,l[0]=0;var o=0;for(e=0,r=0;r<a.length;++r){var s=a[r];t.ext_disjoint_timer_query.getQueryObjectEXT(s,34919)?(o+=t.ext_disjoint_timer_query.getQueryObjectEXT(s,34918),n(s)):a[e++]=s,c[r+1]=o,l[r+1]=e}for(a.length=e,e=0,r=0;r<f.length;++r){var d=f[r],p=d.startQueryIndex,m=d.endQueryIndex;d.sum+=c[m]-c[p];var h=l[p],E=l[m];E===h?(d.stats.gpuTime+=d.sum/1e6,u(d)):(d.startQueryIndex=h,d.endQueryIndex=E,f[e++]=d)}f.length=e}},getNumPendingQueries:function(){return a.length},clear:function(){r.push.apply(r,a);for(var e=0;e<r.length;e++)t.ext_disjoint_timer_query.deleteQueryEXT(r[e]);a.length=0,r.length=0},restore:function(){a.length=0,r.length=0}}};function lt(e,t){for(var r=0;r<e.length;++r)if(e[r]===t)return r;return-1}return function(r){var n=C(r);if(!n)return null;var a=n.gl,i=a.getContextAttributes(),o=a.isContextLost(),u=function(e,t){var r={};function n(t){_.type(t,"string","extension name must be string");var n,a=t.toLowerCase();try{n=r[a]=e.getExtension(a)}catch(e){}return!!n}for(var a=0;a<t.extensions.length;++a){var i=t.extensions[a];if(!n(i))return t.onDestroy(),t.onDone('"'+i+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return t.optionalExtensions.forEach(n),{extensions:r,restore:function(){Object.keys(r).forEach((function(e){if(r[e]&&!n(e))throw new Error("(regl): error restoring extension "+e)}))}}}(a,n);if(!u)return null;var f,s,c=(f={"":0},s=[""],{id:function(e){var t=f[e];return t||(t=f[e]=s.length,s.push(e),t)},str:function(e){return s[e]}}),l={vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},d=u.extensions,p=ct(0,d),m=w(),h=a.drawingBufferWidth,E=a.drawingBufferHeight,b={tick:0,time:0,viewportWidth:h,viewportHeight:E,framebufferWidth:h,framebufferHeight:E,drawingBufferWidth:h,drawingBufferHeight:E,pixelRatio:n.pixelRatio},v=function(e,t){var r=1;t.ext_texture_filter_anisotropic&&(r=e.getParameter(34047));var n=1,a=1;t.webgl_draw_buffers&&(n=e.getParameter(34852),a=e.getParameter(36063));var i=!!t.oes_texture_float;if(i){var o=e.createTexture();e.bindTexture(3553,o),e.texImage2D(3553,0,6408,1,1,0,6408,5126,null);var u=e.createFramebuffer();if(e.bindFramebuffer(36160,u),e.framebufferTexture2D(36160,36064,3553,o,0),e.bindTexture(3553,null),36053!==e.checkFramebufferStatus(36160))i=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(16384);var f=U.allocType(5126,4);e.readPixels(0,0,1,1,6408,5126,f),e.getError()?i=!1:(e.deleteFramebuffer(u),e.deleteTexture(o),i=1===f[0]),U.freeType(f)}}var s=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var c=e.createTexture(),l=U.allocType(5121,36);e.activeTexture(33984),e.bindTexture(34067,c),e.texImage2D(34069,0,6408,3,3,0,6408,5121,l),U.freeType(l),e.bindTexture(34067,null),e.deleteTexture(c),s=!e.getError()}return{colorBits:[e.getParameter(3410),e.getParameter(3411),e.getParameter(3412),e.getParameter(3413)],depthBits:e.getParameter(3414),stencilBits:e.getParameter(3415),subpixelBits:e.getParameter(3408),extensions:Object.keys(t).filter((function(e){return!!t[e]})),maxAnisotropic:r,maxDrawbuffers:n,maxColorAttachments:a,pointSizeDims:e.getParameter(33901),lineWidthDims:e.getParameter(33902),maxViewportDims:e.getParameter(3386),maxCombinedTextureUnits:e.getParameter(35661),maxCubeMapSize:e.getParameter(34076),maxRenderbufferSize:e.getParameter(34024),maxTextureUnits:e.getParameter(34930),maxTextureSize:e.getParameter(3379),maxAttributes:e.getParameter(34921),maxVertexUniforms:e.getParameter(36347),maxVertexTextureUnits:e.getParameter(35660),maxVaryingVectors:e.getParameter(36348),maxFragmentUniforms:e.getParameter(36349),glsl:e.getParameter(35724),renderer:e.getParameter(7937),vendor:e.getParameter(7936),version:e.getParameter(7938),readFloat:i,npotTextureCube:s}}(a,d),y=function(t,r,n,a){var i=0,o={};function u(e){this.id=i++,this.buffer=t.createBuffer(),this.type=e,this.usage=35044,this.byteLength=0,this.dimension=1,this.dtype=5121,this.persistentData=null,n.profile&&(this.stats={size:0})}u.prototype.bind=function(){t.bindBuffer(this.type,this.buffer)},u.prototype.destroy=function(){l(this)};var f=[];function s(e,r,n){e.byteLength=r.byteLength,t.bufferData(e.type,r,n)}function c(t,r,n,a,i,o){var u,f;if(t.usage=n,Array.isArray(r)){if(t.dtype=a||5126,r.length>0)if(Array.isArray(r[0])){u=H(r);for(var c=1,l=1;l<u.length;++l)c*=u[l];t.dimension=c,s(t,f=X(r,u,t.dtype),n),o?t.persistentData=f:U.freeType(f)}else if("number"==typeof r[0]){t.dimension=i;var d=U.allocType(t.dtype,r.length);Y(d,r),s(t,d,n),o?t.persistentData=d:U.freeType(d)}else e(r[0])?(t.dimension=r[0].length,t.dtype=a||W(r[0])||5126,s(t,f=X(r,[r.length,r[0].length],t.dtype),n),o?t.persistentData=f:U.freeType(f)):_.raise("invalid buffer data")}else if(e(r))t.dtype=a||W(r),t.dimension=i,s(t,r,n),o&&(t.persistentData=new Uint8Array(new Uint8Array(r.buffer)));else if(F(r)){u=r.shape;var p=r.stride,m=r.offset,h=0,E=0,b=0,v=0;1===u.length?(h=u[0],E=1,b=p[0],v=0):2===u.length?(h=u[0],E=u[1],b=p[0],v=p[1]):_.raise("invalid shape"),t.dtype=a||W(r.data)||5126,t.dimension=E;var y=U.allocType(t.dtype,h*E);K(y,r.data,h,E,b,v,m),s(t,y,n),o?t.persistentData=y:U.freeType(y)}else r instanceof ArrayBuffer?(t.dtype=5121,t.dimension=i,s(t,r,n),o&&(t.persistentData=new Uint8Array(new Uint8Array(r)))):_.raise("invalid buffer data")}function l(e){r.bufferCount--,a(e);var n=e.buffer;_(n,"buffer must not be deleted already"),t.deleteBuffer(n),e.buffer=null,delete o[e.id]}return n.profile&&(r.getTotalBufferSize=function(){var e=0;return Object.keys(o).forEach((function(t){e+=o[t].stats.size})),e}),{create:function(a,i,f,s){r.bufferCount++;var d=new u(i);function p(r){var a=35044,i=null,o=0,u=0,f=1;return Array.isArray(r)||e(r)||F(r)||r instanceof ArrayBuffer?i=r:"number"==typeof r?o=0|r:r&&(_.type(r,"object","buffer arguments must be an object, a number or an array"),"data"in r&&(_(null===i||Array.isArray(i)||e(i)||F(i),"invalid data for buffer"),i=r.data),"usage"in r&&(_.parameter(r.usage,V,"invalid buffer usage"),a=V[r.usage]),"type"in r&&(_.parameter(r.type,G,"invalid buffer type"),u=G[r.type]),"dimension"in r&&(_.type(r.dimension,"number","invalid dimension"),f=0|r.dimension),"length"in r&&(_.nni(o,"buffer length must be a nonnegative integer"),o=0|r.length)),d.bind(),i?c(d,i,a,u,f,s):(o&&t.bufferData(d.type,o,a),d.dtype=u||5121,d.usage=a,d.dimension=f,d.byteLength=o),n.profile&&(d.stats.size=d.byteLength*z[d.dtype]),p}function m(e,r){_(r+e.byteLength<=d.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+e.byteLength+" starting from offset "+r+" to a buffer of size "+d.byteLength),t.bufferSubData(d.type,r,e)}return o[d.id]=d,f||p(a),p._reglType="buffer",p._buffer=d,p.subdata=function(t,r){var n,a=0|(r||0);if(d.bind(),e(t)||t instanceof ArrayBuffer)m(t,a);else if(Array.isArray(t)){if(t.length>0)if("number"==typeof t[0]){var i=U.allocType(d.dtype,t.length);Y(i,t),m(i,a),U.freeType(i)}else if(Array.isArray(t[0])||e(t[0])){n=H(t);var o=X(t,n,d.dtype);m(o,a),U.freeType(o)}else _.raise("invalid buffer data")}else if(F(t)){n=t.shape;var u=t.stride,f=0,s=0,c=0,l=0;1===n.length?(f=n[0],s=1,c=u[0],l=0):2===n.length?(f=n[0],s=n[1],c=u[0],l=u[1]):_.raise("invalid shape");var h=Array.isArray(t.data)?d.dtype:W(t.data),E=U.allocType(h,f*s);K(E,t.data,f,s,c,l,t.offset),m(E,a),U.freeType(E)}else _.raise("invalid data for buffer subdata");return p},n.profile&&(p.stats=d.stats),p.destroy=function(){l(d)},p},createStream:function(e,t){var r=f.pop();return r||(r=new u(e)),r.bind(),c(r,t,35040,0,1,!1),r},destroyStream:function(e){f.push(e)},clear:function(){B(o).forEach(l),f.forEach(l)},getBuffer:function(e){return e&&e._buffer instanceof u?e._buffer:null},restore:function(){B(o).forEach((function(e){e.buffer=t.createBuffer(),t.bindBuffer(e.type,e.buffer),t.bufferData(e.type,e.persistentData||e.byteLength,e.usage)}))},_initBuffer:c}}(a,l,n,(function(e){return g.destroyBuffer(e)})),g=function(t,r,n,a,i){for(var o=n.maxAttributes,u=new Array(o),f=0;f<o;++f)u[f]=new Le;var s=0,c={},l={Record:Le,scope:{},state:u,currentVAO:null,targetVAO:null,restore:d()?function(){d()&&B(c).forEach((function(e){e.refresh()}))}:function(){},createVAO:function(t){var n=new m;function u(t){_(Array.isArray(t),"arguments to vertex array constructor must be an array"),_(t.length<o,"too many attributes"),_(t.length>0,"must specify at least one attribute");var a={},f=n.attributes;f.length=t.length;for(var s=0;s<t.length;++s){var c,l=t[s],d=f[s]=new Le,p=l.data||l;Array.isArray(p)||e(p)||F(p)?(n.buffers[s]&&(c=n.buffers[s],e(p)&&c._buffer.byteLength>=p.byteLength?c.subdata(p):(c.destroy(),n.buffers[s]=null)),n.buffers[s]||(c=n.buffers[s]=i.create(l,34962,!1,!0)),d.buffer=i.getBuffer(c),d.size=0|d.buffer.dimension,d.normalized=!1,d.type=d.buffer.dtype,d.offset=0,d.stride=0,d.divisor=0,d.state=1,a[s]=1):i.getBuffer(l)?(d.buffer=i.getBuffer(l),d.size=0|d.buffer.dimension,d.normalized=!1,d.type=d.buffer.dtype,d.offset=0,d.stride=0,d.divisor=0,d.state=1):i.getBuffer(l.buffer)?(d.buffer=i.getBuffer(l.buffer),d.size=0|(+l.size||d.buffer.dimension),d.normalized=!!l.normalized||!1,"type"in l?(_.parameter(l.type,G,"invalid buffer type"),d.type=G[l.type]):d.type=d.buffer.dtype,d.offset=0|(l.offset||0),d.stride=0|(l.stride||0),d.divisor=0|(l.divisor||0),d.state=1,_(d.size>=1&&d.size<=4,"size must be between 1 and 4"),_(d.offset>=0,"invalid offset"),_(d.stride>=0&&d.stride<=255,"stride must be between 0 and 255"),_(d.divisor>=0,"divisor must be positive"),_(!d.divisor||!!r.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in l?(_(s>0,"first attribute must not be a constant"),d.x=+l.x||0,d.y=+l.y||0,d.z=+l.z||0,d.w=+l.w||0,d.state=2):_(!1,"invalid attribute spec for location "+s)}for(var m=0;m<n.buffers.length;++m)!a[m]&&n.buffers[m]&&(n.buffers[m].destroy(),n.buffers[m]=null);return n.refresh(),u}return a.vaoCount+=1,u.destroy=function(){for(var e=0;e<n.buffers.length;++e)n.buffers[e]&&n.buffers[e].destroy();n.buffers.length=0,n.destroy()},u._vao=n,u._reglType="vao",u(t)},getVAO:function(e){return"function"==typeof e&&e._vao?e._vao:null},destroyBuffer:function(e){for(var r=0;r<u.length;++r){var n=u[r];n.buffer===e&&(t.disableVertexAttribArray(r),n.buffer=null)}},setVAO:d()?function(e){if(e!==l.currentVAO){var t=d();e?t.bindVertexArrayOES(e.vao):t.bindVertexArrayOES(null),l.currentVAO=e}}:function(e){if(e!==l.currentVAO){if(e)e.bindAttrs();else for(var r=p(),n=0;n<u.length;++n){var a=u[n];a.buffer?(t.enableVertexAttribArray(n),t.vertexAttribPointer(n,a.size,a.type,a.normalized,a.stride,a.offfset),r&&a.divisor&&r.vertexAttribDivisorANGLE(n,a.divisor)):(t.disableVertexAttribArray(n),t.vertexAttrib4f(n,a.x,a.y,a.z,a.w))}l.currentVAO=e}},clear:d()?function(){B(c).forEach((function(e){e.destroy()}))}:function(){}};function d(){return r.oes_vertex_array_object}function p(){return r.angle_instanced_arrays}function m(){this.id=++s,this.attributes=[];var e=d();this.vao=e?e.createVertexArrayOES():null,c[this.id]=this,this.buffers=[]}return m.prototype.bindAttrs=function(){for(var e=p(),r=this.attributes,n=0;n<r.length;++n){var a=r[n];a.buffer?(t.enableVertexAttribArray(n),t.bindBuffer(34962,a.buffer.buffer),t.vertexAttribPointer(n,a.size,a.type,a.normalized,a.stride,a.offset),e&&a.divisor&&e.vertexAttribDivisorANGLE(n,a.divisor)):(t.disableVertexAttribArray(n),t.vertexAttrib4f(n,a.x,a.y,a.z,a.w))}for(var i=r.length;i<o;++i)t.disableVertexAttribArray(i)},m.prototype.refresh=function(){var e=d();e&&(e.bindVertexArrayOES(this.vao),this.bindAttrs(),l.currentVAO=this)},m.prototype.destroy=function(){if(this.vao){var e=d();this===l.currentVAO&&(l.currentVAO=null,e.bindVertexArrayOES(null)),e.deleteVertexArrayOES(this.vao),this.vao=null}c[this.id]&&(delete c[this.id],a.vaoCount-=1)},l}(a,d,v,l,y),A=function(t,r,n,a){var i={},o=0,u={uint8:5121,uint16:5123};function f(e){this.id=o++,i[this.id]=this,this.buffer=e,this.primType=4,this.vertCount=0,this.type=0}r.oes_element_index_uint&&(u.uint32=5125),f.prototype.bind=function(){this.buffer.bind()};var s=[];function c(a,i,o,u,f,s,c){var l;if(a.buffer.bind(),i){var d=c;c||e(i)&&(!F(i)||e(i.data))||(d=r.oes_element_index_uint?5125:5123),n._initBuffer(a.buffer,i,o,d,3)}else t.bufferData(34963,s,o),a.buffer.dtype=l||5121,a.buffer.usage=o,a.buffer.dimension=3,a.buffer.byteLength=s;if(l=c,!c){switch(a.buffer.dtype){case 5121:case 5120:l=5121;break;case 5123:case 5122:l=5123;break;case 5125:case 5124:l=5125;break;default:_.raise("unsupported type for element array")}a.buffer.dtype=l}a.type=l,_(5125!==l||!!r.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var p=f;p<0&&(p=a.buffer.byteLength,5123===l?p>>=1:5125===l&&(p>>=2)),a.vertCount=p;var m=u;if(u<0){m=4;var h=a.buffer.dimension;1===h&&(m=0),2===h&&(m=1),3===h&&(m=4)}a.primType=m}function l(e){a.elementsCount--,_(null!==e.buffer,"must not double destroy elements"),delete i[e.id],e.buffer.destroy(),e.buffer=null}return{create:function(t,r){var i=n.create(null,34963,!0),o=new f(i._buffer);function s(t){if(t)if("number"==typeof t)i(t),o.primType=4,o.vertCount=0|t,o.type=5121;else{var r=null,n=35044,a=-1,f=-1,l=0,d=0;Array.isArray(t)||e(t)||F(t)?r=t:(_.type(t,"object","invalid arguments for elements"),"data"in t&&(r=t.data,_(Array.isArray(r)||e(r)||F(r),"invalid data for element buffer")),"usage"in t&&(_.parameter(t.usage,V,"invalid element buffer usage"),n=V[t.usage]),"primitive"in t&&(_.parameter(t.primitive,Q,"invalid element buffer primitive"),a=Q[t.primitive]),"count"in t&&(_("number"==typeof t.count&&t.count>=0,"invalid vertex count for elements"),f=0|t.count),"type"in t&&(_.parameter(t.type,u,"invalid buffer type"),d=u[t.type]),"length"in t?l=0|t.length:(l=f,5123===d||5122===d?l*=2:5125!==d&&5124!==d||(l*=4))),c(o,r,n,a,f,l,d)}else i(),o.primType=4,o.vertCount=0,o.type=5121;return s}return a.elementsCount++,s(t),s._reglType="elements",s._elements=o,s.subdata=function(e,t){return i.subdata(e,t),s},s.destroy=function(){l(o)},s},createStream:function(e){var t=s.pop();return t||(t=new f(n.create(null,34963,!0,!1)._buffer)),c(t,e,35040,-1,-1,0,0),t},destroyStream:function(e){s.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof f?e._elements:null},clear:function(){B(i).forEach(l)}}}(a,d,y,l),T=function(e,r,n,a){var i={},o={};function u(e,t,r,n){this.name=e,this.id=t,this.location=r,this.info=n}function f(e,t){for(var r=0;r<e.length;++r)if(e[r].id===t.id)return void(e[r].location=t.location);e.push(t)}function s(t,n,a){var u=35632===t?i:o,f=u[n];if(!f){var s=r.str(n);f=e.createShader(t),e.shaderSource(f,s),e.compileShader(f),_.shaderError(e,f,s,t,a),u[n]=f}return f}var c={},l=[],d=0;function p(e,t){this.id=d++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,a.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function m(t,n,i){var o,c,l=s(35632,t.fragId),d=s(35633,t.vertId),p=t.program=e.createProgram();if(e.attachShader(p,l),e.attachShader(p,d),i)for(o=0;o<i.length;++o){var m=i[o];e.bindAttribLocation(p,m[0],m[1])}e.linkProgram(p),_.linkError(e,p,r.str(t.fragId),r.str(t.vertId),n);var h=e.getProgramParameter(p,35718);a.profile&&(t.stats.uniformsCount=h);var E=t.uniforms;for(o=0;o<h;++o)if(c=e.getActiveUniform(p,o))if(c.size>1)for(var b=0;b<c.size;++b){var v=c.name.replace("[0]","["+b+"]");f(E,new u(v,r.id(v),e.getUniformLocation(p,v),c))}else f(E,new u(c.name,r.id(c.name),e.getUniformLocation(p,c.name),c));var y=e.getProgramParameter(p,35721);a.profile&&(t.stats.attributesCount=y);var g=t.attributes;for(o=0;o<y;++o)(c=e.getActiveAttrib(p,o))&&f(g,new u(c.name,r.id(c.name),e.getAttribLocation(p,c.name),c))}return a.profile&&(n.getMaxUniformsCount=function(){var e=0;return l.forEach((function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)})),e},n.getMaxAttributesCount=function(){var e=0;return l.forEach((function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)})),e}),{clear:function(){var t=e.deleteShader.bind(e);B(i).forEach(t),i={},B(o).forEach(t),o={},l.forEach((function(t){e.deleteProgram(t.program)})),l.length=0,c={},n.shaderCount=0},program:function(r,a,u,f){_.command(r>=0,"missing vertex shader",u),_.command(a>=0,"missing fragment shader",u);var s=c[a];s||(s=c[a]={});var d=s[r];if(d&&(d.refCount++,!f))return d;var h=new p(a,r);return n.shaderCount++,m(h,u,f),d||(s[r]=h),l.push(h),t(h,{destroy:function(){if(h.refCount--,h.refCount<=0){e.deleteProgram(h.program);var t=l.indexOf(h);l.splice(t,1),n.shaderCount--}s[h.vertId].refCount<=0&&(e.deleteShader(o[h.vertId]),delete o[h.vertId],delete c[h.fragId][h.vertId]),Object.keys(c[h.fragId]).length||(e.deleteShader(i[h.fragId]),delete i[h.fragId],delete c[h.fragId])}})},restore:function(){i={},o={};for(var e=0;e<l.length;++e)m(l[e],null,l[e].attributes.map((function(e){return[e.location,e.name]})))},shader:s,frag:-1,vert:-1}}(a,c,l,n),x=xe(a,d,v,(function(){I.procs.poll()}),b,l,n),R=function(e,t,r,n,a){var i={rgba4:32854,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041};t.ext_srgb&&(i.srgba=35907),t.ext_color_buffer_half_float&&(i.rgba16f=34842,i.rgb16f=34843),t.webgl_color_buffer_float&&(i.rgba32f=34836);var o=[];Object.keys(i).forEach((function(e){var t=i[e];o[t]=e}));var u=0,f={};function s(e){this.id=u++,this.refCount=1,this.renderbuffer=e,this.format=32854,this.width=0,this.height=0,a.profile&&(this.stats={size:0})}function c(t){var r=t.renderbuffer;_(r,"must not double destroy renderbuffer"),e.bindRenderbuffer(36161,null),e.deleteRenderbuffer(r),t.renderbuffer=null,t.refCount=0,delete f[t.id],n.renderbufferCount--}return s.prototype.decRef=function(){--this.refCount<=0&&c(this)},a.profile&&(n.getTotalRenderbufferSize=function(){var e=0;return Object.keys(f).forEach((function(t){e+=f[t].stats.size})),e}),{create:function(t,u){var c=new s(e.createRenderbuffer());function l(t,n){var u=0,f=0,s=32854;if("object"==typeof t&&t){var d=t;if("shape"in d){var p=d.shape;_(Array.isArray(p)&&p.length>=2,"invalid renderbuffer shape"),u=0|p[0],f=0|p[1]}else"radius"in d&&(u=f=0|d.radius),"width"in d&&(u=0|d.width),"height"in d&&(f=0|d.height);"format"in d&&(_.parameter(d.format,i,"invalid renderbuffer format"),s=i[d.format])}else"number"==typeof t?(u=0|t,f="number"==typeof n?0|n:u):t?_.raise("invalid arguments to renderbuffer constructor"):u=f=1;if(_(u>0&&f>0&&u<=r.maxRenderbufferSize&&f<=r.maxRenderbufferSize,"invalid renderbuffer size"),u!==c.width||f!==c.height||s!==c.format)return l.width=c.width=u,l.height=c.height=f,c.format=s,e.bindRenderbuffer(36161,c.renderbuffer),e.renderbufferStorage(36161,s,u,f),_(0===e.getError(),"invalid render buffer format"),a.profile&&(c.stats.size=Se(c.format,c.width,c.height)),l.format=o[c.format],l}return f[c.id]=c,n.renderbufferCount++,l(t,u),l.resize=function(t,n){var i=0|t,o=0|n||i;return i===c.width&&o===c.height||(_(i>0&&o>0&&i<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),l.width=c.width=i,l.height=c.height=o,e.bindRenderbuffer(36161,c.renderbuffer),e.renderbufferStorage(36161,c.format,i,o),_(0===e.getError(),"invalid render buffer format"),a.profile&&(c.stats.size=Se(c.format,c.width,c.height))),l},l._reglType="renderbuffer",l._renderbuffer=c,a.profile&&(l.stats=c.stats),l.destroy=function(){c.decRef()},l},clear:function(){B(f).forEach(c)},restore:function(){B(f).forEach((function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,t.renderbuffer),e.renderbufferStorage(36161,t.format,t.width,t.height)})),e.bindRenderbuffer(36161,null)}}}(a,d,v,l,n),N=function(e,r,n,a,i,o){var u={cur:null,next:null,dirty:!1,setFBO:null},f=["rgba"],s=["rgba4","rgb565","rgb5 a1"];r.ext_srgb&&s.push("srgba"),r.ext_color_buffer_half_float&&s.push("rgba16f","rgb16f"),r.webgl_color_buffer_float&&s.push("rgba32f");var c=["uint8"];function l(e,t,r){this.target=e,this.texture=t,this.renderbuffer=r;var n=0,a=0;t?(n=t.width,a=t.height):r&&(n=r.width,a=r.height),this.width=n,this.height=a}function d(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function p(e,t,r){if(e)if(e.texture){var n=e.texture._texture,a=Math.max(1,n.width),i=Math.max(1,n.height);_(a===t&&i===r,"inconsistent width/height for supplied texture"),n.refCount+=1}else{var o=e.renderbuffer._renderbuffer;_(o.width===t&&o.height===r,"inconsistent width/height for renderbuffer"),o.refCount+=1}}function m(t,r){r&&(r.texture?e.framebufferTexture2D(36160,t,r.target,r.texture._texture.texture,0):e.framebufferRenderbuffer(36160,t,36161,r.renderbuffer._renderbuffer.renderbuffer))}function h(e){var t=3553,r=null,n=null,a=e;"object"==typeof e&&(a=e.data,"target"in e&&(t=0|e.target)),_.type(a,"function","invalid attachment data");var i=a._reglType;return"texture2d"===i?(r=a,_(3553===t)):"textureCube"===i?(r=a,_(t>=34069&&t<34075,"invalid cube map target")):"renderbuffer"===i?(n=a,t=36161):_.raise("invalid regl object for attachment"),new l(t,r,n)}function E(e,t,r,n,o){if(r){var u=a.create2D({width:e,height:t,format:n,type:o});return u._texture.refCount=0,new l(3553,u,null)}var f=i.create({width:e,height:t,format:n});return f._renderbuffer.refCount=0,new l(36161,null,f)}function b(e){return e&&(e.texture||e.renderbuffer)}function v(e,t,r){e&&(e.texture?e.texture.resize(t,r):e.renderbuffer&&e.renderbuffer.resize(t,r),e.width=t,e.height=r)}r.oes_texture_half_float&&c.push("half float","float16"),r.oes_texture_float&&c.push("float","float32");var y=0,g={};function A(){this.id=y++,g[this.id]=this,this.framebuffer=e.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function T(e){e.colorAttachments.forEach(d),d(e.depthAttachment),d(e.stencilAttachment),d(e.depthStencilAttachment)}function x(t){var r=t.framebuffer;_(r,"must not double destroy framebuffer"),e.deleteFramebuffer(r),t.framebuffer=null,o.framebufferCount--,delete g[t.id]}function R(t){var r;e.bindFramebuffer(36160,t.framebuffer);var a=t.colorAttachments;for(r=0;r<a.length;++r)m(36064+r,a[r]);for(r=a.length;r<n.maxColorAttachments;++r)e.framebufferTexture2D(36160,36064+r,3553,null,0);e.framebufferTexture2D(36160,33306,3553,null,0),e.framebufferTexture2D(36160,36096,3553,null,0),e.framebufferTexture2D(36160,36128,3553,null,0),m(36096,t.depthAttachment),m(36128,t.stencilAttachment),m(33306,t.depthStencilAttachment);var i=e.checkFramebufferStatus(36160);e.isContextLost()||36053===i||_.raise("framebuffer configuration not supported, status = "+Ce[i]),e.bindFramebuffer(36160,u.next?u.next.framebuffer:null),u.cur=u.next,e.getError()}function S(e,a){var i=new A;function l(e,t){var a;_(u.next!==i,"can not update framebuffer which is currently in use");var o=0,d=0,m=!0,v=!0,y=null,g=!0,A="rgba",x="uint8",S=1,O=null,w=null,N=null,I=!1;if("number"==typeof e)o=0|e,d=0|t||o;else if(e){_.type(e,"object","invalid arguments for framebuffer");var C=e;if("shape"in C){var L=C.shape;_(Array.isArray(L)&&L.length>=2,"invalid shape for framebuffer"),o=L[0],d=L[1]}else"radius"in C&&(o=d=C.radius),"width"in C&&(o=C.width),"height"in C&&(d=C.height);("color"in C||"colors"in C)&&(y=C.color||C.colors,Array.isArray(y)&&_(1===y.length||r.webgl_draw_buffers,"multiple render targets not supported")),y||("colorCount"in C&&(S=0|C.colorCount,_(S>0,"invalid color buffer count")),"colorTexture"in C&&(g=!!C.colorTexture,A="rgba4"),"colorType"in C&&(x=C.colorType,g?(_(r.oes_texture_float||!("float"===x||"float32"===x),"you must enable OES_texture_float in order to use floating point framebuffer objects"),_(r.oes_texture_half_float||!("half float"===x||"float16"===x),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===x||"float16"===x?(_(r.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),A="rgba16f"):"float"!==x&&"float32"!==x||(_(r.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),A="rgba32f"),_.oneOf(x,c,"invalid color type")),"colorFormat"in C&&(A=C.colorFormat,f.indexOf(A)>=0?g=!0:s.indexOf(A)>=0?g=!1:g?_.oneOf(C.colorFormat,f,"invalid color format for texture"):_.oneOf(C.colorFormat,s,"invalid color format for renderbuffer"))),("depthTexture"in C||"depthStencilTexture"in C)&&(I=!(!C.depthTexture&&!C.depthStencilTexture),_(!I||r.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in C&&("boolean"==typeof C.depth?m=C.depth:(O=C.depth,v=!1)),"stencil"in C&&("boolean"==typeof C.stencil?v=C.stencil:(w=C.stencil,m=!1)),"depthStencil"in C&&("boolean"==typeof C.depthStencil?m=v=C.depthStencil:(N=C.depthStencil,m=!1,v=!1))}else o=d=1;var D=null,P=null,U=null,F=null;if(Array.isArray(y))D=y.map(h);else if(y)D=[h(y)];else for(D=new Array(S),a=0;a<S;++a)D[a]=E(o,d,g,A,x);_(r.webgl_draw_buffers||D.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),_(D.length<=n.maxColorAttachments,"too many color attachments, not supported"),o=o||D[0].width,d=d||D[0].height,O?P=h(O):m&&!v&&(P=E(o,d,I,"depth","uint32")),w?U=h(w):v&&!m&&(U=E(o,d,!1,"stencil","uint8")),N?F=h(N):!O&&!w&&v&&m&&(F=E(o,d,I,"depth stencil","depth stencil")),_(!!O+!!w+!!N<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var B=null;for(a=0;a<D.length;++a)if(p(D[a],o,d),_(!D[a]||D[a].texture&&Oe.indexOf(D[a].texture._texture.format)>=0||D[a].renderbuffer&&Ie.indexOf(D[a].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+a+" is invalid"),D[a]&&D[a].texture){var M=we[D[a].texture._texture.format]*Ne[D[a].texture._texture.type];null===B?B=M:_(B===M,"all color attachments much have the same number of bits per pixel.")}return p(P,o,d),_(!P||P.texture&&6402===P.texture._texture.format||P.renderbuffer&&33189===P.renderbuffer._renderbuffer.format,"invalid depth attachment for framebuffer object"),p(U,o,d),_(!U||U.renderbuffer&&36168===U.renderbuffer._renderbuffer.format,"invalid stencil attachment for framebuffer object"),p(F,o,d),_(!F||F.texture&&34041===F.texture._texture.format||F.renderbuffer&&34041===F.renderbuffer._renderbuffer.format,"invalid depth-stencil attachment for framebuffer object"),T(i),i.width=o,i.height=d,i.colorAttachments=D,i.depthAttachment=P,i.stencilAttachment=U,i.depthStencilAttachment=F,l.color=D.map(b),l.depth=b(P),l.stencil=b(U),l.depthStencil=b(F),l.width=i.width,l.height=i.height,R(i),l}return o.framebufferCount++,l(e,a),t(l,{resize:function(e,t){_(u.next!==i,"can not resize a framebuffer which is currently in use");var r=Math.max(0|e,1),n=Math.max(0|t||r,1);if(r===i.width&&n===i.height)return l;for(var a=i.colorAttachments,o=0;o<a.length;++o)v(a[o],r,n);return v(i.depthAttachment,r,n),v(i.stencilAttachment,r,n),v(i.depthStencilAttachment,r,n),i.width=l.width=r,i.height=l.height=n,R(i),l},_reglType:"framebuffer",_framebuffer:i,destroy:function(){x(i),T(i)},use:function(e){u.setFBO({framebuffer:l},e)}})}return t(u,{getFramebuffer:function(e){if("function"==typeof e&&"framebuffer"===e._reglType){var t=e._framebuffer;if(t instanceof A)return t}return null},create:S,createCube:function(e){var i=Array(6);function o(e){var n;_(i.indexOf(u.next)<0,"can not update framebuffer which is currently in use");var s,l={color:null},d=0,p=null,m="rgba",h="uint8",E=1;if("number"==typeof e)d=0|e;else if(e){_.type(e,"object","invalid arguments for framebuffer");var b=e;if("shape"in b){var v=b.shape;_(Array.isArray(v)&&v.length>=2,"invalid shape for framebuffer"),_(v[0]===v[1],"cube framebuffer must be square"),d=v[0]}else"radius"in b&&(d=0|b.radius),"width"in b?(d=0|b.width,"height"in b&&_(b.height===d,"must be square")):"height"in b&&(d=0|b.height);("color"in b||"colors"in b)&&(p=b.color||b.colors,Array.isArray(p)&&_(1===p.length||r.webgl_draw_buffers,"multiple render targets not supported")),p||("colorCount"in b&&(E=0|b.colorCount,_(E>0,"invalid color buffer count")),"colorType"in b&&(_.oneOf(b.colorType,c,"invalid color type"),h=b.colorType),"colorFormat"in b&&(m=b.colorFormat,_.oneOf(b.colorFormat,f,"invalid color format for texture"))),"depth"in b&&(l.depth=b.depth),"stencil"in b&&(l.stencil=b.stencil),"depthStencil"in b&&(l.depthStencil=b.depthStencil)}else d=1;if(p)if(Array.isArray(p))for(s=[],n=0;n<p.length;++n)s[n]=p[n];else s=[p];else{s=Array(E);var y={radius:d,format:m,type:h};for(n=0;n<E;++n)s[n]=a.createCube(y)}for(l.color=Array(s.length),n=0;n<s.length;++n){var g=s[n];_("function"==typeof g&&"textureCube"===g._reglType,"invalid cube map"),d=d||g.width,_(g.width===d&&g.height===d,"invalid cube map shape"),l.color[n]={target:34069,data:s[n]}}for(n=0;n<6;++n){for(var A=0;A<s.length;++A)l.color[A].target=34069+n;n>0&&(l.depth=i[0].depth,l.stencil=i[0].stencil,l.depthStencil=i[0].depthStencil),i[n]?i[n](l):i[n]=S(l)}return t(o,{width:d,height:d,color:s})}return o(e),t(o,{faces:i,resize:function(e){var t,r=0|e;if(_(r>0&&r<=n.maxCubeMapSize,"invalid radius for cube fbo"),r===o.width)return o;var a=o.color;for(t=0;t<a.length;++t)a[t].resize(r);for(t=0;t<6;++t)i[t].resize(r);return o.width=o.height=r,o},_reglType:"framebufferCube",destroy:function(){i.forEach((function(e){e.destroy()}))}})},clear:function(){B(g).forEach(x)},restore:function(){u.cur=null,u.next=null,u.dirty=!0,B(g).forEach((function(t){t.framebuffer=e.createFramebuffer(),R(t)}))}})}(a,d,v,x,R,l),I=st(a,c,d,v,y,A,0,N,{},g,T,{elements:null,primitive:4,count:-1,offset:0,instances:-1},b,p,n),L=De(a,N,I.procs.poll,b,i,d,v),D=I.next,P=a.canvas,M=[],k=[],j=[],q=[n.onDestroy],Z=null;function $(){if(0===M.length)return p&&p.update(),void(Z=null);Z=O.next($),fe();for(var e=M.length-1;e>=0;--e){var t=M[e];t&&t(b,null,0)}a.flush(),p&&p.update()}function J(){!Z&&M.length>0&&(Z=O.next($))}function ee(){Z&&(O.cancel($),Z=null)}function te(e){e.preventDefault(),o=!0,ee(),k.forEach((function(e){e()}))}function re(e){a.getError(),o=!1,u.restore(),T.restore(),y.restore(),x.restore(),R.restore(),N.restore(),g.restore(),p&&p.restore(),I.procs.refresh(),J(),j.forEach((function(e){e()}))}function ne(e){function r(e,t){var r={},n={};return Object.keys(e).forEach((function(a){var i=e[a];if(S.isDynamic(i))n[a]=S.unbox(i,a);else{if(t&&Array.isArray(i))for(var o=0;o<i.length;++o)if(S.isDynamic(i[o]))return void(n[a]=S.unbox(i,a));r[a]=i}})),{dynamic:n,static:r}}_(!!e,"invalid args to regl({...})"),_.type(e,"object","invalid args to regl({...})");var n=r(e.context||{},!0),a=r(e.uniforms||{},!0),i=r(e.attributes||{},!1),u=r(function(e){var r=t({},e);function n(e){if(e in r){var t=r[e];delete r[e],Object.keys(t).forEach((function(n){r[e+"."+n]=t[n]}))}}return delete r.uniforms,delete r.attributes,delete r.context,delete r.vao,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),n("blend"),n("depth"),n("cull"),n("stencil"),n("polygonOffset"),n("scissor"),n("sample"),"vao"in e&&(r.vao=e.vao),r}(e),!1),f={gpuTime:0,cpuTime:0,count:0},s=I.compile(u,i,a,n,f),c=s.draw,l=s.batch,d=s.scope,p=[];return t((function(e,t){var r;if(o&&_.raise("context lost"),"function"==typeof e)return d.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(r=0;r<e;++r)d.call(this,null,t,r);else{if(!Array.isArray(e))return d.call(this,e,t,0);for(r=0;r<e.length;++r)d.call(this,e[r],t,r)}else if("number"==typeof e){if(e>0)return l.call(this,function(e){for(;p.length<e;)p.push(null);return p}(0|e),0|e)}else{if(!Array.isArray(e))return c.call(this,e);if(e.length)return l.call(this,e,e.length)}}),{stats:f,destroy:function(){s.destroy()}})}P&&(P.addEventListener("webglcontextlost",te,!1),P.addEventListener("webglcontextrestored",re,!1));var ae=N.setFBO=ne({framebuffer:S.define.call(null,1,"framebuffer")});function ie(e,t){var r=0;I.procs.poll();var n=t.color;n&&(a.clearColor(+n[0]||0,+n[1]||0,+n[2]||0,+n[3]||0),r|=16384),"depth"in t&&(a.clearDepth(+t.depth),r|=256),"stencil"in t&&(a.clearStencil(0|t.stencil),r|=1024),_(!!r,"called regl.clear with no buffer specified"),a.clear(r)}function oe(e){return _.type(e,"function","regl.frame() callback must be a function"),M.push(e),J(),{cancel:function(){var t=lt(M,e);_(t>=0,"cannot cancel a frame twice"),M[t]=function e(){var t=lt(M,e);M[t]=M[M.length-1],M.length-=1,M.length<=0&&ee()}}}}function ue(){var e=D.viewport,t=D.scissor_box;e[0]=e[1]=t[0]=t[1]=0,b.viewportWidth=b.framebufferWidth=b.drawingBufferWidth=e[2]=t[2]=a.drawingBufferWidth,b.viewportHeight=b.framebufferHeight=b.drawingBufferHeight=e[3]=t[3]=a.drawingBufferHeight}function fe(){b.tick+=1,b.time=ce(),ue(),I.procs.poll()}function se(){x.refresh(),ue(),I.procs.refresh(),p&&p.update()}function ce(){return(w()-m)/1e3}se();var le=t(ne,{clear:function(e){if(_("object"==typeof e&&e,"regl.clear() takes an object as input"),"framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var r=0;r<6;++r)ae(t({framebuffer:e.framebuffer.faces[r]},e),ie);else ae(e,ie);else ie(0,e)},prop:S.define.bind(null,1),context:S.define.bind(null,2),this:S.define.bind(null,3),draw:ne({}),buffer:function(e){return y.create(e,34962,!1,!1)},elements:function(e){return A.create(e,!1)},texture:x.create2D,cube:x.createCube,renderbuffer:R.create,framebuffer:N.create,framebufferCube:N.createCube,vao:g.createVAO,attributes:i,frame:oe,on:function(e,t){var r;switch(_.type(t,"function","listener callback must be a function"),e){case"frame":return oe(t);case"lost":r=k;break;case"restore":r=j;break;case"destroy":r=q;break;default:_.raise("invalid event, must be one of frame,lost,restore,destroy")}return r.push(t),{cancel:function(){for(var e=0;e<r.length;++e)if(r[e]===t)return r[e]=r[r.length-1],void r.pop()}}},limits:v,hasExtension:function(e){return v.extensions.indexOf(e.toLowerCase())>=0},read:L,destroy:function(){M.length=0,ee(),P&&(P.removeEventListener("webglcontextlost",te),P.removeEventListener("webglcontextrestored",re)),T.clear(),N.clear(),R.clear(),x.clear(),A.clear(),y.clear(),g.clear(),p&&p.clear(),q.forEach((function(e){e()}))},_gl:a,_refresh:se,poll:function(){fe(),p&&p.update()},now:ce,stats:l});return n.onDone(null,le),le}}()},function(e,t,r){var n=r(30),a=r(31),i=r(32),o=r(33);e.exports=function(e){return n(e)||a(e)||i(e)||o()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(7),a=r(34),i=r(8),o=Function.prototype,u=Object.prototype,f=o.toString,s=u.hasOwnProperty,c=f.call(Object);e.exports=function(e){if(!i(e)||"[object Object]"!=n(e))return!1;var t=a(e);if(null===t)return!0;var r=s.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&f.call(r)==c}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(36);Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}))},function(e,t,r){var n=r(6).default;e.exports=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!==n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(7),a=r(25),i=r(8),o={};o["[object Float32Array]"]=o["[object Float64Array]"]=o["[object Int8Array]"]=o["[object Int16Array]"]=o["[object Int32Array]"]=o["[object Uint8Array]"]=o["[object Uint8ClampedArray]"]=o["[object Uint16Array]"]=o["[object Uint32Array]"]=!0,o["[object Arguments]"]=o["[object Array]"]=o["[object ArrayBuffer]"]=o["[object Boolean]"]=o["[object DataView]"]=o["[object Date]"]=o["[object Error]"]=o["[object Function]"]=o["[object Map]"]=o["[object Number]"]=o["[object Object]"]=o["[object RegExp]"]=o["[object Set]"]=o["[object String]"]=o["[object WeakMap]"]=!1,e.exports=function(e){return i(e)&&a(e.length)&&!!o[n(e)]}},function(e,t,r){var n=r(11),a="object"==typeof self&&self&&self.Object===Object&&self,i=n||a||Function("return this")();e.exports=i},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){var n=r(10),a=Object.prototype,i=a.hasOwnProperty,o=a.toString,u=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,u),r=e[u];try{e[u]=void 0;var n=!0}catch(e){}var a=o.call(e);return n&&(t?e[u]=r:delete e[u]),a}},function(e,t){var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},function(e,t){e.exports=function(e){return function(t){return e(t)}}},function(e,t,r){(function(e){var n=r(11),a=t&&!t.nodeType&&t,i=a&&"object"==typeof e&&e&&!e.nodeType&&e,o=i&&i.exports===a&&n.process,u=function(){try{var e=i&&i.require&&i.require("util").types;return e||o&&o.binding&&o.binding("util")}catch(e){}}();e.exports=u}).call(this,r(28)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){var n=r(6).default;function a(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e.exports=a=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},r=Object.prototype,i=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},u="function"==typeof Symbol?Symbol:{},f=u.iterator||"@@iterator",s=u.asyncIterator||"@@asyncIterator",c=u.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,i=Object.create(a.prototype),u=new w(n||[]);return o(i,"_invoke",{value:x(e,r,u)}),i}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var m={};function h(){}function E(){}function b(){}var v={};l(v,f,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(N([])));g&&g!==r&&i.call(g,f)&&(v=g);var _=b.prototype=h.prototype=Object.create(v);function A(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){var r;o(this,"_invoke",{value:function(a,o){function u(){return new t((function(r,u){!function r(a,o,u,f){var s=p(e[a],e,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==n(l)&&i.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,u,f)}),(function(e){r("throw",e,u,f)})):t.resolve(l).then((function(e){c.value=e,u(c)}),(function(e){return r("throw",e,u,f)}))}f(s.arg)}(a,o,r,u)}))}return r=r?r.then(u,u):u()}})}function x(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return I()}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var u=R(o,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var f=p(e,t,r);if("normal"===f.type){if(n=r.done?"completed":"suspendedYield",f.arg===m)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(n="completed",r.method="throw",r.arg=f.arg)}}}function R(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var a=p(n,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,m;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,m):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function N(e){if(e){var t=e[f];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:I}}function I(){return{value:void 0,done:!0}}return E.prototype=b,o(_,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:E,configurable:!0}),E.displayName=l(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,l(e,c,"GeneratorFunction")),e.prototype=Object.create(_),e},t.awrap=function(e){return{__await:e}},A(T.prototype),l(T.prototype,s,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new T(d(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},A(_),l(_,c,"Generator"),l(_,f,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=N,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),f=i.call(a,"finallyLoc");if(u&&f){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!f)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;O(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),m}},t}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(12);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(35)(Object.getPrototypeOf,Object);e.exports=n},function(e,t){e.exports=function(e,t){return function(r){return e(t(r))}}},function(e,t,r){"use strict";r.r(t),r.d(t,"World",(function(){return we})),r.d(t,"Kernel",(function(){return z}));var n=r(4),a=r.n(n),i=r(0),o=r.n(i),u=r(1),f=r.n(u),s=r(2),c=r.n(s),l=r(5),d=r.n(l),p=r(13),m=r.n(p),h=r(14),E=r.n(h),b=r(3),v=r.n(b),y=1;function g(){return y++}var _,A;(A=_||(_={}))[A.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",A[A.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",A[A.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",A[A.POINTS=0]="POINTS",A[A.LINES=1]="LINES",A[A.LINE_LOOP=2]="LINE_LOOP",A[A.LINE_STRIP=3]="LINE_STRIP",A[A.TRIANGLES=4]="TRIANGLES",A[A.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",A[A.TRIANGLE_FAN=6]="TRIANGLE_FAN",A[A.ZERO=0]="ZERO",A[A.ONE=1]="ONE",A[A.SRC_COLOR=768]="SRC_COLOR",A[A.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",A[A.SRC_ALPHA=770]="SRC_ALPHA",A[A.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",A[A.DST_ALPHA=772]="DST_ALPHA",A[A.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",A[A.DST_COLOR=774]="DST_COLOR",A[A.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",A[A.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",A[A.FUNC_ADD=32774]="FUNC_ADD",A[A.BLEND_EQUATION=32777]="BLEND_EQUATION",A[A.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",A[A.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",A[A.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",A[A.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",A[A.MAX_EXT=32776]="MAX_EXT",A[A.MIN_EXT=32775]="MIN_EXT",A[A.BLEND_DST_RGB=32968]="BLEND_DST_RGB",A[A.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",A[A.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",A[A.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",A[A.CONSTANT_COLOR=32769]="CONSTANT_COLOR",A[A.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",A[A.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",A[A.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",A[A.BLEND_COLOR=32773]="BLEND_COLOR",A[A.ARRAY_BUFFER=34962]="ARRAY_BUFFER",A[A.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",A[A.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",A[A.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",A[A.STREAM_DRAW=35040]="STREAM_DRAW",A[A.STATIC_DRAW=35044]="STATIC_DRAW",A[A.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",A[A.BUFFER_SIZE=34660]="BUFFER_SIZE",A[A.BUFFER_USAGE=34661]="BUFFER_USAGE",A[A.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",A[A.FRONT=1028]="FRONT",A[A.BACK=1029]="BACK",A[A.FRONT_AND_BACK=1032]="FRONT_AND_BACK",A[A.CULL_FACE=2884]="CULL_FACE",A[A.BLEND=3042]="BLEND",A[A.DITHER=3024]="DITHER",A[A.STENCIL_TEST=2960]="STENCIL_TEST",A[A.DEPTH_TEST=2929]="DEPTH_TEST",A[A.SCISSOR_TEST=3089]="SCISSOR_TEST",A[A.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",A[A.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",A[A.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",A[A.NO_ERROR=0]="NO_ERROR",A[A.INVALID_ENUM=1280]="INVALID_ENUM",A[A.INVALID_VALUE=1281]="INVALID_VALUE",A[A.INVALID_OPERATION=1282]="INVALID_OPERATION",A[A.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",A[A.CW=2304]="CW",A[A.CCW=2305]="CCW",A[A.LINE_WIDTH=2849]="LINE_WIDTH",A[A.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",A[A.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",A[A.CULL_FACE_MODE=2885]="CULL_FACE_MODE",A[A.FRONT_FACE=2886]="FRONT_FACE",A[A.DEPTH_RANGE=2928]="DEPTH_RANGE",A[A.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",A[A.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",A[A.DEPTH_FUNC=2932]="DEPTH_FUNC",A[A.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",A[A.STENCIL_FUNC=2962]="STENCIL_FUNC",A[A.STENCIL_FAIL=2964]="STENCIL_FAIL",A[A.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",A[A.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",A[A.STENCIL_REF=2967]="STENCIL_REF",A[A.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",A[A.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",A[A.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",A[A.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",A[A.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",A[A.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",A[A.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",A[A.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",A[A.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",A[A.VIEWPORT=2978]="VIEWPORT",A[A.SCISSOR_BOX=3088]="SCISSOR_BOX",A[A.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",A[A.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",A[A.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",A[A.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",A[A.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",A[A.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",A[A.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",A[A.RED_BITS=3410]="RED_BITS",A[A.GREEN_BITS=3411]="GREEN_BITS",A[A.BLUE_BITS=3412]="BLUE_BITS",A[A.ALPHA_BITS=3413]="ALPHA_BITS",A[A.DEPTH_BITS=3414]="DEPTH_BITS",A[A.STENCIL_BITS=3415]="STENCIL_BITS",A[A.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",A[A.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",A[A.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",A[A.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",A[A.SAMPLES=32937]="SAMPLES",A[A.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",A[A.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",A[A.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",A[A.DONT_CARE=4352]="DONT_CARE",A[A.FASTEST=4353]="FASTEST",A[A.NICEST=4354]="NICEST",A[A.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",A[A.BYTE=5120]="BYTE",A[A.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",A[A.SHORT=5122]="SHORT",A[A.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",A[A.INT=5124]="INT",A[A.UNSIGNED_INT=5125]="UNSIGNED_INT",A[A.FLOAT=5126]="FLOAT",A[A.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",A[A.ALPHA=6406]="ALPHA",A[A.RGB=6407]="RGB",A[A.RGBA=6408]="RGBA",A[A.LUMINANCE=6409]="LUMINANCE",A[A.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",A[A.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",A[A.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",A[A.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",A[A.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",A[A.VERTEX_SHADER=35633]="VERTEX_SHADER",A[A.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",A[A.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",A[A.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",A[A.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",A[A.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",A[A.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",A[A.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",A[A.SHADER_TYPE=35663]="SHADER_TYPE",A[A.DELETE_STATUS=35712]="DELETE_STATUS",A[A.LINK_STATUS=35714]="LINK_STATUS",A[A.VALIDATE_STATUS=35715]="VALIDATE_STATUS",A[A.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",A[A.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",A[A.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",A[A.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",A[A.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",A[A.NEVER=512]="NEVER",A[A.LESS=513]="LESS",A[A.EQUAL=514]="EQUAL",A[A.LEQUAL=515]="LEQUAL",A[A.GREATER=516]="GREATER",A[A.NOTEQUAL=517]="NOTEQUAL",A[A.GEQUAL=518]="GEQUAL",A[A.ALWAYS=519]="ALWAYS",A[A.KEEP=7680]="KEEP",A[A.REPLACE=7681]="REPLACE",A[A.INCR=7682]="INCR",A[A.DECR=7683]="DECR",A[A.INVERT=5386]="INVERT",A[A.INCR_WRAP=34055]="INCR_WRAP",A[A.DECR_WRAP=34056]="DECR_WRAP",A[A.VENDOR=7936]="VENDOR",A[A.RENDERER=7937]="RENDERER",A[A.VERSION=7938]="VERSION",A[A.NEAREST=9728]="NEAREST",A[A.LINEAR=9729]="LINEAR",A[A.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",A[A.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",A[A.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",A[A.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",A[A.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",A[A.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",A[A.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",A[A.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",A[A.TEXTURE_2D=3553]="TEXTURE_2D",A[A.TEXTURE=5890]="TEXTURE",A[A.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",A[A.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",A[A.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",A[A.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",A[A.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",A[A.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",A[A.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",A[A.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",A[A.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",A[A.TEXTURE0=33984]="TEXTURE0",A[A.TEXTURE1=33985]="TEXTURE1",A[A.TEXTURE2=33986]="TEXTURE2",A[A.TEXTURE3=33987]="TEXTURE3",A[A.TEXTURE4=33988]="TEXTURE4",A[A.TEXTURE5=33989]="TEXTURE5",A[A.TEXTURE6=33990]="TEXTURE6",A[A.TEXTURE7=33991]="TEXTURE7",A[A.TEXTURE8=33992]="TEXTURE8",A[A.TEXTURE9=33993]="TEXTURE9",A[A.TEXTURE10=33994]="TEXTURE10",A[A.TEXTURE11=33995]="TEXTURE11",A[A.TEXTURE12=33996]="TEXTURE12",A[A.TEXTURE13=33997]="TEXTURE13",A[A.TEXTURE14=33998]="TEXTURE14",A[A.TEXTURE15=33999]="TEXTURE15",A[A.TEXTURE16=34e3]="TEXTURE16",A[A.TEXTURE17=34001]="TEXTURE17",A[A.TEXTURE18=34002]="TEXTURE18",A[A.TEXTURE19=34003]="TEXTURE19",A[A.TEXTURE20=34004]="TEXTURE20",A[A.TEXTURE21=34005]="TEXTURE21",A[A.TEXTURE22=34006]="TEXTURE22",A[A.TEXTURE23=34007]="TEXTURE23",A[A.TEXTURE24=34008]="TEXTURE24",A[A.TEXTURE25=34009]="TEXTURE25",A[A.TEXTURE26=34010]="TEXTURE26",A[A.TEXTURE27=34011]="TEXTURE27",A[A.TEXTURE28=34012]="TEXTURE28",A[A.TEXTURE29=34013]="TEXTURE29",A[A.TEXTURE30=34014]="TEXTURE30",A[A.TEXTURE31=34015]="TEXTURE31",A[A.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",A[A.REPEAT=10497]="REPEAT",A[A.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",A[A.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",A[A.FLOAT_VEC2=35664]="FLOAT_VEC2",A[A.FLOAT_VEC3=35665]="FLOAT_VEC3",A[A.FLOAT_VEC4=35666]="FLOAT_VEC4",A[A.INT_VEC2=35667]="INT_VEC2",A[A.INT_VEC3=35668]="INT_VEC3",A[A.INT_VEC4=35669]="INT_VEC4",A[A.BOOL=35670]="BOOL",A[A.BOOL_VEC2=35671]="BOOL_VEC2",A[A.BOOL_VEC3=35672]="BOOL_VEC3",A[A.BOOL_VEC4=35673]="BOOL_VEC4",A[A.FLOAT_MAT2=35674]="FLOAT_MAT2",A[A.FLOAT_MAT3=35675]="FLOAT_MAT3",A[A.FLOAT_MAT4=35676]="FLOAT_MAT4",A[A.SAMPLER_2D=35678]="SAMPLER_2D",A[A.SAMPLER_CUBE=35680]="SAMPLER_CUBE",A[A.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",A[A.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",A[A.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",A[A.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",A[A.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",A[A.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",A[A.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",A[A.COMPILE_STATUS=35713]="COMPILE_STATUS",A[A.LOW_FLOAT=36336]="LOW_FLOAT",A[A.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",A[A.HIGH_FLOAT=36338]="HIGH_FLOAT",A[A.LOW_INT=36339]="LOW_INT",A[A.MEDIUM_INT=36340]="MEDIUM_INT",A[A.HIGH_INT=36341]="HIGH_INT",A[A.FRAMEBUFFER=36160]="FRAMEBUFFER",A[A.RENDERBUFFER=36161]="RENDERBUFFER",A[A.RGBA4=32854]="RGBA4",A[A.RGB5_A1=32855]="RGB5_A1",A[A.RGB565=36194]="RGB565",A[A.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",A[A.STENCIL_INDEX=6401]="STENCIL_INDEX",A[A.STENCIL_INDEX8=36168]="STENCIL_INDEX8",A[A.DEPTH_STENCIL=34041]="DEPTH_STENCIL",A[A.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",A[A.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",A[A.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",A[A.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",A[A.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",A[A.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",A[A.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",A[A.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",A[A.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",A[A.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",A[A.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",A[A.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",A[A.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",A[A.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",A[A.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",A[A.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",A[A.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",A[A.NONE=0]="NONE",A[A.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",A[A.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",A[A.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",A[A.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",A[A.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",A[A.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",A[A.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",A[A.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",A[A.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",A[A.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",A[A.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",A[A.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",A[A.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",A[A.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",A[A.COPY_SRC=1]="COPY_SRC",A[A.COPY_DST=2]="COPY_DST",A[A.SAMPLED=4]="SAMPLED",A[A.STORAGE=8]="STORAGE",A[A.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT";var T,x,R,S,O=function(){function e(){f()(this,e),this.config=void 0}return c()(e,[{key:"get",value:function(){return this.config}},{key:"set",value:function(e){this.config=e}}]),e}();"undefined"!=typeof navigator&&/Version\/[\d\.]+.*Safari/.test(navigator.userAgent);!function(e){e.Void="Void",e.Boolean="Boolean",e.Float="Float",e.Uint32="Uint32",e.Int32="Int32",e.Vector="Vector",e.Vector2Float="vec2<f32>",e.Vector3Float="vec3<f32>",e.Vector4Float="vec4<f32>",e.Vector2Boolean="vec2<bool>",e.Vector3Boolean="vec3<bool>",e.Vector4Boolean="vec4<bool>",e.Vector2Uint="vec2<u32>",e.Vector3Uint="vec3<u32>",e.Vector4Uint="vec4<u32>",e.Vector2Int="vec2<i32>",e.Vector3Int="vec3<i32>",e.Vector4Int="vec4<i32>",e.Matrix="Matrix",e.Matrix3x3Float="mat3x3<f32>",e.Matrix4x4Float="mat4x4<i32>",e.Struct="Struct",e.FloatArray="Float[]",e.Vector4FloatArray="vec4<f32>[]"}(T||(T={})),function(e){e.Program="Program",e.Identifier="Identifier",e.VariableDeclaration="VariableDeclaration",e.BlockStatement="BlockStatement",e.ReturnStatement="ReturnStatement",e.FunctionDeclaration="FunctionDeclaration",e.VariableDeclarator="VariableDeclarator",e.AssignmentExpression="AssignmentExpression",e.LogicalExpression="LogicalExpression",e.BinaryExpression="BinaryExpression",e.ArrayExpression="ArrayExpression",e.UnaryExpression="UnaryExpression",e.UpdateExpression="UpdateExpression",e.FunctionExpression="FunctionExpression",e.MemberExpression="MemberExpression",e.ConditionalExpression="ConditionalExpression",e.ExpressionStatement="ExpressionStatement",e.CallExpression="CallExpression",e.NumThreadStatement="NumThreadStatement",e.StorageStatement="StorageStatement",e.DoWhileStatement="DoWhileStatement",e.WhileStatement="WhileStatement",e.ForStatement="ForStatement",e.BreakStatement="BreakStatement",e.ContinueStatement="ContinueStatement",e.IfStatement="IfStatement",e.ImportedFunctionStatement="ImportedFunctionStatement"}(x||(x={})),function(e){e.Input="Input",e.Output="Output",e.Uniform="Uniform",e.Workgroup="Workgroup",e.UniformConstant="UniformConstant",e.Image="Image",e.StorageBuffer="StorageBuffer",e.Private="Private",e.Function="Function"}(R||(R={})),function(e){e.GLSL100="GLSL100",e.GLSL450="GLSL450",e.WGSL="WGSL"}(S||(S={}));function w(){if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var C,L,D,P,U,F,B,M,k,j,G,V,X,H,z=function(){function e(t,r){f()(this,e),this.engine=t,this.configService=r,this.model=void 0,this.dirty=!0,this.compiledBundle=void 0,this.initPromise=void 0}var t,r,n;return c()(e,[{key:"init",value:function(){var e=this.configService.get(),t=e.canvas,r=e.engineOptions;this.initPromise=this.engine.init(I({canvas:t||w(),antialiasing:!1},r))}},{key:"setBundle",value:function(e){this.compiledBundle=JSON.parse(JSON.stringify(e))}},{key:"setDispatch",value:function(e){return this.compiledBundle.context&&(this.compiledBundle.context.dispatch=e),this}},{key:"setMaxIteration",value:function(e){return this.compiledBundle.context&&(this.compiledBundle.context.maxIteration=e),this}},{key:"setBinding",value:function(e,t){var r=this;if("string"==typeof e){var n=m()(t)||d()(t)||E()(t);if(this.compiledBundle&&this.compiledBundle.context){var a=this.compiledBundle.context.defines.find((function(t){return t.name===e}));if(a)return a.value=t,this;var i=this.compiledBundle.context.uniforms.find((function(t){return t.name===e}));i&&(n?(i.data=t,i.isReferer=!1,i.storageClass===R.Uniform?this.model&&this.model.updateUniform(e,t):this.model&&this.model.updateBuffer(e,t)):(i.isReferer=!0,i.data=t))}}else Object.keys(e).forEach((function(t){r.setBinding(t,e[t])}));return this}},{key:"execute",value:(n=a()(v.a.mark((function e(){var t,r,n=this,a=arguments;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>0&&void 0!==a[0]?a[0]:1,!this.dirty){e.next=6;break}return this.compiledBundle.context&&(t>1?this.compiledBundle.context.maxIteration=t:this.compiledBundle.context.maxIteration++),e.next=5,this.compile();case 5:this.dirty=!1;case 6:for(this.engine.beginFrame(),this.engine.clear({}),this.compiledBundle.context&&this.compiledBundle.context.uniforms.filter((function(e){return e.isReferer})).forEach((function(e){var t=e.data,r=e.name;n.model.confirmInput(t.model,r)})),r=0;r<t;r++)this.model.run();return this.engine.endFrame(),e.abrupt("return",this);case 12:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getOutput",value:(r=a()(v.a.mark((function e(){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.model.readData());case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"compile",value:(t=a()(v.a.mark((function e(){var t,r,n;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.initPromise;case 2:return t=I({},this.compiledBundle.context),r=this.engine.supportWebGPU?this.engine.useWGSL?S.WGSL:S.GLSL450:S.GLSL100,n=this.compiledBundle.shaders[r],t.defines.filter((function(e){return e.runtime})).forEach((function(e){var t="".concat("__DefineValuePlaceholder__").concat(e.name);n=n.replace(t,"".concat(e.value))})),t.shader=n,t.uniforms.forEach((function(e){if(!e.data&&e.storageClass===R.StorageBuffer){var r=1;e.type===T.FloatArray?r=1:e.type===T.Vector4FloatArray&&(r=4),e.data=new Float32Array(t.output.length*r).fill(0)}})),this.compiledBundle.context=t,e.next=11,this.engine.createComputeModel(this.compiledBundle.context);case 11:this.model=e.sent;case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),W=r(15),Y=r.n(W),K=function(){function e(t,r){f()(this,e),this.attribute=void 0,this.buffer=void 0;var n=r.buffer,a=r.offset,i=r.stride,o=r.normalized,u=r.size,s=r.divisor;this.buffer=n,this.attribute={buffer:n.get(),offset:a||0,stride:i||0,normalized:o||!1,divisor:s||0},u&&(this.attribute.size=u)}return c()(e,[{key:"get",value:function(){return this.attribute}},{key:"updateBuffer",value:function(e){this.buffer.subData(e)}},{key:"destroy",value:function(){this.buffer.destroy()}}]),e}(),Q=(C={},o()(C,_.POINTS,"points"),o()(C,_.LINES,"lines"),o()(C,_.LINE_LOOP,"line loop"),o()(C,_.LINE_STRIP,"line strip"),o()(C,_.TRIANGLES,"triangles"),o()(C,_.TRIANGLE_FAN,"triangle fan"),o()(C,_.TRIANGLE_STRIP,"triangle strip"),C),q=(L={},o()(L,_.STATIC_DRAW,"static"),o()(L,_.DYNAMIC_DRAW,"dynamic"),o()(L,_.STREAM_DRAW,"stream"),L),Z=(D={},o()(D,_.BYTE,"int8"),o()(D,_.UNSIGNED_INT,"int16"),o()(D,_.INT,"int32"),o()(D,_.UNSIGNED_BYTE,"uint8"),o()(D,_.UNSIGNED_SHORT,"uint16"),o()(D,_.UNSIGNED_INT,"uint32"),o()(D,_.FLOAT,"float"),D),$=(P={},o()(P,_.ALPHA,"alpha"),o()(P,_.LUMINANCE,"luminance"),o()(P,_.LUMINANCE_ALPHA,"luminance alpha"),o()(P,_.RGB,"rgb"),o()(P,_.RGBA,"rgba"),o()(P,_.RGBA4,"rgba4"),o()(P,_.RGB5_A1,"rgb5 a1"),o()(P,_.RGB565,"rgb565"),o()(P,_.DEPTH_COMPONENT,"depth"),o()(P,_.DEPTH_STENCIL,"depth stencil"),P),J=(U={},o()(U,_.DONT_CARE,"dont care"),o()(U,_.NICEST,"nice"),o()(U,_.FASTEST,"fast"),U),ee=(F={},o()(F,_.NEAREST,"nearest"),o()(F,_.LINEAR,"linear"),o()(F,_.LINEAR_MIPMAP_LINEAR,"mipmap"),o()(F,_.NEAREST_MIPMAP_LINEAR,"nearest mipmap linear"),o()(F,_.LINEAR_MIPMAP_NEAREST,"linear mipmap nearest"),o()(F,_.NEAREST_MIPMAP_NEAREST,"nearest mipmap nearest"),F),te=(B={},o()(B,_.REPEAT,"repeat"),o()(B,_.CLAMP_TO_EDGE,"clamp"),o()(B,_.MIRRORED_REPEAT,"mirror"),B),re=(M={},o()(M,_.NONE,"none"),o()(M,_.BROWSER_DEFAULT_WEBGL,"browser"),M),ne=(k={},o()(k,_.NEVER,"never"),o()(k,_.ALWAYS,"always"),o()(k,_.LESS,"less"),o()(k,_.LEQUAL,"lequal"),o()(k,_.GREATER,"greater"),o()(k,_.GEQUAL,"gequal"),o()(k,_.EQUAL,"equal"),o()(k,_.NOTEQUAL,"notequal"),k),ae=(j={},o()(j,_.FUNC_ADD,"add"),o()(j,_.MIN_EXT,"min"),o()(j,_.MAX_EXT,"max"),o()(j,_.FUNC_SUBTRACT,"subtract"),o()(j,_.FUNC_REVERSE_SUBTRACT,"reverse subtract"),j),ie=(G={},o()(G,_.ZERO,"zero"),o()(G,_.ONE,"one"),o()(G,_.SRC_COLOR,"src color"),o()(G,_.ONE_MINUS_SRC_COLOR,"one minus src color"),o()(G,_.SRC_ALPHA,"src alpha"),o()(G,_.ONE_MINUS_SRC_ALPHA,"one minus src alpha"),o()(G,_.DST_COLOR,"dst color"),o()(G,_.ONE_MINUS_DST_COLOR,"one minus dst color"),o()(G,_.DST_ALPHA,"dst alpha"),o()(G,_.ONE_MINUS_DST_ALPHA,"one minus dst alpha"),o()(G,_.CONSTANT_COLOR,"constant color"),o()(G,_.ONE_MINUS_CONSTANT_COLOR,"one minus constant color"),o()(G,_.CONSTANT_ALPHA,"constant alpha"),o()(G,_.ONE_MINUS_CONSTANT_ALPHA,"one minus constant alpha"),o()(G,_.SRC_ALPHA_SATURATE,"src alpha saturate"),G),oe=(V={},o()(V,_.NEVER,"never"),o()(V,_.ALWAYS,"always"),o()(V,_.LESS,"less"),o()(V,_.LEQUAL,"lequal"),o()(V,_.GREATER,"greater"),o()(V,_.GEQUAL,"gequal"),o()(V,_.EQUAL,"equal"),o()(V,_.NOTEQUAL,"notequal"),V),ue=(X={},o()(X,_.ZERO,"zero"),o()(X,_.KEEP,"keep"),o()(X,_.REPLACE,"replace"),o()(X,_.INVERT,"invert"),o()(X,_.INCR,"increment"),o()(X,_.DECR,"decrement"),o()(X,_.INCR_WRAP,"increment wrap"),o()(X,_.DECR_WRAP,"decrement wrap"),X),fe=(H={},o()(H,_.FRONT,"front"),o()(H,_.BACK,"back"),H),se=function(){function e(t,r){f()(this,e),this.buffer=void 0;var n=r.data,a=r.usage,i=r.type;this.buffer=t.buffer({data:n,usage:q[a||_.STATIC_DRAW],type:Z[i||_.UNSIGNED_BYTE]})}return c()(e,[{key:"get",value:function(){return this.buffer}},{key:"destroy",value:function(){}},{key:"subData",value:function(e){var t=e.data,r=e.offset;this.buffer.subdata(t,r)}}]),e}(),ce=r(16),le=r.n(ce);function de(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function pe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?de(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):de(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var me=0,he=function(){function e(t,r){var n=this;f()(this,e),this.reGl=t,this.context=r,this.entity=g(),this.texFBO=void 0,this.computeCommand=void 0,this.textureCache={},this.outputTextureName=void 0,this.swapOutputTextureName=void 0,this.compiledPingpong=void 0,this.dynamicPingpong=void 0;var a={};this.context.uniforms.forEach((function(e){var t=e.name,r=e.type,i=e.data,o=e.isReferer,u=e.storageClass;if(u===R.StorageBuffer){if(o)n.textureCache[t]={data:void 0},a["".concat(t,"Size")]=function(){return i.compiledBundle.context.output.textureSize};else{n.textureCache[t]=n.calcDataTexture(t,r,i);var f=n.textureCache[t],s=f.textureWidth,c=f.isOutput;a["".concat(t,"Size")]=[s,s],c&&(n.outputTextureName=t,n.context.needPingpong&&(n.outputTextureName="".concat(t,"Output"),n.textureCache[n.outputTextureName]=n.calcDataTexture(t,r,i)))}a[t]=function(){return n.textureCache[t].texture}}else if(u===R.Uniform){if(i&&(Array.isArray(i)||d()(i))&&i.length>16)throw new Error("invalid data type ".concat(r));a[t]=function(){return e.data}}}));var i=this.getOuputDataTexture(),o=i.textureWidth,u=i.texelCount;a.u_OutputTextureSize=[o,o],a.u_OutputTexelCount=u,this.context.output.textureSize=[o,o];var s={attributes:{a_Position:[[-1,1,0],[-1,-1,0],[1,1,0],[1,-1,0]],a_TexCoord:[[0,1],[0,0],[1,1],[1,0]]},frag:"#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n#else\n precision mediump float;\n#endif\n".concat(this.context.shader),uniforms:a,vert:"attribute vec3 a_Position;\nattribute vec2 a_TexCoord;\n\nvarying vec2 v_TexCoord;\n\nvoid main() {\n gl_Position = vec4(a_Position, 1.0);\n v_TexCoord = a_TexCoord;\n}",primitive:"triangle strip",count:4};this.computeCommand=this.reGl(s)}var t;return c()(e,[{key:"run",value:function(){var e=this;this.context.maxIteration>1&&this.context.needPingpong&&(this.compiledPingpong=!0),(this.compiledPingpong||this.dynamicPingpong)&&this.swap(),this.texFBO=this.reGl.framebuffer({color:this.getOuputDataTexture().texture}),this.texFBO.use((function(){e.computeCommand()}))}},{key:"readData",value:(t=a()(v.a.mark((function e(){var t,r,n,a,i,o,u,f,s=this;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.reGl({framebuffer:this.texFBO})((function(){t=s.reGl.read()})),!t){e.next=6;break}if(r=this.getOuputDataTexture(),n=r.originalDataLength,a=r.elementsPerTexel,i=r.typedArrayConstructor,o=void 0===i?Float32Array:i,u=[],4!==a)for(f=0;f<t.length;f+=4)1===a?u.push(t[f]):2===a?u.push(t[f],t[f+1]):u.push(t[f],t[f+1],t[f+2]);else u=t;return e.abrupt("return",new o(u.slice(0,n)));case 6:return e.abrupt("return",new Float32Array);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"confirmInput",value:function(e,t){var r;this.entity===e.entity?(this.dynamicPingpong=!0,r=this):r=e,this.textureCache[t].id=r.getOuputDataTexture().id,this.textureCache[t].texture=r.getOuputDataTexture().texture}},{key:"updateUniform",value:function(){}},{key:"updateBuffer",value:function(e,t){var r=this.context.uniforms.find((function(t){return t.name===e}));if(r){var n=this.calcDataTexture(e,r.type,t),a=n.texture,i=n.data;this.textureCache[e].data=i,this.textureCache[e].texture=a}}},{key:"destroy",value:function(){}},{key:"swap",value:function(){if(this.swapOutputTextureName||this.createSwapOutputDataTexture(),this.compiledPingpong){var e=this.context.output.name;this.textureCache[e].id=this.getOuputDataTexture().id,this.textureCache[e].texture=this.getOuputDataTexture().texture}var t=this.outputTextureName;this.outputTextureName=this.swapOutputTextureName,this.swapOutputTextureName=t}},{key:"getOuputDataTexture",value:function(){return this.textureCache[this.outputTextureName]}},{key:"createSwapOutputDataTexture",value:function(){var e=this.cloneDataTexture(this.getOuputDataTexture());this.swapOutputTextureName="".concat(this.entity,"-swap"),this.textureCache[this.swapOutputTextureName]=e}},{key:"cloneDataTexture",value:function(e){var t=e.data,r=e.textureWidth;return pe(pe({},e),{},{id:me++,texture:this.reGl.texture({width:r,height:r,data:t,type:"float"})})}},{key:"calcDataTexture",value:function(e,t,r){var n=1;t===T.Vector4FloatArray&&(n=4);for(var a=[],i=0;i<r.length;i+=n)1===n?a.push(r[i],0,0,0):2===n?a.push(r[i],r[i+1],0,0):3===n?a.push(r[i],r[i+1],r[i+2],0):4===n&&a.push(r[i],r[i+1],r[i+2],r[i+3]);var o=r.length,u=Math.ceil(o/n),f=Math.ceil(Math.sqrt(u)),s=f*f;u<s&&a.push.apply(a,le()(new Array(4*(s-u)).fill(0)));var c=this.reGl.texture({width:f,height:f,data:a,type:"float"});return{id:me++,data:a,originalDataLength:o,typedArrayConstructor:d()(r)?r.constructor:void 0,textureWidth:f,texture:c,texelCount:u,elementsPerTexel:n,isOutput:e===this.context.output.name}}}]),e}(),Ee=function(){function e(t,r){f()(this,e),this.elements=void 0;var n=r.data,a=r.usage,i=r.type,o=r.count;this.elements=t.elements({data:n,usage:q[a||_.STATIC_DRAW],type:Z[i||_.UNSIGNED_BYTE],count:o})}return c()(e,[{key:"get",value:function(){return this.elements}},{key:"subData",value:function(e){var t=e.data;this.elements.subdata(t)}},{key:"destroy",value:function(){this.elements.destroy()}}]),e}(),be=function(){function e(t,r){f()(this,e),this.framebuffer=void 0;var n=r.width,a=r.height,i=r.color,o=r.colors,u=(r.depth,r.stencil,{width:n,height:a});Array.isArray(o)&&(u.colors=o.map((function(e){return e.get()}))),i&&"boolean"!=typeof i&&(u.color=i.get()),this.framebuffer=t.framebuffer(u)}return c()(e,[{key:"get",value:function(){return this.framebuffer}},{key:"destroy",value:function(){this.framebuffer.destroy()}},{key:"resize",value:function(e){var t=e.width,r=e.height;this.framebuffer.resize(t,r)}}]),e}(),ve=r(6),ye=r.n(ve),ge=r(17),_e=r.n(ge);function Ae(e){var t={};return Object.keys(e).forEach((function(r){!function e(t,r,n,a){if(null===r||"number"==typeof r||"boolean"==typeof r||Array.isArray(r)&&"number"==typeof r[0]||d()(r)||""===r||void 0!==r.resize)return void(n["".concat(a&&a+".").concat(t)]=r);_e()(r)&&Object.keys(r).forEach((function(i){e(i,r[i],n,"".concat(a&&a+".").concat(t))}));Array.isArray(r)&&r.forEach((function(r,i){Object.keys(r).forEach((function(o){e(o,r[o],n,"".concat(a&&a+".").concat(t,"[").concat(i,"]"))}))}))}(r,e[r],t,"")})),t}function Te(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function xe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Te(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Te(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Re=function(){function e(t,r){f()(this,e),this.reGl=void 0,this.drawCommand=void 0,this.uniforms={},this.reGl=t;var n=r.vs,a=r.fs,i=r.defines,o=r.attributes,u=r.uniforms,s=r.primitive,c=r.count,l=r.elements,d=r.depth,p=r.blend,m=r.stencil,h=r.cull,E=r.instances,b=r.scissor,v=r.viewport,y={};u&&(this.uniforms=Ae(u),Object.keys(u).forEach((function(e){y[e]=t.prop(e)})));var g={};Object.keys(o).forEach((function(e){g[e]=o[e].get()}));var A=i&&this.generateDefines(i)||"",T={attributes:g,frag:"#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n#else\n precision mediump float;\n#endif\n".concat(A,"\n").concat(a),uniforms:y,vert:"\n".concat(A,"\n").concat(n),primitive:Q[void 0===s?_.TRIANGLES:s]};E&&(T.instances=E),c&&(T.count=c),l&&(T.elements=l.get()),b&&(T.scissor=b),v&&(T.viewport=v),this.initDepthDrawParams({depth:d},T),this.initBlendDrawParams({blend:p},T),this.initStencilDrawParams({stencil:m},T),this.initCullDrawParams({cull:h},T),this.drawCommand=t(T)}return c()(e,[{key:"addUniforms",value:function(e){this.uniforms=xe(xe({},this.uniforms),Ae(e))}},{key:"draw",value:function(e){var t=xe(xe({},this.uniforms),Ae(e.uniforms||{})),r={};Object.keys(t).forEach((function(e){var n=ye()(t[e]);"boolean"===n||"number"===n||Array.isArray(t[e])||t[e].BYTES_PER_ELEMENT?r[e]=t[e]:"string"===n||(r[e]=t[e].get())})),this.drawCommand(r)}},{key:"destroy",value:function(){}},{key:"initDepthDrawParams",value:function(e,t){var r=e.depth;r&&(t.depth={enable:void 0===r.enable||!!r.enable,mask:void 0===r.mask||!!r.mask,func:ne[r.func||_.LESS],range:r.range||[0,1]})}},{key:"initBlendDrawParams",value:function(e,t){var r=e.blend;if(r){var n=r.enable,a=r.func,i=r.equation,o=r.color,u=void 0===o?[0,0,0,0]:o;t.blend={enable:!!n,func:{srcRGB:ie[a&&a.srcRGB||_.SRC_ALPHA],srcAlpha:ie[a&&a.srcAlpha||_.SRC_ALPHA],dstRGB:ie[a&&a.dstRGB||_.ONE_MINUS_SRC_ALPHA],dstAlpha:ie[a&&a.dstAlpha||_.ONE_MINUS_SRC_ALPHA]},equation:{rgb:ae[i&&i.rgb||_.FUNC_ADD],alpha:ae[i&&i.alpha||_.FUNC_ADD]},color:u}}}},{key:"initStencilDrawParams",value:function(e,t){var r=e.stencil;if(r){var n=r.enable,a=r.mask,i=void 0===a?-1:a,o=r.func,u=void 0===o?{cmp:_.ALWAYS,ref:0,mask:-1}:o,f=r.opFront,s=void 0===f?{fail:_.KEEP,zfail:_.KEEP,zpass:_.KEEP}:f,c=r.opBack,l=void 0===c?{fail:_.KEEP,zfail:_.KEEP,zpass:_.KEEP}:c;t.stencil={enable:!!n,mask:i,func:xe(xe({},u),{},{cmp:oe[u.cmp]}),opFront:{fail:ue[s.fail],zfail:ue[s.zfail],zpass:ue[s.zpass]},opBack:{fail:ue[l.fail],zfail:ue[l.zfail],zpass:ue[l.zpass]}}}}},{key:"initCullDrawParams",value:function(e,t){var r=e.cull;if(r){var n=r.enable,a=r.face,i=void 0===a?_.BACK:a;t.cull={enable:!!n,face:fe[i]}}}},{key:"generateDefines",value:function(e){return Object.keys(e).map((function(t){return"#define ".concat(t," ").concat(Number(e[t]))})).join("\n")}}]),e}(),Se=function(){function e(t,r){f()(this,e),this.texture=void 0,this.width=void 0,this.height=void 0;var n=r.data,a=r.type,i=void 0===a?_.UNSIGNED_BYTE:a,o=r.width,u=r.height,s=r.flipY,c=void 0!==s&&s,l=r.format,d=void 0===l?_.RGBA:l,p=r.mipmap,m=void 0!==p&&p,h=r.wrapS,E=void 0===h?_.CLAMP_TO_EDGE:h,b=r.wrapT,v=void 0===b?_.CLAMP_TO_EDGE:b,y=r.aniso,g=void 0===y?0:y,A=r.alignment,T=void 0===A?1:A,x=r.premultiplyAlpha,R=void 0!==x&&x,S=r.mag,O=void 0===S?_.NEAREST:S,w=r.min,N=void 0===w?_.NEAREST:w,I=r.colorSpace,C=void 0===I?_.BROWSER_DEFAULT_WEBGL:I;this.width=o,this.height=u;var L={width:o,height:u,type:Z[i],format:$[d],wrapS:te[E],wrapT:te[v],mag:ee[O],min:ee[N],alignment:T,flipY:c,colorSpace:re[C],premultiplyAlpha:R,aniso:g};n&&(L.data=n),"number"==typeof m?L.mipmap=J[m]:"boolean"==typeof m&&(L.mipmap=m),this.texture=t.texture(L)}return c()(e,[{key:"get",value:function(){return this.texture}},{key:"update",value:function(){this.texture._texture.bind()}},{key:"resize",value:function(e){var t=e.width,r=e.height;this.texture.resize(t,r),this.width=t,this.height=r}},{key:"destroy",value:function(){this.texture.destroy()}}]),e}(),Oe=function(){function e(){var t=this;f()(this,e),this.supportWebGPU=!1,this.useWGSL=!1,this.$canvas=void 0,this.gl=void 0,this.inited=void 0,this.createModel=function(){var e=a()(v.a.mark((function e(r){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.uniforms){e.next=3;break}return e.next=3,Promise.all(Object.keys(r.uniforms).map(function(){var e=a()(v.a.mark((function e(t){var n;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.uniforms[t]||void 0===r.uniforms[t].load){e.next=5;break}return e.next=3,r.uniforms[t].load();case 3:n=e.sent,r.uniforms[t]=n;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 3:return e.abrupt("return",new Re(t.gl,r));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),this.createAttribute=function(e){return new K(t.gl,e)},this.createBuffer=function(e){return new se(t.gl,e)},this.createElements=function(e){return new Ee(t.gl,e)},this.createTexture2D=function(e){return new Se(t.gl,e)},this.createFramebuffer=function(e){return new be(t.gl,e)},this.useFramebuffer=function(e,r){t.gl({framebuffer:e?e.get():null})(r)},this.createComputeModel=function(){var e=a()(v.a.mark((function e(r){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new he(t.gl,r));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),this.clear=function(e){var r=e.color,n=e.depth,a=e.stencil,i=e.framebuffer,o=void 0===i?null:i,u={color:r,depth:n,stencil:a};u.framebuffer=null===o?o:o.get(),t.gl.clear(u)},this.setScissor=function(e){t.gl&&t.gl._gl&&(e.enable&&e.box?(t.gl._gl.enable(_.SCISSOR_TEST),t.gl._gl.scissor(e.box.x,e.box.y,e.box.width,e.box.height)):t.gl._gl.disable(_.SCISSOR_TEST),t.gl._refresh())},this.viewport=function(e){var r=e.x,n=e.y,a=e.width,i=e.height;t.gl&&t.gl._gl&&(t.gl._gl.viewport(r,n,a,i),t.gl._refresh())},this.readPixels=function(e){var r=e.framebuffer,n={x:e.x,y:e.y,width:e.width,height:e.height};return r&&(n.framebuffer=r.get()),t.gl.read(n)},this.getCanvas=function(){return t.$canvas},this.getGLContext=function(){return t.gl._gl},this.destroy=function(){t.gl&&(t.gl.destroy(),t.inited=!1)}}var t;return c()(e,[{key:"init",value:(t=a()(v.a.mark((function e(t){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.inited){e.next=2;break}return e.abrupt("return");case 2:return this.$canvas=t.canvas,e.next=5,new Promise((function(e,r){Y()({canvas:t.canvas,attributes:{alpha:!0,antialias:t.antialias,premultipliedAlpha:!0},pixelRatio:1,extensions:["OES_element_index_uint","OES_texture_float","OES_standard_derivatives","angle_instanced_arrays"],optionalExtensions:["EXT_texture_filter_anisotropic","EXT_blend_minmax","WEBGL_depth_texture"],profile:!0,onDone:function(t,n){!t&&n||r(t),e(n)}})}));case 5:this.gl=e.sent,this.inited=!0;case 7:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"isFloatSupported",value:function(){return this.gl.limits.readFloat}},{key:"beginFrame",value:function(){}},{key:"endFrame",value:function(){}}]),e}(),we=function(){function e(){f()(this,e),this.engine=void 0,this.configService=new O}return c()(e,[{key:"setConfig",value:function(e){this.configService.set(e)}},{key:"setEngine",value:function(e){this.engine=e}},{key:"createEntity",value:function(){return g()}},{key:"createKernel",value:function(e){var t=new z(this.engine,this.configService);return"string"==typeof e?t.setBundle(JSON.parse(e)):t.setBundle(e),t.init(),t}},{key:"destroy",value:function(){this.engine.destroy()}}],[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=new e;return r.setConfig(t),r.setEngine(new Oe),r}}]),e}()}])}));