@antv/g-webgpu 1.9.30 → 1.9.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,(function(e,t){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){a.label=s[1];break}if(6===s[0]&&i[1]>a.label){a.label=i[1],i=s;break}if(i&&i[2]>a.label){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;o>i;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var f="undefined"!=typeof Float32Array?Float32Array:Array;function d(){var e=new f(16);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function p(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function _(e,t,r,n,i,o,a,s,l,u,c,d,p,_,h,E){var R=new f(16);return R[0]=e,R[1]=t,R[2]=r,R[3]=n,R[4]=i,R[5]=o,R[6]=a,R[7]=s,R[8]=l,R[9]=u,R[10]=c,R[11]=d,R[12]=p,R[13]=_,R[14]=h,R[15]=E,R}function h(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function E(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var R,T=function(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],d=t[9],p=t[10],_=t[11],h=t[12],E=t[13],R=t[14],T=t[15],v=r[0],A=r[1],m=r[2],g=r[3];return e[0]=v*n+A*s+m*f+g*h,e[1]=v*i+A*l+m*d+g*E,e[2]=v*o+A*u+m*p+g*R,e[3]=v*a+A*c+m*_+g*T,e[4]=(v=r[4])*n+(A=r[5])*s+(m=r[6])*f+(g=r[7])*h,e[5]=v*i+A*l+m*d+g*E,e[6]=v*o+A*u+m*p+g*R,e[7]=v*a+A*c+m*_+g*T,e[8]=(v=r[8])*n+(A=r[9])*s+(m=r[10])*f+(g=r[11])*h,e[9]=v*i+A*l+m*d+g*E,e[10]=v*o+A*u+m*p+g*R,e[11]=v*a+A*c+m*_+g*T,e[12]=(v=r[12])*n+(A=r[13])*s+(m=r[14])*f+(g=r[15])*h,e[13]=v*i+A*l+m*d+g*E,e[14]=v*o+A*u+m*p+g*R,e[15]=v*a+A*c+m*_+g*T,e};function v(e,t,r){var n=new f(3);return n[0]=e,n[1]=t,n[2]=r,n}function A(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function m(e,t,r,n,i,o,a,s,l,u){var c,f,d,p,_,h=e,E=t,R=r,T=n,v=s,g=l,S=120*Math.PI/180,y=Math.PI/180*(+i||0),C=[];if(u)f=u[0],d=u[1],p=u[2],_=u[3];else{E=(c=A(h,E,-y)).y;var N=((h=c.x)-(v=(c=A(v,g,-y)).x))/2,P=(E-(g=c.y))/2,I=N*N/(R*R)+P*P/(T*T);I>1&&(R*=I=Math.sqrt(I),T*=I);var O=R*R,M=T*T,x=(o===a?-1:1)*Math.sqrt(Math.abs((O*M-O*P*P-M*N*N)/(O*P*P+M*N*N)));p=x*R*P/T+(h+v)/2,f=Math.asin(((E-(_=x*-T*N/R+(E+g)/2))/T*1e9>>0)/1e9),d=Math.asin(((g-_)/T*1e9>>0)/1e9),0>(f=p>h?Math.PI-f:f)&&(f=2*Math.PI+f),0>(d=p>v?Math.PI-d:d)&&(d=2*Math.PI+d),a&&f>d&&(f-=2*Math.PI),!a&&d>f&&(d-=2*Math.PI)}var B=d-f;if(Math.abs(B)>S){var D=d,L=v,F=g;C=m(v=p+R*Math.cos(d=f+S*(a&&d>f?1:-1)),g=_+T*Math.sin(d),R,T,i,0,a,L,F,[d,D,p,_])}B=d-f;var b=Math.cos(f),U=Math.sin(f),G=Math.cos(d),w=Math.sin(d),k=Math.tan(B/4),V=4/3*R*k,X=4/3*T*k,W=[h,E],H=[h+V*U,E-X*b],Y=[v+V*w,g-X*G],z=[v,g];if(H[0]=2*W[0]-H[0],H[1]=2*W[1]-H[1],u)return H.concat(Y,z,C);for(var K=[],j=0,Z=(C=H.concat(Y,z,C)).length;Z>j;j+=1)K[j]=j%2?A(C[j-1],C[j],y).y:A(C[j],C[j+1],y).x;return K}R=new f(3),f!=Float32Array&&(R[0]=0,R[1]=0,R[2]=0);var g=function(e){return null==e},S={}.toString,y=function(e,t){return S.call(e)==="[object "+t+"]"},C=function(e){return y(e,"String")},N=function(e,t,r){return t>e?t:e>r?r:e},P=function(e){return y(e,"Number")},I={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var l,u,c=this._events[s],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(u=1,l=Array(f-1);f>u;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,p=c.length;for(u=0;p>u;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),f){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,i);break;default:if(!l)for(d=1,l=Array(f-1);f>d;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var l=0,u=[],c=s.length;c>l;l++)(s[l].fn!==t||i&&!s[l].once||n&&s[l].context!==n)&&u.push(s[l]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(I);var O,M,x,B,D,L,F,b,U,G,w,k,V,X,W,H,Y,z,K,j,Z,q,Q,$,J,ee,te,re=I.exports;function ne(e,t,r,n){return{dimension:H.TEXTURE_2D,format:e,width:t,height:r,depthOrArrayLayers:1,mipLevelCount:n,usage:Y.SAMPLED}}function ie(e,t,r){return e<<16|t<<8|r}function oe(e){return e>>>8&255}function ae(e){return e>>>16&255}function se(e){return 255&e}function le(e){switch(e){case $.F32:case $.U32:case $.S32:return 4;case $.U16:case $.S16:case $.F16:return 2;case $.U8:case $.S8:return 1;default:throw Error("whoops")}}function ue(e){return le(ae(e))}function ce(e){var t=se(e);if(t&ee.Depth)return j.Depth;if(t&ee.Normalized)return j.Float;var r=ae(e);if(r===$.F16||r===$.F32)return j.Float;if(r===$.U8||r===$.U16||r===$.U32)return j.Uint;if(r===$.S8||r===$.S16||r===$.S32)return j.Sint;throw Error("whoops")}function fe(e,t){if(void 0===t&&(t=""),!e)throw Error("Assert fail: ".concat(t))}function de(e){if(null!=e)return e;throw Error("Missing object")}function pe(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function _e(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.ALWAYS=519]="ALWAYS",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.GEQUAL=518]="GEQUAL",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"}(O||(O={})),function(e){e[e.Buffer=0]="Buffer",e[e.Texture=1]="Texture",e[e.RenderTarget=2]="RenderTarget",e[e.Sampler=3]="Sampler",e[e.Program=4]="Program",e[e.Bindings=5]="Bindings",e[e.InputLayout=6]="InputLayout",e[e.RenderPipeline=7]="RenderPipeline",e[e.ComputePipeline=8]="ComputePipeline",e[e.Readback=9]="Readback",e[e.QueryPool=10]="QueryPool"}(M||(M={})),function(e){e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS"}(x||(x={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(B||(B={})),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK",e[e.FRONT_AND_BACK=3]="FRONT_AND_BACK"}(D||(D={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC=768]="SRC",e[e.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",e[e.DST=774]="DST",e[e.ONE_MINUS_DST=775]="ONE_MINUS_DST",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONST=32769]="CONST",e[e.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(L||(L={})),function(e){e[e.ADD=32774]="ADD",e[e.SUBSTRACT=32778]="SUBSTRACT",e[e.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX"}(F||(F={})),function(e){e[e.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",e[e.REPEAT=1]="REPEAT",e[e.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"}(b||(b={})),function(e){e[e.POINT=0]="POINT",e[e.BILINEAR=1]="BILINEAR"}(U||(U={})),function(e){e[e.NO_MIP=0]="NO_MIP",e[e.NEAREST=1]="NEAREST",e[e.LINEAR=2]="LINEAR"}(G||(G={})),function(e){e[e.POINTS=0]="POINTS",e[e.TRIANGLES=1]="TRIANGLES",e[e.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",e[e.LINES=3]="LINES",e[e.LINE_STRIP=4]="LINE_STRIP"}(w||(w={})),function(e){e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE"}(k||(k={})),function(e){e[e.STATIC=1]="STATIC",e[e.DYNAMIC=2]="DYNAMIC"}(V||(V={})),function(e){e[e.VERTEX=1]="VERTEX",e[e.INSTANCE=2]="INSTANCE"}(X||(X={})),function(e){e.LOADED="loaded"}(W||(W={})),function(e){e[e.TEXTURE_2D=0]="TEXTURE_2D",e[e.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=2]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"}(H||(H={})),function(e){e[e.SAMPLED=1]="SAMPLED",e[e.RENDER_TARGET=2]="RENDER_TARGET"}(Y||(Y={})),function(e){e[e.NONE=0]="NONE",e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA",e[e.RGB=7]="RGB",e[e.ALL=15]="ALL"}(z||(z={})),function(e){e[e.KEEP=7680]="KEEP",e[e.ZERO=0]="ZERO",e[e.REPLACE=7681]="REPLACE",e[e.INVERT=5386]="INVERT",e[e.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",e[e.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",e[e.INCREMENT_WRAP=34055]="INCREMENT_WRAP",e[e.DECREMENT_WRAP=34056]="DECREMENT_WRAP"}(K||(K={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(j||(j={})),function(e){e[e.LOWER_LEFT=0]="LOWER_LEFT",e[e.UPPER_LEFT=1]="UPPER_LEFT"}(Z||(Z={})),function(e){e[e.NEGATIVE_ONE=0]="NEGATIVE_ONE",e[e.ZERO=1]="ZERO"}(q||(q={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(Q||(Q={})),function(e){e[e.U8=1]="U8",e[e.U16=2]="U16",e[e.U32=3]="U32",e[e.S8=4]="S8",e[e.S16=5]="S16",e[e.S32=6]="S32",e[e.F16=7]="F16",e[e.F32=8]="F32",e[e.BC1=65]="BC1",e[e.BC2=66]="BC2",e[e.BC3=67]="BC3",e[e.BC4_UNORM=68]="BC4_UNORM",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5_UNORM=70]="BC5_UNORM",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.U16_PACKED_5551=97]="U16_PACKED_5551",e[e.U16_PACKED_565=98]="U16_PACKED_565",e[e.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}($||($={})),function(e){e[e.R=1]="R",e[e.RG=2]="RG",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.A=5]="A"}(J||(J={})),function(e){e[e.None=0]="None",e[e.Normalized=1]="Normalized",e[e.sRGB=2]="sRGB",e[e.Depth=4]="Depth",e[e.Stencil=8]="Stencil",e[e.RenderTarget=16]="RenderTarget"}(ee||(ee={})),function(e){e[e.ALPHA=ie($.U8,J.A,ee.None)]="ALPHA",e[e.U8_LUMINANCE=ie($.U8,J.A,ee.None)]="U8_LUMINANCE",e[e.F16_LUMINANCE=ie($.F16,J.A,ee.None)]="F16_LUMINANCE",e[e.F32_LUMINANCE=ie($.F32,J.A,ee.None)]="F32_LUMINANCE",e[e.F16_R=ie($.F16,J.R,ee.None)]="F16_R",e[e.F16_RG=ie($.F16,J.RG,ee.None)]="F16_RG",e[e.F16_RGB=ie($.F16,J.RGB,ee.None)]="F16_RGB",e[e.F16_RGBA=ie($.F16,J.RGBA,ee.None)]="F16_RGBA",e[e.F32_R=ie($.F32,J.R,ee.None)]="F32_R",e[e.F32_RG=ie($.F32,J.RG,ee.None)]="F32_RG",e[e.F32_RGB=ie($.F32,J.RGB,ee.None)]="F32_RGB",e[e.F32_RGBA=ie($.F32,J.RGBA,ee.None)]="F32_RGBA",e[e.U8_R=ie($.U8,J.R,ee.None)]="U8_R",e[e.U8_R_NORM=ie($.U8,J.R,ee.Normalized)]="U8_R_NORM",e[e.U8_RG=ie($.U8,J.RG,ee.None)]="U8_RG",e[e.U8_RG_NORM=ie($.U8,J.RG,ee.Normalized)]="U8_RG_NORM",e[e.U8_RGB=ie($.U8,J.RGB,ee.None)]="U8_RGB",e[e.U8_RGB_NORM=ie($.U8,J.RGB,ee.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=ie($.U8,J.RGB,ee.sRGB|ee.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=ie($.U8,J.RGBA,ee.None)]="U8_RGBA",e[e.U8_RGBA_NORM=ie($.U8,J.RGBA,ee.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=ie($.U8,J.RGBA,ee.sRGB|ee.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=ie($.U16,J.R,ee.None)]="U16_R",e[e.U16_R_NORM=ie($.U16,J.R,ee.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=ie($.U16,J.RG,ee.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=ie($.U16,J.RGBA,ee.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=ie($.U16,J.RGB,ee.None)]="U16_RGB",e[e.U32_R=ie($.U32,J.R,ee.None)]="U32_R",e[e.U32_RG=ie($.U32,J.RG,ee.None)]="U32_RG",e[e.S8_R=ie($.S8,J.R,ee.None)]="S8_R",e[e.S8_R_NORM=ie($.S8,J.R,ee.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=ie($.S8,J.RG,ee.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=ie($.S8,J.RGB,ee.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=ie($.S8,J.RGBA,ee.Normalized)]="S8_RGBA_NORM",e[e.S16_R=ie($.S16,J.R,ee.None)]="S16_R",e[e.S16_RG=ie($.S16,J.RG,ee.None)]="S16_RG",e[e.S16_RG_NORM=ie($.S16,J.RG,ee.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=ie($.S16,J.RGB,ee.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=ie($.S16,J.RGBA,ee.None)]="S16_RGBA",e[e.S16_RGBA_NORM=ie($.S16,J.RGBA,ee.Normalized)]="S16_RGBA_NORM",e[e.S32_R=ie($.S32,J.R,ee.None)]="S32_R",e[e.U16_RGBA_5551=ie($.U16_PACKED_5551,J.RGBA,ee.Normalized)]="U16_RGBA_5551",e[e.U16_RGB_565=ie($.U16_PACKED_565,J.RGB,ee.Normalized)]="U16_RGB_565",e[e.BC1=ie($.BC1,J.RGBA,ee.Normalized)]="BC1",e[e.BC1_SRGB=ie($.BC1,J.RGBA,ee.Normalized|ee.sRGB)]="BC1_SRGB",e[e.BC2=ie($.BC2,J.RGBA,ee.Normalized)]="BC2",e[e.BC2_SRGB=ie($.BC2,J.RGBA,ee.Normalized|ee.sRGB)]="BC2_SRGB",e[e.BC3=ie($.BC3,J.RGBA,ee.Normalized)]="BC3",e[e.BC3_SRGB=ie($.BC3,J.RGBA,ee.Normalized|ee.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=ie($.BC4_UNORM,J.R,ee.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=ie($.BC4_SNORM,J.R,ee.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=ie($.BC5_UNORM,J.RG,ee.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=ie($.BC5_SNORM,J.RG,ee.Normalized)]="BC5_SNORM",e[e.D24=ie($.D24,J.R,ee.Depth)]="D24",e[e.D24_S8=ie($.D24S8,J.RG,ee.Depth|ee.Stencil)]="D24_S8",e[e.D32F=ie($.D32F,J.R,ee.Depth)]="D32F",e[e.D32F_S8=ie($.D32FS8,J.RG,ee.Depth|ee.Stencil)]="D32F_S8",e[e.U8_RGB_RT=ie($.U8,J.RGB,ee.RenderTarget|ee.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=ie($.U8,J.RGBA,ee.RenderTarget|ee.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=ie($.U8,J.RGBA,ee.RenderTarget|ee.Normalized|ee.sRGB)]="U8_RGBA_RT_SRGB"}(te||(te={}));var he=_e(0,0,0,0),Ee=_e(0,0,0,1),Re=_e(1,1,1,0),Te=_e(1,1,1,1);function ve(e){return!(!e||0!=(e&e-1))}function Ae(e,t){return null!=e?e:t}function me(e,t,r){e.length=t,e.fill(r)}function ge(e,t){var r=t-1;return e+r&~r}function Se(e,t){return((e+t-1)/t|0)*t}function ye(e,t,r){return r?e|=t:e&=~t,e}function Ce(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function Ne(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Pe(e,t){return void 0===e&&(e={}),e.compare=t.compare,e.depthFailOp=t.depthFailOp,e.passOp=t.passOp,e.failOp=t.failOp,e}function Ie(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Ne(e.rgbBlendState,t.rgbBlendState),Ne(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Oe(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=Ie(e[r],t[r])}function Me(e,t){void 0!==t.attachmentsState&&Oe(e.attachmentsState,t.attachmentsState),e.blendConstant&&t.blendConstant&&function(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}(e.blendConstant,t.blendConstant),e.depthCompare=Ae(t.depthCompare,e.depthCompare),e.depthWrite=Ae(t.depthWrite,e.depthWrite),e.stencilWrite=Ae(t.stencilWrite,e.stencilWrite),e.stencilFront&&t.stencilFront&&Pe(e.stencilFront,t.stencilFront),e.stencilBack&&t.stencilBack&&Pe(e.stencilBack,t.stencilBack),e.cullMode=Ae(t.cullMode,e.cullMode),e.frontFace=Ae(t.frontFace,e.frontFace),e.polygonOffset=Ae(t.polygonOffset,e.polygonOffset)}function xe(e){var t=Object.assign({},e);return t.attachmentsState=[],Oe(t.attachmentsState,e.attachmentsState),t.blendConstant=t.blendConstant&&pe(t.blendConstant),t.stencilFront=Pe(void 0,e.stencilFront),t.stencilBack=Pe(void 0,e.stencilBack),t}var Be={blendMode:F.ADD,blendSrcFactor:L.ONE,blendDstFactor:L.ZERO},De={attachmentsState:[{channelWriteMask:z.ALL,rgbBlendState:Be,alphaBlendState:Be}],blendConstant:pe(he),depthWrite:!0,depthCompare:x.LEQUAL,stencilWrite:!1,stencilFront:{compare:x.ALWAYS,passOp:K.KEEP,depthFailOp:K.KEEP,failOp:K.KEEP},stencilBack:{compare:x.ALWAYS,passOp:K.KEEP,depthFailOp:K.KEEP,failOp:K.KEEP},cullMode:D.NONE,frontFace:B.CCW,polygonOffset:!1};var Le=function(e,t){void 0===e&&(e=null),void 0===t&&(t=De);var r=xe(t);return null!==e&&Me(r,e),r}({depthCompare:x.ALWAYS,depthWrite:!1},De);function Fe(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Oe(e.attachmentsState,De.attachmentsState)),function(e,t){void 0!==t.channelWriteMask&&(e.channelWriteMask=t.channelWriteMask),void 0!==t.rgbBlendMode&&(e.rgbBlendState.blendMode=t.rgbBlendMode),void 0!==t.alphaBlendMode&&(e.alphaBlendState.blendMode=t.alphaBlendMode),void 0!==t.rgbBlendSrcFactor&&(e.rgbBlendState.blendSrcFactor=t.rgbBlendSrcFactor),void 0!==t.alphaBlendSrcFactor&&(e.alphaBlendState.blendSrcFactor=t.alphaBlendSrcFactor),void 0!==t.rgbBlendDstFactor&&(e.rgbBlendState.blendDstFactor=t.rgbBlendDstFactor),void 0!==t.alphaBlendDstFactor&&(e.alphaBlendState.blendDstFactor=t.alphaBlendDstFactor)}(e.attachmentsState[0],t),e}var be,Ue={texture:null,sampler:null,formatKind:j.Float,dimension:H.TEXTURE_2D};function Ge(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function we(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function ke(e,t){return e.buffer===t.buffer&&e.size===t.size&&e.binding===t.binding&&e.offset===t.offset}function Ve(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture&&e.dimension===t.dimension&&e.formatKind===t.formatKind&&e.comparison===t.comparison)}function Xe(e,t){return e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],e.samplerBindings.length===t.samplerBindings.length&&(!!Ge(e.samplerBindings,t.samplerBindings,Ve)&&!!Ge(e.uniformBufferBindings,t.uniformBufferBindings,ke))}function We(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function He(e,t){return!!We(e.rgbBlendState,t.rgbBlendState)&&(!!We(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Ye(e,t){return e.compare==t.compare&&e.depthFailOp===t.depthFailOp&&e.failOp===t.failOp&&e.passOp===t.passOp}function ze(e,t){return e.id===t.id}function Ke(e,t){return e===t}function je(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!(e.megaStateDescriptor&&t.megaStateDescriptor&&!function(e,t){return!(!Ge(e.attachmentsState,t.attachmentsState,He)||e.blendConstant&&t.blendConstant&&((r=e.blendConstant).r!==(n=t.blendConstant).r||r.g!==n.g||r.b!==n.b||r.a!==n.a)||e.stencilFront&&t.stencilFront&&!Ye(e.stencilFront,t.stencilFront)||e.stencilBack&&t.stencilBack&&!Ye(e.stencilBack,t.stencilBack)||e.depthCompare!==t.depthCompare||e.depthWrite!==t.depthWrite||e.stencilWrite!==t.stencilWrite||e.cullMode!==t.cullMode||e.frontFace!==t.frontFace||e.polygonOffset!==t.polygonOffset);var r,n}(e.megaStateDescriptor,t.megaStateDescriptor))&&(!!ze(e.program,t.program)&&(!!Ge(e.colorAttachmentFormats,t.colorAttachmentFormats,Ke)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat)))))}function Ze(e,t){return e.offset===t.offset&&e.shaderLocation===t.shaderLocation&&e.format===t.format&&e.divisor===t.divisor}function qe(e,t){return g(e)?g(t):!g(t)&&(e.arrayStride===t.arrayStride&&e.stepMode===t.stepMode&&Ge(e.attributes,t.attributes,Ze))}function Qe(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Ge(e.vertexBufferDescriptors,t.vertexBufferDescriptors,qe)&&!!ze(e.program,t.program))}function $e(e,t){return e.addressModeU===t.addressModeU&&e.addressModeV===t.addressModeV&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipmapFilter===t.mipmapFilter&&e.lodMinClamp===t.lodMinClamp&&e.lodMaxClamp===t.lodMaxClamp&&e.maxAnisotropy===t.maxAnisotropy&&e.compareFunction===t.compareFunction}function Je(e){return{sampler:e.sampler,texture:e.texture,dimension:e.dimension,formatKind:e.formatKind,comparison:e.comparison}}function et(e){return{binding:e.binding,buffer:e.buffer,offset:e.offset,size:e.size}}function tt(e){return{shaderLocation:e.shaderLocation,format:e.format,offset:e.offset,divisor:e.divisor}}function rt(e){return g(e)?e:{arrayStride:e.arrayStride,stepMode:e.stepMode,attributes:we(e.attributes,tt)}}var nt=/([^[]*)(\[[0-9]+\])?/;function it(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(nt);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}}function ot(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function at(e,t,r,n){var i=null,o=null;return function(a,s,l){var u=t(l,r),c=u.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{fe(o===c,"Uniform length cannot change.");for(var d=0;c>d;++d)if(u[d]!==i[d]){f=!0;break}}return f&&(n(a,e,s,u),i.set(u)),f}}function st(e,t,r,n){e[t](r,n)}function lt(e,t,r,n){e[t](r,!1,n)}var ut={},ct={},ft={},dt=[0];function pt(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(dt[0]=e,e=dt);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function _t(e,t){return pt(e,t,Float32Array,ut)}function ht(e,t){return pt(e,t,Int32Array,ct)}function Et(e,t){return pt(e,t,Uint32Array,ft)}var Rt=((be={})[O.FLOAT]=at.bind(null,"uniform1fv",_t,1,st),be[O.FLOAT_VEC2]=at.bind(null,"uniform2fv",_t,2,st),be[O.FLOAT_VEC3]=at.bind(null,"uniform3fv",_t,3,st),be[O.FLOAT_VEC4]=at.bind(null,"uniform4fv",_t,4,st),be[O.INT]=at.bind(null,"uniform1iv",ht,1,st),be[O.INT_VEC2]=at.bind(null,"uniform2iv",ht,2,st),be[O.INT_VEC3]=at.bind(null,"uniform3iv",ht,3,st),be[O.INT_VEC4]=at.bind(null,"uniform4iv",ht,4,st),be[O.BOOL]=at.bind(null,"uniform1iv",ht,1,st),be[O.BOOL_VEC2]=at.bind(null,"uniform2iv",ht,2,st),be[O.BOOL_VEC3]=at.bind(null,"uniform3iv",ht,3,st),be[O.BOOL_VEC4]=at.bind(null,"uniform4iv",ht,4,st),be[O.FLOAT_MAT2]=at.bind(null,"uniformMatrix2fv",_t,4,lt),be[O.FLOAT_MAT3]=at.bind(null,"uniformMatrix3fv",_t,9,lt),be[O.FLOAT_MAT4]=at.bind(null,"uniformMatrix4fv",_t,16,lt),be[O.UNSIGNED_INT]=at.bind(null,"uniform1uiv",Et,1,st),be[O.UNSIGNED_INT_VEC2]=at.bind(null,"uniform2uiv",Et,2,st),be[O.UNSIGNED_INT_VEC3]=at.bind(null,"uniform3uiv",Et,3,st),be[O.UNSIGNED_INT_VEC4]=at.bind(null,"uniform4uiv",Et,4,st),be[O.FLOAT_MAT2x3]=at.bind(null,"uniformMatrix2x3fv",_t,6,lt),be[O.FLOAT_MAT2x4]=at.bind(null,"uniformMatrix2x4fv",_t,8,lt),be[O.FLOAT_MAT3x2]=at.bind(null,"uniformMatrix3x2fv",_t,6,lt),be[O.FLOAT_MAT3x4]=at.bind(null,"uniformMatrix3x4fv",_t,12,lt),be[O.FLOAT_MAT4x2]=at.bind(null,"uniformMatrix4x2fv",_t,8,lt),be[O.FLOAT_MAT4x3]=at.bind(null,"uniformMatrix4x3fv",_t,12,lt),be[O.SAMPLER_2D]=ot,be[O.SAMPLER_CUBE]=ot,be[O.SAMPLER_3D]=ot,be[O.SAMPLER_2D_SHADOW]=ot,be[O.SAMPLER_2D_ARRAY]=ot,be[O.SAMPLER_2D_ARRAY_SHADOW]=ot,be[O.SAMPLER_CUBE_SHADOW]=ot,be[O.INT_SAMPLER_2D]=ot,be[O.INT_SAMPLER_3D]=ot,be[O.INT_SAMPLER_CUBE]=ot,be[O.INT_SAMPLER_2D_ARRAY]=ot,be[O.UNSIGNED_INT_SAMPLER_2D]=ot,be[O.UNSIGNED_INT_SAMPLER_3D]=ot,be[O.UNSIGNED_INT_SAMPLER_CUBE]=ot,be[O.UNSIGNED_INT_SAMPLER_2D_ARRAY]=ot,be);function Tt(e,t,r){var n=Rt[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)}var vt={"[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};function At(e,t){return"#define ".concat(e," ").concat(t)}function mt(e){if(void 0===e)return null;var t=/binding\s*=\s*(\d+)/.exec(e);if(null!==t){var r=parseInt(t[1],10);if(!Number.isNaN(r))return r}return null}function gt(e,t,r,n,i){var o;void 0===n&&(n=null),void 0===i&&(i=!0);var a="#version 100"===e.glslVersion,s="frag"===t&&(null===(o=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))||void 0===o?void 0:o.length)>1,l=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),c="";null!==n&&(c=Object.keys(n).map((function(e){return At(e,n[e])})).join("\n"));var f=l.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",d=i?l.filter((function(e){return!e.startsWith("precision")})).join("\n"):l.join("\n"),p="";if(e.viewportOrigin===Z.UPPER_LEFT&&(p+="".concat(At("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===q.ZERO&&(p+="".concat(At("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var _=0,h=0,E=0;d=d.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(_,", binding = ").concat(h++,") uniform ").concat(n)})),_++,h=0,fe(e.separateSamplerTextures),d=d.replace(/^(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,r,n,i,o){var a=mt(n);null===a&&(a=h++);var s=u(function(e){return[e,""]}(i),2),l=s[0],c=s[1];return"frag"===t?"\nlayout(set = ".concat(_,", binding = ").concat(2*a+0,") uniform texture").concat(l," T_").concat(o,";\nlayout(set = ").concat(_,", binding = ").concat(2*a+1,") uniform sampler").concat(c," S_").concat(o,";").trim():""})),d=d.replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(E++,") ").concat(t)})),p+="".concat(At("gl_VertexID","gl_VertexIndex"),"\n"),p+="".concat(At("gl_InstanceID","gl_InstanceIndex"),"\n"),f=f.replace(/^precision (.*) sampler(.*);$/gm,"")}else{var R=0;d=d.replace(/^(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,t,r,n,i){var o=mt(r);return null===o&&(o=R++),"uniform sampler".concat(n," ").concat(i,"; // BINDING=").concat(o)}))}if(e.separateSamplerTextures)d=(d=d.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"sampler".concat(t,"(T_").concat(r,", S_").concat(r,")")}))).replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return"T_".concat(t)}));else{var T=[];d=d.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return T.push([r,t]),r})),a&&T.forEach((function(e){var t=u(e,2),r=t[0],n=t[1];d=d.replace(RegExp("texture\\(".concat(r),"g"),(function(){return"texture".concat(n,"(").concat(r)}))})),d=d.replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return t}))}var v="".concat(a?"":e.glslVersion,"\n").concat(a&&s?"#extension GL_EXT_draw_buffers : require\n":"","\n").concat(a&&"frag"===t?"#extension GL_OES_standard_derivatives : enable\n":"").concat(i?f:"","\n").concat(p||"").concat(c?c+"\n":"","\n").concat(d,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(v=v.replace(/^\b(out)\b/g,(function(e,t){return"layout(location = 0) ".concat(t)}))),a){if("frag"===t&&(v=v.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(v=(v=v.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"attribute ".concat(t," ").concat(r,";\n")}))),v=v.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,t){return t.trim().replace(/^.*$/gm,(function(e){var t=e.trim();return t.startsWith("#")?t:e?"uniform ".concat(t):""}))})),"frag"===t)if(s){var A=[];v=v.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,(function(e,t){return A.push(t),"vec4 ".concat(t,";\n")}));var m=v.lastIndexOf("}");v=v.substring(0,m)+"\n ".concat(A.map((function(e,t){return"gl_FragData[".concat(t,"] = ").concat(e,";\n ")})).join("\n"))+v.substring(m)}else{var g;if(v=v.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return g=r,"".concat(t," ").concat(r,";\n")})),g){m=v.lastIndexOf("}");v=v.substring(0,m)+"\n gl_FragColor = vec4(".concat(g,");\n")+v.substring(m)}}v=v.replace(/^\s*layout\((.*)\)/gm,"")}return v}var St=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,null!==i.device.resourceCreationTracker&&i.device.resourceCreationTracker.trackResourceCreated(i),i}return n(t,e),t.prototype.destroy=function(){null!==this.device.resourceCreationTracker&&this.device.resourceCreationTracker.trackResourceDestroyed(this)},t}(re);function yt(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||!(!e||2!==e._version)}function Ct(e){if(se(e)&ee.Normalized)return!1;var t=ae(e);return t===$.S8||t===$.S16||t===$.S32||(t===$.U8||t===$.U16||t===$.U32)}function Nt(e){return e&k.INDEX?O.ELEMENT_ARRAY_BUFFER:e&k.VERTEX?O.ARRAY_BUFFER:e&k.UNIFORM?O.UNIFORM_BUFFER:void 0}function Pt(e){var t=ae(e),r=oe(e),n=se(e),i=function(e){switch(e){case $.U8:return O.UNSIGNED_BYTE;case $.U16:return O.UNSIGNED_SHORT;case $.U32:return O.UNSIGNED_INT;case $.S8:return O.BYTE;case $.S16:return O.SHORT;case $.S32:return O.INT;case $.F16:return O.HALF_FLOAT;case $.F32:return O.FLOAT;default:throw Error("whoops")}}(t),o=function(e){switch(e){case J.R:return 1;case J.RG:return 2;case J.RGB:return 3;case J.RGBA:return 4;default:return 1}}(r);return{size:o,type:i,normalized:!!(n&ee.Normalized)}}function It(e){switch(e){case b.CLAMP_TO_EDGE:return O.CLAMP_TO_EDGE;case b.REPEAT:return O.REPEAT;case b.MIRRORED_REPEAT:return O.MIRRORED_REPEAT;default:throw Error("whoops")}}function Ot(e,t){if(t===G.LINEAR&&e===U.BILINEAR)return O.LINEAR_MIPMAP_LINEAR;if(t===G.LINEAR&&e===U.POINT)return O.NEAREST_MIPMAP_LINEAR;if(t===G.NEAREST&&e===U.BILINEAR)return O.LINEAR_MIPMAP_NEAREST;if(t===G.NEAREST&&e===U.POINT)return O.NEAREST_MIPMAP_NEAREST;if(t===G.NO_MIP&&e===U.BILINEAR)return O.LINEAR;if(t===G.NO_MIP&&e===U.POINT)return O.NEAREST;throw Error("Unknown texture filter mode")}function Mt(e,t){void 0===t&&(t=0);return e.gl_buffer_pages[t/e.pageByteSize|0]}!function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.Bindings;var i=r.samplerBindings;return n.uniformBufferBindings=r.uniformBufferBindings||[],n.samplerBindings=i||[],n.bindingLayouts=n.createBindingLayouts(),n}n(t,e),t.prototype.createBindingLayouts=function(){var e=0,t=0,r=[],n=this.uniformBufferBindings.length,i=this.samplerBindings.length;return r.push({firstUniformBuffer:e,numUniformBuffers:n,firstSampler:t,numSamplers:i}),{numUniformBuffers:e+=n,numSamplers:t+=i,bindingLayoutTables:r}}}(St),function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=M.Buffer;var o=n.viewOrSize,a=n.usage,s=n.hint,l=void 0===s?V.STATIC:s,u=r.uniformBufferMaxPageByteSize,c=r.gl,f=a&k.UNIFORM;f||(yt(c)?c.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null));var d,p=P(o)?ge(o,4):ge(o.byteLength,4);if(i.gl_buffer_pages=[],f){for(var _=p;_>0;)i.gl_buffer_pages.push(i.createBufferPage(Math.min(_,u),a,l)),_-=u;d=u}else i.gl_buffer_pages.push(i.createBufferPage(p,a,l)),d=p;return i.pageByteSize=d,i.byteSize=p,i.usage=a,i.gl_target=Nt(a),P(o)||i.setSubData(0,new Uint8Array(o.buffer)),f||(yt(c)?c.bindVertexArray(i.device.currentBoundVAO):r.OES_vertex_array_object.bindVertexArrayOES(i.device.currentBoundVAO)),i}n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=t.byteLength-r);for(var i=this.device.gl,o=this.pageByteSize,a=e+n,s=e,l=e%o;a>s;){var u=yt(i)?i.COPY_WRITE_BUFFER:this.gl_target,c=Mt(this,s);if(c.ubo)return;i.bindBuffer(u,c),yt(i)?i.bufferSubData(u,l,t,r,Math.min(a-s,o)):i.bufferSubData(u,l,t),s+=o,l=0,r+=o,this.device.debugGroupStatisticsBufferUpload()}},t.prototype.destroy=function(){e.prototype.destroy.call(this);for(var t=0;this.gl_buffer_pages.length>t;t++)this.gl_buffer_pages[t].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[t]);this.gl_buffer_pages=[]},t.prototype.createBufferPage=function(e,t,r){var n=this.device.gl,i=t&k.UNIFORM;if(!yt(n)&&i)return{ubo:!0};var o=this.device.ensureResourceExists(n.createBuffer()),a=Nt(t),s=function(e){switch(e){case V.STATIC:return O.STATIC_DRAW;case V.DYNAMIC:return O.DYNAMIC_DRAW}}(r);return n.bindBuffer(a,o),n.bufferData(a,e,s),o}}(St),function(e){function t(t){var r,n,i,o,a,s=t.device,u=t.descriptor,c=e.call(this,{id:t.id,device:s})||this;c.type=M.InputLayout;var f=u.vertexBufferDescriptors,d=u.indexBufferFormat,p=u.program;fe(d===te.U16_R||d===te.U32_R||null===d);var _=null!==d?function(e){switch(e){case te.U8_R:return O.UNSIGNED_BYTE;case te.U16_R:return O.UNSIGNED_SHORT;case te.U32_R:return O.UNSIGNED_INT;default:throw Error("whoops")}}(d):null,h=null!==d?ue(d):null,E=c.device.gl,R=c.device.ensureResourceExists(yt(E)?E.createVertexArray():s.OES_vertex_array_object.createVertexArrayOES());yt(E)?E.bindVertexArray(R):s.OES_vertex_array_object.bindVertexArrayOES(R),E.bindBuffer(E.ARRAY_BUFFER,Mt(c.device.fallbackVertexBuffer));try{for(var T=l(u.vertexBufferDescriptors),v=T.next();!v.done;v=T.next()){var A=v.value,m=A.stepMode,S=A.attributes;try{for(var y=(i=void 0,l(S)),C=y.next();!C.done;C=y.next()){var N=C.value,P=N.shaderLocation,I=N.format,x=N.divisor,B=void 0===x?1:x,D=yt(E)?P:null===(a=p.attributes[P])||void 0===a?void 0:a.location,L=Pt(I);if(N.vertexFormat=L,!g(D))Ct(I),E.vertexAttribPointer(D,L.size,L.type,L.normalized,0,0),m===X.INSTANCE&&(yt(E)?E.vertexAttribDivisor(D,B):s.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(D,B)),E.enableVertexAttribArray(D)}}catch(e){i={error:e}}finally{try{C&&!C.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{v&&!v.done&&(n=T.return)&&n.call(T)}finally{if(r)throw r.error}}return yt(E)?E.bindVertexArray(null):s.OES_vertex_array_object.bindVertexArrayOES(null),c.vertexBufferDescriptors=f,c.vao=R,c.indexBufferFormat=d,c.indexBufferType=_,c.indexBufferCompByteSize=h,c.program=p,c}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.currentBoundVAO===this.vao&&(yt(this.device.gl)?(this.device.gl.bindVertexArray(null),this.device.gl.deleteVertexArray(this.vao)):(this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao)),this.device.currentBoundVAO=null)}}(St);var xt,Bt=function(e){function t(t){var r=t.device,n=t.descriptor,o=t.fake,a=e.call(this,{id:t.id,device:r})||this;a.type=M.Texture,n=i({dimension:H.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},n);var s,l,u=a.device.gl,c=a.clampmipLevelCount(n);if(a.immutable=n.usage===Y.RENDER_TARGET,a.pixelStore=n.pixelStore,a.format=n.format,a.dimension=n.dimension,a.formatKind=ce(n.format),a.width=n.width,a.height=n.height,a.depthOrArrayLayers=n.depthOrArrayLayers,a.mipmaps=c>=1,!o){l=a.device.ensureResourceExists(u.createTexture());var f=a.device.translateTextureType(n.format),d=a.device.translateTextureInternalFormat(n.format);if(a.device.setActiveTexture(u.TEXTURE0),a.device.currentTextures[0]=null,a.preprocessImage(),n.dimension===H.TEXTURE_2D){if(u.bindTexture(s=O.TEXTURE_2D,l),a.immutable)if(yt(u))u.texStorage2D(s,c,d,n.width,n.height);else{var p=(d===O.DEPTH_COMPONENT||a.isNPOT(),0);(a.format!==te.D32F&&a.format!==te.D24_S8||yt(u)||r.WEBGL_depth_texture)&&(u.texImage2D(s,p,d,n.width,n.height,0,d,f,null),a.mipmaps&&(a.mipmaps=!1,u.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,O.LINEAR),u.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,O.CLAMP_TO_EDGE),u.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,O.CLAMP_TO_EDGE)))}fe(1===n.depthOrArrayLayers)}else if(n.dimension===H.TEXTURE_2D_ARRAY)u.bindTexture(s=O.TEXTURE_2D_ARRAY,l),a.immutable&&yt(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else if(n.dimension===H.TEXTURE_3D)u.bindTexture(s=O.TEXTURE_3D,l),a.immutable&&yt(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else{if(n.dimension!==H.TEXTURE_CUBE_MAP)throw Error("whoops");u.bindTexture(s=O.TEXTURE_CUBE_MAP,l),a.immutable&&yt(u)&&u.texStorage2D(s,c,d,n.width,n.height),fe(6===n.depthOrArrayLayers)}}return a.gl_texture=l,a.gl_target=s,a.mipLevelCount=c,a}return n(t,e),t.prototype.setImageData=function(e,t){void 0===t&&(t=0);var r=this.device.gl;!function(e){switch(ae(e)){case $.BC1:case $.BC2:case $.BC3:case $.BC4_UNORM:case $.BC4_SNORM:case $.BC5_UNORM:case $.BC5_SNORM:return!0;default:;}}(this.format);var n=this.gl_target===O.TEXTURE_3D||this.gl_target===O.TEXTURE_2D_ARRAY,i=this.gl_target===O.TEXTURE_CUBE_MAP,o=Object.prototype.toString.call(e[0])in vt;this.device.setActiveTexture(r.TEXTURE0),this.device.currentTextures[0]=null;var a,s,l=e[0];o?(a=this.width,s=this.height):(s=l.height,this.width=a=l.width,this.height=s),r.bindTexture(this.gl_target,this.gl_texture);var u=this.device.translateTextureFormat(this.format),c=this.device.translateTextureType(this.format);this.preprocessImage();for(var f=0;this.depthOrArrayLayers>f;f++){var d=e[f],p=this.gl_target;i&&(p=O.TEXTURE_CUBE_MAP_POSITIVE_X+f%6),this.immutable?r.texSubImage2D(p,t,0,0,a,s,u,c,d):yt(r)?n?r.texImage3D(p,t,u,a,s,this.depthOrArrayLayers,0,u,c,d):r.texImage2D(p,t,u,a,s,0,u,c,d):o?r.texImage2D(p,t,u,a,s,0,u,c,d):r.texImage2D(p,t,u,u,c,d)}this.mipmaps&&this.generateMipmap(n)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteTexture(this.gl_texture)},t.prototype.clampmipLevelCount=function(e){if(e.dimension===H.TEXTURE_2D_ARRAY&&e.depthOrArrayLayers>1&&ae(e.format)===$.BC1)for(var t=e.width,r=e.height,n=0;e.mipLevelCount>n;n++){if(2>=t||2>=r)return n-1;t=Math.max(t/2|0,1),r=Math.max(r/2|0,1)}return e.mipLevelCount},t.prototype.preprocessImage=function(){var e=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&e.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&e.pixelStorei(O.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&e.pixelStorei(O.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))},t.prototype.generateMipmap=function(e){void 0===e&&(e=!1);var t=this.device.gl;return!yt(t)&&this.isNPOT()||this.gl_texture&&this.gl_target&&(t.bindTexture(this.gl_target,this.gl_texture),e?(t.texParameteri(this.gl_target,O.TEXTURE_BASE_LEVEL,0),t.texParameteri(this.gl_target,O.TEXTURE_MAX_LEVEL,Math.log2(this.width)),t.texParameteri(this.gl_target,O.TEXTURE_MIN_FILTER,O.LINEAR_MIPMAP_LINEAR),t.texParameteri(this.gl_target,O.TEXTURE_MAG_FILTER,O.LINEAR)):t.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,O.NEAREST_MIPMAP_LINEAR),t.generateMipmap(this.gl_target),t.bindTexture(this.gl_target,null)),this},t.prototype.isNPOT=function(){return!yt(this.device.gl)&&(!ve(this.width)||!ve(this.height))},t}(St);let Dt;!function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=M.RenderTarget,i.gl_renderbuffer=null,i.texture=null;var o=i.device.gl,a=n.format,s=n.width,l=n.height,u=n.sampleCount,c=void 0===u?1:u,f=n.texture,d=!1;if(a!==te.D32F&&a!==te.D24_S8||!f||yt(o)||r.WEBGL_depth_texture||(f.destroy(),i.texture=null,d=!0),!d&&f)i.texture=f;else{i.gl_renderbuffer=i.device.ensureResourceExists(o.createRenderbuffer()),o.bindRenderbuffer(o.RENDERBUFFER,i.gl_renderbuffer);var p=i.device.translateTextureInternalFormat(a,!0);yt(o)&&c>1?o.renderbufferStorageMultisample(O.RENDERBUFFER,c,p,s,l):o.renderbufferStorage(O.RENDERBUFFER,p,s,l)}return i.format=a,i.width=s,i.height=l,i.sampleCount=c,i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),null!==this.gl_renderbuffer&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()}}(St),function(e){e[e.NeedsCompile=0]="NeedsCompile",e[e.Compiling=1]="Compiling",e[e.NeedsBind=2]="NeedsBind",e[e.ReadyToUse=3]="ReadyToUse"}(xt||(xt={})),function(e){function t(t,r){var n=t.descriptor,i=e.call(this,{id:t.id,device:t.device})||this;i.rawVertexGLSL=r,i.type=M.Program,i.uniformSetters={},i.attributes=[];var o=i.device.gl;return i.descriptor=n,i.gl_program=i.device.ensureResourceExists(o.createProgram()),i.gl_shader_vert=null,i.gl_shader_frag=null,i.compileState=xt.NeedsCompile,i.tryCompileProgram(),i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)},t.prototype.tryCompileProgram=function(){var e,t;fe(this.compileState===xt.NeedsCompile);var r=this.descriptor,n=this.device.gl;(null===(e=r.vertex)||void 0===e?void 0:e.glsl)&&(null===(t=r.fragment)||void 0===t?void 0:t.glsl)&&(this.gl_shader_vert=this.compileShader(r.vertex.glsl,n.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(r.fragment.glsl,n.FRAGMENT_SHADER),n.attachShader(this.gl_program,this.gl_shader_vert),n.attachShader(this.gl_program,this.gl_shader_frag),n.linkProgram(this.gl_program),this.compileState=xt.Compiling,yt(n)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))},t.prototype.readAttributesFromLinkedProgram=function(){for(var e,t=this.device.gl,r=t.getProgramParameter(this.gl_program,t.ACTIVE_ATTRIBUTES),n=function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""})),t}(this.descriptor.vertex.glsl),i=function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,n,i){var o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r}(this.rawVertexGLSL,n),o=function(r){var n=t.getActiveAttrib(a.gl_program,r),o=n.name,s=n.type,l=n.size,u=t.getAttribLocation(a.gl_program,o),c=null===(e=i.find((function(e){return e.name===o})))||void 0===e?void 0:e.location;0>u||g(c)||(a.attributes[c]={name:o,location:u,type:s,size:l})},a=this,s=0;r>s;s++)o(s)},t.prototype.readUniformLocationsFromLinkedProgram=function(){for(var e=this.device.gl,t=e.getProgramParameter(this.gl_program,e.ACTIVE_UNIFORMS),r=0;t>r;r++){var n=e.getActiveUniform(this.gl_program,r),i=it(n.name).name,o=e.getUniformLocation(this.gl_program,i);if(this.uniformSetters[i]=Tt(e,o,n),n&&n.size>1)for(var a=0;n.size>a;a++)o=e.getUniformLocation(this.gl_program,"".concat(i,"[").concat(a,"]")),this.uniformSetters["".concat(i,"[").concat(a,"]")]=Tt(e,o,n)}},t.prototype.compileShader=function(e,t){var r=this.device.gl,n=this.device.ensureResourceExists(r.createShader(t));return r.shaderSource(n,e),r.compileShader(n),n},t.prototype.setUniformsLegacy=function(e){void 0===e&&(e={});var t=this.device.gl;if(!yt(t)){var r=!1;for(var n in e){r||(t.useProgram(this.gl_program),r=!0);var i=this.uniformSetters[n];if(i){var o=e[n];o instanceof Bt&&(o=o.textureIndex),i(o)}}}return this}}(St),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.QueryPool;var i=n.device.gl;if(yt(i)){var o=r.type;n.gl_query=Ce(r.elemCount,(function(){return n.device.ensureResourceExists(i.createQuery())})),n.gl_query_type=function(e){if(e===Q.OcclusionConservative)return O.ANY_SAMPLES_PASSED_CONSERVATIVE;throw Error("whoops")}(o)}return n}n(t,e),t.prototype.queryResultOcclusion=function(e){var t=this.device.gl;if(yt(t)){var r=this.gl_query[e];return t.getQueryParameter(r,t.QUERY_RESULT_AVAILABLE)?!!t.getQueryParameter(r,t.QUERY_RESULT):null}return null},t.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.device.gl;if(yt(t))for(var r=0;this.gl_query.length>r;r++)t.deleteQuery(this.gl_query[r])}}(St),function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=M.Readback,r.gl_pbo=null,r.gl_sync=null,r}n(t,e),t.prototype.clientWaitAsync=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=10);var n=this.device.gl;return new Promise((function(i,o){!function a(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?i():setTimeout(a,N(r,0,n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL)):o()}()}))},t.prototype.getBufferSubDataAsync=function(e,t,r,n,i,o){return a(this,void 0,void 0,(function(){var a;return s(this,(function(s){switch(s.label){case 0:return yt(a=this.device.gl)?(this.gl_sync=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0),a.flush(),[4,this.clientWaitAsync(this.gl_sync,0,10)]):[3,2];case 1:return s.sent(),a.bindBuffer(e,t),a.getBufferSubData(e,r,n,i,o),a.bindBuffer(e,null),[2,n];case 2:return[2]}}))}))},t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),void 0===u&&(u=o.byteLength||0),a(this,void 0,void 0,(function(){var a,c,f,d,p;return s(this,(function(s){var _;return a=this.device.gl,f=this.device.translateTextureFormat((c=e).format),d=this.device.translateTextureType(c.format),p=le(ae(_=c.format))*oe(_),yt(a)?(this.gl_pbo=this.device.ensureResourceExists(a.createBuffer()),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.bufferData(a.PIXEL_PACK_BUFFER,u,a.STREAM_READ),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),a.bindFramebuffer(O.READ_FRAMEBUFFER,this.device.readbackFramebuffer),a.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,c.gl_texture,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.readPixels(t,r,n,i,f,d,l*p),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),[2,this.getBufferSubDataAsync(a.PIXEL_PACK_BUFFER,this.gl_pbo,0,o,l,0)]):[2,this.readTextureSync(e,t,r,n,i,o,l,u)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){void 0===s&&(s=o.byteLength||0);var l=this.device.gl,u=e,c=this.device.translateTextureType(u.format);return l.bindFramebuffer(O.FRAMEBUFFER,this.device.readbackFramebuffer),l.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,u.gl_texture,0),l.pixelStorei(l.PACK_ALIGNMENT,4),l.readPixels(t,r,n,i,l.RGBA,c,o),o},t.prototype.readBuffer=function(e,t,r,n,i){return a(this,void 0,void 0,(function(){var o;return s(this,(function(a){return yt(o=this.device.gl)?[2,this.getBufferSubDataAsync(o.ARRAY_BUFFER,Mt(e,t),t,r,n,i)]:[2,Promise.reject()]}))}))},t.prototype.destroy=function(){e.prototype.destroy.call(this),yt(this.device.gl)&&(null!==this.gl_sync&&this.device.gl.deleteSync(this.gl_sync),null!==this.gl_pbo&&this.device.gl.deleteBuffer(this.gl_pbo))}}(St),function(e){function t(t){var r,n,o=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;return a.type=M.RenderPipeline,a.drawMode=function(e){switch(e){case w.TRIANGLES:return O.TRIANGLES;case w.POINTS:return O.POINTS;case w.TRIANGLE_STRIP:return O.TRIANGLE_STRIP;case w.LINES:return O.LINES;case w.LINE_STRIP:return O.LINE_STRIP;default:throw Error("Unknown primitive topology mode")}}(null!==(r=o.topology)&&void 0!==r?r:w.TRIANGLES),a.program=o.program,a.inputLayout=o.inputLayout,a.megaState=i(i({},xe(De)),o.megaStateDescriptor),a.colorAttachmentFormats=o.colorAttachmentFormats.slice(),a.depthStencilAttachmentFormat=o.depthStencilAttachmentFormat,a.sampleCount=null!==(n=o.sampleCount)&&void 0!==n?n:1,a}n(t,e)}(St),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=M.ComputePipeline,n.descriptor=r,n}n(t,e)}(St),function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=M.Sampler;var a=o.device.gl;if(yt(a)){var s=o.device.ensureResourceExists(a.createSampler());a.samplerParameteri(s,O.TEXTURE_WRAP_S,It(i.addressModeU)),a.samplerParameteri(s,O.TEXTURE_WRAP_T,It(i.addressModeV)),a.samplerParameteri(s,O.TEXTURE_WRAP_R,It(null!==(r=i.addressModeW)&&void 0!==r?r:i.addressModeU)),a.samplerParameteri(s,O.TEXTURE_MIN_FILTER,Ot(i.minFilter,i.mipmapFilter)),a.samplerParameteri(s,O.TEXTURE_MAG_FILTER,Ot(i.magFilter,G.NO_MIP)),void 0!==i.lodMinClamp&&a.samplerParameterf(s,O.TEXTURE_MIN_LOD,i.lodMinClamp),void 0!==i.lodMaxClamp&&a.samplerParameterf(s,O.TEXTURE_MAX_LOD,i.lodMaxClamp),void 0!==i.compareFunction&&(a.samplerParameteri(s,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.samplerParameteri(s,a.TEXTURE_COMPARE_FUNC,i.compareFunction));var l=null!==(n=i.maxAnisotropy)&&void 0!==n?n:1;l>1&&null!==o.device.EXT_texture_filter_anisotropic&&(fe(i.minFilter===U.BILINEAR&&i.magFilter===U.BILINEAR&&i.mipmapFilter===G.LINEAR),a.samplerParameterf(s,o.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,l)),o.gl_sampler=s}else o.descriptor=i;return o}n(t,e),t.prototype.setTextureParameters=function(e,t,r){var n,i=this.device.gl,o=this.descriptor;this.isNPOT(t,r)?i.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,O.LINEAR):i.texParameteri(e,O.TEXTURE_MIN_FILTER,Ot(o.minFilter,o.mipmapFilter)),i.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,It(o.addressModeU)),i.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,It(o.addressModeV)),i.texParameteri(e,O.TEXTURE_MAG_FILTER,Ot(o.magFilter,G.NO_MIP));var a=null!==(n=o.maxAnisotropy)&&void 0!==n?n:1;a>1&&null!==this.device.EXT_texture_filter_anisotropic&&(fe(o.minFilter===U.BILINEAR&&o.magFilter===U.BILINEAR&&o.mipmapFilter===G.LINEAR),i.texParameteri(e,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a))},t.prototype.destroy=function(){e.prototype.destroy.call(this),yt(this.device.gl)&&this.device.gl.deleteSampler(this.gl_sampler)},t.prototype.isNPOT=function(e,t){return!ve(e)||!ve(t)}}(St);const Lt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&Lt.decode();let Ft=null;function bt(){return null!==Ft&&0!==Ft.byteLength||(Ft=new Uint8Array(Dt.memory.buffer)),Ft}function Ut(e,t){return e>>>=0,Lt.decode(bt().subarray(e,e+t))}const Gt=Array(128).fill(void 0);Gt.push(void 0,null,!0,!1);let wt=Gt.length;function kt(e){return Gt[e]}function Vt(e){const t=kt(e);return function(e){132>e||(Gt[e]=wt,wt=e)}(e),t}let Xt=0;const Wt="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Ht="function"==typeof Wt.encodeInto?function(e,t){return Wt.encodeInto(e,t)}:function(e,t){const r=Wt.encode(e);return t.set(r),{read:e.length,written:r.length}};function Yt(e,t,r){if(void 0===r){const r=Wt.encode(e),n=t(r.length,1)>>>0;return bt().subarray(n,n+r.length).set(r),Xt=r.length,n}let n=e.length,i=t(n,1)>>>0;const o=bt();let a=0;for(;n>a;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),i=r(i,n,n=a+3*e.length,1)>>>0;const t=bt().subarray(i+a,i+n);a+=Ht(e,t).written}return Xt=a,i}let zt=null;function Kt(){return null!==zt&&0!==zt.byteLength||(zt=new Int32Array(Dt.memory.buffer)),zt}function jt(e,t,r){let n,i;try{const s=Dt.__wbindgen_add_to_stack_pointer(-16),l=Yt(e,Dt.__wbindgen_malloc,Dt.__wbindgen_realloc),u=Xt,c=Yt(t,Dt.__wbindgen_malloc,Dt.__wbindgen_realloc);Dt.glsl_compile(s,l,u,c,Xt,r);var o=Kt()[s/4+0],a=Kt()[s/4+1];return n=o,i=a,Ut(o,a)}finally{Dt.__wbindgen_add_to_stack_pointer(16),Dt.__wbindgen_free(n,i,1)}}function Zt(){const e={wbg:{}};return e.wbg.__wbindgen_string_new=function(e,t){return function(e){wt===Gt.length&&Gt.push(Gt.length+1);const t=wt;return wt=Gt[t],Gt[t]=e,t}(Ut(e,t))},e.wbg.__wbindgen_object_drop_ref=function(e){Vt(e)},e.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(kt(e))},e.wbg.__wbg_log_576ca876af0d4a77=function(e,t){console.log(kt(e),kt(t))},e.wbg.__wbindgen_throw=function(e,t){throw Error(Ut(e,t))},e}async function qt(e){if(void 0!==Dt)return Dt;const t=Zt();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:r,module:n}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{const r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}(await e,t);return function(e,t){return Dt=e.exports,qt.__wbindgen_wasm_module=t,zt=null,Ft=null,Dt}(r,n)}var Qt,$t;function Jt(e){if(e===te.U8_R_NORM)return"r8unorm";if(e===te.U8_RG_NORM)return"rg8unorm";if(e===te.U8_RGBA_RT)return"bgra8unorm";if(e===te.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===te.U8_RGBA_NORM)return"rgba8unorm";if(e===te.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===te.S8_R_NORM)return"r8snorm";if(e===te.S8_RG_NORM)return"rg8snorm";if(e===te.S8_RGBA_NORM)return"rgba8snorm";if(e===te.U32_R)return"r32uint";if(e===te.F16_RGBA)return"rgba16float";if(e===te.F32_RGBA)return"rgba32float";if(e===te.D24)return"depth24plus";if(e===te.D24_S8)return"depth24plus-stencil8";if(e===te.D32F)return"depth32float";if(e===te.D32F_S8)return"depth32float-stencil8";if(e===te.BC1)return"bc1-rgba-unorm";if(e===te.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===te.BC2)return"bc2-rgba-unorm";if(e===te.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===te.BC3)return"bc3-rgba-unorm";if(e===te.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===te.BC4_SNORM)return"bc4-r-snorm";if(e===te.BC4_UNORM)return"bc4-r-unorm";if(e===te.BC5_SNORM)return"bc5-rg-snorm";if(e===te.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function er(e){if(e===H.TEXTURE_2D)return"2d";if(e===H.TEXTURE_CUBE_MAP)return"cube";if(e===H.TEXTURE_2D_ARRAY)return"2d-array";if(e===H.TEXTURE_3D)return"3d";throw Error("whoops")}function tr(e){if(e===b.CLAMP_TO_EDGE)return"clamp-to-edge";if(e===b.REPEAT)return"repeat";if(e===b.MIRRORED_REPEAT)return"mirror-repeat";throw Error("whoops")}function rr(e){if(e===U.BILINEAR)return"linear";if(e===U.POINT)return"nearest";throw Error("whoops")}function nr(e){if(e===G.LINEAR)return"linear";if(e===G.NEAREST)return"nearest";if(e===G.NO_MIP)return"nearest";throw Error("whoops")}function ir(e){return e.gpuBuffer}function or(e){if(e===Q.OcclusionConservative)return"occlusion";throw Error("whoops")}function ar(e){switch(e){case w.TRIANGLES:return"triangle-list";case w.POINTS:return"point-list";case w.TRIANGLE_STRIP:return"triangle-strip";case w.LINES:return"line-list";case w.LINE_STRIP:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function sr(e){if(e===D.NONE)return"none";if(e===D.FRONT)return"front";if(e===D.BACK)return"back";throw Error("whoops")}function lr(e){if(e===B.CCW)return"ccw";if(e===B.CW)return"cw";throw Error("whoops")}function ur(e){if(e===L.ZERO)return"zero";if(e===L.ONE)return"one";if(e===L.SRC)return"src";if(e===L.ONE_MINUS_SRC)return"one-minus-src";if(e===L.DST)return"dst";if(e===L.ONE_MINUS_DST)return"one-minus-dst";if(e===L.SRC_ALPHA)return"src-alpha";if(e===L.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(e===L.DST_ALPHA)return"dst-alpha";if(e===L.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(e===L.CONST)return"constant";if(e===L.ONE_MINUS_CONSTANT)return"one-minus-constant";if(e===L.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw Error("whoops")}function cr(e){if(e===F.ADD)return"add";if(e===F.SUBSTRACT)return"subtract";if(e===F.REVERSE_SUBSTRACT)return"reverse-subtract";if(e===F.MIN)return"min";if(e===F.MAX)return"max";throw Error("whoops")}function fr(e){return{operation:cr(e.blendMode),srcFactor:ur(e.blendSrcFactor),dstFactor:ur(e.blendDstFactor)}}function dr(e){return e.blendMode===F.ADD&&e.blendSrcFactor===L.ONE&&e.blendDstFactor===L.ZERO}function pr(e){return dr(e.rgbBlendState)&&dr(e.alphaBlendState)?void 0:{color:fr(e.rgbBlendState),alpha:fr(e.alphaBlendState)}}function _r(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:Jt(t),blend:pr(e),writeMask:e.channelWriteMask}}(t,e[r])}))}function hr(e){if(e===x.NEVER)return"never";if(e===x.LESS)return"less";if(e===x.EQUAL)return"equal";if(e===x.LEQUAL)return"less-equal";if(e===x.GREATER)return"greater";if(e===x.NOTEQUAL)return"not-equal";if(e===x.GEQUAL)return"greater-equal";if(e===x.ALWAYS)return"always";throw Error("whoops")}function Er(e){if(e===K.KEEP)return"keep";if(e===K.REPLACE)return"replace";if(e===K.ZERO)return"zero";if(e===K.DECREMENT_CLAMP)return"decrement-clamp";if(e===K.DECREMENT_WRAP)return"decrement-wrap";if(e===K.INCREMENT_CLAMP)return"increment-clamp";if(e===K.INCREMENT_WRAP)return"increment-wrap";if(e===K.INVERT)return"invert";throw Error("whoops")}function Rr(e){if(e===X.VERTEX)return"vertex";if(e===X.INSTANCE)return"instance";throw Error("whoops")}function Tr(e){if(e===te.U8_R)return"uint8x2";if(e===te.U8_RG)return"uint8x2";if(e===te.U8_RGB)return"uint8x4";if(e===te.U8_RGBA)return"uint8x4";if(e===te.U8_RG_NORM)return"unorm8x2";if(e===te.U8_RGBA_NORM)return"unorm8x4";if(e===te.S8_RGB_NORM)return"snorm8x4";if(e===te.S8_RGBA_NORM)return"snorm8x4";if(e===te.U16_RG_NORM)return"unorm16x2";if(e===te.U16_RGBA_NORM)return"unorm16x4";if(e===te.S16_RG_NORM)return"snorm16x2";if(e===te.S16_RGBA_NORM)return"snorm16x4";if(e===te.S16_RG)return"uint16x2";if(e===te.F16_RG)return"float16x2";if(e===te.F16_RGBA)return"float16x4";if(e===te.F32_R)return"float32";if(e===te.F32_RG)return"float32x2";if(e===te.F32_RGB)return"float32x3";if(e===te.F32_RGBA)return"float32x4";throw"whoops"}function vr(e,t,r,n){switch(void 0===r&&(r=!1),e){case te.S8_R:case te.S8_R_NORM:case te.S8_RG_NORM:case te.S8_RGB_NORM:case te.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case te.U8_R:case te.U8_R_NORM:case te.U8_RG:case te.U8_RG_NORM:case te.U8_RGB:case te.U8_RGB_NORM:case te.U8_RGB_SRGB:case te.U8_RGBA:case te.U8_RGBA_NORM:case te.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case te.S16_R:case te.S16_RG:case te.S16_RG_NORM:case te.S16_RGB_NORM:case te.S16_RGBA:case te.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case te.U16_R:case te.U16_RGB:case te.U16_RGBA_5551:case te.U16_RGBA_NORM:case te.U16_RG_NORM:case te.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case te.S32_R:var l=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&l.set(new Int32Array(n)),l;case te.U32_R:case te.U32_RG:var u=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&u.set(new Uint32Array(n)),u;case te.F32_R:case te.F32_RG:case te.F32_RGB:case te.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(Qt||(Qt={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}($t||($t={}));var Ar=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,i}return n(t,e),t.prototype.destroy=function(){},t}(re),mr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.Bindings;var o=r.pipeline;fe(!!o);var a=r.uniformBufferBindings,s=r.storageBufferBindings,l=r.samplerBindings;n.numUniformBuffers=(null==a?void 0:a.length)||0;var u=[[],[]],c=0;if(s&&s.length)for(var f=0;s.length>f;f++){var d=r.storageBufferBindings[f],p=d.binding,_=d.size,h=d.offset,E={buffer:ir(d.buffer),offset:null!=h?h:0,size:_};u[0].push({binding:null!=p?p:c++,resource:E})}if(a&&a.length)for(f=0;a.length>f;f++){var R=r.uniformBufferBindings[f];p=R.binding,_=R.size,h=R.offset,E={buffer:ir(R.buffer),offset:null!=h?h:0,size:_};u[0].push({binding:null!=p?p:c++,resource:E})}if(l&&l.length){c=0;for(f=0;l.length>f;f++){var T=i(i({},l[f]),Ue),v=null!==(p=r.samplerBindings[f]).texture?p.texture:n.device.getFallbackTexture(T);T.dimension=v.dimension,T.formatKind=ce(v.format),u[1].push({binding:c++,resource:v.gpuTextureView});var A=null!==p.sampler?p.sampler:n.device.getFallbackSampler(T),m=A.gpuSampler;u[1].push({binding:c++,resource:m})}}return n.gpuBindGroup=u.filter((function(e){return e.length>0})).map((function(e,t){return n.device.device.createBindGroup({layout:o.getBindGroupLayout(t),entries:e})})),n}return n(t,e),t}(Ar),gr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.Buffer;var i=r.usage,o=r.viewOrSize,a=!!(i&k.MAP_READ);n.usage=function(e){var t=0;return e&k.INDEX&&(t|=GPUBufferUsage.INDEX),e&k.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&k.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&k.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&k.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),t|GPUBufferUsage.COPY_DST}(i),a&&(n.usage=k.MAP_READ|k.COPY_DST);var s=!P(o);(n.view=P(o)?null:o,n.size=P(o)?ge(o,4):ge(o.byteLength,4),P(o))?n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!a&&s}):(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new(o&&o.constructor||Float32Array)(n.gpuBuffer.getMappedRange()).set(o),n.gpuBuffer.unmap());return n}return n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var l=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(l),r=0,o=0,a=s,n=s}for(var u=15728640,c=0;a-(o+c)>u;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,u),c+=u;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(Ar),Sr=function(){function e(){this.commandEncoder=null,this.gpuComputePassEncoder=null}return e.prototype.dispatchWorkgroups=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.dispatchWorkgroupsIndirect=function(e,t){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,t)},e.prototype.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},e.prototype.beginComputePass=function(){fe(null===this.gpuComputePassEncoder),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=de(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e){this.gpuComputePassEncoder.setBindGroup(0,e.gpuBindGroup[0])},e.prototype.pushDebugGroup=function(e){this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuComputePassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuComputePassEncoder.insertDebugMarker(e)},e}(),yr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var o=r.program.computeStage;if(null===o)return n;var a={layout:"auto",compute:i({},o)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(Ar),Cr=function(e){function t(t){var r,n,i,o,a=t.descriptor,s=e.call(this,{id:t.id,device:t.device})||this;s.type=M.InputLayout;var u=[];try{for(var c=l(a.vertexBufferDescriptors),f=c.next();!f.done;f=c.next()){var d=f.value,p=d.attributes;u.push({arrayStride:d.arrayStride,stepMode:Rr(d.stepMode),attributes:[]});try{for(var _=(i=void 0,l(p)),h=_.next();!h.done;h=_.next()){var E=h.value,R=E.offset;u[u.length-1].attributes.push({shaderLocation:E.shaderLocation,format:Tr(E.format),offset:R})}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return s.indexFormat=function(e){if(null!==e){if(e===te.U16_R)return"uint16";if(e===te.U32_R)return"uint32";throw Error("whoops")}}(a.indexBufferFormat),s.buffers=u,s}return n(t,e),t}(Ar),Nr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=M.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.vertex&&(n.vertexStage=n.createShaderStage(r.vertex,"vertex")),r.fragment&&(n.fragmentStage=n.createShaderStage(r.fragment,"fragment")),r.compute&&(n.computeStage=n.createShaderStage(r.compute,"compute")),n}return n(t,e),t.prototype.setUniformsLegacy=function(e){},t.prototype.createShaderStage=function(e,t){var r,n,i=e.glsl,o=e.entryPoint,a=e.wgsl;if(!a)try{a=this.device.glsl_compile(i,t,!1)}catch(e){throw console.error(e,i),Error("whoops")}var s=function(e){if(!a.includes(e))return"continue";a=(a=a.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),(function(t,r){return"vec4<f32>(textureSample(T_".concat(e).concat(r,"), 0.0, 0.0, 0.0);")}))};try{for(var u=l(["u_TextureFramebufferDepth"]),c=u.next();!c.done;c=u.next()){s(c.value)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return{module:this.device.device.createShaderModule({code:a}),entryPoint:o||"main"}},t}(Ar),Pr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:or(r.type),count:i}),n.resolveBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),n.cpuBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n.results=null,n}return n(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}(Ar),Ir=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=M.Readback,r}return n(t,e),t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),a(this,void 0,void 0,(function(){var a,u,c,f,d,p;return s(this,(function(s){return 0,u=this.getBlockInformationFromFormat((a=e).gpuTextureformat),d=this.device.createBuffer({usage:k.STORAGE|k.MAP_READ|k.COPY_DST,hint:V.STATIC,viewOrSize:f=(c=256*Math.ceil(Math.ceil(n/u.width)*u.length/256))*i}),(p=this.device.device.createCommandEncoder()).copyTextureToBuffer({texture:a.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:d.gpuBuffer,offset:0,bytesPerRow:c},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([p.finish()]),[2,this.readBuffer(d,0,o.byteLength===f?o:null,l,f,a.format)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){throw Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")},t.prototype.readBuffer=function(e,t,r,n,i,o,a,s){var l=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=te.U8_RGB),void 0===a&&(a=!1);var u=e,c=i||u.size,f=r||u.view,d=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||ue(o),p=u;if(!(u.usage&k.MAP_READ&&u.usage&k.COPY_DST)){var _=this.device.device.createCommandEncoder();p=this.device.createBuffer({usage:k.STORAGE|k.MAP_READ|k.COPY_DST,hint:V.STATIC,viewOrSize:c}),_.copyBufferToBuffer(u.gpuBuffer,t,p.gpuBuffer,0,c),this.device.device.queue.submit([_.finish()])}return new Promise((function(e,r){p.gpuBuffer.mapAsync($t.READ,t,c).then((function(){var r=p.gpuBuffer.getMappedRange(t,c),n=f;if(a)n=null===n?vr(o,c,!0,r):vr(o,n.buffer,void 0,r);else if(null===n)switch(d){case 1:(n=new Uint8Array(c)).set(new Uint8Array(r));break;case 2:n=l.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r);break;case 4:(n=new Float32Array(c/4)).set(new Float32Array(r))}else switch(d){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=l.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r,f);break;case 4:var i=f&&f.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}p.gpuBuffer.unmap(),e(n)}),(function(e){return r(e)}))}))},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r},t.prototype.getBlockInformationFromFormat=function(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}},t}(Ar),Or=function(){function e(e){this.device=e,this.commandEncoder=null,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.getTextureView=function(e,t){return fe(e.mipLevelCount>t),1===e.mipLevelCount?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){var t,r,n,i,o,a;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var s=e.colorAttachment.length;this.gfxColorAttachment.length=s,this.gfxColorResolveTo.length=s;for(var l=0;e.colorAttachment.length>l;l++){var u=e.colorAttachment[l],c=e.colorResolveTo[l];if(null===u&&null!==c&&(u=c,c=null),this.gfxColorAttachment[l]=u,this.gfxColorResolveTo[l]=c,this.gfxColorAttachmentLevel[l]=(null===(t=e.colorAttachmentLevel)||void 0===t?void 0:t[l])||0,this.gfxColorResolveToLevel[l]=(null===(r=e.colorResolveToLevel)||void 0===r?void 0:r[l])||0,null===u){this.gpuColorAttachments.length=l,this.gfxColorAttachment.length=l,this.gfxColorResolveTo.length=l;break}void 0===this.gpuColorAttachments[l]&&(this.gpuColorAttachments[l]={}),(d=this.gpuColorAttachments[l]).view=this.getTextureView(u,(null===(n=this.gfxColorAttachmentLevel)||void 0===n?void 0:n[l])||0);var f=null!==(o=null===(i=e.colorClearColor)||void 0===i?void 0:i[l])&&void 0!==o?o:"load";"load"===f?d.loadOp="load":(d.loadOp="clear",d.clearValue=f),d.storeOp=(null===(a=e.colorStore)||void 0===a?void 0:a[l])?"store":"discard",d.resolveTarget=void 0,null!==c&&(u.sampleCount>1?d.resolveTarget=this.getTextureView(c,this.gfxColorResolveToLevel[l]):d.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){var d,p=e.depthStencilAttachment;(d=this.gpuDepthStencilAttachment).view=p.gpuTextureView,!!(se(p.format)&ee.Depth)?("load"===e.depthClearValue?d.depthLoadOp="load":(d.depthLoadOp="clear",d.depthClearValue=e.depthClearValue),d.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.depthLoadOp=void 0,d.depthStoreOp=void 0),!!(se(p.format)&ee.Stencil)?("load"===e.stencilClearValue?d.stencilLoadOp="load":(d.stencilLoadOp="clear",d.stencilClearValue=e.stencilClearValue),d.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.stencilLoadOp=void 0,d.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=g(e.occlusionQueryPool)?void 0:e.occlusionQueryPool.querySet},e.prototype.beginRenderPass=function(e){fe(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.flipY=function(e,t){return this.device.swapChainHeight-e-t},e.prototype.setViewport=function(e,t,r,n,i,o){void 0===i&&(i=0),void 0===o&&(o=1),this.gpuRenderPassEncoder.setViewport(e,this.flipY(t,n),r,n,i,o)},e.prototype.setScissorRect=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(t,n),r,n)},e.prototype.setPipeline=function(e){var t=de(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},e.prototype.setVertexInput=function(e,t,r){if(null!==e){var n=e;null!==r&&this.gpuRenderPassEncoder.setIndexBuffer(ir(r.buffer),de(n.indexFormat),r.offset);for(var i=0;t.length>i;i++){var o=t[i];null!==o&&this.gpuRenderPassEncoder.setVertexBuffer(i,ir(o.buffer),o.offset)}}},e.prototype.setBindings=function(e){var t=e;this.gpuRenderPassEncoder.setBindGroup(0,t.gpuBindGroup[0]),t.gpuBindGroup[1]&&this.gpuRenderPassEncoder.setBindGroup(1,t.gpuBindGroup[1])},e.prototype.setStencilReference=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t,r,n){this.gpuRenderPassEncoder.draw(e,t,r,n)},e.prototype.drawIndexed=function(e,t,r,n,i){this.gpuRenderPassEncoder.drawIndexed(e,t,r,n,i)},e.prototype.drawIndirect=function(e,t){this.gpuRenderPassEncoder.drawIndirect(ir(e),t)},e.prototype.drawIndexedIndirect=function(e,t){this.gpuRenderPassEncoder.drawIndexedIndirect(ir(e),t)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.pushDebugGroup=function(e){this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuRenderPassEncoder.insertDebugMarker(e)},e.prototype.finish=function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;this.gfxColorAttachment.length>e;e++){var t=this.gfxColorAttachment[e],r=this.gfxColorResolveTo[e];null!==t&&null!==r&&1===t.sampleCount&&this.copyAttachment(r,this.gfxColorAttachmentLevel[e],t,this.gfxColorResolveToLevel[e])}return this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.commandEncoder.finish()},e.prototype.copyAttachment=function(e,t,r,n){fe(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},o={texture:e.gpuTexture,mipLevel:t};fe(r.width>>>n==e.width>>>t),fe(r.height>>>n==e.height>>>t),fe(!!(r.usage&Qt.COPY_SRC)),fe(!!(e.usage&Qt.COPY_DST)),this.commandEncoder.copyTextureToTexture(i,o,[e.width,e.height,1])},e}(),Mr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=M.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device.createRenderPipelineInternal(n,!1),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(Ar),xr=function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=M.Sampler;var a=i.lodMinClamp,s=i.mipmapFilter===G.NO_MIP?i.lodMinClamp:i.lodMaxClamp,l=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return l>1&&fe(i.minFilter===U.BILINEAR&&i.magFilter===U.BILINEAR&&i.mipmapFilter===G.LINEAR),o.gpuSampler=o.device.device.createSampler({addressModeU:tr(i.addressModeU),addressModeV:tr(i.addressModeV),addressModeW:tr(null!==(n=i.addressModeW)&&void 0!==n?n:i.addressModeU),lodMinClamp:a,lodMaxClamp:s,minFilter:rr(i.minFilter),magFilter:rr(i.magFilter),mipmapFilter:nr(i.mipmapFilter),compare:void 0!==i.compareFunction?hr(i.compareFunction):void 0,maxAnisotropy:l}),o}return n(t,e),t}(Ar),Br=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=t.sampleCount,o=e.call(this,{id:t.id,device:t.device})||this;o.type=M.Texture;var a=r.dimension,s=r.depthOrArrayLayers,l=r.mipLevelCount;return o.device.createTextureShared({format:r.format,dimension:null!=a?a:H.TEXTURE_2D,width:r.width,height:r.height,depthOrArrayLayers:null!=s?s:1,mipLevelCount:null!=l?l:1,usage:r.usage,sampleCount:null!=i?i:1},o,n),o}return n(t,e),t.prototype.textureFromImageBitmapOrCanvas=function(e,t,r){for(var n=t[0].width,i=t[0].height,o={size:{width:n,height:i,depthOrArrayLayers:r},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=e.createTexture(o),s=0;t.length>s;s++)e.queue.copyExternalImageToTexture({source:t[s]},{texture:a,origin:[0,0,s]},[n,i]);return[a,n,i]},t.prototype.isImageBitmapOrCanvases=function(e){var t=e[0];return t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas},t.prototype.isVideo=function(e){return e[0]instanceof HTMLVideoElement},t.prototype.setImageData=function(e,t){var r,n,i,o,a=this.device.device;this.isImageBitmapOrCanvases(e)?(n=(r=u(this.textureFromImageBitmapOrCanvas(a,e,this.depthOrArrayLayers),3))[0],i=r[1],o=r[2]):this.isVideo(e)&&(n=a.importExternalTexture({source:e[0]})),this.width=i,this.height=o,this.gpuTexture=n,this.gpuTextureView=n.createView({dimension:er(this.dimension)})},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuTexture.destroy()},t}(Ar),Dr=function(){function e(e,t,r,n,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Qt.RENDER_ATTACHMENT|Qt.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Z.UPPER_LEFT,this.clipSpaceNearZ=q.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(H.TEXTURE_2D,j.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(H.TEXTURE_2D,j.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(H.TEXTURE_2D_ARRAY,j.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(H.TEXTURE_3D,j.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(H.TEXTURE_CUBE_MAP,j.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:b.REPEAT,addressModeV:b.REPEAT,minFilter:U.POINT,magFilter:U.POINT,mipmapFilter:G.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:b.REPEAT,addressModeV:b.REPEAT,minFilter:U.POINT,magFilter:U.POINT,mipmapFilter:G.NEAREST,compareFunction:x.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)},this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}return e.prototype.destroy=function(){},e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t)},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new Br({id:0,device:this,descriptor:{format:te.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:H.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",this.setResourceName(r,"Onscreen Texture"),r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new gr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new Br({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new xr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new Br({id:this.getNextUniqueId(),device:this,descriptor:i(i({},e),{dimension:H.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:Y.RENDER_TARGET}),sampleCount:e.sampleCount});return t.depthOrArrayLayers=1,t.type=M.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.format,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.mipLevelCount,s=e.gpuTexture,l=e.gpuTextureView,u=e.usage;fe(!!(u&Qt.RENDER_ATTACHMENT));var c=new Br({id:this.getNextUniqueId(),device:this,descriptor:{format:t,width:r,height:n,depthOrArrayLayers:i,dimension:H.TEXTURE_2D,mipLevelCount:a,usage:u},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=l,c},e.prototype.createProgram=function(e){var t,r;return(null===(t=e.vertex)||void 0===t?void 0:t.glsl)&&(e.vertex.glsl=gt(this.queryVendorInfo(),"vert",e.vertex.glsl)),(null===(r=e.fragment)||void 0===r?void 0:r.glsl)&&(e.fragment.glsl=gt(this.queryVendorInfo(),"frag",e.fragment.glsl)),new Nr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.mipLevelCount,o=Jt(e.format),a=function(e){if(e===H.TEXTURE_2D)return"2d";if(e===H.TEXTURE_CUBE_MAP)return"2d";if(e===H.TEXTURE_2D_ARRAY)return"2d";if(e===H.TEXTURE_3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&Y.SAMPLED&&(t|=Qt.TEXTURE_BINDING|Qt.COPY_DST),e&Y.RENDER_TARGET&&(t|=Qt.RENDER_ATTACHMENT|Qt.TEXTURE_BINDING|Qt.COPY_SRC|Qt.COPY_DST),t}(e.usage);if(t.gpuTextureformat=o,t.dimension=e.dimension,t.format=e.format,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.mipLevelCount=i,t.usage=s,t.sampleCount=e.sampleCount,!r){var l=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,sampleCount:e.sampleCount,usage:s}),u=l.createView();t.gpuTexture=l,t.gpuTextureView=u}},e.prototype.getFallbackSampler=function(e){return e.formatKind===j.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===H.TEXTURE_2D)return e.formatKind===j.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===H.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(t===H.TEXTURE_3D)return this.fallbackTexture3D;if(t===H.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,format:t===j.Float?te.U8_RGBA_NORM:te.D24,usage:Y.SAMPLED,width:1,height:1,depthOrArrayLayers:e===H.TEXTURE_CUBE_MAP?6:1,mipLevelCount:1})},e.prototype.createBindings=function(e){return new mr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new Cr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createComputePipeline=function(e){return new yr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new Mr({id:this.getNextUniqueId(),device:this,descriptor:i({},e)})},e.prototype.createQueryPool=function(e,t){return new Pr({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype.createRenderPipelineInternal=function(e,t){var r;if(null===e.gpuRenderPipeline){var n=e.descriptor,a=n.program,s=a.vertexStage,l=a.fragmentStage;if(null!==s&&null!==l){var u=n.megaStateDescriptor||{},c=u.stencilBack,f=u.stencilFront,d=o(u,["stencilBack","stencilFront"]),p=xe(De);n.megaStateDescriptor=i(i(i({},p),{stencilBack:i(i({},p.stencilBack),c),stencilFront:i(i({},p.stencilFront),f)}),d);var _=n.megaStateDescriptor.attachmentsState[0];n.colorAttachmentFormats.forEach((function(e,t){n.megaStateDescriptor.attachmentsState[t]||(n.megaStateDescriptor.attachmentsState[t]=Ie(void 0,_))}));var h,E,R=(h=null!==(r=n.topology)&&void 0!==r?r:w.TRIANGLES,E=n.megaStateDescriptor,{topology:ar(h),cullMode:sr(E.cullMode),frontFace:lr(E.frontFace)}),T=_r(n.colorAttachmentFormats,n.megaStateDescriptor),v=function(e,t){if(!g(e))return{format:Jt(e),depthWriteEnabled:!!t.depthWrite,depthCompare:hr(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0,stencilFront:{compare:hr(t.stencilFront.compare),passOp:Er(t.stencilFront.passOp),failOp:Er(t.stencilFront.failOp),depthFailOp:Er(t.stencilFront.depthFailOp)},stencilBack:{compare:hr(t.stencilBack.compare),passOp:Er(t.stencilBack.passOp),failOp:Er(t.stencilBack.failOp),depthFailOp:Er(t.stencilBack.depthFailOp)},stencilReadMask:1,stencilWriteMask:1}}(n.depthStencilAttachmentFormat,n.megaStateDescriptor),A=void 0;null!==n.inputLayout&&(A=n.inputLayout.buffers);var m=n.sampleCount,S={layout:"auto",vertex:i(i({},s),{buffers:A}),primitive:R,depthStencil:v,multisample:{count:m},fragment:i(i({},l),{targets:T})};e.gpuRenderPipeline=this.device.createRenderPipeline(S)}}},e.prototype.createReadback=function(){return new Ir({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new Or(this)),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();return void 0===e&&(e=new Sr),e.commandEncoder=this.device.createCommandEncoder(),e.beginComputePass(),e},e.prototype.submitPass=function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null},e.prototype.copySubTexture2D=function(e,t,r,n,i,o){var a=this.device.createCommandEncoder(),s=e,l=n,u={texture:l.gpuTexture,origin:[i,o,0]},c={texture:s.gpuTexture,origin:[t,r,0]};fe(!!(l.usage&Qt.COPY_SRC)),fe(!!(s.usage&Qt.COPY_DST)),a.copyTextureToTexture(u,c,[l.width,l.height,1]),this.device.queue.submit([a.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(ae(e)){case $.BC1:case $.BC2:case $.BC3:case $.BC4_SNORM:case $.BC4_UNORM:case $.BC5_SNORM:case $.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(ae(e)){case $.BC1:case $.BC2:case $.BC3:case $.BC4_SNORM:case $.BC4_UNORM:case $.BC5_SNORM:case $.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}switch(e){case te.U16_RGBA_NORM:case te.F32_RGBA:return!1}return!0},e.prototype.queryPlatformAvailable=function(){return!0},e.prototype.queryVendorInfo=function(){return this},e.prototype.queryRenderPass=function(e){return e.descriptor},e.prototype.queryRenderTarget=function(e){return e},e.prototype.setResourceName=function(e,t){if(e.name=t,e.type===M.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===M.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===M.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===M.Sampler){(r=e).gpuSampler.label=t}else if(e.type===M.RenderPipeline){var r;null!==(r=e).gpuRenderPipeline&&(r.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this.createRenderPipelineInternal(e,!1)},e}(),Lr=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return a(this,void 0,void 0,(function(){var t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:if(void 0===globalThis.navigator.gpu)return[2,null];t=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,globalThis.navigator.gpu.requestAdapter({xrCompatible:this.pluginOptions.xrCompatible})];case 2:return t=s.sent(),[3,4];case 3:return r=s.sent(),console.log(r),[3,4];case 4:return null===t?[2,null]:(n=["depth32float-stencil8","texture-compression-bc"].filter((function(e){return t.features.has(e)})),[4,t.requestDevice({requiredFeatures:n})]);case 5:if((i=s.sent())&&(o=this.pluginOptions.onContextLost,i.lost.then((function(){o&&o()}))),null===i)return[2,null];if(!(a=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,qt(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new Dr(t,i,e,a,jt)]}}))}))},e}(),Fr={exports:{}};function br(e,t,r){r=r||2;var n,i,o,a,s,l,u,c=t&&t.length,f=c?t[0]*r:e.length,d=Ur(e,0,f,r,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=Ur(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(jr(a));for(s.sort(Hr),i=0;s.length>i;i++)r=Gr(r=Yr(s[i],r),r.next);return r}(e,t,d,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var _=r;f>_;_+=r)n>(s=e[_])&&(n=s),i>(l=e[_+1])&&(i=l),s>o&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-n,a-i))?1/u:0}return wr(d,p,r,n,i,u),p}function Ur(e,t,r,n,i){var o,a;if(i===ln(e,t,r,n)>0)for(o=t;r>o;o+=n)a=on(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=on(o,e[o],e[o+1],a);return a&&$r(a,a.next)&&(an(a),a=a.next),a}function Gr(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!$r(n,n.next)&&0!==Qr(n.prev,n,n.next))n=n.next;else{if(an(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function wr(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=Kr(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,l,u=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;u>t&&(s++,n=n.nextZ);t++);for(l=u;s>0||l>0&&n;)0===s||0!==l&&n&&r.z>n.z?(i=n,n=n.nextZ,l--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,u*=2}while(a>1)}(i)}(e,n,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Vr(e,n,i,o):kr(e))t.push(s.i/r),t.push(e.i/r),t.push(l.i/r),an(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?wr(e=Xr(Gr(e),t,r),t,r,n,i,o,2):2===a&&Wr(e,t,r,n,i,o):wr(Gr(e),t,r,n,i,o,1);break}}}function kr(e){var t=e.prev,r=e,n=e.next;if(Qr(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(Zr(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Qr(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vr(e,t,r,n){var i=e.prev,o=e,a=e.next;if(Qr(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,u=Kr(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=Kr(s,l,t,r,n),f=e.prevZ,d=e.nextZ;f&&f.z>=u&&d&&c>=d.z;){if(f!==e.prev&&f!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Qr(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==e.prev&&d!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Qr(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Qr(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&c>=d.z;){if(d!==e.prev&&d!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Qr(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Xr(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!$r(i,o)&&Jr(i,n,n.next,o)&&rn(i,o)&&rn(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),an(n),an(n.next),n=e=o),n=n.next}while(n!==e);return Gr(n)}function Wr(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&qr(a,s)){var l=nn(a,s);return a=Gr(a,a.next),l=Gr(l,l.next),wr(a,t,r,n,i,o),void wr(l,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function Hr(e,t){return e.x-t.x}function Yr(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var l,u=r,c=r.x,f=r.y,d=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!Zr(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(l=Math.abs(o-n.y)/(i-n.x),rn(n,e)&&(d>l||l===d&&(n.x>r.x||n.x===r.x&&zr(r,n)))&&(r=n,d=l)),n=n.next}while(n!==u);return r}(e,t);if(!r)return t;var n=nn(r,e),i=Gr(r,r.next);return Gr(n,n.next),t===r?i:t}function zr(e,t){return 0>Qr(e.prev,e,t.prev)&&0>Qr(t.next,e,e.next)}function Kr(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function jr(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function Zr(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function qr(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Jr(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(rn(e,t)&&rn(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(Qr(e.prev,e,t.prev)||Qr(e,t.prev,t))||$r(e,t)&&Qr(e.prev,e,e.next)>0&&Qr(t.prev,t,t.next)>0)}function Qr(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function $r(e,t){return e.x===t.x&&e.y===t.y}function Jr(e,t,r,n){var i=tn(Qr(e,t,r)),o=tn(Qr(e,t,n)),a=tn(Qr(r,n,e)),s=tn(Qr(r,n,t));return i!==o&&a!==s||(!(0!==i||!en(e,r,t))||(!(0!==o||!en(e,n,t))||(!(0!==a||!en(r,e,n))||!(0!==s||!en(r,t,n)))))}function en(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function tn(e){return e>0?1:0>e?-1:0}function rn(e,t){return 0>Qr(e.prev,e,e.next)?Qr(e,t,e.next)>=0&&Qr(e,e.prev,t)>=0:0>Qr(e,t,e.prev)||0>Qr(e,e.next,t)}function nn(e,t){var r=new sn(e.i,e.x,e.y),n=new sn(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function on(e,t,r,n){var i=new sn(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function an(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function sn(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ln(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}Fr.exports=br,Fr.exports.default=br,br.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(ln(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(ln(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var l=0;for(a=0;n.length>a;a+=3){var u=n[a]*r,c=n[a+1]*r,f=n[a+2]*r;l+=Math.abs((e[u]-e[f])*(e[c+1]-e[u+1])-(e[u]-e[c])*(e[f+1]-e[u+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},br.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var un=Fr.exports;function cn(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}function fn(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function dn(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function pn(e,t,r,n,i,o,a,s,l){if(0===l)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=cn(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var f=function(e,t,r,n,i,o,a,s,l){var u=dn(e,r,i,a,l),c=dn(t,n,o,s,l),f=fn(e,t,r,n,l),d=fn(r,n,i,o,l),p=fn(i,o,a,s,l),_=fn(f.x,f.y,d.x,d.y,l),h=fn(d.x,d.y,p.x,p.y,l);return[[e,t,f.x,f.y,_.x,_.y,u,c],[u,c,h.x,h.y,p.x,p.y,a,s]]}(e,t,r,n,i,o,a,s,.5),d=c(c([],u(f[0]),!1),[l-1],!1),p=c(c([],u(f[1]),!1),[l-1],!1);return pn.apply(void 0,c([],u(d),!1))+pn.apply(void 0,c([],u(p),!1))}function _n(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function hn(e,t,r,n,i,o,a){if(0===a)return(cn(e,t,r,n)+cn(r,n,i,o)+cn(e,t,i,o))/2;var s=function(e,t,r,n,i,o,a){var s=_n(e,r,i,a),l=_n(t,n,o,a),u=fn(e,t,r,n,a),c=fn(r,n,i,o,a);return[[e,t,u.x,u.y,s,l],[s,l,c.x,c.y,i,o]]}(e,t,r,n,i,o,.5),l=s[0],f=s[1];return l.push(a-1),f.push(a-1),hn.apply(void 0,c([],u(l),!1))+hn.apply(void 0,c([],u(f),!1))}var En=function(){function e(){this.drawcalls=[]}return e.tag="c-renderable-3d",e}(),Rn=function(){function e(){this.lights=[]}return e.prototype.addLight=function(e){this.lights.push(e),this.sortLights()},e.prototype.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},e.prototype.addFog=function(e){this.fog=e},e.prototype.removeFog=function(e){this.fog=null},e.prototype.getFog=function(){return this.fog},e.prototype.getAllLights=function(){return this.lights},e.prototype.getDefines=function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e},e.prototype.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}(),Tn=function(e){function r(r){var n=this,a=r.style,s=o(r,["style"]);return(n=e.call(this,i({type:t.Shape.MESH,style:i({x:"",y:"",z:"",lineWidth:0,anchor:[.5,.5,.5]},a)},s))||this).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return n(r,e),r.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.style.geometry.meshes,r=t.indexOf(this);t.splice(r,1),r=(t=this.style.material.meshes).indexOf(this),t.splice(r,1)},r}(t.DisplayObject),vn=function(){function e(){}return e.prototype.update=function(e){var t=e.geometry.computeBoundingBox(),r=t.getMax(),n=t.getMin();return{width:r[0]-n[0],height:r[1]-n[1],depth:r[2]-n[2]}},e}(),An=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}return e.prototype.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},e.prototype.getById=function(e){return this.id2DisplayObjectMap[e]},e.prototype.deleteById=function(e){delete this.id2DisplayObjectMap[e]},e.prototype.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},e.prototype.decodePickingColor=function(e){var t=u(e,3);return t[0]+256*t[1]+65536*t[2]-1},e.prototype.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}(),mn=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}}return e.prototype.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},e.prototype.setDefineString=function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(g(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},e.prototype.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},e.prototype.getDefineString=function(e){return void 0===(t=this.defines[e])?null:t;var t},e.prototype.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&fe("1"===t),null!==t},e}(),gn=function(){function e(e){this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=e;var t=e.queryLimits();this.uniformBufferWordAlignment=t.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=t.uniformBufferMaxPageWordSize}return e.prototype.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},e.prototype.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},e.prototype.allocateChunk=function(e){e=Se(e,this.uniformBufferWordAlignment),fe(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=Se(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},e.prototype.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=Se(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){fe(this.currentWordOffset>e&&this.currentWordOffset>=e+t);r=Se(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize);var n=new Uint8Array(4*r);if(n.set(this.shadowBufferU8,0),this.shadowBufferU8=n,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),r<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}},e.prototype.mapBufferF32=function(){return de(this.shadowBufferF32)},e.prototype.prepareToRender=function(){if(null!==this.shadowBufferF32){var e=de(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:k.UNIFORM,hint:V.DYNAMIC}));var t=Se(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())de(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}},e.prototype.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function Sn(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function yn(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Cn(e){return 0}var Nn=function(){this.keys=[],this.values=[]},Pn=function(){function e(e,t){this.keyEqualFunc=e,this.keyHashFunc=t,this.buckets=new Map}return e.prototype.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},e.prototype.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},e.prototype.get=function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]},e.prototype.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new Nn);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},e.prototype.delete=function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}},e.prototype.clear=function(){this.buckets.clear()},e.prototype.size=function(){var e,t,r=0;try{for(var n=l(this.buckets.values()),i=n.next();!i.done;i=n.next()){r+=i.value.values.length}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.values=function(){var e,t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,7,8,9]),e=l(this.buckets.values()),t=e.next(),s.label=1;case 1:if(t.done)return[3,6];n=(r=t.value).values.length-1,s.label=2;case 2:return n<0?[3,5]:[4,r.values[n]];case 3:s.sent(),s.label=4;case 4:return n--,[3,2];case 5:return t=e.next(),[3,1];case 6:return[3,9];case 7:return i=s.sent(),o={error:i},[3,9];case 8:try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(o)throw o.error}return[7];case 9:return[2]}}))},e}();function In(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:gt(e,"vert",t,n),preprocessedFrag:gt(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function On(e,t){return fe(""!==e.preprocessedVert&&""!==t.preprocessedVert),fe(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Mn(e,t){return e=Sn(e,t.blendMode),e=Sn(e,t.blendSrcFactor),e=Sn(e,t.blendDstFactor)}function xn(e,t){return e=Mn(e,t.rgbBlendState),e=Sn(e=Mn(e,t.alphaBlendState),t.channelWriteMask)}function Bn(e,t){for(var r,n,i,o,a,s,l,u,c=0;t.attachmentsState.length>c;c++)e=xn(e,t.attachmentsState[c]);return e=function(e,t){return Sn(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Sn(e,t.depthCompare),e=Sn(e,t.depthWrite?1:0),e=Sn(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=Sn(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=Sn(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=Sn(e,null===(o=t.stencilFront)||void 0===o?void 0:o.depthFailOp),e=Sn(e,null===(a=t.stencilBack)||void 0===a?void 0:a.compare),e=Sn(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=Sn(e,null===(l=t.stencilBack)||void 0===l?void 0:l.failOp),e=Sn(e,null===(u=t.stencilBack)||void 0===u?void 0:u.depthFailOp),e=Sn(e,t.stencilWrite?1:0),e=Sn(e,t.cullMode),e=Sn(e,t.frontFace?1:0),e=Sn(e,t.polygonOffset?1:0)}function Dn(e){var t=0;t=Sn(t,e.program.id),null!==e.inputLayout&&(t=Sn(t,e.inputLayout.id)),t=Bn(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=Sn(t,e.colorAttachmentFormats[r]||0);return yn(t=Sn(t,e.depthStencilAttachmentFormat||0))}function Ln(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){null!==(n=e.samplerBindings[r])&&null!==n.texture&&(t=Sn(t,n.texture.id))}for(r=0;e.uniformBufferBindings.length>r;r++){var n;null!==(n=e.uniformBufferBindings[r])&&null!==n.buffer&&(t=Sn(t,n.buffer.id),t=Sn(t,n.binding),t=Sn(t,n.offset),t=Sn(t,n.size))}return yn(t)}var Fn,bn,Un=function(){function e(e){this.bindingsCache=new Pn(Xe,Ln),this.renderPipelinesCache=new Pn(je,Dn),this.inputLayoutsCache=new Pn(Qe,Cn),this.programCache=new Pn(On,Cn),this.samplerCache=new Pn($e,Cn),this.device=e}return e.prototype.createBindings=function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&we(t.samplerBindings,Je),uniformBufferBindings:t.uniformBufferBindings&&we(t.uniformBufferBindings,et),pipeline:t.pipeline};r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r},e.prototype.createRenderPipeline=function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var o=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&xe(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});i=this.device.createRenderPipeline(o),this.renderPipelinesCache.add(o,i)}return i},e.prototype.createInputLayout=function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter((function(e){return!!e}));var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:we((t=e).vertexBufferDescriptors,rt),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r},e.prototype.createProgramSimple=function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,o=null;if(i&&n&&(o=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===o){var a=In(this.device,e),s=a.preprocessedVert,l=a.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=l;var u={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};o=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:l}},r),this.programCache.add(u,o)}return o},e.prototype.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},e.prototype.destroy=function(){var e,t,r,n,i,o,a,s,u,c;try{for(var f=l(this.bindingsCache.values()),d=f.next();!d.done;d=f.next()){d.value.destroy()}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var p=l(this.renderPipelinesCache.values()),_=p.next();!_.done;_=p.next()){_.value.destroy()}}catch(e){r={error:e}}finally{try{_&&!_.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var h=l(this.inputLayoutsCache.values()),E=h.next();!E.done;E=h.next()){E.value.destroy()}}catch(e){i={error:e}}finally{try{E&&!E.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}try{for(var R=l(this.programCache.values()),T=R.next();!T.done;T=R.next()){T.value.destroy()}}catch(e){a={error:e}}finally{try{T&&!T.done&&(s=R.return)&&s.call(R)}finally{if(a)throw a.error}}try{for(var v=l(this.samplerCache.values()),A=v.next();!A.done;A=v.next()){A.value.destroy()}}catch(e){u={error:e}}finally{try{A&&!A.done&&(c=v.return)&&c.call(v)}finally{if(u)throw u.error}}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()},e}();!function(e){e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping"}(Fn||(Fn={})),function(e){e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil"}(bn||(bn={}));var Gn,wn=function(){function e(){this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]}return e.prototype.setDebugName=function(e){this.debugName=e},e.prototype.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},e.prototype.setViewport=function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n},e.prototype.attachRenderTargetID=function(e,t,r){void 0===r&&(r=0),fe(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r},e.prototype.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},e.prototype.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},e.prototype.exec=function(e){fe(null===this.execFunc),this.execFunc=e},e.prototype.post=function(e){fe(null===this.postFunc),this.postFunc=e},e.prototype.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),kn=function(){function e(e,t){this.dimension=H.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Y.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,fe(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}return e.prototype.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},e.prototype.reset=function(e){fe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.attachment.destroy()},e}(),Vn=function(){function e(e,t){this.dimension=H.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=Y.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}return e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height},e.prototype.reset=function(e){fe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.texture.destroy()},e}(),Xn=function(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},Wn=function(){function e(e){this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}return e.prototype.acquireRenderTargetForDescription=function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new kn(this.device,e)},e.prototype.acquireSingleSampledTextureForDescription=function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new Vn(this.device,e)},e.prototype.beginGraphBuilder=function(){fe(null===this.currentGraph),this.currentGraph=new Xn},e.prototype.pushPass=function(e){var t=new wn;e(t),this.currentGraph.passes.push(t)},e.prototype.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},e.prototype.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},e.prototype.findMostRecentPassThatAttachedRenderTarget=function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null},e.prototype.resolveRenderTargetPassAttachmentSlot=function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]},e.prototype.findPassForResolveRenderTarget=function(e){var t=de(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return fe(void 0===t.resolveTextureOutputExternalTextures[r]),t},e.prototype.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},e.prototype.resolveRenderTargetToExternalTexture=function(e,t,r){void 0===r&&(r=0);var n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);fe(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r},e.prototype.getRenderTargetDescription=function(e){return de(this.currentGraph.renderTargetDescriptions[e])},e.prototype.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){void 0!==(i=t.renderTargetIDs[r])&&(this.renderTargetOutputCount[i]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[i]++)}for(var n=0;t.resolveTextureInputIDs.length>n;n++){var i,o=t.resolveTextureInputIDs[n];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[i=e.resolveTextureRenderTargetIDs[o]]++}},e.prototype.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(fe(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]},e.prototype.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=de(this.renderTargetAliveForID[e]);return t?(fe(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(fe(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r},e.prototype.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];fe(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=de(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return de(n.texture)},e.prototype.determineResolveParam=function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;fe(!(a&&s));var l=null,u=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(u=!0),a){fe(e.resolveTextureRenderTargetIDs[i]===n),fe(this.resolveTextureUseCount[i]>0),fe(this.renderTargetOutputCount[n]>0);var f=de(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])l=null,u=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=de(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,f.debugName+" (Resolve ".concat(i,")"))}l=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(l=o,c=t.resolveTextureOutputExternalTextureLevel[r]):l=null;return{resolveTo:l,store:u,level:c}},e.prototype.schedulePass=function(e,t){for(var r=t.renderTargetIDs[bn.DepthStencil],n=bn.Color0;bn.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var a=this.determineResolveParam(e,t,n),s=a.store,l=a.level;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorResolveToLevel[n]=l,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[bn.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var c=this.determineResolveParam(e,t,bn.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,p=0,_=0,h=0;t.renderTargets.length>h;h++){var E=t.renderTargets[h];if(E){var R=E.width>>>t.renderTargetLevels[h],T=E.height>>>t.renderTargetLevels[h];0===d&&(d=R,p=T,_=E.sampleCount),fe(R===d),fe(T===p),fe(E.sampleCount===_),E.needsClear=!1}}d>0&&p>0&&(t.viewportX*=d,t.viewportY*=p,t.viewportW*=d,t.viewportH*=p);for(h=0;t.resolveTextureInputIDs.length>h;h++){t.resolveTextureInputTextures[h]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[h])}for(h=0;t.renderTargetIDs.length>h;h++)this.releaseRenderTargetForID(t.renderTargetIDs[h],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},e.prototype.scheduleGraph=function(e){fe(0===this.renderTargetOutputCount.length),fe(0===this.renderTargetResolveCount.length),fe(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(t=0;this.singleSampledTextureDeadPool.length>t;t++)this.singleSampledTextureDeadPool[t].age++;me(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),me(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),me(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(t=0;e.passes.length>t;t++)this.scheduleAddUseCount(e,e.passes[t]);for(t=0;e.passes.length>t;t++)this.schedulePass(e,e.passes[t]);for(t=0;this.renderTargetOutputCount.length>t;t++)fe(0===this.renderTargetOutputCount[t]);for(t=0;this.renderTargetResolveCount.length>t;t++)fe(0===this.renderTargetResolveCount[t]);for(t=0;this.resolveTextureUseCount.length>t;t++)fe(0===this.resolveTextureUseCount[t]);for(t=0;this.renderTargetAliveForID.length>t;t++)fe(void 0===this.renderTargetAliveForID[t]);for(t=0;this.renderTargetDeadPool.length>t;t++)1>this.renderTargetDeadPool[t].age||(this.renderTargetDeadPool[t].destroy(),this.renderTargetDeadPool.splice(t--,1));for(t=0;this.singleSampledTextureDeadPool.length>t;t++)1>this.singleSampledTextureDeadPool[t].age||(this.singleSampledTextureDeadPool[t].destroy(),this.singleSampledTextureDeadPool.splice(t--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},e.prototype.execPass=function(e){fe(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null},e.prototype.execGraph=function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach((function(e){t.execPass(e)})),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0},e.prototype.execute=function(){var e=de(this.currentGraph);this.execGraph(e),this.currentGraph=null},e.prototype.getDebug=function(){return this},e.prototype.getPasses=function(){return this.currentGraph.passes},e.prototype.getPassDebugThumbnails=function(e){return e.debugThumbnails},e.prototype.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},e.prototype.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},e.prototype.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return fe(r>=0),de(t.resolveTextureInputTextures[r])},e.prototype.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},e.prototype.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},e.prototype.newGraphBuilder=function(){return this.beginGraphBuilder(),this},e.prototype.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)fe(void 0===this.renderTargetAliveForID[e]);for(e=0;this.singleSampledTextureForResolveTextureID.length>e;e++)fe(void 0===this.singleSampledTextureForResolveTextureID[e]);for(e=0;this.renderTargetDeadPool.length>e;e++)this.renderTargetDeadPool[e].destroy();for(e=0;this.singleSampledTextureDeadPool.length>e;e++)this.singleSampledTextureDeadPool[e].destroy()},e}();!function(e){e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT"}(Gn||(Gn={}));var Hn=65536,Yn=16;function zn(e,t,r){void 0===r&&(r=Hn);var n=N(e,0,r)/r;return t&&(n=1-n),65535&n*((1<<Yn)-1)}function Kn(e,t){return(16777215&e|(255&t)<<24)>>>0}function jn(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function Zn(e,t){return Kn(jn(0,t),e)}function qn(e,t){return fe(t>=0),(4294967040&e|t>>>8&255)>>>0}function Qn(e){return Kn(0,e)}function $n(e,t){return fe(t>=0),(4278190335&e|t<<8)>>>0}var Jn=_(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var ei,ti=_(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function ri(e,t,r,n,i,o){return void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags"}(ei||(ei={}));var ni,ii=function(){function e(){this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=Ce(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Ce(4,(function(){return 0})),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:xe(De),program:null,topology:w.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return e.prototype.reset=function(){this.sortKey=0,this.flags=ei.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null},e.prototype.setFromTemplate=function(e){var t,r;Me(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=c([],u(e.uniforms),!1),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~ei.InheritedFlags|e.flags&ei.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],o=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=o.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=o.uniformBufferBindings)||void 0===r?void 0:r.length});for(n=0;Math.min(i.uniformBufferBindings.length,o.uniformBufferBindings.length)>n;n++)i.uniformBufferBindings[n].size=e.bindingDescriptors[0].uniformBufferBindings[n].size;this.setSamplerBindingsFromTextureMappings(o.samplerBindings);for(n=0;e.dynamicUniformBufferByteOffsets.length>n;n++)this.dynamicUniformBufferByteOffsets[n]=e.dynamicUniformBufferByteOffsets[n]},e.prototype.validate=function(){for(var e,t=0;this.bindingDescriptors.length>t;t++)for(var r=this.bindingDescriptors[t],n=0;n<(null===(e=r.uniformBufferBindings)||void 0===e?void 0:e.length);n++)fe(r.uniformBufferBindings[n].size>0);fe(this.drawCount>0)},e.prototype.setProgram=function(e){this.renderPipelineDescriptor.program=e},e.prototype.setMegaStateFlags=function(e){return Me(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.setVertexInput=function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e},e.prototype.setBindingLayout=function(e){fe(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:0,buffer:null,size:0});for(t=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>t;t++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})},e.prototype.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=ye(this.flags,ei.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=ye(this.flags,ei.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},e.prototype.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=ye(this.flags,ei.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.setUniforms=function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(P(t)||Array.isArray(t)||t instanceof Float32Array){var i=P(t)?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,c([],u(i),!1))}}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),l=0;n.length>l;l+=4)a+=ri(s,a,n[l],n[l+1],n[l+2],n[l+3])}},e.prototype.setUniformBuffer=function(e){this.uniformBuffer=e},e.prototype.allocateUniformBuffer=function(e,t){var r;return fe((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)},e.prototype.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},e.prototype.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},e.prototype.getUniformBuffer=function(){return this.uniformBuffer},e.prototype.setSamplerBindingsFromTextureMappings=function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}},e.prototype.setAllowSkippingIfPipelineNotReady=function(e){this.flags=ye(this.flags,ei.AllowSkippingIfPipelineNotReady,e)},e.prototype.setAttachmentFormatsFromRenderPass=function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:fe(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:fe(n==a.sampleCount)),fe(n>0),this.renderPipelineDescriptor.sampleCount=n},e.prototype.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var o=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(o)){if(this.flags&ei.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(o)}t.setPipeline(o),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=de(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniformsLegacy(t)}));var s=e.createBindings(i(i({},this.bindingDescriptors[0]),{pipeline:o}));return t.setBindings(s),this.flags&ei.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0},e}();function oi(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(ni||(ni={}));var ai=function(){function e(e,t){void 0===e&&(e=oi),void 0===t&&(t=ni.Forwards),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}return e.prototype.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},e.prototype.insertSorted=function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()},e.prototype.submitRenderInst=function(e){e.flags|=ei.Draw,this.insertSorted(e)},e.prototype.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},e.prototype.drawOnPassRendererNoReset=function(e,t){if(this.ensureSorted(),this.executionOrder===ni.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(r=this.renderInsts.length-1;r>=0;r--)this.renderInsts[r].drawOnPass(e,t)},e.prototype.reset=function(){this.renderInsts.length=0},e.prototype.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),si=function(){function e(){this.pool=[],this.allocCount=0}return e.prototype.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new ii),this.allocCount-1},e.prototype.popRenderInst=function(){this.allocCount--},e.prototype.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},e.prototype.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),li=function(){function e(e){this.renderCache=e,this.instPool=new si,this.templatePool=new si,this.simpleRenderInstList=new ai,this.currentRenderInstList=this.simpleRenderInstList}return e.prototype.newRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r},e.prototype.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},e.prototype.setCurrentRenderInstList=function(e){fe(null===this.simpleRenderInstList),this.currentRenderInstList=e},e.prototype.pushTemplateRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=ei.Template,r},e.prototype.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},e.prototype.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},e.prototype.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),fe(0===this.templatePool.allocCount)},e.prototype.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},e.prototype.disableSimpleMode=function(){this.simpleRenderInstList=null},e.prototype.drawOnPassRenderer=function(e){de(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},e.prototype.drawOnPassRendererNoReset=function(e){de(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),ui=function(){function e(e){this.parameters=e}return e.prototype.getDevice=function(){return this.device},e.prototype.setDevice=function(e){this.device=e,this.renderCache=new Un(e),this.renderGraph=new Wn(this.device),this.renderInstManager=new li(this.renderCache),this.uniformBuffer=new gn(this.device)},e.prototype.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},e.prototype.prepareToRender=function(){this.uniformBuffer.prepareToRender()},e.prototype.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()},e.prototype.getCache=function(){return this.renderCache},e.prototype.getDefines=function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==Fn.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}},e}(),ci=function(){function e(e){this.format=e,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load"}return e.prototype.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},e.prototype.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function fi(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var di,pi=fi(_e(.88,.88,.88,1)),_i=fi(Ee),hi=fi(Te);function Ei(e,t){var r=function(e){return e.antialiasingMode===di.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function Ri(e,t,r){var n=function(e){if(e===bn.Color0)return te.U8_RGBA_RT;if(e===bn.DepthStencil)return te.D24_S8;throw Error("whoops")}(e),i=new ci(n);return Ei(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(di||(di={}));var Ti,vi=function(){function e(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}return e.prototype.reset=function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0},e.prototype.copy=function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias},e}(),Ai=function(){function e(){this.inputTexture=null,this.outputTexture=null}return e.prototype.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),fe(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Vn(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},e.prototype.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},e.prototype.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},e.prototype.destroy=function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)},e}(),mi=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({intensity:Math.PI},n)},a))||this}return n(t,e),t.tag="light",t}(t.DisplayObject);!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(Ti||(Ti={}));var gi,Si=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({type:Ti.NONE,fill:"black",start:1,end:1e3,density:0},n)},a))||this}return n(t,e),t.tag="fog",t}(t.DisplayObject);function yi(e,t,r,n){void 0===n&&(n=V.STATIC);var i=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:n});return i.setSubData(0,new Uint8Array(r)),i}!function(e){e.CHANGED="changed"}(gi||(gi={}));var Ci,Ni,Pi=function(e){function r(t,r){void 0===r&&(r={});var n=e.call(this)||this;return n.device=t,n.props=r,n.drawMode=w.TRIANGLES,n.vertexBuffers=[],n.vertices=[],n.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n}return n(r,e),r.prototype.validate=function(e){return!0},r.prototype.build=function(e){},r.prototype.computeBoundingBox=function(){return new t.AABB},r.prototype.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=yi(this.device,k.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=te.U32_R,this},r.prototype.setVertexBuffer=function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find((function(e){return e.shaderLocation===o}));s?(s.format=n,s.offset=i,s.divisor=a):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:o,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=yi(this.device,k.VERTEX,i.buffer,V.DYNAMIC);return this.vertexBuffers[r]=o,this},r.prototype.getVertexBuffer=function(e){return this.vertexBuffers[e]},r.prototype.updateVertexBuffer=function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var o=i.arrayStride,a=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find((function(e){return e.shaderLocation===t}));if(a)this.getVertexBuffer(e).setSubData(a.offset+r*o,n);this.emit(gi.CHANGED)}},r.prototype.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this},r.prototype.destroy=function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0},r}(re),Ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.features={},t.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",t.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",t.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",t}return n(t,e),t}(mn),Oi=Ce(1,(function(){return new vi}));function Mi(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(bn.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(Le),a.setBindingLayout({numUniformBuffers:1,numSamplers:1}),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);ri(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var l=new Ii,u=t.renderCache.createProgramSimple(l);a.setProgram(u),Ci||((Ci=new Pi(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),Ci.vertexCount=3,Ni=t.getCache().createInputLayout(Ci.inputLayoutDescriptor)),i.exec((function(e,r){Oi[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(Oi),a.setVertexInput(Ni,Ci.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null),a.drawOnPass(t.renderCache,e)}))}))}var xi;!function(e){e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking"}(xi||(xi={}));var Bi,Di=function(){function e(e,t,r,n,i){this.renderHelper=e,this.lightPool=t,this.texturePool=r,this.batchManager=n,this.options=i,this.renderLists={world:new ai,picking:new ai}}return e.prototype.getDevice=function(){return this.device},e.prototype.getSwapChain=function(){return this.swapChain},e.prototype.getRenderLists=function(){return this.renderLists},e.prototype.apply=function(r){var n=this;this.context=r;var o=r.renderingService,l=r.config,u=r.renderingContext.root.ownerDocument.defaultView;l.disableRenderHooks=!0;var c=function(e){var t=e.target;t.nodeName!==mi.tag?t.nodeName!==Si.tag?(t.renderable3D||(t.renderable3D=new En),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},f=function(e){var r,i,o=e.target;if(o.nodeName!==mi.tag)if(o.nodeName!==Si.tag){if(o.nodeName===t.Shape.MESH){var a;if(null===(r=o.style.geometry)||void 0===r?void 0:r.meshes)(a=o.style.geometry.meshes.indexOf(o))>-1&&o.style.geometry.meshes.splice(a,1);if(null===(i=o.style.material)||void 0===i?void 0:i.meshes)(a=o.style.material.meshes.indexOf(o))>-1&&o.style.material.meshes.splice(a,1)}n.swapChain&&n.batchManager.remove(o),delete o.renderable3D}else n.lightPool.removeFog(o);else n.lightPool.removeLight(o)},d=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach((function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)})):n.batchManager.updateAttribute(t,r,i)}},p=function(e){n.swapChain&&n.batchManager.updateAttribute(e.target,"modelMatrix",null)};o.hooks.initAsync.tapPromise(e.tag,(function(){return a(n,void 0,void 0,(function(){var e,n,o,a=this;return s(this,(function(s){switch(s.label){case 0:return u.addEventListener(t.ElementEvent.MOUNTED,c),u.addEventListener(t.ElementEvent.UNMOUNTED,f),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,d),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p),this.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,e=this.context.contextService.getDomElement(),this.context.contextService.resize((n=this.context.config).width,n.height),o=this,[4,this.context.deviceContribution.createSwapChain(e)];case 1:return o.swapChain=s.sent(),this.device=this.swapChain.getDevice(),this.renderHelper.setDevice(this.device),this.renderHelper.renderInstManager.disableSimpleMode(),this.swapChain.configureSwapChain(e.width,e.height),u.addEventListener(t.CanvasEvent.RESIZE,(function(){a.swapChain.configureSwapChain(e.width,e.height)})),this.batchManager.attach(i({device:this.device},r)),[2]}}))}))})),o.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),u.removeEventListener(t.ElementEvent.MOUNTED,c),u.removeEventListener(t.ElementEvent.UNMOUNTED,f),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,d),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p),n.device.destroy(),n.device.checkForLeaks(),l.disableRenderHooks=!1})),o.hooks.beginFrame.tap(e.tag,(function(){var e,r,i=n.swapChain.getCanvas(),o=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)r=he;else{var a=t.parseColor(n.context.config.background);r=n.context.config.background?_e(Number(a.r)/255*Number(a.alpha),Number(a.g)/255*Number(a.alpha),Number(a.b)/255*Number(a.alpha),Number(a.alpha)):Re}var s={backbufferWidth:i.width,backbufferHeight:i.height,antialiasingMode:di.None},l=Ri(bn.Color0,s,fi(r)),u=Ri(bn.DepthStencil,s,hi),c=n.builder.createRenderTargetID(l,"Main Color"),f=n.builder.createRenderTargetID(u,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(bn.Color0,c),e.attachRenderTargetID(bn.DepthStencil,f),e.exec((function(e){n.renderLists.world.drawOnPassRenderer(o.renderCache,e)}))})),(null===(e=n.options)||void 0===e?void 0:e.enableFXAA)&&Mi(n.builder,n.renderHelper,s,c),n.builder.resolveRenderTargetToExternalTexture(c,n.swapChain.getOnscreenTexture())})),o.hooks.endFrame.tap(e.tag,(function(){var e=n.renderHelper.renderInstManager,t=n.renderHelper.pushTemplateRenderInst();t.setBindingLayout({numUniformBuffers:2,numSamplers:0}),t.setMegaStateFlags(Fe({depthWrite:!0,blendConstant:he},{rgbBlendMode:F.ADD,alphaBlendMode:F.ADD,rgbBlendSrcFactor:L.SRC_ALPHA,alphaBlendSrcFactor:L.ONE,rgbBlendDstFactor:L.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:L.ONE_MINUS_SRC_ALPHA}));var r=n.context.config,i=r.width,o=r.height,a=n.context.camera;if(t.setUniforms(0,[{name:xi.PROJECTION_MATRIX,value:a.getPerspective()},{name:xi.VIEW_MATRIX,value:a.getViewTransform()},{name:xi.CAMERA_POSITION,value:a.getPosition()},{name:xi.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:xi.VIEWPORT,value:[i,o]},{name:xi.IS_ORTHO,value:a.isOrtho()?1:0},{name:xi.IS_PICKING,value:0}]),n.batchManager.render(n.renderLists.world),e.popTemplateRenderInst(),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),e.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var s=n.captureOptions,l=s.type,u=s.encoderOptions,c=n.context.contextService.getDomElement().toDataURL(l,u);n.resolveCapturePromise(c),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))},e.prototype.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){var t=this;return s(this,(function(r){return this.enableCapture=!0,this.captureOptions=e,this.capturePromise=new Promise((function(e){t.resolveCapturePromise=function(t){e(t)}})),[2,this.capturePromise]}))}))},e.tag="RenderGraph",e}(),Li=function(){function e(e,t,r,n){this.renderHelper=e,this.renderGraphPlugin=t,this.pickingIdGenerator=r,this.batchManager=n}return e.prototype.apply=function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,l=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new En);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},u=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,l),o.addEventListener(t.ElementEvent.UNMOUNTED,u)})),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,l),o.removeEventListener(t.ElementEvent.UNMOUNTED,u),n.pickingIdGenerator.reset()})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,(function(e){return a(n,void 0,void 0,(function(){return s(this,(function(t){return[2,this.pick(e)]}))}))}))},e.prototype.pick=function(e){var r=e.topmost,n=e.position,i=n.viewportX,o=n.viewportY,a=this.context.contextService.getDPR(),s=this.context.config.width*a,l=this.context.config.height*a,u=i*a,c=o*a;if(!this.renderHelper.renderGraph||u>s||0>u||c>l||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(N(Math.round(u),0,s-1),N(Math.round(c),0,l-1),1,1),r?1:100);return e.picked=f,e},e.prototype.pickByRectangleInDepth=function(e,t){void 0===t&&(t=100);var r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i},e.prototype.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},e.prototype.pickByRectangle=function(e,t){var r,n=this,o=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,l=this.renderHelper.renderGraph.newGraphBuilder(),u=this.context.camera,c=e.x,f=e.y,d=e.width,p=e.height,_={backbufferWidth:d,backbufferHeight:p,antialiasingMode:di.None},h=Ri(bn.Color0,_,fi(he)),E=l.createRenderTargetID(h,"Picking Color"),R=Ri(bn.DepthStencil,_,hi),T=l.createRenderTargetID(R,"Picking Depth"),v=i({},u.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),l.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(bn.Color0,E),e.attachRenderTargetID(bn.DepthStencil,T),e.exec((function(e){a.picking.drawOnPassRenderer(s.renderCache,e)})),e.post((function(e){var t=e.getRenderTargetTexture(bn.Color0),i=o.createReadback();v&&v.enabled?u.setViewOffset(v.fullWidth,v.fullHeight,v.offsetX,v.offsetY,v.width,v.height):u.clearViewOffset(),u.setEnableUpdate(!0);var a=i.readTextureSync(t,0,0,d,p,new Uint8Array(d*p*4)),s=-1;if(!a||0===a[0]&&0===a[1]&&0===a[2]||(s=n.pickingIdGenerator.decodePickingColor(a)),s>-1){var l=n.pickingIdGenerator.getById(s);l&&l.isVisible()&&l.isInteractive()&&(r=l)}i.destroy()}))}));var A=this.renderHelper.pushTemplateRenderInst();A.setBindingLayout({numUniformBuffers:2,numSamplers:0}),A.setMegaStateFlags(Fe({depthWrite:!0},{rgbBlendMode:F.ADD,rgbBlendSrcFactor:L.ONE,rgbBlendDstFactor:L.ZERO,alphaBlendMode:F.ADD,alphaBlendSrcFactor:L.ONE,alphaBlendDstFactor:L.ZERO}));var m=this.context.config,g=m.width,S=m.height,y=this.context.contextService.getDPR();return u.setEnableUpdate(!1),u.setViewOffset(g*y,S*y,c,f,d,p),A.setUniforms(0,[{name:xi.PROJECTION_MATRIX,value:u.getPerspective()},{name:xi.VIEW_MATRIX,value:u.getViewTransform()},{name:xi.CAMERA_POSITION,value:u.getPosition()},{name:xi.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:xi.VIEWPORT,value:[d,p]},{name:xi.IS_ORTHO,value:u.isOrtho()?1:0},{name:xi.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r},e.tag="WebGLPicker",e}(),Fi=5e-4,bi=function(){function e(){this.clipPathMeshCreated=!1}return e.prototype.beforeUploadUBO=function(e,t){},e.prototype.beforeInitMesh=function(e){},e.prototype.afterInitMesh=function(e){},e}();!function(e){e.CHANGED="changed"}(Bi||(Bi={}));var Ui=function(e){function t(t,r){var n=e.call(this)||this;n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var o=xe(De),a=o.cullMode,s=o.depthCompare,l=o.depthWrite,u=o.stencilFront,c=o.stencilBack,f=o.stencilWrite,d=o.frontFace,p=o.polygonOffset,_=o.attachmentsState;return n.device=t,n.props=i({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:l,stencilFront:u,stencilBack:c,stencilWrite:f,frontFace:d,polygonOffset:p,attachmentsState:_,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return n(t,e),Object.defineProperty(t.prototype,"cullMode",{get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frontFace",{get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendConstant",{get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquation",{get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquationAlpha",{get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrc",{get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDst",{get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrcAlpha",{get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDstAlpha",{get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthCompare",{get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTest",{get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthWrite",{get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilFront",{get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilBack",{get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilWrite",{get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilRef",{get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"polygonOffset",{get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dithering",{get:function(){return this.props.dithering},set:function(e){this.props.dithering=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeColor",{get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeLineWidth",{get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShader",{get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())},enumerable:!1,configurable:!0}),t.prototype.compile=function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().split("\n").forEach((function(e){var t=u(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,n){return n.trim().split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var l=function(e){s.uniforms.forEach((function(r){t.push("".concat(o,"[").concat(e,"].").concat(r.name))}))},u=0;5>u;u++)l(u);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}(this.props.fragmentShader)},t.prototype.setUniforms=function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(W.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),g(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()},t.prototype.dispatchMutationEvent=function(){this.emit(Bi.CHANGED)},t}(re),Gi=function(e){function t(t,r){var n=e.call(this,t,i({},r))||this;return n.defines=i(i({},n.defines),{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return n(t,e),t}(Ui);function wi(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function ki(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Vi=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=u(e,2);return void 0!==t[1]})))};function Xi(e,t){return 256*(e=N(Math.floor(e),0,255))+(t=N(Math.floor(t),0,255))}var Wi,Hi,Yi=1,zi="FillTextureMapping";!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX"}(Wi||(Wi={})),function(e){e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX"}(Hi||(Hi={}));var Ki,ji,Zi=function(){function e(e,t,r,n,i,o,a){void 0===o&&(o=-1),this.renderHelper=e,this.texturePool=t,this.lightPool=r,this.drawcallCtors=i,this.index=o,this.context=a,this.id=Yi++,this.gradientAttributeName="fill",this.objects=[],this.program=new mn,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeAnchorIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1}return Object.defineProperty(e.prototype,"instance",{get:function(){return this.objects[0]},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new Gi(this.context.device),this.material.defines=i(i({},wi(Hi)),this.material.defines),this.geometry=new Pi(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},e.prototype.observeGeometryChanged=function(){var e=this;this.geometry.on(gi.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.observeMaterialChanged=function(){var e=this;this.material.on(Bi.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.shouldMergeColor=function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return!(!t.isCSSRGB(i)||!t.isCSSRGB(o))||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n]))},e.prototype.shouldMerge=function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))},e.prototype.createGeometry=function(e){var r=this,n=d(),i=d(),o=[],a=[],s=[],l=[],f=this.divisor;e.forEach((function(e){var f,d=e.parsedStyle,_=d.fill,h=d.stroke,R=d.opacity,A=d.fillOpacity,m=d.strokeOpacity,g=d.lineWidth,S=d.anchor,y=d.visibility,C=d.increasedLineWidthForHitTesting,N=[0,0,0,0];t.isCSSRGB(_)&&(N=[Number(_.r),Number(_.g),Number(_.b),255*Number(_.alpha)]);var P=[0,0,0,0];t.isCSSRGB(h)&&(P=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),T(i,r.context.camera.getViewTransform(),n);var I=e.isInteractive()&&(null===(f=e.renderable3D)||void 0===f?void 0:f.encodedPickingColor)||[0,0,0];if(r.mergeAnchorIntoModelMatrix){var O=e.parsedStyle.anchor,M=0,x=0,B=0,D=e.getGeometryBounds();if(D){var L=D.halfExtents;M=-L[0]*O[0]*2,x=-L[1]*O[1]*2,B=-L[2]*(O[2]||0)*2}T(n,e.getWorldTransform(),E(n,v(M,x,B)))}else p(n,e.getWorldTransform());o.push.apply(o,c([],u(n),!1)),a.push(Xi(N[0],N[1]),Xi(N[2],N[3]),Xi(P[0],P[1]),Xi(P[2],P[3])),s.push(R,A,m,g,"visible"===y?1:0,S[0],S[1],C||0),l.push.apply(l,c(c([],u(I),!1),[e.sortable.renderOrder*Fi],!1))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Wi.MODEL_MATRIX,byteStride:64,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.MODEL_MATRIX0,divisor:f},{format:te.F32_RGBA,bufferByteOffset:16,location:Hi.MODEL_MATRIX1,divisor:f},{format:te.F32_RGBA,bufferByteOffset:32,location:Hi.MODEL_MATRIX2,divisor:f},{format:te.F32_RGBA,bufferByteOffset:48,location:Hi.MODEL_MATRIX3,divisor:f}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Wi.PACKED_COLOR,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.PACKED_COLOR,divisor:f}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Wi.PACKED_STYLE,byteStride:32,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.PACKED_STYLE1,divisor:f},{format:te.F32_RGBA,bufferByteOffset:16,location:Hi.PACKED_STYLE2,divisor:f}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Wi.PICKING_COLOR,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.PICKING_COLOR,divisor:f}],data:new Float32Array(l)})},e.prototype.destroy=function(){this.geometry&&this.geometry.destroy()},e.prototype.applyRenderInst=function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:x.ALWAYS,passOp:K.REPLACE},this.material.stencilBack={compare:x.ALWAYS,passOp:K.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:x.EQUAL,passOp:K.KEEP},this.material.stencilBack={compare:x.EQUAL,passOp:K.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var o=i({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=i(i(i({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort((function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new vi;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:b.CLAMP_TO_EDGE,addressModeV:b.CLAMP_TO_EDGE,minFilter:U.POINT,magFilter:U.BILINEAR,mipmapFilter:G.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!ki(o,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=i(i({},this.material.defines),wi(Hi)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),l=this.renderHelper.getCache().createInputLayout(i(i({},this.geometry.inputLayoutDescriptor),{program:s})),u=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(l,this.geometry.vertexBuffers.filter((function(e){return!!e})).map((function(e){return{buffer:e,byteOffset:0}})),u?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),u?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=Zn(Gn.OPAQUE,t[0].sortable.renderOrder)},e.prototype.updateBatchedAttribute=function(e,r,n,i){var o=this;if(0!==e.length){if("fill"===n||"stroke"===n){var a=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=[0,0,0,0];t.isCSSRGB(n)&&(o=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var s=[0,0,0,0];t.isCSSRGB(i)&&(s=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),a.push(Xi(o[0],o[1]),Xi(o[2],o[3]),Xi(s[0],s[1]),Xi(s[2],s[3]))})),this.geometry.updateVertexBuffer(Wi.PACKED_COLOR,Hi.PACKED_COLOR,r,new Uint8Array(new Float32Array(a).buffer));var s=this.instance.parsedStyle.fill,l=this.textureMappings.findIndex((function(e){return e.name===zi}));if(t.isCSSRGB(s))0>l||(this.textureMappings.splice(l,-1),this.material.textureDirty=!0);else{var f=this.createFillGradientTextureMapping([this.instance]);0>l||this.textureMappings.splice(l,1,f),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var _=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor;_.push(t.opacity,t.fillOpacity,t.strokeOpacity,t.lineWidth,"visible"===t.visibility?1:0,r[0],r[1],t.increasedLineWidthForHitTesting||0)})),this.geometry.updateVertexBuffer(Wi.PACKED_STYLE,Hi.PACKED_STYLE1,r,new Uint8Array(new Float32Array(_).buffer))}else if("modelMatrix"===n){var h=[],R=d();e.forEach((function(e){if(o.mergeAnchorIntoModelMatrix){var t=e.parsedStyle.anchor,r=0,n=0,i=0,a=e.getGeometryBounds();if(a){var s=a.halfExtents;r=-s[0]*t[0]*2,n=-s[1]*t[1]*2,i=-s[2]*(t[2]||0)*2}T(R,e.getWorldTransform(),E(R,v(r,n,i)))}else p(R,e.getWorldTransform());h.push.apply(h,c([],u(R),!1))})),this.geometry.updateVertexBuffer(Wi.MODEL_MATRIX,Hi.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(h).buffer))}else if("pointerEvents"===n){var A=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];A.push.apply(A,c(c([],u(r),!1),[e.sortable.renderOrder*Fi],!1))})),this.geometry.updateVertexBuffer(Wi.PICKING_COLOR,Hi.PICKING_COLOR,r,new Uint8Array(new Float32Array(A).buffer))}}},e.prototype.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)},e.prototype.changeRenderOrder=function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Wi.PICKING_COLOR,Hi.PICKING_COLOR,n,new Uint8Array(new Float32Array(c(c([],u(i),!1),[t*Fi],!1)).buffer))},e.prototype.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Wi.PICKING_COLOR;e.vertexBuffers.length>i;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride;e.vertices[i]=new Float32Array(o/4*r)}var a=0,s=new Uint32Array(r);for(i=0;r>i;i++){for(var l=t[i],u=1;e.vertices.length>u;u++)for(var c=(o=e.inputLayoutDescriptor.vertexBufferDescriptors[u].arrayStride)/4,f=0;c>f;f++)e.vertices[u][a*c+f]=n[u][l*c+f];s[i]=a,a++}for(i=Wi.PICKING_COLOR+1;e.vertexBuffers.length>i;i++){var d=e.inputLayoutDescriptor.vertexBufferDescriptors[i],p=(o=d.arrayStride,e.inputLayoutDescriptor.vertexBufferDescriptors[i].attributes[0]);if(p)e.setVertexBuffer({bufferIndex:i,byteStride:o,stepMode:d.stepMode,attributes:[{format:p.format,bufferByteOffset:p.offset,location:p.shaderLocation,divisor:p.divisor}],data:e.vertices[i]})}var _=new Float32Array(3*r);for(i=0;r>i;)for(u=0;3>u;u++){_[3*(l=s[i++])+u]=1}e.setVertexBuffer({bufferIndex:Wi.BARYCENTRIC,byteStride:12,stepMode:X.VERTEX,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:Number(Hi.BARYCENTRIC)}],data:_}),e.setIndexBuffer(s)},e.prototype.beforeUploadUBO=function(e,t){},e.prototype.uploadUBO=function(e){var r,n=this,o=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),l=!!s,u=null!==(r=o.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(o.defines.USE_WIREFRAME){var f=t.parseColor(o.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:o.wireframeLineWidth})}if(l&&this.uploadFog(c,s),this.uploadMaterial(c,o),u){var d={};a.forEach((function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])}))}c.sort((function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,c);var p=o.blendEquation,_=o.blendEquationAlpha,h=o.blendSrc,E=o.blendDst,R=o.blendSrcAlpha,T=o.blendDstAlpha,v=Vi({blendConstant:o.blendConstant,depthCompare:o.depthCompare,depthWrite:o.depthWrite,stencilFront:o.stencilFront,stencilBack:o.stencilBack,stencilWrite:o.stencilWrite,stencilRef:o.stencilRef,cullMode:o.cullMode,frontFace:o.frontFace,polygonOffset:o.polygonOffset}),A=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(i({attachmentsState:[{channelWriteMask:this.material.stencilWrite?z.NONE:z.ALL,rgbBlendState:i(i({},A.rgbBlendState),Vi({blendMode:p,blendSrcFactor:h,blendDstFactor:E})),alphaBlendState:i(i({},A.alphaBlendState),Vi({blendMode:_,blendSrcFactor:R,blendDstFactor:T}))}]},v)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},e.prototype.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,l=n.density;if(t.isCSSRGB(o)){var u=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,l]}),e.push({name:"u_FogColor",value:u})}},e.prototype.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,c([],u(r),!1))},e.prototype.createFillGradientTextureMapping=function(e){var r,n=this,i=e[0],o=i.parsedStyle[this.gradientAttributeName];if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,ne(te.U8_RGBA_NORM,1,1,1));if(a){var s=new vi;return s.name=zi,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:b.CLAMP_TO_EDGE,addressModeV:b.CLAMP_TO_EDGE,minFilter:U.POINT,magFilter:U.BILINEAR,mipmapFilter:G.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null},e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(Ki||(Ki={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.SIZE=13]="SIZE"}(ji||(ji={}));var qi=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],Qi=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),wi(ji))},r.prototype.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[];t.forEach((function(e,t){var i=e,o=i.parsedStyle.radius,a=r.shouldOmitStroke(i.parsedStyle),s=r.getSize(e.parsedStyle,i.nodeName);n.push.apply(n,c(c([],u(s),!1),[i.parsedStyle.isBillboard?1:0,i.parsedStyle.isSizeAttenuation?1:0,qi.indexOf(i.nodeName),o&&o[0]||0,a?1:0],!1))})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:16,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.POSITION},{format:te.F32_RG,bufferByteOffset:8,location:Hi.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:Ki.PACKED_STYLE,byteStride:28,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:ji.SIZE,divisor:1},{format:te.F32_RGB,bufferByteOffset:16,location:ji.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var a=[];t.forEach((function(e){var t=e,r=o.shouldOmitStroke(t.parsedStyle),n=u(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,c(c([],u([n[0],n[1]]),!1),[t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,qi.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0],!1))})),this.geometry.updateVertexBuffer(Ki.PACKED_STYLE,ji.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}},r.prototype.getSize=function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n},r.prototype.shouldOmitStroke=function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(o||1>n)},r}(Zi),$i=10,Ji=8,eo=100;function to(e,t,r,n,i,o){for(var a=i[i.length-3],s=i[i.length-3],l=null!=o?o:N(hn(a,s,e,t,r,n,3)/$i,Ji,eo),u=0,c=0,f=1;l>=f;++f){var d=f/l;i.push((u=a+(e-a)*d)+(e+(r-e)*d-u)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function ro(e,t,r,n,i,o,a,s){var l=a[a.length-3],u=a[a.length-2];a.length-=3;var c=null!=s?s:N(pn(l,u,e,t,r,n,i,o,3)/$i,Ji,eo),f=0,d=0,p=0,_=0,h=0;a.push(l,u,0);for(var E=1,R=0;c>=E;++E)a.push((p=(d=(f=1-(R=E/c))*f)*f)*l+3*d*R*e+3*f*(_=R*R)*r+(h=_*R)*i,p*u+3*d*R*t+3*f*_*n+h*o,0)}var no,io,oo=1e20,ao=function(){function e(e,t){var r=e.fontSize,n=void 0===r?24:r,i=e.buffer,o=void 0===i?3:i,a=e.radius,s=void 0===a?8:a,l=e.cutoff,u=void 0===l?.25:l,c=e.fontFamily,f=void 0===c?"sans-serif":c,d=e.fontWeight,p=void 0===d?"normal":d,_=e.fontStyle,h=void 0===_?"normal":_,E=e.canvas;this.buffer=o,this.cutoff=u,this.radius=s;var R=this.size=n+4*o,T=t.offscreenCanvasCreator.getOrCreateCanvas(E);T.width=R,T.height=R;var v=t.offscreenCanvasCreator.getOrCreateContext(E,{willReadFrequently:!0});this.ctx=v,v.font="".concat(h," ").concat(p," ").concat(n,"px ").concat(f),v.textBaseline="alphabetic",v.textAlign="left",v.fillStyle="black",this.gridOuter=new Float64Array(R*R),this.gridInner=new Float64Array(R*R),this.f=new Float64Array(R),this.z=new Float64Array(R+1),this.v=new Uint16Array(R)}return e.prototype.draw=function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,a=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=s+2*this.buffer,c=l+2*this.buffer,f=Math.max(u*c,0),d=new Uint8ClampedArray(f),p={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:r};if(0===s||0===l)return p;var _=this,h=_.ctx,E=_.buffer,R=_.gridInner,T=_.gridOuter;h.clearRect(E,E,s,l),h.fillText(e,E,E+a);var v=h.getImageData(E,E,s,l);T.fill(oo,0,f),R.fill(0,0,f);for(var A=0;l>A;A++)for(var m=0;s>m;m++){var g=v.data[4*(A*s+m)+3]/255;if(0!==g){var S=(A+E)*u+m+E;if(1===g)T[S]=0,R[S]=oo;else T[S]=(C=.5-g)>0?C*C:0,R[S]=0>C?C*C:0}}so(T,0,0,u,c,u,this.f,this.v,this.z),so(R,E,E,s,l,u,this.f,this.v,this.z);for(var y=0;f>y;y++){var C;d[y]=Math.round(255-255*((C=Math.sqrt(T[y])-Math.sqrt(R[y]))/this.radius+this.cutoff))}return p},e}();function so(e,t,r,n,i,o,a,s,l){for(var u=t;t+n>u;u++)lo(e,r*o+u,o,i,a,s,l);for(var c=r;r+i>c;c++)lo(e,c*o+t,1,n,a,s,l)}function lo(e,t,r,n,i,o,a){o[0]=0,a[0]=-oo,a[1]=oo,i[0]=e[t];for(var s=1,l=0,u=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{u=(i[s]-i[f=o[l]]+c-f*f)/(s-f)/2}while(a[l]>=u&&--l>-1);o[++l]=s,a[l]=u,a[l+1]=oo}for(s=0,l=0;n>s;s++){for(;s>a[l+1];)l++;var f,d=s-(f=o[l]);e[t+s*r]=i[f]+d*d}}!function(e){e[e.PACKED=5]="PACKED",e[e.VERTEX_NUM=6]="VERTEX_NUM",e[e.TRAVEL=7]="TRAVEL",e[e.DASH=8]="DASH"}(no||(no={})),function(e){e[e.PREV=8]="PREV",e[e.POINT1=9]="POINT1",e[e.POINT2=10]="POINT2",e[e.NEXT=11]="NEXT",e[e.VERTEX_JOINT=12]="VERTEX_JOINT",e[e.VERTEX_NUM=13]="VERTEX_NUM",e[e.TRAVEL=14]="TRAVEL",e[e.DASH=15]="DASH"}(io||(io={}));function uo(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function co(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!g(r[0][2])}var fo,po=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.mergeAnchorIntoModelMatrix=!0,l.segmentNum=-1,l.segmentNum=l.calcSegmentNum(i),l.gradientAttributeName="stroke",l}return n(r,e),r.calcSubpathNum=function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.path.absolutePath.filter((function(e){return"M"===e[0]})).length:1},r.prototype.calcSegmentNum=function(e){return Eo(e,!1,12,this.calcSubpathIndex(e)).instancedCount},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===Ao})).length;return this.index-r}return 0},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.segmentNum===n},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),wi(io))},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=[],s=0,l=0;t.forEach((function(e){var t=Eo(e,!1,12,r.calcSubpathIndex(e)),f=t.pointsBuffer,d=t.travelBuffer,p=t.instancedCount,_=e.parsedStyle,h=_.lineDash;a.push(h&&h[0]||0,h&&h[1]||0,_.lineDashOffset||0,uo(_.isBillboard,_.isSizeAttenuation,co(e))),s+=p;for(var E=0;f.length-12>E;E+=4)i.push(f[E],f[E+1],f[E+2],f[E+3],f[E+4],f[E+5],f[E+6],f[E+7],f[E+8],f[E+9],f[E+10],f[E+11],f[E+12],f[E+13],f[E+14],f[E+15]);o.push.apply(o,c([],u(d),!1)),n.push(0+l,2+l,1+l,0+l,3+l,2+l,4+l,6+l,5+l,4+l,7+l,6+l,4+l,7+l,8+l),l+=9})),i.length&&(this.geometry.setVertexBuffer({bufferIndex:no.PACKED,byteStride:64,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:io.PREV,divisor:1},{format:te.F32_RGB,bufferByteOffset:16,location:io.POINT1,divisor:1},{format:te.F32_R,bufferByteOffset:28,location:io.VERTEX_JOINT,divisor:1},{format:te.F32_RGB,bufferByteOffset:32,location:io.POINT2,divisor:1},{format:te.F32_RGB,bufferByteOffset:48,location:io.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:no.VERTEX_NUM,byteStride:4,stepMode:X.INSTANCE,attributes:[{format:te.F32_R,bufferByteOffset:0,byteStride:4,location:io.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:no.TRAVEL,byteStride:4,stepMode:X.INSTANCE,attributes:[{format:te.F32_R,bufferByteOffset:0,byteStride:4,location:io.TRAVEL,divisor:1}],data:new Float32Array(o)}),this.divisor=s/t.length,this.geometry.setVertexBuffer({bufferIndex:no.DASH,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:io.DASH,divisor:this.divisor}],data:new Float32Array(a)}),e.prototype.createGeometry.call(this,t),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var a=[],s=[],l=0;t.forEach((function(e){var t=Eo(e,!1,12,o.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;l=t.instancedCount;for(var i=0;r.length-12>i;i+=4)a.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,c([],u(n),!1))})),this.geometry.updateVertexBuffer(no.PACKED,io.PREV,r*l,new Uint8Array(new Float32Array(a).buffer)),this.geometry.updateVertexBuffer(no.TRAVEL,io.TRAVEL,r,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var f=[];t.forEach((function(e){var t=e.parsedStyle,r=t.lineDash;f.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,uo(t.isBillboard,t.isSizeAttenuation,co(e)))})),this.geometry.updateVertexBuffer(no.DASH,io.DASH,r,new Uint8Array(new Float32Array(f).buffer))}},r}(Zi);!function(e){e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2"}(fo||(fo={}));var _o=3,ho=4;function Eo(e,r,n,i){var o;void 0===r&&(r=!1),void 0===i&&(i=0);var a=e.parsedStyle,s=a.lineCap,l=a.lineJoin,f=e.sortable.renderOrder*Fi,p=e.parsedStyle,_=p.defX,E=p.defY,R=e.parsedStyle,T=R.markerStart,v=R.markerEnd,A=R.markerStartOffset,g=R.markerEndOffset,S=[],y=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var C=e.parsedStyle.points.points,N=C.length,P=0,I=0,O=0,M=0,x=0;T&&t.isDisplayObject(T)&&A&&(P=Math.cos(x=Math.atan2(C[1][1]-C[0][1],C[1][0]-C[0][0]))*(A||0),I=Math.sin(x)*(A||0)),v&&t.isDisplayObject(v)&&g&&(O=Math.cos(x=Math.atan2(C[N-2][1]-C[N-1][1],C[N-2][0]-C[N-1][0]))*(g||0),M=Math.sin(x)*(g||0));var B=e.nodeName===t.Shape.POLYLINE;if(S[0]=C.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=P,i=I):r===N-1&&(n=O,i=M),e.push(t[0]-_+n,t[1]-E+i,B?t[2]||0:f),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return y=un(S[0],[],3),{pointsBuffer:S[0],travelBuffer:[],triangles:y,instancedCount:Math.round(S[0].length/_o)};S[0].push(S[0][0],S[0][1],S[0][2]||f),(o=S[0]).push.apply(o,c([],u(Ro(S[0][0],S[0][1],S[0][2]||f,S[0][3],S[0][4],S[0][5]||f)),!1))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var D=void 0;if(e.nodeName!==t.Shape.PATH){if(D=t.parsePath(t.convertToPath(e,h(d()))),_=D.rect.x,E=D.rect.y,e.nodeName===t.Shape.RECT){var L=e.parsedStyle;0>L.width&&(_+=D.rect.width),0>L.height&&(E+=D.rect.height)}}else D=e.parsedStyle.path;var F=D.absolutePath,b=D.segments,U=0,G=0,w=0,k=0;x=0;if(T&&T.parentNode&&t.isDisplayObject(T)&&A){var V=u(T.parentNode.getStartTangent(),2);U=Math.cos(x=Math.atan2((X=V[0])[1]-(W=V[1])[1],X[0]-W[0]))*(A||0),G=Math.sin(x)*(A||0)}if(v&&v.parentNode&&t.isDisplayObject(v)&&g){var X,W,H=u(v.parentNode.getEndTangent(),2);w=Math.cos(x=Math.atan2((X=H[0])[1]-(W=H[1])[1],X[0]-W[0]))*(g||0),k=Math.sin(x)*(g||0)}var Y=-1,z=-1;if(F.forEach((function(r,i){var o,a=u(r),s=a[0],l=a.slice(1),d=F[i+1],p=0===i&&(0!==U||0!==G),h=(i===F.length-1||d&&("M"===d[0]||"Z"===d[0]))&&0!==w&&0!==k;if("M"===s)z++,S[z]=[],Y=S[z].length,p?S[z].push(l[0]-_+U,l[1]-E+G,f,l[0]-_,l[1]-E,f):S[z].push(l[0]-_,l[1]-E,f);else if("L"===s)h?S[z].push(l[0]-_+w,l[1]-E+k,f):S[z].push(l[0]-_,l[1]-E,f);else if("Q"===s)to(l[0]-_,l[1]-E,l[2]-_,l[3]-E,S[z],n),h&&S[z].push(l[2]-_+w,l[3]-E+k,f);else if("A"===s){for(var R=u(b[i].prePoint,2),T=m(R[0],R[1],l[0],l[1],l[2],l[3],l[4],l[5],l[6],void 0),v=0;T.length>v;v+=6)ro(T[v]-_,T[v+1]-E,T[v+2]-_,T[v+3]-E,T[v+4]-_,T[v+5]-E,S[z],n);h&&S[z].push(l[5]-_+w,l[6]-E+k,f)}else if("C"===s)ro(l[0]-_,l[1]-E,l[2]-_,l[3]-E,l[4]-_,l[5]-E,S[z],n),h&&S[z].push(l[4]-_+w,l[5]-E+k,f);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var A=1e-4;(Math.abs(S[z][S[z].length-2]-S[z][Y])>A||Math.abs(S[z][S[z].length-1]-S[z][Y+1])>A)&&S[z].push(S[z][Y],S[z][Y+1],f),(o=S[z]).push.apply(o,c([],u(Ro(S[z][Y],S[z][Y+1],S[z][Y+2],S[z][Y+3],S[z][Y+4],S[z][Y+5])),!1))}})),r)return{pointsBuffer:J=S[i],travelBuffer:[],triangles:y=un(J,[],3),instancedCount:Math.round(J.length/_o)}}var K=function(e){var t;switch(e){case"bevel":t=fo.JOINT_BEVEL;break;case"round":t=fo.JOINT_ROUND;break;default:t=fo.JOINT_MITER}return t}(l),j=function(e){var t;switch(e){case"square":t=fo.CAP_SQUARE;break;case"round":t=fo.CAP_ROUND;break;default:t=fo.CAP_BUTT}return t}(s),Z=j;j===fo.CAP_ROUND&&(Z=fo.JOINT_CAP_ROUND),j===fo.CAP_BUTT&&(Z=fo.JOINT_CAP_BUTT),j===fo.CAP_SQUARE&&(Z=fo.JOINT_CAP_SQUARE);for(var q=S[i],Q=(Math.round(0/_o)+2)*ho,$=0,J=[],ee=[],te=0;q.length>te;te+=_o)te>1&&($+=Math.sqrt(Math.pow(q[te]-q[te-_o],2)+Math.pow(q[te+1]-q[te+1-_o],2)+Math.pow(q[te+2]-q[te+2-_o],2))),ee.push($),J[Q++]=q[te],J[Q++]=q[te+1],J[Q++]=q[te+2]||0,J[Q]=K,0==te&&j!==fo.CAP_ROUND&&(J[Q]+=j),q.length>te+2*_o?q.length>te+_o||(J[Q]=0):J[Q]+=Z-K,Q++;return J[Q++]=q[q.length-6],J[Q++]=q[q.length-5],J[Q++]=q[q.length-4]||f,J[Q++]=0,J[0]=q[0],J[1]=q[1],J[2]=q[2]||f,J[3]=0,J[4]=q[3],J[5]=q[4],J[6]=q[5]||f,J[7]=j===fo.CAP_ROUND?j:0,{pointsBuffer:J,travelBuffer:ee,triangles:y,instancedCount:Math.round(q.length/_o)}}function Ro(e,t,r,n,i,o){void 0===n&&(n=e),void 0===i&&(i=t),void 0===o&&(o=r);var a=[n-e,i-t,o-r],s=.01;return[e+a[0]*s,t+a[1]*s,r+a[2]*s]}var To,vo,Ao=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.mergeAnchorIntoModelMatrix=!0,l.trianglesHash=[[],[]],l.trianglesHash=l.calcSegmentNum(i),l}return n(r,e),r.prototype.calcSegmentNum=function(e){var t=Eo(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]},r.prototype.calcSubpathIndex=function(e){return e.nodeName===t.Shape.PATH?this.index:0},r.prototype.compareTrianglesHash=function(e){var t=u(this.trianglesHash,2),r=t[0],n=t[1],i=u(e,2),o=i[0],a=i[1];return r.length===o.length&&n.length===a.length&&(!r.some((function(e,t){return e!==o[t]}))&&!n.some((function(e,t){return e!==a[t]})))},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.compareTrianglesHash(n)},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=0;t.forEach((function(e,t){var s=Eo(e,!0,12,r.calcSubpathIndex(e)),l=s.triangles,f=s.pointsBuffer;if(l.length){var d=e.getGeometryBounds().halfExtents,p=[];f.forEach((function(e,t){t%3!=2&&p.push(e/d[t%3]/2)})),a+=i.length/3,i.push.apply(i,c([],u(f),!1)),o.push.apply(o,c([],u(p),!1)),n.push.apply(n,c([],u(l.map((function(e){return e+a}))),!1))}})),i.length&&(e.prototype.createGeometry.call(this,t),this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:12,stepMode:X.VERTEX,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:Hi.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Wi.UV,byteStride:8,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.UV}],data:new Float32Array(o)}),this.geometry.vertexCount=n.length/t.length,this.geometry.setIndexBuffer(new Uint32Array(n)))},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=i(i({},this.material.defines),{INSTANCED:!0})},r.prototype.updateAttribute=function(t,r,n,i){e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i)},r}(Zi),mo=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(To||(To={})),function(e){e[e.POSITION=8]="POSITION",e[e.UV=10]="UV",e[e.POINTA=9]="POINTA",e[e.POINTB=11]="POINTB",e[e.CAP=12]="CAP",e[e.DASH=13]="DASH"}(vo||(vo={}));var go,So,yo={butt:1,round:2,square:3},Co=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.gradientAttributeName="stroke",l}return n(r,e),r.isLine=function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.path.absolutePath,i=0,o=0,a=0;n.length>a;a++){if("M"===n[a][0]){if(i===r){o=a;break}i++}}if("M"===n[o][0]&&"L"===n[o+1][0]&&(void 0===n[o+2]||"M"===n[o+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){var s=e.parsedStyle.points.points,l=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]);for(a=1;s.length-1>a;a++)if((s[a+1][0]-s[a+1][1])/(s[a][0]-s[a][1])!==l)return!1;return!0}return!1},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * blur\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),wi(vo))},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===Ao})).length;return this.index-r}return 0},r.prototype.createGeometry=function(r){var n=this;e.prototype.createGeometry.call(this,r);var i=[],o=[],a=[],s=[],l=0;r.forEach((function(e){var r,u;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,u=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,defX:c.defX,defY:c.defY,lineCap:c.lineCap,lineDash:R=c.lineDash,lineDashOffset:T=c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:v=c.markerStart,markerEnd:A=c.markerEnd,markerStartOffset:m=c.markerStartOffset,markerEndOffset:g=c.markerEndOffset},u=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,p=d.path.absolutePath,_=d.defX,h=d.defY,E=d.lineCap,R=d.lineDash,T=d.lineDashOffset,v=d.markerStart,A=d.markerEnd,m=d.markerStartOffset,g=d.markerEndOffset,S=d.isBillboard,y=d.isSizeAttenuation,C=0,N=0,P=n.calcSubpathIndex(e),I=0;p.length>I;I++){if("M"===p[I][0]){if(C===P){N=I;break}C++}}r={x1:p[N][1],y1:p[N][2],x2:p[N+1][1],y2:p[N+1][2],z1:0,z2:0,defX:_,defY:h,lineCap:E,lineDash:R,lineDashOffset:T,isBillboard:S,isSizeAttenuation:y,markerStart:v,markerEnd:A,markerStartOffset:m,markerEndOffset:g},u=e.getTotalLength()}var O=r.x1,M=r.y1,x=r.x2,B=r.y2,D=r.z1,L=r.z2,F=r.defX,b=r.defY,U=r.lineCap,G=r.isBillboard,w=r.isSizeAttenuation,k=n.calcOffset(r),V=k.startOffsetX,X=k.startOffsetY,W=k.endOffsetX,H=k.endOffsetY,Y=n.calcDash(r,u),z=Y.dashOffset,K=Y.dashSegmentPercent,j=Y.dashRatioInEachSegment;o.push(yo[U]),a.push(z,K,j,G||w?1:0),i.push(O-F+V,M-b+X,D,x-F+W,B-b+H,L),s.push(0+l,2+l,1+l,0+l,3+l,2+l),l+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:20,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:vo.POSITION,divisor:0},{format:te.F32_RG,bufferByteOffset:12,location:vo.UV,divisor:0}],data:new Float32Array(mo)}),this.geometry.setVertexBuffer({bufferIndex:To.POINT,byteStride:24,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:vo.POINTA,divisor:1},{format:te.F32_RGB,bufferByteOffset:12,location:vo.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:To.CAP,byteStride:4,stepMode:X.INSTANCE,attributes:[{format:te.F32_R,bufferByteOffset:0,location:vo.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:To.DASH,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:vo.DASH,divisor:1}],data:new Float32Array(a)})},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(e.prototype.updateAttribute.call(this,r,n,i,o),this.updateBatchedAttribute(r,n,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"path"===i){var s=[];r.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,defX:n.defX,defY:n.defY,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var o=e.parsedStyle,l=o.path.absolutePath;r={x1:l[0][1],y1:l[0][2],x2:l[1][1],y2:l[1][2],z1:0,z2:0,defX:o.defX,defY:o.defY,lineCap:o.lineCap,isBillboard:o.isBillboard,isSizeAttenuation:o.isSizeAttenuation,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var u=r.x1,c=r.y1,f=r.x2,d=r.y2,p=r.z1,_=r.z2,h=r.defX,E=r.defY,R=a.calcOffset(r);s.push(u-h+R.startOffsetX,c-E+R.startOffsetY,p,f-h+R.endOffsetX,d-E+R.endOffsetY,_)})),this.geometry.updateVertexBuffer(To.POINT,vo.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var l=[];r.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);l.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)})),this.geometry.updateVertexBuffer(To.DASH,vo.DASH,n,new Uint8Array(new Float32Array(l).buffer))}else if("lineCap"===i){var u=[];r.forEach((function(e){u.push(yo[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(To.CAP,vo.CAP,n,new Uint8Array(new Float32Array(u).buffer))}},r.prototype.calcOffset=function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,l=e.markerStartOffset,u=e.markerEndOffset,c=0,f=0,d=0,p=0,_=0;return a&&t.isDisplayObject(a)&&l&&(c=Math.cos(_=Math.atan2(o-n,i-r))*(l||0),f=Math.sin(_)*(l||0)),s&&t.isDisplayObject(s)&&u&&(d=Math.cos(_=Math.atan2(n-o,r-i))*(u||0),p=Math.sin(_)*(u||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:p}},r.prototype.calcDash=function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}},r}(Zi);!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(go||(go={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3"}(So||(So={}));var No=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&this.instance.parsedStyle.img===t.parsedStyle.img},t.prototype.createMaterial=function(e){var t=e[0].parsedStyle.img;this.material.defines=i(i({},this.material.defines),wi(So)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t);this.material.setUniforms({u_Map:r})},t.prototype.createGeometry=function(t){e.prototype.createGeometry.call(this,t);var r=[],n=[];t.forEach((function(e,t){var i=e.parsedStyle,o=i.isBillboard,a=i.billboardRotation,s=i.isSizeAttenuation;r.push(i.width,i.height),n.push(o?1:0,null!=a?a:0,s?1:0,0)})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:8,stepMode:X.INSTANCE,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:go.PACKED_STYLE,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:So.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:Wi.UV,byteStride:8,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})},t.prototype.updateAttribute=function(t,r,n,i){if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"width"===n||"height"===n||"z"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle;o.push(t.width,t.height)})),this.geometry.updateVertexBuffer(Wi.POSITION,Hi.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var a=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;a.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(go.PACKED_STYLE,So.PACKED_STYLE3,r,new Uint8Array(new Float32Array(a).buffer))}else if("img"===n){var s=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:s})}},t}(Zi);function Po(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function Io(e,t,r,n,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,s=t.data,l=0;i.height>l;l++)for(var u=((r.y+l)*e.width+r.x)*o,c=((n.y+l)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[u+f];return t}var Oo=function(){function e(e,t){Po(this,e,1,t)}return e.prototype.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Po({},{width:n,height:i},r);Io(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=o.data}}(this,e,1)},e.prototype.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){Io(e,t,r,n,i,1)},e}();var Mo=function(e){var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i)(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&(r.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:f,metrics:c.metrics})}var s=function(e){var t,r,n,i,o=0,a=0;try{for(var s=l(e),u=s.next();!u.done;u=s.next())o+=(h=u.value).w*h.h,a=Math.max(a,h.w)}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.sort((function(e,t){return t.h-e.h}));var c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(o/.95)),a),h:1/0}],f=0,d=0;try{for(var p=l(e),_=p.next();!_.done;_=p.next())for(var h=_.value,E=c.length-1;E>=0;E--){var R=c[E];if(R.w>=h.w&&R.h>=h.h){if(h.x=R.x,h.y=R.y,d=Math.max(d,h.y+h.h),f=Math.max(f,h.x+h.w),h.w===R.w&&h.h===R.h){var T=c.pop();c.length>E&&(c[E]=T)}else h.h===R.h?(R.x+=h.w,R.w-=h.w):h.w===R.w?(R.y+=h.h,R.h-=h.h):(c.push({x:R.x+h.w,y:R.y,w:R.w-h.w,h:h.h}),R.y+=h.h,R.h-=h.h);break}}}catch(e){n={error:e}}finally{try{_&&!_.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}return{w:f,h:d,fill:o/(f*d)||0}}(r),u=new Oo({width:s.w||1,height:s.h||1});for(var n in e)for(var a in i=e[n]){var c,f;(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&Oo.copy(c.bitmap,u,{x:0,y:0},{x:(f=t[n][a].rect).x+1,y:f.y+1},c.bitmap)}this.image=u,this.positions=t};var xo,Bo,Do,Lo=function(){function e(e){this.runtime=e,this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={}}return e.prototype.getMap=function(){return this.glyphMap},e.prototype.getAtlas=function(){return this.glyphAtlas},e.prototype.getAtlasTexture=function(){return this.glyphAtlasTexture},e.prototype.layout=function(e,t,r,n,i,o,a){var s=this,l=[],u=o,c=a,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=l.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),o=r&&r[n];o&&(l.push({glyph:n,x:u,y:c,scale:1,fontStack:t}),u+=o.metrics.advance+i)}));for(var o=u-i,a=n;l.length>a;a++)l[a].x=l[a].x-f*o;u=0,c+=r})),l},e.prototype.generateAtlas=function(e,t,r,n,o,a,s){var l=this;void 0===t&&(t=""),void 0===o&&(o="");var u=[];this.glyphMap[t]||(u=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(a.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&u.push(e)})),u.length){var f=u.map((function(i){return l.generateSDF(e,t,r,n,o,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=i(i({},this.glyphMap[t]),f),this.glyphAtlas=new Mo(this.glyphMap);var d=this.glyphAtlas.image,p=d.width,_=d.height,h=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=s.createTexture(i(i({},ne(te.ALPHA,p,_,1)),{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([h])}},e.prototype.generateSDF=function(e,t,r,n,i,o){void 0===t&&(t="");var a=o.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new ao({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][o]||(this.textMetricsCache[t][o]=s.ctx.measureText(o).width);var l=s.draw(o),u=l.glyphWidth,c=l.glyphHeight,f=l.glyphLeft,d=l.glyphTop,p=l.glyphAdvance;return{id:a,bitmap:new Oo({width:l.width,height:l.height},l.data),metrics:{width:u,height:c,left:f,top:d-24+3,advance:p}}},e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(xo||(xo={})),function(e){e[e.TEX=12]="TEX",e[e.OFFSET=13]="OFFSET"}(Bo||(Bo={})),function(e){e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke"}(Do||(Do={}));var Fo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.packedBufferObjectMap=new WeakMap,l.tmpMat4=d(),l.fontHash=l.calcFontHash(i),l.glyphManager=new Lo(l.context),l}return n(r,e),r.prototype.calcFontHash=function(e){return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce((function(t,r){return t+e.parsedStyle[r]}),"")},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&(this.index===r&&this.fontHash===this.calcFontHash(t))},r.prototype.createGeometry=function(e){var t=this,r=this.instance.parsedStyle,n=r.textBaseline,i=r.letterSpacing,o=24/r.fontSize,a=[],s=[],l=[],f=0;e.forEach((function(e){var r=e.parsedStyle,d=r.metrics,p=d.font,_=d.lines,h=d.height,E=d.lineHeight,R=r.dx||0,T=r.dy||0,v=0;"middle"===n?v=-h/2:"bottom"===n?v=-h:"top"===n||"hanging"===n?v=0:"alphabetic"===n?(v=.25*E-h,t.context.enableCSSParsing||(v=-h)):"ideographic"===n&&(v=-h);var A=t.glyphManager.getAtlas(),m=t.buildTextBuffers({object:e,lines:_,fontStack:p,lineHeight:o*E,offsetX:o*R,offsetY:o*(v+T),letterSpacing:o*i,glyphAtlas:A,indicesOffset:f}),g=m.indexBuffer,S=m.charUVOffsetBuffer;f=m.indicesOffset;var y=l.length;l.push.apply(l,c([],u(m.charPackedBuffer),!1)),t.packedBufferObjectMap.set(e,[y,l.length]),s.push.apply(s,c([],u(S),!1)),a.push.apply(a,c([],u(g),!1))})),this.geometry.vertexCount=a.length,this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.setVertexBuffer({bufferIndex:xo.INSTANCED,byteStride:128,stepMode:X.VERTEX,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.MODEL_MATRIX0},{format:te.F32_RGBA,bufferByteOffset:16,location:Hi.MODEL_MATRIX1},{format:te.F32_RGBA,bufferByteOffset:32,location:Hi.MODEL_MATRIX2},{format:te.F32_RGBA,bufferByteOffset:48,location:Hi.MODEL_MATRIX3},{format:te.F32_RGBA,bufferByteOffset:64,location:Hi.PACKED_COLOR},{format:te.F32_RGBA,bufferByteOffset:80,location:Hi.PACKED_STYLE1},{format:te.F32_RGBA,bufferByteOffset:96,location:Hi.PACKED_STYLE2},{format:te.F32_RGBA,bufferByteOffset:112,location:Hi.PICKING_COLOR}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:xo.TEX,byteStride:16,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Bo.TEX},{format:te.F32_RG,bufferByteOffset:8,location:Bo.OFFSET}],data:new Float32Array(s)})},r.prototype.createMaterial=function(e){var t;this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4((a_Offset) * fontScale + bufferOffset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=D.BACK,this.material.defines=i(i({},this.material.defines),wi(Bo));var r=this.instance.parsedStyle,n=r.fontSize,o=r.fontFamily,a=void 0===o?"":o,s=r.fontWeight,l=void 0===s?"":s,u=r.fontStyle,c=r.metrics.font,f=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,c,a,""+l,u,f,this.context.device);var d=this.glyphManager.getAtlasTexture(),p=this.glyphManager.getAtlas();this.context.device.setResourceName(d,"TextSDF Texture");var _=p.image,h=_.width,E=_.height;this.material.setUniforms(((t={})[Do.SDF_MAP]=d,t[Do.SDF_MAP_SIZE]=[h,E],t[Do.FONT_SIZE]=n,t[Do.GAMMA_SCALE]=1,t[Do.STROKE_BLUR]=.2,t[Do.HAS_STROKE]=this.index,t))},r.prototype.changeRenderOrder=function(e,t){for(var r=this.geometry.vertices[xo.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[xo.INSTANCED].arrayStride/4,i=u(this.packedBufferObjectMap.get(e),2),o=i[0],a=i[1],s=r.slice(o,a),l=0;a-o>l;l+=n)s[l+n-1]=t*Fi;this.geometry.updateVertexBuffer(xo.INSTANCED,Hi.MODEL_MATRIX0,o/n,new Uint8Array(s.buffer))},r.prototype.updateAttribute=function(e,r,n,i){var o=this;if("text"===n||"fontFamily"===n||"fontSize"===n||"fontWeight"===n||"fontStyle"===n||"fontVariant"===n||"textBaseline"===n||"letterSpacing"===n||"wordWrapWidth"===n||"lineHeight"===n||"wordWrap"===n||"textAlign"===n||"dx"===n||"dy"===n)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===n||"fill"===n||"fillOpacity"===n||"stroke"===n||"strokeOpacity"===n||"opacity"===n||"lineWidth"===n||"visibility"===n||"pointerEvents"===n||"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var a=this.geometry.vertices[xo.INSTANCED],s=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[xo.INSTANCED].arrayStride/4;e.forEach((function(e){var r,n=e.parsedStyle,i=n.fill,l=n.stroke,c=n.opacity,f=n.fillOpacity,d=n.strokeOpacity,_=n.lineWidth,h=n.visibility,E=n.isBillboard,R=n.billboardRotation,T=n.isSizeAttenuation,v=[0,0,0,0];t.isCSSRGB(i)&&(v=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var A=[0,0,0,0];t.isCSSRGB(l)&&(A=[Number(l.r),Number(l.g),Number(l.b),255*Number(l.alpha)]);for(var m=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],g=p(o.tmpMat4,e.getWorldTransform()),S=u(o.packedBufferObjectMap.get(e),2),y=S[0],C=S[1],N=a.slice(y,C),P=0;C-y>P;P+=s)N[P+0]=g[0],N[P+1]=g[1],N[P+2]=g[2],N[P+3]=g[3],N[P+4]=g[4],N[P+5]=g[5],N[P+6]=g[6],N[P+7]=g[7],N[P+8]=g[8],N[P+9]=g[9],N[P+10]=g[10],N[P+11]=g[11],N[P+12]=g[12],N[P+13]=g[13],N[P+14]=g[14],N[P+15]=g[15],N[P+16]=Xi(v[0],v[1]),N[P+17]=Xi(v[2],v[3]),N[P+18]=Xi(A[0],A[1]),N[P+19]=Xi(A[2],A[3]),N[P+20]=c,N[P+21]=f,N[P+22]=d,N[P+23]=_,N[P+24]="visible"===h?1:0,N[P+25]=E?1:0,N[P+26]=T?1:0,N[P+27]=null!=R?R:0,N[P+28]=m[0],N[P+29]=m[1],N[P+30]=m[2];o.geometry.updateVertexBuffer(xo.INSTANCED,Hi.MODEL_MATRIX0,y/s,new Uint8Array(N.buffer))}))}},r.prototype.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,l=e.offsetX,f=e.offsetY,d=e.glyphAtlas,_=e.indicesOffset,h=n.parsedStyle,E=h.textAlign,R=h.fill,T=h.stroke,v=h.opacity,A=h.fillOpacity,m=h.strokeOpacity,g=h.lineWidth,S=h.visibility,y=h.isBillboard,C=h.billboardRotation,N=h.isSizeAttenuation,P=[0,0,0,0];t.isCSSRGB(R)&&(P=[Number(R.r),Number(R.g),Number(R.b),255*Number(R.alpha)]);var I=[0,0,0,0];t.isCSSRGB(T)&&(I=[Number(T.r),Number(T.g),Number(T.b),255*Number(T.alpha)]);var O=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],M=p(this.tmpMat4,n.getWorldTransform()),x=[],B=[],D=[],L=_,F=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var l=a.metrics.advance*i.scale/2,u=[i.x+l,i.y],c=(a.metrics.left-4)*i.scale-l+u[0],f=(-a.metrics.top-4)*i.scale+u[1],d=c+s.w*i.scale,p=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:p},br:{x:d,y:p},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,E,s,l,f),d.positions);return F.forEach((function(e){var t=[];t.push.apply(t,c([],u(M),!1));var r=c(c(c(c([],u(t),!1),[Xi(P[0],P[1]),Xi(P[2],P[3]),Xi(I[0],I[1]),Xi(I[2],I[3]),v,A,m,g,"visible"===S?1:0,y?1:0,N?1:0,null!=C?C:0],!1),u(O),!1),[n.sortable.renderOrder*Fi],!1);x.push.apply(x,c(c(c(c([],u(r),!1),u(r),!1),u(r),!1),u(r),!1)),B.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),B.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),B.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),B.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),D.push(0+L,2+L,1+L),D.push(2+L,0+L,3+L),L+=4})),{indexBuffer:D,charUVOffsetBuffer:B,charPackedBuffer:x,indicesOffset:L}},r}(Zi),bo=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(r,n){return!!e.prototype.shouldMerge.call(this,r,n)&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},r.prototype.updateAttribute=function(t,r,n,i){e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i)},r.prototype.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},r.prototype.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(Zi),Uo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[];return e.parsedStyle.fill.isNone||t.push(Qi),this.needDrawStrokeSeparately(e)&&t.push(po),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}(bi),Go=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.getDrawcallCtors=function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=r.opacity,a=r.strokeOpacity,s=r.lineWidth,l=i&&!i.isNone,u=po.calcSubpathNum(e),c=[];if(e.nodeName!==t.Shape.POLYLINE&&!n.isNone)for(var f=0;u>f;f++)c.push(Ao);for(f=0;u>f;f++)if(0!==a&&0!==o&&0!==s&&l){var d=Co.isLine(e,f);c.push(d?Co:po)}return c},r}(bi);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e),t.prototype.getDrawcallCtors=function(){return[]}}(bi);var wo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[No]},t}(bi),ko=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.stroke;return!(!n||n.isNone||!r.lineWidth)&&t.push(Fo),t.push(Fo),t},t.prototype.beforeUploadUBO=function(e,t){var r;t.material.setUniforms(((r={})[Do.HAS_STROKE]=1===t.instance.renderable3D.drawcalls.length?0:1-t.index,r))},t}(bi),Vo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[Co]},t}(bi),Xo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[bo]},t}(bi),Wo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,o=i&&i.length&&i.some((function(e){return e!==i[0]}));return n.isNone||o||t.push(Qi),o&&t.push(Ao),(o||this.needDrawStrokeSeparately(e))&&t.push(po),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}(bi),Ho=1,Yo=function(){function e(e,t,r,n){this.renderHelper=e,this.rendererFactory=t,this.texturePool=r,this.lightPool=n,this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return e.prototype.destroy=function(){this.drawcalls.forEach((function(e){e.destroy()})),this.drawcalls=[],this.pendingUpdatePatches={}},e.prototype.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.drawcalls.forEach((function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=r.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),r.renderHelper.renderInstManager.submitRenderInst(o,e),t||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))},e.prototype.attach=function(e){this.context=e},e.prototype.add=function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach((function(i,o,a){var s=t.drawcalls.find((function(t){return i===t.constructor&&t.index===o&&t.maxInstances>t.objects.length&&t.shouldMerge(e,o)}));s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,a,o,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[o]=s,s.geometryDirty=!0)}))}},e.prototype.remove=function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach((function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach((function(e){e.destroy()}))}})),r.drawcalls=[])},e.prototype.updateAttribute=function(e,t,r,n){var i=this;void 0===n&&(n=!1);var o=e.renderable3D,a=this.rendererFactory[e.nodeName];if(a){var s=a.getDrawcallCtors(e);if(s.forEach((function(s,l,u){var c=o.drawcalls.find((function(e){return e&&e.index===l&&e.constructor===s}));if(c||((c=o.drawcalls[l])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&i.drawcalls.splice(i.drawcalls.indexOf(c),1),o.drawcalls[o.drawcalls.indexOf(c)]=void 0),(c=i.drawcalls.find((function(t){return s===t.constructor&&t.index===l&&t.maxInstances>t.objects.length&&t.shouldMerge(e,l)})))?c.geometryDirty=!0:((c=new s(i.renderHelper,i.texturePool,i.lightPool,e,u,l,i.context)).renderer=a,c.init(),i.drawcalls.push(c)),c.objects.push(e),o.drawcalls[l]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,l)){var f=c.objects.indexOf(e);if(n)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;i.pendingUpdatePatches[d]||(i.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[d].objectIndices.indexOf(f)&&i.pendingUpdatePatches[d].objectIndices.push(f)}}else i.remove(e),i.add(e);else i.remove(e),i.add(e)})),o.drawcalls.length>s.length)for(var l=o.drawcalls.length-1;l>=s.length;l--){var u=o.drawcalls[l];u.objects.splice(u.objects.indexOf(e),1),u.geometryDirty=!0,0===u.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(u),1),o.drawcalls.pop()}}},e.prototype.changeRenderOrder=function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach((function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)}))},e.prototype.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=Ho++),this.stencilRefCache[e.entity]},e.prototype.updatePendingPatches=function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}},e}(),zo=function(){function e(e,t){this.context=e,this.runtime=t,this.textureCache={}}return e.prototype.getOrCreateTexture=function(e,r,n,o){var a,s=this,l="string"==typeof r?r:r.src||"";if(l&&this.textureCache[l])(a=this.textureCache[l]).emit(W.LOADED);else if(a=e.createTexture(i({format:te.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:H.TEXTURE_2D,usage:Y.SAMPLED,pixelStore:{unpackFlipY:!1}},n)),l&&(this.textureCache[l]=a),C(r)){var u,c=this.context.config.createImage;c?u=c(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){var e=function(e){s.textureCache[l].setImageData([e]),s.textureCache[l].emit(W.LOADED),s.context.renderingService.dirtify(),o&&o(s.textureCache[l])};s.runtime.globalThis.createImageBitmap?s.runtime.globalThis.createImageBitmap(u).then((function(t){return e(t)})).catch((function(){e(u)})):e(u)},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else a.setImageData([r]),a.emit(W.LOADED),this.context.renderingService.dirtify();return a},e.prototype.getOrCreateCanvas=function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)},e.prototype.getOrCreateGradient=function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,o=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),l=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=o;var u=this.context.imagePool;t.forEach((function(e){var t=u.getOrCreateGradient(i(i({type:e.type},e.value),{width:n,height:o}),l);l.fillStyle=t,l.fillRect(0,0,n,o)}))},e.prototype.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,l=r.getGeometryBounds().halfExtents,u=2*l[0]||1,c=2*l[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),p=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);d.width=u,d.height=c;var _=(i=C(o)?this.context.imagePool.getImageSync(o,n):o)&&p.createPattern(i,a);if(s){var h=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));_.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12],f:h[13]})}p.fillStyle=_,p.fillRect(0,0,u,c)},e.prototype.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}(),Ko=function(e){function r(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="device-renderer",r.parameters={toneMapping:Fn.NONE,toneMappingExposure:1},r}return n(r,e),r.prototype.init=function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new vn;var n=new ui(this.parameters),i=new Rn,o=new zo(this.context,e),a=new An,s=new Uo,l=new Go,u=((r={})[t.Shape.CIRCLE]=s,r[t.Shape.ELLIPSE]=s,r[t.Shape.POLYLINE]=l,r[t.Shape.PATH]=l,r[t.Shape.POLYGON]=l,r[t.Shape.RECT]=new Wo,r[t.Shape.IMAGE]=new wo,r[t.Shape.LINE]=new Vo,r[t.Shape.TEXT]=new ko,r[t.Shape.MESH]=new Xo,r[t.Shape.GROUP]=void 0,r[t.Shape.HTML]=void 0,r),c=new Yo(n,u,o,i),f=new Di(n,i,o,c,this.options);this.addRenderingPlugin(f),this.addRenderingPlugin(new Li(n,f,a,c))},r.prototype.destroy=function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]},r.prototype.getRenderGraphPlugin=function(){return this.plugins[0]},r.prototype.getDevice=function(){return this.getRenderGraphPlugin().getDevice()},r.prototype.loadTexture=function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)},r.prototype.toDataURL=function(e){return this.getRenderGraphPlugin().toDataURL(e)},r.prototype.setParameters=function(e){this.parameters=i(i({},this.parameters),e)},r}(t.AbstractRendererPlugin),jo=Object.freeze({__proto__:null,get AntialiasingMode(){return di},Batch:bi,BufferGeometry:Pi,DeviceProgram:mn,DynamicUniformBuffer:gn,FILL_TEXTURE_MAPPING:zi,Fog:Si,get FogType(){return Ti},get GeometryEvent(){return gi},HashMap:Pn,ImageDrawcall:No,Instanced:Zi,InstancedFillDrawcall:Ao,InstancedLineDrawcall:Co,InstancedPathDrawcall:po,get JOINT_TYPE(){return fo},Light:mi,Material:Ui,get MaterialEvent(){return Bi},Mesh:Tn,MeshDrawcall:bo,Plugin:Ko,get RGAttachmentSlot(){return bn},RenderCache:Un,RenderGraphPlugin:Di,RenderHelper:ui,RenderInst:ii,get RenderInstExecutionOrder(){return ni},get RenderInstFlags(){return ei},RenderInstList:ai,RenderInstManager:li,Renderable3D:En,get RendererLayer(){return Gn},SDFDrawcall:Qi,ShaderMaterial:Gi,SingleSampledTexture:Vn,TemporalTexture:Ai,TextDrawcall:Fo,get TextUniform(){return Do},TextureMapping:vi,TexturePool:zo,TinySDF:ao,get ToneMapping(){return Fn},get VertexAttributeBufferIndex(){return Wi},get VertexAttributeLocation(){return Hi},bezierCurveTo:ro,compareDefines:ki,definedProps:Vi,enumToObject:wi,fillColor:function(e,t,r,n){return void 0===n&&(n=r.a),e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r,n){return void 0===n&&(n=0),e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:ri,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:yn,hashCodeNumberUpdate:Sn,makeAttachmentClearDescriptor:fi,makeBackbufferDescSimple:Ri,makeDataBuffer:yi,makeDepthKey:zn,makeSortKey:function(e,t){return void 0===t&&(t=0),e&Gn.TRANSLUCENT?Qn(e):Zn(e,t)},makeSortKeyOpaque:Zn,makeSortKeyTranslucent:Qn,nullHashFunc:Cn,opaqueBlackFullClearRenderPassDescriptor:_i,opaqueWhiteFullClearRenderPassDescriptor:hi,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===q.NEGATIVE_ONE?function(e){T(e,Jn,e)}(e):t===q.ZERO&&function(e){T(e,ti,e)}(e))},pushFXAAPass:Mi,quadCurveTo:to,renderInstCompareNone:null,renderInstCompareSortKey:oi,segmentInstanceGeometry:mo,setBackbufferDescSimple:Ei,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=Hn);var n=!!(e>>>31&1),i=zn(t,n,r);return n?$n(e,i):qn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?$n(e,t):qn(e,t)},setSortKeyLayer:Kn,setSortKeyOpaqueDepth:qn,setSortKeyProgramKey:jn,setSortKeyTranslucentDepth:$n,standardFullClearRenderPassDescriptor:pi,updateBuffer:Eo}),Zo=function(){function e(){}return e.prototype.apply=function(t,r){var n=this,i=t.renderingService,o=t.renderingContext,a=t.config;this.context=t;var s=o.root.ownerDocument.defaultView,l=function(e){i.hooks.pointerMove.call(e)},u=function(e){i.hooks.pointerUp.call(e)},c=function(e){i.hooks.pointerDown.call(e)},f=function(e){i.hooks.pointerOver.call(e)},d=function(e){i.hooks.pointerOut.call(e)},p=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},h=function(e){i.hooks.click.call(e)};i.hooks.init.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?function(e){r.globalThis.document.addEventListener("pointermove",l,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",u,!0),r.globalThis.addEventListener("pointercancel",p,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",l,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.addEventListener("touchstart",c,!0),e.addEventListener("touchend",u,!0),e.addEventListener("touchmove",l,!0),e.addEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.addEventListener("click",h,!0),e.addEventListener("wheel",_,{passive:!0,capture:!0})})),i.hooks.destroy.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):s.supportsPointerEvents&&(e.style.touchAction=""),s.supportsPointerEvents?function(e){r.globalThis.document.removeEventListener("pointermove",l,!0),e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",u,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",l,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",c,!0),e.removeEventListener("touchend",u,!0),e.removeEventListener("touchmove",l,!0),e.removeEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.removeEventListener("click",h,!0),e.removeEventListener("wheel",_,!0)}))},e.tag="DOMInteraction",e}(),qo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="dom-interaction",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new Zo)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),Qo=Object.freeze({__proto__:null,Plugin:qo}),$o=function(){function e(){this.displayObjectHTMLElementMap=new WeakMap}return e.prototype.joinTransformMatrix=function(e){return"matrix(".concat([e[0],e[1],e[4],e[5],e[12],e[13]].join(","),")")},e.prototype.apply=function(r,n){var i=this,o=r.camera,a=r.renderingContext,s=r.renderingService;this.context=r;var l=a.root.ownerDocument.defaultView,u=function(e,t){t.style.transform=i.joinTransformMatrix(e.getWorldTransform())},c=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){i.$camera||(i.$camera=i.createCamera(o));var a=i.getOrCreateEl(r);if(i.$camera.appendChild(a),n.enableCSSParsing){var s=r.ownerDocument.documentElement.attributes;Object.keys(s).forEach((function(e){a.style[e]=s[e]}))}Object.keys(r.attributes).forEach((function(e){i.updateAttribute(e,r)})),u(r,a),i.context.nativeHTMLMap.set(a,r)}},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&i.$camera){var n=i.getOrCreateEl(r);n&&(n.remove(),i.context.nativeHTMLMap.delete(n))}},d=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&i.updateAttribute(e.attrName,r)},p=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var n=i.getOrCreateEl(r);u(r,n)}},_=function(){if(i.$camera){var e=i.context.config,t=e.height;i.$camera.style.width="".concat(e.width||0,"px"),i.$camera.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,_),l.addEventListener(t.ElementEvent.MOUNTED,c),l.addEventListener(t.ElementEvent.UNMOUNTED,f),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,d),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),s.hooks.endFrame.tap(e.tag,(function(){i.$camera&&a.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(i.$camera.style.transform=i.joinTransformMatrix(o.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){i.$camera&&i.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,_),l.removeEventListener(t.ElementEvent.MOUNTED,c),l.removeEventListener(t.ElementEvent.UNMOUNTED,f),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,d),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)}))},e.prototype.createCamera=function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",l=a.querySelector("#"+s);if(!l){var u=(r||document).createElement("div");l=u,u.id=s,u.style.position="absolute",u.style.left="".concat(o.offsetLeft||0,"px"),u.style.top="".concat(o.offsetTop||0,"px"),u.style.transformOrigin="left top",u.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),u.style.overflow="hidden",u.style.pointerEvents="none",u.style.width="".concat(n||0,"px"),u.style.height="".concat(i||0,"px"),a.appendChild(u)}return l}return null},e.prototype.getOrCreateEl=function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style.left="0px",r.style.top="0px",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform())),r},e.prototype.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;C(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].value," ").concat(o[1].value);break;case"width":if(this.context.enableCSSParsing){var a=r.computedStyleMap().get("width");n.style.width=""+a}else{n.style.width=P(a=r.parsedStyle.width)?"".concat(a,"px"):""+a}break;case"height":if(this.context.enableCSSParsing){var s=r.computedStyleMap().get("height");n.style.height=""+s}else{n.style.height=P(s=r.parsedStyle.height)?"".concat(s,"px"):""+s}break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var l=r.parsedStyle.fill,u="";t.isCSSRGB(l)?u=l.isNone?"transparent":r.getAttribute("fill"):Array.isArray(l)?u=r.getAttribute("fill"):t.isPattern(l),n.style.background=u;break;case"stroke":var c=r.parsedStyle.stroke,f="";t.isCSSRGB(c)?f=c.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(c)?f=r.getAttribute("stroke"):t.isPattern(c),n.style["border-color"]=f,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:"x"!==e&&"y"!==e&&(g(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e]))}},e.tag="HTMLRendering",e}(),Jo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="html-renderer",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new $o)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ea=Object.freeze({__proto__:null,Plugin:Jo}),ta=function(){function e(e){this.canvasConfig=e,this.imageCache={},this.gradientCache={},this.patternCache={}}return e.prototype.getImageSync=function(e,t){return this.imageCache[e]?t&&t(this.imageCache[e]):this.getOrCreateImage(e).then((function(e){t&&t(e)})),this.imageCache[e]},e.prototype.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){r.imageCache[e]=a,i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e)}))},e.prototype.getOrCreatePatternSync=function(e,r,n,i,o){var a=this.generatePatternKey(e);if(a&&this.patternCache[a])return this.patternCache[a];var s,l=e.image,u=e.repetition,c=e.transform,f=!1;C(l)?s=this.getImageSync(l,o):n?(s=n,f=!0):s=l;var p=s&&r.createPattern(s,u);if(p){var _=void 0;_=c?t.parsedTransformToMat4(t.parseTransform(c),new t.DisplayObject({})):h(d()),f&&function(e,t,r){var n=r[0],i=r[1],o=r[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(_,_,[1/i,1/i,1]),p.setTransform({a:_[0],b:_[1],c:_[4],d:_[5],e:_[12],f:_[13]})}return a&&p&&(this.patternCache[a]=p),p},e.prototype.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,s=e.height,l=e.cx,u=e.cy,c=e.size;if(this.gradientCache[n])return this.gradientCache[n];var f=null;if(i===t.GradientType.LinearGradient){var d=t.computeLinearGradient(a,s,e.angle);f=r.createLinearGradient(d.x1,d.y1,d.x2,d.y2)}else if(i===t.GradientType.RadialGradient){var p=t.computeRadialGradient(a,s,l,u,c),_=p.x,h=p.y;f=r.createRadialGradient(_,h,0,_,h,p.r)}return f&&(o.forEach((function(e){var r=e.offset;r.unit===t.UnitType.kPercentage&&(null==f||f.addColorStop(r.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]},e.prototype.generateGradientKey=function(e){var t=e.width,r=e.height,n=e.steps,i=e.angle,o=e.cx,a=e.cy,s=e.size;return"gradient-".concat(e.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(t,"-").concat(r,"-").concat(n.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))},e.prototype.generatePatternKey=function(e){var t=e.image,r=e.repetition;return C(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0},e}(),ra=function(){function e(){}return e.prototype.apply=function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e,t,r){var n=e.parsedStyle,i=n.width,o=n.height;i&&!o?e.setAttribute("height",r/t*i):!i&&o&&e.setAttribute("width",t/r*o)},s=function(e){var r=e.target,o=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=o.img,l=o.keepAspectRatio;C(s)&&i.getImageSync(s,(function(e){l&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))}},l=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"img"===e.attrName&&C(o)&&i.getOrCreateImage(o).then((function(e){r.attributes.keepAspectRatio&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,s),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,l)})),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,s),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,l)}))},e.tag="LoadImage",e}(),na=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="image-loader",t}return n(t,e),t.prototype.init=function(){this.context.imagePool=new ta(this.context.config),this.addRenderingPlugin(new ra)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ia=function(){function e(e){this.canvasConfig=e.config,this.deviceRendererPlugin=e.deviceRendererPlugin}return e.prototype.init=function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=C(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.deviceRendererPlugin.getDevice().canvasContext},e.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},e.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},e.prototype.resize=function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(e){return[2,""]}))}))},e}(),oa=function(e){function t(t,r){var n=e.call(this)||this;return n.rendererPlugin=t,n.config=r,n.name="webgpu-context-register",n}return n(t,e),t.prototype.init=function(){this.context.ContextService=ia,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new Lr({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})},t.prototype.destroy=function(){delete this.context.ContextService},t}(t.AbstractRendererPlugin),aa=function(e){function r(r){var n=e.call(this,r)||this;n.clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var i=new Ko;return n.registerPlugin(new oa(i,r)),n.registerPlugin(new na),n.registerPlugin(i),n.registerPlugin(new qo),n.registerPlugin(new Jo),n}return n(r,e),r}(t.AbstractRenderer);e.DeviceRenderer=jo,e.DomInteraction=Qo,e.HTMLRenderer=ea,e.Renderer=aa}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,(function(e,t){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){a.label=s[1];break}if(6===s[0]&&i[1]>a.label){a.label=i[1],i=s;break}if(i&&i[2]>a.label){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;o>i;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var f="undefined"!=typeof Float32Array?Float32Array:Array;function d(){var e=new f(16);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function p(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function _(e,t,r,n,i,o,a,s,l,u,c,d,p,_,h,E){var R=new f(16);return R[0]=e,R[1]=t,R[2]=r,R[3]=n,R[4]=i,R[5]=o,R[6]=a,R[7]=s,R[8]=l,R[9]=u,R[10]=c,R[11]=d,R[12]=p,R[13]=_,R[14]=h,R[15]=E,R}function h(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function E(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var R,v=function(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],d=t[9],p=t[10],_=t[11],h=t[12],E=t[13],R=t[14],v=t[15],T=r[0],A=r[1],m=r[2],g=r[3];return e[0]=T*n+A*s+m*f+g*h,e[1]=T*i+A*l+m*d+g*E,e[2]=T*o+A*u+m*p+g*R,e[3]=T*a+A*c+m*_+g*v,e[4]=(T=r[4])*n+(A=r[5])*s+(m=r[6])*f+(g=r[7])*h,e[5]=T*i+A*l+m*d+g*E,e[6]=T*o+A*u+m*p+g*R,e[7]=T*a+A*c+m*_+g*v,e[8]=(T=r[8])*n+(A=r[9])*s+(m=r[10])*f+(g=r[11])*h,e[9]=T*i+A*l+m*d+g*E,e[10]=T*o+A*u+m*p+g*R,e[11]=T*a+A*c+m*_+g*v,e[12]=(T=r[12])*n+(A=r[13])*s+(m=r[14])*f+(g=r[15])*h,e[13]=T*i+A*l+m*d+g*E,e[14]=T*o+A*u+m*p+g*R,e[15]=T*a+A*c+m*_+g*v,e};function T(e,t,r){var n=new f(3);return n[0]=e,n[1]=t,n[2]=r,n}function A(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function m(e,t,r,n,i,o,a,s,l,u){var c,f,d,p,_,h=e,E=t,R=r,v=n,T=s,g=l,S=120*Math.PI/180,y=Math.PI/180*(+i||0),C=[];if(u)f=u[0],d=u[1],p=u[2],_=u[3];else{E=(c=A(h,E,-y)).y;var P=((h=c.x)-(T=(c=A(T,g,-y)).x))/2,N=(E-(g=c.y))/2,I=P*P/(R*R)+N*N/(v*v);I>1&&(R*=I=Math.sqrt(I),v*=I);var O=R*R,M=v*v,x=(o===a?-1:1)*Math.sqrt(Math.abs((O*M-O*N*N-M*P*P)/(O*N*N+M*P*P)));p=x*R*N/v+(h+T)/2,f=Math.asin(((E-(_=x*-v*P/R+(E+g)/2))/v*1e9>>0)/1e9),d=Math.asin(((g-_)/v*1e9>>0)/1e9),0>(f=p>h?Math.PI-f:f)&&(f=2*Math.PI+f),0>(d=p>T?Math.PI-d:d)&&(d=2*Math.PI+d),a&&f>d&&(f-=2*Math.PI),!a&&d>f&&(d-=2*Math.PI)}var B=d-f;if(Math.abs(B)>S){var D=d,L=T,F=g;C=m(T=p+R*Math.cos(d=f+S*(a&&d>f?1:-1)),g=_+v*Math.sin(d),R,v,i,0,a,L,F,[d,D,p,_])}B=d-f;var b=Math.cos(f),U=Math.sin(f),G=Math.cos(d),w=Math.sin(d),k=Math.tan(B/4),V=4/3*R*k,X=4/3*v*k,W=[h,E],H=[h+V*U,E-X*b],Y=[T+V*w,g-X*G],z=[T,g];if(H[0]=2*W[0]-H[0],H[1]=2*W[1]-H[1],u)return H.concat(Y,z,C);for(var K=[],j=0,Z=(C=H.concat(Y,z,C)).length;Z>j;j+=1)K[j]=j%2?A(C[j-1],C[j],y).y:A(C[j],C[j+1],y).x;return K}R=new f(3),f!=Float32Array&&(R[0]=0,R[1]=0,R[2]=0);var g=function(e){return null==e},S={}.toString,y=function(e,t){return S.call(e)==="[object "+t+"]"},C=function(e){return y(e,"String")},P=function(e,t,r){return t>e?t:e>r?r:e},N=function(e){return y(e,"Number")},I={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var l,u,c=this._events[s],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(u=1,l=Array(f-1);f>u;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,p=c.length;for(u=0;p>u;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),f){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,i);break;default:if(!l)for(d=1,l=Array(f-1);f>d;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var l=0,u=[],c=s.length;c>l;l++)(s[l].fn!==t||i&&!s[l].once||n&&s[l].context!==n)&&u.push(s[l]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(I);var O,M,x,B,D,L,F,b,U,G,w,k,V,X,W,H,Y,z,K,j,Z,q,Q,$,J,ee,te,re=I.exports;function ne(e,t,r,n){return{dimension:H.TEXTURE_2D,format:e,width:t,height:r,depthOrArrayLayers:1,mipLevelCount:n,usage:Y.SAMPLED}}function ie(e,t,r){return e<<16|t<<8|r}function oe(e){return e>>>8&255}function ae(e){return e>>>16&255}function se(e){return 255&e}function le(e){switch(e){case $.F32:case $.U32:case $.S32:return 4;case $.U16:case $.S16:case $.F16:return 2;case $.U8:case $.S8:return 1;default:throw Error("whoops")}}function ue(e){return le(ae(e))}function ce(e){var t=se(e);if(t&ee.Depth)return j.Depth;if(t&ee.Normalized)return j.Float;var r=ae(e);if(r===$.F16||r===$.F32)return j.Float;if(r===$.U8||r===$.U16||r===$.U32)return j.Uint;if(r===$.S8||r===$.S16||r===$.S32)return j.Sint;throw Error("whoops")}function fe(e,t){if(void 0===t&&(t=""),!e)throw Error("Assert fail: ".concat(t))}function de(e){if(null!=e)return e;throw Error("Missing object")}function pe(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function _e(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.ALWAYS=519]="ALWAYS",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.GEQUAL=518]="GEQUAL",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"}(O||(O={})),function(e){e[e.Buffer=0]="Buffer",e[e.Texture=1]="Texture",e[e.RenderTarget=2]="RenderTarget",e[e.Sampler=3]="Sampler",e[e.Program=4]="Program",e[e.Bindings=5]="Bindings",e[e.InputLayout=6]="InputLayout",e[e.RenderPipeline=7]="RenderPipeline",e[e.ComputePipeline=8]="ComputePipeline",e[e.Readback=9]="Readback",e[e.QueryPool=10]="QueryPool"}(M||(M={})),function(e){e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS"}(x||(x={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(B||(B={})),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK",e[e.FRONT_AND_BACK=3]="FRONT_AND_BACK"}(D||(D={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC=768]="SRC",e[e.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",e[e.DST=774]="DST",e[e.ONE_MINUS_DST=775]="ONE_MINUS_DST",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONST=32769]="CONST",e[e.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(L||(L={})),function(e){e[e.ADD=32774]="ADD",e[e.SUBSTRACT=32778]="SUBSTRACT",e[e.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX"}(F||(F={})),function(e){e[e.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",e[e.REPEAT=1]="REPEAT",e[e.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"}(b||(b={})),function(e){e[e.POINT=0]="POINT",e[e.BILINEAR=1]="BILINEAR"}(U||(U={})),function(e){e[e.NO_MIP=0]="NO_MIP",e[e.NEAREST=1]="NEAREST",e[e.LINEAR=2]="LINEAR"}(G||(G={})),function(e){e[e.POINTS=0]="POINTS",e[e.TRIANGLES=1]="TRIANGLES",e[e.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",e[e.LINES=3]="LINES",e[e.LINE_STRIP=4]="LINE_STRIP"}(w||(w={})),function(e){e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE"}(k||(k={})),function(e){e[e.STATIC=1]="STATIC",e[e.DYNAMIC=2]="DYNAMIC"}(V||(V={})),function(e){e[e.VERTEX=1]="VERTEX",e[e.INSTANCE=2]="INSTANCE"}(X||(X={})),function(e){e.LOADED="loaded"}(W||(W={})),function(e){e[e.TEXTURE_2D=0]="TEXTURE_2D",e[e.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=2]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"}(H||(H={})),function(e){e[e.SAMPLED=1]="SAMPLED",e[e.RENDER_TARGET=2]="RENDER_TARGET"}(Y||(Y={})),function(e){e[e.NONE=0]="NONE",e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA",e[e.RGB=7]="RGB",e[e.ALL=15]="ALL"}(z||(z={})),function(e){e[e.KEEP=7680]="KEEP",e[e.ZERO=0]="ZERO",e[e.REPLACE=7681]="REPLACE",e[e.INVERT=5386]="INVERT",e[e.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",e[e.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",e[e.INCREMENT_WRAP=34055]="INCREMENT_WRAP",e[e.DECREMENT_WRAP=34056]="DECREMENT_WRAP"}(K||(K={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(j||(j={})),function(e){e[e.LOWER_LEFT=0]="LOWER_LEFT",e[e.UPPER_LEFT=1]="UPPER_LEFT"}(Z||(Z={})),function(e){e[e.NEGATIVE_ONE=0]="NEGATIVE_ONE",e[e.ZERO=1]="ZERO"}(q||(q={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(Q||(Q={})),function(e){e[e.U8=1]="U8",e[e.U16=2]="U16",e[e.U32=3]="U32",e[e.S8=4]="S8",e[e.S16=5]="S16",e[e.S32=6]="S32",e[e.F16=7]="F16",e[e.F32=8]="F32",e[e.BC1=65]="BC1",e[e.BC2=66]="BC2",e[e.BC3=67]="BC3",e[e.BC4_UNORM=68]="BC4_UNORM",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5_UNORM=70]="BC5_UNORM",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.U16_PACKED_5551=97]="U16_PACKED_5551",e[e.U16_PACKED_565=98]="U16_PACKED_565",e[e.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}($||($={})),function(e){e[e.R=1]="R",e[e.RG=2]="RG",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.A=5]="A"}(J||(J={})),function(e){e[e.None=0]="None",e[e.Normalized=1]="Normalized",e[e.sRGB=2]="sRGB",e[e.Depth=4]="Depth",e[e.Stencil=8]="Stencil",e[e.RenderTarget=16]="RenderTarget"}(ee||(ee={})),function(e){e[e.ALPHA=ie($.U8,J.A,ee.None)]="ALPHA",e[e.U8_LUMINANCE=ie($.U8,J.A,ee.None)]="U8_LUMINANCE",e[e.F16_LUMINANCE=ie($.F16,J.A,ee.None)]="F16_LUMINANCE",e[e.F32_LUMINANCE=ie($.F32,J.A,ee.None)]="F32_LUMINANCE",e[e.F16_R=ie($.F16,J.R,ee.None)]="F16_R",e[e.F16_RG=ie($.F16,J.RG,ee.None)]="F16_RG",e[e.F16_RGB=ie($.F16,J.RGB,ee.None)]="F16_RGB",e[e.F16_RGBA=ie($.F16,J.RGBA,ee.None)]="F16_RGBA",e[e.F32_R=ie($.F32,J.R,ee.None)]="F32_R",e[e.F32_RG=ie($.F32,J.RG,ee.None)]="F32_RG",e[e.F32_RGB=ie($.F32,J.RGB,ee.None)]="F32_RGB",e[e.F32_RGBA=ie($.F32,J.RGBA,ee.None)]="F32_RGBA",e[e.U8_R=ie($.U8,J.R,ee.None)]="U8_R",e[e.U8_R_NORM=ie($.U8,J.R,ee.Normalized)]="U8_R_NORM",e[e.U8_RG=ie($.U8,J.RG,ee.None)]="U8_RG",e[e.U8_RG_NORM=ie($.U8,J.RG,ee.Normalized)]="U8_RG_NORM",e[e.U8_RGB=ie($.U8,J.RGB,ee.None)]="U8_RGB",e[e.U8_RGB_NORM=ie($.U8,J.RGB,ee.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=ie($.U8,J.RGB,ee.sRGB|ee.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=ie($.U8,J.RGBA,ee.None)]="U8_RGBA",e[e.U8_RGBA_NORM=ie($.U8,J.RGBA,ee.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=ie($.U8,J.RGBA,ee.sRGB|ee.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=ie($.U16,J.R,ee.None)]="U16_R",e[e.U16_R_NORM=ie($.U16,J.R,ee.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=ie($.U16,J.RG,ee.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=ie($.U16,J.RGBA,ee.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=ie($.U16,J.RGB,ee.None)]="U16_RGB",e[e.U32_R=ie($.U32,J.R,ee.None)]="U32_R",e[e.U32_RG=ie($.U32,J.RG,ee.None)]="U32_RG",e[e.S8_R=ie($.S8,J.R,ee.None)]="S8_R",e[e.S8_R_NORM=ie($.S8,J.R,ee.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=ie($.S8,J.RG,ee.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=ie($.S8,J.RGB,ee.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=ie($.S8,J.RGBA,ee.Normalized)]="S8_RGBA_NORM",e[e.S16_R=ie($.S16,J.R,ee.None)]="S16_R",e[e.S16_RG=ie($.S16,J.RG,ee.None)]="S16_RG",e[e.S16_RG_NORM=ie($.S16,J.RG,ee.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=ie($.S16,J.RGB,ee.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=ie($.S16,J.RGBA,ee.None)]="S16_RGBA",e[e.S16_RGBA_NORM=ie($.S16,J.RGBA,ee.Normalized)]="S16_RGBA_NORM",e[e.S32_R=ie($.S32,J.R,ee.None)]="S32_R",e[e.U16_RGBA_5551=ie($.U16_PACKED_5551,J.RGBA,ee.Normalized)]="U16_RGBA_5551",e[e.U16_RGB_565=ie($.U16_PACKED_565,J.RGB,ee.Normalized)]="U16_RGB_565",e[e.BC1=ie($.BC1,J.RGBA,ee.Normalized)]="BC1",e[e.BC1_SRGB=ie($.BC1,J.RGBA,ee.Normalized|ee.sRGB)]="BC1_SRGB",e[e.BC2=ie($.BC2,J.RGBA,ee.Normalized)]="BC2",e[e.BC2_SRGB=ie($.BC2,J.RGBA,ee.Normalized|ee.sRGB)]="BC2_SRGB",e[e.BC3=ie($.BC3,J.RGBA,ee.Normalized)]="BC3",e[e.BC3_SRGB=ie($.BC3,J.RGBA,ee.Normalized|ee.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=ie($.BC4_UNORM,J.R,ee.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=ie($.BC4_SNORM,J.R,ee.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=ie($.BC5_UNORM,J.RG,ee.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=ie($.BC5_SNORM,J.RG,ee.Normalized)]="BC5_SNORM",e[e.D24=ie($.D24,J.R,ee.Depth)]="D24",e[e.D24_S8=ie($.D24S8,J.RG,ee.Depth|ee.Stencil)]="D24_S8",e[e.D32F=ie($.D32F,J.R,ee.Depth)]="D32F",e[e.D32F_S8=ie($.D32FS8,J.RG,ee.Depth|ee.Stencil)]="D32F_S8",e[e.U8_RGB_RT=ie($.U8,J.RGB,ee.RenderTarget|ee.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=ie($.U8,J.RGBA,ee.RenderTarget|ee.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=ie($.U8,J.RGBA,ee.RenderTarget|ee.Normalized|ee.sRGB)]="U8_RGBA_RT_SRGB"}(te||(te={}));var he=_e(0,0,0,0),Ee=_e(0,0,0,1),Re=_e(1,1,1,0),ve=_e(1,1,1,1);function Te(e){return!(!e||0!=(e&e-1))}function Ae(e,t){return null!=e?e:t}function me(e,t,r){e.length=t,e.fill(r)}function ge(e,t){var r=t-1;return e+r&~r}function Se(e,t){return((e+t-1)/t|0)*t}function ye(e,t,r){return r?e|=t:e&=~t,e}function Ce(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function Pe(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Ne(e,t){return void 0===e&&(e={}),e.compare=t.compare,e.depthFailOp=t.depthFailOp,e.passOp=t.passOp,e.failOp=t.failOp,e}function Ie(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Pe(e.rgbBlendState,t.rgbBlendState),Pe(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Oe(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=Ie(e[r],t[r])}function Me(e,t){void 0!==t.attachmentsState&&Oe(e.attachmentsState,t.attachmentsState),e.blendConstant&&t.blendConstant&&function(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}(e.blendConstant,t.blendConstant),e.depthCompare=Ae(t.depthCompare,e.depthCompare),e.depthWrite=Ae(t.depthWrite,e.depthWrite),e.stencilWrite=Ae(t.stencilWrite,e.stencilWrite),e.stencilFront&&t.stencilFront&&Ne(e.stencilFront,t.stencilFront),e.stencilBack&&t.stencilBack&&Ne(e.stencilBack,t.stencilBack),e.cullMode=Ae(t.cullMode,e.cullMode),e.frontFace=Ae(t.frontFace,e.frontFace),e.polygonOffset=Ae(t.polygonOffset,e.polygonOffset)}function xe(e){var t=Object.assign({},e);return t.attachmentsState=[],Oe(t.attachmentsState,e.attachmentsState),t.blendConstant=t.blendConstant&&pe(t.blendConstant),t.stencilFront=Ne(void 0,e.stencilFront),t.stencilBack=Ne(void 0,e.stencilBack),t}var Be={blendMode:F.ADD,blendSrcFactor:L.ONE,blendDstFactor:L.ZERO},De={attachmentsState:[{channelWriteMask:z.ALL,rgbBlendState:Be,alphaBlendState:Be}],blendConstant:pe(he),depthWrite:!0,depthCompare:x.LEQUAL,stencilWrite:!1,stencilFront:{compare:x.ALWAYS,passOp:K.KEEP,depthFailOp:K.KEEP,failOp:K.KEEP},stencilBack:{compare:x.ALWAYS,passOp:K.KEEP,depthFailOp:K.KEEP,failOp:K.KEEP},cullMode:D.NONE,frontFace:B.CCW,polygonOffset:!1};var Le=function(e,t){void 0===e&&(e=null),void 0===t&&(t=De);var r=xe(t);return null!==e&&Me(r,e),r}({depthCompare:x.ALWAYS,depthWrite:!1},De);function Fe(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Oe(e.attachmentsState,De.attachmentsState)),function(e,t){void 0!==t.channelWriteMask&&(e.channelWriteMask=t.channelWriteMask),void 0!==t.rgbBlendMode&&(e.rgbBlendState.blendMode=t.rgbBlendMode),void 0!==t.alphaBlendMode&&(e.alphaBlendState.blendMode=t.alphaBlendMode),void 0!==t.rgbBlendSrcFactor&&(e.rgbBlendState.blendSrcFactor=t.rgbBlendSrcFactor),void 0!==t.alphaBlendSrcFactor&&(e.alphaBlendState.blendSrcFactor=t.alphaBlendSrcFactor),void 0!==t.rgbBlendDstFactor&&(e.rgbBlendState.blendDstFactor=t.rgbBlendDstFactor),void 0!==t.alphaBlendDstFactor&&(e.alphaBlendState.blendDstFactor=t.alphaBlendDstFactor)}(e.attachmentsState[0],t),e}var be,Ue={texture:null,sampler:null,formatKind:j.Float,dimension:H.TEXTURE_2D};function Ge(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function we(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function ke(e,t){return e.buffer===t.buffer&&e.size===t.size&&e.binding===t.binding&&e.offset===t.offset}function Ve(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture&&e.dimension===t.dimension&&e.formatKind===t.formatKind&&e.comparison===t.comparison)}function Xe(e,t){return e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],e.samplerBindings.length===t.samplerBindings.length&&(!!Ge(e.samplerBindings,t.samplerBindings,Ve)&&!!Ge(e.uniformBufferBindings,t.uniformBufferBindings,ke))}function We(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function He(e,t){return!!We(e.rgbBlendState,t.rgbBlendState)&&(!!We(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Ye(e,t){return e.compare==t.compare&&e.depthFailOp===t.depthFailOp&&e.failOp===t.failOp&&e.passOp===t.passOp}function ze(e,t){return e.id===t.id}function Ke(e,t){return e===t}function je(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!(e.megaStateDescriptor&&t.megaStateDescriptor&&!function(e,t){return!(!Ge(e.attachmentsState,t.attachmentsState,He)||e.blendConstant&&t.blendConstant&&((r=e.blendConstant).r!==(n=t.blendConstant).r||r.g!==n.g||r.b!==n.b||r.a!==n.a)||e.stencilFront&&t.stencilFront&&!Ye(e.stencilFront,t.stencilFront)||e.stencilBack&&t.stencilBack&&!Ye(e.stencilBack,t.stencilBack)||e.depthCompare!==t.depthCompare||e.depthWrite!==t.depthWrite||e.stencilWrite!==t.stencilWrite||e.cullMode!==t.cullMode||e.frontFace!==t.frontFace||e.polygonOffset!==t.polygonOffset);var r,n}(e.megaStateDescriptor,t.megaStateDescriptor))&&(!!ze(e.program,t.program)&&(!!Ge(e.colorAttachmentFormats,t.colorAttachmentFormats,Ke)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat)))))}function Ze(e,t){return e.offset===t.offset&&e.shaderLocation===t.shaderLocation&&e.format===t.format&&e.divisor===t.divisor}function qe(e,t){return g(e)?g(t):!g(t)&&(e.arrayStride===t.arrayStride&&e.stepMode===t.stepMode&&Ge(e.attributes,t.attributes,Ze))}function Qe(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Ge(e.vertexBufferDescriptors,t.vertexBufferDescriptors,qe)&&!!ze(e.program,t.program))}function $e(e,t){return e.addressModeU===t.addressModeU&&e.addressModeV===t.addressModeV&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipmapFilter===t.mipmapFilter&&e.lodMinClamp===t.lodMinClamp&&e.lodMaxClamp===t.lodMaxClamp&&e.maxAnisotropy===t.maxAnisotropy&&e.compareFunction===t.compareFunction}function Je(e){return{sampler:e.sampler,texture:e.texture,dimension:e.dimension,formatKind:e.formatKind,comparison:e.comparison}}function et(e){return{binding:e.binding,buffer:e.buffer,offset:e.offset,size:e.size}}function tt(e){return{shaderLocation:e.shaderLocation,format:e.format,offset:e.offset,divisor:e.divisor}}function rt(e){return g(e)?e:{arrayStride:e.arrayStride,stepMode:e.stepMode,attributes:we(e.attributes,tt)}}var nt=/([^[]*)(\[[0-9]+\])?/;function it(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(nt);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}}function ot(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function at(e,t,r,n){var i=null,o=null;return function(a,s,l){var u=t(l,r),c=u.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{fe(o===c,"Uniform length cannot change.");for(var d=0;c>d;++d)if(u[d]!==i[d]){f=!0;break}}return f&&(n(a,e,s,u),i.set(u)),f}}function st(e,t,r,n){e[t](r,n)}function lt(e,t,r,n){e[t](r,!1,n)}var ut={},ct={},ft={},dt=[0];function pt(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(dt[0]=e,e=dt);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function _t(e,t){return pt(e,t,Float32Array,ut)}function ht(e,t){return pt(e,t,Int32Array,ct)}function Et(e,t){return pt(e,t,Uint32Array,ft)}var Rt=((be={})[O.FLOAT]=at.bind(null,"uniform1fv",_t,1,st),be[O.FLOAT_VEC2]=at.bind(null,"uniform2fv",_t,2,st),be[O.FLOAT_VEC3]=at.bind(null,"uniform3fv",_t,3,st),be[O.FLOAT_VEC4]=at.bind(null,"uniform4fv",_t,4,st),be[O.INT]=at.bind(null,"uniform1iv",ht,1,st),be[O.INT_VEC2]=at.bind(null,"uniform2iv",ht,2,st),be[O.INT_VEC3]=at.bind(null,"uniform3iv",ht,3,st),be[O.INT_VEC4]=at.bind(null,"uniform4iv",ht,4,st),be[O.BOOL]=at.bind(null,"uniform1iv",ht,1,st),be[O.BOOL_VEC2]=at.bind(null,"uniform2iv",ht,2,st),be[O.BOOL_VEC3]=at.bind(null,"uniform3iv",ht,3,st),be[O.BOOL_VEC4]=at.bind(null,"uniform4iv",ht,4,st),be[O.FLOAT_MAT2]=at.bind(null,"uniformMatrix2fv",_t,4,lt),be[O.FLOAT_MAT3]=at.bind(null,"uniformMatrix3fv",_t,9,lt),be[O.FLOAT_MAT4]=at.bind(null,"uniformMatrix4fv",_t,16,lt),be[O.UNSIGNED_INT]=at.bind(null,"uniform1uiv",Et,1,st),be[O.UNSIGNED_INT_VEC2]=at.bind(null,"uniform2uiv",Et,2,st),be[O.UNSIGNED_INT_VEC3]=at.bind(null,"uniform3uiv",Et,3,st),be[O.UNSIGNED_INT_VEC4]=at.bind(null,"uniform4uiv",Et,4,st),be[O.FLOAT_MAT2x3]=at.bind(null,"uniformMatrix2x3fv",_t,6,lt),be[O.FLOAT_MAT2x4]=at.bind(null,"uniformMatrix2x4fv",_t,8,lt),be[O.FLOAT_MAT3x2]=at.bind(null,"uniformMatrix3x2fv",_t,6,lt),be[O.FLOAT_MAT3x4]=at.bind(null,"uniformMatrix3x4fv",_t,12,lt),be[O.FLOAT_MAT4x2]=at.bind(null,"uniformMatrix4x2fv",_t,8,lt),be[O.FLOAT_MAT4x3]=at.bind(null,"uniformMatrix4x3fv",_t,12,lt),be[O.SAMPLER_2D]=ot,be[O.SAMPLER_CUBE]=ot,be[O.SAMPLER_3D]=ot,be[O.SAMPLER_2D_SHADOW]=ot,be[O.SAMPLER_2D_ARRAY]=ot,be[O.SAMPLER_2D_ARRAY_SHADOW]=ot,be[O.SAMPLER_CUBE_SHADOW]=ot,be[O.INT_SAMPLER_2D]=ot,be[O.INT_SAMPLER_3D]=ot,be[O.INT_SAMPLER_CUBE]=ot,be[O.INT_SAMPLER_2D_ARRAY]=ot,be[O.UNSIGNED_INT_SAMPLER_2D]=ot,be[O.UNSIGNED_INT_SAMPLER_3D]=ot,be[O.UNSIGNED_INT_SAMPLER_CUBE]=ot,be[O.UNSIGNED_INT_SAMPLER_2D_ARRAY]=ot,be);function vt(e,t,r){var n=Rt[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)}var Tt={"[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};function At(e,t){return"#define ".concat(e," ").concat(t)}function mt(e){if(void 0===e)return null;var t=/binding\s*=\s*(\d+)/.exec(e);if(null!==t){var r=parseInt(t[1],10);if(!Number.isNaN(r))return r}return null}function gt(e,t,r,n,i){var o;void 0===n&&(n=null),void 0===i&&(i=!0);var a="#version 100"===e.glslVersion,s="frag"===t&&(null===(o=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))||void 0===o?void 0:o.length)>1,l=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),c="";null!==n&&(c=Object.keys(n).map((function(e){return At(e,n[e])})).join("\n"));var f=l.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",d=i?l.filter((function(e){return!e.startsWith("precision")})).join("\n"):l.join("\n"),p="";if(e.viewportOrigin===Z.UPPER_LEFT&&(p+="".concat(At("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===q.ZERO&&(p+="".concat(At("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var _=0,h=0,E=0;d=d.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(_,", binding = ").concat(h++,") uniform ").concat(n)})),_++,h=0,fe(e.separateSamplerTextures),d=d.replace(/^(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,r,n,i,o){var a=mt(n);null===a&&(a=h++);var s=u(function(e){return[e,""]}(i),2),l=s[0],c=s[1];return"frag"===t?"\nlayout(set = ".concat(_,", binding = ").concat(2*a+0,") uniform texture").concat(l," T_").concat(o,";\nlayout(set = ").concat(_,", binding = ").concat(2*a+1,") uniform sampler").concat(c," S_").concat(o,";").trim():""})),d=d.replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(E++,") ").concat(t)})),p+="".concat(At("gl_VertexID","gl_VertexIndex"),"\n"),p+="".concat(At("gl_InstanceID","gl_InstanceIndex"),"\n"),f=f.replace(/^precision (.*) sampler(.*);$/gm,"")}else{var R=0;d=d.replace(/^(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,t,r,n,i){var o=mt(r);return null===o&&(o=R++),"uniform sampler".concat(n," ").concat(i,"; // BINDING=").concat(o)}))}if(e.separateSamplerTextures)d=(d=d.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"sampler".concat(t,"(T_").concat(r,", S_").concat(r,")")}))).replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return"T_".concat(t)}));else{var v=[];d=d.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return v.push([r,t]),r})),a&&v.forEach((function(e){var t=u(e,2),r=t[0],n=t[1];d=d.replace(RegExp("texture\\(".concat(r),"g"),(function(){return"texture".concat(n,"(").concat(r)}))})),d=d.replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return t}))}var T="".concat(a?"":e.glslVersion,"\n").concat(a&&s?"#extension GL_EXT_draw_buffers : require\n":"","\n").concat(a&&"frag"===t?"#extension GL_OES_standard_derivatives : enable\n":"").concat(i?f:"","\n").concat(p||"").concat(c?c+"\n":"","\n").concat(d,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(T=T.replace(/^\b(out)\b/g,(function(e,t){return"layout(location = 0) ".concat(t)}))),a){if("frag"===t&&(T=T.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(T=(T=T.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"attribute ".concat(t," ").concat(r,";\n")}))),T=T.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,t){return t.trim().replace(/^.*$/gm,(function(e){var t=e.trim();return t.startsWith("#")?t:e?"uniform ".concat(t):""}))})),"frag"===t)if(s){var A=[];T=T.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,(function(e,t){return A.push(t),"vec4 ".concat(t,";\n")}));var m=T.lastIndexOf("}");T=T.substring(0,m)+"\n ".concat(A.map((function(e,t){return"gl_FragData[".concat(t,"] = ").concat(e,";\n ")})).join("\n"))+T.substring(m)}else{var g;if(T=T.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return g=r,"".concat(t," ").concat(r,";\n")})),g){m=T.lastIndexOf("}");T=T.substring(0,m)+"\n gl_FragColor = vec4(".concat(g,");\n")+T.substring(m)}}T=T.replace(/^\s*layout\((.*)\)/gm,"")}return T}var St=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,null!==i.device.resourceCreationTracker&&i.device.resourceCreationTracker.trackResourceCreated(i),i}return n(t,e),t.prototype.destroy=function(){null!==this.device.resourceCreationTracker&&this.device.resourceCreationTracker.trackResourceDestroyed(this)},t}(re);function yt(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||!(!e||2!==e._version)}function Ct(e){if(se(e)&ee.Normalized)return!1;var t=ae(e);return t===$.S8||t===$.S16||t===$.S32||(t===$.U8||t===$.U16||t===$.U32)}function Pt(e){return e&k.INDEX?O.ELEMENT_ARRAY_BUFFER:e&k.VERTEX?O.ARRAY_BUFFER:e&k.UNIFORM?O.UNIFORM_BUFFER:void 0}function Nt(e){var t=ae(e),r=oe(e),n=se(e),i=function(e){switch(e){case $.U8:return O.UNSIGNED_BYTE;case $.U16:return O.UNSIGNED_SHORT;case $.U32:return O.UNSIGNED_INT;case $.S8:return O.BYTE;case $.S16:return O.SHORT;case $.S32:return O.INT;case $.F16:return O.HALF_FLOAT;case $.F32:return O.FLOAT;default:throw Error("whoops")}}(t),o=function(e){switch(e){case J.R:return 1;case J.RG:return 2;case J.RGB:return 3;case J.RGBA:return 4;default:return 1}}(r);return{size:o,type:i,normalized:!!(n&ee.Normalized)}}function It(e){switch(e){case b.CLAMP_TO_EDGE:return O.CLAMP_TO_EDGE;case b.REPEAT:return O.REPEAT;case b.MIRRORED_REPEAT:return O.MIRRORED_REPEAT;default:throw Error("whoops")}}function Ot(e,t){if(t===G.LINEAR&&e===U.BILINEAR)return O.LINEAR_MIPMAP_LINEAR;if(t===G.LINEAR&&e===U.POINT)return O.NEAREST_MIPMAP_LINEAR;if(t===G.NEAREST&&e===U.BILINEAR)return O.LINEAR_MIPMAP_NEAREST;if(t===G.NEAREST&&e===U.POINT)return O.NEAREST_MIPMAP_NEAREST;if(t===G.NO_MIP&&e===U.BILINEAR)return O.LINEAR;if(t===G.NO_MIP&&e===U.POINT)return O.NEAREST;throw Error("Unknown texture filter mode")}function Mt(e,t){void 0===t&&(t=0);return e.gl_buffer_pages[t/e.pageByteSize|0]}!function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.Bindings;var i=r.samplerBindings;return n.uniformBufferBindings=r.uniformBufferBindings||[],n.samplerBindings=i||[],n.bindingLayouts=n.createBindingLayouts(),n}n(t,e),t.prototype.createBindingLayouts=function(){var e=0,t=0,r=[],n=this.uniformBufferBindings.length,i=this.samplerBindings.length;return r.push({firstUniformBuffer:e,numUniformBuffers:n,firstSampler:t,numSamplers:i}),{numUniformBuffers:e+=n,numSamplers:t+=i,bindingLayoutTables:r}}}(St),function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=M.Buffer;var o=n.viewOrSize,a=n.usage,s=n.hint,l=void 0===s?V.STATIC:s,u=r.uniformBufferMaxPageByteSize,c=r.gl,f=a&k.UNIFORM;f||(yt(c)?c.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null));var d,p=N(o)?ge(o,4):ge(o.byteLength,4);if(i.gl_buffer_pages=[],f){for(var _=p;_>0;)i.gl_buffer_pages.push(i.createBufferPage(Math.min(_,u),a,l)),_-=u;d=u}else i.gl_buffer_pages.push(i.createBufferPage(p,a,l)),d=p;return i.pageByteSize=d,i.byteSize=p,i.usage=a,i.gl_target=Pt(a),N(o)||i.setSubData(0,new Uint8Array(o.buffer)),f||(yt(c)?c.bindVertexArray(i.device.currentBoundVAO):r.OES_vertex_array_object.bindVertexArrayOES(i.device.currentBoundVAO)),i}n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=t.byteLength-r);for(var i=this.device.gl,o=this.pageByteSize,a=e+n,s=e,l=e%o;a>s;){var u=yt(i)?i.COPY_WRITE_BUFFER:this.gl_target,c=Mt(this,s);if(c.ubo)return;i.bindBuffer(u,c),yt(i)?i.bufferSubData(u,l,t,r,Math.min(a-s,o)):i.bufferSubData(u,l,t),s+=o,l=0,r+=o,this.device.debugGroupStatisticsBufferUpload()}},t.prototype.destroy=function(){e.prototype.destroy.call(this);for(var t=0;this.gl_buffer_pages.length>t;t++)this.gl_buffer_pages[t].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[t]);this.gl_buffer_pages=[]},t.prototype.createBufferPage=function(e,t,r){var n=this.device.gl,i=t&k.UNIFORM;if(!yt(n)&&i)return{ubo:!0};var o=this.device.ensureResourceExists(n.createBuffer()),a=Pt(t),s=function(e){switch(e){case V.STATIC:return O.STATIC_DRAW;case V.DYNAMIC:return O.DYNAMIC_DRAW}}(r);return n.bindBuffer(a,o),n.bufferData(a,e,s),o}}(St),function(e){function t(t){var r,n,i,o,a,s=t.device,u=t.descriptor,c=e.call(this,{id:t.id,device:s})||this;c.type=M.InputLayout;var f=u.vertexBufferDescriptors,d=u.indexBufferFormat,p=u.program;fe(d===te.U16_R||d===te.U32_R||null===d);var _=null!==d?function(e){switch(e){case te.U8_R:return O.UNSIGNED_BYTE;case te.U16_R:return O.UNSIGNED_SHORT;case te.U32_R:return O.UNSIGNED_INT;default:throw Error("whoops")}}(d):null,h=null!==d?ue(d):null,E=c.device.gl,R=c.device.ensureResourceExists(yt(E)?E.createVertexArray():s.OES_vertex_array_object.createVertexArrayOES());yt(E)?E.bindVertexArray(R):s.OES_vertex_array_object.bindVertexArrayOES(R),E.bindBuffer(E.ARRAY_BUFFER,Mt(c.device.fallbackVertexBuffer));try{for(var v=l(u.vertexBufferDescriptors),T=v.next();!T.done;T=v.next()){var A=T.value,m=A.stepMode,S=A.attributes;try{for(var y=(i=void 0,l(S)),C=y.next();!C.done;C=y.next()){var P=C.value,N=P.shaderLocation,I=P.format,x=P.divisor,B=void 0===x?1:x,D=yt(E)?N:null===(a=p.attributes[N])||void 0===a?void 0:a.location,L=Nt(I);if(P.vertexFormat=L,!g(D))Ct(I),E.vertexAttribPointer(D,L.size,L.type,L.normalized,0,0),m===X.INSTANCE&&(yt(E)?E.vertexAttribDivisor(D,B):s.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(D,B)),E.enableVertexAttribArray(D)}}catch(e){i={error:e}}finally{try{C&&!C.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{T&&!T.done&&(n=v.return)&&n.call(v)}finally{if(r)throw r.error}}return yt(E)?E.bindVertexArray(null):s.OES_vertex_array_object.bindVertexArrayOES(null),c.vertexBufferDescriptors=f,c.vao=R,c.indexBufferFormat=d,c.indexBufferType=_,c.indexBufferCompByteSize=h,c.program=p,c}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.currentBoundVAO===this.vao&&(yt(this.device.gl)?(this.device.gl.bindVertexArray(null),this.device.gl.deleteVertexArray(this.vao)):(this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao)),this.device.currentBoundVAO=null)}}(St);var xt,Bt=function(e){function t(t){var r=t.device,n=t.descriptor,o=t.fake,a=e.call(this,{id:t.id,device:r})||this;a.type=M.Texture,n=i({dimension:H.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},n);var s,l,u=a.device.gl,c=a.clampmipLevelCount(n);if(a.immutable=n.usage===Y.RENDER_TARGET,a.pixelStore=n.pixelStore,a.format=n.format,a.dimension=n.dimension,a.formatKind=ce(n.format),a.width=n.width,a.height=n.height,a.depthOrArrayLayers=n.depthOrArrayLayers,a.mipmaps=c>=1,!o){l=a.device.ensureResourceExists(u.createTexture());var f=a.device.translateTextureType(n.format),d=a.device.translateTextureInternalFormat(n.format);if(a.device.setActiveTexture(u.TEXTURE0),a.device.currentTextures[0]=null,a.preprocessImage(),n.dimension===H.TEXTURE_2D){if(u.bindTexture(s=O.TEXTURE_2D,l),a.immutable)if(yt(u))u.texStorage2D(s,c,d,n.width,n.height);else{var p=(d===O.DEPTH_COMPONENT||a.isNPOT(),0);(a.format!==te.D32F&&a.format!==te.D24_S8||yt(u)||r.WEBGL_depth_texture)&&(u.texImage2D(s,p,d,n.width,n.height,0,d,f,null),a.mipmaps&&(a.mipmaps=!1,u.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,O.LINEAR),u.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,O.CLAMP_TO_EDGE),u.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,O.CLAMP_TO_EDGE)))}fe(1===n.depthOrArrayLayers)}else if(n.dimension===H.TEXTURE_2D_ARRAY)u.bindTexture(s=O.TEXTURE_2D_ARRAY,l),a.immutable&&yt(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else if(n.dimension===H.TEXTURE_3D)u.bindTexture(s=O.TEXTURE_3D,l),a.immutable&&yt(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else{if(n.dimension!==H.TEXTURE_CUBE_MAP)throw Error("whoops");u.bindTexture(s=O.TEXTURE_CUBE_MAP,l),a.immutable&&yt(u)&&u.texStorage2D(s,c,d,n.width,n.height),fe(6===n.depthOrArrayLayers)}}return a.gl_texture=l,a.gl_target=s,a.mipLevelCount=c,a}return n(t,e),t.prototype.setImageData=function(e,t){void 0===t&&(t=0);var r=this.device.gl;!function(e){switch(ae(e)){case $.BC1:case $.BC2:case $.BC3:case $.BC4_UNORM:case $.BC4_SNORM:case $.BC5_UNORM:case $.BC5_SNORM:return!0;default:;}}(this.format);var n=this.gl_target===O.TEXTURE_3D||this.gl_target===O.TEXTURE_2D_ARRAY,i=this.gl_target===O.TEXTURE_CUBE_MAP,o=Object.prototype.toString.call(e[0])in Tt;this.device.setActiveTexture(r.TEXTURE0),this.device.currentTextures[0]=null;var a,s,l=e[0];o?(a=this.width,s=this.height):(s=l.height,this.width=a=l.width,this.height=s),r.bindTexture(this.gl_target,this.gl_texture);var u=this.device.translateTextureFormat(this.format),c=this.device.translateTextureType(this.format);this.preprocessImage();for(var f=0;this.depthOrArrayLayers>f;f++){var d=e[f],p=this.gl_target;i&&(p=O.TEXTURE_CUBE_MAP_POSITIVE_X+f%6),this.immutable?r.texSubImage2D(p,t,0,0,a,s,u,c,d):yt(r)?n?r.texImage3D(p,t,u,a,s,this.depthOrArrayLayers,0,u,c,d):r.texImage2D(p,t,u,a,s,0,u,c,d):o?r.texImage2D(p,t,u,a,s,0,u,c,d):r.texImage2D(p,t,u,u,c,d)}this.mipmaps&&this.generateMipmap(n)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteTexture(this.gl_texture)},t.prototype.clampmipLevelCount=function(e){if(e.dimension===H.TEXTURE_2D_ARRAY&&e.depthOrArrayLayers>1&&ae(e.format)===$.BC1)for(var t=e.width,r=e.height,n=0;e.mipLevelCount>n;n++){if(2>=t||2>=r)return n-1;t=Math.max(t/2|0,1),r=Math.max(r/2|0,1)}return e.mipLevelCount},t.prototype.preprocessImage=function(){var e=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&e.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&e.pixelStorei(O.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&e.pixelStorei(O.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))},t.prototype.generateMipmap=function(e){void 0===e&&(e=!1);var t=this.device.gl;return!yt(t)&&this.isNPOT()||this.gl_texture&&this.gl_target&&(t.bindTexture(this.gl_target,this.gl_texture),e?(t.texParameteri(this.gl_target,O.TEXTURE_BASE_LEVEL,0),t.texParameteri(this.gl_target,O.TEXTURE_MAX_LEVEL,Math.log2(this.width)),t.texParameteri(this.gl_target,O.TEXTURE_MIN_FILTER,O.LINEAR_MIPMAP_LINEAR),t.texParameteri(this.gl_target,O.TEXTURE_MAG_FILTER,O.LINEAR)):t.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,O.NEAREST_MIPMAP_LINEAR),t.generateMipmap(this.gl_target),t.bindTexture(this.gl_target,null)),this},t.prototype.isNPOT=function(){return!yt(this.device.gl)&&(!Te(this.width)||!Te(this.height))},t}(St);let Dt;!function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=M.RenderTarget,i.gl_renderbuffer=null,i.texture=null;var o=i.device.gl,a=n.format,s=n.width,l=n.height,u=n.sampleCount,c=void 0===u?1:u,f=n.texture,d=!1;if(a!==te.D32F&&a!==te.D24_S8||!f||yt(o)||r.WEBGL_depth_texture||(f.destroy(),i.texture=null,d=!0),!d&&f)i.texture=f;else{i.gl_renderbuffer=i.device.ensureResourceExists(o.createRenderbuffer()),o.bindRenderbuffer(o.RENDERBUFFER,i.gl_renderbuffer);var p=i.device.translateTextureInternalFormat(a,!0);yt(o)&&c>1?o.renderbufferStorageMultisample(O.RENDERBUFFER,c,p,s,l):o.renderbufferStorage(O.RENDERBUFFER,p,s,l)}return i.format=a,i.width=s,i.height=l,i.sampleCount=c,i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),null!==this.gl_renderbuffer&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()}}(St),function(e){e[e.NeedsCompile=0]="NeedsCompile",e[e.Compiling=1]="Compiling",e[e.NeedsBind=2]="NeedsBind",e[e.ReadyToUse=3]="ReadyToUse"}(xt||(xt={})),function(e){function t(t,r){var n=t.descriptor,i=e.call(this,{id:t.id,device:t.device})||this;i.rawVertexGLSL=r,i.type=M.Program,i.uniformSetters={},i.attributes=[];var o=i.device.gl;return i.descriptor=n,i.gl_program=i.device.ensureResourceExists(o.createProgram()),i.gl_shader_vert=null,i.gl_shader_frag=null,i.compileState=xt.NeedsCompile,i.tryCompileProgram(),i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)},t.prototype.tryCompileProgram=function(){var e,t;fe(this.compileState===xt.NeedsCompile);var r=this.descriptor,n=this.device.gl;(null===(e=r.vertex)||void 0===e?void 0:e.glsl)&&(null===(t=r.fragment)||void 0===t?void 0:t.glsl)&&(this.gl_shader_vert=this.compileShader(r.vertex.glsl,n.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(r.fragment.glsl,n.FRAGMENT_SHADER),n.attachShader(this.gl_program,this.gl_shader_vert),n.attachShader(this.gl_program,this.gl_shader_frag),n.linkProgram(this.gl_program),this.compileState=xt.Compiling,yt(n)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))},t.prototype.readAttributesFromLinkedProgram=function(){for(var e,t=this.device.gl,r=t.getProgramParameter(this.gl_program,t.ACTIVE_ATTRIBUTES),n=function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""})),t}(this.descriptor.vertex.glsl),i=function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,n,i){var o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r}(this.rawVertexGLSL,n),o=function(r){var n=t.getActiveAttrib(a.gl_program,r),o=n.name,s=n.type,l=n.size,u=t.getAttribLocation(a.gl_program,o),c=null===(e=i.find((function(e){return e.name===o})))||void 0===e?void 0:e.location;0>u||g(c)||(a.attributes[c]={name:o,location:u,type:s,size:l})},a=this,s=0;r>s;s++)o(s)},t.prototype.readUniformLocationsFromLinkedProgram=function(){for(var e=this.device.gl,t=e.getProgramParameter(this.gl_program,e.ACTIVE_UNIFORMS),r=0;t>r;r++){var n=e.getActiveUniform(this.gl_program,r),i=it(n.name).name,o=e.getUniformLocation(this.gl_program,i);if(this.uniformSetters[i]=vt(e,o,n),n&&n.size>1)for(var a=0;n.size>a;a++)o=e.getUniformLocation(this.gl_program,"".concat(i,"[").concat(a,"]")),this.uniformSetters["".concat(i,"[").concat(a,"]")]=vt(e,o,n)}},t.prototype.compileShader=function(e,t){var r=this.device.gl,n=this.device.ensureResourceExists(r.createShader(t));return r.shaderSource(n,e),r.compileShader(n),n},t.prototype.setUniformsLegacy=function(e){void 0===e&&(e={});var t=this.device.gl;if(!yt(t)){var r=!1;for(var n in e){r||(t.useProgram(this.gl_program),r=!0);var i=this.uniformSetters[n];if(i){var o=e[n];o instanceof Bt&&(o=o.textureIndex),i(o)}}}return this}}(St),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.QueryPool;var i=n.device.gl;if(yt(i)){var o=r.type;n.gl_query=Ce(r.elemCount,(function(){return n.device.ensureResourceExists(i.createQuery())})),n.gl_query_type=function(e){if(e===Q.OcclusionConservative)return O.ANY_SAMPLES_PASSED_CONSERVATIVE;throw Error("whoops")}(o)}return n}n(t,e),t.prototype.queryResultOcclusion=function(e){var t=this.device.gl;if(yt(t)){var r=this.gl_query[e];return t.getQueryParameter(r,t.QUERY_RESULT_AVAILABLE)?!!t.getQueryParameter(r,t.QUERY_RESULT):null}return null},t.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.device.gl;if(yt(t))for(var r=0;this.gl_query.length>r;r++)t.deleteQuery(this.gl_query[r])}}(St),function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=M.Readback,r.gl_pbo=null,r.gl_sync=null,r}n(t,e),t.prototype.clientWaitAsync=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=10);var n=this.device.gl;return new Promise((function(i,o){!function a(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?i():setTimeout(a,P(r,0,n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL)):o()}()}))},t.prototype.getBufferSubDataAsync=function(e,t,r,n,i,o){return a(this,void 0,void 0,(function(){var a;return s(this,(function(s){switch(s.label){case 0:return yt(a=this.device.gl)?(this.gl_sync=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0),a.flush(),[4,this.clientWaitAsync(this.gl_sync,0,10)]):[3,2];case 1:return s.sent(),a.bindBuffer(e,t),a.getBufferSubData(e,r,n,i,o),a.bindBuffer(e,null),[2,n];case 2:return[2]}}))}))},t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),void 0===u&&(u=o.byteLength||0),a(this,void 0,void 0,(function(){var a,c,f,d,p;return s(this,(function(s){var _;return a=this.device.gl,f=this.device.translateTextureFormat((c=e).format),d=this.device.translateTextureType(c.format),p=le(ae(_=c.format))*oe(_),yt(a)?(this.gl_pbo=this.device.ensureResourceExists(a.createBuffer()),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.bufferData(a.PIXEL_PACK_BUFFER,u,a.STREAM_READ),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),a.bindFramebuffer(O.READ_FRAMEBUFFER,this.device.readbackFramebuffer),a.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,c.gl_texture,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.readPixels(t,r,n,i,f,d,l*p),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),[2,this.getBufferSubDataAsync(a.PIXEL_PACK_BUFFER,this.gl_pbo,0,o,l,0)]):[2,this.readTextureSync(e,t,r,n,i,o,l,u)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){void 0===s&&(s=o.byteLength||0);var l=this.device.gl,u=e,c=this.device.translateTextureType(u.format);return l.bindFramebuffer(O.FRAMEBUFFER,this.device.readbackFramebuffer),l.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,u.gl_texture,0),l.pixelStorei(l.PACK_ALIGNMENT,4),l.readPixels(t,r,n,i,l.RGBA,c,o),o},t.prototype.readBuffer=function(e,t,r,n,i){return a(this,void 0,void 0,(function(){var o;return s(this,(function(a){return yt(o=this.device.gl)?[2,this.getBufferSubDataAsync(o.ARRAY_BUFFER,Mt(e,t),t,r,n,i)]:[2,Promise.reject()]}))}))},t.prototype.destroy=function(){e.prototype.destroy.call(this),yt(this.device.gl)&&(null!==this.gl_sync&&this.device.gl.deleteSync(this.gl_sync),null!==this.gl_pbo&&this.device.gl.deleteBuffer(this.gl_pbo))}}(St),function(e){function t(t){var r,n,o=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;return a.type=M.RenderPipeline,a.drawMode=function(e){switch(e){case w.TRIANGLES:return O.TRIANGLES;case w.POINTS:return O.POINTS;case w.TRIANGLE_STRIP:return O.TRIANGLE_STRIP;case w.LINES:return O.LINES;case w.LINE_STRIP:return O.LINE_STRIP;default:throw Error("Unknown primitive topology mode")}}(null!==(r=o.topology)&&void 0!==r?r:w.TRIANGLES),a.program=o.program,a.inputLayout=o.inputLayout,a.megaState=i(i({},xe(De)),o.megaStateDescriptor),a.colorAttachmentFormats=o.colorAttachmentFormats.slice(),a.depthStencilAttachmentFormat=o.depthStencilAttachmentFormat,a.sampleCount=null!==(n=o.sampleCount)&&void 0!==n?n:1,a}n(t,e)}(St),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=M.ComputePipeline,n.descriptor=r,n}n(t,e)}(St),function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=M.Sampler;var a=o.device.gl;if(yt(a)){var s=o.device.ensureResourceExists(a.createSampler());a.samplerParameteri(s,O.TEXTURE_WRAP_S,It(i.addressModeU)),a.samplerParameteri(s,O.TEXTURE_WRAP_T,It(i.addressModeV)),a.samplerParameteri(s,O.TEXTURE_WRAP_R,It(null!==(r=i.addressModeW)&&void 0!==r?r:i.addressModeU)),a.samplerParameteri(s,O.TEXTURE_MIN_FILTER,Ot(i.minFilter,i.mipmapFilter)),a.samplerParameteri(s,O.TEXTURE_MAG_FILTER,Ot(i.magFilter,G.NO_MIP)),void 0!==i.lodMinClamp&&a.samplerParameterf(s,O.TEXTURE_MIN_LOD,i.lodMinClamp),void 0!==i.lodMaxClamp&&a.samplerParameterf(s,O.TEXTURE_MAX_LOD,i.lodMaxClamp),void 0!==i.compareFunction&&(a.samplerParameteri(s,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.samplerParameteri(s,a.TEXTURE_COMPARE_FUNC,i.compareFunction));var l=null!==(n=i.maxAnisotropy)&&void 0!==n?n:1;l>1&&null!==o.device.EXT_texture_filter_anisotropic&&(fe(i.minFilter===U.BILINEAR&&i.magFilter===U.BILINEAR&&i.mipmapFilter===G.LINEAR),a.samplerParameterf(s,o.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,l)),o.gl_sampler=s}else o.descriptor=i;return o}n(t,e),t.prototype.setTextureParameters=function(e,t,r){var n,i=this.device.gl,o=this.descriptor;this.isNPOT(t,r)?i.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,O.LINEAR):i.texParameteri(e,O.TEXTURE_MIN_FILTER,Ot(o.minFilter,o.mipmapFilter)),i.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,It(o.addressModeU)),i.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,It(o.addressModeV)),i.texParameteri(e,O.TEXTURE_MAG_FILTER,Ot(o.magFilter,G.NO_MIP));var a=null!==(n=o.maxAnisotropy)&&void 0!==n?n:1;a>1&&null!==this.device.EXT_texture_filter_anisotropic&&(fe(o.minFilter===U.BILINEAR&&o.magFilter===U.BILINEAR&&o.mipmapFilter===G.LINEAR),i.texParameteri(e,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a))},t.prototype.destroy=function(){e.prototype.destroy.call(this),yt(this.device.gl)&&this.device.gl.deleteSampler(this.gl_sampler)},t.prototype.isNPOT=function(e,t){return!Te(e)||!Te(t)}}(St);const Lt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&Lt.decode();let Ft=null;function bt(){return null!==Ft&&0!==Ft.byteLength||(Ft=new Uint8Array(Dt.memory.buffer)),Ft}function Ut(e,t){return e>>>=0,Lt.decode(bt().subarray(e,e+t))}const Gt=Array(128).fill(void 0);Gt.push(void 0,null,!0,!1);let wt=Gt.length;function kt(e){return Gt[e]}function Vt(e){const t=kt(e);return function(e){132>e||(Gt[e]=wt,wt=e)}(e),t}let Xt=0;const Wt="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Ht="function"==typeof Wt.encodeInto?function(e,t){return Wt.encodeInto(e,t)}:function(e,t){const r=Wt.encode(e);return t.set(r),{read:e.length,written:r.length}};function Yt(e,t,r){if(void 0===r){const r=Wt.encode(e),n=t(r.length,1)>>>0;return bt().subarray(n,n+r.length).set(r),Xt=r.length,n}let n=e.length,i=t(n,1)>>>0;const o=bt();let a=0;for(;n>a;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),i=r(i,n,n=a+3*e.length,1)>>>0;const t=bt().subarray(i+a,i+n);a+=Ht(e,t).written}return Xt=a,i}let zt=null;function Kt(){return null!==zt&&0!==zt.byteLength||(zt=new Int32Array(Dt.memory.buffer)),zt}function jt(e,t,r){let n,i;try{const s=Dt.__wbindgen_add_to_stack_pointer(-16),l=Yt(e,Dt.__wbindgen_malloc,Dt.__wbindgen_realloc),u=Xt,c=Yt(t,Dt.__wbindgen_malloc,Dt.__wbindgen_realloc);Dt.glsl_compile(s,l,u,c,Xt,r);var o=Kt()[s/4+0],a=Kt()[s/4+1];return n=o,i=a,Ut(o,a)}finally{Dt.__wbindgen_add_to_stack_pointer(16),Dt.__wbindgen_free(n,i,1)}}function Zt(){const e={wbg:{}};return e.wbg.__wbindgen_string_new=function(e,t){return function(e){wt===Gt.length&&Gt.push(Gt.length+1);const t=wt;return wt=Gt[t],Gt[t]=e,t}(Ut(e,t))},e.wbg.__wbindgen_object_drop_ref=function(e){Vt(e)},e.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(kt(e))},e.wbg.__wbg_log_576ca876af0d4a77=function(e,t){console.log(kt(e),kt(t))},e.wbg.__wbindgen_throw=function(e,t){throw Error(Ut(e,t))},e}async function qt(e){if(void 0!==Dt)return Dt;const t=Zt();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:r,module:n}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{const r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}(await e,t);return function(e,t){return Dt=e.exports,qt.__wbindgen_wasm_module=t,zt=null,Ft=null,Dt}(r,n)}var Qt,$t;function Jt(e){if(e===te.U8_R_NORM)return"r8unorm";if(e===te.U8_RG_NORM)return"rg8unorm";if(e===te.U8_RGBA_RT)return"bgra8unorm";if(e===te.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===te.U8_RGBA_NORM)return"rgba8unorm";if(e===te.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===te.S8_R_NORM)return"r8snorm";if(e===te.S8_RG_NORM)return"rg8snorm";if(e===te.S8_RGBA_NORM)return"rgba8snorm";if(e===te.U32_R)return"r32uint";if(e===te.F16_RGBA)return"rgba16float";if(e===te.F32_RGBA)return"rgba32float";if(e===te.D24)return"depth24plus";if(e===te.D24_S8)return"depth24plus-stencil8";if(e===te.D32F)return"depth32float";if(e===te.D32F_S8)return"depth32float-stencil8";if(e===te.BC1)return"bc1-rgba-unorm";if(e===te.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===te.BC2)return"bc2-rgba-unorm";if(e===te.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===te.BC3)return"bc3-rgba-unorm";if(e===te.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===te.BC4_SNORM)return"bc4-r-snorm";if(e===te.BC4_UNORM)return"bc4-r-unorm";if(e===te.BC5_SNORM)return"bc5-rg-snorm";if(e===te.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function er(e){if(e===H.TEXTURE_2D)return"2d";if(e===H.TEXTURE_CUBE_MAP)return"cube";if(e===H.TEXTURE_2D_ARRAY)return"2d-array";if(e===H.TEXTURE_3D)return"3d";throw Error("whoops")}function tr(e){if(e===b.CLAMP_TO_EDGE)return"clamp-to-edge";if(e===b.REPEAT)return"repeat";if(e===b.MIRRORED_REPEAT)return"mirror-repeat";throw Error("whoops")}function rr(e){if(e===U.BILINEAR)return"linear";if(e===U.POINT)return"nearest";throw Error("whoops")}function nr(e){if(e===G.LINEAR)return"linear";if(e===G.NEAREST)return"nearest";if(e===G.NO_MIP)return"nearest";throw Error("whoops")}function ir(e){return e.gpuBuffer}function or(e){if(e===Q.OcclusionConservative)return"occlusion";throw Error("whoops")}function ar(e){switch(e){case w.TRIANGLES:return"triangle-list";case w.POINTS:return"point-list";case w.TRIANGLE_STRIP:return"triangle-strip";case w.LINES:return"line-list";case w.LINE_STRIP:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function sr(e){if(e===D.NONE)return"none";if(e===D.FRONT)return"front";if(e===D.BACK)return"back";throw Error("whoops")}function lr(e){if(e===B.CCW)return"ccw";if(e===B.CW)return"cw";throw Error("whoops")}function ur(e){if(e===L.ZERO)return"zero";if(e===L.ONE)return"one";if(e===L.SRC)return"src";if(e===L.ONE_MINUS_SRC)return"one-minus-src";if(e===L.DST)return"dst";if(e===L.ONE_MINUS_DST)return"one-minus-dst";if(e===L.SRC_ALPHA)return"src-alpha";if(e===L.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(e===L.DST_ALPHA)return"dst-alpha";if(e===L.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(e===L.CONST)return"constant";if(e===L.ONE_MINUS_CONSTANT)return"one-minus-constant";if(e===L.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw Error("whoops")}function cr(e){if(e===F.ADD)return"add";if(e===F.SUBSTRACT)return"subtract";if(e===F.REVERSE_SUBSTRACT)return"reverse-subtract";if(e===F.MIN)return"min";if(e===F.MAX)return"max";throw Error("whoops")}function fr(e){return{operation:cr(e.blendMode),srcFactor:ur(e.blendSrcFactor),dstFactor:ur(e.blendDstFactor)}}function dr(e){return e.blendMode===F.ADD&&e.blendSrcFactor===L.ONE&&e.blendDstFactor===L.ZERO}function pr(e){return dr(e.rgbBlendState)&&dr(e.alphaBlendState)?void 0:{color:fr(e.rgbBlendState),alpha:fr(e.alphaBlendState)}}function _r(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:Jt(t),blend:pr(e),writeMask:e.channelWriteMask}}(t,e[r])}))}function hr(e){if(e===x.NEVER)return"never";if(e===x.LESS)return"less";if(e===x.EQUAL)return"equal";if(e===x.LEQUAL)return"less-equal";if(e===x.GREATER)return"greater";if(e===x.NOTEQUAL)return"not-equal";if(e===x.GEQUAL)return"greater-equal";if(e===x.ALWAYS)return"always";throw Error("whoops")}function Er(e){if(e===K.KEEP)return"keep";if(e===K.REPLACE)return"replace";if(e===K.ZERO)return"zero";if(e===K.DECREMENT_CLAMP)return"decrement-clamp";if(e===K.DECREMENT_WRAP)return"decrement-wrap";if(e===K.INCREMENT_CLAMP)return"increment-clamp";if(e===K.INCREMENT_WRAP)return"increment-wrap";if(e===K.INVERT)return"invert";throw Error("whoops")}function Rr(e){if(e===X.VERTEX)return"vertex";if(e===X.INSTANCE)return"instance";throw Error("whoops")}function vr(e){if(e===te.U8_R)return"uint8x2";if(e===te.U8_RG)return"uint8x2";if(e===te.U8_RGB)return"uint8x4";if(e===te.U8_RGBA)return"uint8x4";if(e===te.U8_RG_NORM)return"unorm8x2";if(e===te.U8_RGBA_NORM)return"unorm8x4";if(e===te.S8_RGB_NORM)return"snorm8x4";if(e===te.S8_RGBA_NORM)return"snorm8x4";if(e===te.U16_RG_NORM)return"unorm16x2";if(e===te.U16_RGBA_NORM)return"unorm16x4";if(e===te.S16_RG_NORM)return"snorm16x2";if(e===te.S16_RGBA_NORM)return"snorm16x4";if(e===te.S16_RG)return"uint16x2";if(e===te.F16_RG)return"float16x2";if(e===te.F16_RGBA)return"float16x4";if(e===te.F32_R)return"float32";if(e===te.F32_RG)return"float32x2";if(e===te.F32_RGB)return"float32x3";if(e===te.F32_RGBA)return"float32x4";throw"whoops"}function Tr(e,t,r,n){switch(void 0===r&&(r=!1),e){case te.S8_R:case te.S8_R_NORM:case te.S8_RG_NORM:case te.S8_RGB_NORM:case te.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case te.U8_R:case te.U8_R_NORM:case te.U8_RG:case te.U8_RG_NORM:case te.U8_RGB:case te.U8_RGB_NORM:case te.U8_RGB_SRGB:case te.U8_RGBA:case te.U8_RGBA_NORM:case te.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case te.S16_R:case te.S16_RG:case te.S16_RG_NORM:case te.S16_RGB_NORM:case te.S16_RGBA:case te.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case te.U16_R:case te.U16_RGB:case te.U16_RGBA_5551:case te.U16_RGBA_NORM:case te.U16_RG_NORM:case te.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case te.S32_R:var l=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&l.set(new Int32Array(n)),l;case te.U32_R:case te.U32_RG:var u=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&u.set(new Uint32Array(n)),u;case te.F32_R:case te.F32_RG:case te.F32_RGB:case te.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(Qt||(Qt={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}($t||($t={}));var Ar=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,i}return n(t,e),t.prototype.destroy=function(){},t}(re),mr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.Bindings;var o=r.pipeline;fe(!!o);var a=r.uniformBufferBindings,s=r.storageBufferBindings,l=r.samplerBindings;n.numUniformBuffers=(null==a?void 0:a.length)||0;var u=[[],[]],c=0;if(s&&s.length)for(var f=0;s.length>f;f++){var d=r.storageBufferBindings[f],p=d.binding,_=d.size,h=d.offset,E={buffer:ir(d.buffer),offset:null!=h?h:0,size:_};u[0].push({binding:null!=p?p:c++,resource:E})}if(a&&a.length)for(f=0;a.length>f;f++){var R=r.uniformBufferBindings[f];p=R.binding,_=R.size,h=R.offset,E={buffer:ir(R.buffer),offset:null!=h?h:0,size:_};u[0].push({binding:null!=p?p:c++,resource:E})}if(l&&l.length){c=0;for(f=0;l.length>f;f++){var v=i(i({},l[f]),Ue),T=null!==(p=r.samplerBindings[f]).texture?p.texture:n.device.getFallbackTexture(v);v.dimension=T.dimension,v.formatKind=ce(T.format),u[1].push({binding:c++,resource:T.gpuTextureView});var A=null!==p.sampler?p.sampler:n.device.getFallbackSampler(v),m=A.gpuSampler;u[1].push({binding:c++,resource:m})}}return n.gpuBindGroup=u.filter((function(e){return e.length>0})).map((function(e,t){return n.device.device.createBindGroup({layout:o.getBindGroupLayout(t),entries:e})})),n}return n(t,e),t}(Ar),gr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.Buffer;var i=r.usage,o=r.viewOrSize,a=!!(i&k.MAP_READ);n.usage=function(e){var t=0;return e&k.INDEX&&(t|=GPUBufferUsage.INDEX),e&k.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&k.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&k.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&k.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),t|GPUBufferUsage.COPY_DST}(i),a&&(n.usage=k.MAP_READ|k.COPY_DST);var s=!N(o);(n.view=N(o)?null:o,n.size=N(o)?ge(o,4):ge(o.byteLength,4),N(o))?n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!a&&s}):(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new(o&&o.constructor||Float32Array)(n.gpuBuffer.getMappedRange()).set(o),n.gpuBuffer.unmap());return n}return n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var l=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(l),r=0,o=0,a=s,n=s}for(var u=15728640,c=0;a-(o+c)>u;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,u),c+=u;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(Ar),Sr=function(){function e(){this.commandEncoder=null,this.gpuComputePassEncoder=null}return e.prototype.dispatchWorkgroups=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.dispatchWorkgroupsIndirect=function(e,t){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,t)},e.prototype.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},e.prototype.beginComputePass=function(){fe(null===this.gpuComputePassEncoder),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=de(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e){this.gpuComputePassEncoder.setBindGroup(0,e.gpuBindGroup[0])},e.prototype.pushDebugGroup=function(e){this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuComputePassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuComputePassEncoder.insertDebugMarker(e)},e}(),yr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var o=r.program.computeStage;if(null===o)return n;var a={layout:"auto",compute:i({},o)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(Ar),Cr=function(e){function t(t){var r,n,i,o,a=t.descriptor,s=e.call(this,{id:t.id,device:t.device})||this;s.type=M.InputLayout;var u=[];try{for(var c=l(a.vertexBufferDescriptors),f=c.next();!f.done;f=c.next()){var d=f.value,p=d.attributes;u.push({arrayStride:d.arrayStride,stepMode:Rr(d.stepMode),attributes:[]});try{for(var _=(i=void 0,l(p)),h=_.next();!h.done;h=_.next()){var E=h.value,R=E.offset;u[u.length-1].attributes.push({shaderLocation:E.shaderLocation,format:vr(E.format),offset:R})}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return s.indexFormat=function(e){if(null!==e){if(e===te.U16_R)return"uint16";if(e===te.U32_R)return"uint32";throw Error("whoops")}}(a.indexBufferFormat),s.buffers=u,s}return n(t,e),t}(Ar),Pr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=M.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.vertex&&(n.vertexStage=n.createShaderStage(r.vertex,"vertex")),r.fragment&&(n.fragmentStage=n.createShaderStage(r.fragment,"fragment")),r.compute&&(n.computeStage=n.createShaderStage(r.compute,"compute")),n}return n(t,e),t.prototype.setUniformsLegacy=function(e){},t.prototype.createShaderStage=function(e,t){var r,n,i=e.glsl,o=e.entryPoint,a=e.wgsl;if(!a)try{a=this.device.glsl_compile(i,t,!1)}catch(e){throw console.error(e,i),Error("whoops")}var s=function(e){if(!a.includes(e))return"continue";a=(a=a.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),(function(t,r){return"vec4<f32>(textureSample(T_".concat(e).concat(r,"), 0.0, 0.0, 0.0);")}))};try{for(var u=l(["u_TextureFramebufferDepth"]),c=u.next();!c.done;c=u.next()){s(c.value)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return{module:this.device.device.createShaderModule({code:a}),entryPoint:o||"main"}},t}(Ar),Nr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=M.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:or(r.type),count:i}),n.resolveBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),n.cpuBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n.results=null,n}return n(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}(Ar),Ir=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=M.Readback,r}return n(t,e),t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),a(this,void 0,void 0,(function(){var a,u,c,f,d,p;return s(this,(function(s){return 0,u=this.getBlockInformationFromFormat((a=e).gpuTextureformat),d=this.device.createBuffer({usage:k.STORAGE|k.MAP_READ|k.COPY_DST,hint:V.STATIC,viewOrSize:f=(c=256*Math.ceil(Math.ceil(n/u.width)*u.length/256))*i}),(p=this.device.device.createCommandEncoder()).copyTextureToBuffer({texture:a.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:d.gpuBuffer,offset:0,bytesPerRow:c},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([p.finish()]),[2,this.readBuffer(d,0,o.byteLength===f?o:null,l,f,a.format)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){throw Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")},t.prototype.readBuffer=function(e,t,r,n,i,o,a,s){var l=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=te.U8_RGB),void 0===a&&(a=!1);var u=e,c=i||u.size,f=r||u.view,d=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||ue(o),p=u;if(!(u.usage&k.MAP_READ&&u.usage&k.COPY_DST)){var _=this.device.device.createCommandEncoder();p=this.device.createBuffer({usage:k.STORAGE|k.MAP_READ|k.COPY_DST,hint:V.STATIC,viewOrSize:c}),_.copyBufferToBuffer(u.gpuBuffer,t,p.gpuBuffer,0,c),this.device.device.queue.submit([_.finish()])}return new Promise((function(e,r){p.gpuBuffer.mapAsync($t.READ,t,c).then((function(){var r=p.gpuBuffer.getMappedRange(t,c),n=f;if(a)n=null===n?Tr(o,c,!0,r):Tr(o,n.buffer,void 0,r);else if(null===n)switch(d){case 1:(n=new Uint8Array(c)).set(new Uint8Array(r));break;case 2:n=l.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r);break;case 4:(n=new Float32Array(c/4)).set(new Float32Array(r))}else switch(d){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=l.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r,f);break;case 4:var i=f&&f.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}p.gpuBuffer.unmap(),e(n)}),(function(e){return r(e)}))}))},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r},t.prototype.getBlockInformationFromFormat=function(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}},t}(Ar),Or=function(){function e(e){this.device=e,this.commandEncoder=null,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.getTextureView=function(e,t){return fe(e.mipLevelCount>t),1===e.mipLevelCount?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){var t,r,n,i,o,a;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var s=e.colorAttachment.length;this.gfxColorAttachment.length=s,this.gfxColorResolveTo.length=s;for(var l=0;e.colorAttachment.length>l;l++){var u=e.colorAttachment[l],c=e.colorResolveTo[l];if(null===u&&null!==c&&(u=c,c=null),this.gfxColorAttachment[l]=u,this.gfxColorResolveTo[l]=c,this.gfxColorAttachmentLevel[l]=(null===(t=e.colorAttachmentLevel)||void 0===t?void 0:t[l])||0,this.gfxColorResolveToLevel[l]=(null===(r=e.colorResolveToLevel)||void 0===r?void 0:r[l])||0,null===u){this.gpuColorAttachments.length=l,this.gfxColorAttachment.length=l,this.gfxColorResolveTo.length=l;break}void 0===this.gpuColorAttachments[l]&&(this.gpuColorAttachments[l]={}),(d=this.gpuColorAttachments[l]).view=this.getTextureView(u,(null===(n=this.gfxColorAttachmentLevel)||void 0===n?void 0:n[l])||0);var f=null!==(o=null===(i=e.colorClearColor)||void 0===i?void 0:i[l])&&void 0!==o?o:"load";"load"===f?d.loadOp="load":(d.loadOp="clear",d.clearValue=f),d.storeOp=(null===(a=e.colorStore)||void 0===a?void 0:a[l])?"store":"discard",d.resolveTarget=void 0,null!==c&&(u.sampleCount>1?d.resolveTarget=this.getTextureView(c,this.gfxColorResolveToLevel[l]):d.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){var d,p=e.depthStencilAttachment;(d=this.gpuDepthStencilAttachment).view=p.gpuTextureView,!!(se(p.format)&ee.Depth)?("load"===e.depthClearValue?d.depthLoadOp="load":(d.depthLoadOp="clear",d.depthClearValue=e.depthClearValue),d.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.depthLoadOp=void 0,d.depthStoreOp=void 0),!!(se(p.format)&ee.Stencil)?("load"===e.stencilClearValue?d.stencilLoadOp="load":(d.stencilLoadOp="clear",d.stencilClearValue=e.stencilClearValue),d.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.stencilLoadOp=void 0,d.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=g(e.occlusionQueryPool)?void 0:e.occlusionQueryPool.querySet},e.prototype.beginRenderPass=function(e){fe(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.flipY=function(e,t){return this.device.swapChainHeight-e-t},e.prototype.setViewport=function(e,t,r,n,i,o){void 0===i&&(i=0),void 0===o&&(o=1),this.gpuRenderPassEncoder.setViewport(e,this.flipY(t,n),r,n,i,o)},e.prototype.setScissorRect=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(t,n),r,n)},e.prototype.setPipeline=function(e){var t=de(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},e.prototype.setVertexInput=function(e,t,r){if(null!==e){var n=e;null!==r&&this.gpuRenderPassEncoder.setIndexBuffer(ir(r.buffer),de(n.indexFormat),r.offset);for(var i=0;t.length>i;i++){var o=t[i];null!==o&&this.gpuRenderPassEncoder.setVertexBuffer(i,ir(o.buffer),o.offset)}}},e.prototype.setBindings=function(e){var t=e;this.gpuRenderPassEncoder.setBindGroup(0,t.gpuBindGroup[0]),t.gpuBindGroup[1]&&this.gpuRenderPassEncoder.setBindGroup(1,t.gpuBindGroup[1])},e.prototype.setStencilReference=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t,r,n){this.gpuRenderPassEncoder.draw(e,t,r,n)},e.prototype.drawIndexed=function(e,t,r,n,i){this.gpuRenderPassEncoder.drawIndexed(e,t,r,n,i)},e.prototype.drawIndirect=function(e,t){this.gpuRenderPassEncoder.drawIndirect(ir(e),t)},e.prototype.drawIndexedIndirect=function(e,t){this.gpuRenderPassEncoder.drawIndexedIndirect(ir(e),t)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.pushDebugGroup=function(e){this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuRenderPassEncoder.insertDebugMarker(e)},e.prototype.finish=function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;this.gfxColorAttachment.length>e;e++){var t=this.gfxColorAttachment[e],r=this.gfxColorResolveTo[e];null!==t&&null!==r&&1===t.sampleCount&&this.copyAttachment(r,this.gfxColorAttachmentLevel[e],t,this.gfxColorResolveToLevel[e])}return this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.commandEncoder.finish()},e.prototype.copyAttachment=function(e,t,r,n){fe(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},o={texture:e.gpuTexture,mipLevel:t};fe(r.width>>>n==e.width>>>t),fe(r.height>>>n==e.height>>>t),fe(!!(r.usage&Qt.COPY_SRC)),fe(!!(e.usage&Qt.COPY_DST)),this.commandEncoder.copyTextureToTexture(i,o,[e.width,e.height,1])},e}(),Mr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=M.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device.createRenderPipelineInternal(n,!1),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(Ar),xr=function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=M.Sampler;var a=i.lodMinClamp,s=i.mipmapFilter===G.NO_MIP?i.lodMinClamp:i.lodMaxClamp,l=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return l>1&&fe(i.minFilter===U.BILINEAR&&i.magFilter===U.BILINEAR&&i.mipmapFilter===G.LINEAR),o.gpuSampler=o.device.device.createSampler({addressModeU:tr(i.addressModeU),addressModeV:tr(i.addressModeV),addressModeW:tr(null!==(n=i.addressModeW)&&void 0!==n?n:i.addressModeU),lodMinClamp:a,lodMaxClamp:s,minFilter:rr(i.minFilter),magFilter:rr(i.magFilter),mipmapFilter:nr(i.mipmapFilter),compare:void 0!==i.compareFunction?hr(i.compareFunction):void 0,maxAnisotropy:l}),o}return n(t,e),t}(Ar),Br=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=t.sampleCount,o=e.call(this,{id:t.id,device:t.device})||this;o.type=M.Texture;var a=r.dimension,s=r.depthOrArrayLayers,l=r.mipLevelCount;return o.device.createTextureShared({format:r.format,dimension:null!=a?a:H.TEXTURE_2D,width:r.width,height:r.height,depthOrArrayLayers:null!=s?s:1,mipLevelCount:null!=l?l:1,usage:r.usage,sampleCount:null!=i?i:1},o,n),o}return n(t,e),t.prototype.textureFromImageBitmapOrCanvas=function(e,t,r){for(var n=t[0].width,i=t[0].height,o={size:{width:n,height:i,depthOrArrayLayers:r},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=e.createTexture(o),s=0;t.length>s;s++)e.queue.copyExternalImageToTexture({source:t[s]},{texture:a,origin:[0,0,s]},[n,i]);return[a,n,i]},t.prototype.isImageBitmapOrCanvases=function(e){var t=e[0];return t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas},t.prototype.isVideo=function(e){return e[0]instanceof HTMLVideoElement},t.prototype.setImageData=function(e,t){var r,n,i,o,a=this.device.device;this.isImageBitmapOrCanvases(e)?(n=(r=u(this.textureFromImageBitmapOrCanvas(a,e,this.depthOrArrayLayers),3))[0],i=r[1],o=r[2]):this.isVideo(e)&&(n=a.importExternalTexture({source:e[0]})),this.width=i,this.height=o,this.gpuTexture=n,this.gpuTextureView=n.createView({dimension:er(this.dimension)})},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuTexture.destroy()},t}(Ar),Dr=function(){function e(e,t,r,n,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Qt.RENDER_ATTACHMENT|Qt.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Z.UPPER_LEFT,this.clipSpaceNearZ=q.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(H.TEXTURE_2D,j.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(H.TEXTURE_2D,j.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(H.TEXTURE_2D_ARRAY,j.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(H.TEXTURE_3D,j.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(H.TEXTURE_CUBE_MAP,j.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:b.REPEAT,addressModeV:b.REPEAT,minFilter:U.POINT,magFilter:U.POINT,mipmapFilter:G.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:b.REPEAT,addressModeV:b.REPEAT,minFilter:U.POINT,magFilter:U.POINT,mipmapFilter:G.NEAREST,compareFunction:x.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)},this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}return e.prototype.destroy=function(){},e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t)},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new Br({id:0,device:this,descriptor:{format:te.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:H.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",this.setResourceName(r,"Onscreen Texture"),r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new gr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new Br({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new xr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new Br({id:this.getNextUniqueId(),device:this,descriptor:i(i({},e),{dimension:H.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:Y.RENDER_TARGET}),sampleCount:e.sampleCount});return t.depthOrArrayLayers=1,t.type=M.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.format,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.mipLevelCount,s=e.gpuTexture,l=e.gpuTextureView,u=e.usage;fe(!!(u&Qt.RENDER_ATTACHMENT));var c=new Br({id:this.getNextUniqueId(),device:this,descriptor:{format:t,width:r,height:n,depthOrArrayLayers:i,dimension:H.TEXTURE_2D,mipLevelCount:a,usage:u},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=l,c},e.prototype.createProgram=function(e){var t,r;return(null===(t=e.vertex)||void 0===t?void 0:t.glsl)&&(e.vertex.glsl=gt(this.queryVendorInfo(),"vert",e.vertex.glsl)),(null===(r=e.fragment)||void 0===r?void 0:r.glsl)&&(e.fragment.glsl=gt(this.queryVendorInfo(),"frag",e.fragment.glsl)),new Pr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.mipLevelCount,o=Jt(e.format),a=function(e){if(e===H.TEXTURE_2D)return"2d";if(e===H.TEXTURE_CUBE_MAP)return"2d";if(e===H.TEXTURE_2D_ARRAY)return"2d";if(e===H.TEXTURE_3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&Y.SAMPLED&&(t|=Qt.TEXTURE_BINDING|Qt.COPY_DST),e&Y.RENDER_TARGET&&(t|=Qt.RENDER_ATTACHMENT|Qt.TEXTURE_BINDING|Qt.COPY_SRC|Qt.COPY_DST),t}(e.usage);if(t.gpuTextureformat=o,t.dimension=e.dimension,t.format=e.format,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.mipLevelCount=i,t.usage=s,t.sampleCount=e.sampleCount,!r){var l=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,sampleCount:e.sampleCount,usage:s}),u=l.createView();t.gpuTexture=l,t.gpuTextureView=u}},e.prototype.getFallbackSampler=function(e){return e.formatKind===j.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===H.TEXTURE_2D)return e.formatKind===j.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===H.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(t===H.TEXTURE_3D)return this.fallbackTexture3D;if(t===H.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,format:t===j.Float?te.U8_RGBA_NORM:te.D24,usage:Y.SAMPLED,width:1,height:1,depthOrArrayLayers:e===H.TEXTURE_CUBE_MAP?6:1,mipLevelCount:1})},e.prototype.createBindings=function(e){return new mr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new Cr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createComputePipeline=function(e){return new yr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new Mr({id:this.getNextUniqueId(),device:this,descriptor:i({},e)})},e.prototype.createQueryPool=function(e,t){return new Nr({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype.createRenderPipelineInternal=function(e,t){var r;if(null===e.gpuRenderPipeline){var n=e.descriptor,a=n.program,s=a.vertexStage,l=a.fragmentStage;if(null!==s&&null!==l){var u=n.megaStateDescriptor||{},c=u.stencilBack,f=u.stencilFront,d=o(u,["stencilBack","stencilFront"]),p=xe(De);n.megaStateDescriptor=i(i(i({},p),{stencilBack:i(i({},p.stencilBack),c),stencilFront:i(i({},p.stencilFront),f)}),d);var _=n.megaStateDescriptor.attachmentsState[0];n.colorAttachmentFormats.forEach((function(e,t){n.megaStateDescriptor.attachmentsState[t]||(n.megaStateDescriptor.attachmentsState[t]=Ie(void 0,_))}));var h,E,R=(h=null!==(r=n.topology)&&void 0!==r?r:w.TRIANGLES,E=n.megaStateDescriptor,{topology:ar(h),cullMode:sr(E.cullMode),frontFace:lr(E.frontFace)}),v=_r(n.colorAttachmentFormats,n.megaStateDescriptor),T=function(e,t){if(!g(e))return{format:Jt(e),depthWriteEnabled:!!t.depthWrite,depthCompare:hr(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0,stencilFront:{compare:hr(t.stencilFront.compare),passOp:Er(t.stencilFront.passOp),failOp:Er(t.stencilFront.failOp),depthFailOp:Er(t.stencilFront.depthFailOp)},stencilBack:{compare:hr(t.stencilBack.compare),passOp:Er(t.stencilBack.passOp),failOp:Er(t.stencilBack.failOp),depthFailOp:Er(t.stencilBack.depthFailOp)},stencilReadMask:1,stencilWriteMask:1}}(n.depthStencilAttachmentFormat,n.megaStateDescriptor),A=void 0;null!==n.inputLayout&&(A=n.inputLayout.buffers);var m=n.sampleCount,S={layout:"auto",vertex:i(i({},s),{buffers:A}),primitive:R,depthStencil:T,multisample:{count:m},fragment:i(i({},l),{targets:v})};e.gpuRenderPipeline=this.device.createRenderPipeline(S)}}},e.prototype.createReadback=function(){return new Ir({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new Or(this)),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();return void 0===e&&(e=new Sr),e.commandEncoder=this.device.createCommandEncoder(),e.beginComputePass(),e},e.prototype.submitPass=function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null},e.prototype.copySubTexture2D=function(e,t,r,n,i,o){var a=this.device.createCommandEncoder(),s=e,l=n,u={texture:l.gpuTexture,origin:[i,o,0]},c={texture:s.gpuTexture,origin:[t,r,0]};fe(!!(l.usage&Qt.COPY_SRC)),fe(!!(s.usage&Qt.COPY_DST)),a.copyTextureToTexture(u,c,[l.width,l.height,1]),this.device.queue.submit([a.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(ae(e)){case $.BC1:case $.BC2:case $.BC3:case $.BC4_SNORM:case $.BC4_UNORM:case $.BC5_SNORM:case $.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(ae(e)){case $.BC1:case $.BC2:case $.BC3:case $.BC4_SNORM:case $.BC4_UNORM:case $.BC5_SNORM:case $.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}switch(e){case te.U16_RGBA_NORM:case te.F32_RGBA:return!1}return!0},e.prototype.queryPlatformAvailable=function(){return!0},e.prototype.queryVendorInfo=function(){return this},e.prototype.queryRenderPass=function(e){return e.descriptor},e.prototype.queryRenderTarget=function(e){return e},e.prototype.setResourceName=function(e,t){if(e.name=t,e.type===M.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===M.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===M.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===M.Sampler){(r=e).gpuSampler.label=t}else if(e.type===M.RenderPipeline){var r;null!==(r=e).gpuRenderPipeline&&(r.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this.createRenderPipelineInternal(e,!1)},e}(),Lr=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return a(this,void 0,void 0,(function(){var t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:if(void 0===globalThis.navigator.gpu)return[2,null];t=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,globalThis.navigator.gpu.requestAdapter({xrCompatible:this.pluginOptions.xrCompatible})];case 2:return t=s.sent(),[3,4];case 3:return r=s.sent(),console.log(r),[3,4];case 4:return null===t?[2,null]:(n=["depth32float-stencil8","texture-compression-bc"].filter((function(e){return t.features.has(e)})),[4,t.requestDevice({requiredFeatures:n})]);case 5:if((i=s.sent())&&(o=this.pluginOptions.onContextLost,i.lost.then((function(){o&&o()}))),null===i)return[2,null];if(!(a=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,qt(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new Dr(t,i,e,a,jt)]}}))}))},e}(),Fr={exports:{}};function br(e,t,r){r=r||2;var n,i,o,a,s,l,u,c=t&&t.length,f=c?t[0]*r:e.length,d=Ur(e,0,f,r,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=Ur(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(jr(a));for(s.sort(Hr),i=0;s.length>i;i++)r=Gr(r=Yr(s[i],r),r.next);return r}(e,t,d,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var _=r;f>_;_+=r)n>(s=e[_])&&(n=s),i>(l=e[_+1])&&(i=l),s>o&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-n,a-i))?1/u:0}return wr(d,p,r,n,i,u),p}function Ur(e,t,r,n,i){var o,a;if(i===ln(e,t,r,n)>0)for(o=t;r>o;o+=n)a=on(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=on(o,e[o],e[o+1],a);return a&&$r(a,a.next)&&(an(a),a=a.next),a}function Gr(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!$r(n,n.next)&&0!==Qr(n.prev,n,n.next))n=n.next;else{if(an(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function wr(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=Kr(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,l,u=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;u>t&&(s++,n=n.nextZ);t++);for(l=u;s>0||l>0&&n;)0===s||0!==l&&n&&r.z>n.z?(i=n,n=n.nextZ,l--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,u*=2}while(a>1)}(i)}(e,n,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Vr(e,n,i,o):kr(e))t.push(s.i/r),t.push(e.i/r),t.push(l.i/r),an(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?wr(e=Xr(Gr(e),t,r),t,r,n,i,o,2):2===a&&Wr(e,t,r,n,i,o):wr(Gr(e),t,r,n,i,o,1);break}}}function kr(e){var t=e.prev,r=e,n=e.next;if(Qr(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(Zr(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Qr(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vr(e,t,r,n){var i=e.prev,o=e,a=e.next;if(Qr(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,u=Kr(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=Kr(s,l,t,r,n),f=e.prevZ,d=e.nextZ;f&&f.z>=u&&d&&c>=d.z;){if(f!==e.prev&&f!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Qr(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==e.prev&&d!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Qr(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Qr(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&c>=d.z;){if(d!==e.prev&&d!==e.next&&Zr(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Qr(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Xr(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!$r(i,o)&&Jr(i,n,n.next,o)&&rn(i,o)&&rn(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),an(n),an(n.next),n=e=o),n=n.next}while(n!==e);return Gr(n)}function Wr(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&qr(a,s)){var l=nn(a,s);return a=Gr(a,a.next),l=Gr(l,l.next),wr(a,t,r,n,i,o),void wr(l,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function Hr(e,t){return e.x-t.x}function Yr(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var l,u=r,c=r.x,f=r.y,d=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!Zr(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(l=Math.abs(o-n.y)/(i-n.x),rn(n,e)&&(d>l||l===d&&(n.x>r.x||n.x===r.x&&zr(r,n)))&&(r=n,d=l)),n=n.next}while(n!==u);return r}(e,t);if(!r)return t;var n=nn(r,e),i=Gr(r,r.next);return Gr(n,n.next),t===r?i:t}function zr(e,t){return 0>Qr(e.prev,e,t.prev)&&0>Qr(t.next,e,e.next)}function Kr(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function jr(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function Zr(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function qr(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Jr(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(rn(e,t)&&rn(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(Qr(e.prev,e,t.prev)||Qr(e,t.prev,t))||$r(e,t)&&Qr(e.prev,e,e.next)>0&&Qr(t.prev,t,t.next)>0)}function Qr(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function $r(e,t){return e.x===t.x&&e.y===t.y}function Jr(e,t,r,n){var i=tn(Qr(e,t,r)),o=tn(Qr(e,t,n)),a=tn(Qr(r,n,e)),s=tn(Qr(r,n,t));return i!==o&&a!==s||(!(0!==i||!en(e,r,t))||(!(0!==o||!en(e,n,t))||(!(0!==a||!en(r,e,n))||!(0!==s||!en(r,t,n)))))}function en(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function tn(e){return e>0?1:0>e?-1:0}function rn(e,t){return 0>Qr(e.prev,e,e.next)?Qr(e,t,e.next)>=0&&Qr(e,e.prev,t)>=0:0>Qr(e,t,e.prev)||0>Qr(e,e.next,t)}function nn(e,t){var r=new sn(e.i,e.x,e.y),n=new sn(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function on(e,t,r,n){var i=new sn(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function an(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function sn(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ln(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}Fr.exports=br,Fr.exports.default=br,br.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(ln(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(ln(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var l=0;for(a=0;n.length>a;a+=3){var u=n[a]*r,c=n[a+1]*r,f=n[a+2]*r;l+=Math.abs((e[u]-e[f])*(e[c+1]-e[u+1])-(e[u]-e[c])*(e[f+1]-e[u+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},br.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var un=Fr.exports;function cn(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}function fn(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function dn(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function pn(e,t,r,n,i,o,a,s,l){if(0===l)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=cn(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var f=function(e,t,r,n,i,o,a,s,l){var u=dn(e,r,i,a,l),c=dn(t,n,o,s,l),f=fn(e,t,r,n,l),d=fn(r,n,i,o,l),p=fn(i,o,a,s,l),_=fn(f.x,f.y,d.x,d.y,l),h=fn(d.x,d.y,p.x,p.y,l);return[[e,t,f.x,f.y,_.x,_.y,u,c],[u,c,h.x,h.y,p.x,p.y,a,s]]}(e,t,r,n,i,o,a,s,.5),d=c(c([],u(f[0]),!1),[l-1],!1),p=c(c([],u(f[1]),!1),[l-1],!1);return pn.apply(void 0,c([],u(d),!1))+pn.apply(void 0,c([],u(p),!1))}function _n(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function hn(e,t,r,n,i,o,a){if(0===a)return(cn(e,t,r,n)+cn(r,n,i,o)+cn(e,t,i,o))/2;var s=function(e,t,r,n,i,o,a){var s=_n(e,r,i,a),l=_n(t,n,o,a),u=fn(e,t,r,n,a),c=fn(r,n,i,o,a);return[[e,t,u.x,u.y,s,l],[s,l,c.x,c.y,i,o]]}(e,t,r,n,i,o,.5),l=s[0],f=s[1];return l.push(a-1),f.push(a-1),hn.apply(void 0,c([],u(l),!1))+hn.apply(void 0,c([],u(f),!1))}var En=function(){function e(){this.drawcalls=[]}return e.tag="c-renderable-3d",e}(),Rn=function(){function e(){this.lights=[]}return e.prototype.addLight=function(e){this.lights.push(e),this.sortLights()},e.prototype.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},e.prototype.addFog=function(e){this.fog=e},e.prototype.removeFog=function(e){this.fog=null},e.prototype.getFog=function(){return this.fog},e.prototype.getAllLights=function(){return this.lights},e.prototype.getDefines=function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e},e.prototype.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}(),vn=function(e){function r(r){var n=this,a=r.style,s=o(r,["style"]);return(n=e.call(this,i({type:t.Shape.MESH,style:i({x:"",y:"",z:"",lineWidth:0,anchor:[.5,.5,.5]},a)},s))||this).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return n(r,e),r.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.style.geometry.meshes,r=t.indexOf(this);t.splice(r,1),r=(t=this.style.material.meshes).indexOf(this),t.splice(r,1)},r}(t.DisplayObject),Tn=function(){function e(){}return e.prototype.update=function(e){var t=e.geometry.computeBoundingBox(),r=t.getMax(),n=t.getMin();return{width:r[0]-n[0],height:r[1]-n[1],depth:r[2]-n[2]}},e}(),An=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}return e.prototype.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},e.prototype.getById=function(e){return this.id2DisplayObjectMap[e]},e.prototype.deleteById=function(e){delete this.id2DisplayObjectMap[e]},e.prototype.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},e.prototype.decodePickingColor=function(e){var t=u(e,3);return t[0]+256*t[1]+65536*t[2]-1},e.prototype.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}(),mn=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}}return e.prototype.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},e.prototype.setDefineString=function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(g(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},e.prototype.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},e.prototype.getDefineString=function(e){return void 0===(t=this.defines[e])?null:t;var t},e.prototype.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&fe("1"===t),null!==t},e}(),gn=function(){function e(e){this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=e;var t=e.queryLimits();this.uniformBufferWordAlignment=t.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=t.uniformBufferMaxPageWordSize}return e.prototype.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},e.prototype.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},e.prototype.allocateChunk=function(e){e=Se(e,this.uniformBufferWordAlignment),fe(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=Se(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},e.prototype.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=Se(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){fe(this.currentWordOffset>e&&this.currentWordOffset>=e+t);r=Se(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize);var n=new Uint8Array(4*r);if(n.set(this.shadowBufferU8,0),this.shadowBufferU8=n,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),r<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}},e.prototype.mapBufferF32=function(){return de(this.shadowBufferF32)},e.prototype.prepareToRender=function(){if(null!==this.shadowBufferF32){var e=de(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:k.UNIFORM,hint:V.DYNAMIC}));var t=Se(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())de(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}},e.prototype.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function Sn(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function yn(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Cn(e){return 0}var Pn=function(){this.keys=[],this.values=[]},Nn=function(){function e(e,t){this.keyEqualFunc=e,this.keyHashFunc=t,this.buckets=new Map}return e.prototype.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},e.prototype.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},e.prototype.get=function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]},e.prototype.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new Pn);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},e.prototype.delete=function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}},e.prototype.clear=function(){this.buckets.clear()},e.prototype.size=function(){var e,t,r=0;try{for(var n=l(this.buckets.values()),i=n.next();!i.done;i=n.next()){r+=i.value.values.length}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.values=function(){var e,t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,7,8,9]),e=l(this.buckets.values()),t=e.next(),s.label=1;case 1:if(t.done)return[3,6];n=(r=t.value).values.length-1,s.label=2;case 2:return n<0?[3,5]:[4,r.values[n]];case 3:s.sent(),s.label=4;case 4:return n--,[3,2];case 5:return t=e.next(),[3,1];case 6:return[3,9];case 7:return i=s.sent(),o={error:i},[3,9];case 8:try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(o)throw o.error}return[7];case 9:return[2]}}))},e}();function In(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:gt(e,"vert",t,n),preprocessedFrag:gt(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function On(e,t){return fe(""!==e.preprocessedVert&&""!==t.preprocessedVert),fe(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Mn(e,t){return e=Sn(e,t.blendMode),e=Sn(e,t.blendSrcFactor),e=Sn(e,t.blendDstFactor)}function xn(e,t){return e=Mn(e,t.rgbBlendState),e=Sn(e=Mn(e,t.alphaBlendState),t.channelWriteMask)}function Bn(e,t){for(var r,n,i,o,a,s,l,u,c=0;t.attachmentsState.length>c;c++)e=xn(e,t.attachmentsState[c]);return e=function(e,t){return Sn(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Sn(e,t.depthCompare),e=Sn(e,t.depthWrite?1:0),e=Sn(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=Sn(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=Sn(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=Sn(e,null===(o=t.stencilFront)||void 0===o?void 0:o.depthFailOp),e=Sn(e,null===(a=t.stencilBack)||void 0===a?void 0:a.compare),e=Sn(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=Sn(e,null===(l=t.stencilBack)||void 0===l?void 0:l.failOp),e=Sn(e,null===(u=t.stencilBack)||void 0===u?void 0:u.depthFailOp),e=Sn(e,t.stencilWrite?1:0),e=Sn(e,t.cullMode),e=Sn(e,t.frontFace?1:0),e=Sn(e,t.polygonOffset?1:0)}function Dn(e){var t=0;t=Sn(t,e.program.id),null!==e.inputLayout&&(t=Sn(t,e.inputLayout.id)),t=Bn(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=Sn(t,e.colorAttachmentFormats[r]||0);return yn(t=Sn(t,e.depthStencilAttachmentFormat||0))}function Ln(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){null!==(n=e.samplerBindings[r])&&null!==n.texture&&(t=Sn(t,n.texture.id))}for(r=0;e.uniformBufferBindings.length>r;r++){var n;null!==(n=e.uniformBufferBindings[r])&&null!==n.buffer&&(t=Sn(t,n.buffer.id),t=Sn(t,n.binding),t=Sn(t,n.offset),t=Sn(t,n.size))}return yn(t)}var Fn,bn,Un=function(){function e(e){this.bindingsCache=new Nn(Xe,Ln),this.renderPipelinesCache=new Nn(je,Dn),this.inputLayoutsCache=new Nn(Qe,Cn),this.programCache=new Nn(On,Cn),this.samplerCache=new Nn($e,Cn),this.device=e}return e.prototype.createBindings=function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&we(t.samplerBindings,Je),uniformBufferBindings:t.uniformBufferBindings&&we(t.uniformBufferBindings,et),pipeline:t.pipeline};r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r},e.prototype.createRenderPipeline=function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var o=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&xe(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});i=this.device.createRenderPipeline(o),this.renderPipelinesCache.add(o,i)}return i},e.prototype.createInputLayout=function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter((function(e){return!!e}));var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:we((t=e).vertexBufferDescriptors,rt),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r},e.prototype.createProgramSimple=function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,o=null;if(i&&n&&(o=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===o){var a=In(this.device,e),s=a.preprocessedVert,l=a.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=l;var u={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};o=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:l}},r),this.programCache.add(u,o)}return o},e.prototype.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},e.prototype.destroy=function(){var e,t,r,n,i,o,a,s,u,c;try{for(var f=l(this.bindingsCache.values()),d=f.next();!d.done;d=f.next()){d.value.destroy()}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var p=l(this.renderPipelinesCache.values()),_=p.next();!_.done;_=p.next()){_.value.destroy()}}catch(e){r={error:e}}finally{try{_&&!_.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var h=l(this.inputLayoutsCache.values()),E=h.next();!E.done;E=h.next()){E.value.destroy()}}catch(e){i={error:e}}finally{try{E&&!E.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}try{for(var R=l(this.programCache.values()),v=R.next();!v.done;v=R.next()){v.value.destroy()}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=R.return)&&s.call(R)}finally{if(a)throw a.error}}try{for(var T=l(this.samplerCache.values()),A=T.next();!A.done;A=T.next()){A.value.destroy()}}catch(e){u={error:e}}finally{try{A&&!A.done&&(c=T.return)&&c.call(T)}finally{if(u)throw u.error}}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()},e}();!function(e){e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping"}(Fn||(Fn={})),function(e){e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil"}(bn||(bn={}));var Gn,wn=function(){function e(){this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]}return e.prototype.setDebugName=function(e){this.debugName=e},e.prototype.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},e.prototype.setViewport=function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n},e.prototype.attachRenderTargetID=function(e,t,r){void 0===r&&(r=0),fe(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r},e.prototype.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},e.prototype.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},e.prototype.exec=function(e){fe(null===this.execFunc),this.execFunc=e},e.prototype.post=function(e){fe(null===this.postFunc),this.postFunc=e},e.prototype.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),kn=function(){function e(e,t){this.dimension=H.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Y.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,fe(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}return e.prototype.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},e.prototype.reset=function(e){fe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.attachment.destroy()},e}(),Vn=function(){function e(e,t){this.dimension=H.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=Y.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}return e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height},e.prototype.reset=function(e){fe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.texture.destroy()},e}(),Xn=function(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},Wn=function(){function e(e){this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}return e.prototype.acquireRenderTargetForDescription=function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new kn(this.device,e)},e.prototype.acquireSingleSampledTextureForDescription=function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new Vn(this.device,e)},e.prototype.beginGraphBuilder=function(){fe(null===this.currentGraph),this.currentGraph=new Xn},e.prototype.pushPass=function(e){var t=new wn;e(t),this.currentGraph.passes.push(t)},e.prototype.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},e.prototype.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},e.prototype.findMostRecentPassThatAttachedRenderTarget=function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null},e.prototype.resolveRenderTargetPassAttachmentSlot=function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]},e.prototype.findPassForResolveRenderTarget=function(e){var t=de(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return fe(void 0===t.resolveTextureOutputExternalTextures[r]),t},e.prototype.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},e.prototype.resolveRenderTargetToExternalTexture=function(e,t,r){void 0===r&&(r=0);var n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);fe(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r},e.prototype.getRenderTargetDescription=function(e){return de(this.currentGraph.renderTargetDescriptions[e])},e.prototype.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){void 0!==(i=t.renderTargetIDs[r])&&(this.renderTargetOutputCount[i]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[i]++)}for(var n=0;t.resolveTextureInputIDs.length>n;n++){var i,o=t.resolveTextureInputIDs[n];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[i=e.resolveTextureRenderTargetIDs[o]]++}},e.prototype.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(fe(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]},e.prototype.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=de(this.renderTargetAliveForID[e]);return t?(fe(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(fe(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r},e.prototype.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];fe(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=de(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return de(n.texture)},e.prototype.determineResolveParam=function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;fe(!(a&&s));var l=null,u=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(u=!0),a){fe(e.resolveTextureRenderTargetIDs[i]===n),fe(this.resolveTextureUseCount[i]>0),fe(this.renderTargetOutputCount[n]>0);var f=de(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])l=null,u=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=de(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,f.debugName+" (Resolve ".concat(i,")"))}l=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(l=o,c=t.resolveTextureOutputExternalTextureLevel[r]):l=null;return{resolveTo:l,store:u,level:c}},e.prototype.schedulePass=function(e,t){for(var r=t.renderTargetIDs[bn.DepthStencil],n=bn.Color0;bn.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var a=this.determineResolveParam(e,t,n),s=a.store,l=a.level;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorResolveToLevel[n]=l,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[bn.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var c=this.determineResolveParam(e,t,bn.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,p=0,_=0,h=0;t.renderTargets.length>h;h++){var E=t.renderTargets[h];if(E){var R=E.width>>>t.renderTargetLevels[h],v=E.height>>>t.renderTargetLevels[h];0===d&&(d=R,p=v,_=E.sampleCount),fe(R===d),fe(v===p),fe(E.sampleCount===_),E.needsClear=!1}}d>0&&p>0&&(t.viewportX*=d,t.viewportY*=p,t.viewportW*=d,t.viewportH*=p);for(h=0;t.resolveTextureInputIDs.length>h;h++){t.resolveTextureInputTextures[h]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[h])}for(h=0;t.renderTargetIDs.length>h;h++)this.releaseRenderTargetForID(t.renderTargetIDs[h],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},e.prototype.scheduleGraph=function(e){fe(0===this.renderTargetOutputCount.length),fe(0===this.renderTargetResolveCount.length),fe(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(t=0;this.singleSampledTextureDeadPool.length>t;t++)this.singleSampledTextureDeadPool[t].age++;me(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),me(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),me(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(t=0;e.passes.length>t;t++)this.scheduleAddUseCount(e,e.passes[t]);for(t=0;e.passes.length>t;t++)this.schedulePass(e,e.passes[t]);for(t=0;this.renderTargetOutputCount.length>t;t++)fe(0===this.renderTargetOutputCount[t]);for(t=0;this.renderTargetResolveCount.length>t;t++)fe(0===this.renderTargetResolveCount[t]);for(t=0;this.resolveTextureUseCount.length>t;t++)fe(0===this.resolveTextureUseCount[t]);for(t=0;this.renderTargetAliveForID.length>t;t++)fe(void 0===this.renderTargetAliveForID[t]);for(t=0;this.renderTargetDeadPool.length>t;t++)1>this.renderTargetDeadPool[t].age||(this.renderTargetDeadPool[t].destroy(),this.renderTargetDeadPool.splice(t--,1));for(t=0;this.singleSampledTextureDeadPool.length>t;t++)1>this.singleSampledTextureDeadPool[t].age||(this.singleSampledTextureDeadPool[t].destroy(),this.singleSampledTextureDeadPool.splice(t--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},e.prototype.execPass=function(e){fe(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null},e.prototype.execGraph=function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach((function(e){t.execPass(e)})),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0},e.prototype.execute=function(){var e=de(this.currentGraph);this.execGraph(e),this.currentGraph=null},e.prototype.getDebug=function(){return this},e.prototype.getPasses=function(){return this.currentGraph.passes},e.prototype.getPassDebugThumbnails=function(e){return e.debugThumbnails},e.prototype.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},e.prototype.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},e.prototype.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return fe(r>=0),de(t.resolveTextureInputTextures[r])},e.prototype.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},e.prototype.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},e.prototype.newGraphBuilder=function(){return this.beginGraphBuilder(),this},e.prototype.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)fe(void 0===this.renderTargetAliveForID[e]);for(e=0;this.singleSampledTextureForResolveTextureID.length>e;e++)fe(void 0===this.singleSampledTextureForResolveTextureID[e]);for(e=0;this.renderTargetDeadPool.length>e;e++)this.renderTargetDeadPool[e].destroy();for(e=0;this.singleSampledTextureDeadPool.length>e;e++)this.singleSampledTextureDeadPool[e].destroy()},e}();!function(e){e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT"}(Gn||(Gn={}));var Hn=65536,Yn=16;function zn(e,t,r){void 0===r&&(r=Hn);var n=P(e,0,r)/r;return t&&(n=1-n),65535&n*((1<<Yn)-1)}function Kn(e,t){return(16777215&e|(255&t)<<24)>>>0}function jn(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function Zn(e,t){return Kn(jn(0,t),e)}function qn(e,t){return fe(t>=0),(4294967040&e|t>>>8&255)>>>0}function Qn(e){return Kn(0,e)}function $n(e,t){return fe(t>=0),(4278190335&e|t<<8)>>>0}var Jn=_(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var ei,ti=_(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function ri(e,t,r,n,i,o){return void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags"}(ei||(ei={}));var ni,ii=function(){function e(){this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=Ce(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Ce(4,(function(){return 0})),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:xe(De),program:null,topology:w.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return e.prototype.reset=function(){this.sortKey=0,this.flags=ei.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null},e.prototype.setFromTemplate=function(e){var t,r;Me(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=c([],u(e.uniforms),!1),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~ei.InheritedFlags|e.flags&ei.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],o=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=o.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=o.uniformBufferBindings)||void 0===r?void 0:r.length});for(n=0;Math.min(i.uniformBufferBindings.length,o.uniformBufferBindings.length)>n;n++)i.uniformBufferBindings[n].size=e.bindingDescriptors[0].uniformBufferBindings[n].size;this.setSamplerBindingsFromTextureMappings(o.samplerBindings);for(n=0;e.dynamicUniformBufferByteOffsets.length>n;n++)this.dynamicUniformBufferByteOffsets[n]=e.dynamicUniformBufferByteOffsets[n]},e.prototype.validate=function(){for(var e,t=0;this.bindingDescriptors.length>t;t++)for(var r=this.bindingDescriptors[t],n=0;n<(null===(e=r.uniformBufferBindings)||void 0===e?void 0:e.length);n++)fe(r.uniformBufferBindings[n].size>0);fe(this.drawCount>0)},e.prototype.setProgram=function(e){this.renderPipelineDescriptor.program=e},e.prototype.setMegaStateFlags=function(e){return Me(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.setVertexInput=function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e},e.prototype.setBindingLayout=function(e){fe(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:0,buffer:null,size:0});for(t=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>t;t++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})},e.prototype.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=ye(this.flags,ei.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=ye(this.flags,ei.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},e.prototype.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=ye(this.flags,ei.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.setUniforms=function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(N(t)||Array.isArray(t)||t instanceof Float32Array){var i=N(t)?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,c([],u(i),!1))}}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),l=0;n.length>l;l+=4)a+=ri(s,a,n[l],n[l+1],n[l+2],n[l+3])}},e.prototype.setUniformBuffer=function(e){this.uniformBuffer=e},e.prototype.allocateUniformBuffer=function(e,t){var r;return fe((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)},e.prototype.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},e.prototype.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},e.prototype.getUniformBuffer=function(){return this.uniformBuffer},e.prototype.setSamplerBindingsFromTextureMappings=function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}},e.prototype.setAllowSkippingIfPipelineNotReady=function(e){this.flags=ye(this.flags,ei.AllowSkippingIfPipelineNotReady,e)},e.prototype.setAttachmentFormatsFromRenderPass=function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:fe(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:fe(n==a.sampleCount)),fe(n>0),this.renderPipelineDescriptor.sampleCount=n},e.prototype.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var o=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(o)){if(this.flags&ei.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(o)}t.setPipeline(o),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=de(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniformsLegacy(t)}));var s=e.createBindings(i(i({},this.bindingDescriptors[0]),{pipeline:o}));return t.setBindings(s),this.flags&ei.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0},e}();function oi(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(ni||(ni={}));var ai=function(){function e(e,t){void 0===e&&(e=oi),void 0===t&&(t=ni.Forwards),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}return e.prototype.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},e.prototype.insertSorted=function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()},e.prototype.submitRenderInst=function(e){e.flags|=ei.Draw,this.insertSorted(e)},e.prototype.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},e.prototype.drawOnPassRendererNoReset=function(e,t){if(this.ensureSorted(),this.executionOrder===ni.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(r=this.renderInsts.length-1;r>=0;r--)this.renderInsts[r].drawOnPass(e,t)},e.prototype.reset=function(){this.renderInsts.length=0},e.prototype.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),si=function(){function e(){this.pool=[],this.allocCount=0}return e.prototype.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new ii),this.allocCount-1},e.prototype.popRenderInst=function(){this.allocCount--},e.prototype.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},e.prototype.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),li=function(){function e(e){this.renderCache=e,this.instPool=new si,this.templatePool=new si,this.simpleRenderInstList=new ai,this.currentRenderInstList=this.simpleRenderInstList}return e.prototype.newRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r},e.prototype.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},e.prototype.setCurrentRenderInstList=function(e){fe(null===this.simpleRenderInstList),this.currentRenderInstList=e},e.prototype.pushTemplateRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=ei.Template,r},e.prototype.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},e.prototype.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},e.prototype.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),fe(0===this.templatePool.allocCount)},e.prototype.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},e.prototype.disableSimpleMode=function(){this.simpleRenderInstList=null},e.prototype.drawOnPassRenderer=function(e){de(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},e.prototype.drawOnPassRendererNoReset=function(e){de(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),ui=function(){function e(e){this.parameters=e}return e.prototype.getDevice=function(){return this.device},e.prototype.setDevice=function(e){this.device=e,this.renderCache=new Un(e),this.renderGraph=new Wn(this.device),this.renderInstManager=new li(this.renderCache),this.uniformBuffer=new gn(this.device)},e.prototype.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},e.prototype.prepareToRender=function(){this.uniformBuffer.prepareToRender()},e.prototype.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()},e.prototype.getCache=function(){return this.renderCache},e.prototype.getDefines=function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==Fn.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}},e}(),ci=function(){function e(e){this.format=e,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load"}return e.prototype.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},e.prototype.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function fi(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var di,pi=fi(_e(.88,.88,.88,1)),_i=fi(Ee),hi=fi(ve);function Ei(e,t){var r=function(e){return e.antialiasingMode===di.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function Ri(e,t,r){var n=function(e){if(e===bn.Color0)return te.U8_RGBA_RT;if(e===bn.DepthStencil)return te.D24_S8;throw Error("whoops")}(e),i=new ci(n);return Ei(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(di||(di={}));var vi,Ti=function(){function e(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}return e.prototype.reset=function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0},e.prototype.copy=function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias},e}(),Ai=function(){function e(){this.inputTexture=null,this.outputTexture=null}return e.prototype.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),fe(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Vn(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},e.prototype.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},e.prototype.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},e.prototype.destroy=function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)},e}(),mi=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({intensity:Math.PI},n)},a))||this}return n(t,e),t.tag="light",t}(t.DisplayObject);!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(vi||(vi={}));var gi,Si=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({type:vi.NONE,fill:"black",start:1,end:1e3,density:0},n)},a))||this}return n(t,e),t.tag="fog",t}(t.DisplayObject);function yi(e,t,r,n){void 0===n&&(n=V.STATIC);var i=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:n});return i.setSubData(0,new Uint8Array(r)),i}!function(e){e.CHANGED="changed"}(gi||(gi={}));var Ci,Pi,Ni=function(e){function r(t,r){void 0===r&&(r={});var n=e.call(this)||this;return n.device=t,n.props=r,n.drawMode=w.TRIANGLES,n.vertexBuffers=[],n.vertices=[],n.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n}return n(r,e),r.prototype.validate=function(e){return!0},r.prototype.build=function(e){},r.prototype.computeBoundingBox=function(){return new t.AABB},r.prototype.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=yi(this.device,k.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=te.U32_R,this},r.prototype.setVertexBuffer=function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find((function(e){return e.shaderLocation===o}));s?(s.format=n,s.offset=i,s.divisor=a):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:o,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=yi(this.device,k.VERTEX,i.buffer,V.DYNAMIC);return this.vertexBuffers[r]=o,this},r.prototype.getVertexBuffer=function(e){return this.vertexBuffers[e]},r.prototype.updateVertexBuffer=function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var o=i.arrayStride,a=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find((function(e){return e.shaderLocation===t}));if(a)this.getVertexBuffer(e).setSubData(a.offset+r*o,n);this.emit(gi.CHANGED)}},r.prototype.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this},r.prototype.destroy=function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0},r}(re),Ii=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.features={},t.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",t.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",t.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",t}return n(t,e),t}(mn),Oi=Ce(1,(function(){return new Ti}));function Mi(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(bn.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(Le),a.setBindingLayout({numUniformBuffers:1,numSamplers:1}),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);ri(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var l=new Ii,u=t.renderCache.createProgramSimple(l);a.setProgram(u),Ci||((Ci=new Ni(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),Ci.vertexCount=3,Pi=t.getCache().createInputLayout(Ci.inputLayoutDescriptor)),i.exec((function(e,r){Oi[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(Oi),a.setVertexInput(Pi,Ci.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null),a.drawOnPass(t.renderCache,e)}))}))}var xi;!function(e){e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking"}(xi||(xi={}));var Bi,Di=function(){function e(e,t,r,n,i){this.renderHelper=e,this.lightPool=t,this.texturePool=r,this.batchManager=n,this.options=i,this.renderLists={world:new ai,picking:new ai}}return e.prototype.getDevice=function(){return this.device},e.prototype.getSwapChain=function(){return this.swapChain},e.prototype.getRenderLists=function(){return this.renderLists},e.prototype.apply=function(r){var n=this;this.context=r;var o=r.renderingService,l=r.config,u=r.renderingContext.root.ownerDocument.defaultView;l.disableRenderHooks=!0;var c=function(e){var t=e.target;t.nodeName!==mi.tag?t.nodeName!==Si.tag?(t.renderable3D||(t.renderable3D=new En),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},f=function(e){var r,i,o=e.target;if(o.nodeName!==mi.tag)if(o.nodeName!==Si.tag){if(o.nodeName===t.Shape.MESH){var a;if(null===(r=o.style.geometry)||void 0===r?void 0:r.meshes)(a=o.style.geometry.meshes.indexOf(o))>-1&&o.style.geometry.meshes.splice(a,1);if(null===(i=o.style.material)||void 0===i?void 0:i.meshes)(a=o.style.material.meshes.indexOf(o))>-1&&o.style.material.meshes.splice(a,1)}n.swapChain&&n.batchManager.remove(o),delete o.renderable3D}else n.lightPool.removeFog(o);else n.lightPool.removeLight(o)},d=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach((function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)})):n.batchManager.updateAttribute(t,r,i)}},p=function(e){n.swapChain&&n.batchManager.updateAttribute(e.target,"modelMatrix",null)};o.hooks.initAsync.tapPromise(e.tag,(function(){return a(n,void 0,void 0,(function(){var e,n,o,a=this;return s(this,(function(s){switch(s.label){case 0:return u.addEventListener(t.ElementEvent.MOUNTED,c),u.addEventListener(t.ElementEvent.UNMOUNTED,f),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,d),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p),this.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,e=this.context.contextService.getDomElement(),this.context.contextService.resize((n=this.context.config).width,n.height),o=this,[4,this.context.deviceContribution.createSwapChain(e)];case 1:return o.swapChain=s.sent(),this.device=this.swapChain.getDevice(),this.renderHelper.setDevice(this.device),this.renderHelper.renderInstManager.disableSimpleMode(),this.swapChain.configureSwapChain(e.width,e.height),u.addEventListener(t.CanvasEvent.RESIZE,(function(){a.swapChain.configureSwapChain(e.width,e.height)})),this.batchManager.attach(i({device:this.device},r)),[2]}}))}))})),o.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),u.removeEventListener(t.ElementEvent.MOUNTED,c),u.removeEventListener(t.ElementEvent.UNMOUNTED,f),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,d),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p),n.device.destroy(),n.device.checkForLeaks(),l.disableRenderHooks=!1})),o.hooks.beginFrame.tap(e.tag,(function(){var e,r,i=n.swapChain.getCanvas(),o=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)r=he;else{var a=t.parseColor(n.context.config.background);r=n.context.config.background?_e(Number(a.r)/255*Number(a.alpha),Number(a.g)/255*Number(a.alpha),Number(a.b)/255*Number(a.alpha),Number(a.alpha)):Re}var s={backbufferWidth:i.width,backbufferHeight:i.height,antialiasingMode:di.None},l=Ri(bn.Color0,s,fi(r)),u=Ri(bn.DepthStencil,s,hi),c=n.builder.createRenderTargetID(l,"Main Color"),f=n.builder.createRenderTargetID(u,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(bn.Color0,c),e.attachRenderTargetID(bn.DepthStencil,f),e.exec((function(e){n.renderLists.world.drawOnPassRenderer(o.renderCache,e)}))})),(null===(e=n.options)||void 0===e?void 0:e.enableFXAA)&&Mi(n.builder,n.renderHelper,s,c),n.builder.resolveRenderTargetToExternalTexture(c,n.swapChain.getOnscreenTexture())})),o.hooks.endFrame.tap(e.tag,(function(){var e=n.renderHelper.renderInstManager,t=n.renderHelper.pushTemplateRenderInst();t.setBindingLayout({numUniformBuffers:2,numSamplers:0}),t.setMegaStateFlags(Fe({depthWrite:!0,blendConstant:he},{rgbBlendMode:F.ADD,alphaBlendMode:F.ADD,rgbBlendSrcFactor:L.SRC_ALPHA,alphaBlendSrcFactor:L.ONE,rgbBlendDstFactor:L.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:L.ONE_MINUS_SRC_ALPHA}));var r=n.context.config,i=r.width,o=r.height,a=n.context.camera;if(t.setUniforms(0,[{name:xi.PROJECTION_MATRIX,value:a.getPerspective()},{name:xi.VIEW_MATRIX,value:a.getViewTransform()},{name:xi.CAMERA_POSITION,value:a.getPosition()},{name:xi.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:xi.VIEWPORT,value:[i,o]},{name:xi.IS_ORTHO,value:a.isOrtho()?1:0},{name:xi.IS_PICKING,value:0}]),n.batchManager.render(n.renderLists.world),e.popTemplateRenderInst(),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),e.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var s=n.captureOptions,l=s.type,u=s.encoderOptions,c=n.context.contextService.getDomElement().toDataURL(l,u);n.resolveCapturePromise(c),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))},e.prototype.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){var t=this;return s(this,(function(r){return this.enableCapture=!0,this.captureOptions=e,this.capturePromise=new Promise((function(e){t.resolveCapturePromise=function(t){e(t)}})),[2,this.capturePromise]}))}))},e.tag="RenderGraph",e}(),Li=function(){function e(e,t,r,n){this.renderHelper=e,this.renderGraphPlugin=t,this.pickingIdGenerator=r,this.batchManager=n}return e.prototype.apply=function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,l=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new En);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},u=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,l),o.addEventListener(t.ElementEvent.UNMOUNTED,u)})),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,l),o.removeEventListener(t.ElementEvent.UNMOUNTED,u),n.pickingIdGenerator.reset()})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,(function(e){return a(n,void 0,void 0,(function(){return s(this,(function(t){return[2,this.pick(e)]}))}))}))},e.prototype.pick=function(e){var r=e.topmost,n=e.position,i=n.viewportX,o=n.viewportY,a=this.context.contextService.getDPR(),s=this.context.config.width*a,l=this.context.config.height*a,u=i*a,c=o*a;if(!this.renderHelper.renderGraph||u>s||0>u||c>l||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(P(Math.round(u),0,s-1),P(Math.round(c),0,l-1),1,1),r?1:100);return e.picked=f,e},e.prototype.pickByRectangleInDepth=function(e,t){void 0===t&&(t=100);var r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i},e.prototype.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},e.prototype.pickByRectangle=function(e,t){var r,n=this,o=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,l=this.renderHelper.renderGraph.newGraphBuilder(),u=this.context.camera,c=e.x,f=e.y,d=e.width,p=e.height,_={backbufferWidth:d,backbufferHeight:p,antialiasingMode:di.None},h=Ri(bn.Color0,_,fi(he)),E=l.createRenderTargetID(h,"Picking Color"),R=Ri(bn.DepthStencil,_,hi),v=l.createRenderTargetID(R,"Picking Depth"),T=i({},u.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),l.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(bn.Color0,E),e.attachRenderTargetID(bn.DepthStencil,v),e.exec((function(e){a.picking.drawOnPassRenderer(s.renderCache,e)})),e.post((function(e){var t=e.getRenderTargetTexture(bn.Color0),i=o.createReadback();T&&T.enabled?u.setViewOffset(T.fullWidth,T.fullHeight,T.offsetX,T.offsetY,T.width,T.height):u.clearViewOffset(),u.setEnableUpdate(!0);var a=i.readTextureSync(t,0,0,d,p,new Uint8Array(d*p*4)),s=-1;if(!a||0===a[0]&&0===a[1]&&0===a[2]||(s=n.pickingIdGenerator.decodePickingColor(a)),s>-1){var l=n.pickingIdGenerator.getById(s);l&&l.isVisible()&&l.isInteractive()&&(r=l)}i.destroy()}))}));var A=this.renderHelper.pushTemplateRenderInst();A.setBindingLayout({numUniformBuffers:2,numSamplers:0}),A.setMegaStateFlags(Fe({depthWrite:!0},{rgbBlendMode:F.ADD,rgbBlendSrcFactor:L.ONE,rgbBlendDstFactor:L.ZERO,alphaBlendMode:F.ADD,alphaBlendSrcFactor:L.ONE,alphaBlendDstFactor:L.ZERO}));var m=this.context.config,g=m.width,S=m.height,y=this.context.contextService.getDPR();return u.setEnableUpdate(!1),u.setViewOffset(g*y,S*y,c,f,d,p),A.setUniforms(0,[{name:xi.PROJECTION_MATRIX,value:u.getPerspective()},{name:xi.VIEW_MATRIX,value:u.getViewTransform()},{name:xi.CAMERA_POSITION,value:u.getPosition()},{name:xi.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:xi.VIEWPORT,value:[d,p]},{name:xi.IS_ORTHO,value:u.isOrtho()?1:0},{name:xi.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r},e.tag="WebGLPicker",e}(),Fi=5e-4,bi=function(){function e(){this.clipPathMeshCreated=!1}return e.prototype.beforeUploadUBO=function(e,t){},e.prototype.beforeInitMesh=function(e){},e.prototype.afterInitMesh=function(e){},e}();!function(e){e.CHANGED="changed"}(Bi||(Bi={}));var Ui=function(e){function t(t,r){var n=e.call(this)||this;n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var o=xe(De),a=o.cullMode,s=o.depthCompare,l=o.depthWrite,u=o.stencilFront,c=o.stencilBack,f=o.stencilWrite,d=o.frontFace,p=o.polygonOffset,_=o.attachmentsState;return n.device=t,n.props=i({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:l,stencilFront:u,stencilBack:c,stencilWrite:f,frontFace:d,polygonOffset:p,attachmentsState:_,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return n(t,e),Object.defineProperty(t.prototype,"cullMode",{get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frontFace",{get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendConstant",{get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquation",{get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquationAlpha",{get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrc",{get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDst",{get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrcAlpha",{get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDstAlpha",{get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthCompare",{get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTest",{get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthWrite",{get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilFront",{get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilBack",{get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilWrite",{get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilRef",{get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"polygonOffset",{get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dithering",{get:function(){return this.props.dithering},set:function(e){this.props.dithering=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeColor",{get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeLineWidth",{get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShader",{get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())},enumerable:!1,configurable:!0}),t.prototype.compile=function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().split("\n").forEach((function(e){var t=u(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,n){return n.trim().split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var l=function(e){s.uniforms.forEach((function(r){t.push("".concat(o,"[").concat(e,"].").concat(r.name))}))},u=0;5>u;u++)l(u);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}(this.props.fragmentShader)},t.prototype.setUniforms=function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(W.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),g(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()},t.prototype.dispatchMutationEvent=function(){this.emit(Bi.CHANGED)},t}(re),Gi=function(e){function t(t,r){var n=e.call(this,t,i({},r))||this;return n.defines=i(i({},n.defines),{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return n(t,e),t}(Ui);function wi(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function ki(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Vi=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=u(e,2);return void 0!==t[1]})))};function Xi(e,t){return 256*(e=P(Math.floor(e),0,255))+(t=P(Math.floor(t),0,255))}var Wi,Hi,Yi=1,zi="FillTextureMapping";!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX"}(Wi||(Wi={})),function(e){e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX"}(Hi||(Hi={}));var Ki,ji,Zi=function(){function e(e,t,r,n,i,o,a){void 0===o&&(o=-1),this.renderHelper=e,this.texturePool=t,this.lightPool=r,this.drawcallCtors=i,this.index=o,this.context=a,this.id=Yi++,this.gradientAttributeName="fill",this.objects=[],this.program=new mn,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeAnchorIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1}return Object.defineProperty(e.prototype,"instance",{get:function(){return this.objects[0]},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new Gi(this.context.device),this.material.defines=i(i({},wi(Hi)),this.material.defines),this.geometry=new Ni(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},e.prototype.observeGeometryChanged=function(){var e=this;this.geometry.on(gi.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.observeMaterialChanged=function(){var e=this;this.material.on(Bi.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.shouldMergeColor=function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return!(!t.isCSSRGB(i)||!t.isCSSRGB(o))||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n]))},e.prototype.shouldMerge=function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))},e.prototype.createGeometry=function(e){var r=this,n=d(),i=d(),o=[],a=[],s=[],l=[],f=this.divisor;e.forEach((function(e){var f,d=e.parsedStyle,_=d.fill,h=d.stroke,R=d.opacity,A=d.fillOpacity,m=d.strokeOpacity,g=d.lineWidth,S=d.anchor,y=d.visibility,C=d.increasedLineWidthForHitTesting,P=[0,0,0,0];t.isCSSRGB(_)&&(P=[Number(_.r),Number(_.g),Number(_.b),255*Number(_.alpha)]);var N=[0,0,0,0];t.isCSSRGB(h)&&(N=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),v(i,r.context.camera.getViewTransform(),n);var I=e.isInteractive()&&(null===(f=e.renderable3D)||void 0===f?void 0:f.encodedPickingColor)||[0,0,0];if(r.mergeAnchorIntoModelMatrix){var O=e.parsedStyle.anchor,M=0,x=0,B=0,D=e.getGeometryBounds();if(D){var L=D.halfExtents;M=-L[0]*O[0]*2,x=-L[1]*O[1]*2,B=-L[2]*(O[2]||0)*2}v(n,e.getWorldTransform(),E(n,T(M,x,B)))}else p(n,e.getWorldTransform());o.push.apply(o,c([],u(n),!1)),a.push(Xi(P[0],P[1]),Xi(P[2],P[3]),Xi(N[0],N[1]),Xi(N[2],N[3])),s.push(R,A,m,g,"visible"===y?1:0,S[0],S[1],C||0),l.push.apply(l,c(c([],u(I),!1),[e.sortable.renderOrder*Fi],!1))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Wi.MODEL_MATRIX,byteStride:64,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.MODEL_MATRIX0,divisor:f},{format:te.F32_RGBA,bufferByteOffset:16,location:Hi.MODEL_MATRIX1,divisor:f},{format:te.F32_RGBA,bufferByteOffset:32,location:Hi.MODEL_MATRIX2,divisor:f},{format:te.F32_RGBA,bufferByteOffset:48,location:Hi.MODEL_MATRIX3,divisor:f}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Wi.PACKED_COLOR,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.PACKED_COLOR,divisor:f}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Wi.PACKED_STYLE,byteStride:32,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.PACKED_STYLE1,divisor:f},{format:te.F32_RGBA,bufferByteOffset:16,location:Hi.PACKED_STYLE2,divisor:f}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Wi.PICKING_COLOR,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.PICKING_COLOR,divisor:f}],data:new Float32Array(l)})},e.prototype.destroy=function(){this.geometry&&this.geometry.destroy()},e.prototype.applyRenderInst=function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:x.ALWAYS,passOp:K.REPLACE},this.material.stencilBack={compare:x.ALWAYS,passOp:K.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:x.EQUAL,passOp:K.KEEP},this.material.stencilBack={compare:x.EQUAL,passOp:K.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var o=i({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=i(i(i({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort((function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new Ti;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:b.CLAMP_TO_EDGE,addressModeV:b.CLAMP_TO_EDGE,minFilter:U.POINT,magFilter:U.BILINEAR,mipmapFilter:G.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!ki(o,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=i(i({},this.material.defines),wi(Hi)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),l=this.renderHelper.getCache().createInputLayout(i(i({},this.geometry.inputLayoutDescriptor),{program:s})),u=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(l,this.geometry.vertexBuffers.filter((function(e){return!!e})).map((function(e){return{buffer:e,byteOffset:0}})),u?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),u?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=Zn(Gn.OPAQUE,t[0].sortable.renderOrder)},e.prototype.updateBatchedAttribute=function(e,r,n,i){var o=this;if(0!==e.length){if("fill"===n||"stroke"===n){var a=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=[0,0,0,0];t.isCSSRGB(n)&&(o=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var s=[0,0,0,0];t.isCSSRGB(i)&&(s=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),a.push(Xi(o[0],o[1]),Xi(o[2],o[3]),Xi(s[0],s[1]),Xi(s[2],s[3]))})),this.geometry.updateVertexBuffer(Wi.PACKED_COLOR,Hi.PACKED_COLOR,r,new Uint8Array(new Float32Array(a).buffer));var s=this.instance.parsedStyle.fill,l=this.textureMappings.findIndex((function(e){return e.name===zi}));if(t.isCSSRGB(s))0>l||(this.textureMappings.splice(l,-1),this.material.textureDirty=!0);else{var f=this.createFillGradientTextureMapping([this.instance]);0>l||this.textureMappings.splice(l,1,f),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var _=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor;_.push(t.opacity,t.fillOpacity,t.strokeOpacity,t.lineWidth,"visible"===t.visibility?1:0,r[0],r[1],t.increasedLineWidthForHitTesting||0)})),this.geometry.updateVertexBuffer(Wi.PACKED_STYLE,Hi.PACKED_STYLE1,r,new Uint8Array(new Float32Array(_).buffer))}else if("modelMatrix"===n){var h=[],R=d();e.forEach((function(e){if(o.mergeAnchorIntoModelMatrix){var t=e.parsedStyle.anchor,r=0,n=0,i=0,a=e.getGeometryBounds();if(a){var s=a.halfExtents;r=-s[0]*t[0]*2,n=-s[1]*t[1]*2,i=-s[2]*(t[2]||0)*2}v(R,e.getWorldTransform(),E(R,T(r,n,i)))}else p(R,e.getWorldTransform());h.push.apply(h,c([],u(R),!1))})),this.geometry.updateVertexBuffer(Wi.MODEL_MATRIX,Hi.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(h).buffer))}else if("pointerEvents"===n){var A=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];A.push.apply(A,c(c([],u(r),!1),[e.sortable.renderOrder*Fi],!1))})),this.geometry.updateVertexBuffer(Wi.PICKING_COLOR,Hi.PICKING_COLOR,r,new Uint8Array(new Float32Array(A).buffer))}}},e.prototype.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)},e.prototype.changeRenderOrder=function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Wi.PICKING_COLOR,Hi.PICKING_COLOR,n,new Uint8Array(new Float32Array(c(c([],u(i),!1),[t*Fi],!1)).buffer))},e.prototype.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Wi.PICKING_COLOR;e.vertexBuffers.length>i;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride;e.vertices[i]=new Float32Array(o/4*r)}var a=0,s=new Uint32Array(r);for(i=0;r>i;i++){for(var l=t[i],u=1;e.vertices.length>u;u++)for(var c=(o=e.inputLayoutDescriptor.vertexBufferDescriptors[u].arrayStride)/4,f=0;c>f;f++)e.vertices[u][a*c+f]=n[u][l*c+f];s[i]=a,a++}for(i=Wi.PICKING_COLOR+1;e.vertexBuffers.length>i;i++){var d=e.inputLayoutDescriptor.vertexBufferDescriptors[i],p=(o=d.arrayStride,e.inputLayoutDescriptor.vertexBufferDescriptors[i].attributes[0]);if(p)e.setVertexBuffer({bufferIndex:i,byteStride:o,stepMode:d.stepMode,attributes:[{format:p.format,bufferByteOffset:p.offset,location:p.shaderLocation,divisor:p.divisor}],data:e.vertices[i]})}var _=new Float32Array(3*r);for(i=0;r>i;)for(u=0;3>u;u++){_[3*(l=s[i++])+u]=1}e.setVertexBuffer({bufferIndex:Wi.BARYCENTRIC,byteStride:12,stepMode:X.VERTEX,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:Number(Hi.BARYCENTRIC)}],data:_}),e.setIndexBuffer(s)},e.prototype.beforeUploadUBO=function(e,t){},e.prototype.uploadUBO=function(e){var r,n=this,o=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),l=!!s,u=null!==(r=o.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(o.defines.USE_WIREFRAME){var f=t.parseColor(o.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:o.wireframeLineWidth})}if(l&&this.uploadFog(c,s),this.uploadMaterial(c,o),u){var d={};a.forEach((function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])}))}c.sort((function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,c);var p=o.blendEquation,_=o.blendEquationAlpha,h=o.blendSrc,E=o.blendDst,R=o.blendSrcAlpha,v=o.blendDstAlpha,T=Vi({blendConstant:o.blendConstant,depthCompare:o.depthCompare,depthWrite:o.depthWrite,stencilFront:o.stencilFront,stencilBack:o.stencilBack,stencilWrite:o.stencilWrite,stencilRef:o.stencilRef,cullMode:o.cullMode,frontFace:o.frontFace,polygonOffset:o.polygonOffset}),A=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(i({attachmentsState:[{channelWriteMask:this.material.stencilWrite?z.NONE:z.ALL,rgbBlendState:i(i({},A.rgbBlendState),Vi({blendMode:p,blendSrcFactor:h,blendDstFactor:E})),alphaBlendState:i(i({},A.alphaBlendState),Vi({blendMode:_,blendSrcFactor:R,blendDstFactor:v}))}]},T)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},e.prototype.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,l=n.density;if(t.isCSSRGB(o)){var u=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,l]}),e.push({name:"u_FogColor",value:u})}},e.prototype.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,c([],u(r),!1))},e.prototype.createFillGradientTextureMapping=function(e){var r,n=this,i=e[0],o=i.parsedStyle[this.gradientAttributeName];if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,ne(te.U8_RGBA_NORM,1,1,1));if(a){var s=new Ti;return s.name=zi,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:b.CLAMP_TO_EDGE,addressModeV:b.CLAMP_TO_EDGE,minFilter:U.POINT,magFilter:U.BILINEAR,mipmapFilter:G.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null},e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(Ki||(Ki={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.SIZE=13]="SIZE"}(ji||(ji={}));var qi=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],Qi=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),wi(ji))},r.prototype.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[];t.forEach((function(e,t){var i=e,o=i.parsedStyle.radius,a=r.shouldOmitStroke(i.parsedStyle),s=r.getSize(e.parsedStyle,i.nodeName);n.push.apply(n,c(c([],u(s),!1),[i.parsedStyle.isBillboard?1:0,i.parsedStyle.isSizeAttenuation?1:0,qi.indexOf(i.nodeName),o&&o[0]||0,a?1:0],!1))})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:16,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.POSITION},{format:te.F32_RG,bufferByteOffset:8,location:Hi.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:Ki.PACKED_STYLE,byteStride:28,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:ji.SIZE,divisor:1},{format:te.F32_RGB,bufferByteOffset:16,location:ji.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var a=[];t.forEach((function(e){var t=e,r=o.shouldOmitStroke(t.parsedStyle),n=u(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,c(c([],u([n[0],n[1]]),!1),[t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,qi.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0],!1))})),this.geometry.updateVertexBuffer(Ki.PACKED_STYLE,ji.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}},r.prototype.getSize=function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n},r.prototype.shouldOmitStroke=function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(o||1>n)},r}(Zi),$i=10,Ji=8,eo=100;function to(e,t,r,n,i,o){for(var a=i[i.length-3],s=i[i.length-3],l=null!=o?o:P(hn(a,s,e,t,r,n,3)/$i,Ji,eo),u=0,c=0,f=1;l>=f;++f){var d=f/l;i.push((u=a+(e-a)*d)+(e+(r-e)*d-u)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function ro(e,t,r,n,i,o,a,s){var l=a[a.length-3],u=a[a.length-2];a.length-=3;var c=null!=s?s:P(pn(l,u,e,t,r,n,i,o,3)/$i,Ji,eo),f=0,d=0,p=0,_=0,h=0;a.push(l,u,0);for(var E=1,R=0;c>=E;++E)a.push((p=(d=(f=1-(R=E/c))*f)*f)*l+3*d*R*e+3*f*(_=R*R)*r+(h=_*R)*i,p*u+3*d*R*t+3*f*_*n+h*o,0)}var no,io,oo=1e20,ao=function(){function e(e,t){var r=e.fontSize,n=void 0===r?24:r,i=e.buffer,o=void 0===i?3:i,a=e.radius,s=void 0===a?8:a,l=e.cutoff,u=void 0===l?.25:l,c=e.fontFamily,f=void 0===c?"sans-serif":c,d=e.fontWeight,p=void 0===d?"normal":d,_=e.fontStyle,h=void 0===_?"normal":_,E=e.canvas;this.buffer=o,this.cutoff=u,this.radius=s;var R=this.size=n+4*o,v=t.offscreenCanvasCreator.getOrCreateCanvas(E);v.width=R,v.height=R;var T=t.offscreenCanvasCreator.getOrCreateContext(E,{willReadFrequently:!0});this.ctx=T,T.font="".concat(h," ").concat(p," ").concat(n,"px ").concat(f),T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(R*R),this.gridInner=new Float64Array(R*R),this.f=new Float64Array(R),this.z=new Float64Array(R+1),this.v=new Uint16Array(R)}return e.prototype.draw=function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,a=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=s+2*this.buffer,c=l+2*this.buffer,f=Math.max(u*c,0),d=new Uint8ClampedArray(f),p={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:r};if(0===s||0===l)return p;var _=this,h=_.ctx,E=_.buffer,R=_.gridInner,v=_.gridOuter;h.clearRect(E,E,s,l),h.fillText(e,E,E+a);var T=h.getImageData(E,E,s,l);v.fill(oo,0,f),R.fill(0,0,f);for(var A=0;l>A;A++)for(var m=0;s>m;m++){var g=T.data[4*(A*s+m)+3]/255;if(0!==g){var S=(A+E)*u+m+E;if(1===g)v[S]=0,R[S]=oo;else v[S]=(C=.5-g)>0?C*C:0,R[S]=0>C?C*C:0}}so(v,0,0,u,c,u,this.f,this.v,this.z),so(R,E,E,s,l,u,this.f,this.v,this.z);for(var y=0;f>y;y++){var C;d[y]=Math.round(255-255*((C=Math.sqrt(v[y])-Math.sqrt(R[y]))/this.radius+this.cutoff))}return p},e}();function so(e,t,r,n,i,o,a,s,l){for(var u=t;t+n>u;u++)lo(e,r*o+u,o,i,a,s,l);for(var c=r;r+i>c;c++)lo(e,c*o+t,1,n,a,s,l)}function lo(e,t,r,n,i,o,a){o[0]=0,a[0]=-oo,a[1]=oo,i[0]=e[t];for(var s=1,l=0,u=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{u=(i[s]-i[f=o[l]]+c-f*f)/(s-f)/2}while(a[l]>=u&&--l>-1);o[++l]=s,a[l]=u,a[l+1]=oo}for(s=0,l=0;n>s;s++){for(;s>a[l+1];)l++;var f,d=s-(f=o[l]);e[t+s*r]=i[f]+d*d}}!function(e){e[e.PACKED=5]="PACKED",e[e.VERTEX_NUM=6]="VERTEX_NUM",e[e.TRAVEL=7]="TRAVEL",e[e.DASH=8]="DASH"}(no||(no={})),function(e){e[e.PREV=8]="PREV",e[e.POINT1=9]="POINT1",e[e.POINT2=10]="POINT2",e[e.NEXT=11]="NEXT",e[e.VERTEX_JOINT=12]="VERTEX_JOINT",e[e.VERTEX_NUM=13]="VERTEX_NUM",e[e.TRAVEL=14]="TRAVEL",e[e.DASH=15]="DASH"}(io||(io={}));function uo(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function co(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!g(r[0][2])}var fo,po=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.mergeAnchorIntoModelMatrix=!0,l.segmentNum=-1,l.segmentNum=l.calcSegmentNum(i),l.gradientAttributeName="stroke",l}return n(r,e),r.calcSubpathNum=function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.path.absolutePath.filter((function(e){return"M"===e[0]})).length:1},r.prototype.calcSegmentNum=function(e){return Eo(e,!1,12,this.calcSubpathIndex(e)).instancedCount},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===go})).length;return this.index-r}return 0},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.segmentNum===n},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),wi(io))},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=[],s=0,l=0;t.forEach((function(e){var t=Eo(e,!1,12,r.calcSubpathIndex(e)),f=t.pointsBuffer,d=t.travelBuffer,p=t.instancedCount,_=e.parsedStyle,h=_.lineDash;a.push(h&&h[0]||0,h&&h[1]||0,_.lineDashOffset||0,uo(_.isBillboard,_.isSizeAttenuation,co(e))),s+=p;for(var E=0;f.length-12>E;E+=4)i.push(f[E],f[E+1],f[E+2],f[E+3],f[E+4],f[E+5],f[E+6],f[E+7],f[E+8],f[E+9],f[E+10],f[E+11],f[E+12],f[E+13],f[E+14],f[E+15]);o.push.apply(o,c([],u(d),!1)),n.push(0+l,2+l,1+l,0+l,3+l,2+l,4+l,6+l,5+l,4+l,7+l,6+l,4+l,7+l,8+l),l+=9})),i.length&&(this.geometry.setVertexBuffer({bufferIndex:no.PACKED,byteStride:64,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:io.PREV,divisor:1},{format:te.F32_RGB,bufferByteOffset:16,location:io.POINT1,divisor:1},{format:te.F32_R,bufferByteOffset:28,location:io.VERTEX_JOINT,divisor:1},{format:te.F32_RGB,bufferByteOffset:32,location:io.POINT2,divisor:1},{format:te.F32_RGB,bufferByteOffset:48,location:io.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:no.VERTEX_NUM,byteStride:4,stepMode:X.INSTANCE,attributes:[{format:te.F32_R,bufferByteOffset:0,byteStride:4,location:io.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:no.TRAVEL,byteStride:4,stepMode:X.INSTANCE,attributes:[{format:te.F32_R,bufferByteOffset:0,byteStride:4,location:io.TRAVEL,divisor:1}],data:new Float32Array(o)}),this.divisor=s/t.length,this.geometry.setVertexBuffer({bufferIndex:no.DASH,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:io.DASH,divisor:this.divisor}],data:new Float32Array(a)}),e.prototype.createGeometry.call(this,t),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var a=[],s=[],l=0;t.forEach((function(e){var t=Eo(e,!1,12,o.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;l=t.instancedCount;for(var i=0;r.length-12>i;i+=4)a.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,c([],u(n),!1))})),this.geometry.updateVertexBuffer(no.PACKED,io.PREV,r*l,new Uint8Array(new Float32Array(a).buffer)),this.geometry.updateVertexBuffer(no.TRAVEL,io.TRAVEL,r,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var f=[];t.forEach((function(e){var t=e.parsedStyle,r=t.lineDash;f.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,uo(t.isBillboard,t.isSizeAttenuation,co(e)))})),this.geometry.updateVertexBuffer(no.DASH,io.DASH,r,new Uint8Array(new Float32Array(f).buffer))}},r}(Zi);!function(e){e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2"}(fo||(fo={}));var _o=3,ho=4;function Eo(e,r,n,i){var o;void 0===r&&(r=!1),void 0===i&&(i=0);var a=e.parsedStyle,s=a.lineCap,l=a.lineJoin,f=e.sortable.renderOrder*Fi,p=e.parsedStyle,_=p.defX,E=p.defY,R=e.parsedStyle,v=R.markerStart,T=R.markerEnd,A=R.markerStartOffset,g=R.markerEndOffset,S=[],y=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var C=e.parsedStyle.points.points,P=C.length,N=0,I=0,O=0,M=0,x=0;v&&t.isDisplayObject(v)&&A&&(N=Math.cos(x=Math.atan2(C[1][1]-C[0][1],C[1][0]-C[0][0]))*(A||0),I=Math.sin(x)*(A||0)),T&&t.isDisplayObject(T)&&g&&(O=Math.cos(x=Math.atan2(C[P-2][1]-C[P-1][1],C[P-2][0]-C[P-1][0]))*(g||0),M=Math.sin(x)*(g||0));var B=e.nodeName===t.Shape.POLYLINE;if(S[0]=C.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=N,i=I):r===P-1&&(n=O,i=M),e.push(t[0]-_+n,t[1]-E+i,B?t[2]||0:f),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return y=un(S[0],[],3),{pointsBuffer:S[0],travelBuffer:[],triangles:y,instancedCount:Math.round(S[0].length/_o)};S[0].push(S[0][0],S[0][1],S[0][2]||f),(o=S[0]).push.apply(o,c([],u(Ro(S[0][0],S[0][1],S[0][2]||f,S[0][3],S[0][4],S[0][5]||f)),!1))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var D=void 0;if(e.nodeName!==t.Shape.PATH){if(D=t.parsePath(t.convertToPath(e,h(d()))),_=D.rect.x,E=D.rect.y,e.nodeName===t.Shape.RECT){var L=e.parsedStyle;0>L.width&&(_+=D.rect.width),0>L.height&&(E+=D.rect.height)}}else D=e.parsedStyle.path;var F=D.absolutePath,b=D.segments,U=0,G=0,w=0,k=0;x=0;if(v&&v.parentNode&&t.isDisplayObject(v)&&A){var V=u(v.parentNode.getStartTangent(),2);U=Math.cos(x=Math.atan2((X=V[0])[1]-(W=V[1])[1],X[0]-W[0]))*(A||0),G=Math.sin(x)*(A||0)}if(T&&T.parentNode&&t.isDisplayObject(T)&&g){var X,W,H=u(T.parentNode.getEndTangent(),2);w=Math.cos(x=Math.atan2((X=H[0])[1]-(W=H[1])[1],X[0]-W[0]))*(g||0),k=Math.sin(x)*(g||0)}var Y=-1,z=-1;if(F.forEach((function(r,i){var o,a=u(r),s=a[0],l=a.slice(1),d=F[i+1],p=0===i&&(0!==U||0!==G),h=(i===F.length-1||d&&("M"===d[0]||"Z"===d[0]))&&0!==w&&0!==k;if("M"===s)z++,S[z]=[],Y=S[z].length,p?S[z].push(l[0]-_+U,l[1]-E+G,f,l[0]-_,l[1]-E,f):S[z].push(l[0]-_,l[1]-E,f);else if("L"===s)h?S[z].push(l[0]-_+w,l[1]-E+k,f):S[z].push(l[0]-_,l[1]-E,f);else if("Q"===s)to(l[0]-_,l[1]-E,l[2]-_,l[3]-E,S[z],n),h&&S[z].push(l[2]-_+w,l[3]-E+k,f);else if("A"===s){for(var R=u(b[i].prePoint,2),v=m(R[0],R[1],l[0],l[1],l[2],l[3],l[4],l[5],l[6],void 0),T=0;v.length>T;T+=6)ro(v[T]-_,v[T+1]-E,v[T+2]-_,v[T+3]-E,v[T+4]-_,v[T+5]-E,S[z],n);h&&S[z].push(l[5]-_+w,l[6]-E+k,f)}else if("C"===s)ro(l[0]-_,l[1]-E,l[2]-_,l[3]-E,l[4]-_,l[5]-E,S[z],n),h&&S[z].push(l[4]-_+w,l[5]-E+k,f);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var A=1e-4;(Math.abs(S[z][S[z].length-2]-S[z][Y])>A||Math.abs(S[z][S[z].length-1]-S[z][Y+1])>A)&&S[z].push(S[z][Y],S[z][Y+1],f),(o=S[z]).push.apply(o,c([],u(Ro(S[z][Y],S[z][Y+1],S[z][Y+2],S[z][Y+3],S[z][Y+4],S[z][Y+5])),!1))}})),r)return{pointsBuffer:J=S[i],travelBuffer:[],triangles:y=un(J,[],3),instancedCount:Math.round(J.length/_o)}}var K=function(e){var t;switch(e){case"bevel":t=fo.JOINT_BEVEL;break;case"round":t=fo.JOINT_ROUND;break;default:t=fo.JOINT_MITER}return t}(l),j=function(e){var t;switch(e){case"square":t=fo.CAP_SQUARE;break;case"round":t=fo.CAP_ROUND;break;default:t=fo.CAP_BUTT}return t}(s),Z=j;j===fo.CAP_ROUND&&(Z=fo.JOINT_CAP_ROUND),j===fo.CAP_BUTT&&(Z=fo.JOINT_CAP_BUTT),j===fo.CAP_SQUARE&&(Z=fo.JOINT_CAP_SQUARE);for(var q=S[i],Q=(Math.round(0/_o)+2)*ho,$=0,J=[],ee=[],te=0;q.length>te;te+=_o)te>1&&($+=Math.sqrt(Math.pow(q[te]-q[te-_o],2)+Math.pow(q[te+1]-q[te+1-_o],2)+Math.pow(q[te+2]-q[te+2-_o],2))),ee.push($),J[Q++]=q[te],J[Q++]=q[te+1],J[Q++]=q[te+2]||0,J[Q]=K,0==te&&j!==fo.CAP_ROUND&&(J[Q]+=j),q.length>te+2*_o?q.length>te+_o||(J[Q]=0):J[Q]+=Z-K,Q++;return J[Q++]=q[q.length-6],J[Q++]=q[q.length-5],J[Q++]=q[q.length-4]||f,J[Q++]=0,J[0]=q[0],J[1]=q[1],J[2]=q[2]||f,J[3]=0,J[4]=q[3],J[5]=q[4],J[6]=q[5]||f,J[7]=j===fo.CAP_ROUND?j:0,{pointsBuffer:J,travelBuffer:ee,triangles:y,instancedCount:Math.round(q.length/_o)}}function Ro(e,t,r,n,i,o){void 0===n&&(n=e),void 0===i&&(i=t),void 0===o&&(o=r);var a=[n-e,i-t,o-r],s=.01;return[e+a[0]*s,t+a[1]*s,r+a[2]*s]}var vo,To;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(vo||(vo={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3"}(To||(To={}));var Ao,mo,go=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.mergeAnchorIntoModelMatrix=!0,l.trianglesHash=[[],[]],l.trianglesHash=l.calcSegmentNum(i),l}return n(r,e),r.prototype.calcSegmentNum=function(e){var t=Eo(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]},r.prototype.calcSubpathIndex=function(e){return e.nodeName===t.Shape.PATH?this.index:0},r.prototype.compareTrianglesHash=function(e){var t=u(this.trianglesHash,2),r=t[0],n=t[1],i=u(e,2),o=i[0],a=i[1];return r.length===o.length&&n.length===a.length&&(!r.some((function(e,t){return e!==o[t]}))&&!n.some((function(e,t){return e!==a[t]})))},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.compareTrianglesHash(n)},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=0;if(t.forEach((function(e,t){var s=Eo(e,!0,12,r.calcSubpathIndex(e)),l=s.triangles,f=s.pointsBuffer;if(l.length){var d=e.getGeometryBounds().halfExtents,p=[];f.forEach((function(e,t){t%3!=2&&p.push(e/d[t%3]/2)})),a+=i.length/3,i.push.apply(i,c([],u(f),!1)),o.push.apply(o,c([],u(p),!1)),n.push.apply(n,c([],u(l.map((function(e){return e+a}))),!1))}})),i.length){e.prototype.createGeometry.call(this,t);var s=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:12,stepMode:X.VERTEX,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:Hi.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:vo.PACKED_STYLE,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:To.PACKED_STYLE3,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Wi.UV,byteStride:8,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.UV}],data:new Float32Array(o)}),this.geometry.vertexCount=n.length/t.length,this.geometry.setIndexBuffer(new Uint32Array(n))}},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(a_Position.xy, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=i(i(i({},this.material.defines),wi(To)),{INSTANCED:!0})},r.prototype.updateAttribute=function(t,r,n,i){if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;o.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(vo.PACKED_STYLE,To.PACKED_STYLE3,r,new Uint8Array(new Float32Array(o).buffer))}},r}(Zi),So=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(Ao||(Ao={})),function(e){e[e.POSITION=8]="POSITION",e[e.UV=10]="UV",e[e.POINTA=9]="POINTA",e[e.POINTB=11]="POINTB",e[e.CAP=12]="CAP",e[e.DASH=13]="DASH"}(mo||(mo={}));var yo,Co,Po={butt:1,round:2,square:3},No=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.gradientAttributeName="stroke",l}return n(r,e),r.isLine=function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.path.absolutePath,i=0,o=0,a=0;n.length>a;a++){if("M"===n[a][0]){if(i===r){o=a;break}i++}}if("M"===n[o][0]&&"L"===n[o+1][0]&&(void 0===n[o+2]||"M"===n[o+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){var s=e.parsedStyle.points.points,l=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]);for(a=1;s.length-1>a;a++)if((s[a+1][0]-s[a+1][1])/(s[a][0]-s[a][1])!==l)return!1;return!0}return!1},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * blur\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),wi(mo))},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===go})).length;return this.index-r}return 0},r.prototype.createGeometry=function(r){var n=this;e.prototype.createGeometry.call(this,r);var i=[],o=[],a=[],s=[],l=0;r.forEach((function(e){var r,u;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,u=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,defX:c.defX,defY:c.defY,lineCap:c.lineCap,lineDash:R=c.lineDash,lineDashOffset:v=c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:T=c.markerStart,markerEnd:A=c.markerEnd,markerStartOffset:m=c.markerStartOffset,markerEndOffset:g=c.markerEndOffset},u=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,p=d.path.absolutePath,_=d.defX,h=d.defY,E=d.lineCap,R=d.lineDash,v=d.lineDashOffset,T=d.markerStart,A=d.markerEnd,m=d.markerStartOffset,g=d.markerEndOffset,S=d.isBillboard,y=d.isSizeAttenuation,C=0,P=0,N=n.calcSubpathIndex(e),I=0;p.length>I;I++){if("M"===p[I][0]){if(C===N){P=I;break}C++}}r={x1:p[P][1],y1:p[P][2],x2:p[P+1][1],y2:p[P+1][2],z1:0,z2:0,defX:_,defY:h,lineCap:E,lineDash:R,lineDashOffset:v,isBillboard:S,isSizeAttenuation:y,markerStart:T,markerEnd:A,markerStartOffset:m,markerEndOffset:g},u=e.getTotalLength()}var O=r.x1,M=r.y1,x=r.x2,B=r.y2,D=r.z1,L=r.z2,F=r.defX,b=r.defY,U=r.lineCap,G=r.isBillboard,w=r.isSizeAttenuation,k=n.calcOffset(r),V=k.startOffsetX,X=k.startOffsetY,W=k.endOffsetX,H=k.endOffsetY,Y=n.calcDash(r,u),z=Y.dashOffset,K=Y.dashSegmentPercent,j=Y.dashRatioInEachSegment;o.push(Po[U]),a.push(z,K,j,G||w?1:0),i.push(O-F+V,M-b+X,D,x-F+W,B-b+H,L),s.push(0+l,2+l,1+l,0+l,3+l,2+l),l+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:20,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:mo.POSITION,divisor:0},{format:te.F32_RG,bufferByteOffset:12,location:mo.UV,divisor:0}],data:new Float32Array(So)}),this.geometry.setVertexBuffer({bufferIndex:Ao.POINT,byteStride:24,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGB,bufferByteOffset:0,location:mo.POINTA,divisor:1},{format:te.F32_RGB,bufferByteOffset:12,location:mo.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Ao.CAP,byteStride:4,stepMode:X.INSTANCE,attributes:[{format:te.F32_R,bufferByteOffset:0,location:mo.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Ao.DASH,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:mo.DASH,divisor:1}],data:new Float32Array(a)})},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(e.prototype.updateAttribute.call(this,r,n,i,o),this.updateBatchedAttribute(r,n,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"path"===i){var s=[];r.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,defX:n.defX,defY:n.defY,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var o=e.parsedStyle,l=o.path.absolutePath;r={x1:l[0][1],y1:l[0][2],x2:l[1][1],y2:l[1][2],z1:0,z2:0,defX:o.defX,defY:o.defY,lineCap:o.lineCap,isBillboard:o.isBillboard,isSizeAttenuation:o.isSizeAttenuation,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var u=r.x1,c=r.y1,f=r.x2,d=r.y2,p=r.z1,_=r.z2,h=r.defX,E=r.defY,R=a.calcOffset(r);s.push(u-h+R.startOffsetX,c-E+R.startOffsetY,p,f-h+R.endOffsetX,d-E+R.endOffsetY,_)})),this.geometry.updateVertexBuffer(Ao.POINT,mo.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var l=[];r.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);l.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)})),this.geometry.updateVertexBuffer(Ao.DASH,mo.DASH,n,new Uint8Array(new Float32Array(l).buffer))}else if("lineCap"===i){var u=[];r.forEach((function(e){u.push(Po[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Ao.CAP,mo.CAP,n,new Uint8Array(new Float32Array(u).buffer))}},r.prototype.calcOffset=function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,l=e.markerStartOffset,u=e.markerEndOffset,c=0,f=0,d=0,p=0,_=0;return a&&t.isDisplayObject(a)&&l&&(c=Math.cos(_=Math.atan2(o-n,i-r))*(l||0),f=Math.sin(_)*(l||0)),s&&t.isDisplayObject(s)&&u&&(d=Math.cos(_=Math.atan2(n-o,r-i))*(u||0),p=Math.sin(_)*(u||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:p}},r.prototype.calcDash=function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}},r}(Zi);!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(yo||(yo={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3"}(Co||(Co={}));var Io=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&this.instance.parsedStyle.img===t.parsedStyle.img},t.prototype.createMaterial=function(e){var t=e[0].parsedStyle.img;this.material.defines=i(i({},this.material.defines),wi(Co)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t);this.material.setUniforms({u_Map:r})},t.prototype.createGeometry=function(t){e.prototype.createGeometry.call(this,t);var r=[],n=[];t.forEach((function(e,t){var i=e.parsedStyle,o=i.isBillboard,a=i.billboardRotation,s=i.isSizeAttenuation;r.push(i.width,i.height),n.push(o?1:0,null!=a?a:0,s?1:0,0)})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wi.POSITION,byteStride:8,stepMode:X.INSTANCE,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:yo.PACKED_STYLE,byteStride:16,stepMode:X.INSTANCE,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Co.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:Wi.UV,byteStride:8,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Hi.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})},t.prototype.updateAttribute=function(t,r,n,i){if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"width"===n||"height"===n||"z"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle;o.push(t.width,t.height)})),this.geometry.updateVertexBuffer(Wi.POSITION,Hi.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var a=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;a.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(yo.PACKED_STYLE,Co.PACKED_STYLE3,r,new Uint8Array(new Float32Array(a).buffer))}else if("img"===n){var s=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:s})}},t}(Zi);function Oo(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function Mo(e,t,r,n,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,s=t.data,l=0;i.height>l;l++)for(var u=((r.y+l)*e.width+r.x)*o,c=((n.y+l)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[u+f];return t}var xo=function(){function e(e,t){Oo(this,e,1,t)}return e.prototype.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Oo({},{width:n,height:i},r);Mo(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=o.data}}(this,e,1)},e.prototype.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){Mo(e,t,r,n,i,1)},e}();var Bo=function(e){var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i)(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&(r.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:f,metrics:c.metrics})}var s=function(e){var t,r,n,i,o=0,a=0;try{for(var s=l(e),u=s.next();!u.done;u=s.next())o+=(h=u.value).w*h.h,a=Math.max(a,h.w)}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.sort((function(e,t){return t.h-e.h}));var c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(o/.95)),a),h:1/0}],f=0,d=0;try{for(var p=l(e),_=p.next();!_.done;_=p.next())for(var h=_.value,E=c.length-1;E>=0;E--){var R=c[E];if(R.w>=h.w&&R.h>=h.h){if(h.x=R.x,h.y=R.y,d=Math.max(d,h.y+h.h),f=Math.max(f,h.x+h.w),h.w===R.w&&h.h===R.h){var v=c.pop();c.length>E&&(c[E]=v)}else h.h===R.h?(R.x+=h.w,R.w-=h.w):h.w===R.w?(R.y+=h.h,R.h-=h.h):(c.push({x:R.x+h.w,y:R.y,w:R.w-h.w,h:h.h}),R.y+=h.h,R.h-=h.h);break}}}catch(e){n={error:e}}finally{try{_&&!_.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}return{w:f,h:d,fill:o/(f*d)||0}}(r),u=new xo({width:s.w||1,height:s.h||1});for(var n in e)for(var a in i=e[n]){var c,f;(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&xo.copy(c.bitmap,u,{x:0,y:0},{x:(f=t[n][a].rect).x+1,y:f.y+1},c.bitmap)}this.image=u,this.positions=t};var Do,Lo,Fo,bo=function(){function e(e){this.runtime=e,this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={}}return e.prototype.getMap=function(){return this.glyphMap},e.prototype.getAtlas=function(){return this.glyphAtlas},e.prototype.getAtlasTexture=function(){return this.glyphAtlasTexture},e.prototype.layout=function(e,t,r,n,i,o,a){var s=this,l=[],u=o,c=a,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=l.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),o=r&&r[n];o&&(l.push({glyph:n,x:u,y:c,scale:1,fontStack:t}),u+=o.metrics.advance+i)}));for(var o=u-i,a=n;l.length>a;a++)l[a].x=l[a].x-f*o;u=0,c+=r})),l},e.prototype.generateAtlas=function(e,t,r,n,o,a,s){var l=this;void 0===t&&(t=""),void 0===o&&(o="");var u=[];this.glyphMap[t]||(u=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(a.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&u.push(e)})),u.length){var f=u.map((function(i){return l.generateSDF(e,t,r,n,o,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=i(i({},this.glyphMap[t]),f),this.glyphAtlas=new Bo(this.glyphMap);var d=this.glyphAtlas.image,p=d.width,_=d.height,h=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=s.createTexture(i(i({},ne(te.ALPHA,p,_,1)),{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([h])}},e.prototype.generateSDF=function(e,t,r,n,i,o){void 0===t&&(t="");var a=o.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new ao({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][o]||(this.textMetricsCache[t][o]=s.ctx.measureText(o).width);var l=s.draw(o),u=l.glyphWidth,c=l.glyphHeight,f=l.glyphLeft,d=l.glyphTop,p=l.glyphAdvance;return{id:a,bitmap:new xo({width:l.width,height:l.height},l.data),metrics:{width:u,height:c,left:f,top:d-24+3,advance:p}}},e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(Do||(Do={})),function(e){e[e.TEX=12]="TEX",e[e.OFFSET=13]="OFFSET"}(Lo||(Lo={})),function(e){e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke"}(Fo||(Fo={}));var Uo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.packedBufferObjectMap=new WeakMap,l.tmpMat4=d(),l.fontHash=l.calcFontHash(i),l.glyphManager=new bo(l.context),l}return n(r,e),r.prototype.calcFontHash=function(e){return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce((function(t,r){return t+e.parsedStyle[r]}),"")},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&(this.index===r&&this.fontHash===this.calcFontHash(t))},r.prototype.createGeometry=function(e){var t=this,r=this.instance.parsedStyle,n=r.textBaseline,i=r.letterSpacing,o=24/r.fontSize,a=[],s=[],l=[],f=0;e.forEach((function(e){var r=e.parsedStyle,d=r.metrics,p=d.font,_=d.lines,h=d.height,E=d.lineHeight,R=r.dx||0,v=r.dy||0,T=0;"middle"===n?T=-h/2:"bottom"===n?T=-h:"top"===n||"hanging"===n?T=0:"alphabetic"===n?(T=.25*E-h,t.context.enableCSSParsing||(T=-h)):"ideographic"===n&&(T=-h);var A=t.glyphManager.getAtlas(),m=t.buildTextBuffers({object:e,lines:_,fontStack:p,lineHeight:o*E,offsetX:o*R,offsetY:o*(T+v),letterSpacing:o*i,glyphAtlas:A,indicesOffset:f}),g=m.indexBuffer,S=m.charUVOffsetBuffer;f=m.indicesOffset;var y=l.length;l.push.apply(l,c([],u(m.charPackedBuffer),!1)),t.packedBufferObjectMap.set(e,[y,l.length]),s.push.apply(s,c([],u(S),!1)),a.push.apply(a,c([],u(g),!1))})),this.geometry.vertexCount=a.length,this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.setVertexBuffer({bufferIndex:Do.INSTANCED,byteStride:128,stepMode:X.VERTEX,attributes:[{format:te.F32_RGBA,bufferByteOffset:0,location:Hi.MODEL_MATRIX0},{format:te.F32_RGBA,bufferByteOffset:16,location:Hi.MODEL_MATRIX1},{format:te.F32_RGBA,bufferByteOffset:32,location:Hi.MODEL_MATRIX2},{format:te.F32_RGBA,bufferByteOffset:48,location:Hi.MODEL_MATRIX3},{format:te.F32_RGBA,bufferByteOffset:64,location:Hi.PACKED_COLOR},{format:te.F32_RGBA,bufferByteOffset:80,location:Hi.PACKED_STYLE1},{format:te.F32_RGBA,bufferByteOffset:96,location:Hi.PACKED_STYLE2},{format:te.F32_RGBA,bufferByteOffset:112,location:Hi.PICKING_COLOR}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:Do.TEX,byteStride:16,stepMode:X.VERTEX,attributes:[{format:te.F32_RG,bufferByteOffset:0,location:Lo.TEX},{format:te.F32_RG,bufferByteOffset:8,location:Lo.OFFSET}],data:new Float32Array(s)})},r.prototype.createMaterial=function(e){var t;this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm) {\n vec4 mvPosition = vm * mm * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4((a_Offset) * fontScale + bufferOffset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=D.BACK,this.material.defines=i(i({},this.material.defines),wi(Lo));var r=this.instance.parsedStyle,n=r.fontSize,o=r.fontFamily,a=void 0===o?"":o,s=r.fontWeight,l=void 0===s?"":s,u=r.fontStyle,c=r.metrics.font,f=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,c,a,""+l,u,f,this.context.device);var d=this.glyphManager.getAtlasTexture(),p=this.glyphManager.getAtlas();this.context.device.setResourceName(d,"TextSDF Texture");var _=p.image,h=_.width,E=_.height;this.material.setUniforms(((t={})[Fo.SDF_MAP]=d,t[Fo.SDF_MAP_SIZE]=[h,E],t[Fo.FONT_SIZE]=n,t[Fo.GAMMA_SCALE]=1,t[Fo.STROKE_BLUR]=.2,t[Fo.HAS_STROKE]=this.index,t))},r.prototype.changeRenderOrder=function(e,t){for(var r=this.geometry.vertices[Do.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Do.INSTANCED].arrayStride/4,i=u(this.packedBufferObjectMap.get(e),2),o=i[0],a=i[1],s=r.slice(o,a),l=0;a-o>l;l+=n)s[l+n-1]=t*Fi;this.geometry.updateVertexBuffer(Do.INSTANCED,Hi.MODEL_MATRIX0,o/n,new Uint8Array(s.buffer))},r.prototype.updateAttribute=function(e,r,n,i){var o=this;if("text"===n||"fontFamily"===n||"fontSize"===n||"fontWeight"===n||"fontStyle"===n||"fontVariant"===n||"textBaseline"===n||"letterSpacing"===n||"wordWrapWidth"===n||"lineHeight"===n||"wordWrap"===n||"textAlign"===n||"dx"===n||"dy"===n)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===n||"fill"===n||"fillOpacity"===n||"stroke"===n||"strokeOpacity"===n||"opacity"===n||"lineWidth"===n||"visibility"===n||"pointerEvents"===n||"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var a=this.geometry.vertices[Do.INSTANCED],s=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Do.INSTANCED].arrayStride/4;e.forEach((function(e){var r,n=e.parsedStyle,i=n.fill,l=n.stroke,c=n.opacity,f=n.fillOpacity,d=n.strokeOpacity,_=n.lineWidth,h=n.visibility,E=n.isBillboard,R=n.billboardRotation,v=n.isSizeAttenuation,T=[0,0,0,0];t.isCSSRGB(i)&&(T=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var A=[0,0,0,0];t.isCSSRGB(l)&&(A=[Number(l.r),Number(l.g),Number(l.b),255*Number(l.alpha)]);for(var m=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],g=p(o.tmpMat4,e.getWorldTransform()),S=u(o.packedBufferObjectMap.get(e),2),y=S[0],C=S[1],P=a.slice(y,C),N=0;C-y>N;N+=s)P[N+0]=g[0],P[N+1]=g[1],P[N+2]=g[2],P[N+3]=g[3],P[N+4]=g[4],P[N+5]=g[5],P[N+6]=g[6],P[N+7]=g[7],P[N+8]=g[8],P[N+9]=g[9],P[N+10]=g[10],P[N+11]=g[11],P[N+12]=g[12],P[N+13]=g[13],P[N+14]=g[14],P[N+15]=g[15],P[N+16]=Xi(T[0],T[1]),P[N+17]=Xi(T[2],T[3]),P[N+18]=Xi(A[0],A[1]),P[N+19]=Xi(A[2],A[3]),P[N+20]=c,P[N+21]=f,P[N+22]=d,P[N+23]=_,P[N+24]="visible"===h?1:0,P[N+25]=E?1:0,P[N+26]=v?1:0,P[N+27]=null!=R?R:0,P[N+28]=m[0],P[N+29]=m[1],P[N+30]=m[2];o.geometry.updateVertexBuffer(Do.INSTANCED,Hi.MODEL_MATRIX0,y/s,new Uint8Array(P.buffer))}))}},r.prototype.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,l=e.offsetX,f=e.offsetY,d=e.glyphAtlas,_=e.indicesOffset,h=n.parsedStyle,E=h.textAlign,R=h.fill,v=h.stroke,T=h.opacity,A=h.fillOpacity,m=h.strokeOpacity,g=h.lineWidth,S=h.visibility,y=h.isBillboard,C=h.billboardRotation,P=h.isSizeAttenuation,N=[0,0,0,0];t.isCSSRGB(R)&&(N=[Number(R.r),Number(R.g),Number(R.b),255*Number(R.alpha)]);var I=[0,0,0,0];t.isCSSRGB(v)&&(I=[Number(v.r),Number(v.g),Number(v.b),255*Number(v.alpha)]);var O=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],M=p(this.tmpMat4,n.getWorldTransform()),x=[],B=[],D=[],L=_,F=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var l=a.metrics.advance*i.scale/2,u=[i.x+l,i.y],c=(a.metrics.left-4)*i.scale-l+u[0],f=(-a.metrics.top-4)*i.scale+u[1],d=c+s.w*i.scale,p=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:p},br:{x:d,y:p},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,E,s,l,f),d.positions);return F.forEach((function(e){var t=[];t.push.apply(t,c([],u(M),!1));var r=c(c(c(c([],u(t),!1),[Xi(N[0],N[1]),Xi(N[2],N[3]),Xi(I[0],I[1]),Xi(I[2],I[3]),T,A,m,g,"visible"===S?1:0,y?1:0,P?1:0,null!=C?C:0],!1),u(O),!1),[n.sortable.renderOrder*Fi],!1);x.push.apply(x,c(c(c(c([],u(r),!1),u(r),!1),u(r),!1),u(r),!1)),B.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),B.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),B.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),B.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),D.push(0+L,2+L,1+L),D.push(2+L,0+L,3+L),L+=4})),{indexBuffer:D,charUVOffsetBuffer:B,charPackedBuffer:x,indicesOffset:L}},r}(Zi),Go=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(r,n){return!!e.prototype.shouldMerge.call(this,r,n)&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},r.prototype.updateAttribute=function(t,r,n,i){e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i)},r.prototype.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},r.prototype.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(Zi),wo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[];return e.parsedStyle.fill.isNone||t.push(Qi),this.needDrawStrokeSeparately(e)&&t.push(po),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}(bi),ko=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.getDrawcallCtors=function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=r.opacity,a=r.strokeOpacity,s=r.lineWidth,l=r.isBillboard,u=i&&!i.isNone,c=po.calcSubpathNum(e),f=[];if(e.nodeName!==t.Shape.POLYLINE&&!n.isNone)for(var d=0;c>d;d++)f.push(go);for(d=0;c>d;d++)if(0!==a&&0!==o&&0!==s&&u){var p=No.isLine(e,d);f.push(!l&&p?No:po)}return f},r}(bi);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e),t.prototype.getDrawcallCtors=function(){return[]}}(bi);var Vo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[Io]},t}(bi),Xo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.stroke;return!(!n||n.isNone||!r.lineWidth)&&t.push(Uo),t.push(Uo),t},t.prototype.beforeUploadUBO=function(e,t){var r;t.material.setUniforms(((r={})[Fo.HAS_STROKE]=1===t.instance.renderable3D.drawcalls.length?0:1-t.index,r))},t}(bi),Wo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[No]},t}(bi),Ho=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[Go]},t}(bi),Yo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,o=i&&i.length&&i.some((function(e){return e!==i[0]}));return n.isNone||o||t.push(Qi),o&&t.push(go),(o||this.needDrawStrokeSeparately(e))&&t.push(po),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}(bi),zo=1,Ko=function(){function e(e,t,r,n){this.renderHelper=e,this.rendererFactory=t,this.texturePool=r,this.lightPool=n,this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return e.prototype.destroy=function(){this.drawcalls.forEach((function(e){e.destroy()})),this.drawcalls=[],this.pendingUpdatePatches={}},e.prototype.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.drawcalls.forEach((function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=r.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),r.renderHelper.renderInstManager.submitRenderInst(o,e),t||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))},e.prototype.attach=function(e){this.context=e},e.prototype.add=function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach((function(i,o,a){var s=t.drawcalls.find((function(t){return i===t.constructor&&t.index===o&&t.maxInstances>t.objects.length&&t.shouldMerge(e,o)}));s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,a,o,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[o]=s,s.geometryDirty=!0)}))}},e.prototype.remove=function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach((function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach((function(e){e.destroy()}))}})),r.drawcalls=[])},e.prototype.updateAttribute=function(e,t,r,n){var i=this;void 0===n&&(n=!1);var o=e.renderable3D,a=this.rendererFactory[e.nodeName];if(a){var s=a.getDrawcallCtors(e);if(s.forEach((function(s,l,u){var c=o.drawcalls.find((function(e){return e&&e.index===l&&e.constructor===s}));if(c||((c=o.drawcalls[l])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&i.drawcalls.splice(i.drawcalls.indexOf(c),1),o.drawcalls[o.drawcalls.indexOf(c)]=void 0),(c=i.drawcalls.find((function(t){return s===t.constructor&&t.index===l&&t.maxInstances>t.objects.length&&t.shouldMerge(e,l)})))?c.geometryDirty=!0:((c=new s(i.renderHelper,i.texturePool,i.lightPool,e,u,l,i.context)).renderer=a,c.init(),i.drawcalls.push(c)),c.objects.push(e),o.drawcalls[l]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,l)){var f=c.objects.indexOf(e);if(n)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;i.pendingUpdatePatches[d]||(i.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[d].objectIndices.indexOf(f)&&i.pendingUpdatePatches[d].objectIndices.push(f)}}else i.remove(e),i.add(e);else i.remove(e),i.add(e)})),o.drawcalls.length>s.length)for(var l=o.drawcalls.length-1;l>=s.length;l--){var u=o.drawcalls[l];u.objects.splice(u.objects.indexOf(e),1),u.geometryDirty=!0,0===u.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(u),1),o.drawcalls.pop()}}},e.prototype.changeRenderOrder=function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach((function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)}))},e.prototype.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=zo++),this.stencilRefCache[e.entity]},e.prototype.updatePendingPatches=function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}},e}(),jo=function(){function e(e,t){this.context=e,this.runtime=t,this.textureCache={}}return e.prototype.getOrCreateTexture=function(e,r,n,o){var a,s=this,l="string"==typeof r?r:r.src||"";if(l&&this.textureCache[l])(a=this.textureCache[l]).emit(W.LOADED);else if(a=e.createTexture(i({format:te.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:H.TEXTURE_2D,usage:Y.SAMPLED,pixelStore:{unpackFlipY:!1}},n)),l&&(this.textureCache[l]=a),C(r)){var u,c=this.context.config.createImage;c?u=c(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){var e=function(e){s.textureCache[l].setImageData([e]),s.textureCache[l].emit(W.LOADED),s.context.renderingService.dirtify(),o&&o(s.textureCache[l])};s.runtime.globalThis.createImageBitmap?s.runtime.globalThis.createImageBitmap(u).then((function(t){return e(t)})).catch((function(){e(u)})):e(u)},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else a.setImageData([r]),a.emit(W.LOADED),this.context.renderingService.dirtify();return a},e.prototype.getOrCreateCanvas=function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)},e.prototype.getOrCreateGradient=function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,o=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),l=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=o;var u=this.context.imagePool;t.forEach((function(e){var t=u.getOrCreateGradient(i(i({type:e.type},e.value),{width:n,height:o}),l);l.fillStyle=t,l.fillRect(0,0,n,o)}))},e.prototype.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,l=r.getGeometryBounds().halfExtents,u=2*l[0]||1,c=2*l[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),p=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);d.width=u,d.height=c;var _=(i=C(o)?this.context.imagePool.getImageSync(o,n):o)&&p.createPattern(i,a);if(s){var h=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));_.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12],f:h[13]})}p.fillStyle=_,p.fillRect(0,0,u,c)},e.prototype.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}(),Zo=function(e){function r(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="device-renderer",r.parameters={toneMapping:Fn.NONE,toneMappingExposure:1},r}return n(r,e),r.prototype.init=function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new Tn;var n=new ui(this.parameters),i=new Rn,o=new jo(this.context,e),a=new An,s=new wo,l=new ko,u=((r={})[t.Shape.CIRCLE]=s,r[t.Shape.ELLIPSE]=s,r[t.Shape.POLYLINE]=l,r[t.Shape.PATH]=l,r[t.Shape.POLYGON]=l,r[t.Shape.RECT]=new Yo,r[t.Shape.IMAGE]=new Vo,r[t.Shape.LINE]=new Wo,r[t.Shape.TEXT]=new Xo,r[t.Shape.MESH]=new Ho,r[t.Shape.GROUP]=void 0,r[t.Shape.HTML]=void 0,r),c=new Ko(n,u,o,i),f=new Di(n,i,o,c,this.options);this.addRenderingPlugin(f),this.addRenderingPlugin(new Li(n,f,a,c))},r.prototype.destroy=function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]},r.prototype.getRenderGraphPlugin=function(){return this.plugins[0]},r.prototype.getDevice=function(){return this.getRenderGraphPlugin().getDevice()},r.prototype.loadTexture=function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)},r.prototype.toDataURL=function(e){return this.getRenderGraphPlugin().toDataURL(e)},r.prototype.setParameters=function(e){this.parameters=i(i({},this.parameters),e)},r}(t.AbstractRendererPlugin),qo=Object.freeze({__proto__:null,get AntialiasingMode(){return di},Batch:bi,BufferGeometry:Ni,DeviceProgram:mn,DynamicUniformBuffer:gn,FILL_TEXTURE_MAPPING:zi,Fog:Si,get FogType(){return vi},get GeometryEvent(){return gi},HashMap:Nn,ImageDrawcall:Io,Instanced:Zi,InstancedFillDrawcall:go,InstancedLineDrawcall:No,InstancedPathDrawcall:po,get JOINT_TYPE(){return fo},Light:mi,Material:Ui,get MaterialEvent(){return Bi},Mesh:vn,MeshDrawcall:Go,Plugin:Zo,get RGAttachmentSlot(){return bn},RenderCache:Un,RenderGraphPlugin:Di,RenderHelper:ui,RenderInst:ii,get RenderInstExecutionOrder(){return ni},get RenderInstFlags(){return ei},RenderInstList:ai,RenderInstManager:li,Renderable3D:En,get RendererLayer(){return Gn},SDFDrawcall:Qi,ShaderMaterial:Gi,SingleSampledTexture:Vn,TemporalTexture:Ai,TextDrawcall:Uo,get TextUniform(){return Fo},TextureMapping:Ti,TexturePool:jo,TinySDF:ao,get ToneMapping(){return Fn},get VertexAttributeBufferIndex(){return Wi},get VertexAttributeLocation(){return Hi},bezierCurveTo:ro,compareDefines:ki,definedProps:Vi,enumToObject:wi,fillColor:function(e,t,r,n){return void 0===n&&(n=r.a),e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r,n){return void 0===n&&(n=0),e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:ri,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:yn,hashCodeNumberUpdate:Sn,makeAttachmentClearDescriptor:fi,makeBackbufferDescSimple:Ri,makeDataBuffer:yi,makeDepthKey:zn,makeSortKey:function(e,t){return void 0===t&&(t=0),e&Gn.TRANSLUCENT?Qn(e):Zn(e,t)},makeSortKeyOpaque:Zn,makeSortKeyTranslucent:Qn,nullHashFunc:Cn,opaqueBlackFullClearRenderPassDescriptor:_i,opaqueWhiteFullClearRenderPassDescriptor:hi,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===q.NEGATIVE_ONE?function(e){v(e,Jn,e)}(e):t===q.ZERO&&function(e){v(e,ti,e)}(e))},pushFXAAPass:Mi,quadCurveTo:to,renderInstCompareNone:null,renderInstCompareSortKey:oi,segmentInstanceGeometry:So,setBackbufferDescSimple:Ei,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=Hn);var n=!!(e>>>31&1),i=zn(t,n,r);return n?$n(e,i):qn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?$n(e,t):qn(e,t)},setSortKeyLayer:Kn,setSortKeyOpaqueDepth:qn,setSortKeyProgramKey:jn,setSortKeyTranslucentDepth:$n,standardFullClearRenderPassDescriptor:pi,updateBuffer:Eo}),Qo=function(){function e(){}return e.prototype.apply=function(t,r){var n=this,i=t.renderingService,o=t.renderingContext,a=t.config;this.context=t;var s=o.root.ownerDocument.defaultView,l=function(e){i.hooks.pointerMove.call(e)},u=function(e){i.hooks.pointerUp.call(e)},c=function(e){i.hooks.pointerDown.call(e)},f=function(e){i.hooks.pointerOver.call(e)},d=function(e){i.hooks.pointerOut.call(e)},p=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},h=function(e){i.hooks.click.call(e)};i.hooks.init.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?function(e){r.globalThis.document.addEventListener("pointermove",l,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",u,!0),r.globalThis.addEventListener("pointercancel",p,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",l,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.addEventListener("touchstart",c,!0),e.addEventListener("touchend",u,!0),e.addEventListener("touchmove",l,!0),e.addEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.addEventListener("click",h,!0),e.addEventListener("wheel",_,{passive:!0,capture:!0})})),i.hooks.destroy.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):s.supportsPointerEvents&&(e.style.touchAction=""),s.supportsPointerEvents?function(e){r.globalThis.document.removeEventListener("pointermove",l,!0),e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",u,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",l,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",c,!0),e.removeEventListener("touchend",u,!0),e.removeEventListener("touchmove",l,!0),e.removeEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.removeEventListener("click",h,!0),e.removeEventListener("wheel",_,!0)}))},e.tag="DOMInteraction",e}(),$o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="dom-interaction",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new Qo)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),Jo=Object.freeze({__proto__:null,Plugin:$o}),ea=function(){function e(){this.displayObjectHTMLElementMap=new WeakMap}return e.prototype.joinTransformMatrix=function(e){return"matrix(".concat([e[0],e[1],e[4],e[5],e[12],e[13]].join(","),")")},e.prototype.apply=function(r,n){var i=this,o=r.camera,a=r.renderingContext,s=r.renderingService;this.context=r;var l=a.root.ownerDocument.defaultView,u=function(e,t){t.style.transform=i.joinTransformMatrix(e.getWorldTransform())},c=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){i.$camera||(i.$camera=i.createCamera(o));var a=i.getOrCreateEl(r);if(i.$camera.appendChild(a),n.enableCSSParsing){var s=r.ownerDocument.documentElement.attributes;Object.keys(s).forEach((function(e){a.style[e]=s[e]}))}Object.keys(r.attributes).forEach((function(e){i.updateAttribute(e,r)})),u(r,a),i.context.nativeHTMLMap.set(a,r)}},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&i.$camera){var n=i.getOrCreateEl(r);n&&(n.remove(),i.context.nativeHTMLMap.delete(n))}},d=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&i.updateAttribute(e.attrName,r)},p=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var n=i.getOrCreateEl(r);u(r,n)}},_=function(){if(i.$camera){var e=i.context.config,t=e.height;i.$camera.style.width="".concat(e.width||0,"px"),i.$camera.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,_),l.addEventListener(t.ElementEvent.MOUNTED,c),l.addEventListener(t.ElementEvent.UNMOUNTED,f),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,d),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),s.hooks.endFrame.tap(e.tag,(function(){i.$camera&&a.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(i.$camera.style.transform=i.joinTransformMatrix(o.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){i.$camera&&i.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,_),l.removeEventListener(t.ElementEvent.MOUNTED,c),l.removeEventListener(t.ElementEvent.UNMOUNTED,f),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,d),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)}))},e.prototype.createCamera=function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",l=a.querySelector("#"+s);if(!l){var u=(r||document).createElement("div");l=u,u.id=s,u.style.position="absolute",u.style.left="".concat(o.offsetLeft||0,"px"),u.style.top="".concat(o.offsetTop||0,"px"),u.style.transformOrigin="left top",u.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),u.style.overflow="hidden",u.style.pointerEvents="none",u.style.width="".concat(n||0,"px"),u.style.height="".concat(i||0,"px"),a.appendChild(u)}return l}return null},e.prototype.getOrCreateEl=function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style.left="0px",r.style.top="0px",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform())),r},e.prototype.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;C(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].value," ").concat(o[1].value);break;case"width":if(this.context.enableCSSParsing){var a=r.computedStyleMap().get("width");n.style.width=""+a}else{n.style.width=N(a=r.parsedStyle.width)?"".concat(a,"px"):""+a}break;case"height":if(this.context.enableCSSParsing){var s=r.computedStyleMap().get("height");n.style.height=""+s}else{n.style.height=N(s=r.parsedStyle.height)?"".concat(s,"px"):""+s}break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var l=r.parsedStyle.fill,u="";t.isCSSRGB(l)?u=l.isNone?"transparent":r.getAttribute("fill"):Array.isArray(l)?u=r.getAttribute("fill"):t.isPattern(l),n.style.background=u;break;case"stroke":var c=r.parsedStyle.stroke,f="";t.isCSSRGB(c)?f=c.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(c)?f=r.getAttribute("stroke"):t.isPattern(c),n.style["border-color"]=f,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:"x"!==e&&"y"!==e&&(g(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e]))}},e.tag="HTMLRendering",e}(),ta=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="html-renderer",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new ea)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ra=Object.freeze({__proto__:null,Plugin:ta}),na=function(){function e(e){this.canvasConfig=e,this.imageCache={},this.gradientCache={},this.patternCache={}}return e.prototype.getImageSync=function(e,t){return this.imageCache[e]?t&&t(this.imageCache[e]):this.getOrCreateImage(e).then((function(e){t&&t(e)})),this.imageCache[e]},e.prototype.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){r.imageCache[e]=a,i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e)}))},e.prototype.getOrCreatePatternSync=function(e,r,n,i,o){var a=this.generatePatternKey(e);if(a&&this.patternCache[a])return this.patternCache[a];var s,l=e.image,u=e.repetition,c=e.transform,f=!1;C(l)?s=this.getImageSync(l,o):n?(s=n,f=!0):s=l;var p=s&&r.createPattern(s,u);if(p){var _=void 0;_=c?t.parsedTransformToMat4(t.parseTransform(c),new t.DisplayObject({})):h(d()),f&&function(e,t,r){var n=r[0],i=r[1],o=r[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(_,_,[1/i,1/i,1]),p.setTransform({a:_[0],b:_[1],c:_[4],d:_[5],e:_[12],f:_[13]})}return a&&p&&(this.patternCache[a]=p),p},e.prototype.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,s=e.height,l=e.cx,u=e.cy,c=e.size;if(this.gradientCache[n])return this.gradientCache[n];var f=null;if(i===t.GradientType.LinearGradient){var d=t.computeLinearGradient(a,s,e.angle);f=r.createLinearGradient(d.x1,d.y1,d.x2,d.y2)}else if(i===t.GradientType.RadialGradient){var p=t.computeRadialGradient(a,s,l,u,c),_=p.x,h=p.y;f=r.createRadialGradient(_,h,0,_,h,p.r)}return f&&(o.forEach((function(e){var r=e.offset;r.unit===t.UnitType.kPercentage&&(null==f||f.addColorStop(r.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]},e.prototype.generateGradientKey=function(e){var t=e.width,r=e.height,n=e.steps,i=e.angle,o=e.cx,a=e.cy,s=e.size;return"gradient-".concat(e.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(t,"-").concat(r,"-").concat(n.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))},e.prototype.generatePatternKey=function(e){var t=e.image,r=e.repetition;return C(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0},e}(),ia=function(){function e(){}return e.prototype.apply=function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e,t,r){var n=e.parsedStyle,i=n.width,o=n.height;i&&!o?e.setAttribute("height",r/t*i):!i&&o&&e.setAttribute("width",t/r*o)},s=function(e){var r=e.target,o=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=o.img,l=o.keepAspectRatio;C(s)&&i.getImageSync(s,(function(e){l&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))}},l=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"img"===e.attrName&&C(o)&&i.getOrCreateImage(o).then((function(e){r.attributes.keepAspectRatio&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,s),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,l)})),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,s),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,l)}))},e.tag="LoadImage",e}(),oa=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="image-loader",t}return n(t,e),t.prototype.init=function(){this.context.imagePool=new na(this.context.config),this.addRenderingPlugin(new ia)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),aa=function(){function e(e){this.canvasConfig=e.config,this.deviceRendererPlugin=e.deviceRendererPlugin}return e.prototype.init=function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=C(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.deviceRendererPlugin.getDevice().canvasContext},e.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},e.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},e.prototype.resize=function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(e){return[2,""]}))}))},e}(),sa=function(e){function t(t,r){var n=e.call(this)||this;return n.rendererPlugin=t,n.config=r,n.name="webgpu-context-register",n}return n(t,e),t.prototype.init=function(){this.context.ContextService=aa,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new Lr({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})},t.prototype.destroy=function(){delete this.context.ContextService},t}(t.AbstractRendererPlugin),la=function(e){function r(r){var n=e.call(this,r)||this;n.clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var i=new Zo;return n.registerPlugin(new sa(i,r)),n.registerPlugin(new oa),n.registerPlugin(i),n.registerPlugin(new $o),n.registerPlugin(new ta),n}return n(r,e),r}(t.AbstractRenderer);e.DeviceRenderer=qo,e.DomInteraction=Jo,e.HTMLRenderer=ra,e.Renderer=la}));
2
2
  //# sourceMappingURL=index.umd.min.js.map