@antv/g-webgpu 1.0.1 → 1.1.0

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,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@antv/g"),require("mana-syringe")):"function"==typeof define&&define.amd?define(["@antv/g","mana-syringe"],t):"object"==typeof exports?exports.WebGPU=t(require("@antv/g"),require("mana-syringe")):(e.G=e.G||{},e.G.WebGPU=t(e.G,e.G.ManaSyringe))}(window,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,i="~";function o(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function u(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var u=new a(n,r||e,o),s=i?i+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],u]:e._events[s].push(u):(e._events[s]=u,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function l(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),l.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},l.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,o=n.length,a=new Array(o);r<o;r++)a[r]=n[r].fn;return a},l.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},l.prototype.emit=function(e,t,n,r,o,a){var u=i?i+e:e;if(!this._events[u])return!1;var s,l,c=this._events[u],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,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,a),!0}for(l=1,s=new Array(f-1);l<f;l++)s[l-1]=arguments[l];c.fn.apply(c.context,s)}else{var d,h=c.length;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,r);break;default:if(!s)for(d=1,s=new Array(f-1);d<f;d++)s[d-1]=arguments[d];c[l].fn.apply(c[l].context,s)}}return!0},l.prototype.on=function(e,t,n){return u(this,e,t,n,!1)},l.prototype.once=function(e,t,n){return u(this,e,t,n,!0)},l.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||r&&!a.once||n&&a.context!==n||s(this,o);else{for(var u=0,l=[],c=a.length;u<c;u++)(a[u].fn!==t||r&&!a[u].once||n&&a[u].context!==n)&&l.push(a[u]);l.length?this._events[o]=1===l.length?l[0]:l:s(this,o)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,e.exports=l},function(e,t,n){"use strict";function r(e,t,n){n=n||2;var r,u,s,l,c,h,_,E=t&&t.length,v=E?t[0]*n:e.length,R=i(e,0,v,n,!0),T=[];if(!R||R.next===R.prev)return T;if(E&&(R=function(e,t,n,r){var a,u,s,l,c,h=[];for(a=0,u=t.length;a<u;a++)s=t[a]*r,l=a<u-1?t[a+1]*r:e.length,(c=i(e,s,l,r,!1))===c.next&&(c.steiner=!0),h.push(p(c));for(h.sort(f),a=0;a<h.length;a++)n=o(n=d(h[a],n),n.next);return n}(e,t,R,n)),e.length>80*n){r=s=e[0],u=l=e[1];for(var m=n;m<v;m+=n)(c=e[m])<r&&(r=c),(h=e[m+1])<u&&(u=h),c>s&&(s=c),h>l&&(l=h);_=0!==(_=Math.max(s-r,l-u))?1/_:0}return a(R,T,n,r,u,_),T}function i(e,t,n,r,i){var o,a;if(i===N(e,t,n,r)>0)for(o=t;o<n;o+=r)a=C(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=C(o,e[o],e[o+1],a);return a&&T(a,a.next)&&(O(a),a=a.next),a}function o(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!T(r,r.next)&&0!==R(r.prev,r,r.next))r=r.next;else{if(O(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function a(e,t,n,r,i,f,d){if(e){!d&&f&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=_(i.x,i.y,t,n,r)),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,n,r,i,o,a,u,s,l=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,u=0,t=0;t<l&&(u++,r=r.nextZ);t++);for(s=l;u>0||s>0&&r;)0!==u&&(0===s||!r||n.z<=r.z)?(i=n,n=n.nextZ,u--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,l*=2}while(a>1)}(i)}(e,r,i,f);for(var h,p,E=e;e.prev!==e.next;)if(h=e.prev,p=e.next,f?s(e,r,i,f):u(e))t.push(h.i/n),t.push(e.i/n),t.push(p.i/n),O(e),e=p.next,E=p.next;else if((e=p)===E){d?1===d?a(e=l(o(e),t,n),t,n,r,i,f,2):2===d&&c(e,t,n,r,i,f):a(o(e),t,n,r,i,f,1);break}}}function u(e){var t=e.prev,n=e,r=e.next;if(R(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(E(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&R(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function s(e,t,n,r){var i=e.prev,o=e,a=e.next;if(R(i,o,a)>=0)return!1;for(var u=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,s=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,l=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,f=_(u,s,t,n,r),d=_(l,c,t,n,r),h=e.prevZ,p=e.nextZ;h&&h.z>=f&&p&&p.z<=d;){if(h!==e.prev&&h!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&R(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==e.prev&&p!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&R(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=f;){if(h!==e.prev&&h!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&R(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&R(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function l(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!T(i,a)&&m(i,r,r.next,a)&&A(i,a)&&A(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),O(r),O(r.next),r=e=a),r=r.next}while(r!==e);return o(r)}function c(e,t,n,r,i,u){var s=e;do{for(var l=s.next.next;l!==s.prev;){if(s.i!==l.i&&v(s,l)){var c=S(s,l);return s=o(s,s.next),c=o(c,c.next),a(s,t,n,r,i,u),void a(c,t,n,r,i,u)}l=l.next}s=s.next}while(s!==e)}function f(e,t){return e.x-t.x}function d(e,t){var n=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var u=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(u<=i&&u>a){if(a=u,u===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===a)return n;var s,l=n,c=n.x,f=n.y,d=1/0;r=n;do{i>=r.x&&r.x>=c&&i!==r.x&&E(o<f?i:a,o,c,f,o<f?a:i,o,r.x,r.y)&&(s=Math.abs(o-r.y)/(i-r.x),A(r,e)&&(s<d||s===d&&(r.x>n.x||r.x===n.x&&h(n,r)))&&(n=r,d=s)),r=r.next}while(r!==l);return n}(e,t);if(!n)return t;var r=S(n,e),i=o(n,n.next);return o(r,r.next),t===n?i:t}function h(e,t){return R(e.prev,e,t.prev)<0&&R(t.next,e,e.next)<0}function _(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function p(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function E(e,t,n,r,i,o,a,u){return(i-a)*(t-u)-(e-a)*(o-u)>=0&&(e-a)*(r-u)-(n-a)*(t-u)>=0&&(n-a)*(o-u)-(i-a)*(r-u)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&m(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(A(e,t)&&A(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(R(e.prev,e,t.prev)||R(e,t.prev,t))||T(e,t)&&R(e.prev,e,e.next)>0&&R(t.prev,t,t.next)>0)}function R(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function T(e,t){return e.x===t.x&&e.y===t.y}function m(e,t,n,r){var i=g(R(e,t,n)),o=g(R(e,t,r)),a=g(R(n,r,e)),u=g(R(n,r,t));return i!==o&&a!==u||(!(0!==i||!y(e,n,t))||(!(0!==o||!y(e,r,t))||(!(0!==a||!y(n,e,r))||!(0!==u||!y(n,t,r)))))}function y(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function g(e){return e>0?1:e<0?-1:0}function A(e,t){return R(e.prev,e,e.next)<0?R(e,t,e.next)>=0&&R(e,e.prev,t)>=0:R(e,t,e.prev)<0||R(e,e.next,t)<0}function S(e,t){var n=new I(e.i,e.x,e.y),r=new I(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function C(e,t,n,r){var i=new I(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function O(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 I(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function N(e,t,n,r){for(var i=0,o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}e.exports=r,e.exports.default=r,r.deviation=function(e,t,n,r){var i=t&&t.length,o=i?t[0]*n:e.length,a=Math.abs(N(e,0,o,n));if(i)for(var u=0,s=t.length;u<s;u++){var l=t[u]*n,c=u<s-1?t[u+1]*n:e.length;a-=Math.abs(N(e,l,c,n))}var f=0;for(u=0;u<r.length;u+=3){var d=r[u]*n,h=r[u+1]*n,_=r[u+2]*n;f+=Math.abs((e[d]-e[_])*(e[h+1]-e[d+1])-(e[d]-e[h])*(e[_+1]-e[d+1]))}return 0===a&&0===f?0:Math.abs((f-a)/a)},r.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var a=0;a<t;a++)n.vertices.push(e[i][o][a]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n}},function(e,t,n){var r=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,o=Object.create(i.prototype),a=new A(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return C()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=m(a,n);if(u){if(u===c)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=l(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===c)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,a),o}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var c={};function f(){}function d(){}function h(){}var _={};u(_,i,(function(){return this}));var p=Object.getPrototypeOf,E=p&&p(p(S([])));E&&E!==t&&n.call(E,i)&&(_=E);var v=h.prototype=f.prototype=Object.create(_);function R(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,u){var s=l(e[i],e,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,u)}))}u(s.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function m(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,m(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=l(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function g(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return d.prototype=h,u(v,"constructor",h),u(h,"constructor",d),d.displayName=u(h,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,u(e,a,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},R(T.prototype),u(T.prototype,o,(function(){return this})),e.AsyncIterator=T,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new T(s(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(v),u(v,a,"Generator"),u(v,i,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=S,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(g),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,c):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),g(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;g(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(e,t,n){"use strict";n.r(t),n.d(t,"DomInteraction",(function(){return r})),n.d(t,"DeviceRenderer",(function(){return i})),n.d(t,"WebGPUDevice",(function(){return o})),n.d(t,"Renderer",(function(){return wa}));var r={};n.r(r),n.d(r,"Plugin",(function(){return y}));var i={};n.r(i),n.d(i,"Batch",(function(){return ni})),n.d(i,"BlendFactor",(function(){return ae})),n.d(i,"BlendMode",(function(){return ue})),n.d(i,"BufferFrequencyHint",(function(){return he})),n.d(i,"BufferGeometry",(function(){return ii})),n.d(i,"BufferUsage",(function(){return de})),n.d(i,"ChannelWriteMask",(function(){return ve})),n.d(i,"ClipSpaceNearZ",(function(){return ye})),n.d(i,"CompareMode",(function(){return re})),n.d(i,"CopyProgram",(function(){return Co})),n.d(i,"CullMode",(function(){return oe})),n.d(i,"DeviceContribution",(function(){return _o})),n.d(i,"DeviceProgram",(function(){return xn})),n.d(i,"DynamicUniformBuffer",(function(){return Bn})),n.d(i,"Endianness",(function(){return Pt})),n.d(i,"FillMesh",(function(){return wi})),n.d(i,"Fog",(function(){return lo})),n.d(i,"FogType",(function(){return uo})),n.d(i,"Format",(function(){return Oe})),n.d(i,"FormatCompFlags",(function(){return Se})),n.d(i,"FormatFlags",(function(){return Ce})),n.d(i,"FormatTypeFlags",(function(){return Ae})),n.d(i,"FrontFaceMode",(function(){return ie})),n.d(i,"GL",(function(){return Ie})),n.d(i,"HashMap",(function(){return Un})),n.d(i,"ImageMesh",(function(){return Gi})),n.d(i,"Instanced",(function(){return fi})),n.d(i,"InstancedLineMesh",(function(){return yi})),n.d(i,"IsDepthReversed",(function(){return Je})),n.d(i,"JOINT_TYPE",(function(){return Ii})),n.d(i,"Light",(function(){return ao})),n.d(i,"LineMesh",(function(){return Bi})),n.d(i,"Material",(function(){return oi})),n.d(i,"Mesh",(function(){return Zi})),n.d(i,"MeshMesh",(function(){return Qi})),n.d(i,"MipFilterMode",(function(){return ce})),n.d(i,"OpaqueBlack",(function(){return qe})),n.d(i,"OpaqueWhite",(function(){return Qe})),n.d(i,"Plugin",(function(){return Mo})),n.d(i,"PrimitiveTopology",(function(){return fe})),n.d(i,"QueryPoolType",(function(){return ge})),n.d(i,"RenderCache",(function(){return Yn})),n.d(i,"RenderGraphPlugin",(function(){return vo})),n.d(i,"RenderHelper",(function(){return Gr})),n.d(i,"RenderInst",(function(){return Mr})),n.d(i,"RenderInstExecutionOrder",(function(){return Br})),n.d(i,"RenderInstFlags",(function(){return Sr})),n.d(i,"RenderInstList",(function(){return Lr})),n.d(i,"RenderInstManager",(function(){return wr})),n.d(i,"Renderable3D",(function(){return te})),n.d(i,"RendererLayer",(function(){return Jn})),n.d(i,"ResourceType",(function(){return ne})),n.d(i,"SDFMesh",(function(){return pi})),n.d(i,"SamplerFormatKind",(function(){return Te})),n.d(i,"ShaderMaterial",(function(){return ai})),n.d(i,"SingleSampledTexture",(function(){return Qn})),n.d(i,"StencilOp",(function(){return Re})),n.d(i,"TemporalTexture",(function(){return Vr})),n.d(i,"TexFilterMode",(function(){return le})),n.d(i,"TextMesh",(function(){return zi})),n.d(i,"TextUniform",(function(){return Ki})),n.d(i,"TextureDimension",(function(){return pe})),n.d(i,"TextureMapping",(function(){return kr})),n.d(i,"TexturePool",(function(){return zr})),n.d(i,"TextureUsage",(function(){return Ee})),n.d(i,"TransparentBlack",(function(){return ze})),n.d(i,"TransparentWhite",(function(){return Ze})),n.d(i,"UNIFORM_SETTERS",(function(){return yn})),n.d(i,"Uniform",(function(){return xi})),n.d(i,"VertexAttributeBufferIndex",(function(){return si})),n.d(i,"VertexAttributeLocation",(function(){return li})),n.d(i,"VertexBufferFrequency",(function(){return _e})),n.d(i,"ViewportOrigin",(function(){return me})),n.d(i,"WrapMode",(function(){return se})),n.d(i,"align",(function(){return lt})),n.d(i,"alignNonPowerOfTwo",(function(){return ct})),n.d(i,"arrayCopy",(function(){return Bt})),n.d(i,"arrayEqual",(function(){return xt})),n.d(i,"assert",(function(){return We})),n.d(i,"assertExists",(function(){return Xe})),n.d(i,"bindingLayoutDescriptorCopy",(function(){return Qt})),n.d(i,"bindingLayoutDescriptorEqual",(function(){return bt})),n.d(i,"bindingLayoutSamplerDescriptorCopy",(function(){return Zt})),n.d(i,"bindingsDescriptorCopy",(function(){return qt})),n.d(i,"bindingsDescriptorEquals",(function(){return Lt})),n.d(i,"bisectRight",(function(){return ft})),n.d(i,"bufferBindingCopy",(function(){return zt})),n.d(i,"colorCopy",(function(){return je})),n.d(i,"colorEqual",(function(){return He})),n.d(i,"colorNewCopy",(function(){return Ye})),n.d(i,"colorNewFromRGBA",(function(){return Ke})),n.d(i,"compareDepthValues",(function(){return it})),n.d(i,"containerModule",(function(){return Bo})),n.d(i,"copyAttachmentState",(function(){return Tt})),n.d(i,"copyAttachmentStateFromSimple",(function(){return At})),n.d(i,"copyMegaState",(function(){return gt})),n.d(i,"defaultBindingLayoutSamplerDescriptor",(function(){return Dt})),n.d(i,"defaultMegaState",(function(){return Ct})),n.d(i,"enumToObject",(function(){return ui})),n.d(i,"fallbackUndefined",(function(){return at})),n.d(i,"fillArray",(function(){return st})),n.d(i,"fillColor",(function(){return Dr})),n.d(i,"fillMatrix4x4",(function(){return xr})),n.d(i,"fillVec3v",(function(){return Ir})),n.d(i,"fillVec4",(function(){return Nr})),n.d(i,"fillVec4v",(function(){return Pr})),n.d(i,"fullscreenMegaState",(function(){return It})),n.d(i,"getAttributeLocations",(function(){return On})),n.d(i,"getDefines",(function(){return Cn})),n.d(i,"getFormatByteSize",(function(){return we})),n.d(i,"getFormatCompByteSize",(function(){return Le})),n.d(i,"getFormatCompFlags",(function(){return Be})),n.d(i,"getFormatCompFlagsComponentCount",(function(){return De})),n.d(i,"getFormatComponentCount",(function(){return Ue})),n.d(i,"getFormatFlags",(function(){return Fe})),n.d(i,"getFormatSamplerKind",(function(){return Ve})),n.d(i,"getFormatTypeFlags",(function(){return Me})),n.d(i,"getFormatTypeFlagsByteSize",(function(){return be})),n.d(i,"getSortKeyDepth",(function(){return hr})),n.d(i,"getSortKeyLayer",(function(){return nr})),n.d(i,"getSystemEndianness",(function(){return an})),n.d(i,"getUniformSetter",(function(){return gn})),n.d(i,"getUniforms",(function(){return In})),n.d(i,"hashCodeNumberFinish",(function(){return Fn})),n.d(i,"hashCodeNumberUpdate",(function(){return Mn})),n.d(i,"inputLayoutBufferDescriptorCopy",(function(){return en})),n.d(i,"inputLayoutBufferDescriptorEquals",(function(){return Xt})),n.d(i,"inputLayoutDescriptorCopy",(function(){return tn})),n.d(i,"inputLayoutDescriptorEquals",(function(){return Ht})),n.d(i,"isPowerOfTwo",(function(){return ot})),n.d(i,"leftPad",(function(){return Et})),n.d(i,"makeDepthKey",(function(){return tr})),n.d(i,"makeFormat",(function(){return xe})),n.d(i,"makeMegaState",(function(){return Ot})),n.d(i,"makeSortKey",(function(){return cr})),n.d(i,"makeSortKeyOpaque",(function(){return ar})),n.d(i,"makeSortKeyTranslucent",(function(){return sr})),n.d(i,"makeStaticDataBuffer",(function(){return ri})),n.d(i,"makeTextureDescriptor2D",(function(){return Pe})),n.d(i,"nArray",(function(){return _t})),n.d(i,"nullHashFunc",(function(){return bn})),n.d(i,"nullify",(function(){return ut})),n.d(i,"parseUniformName",(function(){return sn})),n.d(i,"prependLineNo",(function(){return pt})),n.d(i,"preprocessProgramObj_GLSL",(function(){return Dn})),n.d(i,"preprocessProgram_GLSL",(function(){return Pn})),n.d(i,"preprocessShader_GLSL",(function(){return Nn})),n.d(i,"projectionMatrixConvertClipSpaceNearZ",(function(){return Or})),n.d(i,"pushFXAAPass",(function(){return Po})),n.d(i,"range",(function(){return vt})),n.d(i,"renderInstCompareNone",(function(){return Fr})),n.d(i,"renderInstCompareSortKey",(function(){return br})),n.d(i,"renderPipelineDescriptorCopy",(function(){return Jt})),n.d(i,"renderPipelineDescriptorEquals",(function(){return Vt})),n.d(i,"reverseDepthForClearValue",(function(){return nt})),n.d(i,"reverseDepthForCompareMode",(function(){return tt})),n.d(i,"reverseDepthForDepthOffset",(function(){return rt})),n.d(i,"reverseDepthForOrthographicProjectionMatrix",(function(){return et})),n.d(i,"reverseDepthForPerspectiveProjectionMatrix",(function(){return $e})),n.d(i,"samplerBindingCopy",(function(){return Yt})),n.d(i,"samplerBindingNew",(function(){return Kt})),n.d(i,"samplerDescriptorEquals",(function(){return jt})),n.d(i,"segmentInstanceGeometry",(function(){return Ti})),n.d(i,"setAttachmentStateSimple",(function(){return Nt})),n.d(i,"setBitFlagEnabled",(function(){return ht})),n.d(i,"setFormatComponentCount",(function(){return ke})),n.d(i,"setFormatFlags",(function(){return Ge})),n.d(i,"setMegaStateFlags",(function(){return yt})),n.d(i,"setSortKeyBias",(function(){return or})),n.d(i,"setSortKeyDepth",(function(){return dr})),n.d(i,"setSortKeyDepthKey",(function(){return fr})),n.d(i,"setSortKeyLayer",(function(){return rr})),n.d(i,"setSortKeyOpaqueDepth",(function(){return ur})),n.d(i,"setSortKeyProgramKey",(function(){return ir})),n.d(i,"setSortKeyTranslucentDepth",(function(){return lr})),n.d(i,"spliceBisectRight",(function(){return dt})),n.d(i,"updateBuffer",(function(){return Fi})),n.d(i,"vertexAttributeDescriptorCopy",(function(){return $t})),n.d(i,"vertexAttributeDescriptorEquals",(function(){return Wt}));var o={};n.r(o),n.d(o,"Plugin",(function(){return Fa}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@antv/g"),require("mana-syringe")):"function"==typeof define&&define.amd?define(["@antv/g","mana-syringe"],t):"object"==typeof exports?exports.WebGPU=t(require("@antv/g"),require("mana-syringe")):(e.G=e.G||{},e.G.WebGPU=t(e.G,e.G.ManaSyringe))}(window,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,i="~";function o(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,r||e,o),u=i?i+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function l(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),l.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},l.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,o=n.length,a=new Array(o);r<o;r++)a[r]=n[r].fn;return a},l.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},l.prototype.emit=function(e,t,n,r,o,a){var s=i?i+e:e;if(!this._events[s])return!1;var u,l,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,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,a),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var d,h=c.length;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,r);break;default:if(!u)for(d=1,u=new Array(f-1);d<f;d++)u[d-1]=arguments[d];c[l].fn.apply(c[l].context,u)}}return!0},l.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},l.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},l.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events[o])return this;if(!t)return u(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||r&&!a.once||n&&a.context!==n||u(this,o);else{for(var s=0,l=[],c=a.length;s<c;s++)(a[s].fn!==t||r&&!a[s].once||n&&a[s].context!==n)&&l.push(a[s]);l.length?this._events[o]=1===l.length?l[0]:l:u(this,o)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&u(this,t)):(this._events=new o,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,e.exports=l},function(e,t,n){"use strict";function r(e,t,n){n=n||2;var r,s,u,l,c,h,_,E=t&&t.length,v=E?t[0]*n:e.length,R=i(e,0,v,n,!0),m=[];if(!R||R.next===R.prev)return m;if(E&&(R=function(e,t,n,r){var a,s,u,l,c,h=[];for(a=0,s=t.length;a<s;a++)u=t[a]*r,l=a<s-1?t[a+1]*r:e.length,(c=i(e,u,l,r,!1))===c.next&&(c.steiner=!0),h.push(p(c));for(h.sort(f),a=0;a<h.length;a++)n=o(n=d(h[a],n),n.next);return n}(e,t,R,n)),e.length>80*n){r=u=e[0],s=l=e[1];for(var T=n;T<v;T+=n)(c=e[T])<r&&(r=c),(h=e[T+1])<s&&(s=h),c>u&&(u=c),h>l&&(l=h);_=0!==(_=Math.max(u-r,l-s))?1/_:0}return a(R,m,n,r,s,_),m}function i(e,t,n,r,i){var o,a;if(i===N(e,t,n,r)>0)for(o=t;o<n;o+=r)a=C(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=C(o,e[o],e[o+1],a);return a&&m(a,a.next)&&(O(a),a=a.next),a}function o(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!m(r,r.next)&&0!==R(r.prev,r,r.next))r=r.next;else{if(O(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function a(e,t,n,r,i,f,d){if(e){!d&&f&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=_(i.x,i.y,t,n,r)),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,n,r,i,o,a,s,u,l=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ);t++);for(u=l;s>0||u>0&&r;)0!==s&&(0===u||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,u--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,l*=2}while(a>1)}(i)}(e,r,i,f);for(var h,p,E=e;e.prev!==e.next;)if(h=e.prev,p=e.next,f?u(e,r,i,f):s(e))t.push(h.i/n),t.push(e.i/n),t.push(p.i/n),O(e),e=p.next,E=p.next;else if((e=p)===E){d?1===d?a(e=l(o(e),t,n),t,n,r,i,f,2):2===d&&c(e,t,n,r,i,f):a(o(e),t,n,r,i,f,1);break}}}function s(e){var t=e.prev,n=e,r=e.next;if(R(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(E(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&R(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function u(e,t,n,r){var i=e.prev,o=e,a=e.next;if(R(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,u=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,l=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,f=_(s,u,t,n,r),d=_(l,c,t,n,r),h=e.prevZ,p=e.nextZ;h&&h.z>=f&&p&&p.z<=d;){if(h!==e.prev&&h!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&R(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==e.prev&&p!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&R(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=f;){if(h!==e.prev&&h!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&R(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&E(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&R(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function l(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!m(i,a)&&T(i,r,r.next,a)&&A(i,a)&&A(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),O(r),O(r.next),r=e=a),r=r.next}while(r!==e);return o(r)}function c(e,t,n,r,i,s){var u=e;do{for(var l=u.next.next;l!==u.prev;){if(u.i!==l.i&&v(u,l)){var c=S(u,l);return u=o(u,u.next),c=o(c,c.next),a(u,t,n,r,i,s),void a(c,t,n,r,i,s)}l=l.next}u=u.next}while(u!==e)}function f(e,t){return e.x-t.x}function d(e,t){var n=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===a)return n;var u,l=n,c=n.x,f=n.y,d=1/0;r=n;do{i>=r.x&&r.x>=c&&i!==r.x&&E(o<f?i:a,o,c,f,o<f?a:i,o,r.x,r.y)&&(u=Math.abs(o-r.y)/(i-r.x),A(r,e)&&(u<d||u===d&&(r.x>n.x||r.x===n.x&&h(n,r)))&&(n=r,d=u)),r=r.next}while(r!==l);return n}(e,t);if(!n)return t;var r=S(n,e),i=o(n,n.next);return o(r,r.next),t===n?i:t}function h(e,t){return R(e.prev,e,t.prev)<0&&R(t.next,e,e.next)<0}function _(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function p(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function E(e,t,n,r,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(r-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&T(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(A(e,t)&&A(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(R(e.prev,e,t.prev)||R(e,t.prev,t))||m(e,t)&&R(e.prev,e,e.next)>0&&R(t.prev,t,t.next)>0)}function R(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function m(e,t){return e.x===t.x&&e.y===t.y}function T(e,t,n,r){var i=g(R(e,t,n)),o=g(R(e,t,r)),a=g(R(n,r,e)),s=g(R(n,r,t));return i!==o&&a!==s||(!(0!==i||!y(e,n,t))||(!(0!==o||!y(e,r,t))||(!(0!==a||!y(n,e,r))||!(0!==s||!y(n,t,r)))))}function y(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function g(e){return e>0?1:e<0?-1:0}function A(e,t){return R(e.prev,e,e.next)<0?R(e,t,e.next)>=0&&R(e,e.prev,t)>=0:R(e,t,e.prev)<0||R(e,e.next,t)<0}function S(e,t){var n=new I(e.i,e.x,e.y),r=new I(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function C(e,t,n,r){var i=new I(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function O(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 I(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function N(e,t,n,r){for(var i=0,o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}e.exports=r,e.exports.default=r,r.deviation=function(e,t,n,r){var i=t&&t.length,o=i?t[0]*n:e.length,a=Math.abs(N(e,0,o,n));if(i)for(var s=0,u=t.length;s<u;s++){var l=t[s]*n,c=s<u-1?t[s+1]*n:e.length;a-=Math.abs(N(e,l,c,n))}var f=0;for(s=0;s<r.length;s+=3){var d=r[s]*n,h=r[s+1]*n,_=r[s+2]*n;f+=Math.abs((e[d]-e[_])*(e[h+1]-e[d+1])-(e[d]-e[h])*(e[_+1]-e[d+1]))}return 0===a&&0===f?0:Math.abs((f-a)/a)},r.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var a=0;a<t;a++)n.vertices.push(e[i][o][a]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n}},function(e,t,n){var r=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,o=Object.create(i.prototype),a=new A(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return C()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=T(a,n);if(s){if(s===c)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=l(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,a),o}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function f(){}function d(){}function h(){}var _={};s(_,i,(function(){return this}));var p=Object.getPrototypeOf,E=p&&p(p(S([])));E&&E!==t&&n.call(E,i)&&(_=E);var v=h.prototype=f.prototype=Object.create(_);function R(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,s){var u=l(e[i],e,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function T(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=l(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function g(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return d.prototype=h,s(v,"constructor",h),s(h,"constructor",d),d.displayName=s(h,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,s(e,a,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},R(m.prototype),s(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new m(u(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(v),s(v,a,"Generator"),s(v,i,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=S,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(g),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,c):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),g(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;g(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(e,t,n){"use strict";n.r(t),n.d(t,"DomInteraction",(function(){return r})),n.d(t,"DeviceRenderer",(function(){return i})),n.d(t,"WebGPUDevice",(function(){return o})),n.d(t,"Renderer",(function(){return qa}));var r={};n.r(r),n.d(r,"Plugin",(function(){return y}));var i={};n.r(i),n.d(i,"AntialiasingMode",(function(){return Xr})),n.d(i,"Batch",(function(){return ai})),n.d(i,"BlendFactor",(function(){return ae})),n.d(i,"BlendMode",(function(){return se})),n.d(i,"BufferFrequencyHint",(function(){return he})),n.d(i,"BufferGeometry",(function(){return li})),n.d(i,"BufferUsage",(function(){return de})),n.d(i,"ChannelWriteMask",(function(){return Re})),n.d(i,"ClipSpaceNearZ",(function(){return ge})),n.d(i,"CompareMode",(function(){return re})),n.d(i,"CopyProgram",(function(){return Mo})),n.d(i,"CullMode",(function(){return oe})),n.d(i,"DeviceContribution",(function(){return Ro})),n.d(i,"DeviceProgram",(function(){return xn})),n.d(i,"DynamicUniformBuffer",(function(){return Bn})),n.d(i,"Endianness",(function(){return Dt})),n.d(i,"FillMesh",(function(){return Hi})),n.d(i,"Fog",(function(){return _o})),n.d(i,"FogType",(function(){return fo})),n.d(i,"Format",(function(){return Ie})),n.d(i,"FormatCompFlags",(function(){return Ce})),n.d(i,"FormatFlags",(function(){return Oe})),n.d(i,"FormatTypeFlags",(function(){return Se})),n.d(i,"FrontFaceMode",(function(){return ie})),n.d(i,"GL",(function(){return Ne})),n.d(i,"GeometryEvent",(function(){return ii})),n.d(i,"HashMap",(function(){return Gn})),n.d(i,"IdentityViewportCoords",(function(){return qn})),n.d(i,"ImageMesh",(function(){return ji})),n.d(i,"Instanced",(function(){return vi})),n.d(i,"InstancedLineMesh",(function(){return Ii})),n.d(i,"IsDepthReversed",(function(){return $e})),n.d(i,"JOINT_TYPE",(function(){return Bi})),n.d(i,"Light",(function(){return co})),n.d(i,"LineMesh",(function(){return Gi})),n.d(i,"Material",(function(){return ci})),n.d(i,"MaterialEvent",(function(){return ui})),n.d(i,"Mesh",(function(){return So})),n.d(i,"MeshMesh",(function(){return to})),n.d(i,"MipFilterMode",(function(){return ce})),n.d(i,"OpaqueBlack",(function(){return Ze})),n.d(i,"OpaqueWhite",(function(){return Je})),n.d(i,"Plugin",(function(){return wo})),n.d(i,"PrimitiveTopology",(function(){return fe})),n.d(i,"QueryPoolType",(function(){return Ae})),n.d(i,"RGAttachmentSlot",(function(){return Yn})),n.d(i,"RenderCache",(function(){return Kn})),n.d(i,"RenderGraphPlugin",(function(){return yo})),n.d(i,"RenderHelper",(function(){return kr})),n.d(i,"RenderInst",(function(){return br})),n.d(i,"RenderInstExecutionOrder",(function(){return Br})),n.d(i,"RenderInstFlags",(function(){return Cr})),n.d(i,"RenderInstList",(function(){return Ur})),n.d(i,"RenderInstManager",(function(){return wr})),n.d(i,"Renderable3D",(function(){return te})),n.d(i,"RendererLayer",(function(){return $n})),n.d(i,"ResourceType",(function(){return ne})),n.d(i,"SDFMesh",(function(){return yi})),n.d(i,"SamplerFormatKind",(function(){return Te})),n.d(i,"ShaderMaterial",(function(){return fi})),n.d(i,"SingleSampledTexture",(function(){return Jn})),n.d(i,"StencilOp",(function(){return me})),n.d(i,"TemporalTexture",(function(){return Zr})),n.d(i,"TexFilterMode",(function(){return le})),n.d(i,"TextMesh",(function(){return eo})),n.d(i,"TextUniform",(function(){return $i})),n.d(i,"TextureDimension",(function(){return Ee})),n.d(i,"TextureEvent",(function(){return pe})),n.d(i,"TextureMapping",(function(){return qr})),n.d(i,"TexturePool",(function(){return Qr})),n.d(i,"TextureUsage",(function(){return ve})),n.d(i,"TransparentBlack",(function(){return qe})),n.d(i,"TransparentWhite",(function(){return Qe})),n.d(i,"UNIFORM_SETTERS",(function(){return gn})),n.d(i,"Uniform",(function(){return Ui})),n.d(i,"VertexAttributeBufferIndex",(function(){return _i})),n.d(i,"VertexAttributeLocation",(function(){return pi})),n.d(i,"VertexBufferFrequency",(function(){return _e})),n.d(i,"ViewportOrigin",(function(){return ye})),n.d(i,"WrapMode",(function(){return ue})),n.d(i,"align",(function(){return ct})),n.d(i,"alignNonPowerOfTwo",(function(){return ft})),n.d(i,"arrayCopy",(function(){return Bt})),n.d(i,"arrayEqual",(function(){return xt})),n.d(i,"assert",(function(){return Xe})),n.d(i,"assertExists",(function(){return He})),n.d(i,"bindingLayoutDescriptorCopy",(function(){return Jt})),n.d(i,"bindingLayoutDescriptorEqual",(function(){return Ft})),n.d(i,"bindingLayoutSamplerDescriptorCopy",(function(){return Qt})),n.d(i,"bindingsDescriptorCopy",(function(){return Zt})),n.d(i,"bindingsDescriptorEquals",(function(){return Ut})),n.d(i,"bisectRight",(function(){return dt})),n.d(i,"bufferBindingCopy",(function(){return qt})),n.d(i,"colorCopy",(function(){return Ye})),n.d(i,"colorEqual",(function(){return je})),n.d(i,"colorNewCopy",(function(){return Ke})),n.d(i,"colorNewFromRGBA",(function(){return ze})),n.d(i,"compareDefines",(function(){return hi})),n.d(i,"compareDepthValues",(function(){return ot})),n.d(i,"containerModule",(function(){return Go})),n.d(i,"copyAttachmentState",(function(){return Tt})),n.d(i,"copyAttachmentStateFromSimple",(function(){return St})),n.d(i,"copyMegaState",(function(){return At})),n.d(i,"defaultBindingLayoutSamplerDescriptor",(function(){return Mt})),n.d(i,"defaultMegaState",(function(){return Ot})),n.d(i,"enumToObject",(function(){return di})),n.d(i,"fallbackUndefined",(function(){return st})),n.d(i,"fillArray",(function(){return lt})),n.d(i,"fillColor",(function(){return Mr})),n.d(i,"fillMatrix4x4",(function(){return xr})),n.d(i,"fillVec3v",(function(){return Nr})),n.d(i,"fillVec4",(function(){return Pr})),n.d(i,"fillVec4v",(function(){return Dr})),n.d(i,"fullscreenMegaState",(function(){return Nt})),n.d(i,"getAttributeLocations",(function(){return In})),n.d(i,"getDefines",(function(){return On})),n.d(i,"getFormatByteSize",(function(){return we})),n.d(i,"getFormatCompByteSize",(function(){return Ue})),n.d(i,"getFormatCompFlags",(function(){return Be})),n.d(i,"getFormatCompFlagsComponentCount",(function(){return Me})),n.d(i,"getFormatComponentCount",(function(){return Ge})),n.d(i,"getFormatFlags",(function(){return Le})),n.d(i,"getFormatSamplerKind",(function(){return Ve})),n.d(i,"getFormatTypeFlags",(function(){return be})),n.d(i,"getFormatTypeFlagsByteSize",(function(){return Fe})),n.d(i,"getSortKeyDepth",(function(){return _r})),n.d(i,"getSortKeyLayer",(function(){return rr})),n.d(i,"getSystemEndianness",(function(){return sn})),n.d(i,"getUniformSetter",(function(){return An})),n.d(i,"getUniforms",(function(){return Nn})),n.d(i,"hashCodeNumberFinish",(function(){return Ln})),n.d(i,"hashCodeNumberUpdate",(function(){return bn})),n.d(i,"inputLayoutBufferDescriptorCopy",(function(){return tn})),n.d(i,"inputLayoutBufferDescriptorEquals",(function(){return Ht})),n.d(i,"inputLayoutDescriptorCopy",(function(){return nn})),n.d(i,"inputLayoutDescriptorEquals",(function(){return jt})),n.d(i,"isPowerOfTwo",(function(){return at})),n.d(i,"leftPad",(function(){return vt})),n.d(i,"makeAttachmentClearDescriptor",(function(){return Vr})),n.d(i,"makeBackbufferDescSimple",(function(){return zr})),n.d(i,"makeDepthKey",(function(){return nr})),n.d(i,"makeFormat",(function(){return xe})),n.d(i,"makeMegaState",(function(){return It})),n.d(i,"makeSortKey",(function(){return fr})),n.d(i,"makeSortKeyOpaque",(function(){return sr})),n.d(i,"makeSortKeyTranslucent",(function(){return lr})),n.d(i,"makeStaticDataBuffer",(function(){return si})),n.d(i,"makeTextureDescriptor2D",(function(){return De})),n.d(i,"nArray",(function(){return pt})),n.d(i,"nullHashFunc",(function(){return Fn})),n.d(i,"nullify",(function(){return ut})),n.d(i,"opaqueBlackFullClearRenderPassDescriptor",(function(){return jr})),n.d(i,"opaqueWhiteFullClearRenderPassDescriptor",(function(){return Yr})),n.d(i,"parseUniformName",(function(){return ln})),n.d(i,"prependLineNo",(function(){return Et})),n.d(i,"preprocessProgramObj_GLSL",(function(){return Mn})),n.d(i,"preprocessProgram_GLSL",(function(){return Dn})),n.d(i,"preprocessShader_GLSL",(function(){return Pn})),n.d(i,"projectionMatrixConvertClipSpaceNearZ",(function(){return Ir})),n.d(i,"pushFXAAPass",(function(){return Lo})),n.d(i,"range",(function(){return Rt})),n.d(i,"renderInstCompareNone",(function(){return Lr})),n.d(i,"renderInstCompareSortKey",(function(){return Fr})),n.d(i,"renderPipelineDescriptorCopy",(function(){return $t})),n.d(i,"renderPipelineDescriptorEquals",(function(){return Vt})),n.d(i,"reverseDepthForClearValue",(function(){return rt})),n.d(i,"reverseDepthForCompareMode",(function(){return nt})),n.d(i,"reverseDepthForDepthOffset",(function(){return it})),n.d(i,"reverseDepthForOrthographicProjectionMatrix",(function(){return tt})),n.d(i,"reverseDepthForPerspectiveProjectionMatrix",(function(){return et})),n.d(i,"samplerBindingCopy",(function(){return Kt})),n.d(i,"samplerBindingNew",(function(){return zt})),n.d(i,"samplerDescriptorEquals",(function(){return Yt})),n.d(i,"segmentInstanceGeometry",(function(){return Ci})),n.d(i,"setAttachmentStateSimple",(function(){return Pt})),n.d(i,"setBackbufferDescSimple",(function(){return Kr})),n.d(i,"setBitFlagEnabled",(function(){return _t})),n.d(i,"setFormatComponentCount",(function(){return We})),n.d(i,"setFormatFlags",(function(){return ke})),n.d(i,"setMegaStateFlags",(function(){return gt})),n.d(i,"setSortKeyBias",(function(){return ar})),n.d(i,"setSortKeyDepth",(function(){return hr})),n.d(i,"setSortKeyDepthKey",(function(){return dr})),n.d(i,"setSortKeyLayer",(function(){return ir})),n.d(i,"setSortKeyOpaqueDepth",(function(){return ur})),n.d(i,"setSortKeyProgramKey",(function(){return or})),n.d(i,"setSortKeyTranslucentDepth",(function(){return cr})),n.d(i,"spliceBisectRight",(function(){return ht})),n.d(i,"standardFullClearRenderPassDescriptor",(function(){return Hr})),n.d(i,"updateBuffer",(function(){return ki})),n.d(i,"vertexAttributeDescriptorCopy",(function(){return en})),n.d(i,"vertexAttributeDescriptorEquals",(function(){return Xt}));var o={};n.r(o),n.d(o,"Plugin",(function(){return Va}));
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -13,4 +13,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function l(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var u=e.length-1;u>=0;u--)(i=e[u])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function u(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}s((r=r.apply(e,t||[])).next())}))}function d(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}Object.create;function h(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function p(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}Object.create;var E=n(0),v=n(1),R=/mobile|tablet|ip(ad|hone|od)|android/i,T=function(){function e(){}var t;return t=e,e.prototype.apply=function(e){var n=this,r=this.renderingContext.root.ownerDocument.defaultView,i=r.supportTouchEvent&&R.test(navigator.userAgent),o=function(t){e.hooks.pointerMove.call(t)},a=function(t){e.hooks.pointerUp.call(t)},u=function(t){e.hooks.pointerDown.call(t)},s=function(t){e.hooks.pointerOver.call(t)},l=function(t){e.hooks.pointerOut.call(t)},c=function(t){e.hooks.pointerCancel.call(t)},h=function(t){e.hooks.pointerWheel.call(t)},_=function(e){e.addEventListener("touchstart",u,!0),e.addEventListener("touchend",a,!0),e.addEventListener("touchmove",o,!0),e.addEventListener("touchcancel",c,!0)},p=function(e){globalThis.document.addEventListener("mousemove",o,!0),e.addEventListener("mousedown",u,!0),e.addEventListener("mouseout",l,!0),e.addEventListener("mouseover",s,!0),globalThis.addEventListener("mouseup",a,!0)},E=function(e){e.removeEventListener("touchstart",u,!0),e.removeEventListener("touchend",a,!0),e.removeEventListener("touchmove",o,!0)},v=function(e){globalThis.document.removeEventListener("mousemove",o,!0),e.removeEventListener("mousedown",u,!0),e.removeEventListener("mouseout",l,!0),e.removeEventListener("mouseover",s,!0),globalThis.removeEventListener("mouseup",a,!0)};e.hooks.init.tapPromise(t.tag,(function(){return f(n,void 0,void 0,(function(){var e;return d(this,(function(t){return e=this.contextService.getDomElement(),r.supportPointerEvent&&function(e){globalThis.document.addEventListener("pointermove",o,!0),e.addEventListener("pointerdown",u,!0),e.addEventListener("pointerleave",l,!0),e.addEventListener("pointerover",s,!0),globalThis.addEventListener("pointerup",a,!0)}(e),i?_(e):r.supportTouchEvent?(_(e),r.supportPointerEvent||p(e)):r.supportPointerEvent||p(e),e.addEventListener("wheel",h,{passive:!0,capture:!0}),[2]}))}))})),e.hooks.destroy.tap(t.tag,(function(){var e=n.contextService.getDomElement();r.supportPointerEvent&&function(e){globalThis.document.removeEventListener("pointermove",o,!0),e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointerleave",l,!0),e.removeEventListener("pointerover",s,!0),globalThis.removeEventListener("pointerup",a,!0)}(e),i?E(e):r.supportTouchEvent?(E(e),r.supportPointerEvent||v(e)):r.supportPointerEvent||v(e),e.removeEventListener("wheel",h,!0)}))},e.tag="DOMInteraction",l([Object(v.inject)(E.ContextService),c("design:type",Object)],e.prototype,"contextService",void 0),l([Object(v.inject)(E.RenderingContext),c("design:type",Object)],e.prototype,"renderingContext",void 0),e=t=l([Object(v.singleton)({contrib:E.RenderingPluginContribution})],e)}(),m=Object(v.Module)((function(e){e(T)})),y=function(){function e(){this.name="dom-interaction"}return e.prototype.init=function(e){e.load(m,!0)},e.prototype.destroy=function(e){e.unload(m)},e}(),g=(n(4),n(2)),A=n(3),S=n.n(A);const C=1e20;class O{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=n;const u=this.size=e+4*t,s=this._createCanvas(u),l=this.ctx=s.getContext("2d",{willReadFrequently:!0});l.font=`${a} ${o} ${e}px ${i}`,l.textBaseline="alphabetic",l.textAlign="left",l.fillStyle="black",this.gridOuter=new Float64Array(u*u),this.gridInner=new Float64Array(u*u),this.f=new Float64Array(u),this.z=new Float64Array(u+1),this.v=new Uint16Array(u)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),u=Math.min(this.size-this.buffer,Math.ceil(o-i)),s=Math.min(this.size-this.buffer,a+Math.ceil(r)),l=u+2*this.buffer,c=s+2*this.buffer,f=Math.max(l*c,0),d=new Uint8ClampedArray(f),h={data:d,width:l,height:c,glyphWidth:u,glyphHeight:s,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===u||0===s)return h;const{ctx:_,buffer:p,gridInner:E,gridOuter:v}=this;_.clearRect(p,p,u,s),_.fillText(e,p,p+a);const R=_.getImageData(p,p,u,s);v.fill(C,0,f),E.fill(0,0,f);for(let e=0;e<s;e++)for(let t=0;t<u;t++){const n=R.data[4*(e*u+t)+3]/255;if(0===n)continue;const r=(e+p)*l+t+p;if(1===n)v[r]=0,E[r]=C;else{const e=.5-n;v[r]=e>0?e*e:0,E[r]=e<0?e*e:0}}I(v,0,0,l,c,l,this.f,this.v,this.z),I(E,p,p,u,s,l,this.f,this.v,this.z);for(let e=0;e<f;e++){const t=Math.sqrt(v[e])-Math.sqrt(E[e]);d[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return h}}function I(e,t,n,r,i,o,a,u,s){for(let l=t;l<t+r;l++)N(e,n*o+l,o,i,a,u,s);for(let l=n;l<n+i;l++)N(e,l*o+t,1,r,a,u,s)}function N(e,t,n,r,i,o,a){o[0]=0,a[0]=-C,a[1]=C,i[0]=e[t];for(let u=1,s=0,l=0;u<r;u++){i[u]=e[t+u*n];const r=u*u;do{const e=o[s];l=(i[u]-i[e]+r-e*e)/(u-e)/2}while(l<=a[s]&&--s>-1);s++,o[s]=u,a[s]=l,a[s+1]=C}for(let u=0,s=0;u<r;u++){for(;a[s+1]<u;)s++;const r=o[s],l=u-r;e[t+u*n]=i[r]+l*l}}function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){L(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function x(e,t,n,r,i,o,a){try{var u=e[o](a),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,i)}function B(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){x(o,r,i,a,u,"next",e)}function u(e){x(o,r,i,a,u,"throw",e)}a(void 0)}))}}function M(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function b(e,t,n){return t&&F(e.prototype,t),n&&F(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function L(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&G(e,t)}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function G(e,t){return(G=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function V(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function W(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return V(e)}function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=w(e);if(t){var i=w(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return W(this,n)}}function H(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=w(e)););return e}function j(){return(j="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=H(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}}).apply(this,arguments)}function Y(e,t){return q(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){u=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw i}}return o}(e,t)||Q(e,t)||$()}function K(e){return q(e)||Z(e)||Q(e)||$()}function z(e){return function(e){if(Array.isArray(e))return J(e)}(e)||Z(e)||Q(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e){if(Array.isArray(e))return e}function Z(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function Q(e,t){if(e){if("string"==typeof e)return J(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?J(e,t):void 0}}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function $(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ee(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Q(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}var te=b((function e(){M(this,e),this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]}));te.tag="c-renderable-3d";var ne,re,ie,oe,ae,ue,se,le,ce,fe,de,he,_e,pe,Ee,ve,Re,Te,me,ye,ge,Ae,Se,Ce,Oe,Ie,Ne=function(){function e(){M(this,e),this.counter=0,this.id2DisplayObjectMap={}}return b(e,[{key:"getId",value:function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t}},{key:"getById",value:function(e){return this.id2DisplayObjectMap[e]}},{key:"reset",value:function(){this.counter=0,this.id2DisplayObjectMap={}}},{key:"decodePickingColor",value:function(e){var t=Y(e,3);return t[0]+256*t[1]+65536*t[2]-1}},{key:"encodePickingColor",value:function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]}}]),e}();function Pe(e,t,n,r){return{dimension:pe.n2D,pixelFormat:e,width:t,height:n,depth:1,numLevels:r,usage:Ee.Sampled}}function De(e){return e}function xe(e,t,n){return e<<16|t<<8|n}function Be(e){return e>>>8&255}function Me(e){return e>>>16&255}function Fe(e){return 255&e}function be(e){switch(e){case Ae.F32:case Ae.U32:case Ae.S32:return 4;case Ae.U16:case Ae.S16:case Ae.F16:return 2;case Ae.U8:case Ae.S8:return 1;default:throw new Error("whoops")}}function Le(e){return be(Me(e))}function Ue(e){return Be(e)}function we(e){return be(Me(e))*Be(e)}function Ge(e,t){return 4294967040&e|t}function ke(e,t){return 4294902015&e|t<<8}function Ve(e){var t=Fe(e);if(t&Ce.Depth)return Te.Depth;if(t&Ce.Normalized)return Te.Float;var n=Me(e);if(n===Ae.F16||n===Ae.F32)return Te.Float;if(n===Ae.U8||n===Ae.U16||n===Ae.U32)return Te.Uint;if(n===Ae.S8||n===Ae.S16||n===Ae.S32)return Te.Sint;throw new Error("whoops")}function We(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e)throw console.error((new Error).stack),new Error("Assert fail: ".concat(t))}function Xe(e){if(null!=e)return e;throw new Error("Missing object")}function He(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function je(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function Ye(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function Ke(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{r:e,g:t,b:n,a:r}}Ne=l([Object(v.singleton)()],Ne),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.InputState=7]="InputState",e[e.RenderPipeline=8]="RenderPipeline",e[e.ComputePipeline=9]="ComputePipeline",e[e.Readback=10]="Readback",e[e.QueryPool=11]="QueryPool"}(ne||(ne={})),function(e){e[e.Never=512]="Never",e[e.Less=513]="Less",e[e.Equal=514]="Equal",e[e.LessEqual=515]="LessEqual",e[e.Greater=516]="Greater",e[e.NotEqual=517]="NotEqual",e[e.GreaterEqual=518]="GreaterEqual",e[e.Always=519]="Always"}(re||(re={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(ie||(ie={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(oe||(oe={})),function(e){e[e.Zero=0]="Zero",e[e.One=1]="One",e[e.Src=768]="Src",e[e.OneMinusSrc=769]="OneMinusSrc",e[e.Dst=774]="Dst",e[e.OneMinusDst=775]="OneMinusDst",e[e.SrcAlpha=770]="SrcAlpha",e[e.OneMinusSrcAlpha=771]="OneMinusSrcAlpha",e[e.DstAlpha=772]="DstAlpha",e[e.OneMinusDstAlpha=773]="OneMinusDstAlpha"}(ae||(ae={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(ue||(ue={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(se||(se={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(le||(le={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(ce||(ce={})),function(e){e[e.Points=0]="Points",e[e.Triangles=1]="Triangles",e[e.TriangleStrip=2]="TriangleStrip",e[e.Lines=3]="Lines",e[e.LineStrip=4]="LineStrip"}(fe||(fe={})),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"}(de||(de={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(he||(he={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(_e||(_e={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(pe||(pe={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(Ee||(Ee={})),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.AllChannels=15]="AllChannels"}(ve||(ve={})),function(e){e[e.Keep=7680]="Keep",e[e.Zero=0]="Zero",e[e.Replace=7681]="Replace",e[e.Invert=5386]="Invert",e[e.IncrementClamp=7682]="IncrementClamp",e[e.DecrementClamp=7683]="DecrementClamp",e[e.IncrementWrap=34055]="IncrementWrap",e[e.DecrementWrap=34056]="DecrementWrap"}(Re||(Re={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(Te||(Te={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(me||(me={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(ye||(ye={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(ge||(ge={})),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.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(Ae||(Ae={})),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"}(Se||(Se={})),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"}(Ce||(Ce={})),function(e){e[e.ALPHA=xe(Ae.U8,Se.A,Ce.None)]="ALPHA",e[e.F16_R=xe(Ae.F16,Se.R,Ce.None)]="F16_R",e[e.F16_RG=xe(Ae.F16,Se.RG,Ce.None)]="F16_RG",e[e.F16_RGB=xe(Ae.F16,Se.RGB,Ce.None)]="F16_RGB",e[e.F16_RGBA=xe(Ae.F16,Se.RGBA,Ce.None)]="F16_RGBA",e[e.F32_R=xe(Ae.F32,Se.R,Ce.None)]="F32_R",e[e.F32_RG=xe(Ae.F32,Se.RG,Ce.None)]="F32_RG",e[e.F32_RGB=xe(Ae.F32,Se.RGB,Ce.None)]="F32_RGB",e[e.F32_RGBA=xe(Ae.F32,Se.RGBA,Ce.None)]="F32_RGBA",e[e.U8_R=xe(Ae.U8,Se.R,Ce.None)]="U8_R",e[e.U8_R_NORM=xe(Ae.U8,Se.R,Ce.Normalized)]="U8_R_NORM",e[e.U8_RG=xe(Ae.U8,Se.RG,Ce.None)]="U8_RG",e[e.U8_RG_NORM=xe(Ae.U8,Se.RG,Ce.Normalized)]="U8_RG_NORM",e[e.U8_RGB=xe(Ae.U8,Se.RGB,Ce.None)]="U8_RGB",e[e.U8_RGB_NORM=xe(Ae.U8,Se.RGB,Ce.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=xe(Ae.U8,Se.RGB,Ce.sRGB|Ce.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=xe(Ae.U8,Se.RGBA,Ce.None)]="U8_RGBA",e[e.U8_RGBA_NORM=xe(Ae.U8,Se.RGBA,Ce.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=xe(Ae.U8,Se.RGBA,Ce.sRGB|Ce.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=xe(Ae.U16,Se.R,Ce.None)]="U16_R",e[e.U16_R_NORM=xe(Ae.U16,Se.R,Ce.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=xe(Ae.U16,Se.RG,Ce.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=xe(Ae.U16,Se.RGBA,Ce.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=xe(Ae.U16,Se.RGB,Ce.None)]="U16_RGB",e[e.U32_R=xe(Ae.U32,Se.R,Ce.None)]="U32_R",e[e.U32_RG=xe(Ae.U32,Se.RG,Ce.None)]="U32_RG",e[e.S8_R=xe(Ae.S8,Se.R,Ce.None)]="S8_R",e[e.S8_R_NORM=xe(Ae.S8,Se.R,Ce.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=xe(Ae.S8,Se.RG,Ce.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=xe(Ae.S8,Se.RGB,Ce.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=xe(Ae.S8,Se.RGBA,Ce.Normalized)]="S8_RGBA_NORM",e[e.S16_R=xe(Ae.S16,Se.R,Ce.None)]="S16_R",e[e.S16_RG=xe(Ae.S16,Se.RG,Ce.None)]="S16_RG",e[e.S16_RG_NORM=xe(Ae.S16,Se.RG,Ce.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=xe(Ae.S16,Se.RGB,Ce.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=xe(Ae.S16,Se.RGBA,Ce.None)]="S16_RGBA",e[e.S16_RGBA_NORM=xe(Ae.S16,Se.RGBA,Ce.Normalized)]="S16_RGBA_NORM",e[e.S32_R=xe(Ae.S32,Se.R,Ce.None)]="S32_R",e[e.U16_RGBA_5551=xe(Ae.U16_PACKED_5551,Se.RGBA,Ce.Normalized)]="U16_RGBA_5551",e[e.BC1=xe(Ae.BC1,Se.RGBA,Ce.Normalized)]="BC1",e[e.BC1_SRGB=xe(Ae.BC1,Se.RGBA,Ce.Normalized|Ce.sRGB)]="BC1_SRGB",e[e.BC2=xe(Ae.BC2,Se.RGBA,Ce.Normalized)]="BC2",e[e.BC2_SRGB=xe(Ae.BC2,Se.RGBA,Ce.Normalized|Ce.sRGB)]="BC2_SRGB",e[e.BC3=xe(Ae.BC3,Se.RGBA,Ce.Normalized)]="BC3",e[e.BC3_SRGB=xe(Ae.BC3,Se.RGBA,Ce.Normalized|Ce.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=xe(Ae.BC4_UNORM,Se.R,Ce.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=xe(Ae.BC4_SNORM,Se.R,Ce.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=xe(Ae.BC5_UNORM,Se.RG,Ce.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=xe(Ae.BC5_SNORM,Se.RG,Ce.Normalized)]="BC5_SNORM",e[e.D24=xe(Ae.D24,Se.R,Ce.Depth)]="D24",e[e.D24_S8=xe(Ae.D24S8,Se.RG,Ce.Depth|Ce.Stencil)]="D24_S8",e[e.D32F=xe(Ae.D32F,Se.R,Ce.Depth)]="D32F",e[e.D32F_S8=xe(Ae.D32FS8,Se.RG,Ce.Depth|Ce.Stencil)]="D32F_S8",e[e.U8_RGB_RT=xe(Ae.U8,Se.RGB,Ce.RenderTarget|Ce.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=xe(Ae.U8,Se.RGBA,Ce.RenderTarget|Ce.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=xe(Ae.U8,Se.RGBA,Ce.RenderTarget|Ce.Normalized|Ce.sRGB)]="U8_RGBA_RT_SRGB"}(Oe||(Oe={})),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"}(Ie||(Ie={}));var ze=Ke(0,0,0,0),qe=Ke(0,0,0,1),Ze=Ke(1,1,1,0),Qe=Ke(1,1,1,1),Je=!0;function $e(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Je;t&&(e[10]=-e[10],e[14]=-e[14])}function et(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Je;t&&(e[10]=-e[10],e[14]=1-e[14])}function tt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Je;if(!t)return e;switch(e){case re.Less:return re.Greater;case re.LessEqual:return re.GreaterEqual;case re.GreaterEqual:return re.LessEqual;case re.Greater:return re.Less;default:return e}}function nt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Je;return t?1-e:e}function rt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Je;return t?-e:e}function it(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Je;if((n=tt(n,r))===re.Less)return e<t;if(n===re.LessEqual)return e<=t;if(n===re.Greater)return e>t;if(n===re.GreaterEqual)return e>=t;throw new Error("whoops")}function ot(e){return e&&0==(e&e-1)}function at(e,t){return null!=e?e:t}function ut(e){return void 0===e?null:e}function st(e,t,n){e.length=t,e.fill(n)}function lt(e,t){var n=t-1;return e+n&~n}function ct(e,t){return((e+t-1)/t|0)*t}function ft(e,t,n){for(var r=0,i=e.length;r<i;){var o=r+(i-r>>>1);n(t,e[o])<0?i=o:r=o+1}return r}function dt(e,t,n){var r=ft(e,t,n);e.splice(r,0,t)}function ht(e,t,n){return n?e|=t:e&=~t,e}function _t(e,t){for(var n=new Array(e),r=0;r<e;r++)n[r]=t();return n}function pt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e.split("\n");return n.map((function(e,n){return"".concat(Et(""+(t+n),4," ")," ").concat(e)})).join("\n")}function Et(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0";e.length<t;)e="".concat(n).concat(e);return e}function vt(e,t){for(var n=[],r=e;r<e+t;r++)n.push(r);return n}function Rt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Tt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Rt(e.rgbBlendState,t.rgbBlendState),Rt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function mt(e,t){e.length!==t.length&&(e.length=t.length);for(var n=0;n<t.length;n++)e[n]=Tt(e[n],t[n])}function yt(e,t){void 0!==t.attachmentsState&&mt(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&je(e.blendConstant,t.blendConstant),e.depthCompare=at(t.depthCompare,e.depthCompare),e.depthWrite=at(t.depthWrite,e.depthWrite),e.stencilCompare=at(t.stencilCompare,e.stencilCompare),e.stencilWrite=at(t.stencilWrite,e.stencilWrite),e.stencilPassOp=at(t.stencilPassOp,e.stencilPassOp),e.stencilRef=at(t.stencilRef,e.stencilRef),e.cullMode=at(t.cullMode,e.cullMode),e.frontFace=at(t.frontFace,e.frontFace),e.polygonOffset=at(t.polygonOffset,e.polygonOffset)}function gt(e){var t=Object.assign({},e);return t.attachmentsState=[],mt(t.attachmentsState,e.attachmentsState),t.blendConstant=Ye(t.blendConstant),t}function At(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)}var St={blendMode:ue.Add,blendSrcFactor:ae.One,blendDstFactor:ae.Zero},Ct={attachmentsState:[{channelWriteMask:ve.RGB,rgbBlendState:St,alphaBlendState:St}],blendConstant:Ye(ze),depthWrite:!0,depthCompare:re.LessEqual,stencilCompare:re.Always,stencilWrite:!1,stencilPassOp:Re.Keep,stencilRef:0,cullMode:oe.None,frontFace:ie.CCW,polygonOffset:!1};function Ot(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ct,n=gt(t);return null!==e&&yt(n,e),n}var It=Ot({depthCompare:re.Always,depthWrite:!1},Ct);function Nt(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],mt(e.attachmentsState,Ct.attachmentsState)),At(e.attachmentsState[0],t),e}var Pt,Dt={formatKind:Te.Float,dimension:pe.n2D};function xt(e,t,n){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Bt(e,t){for(var n=Array(e.length),r=0;r<e.length;r++)n[r]=t(e[r]);return n}function Mt(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function Ft(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function bt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Lt(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!xt(e.samplerBindings,t.samplerBindings,Ft)&&(!!xt(e.uniformBufferBindings,t.uniformBufferBindings,Mt)&&!!Gt(e.bindingLayout,t.bindingLayout)))}function Ut(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function wt(e,t){return!!Ut(e.rgbBlendState,t.rgbBlendState)&&(!!Ut(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Gt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function kt(e,t){return e===t}function Vt(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!xt(e.attachmentsState,t.attachmentsState,wt)&&(!!He(e.blendConstant,t.blendConstant)&&(e.depthCompare===t.depthCompare&&e.depthWrite===t.depthWrite&&e.stencilCompare===t.stencilCompare&&e.stencilWrite===t.stencilWrite&&e.stencilPassOp===t.stencilPassOp&&e.stencilRef===t.stencilRef&&e.cullMode===t.cullMode&&e.frontFace===t.frontFace&&e.polygonOffset===t.polygonOffset))}(e.megaStateDescriptor,t.megaStateDescriptor)&&(!!function(e,t){return e.id===t.id}(e.program,t.program)&&(!!xt(e.bindingLayouts,t.bindingLayouts,Gt)&&(!!xt(e.colorAttachmentFormats,t.colorAttachmentFormats,kt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function Wt(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Xt(e,t){return Object(E.isNil)(e)?Object(E.isNil)(t):!Object(E.isNil)(t)&&(e.byteStride===t.byteStride&&e.frequency===t.frequency)}function Ht(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!xt(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Xt)&&!!xt(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,Wt))}function jt(e,t){return e.wrapS===t.wrapS&&e.wrapT===t.wrapT&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipFilter===t.mipFilter&&e.minLOD===t.minLOD&&e.maxLOD===t.maxLOD&&e.maxAnisotropy===t.maxAnisotropy&&e.compareMode===t.compareMode}function Yt(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function Kt(){return{sampler:null,texture:null,lateBinding:null}}function zt(e){return{buffer:e.buffer,wordCount:e.wordCount}}function qt(e){return{bindingLayout:e.bindingLayout,samplerBindings:Bt(e.samplerBindings,Yt),uniformBufferBindings:Bt(e.uniformBufferBindings,zt),pipeline:e.pipeline}}function Zt(e){return{dimension:e.dimension,formatKind:e.formatKind}}function Qt(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?Bt(e.samplerEntries,Zt):void 0}}function Jt(e){var t=Bt(e.bindingLayouts,Qt),n=e.inputLayout,r=e.program,i=e.topology;return{bindingLayouts:t,inputLayout:n,megaStateDescriptor:gt(e.megaStateDescriptor),program:r,topology:i,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function $t(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function en(e){return Object(E.isNil)(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function tn(e){return{vertexAttributeDescriptors:Bt(e.vertexAttributeDescriptors,$t),vertexBufferDescriptors:Bt(e.vertexBufferDescriptors,en),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(Pt||(Pt={}));var nn,rn=new Uint16Array([65279]),on=255==new DataView(rn.buffer).getUint8(0)?Pt.LITTLE_ENDIAN:Pt.BIG_ENDIAN;function an(){return on}var un=/([^[]*)(\[[0-9]+\])?/;function sn(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(un);if(!t||t.length<2)throw new Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:Boolean(t[2])}}function ln(){var e=null;return function(t,n,r){var i=e!==r;return i&&(t.uniform1i(n,r),e=r),i}}function cn(e,t,n,r){var i=null,o=null;return function(a,u,s){var l=t(s,n),c=l.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{We(o===c,"Uniform length cannot change.");for(var d=0;d<c;++d)if(l[d]!==i[d]){f=!0;break}}return f&&(r(a,e,u,l),i.set(l)),f}}function fn(e,t,n,r){e[t](n,r)}function dn(e,t,n,r){e[t](n,!1,r)}var hn={},_n={},pn={},En=[0];function vn(e,t,n,r){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(En[0]=e,e=En);var i=e.length;if(e instanceof n)return e;var o=r[i];o||(o=new n(i),r[i]=o);for(var a=0;a<i;a++)o[a]=e[a];return o}function Rn(e,t){return vn(e,t,Float32Array,hn)}function Tn(e,t){return vn(e,t,Int32Array,_n)}function mn(e,t){return vn(e,t,Uint32Array,pn)}var yn=(L(nn={},Ie.FLOAT,cn.bind(null,"uniform1fv",Rn,1,fn)),L(nn,Ie.FLOAT_VEC2,cn.bind(null,"uniform2fv",Rn,2,fn)),L(nn,Ie.FLOAT_VEC3,cn.bind(null,"uniform3fv",Rn,3,fn)),L(nn,Ie.FLOAT_VEC4,cn.bind(null,"uniform4fv",Rn,4,fn)),L(nn,Ie.INT,cn.bind(null,"uniform1iv",Tn,1,fn)),L(nn,Ie.INT_VEC2,cn.bind(null,"uniform2iv",Tn,2,fn)),L(nn,Ie.INT_VEC3,cn.bind(null,"uniform3iv",Tn,3,fn)),L(nn,Ie.INT_VEC4,cn.bind(null,"uniform4iv",Tn,4,fn)),L(nn,Ie.BOOL,cn.bind(null,"uniform1iv",Tn,1,fn)),L(nn,Ie.BOOL_VEC2,cn.bind(null,"uniform2iv",Tn,2,fn)),L(nn,Ie.BOOL_VEC3,cn.bind(null,"uniform3iv",Tn,3,fn)),L(nn,Ie.BOOL_VEC4,cn.bind(null,"uniform4iv",Tn,4,fn)),L(nn,Ie.FLOAT_MAT2,cn.bind(null,"uniformMatrix2fv",Rn,4,dn)),L(nn,Ie.FLOAT_MAT3,cn.bind(null,"uniformMatrix3fv",Rn,9,dn)),L(nn,Ie.FLOAT_MAT4,cn.bind(null,"uniformMatrix4fv",Rn,16,dn)),L(nn,Ie.SAMPLER_2D,ln),L(nn,Ie.SAMPLER_CUBE,ln),L(nn,Ie.UNSIGNED_INT,cn.bind(null,"uniform1uiv",mn,1,fn)),L(nn,Ie.UNSIGNED_INT_VEC2,cn.bind(null,"uniform2uiv",mn,2,fn)),L(nn,Ie.UNSIGNED_INT_VEC3,cn.bind(null,"uniform3uiv",mn,3,fn)),L(nn,Ie.UNSIGNED_INT_VEC4,cn.bind(null,"uniform4uiv",mn,4,fn)),L(nn,Ie.FLOAT_MAT2x3,cn.bind(null,"uniformMatrix2x3fv",Rn,6,dn)),L(nn,Ie.FLOAT_MAT2x4,cn.bind(null,"uniformMatrix2x4fv",Rn,8,dn)),L(nn,Ie.FLOAT_MAT3x2,cn.bind(null,"uniformMatrix3x2fv",Rn,6,dn)),L(nn,Ie.FLOAT_MAT3x4,cn.bind(null,"uniformMatrix3x4fv",Rn,12,dn)),L(nn,Ie.FLOAT_MAT4x2,cn.bind(null,"uniformMatrix4x2fv",Rn,8,dn)),L(nn,Ie.FLOAT_MAT4x3,cn.bind(null,"uniformMatrix4x3fv",Rn,12,dn)),L(nn,Ie.SAMPLER_2D,ln),L(nn,Ie.SAMPLER_CUBE,ln),L(nn,Ie.SAMPLER_3D,ln),L(nn,Ie.SAMPLER_2D_SHADOW,ln),L(nn,Ie.SAMPLER_2D_ARRAY,ln),L(nn,Ie.SAMPLER_2D_ARRAY_SHADOW,ln),L(nn,Ie.SAMPLER_CUBE_SHADOW,ln),L(nn,Ie.INT_SAMPLER_2D,ln),L(nn,Ie.INT_SAMPLER_3D,ln),L(nn,Ie.INT_SAMPLER_CUBE,ln),L(nn,Ie.INT_SAMPLER_2D_ARRAY,ln),L(nn,Ie.UNSIGNED_INT_SAMPLER_2D,ln),L(nn,Ie.UNSIGNED_INT_SAMPLER_3D,ln),L(nn,Ie.UNSIGNED_INT_SAMPLER_CUBE,ln),L(nn,Ie.UNSIGNED_INT_SAMPLER_2D_ARRAY,ln),nn);function gn(e,t,n){var r=yn[n.type];if(!r)throw new Error("Unknown GLSL uniform type ".concat(n.type));return r().bind(null,e,t)}var An=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function Sn(e,t){return"#define ".concat(e," ").concat(t)}function Cn(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,n,r){var i=Number(r);return t[n]=isNaN(i)?r:i,""})),t}function On(e,t){var n=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,r,i){var o=Number(r);return n.push({location:isNaN(o)?t[r]:o,name:i}),""})),n}function In(e){var t=[],n=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,r){var i=[];return r.trim().split("\n").forEach((function(e){var t=Y(e.trim().split(/\s+/),2),n=t[0],r=t[1];i.push({type:n.trim(),name:r.replace(";","").trim()})})),n.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,r){return r.trim().split("\n").forEach((function(e){var r=e.trim().split(" "),i=r[0]||"",o=r[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var u=n.find((function(e){return i===e.type}));if(u)if(a)for(var s=function(e){u.uniforms.forEach((function(n){t.push("".concat(o,"[").concat(e,"].").concat(n.name))}))},l=0;l<5;l++)s(l);else u.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}function Nn(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i="#version 100"===e.glslVersion,o=!1,a=n.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),u="";null!==r&&(u=z(r.entries()).map((function(e){var t=Y(e,2);return Sn(t[0],t[1])})).join("\n"));var s=a.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",l=a.filter((function(e){return!e.startsWith("precision")})).join("\n"),c="";if(e.viewportOrigin===me.UpperLeft&&(c+="".concat(Sn("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===ye.Zero&&(c+="".concat(Sn("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var f=0,d=0,h=0;l=l.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,n,r){var i=n?"".concat(n,", "):"";return"layout(".concat(i,"set = ").concat(f,", binding = ").concat(d++,") uniform ").concat(r)})),f++,d=0,We(e.separateSamplerTextures),l=(l=l.replace(/uniform sampler2D (.*);/g,(function(e,n){return"frag"===t?"\nlayout(set = ".concat(f,", binding = ").concat(d++,") uniform texture2D T_").concat(n,";\nlayout(set = ").concat(f,", binding = ").concat(d++,") uniform sampler S_").concat(n,";\n"):""}))).replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(h++,") ").concat(t)})),c+="".concat(Sn("gl_VertexID","gl_VertexIndex"),"\n")}l=e.separateSamplerTextures?(l=(l=(l=l.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"texture2D T_P_".concat(t,", sampler S_P_").concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"T_".concat(t,", S_").concat(t)}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D(T_".concat(t,", S_").concat(t,")")})):(l=(l=(l=l.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D P_".concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return t}));var _="\n".concat(e.glslVersion,"\n").concat(i&&o?"#extension GL_EXT_draw_buffers : require":"","\n").concat(i&&"frag"===t?"#extension GL_OES_standard_derivatives : enable":"","\n").concat(s,"\n").concat(c,"\n").concat(u,"\n").concat(l,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(_=_.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) ".concat(t)}))),i){if("frag"===t&&(_=_.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return"varying ".concat(t," ").concat(n,";\n")}))),"vert"===t&&(_=(_=_.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return"varying ".concat(t," ").concat(n,";\n")}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return"attribute ".concat(t," ").concat(n,";\n")}))),_=_.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){var p,E=(_=_.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return p=n,"".concat(t," ").concat(n,";\n")}))).lastIndexOf("}");_=_.substring(0,E)+"\n gl_FragColor = vec4(".concat(p,");\n")+_.substring(E)}_=_.replace(/^\s*layout\((.*)\)/gm,"");var v,R=ee(An);try{for(R.s();!(v=R.n()).done;){var T=Y(v.value,2),m=T[0],y=T[1];_=_.replace(m,y)}}catch(e){R.e(e)}finally{R.f()}}return _}function Pn(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=Nn(e,"vert",t,r,i),a=Nn(e,"frag",n,r,i);return{vert:t,frag:n,preprocessedVert:o,preprocessedFrag:a}}function Dn(e,t){var n=void 0!==t.defines?t.defines:null,r=void 0!==t.features?t.features:null,i=void 0!==t.both?t.both+t.vert:t.vert,o=void 0!==t.both?t.both+t.frag:t.frag;return Pn(e.queryVendorInfo(),i,o,n,r)}var xn=function(){function e(){M(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines=new Map,this.features={MRT:!0}}return b(e,[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,t){if(null!==t){if(this.defines.get(e)===t)return!1;this.defines.set(e,t)}else{if(!this.defines.has(e))return!1;this.defines.delete(e)}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return ut(this.defines.get(e))}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&We("1"===t),null!==t}},{key:"ensurePreprocessed",value:function(e){""===this.preprocessedVert&&(this.preprocessedVert=Nn(e,"vert",this.both+this.vert,this.defines,this.features),this.preprocessedFrag=Nn(e,"frag",this.both+this.frag,this.defines,this.features))}}]),e}(),Bn=function(){function e(t){M(this,e),this.device=void 0,this.uniformBufferWordAlignment=void 0,this.uniformBufferMaxPageWordSize=void 0,this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=t;var n=t.queryLimits();this.uniformBufferWordAlignment=n.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=n.uniformBufferMaxPageWordSize}return b(e,[{key:"isSupportedUBO",value:function(){return"WebGL1"!==this.device.queryVendorInfo().platformString}},{key:"findPageIndex",value:function(e){return e/this.uniformBufferMaxPageWordSize|0}},{key:"allocateChunk",value:function(e){We((e=ct(e,this.uniformBufferWordAlignment))<this.uniformBufferMaxPageWordSize);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=ct(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t}},{key:"ensureShadowBuffer",value:function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var n=ct(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*n),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){We(e<this.currentWordOffset&&e+t<=this.currentWordOffset);var r=ct(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*r);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),!(this.currentWordOffset<=r))throw new Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}}},{key:"mapBufferF32",value:function(){return Xe(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=Xe(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:this.currentBufferWordSize,usage:de.UNIFORM|de.COPY_DST,hint:he.Dynamic}));var t=ct(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(!(t<=this.currentBufferWordSize))throw new Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())Xe(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}}},{key:"destroy",value:function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null}}]),e}();function Mn(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function Fn(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function bn(e){return 0}var Ln=b((function e(){M(this,e),this.keys=[],this.values=[]})),Un=function(){function e(t,n){M(this,e),this.keyEqualFunc=void 0,this.keyHashFunc=void 0,this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=n}return b(e,[{key:"findBucketIndex",value:function(e,t){for(var n=0;n<e.keys.length;n++)if(this.keyEqualFunc(t,e.keys[n]))return n;return-1}},{key:"findBucket",value:function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)}},{key:"get",value:function(e){var t=this.findBucket(e);if(void 0===t)return null;var n=this.findBucketIndex(t,e);return n<0?null:t.values[n]}},{key:"add",value:function(e,t){var n=this.keyHashFunc(e);void 0===this.buckets.get(n)&&this.buckets.set(n,new Ln);var r=this.buckets.get(n);r.keys.push(e),r.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var n=this.findBucketIndex(t,e);-1!==n&&(t.keys.splice(n,1),t.values.splice(n,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,n=ee(this.buckets.values());try{for(n.s();!(e=n.n()).done;){t+=e.value.values.length}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"values",value:regeneratorRuntime.mark((function e(){var t,n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=ee(this.buckets.values()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=14;break}r=n.value,i=r.values.length-1;case 6:if(!(i>=0)){e.next=12;break}return e.next=9,r.values[i];case 9:i--,e.next=6;break;case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),t.e(e.t0);case 19:return e.prev=19,t.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[1,16,19,22]])}))}]),e}();function wn(e,t){return We(""!==e.preprocessedVert&&""!==t.preprocessedVert),We(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Gn(e,t){return e=Mn(e,t.numUniformBuffers),e=Mn(e,t.numSamplers)}function kn(e,t){return e=Mn(e,t.blendMode),e=Mn(e,t.blendSrcFactor),e=Mn(e,t.blendDstFactor)}function Vn(e,t){return e=kn(e,t.rgbBlendState),e=Mn(e=kn(e,t.alphaBlendState),t.channelWriteMask)}function Wn(e,t){for(var n=0;n<t.attachmentsState.length;n++)e=Vn(e,t.attachmentsState[n]);return e=function(e,t){return e=Mn(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Mn(e,t.depthCompare),e=Mn(e,t.depthWrite?1:0),e=Mn(e,t.stencilCompare),e=Mn(e,t.stencilPassOp),e=Mn(e,t.stencilWrite?1:0),e=Mn(e,t.cullMode),e=Mn(e,t.frontFace?1:0),e=Mn(e,t.polygonOffset?1:0)}function Xn(e){var t=0;t=Mn(t,e.program.id),null!==e.inputLayout&&(t=Mn(t,e.inputLayout.id));for(var n=0;n<e.bindingLayouts.length;n++)t=Gn(t,e.bindingLayouts[n]);t=Wn(t,e.megaStateDescriptor);for(var r=0;r<e.colorAttachmentFormats.length;r++)t=Mn(t,e.colorAttachmentFormats[r]||0);return Fn(t=Mn(t,e.depthStencilAttachmentFormat||0))}function Hn(e){for(var t=0,n=0;n<e.samplerBindings.length;n++){var r=e.samplerBindings[n];null!==r&&null!==r.texture&&(t=Mn(t,r.texture.id))}for(var i=0;i<e.uniformBufferBindings.length;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=Mn(t,o.buffer.id),t=Mn(t,o.wordCount))}return Fn(t)}var jn,Yn=function(){function e(t){M(this,e),this.device=void 0,this.bindingsCache=new Un(Lt,Hn),this.renderPipelinesCache=new Un(Vt,Xn),this.inputLayoutsCache=new Un(Ht,bn),this.programCache=new Un(wn,bn),this.samplerCache=new Un(jt,bn),this.device=t}return b(e,[{key:"createBindings",value:function(e){var t=this.bindingsCache.get(e);if(null===t){var n=qt(e);t=this.device.createBindings(n),this.bindingsCache.add(n,t)}return t}},{key:"createRenderPipeline",value:function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var n=Jt(e);t=this.device.createRenderPipeline(n),this.renderPipelinesCache.add(n,t)}return t}},{key:"createInputLayout",value:function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var n=tn(e);t=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,t)}return t}},{key:"createProgramSimple",value:function(e){var t,n=this.programCache.get(e);if(null===n){var r={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};n=this.device.createProgramSimple(r),this.programCache.add(r,n)}return n}},{key:"createProgram",value:function(e){return e.ensurePreprocessed(this.device.queryVendorInfo()),this.createProgramSimple(e)}},{key:"createSampler",value:function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t}},{key:"destroy",value:function(){var e,t=ee(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var n,r=ee(this.renderPipelinesCache.values());try{for(r.s();!(n=r.n()).done;){n.value.destroy()}}catch(e){r.e(e)}finally{r.f()}var i,o=ee(this.inputLayoutsCache.values());try{for(o.s();!(i=o.n()).done;){i.value.destroy()}}catch(e){o.e(e)}finally{o.f()}var a,u=ee(this.programCache.values());try{for(u.s();!(a=u.n()).done;){a.value.destroy()}}catch(e){u.e(e)}finally{u.f()}var s,l=ee(this.samplerCache.values());try{for(l.s();!(s=l.n()).done;){s.value.destroy()}}catch(e){l.e(e)}finally{l.f()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}]),e}();!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"}(jn||(jn={}));var Kn,zn={x:0,y:0,w:1,h:1},qn=function(){function e(){M(this,e),this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=zn,this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorResolveTo:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=0,this.viewportH=0,this.execFunc=null,this.postFunc=null,this.debugName=void 0,this.debugThumbnails=[]}return b(e,[{key:"setDebugName",value:function(e){this.debugName=e}},{key:"pushDebugThumbnail",value:function(e){this.debugThumbnails[e]=!0}},{key:"setViewport",value:function(e){this.viewport=e}},{key:"attachRenderTargetID",value:function(e,t){We(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t}},{key:"attachResolveTexture",value:function(e){this.resolveTextureInputIDs.push(e)}},{key:"attachOcclusionQueryPool",value:function(e){this.descriptor.occlusionQueryPool=e}},{key:"resolveToExternalTexture",value:function(e,t){this.resolveTextureOutputExternalTextures[e]=t}},{key:"exec",value:function(e){We(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){We(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}]),e}(),Zn=function(){function e(t,n){M(this,e),this.debugName=void 0,this.dimension=pe.n2D,this.depth=1,this.numLevels=1,this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.usage=Ee.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.attachment=void 0,this.age=0,this.pixelFormat=n.pixelFormat,this.width=n.width,this.height=n.height,this.sampleCount=n.sampleCount,We(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))}return b(e,[{key:"setDebugName",value:function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}},{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount}},{key:"reset",value:function(e){We(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()}}]),e}(),Qn=function(){function e(t,n){M(this,e),this.dimension=pe.n2D,this.depth=1,this.numLevels=1,this.usage=Ee.RenderTarget,this.pixelFormat=void 0,this.width=0,this.height=0,this.texture=void 0,this.age=0,this.immutable=!0,this.pixelFormat=n.pixelFormat,this.width=n.width,this.height=n.height,this.texture=t.createTexture(this)}return b(e,[{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){We(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}]),e}();Kn=Symbol.species;var Jn,$n=b((function e(){M(this,e),this[Kn]=void 0,this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]})),er=function(){function e(t){M(this,e),this.device=void 0,this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=t}return b(e,[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;t<this.renderTargetDeadPool.length;t++){var n=this.renderTargetDeadPool[t];if(n.matchesDescription(e))return n.reset(e),this.renderTargetDeadPool.splice(t--,1),n}return new Zn(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;t<this.singleSampledTextureDeadPool.length;t++){var n=this.singleSampledTextureDeadPool[t];if(n.matchesDescription(e))return n.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),n}return new Qn(this.device,e)}},{key:"beginGraphBuilder",value:function(){We(null===this.currentGraph),this.currentGraph=new $n}},{key:"pushPass",value:function(e){var t=new qn;e(t),this.currentGraph.passes.push(t)}},{key:"createRenderTargetID",value:function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1}},{key:"createResolveTextureID",value:function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}},{key:"findMostRecentPassThatAttachedRenderTarget",value:function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var n=this.currentGraph.passes[t];if(n.renderTargetIDs.includes(e))return n}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var n=e;if(void 0===n.resolveTextureOutputIDs[t]){var r=n.renderTargetIDs[t],i=this.createResolveTextureID(r);n.resolveTextureOutputIDs[t]=i}return n.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=Xe(this.findMostRecentPassThatAttachedRenderTarget(e)),n=t.renderTargetIDs.indexOf(e);return We(void 0===t.resolveTextureOutputExternalTextures[n]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),n=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,n)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var n=this.findPassForResolveRenderTarget(e),r=n.renderTargetIDs.indexOf(e);We(void 0===n.resolveTextureOutputIDs[r]),n.resolveTextureOutputExternalTextures[r]=t}},{key:"getRenderTargetDescription",value:function(e){return Xe(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var n=0;n<t.renderTargetIDs.length;n++){var r=t.renderTargetIDs[n];void 0!==r&&(this.renderTargetOutputCount[r]++,t.renderTargetExtraRefs[n]&&this.renderTargetOutputCount[r]++)}for(var i=0;i<t.resolveTextureInputIDs.length;i++){var o=t.resolveTextureInputIDs[i];if(void 0!==o){this.resolveTextureUseCount[o]++;var a=e.resolveTextureRenderTargetIDs[o];this.renderTargetResolveCount[a]++}}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if(We(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var n=e.renderTargetDescriptions[t],r=this.acquireRenderTargetForDescription(n);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var n=Xe(this.renderTargetAliveForID[e]);return t?(We(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(We(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(n.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(n)),n}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var n=e.resolveTextureRenderTargetIDs[t];We(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var r=Xe(this.releaseRenderTargetForID(n,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return Xe(r.texture)}},{key:"determineResolveParam",value:function(e,t,n){var r=t.renderTargetIDs[n],i=t.resolveTextureOutputIDs[n],o=t.resolveTextureOutputExternalTextures[n],a=void 0!==i,u=void 0!==o;We(!(a&&u));var s=null,l=!1;if(this.renderTargetOutputCount[r]>1&&(l=!0),a){We(e.resolveTextureRenderTargetIDs[i]===r),We(this.resolveTextureUseCount[i]>0),We(this.renderTargetOutputCount[r]>0);var c=Xe(this.renderTargetAliveForID[r]);if(null!==c.texture&&1===this.renderTargetOutputCount[r])s=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=Xe(e.renderTargetDescriptions[r]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(f),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,c.debugName+" (Resolve ".concat(i,")"))}s=this.singleSampledTextureForResolveTextureID[i].texture}}else s=u?o:null;return{resolveTo:s,store:l}}},{key:"schedulePass",value:function(e,t){for(var n=t.renderTargetIDs[jn.DepthStencil],r=jn.Color0;r<=jn.ColorMax;r++){var i=t.renderTargetIDs[r],o=this.acquireRenderTargetForID(e,i);t.renderTargets[r]=o,t.descriptor.colorAttachment[r]=null!==o?o.attachment:null;var a=this.determineResolveParam(e,t,r),u=a.resolveTo,s=a.store;t.descriptor.colorResolveTo[r]=u,t.descriptor.colorStore[r]=s,t.descriptor.colorClearColor[r]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,n);t.renderTargets[jn.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,jn.DepthStencil),f=c.resolveTo,d=c.store;t.descriptor.depthStencilResolveTo=f,t.descriptor.depthStencilStore=d,t.descriptor.depthClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[n].depthClearValue:"load",t.descriptor.stencilClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[n].stencilClearValue:"load";for(var h=0,_=0,p=0,E=0;E<t.renderTargets.length;E++){var v=t.renderTargets[E];v&&(0===h&&(h=v.width,_=v.height,p=v.sampleCount),We(v.width===h),We(v.height===_),We(v.sampleCount===p),v.needsClear=!1)}if(h>0&&_>0){var R=h*t.viewport.x,T=_*t.viewport.y,m=h*t.viewport.w,y=_*t.viewport.h;t.viewportX=R,t.viewportY=T,t.viewportW=m,t.viewportH=y}for(var g=0;g<t.resolveTextureInputIDs.length;g++){var A=t.resolveTextureInputIDs[g];t.resolveTextureInputTextures[g]=this.acquireResolveTextureInputTextureForID(e,A)}for(var S=0;S<t.renderTargetIDs.length;S++)this.releaseRenderTargetForID(t.renderTargetIDs[S],!0);for(var C=0;C<t.renderTargetExtraRefs.length;C++)t.renderTargetExtraRefs[C]&&this.releaseRenderTargetForID(t.renderTargetIDs[C],!0)}},{key:"scheduleGraph",value:function(e){We(0===this.renderTargetOutputCount.length),We(0===this.renderTargetResolveCount.length),We(0===this.resolveTextureUseCount.length);for(var t=0;t<this.renderTargetDeadPool.length;t++)this.renderTargetDeadPool[t].age++;for(var n=0;n<this.singleSampledTextureDeadPool.length;n++)this.singleSampledTextureDeadPool[n].age++;st(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),st(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),st(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var r=0;r<e.passes.length;r++)this.scheduleAddUseCount(e,e.passes[r]);for(var i=0;i<e.passes.length;i++)this.schedulePass(e,e.passes[i]);for(var o=0;o<this.renderTargetOutputCount.length;o++)We(0===this.renderTargetOutputCount[o]);for(var a=0;a<this.renderTargetResolveCount.length;a++)We(0===this.renderTargetResolveCount[a]);for(var u=0;u<this.resolveTextureUseCount.length;u++)We(0===this.resolveTextureUseCount[u]);for(var s=0;s<this.renderTargetAliveForID.length;s++)We(void 0===this.renderTargetAliveForID[s]);for(var l=0;l<this.renderTargetDeadPool.length;l++)this.renderTargetDeadPool[l].age>=1&&(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;c<this.singleSampledTextureDeadPool.length;c++)this.singleSampledTextureDeadPool[c].age>=1&&(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}},{key:"execPass",value:function(e){We(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.beginDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.endDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null}},{key:"execGraph",value:function(e){var t=this;this.scheduleGraph(e),e.passes.forEach((function(e){t.execPass(e)})),this.singleSampledTextureForResolveTextureID.length=0}},{key:"execute",value:function(){var e=Xe(this.currentGraph);this.execGraph(e),this.currentGraph=null}},{key:"getDebug",value:function(){return this}},{key:"getPasses",value:function(){return this.currentGraph.passes}},{key:"getPassDebugThumbnails",value:function(e){return e.debugThumbnails}},{key:"getPassRenderTargetID",value:function(e,t){return e.renderTargetIDs[t]}},{key:"getRenderTargetIDDebugName",value:function(e){return this.currentGraph.renderTargetDebugNames[e]}},{key:"getResolveTextureForID",value:function(e){var t=this.currentPass,n=t.resolveTextureInputIDs.indexOf(e);return We(n>=0),Xe(t.resolveTextureInputTextures[n])}},{key:"getRenderTargetAttachment",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null}},{key:"getRenderTargetTexture",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null}},{key:"newGraphBuilder",value:function(){return this.beginGraphBuilder(),this}},{key:"destroy",value:function(){for(var e=0;e<this.renderTargetAliveForID.length;e++)We(void 0===this.renderTargetAliveForID[e]);for(var t=0;t<this.singleSampledTextureForResolveTextureID.length;t++)We(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var n=0;n<this.renderTargetDeadPool.length;n++)this.renderTargetDeadPool[n].destroy();for(var r=0;r<this.singleSampledTextureDeadPool.length;r++)this.singleSampledTextureDeadPool[r].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"}(Jn||(Jn={}));function tr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,r=Object(E.clamp)(e,0,n)/n;t&&(r=1-r);var i=65535*r;return 65535&i}function nr(e){return e>>>24&255}function rr(e,t){return(16777215&e|(255&t)<<24)>>>0}function ir(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function or(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e}function ar(e,t){return rr(ir(0,t),e)}function ur(e,t){return We(t>=0),(4294967040&e|t>>>8&255)>>>0}function sr(e){return rr(0,e)}function lr(e,t){return We(t>=0),(4278190335&e|t<<8)>>>0}function cr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&Jn.TRANSLUCENT?sr(e):ar(e,t)}function fr(e,t){return!!(e>>>31&1)?lr(e,t):ur(e,t)}function dr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,r=!!(e>>>31&1),i=tr(t,r,n);return r?lr(e,i):ur(e,i)}function hr(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e}var _r="undefined"!=typeof Float32Array?Float32Array:Array;function pr(){var e=new _r(16);return _r!=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 Er(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 vr(e,t,n,r,i,o,a,u,s,l,c,f,d,h,_,p){var E=new _r(16);return E[0]=e,E[1]=t,E[2]=n,E[3]=r,E[4]=i,E[5]=o,E[6]=a,E[7]=u,E[8]=s,E[9]=l,E[10]=c,E[11]=f,E[12]=d,E[13]=h,E[14]=_,E[15]=p,E}function Rr(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 Tr=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],u=t[4],s=t[5],l=t[6],c=t[7],f=t[8],d=t[9],h=t[10],_=t[11],p=t[12],E=t[13],v=t[14],R=t[15],T=n[0],m=n[1],y=n[2],g=n[3];return e[0]=T*r+m*u+y*f+g*p,e[1]=T*i+m*s+y*d+g*E,e[2]=T*o+m*l+y*h+g*v,e[3]=T*a+m*c+y*_+g*R,T=n[4],m=n[5],y=n[6],g=n[7],e[4]=T*r+m*u+y*f+g*p,e[5]=T*i+m*s+y*d+g*E,e[6]=T*o+m*l+y*h+g*v,e[7]=T*a+m*c+y*_+g*R,T=n[8],m=n[9],y=n[10],g=n[11],e[8]=T*r+m*u+y*f+g*p,e[9]=T*i+m*s+y*d+g*E,e[10]=T*o+m*l+y*h+g*v,e[11]=T*a+m*c+y*_+g*R,T=n[12],m=n[13],y=n[14],g=n[15],e[12]=T*r+m*u+y*f+g*p,e[13]=T*i+m*s+y*d+g*E,e[14]=T*o+m*l+y*h+g*v,e[15]=T*a+m*c+y*_+g*R,e};function mr(e,t,n){var r=new _r(3);return r[0]=e,r[1]=t,r[2]=n,r}var yr,gr;yr=new _r(3),_r!=Float32Array&&(yr[0]=0,yr[1]=0,yr[2]=0),gr=yr;!function(){var e=function(){var e=new _r(2);return _r!=Float32Array&&(e[0]=0,e[1]=0),e}()}();var Ar=vr(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Sr,Cr=vr(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Or(e,t,n){t!==n&&(t===ye.NegativeOne?function(e){Tr(e,Ar,e)}(e):t===ye.Zero&&function(e){Tr(e,Cr,e)}(e))}function Ir(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=r,4}function Nr(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return e[t+0]=n,e[t+1]=r,e[t+2]=i,e[t+3]=o,4}function Pr(e,t,n){return e[t+0]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],4}function Dr(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.a;return e[t+0]=n.r,e[t+1]=n.g,e[t+2]=n.b,e[t+3]=r,4}function xr(e,t,n){return e[t+0]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],16}!function(e){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"}(Sr||(Sr={}));var Br,Mr=function(){function e(){M(this,e),this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=_t(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=_t(4,(function(){return 0})),this.flags=0,this.inputState=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={bindingLayouts:[],inputLayout:null,megaStateDescriptor:gt(Ct),program:null,topology:fe.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return b(e,[{key:"reset",value:function(){this.sortKey=0,this.flags=Sr.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){yt(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 t=0;t<e.renderPipelineDescriptor.colorAttachmentFormats.length;t++)this.renderPipelineDescriptor.colorAttachmentFormats[t]=e.renderPipelineDescriptor.colorAttachmentFormats[t];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.inputState=e.inputState,this.uniformBuffer=e.uniformBuffer,this.uniforms=z(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~Sr.InheritedFlags|e.flags&Sr.InheritedFlags,this.sortKey=e.sortKey;var n=this.bindingDescriptors[0],r=e.bindingDescriptors[0];null!==r.bindingLayout&&this.setBindingLayout(r.bindingLayout);for(var i=0;i<Math.min(n.uniformBufferBindings.length,r.uniformBufferBindings.length);i++)n.uniformBufferBindings[i].wordCount=e.bindingDescriptors[0].uniformBufferBindings[i].wordCount;this.setSamplerBindingsFromTextureMappings(r.samplerBindings);for(var o=0;o<e.dynamicUniformBufferByteOffsets.length;o++)this.dynamicUniformBufferByteOffsets[o]=e.dynamicUniformBufferByteOffsets[o]}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return yt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor}},{key:"getMegaStateFlags",value:function(){return this.renderPipelineDescriptor.megaStateDescriptor}},{key:"setInputLayoutAndState",value:function(e,t){this.inputState=t,this.renderPipelineDescriptor.inputLayout=e}},{key:"setBindingLayout",value:function(e){We(e.numUniformBuffers<this.dynamicUniformBufferByteOffsets.length),this.renderPipelineDescriptor.bindingLayouts[0]=e,this.bindingDescriptors[0].bindingLayout=e;for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;t<e.numUniformBuffers;t++)this.bindingDescriptors[0].uniformBufferBindings.push({buffer:null,wordCount:0});for(var n=this.bindingDescriptors[0].samplerBindings.length;n<e.numSamplers;n++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})}},{key:"setBindingLayouts",value:function(e){We(e.length<=this.bindingDescriptors.length),We(1===e.length),this.setBindingLayout(e[0])}},{key:"drawIndexes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=ht(this.flags,Sr.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=ht(this.flags,Sr.Indexed,!0),this.drawCount=e,this.drawStart=n,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=ht(this.flags,Sr.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"setUniforms",value:function(e,t){if(0!==t.length){this.uniforms[e]=t;var n=0,r=[];t.forEach((function(e){var t=e.value,i="number"==typeof t?[t]:t,o=i.length>4?4:i.length,a=4-n%4;if(4!==a)if(a>=o);else{n+=a;for(var u=0;u<a;u++)r.push(0)}n+=i.length,r.push.apply(r,z(i))}));var i=4-r.length%4;if(4!==i)for(var o=0;o<i;o++)r.push(0);for(var a=this.allocateUniformBuffer(e,r.length),u=this.mapUniformBufferF32(e),s=0;s<r.length;s+=4)a+=Nr(u,a,r[s],r[s+1],r[s+2],r[s+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){return We(this.bindingDescriptors[0].bindingLayout.numUniformBuffers<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=t,this.getUniformBufferOffset(e)}},{key:"getUniformBufferOffset",value:function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2}},{key:"setUniformBufferOffset",value:function(e,t,n){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=n}},{key:"mapUniformBufferF32",value:function(e){return this.uniformBuffer.mapBufferF32()}},{key:"getUniformBuffer",value:function(){return this.uniformBuffer}},{key:"setSamplerBindingsFromTextureMappings",value:function(e){e=e.filter((function(e){return e}));for(var t=0;t<this.bindingDescriptors[0].samplerBindings.length;t++){var n=this.bindingDescriptors[0].samplerBindings[t],r=e[t];null!=r?(n.texture=r.texture,n.sampler=r.sampler,n.lateBinding=r.lateBinding):(n.texture=null,n.sampler=null,n.lateBinding=null)}}},{key:"hasLateSamplerBinding",value:function(e){for(var t=0;t<this.bindingDescriptors[0].samplerBindings.length;t++){if(this.bindingDescriptors[0].samplerBindings[t].lateBinding===e)return!0}return!1}},{key:"resolveLateSamplerBinding",value:function(e,t){for(var n=0;n<this.bindingDescriptors[0].samplerBindings.length;n++){var r=this.bindingDescriptors[0].samplerBindings[n];r.lateBinding===e&&(null===t?(r.texture=null,r.sampler=null):(We(null===t.lateBinding),r.texture=t.texture,null!==t.sampler&&(r.sampler=t.sampler)),r.lateBinding=null)}}},{key:"queryPipelineReady",value:function(e){var t=e.createRenderPipeline(this.renderPipelineDescriptor);return e.device.queryPipelineReady(t)}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=ht(this.flags,Sr.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value:function(e,t){for(var n=e.queryRenderPass(t),r=-1,i=0;i<n.colorAttachment.length;i++){var o=null!==n.colorAttachment[i]?e.queryRenderTarget(n.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.pixelFormat:null,null!==o&&(-1===r?r=o.sampleCount:We(r===o.sampleCount))}var a=null!==n.depthStencilAttachment?e.queryRenderTarget(n.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.pixelFormat:null,null!==a&&(-1===r?r=a.sampleCount:We(r==a.sampleCount)),We(r>0),this.renderPipelineDescriptor.sampleCount=r}},{key:"drawOnPass",value:function(e,t){var n=this,r=e.device;this.setAttachmentFormatsFromRenderPass(r,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!r.queryPipelineReady(i)){if(this.flags&Sr.AllowSkippingIfPipelineNotReady)return!1;r.pipelineForceReady(i)}t.setPipeline(i),t.setInputState(this.inputState);for(var o=0;o<this.bindingDescriptors[0].uniformBufferBindings.length;o++)this.bindingDescriptors[0].uniformBufferBindings[o].buffer=Xe(this.uniformBuffer.buffer);this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){var n=e.name,r=e.value;t[n]=r})),n.renderPipelineDescriptor.program.setUniforms(t)}));var a=e.createBindings(D(D({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(We(!!(this.flags&Sr.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&Sr.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0}}]),e}(),Fr=null;function br(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(Br||(Br={}));var Lr=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:br,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Br.Forwards;M(this,e),this.renderInsts=[],this.compareFunction=void 0,this.executionOrder=void 0,this.usePostSort=!1,this.compareFunction=t,this.executionOrder=n}return b(e,[{key:"checkUsePostSort",value:function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500}},{key:"insertSorted",value:function(e){null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):dt(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Sr.Draw,this.insertSorted(e)}},{key:"hasLateSamplerBinding",value:function(e){for(var t=0;t<this.renderInsts.length;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1}},{key:"resolveLateSamplerBinding",value:function(e,t){for(var n=0;n<this.renderInsts.length;n++)this.renderInsts[n].resolveLateSamplerBinding(e,t)}},{key:"ensureSorted",value:function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)}},{key:"drawOnPassRendererNoReset",value:function(e,t){this.ensureSorted();var n=0;if(this.executionOrder===Br.Forwards)for(var r=0;r<this.renderInsts.length;r++)this.renderInsts[r].drawOnPass(e,t)&&n++;else for(var i=this.renderInsts.length-1;i>=0;i--)this.renderInsts[i].drawOnPass(e,t)&&n++;return n}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}]),e}(),Ur=function(){function e(){M(this,e),this.pool=[],this.allocCount=0}return b(e,[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new Mr),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;e<this.pool.length;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}]),e}(),wr=function(){function e(t){M(this,e),this.renderCache=void 0,this.instPool=new Ur,this.templatePool=new Ur,this.simpleRenderInstList=new Lr,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t}return b(e,[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),n=this.instPool.pool[t];return n.debug=null,e>=0&&n.setFromTemplate(this.templatePool.pool[e]),n}},{key:"submitRenderInst",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.currentRenderInstList;t.submitRenderInst(e)}},{key:"setCurrentRenderInstList",value:function(e){We(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),n=this.templatePool.pool[t];return e>=0&&n.setFromTemplate(this.templatePool.pool[e]),n.flags|=Sr.Template,n}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1;return this.templatePool.pool[e]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),We(0===this.templatePool.allocCount)}},{key:"destroy",value:function(){this.instPool.destroy(),this.renderCache.destroy()}},{key:"disableSimpleMode",value:function(){this.simpleRenderInstList=null}},{key:"drawOnPassRenderer",value:function(e){Xe(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){Xe(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}]),e}(),Gr=function(){function e(){M(this,e),this.renderCache=void 0,this.renderGraph=void 0,this.renderInstManager=void 0,this.uniformBuffer=void 0,this.device=void 0}return b(e,[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new Yn(e),this.renderGraph=new er(this.device),this.renderInstManager=new wr(this.renderCache),this.uniformBuffer=new Bn(this.device)}},{key:"pushTemplateRenderInst",value:function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e}},{key:"prepareToRender",value:function(){this.uniformBuffer.prepareToRender()}},{key:"destroy",value:function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache.destroy(),this.renderGraph.destroy()}},{key:"getCache",value:function(){return this.renderCache}}]),e}();Gr=l([Object(v.singleton)()],Gr);var kr=function(){function e(){M(this,e),this.name=void 0,this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}return b(e,[{key:"reset",value:function(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}},{key:"copy",value:function(e){this.texture=e.texture,this.sampler=e.sampler,this.lateBinding=e.lateBinding,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias}}]),e}(),Vr=function(){function e(){M(this,e),this.inputTexture=null,this.outputTexture=null}return b(e,[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),We(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Qn(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))}},{key:"getTextureForSampling",value:function(){return null!==this.inputTexture?this.inputTexture.texture:null}},{key:"getTextureForResolving",value:function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture}},{key:"destroy",value:function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)}}]),e}(),Wr=function(){function e(t){M(this,e),this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.pixelFormat=t}return b(e,[{key:"setDimensions",value:function(e,t,n){this.width=e,this.height=t,this.sampleCount=n}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}]),e}();function Xr(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var Hr,jr=Xr(Qe);function Yr(e,t){var n=function(e){return e.antialiasingMode===Hr.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,n)}function Kr(e,t,n){var r=function(e){if(e===jn.Color0)return Oe.U8_RGBA_RT;if(e===jn.DepthStencil)return Oe.D24_S8;throw new Error("whoops")}(e),i=new Wr(r);return Yr(i,t),null!==n&&(i.colorClearColor=n.colorClearColor,i.depthClearValue=n.depthClearValue,i.stencilClearValue=n.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(Hr||(Hr={}));var zr=function(){function e(){M(this,e),this.offscreenCanvas=void 0,this.renderingService=void 0,this.canvasConfig=void 0,this.textureCache={},this.gradientCache={}}return b(e,[{key:"getOrCreateTexture",value:function(e,t,n,r){var i=this,o="string"==typeof t?t:t.src||"";if(!this.textureCache[o])if(this.textureCache[o]=e.createTexture(D({pixelFormat:Oe.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:pe.n2D,usage:Ee.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),"string"!=typeof t)this.textureCache[o].setImageData(t),this.textureCache[o].emit("loaded"),this.renderingService.dirtify();else{var a,u=this.canvasConfig.createImage;u?a=u():E.isBrowser&&(a=new window.Image),a&&(a.onload=function(){i.textureCache[o].setImageData(a),i.textureCache[o].emit("loaded"),i.renderingService.dirtify(),r&&r(i.textureCache[o])},a.onerror=function(){},a.crossOrigin="Anonymous",a.src=t)}return this.textureCache[o]}},{key:"getOrCreateCanvas",value:function(){return this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var t=this.generateCacheKey(e),n=e.type,r=e.x0,i=e.y0,o=e.x1,a=e.y1,u=e.steps,s=e.width,l=e.height,c=this.gradientCache[t],f=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),d=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);if(!c){if(f.width=s,f.height=l,n===E.GradientPatternType.LinearGradient)c=d.createLinearGradient(r*s,i*l,o*s,a*l);else if(n===E.GradientPatternType.RadialGradient){var h=Math.sqrt(s*s+l*l)/2;c=d.createRadialGradient(r*s,i*l,0,o*s,a*l,e.r1*h)}u.forEach((function(e){var t,n=Y(e,2),r=n[0],i=n[1];null===(t=c)||void 0===t||t.addColorStop(Number(r),i)})),this.gradientCache[t]=c}f.src=t,c&&(d.fillStyle=c,d.fillRect(0,0,s,l))}},{key:"generateCacheKey",value:function(e){var t=e.type,n=e.x0,r=e.y0,i=e.x1,o=e.y1,a=e.r1,u=e.steps,s=e.width,l=e.height;return"gradient-".concat(t,"-").concat(n,"-").concat(r,"-").concat(i,"-").concat(o,"-").concat(a||0,"-").concat(s,"-").concat(l,"-").concat(u.map((function(e){return e.join("")})).join("-"))}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={},this.gradientCache={}}}]),e}();l([Object(v.inject)(E.OffscreenCanvasCreator),c("design:type",E.OffscreenCanvasCreator)],zr.prototype,"offscreenCanvas",void 0),l([Object(v.inject)(E.RenderingService),c("design:type",E.RenderingService)],zr.prototype,"renderingService",void 0),l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],zr.prototype,"canvasConfig",void 0),zr=l([Object(v.singleton)()],zr);var qr=function(){function e(){M(this,e),this.lights=[],this.fog=void 0}return b(e,[{key:"addLight",value:function(e){this.lights.push(e),this.sortLights()}},{key:"removeLight",value:function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()}},{key:"addFog",value:function(e){this.fog=e}},{key:"removeFog",value:function(e){this.fog=null}},{key:"getFog",value:function(){return this.fog}},{key:"getAllLights",value:function(){return this.lights}},{key:"getDefines",value: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}},{key:"sortLights",value:function(){this.lights.sort((function(e,t){return e.order-t.order}))}}]),e}();qr=l([Object(v.singleton)()],qr);var Zr=v.Syringe.defineToken("RendererFactory"),Qr=v.Syringe.defineToken("ShapeRenderer"),Jr=v.Syringe.defineToken("MeshFactory"),$r=1,ei=function(){function e(){M(this,e),this.renderHelper=void 0,this.rendererFactory=void 0,this.meshFactory=void 0,this.device=void 0,this.renderingService=void 0,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return b(e,[{key:"render",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||this.updatePendingPatches(),this.meshes.forEach((function(r){r.init(t.device,t.renderingService);var i=r.objects;r.clipPathTarget&&(i=[r.clipPath]);var o=t.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),r.applyRenderInst(o,i),t.renderHelper.renderInstManager.submitRenderInst(o,e),n||r.objects.forEach((function(e){e.renderable.dirty=!1}))}))}},{key:"attach",value:function(e,t){this.device=e,this.renderingService=t}},{key:"add",value:function(e){var t=this,n=e.renderable3D;if(n&&!n.meshes.length){var r=this.rendererFactory(e.nodeName);r&&r.meshes.forEach((function(i,o){if(n.meshes[o]=void 0,r.shouldSubmitRenderInst(e,o)){var a=t.meshes.find((function(t){return i===t.constructor&&t.index===o&&t.shouldMerge(e,o)}));a||((a=t.meshFactory(i)).renderer=r,a.index=o,t.meshes.push(a)),a&&(a.objects.push(e),n.meshes[o]=a,a.geometryDirty=!0)}}))}}},{key:"remove",value:function(e){var t=this,n=e.renderable3D;n&&(n.meshes.forEach((function(n){if(n){var r=n.objects.indexOf(e);r>-1&&(n.objects.splice(r,1),n.geometryDirty=!0),0===n.objects.length&&t.meshes.splice(t.meshes.indexOf(n),1)}})),n.meshes=[])}},{key:"updateAttribute",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=e.renderable3D,a=this.rendererFactory(e.nodeName);a&&a.meshes.forEach((function(u,s){var l=a.shouldSubmitRenderInst(e,s),c=o.meshes.find((function(e){return e&&e.index===s&&e.constructor===u}));if(l!==!!c&&(c&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&r.meshes.splice(r.meshes.indexOf(c),1),o.meshes[o.meshes.indexOf(c)]=void 0),l&&((c=r.meshes.find((function(t){return u===t.constructor&&t.index===s&&t.shouldMerge(e,s)})))||((c=r.meshFactory(u)).renderer=a,c.index=s,c.init(r.device,r.renderingService),r.meshes.push(c)),c&&(c.objects.push(e),o.meshes[s]=c))),l&&c&&c.inited&&!c.geometryDirty){var f=c.objects.indexOf(e);if(i)e.parsedStyle[t]=n,c.updateAttribute([e],f,t,n);else{var d=c.id+t;r.pendingUpdatePatches[d]||(r.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:n}),-1===r.pendingUpdatePatches[d].objectIndices.indexOf(f)&&r.pendingUpdatePatches[d].objectIndices.push(f)}}}))}},{key:"changeRenderOrder",value:function(e,t){var n=e.renderable3D;n&&n.meshes.length&&n.meshes.forEach((function(n){n&&n.inited&&!n.geometryDirty&&(n.renderer.shouldSubmitRenderInst(e,n.index)&&n.inited&&n.changeRenderOrder(e,t))}))}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=$r++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var n=e.pendingUpdatePatches[t],r=n.instance,i=n.objectIndices,o=n.name,a=n.value;i.sort((function(e,t){return e-t}));var u=[];i.forEach((function(e){var t=u[u.length-1];t&&e===t[t.length-1]+1?t.push(e):u.push([e])})),u.forEach((function(e){r.updateAttribute(r.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}}}]),e}();l([Object(v.inject)(Gr),c("design:type",Gr)],ei.prototype,"renderHelper",void 0),l([Object(v.inject)(Zr),c("design:type",Function)],ei.prototype,"rendererFactory",void 0),l([Object(v.inject)(Jr),c("design:type",Function)],ei.prototype,"meshFactory",void 0),ei=l([Object(v.singleton)()],ei);var ti=1,ni=function(){function e(){M(this,e),this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.batchManager=void 0,this.device=void 0,this.renderingService=void 0,this.id=ti++,this.meshes=[],this.clipPathMeshCreated=!1}return b(e,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}},{key:"beforeUploadUBO",value:function(e,t,n){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}]),e}();function ri(e,t,n){var r=e.createBuffer({viewOrSize:lt(n.byteLength,4)/4,usage:t,hint:he.Static});return r.setSubData(0,new Uint8Array(n)),r}l([Object(v.inject)(Gr),c("design:type",Gr)],ni.prototype,"renderHelper",void 0),l([Object(v.inject)(zr),c("design:type",zr)],ni.prototype,"texturePool",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],ni.prototype,"camera",void 0),l([Object(v.inject)(qr),c("design:type",qr)],ni.prototype,"lightPool",void 0),l([Object(v.inject)(ei),c("design:type",ei)],ni.prototype,"batchManager",void 0),ni=l([Object(v.injectable)()],ni);var ii=function(e){U(n,e);var t=X(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return M(this,n),(r=t.call(this)).device=void 0,r.props=void 0,r.drawMode=fe.Triangles,r.vertexBuffers=[],r.vertices=[],r.indexBuffer=void 0,r.indices=void 0,r.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:Oe.U32_R},r.vertexCount=0,r.instancedCount=0,r.indexStart=0,r.primitiveStart=0,r.dirty=!0,r.meshes=[],r.device=e,r.props=i,r}return b(n,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new E.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=ri(this.device,de.INDEX|de.COPY_DST,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this}},{key:"setVertexBuffer",value:function(e){var t=this,n=e.bufferIndex,r=e.byteStride,i=e.frequency,o=e.attributes,a=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[n]={byteStride:r,frequency:i},this.vertices[n]=a,o.forEach((function(e){var r=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,u=e.byteStride,s=t.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===n&&e.location===o}));s?(s.format=r,s.bufferByteOffset=i,s.byteStride=u,s.divisor=a):t.inputLayoutDescriptor.vertexAttributeDescriptors.push({format:r,bufferIndex:n,bufferByteOffset:i,location:o,byteStride:u,divisor:a})})),this.vertexBuffers[n]&&this.vertexBuffers[n].destroy();var u=ri(this.device,de.VERTEX|de.COPY_DST,a.buffer);return this.vertexBuffers[n]=u,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value:function(e,t,n,r){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e].byteStride,o=this.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.location===t}));if(o){var a=n*i;this.getVertexBuffer(e).setSubData(o.bufferByteOffset+a,r)}this.meshes.forEach((function(e){e.dispatchEvent(new E.MutationEvent(E.ElementEvent.ATTR_MODIFIED,e,null,null,"geometry",E.MutationEvent.MODIFICATION,null,null))}))}},{key:"updateIndices",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.indexBuffer&&this.indexBuffer.setSubData(t,ArrayBuffer.isView(e)?e:new Uint32Array(e)),this}},{key:"destroy",value:function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexAttributeDescriptors=[],this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0}}]),n}(g.EventEmitter);var oi=function(){function e(t,n){M(this,e),this.device=void 0,this.props={},this.meshes=[],this.defines={},this.uniforms={},this.uniformNames=void 0,this.uboBuffer=[],this.textures={},this.samplers=[],this.programDirty=!0,this.textureDirty=!0,this.geometryDirty=!0;var r=gt(Ct),i=r.cullMode,o=r.depthCompare,a=r.depthWrite,u=r.stencilCompare,s=r.stencilWrite,l=r.stencilPassOp,c=r.frontFace,f=r.polygonOffset,d=r.attachmentsState;this.device=t,this.props=D({cullMode:i,depthTest:!0,depthCompare:o,depthWrite:a,stencilCompare:u,stencilWrite:s,stencilPassOp:l,frontFace:c,polygonOffset:f,attachmentsState:d,blendEquation:ue.Add,blendEquationAlpha:ue.Add,blendSrc:ae.SrcAlpha,blendDst:ae.OneMinusSrcAlpha,blendSrcAlpha:ae.Zero,blendDstAlpha:ae.One,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},n),this.compile()}return b(e,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilCompare",get:function(){return this.props.stencilCompare},set:function(e){this.props.stencilCompare=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilPassOp",get:function(){return this.props.stencilPassOp},set:function(e){this.props.stencilPassOp=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"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.defines.USE_WIREFRAME=!!e}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}},{key:"compile",value:function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,n){return e.samplers.push(n),""})),this.uniformNames=In(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var t=this;Object.keys(e).forEach((function(n){var r,i=e[n],o=t.textures[n];o&&o!==i&&(t.textureDirty=!0),(r=i)&&r.type?(t.textures[n]=i,t.textureDirty=!0,i.on("loaded",(function(){t.meshes.forEach((function(e){e.renderable.dirty=!0}))}))):t.uniforms[n]=i,Object(E.isNil)(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),this.meshes.forEach((function(e){e.dispatchEvent(new E.MutationEvent(E.ElementEvent.ATTR_MODIFIED,e,null,null,"material",E.MutationEvent.MODIFICATION,null,null))}))}}]),e}(),ai=function(e){U(n,e);var t=X(n);function n(e,r){var i;return M(this,n),(i=t.call(this,e,D({},r))).defines=D(D({},i.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),i}return b(n)}(oi);function ui(e){var t={};return Object.keys(e).forEach((function(n){"number"==typeof e[n]&&(t[n]=e[n])})),t}var si,li,ci=1;!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.FILL=1]="FILL",e[e.STROKE=2]="STROKE",e[e.PACKED_STYLE1=3]="PACKED_STYLE1",e[e.PACKED_STYLE2=4]="PACKED_STYLE2",e[e.PICKING_COLOR=5]="PICKING_COLOR",e[e.POSITION=6]="POSITION",e[e.NORMAL=7]="NORMAL",e[e.UV=8]="UV",e[e.BARYCENTRIC=9]="BARYCENTRIC",e[e.MAX=10]="MAX"}(si||(si={})),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.COLOR=4]="COLOR",e[e.STROKE_COLOR=5]="STROKE_COLOR",e[e.PACKED_STYLE1=6]="PACKED_STYLE1",e[e.PACKED_STYLE2=7]="PACKED_STYLE2",e[e.PICKING_COLOR=8]="PICKING_COLOR",e[e.POSITION=9]="POSITION",e[e.NORMAL=10]="NORMAL",e[e.UV=11]="UV",e[e.BARYCENTRIC=12]="BARYCENTRIC",e[e.MAX=13]="MAX"}(li||(li={}));var fi=function(){function e(){M(this,e),this.id=ci++,this.renderer=void 0,this.index=-1,this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.device=void 0,this.renderingService=void 0,this.objects=[],this.material=void 0,this.geometry=void 0,this.clipPath=void 0,this.clipPathTarget=void 0,this.inputState=void 0,this.program=new xn,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1}return b(e,[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(e,t){this.inited||(this.renderer.beforeInitMesh(this),this.device=e,this.renderingService=t,this.material=new ai(this.device),this.material.defines=D(D({},ui(li)),this.material.defines),this.geometry=new ii(this.device),this.inited=!0,this.renderer.afterInitMesh(this))}},{key:"shouldMerge",value:function(e,t){return!this.instance||this.instance.nodeName===e.nodeName&&!e.parsedStyle.clipPath}},{key:"createGeometry",value:function(e){var t=this,n=pr(),r=pr(),i=[],o=[],a=[],u=[],s=[],l=[];e.forEach((function(e){var c,f=e.parsedStyle,d=f.fill,h=f.stroke,_=f.opacity,p=f.fillOpacity,v=f.strokeOpacity,R=f.lineWidth,T=f.anchor,m=f.visibility,y=f.increasedLineWidthForHitTesting,g=[0,0,0,0];d instanceof E.CSSRGB&&(g=[Number(d.r)/255,Number(d.g)/255,Number(d.b)/255,Number(d.alpha)]);var A=[0,0,0,0];h instanceof E.CSSRGB&&(A=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]),t.clipPathTarget?(Er(n,e.getLocalTransform()),g=[1,1,1,1],Tr(n,t.clipPathTarget.getWorldTransform(),n)):Er(n,e.getWorldTransform()),Tr(r,t.camera.getViewTransform(),n);var S=e.isInteractive()&&(null===(c=e.renderable3D)||void 0===c?void 0:c.encodedPickingColor)||[0,0,0];i.push.apply(i,z(n)),o.push.apply(o,z(g)),a.push.apply(a,z(A)),u.push(_.value,p.value,v.value,R.value),s.push("visible"===m.value?1:0,T[0].value,T[1].value,(null==y?void 0:y.value)||0),l.push.apply(l,z(S).concat([.005*e.sortable.renderOrder]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:si.MODEL_MATRIX,byteStride:64,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:li.MODEL_MATRIX0,divisor:1},{format:Oe.F32_RGBA,bufferByteOffset:16,location:li.MODEL_MATRIX1,divisor:1},{format:Oe.F32_RGBA,bufferByteOffset:32,location:li.MODEL_MATRIX2,divisor:1},{format:Oe.F32_RGBA,bufferByteOffset:48,location:li.MODEL_MATRIX3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:si.FILL,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:li.COLOR,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:si.STROKE,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:li.STROKE_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:si.PACKED_STYLE1,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:li.PACKED_STYLE1,divisor:1}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:si.PACKED_STYLE2,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:li.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:si.PICKING_COLOR,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:li.PICKING_COLOR,divisor:1}],data:new Float32Array(l)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()}},{key:"applyRenderInst",value:function(e,t){var n=this,r=this.lightPool.getAllLights(),i=!!this.lightPool.getFog(),o=!!r.length;if(i===this.material.defines.USE_FOG&&o===this.material.defines.USE_LIGHT||(this.material.programDirty=!0),this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=D(D({},this.material.defines),this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=re.Always,this.material.stencilPassOp=Re.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=re.Equal,this.material.stencilPassOp=Re.Keep):this.material.stencilWrite=!1,this.material.textureDirty||this.materialDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0,this.textureMappings.push(a)):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.materialDirty=!0}(this.material.programDirty||this.materialDirty)&&(this.createMaterial(t),this.material.defines=D(D({},this.material.defines),ui(li)),Object.keys(this.material.defines).forEach((function(e){var t=n.material.defines[e];"number"==typeof t?n.program.setDefineString(e,"".concat(t)):n.program.setDefineBool(e,t)})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.programDescriptorSimpleWithOrig=Dn(this.device,this.program),this.material.programDirty=!1),(this.material.textureDirty||this.materialDirty)&&(Object.keys(this.material.textures).sort((function(e,t){return n.material.samplers.indexOf(e)-n.material.samplers.indexOf(t)})).forEach((function(e){var t=new kr;t.name=e,t.texture=n.material.textures[e],n.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=n.renderHelper.getCache().createSampler({wrapS:se.Clamp,wrapT:se.Clamp,minFilter:le.Point,magFilter:le.Bilinear,mipFilter:ce.Linear,minLOD:0,maxLOD:0}),n.textureMappings.push(t)})),this.material.textureDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.inputStateDirty=!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,this.inputStateDirty=!0);var u=this.renderHelper.getCache().createInputLayout(this.geometry.inputLayoutDescriptor),s=this.renderHelper.getCache().createProgramSimple(this.programDescriptorSimpleWithOrig),l=!!this.geometry.indexBuffer;this.inputStateDirty&&(this.inputState&&this.inputState.destroy(),this.inputState=this.device.createInputState(u,this.geometry.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),l?{buffer:this.geometry.indexBuffer,byteOffset:0}:null,s),this.inputStateDirty=!1),e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setInputLayoutAndState(u,this.inputState),this.renderer.beforeUploadUBO(e,this,this.index),this.uploadUBO(e),l?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=ar(Jn.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value:function(e,t,n,r){if("fill"===n){var i=this.instance.parsedStyle.fill,o=this.textureMappings.findIndex((function(e){return"FillTextureMapping"===e.name}));if(i instanceof E.CSSRGB){var a=[];e.forEach((function(e){var t=e.parsedStyle.fill;a.push(Number(t.r)/255,Number(t.g)/255,Number(t.b)/255,Number(t.alpha))})),this.geometry.updateVertexBuffer(si.FILL,li.COLOR,t,new Uint8Array(new Float32Array(a).buffer)),o>=0&&(this.textureMappings.splice(o,-1),this.material.textureDirty=!0)}else{var u=this.createFillGradientTextureMapping([this.instance]);o>=0&&this.textureMappings.splice(o,1,u),this.material.textureDirty=!0}}else if("stroke"===n){var s=[];e.forEach((function(e){var t=e.parsedStyle.stroke;s.push(Number(t.r)/255,Number(t.g)/255,Number(t.b)/255,Number(t.alpha))})),this.geometry.updateVertexBuffer(si.STROKE,li.STROKE_COLOR,t,new Uint8Array(new Float32Array(s).buffer))}else if(["opacity","fillOpacity","strokeOpacity","lineWidth"].indexOf(n)>-1){var l=[];e.forEach((function(e){var t=e.parsedStyle,n=t.opacity,r=t.fillOpacity,i=t.strokeOpacity,o=t.lineWidth;l.push(n.value,r.value,i.value,o.value)})),this.geometry.updateVertexBuffer(si.PACKED_STYLE1,li.PACKED_STYLE1,t,new Uint8Array(new Float32Array(l).buffer))}else if("modelMatrix"===n){var c=[];e.forEach((function(e){var t=Er(pr(),e.getWorldTransform());c.push.apply(c,z(t))})),this.geometry.updateVertexBuffer(si.MODEL_MATRIX,li.MODEL_MATRIX0,t,new Uint8Array(new Float32Array(c).buffer))}else if("visibility"===n||"anchor"===n||"increasedLineWidthForHitTesting"===n){var f=[];e.forEach((function(e){var t=e.parsedStyle,n=t.visibility,r=t.anchor,i=t.increasedLineWidthForHitTesting;f.push("visible"===n.value?1:0,r[0].value,r[1].value,(null==i?void 0:i.value)||0)})),this.geometry.updateVertexBuffer(si.PACKED_STYLE2,li.PACKED_STYLE2,t,new Uint8Array(new Float32Array(f).buffer))}else if("pointerEvents"===n){var d=[];e.forEach((function(e){var t,n=r&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];d.push.apply(d,z(n).concat([.005*e.sortable.renderOrder]))})),this.geometry.updateVertexBuffer(si.PICKING_COLOR,li.PICKING_COLOR,t,new Uint8Array(new Float32Array(d).buffer))}}},{key:"updateAttribute",value:function(e,t,n,r){"clipPath"===n&&this.clipPath&&(this.geometryDirty=!0)}},{key:"changeRenderOrder",value:function(e,t){var n,r=this.objects.indexOf(e),i=e.isInteractive()&&(null===(n=e.renderable3D)||void 0===n?void 0:n.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(si.PICKING_COLOR,li.PICKING_COLOR,r,new Uint8Array(new Float32Array([].concat(z(i),[.005*t])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,n=e.indices.length,r=e.vertices.map((function(e){return e.slice()})),i=si.PICKING_COLOR;i<e.vertexBuffers.length;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride;e.vertices[i]=new Float32Array(o/4*n)}for(var a=0,u=new Uint32Array(n),s=0;s<n;s++){for(var l=t[s],c=1;c<e.vertices.length;c++)for(var f=e.inputLayoutDescriptor.vertexBufferDescriptors[c].byteStride/4,d=0;d<f;d++)e.vertices[c][a*f+d]=r[c][l*f+d];u[s]=a,a++}for(var h=function(t){if(4===t)return"continue";var n=e.inputLayoutDescriptor.vertexBufferDescriptors[t],r=n.frequency,i=n.byteStride,o=e.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===t}));if(o){var a=o.location,u=o.bufferIndex,s=o.bufferByteOffset,l=o.format,c=o.divisor;e.setVertexBuffer({bufferIndex:u,byteStride:i,frequency:r,attributes:[{format:l,bufferByteOffset:s,location:a,divisor:c}],data:e.vertices[t]})}},_=si.PICKING_COLOR;_<e.vertexBuffers.length;_++)h(_);for(var p=new Float32Array(3*n),E=0;E<n;)for(var v=0;v<3;v++){p[3*u[E++]+v]=1}e.setVertexBuffer({bufferIndex:si.BARYCENTRIC,byteStride:12,frequency:_e.PerVertex,attributes:[{format:Oe.F32_RGB,bufferByteOffset:0,location:Number(li.BARYCENTRIC)}],data:p}),e.setIndexBuffer(u)}},{key:"beforeUploadUBO",value:function(e,t,n){}},{key:"uploadUBO",value:function(e){var t=this,n=this.material,r=this.lightPool.getAllLights(),i=this.lightPool.getFog(),o=!!i,a=!!r.length,u=n.defines.USE_WIREFRAME,s=[];if(u){var l=Object(E.parseColor)(n.wireframeColor);s.push({name:"u_WireframeLineColor",value:[Number(l.r)/255,Number(l.g)/255,Number(l.b)/255]}),s.push({name:"u_WireframeLineWidth",value:n.wireframeLineWidth})}if(o&&this.uploadFog(s,i),this.uploadMaterial(s,n),a){var c={};r.forEach((function(e){c[e.define]||(c[e.define]=-1),c[e.define]++,e.uploadUBO(s,c[e.define])}))}s.sort((function(e,n){return t.material.uniformNames.indexOf(e.name)-t.material.uniformNames.indexOf(n.name)})),e.setUniforms(1,s);var f=n.depthCompare,d=n.depthWrite,h=n.stencilCompare,_=n.stencilWrite,p=n.stencilPassOp,v=n.stencilRef,R=n.cullMode,T=n.frontFace,m=n.polygonOffset,y=n.blendEquation,g=n.blendEquationAlpha,A=n.blendSrc,S=n.blendDst,C=n.blendSrcAlpha,O=n.blendDstAlpha;e.setMegaStateFlags({attachmentsState:[{channelWriteMask:this.material.stencilWrite?ve.None:ve.AllChannels,rgbBlendState:{blendMode:y,blendSrcFactor:A,blendDstFactor:S},alphaBlendState:{blendMode:g,blendSrcFactor:C,blendDstFactor:O}}],depthCompare:f,depthWrite:d,stencilCompare:h,stencilWrite:_,stencilPassOp:p,stencilRef:v,cullMode:R,frontFace:T,polygonOffset:m}),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,t){var n=t.parsedStyle,r=n.type,i=n.fill,o=n.start,a=n.end,u=n.density;if(i instanceof E.CSSRGB){var s=[Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)];e.push({name:"u_FogInfos",value:[r,o,a,u]}),e.push({name:"u_FogColor",value:s})}}},{key:"uploadMaterial",value:function(e,t){var n=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,z(n))}},{key:"createFillGradientTextureMapping",value:function(e){var t=e[0],n=t.nodeName===E.Shape.LINE?t.parsedStyle.stroke:t.parsedStyle.fill;if(n&&n instanceof E.CSSGradientValue){var r;n.type===E.GradientPatternType.LinearGradient||n.type===E.GradientPatternType.RadialGradient?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient(D(D({type:n.type},n.value),{},{width:128,height:128})),r=this.texturePool.getOrCreateCanvas()):(this.program.setDefineBool("USE_PATTERN",!0),r=n.value.src);var i=new kr;return i.name="FillTextureMapping",i.texture=this.texturePool.getOrCreateTexture(this.device,r,Pe(Oe.U8_RGBA_NORM,1,1,1)),i.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0}))})),this.device.setResourceName(i.texture,"Fill Texture"+this.id),i.sampler=this.renderHelper.getCache().createSampler({wrapS:se.Repeat,wrapT:se.Repeat,minFilter:le.Point,magFilter:le.Bilinear,mipFilter:ce.Linear,minLOD:0,maxLOD:0}),i}return null}}]),e}();l([Object(v.inject)(Gr),c("design:type",Gr)],fi.prototype,"renderHelper",void 0),l([Object(v.inject)(zr),c("design:type",zr)],fi.prototype,"texturePool",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],fi.prototype,"camera",void 0),l([Object(v.inject)(qr),c("design:type",qr)],fi.prototype,"lightPool",void 0),fi=l([Object(v.injectable)()],fi);var di,hi;!function(e){e[e.PACKED_STYLE3=10]="PACKED_STYLE3",e[e.SIZE=11]="SIZE"}(di||(di={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(hi||(hi={}));var _i=[E.Shape.CIRCLE,E.Shape.ELLIPSE],pi=function(e){U(n,e);var t=X(n);function n(){return M(this,n),t.apply(this,arguments)}return b(n,[{key:"shouldMerge",value:function(e,t){var r=j(w(n.prototype),"shouldMerge",this).call(this,e,t);if(!r)return!1;if(this.needDrawStrokeSeparately(e)||this.needDrawStrokeSeparately(this.instance))return!1;var i=this.instance.parsedStyle.fill,o=e.parsedStyle.fill;return i.isNone===o.isNone}},{key:"createMaterial",value: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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n mat4 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 * 0.5 + 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 float antialiasblur = 1.0 / (a_Size.x + strokeWidth);\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * radius;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\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 vec4 v_Data;\nin vec2 v_Radius;\nin vec4 v_StylePacked3;\n\nout vec4 outputColor;\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\nvoid main() {\n int shape = int(floor(v_Data.w + 0.5));\n float epsilon = 0.00001;\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 float antialiasblur = v_Data.z;\n float antialiased_blur = -max(0.0, antialiasblur);\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius;\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data.xy, 1.0);\n inner_df = sdCircle(v_Data.xy, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data.xy, vec2(1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\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 // vec2 imagecoord = mod(v_Uv, 0.1);\n // vec4 texel = texture(SAMPLER_2D(u_Map), imagecoord);\n // u_Color = texel;\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=D(D({},this.material.defines),ui(hi))}},{key:"createGeometry",value:function(e){var t=this;j(w(n.prototype),"createGeometry",this).call(this,e);var r=[],i=[],o=[],a=[];e.forEach((function(e,n){var u=e,s=4*n,l=u.parsedStyle.radius,c=t.shouldOmitStroke(u.parsedStyle),f=t.getSize(e.parsedStyle,u.nodeName);i.push.apply(i,z(f)),o.push(_i.indexOf(u.nodeName),l||0,c?1:0,0),r.push(-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1),a.push(0+s,2+s,1+s,0+s,3+s,2+s)})),this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:si.POSITION,byteStride:16,frequency:_e.PerVertex,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,location:li.POSITION},{format:Oe.F32_RG,bufferByteOffset:8,location:li.UV}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:di.SIZE,byteStride:8,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,location:hi.SIZE,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:di.PACKED_STYLE3,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:hi.PACKED_STYLE3,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(j(w(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"r"===r||"rx"===r||"ry"===r||"lineWidth"===r){var a=[];e.forEach((function(e){var t=Y(o.getSize(e.parsedStyle,e.nodeName),2),n=[t[0],t[1]];a.push.apply(a,n)})),this.geometry.updateVertexBuffer(di.SIZE,hi.SIZE,t,new Uint8Array(new Float32Array(a).buffer))}else if("stroke"===r||"lineDash"===r||"strokeOpacity"===r){var u=[];e.forEach((function(e){var t=e,n=o.shouldOmitStroke(t.parsedStyle);u.push(_i.indexOf(e.nodeName),e.parsedStyle.radius||0,n?1:0,0)})),this.geometry.updateVertexBuffer(di.PACKED_STYLE3,hi.PACKED_STYLE3,t,new Uint8Array(new Float32Array(u).buffer))}}},{key:"getSize",value:function(e,t){var n=[0,0];if(t===E.Shape.CIRCLE){var r=e.r;n=[r.value,r.value]}else if(t===E.Shape.ELLIPSE){var i=e.rx,o=e.ry;n=[i.value,o.value]}return n}},{key:"shouldOmitStroke",value:function(e){var t=e.lineDash,n=e.stroke,r=e.strokeOpacity;return!(!n||!(t&&t.length&&t.every((function(e){return 0!==e.value}))||1!==r.value))}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,n=t.stroke,r=t.lineDash,i=t.lineWidth,o=t.strokeOpacity;return n&&i.value>0&&(o.value<1||r&&r.length&&r.every((function(e){return 0!==e.value})))}}]),n}(fi);pi=l([Object(v.injectable)()],pi);var Ei,vi,Ri,Ti=[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=10]="POINT",e[e.CAP=11]="CAP",e[e.DASH=12]="DASH"}(vi||(vi={})),function(e){e[e.POSITION=9]="POSITION",e[e.UV=11]="UV",e[e.POINTA=10]="POINTA",e[e.POINTB=12]="POINTB",e[e.CAP=13]="CAP",e[e.DASH=14]="DASH"}(Ri||(Ri={}));var mi=(L(Ei={},E.LineCap.BUTT,1),L(Ei,E.LineCap.ROUND,2),L(Ei,E.LineCap.SQUARE,3),Ei),yi=function(e){U(n,e);var t=X(n);function n(){return M(this,n),t.apply(this,arguments)}return b(n,[{key:"shouldMerge",value:function(e,t){var r=j(w(n.prototype),"shouldMerge",this).call(this,e,t);if(!r)return!1;var i=this.instance;if(i.nodeName===E.Shape.LINE){var o=i.parsedStyle.stroke,a=e.parsedStyle.stroke;if(o.toString()!==a.toString())return!1}return!0}},{key:"createMaterial",value: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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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;\n// out vec2 v_Normal;\n\nvoid main() {\n mat4 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 * 0.5 + 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 float isBillboard = a_Dash.w;\n if (isBillboard < 0.5) {\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 * strokeWidth * 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(strokeWidth / 2.0);\n }\n\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n // clip space\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 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + strokeWidth * (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 }\n\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;\n// in vec2 v_Normal;\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_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n // float blur = 1. - smoothstep(0.98, 1., length(v_Normal));\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 outputColor.a = outputColor.a\n // * blur\n * u_Opacity * u_StrokeOpacity\n * ceil(mod(v_Dash.x + u_dash_offset, u_dash_array) - (u_dash_array * u_dash_ratio));\n }\n}",this.material.defines=D(D({},this.material.defines),ui(Ri))}},{key:"createGeometry",value:function(e){var t=this;j(w(n.prototype),"createGeometry",this).call(this,e);var r=[],i=[],o=[],a=[],u=0;e.forEach((function(e){var n=e.parsedStyle,s=n.x1,l=n.y1,c=n.x2,f=n.y2,d=n.z1,h=n.z2,_=n.defX,p=n.defY,E=n.lineCap,v=n.isBillboard,R=t.calcDash(e),T=R.dashOffset,m=R.dashSegmentPercent,y=R.dashRatioInEachSegment;i.push(mi[E.value]),o.push(T,m,y,v?1:0),r.push(s.value-_,l.value-p,d.value,c.value-_,f.value-p,h.value),a.push(0+u,2+u,1+u,0+u,3+u,2+u),u+=4})),this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:si.POSITION,byteStride:20,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGB,bufferByteOffset:0,location:Ri.POSITION,divisor:0},{format:Oe.F32_RG,bufferByteOffset:12,location:Ri.UV,divisor:0}],data:new Float32Array(Ti)}),this.geometry.setVertexBuffer({bufferIndex:vi.POINT,byteStride:24,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGB,bufferByteOffset:0,location:Ri.POINTA,divisor:1},{format:Oe.F32_RGB,bufferByteOffset:12,location:Ri.POINTB,divisor:1}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:vi.CAP,byteStride:4,frequency:_e.PerInstance,attributes:[{format:Oe.F32_R,bufferByteOffset:0,location:Ri.CAP,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:vi.DASH,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:Ri.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(j(w(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"x1"===r||"y1"===r||"x2"===r||"y2"===r||"z1"===r||"z2"===r){var a=[];e.forEach((function(e){var t=e.parsedStyle,n=t.x1,r=t.y1,i=t.x2,o=t.y2,u=t.z1,s=t.z2,l=t.defX,c=t.defY;a.push(n.value-l,r.value-c,u.value,i.value-l,o.value-c,s.value)})),this.geometry.updateVertexBuffer(vi.POINT,Ri.POINTA,t,new Uint8Array(new Float32Array(a).buffer))}else if("lineDashOffset"===r||"lineDash"===r){var u=[];e.forEach((function(e){var t=o.calcDash(e),n=t.dashOffset,r=t.dashSegmentPercent,i=t.dashRatioInEachSegment;u.push(n,r,i,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(vi.DASH,Ri.DASH,t,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===r){var s=[];e.forEach((function(e){var t=e.parsedStyle.lineCap;s.push(mi[t])})),this.geometry.updateVertexBuffer(vi.CAP,Ri.CAP,t,new Uint8Array(new Float32Array(s).buffer))}}},{key:"calcDash",value:function(e){var t=e.parsedStyle,n=t.lineDash,r=t.lineDashOffset,i=e.getTotalLength(),o=0,a=1,u=0;if(n&&n.length){o=(r&&r.value||0)/i;var s=n.reduce((function(e,t){return e+t.value}),0);a=s/i,u=n[1].value/s}return{dashOffset:o,dashSegmentPercent:a,dashRatioInEachSegment:u}}}]),n}(fi);function gi(e,t,n,r){var i=e-n,o=t-r;return Math.sqrt(i*i+o*o)}yi=l([Object(v.injectable)()],yi);var Ai=function(e,t,n,r,i){return{x:(1-i)*e+i*n,y:(1-i)*t+i*r}};function Si(e,t,n,r,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*n*i*i*o+r*i*i*i}function Ci(e,t,n,r,i,o,a,u,s){var l=Si(e,n,i,a,s),c=Si(t,r,o,u,s),f=Ai(e,t,n,r,s),d=Ai(n,r,i,o,s),h=Ai(i,o,a,u,s),_=Ai(f.x,f.y,d.x,d.y,s),p=Ai(d.x,d.y,h.x,h.y,s);return[[e,t,f.x,f.y,_.x,_.y,l,c],[l,c,p.x,p.y,h.x,h.y,a,u]]}function Oi(e,t,n,r,i,o,a,u,s){if(0===s)return function(e,t){for(var n=0,r=e.length,i=0;i<r;i++){n+=gi(e[i],t[i],e[(i+1)%r],t[(i+1)%r])}return n/2}([e,n,i,a],[t,r,o,u]);var l=Ci(e,t,n,r,i,o,a,u,.5),c=p(p([],_(l[0]),!1),[s-1],!1),f=p(p([],_(l[1]),!1),[s-1],!1);return Oi.apply(void 0,p([],_(c),!1))+Oi.apply(void 0,p([],_(f),!1))}var Ii,Ni=function(e,t,n,r,i,o,a,u){return Oi(e,t,n,r,i,o,a,u,3)};!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"}(Ii||(Ii={}));var Pi,Di,xi;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(Pi||(Pi={})),function(e){e[e.PREV=0]="PREV",e[e.POINT1=1]="POINT1",e[e.POINT2=2]="POINT2",e[e.NEXT=3]="NEXT",e[e.VERTEX_JOINT=4]="VERTEX_JOINT",e[e.VERTEX_NUM=5]="VERTEX_NUM",e[e.TRAVEL=6]="TRAVEL"}(Di||(Di={})),function(e){e.MODEL_MATRIX="u_ModelMatrix",e.COLOR="u_Color",e.STROKE_COLOR="u_StrokeColor",e.STROKE_WIDTH="u_StrokeWidth",e.INCREASED_LINE_WIDTH_FOR_HIT_TESTING="u_IncreasedLineWidthForHitTesting",e.OPACITY="u_Opacity",e.FILL_OPACITY="u_FillOpacity",e.STROKE_OPACITY="u_StrokeOpacity",e.EXPAND="u_Expand",e.MITER_LIMIT="u_MiterLimit",e.SCALE_MODE="u_ScaleMode",e.ALIGNMENT="u_Alignment",e.PICKING_COLOR="u_PickingColor",e.DASH="u_Dash",e.GAP="u_Gap",e.DASH_OFFSET="u_DashOffset",e.VISIBLE="u_Visible",e.Z_INDEX="u_ZIndex"}(xi||(xi={}));var Bi=function(e){U(n,e);var t=X(n);function n(){return M(this,n),t.apply(this,arguments)}return b(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;j(w(n.prototype),"updateAttribute",this).call(this,e,t,r,i),e.forEach((function(e){var t=e.parsedStyle,n=t.stroke,a=t.opacity,u=t.fillOpacity,s=t.strokeOpacity,l=t.lineWidth,c=t.increasedLineWidthForHitTesting,f=t.anchor,d=t.lineDash,h=t.lineDashOffset,_=t.visibility;if("lineJoin"===r||"lineCap"===r||e.nodeName===E.Shape.CIRCLE&&"r"===r||e.nodeName===E.Shape.ELLIPSE&&("rx"===r||"ry"===r)||e.nodeName===E.Shape.RECT&&("width"===r||"height"===r||"radius"===r)||e.nodeName===E.Shape.LINE&&("x1"===r||"y1"===r||"x2"===r||"y2"===r)||e.nodeName===E.Shape.POLYLINE&&"points"===r||e.nodeName===E.Shape.POLYGON&&"points"===r||e.nodeName===E.Shape.PATH&&"path"===r)o.material.geometryDirty=!0,o.material.programDirty=!0;else if("stroke"===r){var p=[0,0,0,0];n instanceof E.CSSRGB&&(p=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),o.material.setUniforms(L({},xi.STROKE_COLOR,p))}else if("opacity"===r)o.material.setUniforms(L({},xi.OPACITY,a.value));else if("fillOpacity"===r)o.material.setUniforms(L({},xi.FILL_OPACITY,u.value));else if("strokeOpacity"===r)o.material.setUniforms(L({},xi.STROKE_OPACITY,s.value));else if("lineWidth"===r)o.material.setUniforms(L({},xi.STROKE_WIDTH,l.value));else if("increasedLineWidthForHitTesting"===r)o.material.setUniforms(L({},xi.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,c.value));else if("anchor"===r||"modelMatrix"===r){var v=0,R=0,T=e.getGeometryBounds();if(T){var m=T.halfExtents;v=-m[0]*f[0].value*2,R=-m[1]*f[1].value*2}var y=pr();Tr(y,e.getWorldTransform(),Rr(y,mr(v,R,0))),o.material.setUniforms(L({},xi.MODEL_MATRIX,y))}else if("visibility"===r)o.material.setUniforms(L({},xi.VISIBLE,"visible"===_.value?1:0));else if("lineDash"===r){var g;o.material.setUniforms((L(g={},xi.DASH,d[0].value||0),L(g,xi.GAP,d[1].value||0),g))}else if("lineDashOffset"===r)o.material.setUniforms(L({},xi.DASH_OFFSET,h&&h.value||0));else if("pointerEvents"===r){var A,S=i&&e.isInteractive()&&(null===(A=e.renderable3D)||void 0===A?void 0:A.encodedPickingColor)||[0,0,0];o.material.setUniforms(L({},xi.PICKING_COLOR,S))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(L({},xi.Z_INDEX,.005*t))}},{key:"createMaterial",value:function(e){var t,n,r,i;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(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 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\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\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\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\nvoid main() {\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\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 next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\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 gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\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};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\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 if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * 0.5 + u_DashOffset, u_Dash + u_Gap) - (u_Gap * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * 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 outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n }\n}",this.material.defines=D(D({},this.material.defines),ui(Di));var o=e[0],a=o.parsedStyle,u=a.fill,s=a.stroke,l=a.opacity,c=a.fillOpacity,f=a.strokeOpacity,d=a.lineWidth,h=a.increasedLineWidthForHitTesting,_=a.anchor,p=a.lineDash,v=a.lineDashOffset,R=a.visibility,T=[0,0,0,0];u instanceof E.CSSRGB&&(T=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var m=[0,0,0,0];s instanceof E.CSSRGB&&(m=[Number(s.r)/255,Number(s.g)/255,Number(s.b)/255,Number(s.alpha)]);var y=o.isInteractive()&&(null===(t=o.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0],g=0,A=0,S=o.getGeometryBounds();if(S){var C=S.halfExtents;g=-C[0]*_[0].value*2,A=-C[1]*_[1].value*2}var O=pr();Tr(O,o.getWorldTransform(),Rr(O,mr(g,A,0))),this.material.setUniforms((L(i={},xi.MODEL_MATRIX,O),L(i,xi.COLOR,T),L(i,xi.STROKE_COLOR,m),L(i,xi.STROKE_WIDTH,d.value),L(i,xi.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,h.value),L(i,xi.OPACITY,l.value),L(i,xi.FILL_OPACITY,c.value),L(i,xi.STROKE_OPACITY,f.value),L(i,xi.EXPAND,1),L(i,xi.MITER_LIMIT,5),L(i,xi.SCALE_MODE,1),L(i,xi.ALIGNMENT,.5),L(i,xi.PICKING_COLOR,y),L(i,xi.DASH,p&&(null===(n=p[0])||void 0===n?void 0:n.value)||0),L(i,xi.GAP,p&&(null===(r=p[1])||void 0===r?void 0:r.value)||0),L(i,xi.DASH_OFFSET,v&&v.value||0),L(i,xi.VISIBLE,"visible"===R.value?1:0),L(i,xi.Z_INDEX,.005*o.sortable.renderOrder),i)),this.material.cullMode=oe.None}},{key:"createGeometry",value:function(e){var t=Fi(e[0]),n=t.pointsBuffer,r=t.travelBuffer,i=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:Pi.PACKED,byteStride:48,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,byteStride:12,location:Di.PREV,divisor:1},{format:Oe.F32_RG,bufferByteOffset:12,byteStride:12,location:Di.POINT1,divisor:1},{format:Oe.F32_R,bufferByteOffset:20,byteStride:12,location:Di.VERTEX_JOINT,divisor:1},{format:Oe.F32_RG,bufferByteOffset:24,byteStride:12,location:Di.POINT2,divisor:1},{format:Oe.F32_RG,bufferByteOffset:36,byteStride:12,location:Di.NEXT,divisor:1}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:Pi.VERTEX_NUM,byteStride:4,frequency:_e.PerInstance,attributes:[{format:Oe.F32_R,bufferByteOffset:0,byteStride:4,location:Di.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Pi.TRAVEL,byteStride:4,frequency:_e.PerInstance,attributes:[{format:Oe.F32_R,bufferByteOffset:0,byteStride:4,location:Di.TRAVEL,divisor:1}],data:new Float32Array(r)}),this.geometry.vertexCount=15,this.geometry.instancedCount=i,this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2,4,6,5,4,7,6,4,7,8]))}}]),n}(fi);function Mi(e,t,n,r,i,o,a){var u=a[a.length-2],s=a[a.length-1];a.length-=2;var l=function(e){var t=Math.ceil(e/10);t<8?t=8:t>2048&&(t=2048);return t}(Ni(u,s,e,t,n,r,i,o)),c=0,f=0,d=0,h=0,_=0;a.push(u,s);for(var p=1,E=0;p<=l;++p)d=(f=(c=1-(E=p/l))*c)*c,_=(h=E*E)*E,a.push(d*u+3*f*E*e+3*c*h*n+_*i,d*s+3*f*E*t+3*c*h*r+_*o)}Bi=l([Object(v.injectable)()],Bi);function Fi(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.parsedStyle,r=n.lineCap,i=n.lineJoin,o=e.parsedStyle,a=o.defX,u=o.defY,s=[],l=[];if(e.nodeName===E.Shape.POLYLINE||e.nodeName===E.Shape.POLYGON){if(s=e.parsedStyle.points.points.reduce((function(e,t){return e.push(t[0]-a,t[1]-u),e}),[]),e.nodeName===E.Shape.POLYGON){if(t)return l=S()(s,[],2),{pointsBuffer:s,travelBuffer:[],triangles:l,instancedCount:Math.round(s.length/2)};var c;s.push(s[0],s[1]),(c=s).push.apply(c,z(Ui(s[0],s[1],s[2],s[3])))}}else if(e.nodeName===E.Shape.PATH||e.nodeName===E.Shape.CIRCLE||e.nodeName===E.Shape.ELLIPSE||e.nodeName===E.Shape.RECT){var f;e.nodeName!==E.Shape.PATH?(f=Object(E.parsePath)(Object(E.convertToPath)(e)),a=f.rect.x,u=f.rect.y):f=e.parsedStyle.path;var d=f,h=d.zCommandIndexes,_=z(f.curve).map((function(e,t){return h.includes(t)?["Z"]:e})),p=-1;if(_.forEach((function(t){var n=K(t),r=n[0],i=n.slice(1);if("M"===r)p=s.length,s.push(i[0]-a,i[1]-u);else if("C"===r)Mi(i[0]-a,i[1]-u,i[2]-a,i[3]-u,i[4]-a,i[5]-u,s);else if("Z"===r&&(e.nodeName===E.Shape.PATH||e.nodeName===E.Shape.RECT)){var o;s.push(s[p],s[p+1]),(o=s).push.apply(o,z(Ui(s[p],s[p+1],s[p+2],s[p+3])))}})),t)return l=S()(s,[],2),{pointsBuffer:s,travelBuffer:[],triangles:l,instancedCount:Math.round(s.length/2)}}var v=bi(i.value),R=Li(r.value),T=R;R===Ii.CAP_ROUND&&(T=Ii.JOINT_CAP_ROUND),R===Ii.CAP_BUTT&&(T=Ii.JOINT_CAP_BUTT),R===Ii.CAP_SQUARE&&(T=Ii.JOINT_CAP_SQUARE);for(var m=3*(Math.round(0)+2),y=0,g=[],A=[],C=0;C<s.length;C+=2)C>1&&(y+=Math.sqrt(Math.pow(s[C]-s[C-2],2)+Math.pow(s[C+1]-s[C+1-2],2))),A.push(y),g[m++]=s[C],g[m++]=s[C+1],g[m]=v,0==C&&R!==Ii.CAP_ROUND&&(g[m]+=R),C+4>=s.length?g[m]+=T-v:C+2>=s.length&&(g[m]=0),m++;g[m++]=s[s.length-4],g[m++]=s[s.length-3],g[m++]=0,g[0]=s[0],g[1]=s[1],g[2]=0,g[3]=s[2],g[4]=s[3],g[5]=R===Ii.CAP_ROUND?R:0;var O=Math.round(s.length/2);return{pointsBuffer:g,travelBuffer:A,triangles:l,instancedCount:O}}function bi(e){var t;switch(e){case E.LineJoin.BEVEL:t=Ii.JOINT_BEVEL;break;case E.LineJoin.ROUND:t=Ii.JOINT_ROUND;break;default:t=Ii.JOINT_MITER}return t}function Li(e){var t;switch(e){case E.LineCap.SQUARE:t=Ii.CAP_SQUARE;break;case E.LineCap.ROUND:t=Ii.CAP_ROUND;break;default:t=Ii.CAP_BUTT}return t}function Ui(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t,i=[n-e,r-t],o=.01;return[e+i[0]*o,t+i[1]*o]}var wi=function(e){U(n,e);var t=X(n);function n(){return M(this,n),t.apply(this,arguments)}return b(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"createGeometry",value:function(e){var t=Fi(e[0],!0),n=t.triangles,r=t.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:si.POSITION,byteStride:8,frequency:_e.PerVertex,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,byteStride:8,location:li.POSITION}],data:new Float32Array(r)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))}},{key:"createMaterial",value:function(e){var t,n;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(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n\nlayout(location = POSITION) in vec2 a_Position;\n\nvoid main() {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * u_ModelMatrix * vec4(a_Position, u_ZIndex, 1.0);\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};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * 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_Color;\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}";var r=e[0],i=r.parsedStyle,o=i.fill,a=i.opacity,u=i.fillOpacity,s=i.anchor,l=i.visibility,c=[0,0,0,0];o instanceof E.CSSRGB&&(c=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)]);var f=r.isInteractive()&&(null===(t=r.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0],d=0,h=0,_=r.getGeometryBounds();if(_){var p=_.halfExtents;d=-p[0]*s[0].value*2,h=-p[1]*s[1].value*2}var v=pr();Tr(v,r.getWorldTransform(),Rr(v,mr(d,h,0))),this.material.setUniforms((L(n={},xi.MODEL_MATRIX,v),L(n,xi.COLOR,c),L(n,xi.PICKING_COLOR,f),L(n,xi.OPACITY,a.value),L(n,xi.FILL_OPACITY,u.value),L(n,xi.VISIBLE,"visible"===l.value?1:0),L(n,xi.Z_INDEX,.005*r.sortable.renderOrder),n))}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;j(w(n.prototype),"updateAttribute",this).call(this,e,t,r,i),e.forEach((function(e){var t=e.parsedStyle,n=t.fill,a=t.opacity,u=t.fillOpacity,s=t.anchor,l=t.visibility;if("lineJoin"===r||"lineCap"===r||e.nodeName===E.Shape.RECT&&("width"===r||"height"===r||"radius"===r)||e.nodeName===E.Shape.LINE&&("x1"===r||"y1"===r||"x2"===r||"y2"===r)||e.nodeName===E.Shape.POLYLINE&&"points"===r||e.nodeName===E.Shape.POLYGON&&"points"===r||e.nodeName===E.Shape.PATH&&"path"===r)o.material.geometryDirty=!0,o.material.programDirty=!0;else if("fill"===r){var c=[0,0,0,0];n instanceof E.CSSRGB&&(c=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),o.material.setUniforms(L({},xi.COLOR,c))}else if("opacity"===r)o.material.setUniforms(L({},xi.OPACITY,a.value));else if("fillOpacity"===r)o.material.setUniforms(L({},xi.FILL_OPACITY,u.value));else if("anchor"===r||"modelMatrix"===r){var f=0,d=0,h=e.getGeometryBounds();if(h){var _=h.halfExtents;f=-_[0]*s[0].value*2,d=-_[1]*s[1].value*2}var p=pr();Tr(p,e.getWorldTransform(),Rr(p,mr(f,d,0))),o.material.setUniforms(L({},xi.MODEL_MATRIX,p))}else if("visibility"===r)o.material.setUniforms(L({},xi.VISIBLE,"visible"===l.value?1:0));else if("pointerEvents"===r){var v,R=i&&e.isInteractive()&&(null===(v=e.renderable3D)||void 0===v?void 0:v.encodedPickingColor)||[0,0,0];o.material.setUniforms(L({},xi.PICKING_COLOR,R))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(L({},xi.Z_INDEX,.005*t))}}]),n}(fi);wi=l([Object(v.injectable)()],wi);var Gi=function(e){U(n,e);var t=X(n);function n(){return M(this,n),t.apply(this,arguments)}return b(n,[{key:"shouldMerge",value:function(e,t){var r=j(w(n.prototype),"shouldMerge",this).call(this,e,t);return!!r&&this.instance.parsedStyle.img===e.parsedStyle.img}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.img;this.material.defines=D(D({},this.material.defines),{},{USE_UV:!0,USE_MAP:!0}),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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\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\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 outputColor.a = outputColor.a * u_Opacity;\n }\n}";var n=this.texturePool.getOrCreateTexture(this.device,t);n.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0}))})),this.material.setUniforms({u_Map:n})}},{key:"createGeometry",value:function(e){j(w(n.prototype),"createGeometry",this).call(this,e);var t=[],r=[],i=[];e.forEach((function(e,n){var o=4*n,a=e.parsedStyle,u=a.width,s=a.height;t.push(u.value,s.value),r.push(0,0,1,0,1,1,0,1),i.push(0+o,2+o,1+o,0+o,3+o,2+o)})),this.geometry.setIndexBuffer(new Uint32Array(i)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:si.POSITION,byteStride:8,frequency:_e.PerInstance,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,location:li.POSITION}],data:new Float32Array(t)}),this.geometry.setVertexBuffer({bufferIndex:si.UV,byteStride:8,frequency:_e.PerVertex,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,location:li.UV}],data:new Float32Array(r)})}},{key:"updateAttribute",value:function(e,t,r,i){if(j(w(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"width"===r||"height"===r){var o=[];e.forEach((function(e){var t=e.parsedStyle,n=t.width,r=t.height;o.push(n.value,r.value)})),this.geometry.updateVertexBuffer(si.POSITION,li.POSITION,t,new Uint8Array(new Float32Array(o).buffer))}else if("img"===r){var a=this.texturePool.getOrCreateTexture(this.device,i);a.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0}))})),this.material.setUniforms({u_Map:a})}}}]),n}(fi);function ki(e,t,n,r){var i=t.width,o=t.height;if(r){if(r.length!==i*o*n)throw new RangeError("mismatched image size")}else r=new Uint8Array(i*o*n);return e.width=i,e.height=o,e.data=r,e}function Vi(e,t,n,r,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.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||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,u=t.data,s=0;s<i.height;s++)for(var l=((n.y+s)*e.width+n.x)*o,c=((r.y+s)*t.width+r.x)*o,f=0;f<i.width*o;f++)u[c+f]=a[l+f];return t}Gi=l([Object(v.injectable)()],Gi);var Wi=function(){function e(t,n){M(this,e),this.width=void 0,this.height=void 0,this.data=void 0,ki(this,t,1,n)}return b(e,[{key:"resize",value:function(e){!function(e,t,n){var r=t.width,i=t.height;if(r!==e.width||i!==e.height){var o=ki({},{width:r,height:i},n);Vi(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,i)},n),e.width=r,e.height=i,e.data=o.data}}(this,e,1)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,n,r,i){Vi(e,t,n,r,i,1)}}]),e}();var Xi=b((function e(t){M(this,e),this.image=void 0,this.positions=void 0;var n={},r=[];for(var i in t){var o=t[i],a=n[i]={};for(var u in o){var s=o[+u];if(s&&0!==s.bitmap.width&&0!==s.bitmap.height){var l={x:0,y:0,w:s.bitmap.width+2,h:s.bitmap.height+2};r.push(l),a[u]={rect:l,metrics:s.metrics}}}}var c=function(e){var t,n=0,r=0,i=ee(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;n+=o.w*o.h,r=Math.max(r,o.w)}}catch(e){i.e(e)}finally{i.f()}e.sort((function(e,t){return t.h-e.h}));var a,u=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),r),h:1/0}],s=0,l=0,c=ee(e);try{for(c.s();!(a=c.n()).done;)for(var f=a.value,d=u.length-1;d>=0;d--){var h=u[d];if(!(f.w>h.w||f.h>h.h)){if(f.x=h.x,f.y=h.y,l=Math.max(l,f.y+f.h),s=Math.max(s,f.x+f.w),f.w===h.w&&f.h===h.h){var _=u.pop();d<u.length&&(u[d]=_)}else f.h===h.h?(h.x+=f.w,h.w-=f.w):f.w===h.w?(h.y+=f.h,h.h-=f.h):(u.push({x:h.x+f.w,y:h.y,w:h.w-f.w,h:f.h}),h.y+=f.h,h.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:s,h:l,fill:n/(s*l)||0}}(r),f=c.w,d=c.h,h=new Wi({width:f||1,height:d||1});for(var _ in t){var p=t[_];for(var E in p){var v=p[+E];if(v&&0!==v.bitmap.width&&0!==v.bitmap.height){var R=n[_][E].rect;Wi.copy(v.bitmap,h,{x:0,y:0},{x:R.x+1,y:R.y+1},v.bitmap)}}}this.image=h,this.positions=n}));function Hi(){for(var e=[],t=32;t<128;t++)e.push(String.fromCharCode(t));return e}var ji=function(){function e(){M(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphAtlas=void 0,this.glyphMap={},this.glyphAtlasTexture=void 0}return b(e,[{key:"getMap",value:function(){return this.glyphMap}},{key:"getAtlas",value:function(){return this.glyphAtlas}},{key:"getAtlasTexture",value:function(){return this.glyphAtlasTexture}},{key:"layout",value:function(e,t,n,r,i,o,a){var u=this,s=[],l=o,c=a,f="right"===r||"end"===r?1:"left"===r||"start"===r?0:.5;return e.forEach((function(e){var r=s.length;Array.from(e).forEach((function(e){var n=u.glyphMap[t],r=e.charCodeAt(0),o=n&&n[r];o&&(s.push({glyph:r,x:l,y:c,scale:1,fontStack:t}),l+=o.metrics.advance+i)}));for(var o=l-i,a=r;a<s.length;a++)s[a].x=s[a].x-f*o;l=0,c+=n})),s}},{key:"generateAtlas",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,u=[];this.glyphMap[t]||(u=Hi());var s=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(o.split(""))).forEach((function(e){-1===s.indexOf(e.charCodeAt(0).toString())&&u.push(e)})),u.length){var l=u.map((function(o){return e.generateSDF(t,n,r,i,o)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=D(D({},this.glyphMap[t]),l),this.glyphAtlas=new Xi(this.glyphMap);var c=this.glyphAtlas.image,f=c.width,d=c.height,h=c.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=a.createTexture(D(D({},Pe(Oe.ALPHA,f,d,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([h],0)}}},{key:"generateSDF",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,o=i.charCodeAt(0),a=this.sdfGeneratorCache[e];a||(a=this.sdfGeneratorCache[e]=new O({fontSize:24,fontFamily:t,fontWeight:n,fontStyle:r,buffer:3,radius:8,cutoff:.25})),this.textMetricsCache[e]||(this.textMetricsCache[e]={}),this.textMetricsCache[e][i]||(this.textMetricsCache[e][i]=a.ctx.measureText(i).width);var u=a.draw(i),s=u.data,l=u.width,c=u.height,f=u.glyphWidth,d=u.glyphHeight,h=u.glyphLeft,_=u.glyphTop,p=u.glyphAdvance;return{id:o,bitmap:new Wi({width:l,height:c},s),metrics:{width:f,height:d,left:h,top:_-24+3,advance:p}}}}]),e}();ji=l([Object(v.injectable)()],ji);var Yi,Ki;!function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(Yi||(Yi={})),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"}(Ki||(Ki={}));var zi=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).glyphManager=void 0,e}return b(n,[{key:"shouldMerge",value:function(e,t){var r=j(w(n.prototype),"shouldMerge",this).call(this,e,t);if(!r)return!1;if(this.index!==t)return!1;var i=this.instance;return i.parsedStyle.fontSize.value===e.parsedStyle.fontSize.value&&(i.parsedStyle.metrics.font===e.parsedStyle.metrics.font&&!["fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(t){return i.parsedStyle[t]!==e.parsedStyle[t]})))}},{key:"createGeometry",value:function(e){var t=this,n=this.instance.parsedStyle,r=n.textBaseline,i=n.fontSize,o=n.letterSpacing,a=void 0===o?0:o,u=24/i.value,s=[],l=[],c=[],f=0;e.forEach((function(e){var n=e.parsedStyle,i=n.metrics,o=n.dx,d=n.dy,h=i.font,_=i.lines,p=i.height,v=i.lineHeight,R=0,T=0;o&&o.unit===E.UnitType.kPixels&&(R+=o.value),d&&d.unit===E.UnitType.kPixels&&(T+=d.value);var m=0;"middle"===r.value?m=-p/2:"bottom"===r.value?m=-p:"top"===r.value||"hanging"===r.value?m=0:"alphabetic"===r.value?m=.25*v-p:"ideographic"===r.value&&(m=-p);var y=t.glyphManager.getAtlas(),g=t.buildTextBuffers({object:e,lines:_,fontStack:h,lineHeight:u*v,offsetX:u*R,offsetY:u*(m+T),letterSpacing:u*a,glyphAtlas:y,indicesOffset:f}),A=g.indicesOffset,S=g.indexBuffer,C=g.charUVOffsetBuffer,O=g.charPackedBuffer;f=A,c.push.apply(c,z(O)),l.push.apply(l,z(C)),s.push.apply(s,z(S))})),this.geometry.vertexCount=s.length,this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.setVertexBuffer({bufferIndex:0,byteStride:144,frequency:_e.PerVertex,attributes:[{format:Oe.F32_RGBA,bufferByteOffset:0,location:li.MODEL_MATRIX0},{format:Oe.F32_RGBA,bufferByteOffset:16,location:li.MODEL_MATRIX1},{format:Oe.F32_RGBA,bufferByteOffset:32,location:li.MODEL_MATRIX2},{format:Oe.F32_RGBA,bufferByteOffset:48,location:li.MODEL_MATRIX3},{format:Oe.F32_RGBA,bufferByteOffset:64,location:li.COLOR},{format:Oe.F32_RGBA,bufferByteOffset:80,location:li.STROKE_COLOR},{format:Oe.F32_RGBA,bufferByteOffset:96,location:li.PACKED_STYLE1},{format:Oe.F32_RGBA,bufferByteOffset:112,location:li.PACKED_STYLE2},{format:Oe.F32_RGBA,bufferByteOffset:128,location:li.PICKING_COLOR}],data:new Float32Array(c)}),this.geometry.setVertexBuffer({bufferIndex:1,byteStride:16,frequency:_e.PerVertex,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,location:Yi.TEX},{format:Oe.F32_RG,bufferByteOffset:8,location:Yi.OFFSET}],data:new Float32Array(l)})}},{key:"createMaterial",value: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(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\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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_UV;\nout float v_GammaScale;\n\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n v_UV = a_Tex / u_SDFMapSize;\n\n float fontScale = u_FontSize / 24.;\n\n gl_Position = project(vec4(a_Offset * fontScale, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n v_GammaScale = gl_Position.w;\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};\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\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nin vec2 v_UV;\nin float v_GammaScale;\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\n float dist = texture(SAMPLER_2D(u_SDFMap), v_UV).a;\n\n float EDGE_GAMMA = 0.105 / u_DevicePixelRatio;\n float fontScale = u_FontSize / 24.0;\n highp float gamma = EDGE_GAMMA / (fontScale * u_GammaScale);\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 gamma = (u_StrokeBlur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_GammaScale);\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = gamma * v_GammaScale;\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 < 0.001) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=oe.Back,this.material.defines=D(D({},this.material.defines),ui(Yi));var n=this.instance.parsedStyle,r=n.fontSize,i=n.fontFamily,o=void 0===i?"":i,a=n.fontWeight,u=n.fontStyle,s=n.metrics.font,l=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(s,o,a.toString(),u.toString(),l,this.device);var c=this.glyphManager.getAtlasTexture(),f=this.glyphManager.getAtlas();this.device.setResourceName(c,"TextSDF Texture");var d=f.image,h=d.width,_=d.height;this.material.setUniforms((L(t={},Ki.SDF_MAP,c),L(t,Ki.SDF_MAP_SIZE,[h,_]),L(t,Ki.FONT_SIZE,r.value),L(t,Ki.GAMMA_SCALE,1),L(t,Ki.STROKE_BLUR,.2),L(t,Ki.HAS_STROKE,this.index),t))}},{key:"changeRenderOrder",value:function(e,t){this.material&&(this.material.programDirty=!0,this.material.geometryDirty=!0)}},{key:"updateAttribute",value:function(e,t,n,r){"text"===n||"fontFamily"===n||"fontSize"===n||"fontWeight"===n||"fontStyle"===n||"fontVariant"===n||"textBaseline"===n||"letterSpacing"===n||"wordWrapWidth"===n||"lineHeight"===n||"wordWrap"===n||"textAlign"===n||"modelMatrix"===n||"visibility"===n||"dx"===n||"dy"===n?(this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0):"fill"!==n&&"fillOpacity"!==n&&"stroke"!==n&&"strokeOpacity"!==n&&"opacity"!==n&&"lineWidth"!==n&&"visibility"!==n&&"pointerEvents"!==n||(this.material.geometryDirty=!0)}},{key:"buildTextBuffers",value:function(e){var t,n=e.object,r=e.lines,i=e.fontStack,o=e.lineHeight,a=e.letterSpacing,u=e.offsetX,s=e.offsetY,l=e.glyphAtlas,c=e.indicesOffset,f=n.parsedStyle,d=f.textAlign,h=f.fill,_=f.stroke,p=f.opacity,v=f.fillOpacity,R=f.strokeOpacity,T=f.lineWidth,m=f.visibility,y=[0,0,0,0];h instanceof E.CSSRGB&&(y=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]);var g=[0,0,0,0];_ instanceof E.CSSRGB&&(g=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)]);var A=n.isInteractive()&&(null===(t=n.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0],S=Er(pr(),n.getWorldTransform()),C=[],O=[],I=[],N=c;return function(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var u=a.rect;if(u){var s=a.metrics.advance*i.scale/2,l=[i.x+s,i.y],c=(a.metrics.left-4)*i.scale-s+l[0],f=(-a.metrics.top-4)*i.scale+l[1],d=c+u.w*i.scale,h=f+u.h*i.scale,_={x:c,y:f},p={x:d,y:f},E={x:c,y:h},v={x:d,y:h};n.push({tl:_,tr:p,bl:E,br:v,tex:u,glyphOffset:[0,0]})}}}return n}(this.glyphManager.layout(r,i,o,d.value,a,u,s),l.positions).forEach((function(e){var t=[].concat(z(S),z(y),z(g),[p.value,v.value,R.value,T.value,"visible"===m.value?1:0,0,0,0],z(A),[.005*n.sortable.renderOrder]);C.push.apply(C,z(t).concat(z(t),z(t),z(t))),O.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),O.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),O.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),O.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),I.push(0+N,2+N,1+N),I.push(2+N,0+N,3+N),N+=4})),{indexBuffer:I,charUVOffsetBuffer:O,charPackedBuffer:C,indicesOffset:N}}}]),n}(fi);l([Object(v.inject)(ji),c("design:type",ji)],zi.prototype,"glyphManager",void 0),zi=l([Object(v.injectable)()],zi);var qi=["style"],Zi=function(e){U(n,e);var t=X(n);function n(e){var r,i=e.style,o=k(e,qi);return M(this,n),(r=t.call(this,D({type:n.tag,style:D({lineWidth:0},i)},o))).cullable.enable=!1,r.style.geometry.meshes.push(V(r)),r.style.material.meshes.push(V(r)),r}return b(n,[{key:"destroy",value:function(){j(w(n.prototype),"destroy",this).call(this);var e=this.style.geometry.meshes,t=e.indexOf(this);e.splice(t,1),t=(e=this.style.material.meshes).indexOf(this),e.splice(t,1)}}]),n}(E.DisplayObject);Zi.tag="mesh";var Qi=function(e){U(n,e);var t=X(n);function n(){return M(this,n),t.apply(this,arguments)}return b(n,[{key:"shouldMerge",value:function(e,t){var r=j(w(n.prototype),"shouldMerge",this).call(this,e,t);return!!r&&(this.instance.nodeName!==Zi.tag||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,r,i){j(w(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i)}},{key:"createMaterial",value:function(e){var t=this.instance.parsedStyle.material;this.material=t}},{key:"createGeometry",value:function(e){var t=this.instance.parsedStyle.geometry;this.geometry=t,j(w(n.prototype),"createGeometry",this).call(this,e),this.geometry.build(e)}}]),n}(fi);Qi=l([Object(v.injectable)()],Qi);var Ji=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[pi,Bi],e}return b(n,[{key:"shouldSubmitRenderInst",value:function(e,t){if(0===t&&e.parsedStyle.fill.isNone)return!1;return 1!==t||this.needDrawStrokeSeparately(e)}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,n=t.fill,r=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,u=n&&!n.isNone,s=r&&!r.isNone,l=i&&i.length&&i.every((function(e){return 0!==e.value}));return!u||s&&o.value>0&&(a.value<1||l)}}]),n}(ni);Ji=l([Object(v.injectable)({token:[{token:Qr,named:E.Shape.CIRCLE},{token:Qr,named:E.Shape.ELLIPSE}]})],Ji);var $i=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[wi,Bi],e}return b(n,[{key:"shouldSubmitRenderInst",value:function(e,t){var n=e.parsedStyle,r=n.fill,i=n.strokeOpacity,o=n.lineDash,a=n.lineWidth,u=e.nodeName;if(0===t&&(e.nodeName===E.Shape.POLYLINE||r.isNone))return!1;if(1===t){if(0===i.value||0===a.value)return!1;var s=o&&o.length&&o.every((function(e){return 0!==e.value}));if(u===E.Shape.CIRCLE||u===E.Shape.ELLIPSE)return s}return!0}}]),n}(ni);$i=l([Object(v.injectable)({token:[{token:Qr,named:E.Shape.POLYLINE},{token:Qr,named:E.Shape.PATH},{token:Qr,named:E.Shape.POLYGON},{token:Qr,named:E.Shape.RECT}]})],$i);var eo=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[],e}return b(n,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),n}(ni);eo=l([Object(v.injectable)({token:[{token:Qr,named:E.Shape.GROUP}]})],eo);var to=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Gi],e}return b(n,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),n}(ni);to=l([Object(v.injectable)({token:[{token:Qr,named:E.Shape.IMAGE}]})],to);var no=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[zi,zi],e}return b(n,[{key:"shouldSubmitRenderInst",value:function(e,t){var n=e.parsedStyle,r=n.stroke,i=n.lineWidth;return!(!(r&&i&&i.value)&&0===t)}},{key:"beforeUploadUBO",value:function(e,t,n){t.material.setUniforms(L({},Ki.HAS_STROKE,1-t.index))}}]),n}(ni);no=l([Object(v.injectable)({token:[{token:Qr,named:E.Shape.TEXT}]})],no);var ro=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[yi],e}return b(n,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),n}(ni);ro=l([Object(v.injectable)({token:{token:Qr,named:E.Shape.LINE}})],ro);var io=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Qi],e}return b(n)}(ni);io=l([Object(v.injectable)({token:[{token:Qr,named:Zi.tag}]})],io);var oo=["style"],ao=function(e){U(n,e);var t=X(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,i=k(e,oo);return M(this,n),t.call(this,D({type:n.tag,style:D({intensity:Math.PI},r)},i))}return b(n)}(E.DisplayObject);ao.tag="light";var uo,so=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(uo||(uo={}));var lo=function(e){U(n,e);var t=X(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,i=k(e,so);return M(this,n),t.call(this,D({type:n.tag,style:D({type:uo.NONE,fill:"black",start:1,end:1e3,density:0},r)},i))}return b(n)}(E.DisplayObject);lo.tag="fog";var co,fo,ho,_o=v.Syringe.defineToken("DeviceContribution");!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"}(ho||(ho={}));var po,Eo,vo=((co=function(){function e(){M(this,e),this.canvasConfig=void 0,this.contextService=void 0,this.renderingContext=void 0,this.camera=void 0,this.renderHelper=void 0,this.lightPool=void 0,this.texturePool=void 0,this.batchManager=void 0,this.deviceContribution=void 0,this.device=void 0,this.swapChain=void 0,this.renderLists={world:new Lr,picking:new Lr},this.builder=void 0}var t;return b(e,[{key:"getDevice",value:function(){return this.device}},{key:"getSwapChain",value:function(){return this.swapChain}},{key:"getRenderLists",value:function(){return this.renderLists}},{key:"apply",value:function(e){var t=this,n=function(e){var n=e.target;if(n.nodeName!==ao.tag)if(n.nodeName!==lo.tag){var r=new te;n.renderable3D=r,t.batchManager.add(n)}else t.lightPool.addFog(n);else t.lightPool.addLight(n)},r=function(e){var n=e.target;n.nodeName!==ao.tag?n.nodeName!==lo.tag?(t.batchManager.remove(n),delete n.renderable3D):t.lightPool.removeFog(n):t.lightPool.removeLight(n)},i=function(e){var n=e.target,r=e.attrName,i=e.newValue;t.batchManager.updateAttribute(n,r,i)},o=function(e){var n=e.target,r=e.detail.renderOrder;t.batchManager.changeRenderOrder(n,r)};e.hooks.init.tapPromise(fo.tag,B(regeneratorRuntime.mark((function a(){var u,s,l,c;return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return t.renderingContext.root.addEventListener(E.ElementEvent.MOUNTED,n),t.renderingContext.root.addEventListener(E.ElementEvent.UNMOUNTED,r),t.renderingContext.root.addEventListener(E.ElementEvent.ATTR_MODIFIED,i),t.renderingContext.root.addEventListener(E.ElementEvent.RENDER_ORDER_CHANGED,o),t.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering=!1,u=t.contextService.getDomElement(),s=t.canvasConfig,l=s.width,c=s.height,t.contextService.resize(l,c),a.next=10,t.createSwapChain(u);case 10:t.device=t.swapChain.getDevice(),t.renderHelper.setDevice(t.device),t.renderHelper.renderInstManager.disableSimpleMode(),t.swapChain.configureSwapChain(u.width,u.height),t.renderingContext.root.ownerDocument.defaultView.on(E.CanvasEvent.RESIZE,(function(){t.swapChain.configureSwapChain(u.width,u.height)})),t.batchManager.attach(t.device,e);case 16:case"end":return a.stop()}}),a)})))),e.hooks.destroy.tap(fo.tag,(function(){t.renderHelper.destroy(),t.renderingContext.root.removeEventListener(E.ElementEvent.MOUNTED,n),t.renderingContext.root.removeEventListener(E.ElementEvent.UNMOUNTED,r),t.renderingContext.root.removeEventListener(E.ElementEvent.ATTR_MODIFIED,i),t.renderingContext.root.removeEventListener(E.ElementEvent.RENDER_ORDER_CHANGED,o)})),e.hooks.beginFrame.tap(fo.tag,(function(){var e=t.swapChain.getCanvas(),n=t.renderHelper.renderInstManager;t.builder=t.renderHelper.renderGraph.newGraphBuilder();var r=Object(E.parseColor)(t.canvasConfig.background),i=t.canvasConfig.background?Ke(Number(r.r)/255,Number(r.g)/255,Number(r.b)/255,Number(r.alpha)):Ze,o={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:Hr.None},a=Kr(jn.Color0,o,Xr(i)),u=Kr(jn.DepthStencil,o,jr),s=t.builder.createRenderTargetID(a,"Main Color"),l=t.builder.createRenderTargetID(u,"Main Depth");t.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(jn.Color0,s),e.attachRenderTargetID(jn.DepthStencil,l),e.exec((function(e){t.renderLists.world.drawOnPassRenderer(n.renderCache,e)}))})),t.builder.resolveRenderTargetToExternalTexture(s,t.swapChain.getOnscreenTexture())})),e.hooks.endFrame.tap(fo.tag,(function(){var e=t.renderHelper.renderInstManager,n=t.renderHelper.pushTemplateRenderInst();n.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),n.setMegaStateFlags(Nt({depthWrite:!0},{rgbBlendMode:ue.Add,alphaBlendMode:ue.Add,rgbBlendSrcFactor:ae.SrcAlpha,alphaBlendSrcFactor:ae.Zero,rgbBlendDstFactor:ae.OneMinusSrcAlpha,alphaBlendDstFactor:ae.One}));var r=t.canvasConfig,i=r.width,o=r.height;n.setUniforms(0,[{name:ho.PROJECTION_MATRIX,value:t.camera.getPerspective()},{name:ho.VIEW_MATRIX,value:t.camera.getViewTransform()},{name:ho.CAMERA_POSITION,value:t.camera.getPosition()},{name:ho.DEVICE_PIXEL_RATIO,value:t.contextService.getDPR()},{name:ho.VIEWPORT,value:[i,o]},{name:ho.IS_ORTHO,value:t.camera.isOrtho()?1:0},{name:ho.IS_PICKING,value:0}]),t.batchManager.render(t.renderLists.world),e.popTemplateRenderInst(),t.renderHelper.prepareToRender(),t.renderHelper.renderGraph.execute(),e.resetRenderInsts(),t.swapChain.present()}))}},{key:"createSwapChain",value:(t=B(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deviceContribution.createSwapChain(t);case 2:this.swapChain=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"loadTexture",value:function(e,t,n){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){n&&n(e)}))}}]),e}()).tag="RenderGraph",fo=co);l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],vo.prototype,"canvasConfig",void 0),l([Object(v.inject)(E.ContextService),c("design:type",Object)],vo.prototype,"contextService",void 0),l([Object(v.inject)(E.RenderingContext),c("design:type",Object)],vo.prototype,"renderingContext",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],vo.prototype,"camera",void 0),l([Object(v.inject)(Gr),c("design:type",Gr)],vo.prototype,"renderHelper",void 0),l([Object(v.inject)(qr),c("design:type",qr)],vo.prototype,"lightPool",void 0),l([Object(v.inject)(zr),c("design:type",zr)],vo.prototype,"texturePool",void 0),l([Object(v.inject)(ei),c("design:type",ei)],vo.prototype,"batchManager",void 0),l([Object(v.inject)(_o),c("design:type",Object)],vo.prototype,"deviceContribution",void 0),vo=fo=l([Object(v.singleton)({contrib:E.RenderingPluginContribution})],vo);var Ro=((po=function(){function e(){M(this,e),this.canvasConfig=void 0,this.sceneGraphService=void 0,this.contextService=void 0,this.renderingContext=void 0,this.renderHelper=void 0,this.renderGraphPlugin=void 0,this.pickingIdGenerator=void 0,this.camera=void 0,this.batchManager=void 0}var t,n;return b(e,[{key:"apply",value:function(e){var t=this,n=function(e){var n=e.target,r=n.renderable3D;if(r){var i=t.pickingIdGenerator.getId(n);r.pickingId=i,r.encodedPickingColor=t.pickingIdGenerator.encodePickingColor(i)}};e.hooks.init.tapPromise(Eo.tag,B(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.renderingContext.root.addEventListener(E.ElementEvent.MOUNTED,n);case 1:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Eo.tag,(function(){t.renderingContext.root.removeEventListener(E.ElementEvent.MOUNTED,n)})),e.hooks.pick.tapPromise(Eo.tag,function(){var e=B(regeneratorRuntime.mark((function e(n){var r,i,o,a,u,s,l,c,f,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.topmost,i=n.position,o=i.viewportX,a=i.viewportY,u=t.contextService.getDPR(),s=t.canvasConfig.width*u,l=t.canvasConfig.height*u,f=a*u,!((c=o*u)>s||c<0||f>l||f<0)){e.next=10;break}return n.picked=[],e.abrupt("return",n);case 10:return e.next=12,t.pickByRectangleInDepth(new E.Rectangle(Object(E.clamp)(Math.round(c),0,s-1),Object(E.clamp)(Math.round(f),0,l-1),1,1),r?1:100);case 12:return d=e.sent,n.picked=d,e.abrupt("return",n);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"pickByRectangleInDepth",value:(n=B(regeneratorRuntime.mark((function e(t){var n,r,i,o,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=a.length>1&&void 0!==a[1]?a[1]:100,r=null,i=1,o=[];case 4:return e.next=6,this.pickByRectangle(t,r);case 6:if(!(r=e.sent)){e.next=12;break}i++,o.push(r),e.next=13;break;case 12:return e.abrupt("break",14);case 13:if(r&&i<=n){e.next=4;break}case 14:return n>1&&this.restorePickingColor(o),e.abrupt("return",o);case 16:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"restorePickingColor",value:function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))}},{key:"pickByRectangle",value:(t=B(regeneratorRuntime.mark((function e(t,n){var r,i,o,a,u,s,l,c,f,d,h,_,p,E,v,R,T,m,y,g,A,S,C,O,I,N;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.renderGraphPlugin.getDevice(),i=this.renderGraphPlugin.getRenderLists(),o=this.renderHelper.renderInstManager,a=this.renderHelper.renderGraph.newGraphBuilder(),u=Ze,s=t.x,l=t.y,c=t.width,f=t.height,d={backbufferWidth:c,backbufferHeight:f,antialiasingMode:Hr.None},h=Kr(jn.Color0,d,Xr(u)),_=a.createRenderTargetID(h,"Picking Color"),p=Kr(jn.DepthStencil,d,jr),E=a.createRenderTargetID(p,"Picking Depth"),v=new Qn(r,h),a.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(jn.Color0,_),e.attachRenderTargetID(jn.DepthStencil,E),e.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)}))})),a.resolveRenderTargetToExternalTexture(_,v.texture),(R=this.renderHelper.pushTemplateRenderInst()).setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),R.setMegaStateFlags(Nt({depthWrite:!0},{rgbBlendMode:ue.Add,rgbBlendSrcFactor:ae.One,rgbBlendDstFactor:ae.Zero,alphaBlendMode:ue.Add,alphaBlendSrcFactor:ae.One,alphaBlendDstFactor:ae.Zero})),T=this.canvasConfig,m=T.width,y=T.height,g=this.contextService.getDPR(),A=D({},this.camera.getView()),this.camera.setEnableUpdate(!1),this.camera.setViewOffset(m*g,y*g,s,l,c,f),R.setUniforms(0,[{name:ho.PROJECTION_MATRIX,value:this.camera.getPerspective()},{name:ho.VIEW_MATRIX,value:this.camera.getViewTransform()},{name:ho.CAMERA_POSITION,value:this.camera.getPosition()},{name:ho.DEVICE_PIXEL_RATIO,value:this.contextService.getDPR()},{name:ho.VIEWPORT,value:[m,y]},{name:ho.IS_ORTHO,value:this.camera.isOrtho()?1:0},{name:ho.IS_PICKING,value:1}]),n&&this.batchManager.updateAttribute(n,"pointerEvents",!1,!0),this.batchManager.render(i.picking,!0),o.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),o.resetRenderInsts(),C=r.createReadback(),A&&A.enabled?this.camera.setViewOffset(A.fullWidth,A.fullHeight,A.offsetX,A.offsetY,A.width,A.height):this.camera.clearViewOffset(),this.camera.setEnableUpdate(!0),!v.texture){e.next=40;break}return e.next=35,C.readTexture(v.texture,0,0,c,f,new Uint8Array(c*f*4));case 35:O=e.sent,I=-1,!O||0===O[0]&&0===O[1]&&0===O[2]||(I=this.pickingIdGenerator.decodePickingColor(O)),I>-1&&(N=this.pickingIdGenerator.getById(I))&&N.isVisible()&&N.isInteractive()&&(S=N),C.destroy();case 40:return v.destroy(),e.abrupt("return",S);case 42:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]),e}()).tag="WebGLPicker",Eo=po);l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],Ro.prototype,"canvasConfig",void 0),l([Object(v.inject)(E.SceneGraphService),c("design:type",Object)],Ro.prototype,"sceneGraphService",void 0),l([Object(v.inject)(E.ContextService),c("design:type",Object)],Ro.prototype,"contextService",void 0),l([Object(v.inject)(E.RenderingContext),c("design:type",Object)],Ro.prototype,"renderingContext",void 0),l([Object(v.inject)(Gr),c("design:type",Gr)],Ro.prototype,"renderHelper",void 0),l([Object(v.inject)(vo),c("design:type",vo)],Ro.prototype,"renderGraphPlugin",void 0),l([Object(v.inject)(Ne),c("design:type",Ne)],Ro.prototype,"pickingIdGenerator",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],Ro.prototype,"camera",void 0),l([Object(v.inject)(ei),c("design:type",ei)],Ro.prototype,"batchManager",void 0),Ro=Eo=l([Object(v.singleton)({contrib:E.RenderingPluginContribution})],Ro);var To=function(){function e(){M(this,e)}return b(e,[{key:"update",value:function(e){var t=e.geometry,n=e.x,r=e.y,i=e.z;return t.computeBoundingBox(),{width:0,height:0,depth:0,x:n&&n.value||0,y:r&&r.value||0,z:i&&i.value||0}}}]),e}();To=l([Object(v.singleton)({token:{token:E.GeometryAABBUpdater,named:Zi.tag}})],To);var mo,yo,go,Ao="#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}",So="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = texture(SAMPLER_2D(u_Texture), v_TexCoord);\n}",Co=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).vert=Ao,e.frag=So,e.features={},e}return b(n)}(xn),Oo="#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}",Io=function(e){U(n,e);var t=X(n);function n(){var e;M(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).features={},e.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",e.vert=Ao,e.frag=Oo,e}return b(n)}(xn),No=_t(1,(function(){return new kr}));function Po(e,t,n,r){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(jn.Color0,r);var o=e.resolveRenderTarget(r);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(It),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var u=a.allocateUniformBuffer(0,4);Nr(a.mapUniformBufferF32(0),u,1/n.backbufferWidth,1/n.backbufferHeight);var s=new Io,l=t.renderCache.createProgram(s);a.setProgram(l),mo||((mo=new ii(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:_e.PerVertex,attributes:[{format:Oe.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),mo.vertexCount=3,go=t.getCache().createInputLayout(mo.inputLayoutDescriptor),yo=t.getDevice().createInputState(go,mo.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,n){No[0].texture=n.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(No),a.setInputLayoutAndState(go,yo),a.drawOnPass(t.renderCache,e)}))}))}var Do,xo,Bo=Object(v.Module)((function(e){e(Gr),e(zr),e(qr),e(ji),e(Ne),e(ei),e(vo),e(Ro),e(pi),e(yi),e(Bi),e(wi),e(Gi),e(zi),e(Qi),e({token:Jr,useFactory:function(e){return function(t){return e.container.isBound(t)&&e.container.get(t)||null}}}),e(Ji),e($i),e(to),e(ro),e(no),e(io),e({token:Zr,useFactory:function(e){var t={};return function(n){return t[n]||e.container.isBoundNamed(Qr,n)&&(t[n]=e.container.getNamed(Qr,n)),t[n]||null}}})})),Mo=function(){function e(){M(this,e),this.name="device-renderer",this.container=void 0}return b(e,[{key:"init",value:function(e){v.GlobalContainer.isBound(To)||v.GlobalContainer.register(To),this.container=e,e.load(Bo,!0)}},{key:"destroy",value:function(e){v.GlobalContainer.isBound(To)&&v.GlobalContainer.remove(To),e.unload(Bo)}},{key:"getDevice",value:function(){return this.container.get(vo).getDevice()}},{key:"loadTexture",value:function(e,t,n){return this.container.get(vo).loadTexture(e,t,n)}}]),e}(),Fo=v.Syringe.defineToken("WebGPUDeviceOptions");function bo(e){if(e===Oe.U8_RGBA_RT)return"bgra8unorm";if(e===Oe.U8_RGBA_NORM)return"rgba8unorm";if(e===Oe.U8_RG_NORM)return"rg8unorm";if(e===Oe.U32_R)return"r32uint";if(e===Oe.D24)return"depth24plus";if(e===Oe.D24_S8)return"depth24plus-stencil8";if(e===Oe.D32F)return"depth32float";if(e===Oe.D32F_S8)return"depth32float-stencil8";if(e===Oe.BC1)return"bc1-rgba-unorm";if(e===Oe.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===Oe.BC2)return"bc2-rgba-unorm";if(e===Oe.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===Oe.BC3)return"bc3-rgba-unorm";if(e===Oe.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===Oe.BC4_SNORM)return"bc4-r-snorm";if(e===Oe.BC4_UNORM)return"bc4-r-unorm";if(e===Oe.BC5_SNORM)return"bc5-rg-snorm";if(e===Oe.BC5_UNORM)return"bc5-rg-unorm";throw new Error("whoops")}function Lo(e){if(e===se.Clamp)return"clamp-to-edge";if(e===se.Repeat)return"repeat";if(e===se.Mirror)return"mirror-repeat";throw new Error("whoops")}function Uo(e){if(e===le.Bilinear)return"linear";if(e===le.Point)return"nearest";throw new Error("whoops")}function wo(e){if(e===ce.Linear)return"linear";if(e===ce.Nearest)return"nearest";if(e===ce.NoMip)return"nearest";throw new Error("whoops")}function Go(e){return e.gpuBuffer}function ko(e){if(e===ge.OcclusionConservative)return"occlusion";throw new Error("whoops")}function Vo(e){switch(e){case fe.Triangles:return"triangle-list";case fe.Points:return"point-list";case fe.TriangleStrip:return"triangle-strip";case fe.Lines:return"line-list";case fe.LineStrip:return"line-strip";default:throw new Error("Unknown primitive topology mode")}}function Wo(e){if(e===oe.None)return"none";if(e===oe.Front)return"front";if(e===oe.Back)return"back";throw new Error("whoops")}function Xo(e){if(e===ie.CCW)return"ccw";if(e===ie.CW)return"cw";throw new Error("whoops")}function Ho(e){if(e===ae.Zero)return"zero";if(e===ae.One)return"one";if(e===ae.Src)return"src";if(e===ae.OneMinusSrc)return"one-minus-src";if(e===ae.Dst)return"dst";if(e===ae.OneMinusDst)return"one-minus-dst";if(e===ae.SrcAlpha)return"src-alpha";if(e===ae.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===ae.DstAlpha)return"dst-alpha";if(e===ae.OneMinusDstAlpha)return"one-minus-dst-alpha";throw new Error("whoops")}function jo(e){if(e===ue.Add)return"add";if(e===ue.Subtract)return"subtract";if(e===ue.ReverseSubtract)return"reverse-subtract";throw new Error("whoops")}function Yo(e){return{operation:jo(e.blendMode),srcFactor:Ho(e.blendSrcFactor),dstFactor:Ho(e.blendDstFactor)}}function Ko(e,t){return t.attachmentsState.map((function(t,n){return function(e,t){return{format:bo(t),blend:{color:Yo(e.rgbBlendState),alpha:Yo(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[n])}))}function zo(e){if(e===re.Never)return"never";if(e===re.Less)return"less";if(e===re.Equal)return"equal";if(e===re.LessEqual)return"less-equal";if(e===re.Greater)return"greater";if(e===re.NotEqual)return"not-equal";if(e===re.GreaterEqual)return"greater-equal";if(e===re.Always)return"always";throw new Error("whoops")}function qo(e){if(e===_e.PerVertex)return"vertex";if(e===_e.PerInstance)return"instance";throw new Error("whoops")}function Zo(e){if(e===Oe.U8_R)return"uint8x2";if(e===Oe.U8_RG)return"uint8x2";if(e===Oe.U8_RGB)return"uint8x4";if(e===Oe.U8_RGBA)return"uint8x4";if(e===Oe.U8_RGBA_NORM)return"unorm8x4";if(e===Oe.S8_RGB_NORM)return"snorm8x4";if(e===Oe.S8_RGBA_NORM)return"snorm8x4";if(e===Oe.S16_RG)return"uint16x2";if(e===Oe.F32_R)return"float32";if(e===Oe.F32_RG)return"float32x2";if(e===Oe.F32_RGB)return"float32x3";if(e===Oe.F32_RGBA)return"float32x4";throw new Error("whoops")}function Qo(e){switch(Me(e)){case Ae.BC1:case Ae.BC2:case Ae.BC3:case Ae.BC4_SNORM:case Ae.BC4_UNORM:case Ae.BC5_SNORM:case Ae.BC5_UNORM:return 4;default:return 1}}function Jo(e,t,n,r){switch(void 0===n&&(n=!1),e){case Oe.S8_R:case Oe.S8_R_NORM:case Oe.S8_RG_NORM:case Oe.S8_RGB_NORM:case Oe.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return r&&i.set(new Int8Array(r)),i;case Oe.U8_R:case Oe.U8_R_NORM:case Oe.U8_RG:case Oe.U8_RG_NORM:case Oe.U8_RGB:case Oe.U8_RGB_NORM:case Oe.U8_RGB_SRGB:case Oe.U8_RGBA:case Oe.U8_RGBA_NORM:case Oe.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return r&&o.set(new Uint8Array(r)),o;case Oe.S16_R:case Oe.S16_RG:case Oe.S16_RG_NORM:case Oe.S16_RGB_NORM:case Oe.S16_RGBA:case Oe.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(n?t/2:t);return r&&a.set(new Int16Array(r)),a;case Oe.U16_R:case Oe.U16_RGB:case Oe.U16_RGBA_5551:case Oe.U16_RGBA_NORM:case Oe.U16_RG_NORM:case Oe.U16_R_NORM:var u=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(n?t/2:t);return r&&u.set(new Uint16Array(r)),u;case Oe.S32_R:var s=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(n?t/4:t);return r&&s.set(new Int32Array(r)),s;case Oe.U32_R:case Oe.U32_RG:var l=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(n?t/4:t);return r&&l.set(new Uint32Array(r)),l;case Oe.F32_R:case Oe.F32_RG:case Oe.F32_RGB:case Oe.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(n?t/4:t);return r&&c.set(new Float32Array(r)),c}var f=(ArrayBuffer,new Uint8Array(t));return r&&f.set(new Uint8Array(r)),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"}(Do||(Do={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(xo||(xo={}));var $o=function(e){function t(t){var n=t.id,r=t.device,i=e.call(this)||this;return i.id=n,i.device=r,i}return u(t,e),t.prototype.destroy=function(){},t}(g.EventEmitter),ea=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.Bindings;var a=i.pipeline,u=i.bindingLayout;We(!!a);for(var s=[[],[]],l=0,c=0;c<u.storageEntries.length;c++){We((d=i.storageBufferBindings[c]).wordCount>0);var f={buffer:Go(d.buffer),offset:0,size:d.wordCount<<2};s[0].push({binding:l++,resource:f})}for(c=0;c<u.numUniformBuffers;c++){We((d=i.uniformBufferBindings[c]).wordCount>0);f={buffer:Go(d.buffer),offset:0,size:d.wordCount<<2};s[0].push({binding:l++,resource:f})}l=0;for(c=0;c<u.numSamplers;c++){var d,h=void 0!==u.samplerEntries?u.samplerEntries[c]:Dt,_=null!==(d=i.samplerBindings[c]).texture?d.texture:o.device.getFallbackTexture(h);We(h.dimension===_.dimension),We(h.formatKind===Ve(_.pixelFormat));var p=_.gpuTextureView;s[1].push({binding:l++,resource:p});var E=null!==d.sampler?d.sampler:o.device.fallbackSampler,v=E.gpuSampler;s[1].push({binding:l++,resource:v})}return o.gpuBindGroup=s.map((function(e,t){return o.device.device.createBindGroup({layout:a.getBindGroupLayout(t),entries:e})})),o.bindingLayout=i.bindingLayout,o}return u(t,e),t}($o);function ta(e){return void 0!==e.byteLength}var na=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.Buffer;var a=i.usage,u=i.viewOrSize,s=ta(u)?u.byteLength+3&-4:u+3&-4;o.usage=a,o.usage&de.MAP_READ&&(o.usage=de.MAP_READ|de.COPY_DST);var l=ta(u);if(o.size=ta(u)?u.byteLength:u,o.view=ta(u)?u:null,o.gpuBuffer=o.device.device.createBuffer({usage:o.usage,size:s,mappedAtCreation:l}),l){var c=o.gpuBuffer.getMappedRange();new u.constructor(c).set(u),o.gpuBuffer.unmap()}return o}return u(t,e),t.prototype.setSubData=function(e,t,n,r){void 0===n&&(n=0),void 0===r&&(r=0);var i=this.gpuBuffer;r=r||t.byteLength,r=Math.min(r,this.size-e);var o=t.byteOffset+n,a=o+r,u=r+3&-4;if(u!==r){var s=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(u)).set(s),n=0,o=0,a=u,r=u}for(var l=0;a-(o+l)>15728640;)this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,15728640),l+=15728640;this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,r-l)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}($o),ra=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.InputLayout;for(var a=[],u=0;u<i.vertexBufferDescriptors.length;u++){if(null!==(f=i.vertexBufferDescriptors[u])){var s=f.byteStride,l=qo(f.frequency);a[u]={arrayStride:s,stepMode:l,attributes:[]}}}for(u=0;u<i.vertexAttributeDescriptors.length;u++){var c=i.vertexAttributeDescriptors[u],f=Xe(a[c.bufferIndex]),d={shaderLocation:c.location,format:Zo(c.format),offset:c.bufferByteOffset};f.attributes.push(d)}return o.indexFormat=function(e){if(null!==e){if(e===Oe.U16_R)return"uint16";if(e===Oe.U32_R)return"uint32";throw new Error("whoops")}}(i.indexBufferFormat),o.buffers=a,o}return u(t,e),t}($o),ia=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;return o.type=ne.Program,o.vertexStage=null,o.fragmentStage=null,o.computeStage=null,o.descriptor=i,i.preprocessedVert&&(o.vertexStage=o.createShaderStage(i.preprocessedVert,"vertex")),i.preprocessedFrag&&(o.fragmentStage=o.createShaderStage(i.preprocessedFrag,"fragment")),i.preprocessedCompute&&(o.computeStage=o.createShaderStage(i.preprocessedCompute,"compute")),o}return u(t,e),t.prototype.createShaderStage=function(e,t){var n,r,i=e;if("compute"!==t)try{i=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),new Error("whoops")}var o=function(e){if(!i.includes(e))return"continue";i=(i=i.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(new RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),(function(t,n){return"vec4<f32>(textureSample(T_".concat(e).concat(n,"), 0.0, 0.0, 0.0);")}))};try{for(var a=h(["u_TextureFramebufferDepth"]),u=a.next();!u.done;u=a.next()){o(u.value)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return{module:this.device.device.createShaderModule({code:i}),entryPoint:"main"}},t}($o),oa=function(){function e(){this.commandEncoder=null,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorResolveTo=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadValue:"load",depthStoreOp:"store",stencilLoadValue:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.setRenderPassDescriptor=function(e){this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var t=e.colorAttachment.length;this.gfxColorAttachment.length=t,this.gfxColorResolveTo.length=t;for(var n=0;n<e.colorAttachment.length;n++){var r=e.colorAttachment[n],i=e.colorResolveTo[n];if(null===r&&null!==i&&(r=i,i=null),this.gfxColorAttachment[n]=r,this.gfxColorResolveTo[n]=i,null===r){this.gpuColorAttachments.length=n,this.gfxColorAttachment.length=n,this.gfxColorResolveTo.length=n;break}void 0===this.gpuColorAttachments[n]&&(this.gpuColorAttachments[n]={}),(a=this.gpuColorAttachments[n]).view=r.gpuTextureView;var o=e.colorClearColor[n];"load"===o?a.loadOp="load":(a.loadOp="clear",a.clearValue=o),a.storeOp=e.colorStore[n]?"store":"discard",a.resolveTarget=void 0,null!==i&&(r.sampleCount>1?a.resolveTarget=i.gpuTextureView:a.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var a,u=e.depthStencilAttachment;(a=this.gpuDepthStencilAttachment).view=u.gpuTextureView,"load"===e.depthClearValue?a.depthLoadOp="load":(a.depthLoadOp="clear",a.depthClearValue=e.depthClearValue),"load"===e.stencilClearValue?a.stencilLoadOp="load":(a.stencilLoadOp="clear",a.stencilClearValue=e.stencilClearValue),a.depthStoreOp=e.depthStencilStore?"store":"discard",a.stencilStoreOp=e.depthStencilStore?"store":"discard",this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment,null!==this.gfxDepthStencilResolveTo&&(a.depthStoreOp="store",a.stencilStoreOp="store")}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0},e.prototype.beginRenderPass=function(e){We(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.setViewport=function(e,t,n,r){this.gpuRenderPassEncoder.setViewport(e,t,n,r,0,1)},e.prototype.setScissor=function(e,t,n,r){this.gpuRenderPassEncoder.setScissorRect(e,t,n,r)},e.prototype.setPipeline=function(e){var t=Xe(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},e.prototype.setInputState=function(e){if(null!==e){var t=e;if(null!==t.indexBuffer){var n=t.inputLayout,r=t.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Go(r.buffer),Xe(n.indexFormat),r.byteOffset)}for(var i=0;i<t.vertexBuffers.length;i++){var o=t.vertexBuffers[i];null!==o&&this.gpuRenderPassEncoder.setVertexBuffer(i,Go(o.buffer),o.byteOffset)}}},e.prototype.setBindings=function(e,t,n){var r=t;this.gpuRenderPassEncoder.setBindGroup(e+0,r.gpuBindGroup[0],n.slice(0,r.bindingLayout.numUniformBuffers)),this.gpuRenderPassEncoder.setBindGroup(e+1,r.gpuBindGroup[1])},e.prototype.setStencilRef=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)},e.prototype.drawIndexed=function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)},e.prototype.drawIndexedInstanced=function(e,t,n){this.gpuRenderPassEncoder.drawIndexed(e,n,t,0,0)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(e){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.beginDebugGroup=function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.endDebugGroup=function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.finish=function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;e<this.gfxColorAttachment.length;e++){var t=this.gfxColorAttachment[e],n=this.gfxColorResolveTo[e];null!==t&&null!==n&&1===t.sampleCount&&this.copyAttachment(n,t)}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,this.gfxDepthStencilAttachment)),this.commandEncoder.finish()},e.prototype.copyAttachment=function(e,t){We(1===t.sampleCount);var n={texture:t.gpuTexture},r={texture:e.gpuTexture};We(t.width===e.width),We(t.height===e.height),We(!!(t.usage&Do.COPY_SRC)),We(!!(e.usage&Do.COPY_DST)),this.commandEncoder.copyTextureToTexture(n,r,[e.width,e.height,1])},e}(),aa=function(e){function t(t){var n,r,i=t.id,o=t.device,a=t.descriptor,u=this;(u=e.call(this,{id:i,device:o})||this).type=ne.Sampler;var s=a.minLOD,l=a.mipFilter===ce.NoMip?a.minLOD:a.maxLOD,c=null!==(n=a.maxAnisotropy)&&void 0!==n?n:1;return c>1&&We(a.minFilter===le.Bilinear&&a.magFilter===le.Bilinear&&a.mipFilter===ce.Linear),u.gpuSampler=u.device.device.createSampler({addressModeU:Lo(a.wrapS),addressModeV:Lo(a.wrapT),addressModeW:Lo(null!==(r=a.wrapQ)&&void 0!==r?r:a.wrapS),lodMinClamp:s,lodMaxClamp:l,minFilter:Uo(a.minFilter),magFilter:Uo(a.magFilter),mipmapFilter:wo(a.mipFilter),maxAnisotropy:c}),u}return u(t,e),t}($o),ua=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=t.skipCreate,a=e.call(this,{id:n,device:r})||this;return a.type=ne.Texture,a.device.createTextureShared({pixelFormat:i.pixelFormat,dimension:i.dimension,width:i.width,height:i.height,depthOrArrayLayers:i.depth,numLevels:i.numLevels,usage:i.usage,sampleCount:1},a,o),a}return u(t,e),t.prototype.setImageData=function(e,t){},t.prototype.destroy=function(){this.gpuTexture.destroy()},t}($o),sa=function(e){function t(t){var n=t.id,r=t.device,i=t.inputLayout,o=t.vertexBuffers,a=t.indexBuffer,u=e.call(this,{id:n,device:r})||this;return u.type=ne.InputState,u.inputLayout=i,u.vertexBuffers=o,u.indexBuffer=a,u}return u(t,e),t}($o),la=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;return o.type=ne.RenderPipeline,o.isCreating=!1,o.isCreatingAsync=!1,o.gpuRenderPipeline=null,o.descriptor=i,o.device.ensureRenderPipeline(o),o}return u(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}($o),ca=function(e){function t(t){var n=t.id,r=t.device,i=e.call(this,{id:n,device:r})||this;return i.type=ne.Readback,i}return u(t,e),t.prototype.readTexture=function(e,t,n,r,i,o,a,u){void 0===a&&(a=0),void 0===u&&(u=0);var s=e,l=this.getBlockInformationFromFormat(s.format),c=Math.ceil(r/l.width)*l.length,f=256*Math.ceil(c/256),d=f*i,h=this.device.createBuffer({usage:de.STORAGE|de.MAP_READ|de.COPY_DST,hint:he.Static,viewOrSize:d}),_=this.device.device.createCommandEncoder();return _.copyTextureToBuffer({texture:s.gpuTexture,mipLevel:0,origin:{x:t,y:n,z:Math.max(0,0)}},{buffer:h.gpuBuffer,offset:0,bytesPerRow:f},{width:r,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([_.finish()]),this.readBuffer(h,d,o,a,u,s.pixelFormat)},t.prototype.readBuffer=function(e,t,n,r,i,o,a,u){var s=this;void 0===t&&(t=0),void 0===n&&(n=null),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=Oe.U8_RGB),void 0===a&&(a=!1),void 0===u&&(u=!1);var l=e,c=i||l.size,f=n||l.view,d=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||Le(o),h=l;if(!(l.usage&de.MAP_READ&&l.usage&de.COPY_DST)){var _=this.device.device.createCommandEncoder();h=this.device.createBuffer({usage:de.STORAGE|de.MAP_READ|de.COPY_DST,hint:he.Static,viewOrSize:c}),_.copyBufferToBuffer(l.gpuBuffer,t,h.gpuBuffer,0,c),this.device.device.queue.submit([_.finish()])}return new Promise((function(e,n){h.gpuBuffer.mapAsync(xo.READ,t,c).then((function(){var n=h.gpuBuffer.getMappedRange(t,c),r=f;if(a)r=null===r?Jo(o,c,!0,n):Jo(o,r.buffer,void 0,n);else if(null===r)switch(d){case 1:(r=new Uint8Array(c)).set(new Uint8Array(n));break;case 2:r=s.getHalfFloatAsFloatRGBAArrayBuffer(c/2,n);break;case 4:(r=new Float32Array(c/4)).set(new Float32Array(n))}else switch(d){case 1:(r=new Uint8Array(r.buffer)).set(new Uint8Array(n));break;case 2:r=s.getHalfFloatAsFloatRGBAArrayBuffer(c/2,n,f);break;case 4:var i=f&&f.constructor||Float32Array;(r=new i(r.buffer)).set(new i(n))}h.gpuBuffer.unmap(),e(r)}),(function(e){return n(e)}))}))},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,n){n||(n=new Float32Array(e));for(var r,i,o,a,u=new Uint16Array(t);e--;)n[e]=(r=u[e],i=void 0,o=void 0,a=void 0,i=(32768&r)>>15,a=1023&r,0===(o=(31744&r)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/Math.pow(2,10)):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/Math.pow(2,10)));return n},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":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":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 new Error("No fixed size for Stencil8 format!");case"depth16unorm":return{width:1,height:1,length:2};case"depth24plus":throw new Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw new Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float":case"depth24unorm-stencil8":return{width:1,height:1,length:4};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};default:return{width:1,height:1,length:4}}},t}($o),fa=function(){function e(){this.commandEncoder=null,this.gpuComputePassEncoder=null}return e.prototype.dispatch=function(e,t,n){this.gpuComputePassEncoder.dispatch(e,t,n)},e.prototype.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},e.prototype.beginComputePass=function(e){We(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=Xe(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e,t){var n=t;this.gpuComputePassEncoder.setBindGroup(e,n.gpuBindGroup[0])},e.prototype.setComputePassDescriptor=function(e){this.descriptor=e},e}(),da=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.ComputePipeline,o.gpuComputePipeline=null,o.descriptor=i;var a=i.program.computeStage;if(null===a)return o;var u={compute:s({},a)};return o.gpuComputePipeline=o.device.device.createComputePipeline(u),void 0!==o.name&&(o.gpuComputePipeline.label=o.name),o}return u(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}($o),ha=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.QueryPool;var a=i.elemCount,u=i.type;return o.querySet=o.device.device.createQuerySet({type:ko(u),count:a}),o}return u(t,e),t.prototype.queryResultOcclusion=function(e){return!0},t}($o),_a=function(){function e(e,t,n,r,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Do.RENDER_ATTACHMENT|Do.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new Un(bt,bn),this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=me.UpperLeft,this.clipSpaceNearZ=ye.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.adapter=e,this.device=t,this.canvas=n,this.canvasContext=r,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(pe.n2D,Te.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(pe.n2D,Te.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(pe.n2DArray,Te.Float),this.fallbackTexture3D=this.createFallbackTexture(pe.n3D,Te.Float),this.fallbackTextureCube=this.createFallbackTexture(pe.Cube,Te.Float),this.fallbackSampler=this.createSampler({wrapS:se.Clamp,wrapT:se.Clamp,minFilter:le.Point,magFilter:le.Point,mipFilter:ce.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}return e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t,this.canvasContext.configure({device:this.device,format:"bgra8unorm",usage:this.swapChainTextureUsage,compositingAlphaMode:"premultiplied"}))},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),n=new ua({id:0,device:this,descriptor:{pixelFormat:Oe.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:pe.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return n.depthOrArrayLayers=1,n.sampleCount=1,n.gpuTexture=e,n.gpuTextureView=t,n},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.present=function(){},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new na({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new ua({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new aa({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new ua({id:this.getNextUniqueId(),device:this,descriptor:s(s({},e),{dimension:pe.n2D,numLevels:1,depth:1,usage:Ee.RenderTarget})});return t.depthOrArrayLayers=1,t.type=ne.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e,n=t.pixelFormat,r=t.width,i=t.height,o=t.depthOrArrayLayers,a=t.sampleCount,u=t.numLevels,s=t.gpuTexture,l=t.gpuTextureView,c=t.usage;We(!!(c&Do.RENDER_ATTACHMENT));var f=new ua({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:n,width:r,height:i,depth:o,dimension:pe.n2D,numLevels:u,usage:c},skipCreate:!0});return f.depthOrArrayLayers=o,f.sampleCount=a,f.gpuTexture=s,f.gpuTextureView=l,f},e.prototype.createProgram=function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)},e.prototype.createProgramSimple=function(e){return new ia({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,n){var r={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.numLevels,o=bo(e.pixelFormat),a=function(e){if(e===pe.n2D)return"2d";if(e===pe.Cube)return"3d";if(e===pe.n2DArray)return"3d";if(e===pe.n3D)return"3d";throw new Error("whoops")}(e.dimension),u=function(e){var t=0;return e&Ee.Sampled&&(t|=Do.TEXTURE_BINDING|Do.COPY_DST),e&Ee.RenderTarget&&(t|=Do.RENDER_ATTACHMENT|Do.TEXTURE_BINDING|Do.COPY_SRC|Do.COPY_DST),t}(e.usage);if(t.format=o,t.dimension=e.dimension,t.pixelFormat=e.pixelFormat,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.numLevels=i,t.usage=u,t.sampleCount=1,!n){var s=this.device.createTexture({size:r,mipLevelCount:i,format:o,dimension:a,usage:u}),l=s.createView();t.gpuTexture=s,t.gpuTextureView=l}},e.prototype.getFallbackTexture=function(e){var t=e.dimension,n=e.formatKind;if(t===pe.n2D)return n===Te.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===pe.n2DArray)return this.fallbackTexture2DArray;if(t===pe.n3D)return this.fallbackTexture3D;if(t===pe.Cube)return this.fallbackTextureCube;throw new Error("whoops")},e.prototype.createFallbackTexture=function(e,t){var n=e===pe.Cube?6:1,r=t===Te.Float?Oe.U8_RGBA_NORM:Oe.D24;return this.createTexture({dimension:e,pixelFormat:r,usage:Ee.Sampled,width:1,height:1,depth:n,numLevels:1})},e.prototype.createBindings=function(e){return e.pipeline,new ea({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new ra({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputState=function(e,t,n){return new sa({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:n})},e.prototype.createComputePipeline=function(e){return new da({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new la({id:this.getNextUniqueId(),device:this,descriptor:s({},e)})},e.prototype.createQueryPool=function(e,t){return new ha({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype.ensureRenderPipeline=function(e){if(!e.isCreating&&null===e.gpuRenderPipeline){var t=e.descriptor,n=t.program,r=n.vertexStage,i=n.fragmentStage;if(null!==r&&null!==i){var o,a,u=(o=t.topology,a=t.megaStateDescriptor,{topology:Vo(o),cullMode:Wo(a.cullMode),frontFace:Xo(a.frontFace)}),l=Ko(t.colorAttachmentFormats,t.megaStateDescriptor),c=function(e,t){if(null!==e)return{format:bo(e),depthWriteEnabled:t.depthWrite,depthCompare:zo(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(t.depthStencilAttachmentFormat,t.megaStateDescriptor),f=void 0;null!==t.inputLayout&&(f=t.inputLayout.buffers);var d=t.sampleCount;e.isCreating=!0;var h={vertex:s(s({},r),{buffers:f}),primitive:u,depthStencil:c,multisample:{count:d},fragment:s(s({},i),{targets:l})};e.gpuRenderPipeline=this.device.createRenderPipeline(h),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}},e.prototype.createReadback=function(){return new ca({id:this.getNextUniqueId(),device:this})},e.prototype.destroyRenderTarget=function(e){e.gpuTexture.destroy()},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new oa),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},e.prototype.createComputePass=function(e){var t=this.computePassPool.pop();return void 0===t&&(t=new fa),t.commandEncoder=this.device.createCommandEncoder(),t.beginComputePass(e),t},e.prototype.submitPass=function(e){var t=this.device.queue,n=e,r=n.finish();t.submit([r]),n.commandEncoder=null,n instanceof oa?this.renderPassPool.push(n):this.computePassPool.push(n)},e.prototype.copySubTexture2D=function(e,t,n,r,i,o){var a=this.device.createCommandEncoder(),u=e,s=r,l={texture:s.gpuTexture,origin:[i,o,0]},c={texture:u.gpuTexture,origin:[t,n,0]};We(!!(s.usage&Do.COPY_SRC)),We(!!(u.usage&Do.COPY_DST)),a.copyTextureToTexture(l,c,[s.width,s.height,1]),this.device.queue.submit([a.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}},e.prototype.queryTextureFormatSupported=function(e,t,n){if(function(e){switch(Me(e)){case Ae.BC1:case Ae.BC2:case Ae.BC3:case Ae.BC4_SNORM:case Ae.BC4_UNORM:case Ae.BC5_SNORM:case Ae.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var r=Qo(e);return t%r==0&&n%r==0&&this.featureTextureCompressionBC}return!0},e.prototype.queryPipelineReady=function(e){var t=e;return this.ensureRenderPipeline(t),null!==t.gpuRenderPipeline},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===ne.Buffer)(n=e).gpuBuffer.label=t;else if(e.type===ne.Texture){(n=e).gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===ne.RenderTarget){(n=e).gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===ne.Sampler){(n=e).gpuSampler.label=t}else if(e.type===ne.RenderPipeline){var n;null!==(n=e).gpuRenderPipeline&&(n.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pushDebugGroup=function(e){},e.prototype.popDebugGroup=function(){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){},e}();let pa,Ea=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Ea.decode();let va=null;function Ra(){return null!==va&&va.buffer===pa.memory.buffer||(va=new Uint8Array(pa.memory.buffer)),va}function Ta(e,t){return Ea.decode(Ra().subarray(e,e+t))}const ma=new Array(32).fill(void 0);ma.push(void 0,null,!0,!1);let ya=ma.length;function ga(e){return ma[e]}function Aa(e){const t=ga(e);return function(e){e<36||(ma[e]=ya,ya=e)}(e),t}let Sa=0,Ca=new TextEncoder("utf-8");const Oa="function"==typeof Ca.encodeInto?function(e,t){return Ca.encodeInto(e,t)}:function(e,t){const n=Ca.encode(e);return t.set(n),{read:e.length,written:n.length}};function Ia(e,t,n){if(void 0===n){const n=Ca.encode(e),r=t(n.length);return Ra().subarray(r,r+n.length).set(n),Sa=n.length,r}let r=e.length,i=t(r);const o=Ra();let a=0;for(;a<r;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==r){0!==a&&(e=e.slice(a)),i=n(i,r,r=a+3*e.length);const t=Ra().subarray(i+a,i+r);a+=Oa(e,t).written}return Sa=a,i}let Na=null;function Pa(){return null!==Na&&Na.buffer===pa.memory.buffer||(Na=new Int32Array(pa.memory.buffer)),Na}function Da(e,t,n){try{const l=pa.__wbindgen_add_to_stack_pointer(-16);var r=Ia(e,pa.__wbindgen_malloc,pa.__wbindgen_realloc),i=Sa,o=Ia(t,pa.__wbindgen_malloc,pa.__wbindgen_realloc),a=Sa;pa.glsl_compile(l,r,i,o,a,n);var u=Pa()[l/4+0],s=Pa()[l/4+1];return Ta(u,s)}finally{pa.__wbindgen_add_to_stack_pointer(16),pa.__wbindgen_free(u,s)}}var xa=async function e(t){const n={wbg:{}};n.wbg.__wbindgen_string_new=function(e,t){return function(e){ya===ma.length&&ma.push(ma.length+1);const t=ya;return ya=ma[t],ma[t]=e,t}(Ta(e,t))},n.wbg.__wbindgen_object_drop_ref=function(e){Aa(e)},n.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(ga(e))},n.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(ga(e),ga(t))},n.wbg.__wbindgen_throw=function(e,t){throw new Error(Ta(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:r,module:i}=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 n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}{const n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}(await t,n);return pa=r.exports,e.__wbindgen_wasm_module=i,pa},Ba=function(){function e(){}return e.prototype.createSwapChain=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,o;return d(this,(function(a){switch(a.label){case 0:if(void 0===navigator.gpu)return[2,null];t=null,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,navigator.gpu.requestAdapter()];case 2:return t=a.sent(),[3,4];case 3:return n=a.sent(),console.log(n),[3,4];case 4:return null===t?[2,null]:(r=["depth24unorm-stencil8","depth32float-stencil8","texture-compression-bc"].filter((function(e){return t.features.has(e)})),[4,t.requestDevice({requiredFeatures:r})]);case 5:if(null===(i=a.sent()))return[2,null];if(!(o=e.getContext("webgpu")))return[2,null];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,xa("/glsl_wgsl_compiler_bg.wasm")];case 7:return a.sent(),[3,9];case 8:return a.sent(),[3,9];case 9:return[2,new _a(t,i,e,o,Da)]}}))}))},l([Object(v.inject)(Fo),c("design:type",Object)],e.prototype,"pluginOptions",void 0),e=l([Object(v.singleton)({token:_o})],e)}(),Ma=Object(v.Module)((function(e){e(Ba)})),Fa=function(){function e(e){void 0===e&&(e={}),this.options=e,this.name="webgpu-device"}return e.prototype.init=function(e){e.register(Fo,{useValue:s({},this.options)}),e.load(Ma,!0)},e.prototype.destroy=function(e){e.remove(Fo),e.unload(Ma)},e}(),ba=function(){function e(){}return e.prototype.init=function(){var e=this.canvasConfig,t=e.container,n=e.canvas,r=e.devicePixelRatio;if(n)this.$canvas=n,t&&n.parentElement!==t&&t.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=Object(E.isString)(t)?document.getElementById(t):t,this.$container)){var i=document.createElement("canvas");this.$container.appendChild(i),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=i}var o=r||E.isBrowser&&window.devicePixelRatio||1;o=o>=1?Math.ceil(o):1,this.dpr=o},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.context},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,t){if(this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*t,Object(E.setDOMSize)(this.$canvas,e,t)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],e.prototype,"canvasConfig",void 0),e=l([Object(v.singleton)({token:E.ContextService})],e)}(),La=Object(v.Module)((function(e){e(ba)})),Ua=function(){function e(){this.name="webgpu-context-register"}return e.prototype.init=function(e){e.load(La,!0)},e.prototype.destroy=function(e){e.unload(La)},e}(),wa=function(e){function t(t){var n=e.call(this,t)||this;return n.registerPlugin(new Ua),n.registerPlugin(new Fa),n.registerPlugin(new Mo),n.registerPlugin(new y),n}return u(t,e),t}(E.AbstractRenderer)}])}));
16
+ var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function l(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))}function d(e,t){var n,r,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(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}Object.create;function h(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function p(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}Object.create;var E=n(0),v=n(1),R=/mobile|tablet|ip(ad|hone|od)|android/i,m=function(){function e(){}var t;return t=e,e.prototype.apply=function(e){var n=this,r=this.renderingContext.root.ownerDocument.defaultView,i=r.supportTouchEvent&&R.test(navigator.userAgent),o=function(t){e.hooks.pointerMove.call(t)},a=function(t){e.hooks.pointerUp.call(t)},s=function(t){e.hooks.pointerDown.call(t)},u=function(t){e.hooks.pointerOver.call(t)},l=function(t){e.hooks.pointerOut.call(t)},c=function(t){e.hooks.pointerCancel.call(t)},h=function(t){e.hooks.pointerWheel.call(t)},_=function(e){e.addEventListener("touchstart",s,!0),e.addEventListener("touchend",a,!0),e.addEventListener("touchmove",o,!0),e.addEventListener("touchcancel",c,!0)},p=function(e){globalThis.document.addEventListener("mousemove",o,!0),e.addEventListener("mousedown",s,!0),e.addEventListener("mouseout",l,!0),e.addEventListener("mouseover",u,!0),globalThis.addEventListener("mouseup",a,!0)},E=function(e){e.removeEventListener("touchstart",s,!0),e.removeEventListener("touchend",a,!0),e.removeEventListener("touchmove",o,!0)},v=function(e){globalThis.document.removeEventListener("mousemove",o,!0),e.removeEventListener("mousedown",s,!0),e.removeEventListener("mouseout",l,!0),e.removeEventListener("mouseover",u,!0),globalThis.removeEventListener("mouseup",a,!0)};e.hooks.init.tapPromise(t.tag,(function(){return f(n,void 0,void 0,(function(){var e;return d(this,(function(t){return e=this.contextService.getDomElement(),r.supportPointerEvent&&function(e){globalThis.document.addEventListener("pointermove",o,!0),e.addEventListener("pointerdown",s,!0),e.addEventListener("pointerleave",l,!0),e.addEventListener("pointerover",u,!0),globalThis.addEventListener("pointerup",a,!0)}(e),i?_(e):r.supportTouchEvent?(_(e),r.supportPointerEvent||p(e)):r.supportPointerEvent||p(e),e.addEventListener("wheel",h,{passive:!0,capture:!0}),[2]}))}))})),e.hooks.destroy.tap(t.tag,(function(){var e=n.contextService.getDomElement();r.supportPointerEvent&&function(e){globalThis.document.removeEventListener("pointermove",o,!0),e.removeEventListener("pointerdown",s,!0),e.removeEventListener("pointerleave",l,!0),e.removeEventListener("pointerover",u,!0),globalThis.removeEventListener("pointerup",a,!0)}(e),i?E(e):r.supportTouchEvent?(E(e),r.supportPointerEvent||v(e)):r.supportPointerEvent||v(e),e.removeEventListener("wheel",h,!0)}))},e.tag="DOMInteraction",l([Object(v.inject)(E.ContextService),c("design:type",Object)],e.prototype,"contextService",void 0),l([Object(v.inject)(E.RenderingContext),c("design:type",Object)],e.prototype,"renderingContext",void 0),e=t=l([Object(v.singleton)({contrib:E.RenderingPluginContribution})],e)}(),T=Object(v.Module)((function(e){e(m)})),y=function(){function e(){this.name="dom-interaction"}return e.prototype.init=function(e){e.load(T,!0)},e.prototype.destroy=function(e){e.unload(T)},e}(),g=(n(4),n(2)),A=n(3),S=n.n(A);const C=1e20;class O{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=n;const s=this.size=e+4*t,u=this._createCanvas(s),l=this.ctx=u.getContext("2d",{willReadFrequently:!0});l.font=`${a} ${o} ${e}px ${i}`,l.textBaseline="alphabetic",l.textAlign="left",l.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),s=Math.min(this.size-this.buffer,Math.ceil(o-i)),u=Math.min(this.size-this.buffer,a+Math.ceil(r)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),d=new Uint8ClampedArray(f),h={data:d,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===u)return h;const{ctx:_,buffer:p,gridInner:E,gridOuter:v}=this;_.clearRect(p,p,s,u),_.fillText(e,p,p+a);const R=_.getImageData(p,p,s,u);v.fill(C,0,f),E.fill(0,0,f);for(let e=0;e<u;e++)for(let t=0;t<s;t++){const n=R.data[4*(e*s+t)+3]/255;if(0===n)continue;const r=(e+p)*l+t+p;if(1===n)v[r]=0,E[r]=C;else{const e=.5-n;v[r]=e>0?e*e:0,E[r]=e<0?e*e:0}}I(v,0,0,l,c,l,this.f,this.v,this.z),I(E,p,p,s,u,l,this.f,this.v,this.z);for(let e=0;e<f;e++){const t=Math.sqrt(v[e])-Math.sqrt(E[e]);d[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return h}}function I(e,t,n,r,i,o,a,s,u){for(let l=t;l<t+r;l++)N(e,n*o+l,o,i,a,s,u);for(let l=n;l<n+i;l++)N(e,l*o+t,1,r,a,s,u)}function N(e,t,n,r,i,o,a){o[0]=0,a[0]=-C,a[1]=C,i[0]=e[t];for(let s=1,u=0,l=0;s<r;s++){i[s]=e[t+s*n];const r=s*s;do{const e=o[u];l=(i[s]-i[e]+r-e*e)/(s-e)/2}while(l<=a[u]&&--u>-1);u++,o[u]=s,a[u]=l,a[u+1]=C}for(let s=0,u=0;s<r;s++){for(;a[u+1]<s;)u++;const r=o[u],l=s-r;e[t+s*n]=i[r]+l*l}}function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){F(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function M(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function x(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){M(o,r,i,a,s,"next",e)}function s(e){M(o,r,i,a,s,"throw",e)}a(void 0)}))}}function B(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function L(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function F(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&w(e,t)}function G(e){return(G=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function W(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function V(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return W(e)}function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=G(e);if(t){var i=G(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return V(this,n)}}function H(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=G(e)););return e}function j(){return(j="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=H(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}}).apply(this,arguments)}function Y(e,t){return q(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}(e,t)||Q(e,t)||$()}function K(e){return q(e)||Z(e)||Q(e)||$()}function z(e){return function(e){if(Array.isArray(e))return J(e)}(e)||Z(e)||Q(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e){if(Array.isArray(e))return e}function Z(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function Q(e,t){if(e){if("string"==typeof e)return J(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?J(e,t):void 0}}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function $(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ee(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Q(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}var te=L((function e(){B(this,e),this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]}));te.tag="c-renderable-3d";var ne,re,ie,oe,ae,se,ue,le,ce,fe,de,he,_e,pe,Ee,ve,Re,me,Te,ye,ge,Ae,Se,Ce,Oe,Ie,Ne,Pe=function(){function e(){B(this,e),this.counter=0,this.id2DisplayObjectMap={}}return L(e,[{key:"getId",value:function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t}},{key:"getById",value:function(e){return this.id2DisplayObjectMap[e]}},{key:"reset",value:function(){this.counter=0,this.id2DisplayObjectMap={}}},{key:"decodePickingColor",value:function(e){var t=Y(e,3);return t[0]+256*t[1]+65536*t[2]-1}},{key:"encodePickingColor",value:function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]}}]),e}();function De(e,t,n,r){return{dimension:Ee.n2D,pixelFormat:e,width:t,height:n,depth:1,numLevels:r,usage:ve.Sampled}}function Me(e){return e}function xe(e,t,n){return e<<16|t<<8|n}function Be(e){return e>>>8&255}function be(e){return e>>>16&255}function Le(e){return 255&e}function Fe(e){switch(e){case Se.F32:case Se.U32:case Se.S32:return 4;case Se.U16:case Se.S16:case Se.F16:return 2;case Se.U8:case Se.S8:return 1;default:throw new Error("whoops")}}function Ue(e){return Fe(be(e))}function Ge(e){return Be(e)}function we(e){return Fe(be(e))*Be(e)}function ke(e,t){return 4294967040&e|t}function We(e,t){return 4294902015&e|t<<8}function Ve(e){var t=Le(e);if(t&Oe.Depth)return Te.Depth;if(t&Oe.Normalized)return Te.Float;var n=be(e);if(n===Se.F16||n===Se.F32)return Te.Float;if(n===Se.U8||n===Se.U16||n===Se.U32)return Te.Uint;if(n===Se.S8||n===Se.S16||n===Se.S32)return Te.Sint;throw new Error("whoops")}function Xe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e)throw console.error((new Error).stack),new Error("Assert fail: ".concat(t))}function He(e){if(null!=e)return e;throw new Error("Missing object")}function je(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function Ye(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function Ke(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function ze(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{r:e,g:t,b:n,a:r}}Pe=l([Object(v.singleton)()],Pe),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.InputState=7]="InputState",e[e.RenderPipeline=8]="RenderPipeline",e[e.ComputePipeline=9]="ComputePipeline",e[e.Readback=10]="Readback",e[e.QueryPool=11]="QueryPool"}(ne||(ne={})),function(e){e[e.Never=512]="Never",e[e.Less=513]="Less",e[e.Equal=514]="Equal",e[e.LessEqual=515]="LessEqual",e[e.Greater=516]="Greater",e[e.NotEqual=517]="NotEqual",e[e.GreaterEqual=518]="GreaterEqual",e[e.Always=519]="Always"}(re||(re={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(ie||(ie={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(oe||(oe={})),function(e){e[e.Zero=0]="Zero",e[e.One=1]="One",e[e.Src=768]="Src",e[e.OneMinusSrc=769]="OneMinusSrc",e[e.Dst=774]="Dst",e[e.OneMinusDst=775]="OneMinusDst",e[e.SrcAlpha=770]="SrcAlpha",e[e.OneMinusSrcAlpha=771]="OneMinusSrcAlpha",e[e.DstAlpha=772]="DstAlpha",e[e.OneMinusDstAlpha=773]="OneMinusDstAlpha"}(ae||(ae={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(se||(se={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(ue||(ue={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(le||(le={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(ce||(ce={})),function(e){e[e.Points=0]="Points",e[e.Triangles=1]="Triangles",e[e.TriangleStrip=2]="TriangleStrip",e[e.Lines=3]="Lines",e[e.LineStrip=4]="LineStrip"}(fe||(fe={})),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"}(de||(de={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(he||(he={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(_e||(_e={})),function(e){e.LOADED="loaded"}(pe||(pe={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(Ee||(Ee={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(ve||(ve={})),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.AllChannels=15]="AllChannels"}(Re||(Re={})),function(e){e[e.Keep=7680]="Keep",e[e.Zero=0]="Zero",e[e.Replace=7681]="Replace",e[e.Invert=5386]="Invert",e[e.IncrementClamp=7682]="IncrementClamp",e[e.DecrementClamp=7683]="DecrementClamp",e[e.IncrementWrap=34055]="IncrementWrap",e[e.DecrementWrap=34056]="DecrementWrap"}(me||(me={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(Te||(Te={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(ye||(ye={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(ge||(ge={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(Ae||(Ae={})),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.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(Se||(Se={})),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"}(Ce||(Ce={})),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"}(Oe||(Oe={})),function(e){e[e.ALPHA=xe(Se.U8,Ce.A,Oe.None)]="ALPHA",e[e.F16_R=xe(Se.F16,Ce.R,Oe.None)]="F16_R",e[e.F16_RG=xe(Se.F16,Ce.RG,Oe.None)]="F16_RG",e[e.F16_RGB=xe(Se.F16,Ce.RGB,Oe.None)]="F16_RGB",e[e.F16_RGBA=xe(Se.F16,Ce.RGBA,Oe.None)]="F16_RGBA",e[e.F32_R=xe(Se.F32,Ce.R,Oe.None)]="F32_R",e[e.F32_RG=xe(Se.F32,Ce.RG,Oe.None)]="F32_RG",e[e.F32_RGB=xe(Se.F32,Ce.RGB,Oe.None)]="F32_RGB",e[e.F32_RGBA=xe(Se.F32,Ce.RGBA,Oe.None)]="F32_RGBA",e[e.U8_R=xe(Se.U8,Ce.R,Oe.None)]="U8_R",e[e.U8_R_NORM=xe(Se.U8,Ce.R,Oe.Normalized)]="U8_R_NORM",e[e.U8_RG=xe(Se.U8,Ce.RG,Oe.None)]="U8_RG",e[e.U8_RG_NORM=xe(Se.U8,Ce.RG,Oe.Normalized)]="U8_RG_NORM",e[e.U8_RGB=xe(Se.U8,Ce.RGB,Oe.None)]="U8_RGB",e[e.U8_RGB_NORM=xe(Se.U8,Ce.RGB,Oe.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=xe(Se.U8,Ce.RGB,Oe.sRGB|Oe.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=xe(Se.U8,Ce.RGBA,Oe.None)]="U8_RGBA",e[e.U8_RGBA_NORM=xe(Se.U8,Ce.RGBA,Oe.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=xe(Se.U8,Ce.RGBA,Oe.sRGB|Oe.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=xe(Se.U16,Ce.R,Oe.None)]="U16_R",e[e.U16_R_NORM=xe(Se.U16,Ce.R,Oe.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=xe(Se.U16,Ce.RG,Oe.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=xe(Se.U16,Ce.RGBA,Oe.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=xe(Se.U16,Ce.RGB,Oe.None)]="U16_RGB",e[e.U32_R=xe(Se.U32,Ce.R,Oe.None)]="U32_R",e[e.U32_RG=xe(Se.U32,Ce.RG,Oe.None)]="U32_RG",e[e.S8_R=xe(Se.S8,Ce.R,Oe.None)]="S8_R",e[e.S8_R_NORM=xe(Se.S8,Ce.R,Oe.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=xe(Se.S8,Ce.RG,Oe.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=xe(Se.S8,Ce.RGB,Oe.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=xe(Se.S8,Ce.RGBA,Oe.Normalized)]="S8_RGBA_NORM",e[e.S16_R=xe(Se.S16,Ce.R,Oe.None)]="S16_R",e[e.S16_RG=xe(Se.S16,Ce.RG,Oe.None)]="S16_RG",e[e.S16_RG_NORM=xe(Se.S16,Ce.RG,Oe.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=xe(Se.S16,Ce.RGB,Oe.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=xe(Se.S16,Ce.RGBA,Oe.None)]="S16_RGBA",e[e.S16_RGBA_NORM=xe(Se.S16,Ce.RGBA,Oe.Normalized)]="S16_RGBA_NORM",e[e.S32_R=xe(Se.S32,Ce.R,Oe.None)]="S32_R",e[e.U16_RGBA_5551=xe(Se.U16_PACKED_5551,Ce.RGBA,Oe.Normalized)]="U16_RGBA_5551",e[e.BC1=xe(Se.BC1,Ce.RGBA,Oe.Normalized)]="BC1",e[e.BC1_SRGB=xe(Se.BC1,Ce.RGBA,Oe.Normalized|Oe.sRGB)]="BC1_SRGB",e[e.BC2=xe(Se.BC2,Ce.RGBA,Oe.Normalized)]="BC2",e[e.BC2_SRGB=xe(Se.BC2,Ce.RGBA,Oe.Normalized|Oe.sRGB)]="BC2_SRGB",e[e.BC3=xe(Se.BC3,Ce.RGBA,Oe.Normalized)]="BC3",e[e.BC3_SRGB=xe(Se.BC3,Ce.RGBA,Oe.Normalized|Oe.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=xe(Se.BC4_UNORM,Ce.R,Oe.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=xe(Se.BC4_SNORM,Ce.R,Oe.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=xe(Se.BC5_UNORM,Ce.RG,Oe.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=xe(Se.BC5_SNORM,Ce.RG,Oe.Normalized)]="BC5_SNORM",e[e.D24=xe(Se.D24,Ce.R,Oe.Depth)]="D24",e[e.D24_S8=xe(Se.D24S8,Ce.RG,Oe.Depth|Oe.Stencil)]="D24_S8",e[e.D32F=xe(Se.D32F,Ce.R,Oe.Depth)]="D32F",e[e.D32F_S8=xe(Se.D32FS8,Ce.RG,Oe.Depth|Oe.Stencil)]="D32F_S8",e[e.U8_RGB_RT=xe(Se.U8,Ce.RGB,Oe.RenderTarget|Oe.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=xe(Se.U8,Ce.RGBA,Oe.RenderTarget|Oe.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=xe(Se.U8,Ce.RGBA,Oe.RenderTarget|Oe.Normalized|Oe.sRGB)]="U8_RGBA_RT_SRGB"}(Ie||(Ie={})),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"}(Ne||(Ne={}));var qe=ze(0,0,0,0),Ze=ze(0,0,0,1),Qe=ze(1,1,1,0),Je=ze(1,1,1,1),$e=!0;function et(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$e;t&&(e[10]=-e[10],e[14]=-e[14])}function tt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$e;t&&(e[10]=-e[10],e[14]=1-e[14])}function nt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$e;if(!t)return e;switch(e){case re.Less:return re.Greater;case re.LessEqual:return re.GreaterEqual;case re.GreaterEqual:return re.LessEqual;case re.Greater:return re.Less;default:return e}}function rt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$e;return t?1-e:e}function it(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$e;return t?-e:e}function ot(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$e;if((n=nt(n,r))===re.Less)return e<t;if(n===re.LessEqual)return e<=t;if(n===re.Greater)return e>t;if(n===re.GreaterEqual)return e>=t;throw new Error("whoops")}function at(e){return e&&0==(e&e-1)}function st(e,t){return null!=e?e:t}function ut(e){return void 0===e?null:e}function lt(e,t,n){e.length=t,e.fill(n)}function ct(e,t){var n=t-1;return e+n&~n}function ft(e,t){return((e+t-1)/t|0)*t}function dt(e,t,n){for(var r=0,i=e.length;r<i;){var o=r+(i-r>>>1);n(t,e[o])<0?i=o:r=o+1}return r}function ht(e,t,n){var r=dt(e,t,n);e.splice(r,0,t)}function _t(e,t,n){return n?e|=t:e&=~t,e}function pt(e,t){for(var n=new Array(e),r=0;r<e;r++)n[r]=t();return n}function Et(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e.split("\n");return n.map((function(e,n){return"".concat(vt(""+(t+n),4," ")," ").concat(e)})).join("\n")}function vt(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0";e.length<t;)e="".concat(n).concat(e);return e}function Rt(e,t){for(var n=[],r=e;r<e+t;r++)n.push(r);return n}function mt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Tt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),mt(e.rgbBlendState,t.rgbBlendState),mt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function yt(e,t){e.length!==t.length&&(e.length=t.length);for(var n=0;n<t.length;n++)e[n]=Tt(e[n],t[n])}function gt(e,t){void 0!==t.attachmentsState&&yt(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&Ye(e.blendConstant,t.blendConstant),e.depthCompare=st(t.depthCompare,e.depthCompare),e.depthWrite=st(t.depthWrite,e.depthWrite),e.stencilCompare=st(t.stencilCompare,e.stencilCompare),e.stencilWrite=st(t.stencilWrite,e.stencilWrite),e.stencilPassOp=st(t.stencilPassOp,e.stencilPassOp),e.stencilRef=st(t.stencilRef,e.stencilRef),e.cullMode=st(t.cullMode,e.cullMode),e.frontFace=st(t.frontFace,e.frontFace),e.polygonOffset=st(t.polygonOffset,e.polygonOffset)}function At(e){var t=Object.assign({},e);return t.attachmentsState=[],yt(t.attachmentsState,e.attachmentsState),t.blendConstant=Ke(t.blendConstant),t}function St(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)}var Ct={blendMode:se.Add,blendSrcFactor:ae.One,blendDstFactor:ae.Zero},Ot={attachmentsState:[{channelWriteMask:Re.RGB,rgbBlendState:Ct,alphaBlendState:Ct}],blendConstant:Ke(qe),depthWrite:!0,depthCompare:re.LessEqual,stencilCompare:re.Always,stencilWrite:!1,stencilPassOp:me.Keep,stencilRef:0,cullMode:oe.None,frontFace:ie.CCW,polygonOffset:!1};function It(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot,n=At(t);return null!==e&&gt(n,e),n}var Nt=It({depthCompare:re.Always,depthWrite:!1},Ot);function Pt(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],yt(e.attachmentsState,Ot.attachmentsState)),St(e.attachmentsState[0],t),e}var Dt,Mt={formatKind:Te.Float,dimension:Ee.n2D};function xt(e,t,n){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Bt(e,t){for(var n=Array(e.length),r=0;r<e.length;r++)n[r]=t(e[r]);return n}function bt(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function Lt(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function Ft(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Ut(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!xt(e.samplerBindings,t.samplerBindings,Lt)&&(!!xt(e.uniformBufferBindings,t.uniformBufferBindings,bt)&&!!kt(e.bindingLayout,t.bindingLayout)))}function Gt(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function wt(e,t){return!!Gt(e.rgbBlendState,t.rgbBlendState)&&(!!Gt(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function kt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Wt(e,t){return e===t}function Vt(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!xt(e.attachmentsState,t.attachmentsState,wt)&&(!!je(e.blendConstant,t.blendConstant)&&(e.depthCompare===t.depthCompare&&e.depthWrite===t.depthWrite&&e.stencilCompare===t.stencilCompare&&e.stencilWrite===t.stencilWrite&&e.stencilPassOp===t.stencilPassOp&&e.stencilRef===t.stencilRef&&e.cullMode===t.cullMode&&e.frontFace===t.frontFace&&e.polygonOffset===t.polygonOffset))}(e.megaStateDescriptor,t.megaStateDescriptor)&&(!!function(e,t){return e.id===t.id}(e.program,t.program)&&(!!xt(e.bindingLayouts,t.bindingLayouts,kt)&&(!!xt(e.colorAttachmentFormats,t.colorAttachmentFormats,Wt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function Xt(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Ht(e,t){return Object(E.isNil)(e)?Object(E.isNil)(t):!Object(E.isNil)(t)&&(e.byteStride===t.byteStride&&e.frequency===t.frequency)}function jt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!xt(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Ht)&&!!xt(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,Xt))}function Yt(e,t){return e.wrapS===t.wrapS&&e.wrapT===t.wrapT&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipFilter===t.mipFilter&&e.minLOD===t.minLOD&&e.maxLOD===t.maxLOD&&e.maxAnisotropy===t.maxAnisotropy&&e.compareMode===t.compareMode}function Kt(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function zt(){return{sampler:null,texture:null,lateBinding:null}}function qt(e){return{buffer:e.buffer,wordCount:e.wordCount}}function Zt(e){return{bindingLayout:e.bindingLayout,samplerBindings:Bt(e.samplerBindings,Kt),uniformBufferBindings:Bt(e.uniformBufferBindings,qt),pipeline:e.pipeline}}function Qt(e){return{dimension:e.dimension,formatKind:e.formatKind}}function Jt(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?Bt(e.samplerEntries,Qt):void 0}}function $t(e){var t=Bt(e.bindingLayouts,Jt),n=e.inputLayout,r=e.program,i=e.topology;return{bindingLayouts:t,inputLayout:n,megaStateDescriptor:At(e.megaStateDescriptor),program:r,topology:i,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function en(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function tn(e){return Object(E.isNil)(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function nn(e){return{vertexAttributeDescriptors:Bt(e.vertexAttributeDescriptors,en),vertexBufferDescriptors:Bt(e.vertexBufferDescriptors,tn),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(Dt||(Dt={}));var rn,on=new Uint16Array([65279]),an=255==new DataView(on.buffer).getUint8(0)?Dt.LITTLE_ENDIAN:Dt.BIG_ENDIAN;function sn(){return an}var un=/([^[]*)(\[[0-9]+\])?/;function ln(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(un);if(!t||t.length<2)throw new Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:Boolean(t[2])}}function cn(){var e=null;return function(t,n,r){var i=e!==r;return i&&(t.uniform1i(n,r),e=r),i}}function fn(e,t,n,r){var i=null,o=null;return function(a,s,u){var l=t(u,n),c=l.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{Xe(o===c,"Uniform length cannot change.");for(var d=0;d<c;++d)if(l[d]!==i[d]){f=!0;break}}return f&&(r(a,e,s,l),i.set(l)),f}}function dn(e,t,n,r){e[t](n,r)}function hn(e,t,n,r){e[t](n,!1,r)}var _n={},pn={},En={},vn=[0];function Rn(e,t,n,r){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(vn[0]=e,e=vn);var i=e.length;if(e instanceof n)return e;var o=r[i];o||(o=new n(i),r[i]=o);for(var a=0;a<i;a++)o[a]=e[a];return o}function mn(e,t){return Rn(e,t,Float32Array,_n)}function Tn(e,t){return Rn(e,t,Int32Array,pn)}function yn(e,t){return Rn(e,t,Uint32Array,En)}var gn=(F(rn={},Ne.FLOAT,fn.bind(null,"uniform1fv",mn,1,dn)),F(rn,Ne.FLOAT_VEC2,fn.bind(null,"uniform2fv",mn,2,dn)),F(rn,Ne.FLOAT_VEC3,fn.bind(null,"uniform3fv",mn,3,dn)),F(rn,Ne.FLOAT_VEC4,fn.bind(null,"uniform4fv",mn,4,dn)),F(rn,Ne.INT,fn.bind(null,"uniform1iv",Tn,1,dn)),F(rn,Ne.INT_VEC2,fn.bind(null,"uniform2iv",Tn,2,dn)),F(rn,Ne.INT_VEC3,fn.bind(null,"uniform3iv",Tn,3,dn)),F(rn,Ne.INT_VEC4,fn.bind(null,"uniform4iv",Tn,4,dn)),F(rn,Ne.BOOL,fn.bind(null,"uniform1iv",Tn,1,dn)),F(rn,Ne.BOOL_VEC2,fn.bind(null,"uniform2iv",Tn,2,dn)),F(rn,Ne.BOOL_VEC3,fn.bind(null,"uniform3iv",Tn,3,dn)),F(rn,Ne.BOOL_VEC4,fn.bind(null,"uniform4iv",Tn,4,dn)),F(rn,Ne.FLOAT_MAT2,fn.bind(null,"uniformMatrix2fv",mn,4,hn)),F(rn,Ne.FLOAT_MAT3,fn.bind(null,"uniformMatrix3fv",mn,9,hn)),F(rn,Ne.FLOAT_MAT4,fn.bind(null,"uniformMatrix4fv",mn,16,hn)),F(rn,Ne.SAMPLER_2D,cn),F(rn,Ne.SAMPLER_CUBE,cn),F(rn,Ne.UNSIGNED_INT,fn.bind(null,"uniform1uiv",yn,1,dn)),F(rn,Ne.UNSIGNED_INT_VEC2,fn.bind(null,"uniform2uiv",yn,2,dn)),F(rn,Ne.UNSIGNED_INT_VEC3,fn.bind(null,"uniform3uiv",yn,3,dn)),F(rn,Ne.UNSIGNED_INT_VEC4,fn.bind(null,"uniform4uiv",yn,4,dn)),F(rn,Ne.FLOAT_MAT2x3,fn.bind(null,"uniformMatrix2x3fv",mn,6,hn)),F(rn,Ne.FLOAT_MAT2x4,fn.bind(null,"uniformMatrix2x4fv",mn,8,hn)),F(rn,Ne.FLOAT_MAT3x2,fn.bind(null,"uniformMatrix3x2fv",mn,6,hn)),F(rn,Ne.FLOAT_MAT3x4,fn.bind(null,"uniformMatrix3x4fv",mn,12,hn)),F(rn,Ne.FLOAT_MAT4x2,fn.bind(null,"uniformMatrix4x2fv",mn,8,hn)),F(rn,Ne.FLOAT_MAT4x3,fn.bind(null,"uniformMatrix4x3fv",mn,12,hn)),F(rn,Ne.SAMPLER_2D,cn),F(rn,Ne.SAMPLER_CUBE,cn),F(rn,Ne.SAMPLER_3D,cn),F(rn,Ne.SAMPLER_2D_SHADOW,cn),F(rn,Ne.SAMPLER_2D_ARRAY,cn),F(rn,Ne.SAMPLER_2D_ARRAY_SHADOW,cn),F(rn,Ne.SAMPLER_CUBE_SHADOW,cn),F(rn,Ne.INT_SAMPLER_2D,cn),F(rn,Ne.INT_SAMPLER_3D,cn),F(rn,Ne.INT_SAMPLER_CUBE,cn),F(rn,Ne.INT_SAMPLER_2D_ARRAY,cn),F(rn,Ne.UNSIGNED_INT_SAMPLER_2D,cn),F(rn,Ne.UNSIGNED_INT_SAMPLER_3D,cn),F(rn,Ne.UNSIGNED_INT_SAMPLER_CUBE,cn),F(rn,Ne.UNSIGNED_INT_SAMPLER_2D_ARRAY,cn),rn);function An(e,t,n){var r=gn[n.type];if(!r)throw new Error("Unknown GLSL uniform type ".concat(n.type));return r().bind(null,e,t)}var Sn=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function Cn(e,t){return"#define ".concat(e," ").concat(t)}function On(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,n,r){var i=Number(r);return t[n]=isNaN(i)?r:i,""})),t}function In(e,t){var n=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,r,i){var o=Number(r);return n.push({location:isNaN(o)?t[r]:o,name:i}),""})),n}function Nn(e){var t=[],n=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,r){var i=[];return r.trim().split("\n").forEach((function(e){var t=Y(e.trim().split(/\s+/),2),n=t[0],r=t[1];i.push({type:n.trim(),name:r.replace(";","").trim()})})),n.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,r){return r.trim().split("\n").forEach((function(e){var r=e.trim().split(" "),i=r[0]||"",o=r[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=n.find((function(e){return i===e.type}));if(s)if(a)for(var u=function(e){s.uniforms.forEach((function(n){t.push("".concat(o,"[").concat(e,"].").concat(n.name))}))},l=0;l<5;l++)u(l);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}function Pn(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i="#version 100"===e.glslVersion,o=!1,a=n.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),s="";null!==r&&(s=z(r.entries()).map((function(e){var t=Y(e,2);return Cn(t[0],t[1])})).join("\n"));var u=a.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",l=a.filter((function(e){return!e.startsWith("precision")})).join("\n"),c="";if(e.viewportOrigin===ye.UpperLeft&&(c+="".concat(Cn("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===ge.Zero&&(c+="".concat(Cn("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var f=0,d=0,h=0;l=l.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,n,r){var i=n?"".concat(n,", "):"";return"layout(".concat(i,"set = ").concat(f,", binding = ").concat(d++,") uniform ").concat(r)})),f++,d=0,Xe(e.separateSamplerTextures),l=(l=l.replace(/uniform sampler2D (.*);/g,(function(e,n){return"frag"===t?"\nlayout(set = ".concat(f,", binding = ").concat(d++,") uniform texture2D T_").concat(n,";\nlayout(set = ").concat(f,", binding = ").concat(d++,") uniform sampler S_").concat(n,";\n"):""}))).replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(h++,") ").concat(t)})),c+="".concat(Cn("gl_VertexID","gl_VertexIndex"),"\n")}l=e.separateSamplerTextures?(l=(l=(l=l.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"texture2D T_P_".concat(t,", sampler S_P_").concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"T_".concat(t,", S_").concat(t)}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D(T_".concat(t,", S_").concat(t,")")})):(l=(l=(l=l.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D P_".concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return t}));var _="".concat(i?"":e.glslVersion,"\n").concat(i&&o?"#extension GL_EXT_draw_buffers : require":"","\n").concat(i&&"frag"===t?"#extension GL_OES_standard_derivatives : enable":"","\n").concat(u,"\n").concat(c,"\n").concat(s,"\n").concat(l,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(_=_.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) ".concat(t)}))),i){if("frag"===t&&(_=_.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return"varying ".concat(t," ").concat(n,";\n")}))),"vert"===t&&(_=(_=_.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return"varying ".concat(t," ").concat(n,";\n")}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return"attribute ".concat(t," ").concat(n,";\n")}))),_=_.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){var p,E=(_=_.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,n){return p=n,"".concat(t," ").concat(n,";\n")}))).lastIndexOf("}");_=_.substring(0,E)+"\n gl_FragColor = vec4(".concat(p,");\n")+_.substring(E)}_=_.replace(/^\s*layout\((.*)\)/gm,"");var v,R=ee(Sn);try{for(R.s();!(v=R.n()).done;){var m=Y(v.value,2),T=m[0],y=m[1];_=_.replace(T,y)}}catch(e){R.e(e)}finally{R.f()}}return _}function Dn(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=Pn(e,"vert",t,r,i),a=Pn(e,"frag",n,r,i);return{vert:t,frag:n,preprocessedVert:o,preprocessedFrag:a}}function Mn(e,t){var n=void 0!==t.defines?t.defines:null,r=void 0!==t.features?t.features:null,i=void 0!==t.both?t.both+t.vert:t.vert,o=void 0!==t.both?t.both+t.frag:t.frag;return Dn(e.queryVendorInfo(),i,o,n,r)}var xn=function(){function e(){B(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines=new Map,this.features={MRT:!0}}return L(e,[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,t){if(null!==t){if(this.defines.get(e)===t)return!1;this.defines.set(e,t)}else{if(!this.defines.has(e))return!1;this.defines.delete(e)}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return ut(this.defines.get(e))}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&Xe("1"===t),null!==t}},{key:"ensurePreprocessed",value:function(e){""===this.preprocessedVert&&(this.preprocessedVert=Pn(e,"vert",this.both+this.vert,this.defines,this.features),this.preprocessedFrag=Pn(e,"frag",this.both+this.frag,this.defines,this.features))}}]),e}(),Bn=function(){function e(t){B(this,e),this.device=void 0,this.uniformBufferWordAlignment=void 0,this.uniformBufferMaxPageWordSize=void 0,this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=t;var n=t.queryLimits();this.uniformBufferWordAlignment=n.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=n.uniformBufferMaxPageWordSize}return L(e,[{key:"isSupportedUBO",value:function(){return"WebGL1"!==this.device.queryVendorInfo().platformString}},{key:"findPageIndex",value:function(e){return e/this.uniformBufferMaxPageWordSize|0}},{key:"allocateChunk",value:function(e){Xe((e=ft(e,this.uniformBufferWordAlignment))<this.uniformBufferMaxPageWordSize);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=ft(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t}},{key:"ensureShadowBuffer",value:function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var n=ft(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*n),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Xe(e<this.currentWordOffset&&e+t<=this.currentWordOffset);var r=ft(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*r);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),!(this.currentWordOffset<=r))throw new Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}}},{key:"mapBufferF32",value:function(){return He(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=He(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:this.currentBufferWordSize,usage:de.UNIFORM|de.COPY_DST,hint:he.Dynamic}));var t=ft(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(!(t<=this.currentBufferWordSize))throw new Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())He(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}}},{key:"destroy",value:function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null}}]),e}();function bn(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function Ln(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Fn(e){return 0}var Un=L((function e(){B(this,e),this.keys=[],this.values=[]})),Gn=function(){function e(t,n){B(this,e),this.keyEqualFunc=void 0,this.keyHashFunc=void 0,this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=n}return L(e,[{key:"findBucketIndex",value:function(e,t){for(var n=0;n<e.keys.length;n++)if(this.keyEqualFunc(t,e.keys[n]))return n;return-1}},{key:"findBucket",value:function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)}},{key:"get",value:function(e){var t=this.findBucket(e);if(void 0===t)return null;var n=this.findBucketIndex(t,e);return n<0?null:t.values[n]}},{key:"add",value:function(e,t){var n=this.keyHashFunc(e);void 0===this.buckets.get(n)&&this.buckets.set(n,new Un);var r=this.buckets.get(n);r.keys.push(e),r.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var n=this.findBucketIndex(t,e);-1!==n&&(t.keys.splice(n,1),t.values.splice(n,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,n=ee(this.buckets.values());try{for(n.s();!(e=n.n()).done;){t+=e.value.values.length}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"values",value:regeneratorRuntime.mark((function e(){var t,n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=ee(this.buckets.values()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=14;break}r=n.value,i=r.values.length-1;case 6:if(!(i>=0)){e.next=12;break}return e.next=9,r.values[i];case 9:i--,e.next=6;break;case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),t.e(e.t0);case 19:return e.prev=19,t.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[1,16,19,22]])}))}]),e}();function wn(e,t){return Xe(""!==e.preprocessedVert&&""!==t.preprocessedVert),Xe(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function kn(e,t){return e=bn(e,t.numUniformBuffers),e=bn(e,t.numSamplers)}function Wn(e,t){return e=bn(e,t.blendMode),e=bn(e,t.blendSrcFactor),e=bn(e,t.blendDstFactor)}function Vn(e,t){return e=Wn(e,t.rgbBlendState),e=bn(e=Wn(e,t.alphaBlendState),t.channelWriteMask)}function Xn(e,t){for(var n=0;n<t.attachmentsState.length;n++)e=Vn(e,t.attachmentsState[n]);return e=function(e,t){return e=bn(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=bn(e,t.depthCompare),e=bn(e,t.depthWrite?1:0),e=bn(e,t.stencilCompare),e=bn(e,t.stencilPassOp),e=bn(e,t.stencilWrite?1:0),e=bn(e,t.cullMode),e=bn(e,t.frontFace?1:0),e=bn(e,t.polygonOffset?1:0)}function Hn(e){var t=0;t=bn(t,e.program.id),null!==e.inputLayout&&(t=bn(t,e.inputLayout.id));for(var n=0;n<e.bindingLayouts.length;n++)t=kn(t,e.bindingLayouts[n]);t=Xn(t,e.megaStateDescriptor);for(var r=0;r<e.colorAttachmentFormats.length;r++)t=bn(t,e.colorAttachmentFormats[r]||0);return Ln(t=bn(t,e.depthStencilAttachmentFormat||0))}function jn(e){for(var t=0,n=0;n<e.samplerBindings.length;n++){var r=e.samplerBindings[n];null!==r&&null!==r.texture&&(t=bn(t,r.texture.id))}for(var i=0;i<e.uniformBufferBindings.length;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=bn(t,o.buffer.id),t=bn(t,o.wordCount))}return Ln(t)}var Yn,Kn=function(){function e(t){B(this,e),this.device=void 0,this.bindingsCache=new Gn(Ut,jn),this.renderPipelinesCache=new Gn(Vt,Hn),this.inputLayoutsCache=new Gn(jt,Fn),this.programCache=new Gn(wn,Fn),this.samplerCache=new Gn(Yt,Fn),this.device=t}return L(e,[{key:"createBindings",value:function(e){var t=this.bindingsCache.get(e);if(null===t){var n=Zt(e);t=this.device.createBindings(n),this.bindingsCache.add(n,t)}return t}},{key:"createRenderPipeline",value:function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var n=$t(e);t=this.device.createRenderPipeline(n),this.renderPipelinesCache.add(n,t)}return t}},{key:"createInputLayout",value:function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var n=nn(e);t=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,t)}return t}},{key:"createProgramSimple",value:function(e){var t,n=this.programCache.get(e);if(null===n){var r={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};n=this.device.createProgramSimple(r),this.programCache.add(r,n)}return n}},{key:"createProgram",value:function(e){return e.ensurePreprocessed(this.device.queryVendorInfo()),this.createProgramSimple(e)}},{key:"createSampler",value:function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t}},{key:"destroy",value:function(){var e,t=ee(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var n,r=ee(this.renderPipelinesCache.values());try{for(r.s();!(n=r.n()).done;){n.value.destroy()}}catch(e){r.e(e)}finally{r.f()}var i,o=ee(this.inputLayoutsCache.values());try{for(o.s();!(i=o.n()).done;){i.value.destroy()}}catch(e){o.e(e)}finally{o.f()}var a,s=ee(this.programCache.values());try{for(s.s();!(a=s.n()).done;){a.value.destroy()}}catch(e){s.e(e)}finally{s.f()}var u,l=ee(this.samplerCache.values());try{for(l.s();!(u=l.n()).done;){u.value.destroy()}}catch(e){l.e(e)}finally{l.f()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}]),e}();!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"}(Yn||(Yn={}));var zn,qn={x:0,y:0,w:1,h:1},Zn=function(){function e(){B(this,e),this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=qn,this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorResolveTo:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=0,this.viewportH=0,this.execFunc=null,this.postFunc=null,this.debugName=void 0,this.debugThumbnails=[]}return L(e,[{key:"setDebugName",value:function(e){this.debugName=e}},{key:"pushDebugThumbnail",value:function(e){this.debugThumbnails[e]=!0}},{key:"setViewport",value:function(e){this.viewport=e}},{key:"attachRenderTargetID",value:function(e,t){Xe(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t}},{key:"attachResolveTexture",value:function(e){this.resolveTextureInputIDs.push(e)}},{key:"attachOcclusionQueryPool",value:function(e){this.descriptor.occlusionQueryPool=e}},{key:"resolveToExternalTexture",value:function(e,t){this.resolveTextureOutputExternalTextures[e]=t}},{key:"exec",value:function(e){Xe(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){Xe(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}]),e}(),Qn=function(){function e(t,n){B(this,e),this.debugName=void 0,this.dimension=Ee.n2D,this.depth=1,this.numLevels=1,this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.usage=ve.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.attachment=void 0,this.age=0,this.pixelFormat=n.pixelFormat,this.width=n.width,this.height=n.height,this.sampleCount=n.sampleCount,Xe(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))}return L(e,[{key:"setDebugName",value:function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}},{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount}},{key:"reset",value:function(e){Xe(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()}}]),e}(),Jn=function(){function e(t,n){B(this,e),this.dimension=Ee.n2D,this.depth=1,this.numLevels=1,this.usage=ve.RenderTarget,this.pixelFormat=void 0,this.width=0,this.height=0,this.texture=void 0,this.age=0,this.immutable=!0,this.pixelFormat=n.pixelFormat,this.width=n.width,this.height=n.height,this.texture=t.createTexture(this)}return L(e,[{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){Xe(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}]),e}();zn=Symbol.species;var $n,er=L((function e(){B(this,e),this[zn]=void 0,this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]})),tr=function(){function e(t){B(this,e),this.device=void 0,this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=t}return L(e,[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;t<this.renderTargetDeadPool.length;t++){var n=this.renderTargetDeadPool[t];if(n.matchesDescription(e))return n.reset(e),this.renderTargetDeadPool.splice(t--,1),n}return new Qn(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;t<this.singleSampledTextureDeadPool.length;t++){var n=this.singleSampledTextureDeadPool[t];if(n.matchesDescription(e))return n.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),n}return new Jn(this.device,e)}},{key:"beginGraphBuilder",value:function(){Xe(null===this.currentGraph),this.currentGraph=new er}},{key:"pushPass",value:function(e){var t=new Zn;e(t),this.currentGraph.passes.push(t)}},{key:"createRenderTargetID",value:function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1}},{key:"createResolveTextureID",value:function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}},{key:"findMostRecentPassThatAttachedRenderTarget",value:function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var n=this.currentGraph.passes[t];if(n.renderTargetIDs.includes(e))return n}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var n=e;if(void 0===n.resolveTextureOutputIDs[t]){var r=n.renderTargetIDs[t],i=this.createResolveTextureID(r);n.resolveTextureOutputIDs[t]=i}return n.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=He(this.findMostRecentPassThatAttachedRenderTarget(e)),n=t.renderTargetIDs.indexOf(e);return Xe(void 0===t.resolveTextureOutputExternalTextures[n]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),n=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,n)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var n=this.findPassForResolveRenderTarget(e),r=n.renderTargetIDs.indexOf(e);Xe(void 0===n.resolveTextureOutputIDs[r]),n.resolveTextureOutputExternalTextures[r]=t}},{key:"getRenderTargetDescription",value:function(e){return He(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var n=0;n<t.renderTargetIDs.length;n++){var r=t.renderTargetIDs[n];void 0!==r&&(this.renderTargetOutputCount[r]++,t.renderTargetExtraRefs[n]&&this.renderTargetOutputCount[r]++)}for(var i=0;i<t.resolveTextureInputIDs.length;i++){var o=t.resolveTextureInputIDs[i];if(void 0!==o){this.resolveTextureUseCount[o]++;var a=e.resolveTextureRenderTargetIDs[o];this.renderTargetResolveCount[a]++}}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if(Xe(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var n=e.renderTargetDescriptions[t],r=this.acquireRenderTargetForDescription(n);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var n=He(this.renderTargetAliveForID[e]);return t?(Xe(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Xe(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(n.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(n)),n}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var n=e.resolveTextureRenderTargetIDs[t];Xe(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var r=He(this.releaseRenderTargetForID(n,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return He(r.texture)}},{key:"determineResolveParam",value:function(e,t,n){var r=t.renderTargetIDs[n],i=t.resolveTextureOutputIDs[n],o=t.resolveTextureOutputExternalTextures[n],a=void 0!==i,s=void 0!==o;Xe(!(a&&s));var u=null,l=!1;if(this.renderTargetOutputCount[r]>1&&(l=!0),a){Xe(e.resolveTextureRenderTargetIDs[i]===r),Xe(this.resolveTextureUseCount[i]>0),Xe(this.renderTargetOutputCount[r]>0);var c=He(this.renderTargetAliveForID[r]);if(null!==c.texture&&1===this.renderTargetOutputCount[r])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=He(e.renderTargetDescriptions[r]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(f),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,c.debugName+" (Resolve ".concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else u=s?o:null;return{resolveTo:u,store:l}}},{key:"schedulePass",value:function(e,t){for(var n=t.renderTargetIDs[Yn.DepthStencil],r=Yn.Color0;r<=Yn.ColorMax;r++){var i=t.renderTargetIDs[r],o=this.acquireRenderTargetForID(e,i);t.renderTargets[r]=o,t.descriptor.colorAttachment[r]=null!==o?o.attachment:null;var a=this.determineResolveParam(e,t,r),s=a.resolveTo,u=a.store;t.descriptor.colorResolveTo[r]=s,t.descriptor.colorStore[r]=u,t.descriptor.colorClearColor[r]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,n);t.renderTargets[Yn.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,Yn.DepthStencil),f=c.resolveTo,d=c.store;t.descriptor.depthStencilResolveTo=f,t.descriptor.depthStencilStore=d,t.descriptor.depthClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[n].depthClearValue:"load",t.descriptor.stencilClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[n].stencilClearValue:"load";for(var h=0,_=0,p=0,E=0;E<t.renderTargets.length;E++){var v=t.renderTargets[E];v&&(0===h&&(h=v.width,_=v.height,p=v.sampleCount),Xe(v.width===h),Xe(v.height===_),Xe(v.sampleCount===p),v.needsClear=!1)}if(h>0&&_>0){var R=h*t.viewport.x,m=_*t.viewport.y,T=h*t.viewport.w,y=_*t.viewport.h;t.viewportX=R,t.viewportY=m,t.viewportW=T,t.viewportH=y}for(var g=0;g<t.resolveTextureInputIDs.length;g++){var A=t.resolveTextureInputIDs[g];t.resolveTextureInputTextures[g]=this.acquireResolveTextureInputTextureForID(e,A)}for(var S=0;S<t.renderTargetIDs.length;S++)this.releaseRenderTargetForID(t.renderTargetIDs[S],!0);for(var C=0;C<t.renderTargetExtraRefs.length;C++)t.renderTargetExtraRefs[C]&&this.releaseRenderTargetForID(t.renderTargetIDs[C],!0)}},{key:"scheduleGraph",value:function(e){Xe(0===this.renderTargetOutputCount.length),Xe(0===this.renderTargetResolveCount.length),Xe(0===this.resolveTextureUseCount.length);for(var t=0;t<this.renderTargetDeadPool.length;t++)this.renderTargetDeadPool[t].age++;for(var n=0;n<this.singleSampledTextureDeadPool.length;n++)this.singleSampledTextureDeadPool[n].age++;lt(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),lt(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),lt(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var r=0;r<e.passes.length;r++)this.scheduleAddUseCount(e,e.passes[r]);for(var i=0;i<e.passes.length;i++)this.schedulePass(e,e.passes[i]);for(var o=0;o<this.renderTargetOutputCount.length;o++)Xe(0===this.renderTargetOutputCount[o]);for(var a=0;a<this.renderTargetResolveCount.length;a++)Xe(0===this.renderTargetResolveCount[a]);for(var s=0;s<this.resolveTextureUseCount.length;s++)Xe(0===this.resolveTextureUseCount[s]);for(var u=0;u<this.renderTargetAliveForID.length;u++)Xe(void 0===this.renderTargetAliveForID[u]);for(var l=0;l<this.renderTargetDeadPool.length;l++)this.renderTargetDeadPool[l].age>=1&&(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;c<this.singleSampledTextureDeadPool.length;c++)this.singleSampledTextureDeadPool[c].age>=1&&(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}},{key:"execPass",value:function(e){Xe(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.beginDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.endDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null}},{key:"execGraph",value:function(e){var t=this;this.scheduleGraph(e),e.passes.forEach((function(e){t.execPass(e)})),this.singleSampledTextureForResolveTextureID.length=0}},{key:"execute",value:function(){var e=He(this.currentGraph);this.execGraph(e),this.currentGraph=null}},{key:"getDebug",value:function(){return this}},{key:"getPasses",value:function(){return this.currentGraph.passes}},{key:"getPassDebugThumbnails",value:function(e){return e.debugThumbnails}},{key:"getPassRenderTargetID",value:function(e,t){return e.renderTargetIDs[t]}},{key:"getRenderTargetIDDebugName",value:function(e){return this.currentGraph.renderTargetDebugNames[e]}},{key:"getResolveTextureForID",value:function(e){var t=this.currentPass,n=t.resolveTextureInputIDs.indexOf(e);return Xe(n>=0),He(t.resolveTextureInputTextures[n])}},{key:"getRenderTargetAttachment",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null}},{key:"getRenderTargetTexture",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null}},{key:"newGraphBuilder",value:function(){return this.beginGraphBuilder(),this}},{key:"destroy",value:function(){for(var e=0;e<this.renderTargetAliveForID.length;e++)Xe(void 0===this.renderTargetAliveForID[e]);for(var t=0;t<this.singleSampledTextureForResolveTextureID.length;t++)Xe(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var n=0;n<this.renderTargetDeadPool.length;n++)this.renderTargetDeadPool[n].destroy();for(var r=0;r<this.singleSampledTextureDeadPool.length;r++)this.singleSampledTextureDeadPool[r].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"}($n||($n={}));function nr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,r=Object(E.clamp)(e,0,n)/n;t&&(r=1-r);var i=65535*r;return 65535&i}function rr(e){return e>>>24&255}function ir(e,t){return(16777215&e|(255&t)<<24)>>>0}function or(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function ar(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e}function sr(e,t){return ir(or(0,t),e)}function ur(e,t){return Xe(t>=0),(4294967040&e|t>>>8&255)>>>0}function lr(e){return ir(0,e)}function cr(e,t){return Xe(t>=0),(4278190335&e|t<<8)>>>0}function fr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&$n.TRANSLUCENT?lr(e):sr(e,t)}function dr(e,t){return!!(e>>>31&1)?cr(e,t):ur(e,t)}function hr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,r=!!(e>>>31&1),i=nr(t,r,n);return r?cr(e,i):ur(e,i)}function _r(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e}var pr="undefined"!=typeof Float32Array?Float32Array:Array;function Er(){var e=new pr(16);return pr!=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 vr(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 Rr(e,t,n,r,i,o,a,s,u,l,c,f,d,h,_,p){var E=new pr(16);return E[0]=e,E[1]=t,E[2]=n,E[3]=r,E[4]=i,E[5]=o,E[6]=a,E[7]=s,E[8]=u,E[9]=l,E[10]=c,E[11]=f,E[12]=d,E[13]=h,E[14]=_,E[15]=p,E}function mr(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 Tr=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],d=t[9],h=t[10],_=t[11],p=t[12],E=t[13],v=t[14],R=t[15],m=n[0],T=n[1],y=n[2],g=n[3];return e[0]=m*r+T*s+y*f+g*p,e[1]=m*i+T*u+y*d+g*E,e[2]=m*o+T*l+y*h+g*v,e[3]=m*a+T*c+y*_+g*R,m=n[4],T=n[5],y=n[6],g=n[7],e[4]=m*r+T*s+y*f+g*p,e[5]=m*i+T*u+y*d+g*E,e[6]=m*o+T*l+y*h+g*v,e[7]=m*a+T*c+y*_+g*R,m=n[8],T=n[9],y=n[10],g=n[11],e[8]=m*r+T*s+y*f+g*p,e[9]=m*i+T*u+y*d+g*E,e[10]=m*o+T*l+y*h+g*v,e[11]=m*a+T*c+y*_+g*R,m=n[12],T=n[13],y=n[14],g=n[15],e[12]=m*r+T*s+y*f+g*p,e[13]=m*i+T*u+y*d+g*E,e[14]=m*o+T*l+y*h+g*v,e[15]=m*a+T*c+y*_+g*R,e};function yr(e,t,n){var r=new pr(3);return r[0]=e,r[1]=t,r[2]=n,r}var gr,Ar;gr=new pr(3),pr!=Float32Array&&(gr[0]=0,gr[1]=0,gr[2]=0),Ar=gr;!function(){var e=function(){var e=new pr(2);return pr!=Float32Array&&(e[0]=0,e[1]=0),e}()}();var Sr=Rr(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Cr,Or=Rr(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Ir(e,t,n){t!==n&&(t===ge.NegativeOne?function(e){Tr(e,Sr,e)}(e):t===ge.Zero&&function(e){Tr(e,Or,e)}(e))}function Nr(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=r,4}function Pr(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return e[t+0]=n,e[t+1]=r,e[t+2]=i,e[t+3]=o,4}function Dr(e,t,n){return e[t+0]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],4}function Mr(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.a;return e[t+0]=n.r,e[t+1]=n.g,e[t+2]=n.b,e[t+3]=r,4}function xr(e,t,n){return e[t+0]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],16}!function(e){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"}(Cr||(Cr={}));var Br,br=function(){function e(){B(this,e),this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=pt(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=pt(4,(function(){return 0})),this.flags=0,this.inputState=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={bindingLayouts:[],inputLayout:null,megaStateDescriptor:At(Ot),program:null,topology:fe.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return L(e,[{key:"reset",value:function(){this.sortKey=0,this.flags=Cr.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){gt(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 t=0;t<e.renderPipelineDescriptor.colorAttachmentFormats.length;t++)this.renderPipelineDescriptor.colorAttachmentFormats[t]=e.renderPipelineDescriptor.colorAttachmentFormats[t];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.inputState=e.inputState,this.uniformBuffer=e.uniformBuffer,this.uniforms=z(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~Cr.InheritedFlags|e.flags&Cr.InheritedFlags,this.sortKey=e.sortKey;var n=this.bindingDescriptors[0],r=e.bindingDescriptors[0];null!==r.bindingLayout&&this.setBindingLayout(r.bindingLayout);for(var i=0;i<Math.min(n.uniformBufferBindings.length,r.uniformBufferBindings.length);i++)n.uniformBufferBindings[i].wordCount=e.bindingDescriptors[0].uniformBufferBindings[i].wordCount;this.setSamplerBindingsFromTextureMappings(r.samplerBindings);for(var o=0;o<e.dynamicUniformBufferByteOffsets.length;o++)this.dynamicUniformBufferByteOffsets[o]=e.dynamicUniformBufferByteOffsets[o]}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return gt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor}},{key:"getMegaStateFlags",value:function(){return this.renderPipelineDescriptor.megaStateDescriptor}},{key:"setInputLayoutAndState",value:function(e,t){this.inputState=t,this.renderPipelineDescriptor.inputLayout=e}},{key:"setBindingLayout",value:function(e){Xe(e.numUniformBuffers<this.dynamicUniformBufferByteOffsets.length),this.renderPipelineDescriptor.bindingLayouts[0]=e,this.bindingDescriptors[0].bindingLayout=e;for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;t<e.numUniformBuffers;t++)this.bindingDescriptors[0].uniformBufferBindings.push({buffer:null,wordCount:0});for(var n=this.bindingDescriptors[0].samplerBindings.length;n<e.numSamplers;n++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})}},{key:"setBindingLayouts",value:function(e){Xe(e.length<=this.bindingDescriptors.length),Xe(1===e.length),this.setBindingLayout(e[0])}},{key:"drawIndexes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=_t(this.flags,Cr.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=_t(this.flags,Cr.Indexed,!0),this.drawCount=e,this.drawStart=n,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=_t(this.flags,Cr.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"setUniforms",value:function(e,t){if(0!==t.length){this.uniforms[e]=t;var n=0,r=[];t.forEach((function(e){var t=e.value,i="number"==typeof t?[t]:t,o=i.length>4?4:i.length,a=4-n%4;if(4!==a)if(a>=o);else{n+=a;for(var s=0;s<a;s++)r.push(0)}n+=i.length,r.push.apply(r,z(i))}));var i=4-r.length%4;if(4!==i)for(var o=0;o<i;o++)r.push(0);for(var a=this.allocateUniformBuffer(e,r.length),s=this.mapUniformBufferF32(e),u=0;u<r.length;u+=4)a+=Pr(s,a,r[u],r[u+1],r[u+2],r[u+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){return Xe(this.bindingDescriptors[0].bindingLayout.numUniformBuffers<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=t,this.getUniformBufferOffset(e)}},{key:"getUniformBufferOffset",value:function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2}},{key:"setUniformBufferOffset",value:function(e,t,n){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=n}},{key:"mapUniformBufferF32",value:function(e){return this.uniformBuffer.mapBufferF32()}},{key:"getUniformBuffer",value:function(){return this.uniformBuffer}},{key:"setSamplerBindingsFromTextureMappings",value:function(e){e=e.filter((function(e){return e}));for(var t=0;t<this.bindingDescriptors[0].samplerBindings.length;t++){var n=this.bindingDescriptors[0].samplerBindings[t],r=e[t];null!=r?(n.texture=r.texture,n.sampler=r.sampler,n.lateBinding=r.lateBinding):(n.texture=null,n.sampler=null,n.lateBinding=null)}}},{key:"hasLateSamplerBinding",value:function(e){for(var t=0;t<this.bindingDescriptors[0].samplerBindings.length;t++){if(this.bindingDescriptors[0].samplerBindings[t].lateBinding===e)return!0}return!1}},{key:"resolveLateSamplerBinding",value:function(e,t){for(var n=0;n<this.bindingDescriptors[0].samplerBindings.length;n++){var r=this.bindingDescriptors[0].samplerBindings[n];r.lateBinding===e&&(null===t?(r.texture=null,r.sampler=null):(Xe(null===t.lateBinding),r.texture=t.texture,null!==t.sampler&&(r.sampler=t.sampler)),r.lateBinding=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=_t(this.flags,Cr.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value:function(e,t){for(var n=e.queryRenderPass(t),r=-1,i=0;i<n.colorAttachment.length;i++){var o=null!==n.colorAttachment[i]?e.queryRenderTarget(n.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.pixelFormat:null,null!==o&&(-1===r?r=o.sampleCount:Xe(r===o.sampleCount))}var a=null!==n.depthStencilAttachment?e.queryRenderTarget(n.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.pixelFormat:null,null!==a&&(-1===r?r=a.sampleCount:Xe(r==a.sampleCount)),Xe(r>0),this.renderPipelineDescriptor.sampleCount=r}},{key:"drawOnPass",value:function(e,t){var n=this,r=e.device;this.setAttachmentFormatsFromRenderPass(r,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!r.pipelineQueryReady(i)){if(this.flags&Cr.AllowSkippingIfPipelineNotReady)return!1;r.pipelineForceReady(i)}t.setPipeline(i),t.setInputState(this.inputState);for(var o=0;o<this.bindingDescriptors[0].uniformBufferBindings.length;o++)this.bindingDescriptors[0].uniformBufferBindings[o].buffer=He(this.uniformBuffer.buffer);this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){var n=e.name,r=e.value;t[n]=r})),n.renderPipelineDescriptor.program.setUniforms(t)}));var a=e.createBindings(D(D({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(Xe(!!(this.flags&Cr.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&Cr.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0}}]),e}(),Lr=null;function Fr(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(Br||(Br={}));var Ur=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Fr,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Br.Forwards;B(this,e),this.renderInsts=[],this.compareFunction=void 0,this.executionOrder=void 0,this.usePostSort=!1,this.compareFunction=t,this.executionOrder=n}return L(e,[{key:"checkUsePostSort",value:function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500}},{key:"insertSorted",value:function(e){null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):ht(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Cr.Draw,this.insertSorted(e)}},{key:"hasLateSamplerBinding",value:function(e){for(var t=0;t<this.renderInsts.length;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1}},{key:"resolveLateSamplerBinding",value:function(e,t){for(var n=0;n<this.renderInsts.length;n++)this.renderInsts[n].resolveLateSamplerBinding(e,t)}},{key:"ensureSorted",value:function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)}},{key:"drawOnPassRendererNoReset",value:function(e,t){this.ensureSorted();var n=0;if(this.executionOrder===Br.Forwards)for(var r=0;r<this.renderInsts.length;r++)this.renderInsts[r].drawOnPass(e,t)&&n++;else for(var i=this.renderInsts.length-1;i>=0;i--)this.renderInsts[i].drawOnPass(e,t)&&n++;return n}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}]),e}(),Gr=function(){function e(){B(this,e),this.pool=[],this.allocCount=0}return L(e,[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new br),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;e<this.pool.length;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}]),e}(),wr=function(){function e(t){B(this,e),this.renderCache=void 0,this.instPool=new Gr,this.templatePool=new Gr,this.simpleRenderInstList=new Ur,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t}return L(e,[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),n=this.instPool.pool[t];return n.debug=null,e>=0&&n.setFromTemplate(this.templatePool.pool[e]),n}},{key:"submitRenderInst",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.currentRenderInstList;t.submitRenderInst(e)}},{key:"setCurrentRenderInstList",value:function(e){Xe(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),n=this.templatePool.pool[t];return e>=0&&n.setFromTemplate(this.templatePool.pool[e]),n.flags|=Cr.Template,n}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1;return this.templatePool.pool[e]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Xe(0===this.templatePool.allocCount)}},{key:"destroy",value:function(){this.instPool.destroy(),this.renderCache.destroy()}},{key:"disableSimpleMode",value:function(){this.simpleRenderInstList=null}},{key:"drawOnPassRenderer",value:function(e){He(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){He(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}]),e}(),kr=function(){function e(){B(this,e),this.renderCache=void 0,this.renderGraph=void 0,this.renderInstManager=void 0,this.uniformBuffer=void 0,this.device=void 0}return L(e,[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new Kn(e),this.renderGraph=new tr(this.device),this.renderInstManager=new wr(this.renderCache),this.uniformBuffer=new Bn(this.device)}},{key:"pushTemplateRenderInst",value:function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e}},{key:"prepareToRender",value:function(){this.uniformBuffer.prepareToRender()}},{key:"destroy",value:function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache.destroy(),this.renderGraph.destroy()}},{key:"getCache",value:function(){return this.renderCache}}]),e}();kr=l([Object(v.singleton)()],kr);var Wr=function(){function e(t){B(this,e),this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.pixelFormat=t}return L(e,[{key:"setDimensions",value:function(e,t,n){this.width=e,this.height=t,this.sampleCount=n}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}]),e}();function Vr(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var Xr,Hr=Vr(ze(.88,.88,.88,1)),jr=Vr(Ze),Yr=Vr(Je);function Kr(e,t){var n=function(e){return e.antialiasingMode===Xr.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,n)}function zr(e,t,n){var r=function(e){if(e===Yn.Color0)return Ie.U8_RGBA_RT;if(e===Yn.DepthStencil)return Ie.D24_S8;throw new Error("whoops")}(e),i=new Wr(r);return Kr(i,t),null!==n&&(i.colorClearColor=n.colorClearColor,i.depthClearValue=n.depthClearValue,i.stencilClearValue=n.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(Xr||(Xr={}));var qr=function(){function e(){B(this,e),this.name=void 0,this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}return L(e,[{key:"reset",value:function(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}},{key:"copy",value:function(e){this.texture=e.texture,this.sampler=e.sampler,this.lateBinding=e.lateBinding,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias}}]),e}(),Zr=function(){function e(){B(this,e),this.inputTexture=null,this.outputTexture=null}return L(e,[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Xe(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Jn(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))}},{key:"getTextureForSampling",value:function(){return null!==this.inputTexture?this.inputTexture.texture:null}},{key:"getTextureForResolving",value:function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture}},{key:"destroy",value:function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)}}]),e}(),Qr=function(){function e(){B(this,e),this.offscreenCanvas=void 0,this.renderingService=void 0,this.canvasConfig=void 0,this.textureCache={},this.gradientCache={}}return L(e,[{key:"getOrCreateTexture",value:function(e,t,n,r){var i=this,o="string"==typeof t?t:t.src||"";if(this.textureCache[o])this.textureCache[o].emit(pe.LOADED);else if(this.textureCache[o]=e.createTexture(D({pixelFormat:Ie.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:Ee.n2D,usage:ve.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),"string"!=typeof t)this.textureCache[o].setImageData(t),this.textureCache[o].emit(pe.LOADED),this.renderingService.dirtify();else{var a,s=this.canvasConfig.createImage;s?a=s(t):E.isBrowser&&(a=new window.Image),a&&(a.onload=function(){i.textureCache[o].setImageData(a),i.textureCache[o].emit(pe.LOADED),i.renderingService.dirtify(),r&&r(i.textureCache[o])},a.onerror=function(){},a.crossOrigin="Anonymous",a.src=t)}return this.textureCache[o]}},{key:"getOrCreateCanvas",value:function(){return this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var t=this.generateCacheKey(e),n=e.type,r=e.x0,i=e.y0,o=e.x1,a=e.y1,s=e.steps,u=e.width,l=e.height,c=this.gradientCache[t],f=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),d=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);if(!c){if(f.width=u,f.height=l,n===E.GradientPatternType.LinearGradient)c=d.createLinearGradient(r*u,i*l,o*u,a*l);else if(n===E.GradientPatternType.RadialGradient){var h=Math.sqrt(u*u+l*l)/2;c=d.createRadialGradient(r*u,i*l,0,o*u,a*l,e.r1*h)}s.forEach((function(e){var t,n=Y(e,2),r=n[0],i=n[1];null===(t=c)||void 0===t||t.addColorStop(Number(r),i)})),this.gradientCache[t]=c}f.src=t,c&&(d.fillStyle=c,d.fillRect(0,0,u,l))}},{key:"generateCacheKey",value:function(e){var t=e.type,n=e.x0,r=e.y0,i=e.x1,o=e.y1,a=e.r1,s=e.steps,u=e.width,l=e.height;return"gradient-".concat(t,"-").concat(n,"-").concat(r,"-").concat(i,"-").concat(o,"-").concat(a||0,"-").concat(u,"-").concat(l,"-").concat(s.map((function(e){return e.join("")})).join("-"))}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={},this.gradientCache={}}}]),e}();l([Object(v.inject)(E.OffscreenCanvasCreator),c("design:type",E.OffscreenCanvasCreator)],Qr.prototype,"offscreenCanvas",void 0),l([Object(v.inject)(E.RenderingService),c("design:type",E.RenderingService)],Qr.prototype,"renderingService",void 0),l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],Qr.prototype,"canvasConfig",void 0),Qr=l([Object(v.singleton)()],Qr);var Jr=function(){function e(){B(this,e),this.lights=[],this.fog=void 0}return L(e,[{key:"addLight",value:function(e){this.lights.push(e),this.sortLights()}},{key:"removeLight",value:function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()}},{key:"addFog",value:function(e){this.fog=e}},{key:"removeFog",value:function(e){this.fog=null}},{key:"getFog",value:function(){return this.fog}},{key:"getAllLights",value:function(){return this.lights}},{key:"getDefines",value: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}},{key:"sortLights",value:function(){this.lights.sort((function(e,t){return e.order-t.order}))}}]),e}();Jr=l([Object(v.singleton)()],Jr);var $r=v.Syringe.defineToken("RendererFactory"),ei=v.Syringe.defineToken("ShapeRenderer"),ti=v.Syringe.defineToken("MeshFactory"),ni=1,ri=function(){function e(){B(this,e),this.renderHelper=void 0,this.rendererFactory=void 0,this.meshFactory=void 0,this.device=void 0,this.renderingService=void 0,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return L(e,[{key:"render",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n||this.updatePendingPatches(),this.meshes.forEach((function(r){r.init(t.device,t.renderingService);var i=r.objects;r.clipPathTarget&&(i=[r.clipPath]);var o=t.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),r.applyRenderInst(o,i),t.renderHelper.renderInstManager.submitRenderInst(o,e),n||r.objects.forEach((function(e){e.renderable.dirty=!1}))}))}},{key:"attach",value:function(e,t){this.device=e,this.renderingService=t}},{key:"add",value:function(e){var t=this,n=e.renderable3D;if(n&&!n.meshes.length){var r=this.rendererFactory(e.nodeName);r&&r.meshes.forEach((function(i,o){if(n.meshes[o]=void 0,r.shouldSubmitRenderInst(e,o)){var a=t.meshes.find((function(t){return i===t.constructor&&t.index===o&&t.shouldMerge(e,o)}));a||((a=t.meshFactory(i)).renderer=r,a.index=o,t.meshes.push(a)),a&&(a.objects.push(e),n.meshes[o]=a,a.geometryDirty=!0)}}))}}},{key:"remove",value:function(e){var t=this,n=e.renderable3D;n&&(n.meshes.forEach((function(n){if(n){var r=n.objects.indexOf(e);r>-1&&(n.objects.splice(r,1),n.geometryDirty=!0),0===n.objects.length&&t.meshes.splice(t.meshes.indexOf(n),1)}})),n.meshes=[])}},{key:"updateAttribute",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=e.renderable3D,a=this.rendererFactory(e.nodeName);a&&a.meshes.forEach((function(s,u){var l=a.shouldSubmitRenderInst(e,u),c=o.meshes.find((function(e){return e&&e.index===u&&e.constructor===s}));if(l!==!!c&&(c&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&r.meshes.splice(r.meshes.indexOf(c),1),o.meshes[o.meshes.indexOf(c)]=void 0),l&&((c=r.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))||((c=r.meshFactory(s)).renderer=a,c.index=u,c.init(r.device,r.renderingService),r.meshes.push(c)),c&&(c.objects.push(e),o.meshes[u]=c))),l&&c&&c.inited&&!c.geometryDirty){var f=c.objects.indexOf(e);if(i)e.parsedStyle[t]=n,c.updateAttribute([e],f,t,n);else{var d=c.id+t;r.pendingUpdatePatches[d]||(r.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:n}),-1===r.pendingUpdatePatches[d].objectIndices.indexOf(f)&&r.pendingUpdatePatches[d].objectIndices.push(f)}}}))}},{key:"changeRenderOrder",value:function(e,t){var n=e.renderable3D;n&&n.meshes.length&&n.meshes.forEach((function(n){n&&n.inited&&!n.geometryDirty&&(n.renderer.shouldSubmitRenderInst(e,n.index)&&n.inited&&n.changeRenderOrder(e,t))}))}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=ni++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var n=e.pendingUpdatePatches[t],r=n.instance,i=n.objectIndices,o=n.name,a=n.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){r.updateAttribute(r.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}}}]),e}();l([Object(v.inject)(kr),c("design:type",kr)],ri.prototype,"renderHelper",void 0),l([Object(v.inject)($r),c("design:type",Function)],ri.prototype,"rendererFactory",void 0),l([Object(v.inject)(ti),c("design:type",Function)],ri.prototype,"meshFactory",void 0),ri=l([Object(v.singleton)()],ri);var ii,oi=1,ai=function(){function e(){B(this,e),this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.batchManager=void 0,this.device=void 0,this.renderingService=void 0,this.id=oi++,this.meshes=[],this.clipPathMeshCreated=!1}return L(e,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}},{key:"beforeUploadUBO",value:function(e,t,n){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}]),e}();function si(e,t,n){var r=e.createBuffer({viewOrSize:ct(n.byteLength,4)/4,usage:t,hint:he.Static});return r.setSubData(0,new Uint8Array(n)),r}l([Object(v.inject)(kr),c("design:type",kr)],ai.prototype,"renderHelper",void 0),l([Object(v.inject)(Qr),c("design:type",Qr)],ai.prototype,"texturePool",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],ai.prototype,"camera",void 0),l([Object(v.inject)(Jr),c("design:type",Jr)],ai.prototype,"lightPool",void 0),l([Object(v.inject)(ri),c("design:type",ri)],ai.prototype,"batchManager",void 0),ai=l([Object(v.injectable)()],ai),function(e){e.CHANGED="changed"}(ii||(ii={}));var ui,li=function(e){U(n,e);var t=X(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return B(this,n),(r=t.call(this)).device=void 0,r.props=void 0,r.drawMode=fe.Triangles,r.vertexBuffers=[],r.vertices=[],r.indexBuffer=void 0,r.indices=void 0,r.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:Ie.U32_R},r.vertexCount=0,r.instancedCount=0,r.indexStart=0,r.primitiveStart=0,r.dirty=!0,r.meshes=[],r.device=e,r.props=i,r}return L(n,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new E.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=si(this.device,de.INDEX|de.COPY_DST,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this}},{key:"setVertexBuffer",value:function(e){var t=this,n=e.bufferIndex,r=e.byteStride,i=e.frequency,o=e.attributes,a=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[n]={byteStride:r,frequency:i},this.vertices[n]=a,o.forEach((function(e){var r=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=e.byteStride,u=t.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===n&&e.location===o}));u?(u.format=r,u.bufferByteOffset=i,u.byteStride=s,u.divisor=a):t.inputLayoutDescriptor.vertexAttributeDescriptors.push({format:r,bufferIndex:n,bufferByteOffset:i,location:o,byteStride:s,divisor:a})})),this.vertexBuffers[n]&&this.vertexBuffers[n].destroy();var s=si(this.device,de.VERTEX|de.COPY_DST,a.buffer);return this.vertexBuffers[n]=s,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value:function(e,t,n,r){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e].byteStride,o=this.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.location===t}));if(o){var a=n*i;this.getVertexBuffer(e).setSubData(o.bufferByteOffset+a,r)}this.emit(ii.CHANGED)}},{key:"updateIndices",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.indexBuffer&&this.indexBuffer.setSubData(t,ArrayBuffer.isView(e)?e:new Uint32Array(e)),this}},{key:"destroy",value:function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexAttributeDescriptors=[],this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0}}]),n}(g.EventEmitter);!function(e){e.CHANGED="changed"}(ui||(ui={}));var ci=function(e){U(n,e);var t=X(n);function n(e,r){var i;B(this,n),(i=t.call(this)).device=void 0,i.props={},i.meshes=[],i.defines={},i.uniforms={},i.uniformNames=void 0,i.uboBuffer=[],i.textures={},i.samplers=[],i.programDirty=!0,i.textureDirty=!0,i.geometryDirty=!0;var o=At(Ot),a=o.cullMode,s=o.depthCompare,u=o.depthWrite,l=o.stencilCompare,c=o.stencilWrite,f=o.stencilPassOp,d=o.frontFace,h=o.polygonOffset,_=o.attachmentsState;return i.device=e,i.props=D({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilCompare:l,stencilWrite:c,stencilPassOp:f,frontFace:d,polygonOffset:h,attachmentsState:_,blendEquation:se.Add,blendEquationAlpha:se.Add,blendSrc:ae.SrcAlpha,blendDst:ae.OneMinusSrcAlpha,blendSrcAlpha:ae.Zero,blendDstAlpha:ae.One,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),i.compile(),i}return L(n,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilCompare",get:function(){return this.props.stencilCompare},set:function(e){this.props.stencilCompare=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilPassOp",get:function(){return this.props.stencilPassOp},set:function(e){this.props.stencilPassOp=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"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}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}},{key:"compile",value:function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,n){return e.samplers.push(n),""})),this.uniformNames=Nn(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var t=this,n=!1;Object.keys(e).forEach((function(r){var i,o=e[r],a=t.textures[r];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[r]=o,t.textureDirty=!0,o.on(pe.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[r]=o,n=!0),Object(E.isNil)(e[r])&&(delete t.textures[r],delete t.uniforms[r])})),n&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(ui.CHANGED)}}]),n}(g.EventEmitter),fi=function(e){U(n,e);var t=X(n);function n(e,r){var i;return B(this,n),(i=t.call(this,e,D({},r))).defines=D(D({},i.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),i}return L(n)}(ci);function di(e){var t={};return Object.keys(e).forEach((function(n){"number"==typeof e[n]&&(t[n]=e[n])})),t}function hi(e,t){var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return e[n]===t[n]}))}var _i,pi,Ei=1;!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.FILL_STROKE=1]="FILL_STROKE",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"}(_i||(_i={})),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.COLOR=4]="COLOR",e[e.STROKE_COLOR=5]="STROKE_COLOR",e[e.PACKED_STYLE1=6]="PACKED_STYLE1",e[e.PACKED_STYLE2=7]="PACKED_STYLE2",e[e.PICKING_COLOR=8]="PICKING_COLOR",e[e.POSITION=9]="POSITION",e[e.NORMAL=10]="NORMAL",e[e.UV=11]="UV",e[e.BARYCENTRIC=12]="BARYCENTRIC",e[e.MAX=13]="MAX"}(pi||(pi={}));var vi=function(){function e(){B(this,e),this.id=Ei++,this.renderer=void 0,this.index=-1,this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.device=void 0,this.renderingService=void 0,this.objects=[],this.material=void 0,this.geometry=void 0,this.clipPath=void 0,this.clipPathTarget=void 0,this.inputState=void 0,this.program=new xn,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1}return L(e,[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(e,t){this.inited||(this.renderer.beforeInitMesh(this),this.device=e,this.renderingService=t,this.material=new fi(this.device),this.material.defines=D(D({},di(pi)),this.material.defines),this.geometry=new li(this.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))}},{key:"observeGeometryChanged",value:function(){var e=this;this.geometry.on(ii.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))}},{key:"observeMaterialChanged",value:function(){var e=this;this.material.on(ui.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))}},{key:"shouldMerge",value:function(e,t){return!this.instance||this.instance.nodeName===e.nodeName&&!e.parsedStyle.clipPath}},{key:"createGeometry",value:function(e){var t=this,n=Er(),r=Er(),i=[],o=[],a=[],s=[];e.forEach((function(e){var u,l=e.parsedStyle,c=l.fill,f=l.stroke,d=l.opacity,h=l.fillOpacity,_=l.strokeOpacity,p=l.lineWidth,v=l.anchor,R=l.visibility,m=l.increasedLineWidthForHitTesting,T=[0,0,0,0];c instanceof E.CSSRGB&&(T=[Number(c.r)/255,Number(c.g)/255,Number(c.b)/255,Number(c.alpha)]);var y=[0,0,0,0];f instanceof E.CSSRGB&&(y=[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255,Number(f.alpha)]),t.clipPathTarget?(vr(n,e.getLocalTransform()),T=[1,1,1,1],Tr(n,t.clipPathTarget.getWorldTransform(),n)):vr(n,e.getWorldTransform()),Tr(r,t.camera.getViewTransform(),n);var g=e.isInteractive()&&(null===(u=e.renderable3D)||void 0===u?void 0:u.encodedPickingColor)||[0,0,0];i.push.apply(i,z(n)),o.push.apply(o,z(T).concat(z(y))),a.push(d.value,h.value,_.value,p.value,"visible"===R.value?1:0,v[0].value,v[1].value,(null==m?void 0:m.value)||0),s.push.apply(s,z(g).concat([.005*e.sortable.renderOrder]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:_i.MODEL_MATRIX,byteStride:64,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RGBA,bufferByteOffset:0,location:pi.MODEL_MATRIX0,divisor:1},{format:Ie.F32_RGBA,bufferByteOffset:16,location:pi.MODEL_MATRIX1,divisor:1},{format:Ie.F32_RGBA,bufferByteOffset:32,location:pi.MODEL_MATRIX2,divisor:1},{format:Ie.F32_RGBA,bufferByteOffset:48,location:pi.MODEL_MATRIX3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:_i.FILL_STROKE,byteStride:32,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RGBA,bufferByteOffset:0,location:pi.COLOR,divisor:1},{format:Ie.F32_RGBA,bufferByteOffset:16,location:pi.STROKE_COLOR,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:_i.PACKED_STYLE,byteStride:32,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RGBA,bufferByteOffset:0,location:pi.PACKED_STYLE1,divisor:1},{format:Ie.F32_RGBA,bufferByteOffset:16,location:pi.PACKED_STYLE2,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:_i.PICKING_COLOR,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RGBA,bufferByteOffset:0,location:pi.PICKING_COLOR,divisor:1}],data:new Float32Array(s)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()}},{key:"applyRenderInst",value:function(e,t){var n=this,r=this.lightPool.getAllLights(),i=!!this.lightPool.getFog(),o=!!r.length,a=D({},this.material.defines);if(this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=D(D({},this.material.defines),this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=re.Always,this.material.stencilPassOp=me.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=re.Equal,this.material.stencilPassOp=me.Keep):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t),this.material.textureDirty){this.textureMappings=[];var s=this.createFillGradientTextureMapping(t);s&&this.textureMappings.push(s),Object.keys(this.material.textures).sort((function(e,t){return n.material.samplers.indexOf(e)-n.material.samplers.indexOf(t)})).forEach((function(e){var t=new qr;t.name=e,t.texture=n.material.textures[e],n.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=n.renderHelper.getCache().createSampler({wrapS:ue.Clamp,wrapT:ue.Clamp,minFilter:le.Point,magFilter:le.Bilinear,mipFilter:ce.Linear,minLOD:0,maxLOD:0}),n.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}(hi(a,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=D(D({},this.material.defines),di(pi)),Object.keys(this.material.defines).forEach((function(e){var t=n.material.defines[e];"number"==typeof t?n.program.setDefineString(e,"".concat(t)):n.program.setDefineBool(e,t)})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.programDescriptorSimpleWithOrig=Mn(this.device,this.program),this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.inputStateDirty=!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,this.inputStateDirty=!0);var u=this.renderHelper.getCache().createInputLayout(this.geometry.inputLayoutDescriptor),l=this.renderHelper.getCache().createProgramSimple(this.programDescriptorSimpleWithOrig),c=!!this.geometry.indexBuffer;this.inputStateDirty&&(this.inputState&&this.inputState.destroy(),this.inputState=this.device.createInputState(u,this.geometry.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),c?{buffer:this.geometry.indexBuffer,byteOffset:0}:null,l),this.inputStateDirty=!1),e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(l),e.setInputLayoutAndState(u,this.inputState),this.renderer.beforeUploadUBO(e,this,this.index),this.uploadUBO(e),c?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=sr($n.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value:function(e,t,n,r){if("fill"===n||"stroke"===n){var i=[];e.forEach((function(e){var t=e.parsedStyle,n=t.fill,r=t.stroke,o=[0,0,0,0];n instanceof E.CSSRGB&&(o=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]);var a=[0,0,0,0];r instanceof E.CSSRGB&&(a=[Number(r.r)/255,Number(r.g)/255,Number(r.b)/255,Number(r.alpha)]),i.push.apply(i,z(o).concat(z(a)))})),this.geometry.updateVertexBuffer(_i.FILL_STROKE,pi.COLOR,t,new Uint8Array(new Float32Array(i).buffer));var o=this.instance.parsedStyle.fill,a=this.textureMappings.findIndex((function(e){return"FillTextureMapping"===e.name}));if(o instanceof E.CSSRGB)a>=0&&(this.textureMappings.splice(a,-1),this.material.textureDirty=!0);else{var s=this.createFillGradientTextureMapping([this.instance]);a>=0&&this.textureMappings.splice(a,1,s),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var u=[];e.forEach((function(e){var t=e.parsedStyle,n=t.opacity,r=t.fillOpacity,i=t.strokeOpacity,o=t.lineWidth,a=t.visibility,s=t.anchor,l=t.increasedLineWidthForHitTesting;u.push(n.value,r.value,i.value,o.value,"visible"===a.value?1:0,s[0].value,s[1].value,(null==l?void 0:l.value)||0)})),this.geometry.updateVertexBuffer(_i.PACKED_STYLE,pi.PACKED_STYLE1,t,new Uint8Array(new Float32Array(u).buffer))}else if("modelMatrix"===n){var l=[];e.forEach((function(e){var t=vr(Er(),e.getWorldTransform());l.push.apply(l,z(t))})),this.geometry.updateVertexBuffer(_i.MODEL_MATRIX,pi.MODEL_MATRIX0,t,new Uint8Array(new Float32Array(l).buffer))}else if("pointerEvents"===n){var c=[];e.forEach((function(e){var t,n=r&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];c.push.apply(c,z(n).concat([.005*e.sortable.renderOrder]))})),this.geometry.updateVertexBuffer(_i.PICKING_COLOR,pi.PICKING_COLOR,t,new Uint8Array(new Float32Array(c).buffer))}}},{key:"updateAttribute",value:function(e,t,n,r){"clipPath"===n&&this.clipPath&&(this.geometryDirty=!0)}},{key:"changeRenderOrder",value:function(e,t){var n,r=this.objects.indexOf(e),i=e.isInteractive()&&(null===(n=e.renderable3D)||void 0===n?void 0:n.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(_i.PICKING_COLOR,pi.PICKING_COLOR,r,new Uint8Array(new Float32Array([].concat(z(i),[.005*t])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,n=e.indices.length,r=e.vertices.map((function(e){return e.slice()})),i=_i.PICKING_COLOR;i<e.vertexBuffers.length;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride;e.vertices[i]=new Float32Array(o/4*n)}for(var a=0,s=new Uint32Array(n),u=0;u<n;u++){for(var l=t[u],c=1;c<e.vertices.length;c++)for(var f=e.inputLayoutDescriptor.vertexBufferDescriptors[c].byteStride/4,d=0;d<f;d++)e.vertices[c][a*f+d]=r[c][l*f+d];s[u]=a,a++}for(var h=function(t){var n=e.inputLayoutDescriptor.vertexBufferDescriptors[t],r=n.frequency,i=n.byteStride,o=e.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===t}));if(o){var a=o.location,s=o.bufferIndex,u=o.bufferByteOffset,l=o.format,c=o.divisor;e.setVertexBuffer({bufferIndex:s,byteStride:i,frequency:r,attributes:[{format:l,bufferByteOffset:u,location:a,divisor:c}],data:e.vertices[t]})}},_=_i.PICKING_COLOR+1;_<e.vertexBuffers.length;_++)h(_);for(var p=new Float32Array(3*n),E=0;E<n;)for(var v=0;v<3;v++){p[3*s[E++]+v]=1}e.setVertexBuffer({bufferIndex:_i.BARYCENTRIC,byteStride:12,frequency:_e.PerVertex,attributes:[{format:Ie.F32_RGB,bufferByteOffset:0,location:Number(pi.BARYCENTRIC)}],data:p}),e.setIndexBuffer(s)}},{key:"beforeUploadUBO",value:function(e,t,n){}},{key:"uploadUBO",value:function(e){var t=this,n=this.material,r=this.lightPool.getAllLights(),i=this.lightPool.getFog(),o=!!i,a=!!r.length,s=n.defines.USE_WIREFRAME,u=[];if(s){var l=Object(E.parseColor)(n.wireframeColor);u.push({name:"u_WireframeLineColor",value:[Number(l.r)/255,Number(l.g)/255,Number(l.b)/255]}),u.push({name:"u_WireframeLineWidth",value:n.wireframeLineWidth})}if(o&&this.uploadFog(u,i),this.uploadMaterial(u,n),a){var c={};r.forEach((function(e){c[e.define]||(c[e.define]=-1),c[e.define]++,e.uploadUBO(u,c[e.define])}))}u.sort((function(e,n){return t.material.uniformNames.indexOf(e.name)-t.material.uniformNames.indexOf(n.name)})),e.setUniforms(1,u);var f=n.depthCompare,d=n.depthWrite,h=n.stencilCompare,_=n.stencilWrite,p=n.stencilPassOp,v=n.stencilRef,R=n.cullMode,m=n.frontFace,T=n.polygonOffset,y=n.blendEquation,g=n.blendEquationAlpha,A=n.blendSrc,S=n.blendDst,C=n.blendSrcAlpha,O=n.blendDstAlpha;e.setMegaStateFlags({attachmentsState:[{channelWriteMask:this.material.stencilWrite?Re.None:Re.AllChannels,rgbBlendState:{blendMode:y,blendSrcFactor:A,blendDstFactor:S},alphaBlendState:{blendMode:g,blendSrcFactor:C,blendDstFactor:O}}],depthCompare:f,depthWrite:d,stencilCompare:h,stencilWrite:_,stencilPassOp:p,stencilRef:v,cullMode:R,frontFace:m,polygonOffset:T}),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,t){var n=t.parsedStyle,r=n.type,i=n.fill,o=n.start,a=n.end,s=n.density;if(i instanceof E.CSSRGB){var u=[Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)];e.push({name:"u_FogInfos",value:[r,o,a,s]}),e.push({name:"u_FogColor",value:u})}}},{key:"uploadMaterial",value:function(e,t){var n=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,z(n))}},{key:"createFillGradientTextureMapping",value:function(e){var t=e[0],n=t.nodeName===E.Shape.LINE?t.parsedStyle.stroke:t.parsedStyle.fill;if(n&&n instanceof E.CSSGradientValue){var r;n.type===E.GradientPatternType.LinearGradient||n.type===E.GradientPatternType.RadialGradient?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient(D(D({type:n.type},n.value),{},{width:128,height:128})),r=this.texturePool.getOrCreateCanvas()):(this.program.setDefineBool("USE_PATTERN",!0),r=n.value.src);var i=new qr;return i.name="FillTextureMapping",i.texture=this.texturePool.getOrCreateTexture(this.device,r,De(Ie.U8_RGBA_NORM,1,1,1)),i.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0}))})),this.device.setResourceName(i.texture,"Fill Texture"+this.id),i.sampler=this.renderHelper.getCache().createSampler({wrapS:ue.Repeat,wrapT:ue.Repeat,minFilter:le.Point,magFilter:le.Bilinear,mipFilter:ce.Linear,minLOD:0,maxLOD:0}),i}return null}}]),e}();l([Object(v.inject)(kr),c("design:type",kr)],vi.prototype,"renderHelper",void 0),l([Object(v.inject)(Qr),c("design:type",Qr)],vi.prototype,"texturePool",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],vi.prototype,"camera",void 0),l([Object(v.inject)(Jr),c("design:type",Jr)],vi.prototype,"lightPool",void 0),vi=l([Object(v.injectable)()],vi);var Ri,mi;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(Ri||(Ri={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(mi||(mi={}));var Ti=[E.Shape.CIRCLE,E.Shape.ELLIPSE],yi=function(e){U(n,e);var t=X(n);function n(){return B(this,n),t.apply(this,arguments)}return L(n,[{key:"shouldMerge",value:function(e,t){var r=j(G(n.prototype),"shouldMerge",this).call(this,e,t);if(!r)return!1;if(this.needDrawStrokeSeparately(e)||this.needDrawStrokeSeparately(this.instance))return!1;var i=this.instance.parsedStyle.fill,o=e.parsedStyle.fill;return i.isNone===o.isNone}},{key:"createMaterial",value: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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n mat4 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 * 0.5 + 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 float antialiasblur = 1.0 / (a_Size.x + strokeWidth);\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * radius;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\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 vec4 v_Data;\nin vec2 v_Radius;\nin vec4 v_StylePacked3;\n\nout vec4 outputColor;\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\nvoid main() {\n int shape = int(floor(v_Data.w + 0.5));\n float epsilon = 0.00001;\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 float antialiasblur = v_Data.z;\n float antialiased_blur = -max(0.0, antialiasblur);\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius;\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data.xy, 1.0);\n inner_df = sdCircle(v_Data.xy, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data.xy, vec2(1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\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 // vec2 imagecoord = mod(v_Uv, 0.1);\n // vec4 texel = texture(SAMPLER_2D(u_Map), imagecoord);\n // u_Color = texel;\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=D(D({},this.material.defines),di(mi))}},{key:"createGeometry",value:function(e){var t=this;j(G(n.prototype),"createGeometry",this).call(this,e);var r=[],i=[],o=[];e.forEach((function(e,n){var a=e,s=4*n,u=a.parsedStyle.radius,l=t.shouldOmitStroke(a.parsedStyle),c=t.getSize(e.parsedStyle,a.nodeName);i.push.apply(i,z(c).concat([Ti.indexOf(a.nodeName),u||0,l?1:0,0])),r.push(-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1),o.push(0+s,2+s,1+s,0+s,3+s,2+s)})),this.geometry.setIndexBuffer(new Uint32Array(o)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:_i.POSITION,byteStride:16,frequency:_e.PerVertex,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,location:pi.POSITION},{format:Ie.F32_RG,bufferByteOffset:8,location:pi.UV}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Ri.PACKED_STYLE,byteStride:24,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,location:mi.SIZE,divisor:1},{format:Ie.F32_RGBA,bufferByteOffset:8,location:mi.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(j(G(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"r"===r||"rx"===r||"ry"===r||"lineWidth"===r||"stroke"===r||"lineDash"===r||"strokeOpacity"===r){var a=[];e.forEach((function(e){var t=e,n=o.shouldOmitStroke(t.parsedStyle),r=Y(o.getSize(e.parsedStyle,e.nodeName),2),i=[r[0],r[1]];a.push.apply(a,i.concat([Ti.indexOf(e.nodeName),e.parsedStyle.radius||0,n?1:0,0]))})),this.geometry.updateVertexBuffer(Ri.PACKED_STYLE,mi.SIZE,t,new Uint8Array(new Float32Array(a).buffer))}}},{key:"getSize",value:function(e,t){var n=[0,0];if(t===E.Shape.CIRCLE){var r=e.r;n=[r.value,r.value]}else if(t===E.Shape.ELLIPSE){var i=e.rx,o=e.ry;n=[i.value,o.value]}return n}},{key:"shouldOmitStroke",value:function(e){var t=e.lineDash,n=e.stroke,r=e.strokeOpacity;return!(!n||!(t&&t.length&&t.every((function(e){return 0!==e.value}))||1!==r.value))}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,n=t.stroke,r=t.lineDash,i=t.lineWidth,o=t.strokeOpacity;return n&&i.value>0&&(o.value<1||r&&r.length&&r.every((function(e){return 0!==e.value})))}}]),n}(vi);yi=l([Object(v.injectable)()],yi);var gi,Ai,Si,Ci=[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=8]="POINT",e[e.CAP=9]="CAP",e[e.DASH=10]="DASH"}(Ai||(Ai={})),function(e){e[e.POSITION=9]="POSITION",e[e.UV=11]="UV",e[e.POINTA=10]="POINTA",e[e.POINTB=12]="POINTB",e[e.CAP=13]="CAP",e[e.DASH=14]="DASH"}(Si||(Si={}));var Oi=(F(gi={},E.LineCap.BUTT,1),F(gi,E.LineCap.ROUND,2),F(gi,E.LineCap.SQUARE,3),gi),Ii=function(e){U(n,e);var t=X(n);function n(){return B(this,n),t.apply(this,arguments)}return L(n,[{key:"shouldMerge",value:function(e,t){var r=j(G(n.prototype),"shouldMerge",this).call(this,e,t);if(!r)return!1;var i=this.instance;if(i.nodeName===E.Shape.LINE){var o=i.parsedStyle.stroke,a=e.parsedStyle.stroke;if(o.toString()!==a.toString())return!1}return!0}},{key:"createMaterial",value: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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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;\n// out vec2 v_Normal;\n\nvoid main() {\n mat4 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 * 0.5 + 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 float isBillboard = a_Dash.w;\n if (isBillboard < 0.5) {\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 * strokeWidth * 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(strokeWidth / 2.0);\n }\n\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n // clip space\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 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + strokeWidth * (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 }\n\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;\n// in vec2 v_Normal;\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_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n // float blur = 1. - smoothstep(0.98, 1., length(v_Normal));\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 outputColor.a = outputColor.a\n // * blur\n * u_Opacity * u_StrokeOpacity\n * ceil(mod(v_Dash.x + u_dash_offset, u_dash_array) - (u_dash_array * u_dash_ratio));\n }\n}",this.material.defines=D(D({},this.material.defines),di(Si))}},{key:"createGeometry",value:function(e){var t=this;j(G(n.prototype),"createGeometry",this).call(this,e);var r=[],i=[],o=[],a=[],s=0;e.forEach((function(e){var n=e.parsedStyle,u=n.x1,l=n.y1,c=n.x2,f=n.y2,d=n.z1,h=n.z2,_=n.defX,p=n.defY,E=n.lineCap,v=n.isBillboard,R=t.calcDash(e),m=R.dashOffset,T=R.dashSegmentPercent,y=R.dashRatioInEachSegment;i.push(Oi[E.value]),o.push(m,T,y,v?1:0),r.push(u.value-_,l.value-p,d.value,c.value-_,f.value-p,h.value),a.push(0+s,2+s,1+s,0+s,3+s,2+s),s+=4})),this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:_i.POSITION,byteStride:20,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RGB,bufferByteOffset:0,location:Si.POSITION,divisor:0},{format:Ie.F32_RG,bufferByteOffset:12,location:Si.UV,divisor:0}],data:new Float32Array(Ci)}),this.geometry.setVertexBuffer({bufferIndex:Ai.POINT,byteStride:24,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RGB,bufferByteOffset:0,location:Si.POINTA,divisor:1},{format:Ie.F32_RGB,bufferByteOffset:12,location:Si.POINTB,divisor:1}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Ai.CAP,byteStride:4,frequency:_e.PerInstance,attributes:[{format:Ie.F32_R,bufferByteOffset:0,location:Si.CAP,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Ai.DASH,byteStride:16,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RGBA,bufferByteOffset:0,location:Si.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(j(G(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"x1"===r||"y1"===r||"x2"===r||"y2"===r||"z1"===r||"z2"===r){var a=[];e.forEach((function(e){var t=e.parsedStyle,n=t.x1,r=t.y1,i=t.x2,o=t.y2,s=t.z1,u=t.z2,l=t.defX,c=t.defY;a.push(n.value-l,r.value-c,s.value,i.value-l,o.value-c,u.value)})),this.geometry.updateVertexBuffer(Ai.POINT,Si.POINTA,t,new Uint8Array(new Float32Array(a).buffer))}else if("lineDashOffset"===r||"lineDash"===r){var s=[];e.forEach((function(e){var t=o.calcDash(e),n=t.dashOffset,r=t.dashSegmentPercent,i=t.dashRatioInEachSegment;s.push(n,r,i,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Ai.DASH,Si.DASH,t,new Uint8Array(new Float32Array(s).buffer))}else if("lineCap"===r){var u=[];e.forEach((function(e){var t=e.parsedStyle.lineCap;u.push(Oi[t])})),this.geometry.updateVertexBuffer(Ai.CAP,Si.CAP,t,new Uint8Array(new Float32Array(u).buffer))}}},{key:"calcDash",value:function(e){var t=e.parsedStyle,n=t.lineDash,r=t.lineDashOffset,i=e.getTotalLength(),o=0,a=1,s=0;if(n&&n.length){o=(r&&r.value||0)/i;var u=n.reduce((function(e,t){return e+t.value}),0);a=u/i,s=n[1].value/u}return{dashOffset:o,dashSegmentPercent:a,dashRatioInEachSegment:s}}}]),n}(vi);function Ni(e,t,n,r){var i=e-n,o=t-r;return Math.sqrt(i*i+o*o)}Ii=l([Object(v.injectable)()],Ii);var Pi=function(e,t,n,r,i){return{x:(1-i)*e+i*n,y:(1-i)*t+i*r}};function Di(e,t,n,r,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*n*i*i*o+r*i*i*i}function Mi(e,t,n,r,i,o,a,s,u){var l=Di(e,n,i,a,u),c=Di(t,r,o,s,u),f=Pi(e,t,n,r,u),d=Pi(n,r,i,o,u),h=Pi(i,o,a,s,u),_=Pi(f.x,f.y,d.x,d.y,u),p=Pi(d.x,d.y,h.x,h.y,u);return[[e,t,f.x,f.y,_.x,_.y,l,c],[l,c,p.x,p.y,h.x,h.y,a,s]]}function xi(e,t,n,r,i,o,a,s,u){if(0===u)return function(e,t){for(var n=0,r=e.length,i=0;i<r;i++){n+=Ni(e[i],t[i],e[(i+1)%r],t[(i+1)%r])}return n/2}([e,n,i,a],[t,r,o,s]);var l=Mi(e,t,n,r,i,o,a,s,.5),c=p(p([],_(l[0]),!1),[u-1],!1),f=p(p([],_(l[1]),!1),[u-1],!1);return xi.apply(void 0,p([],_(c),!1))+xi.apply(void 0,p([],_(f),!1))}var Bi,bi=function(e,t,n,r,i,o,a,s){return xi(e,t,n,r,i,o,a,s,3)};!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"}(Bi||(Bi={}));var Li,Fi,Ui;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(Li||(Li={})),function(e){e[e.PREV=0]="PREV",e[e.POINT1=1]="POINT1",e[e.POINT2=2]="POINT2",e[e.NEXT=3]="NEXT",e[e.VERTEX_JOINT=4]="VERTEX_JOINT",e[e.VERTEX_NUM=5]="VERTEX_NUM",e[e.TRAVEL=6]="TRAVEL"}(Fi||(Fi={})),function(e){e.MODEL_MATRIX="u_ModelMatrix",e.COLOR="u_Color",e.STROKE_COLOR="u_StrokeColor",e.STROKE_WIDTH="u_StrokeWidth",e.INCREASED_LINE_WIDTH_FOR_HIT_TESTING="u_IncreasedLineWidthForHitTesting",e.OPACITY="u_Opacity",e.FILL_OPACITY="u_FillOpacity",e.STROKE_OPACITY="u_StrokeOpacity",e.EXPAND="u_Expand",e.MITER_LIMIT="u_MiterLimit",e.SCALE_MODE="u_ScaleMode",e.ALIGNMENT="u_Alignment",e.PICKING_COLOR="u_PickingColor",e.DASH="u_Dash",e.GAP="u_Gap",e.DASH_OFFSET="u_DashOffset",e.VISIBLE="u_Visible",e.Z_INDEX="u_ZIndex"}(Ui||(Ui={}));var Gi=function(e){U(n,e);var t=X(n);function n(){return B(this,n),t.apply(this,arguments)}return L(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;j(G(n.prototype),"updateAttribute",this).call(this,e,t,r,i),e.forEach((function(e){var t=e.parsedStyle,n=t.stroke,a=t.opacity,s=t.fillOpacity,u=t.strokeOpacity,l=t.lineWidth,c=t.increasedLineWidthForHitTesting,f=t.anchor,d=t.lineDash,h=t.lineDashOffset,_=t.visibility;if("lineJoin"===r||"lineCap"===r||e.nodeName===E.Shape.CIRCLE&&"r"===r||e.nodeName===E.Shape.ELLIPSE&&("rx"===r||"ry"===r)||e.nodeName===E.Shape.RECT&&("width"===r||"height"===r||"radius"===r)||e.nodeName===E.Shape.LINE&&("x1"===r||"y1"===r||"x2"===r||"y2"===r)||e.nodeName===E.Shape.POLYLINE&&"points"===r||e.nodeName===E.Shape.POLYGON&&"points"===r||e.nodeName===E.Shape.PATH&&"path"===r)o.material.geometryDirty=!0,o.material.programDirty=!0;else if("stroke"===r){var p=[0,0,0,0];n instanceof E.CSSRGB&&(p=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),o.material.setUniforms(F({},Ui.STROKE_COLOR,p))}else if("opacity"===r)o.material.setUniforms(F({},Ui.OPACITY,a.value));else if("fillOpacity"===r)o.material.setUniforms(F({},Ui.FILL_OPACITY,s.value));else if("strokeOpacity"===r)o.material.setUniforms(F({},Ui.STROKE_OPACITY,u.value));else if("lineWidth"===r)o.material.setUniforms(F({},Ui.STROKE_WIDTH,l.value));else if("increasedLineWidthForHitTesting"===r)o.material.setUniforms(F({},Ui.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,c.value));else if("anchor"===r||"modelMatrix"===r){var v=0,R=0,m=e.getGeometryBounds();if(m){var T=m.halfExtents;v=-T[0]*f[0].value*2,R=-T[1]*f[1].value*2}var y=Er();Tr(y,e.getWorldTransform(),mr(y,yr(v,R,0))),o.material.setUniforms(F({},Ui.MODEL_MATRIX,y))}else if("visibility"===r)o.material.setUniforms(F({},Ui.VISIBLE,"visible"===_.value?1:0));else if("lineDash"===r){var g;o.material.setUniforms((F(g={},Ui.DASH,d[0].value||0),F(g,Ui.GAP,d[1].value||0),g))}else if("lineDashOffset"===r)o.material.setUniforms(F({},Ui.DASH_OFFSET,h&&h.value||0));else if("pointerEvents"===r){var A,S=i&&e.isInteractive()&&(null===(A=e.renderable3D)||void 0===A?void 0:A.encodedPickingColor)||[0,0,0];o.material.setUniforms(F({},Ui.PICKING_COLOR,S))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(F({},Ui.Z_INDEX,.005*t))}},{key:"createMaterial",value:function(e){var t,n,r,i;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(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 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\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\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\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\nvoid main() {\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\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 next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\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 gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\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};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\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 if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * 0.5 + u_DashOffset, u_Dash + u_Gap) - (u_Gap * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * 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 outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n }\n}",this.material.defines=D(D({},this.material.defines),di(Fi));var o=e[0],a=o.parsedStyle,s=a.fill,u=a.stroke,l=a.opacity,c=a.fillOpacity,f=a.strokeOpacity,d=a.lineWidth,h=a.increasedLineWidthForHitTesting,_=a.anchor,p=a.lineDash,v=a.lineDashOffset,R=a.visibility,m=[0,0,0,0];s instanceof E.CSSRGB&&(m=[Number(s.r)/255,Number(s.g)/255,Number(s.b)/255,Number(s.alpha)]);var T=[0,0,0,0];u instanceof E.CSSRGB&&(T=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var y=o.isInteractive()&&(null===(t=o.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0],g=0,A=0,S=o.getGeometryBounds();if(S){var C=S.halfExtents;g=-C[0]*_[0].value*2,A=-C[1]*_[1].value*2}var O=Er();Tr(O,o.getWorldTransform(),mr(O,yr(g,A,0))),this.material.setUniforms((F(i={},Ui.MODEL_MATRIX,O),F(i,Ui.COLOR,m),F(i,Ui.STROKE_COLOR,T),F(i,Ui.STROKE_WIDTH,d.value),F(i,Ui.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,h.value),F(i,Ui.OPACITY,l.value),F(i,Ui.FILL_OPACITY,c.value),F(i,Ui.STROKE_OPACITY,f.value),F(i,Ui.EXPAND,1),F(i,Ui.MITER_LIMIT,5),F(i,Ui.SCALE_MODE,1),F(i,Ui.ALIGNMENT,.5),F(i,Ui.PICKING_COLOR,y),F(i,Ui.DASH,p&&(null===(n=p[0])||void 0===n?void 0:n.value)||0),F(i,Ui.GAP,p&&(null===(r=p[1])||void 0===r?void 0:r.value)||0),F(i,Ui.DASH_OFFSET,v&&v.value||0),F(i,Ui.VISIBLE,"visible"===R.value?1:0),F(i,Ui.Z_INDEX,.005*o.sortable.renderOrder),i)),this.material.cullMode=oe.None}},{key:"createGeometry",value:function(e){var t=ki(e[0]),n=t.pointsBuffer,r=t.travelBuffer,i=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:Li.PACKED,byteStride:48,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,byteStride:12,location:Fi.PREV,divisor:1},{format:Ie.F32_RG,bufferByteOffset:12,byteStride:12,location:Fi.POINT1,divisor:1},{format:Ie.F32_R,bufferByteOffset:20,byteStride:12,location:Fi.VERTEX_JOINT,divisor:1},{format:Ie.F32_RG,bufferByteOffset:24,byteStride:12,location:Fi.POINT2,divisor:1},{format:Ie.F32_RG,bufferByteOffset:36,byteStride:12,location:Fi.NEXT,divisor:1}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:Li.VERTEX_NUM,byteStride:4,frequency:_e.PerInstance,attributes:[{format:Ie.F32_R,bufferByteOffset:0,byteStride:4,location:Fi.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Li.TRAVEL,byteStride:4,frequency:_e.PerInstance,attributes:[{format:Ie.F32_R,bufferByteOffset:0,byteStride:4,location:Fi.TRAVEL,divisor:1}],data:new Float32Array(r)}),this.geometry.vertexCount=15,this.geometry.instancedCount=i,this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2,4,6,5,4,7,6,4,7,8]))}}]),n}(vi);function wi(e,t,n,r,i,o,a){var s=a[a.length-2],u=a[a.length-1];a.length-=2;var l=function(e){var t=Math.ceil(e/10);t<8?t=8:t>2048&&(t=2048);return t}(bi(s,u,e,t,n,r,i,o)),c=0,f=0,d=0,h=0,_=0;a.push(s,u);for(var p=1,E=0;p<=l;++p)d=(f=(c=1-(E=p/l))*c)*c,_=(h=E*E)*E,a.push(d*s+3*f*E*e+3*c*h*n+_*i,d*u+3*f*E*t+3*c*h*r+_*o)}Gi=l([Object(v.injectable)()],Gi);function ki(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.parsedStyle,r=n.lineCap,i=n.lineJoin,o=e.parsedStyle,a=o.defX,s=o.defY,u=[],l=[];if(e.nodeName===E.Shape.POLYLINE||e.nodeName===E.Shape.POLYGON){if(u=e.parsedStyle.points.points.reduce((function(e,t){return e.push(t[0]-a,t[1]-s),e}),[]),e.nodeName===E.Shape.POLYGON){if(t)return l=S()(u,[],2),{pointsBuffer:u,travelBuffer:[],triangles:l,instancedCount:Math.round(u.length/2)};var c;u.push(u[0],u[1]),(c=u).push.apply(c,z(Xi(u[0],u[1],u[2],u[3])))}}else if(e.nodeName===E.Shape.PATH||e.nodeName===E.Shape.CIRCLE||e.nodeName===E.Shape.ELLIPSE||e.nodeName===E.Shape.RECT){var f;e.nodeName!==E.Shape.PATH?(f=Object(E.parsePath)(Object(E.convertToPath)(e,!1),e),a=f.rect.x,s=f.rect.y):f=e.parsedStyle.path;var d=f,h=d.zCommandIndexes,_=z(f.curve).map((function(e,t){return h.includes(t)?["Z"]:e})),p=-1;if(_.forEach((function(t){var n=K(t),r=n[0],i=n.slice(1);if("M"===r)p=u.length,u.push(i[0]-a,i[1]-s);else if("C"===r)wi(i[0]-a,i[1]-s,i[2]-a,i[3]-s,i[4]-a,i[5]-s,u);else if("Z"===r&&(e.nodeName===E.Shape.PATH||e.nodeName===E.Shape.RECT)){var o;u.push(u[p],u[p+1]),(o=u).push.apply(o,z(Xi(u[p],u[p+1],u[p+2],u[p+3])))}})),t)return l=S()(u,[],2),{pointsBuffer:u,travelBuffer:[],triangles:l,instancedCount:Math.round(u.length/2)}}var v=Wi(i.value),R=Vi(r.value),m=R;R===Bi.CAP_ROUND&&(m=Bi.JOINT_CAP_ROUND),R===Bi.CAP_BUTT&&(m=Bi.JOINT_CAP_BUTT),R===Bi.CAP_SQUARE&&(m=Bi.JOINT_CAP_SQUARE);for(var T=3*(Math.round(0)+2),y=0,g=[],A=[],C=0;C<u.length;C+=2)C>1&&(y+=Math.sqrt(Math.pow(u[C]-u[C-2],2)+Math.pow(u[C+1]-u[C+1-2],2))),A.push(y),g[T++]=u[C],g[T++]=u[C+1],g[T]=v,0==C&&R!==Bi.CAP_ROUND&&(g[T]+=R),C+4>=u.length?g[T]+=m-v:C+2>=u.length&&(g[T]=0),T++;g[T++]=u[u.length-4],g[T++]=u[u.length-3],g[T++]=0,g[0]=u[0],g[1]=u[1],g[2]=0,g[3]=u[2],g[4]=u[3],g[5]=R===Bi.CAP_ROUND?R:0;var O=Math.round(u.length/2);return{pointsBuffer:g,travelBuffer:A,triangles:l,instancedCount:O}}function Wi(e){var t;switch(e){case E.LineJoin.BEVEL:t=Bi.JOINT_BEVEL;break;case E.LineJoin.ROUND:t=Bi.JOINT_ROUND;break;default:t=Bi.JOINT_MITER}return t}function Vi(e){var t;switch(e){case E.LineCap.SQUARE:t=Bi.CAP_SQUARE;break;case E.LineCap.ROUND:t=Bi.CAP_ROUND;break;default:t=Bi.CAP_BUTT}return t}function Xi(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t,i=[n-e,r-t],o=.01;return[e+i[0]*o,t+i[1]*o]}var Hi=function(e){U(n,e);var t=X(n);function n(){return B(this,n),t.apply(this,arguments)}return L(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"createGeometry",value:function(e){var t=ki(e[0],!0),n=t.triangles,r=t.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:_i.POSITION,byteStride:8,frequency:_e.PerVertex,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,byteStride:8,location:pi.POSITION}],data:new Float32Array(r)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))}},{key:"createMaterial",value:function(e){var t,n;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(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n\nlayout(location = POSITION) in vec2 a_Position;\n\nvoid main() {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * u_ModelMatrix * vec4(a_Position, u_ZIndex, 1.0);\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};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * 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_Color;\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}";var r=e[0],i=r.parsedStyle,o=i.fill,a=i.opacity,s=i.fillOpacity,u=i.anchor,l=i.visibility,c=[0,0,0,0];o instanceof E.CSSRGB&&(c=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)]);var f=r.isInteractive()&&(null===(t=r.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0],d=0,h=0,_=r.getGeometryBounds();if(_){var p=_.halfExtents;d=-p[0]*u[0].value*2,h=-p[1]*u[1].value*2}var v=Er();Tr(v,r.getWorldTransform(),mr(v,yr(d,h,0))),this.material.setUniforms((F(n={},Ui.MODEL_MATRIX,v),F(n,Ui.COLOR,c),F(n,Ui.PICKING_COLOR,f),F(n,Ui.OPACITY,a.value),F(n,Ui.FILL_OPACITY,s.value),F(n,Ui.VISIBLE,"visible"===l.value?1:0),F(n,Ui.Z_INDEX,.005*r.sortable.renderOrder),n))}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;j(G(n.prototype),"updateAttribute",this).call(this,e,t,r,i),e.forEach((function(e){var t=e.parsedStyle,n=t.fill,a=t.opacity,s=t.fillOpacity,u=t.anchor,l=t.visibility;if("lineJoin"===r||"lineCap"===r||e.nodeName===E.Shape.RECT&&("width"===r||"height"===r||"radius"===r)||e.nodeName===E.Shape.LINE&&("x1"===r||"y1"===r||"x2"===r||"y2"===r)||e.nodeName===E.Shape.POLYLINE&&"points"===r||e.nodeName===E.Shape.POLYGON&&"points"===r||e.nodeName===E.Shape.PATH&&"path"===r)o.material.geometryDirty=!0,o.material.programDirty=!0;else if("fill"===r){var c=[0,0,0,0];n instanceof E.CSSRGB&&(c=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),o.material.setUniforms(F({},Ui.COLOR,c))}else if("opacity"===r)o.material.setUniforms(F({},Ui.OPACITY,a.value));else if("fillOpacity"===r)o.material.setUniforms(F({},Ui.FILL_OPACITY,s.value));else if("anchor"===r||"modelMatrix"===r){var f=0,d=0,h=e.getGeometryBounds();if(h){var _=h.halfExtents;f=-_[0]*u[0].value*2,d=-_[1]*u[1].value*2}var p=Er();Tr(p,e.getWorldTransform(),mr(p,yr(f,d,0))),o.material.setUniforms(F({},Ui.MODEL_MATRIX,p))}else if("visibility"===r)o.material.setUniforms(F({},Ui.VISIBLE,"visible"===l.value?1:0));else if("pointerEvents"===r){var v,R=i&&e.isInteractive()&&(null===(v=e.renderable3D)||void 0===v?void 0:v.encodedPickingColor)||[0,0,0];o.material.setUniforms(F({},Ui.PICKING_COLOR,R))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(F({},Ui.Z_INDEX,.005*t))}}]),n}(vi);Hi=l([Object(v.injectable)()],Hi);var ji=function(e){U(n,e);var t=X(n);function n(){return B(this,n),t.apply(this,arguments)}return L(n,[{key:"shouldMerge",value:function(e,t){var r=j(G(n.prototype),"shouldMerge",this).call(this,e,t);return!!r&&this.instance.parsedStyle.img===e.parsedStyle.img}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.img;this.material.defines=D({},this.material.defines),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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\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\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 outputColor.a = outputColor.a * u_Opacity;\n }\n}";var n=this.texturePool.getOrCreateTexture(this.device,t);this.material.setUniforms({u_Map:n})}},{key:"createGeometry",value:function(e){j(G(n.prototype),"createGeometry",this).call(this,e);var t=[],r=[],i=[];e.forEach((function(e,n){var o=4*n,a=e.parsedStyle,s=a.width,u=a.height;t.push(s.value,u.value),r.push(0,0,1,0,1,1,0,1),i.push(0+o,2+o,1+o,0+o,3+o,2+o)})),this.geometry.setIndexBuffer(new Uint32Array(i)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:_i.POSITION,byteStride:8,frequency:_e.PerInstance,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,location:pi.POSITION}],data:new Float32Array(t)}),this.geometry.setVertexBuffer({bufferIndex:_i.UV,byteStride:8,frequency:_e.PerVertex,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,location:pi.UV}],data:new Float32Array(r)})}},{key:"updateAttribute",value:function(e,t,r,i){if(j(G(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"width"===r||"height"===r){var o=[];e.forEach((function(e){var t=e.parsedStyle,n=t.width,r=t.height;o.push(n.value,r.value)})),this.geometry.updateVertexBuffer(_i.POSITION,pi.POSITION,t,new Uint8Array(new Float32Array(o).buffer))}else if("img"===r){var a=this.texturePool.getOrCreateTexture(this.device,i);this.material.setUniforms({u_Map:a})}}}]),n}(vi);function Yi(e,t,n,r){var i=t.width,o=t.height;if(r){if(r.length!==i*o*n)throw new RangeError("mismatched image size")}else r=new Uint8Array(i*o*n);return e.width=i,e.height=o,e.data=r,e}function Ki(e,t,n,r,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.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||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,s=t.data,u=0;u<i.height;u++)for(var l=((n.y+u)*e.width+n.x)*o,c=((r.y+u)*t.width+r.x)*o,f=0;f<i.width*o;f++)s[c+f]=a[l+f];return t}ji=l([Object(v.injectable)()],ji);var zi=function(){function e(t,n){B(this,e),this.width=void 0,this.height=void 0,this.data=void 0,Yi(this,t,1,n)}return L(e,[{key:"resize",value:function(e){!function(e,t,n){var r=t.width,i=t.height;if(r!==e.width||i!==e.height){var o=Yi({},{width:r,height:i},n);Ki(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,i)},n),e.width=r,e.height=i,e.data=o.data}}(this,e,1)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,n,r,i){Ki(e,t,n,r,i,1)}}]),e}();var qi=L((function e(t){B(this,e),this.image=void 0,this.positions=void 0;var n={},r=[];for(var i in t){var o=t[i],a=n[i]={};for(var s in o){var u=o[+s];if(u&&0!==u.bitmap.width&&0!==u.bitmap.height){var l={x:0,y:0,w:u.bitmap.width+2,h:u.bitmap.height+2};r.push(l),a[s]={rect:l,metrics:u.metrics}}}}var c=function(e){var t,n=0,r=0,i=ee(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;n+=o.w*o.h,r=Math.max(r,o.w)}}catch(e){i.e(e)}finally{i.f()}e.sort((function(e,t){return t.h-e.h}));var a,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),r),h:1/0}],u=0,l=0,c=ee(e);try{for(c.s();!(a=c.n()).done;)for(var f=a.value,d=s.length-1;d>=0;d--){var h=s[d];if(!(f.w>h.w||f.h>h.h)){if(f.x=h.x,f.y=h.y,l=Math.max(l,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===h.w&&f.h===h.h){var _=s.pop();d<s.length&&(s[d]=_)}else f.h===h.h?(h.x+=f.w,h.w-=f.w):f.w===h.w?(h.y+=f.h,h.h-=f.h):(s.push({x:h.x+f.w,y:h.y,w:h.w-f.w,h:f.h}),h.y+=f.h,h.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:u,h:l,fill:n/(u*l)||0}}(r),f=c.w,d=c.h,h=new zi({width:f||1,height:d||1});for(var _ in t){var p=t[_];for(var E in p){var v=p[+E];if(v&&0!==v.bitmap.width&&0!==v.bitmap.height){var R=n[_][E].rect;zi.copy(v.bitmap,h,{x:0,y:0},{x:R.x+1,y:R.y+1},v.bitmap)}}}this.image=h,this.positions=n}));function Zi(){for(var e=[],t=32;t<128;t++)e.push(String.fromCharCode(t));return e}var Qi=function(){function e(){B(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphAtlas=void 0,this.glyphMap={},this.glyphAtlasTexture=void 0}return L(e,[{key:"getMap",value:function(){return this.glyphMap}},{key:"getAtlas",value:function(){return this.glyphAtlas}},{key:"getAtlasTexture",value:function(){return this.glyphAtlasTexture}},{key:"layout",value:function(e,t,n,r,i,o,a){var s=this,u=[],l=o,c=a,f="right"===r||"end"===r?1:"left"===r||"start"===r?0:.5;return e.forEach((function(e){var r=u.length;Array.from(e).forEach((function(e){var n=s.glyphMap[t],r=e.charCodeAt(0),o=n&&n[r];o&&(u.push({glyph:r,x:l,y:c,scale:1,fontStack:t}),l+=o.metrics.advance+i)}));for(var o=l-i,a=r;a<u.length;a++)u[a].x=u[a].x-f*o;l=0,c+=n})),u}},{key:"generateAtlas",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,s=[];this.glyphMap[t]||(s=Zi());var u=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(o.split(""))).forEach((function(e){-1===u.indexOf(e.charCodeAt(0).toString())&&s.push(e)})),s.length){var l=s.map((function(o){return e.generateSDF(t,n,r,i,o)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=D(D({},this.glyphMap[t]),l),this.glyphAtlas=new qi(this.glyphMap);var c=this.glyphAtlas.image,f=c.width,d=c.height,h=c.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=a.createTexture(D(D({},De(Ie.ALPHA,f,d,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([h],0)}}},{key:"generateSDF",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,o=i.charCodeAt(0),a=this.sdfGeneratorCache[e];a||(a=this.sdfGeneratorCache[e]=new O({fontSize:24,fontFamily:t,fontWeight:n,fontStyle:r,buffer:3,radius:8,cutoff:.25})),this.textMetricsCache[e]||(this.textMetricsCache[e]={}),this.textMetricsCache[e][i]||(this.textMetricsCache[e][i]=a.ctx.measureText(i).width);var s=a.draw(i),u=s.data,l=s.width,c=s.height,f=s.glyphWidth,d=s.glyphHeight,h=s.glyphLeft,_=s.glyphTop,p=s.glyphAdvance;return{id:o,bitmap:new zi({width:l,height:c},u),metrics:{width:f,height:d,left:h,top:_-24+3,advance:p}}}}]),e}();Qi=l([Object(v.injectable)()],Qi);var Ji,$i;!function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(Ji||(Ji={})),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"}($i||($i={}));var eo=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).glyphManager=void 0,e}return L(n,[{key:"shouldMerge",value:function(e,t){var r=j(G(n.prototype),"shouldMerge",this).call(this,e,t);if(!r)return!1;if(this.index!==t)return!1;var i=this.instance;return i.parsedStyle.fontSize.value===e.parsedStyle.fontSize.value&&(i.parsedStyle.metrics.font===e.parsedStyle.metrics.font&&!["fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(t){return i.parsedStyle[t]!==e.parsedStyle[t]})))}},{key:"createGeometry",value:function(e){var t=this,n=this.instance.parsedStyle,r=n.textBaseline,i=n.fontSize,o=n.letterSpacing,a=void 0===o?0:o,s=24/i.value,u=[],l=[],c=[],f=0;e.forEach((function(e){var n=e.parsedStyle,i=n.metrics,o=n.dx,d=n.dy,h=i.font,_=i.lines,p=i.height,v=i.lineHeight,R=0,m=0;o&&o.unit===E.UnitType.kPixels&&(R+=o.value),d&&d.unit===E.UnitType.kPixels&&(m+=d.value);var T=0;"middle"===r.value?T=-p/2:"bottom"===r.value?T=-p:"top"===r.value||"hanging"===r.value?T=0:"alphabetic"===r.value?T=.25*v-p:"ideographic"===r.value&&(T=-p);var y=t.glyphManager.getAtlas(),g=t.buildTextBuffers({object:e,lines:_,fontStack:h,lineHeight:s*v,offsetX:s*R,offsetY:s*(T+m),letterSpacing:s*a,glyphAtlas:y,indicesOffset:f}),A=g.indicesOffset,S=g.indexBuffer,C=g.charUVOffsetBuffer,O=g.charPackedBuffer;f=A,c.push.apply(c,z(O)),l.push.apply(l,z(C)),u.push.apply(u,z(S))})),this.geometry.vertexCount=u.length,this.geometry.setIndexBuffer(new Uint32Array(u)),this.geometry.setVertexBuffer({bufferIndex:0,byteStride:144,frequency:_e.PerVertex,attributes:[{format:Ie.F32_RGBA,bufferByteOffset:0,location:pi.MODEL_MATRIX0},{format:Ie.F32_RGBA,bufferByteOffset:16,location:pi.MODEL_MATRIX1},{format:Ie.F32_RGBA,bufferByteOffset:32,location:pi.MODEL_MATRIX2},{format:Ie.F32_RGBA,bufferByteOffset:48,location:pi.MODEL_MATRIX3},{format:Ie.F32_RGBA,bufferByteOffset:64,location:pi.COLOR},{format:Ie.F32_RGBA,bufferByteOffset:80,location:pi.STROKE_COLOR},{format:Ie.F32_RGBA,bufferByteOffset:96,location:pi.PACKED_STYLE1},{format:Ie.F32_RGBA,bufferByteOffset:112,location:pi.PACKED_STYLE2},{format:Ie.F32_RGBA,bufferByteOffset:128,location:pi.PICKING_COLOR}],data:new Float32Array(c)}),this.geometry.setVertexBuffer({bufferIndex:1,byteStride:16,frequency:_e.PerVertex,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,location:Ji.TEX},{format:Ie.F32_RG,bufferByteOffset:8,location:Ji.OFFSET}],data:new Float32Array(l)})}},{key:"createMaterial",value: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(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\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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_UV;\nout float v_GammaScale;\n\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n v_UV = a_Tex / u_SDFMapSize;\n\n float fontScale = u_FontSize / 24.;\n\n gl_Position = project(vec4(a_Offset * fontScale, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n v_GammaScale = gl_Position.w;\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};\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\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nin vec2 v_UV;\nin float v_GammaScale;\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\n float dist = texture(SAMPLER_2D(u_SDFMap), v_UV).a;\n\n float EDGE_GAMMA = 0.105 / u_DevicePixelRatio;\n float fontScale = u_FontSize / 24.0;\n highp float gamma = EDGE_GAMMA / (fontScale * u_GammaScale);\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 gamma = (u_StrokeBlur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_GammaScale);\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = gamma * v_GammaScale;\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 < 0.001) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=oe.Back,this.material.defines=D(D({},this.material.defines),di(Ji));var n=this.instance.parsedStyle,r=n.fontSize,i=n.fontFamily,o=void 0===i?"":i,a=n.fontWeight,s=n.fontStyle,u=n.metrics.font,l=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(u,o,a.toString(),s.toString(),l,this.device);var c=this.glyphManager.getAtlasTexture(),f=this.glyphManager.getAtlas();this.device.setResourceName(c,"TextSDF Texture");var d=f.image,h=d.width,_=d.height;this.material.setUniforms((F(t={},$i.SDF_MAP,c),F(t,$i.SDF_MAP_SIZE,[h,_]),F(t,$i.FONT_SIZE,r.value),F(t,$i.GAMMA_SCALE,1),F(t,$i.STROKE_BLUR,.2),F(t,$i.HAS_STROKE,this.index),t))}},{key:"changeRenderOrder",value:function(e,t){this.material&&(this.material.programDirty=!0,this.material.geometryDirty=!0)}},{key:"updateAttribute",value:function(e,t,n,r){"text"===n||"fontFamily"===n||"fontSize"===n||"fontWeight"===n||"fontStyle"===n||"fontVariant"===n||"textBaseline"===n||"letterSpacing"===n||"wordWrapWidth"===n||"lineHeight"===n||"wordWrap"===n||"textAlign"===n||"modelMatrix"===n||"visibility"===n||"dx"===n||"dy"===n?(this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0):"fill"!==n&&"fillOpacity"!==n&&"stroke"!==n&&"strokeOpacity"!==n&&"opacity"!==n&&"lineWidth"!==n&&"visibility"!==n&&"pointerEvents"!==n||(this.material.geometryDirty=!0)}},{key:"buildTextBuffers",value:function(e){var t,n=e.object,r=e.lines,i=e.fontStack,o=e.lineHeight,a=e.letterSpacing,s=e.offsetX,u=e.offsetY,l=e.glyphAtlas,c=e.indicesOffset,f=n.parsedStyle,d=f.textAlign,h=f.fill,_=f.stroke,p=f.opacity,v=f.fillOpacity,R=f.strokeOpacity,m=f.lineWidth,T=f.visibility,y=[0,0,0,0];h instanceof E.CSSRGB&&(y=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]);var g=[0,0,0,0];_ instanceof E.CSSRGB&&(g=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)]);var A=n.isInteractive()&&(null===(t=n.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0],S=vr(Er(),n.getWorldTransform()),C=[],O=[],I=[],N=c;return function(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var u=a.metrics.advance*i.scale/2,l=[i.x+u,i.y],c=(a.metrics.left-4)*i.scale-u+l[0],f=(-a.metrics.top-4)*i.scale+l[1],d=c+s.w*i.scale,h=f+s.h*i.scale,_={x:c,y:f},p={x:d,y:f},E={x:c,y:h},v={x:d,y:h};n.push({tl:_,tr:p,bl:E,br:v,tex:s,glyphOffset:[0,0]})}}}return n}(this.glyphManager.layout(r,i,o,d.value,a,s,u),l.positions).forEach((function(e){var t=[].concat(z(S),z(y),z(g),[p.value,v.value,R.value,m.value,"visible"===T.value?1:0,0,0,0],z(A),[.005*n.sortable.renderOrder]);C.push.apply(C,z(t).concat(z(t),z(t),z(t))),O.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),O.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),O.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),O.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),I.push(0+N,2+N,1+N),I.push(2+N,0+N,3+N),N+=4})),{indexBuffer:I,charUVOffsetBuffer:O,charPackedBuffer:C,indicesOffset:N}}}]),n}(vi);l([Object(v.inject)(Qi),c("design:type",Qi)],eo.prototype,"glyphManager",void 0),eo=l([Object(v.injectable)()],eo);var to=function(e){U(n,e);var t=X(n);function n(){return B(this,n),t.apply(this,arguments)}return L(n,[{key:"shouldMerge",value:function(e,t){var r=j(G(n.prototype),"shouldMerge",this).call(this,e,t);return!!r&&(this.instance.nodeName!==E.Shape.MESH||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,r,i){j(G(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i)}},{key:"createMaterial",value:function(e){var t=this.instance.parsedStyle.material;this.material=t,this.observeMaterialChanged()}},{key:"createGeometry",value:function(e){var t=this.instance.parsedStyle.geometry;this.geometry=t,j(G(n.prototype),"createGeometry",this).call(this,e),this.geometry.build(e),this.observeGeometryChanged()}}]),n}(vi);to=l([Object(v.injectable)()],to);var no=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[yi,Gi],e}return L(n,[{key:"shouldSubmitRenderInst",value:function(e,t){if(0===t&&e.parsedStyle.fill.isNone)return!1;return 1!==t||this.needDrawStrokeSeparately(e)}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,n=t.fill,r=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=n&&!n.isNone,u=r&&!r.isNone,l=i&&i.length&&i.every((function(e){return 0!==e.value}));return!s||u&&o.value>0&&(a.value<1||l)}}]),n}(ai);no=l([Object(v.injectable)({token:[{token:ei,named:E.Shape.CIRCLE},{token:ei,named:E.Shape.ELLIPSE}]})],no);var ro=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Hi,Gi],e}return L(n,[{key:"shouldSubmitRenderInst",value:function(e,t){var n=e.parsedStyle,r=n.fill,i=n.strokeOpacity,o=n.lineDash,a=n.lineWidth,s=e.nodeName;if(0===t&&(e.nodeName===E.Shape.POLYLINE||r.isNone))return!1;if(1===t){if(0===i.value||0===a.value)return!1;var u=o&&o.length&&o.every((function(e){return 0!==e.value}));if(s===E.Shape.CIRCLE||s===E.Shape.ELLIPSE)return u}return!0}}]),n}(ai);ro=l([Object(v.injectable)({token:[{token:ei,named:E.Shape.POLYLINE},{token:ei,named:E.Shape.PATH},{token:ei,named:E.Shape.POLYGON},{token:ei,named:E.Shape.RECT}]})],ro);var io=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[],e}return L(n,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),n}(ai);io=l([Object(v.injectable)({token:[{token:ei,named:E.Shape.GROUP}]})],io);var oo=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[ji],e}return L(n,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),n}(ai);oo=l([Object(v.injectable)({token:[{token:ei,named:E.Shape.IMAGE}]})],oo);var ao=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[eo,eo],e}return L(n,[{key:"shouldSubmitRenderInst",value:function(e,t){var n=e.parsedStyle,r=n.stroke,i=n.lineWidth;return!(!(r&&i&&i.value)&&0===t)}},{key:"beforeUploadUBO",value:function(e,t,n){t.material.setUniforms(F({},$i.HAS_STROKE,1-t.index))}}]),n}(ai);ao=l([Object(v.injectable)({token:[{token:ei,named:E.Shape.TEXT}]})],ao);var so=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Ii],e}return L(n,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),n}(ai);so=l([Object(v.injectable)({token:{token:ei,named:E.Shape.LINE}})],so);var uo=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[to],e}return L(n)}(ai);uo=l([Object(v.injectable)({token:[{token:ei,named:E.Shape.MESH}]})],uo);var lo=["style"],co=function(e){U(n,e);var t=X(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,i=k(e,lo);return B(this,n),t.call(this,D({type:n.tag,style:D({intensity:Math.PI},r)},i))}return L(n)}(E.DisplayObject);co.tag="light";var fo,ho=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(fo||(fo={}));var _o=function(e){U(n,e);var t=X(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,i=k(e,ho);return B(this,n),t.call(this,D({type:n.tag,style:D({type:fo.NONE,fill:"black",start:1,end:1e3,density:0},r)},i))}return L(n)}(E.DisplayObject);_o.tag="fog";var po,Eo,vo,Ro=v.Syringe.defineToken("DeviceContribution");!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"}(vo||(vo={}));var mo,To,yo=((po=function(){function e(){B(this,e),this.canvasConfig=void 0,this.contextService=void 0,this.renderingContext=void 0,this.camera=void 0,this.renderHelper=void 0,this.lightPool=void 0,this.texturePool=void 0,this.batchManager=void 0,this.deviceContribution=void 0,this.device=void 0,this.swapChain=void 0,this.renderLists={world:new Ur,picking:new Ur},this.builder=void 0}return L(e,[{key:"getDevice",value:function(){return this.device}},{key:"getSwapChain",value:function(){return this.swapChain}},{key:"getRenderLists",value:function(){return this.renderLists}},{key:"apply",value:function(e){var t=this,n=function(e){var n=e.target;if(n.nodeName!==co.tag)if(n.nodeName!==_o.tag){var r=new te;n.renderable3D=r,t.batchManager.add(n)}else t.lightPool.addFog(n);else t.lightPool.addLight(n)},r=function(e){var n=e.target;n.nodeName!==co.tag?n.nodeName!==_o.tag?(t.batchManager.remove(n),delete n.renderable3D):t.lightPool.removeFog(n):t.lightPool.removeLight(n)},i=function(e){var n=e.target,r=e.attrName,i=e.newValue;t.batchManager.updateAttribute(n,r,i)},o=function(e){var n=e.target,r=e.detail.renderOrder;t.batchManager.changeRenderOrder(n,r)};e.hooks.init.tapPromise(Eo.tag,x(regeneratorRuntime.mark((function a(){var s,u,l,c;return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return t.renderingContext.root.addEventListener(E.ElementEvent.MOUNTED,n),t.renderingContext.root.addEventListener(E.ElementEvent.UNMOUNTED,r),t.renderingContext.root.addEventListener(E.ElementEvent.ATTR_MODIFIED,i),t.renderingContext.root.addEventListener(E.ElementEvent.RENDER_ORDER_CHANGED,o),t.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering=!1,s=t.contextService.getDomElement(),u=t.canvasConfig,l=u.width,c=u.height,t.contextService.resize(l,c),a.next=10,t.deviceContribution.createSwapChain(s);case 10:t.swapChain=a.sent,t.device=t.swapChain.getDevice(),t.renderHelper.setDevice(t.device),t.renderHelper.renderInstManager.disableSimpleMode(),t.swapChain.configureSwapChain(s.width,s.height),t.renderingContext.root.ownerDocument.defaultView.on(E.CanvasEvent.RESIZE,(function(){t.swapChain.configureSwapChain(s.width,s.height)})),t.batchManager.attach(t.device,e);case 17:case"end":return a.stop()}}),a)})))),e.hooks.destroy.tap(Eo.tag,(function(){t.renderHelper.destroy(),t.renderingContext.root.removeEventListener(E.ElementEvent.MOUNTED,n),t.renderingContext.root.removeEventListener(E.ElementEvent.UNMOUNTED,r),t.renderingContext.root.removeEventListener(E.ElementEvent.ATTR_MODIFIED,i),t.renderingContext.root.removeEventListener(E.ElementEvent.RENDER_ORDER_CHANGED,o)})),e.hooks.beginFrame.tap(Eo.tag,(function(){var e=t.swapChain.getCanvas(),n=t.renderHelper.renderInstManager;t.builder=t.renderHelper.renderGraph.newGraphBuilder();var r=Object(E.parseColor)(t.canvasConfig.background),i=t.canvasConfig.background?ze(Number(r.r)/255,Number(r.g)/255,Number(r.b)/255,Number(r.alpha)):Qe,o={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:Xr.None},a=zr(Yn.Color0,o,Vr(i)),s=zr(Yn.DepthStencil,o,Yr),u=t.builder.createRenderTargetID(a,"Main Color"),l=t.builder.createRenderTargetID(s,"Main Depth");t.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Yn.Color0,u),e.attachRenderTargetID(Yn.DepthStencil,l),e.exec((function(e){t.renderLists.world.drawOnPassRenderer(n.renderCache,e)}))})),t.builder.resolveRenderTargetToExternalTexture(u,t.swapChain.getOnscreenTexture())})),e.hooks.endFrame.tap(Eo.tag,(function(){var e=t.renderHelper.renderInstManager,n=t.renderHelper.pushTemplateRenderInst();n.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),n.setMegaStateFlags(Pt({depthWrite:!0},{rgbBlendMode:se.Add,alphaBlendMode:se.Add,rgbBlendSrcFactor:ae.SrcAlpha,alphaBlendSrcFactor:ae.Zero,rgbBlendDstFactor:ae.OneMinusSrcAlpha,alphaBlendDstFactor:ae.One}));var r=t.canvasConfig,i=r.width,o=r.height;n.setUniforms(0,[{name:vo.PROJECTION_MATRIX,value:t.camera.getPerspective()},{name:vo.VIEW_MATRIX,value:t.camera.getViewTransform()},{name:vo.CAMERA_POSITION,value:t.camera.getPosition()},{name:vo.DEVICE_PIXEL_RATIO,value:t.contextService.getDPR()},{name:vo.VIEWPORT,value:[i,o]},{name:vo.IS_ORTHO,value:t.camera.isOrtho()?1:0},{name:vo.IS_PICKING,value:0}]),t.batchManager.render(t.renderLists.world),e.popTemplateRenderInst(),t.renderHelper.prepareToRender(),t.renderHelper.renderGraph.execute(),e.resetRenderInsts(),t.swapChain.present()}))}},{key:"loadTexture",value:function(e,t,n){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){n&&n(e)}))}}]),e}()).tag="RenderGraph",Eo=po);l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],yo.prototype,"canvasConfig",void 0),l([Object(v.inject)(E.ContextService),c("design:type",Object)],yo.prototype,"contextService",void 0),l([Object(v.inject)(E.RenderingContext),c("design:type",Object)],yo.prototype,"renderingContext",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],yo.prototype,"camera",void 0),l([Object(v.inject)(kr),c("design:type",kr)],yo.prototype,"renderHelper",void 0),l([Object(v.inject)(Jr),c("design:type",Jr)],yo.prototype,"lightPool",void 0),l([Object(v.inject)(Qr),c("design:type",Qr)],yo.prototype,"texturePool",void 0),l([Object(v.inject)(ri),c("design:type",ri)],yo.prototype,"batchManager",void 0),l([Object(v.inject)(Ro),c("design:type",Object)],yo.prototype,"deviceContribution",void 0),yo=Eo=l([Object(v.singleton)({contrib:E.RenderingPluginContribution})],yo);var go=((mo=function(){function e(){B(this,e),this.canvasConfig=void 0,this.sceneGraphService=void 0,this.contextService=void 0,this.renderingContext=void 0,this.renderHelper=void 0,this.renderGraphPlugin=void 0,this.pickingIdGenerator=void 0,this.camera=void 0,this.batchManager=void 0}var t;return L(e,[{key:"apply",value:function(e){var t=this,n=function(e){var n=e.target,r=n.renderable3D;if(r){var i=t.pickingIdGenerator.getId(n);r.pickingId=i,r.encodedPickingColor=t.pickingIdGenerator.encodePickingColor(i)}};e.hooks.init.tapPromise(To.tag,x(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.renderingContext.root.addEventListener(E.ElementEvent.MOUNTED,n);case 1:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(To.tag,(function(){t.renderingContext.root.removeEventListener(E.ElementEvent.MOUNTED,n)})),e.hooks.pick.tapPromise(To.tag,function(){var e=x(regeneratorRuntime.mark((function e(n){var r,i,o,a,s,u,l,c,f,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.topmost,i=n.position,o=i.viewportX,a=i.viewportY,s=t.contextService.getDPR(),u=t.canvasConfig.width*s,l=t.canvasConfig.height*s,f=a*s,!((c=o*s)>u||c<0||f>l||f<0)){e.next=10;break}return n.picked=[],e.abrupt("return",n);case 10:return e.next=12,t.pickByRectangleInDepth(new E.Rectangle(Object(E.clamp)(Math.round(c),0,u-1),Object(E.clamp)(Math.round(f),0,l-1),1,1),r?1:100);case 12:return d=e.sent,n.picked=d,e.abrupt("return",n);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"pickByRectangleInDepth",value:(t=x(regeneratorRuntime.mark((function e(t){var n,r,i,o,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=a.length>1&&void 0!==a[1]?a[1]:100,r=null,i=1,o=[];case 4:return e.next=6,this.pickByRectangle(t,r);case 6:if(!(r=e.sent)){e.next=12;break}i++,o.push(r),e.next=13;break;case 12:return e.abrupt("break",14);case 13:if(r&&i<=n){e.next=4;break}case 14:return n>1&&this.restorePickingColor(o),e.abrupt("return",o);case 16:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"restorePickingColor",value:function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))}},{key:"pickByRectangle",value:function(e,t){var n=this,r=this.renderGraphPlugin.getDevice(),i=this.renderGraphPlugin.getRenderLists(),o=this.renderHelper.renderInstManager,a=this.renderHelper.renderGraph.newGraphBuilder(),s=Qe,u=e.x,l=e.y,c=e.width,f=e.height,d={backbufferWidth:c,backbufferHeight:f,antialiasingMode:Xr.None},h=zr(Yn.Color0,d,Vr(s)),_=a.createRenderTargetID(h,"Picking Color"),p=zr(Yn.DepthStencil,d,Yr),E=a.createRenderTargetID(p,"Picking Depth"),v=D({},this.camera.getView());return new Promise((function(e){n.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),a.pushPass((function(t){t.setDebugName("Picking Pass"),t.attachRenderTargetID(Yn.Color0,_),t.attachRenderTargetID(Yn.DepthStencil,E),t.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)})),t.post((function(t){var i=t.getRenderTargetTexture(Yn.Color0),o=r.createReadback();v&&v.enabled?n.camera.setViewOffset(v.fullWidth,v.fullHeight,v.offsetX,v.offsetY,v.width,v.height):n.camera.clearViewOffset(),n.camera.setEnableUpdate(!0),o.readTexture(i,0,0,c,f,new Uint8Array(c*f*4)).then((function(t){var r,i=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(i=n.pickingIdGenerator.decodePickingColor(t)),i>-1){var a=n.pickingIdGenerator.getById(i);a&&a.isVisible()&&a.isInteractive()&&(r=a)}o.destroy(),e(r)}))}))}));var s=n.renderHelper.pushTemplateRenderInst();s.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),s.setMegaStateFlags(Pt({depthWrite:!0},{rgbBlendMode:se.Add,rgbBlendSrcFactor:ae.One,rgbBlendDstFactor:ae.Zero,alphaBlendMode:se.Add,alphaBlendSrcFactor:ae.One,alphaBlendDstFactor:ae.Zero}));var d=n.canvasConfig,h=d.width,p=d.height,R=n.contextService.getDPR();n.camera.setEnableUpdate(!1),n.camera.setViewOffset(h*R,p*R,u,l,c,f),s.setUniforms(0,[{name:vo.PROJECTION_MATRIX,value:n.camera.getPerspective()},{name:vo.VIEW_MATRIX,value:n.camera.getViewTransform()},{name:vo.CAMERA_POSITION,value:n.camera.getPosition()},{name:vo.DEVICE_PIXEL_RATIO,value:n.contextService.getDPR()},{name:vo.VIEWPORT,value:[h,p]},{name:vo.IS_ORTHO,value:n.camera.isOrtho()?1:0},{name:vo.IS_PICKING,value:1}]),t&&n.batchManager.updateAttribute(t,"pointerEvents",!1,!0),n.batchManager.render(i.picking,!0),o.popTemplateRenderInst(),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),o.resetRenderInsts()}))}}]),e}()).tag="WebGLPicker",To=mo);l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],go.prototype,"canvasConfig",void 0),l([Object(v.inject)(E.SceneGraphService),c("design:type",Object)],go.prototype,"sceneGraphService",void 0),l([Object(v.inject)(E.ContextService),c("design:type",Object)],go.prototype,"contextService",void 0),l([Object(v.inject)(E.RenderingContext),c("design:type",Object)],go.prototype,"renderingContext",void 0),l([Object(v.inject)(kr),c("design:type",kr)],go.prototype,"renderHelper",void 0),l([Object(v.inject)(yo),c("design:type",yo)],go.prototype,"renderGraphPlugin",void 0),l([Object(v.inject)(Pe),c("design:type",Pe)],go.prototype,"pickingIdGenerator",void 0),l([Object(v.inject)(E.DefaultCamera),c("design:type",E.Camera)],go.prototype,"camera",void 0),l([Object(v.inject)(ri),c("design:type",ri)],go.prototype,"batchManager",void 0),go=To=l([Object(v.singleton)({contrib:E.RenderingPluginContribution})],go);var Ao=["style"],So=function(e){U(n,e);var t=X(n);function n(e){var r,i=e.style,o=k(e,Ao);return B(this,n),(r=t.call(this,D({type:E.Shape.MESH,style:D({x:"",y:"",z:"",lineWidth:0},i)},o))).cullable.enable=!1,r.style.geometry.meshes.push(W(r)),r.style.material.meshes.push(W(r)),r}return L(n,[{key:"destroy",value:function(){j(G(n.prototype),"destroy",this).call(this);var e=this.style.geometry.meshes,t=e.indexOf(this);e.splice(t,1),t=(e=this.style.material.meshes).indexOf(this),e.splice(t,1)}}]),n}(E.DisplayObject),Co=function(){function e(){B(this,e)}return L(e,[{key:"update",value:function(e){return e.geometry.computeBoundingBox(),{width:0,height:0,depth:0}}}]),e}();Co=l([Object(v.singleton)({token:{token:E.GeometryAABBUpdater,named:E.Shape.MESH}})],Co);var Oo,Io,No,Po="#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}",Do="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = texture(SAMPLER_2D(u_Texture), v_TexCoord);\n}",Mo=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).vert=Po,e.frag=Do,e.features={},e}return L(n)}(xn),xo="#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}",Bo=function(e){U(n,e);var t=X(n);function n(){var e;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).features={},e.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",e.vert=Po,e.frag=xo,e}return L(n)}(xn),bo=pt(1,(function(){return new qr}));function Lo(e,t,n,r){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Yn.Color0,r);var o=e.resolveRenderTarget(r);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(Nt),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);Pr(a.mapUniformBufferF32(0),s,1/n.backbufferWidth,1/n.backbufferHeight);var u=new Bo,l=t.renderCache.createProgram(u);a.setProgram(l),Oo||((Oo=new li(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:_e.PerVertex,attributes:[{format:Ie.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),Oo.vertexCount=3,No=t.getCache().createInputLayout(Oo.inputLayoutDescriptor),Io=t.getDevice().createInputState(No,Oo.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,n){bo[0].texture=n.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(bo),a.setInputLayoutAndState(No,Io),a.drawOnPass(t.renderCache,e)}))}))}var Fo,Uo,Go=Object(v.Module)((function(e){e(kr),e(Qr),e(Jr),e(Qi),e(Pe),e(ri),e(yo),e(go),e(yi),e(Ii),e(Gi),e(Hi),e(ji),e(eo),e(to),e({token:ti,useFactory:function(e){return function(t){return e.container.isBound(t)&&e.container.get(t)||null}}}),e(no),e(ro),e(oo),e(so),e(ao),e(uo),e({token:$r,useFactory:function(e){var t={};return function(n){return t[n]||e.container.isBoundNamed(ei,n)&&(t[n]=e.container.getNamed(ei,n)),t[n]||null}}})})),wo=function(){function e(){B(this,e),this.name="device-renderer",this.container=void 0}return L(e,[{key:"init",value:function(e){v.GlobalContainer.isBound(Co)||v.GlobalContainer.register(Co),this.container=e,e.load(Go,!0)}},{key:"destroy",value:function(e){v.GlobalContainer.isBound(Co)&&v.GlobalContainer.remove(Co),e.unload(Go)}},{key:"getDevice",value:function(){return this.container.get(yo).getDevice()}},{key:"loadTexture",value:function(e,t,n){return this.container.get(yo).loadTexture(e,t,n)}}]),e}(),ko=v.Syringe.defineToken("WebGPUDeviceOptions");function Wo(e){if(e===Ie.U8_RGBA_RT)return"bgra8unorm";if(e===Ie.U8_RGBA_NORM)return"rgba8unorm";if(e===Ie.U8_RG_NORM)return"rg8unorm";if(e===Ie.U32_R)return"r32uint";if(e===Ie.D24)return"depth24plus";if(e===Ie.D24_S8)return"depth24plus-stencil8";if(e===Ie.D32F)return"depth32float";if(e===Ie.D32F_S8)return"depth32float-stencil8";if(e===Ie.BC1)return"bc1-rgba-unorm";if(e===Ie.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===Ie.BC2)return"bc2-rgba-unorm";if(e===Ie.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===Ie.BC3)return"bc3-rgba-unorm";if(e===Ie.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===Ie.BC4_SNORM)return"bc4-r-snorm";if(e===Ie.BC4_UNORM)return"bc4-r-unorm";if(e===Ie.BC5_SNORM)return"bc5-rg-snorm";if(e===Ie.BC5_UNORM)return"bc5-rg-unorm";throw new Error("whoops")}function Vo(e){if(e===ue.Clamp)return"clamp-to-edge";if(e===ue.Repeat)return"repeat";if(e===ue.Mirror)return"mirror-repeat";throw new Error("whoops")}function Xo(e){if(e===le.Bilinear)return"linear";if(e===le.Point)return"nearest";throw new Error("whoops")}function Ho(e){if(e===ce.Linear)return"linear";if(e===ce.Nearest)return"nearest";if(e===ce.NoMip)return"nearest";throw new Error("whoops")}function jo(e){if(e===Te.Float)return"float";if(e===Te.Depth)return"depth";throw new Error("whoops")}function Yo(e){if(e===Ee.n2D)return"2d";if(e===Ee.n2DArray)return"2d-array";if(e===Ee.n3D)return"3d";if(e===Ee.Cube)return"cube";throw new Error("whoops")}function Ko(e){return e.gpuBuffer}function zo(e){if(e===Ae.OcclusionConservative)return"occlusion";throw new Error("whoops")}function qo(e){switch(e){case fe.Triangles:return"triangle-list";case fe.Points:return"point-list";case fe.TriangleStrip:return"triangle-strip";case fe.Lines:return"line-list";case fe.LineStrip:return"line-strip";default:throw new Error("Unknown primitive topology mode")}}function Zo(e){if(e===oe.None)return"none";if(e===oe.Front)return"front";if(e===oe.Back)return"back";throw new Error("whoops")}function Qo(e){if(e===ie.CCW)return"ccw";if(e===ie.CW)return"cw";throw new Error("whoops")}function Jo(e){if(e===ae.Zero)return"zero";if(e===ae.One)return"one";if(e===ae.Src)return"src";if(e===ae.OneMinusSrc)return"one-minus-src";if(e===ae.Dst)return"dst";if(e===ae.OneMinusDst)return"one-minus-dst";if(e===ae.SrcAlpha)return"src-alpha";if(e===ae.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===ae.DstAlpha)return"dst-alpha";if(e===ae.OneMinusDstAlpha)return"one-minus-dst-alpha";throw new Error("whoops")}function $o(e){if(e===se.Add)return"add";if(e===se.Subtract)return"subtract";if(e===se.ReverseSubtract)return"reverse-subtract";throw new Error("whoops")}function ea(e){return{operation:$o(e.blendMode),srcFactor:Jo(e.blendSrcFactor),dstFactor:Jo(e.blendDstFactor)}}function ta(e,t){return t.attachmentsState.map((function(t,n){return function(e,t){return{format:Wo(t),blend:{color:ea(e.rgbBlendState),alpha:ea(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[n])}))}function na(e){if(e===re.Never)return"never";if(e===re.Less)return"less";if(e===re.Equal)return"equal";if(e===re.LessEqual)return"less-equal";if(e===re.Greater)return"greater";if(e===re.NotEqual)return"not-equal";if(e===re.GreaterEqual)return"greater-equal";if(e===re.Always)return"always";throw new Error("whoops")}function ra(e){if(e===_e.PerVertex)return"vertex";if(e===_e.PerInstance)return"instance";throw new Error("whoops")}function ia(e){if(e===Ie.U8_R)return"uint8x2";if(e===Ie.U8_RG)return"uint8x2";if(e===Ie.U8_RGB)return"uint8x4";if(e===Ie.U8_RGBA)return"uint8x4";if(e===Ie.U8_RGBA_NORM)return"unorm8x4";if(e===Ie.S8_RGB_NORM)return"snorm8x4";if(e===Ie.S8_RGBA_NORM)return"snorm8x4";if(e===Ie.S16_RG)return"uint16x2";if(e===Ie.F32_R)return"float32";if(e===Ie.F32_RG)return"float32x2";if(e===Ie.F32_RGB)return"float32x3";if(e===Ie.F32_RGBA)return"float32x4";throw new Error("whoops")}function oa(e){switch(be(e)){case Se.BC1:case Se.BC2:case Se.BC3:case Se.BC4_SNORM:case Se.BC4_UNORM:case Se.BC5_SNORM:case Se.BC5_UNORM:return 4;default:return 1}}function aa(e,t,n,r){switch(void 0===n&&(n=!1),e){case Ie.S8_R:case Ie.S8_R_NORM:case Ie.S8_RG_NORM:case Ie.S8_RGB_NORM:case Ie.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return r&&i.set(new Int8Array(r)),i;case Ie.U8_R:case Ie.U8_R_NORM:case Ie.U8_RG:case Ie.U8_RG_NORM:case Ie.U8_RGB:case Ie.U8_RGB_NORM:case Ie.U8_RGB_SRGB:case Ie.U8_RGBA:case Ie.U8_RGBA_NORM:case Ie.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return r&&o.set(new Uint8Array(r)),o;case Ie.S16_R:case Ie.S16_RG:case Ie.S16_RG_NORM:case Ie.S16_RGB_NORM:case Ie.S16_RGBA:case Ie.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(n?t/2:t);return r&&a.set(new Int16Array(r)),a;case Ie.U16_R:case Ie.U16_RGB:case Ie.U16_RGBA_5551:case Ie.U16_RGBA_NORM:case Ie.U16_RG_NORM:case Ie.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(n?t/2:t);return r&&s.set(new Uint16Array(r)),s;case Ie.S32_R:var u=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(n?t/4:t);return r&&u.set(new Int32Array(r)),u;case Ie.U32_R:case Ie.U32_RG:var l=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(n?t/4:t);return r&&l.set(new Uint32Array(r)),l;case Ie.F32_R:case Ie.F32_RG:case Ie.F32_RGB:case Ie.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(n?t/4:t);return r&&c.set(new Float32Array(r)),c}var f=(ArrayBuffer,new Uint8Array(t));return r&&f.set(new Uint8Array(r)),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"}(Fo||(Fo={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Uo||(Uo={}));var sa=function(e){function t(t){var n=t.id,r=t.device,i=e.call(this)||this;return i.id=n,i.device=r,i}return s(t,e),t.prototype.destroy=function(){},t}(g.EventEmitter),ua=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.Bindings;var a=i.pipeline,s=i.bindingLayout;Xe(!!a);var u=o.device._createBindGroupLayout(s),l=[[],[]],c=0;if(s.storageEntries)for(var f=0;f<s.storageEntries.length;f++){Xe((h=i.storageBufferBindings[f]).wordCount>0);var d={buffer:Ko(h.buffer),offset:0,size:h.wordCount<<2};l[0].push({binding:c++,resource:d})}for(f=0;f<s.numUniformBuffers;f++){Xe((h=i.uniformBufferBindings[f]).wordCount>0);d={buffer:Ko(h.buffer),offset:0,size:h.wordCount<<2};l[0].push({binding:c++,resource:d})}c=0;for(f=0;f<s.numSamplers;f++){var h,_=void 0!==s.samplerEntries?s.samplerEntries[f]:Mt,p=null!==(h=i.samplerBindings[f]).texture?h.texture:o.device.getFallbackTexture(_);Xe(_.dimension===p.dimension),Xe(_.formatKind===Ve(p.pixelFormat));var E=p.gpuTextureView;l[1].push({binding:c++,resource:E});var v=null!==h.sampler?h.sampler:o.device.fallbackSampler,R=v.gpuSampler;l[1].push({binding:c++,resource:R})}return o.gpuBindGroup=l.map((function(e,t){return o.device.device.createBindGroup({layout:a.getBindGroupLayout(t),entries:e})})),o.bindingLayout=i.bindingLayout,o.bindGroupLayout=u,o}return s(t,e),t}(sa);function la(e){return void 0!==e.byteLength}var ca=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.Buffer;var a=i.usage,s=i.viewOrSize,u=la(s)?s.byteLength+3&-4:s+3&-4;o.usage=a,o.usage&de.MAP_READ&&(o.usage=de.MAP_READ|de.COPY_DST);var l=la(s);if(o.size=la(s)?s.byteLength:s,o.view=la(s)?s:null,o.gpuBuffer=o.device.device.createBuffer({usage:o.usage,size:u,mappedAtCreation:l}),l){var c=o.gpuBuffer.getMappedRange();new s.constructor(c).set(s),o.gpuBuffer.unmap()}return o}return s(t,e),t.prototype.setSubData=function(e,t,n,r){void 0===n&&(n=0),void 0===r&&(r=0);var i=this.gpuBuffer;r=r||t.byteLength,r=Math.min(r,this.size-e);var o=t.byteOffset+n,a=o+r,s=r+3&-4;if(s!==r){var u=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(u),n=0,o=0,a=s,r=s}for(var l=0;a-(o+l)>15728640;)this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,15728640),l+=15728640;this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,r-l)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(sa),fa=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.InputLayout;for(var a=[],s=0;s<i.vertexBufferDescriptors.length;s++){var u=i.vertexBufferDescriptors[s];if(!Object(E.isNil)(u)){var l=u.byteStride,c=ra(u.frequency);a[s]={arrayStride:l,stepMode:c,attributes:[]}}}for(s=0;s<i.vertexAttributeDescriptors.length;s++){var f=i.vertexAttributeDescriptors[s],d=(u=He(a[f.bufferIndex]),{shaderLocation:f.location,format:ia(f.format),offset:f.bufferByteOffset});u.attributes.push(d)}return o.indexFormat=function(e){if(null!==e){if(e===Ie.U16_R)return"uint16";if(e===Ie.U32_R)return"uint32";throw new Error("whoops")}}(i.indexBufferFormat),o.buffers=a,o}return s(t,e),t}(sa),da=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;return o.type=ne.Program,o.vertexStage=null,o.fragmentStage=null,o.computeStage=null,o.descriptor=i,i.preprocessedVert&&(o.vertexStage=o.createShaderStage(i.preprocessedVert,"vertex")),i.preprocessedFrag&&(o.fragmentStage=o.createShaderStage(i.preprocessedFrag,"fragment")),i.preprocessedCompute&&(o.computeStage=o.createShaderStage(i.preprocessedCompute,"compute")),o}return s(t,e),t.prototype.createShaderStage=function(e,t){var n,r,i=e;if("compute"!==t)try{i=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),new Error("whoops")}var o=function(e){if(!i.includes(e))return"continue";i=(i=i.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(new RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),(function(t,n){return"vec4<f32>(textureSample(T_".concat(e).concat(n,"), 0.0, 0.0, 0.0);")}))};try{for(var a=h(["u_TextureFramebufferDepth"]),s=a.next();!s.done;s=a.next()){o(s.value)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return{module:this.device.device.createShaderModule({code:i}),entryPoint:"main"}},t}(sa),ha=function(){function e(){this.commandEncoder=null,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorResolveTo=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadValue:"load",depthStoreOp:"store",stencilLoadValue:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.setRenderPassDescriptor=function(e){this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var t=e.colorAttachment.length;this.gfxColorAttachment.length=t,this.gfxColorResolveTo.length=t;for(var n=0;n<e.colorAttachment.length;n++){var r=e.colorAttachment[n],i=e.colorResolveTo[n];if(null===r&&null!==i&&(r=i,i=null),this.gfxColorAttachment[n]=r,this.gfxColorResolveTo[n]=i,null===r){this.gpuColorAttachments.length=n,this.gfxColorAttachment.length=n,this.gfxColorResolveTo.length=n;break}void 0===this.gpuColorAttachments[n]&&(this.gpuColorAttachments[n]={}),(a=this.gpuColorAttachments[n]).view=r.gpuTextureView;var o=e.colorClearColor[n];"load"===o?a.loadOp="load":(a.loadOp="clear",a.clearValue=o),a.storeOp=e.colorStore[n]?"store":"discard",a.resolveTarget=void 0,null!==i&&(r.sampleCount>1?a.resolveTarget=i.gpuTextureView:a.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var a,s=e.depthStencilAttachment;(a=this.gpuDepthStencilAttachment).view=s.gpuTextureView,"load"===e.depthClearValue?a.depthLoadOp="load":(a.depthLoadOp="clear",a.depthClearValue=e.depthClearValue),"load"===e.stencilClearValue?a.stencilLoadOp="load":(a.stencilLoadOp="clear",a.stencilClearValue=e.stencilClearValue),a.depthStoreOp=e.depthStencilStore?"store":"discard",a.stencilStoreOp=e.depthStencilStore?"store":"discard",this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment,null!==this.gfxDepthStencilResolveTo&&(a.depthStoreOp="store",a.stencilStoreOp="store")}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0},e.prototype.beginRenderPass=function(e){Xe(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.setViewport=function(e,t,n,r){this.gpuRenderPassEncoder.setViewport(e,t,n,r,0,1)},e.prototype.setScissor=function(e,t,n,r){this.gpuRenderPassEncoder.setScissorRect(e,t,n,r)},e.prototype.setPipeline=function(e){var t=He(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},e.prototype.setInputState=function(e){if(null!==e){var t=e;if(null!==t.indexBuffer){var n=t.inputLayout,r=t.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Ko(r.buffer),He(n.indexFormat),r.byteOffset)}for(var i=0;i<t.vertexBuffers.length;i++){var o=t.vertexBuffers[i];Object(E.isNil)(o)||this.gpuRenderPassEncoder.setVertexBuffer(i,Ko(o.buffer),o.byteOffset)}}},e.prototype.setBindings=function(e,t,n){var r=t;this.gpuRenderPassEncoder.setBindGroup(e+0,r.gpuBindGroup[0],n.slice(0,r.bindingLayout.numUniformBuffers)),this.gpuRenderPassEncoder.setBindGroup(e+1,r.gpuBindGroup[1])},e.prototype.setStencilRef=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)},e.prototype.drawIndexed=function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)},e.prototype.drawIndexedInstanced=function(e,t,n){this.gpuRenderPassEncoder.drawIndexed(e,n,t,0,0)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(e){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.beginDebugGroup=function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.endDebugGroup=function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.finish=function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;e<this.gfxColorAttachment.length;e++){var t=this.gfxColorAttachment[e],n=this.gfxColorResolveTo[e];null!==t&&null!==n&&1===t.sampleCount&&this.copyAttachment(n,t)}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,this.gfxDepthStencilAttachment)),this.commandEncoder.finish()},e.prototype.copyAttachment=function(e,t){Xe(1===t.sampleCount);var n={texture:t.gpuTexture},r={texture:e.gpuTexture};Xe(t.width===e.width),Xe(t.height===e.height),Xe(!!(t.usage&Fo.COPY_SRC)),Xe(!!(e.usage&Fo.COPY_DST)),this.commandEncoder.copyTextureToTexture(n,r,[e.width,e.height,1])},e}(),_a=function(e){function t(t){var n,r,i=t.id,o=t.device,a=t.descriptor,s=this;(s=e.call(this,{id:i,device:o})||this).type=ne.Sampler;var u=a.minLOD,l=a.mipFilter===ce.NoMip?a.minLOD:a.maxLOD,c=null!==(n=a.maxAnisotropy)&&void 0!==n?n:1;return c>1&&Xe(a.minFilter===le.Bilinear&&a.magFilter===le.Bilinear&&a.mipFilter===ce.Linear),s.gpuSampler=s.device.device.createSampler({addressModeU:Vo(a.wrapS),addressModeV:Vo(a.wrapT),addressModeW:Vo(null!==(r=a.wrapQ)&&void 0!==r?r:a.wrapS),lodMinClamp:u,lodMaxClamp:l,minFilter:Xo(a.minFilter),magFilter:Xo(a.magFilter),mipmapFilter:Ho(a.mipFilter),maxAnisotropy:c}),s}return s(t,e),t}(sa),pa=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=t.skipCreate,a=e.call(this,{id:n,device:r})||this;return a.type=ne.Texture,a.device.createTextureShared({pixelFormat:i.pixelFormat,dimension:i.dimension,width:i.width,height:i.height,depthOrArrayLayers:i.depth,numLevels:i.numLevels,usage:i.usage,sampleCount:1},a,o),a}return s(t,e),t.prototype.setImageData=function(e,t){},t.prototype.destroy=function(){this.gpuTexture.destroy()},t}(sa),Ea=function(e){function t(t){var n=t.id,r=t.device,i=t.inputLayout,o=t.vertexBuffers,a=t.indexBuffer,s=e.call(this,{id:n,device:r})||this;return s.type=ne.InputState,s.inputLayout=i,s.vertexBuffers=o,s.indexBuffer=a,s}return s(t,e),t}(sa),va=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;return o.type=ne.RenderPipeline,o.isCreating=!1,o.isCreatingAsync=!1,o.gpuRenderPipeline=null,o.descriptor=i,o.device._createRenderPipeline(o,!1),o}return s(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(sa),Ra=function(e){function t(t){var n=t.id,r=t.device,i=e.call(this,{id:n,device:r})||this;return i.type=ne.Readback,i}return s(t,e),t.prototype.readTexture=function(e,t,n,r,i,o,a,s){void 0===a&&(a=0),void 0===s&&(s=0);var u=e,l=this.getBlockInformationFromFormat(u.format),c=Math.ceil(r/l.width)*l.length,f=256*Math.ceil(c/256),d=f*i,h=this.device.createBuffer({usage:de.STORAGE|de.MAP_READ|de.COPY_DST,hint:he.Static,viewOrSize:d}),_=this.device.device.createCommandEncoder();return _.copyTextureToBuffer({texture:u.gpuTexture,mipLevel:0,origin:{x:t,y:n,z:Math.max(0,0)}},{buffer:h.gpuBuffer,offset:0,bytesPerRow:f},{width:r,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([_.finish()]),this.readBuffer(h,d,o,a,s,u.pixelFormat)},t.prototype.readBuffer=function(e,t,n,r,i,o,a,s){var u=this;void 0===t&&(t=0),void 0===n&&(n=null),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=Ie.U8_RGB),void 0===a&&(a=!1),void 0===s&&(s=!1);var l=e,c=i||l.size,f=n||l.view,d=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||Ue(o),h=l;if(!(l.usage&de.MAP_READ&&l.usage&de.COPY_DST)){var _=this.device.device.createCommandEncoder();h=this.device.createBuffer({usage:de.STORAGE|de.MAP_READ|de.COPY_DST,hint:he.Static,viewOrSize:c}),_.copyBufferToBuffer(l.gpuBuffer,t,h.gpuBuffer,0,c),this.device.device.queue.submit([_.finish()])}return new Promise((function(e,n){h.gpuBuffer.mapAsync(Uo.READ,t,c).then((function(){var n=h.gpuBuffer.getMappedRange(t,c),r=f;if(a)r=null===r?aa(o,c,!0,n):aa(o,r.buffer,void 0,n);else if(null===r)switch(d){case 1:(r=new Uint8Array(c)).set(new Uint8Array(n));break;case 2:r=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,n);break;case 4:(r=new Float32Array(c/4)).set(new Float32Array(n))}else switch(d){case 1:(r=new Uint8Array(r.buffer)).set(new Uint8Array(n));break;case 2:r=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,n,f);break;case 4:var i=f&&f.constructor||Float32Array;(r=new i(r.buffer)).set(new i(n))}h.gpuBuffer.unmap(),e(r)}),(function(e){return n(e)}))}))},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,n){n||(n=new Float32Array(e));for(var r,i,o,a,s=new Uint16Array(t);e--;)n[e]=(r=s[e],i=void 0,o=void 0,a=void 0,i=(32768&r)>>15,a=1023&r,0===(o=(31744&r)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/Math.pow(2,10)):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/Math.pow(2,10)));return n},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":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":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 new Error("No fixed size for Stencil8 format!");case"depth16unorm":return{width:1,height:1,length:2};case"depth24plus":throw new Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw new Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float":case"depth24unorm-stencil8":return{width:1,height:1,length:4};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};default:return{width:1,height:1,length:4}}},t}(sa),ma=function(){function e(){this.commandEncoder=null,this.gpuComputePassEncoder=null}return e.prototype.dispatch=function(e,t,n){this.gpuComputePassEncoder.dispatch(e,t,n)},e.prototype.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},e.prototype.beginComputePass=function(e){Xe(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=He(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e,t){var n=t;this.gpuComputePassEncoder.setBindGroup(e,n.gpuBindGroup[0])},e.prototype.setComputePassDescriptor=function(e){this.descriptor=e},e}(),Ta=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.ComputePipeline,o.gpuComputePipeline=null,o.descriptor=i;var a=i.program.computeStage;if(null===a)return o;var s={compute:u({},a)};return o.gpuComputePipeline=o.device.device.createComputePipeline(s),void 0!==o.name&&(o.gpuComputePipeline.label=o.name),o}return s(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(sa),ya=function(e){function t(t){var n=t.id,r=t.device,i=t.descriptor,o=e.call(this,{id:n,device:r})||this;o.type=ne.QueryPool;var a=i.elemCount,s=i.type;return o.querySet=o.device.device.createQuerySet({type:zo(s),count:a}),o}return s(t,e),t.prototype.queryResultOcclusion=function(e){return!0},t}(sa),ga=function(){function e(e,t,n,r,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Fo.RENDER_ATTACHMENT|Fo.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new Gn(Ft,Fn),this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=ye.UpperLeft,this.clipSpaceNearZ=ge.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.adapter=e,this.device=t,this.canvas=n,this.canvasContext=r,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(Ee.n2D,Te.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(Ee.n2D,Te.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(Ee.n2DArray,Te.Float),this.fallbackTexture3D=this.createFallbackTexture(Ee.n3D,Te.Float),this.fallbackTextureCube=this.createFallbackTexture(Ee.Cube,Te.Float),this.fallbackSampler=this.createSampler({wrapS:ue.Clamp,wrapT:ue.Clamp,minFilter:le.Point,magFilter:le.Point,mipFilter:ce.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}return e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t,this.canvasContext.configure({device:this.device,format:"bgra8unorm",usage:this.swapChainTextureUsage,compositingAlphaMode:"premultiplied"}))},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),n=new pa({id:0,device:this,descriptor:{pixelFormat:Ie.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:Ee.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return n.depthOrArrayLayers=1,n.sampleCount=1,n.gpuTexture=e,n.gpuTextureView=t,n},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.present=function(){},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new ca({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new pa({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new _a({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new pa({id:this.getNextUniqueId(),device:this,descriptor:u(u({},e),{dimension:Ee.n2D,numLevels:1,depth:1,usage:ve.RenderTarget})});return t.depthOrArrayLayers=1,t.type=ne.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e,n=t.pixelFormat,r=t.width,i=t.height,o=t.depthOrArrayLayers,a=t.sampleCount,s=t.numLevels,u=t.gpuTexture,l=t.gpuTextureView,c=t.usage;Xe(!!(c&Fo.RENDER_ATTACHMENT));var f=new pa({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:n,width:r,height:i,depth:o,dimension:Ee.n2D,numLevels:s,usage:c},skipCreate:!0});return f.depthOrArrayLayers=o,f.sampleCount=a,f.gpuTexture=u,f.gpuTextureView=l,f},e.prototype.createProgram=function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)},e.prototype.createProgramSimple=function(e){return new da({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,n){var r={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.numLevels,o=Wo(e.pixelFormat),a=function(e){if(e===Ee.n2D)return"2d";if(e===Ee.Cube)return"3d";if(e===Ee.n2DArray)return"3d";if(e===Ee.n3D)return"3d";throw new Error("whoops")}(e.dimension),s=function(e){var t=0;return e&ve.Sampled&&(t|=Fo.TEXTURE_BINDING|Fo.COPY_DST),e&ve.RenderTarget&&(t|=Fo.RENDER_ATTACHMENT|Fo.TEXTURE_BINDING|Fo.COPY_SRC|Fo.COPY_DST),t}(e.usage);if(t.format=o,t.dimension=e.dimension,t.pixelFormat=e.pixelFormat,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.numLevels=i,t.usage=s,t.sampleCount=1,!n){var u=this.device.createTexture({size:r,mipLevelCount:i,format:o,dimension:a,usage:s}),l=u.createView();t.gpuTexture=u,t.gpuTextureView=l}},e.prototype.getFallbackTexture=function(e){var t=e.dimension,n=e.formatKind;if(t===Ee.n2D)return n===Te.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===Ee.n2DArray)return this.fallbackTexture2DArray;if(t===Ee.n3D)return this.fallbackTexture3D;if(t===Ee.Cube)return this.fallbackTextureCube;throw new Error("whoops")},e.prototype.createFallbackTexture=function(e,t){var n=e===Ee.Cube?6:1,r=t===Te.Float?Ie.U8_RGBA_NORM:Ie.D24;return this.createTexture({dimension:e,pixelFormat:r,usage:ve.Sampled,width:1,height:1,depth:n,numLevels:1})},e.prototype.createBindings=function(e){return new ua({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new fa({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputState=function(e,t,n){return new Ea({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:n})},e.prototype.createComputePipeline=function(e){return new Ta({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new va({id:this.getNextUniqueId(),device:this,descriptor:u({},e)})},e.prototype.createQueryPool=function(e,t){return new ya({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype._createBindGroupLayout=function(e){var t=this.bindGroupLayoutCache.get(e);return null===t&&(t=this._createBindGroupLayoutInternal(e),this.bindGroupLayoutCache.add(e,t)),t},e.prototype._createBindGroupLayoutInternal=function(e){var t,n=this,r=[[],[]];if(e.storageEntries)for(var i=0;i<e.storageEntries.length;i++)r[0].push({binding:r[0].length,visibility:GPUShaderStage.COMPUTE,buffer:{type:e.storageEntries[i].type}});for(i=0;i<e.numUniformBuffers;i++)r[0].push({binding:r[0].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}});for(i=0;i<e.numSamplers;i++){var o=void 0!==e.samplerEntries?e.samplerEntries[i]:Mt;r[1].push({binding:r[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:(t=o,{sampleType:jo(t.formatKind),viewDimension:Yo(t.dimension)})}),r[1].push({binding:r[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}})}return{gpuBindGroupLayout:r.map((function(e){return n.device.createBindGroupLayout({entries:e})}))}},e.prototype._createPipelineLayout=function(e){var t=this,n=e.flatMap((function(e){return t._createBindGroupLayout(e).gpuBindGroupLayout}));return this.device.createPipelineLayout({bindGroupLayouts:n})},e.prototype._createRenderPipeline=function(e,t){if(void 0===t&&(t=!1),!e.isCreating&&null===e.gpuRenderPipeline){var n=e.descriptor,r=n.program,i=r.vertexStage,o=r.fragmentStage;if(null!==i&&null!==o){var a,s,l=this._createPipelineLayout(n.bindingLayouts),c=(a=n.topology,s=n.megaStateDescriptor,{topology:qo(a),cullMode:Zo(s.cullMode),frontFace:Qo(s.frontFace)}),f=ta(n.colorAttachmentFormats,n.megaStateDescriptor),d=function(e,t){if(null!==e)return{format:Wo(e),depthWriteEnabled:t.depthWrite,depthCompare:na(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(n.depthStencilAttachmentFormat,n.megaStateDescriptor),h=void 0;null!==n.inputLayout&&(h=n.inputLayout.buffers);var _=n.sampleCount;e.isCreating=!0;var p={layout:l,vertex:u(u({},i),{buffers:h}),primitive:c,depthStencil:d,multisample:{count:_},fragment:u(u({},o),{targets:f})};e.gpuRenderPipeline=this.device.createRenderPipeline(p),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}},e.prototype.createReadback=function(){return new Ra({id:this.getNextUniqueId(),device:this})},e.prototype.destroyRenderTarget=function(e){e.gpuTexture.destroy()},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new ha),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},e.prototype.createComputePass=function(e){var t=this.computePassPool.pop();return void 0===t&&(t=new ma),t.commandEncoder=this.device.createCommandEncoder(),t.beginComputePass(e),t},e.prototype.submitPass=function(e){var t=this.device.queue,n=e,r=n.finish();t.submit([r]),n.commandEncoder=null,n instanceof ha?this.renderPassPool.push(n):this.computePassPool.push(n)},e.prototype.copySubTexture2D=function(e,t,n,r,i,o){var a=this.device.createCommandEncoder(),s=e,u=r,l={texture:u.gpuTexture,origin:[i,o,0]},c={texture:s.gpuTexture,origin:[t,n,0]};Xe(!!(u.usage&Fo.COPY_SRC)),Xe(!!(s.usage&Fo.COPY_DST)),a.copyTextureToTexture(l,c,[u.width,u.height,1]),this.device.queue.submit([a.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}},e.prototype.queryTextureFormatSupported=function(e,t,n){if(function(e){switch(be(e)){case Se.BC1:case Se.BC2:case Se.BC3:case Se.BC4_SNORM:case Se.BC4_UNORM:case Se.BC5_SNORM:case Se.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var r=oa(e);return t%r==0&&n%r==0&&this.featureTextureCompressionBC}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===ne.Buffer)(n=e).gpuBuffer.label=t;else if(e.type===ne.Texture){(n=e).gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===ne.RenderTarget){(n=e).gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===ne.Sampler){(n=e).gpuSampler.label=t}else if(e.type===ne.RenderPipeline){var n;null!==(n=e).gpuRenderPipeline&&(n.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pushDebugGroup=function(e){},e.prototype.popDebugGroup=function(){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){var t=e;this._createRenderPipeline(t,!1)},e}();let Aa,Sa=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Sa.decode();let Ca=null;function Oa(){return null!==Ca&&Ca.buffer===Aa.memory.buffer||(Ca=new Uint8Array(Aa.memory.buffer)),Ca}function Ia(e,t){return Sa.decode(Oa().subarray(e,e+t))}const Na=new Array(32).fill(void 0);Na.push(void 0,null,!0,!1);let Pa=Na.length;function Da(e){return Na[e]}function Ma(e){const t=Da(e);return function(e){e<36||(Na[e]=Pa,Pa=e)}(e),t}let xa=0,Ba=new TextEncoder("utf-8");const ba="function"==typeof Ba.encodeInto?function(e,t){return Ba.encodeInto(e,t)}:function(e,t){const n=Ba.encode(e);return t.set(n),{read:e.length,written:n.length}};function La(e,t,n){if(void 0===n){const n=Ba.encode(e),r=t(n.length);return Oa().subarray(r,r+n.length).set(n),xa=n.length,r}let r=e.length,i=t(r);const o=Oa();let a=0;for(;a<r;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==r){0!==a&&(e=e.slice(a)),i=n(i,r,r=a+3*e.length);const t=Oa().subarray(i+a,i+r);a+=ba(e,t).written}return xa=a,i}let Fa=null;function Ua(){return null!==Fa&&Fa.buffer===Aa.memory.buffer||(Fa=new Int32Array(Aa.memory.buffer)),Fa}function Ga(e,t,n){try{const l=Aa.__wbindgen_add_to_stack_pointer(-16);var r=La(e,Aa.__wbindgen_malloc,Aa.__wbindgen_realloc),i=xa,o=La(t,Aa.__wbindgen_malloc,Aa.__wbindgen_realloc),a=xa;Aa.glsl_compile(l,r,i,o,a,n);var s=Ua()[l/4+0],u=Ua()[l/4+1];return Ia(s,u)}finally{Aa.__wbindgen_add_to_stack_pointer(16),Aa.__wbindgen_free(s,u)}}var wa=async function e(t){const n={wbg:{}};n.wbg.__wbindgen_string_new=function(e,t){return function(e){Pa===Na.length&&Na.push(Na.length+1);const t=Pa;return Pa=Na[t],Na[t]=e,t}(Ia(e,t))},n.wbg.__wbindgen_object_drop_ref=function(e){Ma(e)},n.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(Da(e))},n.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(Da(e),Da(t))},n.wbg.__wbindgen_throw=function(e,t){throw new Error(Ia(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:r,module:i}=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 n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}{const n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}(await t,n);return Aa=r.exports,e.__wbindgen_wasm_module=i,Aa},ka=function(){function e(){}return e.prototype.createSwapChain=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,o;return d(this,(function(a){switch(a.label){case 0:if(void 0===navigator.gpu)return[2,null];t=null,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,navigator.gpu.requestAdapter()];case 2:return t=a.sent(),[3,4];case 3:return n=a.sent(),console.log(n),[3,4];case 4:return null===t?[2,null]:(r=["depth24unorm-stencil8","depth32float-stencil8","texture-compression-bc"].filter((function(e){return t.features.has(e)})),[4,t.requestDevice({requiredFeatures:r})]);case 5:if(null===(i=a.sent()))return[2,null];if(!(o=e.getContext("webgpu")))return[2,null];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,wa("/glsl_wgsl_compiler_bg.wasm")];case 7:return a.sent(),[3,9];case 8:return a.sent(),[3,9];case 9:return[2,new ga(t,i,e,o,Ga)]}}))}))},l([Object(v.inject)(ko),c("design:type",Object)],e.prototype,"pluginOptions",void 0),e=l([Object(v.singleton)({token:Ro})],e)}(),Wa=Object(v.Module)((function(e){e(ka)})),Va=function(){function e(e){void 0===e&&(e={}),this.options=e,this.name="webgpu-device"}return e.prototype.init=function(e){e.register(ko,{useValue:u({},this.options)}),e.load(Wa,!0)},e.prototype.destroy=function(e){e.remove(ko),e.unload(Wa)},e}(),Xa=function(){function e(){}var t;return t=e,e.prototype.apply=function(e){var n=this,r=function(e){var t=e.target;if(t.nodeName===E.Shape.HTML){var r=n.getOrCreateEl(t),i=t.ownerDocument.documentElement.attributes;Object.keys(i).forEach((function(e){r.style[e]=i[e]})),Object.keys(t.attributes).forEach((function(e){n.updateAttribute(e,t)}))}},i=function(e){var t=e.target;if(t.nodeName===E.Shape.HTML){var r=n.getId(t),i=n.contextService.getDomElement().parentNode;if(i){var o=i.querySelector("#"+r);o&&i.removeChild(o)}}},o=function(e){var t=e.target;if(t.nodeName===E.Shape.HTML){var r=e.attrName;n.updateAttribute(r,t)}};e.hooks.init.tapPromise(t.tag,(function(){return f(n,void 0,void 0,(function(){return d(this,(function(e){return this.renderingContext.root.addEventListener(E.ElementEvent.MOUNTED,r),this.renderingContext.root.addEventListener(E.ElementEvent.UNMOUNTED,i),this.renderingContext.root.addEventListener(E.ElementEvent.ATTR_MODIFIED,o),[2]}))}))})),e.hooks.destroy.tap(t.tag,(function(){n.renderingContext.root.removeEventListener(E.ElementEvent.MOUNTED,r),n.renderingContext.root.removeEventListener(E.ElementEvent.UNMOUNTED,i),n.renderingContext.root.removeEventListener(E.ElementEvent.ATTR_MODIFIED,o)}))},e.prototype.getId=function(e){return e.id||"g-html-"+e.entity},e.prototype.getOrCreateEl=function(e){var t=this.getId(e),n=this.contextService.getDomElement().parentNode;if(n){var r=n.querySelector("#"+t);if(!r){r=document.createElement("div"),e.parsedStyle.$el=r,r.id=t,e.name&&r.setAttribute("name",e.name),e.className&&r.setAttribute("className",e.className),n.appendChild(r),r.style.position="absolute",r.style.left="0",r.style.top="0",r.style["will-change"]="transform";var i=e.getWorldTransform();r.style.transform="matrix(".concat([i[0],i[1],i[4],i[5],i[12],i[13]].join(","),")")}return r}return null},e.prototype.updateAttribute=function(e,t){var n=this.getOrCreateEl(t);switch(e){case"innerHTML":var r=t.parsedStyle.innerHTML;Object(E.isString)(r)?n.innerHTML=r:(n.innerHTML="",n.appendChild(r));break;case"modelMatrix":case"transformOrigin":var i=t.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(i[0].value," ").concat(i[1].value);var o=t.getWorldTransform();n.style.transform="matrix(".concat([o[0],o[1],o[4],o[5],o[12],o[13]].join(","),")");break;case"width":var a=t.parsedStyle.width;n.style.width="".concat((null==a?void 0:a.value)||0,"px");break;case"height":var s=t.parsedStyle.height;n.style.height="".concat((null==s?void 0:s.value)||0,"px");break;case"zIndex":var u=t.parsedStyle.zIndex;n.style["z-index"]="".concat(u.value);break;case"visibility":var l=t.parsedStyle.visibility;n.style.visibility=l.value;break;case"pointerEvents":var c=t.parsedStyle.pointerEvents;n.style.pointerEvents=c.value;break;case"opacity":var f=t.parsedStyle.opacity;n.style.opacity="".concat(f.value);break;case"fill":var d=t.parsedStyle.fill,h="";if(d instanceof E.CSSRGB)h=d.toString();else if(d instanceof E.CSSGradientValue&&d.type===E.GradientPatternType.LinearGradient){var _=d.value.steps.map((function(e){return"".concat(e[1]," ").concat(100*Number(e[0]),"%")})).join(",");h="linear-gradient(to right, ".concat(_,");")}n.style.background=h;break;case"stroke":var p=t.parsedStyle.stroke;n.style["border-color"]=p.toString(),n.style["border-style"]="solid";break;case"lineWidth":var v=t.parsedStyle.lineWidth;n.style["border-width"]="".concat(v.value||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":var R=t.parsedStyle.filter;n.style.filter=R}},e.tag="HTMLRendering",l([Object(v.inject)(E.ContextService),c("design:type",Object)],e.prototype,"contextService",void 0),l([Object(v.inject)(E.RenderingContext),c("design:type",Object)],e.prototype,"renderingContext",void 0),e=t=l([Object(v.singleton)({contrib:E.RenderingPluginContribution})],e)}(),Ha=Object(v.Module)((function(e){e(Xa)})),ja=function(){function e(){this.name="html-renderer"}return e.prototype.init=function(e){e.load(Ha,!0)},e.prototype.destroy=function(e){e.unload(Ha)},e}(),Ya=function(){function e(){}return e.prototype.init=function(){var e=this.canvasConfig,t=e.container,n=e.canvas,r=e.devicePixelRatio;if(n)this.$canvas=n,t&&n.parentElement!==t&&t.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=Object(E.isString)(t)?document.getElementById(t):t,this.$container)){var i=document.createElement("canvas");this.$container.appendChild(i),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=i}var o=r||E.isBrowser&&window.devicePixelRatio||1;o=o>=1?Math.ceil(o):1,this.dpr=o},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.context},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,t){if(this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*t,Object(E.setDOMSize)(this.$canvas,e,t)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},l([Object(v.inject)(E.CanvasConfig),c("design:type",Object)],e.prototype,"canvasConfig",void 0),e=l([Object(v.singleton)({token:E.ContextService})],e)}(),Ka=Object(v.Module)((function(e){e(Ya)})),za=function(){function e(){this.name="webgpu-context-register"}return e.prototype.init=function(e){e.load(Ka,!0)},e.prototype.destroy=function(e){e.unload(Ka)},e}(),qa=function(e){function t(t){var n=e.call(this,t)||this;return n.registerPlugin(new za),n.registerPlugin(new Va),n.registerPlugin(new wo),n.registerPlugin(new y),n.registerPlugin(new ja),n}return s(t,e),t}(E.AbstractRenderer)}])}));