@antv/g-webgpu 1.1.3 → 1.1.6
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.
- package/dist/WebGLContextService.d.ts +2 -3
- package/dist/WebGLContextService.d.ts.map +1 -1
- package/dist/index.esm.js +193 -82
- package/dist/index.js +193 -82
- package/dist/index.umd.js +7646 -6520
- package/dist/index.umd.min.js +5 -5
- package/package.json +6 -6
package/dist/index.umd.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g"),require("mana-syringe")):"function"==typeof define&&define.amd?define(["exports","@antv/g","mana-syringe"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G,e.window.G.ManaSyringe)}(this,(function(e,t,r){"use strict";function n(e,t){
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g"),require("mana-syringe")):"function"==typeof define&&define.amd?define(["exports","@antv/g","mana-syringe"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G,e.window.G.ManaSyringe)}(this,(function(e,t,r){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function l(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 function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function c(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 r,n=s(e);if(t){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function f(e,t,r,n){var i,o=arguments.length,a=3>o?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(3>o?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3
|
-
a=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function d(){}function h(){}function p(){}var _={};u(_,i,(function(){return this}));var E=Object.getPrototypeOf,v=E&&E(E(C([])));v&&v!==t&&r.call(v,i)&&(_=v);var R=p.prototype=d.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){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 f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.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,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function C(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 n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,u(R,"constructor",p),u(p,"constructor",h),h.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(R),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(R),u(R,s,"Generator"),u(R,i,(function(){return this})),u(R,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,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(A),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):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),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function s(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){s(o,n,i,a,u,"next",e)}function u(e){s(o,n,i,a,u,"throw",e)}a(void 0)}))}}var l,c,f=/mobile|tablet|ip(ad|hone|od)|android/i,d=(l=function(){function e(){this.contextService=void 0,this.renderingContext=void 0}return e.prototype.apply=function(e){var t=this,r=this.renderingContext.root.ownerDocument.defaultView,n=r.supportTouchEvent&&f.test(navigator.userAgent),i=function(t){e.hooks.pointerMove.call(t)},o=function(t){e.hooks.pointerUp.call(t)},s=function(t){e.hooks.pointerDown.call(t)},l=function(t){e.hooks.pointerOver.call(t)},d=function(t){e.hooks.pointerOut.call(t)},h=function(t){e.hooks.pointerCancel.call(t)},p=function(t){e.hooks.pointerWheel.call(t)},_=function(e){globalThis.document.addEventListener("pointermove",i,!0),e.addEventListener("pointerdown",s,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",l,!0),globalThis.addEventListener("pointerup",o,!0)},E=function(e){e.addEventListener("touchstart",s,!0),e.addEventListener("touchend",o,!0),e.addEventListener("touchmove",i,!0),e.addEventListener("touchcancel",h,!0)},v=function(e){globalThis.document.addEventListener("mousemove",i,!0),e.addEventListener("mousedown",s,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",l,!0),globalThis.addEventListener("mouseup",o,!0)},R=function(e){e.removeEventListener("touchstart",s,!0),e.removeEventListener("touchend",o,!0),e.removeEventListener("touchmove",i,!0)},g=function(e){globalThis.document.removeEventListener("mousemove",i,!0),e.removeEventListener("mousedown",s,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",l,!0),globalThis.removeEventListener("mouseup",o,!0)};e.hooks.init.tapPromise(c.tag,u(a().mark((function e(){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=t.contextService.getDomElement(),r.supportPointerEvent&&_(i),n?E(i):r.supportTouchEvent?(E(i),r.supportPointerEvent||v(i)):r.supportPointerEvent||v(i),i.addEventListener("wheel",p,{passive:!0,capture:!0});case 4:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(c.tag,(function(){var e=t.contextService.getDomElement();r.supportPointerEvent&&function(e){globalThis.document.removeEventListener("pointermove",i,!0),e.removeEventListener("pointerdown",s,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",l,!0),globalThis.removeEventListener("pointerup",o,!0)}(e),n?R(e):r.supportTouchEvent?(R(e),r.supportPointerEvent||g(e)):r.supportPointerEvent||g(e),e.removeEventListener("wheel",p,!0)}))},e}(),l.tag="DOMInteraction",c=l);i([r.inject(t.ContextService),o("design:type",Object)],d.prototype,"contextService",void 0),i([r.inject(t.RenderingContext),o("design:type",Object)],d.prototype,"renderingContext",void 0),d=c=i([r.singleton({contrib:t.RenderingPluginContribution})],d);var h=r.Module((function(e){e(d)})),p=function(){function e(){this.name="dom-interaction"}var t=e.prototype;return t.init=function(e){e.load(h,!0)},t.destroy=function(e){e.unload(h)},e}(),_=Object.freeze({__proto__:null,Plugin:p});function E(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},r.exports),r.exports}E((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof E?t:E).prototype),o=new N(n||[]);return i._invoke=function(e,t,r){var n=f;return function(i,o){if(n===h)throw Error("Generator is already running");if(n===p){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=C(a,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var u=c(e,t,r);if("normal"===u.type){if(n=r.done?p:d,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f="suspendedStart",d="suspendedYield",h="executing",p="completed",_={};function E(){}function v(){}function R(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,T=m&&m(m(x([])));T&&T!==r&&n.call(T,o)&&(g=T);var y=R.prototype=E.prototype=Object.create(g);function A(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.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){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function C(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method))return _;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var i=c(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,_;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,_):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}function O(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 I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function x(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:t,done:!0}}return v.prototype=R,u(y,"constructor",R),u(R,"constructor",v),v.displayName=u(R,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,R):(e.__proto__=R,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},A(S.prototype),u(S.prototype,a,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new S(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},A(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=x,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},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 r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(this.prev>=a.tryLoc){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(a.catchLoc>this.prev)return i(a.catchLoc,!0);if(a.finallyLoc>this.prev)return i(a.finallyLoc)}else if(u){if(a.catchLoc>this.prev)return i(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(a.finallyLoc>this.prev)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){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,_):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),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:x(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),_}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));var v=E((function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),u=r?r+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 a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var 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,i),!0;case 5:return c.fn.call(c.context,t,n,i,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(l=1,u=Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var d,h=c.length;for(l=0;h>l;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,i);break;default:if(!u)for(d=1,u=Array(f-1);f>d;d++)u[d-1]=arguments[d];c[l].fn.apply(c[l].context,u)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var u=0,l=[],c=s.length;c>u;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[o]=1===l.length?l[0]:l:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s})),R=m,g=m;function m(e,t,r){r=r||2;var n,i,o,a,s,u,l,c=t&&t.length,f=c?t[0]*r:e.length,d=T(e,0,f,r,!0),h=[];if(!d||d.next===d.prev)return h;if(c&&(d=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=T(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(B(a));for(s.sort(N),i=0;s.length>i;i++)r=y(r=x(s[i],r),r.next);return r}(e,t,d,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var p=r;f>p;p+=r)n>(s=e[p])&&(n=s),i>(u=e[p+1])&&(i=u),s>o&&(o=s),u>a&&(a=u);l=0!==(l=Math.max(o-n,a-i))?1/l:0}return A(d,h,r,n,i,l),h}function T(e,t,r,n,i){var o,a;if(i===Y(e,t,r,n)>0)for(o=t;r>o;o+=n)a=V(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=V(o,e[o],e[o+1],a);return a&&b(a,a.next)&&(X(a),a=a.next),a}function y(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!b(n,n.next)&&0!==F(n.prev,n,n.next))n=n.next;else{if(X(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function A(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=D(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,u,l=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;l>t&&(s++,n=n.nextZ);t++);for(u=l;s>0||u>0&&n;)0===s||0!==u&&n&&r.z>n.z?(i=n,n=n.nextZ,u--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,l*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,l=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?C(e,n,i,o):S(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),X(e),e=u.next,l=u.next;else if((e=u)===l){a?1===a?A(e=O(y(e),t,r),t,r,n,i,o,2):2===a&&I(e,t,r,n,i,o):A(y(e),t,r,n,i,o,1);break}}}function S(e){var t=e.prev,r=e,n=e.next;if(F(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(M(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&F(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function C(e,t,r,n){var i=e.prev,o=e,a=e.next;if(F(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=D(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=D(s,u,t,r,n),f=e.prevZ,d=e.nextZ;f&&f.z>=l&&d&&c>=d.z;){if(f!==e.prev&&f!==e.next&&M(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&F(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==e.prev&&d!==e.next&&M(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&F(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=l;){if(f!==e.prev&&f!==e.next&&M(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&F(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&c>=d.z;){if(d!==e.prev&&d!==e.next&&M(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&F(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function O(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!b(i,o)&&U(i,n,n.next,o)&&k(i,o)&&k(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),X(n),X(n.next),n=e=o),n=n.next}while(n!==e);return y(n)}function I(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&L(a,s)){var u=W(a,s);return a=y(a,a.next),u=y(u,u.next),A(a,t,r,n,i,o),void A(u,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function N(e,t){return e.x-t.x}function x(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var u,l=r,c=r.x,f=r.y,d=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!M(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(u=Math.abs(o-n.y)/(i-n.x),k(n,e)&&(d>u||u===d&&(n.x>r.x||n.x===r.x&&P(r,n)))&&(r=n,d=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=W(r,e),i=y(r,r.next);return y(n,n.next),t===r?i:t}function P(e,t){return 0>F(e.prev,e,t.prev)&&0>F(t.next,e,e.next)}function D(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function B(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function M(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function L(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&U(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(k(e,t)&&k(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(F(e.prev,e,t.prev)||F(e,t.prev,t))||b(e,t)&&F(e.prev,e,e.next)>0&&F(t.prev,t,t.next)>0)}function F(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function b(e,t){return e.x===t.x&&e.y===t.y}function U(e,t,r,n){var i=G(F(e,t,r)),o=G(F(e,t,n)),a=G(F(r,n,e)),s=G(F(r,n,t));return i!==o&&a!==s||(!(0!==i||!w(e,r,t))||(!(0!==o||!w(e,n,t))||(!(0!==a||!w(r,e,n))||!(0!==s||!w(r,t,n)))))}function w(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function G(e){return e>0?1:0>e?-1:0}function k(e,t){return 0>F(e.prev,e,e.next)?F(e,t,e.next)>=0&&F(e,e.prev,t)>=0:0>F(e,t,e.prev)||0>F(e,e.next,t)}function W(e,t){var r=new H(e.i,e.x,e.y),n=new H(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function V(e,t,r,n){var i=new H(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function X(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 H(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Y(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}m.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(Y(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(Y(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var u=0;for(a=0;n.length>a;a+=3){var l=n[a]*r,c=n[a+1]*r,f=n[a+2]*r;u+=Math.abs((e[l]-e[f])*(e[c+1]-e[l+1])-(e[l]-e[c])*(e[f+1]-e[l+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},m.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r},R.default=g;const K=1e20;class j{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=n,this.radius=r;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:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(r),s=Math.min(this.size-this.buffer,Math.ceil(o-i)),u=Math.min(this.size-this.buffer,a+Math.ceil(n)),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:p,buffer:_,gridInner:E,gridOuter:v}=this;p.clearRect(_,_,s,u),p.fillText(e,_,_+a);const R=p.getImageData(_,_,s,u);v.fill(K,0,f),E.fill(0,0,f);for(let e=0;u>e;e++)for(let t=0;s>t;t++){const r=R.data[4*(e*s+t)+3]/255;if(0===r)continue;const n=(e+_)*l+t+_;if(1===r)v[n]=0,E[n]=K;else{const e=.5-r;v[n]=e>0?e*e:0,E[n]=0>e?e*e:0}}z(v,0,0,l,c,l,this.f,this.v,this.z),z(E,_,_,s,u,l,this.f,this.v,this.z);for(let e=0;f>e;e++){d[e]=Math.round(255-255*((Math.sqrt(v[e])-Math.sqrt(E[e]))/this.radius+this.cutoff))}return h}}function z(e,t,r,n,i,o,a,s,u){for(let l=t;t+n>l;l++)q(e,r*o+l,o,i,a,s,u);for(let l=r;r+i>l;l++)q(e,l*o+t,1,n,a,s,u)}function q(e,t,r,n,i,o,a){o[0]=0,a[0]=-K,a[1]=K,i[0]=e[t];for(let s=1,u=0,l=0;n>s;s++){i[s]=e[t+s*r];const n=s*s;do{const e=o[u];l=(i[s]-i[e]+n-e*e)/(s-e)/2}while(a[u]>=l&&--u>-1);u++,o[u]=s,a[u]=l,a[u+1]=K}for(let s=0,u=0;n>s;s++){for(;s>a[u+1];)u++;const n=o[u],l=s-n;e[t+s*r]=i[n]+l*l}}var Z=function(){this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]};Z.tag="c-renderable-3d";var Q,J,$,ee,te,re,ne,ie,oe,ae,se,ue,le,ce,fe,de,he,pe,_e,Ee,ve,Re,ge,me,Te,ye,Ae,Se=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}var t=e.prototype;return t.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},t.getById=function(e){return this.id2DisplayObjectMap[e]},t.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},t.decodePickingColor=function(e){return e[0]+256*e[1]+65536*e[2]-1},t.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}();function Ce(){
|
|
3
|
+
d=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new C(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return I()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function p(){}function _(){}var v={};u(v,o,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(O([])));y&&y!==t&&r.call(y,o)&&(v=y);var g=_.prototype=h.prototype=Object.create(v);function m(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){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 f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.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,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function A(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 S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return p.prototype=_,u(g,"constructor",_),u(_,"constructor",p),p.displayName=u(_,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,u(e,s,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(R.prototype),u(R.prototype,a,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),u(g,s,"Generator"),u(g,o,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,C.prototype={constructor:C,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(S),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):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),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:O(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function p(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function _(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){p(o,n,i,a,s,"next",e)}function s(e){p(o,n,i,a,s,"throw",e)}a(void 0)}))}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function y(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var g,m,R=(g=function(){function e(){v(this,e),this.contextService=void 0,this.renderingContext=void 0}return y(e,[{key:"apply",value:function(e){var t=this,r=this.renderingContext.root.ownerDocument.defaultView,n=function(t){e.hooks.pointerMove.call(t)},i=function(t){e.hooks.pointerUp.call(t)},o=function(t){e.hooks.pointerDown.call(t)},a=function(t){e.hooks.pointerOver.call(t)},s=function(t){e.hooks.pointerOut.call(t)},u=function(t){e.hooks.pointerCancel.call(t)},l=function(t){e.hooks.pointerWheel.call(t)},c=function(e){globalThis.document.addEventListener("pointermove",n,!0),e.addEventListener("pointerdown",o,!0),e.addEventListener("pointerleave",s,!0),e.addEventListener("pointerover",a,!0),globalThis.addEventListener("pointerup",i,!0)},f=function(e){e.addEventListener("touchstart",o,!0),e.addEventListener("touchend",i,!0),e.addEventListener("touchmove",n,!0),e.addEventListener("touchcancel",u,!0)},h=function(e){globalThis.document.addEventListener("mousemove",n,!0),e.addEventListener("mousedown",o,!0),e.addEventListener("mouseout",s,!0),e.addEventListener("mouseover",a,!0),globalThis.addEventListener("mouseup",i,!0)};e.hooks.init.tapPromise(m.tag,_(d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.contextService.getDomElement(),globalThis.navigator.msPointerEnabled?(n.style.msContentZooming="none",n.style.msTouchAction="none"):r.supportsPointerEvents&&(n.style.touchAction="none"),r.supportsPointerEvents?c(n):h(n),r.supportsTouchEvents&&f(n),n.addEventListener("wheel",l,{passive:!0,capture:!0});case 5:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(m.tag,(function(){var e=t.contextService.getDomElement();r.supportsPointerEvents?function(e){globalThis.document.removeEventListener("pointermove",n,!0),e.removeEventListener("pointerdown",o,!0),e.removeEventListener("pointerleave",s,!0),e.removeEventListener("pointerover",a,!0),globalThis.removeEventListener("pointerup",i,!0)}(e):function(e){globalThis.document.removeEventListener("mousemove",n,!0),e.removeEventListener("mousedown",o,!0),e.removeEventListener("mouseout",s,!0),e.removeEventListener("mouseover",a,!0),globalThis.removeEventListener("mouseup",i,!0)}(e),r.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",o,!0),e.removeEventListener("touchend",i,!0),e.removeEventListener("touchmove",n,!0)}(e),e.removeEventListener("wheel",l,!0)}))}}]),e}(),g.tag="DOMInteraction",m=g);f([r.inject(t.ContextService),h("design:type",Object)],R.prototype,"contextService",void 0),f([r.inject(t.RenderingContext),h("design:type",Object)],R.prototype,"renderingContext",void 0),R=m=f([r.singleton({contrib:t.RenderingPluginContribution})],R);var T=r.Module((function(e){e(R)})),A=function(){function e(){v(this,e),this.name="dom-interaction"}return y(e,[{key:"init",value:function(e){e.load(T,!0)}},{key:"destroy",value:function(e){e.unload(T)}}]),e}(),S=Object.freeze({__proto__:null,Plugin:A});function C(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},r.exports),r.exports}C((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof v?t:v).prototype),o=new N(n||[]);return i._invoke=function(e,t,r){var n=f;return function(i,o){if(n===d)throw Error("Generator is already running");if(n===p){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=C(a,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=c(e,t,r);if("normal"===u.type){if(n=r.done?p:h,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f="suspendedStart",h="suspendedYield",d="executing",p="completed",_={};function v(){}function E(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,R=m&&m(m(x([])));R&&R!==r&&n.call(R,o)&&(g=R);var T=y.prototype=v.prototype=Object.create(g);function A(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.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){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function C(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method))return _;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var i=c(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,_;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,_):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}function O(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 I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function x(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:t,done:!0}}return E.prototype=y,u(T,"constructor",y),u(y,"constructor",E),E.displayName=u(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,u(e,s,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},A(S.prototype),u(S.prototype,a,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new S(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},A(T),u(T,s,"Generator"),u(T,o,(function(){return this})),u(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=x,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},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 r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(this.prev>=a.tryLoc){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(a.catchLoc>this.prev)return i(a.catchLoc,!0);if(a.finallyLoc>this.prev)return i(a.finallyLoc)}else if(u){if(a.catchLoc>this.prev)return i(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(a.finallyLoc>this.prev)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){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,_):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),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:x(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),_}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));var O=C((function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),u=r?r+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 a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var 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,i),!0;case 5:return c.fn.call(c.context,t,n,i,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(l=1,u=Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h,d=c.length;for(l=0;d>l;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,i);break;default:if(!u)for(h=1,u=Array(f-1);f>h;h++)u[h-1]=arguments[h];c[l].fn.apply(c[l].context,u)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var u=0,l=[],c=s.length;c>u;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[o]=1===l.length?l[0]:l:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s})),I=x,N=x;function x(e,t,r){r=r||2;var n,i,o,a,s,u,l,c=t&&t.length,f=c?t[0]*r:e.length,h=P(e,0,f,r,!0),d=[];if(!h||h.next===h.prev)return d;if(c&&(h=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=P(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(W(a));for(s.sort(U),i=0;s.length>i;i++)r=D(r=w(s[i],r),r.next);return r}(e,t,h,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var p=r;f>p;p+=r)n>(s=e[p])&&(n=s),i>(u=e[p+1])&&(i=u),s>o&&(o=s),u>a&&(a=u);l=0!==(l=Math.max(o-n,a-i))?1/l:0}return B(h,d,r,n,i,l),d}function P(e,t,r,n,i){var o,a;if(i===ee(e,t,r,n)>0)for(o=t;r>o;o+=n)a=Q(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=Q(o,e[o],e[o+1],a);return a&&j(a,a.next)&&(J(a),a=a.next),a}function D(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!j(n,n.next)&&0!==H(n.prev,n,n.next))n=n.next;else{if(J(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function B(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=G(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,u,l=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;l>t&&(s++,n=n.nextZ);t++);for(u=l;s>0||u>0&&n;)0===s||0!==u&&n&&r.z>n.z?(i=n,n=n.nextZ,u--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,l*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,l=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?b(e,n,i,o):M(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),J(e),e=u.next,l=u.next;else if((e=u)===l){a?1===a?B(e=L(D(e),t,r),t,r,n,i,o,2):2===a&&F(e,t,r,n,i,o):B(D(e),t,r,n,i,o,1);break}}}function M(e){var t=e.prev,r=e,n=e.next;if(H(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(V(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&H(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function b(e,t,r,n){var i=e.prev,o=e,a=e.next;if(H(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=G(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=G(s,u,t,r,n),f=e.prevZ,h=e.nextZ;f&&f.z>=l&&h&&c>=h.z;){if(f!==e.prev&&f!==e.next&&V(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&H(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,h!==e.prev&&h!==e.next&&V(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&H(h.prev,h,h.next)>=0)return!1;h=h.nextZ}for(;f&&f.z>=l;){if(f!==e.prev&&f!==e.next&&V(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&H(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;h&&c>=h.z;){if(h!==e.prev&&h!==e.next&&V(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&H(h.prev,h,h.next)>=0)return!1;h=h.nextZ}return!0}function L(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!j(i,o)&&Y(i,n,n.next,o)&&q(i,o)&&q(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),J(n),J(n.next),n=e=o),n=n.next}while(n!==e);return D(n)}function F(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&X(a,s)){var u=Z(a,s);return a=D(a,a.next),u=D(u,u.next),B(a,t,r,n,i,o),void B(u,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function U(e,t){return e.x-t.x}function w(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var u,l=r,c=r.x,f=r.y,h=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!V(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(u=Math.abs(o-n.y)/(i-n.x),q(n,e)&&(h>u||u===h&&(n.x>r.x||n.x===r.x&&k(r,n)))&&(r=n,h=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=Z(r,e),i=D(r,r.next);return D(n,n.next),t===r?i:t}function k(e,t){return 0>H(e.prev,e,t.prev)&&0>H(t.next,e,e.next)}function G(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function W(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function V(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function X(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Y(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(q(e,t)&&q(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(H(e.prev,e,t.prev)||H(e,t.prev,t))||j(e,t)&&H(e.prev,e,e.next)>0&&H(t.prev,t,t.next)>0)}function H(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function j(e,t){return e.x===t.x&&e.y===t.y}function Y(e,t,r,n){var i=z(H(e,t,r)),o=z(H(e,t,n)),a=z(H(r,n,e)),s=z(H(r,n,t));return i!==o&&a!==s||(!(0!==i||!K(e,r,t))||(!(0!==o||!K(e,n,t))||(!(0!==a||!K(r,e,n))||!(0!==s||!K(r,t,n)))))}function K(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function z(e){return e>0?1:0>e?-1:0}function q(e,t){return 0>H(e.prev,e,e.next)?H(e,t,e.next)>=0&&H(e,e.prev,t)>=0:0>H(e,t,e.prev)||0>H(e,e.next,t)}function Z(e,t){var r=new $(e.i,e.x,e.y),n=new $(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function Q(e,t,r,n){var i=new $(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function J(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 $(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ee(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}x.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(ee(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(ee(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var u=0;for(a=0;n.length>a;a+=3){var l=n[a]*r,c=n[a+1]*r,f=n[a+2]*r;u+=Math.abs((e[l]-e[f])*(e[c+1]-e[l+1])-(e[l]-e[c])*(e[f+1]-e[l+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},x.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r},I.default=N;const te=1e20;class re{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=n,this.radius=r;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:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(r),s=Math.min(this.size-this.buffer,Math.ceil(o-i)),u=Math.min(this.size-this.buffer,a+Math.ceil(n)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),h=new Uint8ClampedArray(f),d={data:h,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===u)return d;const{ctx:p,buffer:_,gridInner:v,gridOuter:E}=this;p.clearRect(_,_,s,u),p.fillText(e,_,_+a);const y=p.getImageData(_,_,s,u);E.fill(te,0,f),v.fill(0,0,f);for(let e=0;u>e;e++)for(let t=0;s>t;t++){const r=y.data[4*(e*s+t)+3]/255;if(0===r)continue;const n=(e+_)*l+t+_;if(1===r)E[n]=0,v[n]=te;else{const e=.5-r;E[n]=e>0?e*e:0,v[n]=0>e?e*e:0}}ne(E,0,0,l,c,l,this.f,this.v,this.z),ne(v,_,_,s,u,l,this.f,this.v,this.z);for(let e=0;f>e;e++){h[e]=Math.round(255-255*((Math.sqrt(E[e])-Math.sqrt(v[e]))/this.radius+this.cutoff))}return d}}function ne(e,t,r,n,i,o,a,s,u){for(let l=t;t+n>l;l++)ie(e,r*o+l,o,i,a,s,u);for(let l=r;r+i>l;l++)ie(e,l*o+t,1,n,a,s,u)}function ie(e,t,r,n,i,o,a){o[0]=0,a[0]=-te,a[1]=te,i[0]=e[t];for(let s=1,u=0,l=0;n>s;s++){i[s]=e[t+s*r];const n=s*s;do{const e=o[u];l=(i[s]-i[e]+n-e*e)/(s-e)/2}while(a[u]>=l&&--u>-1);u++,o[u]=s,a[u]=l,a[u+1]=te}for(let s=0,u=0;n>s;s++){for(;s>a[u+1];)u++;const n=o[u],l=s-n;e[t+s*r]=i[n]+l*l}}function oe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ae(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?oe(Object(r),!0).forEach((function(t){de(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function se(){
|
|
4
4
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
5
|
-
Ce=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=m(a,r);if(s){if(s===c)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function f(){}function d(){}function h(){}var p={};s(p,i,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(S([])));E&&E!==t&&r.call(E,i)&&(p=E);var v=h.prototype=f.prototype=Object.create(p);function R(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function n(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&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function m(e,t){var r=e.iterator[t.method];if(void 0===r){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 n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var i=n.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 T(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 y(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,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 n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],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(g.prototype),s(g.prototype,o,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?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 r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},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(y),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(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 r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),y(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;y(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}function Oe(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Ie(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Oe(o,n,i,a,s,"next",e)}function s(e){Oe(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Ne(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function xe(e,t,r){return t&&Ne(e.prototype,t),r&&Ne(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(){return Pe=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Pe.apply(this,arguments)}function De(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Be(e,t)}function Be(e,t){return Be=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Be(e,t)}function Me(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;o.length>n;n++)0>t.indexOf(r=o[n])&&(i[r]=e[r]);return i}function Le(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function be(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Fe(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fe(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ue(e,t,r,n){return{dimension:fe.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:de.Sampled}}function we(e){return e}function Ge(e,t,r){return e<<16|t<<8|r}function ke(e){return e>>>8&255}function We(e){return e>>>16&255}function Ve(e){return 255&e}function Xe(e){switch(e){case ge.F32:case ge.U32:case ge.S32:return 4;case ge.U16:case ge.S16:case ge.F16:return 2;case ge.U8:case ge.S8:return 1;default:throw Error("whoops")}}function He(e){return Xe(We(e))}function Ye(e){var t=Ve(e);if(t&Te.Depth)return _e.Depth;if(t&Te.Normalized)return _e.Float;var r=We(e);if(r===ge.F16||r===ge.F32)return _e.Float;if(r===ge.U8||r===ge.U16||r===ge.U32)return _e.Uint;if(r===ge.S8||r===ge.S16||r===ge.S32)return _e.Sint;throw Error("whoops")}function Ke(e,t){if(void 0===t&&(t=""),!e)throw console.error(Error().stack),Error("Assert fail: "+t)}function je(e){if(null!=e)return e;throw Error("Missing object")}function ze(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function qe(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function Ze(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function Qe(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}Se=i([r.singleton()],Se),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"}(Q||(Q={})),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"}(J||(J={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}($||($={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(ee||(ee={})),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"}(te||(te={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(re||(re={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(ne||(ne={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(ie||(ie={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(oe||(oe={})),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"}(ae||(ae={})),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"}(se||(se={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(ue||(ue={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(le||(le={})),function(e){e.LOADED="loaded"}(ce||(ce={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(fe||(fe={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(de||(de={})),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"}(he||(he={})),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"}(pe||(pe={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(_e||(_e={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(Ee||(Ee={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(ve||(ve={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(Re||(Re={})),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"}(ge||(ge={})),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"}(me||(me={})),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"}(Te||(Te={})),function(e){e[e.ALPHA=Ge(ge.U8,me.A,Te.None)]="ALPHA",e[e.F16_R=Ge(ge.F16,me.R,Te.None)]="F16_R",e[e.F16_RG=Ge(ge.F16,me.RG,Te.None)]="F16_RG",e[e.F16_RGB=Ge(ge.F16,me.RGB,Te.None)]="F16_RGB",e[e.F16_RGBA=Ge(ge.F16,me.RGBA,Te.None)]="F16_RGBA",e[e.F32_R=Ge(ge.F32,me.R,Te.None)]="F32_R",e[e.F32_RG=Ge(ge.F32,me.RG,Te.None)]="F32_RG",e[e.F32_RGB=Ge(ge.F32,me.RGB,Te.None)]="F32_RGB",e[e.F32_RGBA=Ge(ge.F32,me.RGBA,Te.None)]="F32_RGBA",e[e.U8_R=Ge(ge.U8,me.R,Te.None)]="U8_R",e[e.U8_R_NORM=Ge(ge.U8,me.R,Te.Normalized)]="U8_R_NORM",e[e.U8_RG=Ge(ge.U8,me.RG,Te.None)]="U8_RG",e[e.U8_RG_NORM=Ge(ge.U8,me.RG,Te.Normalized)]="U8_RG_NORM",e[e.U8_RGB=Ge(ge.U8,me.RGB,Te.None)]="U8_RGB",e[e.U8_RGB_NORM=Ge(ge.U8,me.RGB,Te.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=Ge(ge.U8,me.RGB,Te.sRGB|Te.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=Ge(ge.U8,me.RGBA,Te.None)]="U8_RGBA",e[e.U8_RGBA_NORM=Ge(ge.U8,me.RGBA,Te.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=Ge(ge.U8,me.RGBA,Te.sRGB|Te.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=Ge(ge.U16,me.R,Te.None)]="U16_R",e[e.U16_R_NORM=Ge(ge.U16,me.R,Te.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=Ge(ge.U16,me.RG,Te.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=Ge(ge.U16,me.RGBA,Te.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=Ge(ge.U16,me.RGB,Te.None)]="U16_RGB",e[e.U32_R=Ge(ge.U32,me.R,Te.None)]="U32_R",e[e.U32_RG=Ge(ge.U32,me.RG,Te.None)]="U32_RG",e[e.S8_R=Ge(ge.S8,me.R,Te.None)]="S8_R",e[e.S8_R_NORM=Ge(ge.S8,me.R,Te.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=Ge(ge.S8,me.RG,Te.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=Ge(ge.S8,me.RGB,Te.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=Ge(ge.S8,me.RGBA,Te.Normalized)]="S8_RGBA_NORM",e[e.S16_R=Ge(ge.S16,me.R,Te.None)]="S16_R",e[e.S16_RG=Ge(ge.S16,me.RG,Te.None)]="S16_RG",e[e.S16_RG_NORM=Ge(ge.S16,me.RG,Te.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=Ge(ge.S16,me.RGB,Te.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=Ge(ge.S16,me.RGBA,Te.None)]="S16_RGBA",e[e.S16_RGBA_NORM=Ge(ge.S16,me.RGBA,Te.Normalized)]="S16_RGBA_NORM",e[e.S32_R=Ge(ge.S32,me.R,Te.None)]="S32_R",e[e.U16_RGBA_5551=Ge(ge.U16_PACKED_5551,me.RGBA,Te.Normalized)]="U16_RGBA_5551",e[e.BC1=Ge(ge.BC1,me.RGBA,Te.Normalized)]="BC1",e[e.BC1_SRGB=Ge(ge.BC1,me.RGBA,Te.Normalized|Te.sRGB)]="BC1_SRGB",e[e.BC2=Ge(ge.BC2,me.RGBA,Te.Normalized)]="BC2",e[e.BC2_SRGB=Ge(ge.BC2,me.RGBA,Te.Normalized|Te.sRGB)]="BC2_SRGB",e[e.BC3=Ge(ge.BC3,me.RGBA,Te.Normalized)]="BC3",e[e.BC3_SRGB=Ge(ge.BC3,me.RGBA,Te.Normalized|Te.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=Ge(ge.BC4_UNORM,me.R,Te.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=Ge(ge.BC4_SNORM,me.R,Te.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=Ge(ge.BC5_UNORM,me.RG,Te.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=Ge(ge.BC5_SNORM,me.RG,Te.Normalized)]="BC5_SNORM",e[e.D24=Ge(ge.D24,me.R,Te.Depth)]="D24",e[e.D24_S8=Ge(ge.D24S8,me.RG,Te.Depth|Te.Stencil)]="D24_S8",e[e.D32F=Ge(ge.D32F,me.R,Te.Depth)]="D32F",e[e.D32F_S8=Ge(ge.D32FS8,me.RG,Te.Depth|Te.Stencil)]="D32F_S8",e[e.U8_RGB_RT=Ge(ge.U8,me.RGB,Te.RenderTarget|Te.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=Ge(ge.U8,me.RGBA,Te.RenderTarget|Te.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=Ge(ge.U8,me.RGBA,Te.RenderTarget|Te.Normalized|Te.sRGB)]="U8_RGBA_RT_SRGB"}(ye||(ye={})),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"}(Ae||(Ae={}));var Je=Qe(0,0,0,0),$e=Qe(0,0,0,1),et=Qe(1,1,1,0),tt=Qe(1,1,1,1),rt=!0;function nt(e,t){if(void 0===t&&(t=rt),!t)return e;switch(e){case J.Less:return J.Greater;case J.LessEqual:return J.GreaterEqual;case J.GreaterEqual:return J.LessEqual;case J.Greater:return J.Less;default:return e}}function it(e,t){return null!=e?e:t}function ot(e){return void 0===e?null:e}function at(e,t,r){e.length=t,e.fill(r)}function st(e,t){var r=t-1;return e+r&~r}function ut(e,t){return((e+t-1)/t|0)*t}function lt(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}function ct(e,t,r){var n=lt(e,t,r);e.splice(n,0,t)}function ft(e,t,r){return r?e|=t:e&=~t,e}function dt(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function ht(e,t,r){for(void 0===r&&(r="0");t>e.length;)e=""+r+e;return e}function pt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function _t(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),pt(e.rgbBlendState,t.rgbBlendState),pt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Et(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=_t(e[r],t[r])}function vt(e,t){void 0!==t.attachmentsState&&Et(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&qe(e.blendConstant,t.blendConstant),e.depthCompare=it(t.depthCompare,e.depthCompare),e.depthWrite=it(t.depthWrite,e.depthWrite),e.stencilCompare=it(t.stencilCompare,e.stencilCompare),e.stencilWrite=it(t.stencilWrite,e.stencilWrite),e.stencilPassOp=it(t.stencilPassOp,e.stencilPassOp),e.stencilRef=it(t.stencilRef,e.stencilRef),e.cullMode=it(t.cullMode,e.cullMode),e.frontFace=it(t.frontFace,e.frontFace),e.polygonOffset=it(t.polygonOffset,e.polygonOffset)}function Rt(e){var t=Object.assign({},e);return t.attachmentsState=[],Et(t.attachmentsState,e.attachmentsState),t.blendConstant=Ze(t.blendConstant),t}function gt(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 mt={blendMode:re.Add,blendSrcFactor:te.One,blendDstFactor:te.Zero},Tt={attachmentsState:[{channelWriteMask:he.RGB,rgbBlendState:mt,alphaBlendState:mt}],blendConstant:Ze(Je),depthWrite:!0,depthCompare:J.LessEqual,stencilCompare:J.Always,stencilWrite:!1,stencilPassOp:pe.Keep,stencilRef:0,cullMode:ee.None,frontFace:$.CCW,polygonOffset:!1};function yt(e,t){void 0===e&&(e=null),void 0===t&&(t=Tt);var r=Rt(t);return null!==e&&vt(r,e),r}var At=yt({depthCompare:J.Always,depthWrite:!1},Tt);function St(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Et(e.attachmentsState,Tt.attachmentsState)),gt(e.attachmentsState[0],t),e}var Ct,Ot={formatKind:_e.Float,dimension:fe.n2D};function It(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function Nt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function xt(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function Pt(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function Dt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Bt(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!It(e.samplerBindings,t.samplerBindings,Pt)&&(!!It(e.uniformBufferBindings,t.uniformBufferBindings,xt)&&!!Ft(e.bindingLayout,t.bindingLayout)))}function Mt(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function Lt(e,t){return!!Mt(e.rgbBlendState,t.rgbBlendState)&&(!!Mt(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Ft(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function bt(e,t){return e===t}function Ut(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!It(e.attachmentsState,t.attachmentsState,Lt)&&!!ze(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)&&(!!It(e.bindingLayouts,t.bindingLayouts,Ft)&&(!!It(e.colorAttachmentFormats,t.colorAttachmentFormats,bt)&&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 Gt(e,r){return t.isNil(e)?t.isNil(r):!t.isNil(r)&&(e.byteStride===r.byteStride&&e.frequency===r.frequency)}function kt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!It(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Gt)&&!!It(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,wt))}function Wt(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 Vt(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function Xt(e){return{buffer:e.buffer,wordCount:e.wordCount}}function Ht(e){return{bindingLayout:e.bindingLayout,samplerBindings:Nt(e.samplerBindings,Vt),uniformBufferBindings:Nt(e.uniformBufferBindings,Xt),pipeline:e.pipeline}}function Yt(e){return{dimension:e.dimension,formatKind:e.formatKind}}function Kt(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?Nt(e.samplerEntries,Yt):void 0}}function jt(e){var t=Nt(e.bindingLayouts,Kt),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:Rt(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function zt(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function qt(e){return t.isNil(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function Zt(e){return{vertexAttributeDescriptors:Nt(e.vertexAttributeDescriptors,zt),vertexBufferDescriptors:Nt(e.vertexBufferDescriptors,qt),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(Ct||(Ct={}));var Qt,Jt=new Uint16Array([65279]),$t=255==new DataView(Jt.buffer).getUint8(0)?Ct.LITTLE_ENDIAN:Ct.BIG_ENDIAN;var er=/([^[]*)(\[[0-9]+\])?/;function tr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function rr(e,t,r,n){var i=null,o=null;return function(a,s,u){var l=t(u,r),c=l.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{Ke(o===c,"Uniform length cannot change.");for(var d=0;c>d;++d)if(l[d]!==i[d]){f=!0;break}}return f&&(n(a,e,s,l),i.set(l)),f}}function nr(e,t,r,n){e[t](r,n)}function ir(e,t,r,n){e[t](r,!1,n)}var or={},ar={},sr={},ur=[0];function lr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(ur[0]=e,e=ur);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function cr(e,t){return lr(e,t,Float32Array,or)}function fr(e,t){return lr(e,t,Int32Array,ar)}function dr(e,t){return lr(e,t,Uint32Array,sr)}var hr=((Qt={})[Ae.FLOAT]=rr.bind(null,"uniform1fv",cr,1,nr),Qt[Ae.FLOAT_VEC2]=rr.bind(null,"uniform2fv",cr,2,nr),Qt[Ae.FLOAT_VEC3]=rr.bind(null,"uniform3fv",cr,3,nr),Qt[Ae.FLOAT_VEC4]=rr.bind(null,"uniform4fv",cr,4,nr),Qt[Ae.INT]=rr.bind(null,"uniform1iv",fr,1,nr),Qt[Ae.INT_VEC2]=rr.bind(null,"uniform2iv",fr,2,nr),Qt[Ae.INT_VEC3]=rr.bind(null,"uniform3iv",fr,3,nr),Qt[Ae.INT_VEC4]=rr.bind(null,"uniform4iv",fr,4,nr),Qt[Ae.BOOL]=rr.bind(null,"uniform1iv",fr,1,nr),Qt[Ae.BOOL_VEC2]=rr.bind(null,"uniform2iv",fr,2,nr),Qt[Ae.BOOL_VEC3]=rr.bind(null,"uniform3iv",fr,3,nr),Qt[Ae.BOOL_VEC4]=rr.bind(null,"uniform4iv",fr,4,nr),Qt[Ae.FLOAT_MAT2]=rr.bind(null,"uniformMatrix2fv",cr,4,ir),Qt[Ae.FLOAT_MAT3]=rr.bind(null,"uniformMatrix3fv",cr,9,ir),Qt[Ae.FLOAT_MAT4]=rr.bind(null,"uniformMatrix4fv",cr,16,ir),Qt[Ae.SAMPLER_2D]=tr,Qt[Ae.SAMPLER_CUBE]=tr,Qt[Ae.UNSIGNED_INT]=rr.bind(null,"uniform1uiv",dr,1,nr),Qt[Ae.UNSIGNED_INT_VEC2]=rr.bind(null,"uniform2uiv",dr,2,nr),Qt[Ae.UNSIGNED_INT_VEC3]=rr.bind(null,"uniform3uiv",dr,3,nr),Qt[Ae.UNSIGNED_INT_VEC4]=rr.bind(null,"uniform4uiv",dr,4,nr),Qt[Ae.FLOAT_MAT2x3]=rr.bind(null,"uniformMatrix2x3fv",cr,6,ir),Qt[Ae.FLOAT_MAT2x4]=rr.bind(null,"uniformMatrix2x4fv",cr,8,ir),Qt[Ae.FLOAT_MAT3x2]=rr.bind(null,"uniformMatrix3x2fv",cr,6,ir),Qt[Ae.FLOAT_MAT3x4]=rr.bind(null,"uniformMatrix3x4fv",cr,12,ir),Qt[Ae.FLOAT_MAT4x2]=rr.bind(null,"uniformMatrix4x2fv",cr,8,ir),Qt[Ae.FLOAT_MAT4x3]=rr.bind(null,"uniformMatrix4x3fv",cr,12,ir),Qt[Ae.SAMPLER_2D]=tr,Qt[Ae.SAMPLER_CUBE]=tr,Qt[Ae.SAMPLER_3D]=tr,Qt[Ae.SAMPLER_2D_SHADOW]=tr,Qt[Ae.SAMPLER_2D_ARRAY]=tr,Qt[Ae.SAMPLER_2D_ARRAY_SHADOW]=tr,Qt[Ae.SAMPLER_CUBE_SHADOW]=tr,Qt[Ae.INT_SAMPLER_2D]=tr,Qt[Ae.INT_SAMPLER_3D]=tr,Qt[Ae.INT_SAMPLER_CUBE]=tr,Qt[Ae.INT_SAMPLER_2D_ARRAY]=tr,Qt[Ae.UNSIGNED_INT_SAMPLER_2D]=tr,Qt[Ae.UNSIGNED_INT_SAMPLER_3D]=tr,Qt[Ae.UNSIGNED_INT_SAMPLER_CUBE]=tr,Qt[Ae.UNSIGNED_INT_SAMPLER_2D_ARRAY]=tr,Qt);var pr=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function _r(e,t){return"#define "+e+" "+t}function Er(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().split("\n").forEach((function(e){var t=e.trim().split(/\s+/),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,n){return n.trim().split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var u=function(e){s.uniforms.forEach((function(r){t.push(o+"["+e+"]."+r.name)}))},l=0;5>l;l++)u(l);else s.uniforms.forEach((function(e){t.push(o+"."+e.name)}))}o&&t.push(o)}})),""})),t}function vr(e,t,r,n,i){void 0===n&&(n=null);var o="#version 100"===e.glslVersion,a=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),s="";null!==n&&(s=Object.keys(n).map((function(e){return _r(e,n[e])})).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===Ee.UpperLeft&&(c+=_r("VIEWPORT_ORIGIN_TL","1")+"\n"),e.clipSpaceNearZ===ve.Zero&&(c+=_r("CLIPSPACE_NEAR_ZERO","1")+"\n"),e.explicitBindingLocations){var f=0,d=0,h=0;l=l.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout("+(r?r+", ":"")+"set = "+f+", binding = "+d+++") uniform "+n})),f++,d=0,Ke(e.separateSamplerTextures),l=(l=l.replace(/uniform sampler2D (.*);/g,(function(e,r){return"frag"===t?"\nlayout(set = "+f+", binding = "+d+++") uniform texture2D T_"+r+";\nlayout(set = "+f+", binding = "+d+++") uniform sampler S_"+r+";\n":""}))).replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = "+h+++") "+t})),c+=_r("gl_VertexID","gl_VertexIndex")+"\n"}l=e.separateSamplerTextures?(l=(l=(l=l.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"texture2D T_P_"+t+", sampler S_P_"+t}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_"+t+")"}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"T_"+t+", S_"+t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D(T_"+t+", S_"+t+")"})):(l=(l=(l=l.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D P_"+t}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_"+t+")"}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return t}));var p=((o?"":e.glslVersion)+"\n\n"+(o&&"frag"===t?"#extension GL_OES_standard_derivatives : enable":"")+"\n"+u+"\n"+c+"\n"+s+"\n"+l+"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(p=p.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) "+t}))),o){if("frag"===t&&(p=p.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying "+t+" "+r+";\n"}))),"vert"===t&&(p=(p=p.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying "+t+" "+r+";\n"}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"attribute "+t+" "+r+";\n"}))),p=p.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 "+t:""}))})),"frag"===t){var _,E=(p=p.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return _=r,t+" "+r+";\n"}))).lastIndexOf("}");p=p.substring(0,E)+"\n gl_FragColor = vec4("+_+");\n"+p.substring(E)}p=p.replace(/^\s*layout\((.*)\)/gm,"");for(var v,R=be(pr);!(v=R()).done;){var g=v.value;p=p.replace(g[0],g[1])}}return p}function Rr(e,t,r,n,i){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:vr(e,"vert",t,n),preprocessedFrag:vr(e,"frag",r,n)}}function gr(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return Rr(e.queryVendorInfo(),n,i,r)}var mr=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}var r=e.prototype;return r.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},r.setDefineString=function(e,r){if(null!==r){if(this.defines[e]===r)return!1;this.defines[e]=r}else{if(t.isNil(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},r.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},r.getDefineString=function(e){return ot(this.defines[e])},r.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&Ke("1"===t),null!==t},r.ensurePreprocessed=function(e){""===this.preprocessedVert&&(this.preprocessedVert=vr(e,"vert",this.both+this.vert,this.defines),this.preprocessedFrag=vr(e,"frag",this.both+this.frag,this.defines))},e}(),Tr=function(){function e(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=e;var t=e.queryLimits();this.uniformBufferWordAlignment=t.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=t.uniformBufferMaxPageWordSize}var t=e.prototype;return t.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},t.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},t.allocateChunk=function(e){e=ut(e,this.uniformBufferWordAlignment),Ke(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=ut(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},t.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=ut(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Ke(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=ut(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset ["+this.currentWordOffset+"] <= newWordCount ["+n+"]")}},t.mapBufferF32=function(){return je(this.shadowBufferF32)},t.prepareToRender=function(){if(null!==this.shadowBufferF32){var e=je(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:se.UNIFORM|se.COPY_DST,hint:ue.Dynamic}));var t=ut(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount ["+t+"] ("+this.currentWordOffset+" aligned "+this.uniformBufferMaxPageWordSize+") <= this.currentBufferWordSize ["+this.currentBufferWordSize+"]");if(this.isSupportedUBO())je(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}},t.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function yr(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function Ar(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Sr(e){return 0}var Cr=function(){this.keys=[],this.values=[]},Or=function(){function e(e,t){this.keyEqualFunc=void 0,this.keyHashFunc=void 0,this.buckets=new Map,this.keyEqualFunc=e,this.keyHashFunc=t}var t=e.prototype;return t.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},t.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},t.get=function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]},t.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new Cr);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},t.delete=function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}},t.clear=function(){this.buckets.clear()},t.size=function(){for(var e,t=0,r=be(this.buckets.values());!(e=r()).done;){t+=e.value.values.length}return t},t.values=Ce().mark((function e(){var t,r,n,i;return Ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=be(this.buckets.values());case 1:if((r=t()).done){e.next=12;break}i=(n=r.value).values.length-1;case 4:if(i<0){e.next=10;break}return e.next=7,n.values[i];case 7:i--,e.next=4;break;case 10:e.next=1;break;case 12:case"end":return e.stop()}}),e,this)})),e}();function Ir(e,t){return Ke(""!==e.preprocessedVert&&""!==t.preprocessedVert),Ke(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Nr(e,t){return e=yr(e,t.numUniformBuffers),e=yr(e,t.numSamplers)}function xr(e,t){return e=yr(e,t.blendMode),e=yr(e,t.blendSrcFactor),e=yr(e,t.blendDstFactor)}function Pr(e,t){return e=xr(e,t.rgbBlendState),e=yr(e=xr(e,t.alphaBlendState),t.channelWriteMask)}function Dr(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=Pr(e,t.attachmentsState[r]);return e=function(e,t){return yr(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=yr(e,t.depthCompare),e=yr(e,t.depthWrite?1:0),e=yr(e,t.stencilCompare),e=yr(e,t.stencilPassOp),e=yr(e,t.stencilWrite?1:0),e=yr(e,t.cullMode),e=yr(e,t.frontFace?1:0),e=yr(e,t.polygonOffset?1:0)}function Br(e){var t=0;t=yr(t,e.program.id),null!==e.inputLayout&&(t=yr(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=Nr(t,e.bindingLayouts[r]);t=Dr(t,e.megaStateDescriptor);for(var n=0;e.colorAttachmentFormats.length>n;n++)t=yr(t,e.colorAttachmentFormats[n]||0);return Ar(t=yr(t,e.depthStencilAttachmentFormat||0))}function Mr(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=yr(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=yr(t,o.buffer.id),t=yr(t,o.wordCount))}return Ar(t)}var Lr,Fr=function(){function e(e){this.device=void 0,this.bindingsCache=new Or(Bt,Mr),this.renderPipelinesCache=new Or(Ut,Br),this.inputLayoutsCache=new Or(kt,Sr),this.programCache=new Or(Ir,Sr),this.samplerCache=new Or(Wt,Sr),this.device=e}var t=e.prototype;return t.createBindings=function(e){var t=this.bindingsCache.get(e);if(null===t){var r=Ht(e);t=this.device.createBindings(r),this.bindingsCache.add(r,t)}return t},t.createRenderPipeline=function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var r=jt(e);t=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,t)}return t},t.createInputLayout=function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var r=Zt(e);t=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,t)}return t},t.createProgramSimple=function(e){var t,r=this.programCache.get(e);if(null===r){var n={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};r=this.device.createProgramSimple(n),this.programCache.add(n,r)}return r},t.createProgram=function(e){return e.ensurePreprocessed(this.device.queryVendorInfo()),this.createProgramSimple(e)},t.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},t.destroy=function(){for(var e,t=be(this.bindingsCache.values());!(e=t()).done;){e.value.destroy()}for(var r,n=be(this.renderPipelinesCache.values());!(r=n()).done;){r.value.destroy()}for(var i,o=be(this.inputLayoutsCache.values());!(i=o()).done;){i.value.destroy()}for(var a,s=be(this.programCache.values());!(a=s()).done;){a.value.destroy()}for(var u,l=be(this.samplerCache.values());!(u=l()).done;){u.value.destroy()}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"}(Lr||(Lr={}));var br,Ur={x:0,y:0,w:1,h:1},wr=function(){function e(){this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=Ur,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=[]}var t=e.prototype;return t.setDebugName=function(e){this.debugName=e},t.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},t.setViewport=function(e){this.viewport=e},t.attachRenderTargetID=function(e,t){Ke(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t},t.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},t.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},t.resolveToExternalTexture=function(e,t){this.resolveTextureOutputExternalTextures[e]=t},t.exec=function(e){Ke(null===this.execFunc),this.execFunc=e},t.post=function(e){Ke(null===this.postFunc),this.postFunc=e},t.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),Gr=function(){function e(e,t){this.debugName=void 0,this.dimension=fe.n2D,this.depth=1,this.numLevels=1,this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.usage=de.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.attachment=void 0,this.age=0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,Ke(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}var t=e.prototype;return t.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},t.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},t.reset=function(e){Ke(this.matchesDescription(e)),this.age=0},t.destroy=function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()},e}(),kr=function(){function e(e,t){this.dimension=fe.n2D,this.depth=1,this.numLevels=1,this.usage=de.RenderTarget,this.pixelFormat=void 0,this.width=0,this.height=0,this.texture=void 0,this.age=0,this.immutable=!0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}var t=e.prototype;return t.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height},t.reset=function(e){Ke(this.matchesDescription(e)),this.age=0},t.destroy=function(){this.texture.destroy()},e}();br=Symbol.species;var Wr,Vr=function(){this[br]=void 0,this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},Xr=function(){function e(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=e}var t=e.prototype;return t.acquireRenderTargetForDescription=function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new Gr(this.device,e)},t.acquireSingleSampledTextureForDescription=function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new kr(this.device,e)},t.beginGraphBuilder=function(){Ke(null===this.currentGraph),this.currentGraph=new Vr},t.pushPass=function(e){var t=new wr;e(t),this.currentGraph.passes.push(t)},t.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},t.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},t.findMostRecentPassThatAttachedRenderTarget=function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null},t.resolveRenderTargetPassAttachmentSlot=function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]},t.findPassForResolveRenderTarget=function(e){var t=je(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Ke(void 0===t.resolveTextureOutputExternalTextures[r]),t},t.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},t.resolveRenderTargetToExternalTexture=function(e,t){var r=this.findPassForResolveRenderTarget(e),n=r.renderTargetIDs.indexOf(e);Ke(void 0===r.resolveTextureOutputIDs[n]),r.resolveTextureOutputExternalTextures[n]=t},t.getRenderTargetDescription=function(e){return je(this.currentGraph.renderTargetDescriptions[e])},t.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var o=t.resolveTextureInputIDs[i];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[o]]++}},t.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(Ke(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]},t.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=je(this.renderTargetAliveForID[e]);return t?(Ke(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Ke(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r},t.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];Ke(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=je(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return je(n.texture)},t.determineResolveParam=function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;Ke(!(a&&s));var u=null,l=!1;if(this.renderTargetOutputCount[n]>1&&(l=!0),a){Ke(e.resolveTextureRenderTargetIDs[i]===n),Ke(this.resolveTextureUseCount[i]>0),Ke(this.renderTargetOutputCount[n]>0);var c=je(this.renderTargetAliveForID[n]);if(null!==c.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=je(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(f),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,c.debugName+" (Resolve "+i+")")}u=this.singleSampledTextureForResolveTextureID[i].texture}}else u=s?o:null;return{resolveTo:u,store:l}},t.schedulePass=function(e,t){for(var r=t.renderTargetIDs[Lr.DepthStencil],n=Lr.Color0;Lr.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null;var a=this.determineResolveParam(e,t,n),s=a.store;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[Lr.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var l=this.determineResolveParam(e,t,Lr.DepthStencil),c=l.store;t.descriptor.depthStencilResolveTo=l.resolveTo,t.descriptor.depthStencilStore=c,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var f=0,d=0,h=0,p=0;t.renderTargets.length>p;p++){var _=t.renderTargets[p];_&&(0===f&&(f=_.width,d=_.height,h=_.sampleCount),Ke(_.width===f),Ke(_.height===d),Ke(_.sampleCount===h),_.needsClear=!1)}if(f>0&&d>0){var E=d*t.viewport.y,v=f*t.viewport.w,R=d*t.viewport.h;t.viewportX=f*t.viewport.x,t.viewportY=E,t.viewportW=v,t.viewportH=R}for(var g=0;t.resolveTextureInputIDs.length>g;g++){t.resolveTextureInputTextures[g]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[g])}for(var m=0;t.renderTargetIDs.length>m;m++)this.releaseRenderTargetForID(t.renderTargetIDs[m],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},t.scheduleGraph=function(e){Ke(0===this.renderTargetOutputCount.length),Ke(0===this.renderTargetResolveCount.length),Ke(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;at(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),at(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),at(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var o=0;this.renderTargetOutputCount.length>o;o++)Ke(0===this.renderTargetOutputCount[o]);for(var a=0;this.renderTargetResolveCount.length>a;a++)Ke(0===this.renderTargetResolveCount[a]);for(var s=0;this.resolveTextureUseCount.length>s;s++)Ke(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)Ke(void 0===this.renderTargetAliveForID[u]);for(var l=0;this.renderTargetDeadPool.length>l;l++)1>this.renderTargetDeadPool[l].age||(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;this.singleSampledTextureDeadPool.length>c;c++)1>this.singleSampledTextureDeadPool[c].age||(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},t.execPass=function(e){Ke(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},t.execGraph=function(e){var t=this;this.scheduleGraph(e),e.passes.forEach((function(e){t.execPass(e)})),this.singleSampledTextureForResolveTextureID.length=0},t.execute=function(){var e=je(this.currentGraph);this.execGraph(e),this.currentGraph=null},t.getDebug=function(){return this},t.getPasses=function(){return this.currentGraph.passes},t.getPassDebugThumbnails=function(e){return e.debugThumbnails},t.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},t.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},t.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return Ke(r>=0),je(t.resolveTextureInputTextures[r])},t.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},t.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},t.newGraphBuilder=function(){return this.beginGraphBuilder(),this},t.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)Ke(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)Ke(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].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"}(Wr||(Wr={}));function Hr(e,r,n){void 0===n&&(n=65536);var i=t.clamp(e,0,n)/n;return r&&(i=1-i),65535&65535*i}function Yr(e,t){return(16777215&e|(255&t)<<24)>>>0}function Kr(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function jr(e,t){return Yr(Kr(0,t),e)}function zr(e,t){return Ke(t>=0),(4294967040&e|t>>>8&255)>>>0}function qr(e){return Yr(0,e)}function Zr(e,t){return Ke(t>=0),(4278190335&e|t<<8)>>>0}var Qr="undefined"!=typeof Float32Array?Float32Array:Array;function Jr(){var e=new Qr(16);return Qr!=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 $r(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 en(e,t,r,n,i,o,a,s,u,l,c,f,d,h,p,_){var E=new Qr(16);return E[0]=e,E[1]=t,E[2]=r,E[3]=n,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]=p,E[15]=_,E}function tn(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 rn=function(e,t,r){var n=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],p=t[11],_=t[12],E=t[13],v=t[14],R=t[15],g=r[0],m=r[1],T=r[2],y=r[3];return e[0]=g*n+m*s+T*f+y*_,e[1]=g*i+m*u+T*d+y*E,e[2]=g*o+m*l+T*h+y*v,e[3]=g*a+m*c+T*p+y*R,e[4]=(g=r[4])*n+(m=r[5])*s+(T=r[6])*f+(y=r[7])*_,e[5]=g*i+m*u+T*d+y*E,e[6]=g*o+m*l+T*h+y*v,e[7]=g*a+m*c+T*p+y*R,e[8]=(g=r[8])*n+(m=r[9])*s+(T=r[10])*f+(y=r[11])*_,e[9]=g*i+m*u+T*d+y*E,e[10]=g*o+m*l+T*h+y*v,e[11]=g*a+m*c+T*p+y*R,e[12]=(g=r[12])*n+(m=r[13])*s+(T=r[14])*f+(y=r[15])*_,e[13]=g*i+m*u+T*d+y*E,e[14]=g*o+m*l+T*h+y*v,e[15]=g*a+m*c+T*p+y*R,e};function nn(e,t,r){var n=new Qr(3);return n[0]=e,n[1]=t,n[2]=r,n}var on,an;on=new Qr(3),Qr!=Float32Array&&(on[0]=0,on[1]=0,on[2]=0),an=on;!function(){var e=function(){var e=new Qr(2);return Qr!=Float32Array&&(e[0]=0,e[1]=0),e}()}();var sn=en(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var un,ln=en(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function cn(e,t,r,n,i,o){return void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags"}(un||(un={}));var fn,dn=function(){function e(){this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=dt(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=dt(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:Rt(Tt),program:null,topology:ae.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}var t=e.prototype;return t.reset=function(){this.sortKey=0,this.flags=un.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null},t.setFromTemplate=function(e){vt(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;e.renderPipelineDescriptor.colorAttachmentFormats.length>t;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=[].concat(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~un.InheritedFlags|e.flags&un.InheritedFlags,this.sortKey=e.sortKey;var r=this.bindingDescriptors[0],n=e.bindingDescriptors[0];null!==n.bindingLayout&&this.setBindingLayout(n.bindingLayout);for(var i=0;Math.min(r.uniformBufferBindings.length,n.uniformBufferBindings.length)>i;i++)r.uniformBufferBindings[i].wordCount=e.bindingDescriptors[0].uniformBufferBindings[i].wordCount;this.setSamplerBindingsFromTextureMappings(n.samplerBindings);for(var o=0;e.dynamicUniformBufferByteOffsets.length>o;o++)this.dynamicUniformBufferByteOffsets[o]=e.dynamicUniformBufferByteOffsets[o]},t.setProgram=function(e){this.renderPipelineDescriptor.program=e},t.setMegaStateFlags=function(e){return vt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},t.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},t.setInputLayoutAndState=function(e,t){this.inputState=t,this.renderPipelineDescriptor.inputLayout=e},t.setBindingLayout=function(e){Ke(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers),this.renderPipelineDescriptor.bindingLayouts[0]=e,this.bindingDescriptors[0].bindingLayout=e;for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({buffer:null,wordCount:0});for(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})},t.setBindingLayouts=function(e){Ke(this.bindingDescriptors.length>=e.length),Ke(1===e.length),this.setBindingLayout(e[0])},t.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=ft(this.flags,un.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},t.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=ft(this.flags,un.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},t.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=ft(this.flags,un.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},t.setUniforms=function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value,i="number"==typeof t?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,i)}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)a+=cn(s,a,n[u],n[u+1],n[u+2],n[u+3])}},t.setUniformBuffer=function(e){this.uniformBuffer=e},t.allocateUniformBuffer=function(e,t){return Ke(this.dynamicUniformBufferByteOffsets.length>this.bindingDescriptors[0].bindingLayout.numUniformBuffers),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=t,this.getUniformBufferOffset(e)},t.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},t.setUniformBufferOffset=function(e,t,r){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=r},t.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},t.getUniformBuffer=function(){return this.uniformBuffer},t.setSamplerBindingsFromTextureMappings=function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler,r.lateBinding=n.lateBinding):(r.texture=null,r.sampler=null,r.lateBinding=null)}},t.hasLateSamplerBinding=function(e){for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){if(this.bindingDescriptors[0].samplerBindings[t].lateBinding===e)return!0}return!1},t.resolveLateSamplerBinding=function(e,t){for(var r=0;this.bindingDescriptors[0].samplerBindings.length>r;r++){var n=this.bindingDescriptors[0].samplerBindings[r];n.lateBinding===e&&(null===t?(n.texture=null,n.sampler=null):(Ke(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}},t.setAllowSkippingIfPipelineNotReady=function(e){this.flags=ft(this.flags,un.AllowSkippingIfPipelineNotReady,e)},t.setAttachmentFormatsFromRenderPass=function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.pixelFormat:null,null!==o&&(-1===n?n=o.sampleCount:Ke(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.pixelFormat:null,null!==a&&(-1===n?n=a.sampleCount:Ke(n==a.sampleCount)),Ke(n>0),this.renderPipelineDescriptor.sampleCount=n},t.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&un.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setInputState(this.inputState);for(var o=0;this.bindingDescriptors[0].uniformBufferBindings.length>o;o++)this.bindingDescriptors[0].uniformBufferBindings[o].buffer=je(this.uniformBuffer.buffer);this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniforms(t)}));var a=e.createBindings(Pe({},this.bindingDescriptors[0],{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(Ke(!!(this.flags&un.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&un.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0},e}();function hn(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(fn||(fn={}));var pn=function(){function e(e,t){void 0===e&&(e=hn),void 0===t&&(t=fn.Forwards),this.renderInsts=[],this.compareFunction=void 0,this.executionOrder=void 0,this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}var t=e.prototype;return t.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},t.insertSorted=function(e){null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):ct(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()},t.submitRenderInst=function(e){e.flags|=un.Draw,this.insertSorted(e)},t.hasLateSamplerBinding=function(e){for(var t=0;this.renderInsts.length>t;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1},t.resolveLateSamplerBinding=function(e,t){for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].resolveLateSamplerBinding(e,t)},t.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},t.drawOnPassRendererNoReset=function(e,t){this.ensureSorted();var r=0;if(this.executionOrder===fn.Forwards)for(var n=0;this.renderInsts.length>n;n++)this.renderInsts[n].drawOnPass(e,t)&&r++;else for(var i=this.renderInsts.length-1;i>=0;i--)this.renderInsts[i].drawOnPass(e,t)&&r++;return r},t.reset=function(){this.renderInsts.length=0},t.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),_n=function(){function e(){this.pool=[],this.allocCount=0}var t=e.prototype;return t.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new dn),this.allocCount-1},t.popRenderInst=function(){this.allocCount--},t.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},t.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),En=function(){function e(e){this.renderCache=void 0,this.instPool=new _n,this.templatePool=new _n,this.simpleRenderInstList=new pn,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=e}var t=e.prototype;return t.newRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r},t.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},t.setCurrentRenderInstList=function(e){Ke(null===this.simpleRenderInstList),this.currentRenderInstList=e},t.pushTemplateRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=un.Template,r},t.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},t.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},t.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Ke(0===this.templatePool.allocCount)},t.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},t.disableSimpleMode=function(){this.simpleRenderInstList=null},t.drawOnPassRenderer=function(e){je(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},t.drawOnPassRendererNoReset=function(e){je(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),vn=function(){function e(){this.renderCache=void 0,this.renderGraph=void 0,this.renderInstManager=void 0,this.uniformBuffer=void 0,this.device=void 0}var t=e.prototype;return t.getDevice=function(){return this.device},t.setDevice=function(e){this.device=e,this.renderCache=new Fr(e),this.renderGraph=new Xr(this.device),this.renderInstManager=new En(this.renderCache),this.uniformBuffer=new Tr(this.device)},t.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},t.prepareToRender=function(){this.uniformBuffer.prepareToRender()},t.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache.destroy(),this.renderGraph.destroy()},t.getCache=function(){return this.renderCache},e}();vn=i([r.singleton()],vn);var Rn=function(){function e(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=e}var t=e.prototype;return t.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},t.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function gn(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var mn,Tn=gn(Qe(.88,.88,.88,1)),yn=gn($e),An=gn(tt);function Sn(e,t){var r=function(e){return e.antialiasingMode===mn.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function Cn(e,t,r){var n=function(e){if(e===Lr.Color0)return ye.U8_RGBA_RT;if(e===Lr.DepthStencil)return ye.D24_S8;throw Error("whoops")}(e),i=new Rn(n);return Sn(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(mn||(mn={}));var On=function(){function e(){this.name=void 0,this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}var t=e.prototype;return t.reset=function(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0},t.copy=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}(),In=function(){function e(){this.inputTexture=null,this.outputTexture=null}var t=e.prototype;return t.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Ke(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new kr(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},t.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},t.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},t.destroy=function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)},e}(),Nn=function(){function e(){this.offscreenCanvas=void 0,this.renderingService=void 0,this.canvasConfig=void 0,this.textureCache={},this.gradientCache={}}var r=e.prototype;return r.getOrCreateTexture=function(e,r,n,i){var o=this,a="string"==typeof r?r:r.src||"";if(this.textureCache[a])this.textureCache[a].emit(ce.LOADED);else if(this.textureCache[a]=e.createTexture(Pe({pixelFormat:ye.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:fe.n2D,usage:de.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),"string"!=typeof r)this.textureCache[a].setImageData(r),this.textureCache[a].emit(ce.LOADED),this.renderingService.dirtify();else{var s,u=this.canvasConfig.createImage;u?s=u(r):t.isBrowser&&(s=new window.Image),s&&(s.onload=function(){o.textureCache[a].setImageData(s),o.textureCache[a].emit(ce.LOADED),o.renderingService.dirtify(),i&&i(o.textureCache[a])},s.onerror=function(){},s.crossOrigin="Anonymous",s.src=r)}return this.textureCache[a]},r.getOrCreateCanvas=function(){return this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas)},r.getOrCreateGradient=function(e){var r=this.generateCacheKey(e),n=e.type,i=e.x0,o=e.y0,a=e.x1,s=e.y1,u=e.steps,l=e.width,c=e.height,f=this.gradientCache[r],d=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),h=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);if(!f){if(d.width=l,d.height=c,n===t.GradientPatternType.LinearGradient)f=h.createLinearGradient(i*l,o*c,a*l,s*c);else if(n===t.GradientPatternType.RadialGradient){f=h.createRadialGradient(i*l,o*c,0,a*l,s*c,e.r1*(Math.sqrt(l*l+c*c)/2))}u.forEach((function(e){var t,r=e[1];null===(t=f)||void 0===t||t.addColorStop(Number(e[0]),r)})),this.gradientCache[r]=f}d.src=r,f&&(h.fillStyle=f,h.fillRect(0,0,l,c))},r.generateCacheKey=function(e){return"gradient-"+e.type+"-"+e.x0+"-"+e.y0+"-"+e.x1+"-"+e.y1+"-"+(e.r1||0)+"-"+e.width+"-"+e.height+"-"+e.steps.map((function(e){return e.join("")})).join("-")},r.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={},this.gradientCache={}},e}();i([r.inject(t.OffscreenCanvasCreator),o("design:type",t.OffscreenCanvasCreator)],Nn.prototype,"offscreenCanvas",void 0),i([r.inject(t.RenderingService),o("design:type",t.RenderingService)],Nn.prototype,"renderingService",void 0),i([r.inject(t.CanvasConfig),o("design:type",Object)],Nn.prototype,"canvasConfig",void 0),Nn=i([r.singleton()],Nn);var xn=function(){function e(){this.lights=[],this.fog=void 0}var t=e.prototype;return t.addLight=function(e){this.lights.push(e),this.sortLights()},t.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},t.addFog=function(e){this.fog=e},t.removeFog=function(e){this.fog=null},t.getFog=function(){return this.fog},t.getAllLights=function(){return this.lights},t.getDefines=function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e},t.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}();xn=i([r.singleton()],xn);var Pn=r.Syringe.defineToken("RendererFactory"),Dn=r.Syringe.defineToken("ShapeRenderer"),Bn=r.Syringe.defineToken("MeshFactory"),Mn=1,Ln=function(){function 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={}}var t=e.prototype;return t.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.meshes.forEach((function(n){n.init(r.device,r.renderingService);var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=r.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),r.renderHelper.renderInstManager.submitRenderInst(o,e),t||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))},t.attach=function(e,t){this.device=e,this.renderingService=t},t.add=function(e){var t=this,r=e.renderable3D;if(r&&!r.meshes.length){var n=this.rendererFactory(e.nodeName);n&&n.meshes.forEach((function(i,o){if(r.meshes[o]=void 0,n.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=n,a.index=o,t.meshes.push(a)),a&&(a.objects.push(e),r.meshes[o]=a,a.geometryDirty=!0)}}))}},t.remove=function(e){var t=this,r=e.renderable3D;r&&(r.meshes.forEach((function(r){if(r){var n=r.objects.indexOf(e);n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length&&t.meshes.splice(t.meshes.indexOf(r),1)}})),r.meshes=[])},t.updateAttribute=function(e,t,r,n){var i=this;void 0===n&&(n=!1);var 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&&i.meshes.splice(i.meshes.indexOf(c),1),o.meshes[o.meshes.indexOf(c)]=void 0),l&&((c=i.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))||((c=i.meshFactory(s)).renderer=a,c.index=u,c.init(i.device,i.renderingService),i.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(n)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;i.pendingUpdatePatches[d]||(i.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[d].objectIndices.indexOf(f)&&i.pendingUpdatePatches[d].objectIndices.push(f)}}}))},t.changeRenderOrder=function(e,t){var r=e.renderable3D;r&&r.meshes.length&&r.meshes.forEach((function(r){r&&r.inited&&!r.geometryDirty&&(r.renderer.shouldSubmitRenderInst(e,r.index)&&r.inited&&r.changeRenderOrder(e,t))}))},t.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=Mn++),this.stencilRefCache[e.entity]},t.updatePendingPatches=function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}},e}();i([r.inject(vn),o("design:type",vn)],Ln.prototype,"renderHelper",void 0),i([r.inject(Pn),o("design:type",Function)],Ln.prototype,"rendererFactory",void 0),i([r.inject(Bn),o("design:type",Function)],Ln.prototype,"meshFactory",void 0),Ln=i([r.singleton()],Ln);var Fn,bn=.005,Un=1,wn=function(){function 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=Un++,this.meshes=[],this.clipPathMeshCreated=!1}var t=e.prototype;return t.shouldSubmitRenderInst=function(e,t){return!0},t.beforeUploadUBO=function(e,t,r){},t.beforeInitMesh=function(e){},t.afterInitMesh=function(e){},e}();function Gn(e,t,r){var n=e.createBuffer({viewOrSize:st(r.byteLength,4)/4,usage:t,hint:ue.Static});return n.setSubData(0,new Uint8Array(r)),n}i([r.inject(vn),o("design:type",vn)],wn.prototype,"renderHelper",void 0),i([r.inject(Nn),o("design:type",Nn)],wn.prototype,"texturePool",void 0),i([r.inject(t.DefaultCamera),o("design:type",t.Camera)],wn.prototype,"camera",void 0),i([r.inject(xn),o("design:type",xn)],wn.prototype,"lightPool",void 0),i([r.inject(Ln),o("design:type",Ln)],wn.prototype,"batchManager",void 0),wn=i([r.injectable()],wn),function(e){e.CHANGED="changed"}(Fn||(Fn={}));var kn,Wn=function(e){function r(t,r){var n;return void 0===r&&(r={}),(n=e.call(this)||this).device=void 0,n.props=void 0,n.drawMode=ae.Triangles,n.vertexBuffers=[],n.vertices=[],n.indexBuffer=void 0,n.indices=void 0,n.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:ye.U32_R},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n.device=t,n.props=r,n}De(r,e);var n=r.prototype;return n.validate=function(e){return!0},n.build=function(e){},n.computeBoundingBox=function(){return new t.AABB},n.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=Gn(this.device,se.INDEX|se.COPY_DST,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this},n.setVertexBuffer=function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={byteStride:e.byteStride,frequency:e.frequency},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=e.byteStride,u=t.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===r&&e.location===o}));u?(u.format=n,u.bufferByteOffset=i,u.byteStride=s,u.divisor=a):t.inputLayoutDescriptor.vertexAttributeDescriptors.push({format:n,bufferIndex:r,bufferByteOffset:i,location:o,byteStride:s,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=Gn(this.device,se.VERTEX|se.COPY_DST,i.buffer);return this.vertexBuffers[r]=o,this},n.getVertexBuffer=function(e){return this.vertexBuffers[e]},n.updateVertexBuffer=function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e].byteStride,o=this.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.location===t}));o&&this.getVertexBuffer(e).setSubData(o.bufferByteOffset+r*i,n);this.emit(Fn.CHANGED)},n.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,ArrayBuffer.isView(e)?e:new Uint32Array(e)),this},n.destroy=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},r}(v.EventEmitter);!function(e){e.CHANGED="changed"}(kn||(kn={}));var Vn=function(e){function r(t,r){var n;(n=e.call(this)||this).device=void 0,n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uniformNames=void 0,n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var i=Rt(Tt),o=i.cullMode,a=i.depthCompare,s=i.depthWrite,u=i.stencilCompare,l=i.stencilWrite,c=i.stencilPassOp,f=i.frontFace,d=i.polygonOffset,h=i.attachmentsState;return n.device=t,n.props=Pe({cullMode:o,depthTest:!0,depthCompare:a,depthWrite:s,stencilCompare:u,stencilWrite:l,stencilPassOp:c,frontFace:f,polygonOffset:d,attachmentsState:h,blendEquation:re.Add,blendEquationAlpha:re.Add,blendSrc:te.SrcAlpha,blendDst:te.OneMinusSrcAlpha,blendSrcAlpha:te.Zero,blendDstAlpha:te.One,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}De(r,e);var n=r.prototype;return n.compile=function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=Er(this.props.fragmentShader)},n.setUniforms=function(e){var r=this,n=!1;Object.keys(e).forEach((function(i){var o,a=e[i],s=r.textures[i];s&&s!==a&&(r.textureDirty=!0),(o=a)&&o.type?(r.textures[i]=a,r.textureDirty=!0,a.on(ce.LOADED,(function(){r.dispatchMutationEvent()}))):(r.uniforms[i]=a,n=!0),t.isNil(e[i])&&(delete r.textures[i],delete r.uniforms[i])})),n&&this.dispatchMutationEvent()},n.dispatchMutationEvent=function(){this.emit(kn.CHANGED)},xe(r,[{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())}}]),r}(v.EventEmitter),Xn=function(e){function t(t,r){var n;return(n=e.call(this,t,Pe({},r))||this).defines=Pe({},n.defines,{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return De(t,e),t}(Vn);function Hn(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function Yn(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Kn,jn,zn=1,qn="FillTextureMapping";!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"}(Kn||(Kn={})),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"}(jn||(jn={}));var Zn=function(){function e(){this.id=zn++,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 mr,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1}var r=e.prototype;return r.init=function(e,t){this.inited||(this.renderer.beforeInitMesh(this),this.device=e,this.renderingService=t,this.material=new Xn(this.device),this.material.defines=Pe({},Hn(jn),this.material.defines),this.geometry=new Wn(this.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},r.observeGeometryChanged=function(){var e=this;this.geometry.on(Fn.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))},r.observeMaterialChanged=function(){var e=this;this.material.on(kn.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))},r.shouldMerge=function(e,t){return!this.instance||this.instance.nodeName===e.nodeName&&!e.parsedStyle.clipPath},r.createGeometry=function(e){var r=this,n=Jr(),i=Jr(),o=[],a=[],s=[],u=[];e.forEach((function(e){var l,c=e.parsedStyle,f=c.fill,d=c.stroke,h=c.opacity,p=c.fillOpacity,_=c.strokeOpacity,E=c.lineWidth,v=c.anchor,R=c.visibility,g=c.increasedLineWidthForHitTesting,m=[0,0,0,0];f instanceof t.CSSRGB&&(m=[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255,Number(f.alpha)]);var T=[0,0,0,0];d instanceof t.CSSRGB&&(T=[Number(d.r)/255,Number(d.g)/255,Number(d.b)/255,Number(d.alpha)]),r.clipPathTarget?($r(n,e.getLocalTransform()),m=[1,1,1,1],rn(n,r.clipPathTarget.getWorldTransform(),n)):$r(n,e.getWorldTransform()),rn(i,r.camera.getViewTransform(),n);var y=e.isInteractive()&&(null===(l=e.renderable3D)||void 0===l?void 0:l.encodedPickingColor)||[0,0,0];o.push.apply(o,n),a.push.apply(a,m.concat(T)),s.push(h.value,p.value,_.value,E.value,"visible"===R.value?1:0,v[0].value,v[1].value,(null==g?void 0:g.value)||0),u.push.apply(u,y.concat([e.sortable.renderOrder*bn]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Kn.MODEL_MATRIX,byteStride:64,frequency:le.PerInstance,attributes:[{format:ye.F32_RGBA,bufferByteOffset:0,location:jn.MODEL_MATRIX0,divisor:1},{format:ye.F32_RGBA,bufferByteOffset:16,location:jn.MODEL_MATRIX1,divisor:1},{format:ye.F32_RGBA,bufferByteOffset:32,location:jn.MODEL_MATRIX2,divisor:1},{format:ye.F32_RGBA,bufferByteOffset:48,location:jn.MODEL_MATRIX3,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Kn.FILL_STROKE,byteStride:32,frequency:le.PerInstance,attributes:[{format:ye.F32_RGBA,bufferByteOffset:0,location:jn.COLOR,divisor:1},{format:ye.F32_RGBA,bufferByteOffset:16,location:jn.STROKE_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Kn.PACKED_STYLE,byteStride:32,frequency:le.PerInstance,attributes:[{format:ye.F32_RGBA,bufferByteOffset:0,location:jn.PACKED_STYLE1,divisor:1},{format:ye.F32_RGBA,bufferByteOffset:16,location:jn.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Kn.PICKING_COLOR,byteStride:16,frequency:le.PerInstance,attributes:[{format:ye.F32_RGBA,bufferByteOffset:0,location:jn.PICKING_COLOR,divisor:1}],data:new Float32Array(u)})},r.destroy=function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()},r.applyRenderInst=function(e,t){var r=this,n=this.lightPool.getAllLights(),i=!!this.lightPool.getFog(),o=!!n.length,a=Pe({},this.material.defines);if(this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=Pe({},this.material.defines,this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=J.Always,this.material.stencilPassOp=pe.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=J.Equal,this.material.stencilPassOp=pe.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 r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new On;t.name=e,t.texture=r.material.textures[e],r.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:ne.Clamp,wrapT:ne.Clamp,minFilter:ie.Point,magFilter:ie.Bilinear,mipFilter:oe.Linear,minLOD:0,maxLOD:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(Yn(a,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=Pe({},this.material.defines,Hn(jn)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"number"==typeof t?r.program.setDefineString(e,""+t):r.program.setDefineBool(e,t)})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.programDescriptorSimpleWithOrig=gr(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=jr(Wr.OPAQUE,t[0].sortable.renderOrder)},r.updateBatchedAttribute=function(e,r,n,i){if("fill"===n||"stroke"===n){var o=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=[0,0,0,0];n instanceof t.CSSRGB&&(a=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]);var s=[0,0,0,0];i instanceof t.CSSRGB&&(s=[Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)]),o.push.apply(o,a.concat(s))})),this.geometry.updateVertexBuffer(Kn.FILL_STROKE,jn.COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===qn}));if(a instanceof t.CSSRGB)0>s||(this.textureMappings.splice(s,-1),this.material.textureDirty=!0);else{var u=this.createFillGradientTextureMapping([this.instance]);0>s||this.textureMappings.splice(s,1,u),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var l=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor,n=t.increasedLineWidthForHitTesting;l.push(t.opacity.value,t.fillOpacity.value,t.strokeOpacity.value,t.lineWidth.value,"visible"===t.visibility.value?1:0,r[0].value,r[1].value,(null==n?void 0:n.value)||0)})),this.geometry.updateVertexBuffer(Kn.PACKED_STYLE,jn.PACKED_STYLE1,r,new Uint8Array(new Float32Array(l).buffer))}else if("modelMatrix"===n){var c=[];e.forEach((function(e){var t=$r(Jr(),e.getWorldTransform());c.push.apply(c,t)})),this.geometry.updateVertexBuffer(Kn.MODEL_MATRIX,jn.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(c).buffer))}else if("pointerEvents"===n){var f=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];f.push.apply(f,r.concat([e.sortable.renderOrder*bn]))})),this.geometry.updateVertexBuffer(Kn.PICKING_COLOR,jn.PICKING_COLOR,r,new Uint8Array(new Float32Array(f).buffer))}},r.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)},r.changeRenderOrder=function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Kn.PICKING_COLOR,jn.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(i,[t*bn])).buffer))},r.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Kn.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride/4*r)}for(var o=0,a=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],l=1;e.vertices.length>l;l++)for(var c=e.inputLayoutDescriptor.vertexBufferDescriptors[l].byteStride/4,f=0;c>f;f++)e.vertices[l][o*c+f]=n[l][u*c+f];a[s]=o,o++}for(var d=function(t){var r=e.inputLayoutDescriptor.vertexBufferDescriptors[t],n=r.frequency,i=r.byteStride,o=e.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===t}));o&&e.setVertexBuffer({bufferIndex:o.bufferIndex,byteStride:i,frequency:n,attributes:[{format:o.format,bufferByteOffset:o.bufferByteOffset,location:o.location,divisor:o.divisor}],data:e.vertices[t]})},h=Kn.PICKING_COLOR+1;e.vertexBuffers.length>h;h++)d(h);for(var p=new Float32Array(3*r),_=0;r>_;)for(var E=0;3>E;E++){p[3*a[_++]+E]=1}e.setVertexBuffer({bufferIndex:Kn.BARYCENTRIC,byteStride:12,frequency:le.PerVertex,attributes:[{format:ye.F32_RGB,bufferByteOffset:0,location:Number(jn.BARYCENTRIC)}],data:p}),e.setIndexBuffer(a)},r.beforeUploadUBO=function(e,t,r){},r.uploadUBO=function(e){var r=this,n=this.material,i=this.lightPool.getAllLights(),o=this.lightPool.getFog(),a=!!o,s=!!i.length,u=[];if(n.defines.USE_WIREFRAME){var l=t.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(a&&this.uploadFog(u,o),this.uploadMaterial(u,n),s){var c={};i.forEach((function(e){c[e.define]||(c[e.define]=-1),c[e.define]++,e.uploadUBO(u,c[e.define])}))}u.sort((function(e,t){return r.material.uniformNames.indexOf(e.name)-r.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,u),e.setMegaStateFlags({attachmentsState:[{channelWriteMask:this.material.stencilWrite?he.None:he.AllChannels,rgbBlendState:{blendMode:n.blendEquation,blendSrcFactor:n.blendSrc,blendDstFactor:n.blendDst},alphaBlendState:{blendMode:n.blendEquationAlpha,blendSrcFactor:n.blendSrcAlpha,blendDstFactor:n.blendDstAlpha}}],depthCompare:n.depthCompare,depthWrite:n.depthWrite,stencilCompare:n.stencilCompare,stencilWrite:n.stencilWrite,stencilPassOp:n.stencilPassOp,stencilRef:n.stencilRef,cullMode:n.cullMode,frontFace:n.frontFace,polygonOffset:n.polygonOffset}),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},r.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,u=n.density;if(o instanceof t.CSSRGB){var l=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,u]}),e.push({name:"u_FogColor",value:l})}},r.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,r)},r.createFillGradientTextureMapping=function(e){var r=e[0],n=r.nodeName===t.Shape.LINE?r.parsedStyle.stroke:r.parsedStyle.fill;if(n&&n instanceof t.CSSGradientValue){var i;n.type===t.GradientPatternType.LinearGradient||n.type===t.GradientPatternType.RadialGradient?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient(Pe({type:n.type},n.value,{width:128,height:128})),i=this.texturePool.getOrCreateCanvas()):(this.program.setDefineBool("USE_PATTERN",!0),i=n.value.src);var o=new On;return o.name=qn,o.texture=this.texturePool.getOrCreateTexture(this.device,i,Ue(ye.U8_RGBA_NORM,1,1,1)),o.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0}))})),this.device.setResourceName(o.texture,"Fill Texture"+this.id),o.sampler=this.renderHelper.getCache().createSampler({wrapS:ne.Repeat,wrapT:ne.Repeat,minFilter:ie.Point,magFilter:ie.Bilinear,mipFilter:oe.Linear,minLOD:0,maxLOD:0}),o}return null},xe(e,[{key:"instance",get:function(){return this.objects[0]}}]),e}();i([r.inject(vn),o("design:type",vn)],Zn.prototype,"renderHelper",void 0),i([r.inject(Nn),o("design:type",Nn)],Zn.prototype,"texturePool",void 0),i([r.inject(t.DefaultCamera),o("design:type",t.Camera)],Zn.prototype,"camera",void 0),i([r.inject(xn),o("design:type",xn)],Zn.prototype,"lightPool",void 0),Zn=i([r.injectable()],Zn);var Qn,Jn;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(Qn||(Qn={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(Jn||(Jn={}));var $n=[t.Shape.CIRCLE,t.Shape.ELLIPSE],ei=function(e){function r(){return e.apply(this,arguments)||this}De(r,e);var n=r.prototype;return n.shouldMerge=function(t,r){var n=e.prototype.shouldMerge.call(this,t,r);return!!n&&(!this.needDrawStrokeSeparately(t)&&!this.needDrawStrokeSeparately(this.instance)&&this.instance.parsedStyle.fill.isNone===t.parsedStyle.fill.isNone)},n.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = 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=Pe({},this.material.defines,Hn(Jn))},n.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[],i=[],o=[];t.forEach((function(e,t){var a=e,s=4*t,u=a.parsedStyle.radius,l=r.shouldOmitStroke(a.parsedStyle),c=r.getSize(e.parsedStyle,a.nodeName);i.push.apply(i,c.concat([$n.indexOf(a.nodeName),u||0,l?1:0,0])),n.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:Kn.POSITION,byteStride:16,frequency:le.PerVertex,attributes:[{format:ye.F32_RG,bufferByteOffset:0,location:jn.POSITION},{format:ye.F32_RG,bufferByteOffset:8,location:jn.UV}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:Qn.PACKED_STYLE,byteStride:24,frequency:le.PerInstance,attributes:[{format:ye.F32_RG,bufferByteOffset:0,location:Jn.SIZE,divisor:1},{format:ye.F32_RGBA,bufferByteOffset:8,location:Jn.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})},n.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n){var a=[];t.forEach((function(e){var t=o.shouldOmitStroke(e.parsedStyle),r=o.getSize(e.parsedStyle,e.nodeName);a.push.apply(a,[r[0],r[1]].concat([$n.indexOf(e.nodeName),e.parsedStyle.radius||0,t?1:0,0]))})),this.geometry.updateVertexBuffer(Qn.PACKED_STYLE,Jn.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}},n.getSize=function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i.value,i.value]}else if(r===t.Shape.ELLIPSE){n=[e.rx.value,e.ry.value]}return n},n.shouldOmitStroke=function(e){var t=e.lineDash,r=e.strokeOpacity;return!(!e.stroke||!(t&&t.length&&t.every((function(e){return 0!==e.value}))||1!==r.value))},n.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.lineDash;return t.stroke&&t.lineWidth.value>0&&(1>t.strokeOpacity.value||r&&r.length&&r.every((function(e){return 0!==e.value})))},r}(Zn);ei=i([r.injectable()],ei);var ti,ri,ni=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(ti||(ti={})),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 ii={butt:1,round:2,square:3},oi=function(e){function r(){return e.apply(this,arguments)||this}De(r,e);var n=r.prototype;return n.shouldMerge=function(r,n){var i=e.prototype.shouldMerge.call(this,r,n);if(!i)return!1;var o=this.instance;if(o.nodeName===t.Shape.LINE&&""+o.parsedStyle.stroke!=""+r.parsedStyle.stroke)return!1;return!0},n.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = 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=Pe({},this.material.defines,Hn(ri))},n.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[],i=[],o=[],a=[],s=0;t.forEach((function(e){var t=e.parsedStyle,u=t.x1,l=t.y1,c=t.x2,f=t.y2,d=t.z1,h=t.z2,p=t.defX,_=t.defY,E=t.lineCap,v=t.isBillboard,R=r.calcDash(e),g=R.dashOffset,m=R.dashSegmentPercent,T=R.dashRatioInEachSegment;i.push(ii[E.value]),o.push(g,m,T,v?1:0),n.push(u.value-p,l.value-_,d.value,c.value-p,f.value-_,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:Kn.POSITION,byteStride:20,frequency:le.PerInstance,attributes:[{format:ye.F32_RGB,bufferByteOffset:0,location:ri.POSITION,divisor:0},{format:ye.F32_RG,bufferByteOffset:12,location:ri.UV,divisor:0}],data:new Float32Array(ni)}),this.geometry.setVertexBuffer({bufferIndex:ti.POINT,byteStride:24,frequency:le.PerInstance,attributes:[{format:ye.F32_RGB,bufferByteOffset:0,location:ri.POINTA,divisor:1},{format:ye.F32_RGB,bufferByteOffset:12,location:ri.POINTB,divisor:1}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:ti.CAP,byteStride:4,frequency:le.PerInstance,attributes:[{format:ye.F32_R,bufferByteOffset:0,location:ri.CAP,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ti.DASH,byteStride:16,frequency:le.PerInstance,attributes:[{format:ye.F32_RGBA,bufferByteOffset:0,location:ri.DASH,divisor:1}],data:new Float32Array(o)})},n.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"x1"===n||"y1"===n||"x2"===n||"y2"===n||"z1"===n||"z2"===n){var a=[];t.forEach((function(e){var t=e.parsedStyle,r=t.defX,n=t.defY;a.push(t.x1.value-r,t.y1.value-n,t.z1.value,t.x2.value-r,t.y2.value-n,t.z2.value)})),this.geometry.updateVertexBuffer(ti.POINT,ri.POINTA,r,new Uint8Array(new Float32Array(a).buffer))}else if("lineDashOffset"===n||"lineDash"===n){var s=[];t.forEach((function(e){var t=o.calcDash(e);s.push(t.dashOffset,t.dashSegmentPercent,t.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(ti.DASH,ri.DASH,r,new Uint8Array(new Float32Array(s).buffer))}else if("lineCap"===n){var u=[];t.forEach((function(e){u.push(ii[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(ti.CAP,ri.CAP,r,new Uint8Array(new Float32Array(u).buffer))}},n.calcDash=function(e){var t=e.parsedStyle,r=t.lineDash,n=t.lineDashOffset,i=e.getTotalLength(),o=0,a=1,s=0;if(r&&r.length){o=(n&&n.value||0)/i;var u=r.reduce((function(e,t){return e+t.value}),0);a=u/i,s=r[1].value/u}return{dashOffset:o,dashSegmentPercent:a,dashRatioInEachSegment:s}},r}(Zn);function ai(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}oi=i([r.injectable()],oi);var si=function(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}};function ui(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function li(e,t,r,n,i,o,a,s,u){var l=ui(e,r,i,a,u),c=ui(t,n,o,s,u),f=si(e,t,r,n,u),d=si(r,n,i,o,u),h=si(i,o,a,s,u),p=si(f.x,f.y,d.x,d.y,u),_=si(d.x,d.y,h.x,h.y,u);return[[e,t,f.x,f.y,p.x,p.y,l,c],[l,c,_.x,_.y,h.x,h.y,a,s]]}function ci(e,t,r,n,i,o,a,s,u){if(0===u)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=ai(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var l=li(e,t,r,n,i,o,a,s,.5),c=[].concat(l[0],[u-1]),f=[].concat(l[1],[u-1]);return ci.apply(void 0,c)+ci.apply(void 0,f)}var fi,di=function(e,t,r,n,i,o,a,s){return ci(e,t,r,n,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"}(fi||(fi={}));var hi,pi,_i;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(hi||(hi={})),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"}(pi||(pi={})),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"}(_i||(_i={}));var Ei=function(e){function r(){return e.apply(this,arguments)||this}De(r,e);var n=r.prototype;return n.shouldMerge=function(e,t){return!1},n.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r=e.parsedStyle,n=r.stroke,s=r.opacity,u=r.fillOpacity,l=r.strokeOpacity,c=r.lineWidth,f=r.increasedLineWidthForHitTesting,d=r.anchor,h=r.lineDash,p=r.lineDashOffset,_=r.visibility;if("lineJoin"===i||"lineCap"===i||e.nodeName===t.Shape.CIRCLE&&"r"===i||e.nodeName===t.Shape.ELLIPSE&&("rx"===i||"ry"===i)||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("stroke"===i){var E,v=[0,0,0,0];n instanceof t.CSSRGB&&(v=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(((E={})[_i.STROKE_COLOR]=v,E))}else if("opacity"===i){var R;a.material.setUniforms(((R={})[_i.OPACITY]=s.value,R))}else if("fillOpacity"===i){var g;a.material.setUniforms(((g={})[_i.FILL_OPACITY]=u.value,g))}else if("strokeOpacity"===i){var m;a.material.setUniforms(((m={})[_i.STROKE_OPACITY]=l.value,m))}else if("lineWidth"===i){var T;a.material.setUniforms(((T={})[_i.STROKE_WIDTH]=c.value,T))}else if("increasedLineWidthForHitTesting"===i){var y;a.material.setUniforms(((y={})[_i.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=f.value,y))}else if("anchor"===i||"modelMatrix"===i){var A,S=0,C=0,O=e.getGeometryBounds();if(O){var I=O.halfExtents;S=-I[0]*d[0].value*2,C=-I[1]*d[1].value*2}var N=Jr();rn(N,e.getWorldTransform(),tn(N,nn(S,C,0))),a.material.setUniforms(((A={})[_i.MODEL_MATRIX]=N,A))}else if("visibility"===i){var x;a.material.setUniforms(((x={})[_i.VISIBLE]="visible"===_.value?1:0,x))}else if("lineDash"===i){var P;a.material.setUniforms(((P={})[_i.DASH]=h[0].value||0,P[_i.GAP]=h[1].value||0,P))}else if("lineDashOffset"===i){var D;a.material.setUniforms(((D={})[_i.DASH_OFFSET]=p&&p.value||0,D))}else if("pointerEvents"===i){var B,M,L=o&&e.isInteractive()&&(null===(B=e.renderable3D)||void 0===B?void 0:B.encodedPickingColor)||[0,0,0];a.material.setUniforms(((M={})[_i.PICKING_COLOR]=L,M))}}))},n.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[_i.Z_INDEX]=t*bn,r))},n.createMaterial=function(e){var r,n,i,o;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=Pe({},this.material.defines,Hn(pi));var a=e[0],s=a.parsedStyle,u=s.fill,l=s.stroke,c=s.opacity,f=s.fillOpacity,d=s.strokeOpacity,h=s.lineWidth,p=s.increasedLineWidthForHitTesting,_=s.anchor,E=s.lineDash,v=s.lineDashOffset,R=s.visibility,g=[0,0,0,0];u instanceof t.CSSRGB&&(g=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var m=[0,0,0,0];l instanceof t.CSSRGB&&(m=[Number(l.r)/255,Number(l.g)/255,Number(l.b)/255,Number(l.alpha)]);var T=a.isInteractive()&&(null===(r=a.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],y=0,A=0,S=a.getGeometryBounds();if(S){var C=S.halfExtents;y=-C[0]*_[0].value*2,A=-C[1]*_[1].value*2}var O=Jr();rn(O,a.getWorldTransform(),tn(O,nn(y,A,0))),this.material.setUniforms(((o={})[_i.MODEL_MATRIX]=O,o[_i.COLOR]=g,o[_i.STROKE_COLOR]=m,o[_i.STROKE_WIDTH]=h.value,o[_i.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=p.value,o[_i.OPACITY]=c.value,o[_i.FILL_OPACITY]=f.value,o[_i.STROKE_OPACITY]=d.value,o[_i.EXPAND]=1,o[_i.MITER_LIMIT]=5,o[_i.SCALE_MODE]=1,o[_i.ALIGNMENT]=.5,o[_i.PICKING_COLOR]=T,o[_i.DASH]=E&&(null===(n=E[0])||void 0===n?void 0:n.value)||0,o[_i.GAP]=E&&(null===(i=E[1])||void 0===i?void 0:i.value)||0,o[_i.DASH_OFFSET]=v&&v.value||0,o[_i.VISIBLE]="visible"===R.value?1:0,o[_i.Z_INDEX]=a.sortable.renderOrder*bn,o)),this.material.cullMode=ee.None},n.createGeometry=function(e){var t=gi(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:hi.PACKED,byteStride:48,frequency:le.PerInstance,attributes:[{format:ye.F32_RG,bufferByteOffset:0,byteStride:12,location:pi.PREV,divisor:1},{format:ye.F32_RG,bufferByteOffset:12,byteStride:12,location:pi.POINT1,divisor:1},{format:ye.F32_R,bufferByteOffset:20,byteStride:12,location:pi.VERTEX_JOINT,divisor:1},{format:ye.F32_RG,bufferByteOffset:24,byteStride:12,location:pi.POINT2,divisor:1},{format:ye.F32_RG,bufferByteOffset:36,byteStride:12,location:pi.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:hi.VERTEX_NUM,byteStride:4,frequency:le.PerInstance,attributes:[{format:ye.F32_R,bufferByteOffset:0,byteStride:4,location:pi.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:hi.TRAVEL,byteStride:4,frequency:le.PerInstance,attributes:[{format:ye.F32_R,bufferByteOffset:0,byteStride:4,location:pi.TRAVEL,divisor:1}],data:new Float32Array(r)}),this.geometry.vertexCount=15,this.geometry.instancedCount=n,this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2,4,6,5,4,7,6,4,7,8]))},r}(Zn);function vi(e,t,r,n,i,o,a){var s=a[a.length-2],u=a[a.length-1];a.length-=2;var l=function(e,t){var r=Math.ceil(e/10);8>r?r=8:r>Ri&&(r=Ri);return r}(di(s,u,e,t,r,n,i,o)),c=0,f=0,d=0,h=0,p=0;a.push(s,u);for(var _=1,E=0;l>=_;++_)a.push((d=(f=(c=1-(E=_/l))*c)*c)*s+3*f*E*e+3*c*(h=E*E)*r+(p=h*E)*i,d*u+3*f*E*t+3*c*h*n+p*o)}Ei=i([r.injectable()],Ei);var Ri=2048;function gi(e,r){void 0===r&&(r=!1);var n=e.parsedStyle,i=n.lineCap,o=n.lineJoin,a=e.parsedStyle,s=a.defX,u=a.defY,l=[],c=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){if(l=e.parsedStyle.points.points.reduce((function(e,t){return e.push(t[0]-s,t[1]-u),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return c=R(l,[],2),{pointsBuffer:l,travelBuffer:[],triangles:c,instancedCount:Math.round(l.length/2)};var f;l.push(l[0],l[1]),(f=l).push.apply(f,mi(l[0],l[1],l[2],l[3]))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var d;e.nodeName!==t.Shape.PATH?(d=t.parsePath(t.convertToPath(e,!1),e),s=d.rect.x,u=d.rect.y):d=e.parsedStyle.path;var h=d.zCommandIndexes,p=[].concat(d.curve).map((function(e,t){return h.includes(t)?["Z"]:e})),_=-1;if(p.forEach((function(r){var n=r[0],i=r.slice(1);if("M"===n)_=l.length,l.push(i[0]-s,i[1]-u);else if("C"===n)vi(i[0]-s,i[1]-u,i[2]-s,i[3]-u,i[4]-s,i[5]-u,l);else if("Z"===n&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var o;l.push(l[_],l[_+1]),(o=l).push.apply(o,mi(l[_],l[_+1],l[_+2],l[_+3]))}})),r)return c=R(l,[],2),{pointsBuffer:l,travelBuffer:[],triangles:c,instancedCount:Math.round(l.length/2)}}var E=function(e){var t;switch(e){case"bevel":t=fi.JOINT_BEVEL;break;case"round":t=fi.JOINT_ROUND;break;default:t=fi.JOINT_MITER}return t}(o.value),v=function(e){var t;switch(e){case"square":t=fi.CAP_SQUARE;break;case"round":t=fi.CAP_ROUND;break;default:t=fi.CAP_BUTT}return t}(i.value),g=v;v===fi.CAP_ROUND&&(g=fi.JOINT_CAP_ROUND),v===fi.CAP_BUTT&&(g=fi.JOINT_CAP_BUTT),v===fi.CAP_SQUARE&&(g=fi.JOINT_CAP_SQUARE);for(var m=6,T=0,y=[],A=[],S=0;l.length>S;S+=2)S>1&&(T+=Math.sqrt(Math.pow(l[S]-l[S-2],2)+Math.pow(l[S+1]-l[S+1-2],2))),A.push(T),y[m++]=l[S],y[m++]=l[S+1],y[m]=E,0==S&&v!==fi.CAP_ROUND&&(y[m]+=v),l.length>S+4?l.length>S+2||(y[m]=0):y[m]+=g-E,m++;return y[m++]=l[l.length-4],y[m++]=l[l.length-3],y[m++]=0,y[0]=l[0],y[1]=l[1],y[2]=0,y[3]=l[2],y[4]=l[3],y[5]=v===fi.CAP_ROUND?v:0,{pointsBuffer:y,travelBuffer:A,triangles:c,instancedCount:Math.round(l.length/2)}}function mi(e,t,r,n){void 0===r&&(r=e),void 0===n&&(n=t);var i=[r-e,n-t];return[e+.01*i[0],t+.01*i[1]]}var Ti=function(e){function r(){return e.apply(this,arguments)||this}De(r,e);var n=r.prototype;return n.shouldMerge=function(e,t){return!1},n.createGeometry=function(e){var t=gi(e[0],!0),r=t.triangles;this.geometry.setVertexBuffer({bufferIndex:Kn.POSITION,byteStride:8,frequency:le.PerVertex,attributes:[{format:ye.F32_RG,bufferByteOffset:0,byteStride:8,location:jn.POSITION}],data:new Float32Array(t.pointsBuffer)}),this.geometry.vertexCount=r.length,this.geometry.setIndexBuffer(new Uint32Array(r))},n.createMaterial=function(e){var r,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 i=e[0],o=i.parsedStyle,a=o.fill,s=o.opacity,u=o.fillOpacity,l=o.anchor,c=o.visibility,f=[0,0,0,0];a instanceof t.CSSRGB&&(f=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var d=i.isInteractive()&&(null===(r=i.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],h=0,p=0,_=i.getGeometryBounds();if(_){var E=_.halfExtents;h=-E[0]*l[0].value*2,p=-E[1]*l[1].value*2}var v=Jr();rn(v,i.getWorldTransform(),tn(v,nn(h,p,0))),this.material.setUniforms(((n={})[_i.MODEL_MATRIX]=v,n[_i.COLOR]=f,n[_i.PICKING_COLOR]=d,n[_i.OPACITY]=s.value,n[_i.FILL_OPACITY]=u.value,n[_i.VISIBLE]="visible"===c.value?1:0,n[_i.Z_INDEX]=i.sortable.renderOrder*bn,n))},n.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r=e.parsedStyle,n=r.fill,s=r.opacity,u=r.fillOpacity,l=r.anchor,c=r.visibility;if("lineJoin"===i||"lineCap"===i||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("fill"===i){var f,d=[0,0,0,0];n instanceof t.CSSRGB&&(d=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(((f={})[_i.COLOR]=d,f))}else if("opacity"===i){var h;a.material.setUniforms(((h={})[_i.OPACITY]=s.value,h))}else if("fillOpacity"===i){var p;a.material.setUniforms(((p={})[_i.FILL_OPACITY]=u.value,p))}else if("anchor"===i||"modelMatrix"===i){var _,E=0,v=0,R=e.getGeometryBounds();if(R){var g=R.halfExtents;E=-g[0]*l[0].value*2,v=-g[1]*l[1].value*2}var m=Jr();rn(m,e.getWorldTransform(),tn(m,nn(E,v,0))),a.material.setUniforms(((_={})[_i.MODEL_MATRIX]=m,_))}else if("visibility"===i){var T;a.material.setUniforms(((T={})[_i.VISIBLE]="visible"===c.value?1:0,T))}else if("pointerEvents"===i){var y,A,S=o&&e.isInteractive()&&(null===(y=e.renderable3D)||void 0===y?void 0:y.encodedPickingColor)||[0,0,0];a.material.setUniforms(((A={})[_i.PICKING_COLOR]=S,A))}}))},n.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[_i.Z_INDEX]=t*bn,r))},r}(Zn);Ti=i([r.injectable()],Ti);var yi=function(e){function t(){return e.apply(this,arguments)||this}De(t,e);var r=t.prototype;return r.shouldMerge=function(t,r){var n=e.prototype.shouldMerge.call(this,t,r);return!!n&&this.instance.parsedStyle.img===t.parsedStyle.img},r.createMaterial=function(e){var t=e[0].parsedStyle.img;this.material.defines=Pe({},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 r=this.texturePool.getOrCreateTexture(this.device,t);this.material.setUniforms({u_Map:r})},r.createGeometry=function(t){e.prototype.createGeometry.call(this,t);var r=[],n=[],i=[];t.forEach((function(e,t){var o=4*t,a=e.parsedStyle;r.push(a.width.value,a.height.value),n.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:Kn.POSITION,byteStride:8,frequency:le.PerInstance,attributes:[{format:ye.F32_RG,bufferByteOffset:0,location:jn.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Kn.UV,byteStride:8,frequency:le.PerVertex,attributes:[{format:ye.F32_RG,bufferByteOffset:0,location:jn.UV}],data:new Float32Array(n)})},r.updateAttribute=function(t,r,n,i){if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"width"===n||"height"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle;o.push(t.width.value,t.height.value)})),this.geometry.updateVertexBuffer(Kn.POSITION,jn.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.device,i);this.material.setUniforms({u_Map:a})}},t}(Zn);yi=i([r.injectable()],yi);function Ai(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function Si(e,t,r,n,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*o,c=((n.y+u)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[l+f];return t}var Ci=function(){function e(e,t){this.width=void 0,this.height=void 0,this.data=void 0,Ai(this,e,1,t)}var t=e.prototype;return t.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Ai({},{width:n,height:i},r);Si(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=o.data}}(this,e,1)},t.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){Si(e,t,r,n,i,1)},e}();var Oi=function(e){this.image=void 0,this.positions=void 0;var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i){if((l=i[+a])&&0!==l.bitmap.width&&0!==l.bitmap.height)r.push(c={x:0,y:0,w:l.bitmap.width+2,h:l.bitmap.height+2}),o[a]={rect:c,metrics:l.metrics}}}var s=function(e){for(var t,r=0,n=0,i=be(e);!(t=i()).done;){var o=t.value;r+=o.w*o.h,n=Math.max(n,o.w)}e.sort((function(e,t){return t.h-e.h}));for(var a,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}],u=0,l=0,c=be(e);!(a=c()).done;)for(var f=a.value,d=s.length-1;d>=0;d--){var h=s[d];if(h.w>=f.w&&h.h>=f.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 p=s.pop();s.length>d&&(s[d]=p)}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}}return{w:u,h:l,fill:r/(u*l)||0}}(r),u=new Ci({width:s.w||1,height:s.h||1});for(var n in e){i=e[n];for(var a in i){var l,c;if((l=i[+a])&&0!==l.bitmap.width&&0!==l.bitmap.height)Ci.copy(l.bitmap,u,{x:0,y:0},{x:(c=t[n][a].rect).x+1,y:c.y+1},l.bitmap)}}this.image=u,this.positions=t};var Ii,Ni,xi,Pi=function(){function e(){this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphAtlas=void 0,this.glyphMap={},this.glyphAtlasTexture=void 0}var t=e.prototype;return t.getMap=function(){return this.glyphMap},t.getAtlas=function(){return this.glyphAtlas},t.getAtlasTexture=function(){return this.glyphAtlasTexture},t.layout=function(e,t,r,n,i,o,a){var s=this,u=[],l=o,c=a,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=u.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),o=r&&r[n];o&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=o.metrics.advance+i)}));for(var o=l-i,a=n;u.length>a;a++)u[a].x=u[a].x-f*o;l=0,c+=r})),u},t.generateAtlas=function(e,t,r,n,i,o){var a=this;void 0===e&&(e=""),void 0===n&&(n="");var s=[];this.glyphMap[e]||(s=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var u=Object.keys(this.glyphMap[e]||{});if(Array.from(new Set(i.split(""))).forEach((function(e){-1===u.indexOf(""+e.charCodeAt(0))&&s.push(e)})),s.length){var l=s.map((function(i){return a.generateSDF(e,t,r,n,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[e]=Pe({},this.glyphMap[e],l),this.glyphAtlas=new Oi(this.glyphMap);var c=this.glyphAtlas.image,f=c.width,d=c.height,h=c.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=o.createTexture(Pe({},Ue(ye.ALPHA,f,d,1),{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([h],0)}},t.generateSDF=function(e,t,r,n,i){void 0===e&&(e="");var o=i.charCodeAt(0),a=this.sdfGeneratorCache[e];a||(a=this.sdfGeneratorCache[e]=new j({fontSize:24,fontFamily:t,fontWeight:r,fontStyle:n,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.glyphWidth,l=s.glyphHeight,c=s.glyphLeft,f=s.glyphTop,d=s.glyphAdvance;return{id:o,bitmap:new Ci({width:s.width,height:s.height},s.data),metrics:{width:u,height:l,left:c,top:f-24+3,advance:d}}},e}();Pi=i([r.injectable()],Pi),function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(Ii||(Ii={})),function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(Ni||(Ni={})),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"}(xi||(xi={}));var Di=function(e){function r(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).glyphManager=void 0,t}De(r,e);var n=r.prototype;return n.shouldMerge=function(t,r){var n=e.prototype.shouldMerge.call(this,t,r);if(!n)return!1;if(this.index!==r)return!1;var i=this.instance;return i.parsedStyle.fontSize.value===t.parsedStyle.fontSize.value&&(i.parsedStyle.metrics.font===t.parsedStyle.metrics.font&&!["fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(e){return i.parsedStyle[e]!==t.parsedStyle[e]})))},n.createGeometry=function(e){var r=this,n=this.instance.parsedStyle,i=n.textBaseline,o=n.letterSpacing,a=void 0===o?0:o,s=24/n.fontSize.value,u=[],l=[],c=[],f=0;e.forEach((function(e){var n=e.parsedStyle,o=n.metrics,d=n.dx,h=n.dy,p=o.font,_=o.lines,E=o.height,v=o.lineHeight,R=0,g=0;d&&d.unit===t.UnitType.kPixels&&(R+=d.value),h&&h.unit===t.UnitType.kPixels&&(g+=h.value);var m=0;"middle"===i.value?m=-E/2:"bottom"===i.value?m=-E:"top"===i.value||"hanging"===i.value?m=0:"alphabetic"===i.value?m=.25*v-E:"ideographic"===i.value&&(m=-E);var T=r.glyphManager.getAtlas(),y=r.buildTextBuffers({object:e,lines:_,fontStack:p,lineHeight:s*v,offsetX:s*R,offsetY:s*(m+g),letterSpacing:s*a,glyphAtlas:T,indicesOffset:f}),A=y.indexBuffer,S=y.charUVOffsetBuffer;f=y.indicesOffset,c.push.apply(c,y.charPackedBuffer),l.push.apply(l,S),u.push.apply(u,A)})),this.geometry.vertexCount=u.length,this.geometry.setIndexBuffer(new Uint32Array(u)),this.geometry.setVertexBuffer({bufferIndex:Ii.INSTANCED,byteStride:144,frequency:le.PerVertex,attributes:[{format:ye.F32_RGBA,bufferByteOffset:0,location:jn.MODEL_MATRIX0},{format:ye.F32_RGBA,bufferByteOffset:16,location:jn.MODEL_MATRIX1},{format:ye.F32_RGBA,bufferByteOffset:32,location:jn.MODEL_MATRIX2},{format:ye.F32_RGBA,bufferByteOffset:48,location:jn.MODEL_MATRIX3},{format:ye.F32_RGBA,bufferByteOffset:64,location:jn.COLOR},{format:ye.F32_RGBA,bufferByteOffset:80,location:jn.STROKE_COLOR},{format:ye.F32_RGBA,bufferByteOffset:96,location:jn.PACKED_STYLE1},{format:ye.F32_RGBA,bufferByteOffset:112,location:jn.PACKED_STYLE2},{format:ye.F32_RGBA,bufferByteOffset:128,location:jn.PICKING_COLOR}],data:new Float32Array(c)}),this.geometry.setVertexBuffer({bufferIndex:Ii.TEX,byteStride:16,frequency:le.PerVertex,attributes:[{format:ye.F32_RG,bufferByteOffset:0,location:Ni.TEX},{format:ye.F32_RG,bufferByteOffset:8,location:Ni.OFFSET}],data:new Float32Array(l)})},n.createMaterial=function(e){var t;this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(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=ee.Back,this.material.defines=Pe({},this.material.defines,Hn(Ni));var r=this.instance.parsedStyle,n=r.fontSize,i=r.fontFamily,o=void 0===i?"":i,a=r.fontWeight,s=r.fontStyle,u=r.metrics.font,l=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(u,o,""+a,""+s,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,p=d.height;this.material.setUniforms(((t={})[xi.SDF_MAP]=c,t[xi.SDF_MAP_SIZE]=[h,p],t[xi.FONT_SIZE]=n.value,t[xi.GAMMA_SCALE]=1,t[xi.STROKE_BLUR]=.2,t[xi.HAS_STROKE]=this.index,t))},n.changeRenderOrder=function(e,t){this.material&&(this.material.programDirty=!0,this.material.geometryDirty=!0)},n.updateAttribute=function(e,t,r,n){"text"===r||"fontFamily"===r||"fontSize"===r||"fontWeight"===r||"fontStyle"===r||"fontVariant"===r||"textBaseline"===r||"letterSpacing"===r||"wordWrapWidth"===r||"lineHeight"===r||"wordWrap"===r||"textAlign"===r||"modelMatrix"===r||"visibility"===r||"dx"===r||"dy"===r?(this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0):"fill"!==r&&"fillOpacity"!==r&&"stroke"!==r&&"strokeOpacity"!==r&&"opacity"!==r&&"lineWidth"!==r&&"visibility"!==r&&"pointerEvents"!==r||(this.material.geometryDirty=!0)},n.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,u=e.offsetX,l=e.offsetY,c=e.glyphAtlas,f=e.indicesOffset,d=n.parsedStyle,h=d.textAlign,p=d.fill,_=d.stroke,E=d.opacity,v=d.fillOpacity,R=d.strokeOpacity,g=d.lineWidth,m=d.visibility,T=[0,0,0,0];p instanceof t.CSSRGB&&(T=[Number(p.r)/255,Number(p.g)/255,Number(p.b)/255,Number(p.alpha)]);var y=[0,0,0,0];_ instanceof t.CSSRGB&&(y=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)]);var A=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=$r(Jr(),n.getWorldTransform()),C=[],O=[],I=[],N=f,x=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var 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;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:h},br:{x:d,y:h},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,h.value,s,u,l),c.positions);return x.forEach((function(e){var t=[];t.push.apply(t,S);var r=[].concat(t,T,y,[E.value,v.value,R.value,g.value,"visible"===m.value?1:0,0,0,0],A,[n.sortable.renderOrder*bn]);C.push.apply(C,r.concat(r,r,r)),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}},r}(Zn);i([r.inject(Pi),o("design:type",Pi)],Di.prototype,"glyphManager",void 0),Di=i([r.injectable()],Di);var Bi=function(e){function r(){return e.apply(this,arguments)||this}De(r,e);var n=r.prototype;return n.shouldMerge=function(r,n){var i=e.prototype.shouldMerge.call(this,r,n);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},n.updateAttribute=function(t,r,n,i){e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i)},n.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},n.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(Zn);Bi=i([r.injectable()],Bi);var Mi=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[ei,Ei],t}De(t,e);var r=t.prototype;return r.shouldSubmitRenderInst=function(e,t){if(0===t&&e.parsedStyle.fill.isNone)return!1;return 1!==t||this.needDrawStrokeSeparately(e)},r.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e.value}));return!s||u&&o.value>0&&(1>a.value||l)},t}(wn);Mi=i([r.injectable({token:[{token:Dn,named:t.Shape.CIRCLE},{token:Dn,named:t.Shape.ELLIPSE}]})],Mi);var Li=function(e){function r(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[Ti,Ei],t}return De(r,e),r.prototype.shouldSubmitRenderInst=function(e,r){var n=e.parsedStyle,i=n.lineDash,o=e.nodeName;if(0===r&&(e.nodeName===t.Shape.POLYLINE||n.fill.isNone))return!1;if(1===r){if(0===n.strokeOpacity.value||0===n.lineWidth.value)return!1;var a=i&&i.length&&i.every((function(e){return 0!==e.value}));if(o===t.Shape.CIRCLE||o===t.Shape.ELLIPSE)return a}return!0},r}(wn);Li=i([r.injectable({token:[{token:Dn,named:t.Shape.POLYLINE},{token:Dn,named:t.Shape.PATH},{token:Dn,named:t.Shape.POLYGON},{token:Dn,named:t.Shape.RECT}]})],Li);var Fi=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[],t}return De(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(wn);Fi=i([r.injectable({token:[{token:Dn,named:t.Shape.GROUP}]})],Fi);var bi=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[yi],t}return De(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(wn);bi=i([r.injectable({token:[{token:Dn,named:t.Shape.IMAGE}]})],bi);var Ui=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[Di,Di],t}De(t,e);var r=t.prototype;return r.shouldSubmitRenderInst=function(e,t){var r=e.parsedStyle,n=r.lineWidth;return!(!(r.stroke&&n&&n.value)&&0===t)},r.beforeUploadUBO=function(e,t,r){var n;t.material.setUniforms(((n={})[xi.HAS_STROKE]=1-t.index,n))},t}(wn);Ui=i([r.injectable({token:[{token:Dn,named:t.Shape.TEXT}]})],Ui);var wi=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[oi],t}return De(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(wn);wi=i([r.injectable({token:{token:Dn,named:t.Shape.LINE}})],wi);var Gi=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[Bi],t}return De(t,e),t}(wn);Gi=i([r.injectable({token:[{token:Dn,named:t.Shape.MESH}]})],Gi);var ki=["style"],Wi=function(e){function t(r){var n=void 0===r?{}:r,i=n.style,o=Me(n,ki);return e.call(this,Pe({type:t.tag,style:Pe({intensity:Math.PI},i)},o))||this}return De(t,e),t}(t.DisplayObject);Wi.tag="light";var Vi,Xi=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(Vi||(Vi={}));var Hi=function(e){function t(r){var n=void 0===r?{}:r,i=n.style,o=Me(n,Xi);return e.call(this,Pe({type:t.tag,style:Pe({type:Vi.NONE,fill:"black",start:1,end:1e3,density:0},i)},o))||this}return De(t,e),t}(t.DisplayObject);Hi.tag="fog";var Yi,Ki,ji,zi=r.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"}(ji||(ji={}));var qi,Zi,Qi=(Yi=function(){function 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 pn,picking:new pn},this.builder=void 0}var r=e.prototype;return r.getDevice=function(){return this.device},r.getSwapChain=function(){return this.swapChain},r.getRenderLists=function(){return this.renderLists},r.apply=function(e){var r=this,n=function(e){var t=e.target;if(t.nodeName!==Wi.tag)if(t.nodeName!==Hi.tag){var n=new Z;t.renderable3D=n,r.batchManager.add(t)}else r.lightPool.addFog(t);else r.lightPool.addLight(t)},i=function(e){var t=e.target;t.nodeName!==Wi.tag?t.nodeName!==Hi.tag?(r.batchManager.remove(t),delete t.renderable3D):r.lightPool.removeFog(t):r.lightPool.removeLight(t)},o=function(e){r.batchManager.updateAttribute(e.target,e.attrName,e.newValue)},a=function(e){r.batchManager.changeRenderOrder(e.target,e.detail.renderOrder)};e.hooks.init.tapPromise(Ki.tag,Ie(Ce().mark((function s(){var u,l;return Ce().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.addEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a),r.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering=!1,u=r.contextService.getDomElement(),r.contextService.resize((l=r.canvasConfig).width,l.height),s.next=10,r.deviceContribution.createSwapChain(u);case 10:r.swapChain=s.sent,r.device=r.swapChain.getDevice(),r.renderHelper.setDevice(r.device),r.renderHelper.renderInstManager.disableSimpleMode(),r.swapChain.configureSwapChain(u.width,u.height),r.renderingContext.root.ownerDocument.defaultView.on(t.CanvasEvent.RESIZE,(function(){r.swapChain.configureSwapChain(u.width,u.height)})),r.batchManager.attach(r.device,e);case 17:case"end":return s.stop()}}),s)})))),e.hooks.destroy.tap(Ki.tag,(function(){r.renderHelper.destroy(),r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.removeEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a)})),e.hooks.beginFrame.tap(Ki.tag,(function(){var e=r.swapChain.getCanvas(),n=r.renderHelper.renderInstManager;r.builder=r.renderHelper.renderGraph.newGraphBuilder();var i=t.parseColor(r.canvasConfig.background),o=r.canvasConfig.background?Qe(Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)):et,a={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:mn.None},s=Cn(Lr.Color0,a,gn(o)),u=Cn(Lr.DepthStencil,a,An),l=r.builder.createRenderTargetID(s,"Main Color"),c=r.builder.createRenderTargetID(u,"Main Depth");r.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Lr.Color0,l),e.attachRenderTargetID(Lr.DepthStencil,c),e.exec((function(e){r.renderLists.world.drawOnPassRenderer(n.renderCache,e)}))})),r.builder.resolveRenderTargetToExternalTexture(l,r.swapChain.getOnscreenTexture())})),e.hooks.endFrame.tap(Ki.tag,(function(){var e=r.renderHelper.renderInstManager,t=r.renderHelper.pushTemplateRenderInst();t.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),t.setMegaStateFlags(St({depthWrite:!0},{rgbBlendMode:re.Add,alphaBlendMode:re.Add,rgbBlendSrcFactor:te.SrcAlpha,alphaBlendSrcFactor:te.Zero,rgbBlendDstFactor:te.OneMinusSrcAlpha,alphaBlendDstFactor:te.One}));var n=r.canvasConfig,i=n.width,o=n.height;t.setUniforms(0,[{name:ji.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:ji.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:ji.CAMERA_POSITION,value:r.camera.getPosition()},{name:ji.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:ji.VIEWPORT,value:[i,o]},{name:ji.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:ji.IS_PICKING,value:0}]),r.batchManager.render(r.renderLists.world),e.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),e.resetRenderInsts(),r.swapChain.present()}))},r.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e}(),Yi.tag="RenderGraph",Ki=Yi);i([r.inject(t.CanvasConfig),o("design:type",Object)],Qi.prototype,"canvasConfig",void 0),i([r.inject(t.ContextService),o("design:type",Object)],Qi.prototype,"contextService",void 0),i([r.inject(t.RenderingContext),o("design:type",Object)],Qi.prototype,"renderingContext",void 0),i([r.inject(t.DefaultCamera),o("design:type",t.Camera)],Qi.prototype,"camera",void 0),i([r.inject(vn),o("design:type",vn)],Qi.prototype,"renderHelper",void 0),i([r.inject(xn),o("design:type",xn)],Qi.prototype,"lightPool",void 0),i([r.inject(Nn),o("design:type",Nn)],Qi.prototype,"texturePool",void 0),i([r.inject(Ln),o("design:type",Ln)],Qi.prototype,"batchManager",void 0),i([r.inject(zi),o("design:type",Object)],Qi.prototype,"deviceContribution",void 0),Qi=Ki=i([r.singleton({contrib:t.RenderingPluginContribution})],Qi);var Ji=(qi=function(){function 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 r=e.prototype;return r.apply=function(e){var r=this,n=function(e){var t=e.target,n=t.renderable3D;if(n){var i=r.pickingIdGenerator.getId(t);n.pickingId=i,n.encodedPickingColor=r.pickingIdGenerator.encodePickingColor(i)}};e.hooks.init.tapPromise(Zi.tag,Ie(Ce().mark((function e(){return Ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n);case 1:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Zi.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n)})),e.hooks.pick.tapPromise(Zi.tag,function(){var e=Ie(Ce().mark((function e(n){var i,o,a,s,u,l,c,f,d;return Ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.topmost,a=(o=n.position).viewportX,s=o.viewportY,u=r.contextService.getDPR(),c=r.canvasConfig.height*u,d=s*u,!((f=a*u)>(l=r.canvasConfig.width*u)||0>f||d>c||0>d)){e.next=10;break}return n.picked=[],e.abrupt("return",n);case 10:return e.next=12,r.pickByRectangleInDepth(new t.Rectangle(t.clamp(Math.round(f),0,l-1),t.clamp(Math.round(d),0,c-1),1,1),i?1:100);case 12:return n.picked=e.sent,e.abrupt("return",n);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())},r.pickByRectangleInDepth=function(){var e=Ie(Ce().mark((function e(t,r){var n,i,o;return Ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:void 0===r&&(r=100),n=null,i=1,o=[];case 4:return e.next=6,this.pickByRectangle(t,n);case 6:if(!(n=e.sent)){e.next=12;break}i++,o.push(n),e.next=13;break;case 12:return e.abrupt("break",14);case 13:if(n&&r>=i){e.next=4;break}case 14:return r>1&&this.restorePickingColor(o),e.abrupt("return",o);case 16:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},r.pickByRectangle=function(e,t){var r=this,n=this.renderGraphPlugin.getDevice(),i=this.renderGraphPlugin.getRenderLists(),o=this.renderHelper.renderInstManager,a=this.renderHelper.renderGraph.newGraphBuilder(),s=e.x,u=e.y,l=e.width,c=e.height,f={backbufferWidth:l,backbufferHeight:c,antialiasingMode:mn.None},d=Cn(Lr.Color0,f,gn(et)),h=a.createRenderTargetID(d,"Picking Color"),p=Cn(Lr.DepthStencil,f,An),_=a.createRenderTargetID(p,"Picking Depth"),E=Pe({},this.camera.getView());return new Promise((function(e){r.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),a.pushPass((function(t){t.setDebugName("Picking Pass"),t.attachRenderTargetID(Lr.Color0,h),t.attachRenderTargetID(Lr.DepthStencil,_),t.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)})),t.post((function(t){var i=t.getRenderTargetTexture(Lr.Color0),o=n.createReadback();E&&E.enabled?r.camera.setViewOffset(E.fullWidth,E.fullHeight,E.offsetX,E.offsetY,E.width,E.height):r.camera.clearViewOffset(),r.camera.setEnableUpdate(!0),o.readTexture(i,0,0,l,c,new Uint8Array(l*c*4)).then((function(t){var n,i=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(i=r.pickingIdGenerator.decodePickingColor(t)),i>-1){var a=r.pickingIdGenerator.getById(i);a&&a.isVisible()&&a.isInteractive()&&(n=a)}o.destroy(),e(n)}))}))}));var f=r.renderHelper.pushTemplateRenderInst();f.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),f.setMegaStateFlags(St({depthWrite:!0},{rgbBlendMode:re.Add,rgbBlendSrcFactor:te.One,rgbBlendDstFactor:te.Zero,alphaBlendMode:re.Add,alphaBlendSrcFactor:te.One,alphaBlendDstFactor:te.Zero}));var d=r.canvasConfig,p=d.width,v=d.height,R=r.contextService.getDPR();r.camera.setEnableUpdate(!1),r.camera.setViewOffset(p*R,v*R,s,u,l,c),f.setUniforms(0,[{name:ji.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:ji.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:ji.CAMERA_POSITION,value:r.camera.getPosition()},{name:ji.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:ji.VIEWPORT,value:[p,v]},{name:ji.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:ji.IS_PICKING,value:1}]),t&&r.batchManager.updateAttribute(t,"pointerEvents",!1,!0),r.batchManager.render(i.picking,!0),o.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),o.resetRenderInsts()}))},e}(),qi.tag="WebGLPicker",Zi=qi);i([r.inject(t.CanvasConfig),o("design:type",Object)],Ji.prototype,"canvasConfig",void 0),i([r.inject(t.SceneGraphService),o("design:type",Object)],Ji.prototype,"sceneGraphService",void 0),i([r.inject(t.ContextService),o("design:type",Object)],Ji.prototype,"contextService",void 0),i([r.inject(t.RenderingContext),o("design:type",Object)],Ji.prototype,"renderingContext",void 0),i([r.inject(vn),o("design:type",vn)],Ji.prototype,"renderHelper",void 0),i([r.inject(Qi),o("design:type",Qi)],Ji.prototype,"renderGraphPlugin",void 0),i([r.inject(Se),o("design:type",Se)],Ji.prototype,"pickingIdGenerator",void 0),i([r.inject(t.DefaultCamera),o("design:type",t.Camera)],Ji.prototype,"camera",void 0),i([r.inject(Ln),o("design:type",Ln)],Ji.prototype,"batchManager",void 0),Ji=Zi=i([r.singleton({contrib:t.RenderingPluginContribution})],Ji);var $i=["style"],eo=function(e){function r(r){var n,i=r.style,o=Me(r,$i);return(n=e.call(this,Pe({type:t.Shape.MESH,style:Pe({x:"",y:"",z:"",lineWidth:0},i)},o))||this).cullable.enable=!1,n.style.geometry.meshes.push(Le(n)),n.style.material.meshes.push(Le(n)),n}return De(r,e),r.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.style.geometry.meshes,r=t.indexOf(this);t.splice(r,1),r=(t=this.style.material.meshes).indexOf(this),t.splice(r,1)},r}(t.DisplayObject),to=function(){function e(){}return e.prototype.update=function(e){return e.geometry.computeBoundingBox(),{width:0,height:0,depth:0}},e}();to=i([r.singleton({token:{token:t.GeometryAABBUpdater,named:t.Shape.MESH}})],to);var ro,no,io,oo="#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}",ao="#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}",so=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).vert=oo,t.frag=ao,t.features={},t}return De(t,e),t}(mr),uo="#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}",lo=function(e){function t(){for(var t,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).features={},t.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",t.vert=oo,t.frag=uo,t}return De(t,e),t}(mr),co=dt(1,(function(){return new On}));var fo=r.Module((function(e){e(vn),e(Nn),e(xn),e(Pi),e(Se),e(Ln),e(Qi),e(Ji),e(ei),e(oi),e(Ei),e(Ti),e(yi),e(Di),e(Bi),e({token:Bn,useFactory:function(e){return function(t){return e.container.isBound(t)&&e.container.get(t)||null}}}),e(Mi),e(Li),e(bi),e(wi),e(Ui),e(Gi),e({token:Pn,useFactory:function(e){var t={};return function(r){return t[r]||e.container.isBoundNamed(Dn,r)&&(t[r]=e.container.getNamed(Dn,r)),t[r]||null}}})})),ho=function(){function e(){this.name="device-renderer",this.container=void 0}var t=e.prototype;return t.init=function(e){r.GlobalContainer.isBound(to)||r.GlobalContainer.register(to),this.container=e,e.load(fo,!0)},t.destroy=function(e){r.GlobalContainer.isBound(to)&&r.GlobalContainer.remove(to),e.unload(fo)},t.getDevice=function(){return this.container.get(Qi).getDevice()},t.loadTexture=function(e,t,r){return this.container.get(Qi).loadTexture(e,t,r)},e}(),po=Object.freeze({__proto__:null,get AntialiasingMode(){return mn},get Batch(){return wn},get BlendFactor(){return te},get BlendMode(){return re},get BufferFrequencyHint(){return ue},BufferGeometry:Wn,get BufferUsage(){return se},get ChannelWriteMask(){return he},get ClipSpaceNearZ(){return ve},get CompareMode(){return J},CopyProgram:so,get CullMode(){return ee},DeviceContribution:zi,DeviceProgram:mr,DynamicUniformBuffer:Tr,get Endianness(){return Ct},get FillMesh(){return Ti},Fog:Hi,get FogType(){return Vi},get Format(){return ye},get FormatCompFlags(){return me},get FormatFlags(){return Te},get FormatTypeFlags(){return ge},get FrontFaceMode(){return $},get GL(){return Ae},get GeometryEvent(){return Fn},HashMap:Or,IdentityViewportCoords:Ur,get ImageMesh(){return yi},get Instanced(){return Zn},get InstancedLineMesh(){return oi},IsDepthReversed:rt,get JOINT_TYPE(){return fi},Light:Wi,get LineMesh(){return Ei},Material:Vn,get MaterialEvent(){return kn},Mesh:eo,get MeshMesh(){return Bi},get MipFilterMode(){return oe},OpaqueBlack:$e,OpaqueWhite:tt,Plugin:ho,get PrimitiveTopology(){return ae},get QueryPoolType(){return Re},get RGAttachmentSlot(){return Lr},RenderCache:Fr,get RenderGraphPlugin(){return Qi},get RenderHelper(){return vn},RenderInst:dn,get RenderInstExecutionOrder(){return fn},get RenderInstFlags(){return un},RenderInstList:pn,RenderInstManager:En,Renderable3D:Z,get RendererLayer(){return Wr},get ResourceType(){return Q},get SDFMesh(){return ei},get SamplerFormatKind(){return _e},ShaderMaterial:Xn,SingleSampledTexture:kr,get StencilOp(){return pe},TemporalTexture:In,get TexFilterMode(){return ie},get TextMesh(){return Di},get TextUniform(){return xi},get TextureDimension(){return fe},get TextureEvent(){return ce},TextureMapping:On,get TexturePool(){return Nn},get TextureUsage(){return de},TransparentBlack:Je,TransparentWhite:et,UNIFORM_SETTERS:hr,get Uniform(){return _i},get VertexAttributeBufferIndex(){return Kn},get VertexAttributeLocation(){return jn},get VertexBufferFrequency(){return le},get ViewportOrigin(){return Ee},get WrapMode(){return ne},align:st,alignNonPowerOfTwo:ut,arrayCopy:Nt,arrayEqual:It,assert:Ke,assertExists:je,bindingLayoutDescriptorCopy:Kt,bindingLayoutDescriptorEqual:Dt,bindingLayoutSamplerDescriptorCopy:Yt,bindingsDescriptorCopy:Ht,bindingsDescriptorEquals:Bt,bisectRight:lt,bufferBindingCopy:Xt,colorCopy:qe,colorEqual:ze,colorNewCopy:Ze,colorNewFromRGBA:Qe,compareDefines:Yn,compareDepthValues:function(e,t,r,n){if(void 0===n&&(n=rt),(r=nt(r,n))===J.Less)return t>e;if(r===J.LessEqual)return t>=e;if(r===J.Greater)return e>t;if(r===J.GreaterEqual)return e>=t;throw Error("whoops")},containerModule:fo,copyAttachmentState:_t,copyAttachmentStateFromSimple:gt,copyMegaState:Rt,defaultBindingLayoutSamplerDescriptor:Ot,defaultMegaState:Tt,enumToObject:Hn,fallbackUndefined:it,fillArray:at,fillColor:function(e,t,r,n){return void 0===n&&(n=r.a),e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r,n){return void 0===n&&(n=0),e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:cn,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},fullscreenMegaState:At,getAttributeLocations:function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,n,i){var o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r},getDefines:function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""})),t},getFormatByteSize:function(e){return Xe(We(e))*ke(e)},getFormatCompByteSize:He,getFormatCompFlags:ke,getFormatCompFlagsComponentCount:we,getFormatComponentCount:function(e){return ke(e)},getFormatFlags:Ve,getFormatSamplerKind:Ye,getFormatTypeFlags:We,getFormatTypeFlagsByteSize:Xe,getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},getSystemEndianness:function(){return $t},getUniformSetter:function(e,t,r){var n=hr[r.type];if(!n)throw Error("Unknown GLSL uniform type "+r.type);return n().bind(null,e,t)},getUniforms:Er,hashCodeNumberFinish:Ar,hashCodeNumberUpdate:yr,inputLayoutBufferDescriptorCopy:qt,inputLayoutBufferDescriptorEquals:Gt,inputLayoutDescriptorCopy:Zt,inputLayoutDescriptorEquals:kt,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:ht,makeAttachmentClearDescriptor:gn,makeBackbufferDescSimple:Cn,makeDepthKey:Hr,makeFormat:Ge,makeMegaState:yt,makeSortKey:function(e,t){return void 0===t&&(t=0),e&Wr.TRANSLUCENT?qr(e):jr(e,t)},makeSortKeyOpaque:jr,makeSortKeyTranslucent:qr,makeStaticDataBuffer:Gn,makeTextureDescriptor2D:Ue,nArray:dt,nullHashFunc:Sr,nullify:ot,opaqueBlackFullClearRenderPassDescriptor:yn,opaqueWhiteFullClearRenderPassDescriptor:An,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(er);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name "+e);return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}},prependLineNo:function(e,t){return void 0===t&&(t=1),e.split("\n").map((function(e,r){return ht(""+(t+r),4," ")+" "+e})).join("\n")},preprocessProgramObj_GLSL:gr,preprocessProgram_GLSL:Rr,preprocessShader_GLSL:vr,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===ve.NegativeOne?function(e){rn(e,sn,e)}(e):t===ve.Zero&&function(e){rn(e,ln,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Lr.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(At),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);cn(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new lo,l=t.renderCache.createProgram(u);a.setProgram(l),ro||((ro=new Wn(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:le.PerVertex,attributes:[{format:ye.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),ro.vertexCount=3,io=t.getCache().createInputLayout(ro.inputLayoutDescriptor),no=t.getDevice().createInputState(io,ro.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,r){co[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(co),a.setInputLayoutAndState(io,no),a.drawOnPass(t.renderCache,e)}))}))},range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:hn,renderPipelineDescriptorCopy:jt,renderPipelineDescriptorEquals:Ut,reverseDepthForClearValue:function(e,t){return void 0===t&&(t=rt),t?1-e:e},reverseDepthForCompareMode:nt,reverseDepthForDepthOffset:function(e,t){return void 0===t&&(t=rt),t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e,t){void 0===t&&(t=rt),t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e,t){void 0===t&&(t=rt),t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:Vt,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:Wt,segmentInstanceGeometry:ni,setAttachmentStateSimple:St,setBackbufferDescSimple:Sn,setBitFlagEnabled:ft,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:vt,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=65536);var n=!!(e>>>31&1),i=Hr(t,n,r);return n?Zr(e,i):zr(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?Zr(e,t):zr(e,t)},setSortKeyLayer:Yr,setSortKeyOpaqueDepth:zr,setSortKeyProgramKey:Kr,setSortKeyTranslucentDepth:Zr,spliceBisectRight:ct,standardFullClearRenderPassDescriptor:Tn,updateBuffer:gi,vertexAttributeDescriptorCopy:zt,vertexAttributeDescriptorEquals:wt});function _o(){
|
|
5
|
+
se=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.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,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"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,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,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(A),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):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),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function ue(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function le(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){ue(o,n,i,a,s,"next",e)}function s(e){ue(o,n,i,a,s,"throw",e)}a(void 0)}))}}function ce(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function fe(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function he(e,t,r){return t&&fe(e.prototype,t),r&&fe(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function de(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pe(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&&ve(e,t)}function _e(e){return _e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_e(e)}function ve(e,t){return ve=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ve(e,t)}function Ee(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;o.length>n;n++)0>t.indexOf(r=o[n])&&(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;o.length>n;n++)0>t.indexOf(r=o[n])&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function ye(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ge(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return ye(e)}function me(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 r,n=_e(e);if(t){var i=_e(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return ge(this,r)}}function Re(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_e(e)););return e}function Te(){return Te="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=Re(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},Te.apply(this,arguments)}function Ae(e,t){return Oe(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||Ne(e,t)||Pe()}function Se(e){return Oe(e)||Ie(e)||Ne(e)||Pe()}function Ce(e){return function(e){if(Array.isArray(e))return xe(e)}(e)||Ie(e)||Ne(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 Oe(e){if(Array.isArray(e))return e}function Ie(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function Ne(e,t){if(e){if("string"==typeof e)return xe(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xe(e,t):void 0}}function xe(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function Pe(){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 De(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Ne(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},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(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var Be=he((function e(){ce(this,e),this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]}));Be.tag="c-renderable-3d";var Me,be,Le,Fe,Ue,we,ke,Ge,We,Ve,Xe,He,je,Ye,Ke,ze,qe,Ze,Qe,Je,$e,et,tt,rt,nt,it,ot,at=function(){function e(){ce(this,e),this.counter=0,this.id2DisplayObjectMap={}}return he(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=Ae(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 st(e,t,r,n){return{dimension:Ke.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:ze.Sampled}}function ut(e){return e}function lt(e,t,r){return e<<16|t<<8|r}function ct(e){return e>>>8&255}function ft(e){return e>>>16&255}function ht(e){return 255&e}function dt(e){switch(e){case tt.F32:case tt.U32:case tt.S32:return 4;case tt.U16:case tt.S16:case tt.F16:return 2;case tt.U8:case tt.S8:return 1;default:throw Error("whoops")}}function pt(e){return dt(ft(e))}function _t(e){var t=ht(e);if(t&nt.Depth)return Qe.Depth;if(t&nt.Normalized)return Qe.Float;var r=ft(e);if(r===tt.F16||r===tt.F32)return Qe.Float;if(r===tt.U8||r===tt.U16||r===tt.U32)return Qe.Uint;if(r===tt.S8||r===tt.S16||r===tt.S32)return Qe.Sint;throw Error("whoops")}function vt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e)throw console.error(Error().stack),Error("Assert fail: ".concat(t))}function Et(e){if(null!=e)return e;throw Error("Missing object")}function yt(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function gt(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function mt(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function Rt(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{r:e,g:t,b:r,a:n}}at=f([r.singleton()],at),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"}(Me||(Me={})),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"}(be||(be={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(Le||(Le={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(Fe||(Fe={})),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"}(Ue||(Ue={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(we||(we={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(ke||(ke={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(Ge||(Ge={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(We||(We={})),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"}(Ve||(Ve={})),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"}(Xe||(Xe={})),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"}(je||(je={})),function(e){e.LOADED="loaded"}(Ye||(Ye={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(Ke||(Ke={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(ze||(ze={})),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"}(qe||(qe={})),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"}(Ze||(Ze={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(Qe||(Qe={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(Je||(Je={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}($e||($e={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(et||(et={})),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"}(tt||(tt={})),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"}(rt||(rt={})),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"}(nt||(nt={})),function(e){e[e.ALPHA=lt(tt.U8,rt.A,nt.None)]="ALPHA",e[e.F16_R=lt(tt.F16,rt.R,nt.None)]="F16_R",e[e.F16_RG=lt(tt.F16,rt.RG,nt.None)]="F16_RG",e[e.F16_RGB=lt(tt.F16,rt.RGB,nt.None)]="F16_RGB",e[e.F16_RGBA=lt(tt.F16,rt.RGBA,nt.None)]="F16_RGBA",e[e.F32_R=lt(tt.F32,rt.R,nt.None)]="F32_R",e[e.F32_RG=lt(tt.F32,rt.RG,nt.None)]="F32_RG",e[e.F32_RGB=lt(tt.F32,rt.RGB,nt.None)]="F32_RGB",e[e.F32_RGBA=lt(tt.F32,rt.RGBA,nt.None)]="F32_RGBA",e[e.U8_R=lt(tt.U8,rt.R,nt.None)]="U8_R",e[e.U8_R_NORM=lt(tt.U8,rt.R,nt.Normalized)]="U8_R_NORM",e[e.U8_RG=lt(tt.U8,rt.RG,nt.None)]="U8_RG",e[e.U8_RG_NORM=lt(tt.U8,rt.RG,nt.Normalized)]="U8_RG_NORM",e[e.U8_RGB=lt(tt.U8,rt.RGB,nt.None)]="U8_RGB",e[e.U8_RGB_NORM=lt(tt.U8,rt.RGB,nt.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=lt(tt.U8,rt.RGB,nt.sRGB|nt.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=lt(tt.U8,rt.RGBA,nt.None)]="U8_RGBA",e[e.U8_RGBA_NORM=lt(tt.U8,rt.RGBA,nt.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=lt(tt.U8,rt.RGBA,nt.sRGB|nt.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=lt(tt.U16,rt.R,nt.None)]="U16_R",e[e.U16_R_NORM=lt(tt.U16,rt.R,nt.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=lt(tt.U16,rt.RG,nt.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=lt(tt.U16,rt.RGBA,nt.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=lt(tt.U16,rt.RGB,nt.None)]="U16_RGB",e[e.U32_R=lt(tt.U32,rt.R,nt.None)]="U32_R",e[e.U32_RG=lt(tt.U32,rt.RG,nt.None)]="U32_RG",e[e.S8_R=lt(tt.S8,rt.R,nt.None)]="S8_R",e[e.S8_R_NORM=lt(tt.S8,rt.R,nt.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=lt(tt.S8,rt.RG,nt.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=lt(tt.S8,rt.RGB,nt.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=lt(tt.S8,rt.RGBA,nt.Normalized)]="S8_RGBA_NORM",e[e.S16_R=lt(tt.S16,rt.R,nt.None)]="S16_R",e[e.S16_RG=lt(tt.S16,rt.RG,nt.None)]="S16_RG",e[e.S16_RG_NORM=lt(tt.S16,rt.RG,nt.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=lt(tt.S16,rt.RGB,nt.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=lt(tt.S16,rt.RGBA,nt.None)]="S16_RGBA",e[e.S16_RGBA_NORM=lt(tt.S16,rt.RGBA,nt.Normalized)]="S16_RGBA_NORM",e[e.S32_R=lt(tt.S32,rt.R,nt.None)]="S32_R",e[e.U16_RGBA_5551=lt(tt.U16_PACKED_5551,rt.RGBA,nt.Normalized)]="U16_RGBA_5551",e[e.BC1=lt(tt.BC1,rt.RGBA,nt.Normalized)]="BC1",e[e.BC1_SRGB=lt(tt.BC1,rt.RGBA,nt.Normalized|nt.sRGB)]="BC1_SRGB",e[e.BC2=lt(tt.BC2,rt.RGBA,nt.Normalized)]="BC2",e[e.BC2_SRGB=lt(tt.BC2,rt.RGBA,nt.Normalized|nt.sRGB)]="BC2_SRGB",e[e.BC3=lt(tt.BC3,rt.RGBA,nt.Normalized)]="BC3",e[e.BC3_SRGB=lt(tt.BC3,rt.RGBA,nt.Normalized|nt.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=lt(tt.BC4_UNORM,rt.R,nt.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=lt(tt.BC4_SNORM,rt.R,nt.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=lt(tt.BC5_UNORM,rt.RG,nt.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=lt(tt.BC5_SNORM,rt.RG,nt.Normalized)]="BC5_SNORM",e[e.D24=lt(tt.D24,rt.R,nt.Depth)]="D24",e[e.D24_S8=lt(tt.D24S8,rt.RG,nt.Depth|nt.Stencil)]="D24_S8",e[e.D32F=lt(tt.D32F,rt.R,nt.Depth)]="D32F",e[e.D32F_S8=lt(tt.D32FS8,rt.RG,nt.Depth|nt.Stencil)]="D32F_S8",e[e.U8_RGB_RT=lt(tt.U8,rt.RGB,nt.RenderTarget|nt.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=lt(tt.U8,rt.RGBA,nt.RenderTarget|nt.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=lt(tt.U8,rt.RGBA,nt.RenderTarget|nt.Normalized|nt.sRGB)]="U8_RGBA_RT_SRGB"}(it||(it={})),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"}(ot||(ot={}));var Tt=Rt(0,0,0,0),At=Rt(0,0,0,1),St=Rt(1,1,1,0),Ct=Rt(1,1,1,1),Ot=!0;function It(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot;if(!t)return e;switch(e){case be.Less:return be.Greater;case be.LessEqual:return be.GreaterEqual;case be.GreaterEqual:return be.LessEqual;case be.Greater:return be.Less;default:return e}}function Nt(e,t){return null!=e?e:t}function xt(e){return void 0===e?null:e}function Pt(e,t,r){e.length=t,e.fill(r)}function Dt(e,t){var r=t-1;return e+r&~r}function Bt(e,t){return((e+t-1)/t|0)*t}function Mt(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}function bt(e,t,r){var n=Mt(e,t,r);e.splice(n,0,t)}function Lt(e,t,r){return r?e|=t:e&=~t,e}function Ft(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function Ut(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0";t>e.length;)e="".concat(r).concat(e);return e}function wt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function kt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),wt(e.rgbBlendState,t.rgbBlendState),wt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Gt(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=kt(e[r],t[r])}function Wt(e,t){void 0!==t.attachmentsState&&Gt(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&>(e.blendConstant,t.blendConstant),e.depthCompare=Nt(t.depthCompare,e.depthCompare),e.depthWrite=Nt(t.depthWrite,e.depthWrite),e.stencilCompare=Nt(t.stencilCompare,e.stencilCompare),e.stencilWrite=Nt(t.stencilWrite,e.stencilWrite),e.stencilPassOp=Nt(t.stencilPassOp,e.stencilPassOp),e.stencilRef=Nt(t.stencilRef,e.stencilRef),e.cullMode=Nt(t.cullMode,e.cullMode),e.frontFace=Nt(t.frontFace,e.frontFace),e.polygonOffset=Nt(t.polygonOffset,e.polygonOffset)}function Vt(e){var t=Object.assign({},e);return t.attachmentsState=[],Gt(t.attachmentsState,e.attachmentsState),t.blendConstant=mt(t.blendConstant),t}function Xt(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 Ht={blendMode:we.Add,blendSrcFactor:Ue.One,blendDstFactor:Ue.Zero},jt={attachmentsState:[{channelWriteMask:qe.RGB,rgbBlendState:Ht,alphaBlendState:Ht}],blendConstant:mt(Tt),depthWrite:!0,depthCompare:be.LessEqual,stencilCompare:be.Always,stencilWrite:!1,stencilPassOp:Ze.Keep,stencilRef:0,cullMode:Fe.None,frontFace:Le.CCW,polygonOffset:!1};function Yt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jt,r=Vt(t);return null!==e&&Wt(r,e),r}var Kt=Yt({depthCompare:be.Always,depthWrite:!1},jt);function zt(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Gt(e.attachmentsState,jt.attachmentsState)),Xt(e.attachmentsState[0],t),e}var qt,Zt={formatKind:Qe.Float,dimension:Ke.n2D};function Qt(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function Jt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function $t(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function er(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function tr(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function rr(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!Qt(e.samplerBindings,t.samplerBindings,er)&&(!!Qt(e.uniformBufferBindings,t.uniformBufferBindings,$t)&&!!or(e.bindingLayout,t.bindingLayout)))}function nr(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function ir(e,t){return!!nr(e.rgbBlendState,t.rgbBlendState)&&(!!nr(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function or(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function ar(e,t){return e===t}function sr(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!Qt(e.attachmentsState,t.attachmentsState,ir)&&!!yt(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)&&(!!Qt(e.bindingLayouts,t.bindingLayouts,or)&&(!!Qt(e.colorAttachmentFormats,t.colorAttachmentFormats,ar)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function ur(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function lr(e,r){return t.isNil(e)?t.isNil(r):!t.isNil(r)&&(e.byteStride===r.byteStride&&e.frequency===r.frequency)}function cr(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Qt(e.vertexBufferDescriptors,t.vertexBufferDescriptors,lr)&&!!Qt(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,ur))}function fr(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 hr(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function dr(e){return{buffer:e.buffer,wordCount:e.wordCount}}function pr(e){return{bindingLayout:e.bindingLayout,samplerBindings:Jt(e.samplerBindings,hr),uniformBufferBindings:Jt(e.uniformBufferBindings,dr),pipeline:e.pipeline}}function _r(e){return{dimension:e.dimension,formatKind:e.formatKind}}function vr(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?Jt(e.samplerEntries,_r):void 0}}function Er(e){var t=Jt(e.bindingLayouts,vr),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:Vt(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function yr(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function gr(e){return t.isNil(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function mr(e){return{vertexAttributeDescriptors:Jt(e.vertexAttributeDescriptors,yr),vertexBufferDescriptors:Jt(e.vertexBufferDescriptors,gr),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(qt||(qt={}));var Rr,Tr=new Uint16Array([65279]),Ar=255==new DataView(Tr.buffer).getUint8(0)?qt.LITTLE_ENDIAN:qt.BIG_ENDIAN;var Sr=/([^[]*)(\[[0-9]+\])?/;function Cr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function Or(e,t,r,n){var i=null,o=null;return function(a,s,u){var l=t(u,r),c=l.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{vt(o===c,"Uniform length cannot change.");for(var h=0;c>h;++h)if(l[h]!==i[h]){f=!0;break}}return f&&(n(a,e,s,l),i.set(l)),f}}function Ir(e,t,r,n){e[t](r,n)}function Nr(e,t,r,n){e[t](r,!1,n)}var xr={},Pr={},Dr={},Br=[0];function Mr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Br[0]=e,e=Br);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function br(e,t){return Mr(e,t,Float32Array,xr)}function Lr(e,t){return Mr(e,t,Int32Array,Pr)}function Fr(e,t){return Mr(e,t,Uint32Array,Dr)}var Ur=(de(Rr={},ot.FLOAT,Or.bind(null,"uniform1fv",br,1,Ir)),de(Rr,ot.FLOAT_VEC2,Or.bind(null,"uniform2fv",br,2,Ir)),de(Rr,ot.FLOAT_VEC3,Or.bind(null,"uniform3fv",br,3,Ir)),de(Rr,ot.FLOAT_VEC4,Or.bind(null,"uniform4fv",br,4,Ir)),de(Rr,ot.INT,Or.bind(null,"uniform1iv",Lr,1,Ir)),de(Rr,ot.INT_VEC2,Or.bind(null,"uniform2iv",Lr,2,Ir)),de(Rr,ot.INT_VEC3,Or.bind(null,"uniform3iv",Lr,3,Ir)),de(Rr,ot.INT_VEC4,Or.bind(null,"uniform4iv",Lr,4,Ir)),de(Rr,ot.BOOL,Or.bind(null,"uniform1iv",Lr,1,Ir)),de(Rr,ot.BOOL_VEC2,Or.bind(null,"uniform2iv",Lr,2,Ir)),de(Rr,ot.BOOL_VEC3,Or.bind(null,"uniform3iv",Lr,3,Ir)),de(Rr,ot.BOOL_VEC4,Or.bind(null,"uniform4iv",Lr,4,Ir)),de(Rr,ot.FLOAT_MAT2,Or.bind(null,"uniformMatrix2fv",br,4,Nr)),de(Rr,ot.FLOAT_MAT3,Or.bind(null,"uniformMatrix3fv",br,9,Nr)),de(Rr,ot.FLOAT_MAT4,Or.bind(null,"uniformMatrix4fv",br,16,Nr)),de(Rr,ot.SAMPLER_2D,Cr),de(Rr,ot.SAMPLER_CUBE,Cr),de(Rr,ot.UNSIGNED_INT,Or.bind(null,"uniform1uiv",Fr,1,Ir)),de(Rr,ot.UNSIGNED_INT_VEC2,Or.bind(null,"uniform2uiv",Fr,2,Ir)),de(Rr,ot.UNSIGNED_INT_VEC3,Or.bind(null,"uniform3uiv",Fr,3,Ir)),de(Rr,ot.UNSIGNED_INT_VEC4,Or.bind(null,"uniform4uiv",Fr,4,Ir)),de(Rr,ot.FLOAT_MAT2x3,Or.bind(null,"uniformMatrix2x3fv",br,6,Nr)),de(Rr,ot.FLOAT_MAT2x4,Or.bind(null,"uniformMatrix2x4fv",br,8,Nr)),de(Rr,ot.FLOAT_MAT3x2,Or.bind(null,"uniformMatrix3x2fv",br,6,Nr)),de(Rr,ot.FLOAT_MAT3x4,Or.bind(null,"uniformMatrix3x4fv",br,12,Nr)),de(Rr,ot.FLOAT_MAT4x2,Or.bind(null,"uniformMatrix4x2fv",br,8,Nr)),de(Rr,ot.FLOAT_MAT4x3,Or.bind(null,"uniformMatrix4x3fv",br,12,Nr)),de(Rr,ot.SAMPLER_2D,Cr),de(Rr,ot.SAMPLER_CUBE,Cr),de(Rr,ot.SAMPLER_3D,Cr),de(Rr,ot.SAMPLER_2D_SHADOW,Cr),de(Rr,ot.SAMPLER_2D_ARRAY,Cr),de(Rr,ot.SAMPLER_2D_ARRAY_SHADOW,Cr),de(Rr,ot.SAMPLER_CUBE_SHADOW,Cr),de(Rr,ot.INT_SAMPLER_2D,Cr),de(Rr,ot.INT_SAMPLER_3D,Cr),de(Rr,ot.INT_SAMPLER_CUBE,Cr),de(Rr,ot.INT_SAMPLER_2D_ARRAY,Cr),de(Rr,ot.UNSIGNED_INT_SAMPLER_2D,Cr),de(Rr,ot.UNSIGNED_INT_SAMPLER_3D,Cr),de(Rr,ot.UNSIGNED_INT_SAMPLER_CUBE,Cr),de(Rr,ot.UNSIGNED_INT_SAMPLER_2D_ARRAY,Cr),Rr);var wr=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function kr(e,t){return"#define ".concat(e," ").concat(t)}function Gr(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().split("\n").forEach((function(e){var t=Ae(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,n){return n.trim().split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var u=function(e){s.uniforms.forEach((function(r){t.push("".concat(o,"[").concat(e,"].").concat(r.name))}))},l=0;5>l;l++)u(l);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}function Wr(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i="#version 100"===e.glslVersion,o=!1,a=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),s="";null!==n&&(s=Object.keys(n).map((function(e){return kr(e,n[e])})).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===Je.UpperLeft&&(c+="".concat(kr("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===$e.Zero&&(c+="".concat(kr("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var f=0,h=0,d=0;l=l.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(f,", binding = ").concat(h++,") uniform ").concat(n)})),f++,h=0,vt(e.separateSamplerTextures),l=(l=l.replace(/uniform sampler2D (.*);/g,(function(e,r){return"frag"===t?"\nlayout(set = ".concat(f,", binding = ").concat(h++,") uniform texture2D T_").concat(r,";\nlayout(set = ").concat(f,", binding = ").concat(h++,") uniform sampler S_").concat(r,";\n"):""}))).replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(d++,") ").concat(t)})),c+="".concat(kr("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 p="".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&&(p=p.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) ".concat(t)}))),i){if("frag"===t&&(p=p.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(p=(p=p.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"attribute ".concat(t," ").concat(r,";\n")}))),p=p.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 _,v=(p=p.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return _=r,"".concat(t," ").concat(r,";\n")}))).lastIndexOf("}");p=p.substring(0,v)+"\n gl_FragColor = vec4(".concat(_,");\n")+p.substring(v)}p=p.replace(/^\s*layout\((.*)\)/gm,"");var E,y=De(wr);try{for(y.s();!(E=y.n()).done;){var g=Ae(E.value,2),m=g[0],R=g[1];p=p.replace(m,R)}}catch(e){y.e(e)}finally{y.f()}}return p}function Vr(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=Wr(e,"vert",t,n,i),a=Wr(e,"frag",r,n,i);return{vert:t,frag:r,preprocessedVert:o,preprocessedFrag:a}}function Xr(e,t){var r=void 0!==t.defines?t.defines:null,n=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 Vr(e.queryVendorInfo(),i,o,r,n)}var Hr=function(){function e(){ce(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}return he(e,[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,r){if(null!==r){if(this.defines[e]===r)return!1;this.defines[e]=r}else{if(t.isNil(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return xt(this.defines[e])}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&vt("1"===t),null!==t}},{key:"ensurePreprocessed",value:function(e){""===this.preprocessedVert&&(this.preprocessedVert=Wr(e,"vert",this.both+this.vert,this.defines,this.features),this.preprocessedFrag=Wr(e,"frag",this.both+this.frag,this.defines,this.features))}}]),e}(),jr=function(){function e(t){ce(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 r=t.queryLimits();this.uniformBufferWordAlignment=r.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=r.uniformBufferMaxPageWordSize}return he(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){e=Bt(e,this.uniformBufferWordAlignment),vt(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=Bt(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 r=Bt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){vt(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=Bt(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(n,"]"))}}},{key:"mapBufferF32",value:function(){return Et(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=Et(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:Xe.UNIFORM|Xe.COPY_DST,hint:He.Dynamic}));var t=Bt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())Et(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 Yr(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function Kr(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function zr(e){return 0}var qr=he((function e(){ce(this,e),this.keys=[],this.values=[]})),Zr=function(){function e(t,r){ce(this,e),this.keyEqualFunc=void 0,this.keyHashFunc=void 0,this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=r}return he(e,[{key:"findBucketIndex",value:function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;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 r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]}},{key:"add",value:function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new qr);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,r=De(this.buckets.values());try{for(r.s();!(e=r.n()).done;){t+=e.value.values.length}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"values",value:se().mark((function e(){var t,r,n,i;return se().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=De(this.buckets.values()),e.prev=1,t.s();case 3:if((r=t.n()).done){e.next=14;break}i=(n=r.value).values.length-1;case 6:if(i<0){e.next=12;break}return e.next=9,n.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 Qr(e,t){return vt(""!==e.preprocessedVert&&""!==t.preprocessedVert),vt(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Jr(e,t){return e=Yr(e,t.numUniformBuffers),e=Yr(e,t.numSamplers)}function $r(e,t){return e=Yr(e,t.blendMode),e=Yr(e,t.blendSrcFactor),e=Yr(e,t.blendDstFactor)}function en(e,t){return e=$r(e,t.rgbBlendState),e=Yr(e=$r(e,t.alphaBlendState),t.channelWriteMask)}function tn(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=en(e,t.attachmentsState[r]);return e=function(e,t){return Yr(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Yr(e,t.depthCompare),e=Yr(e,t.depthWrite?1:0),e=Yr(e,t.stencilCompare),e=Yr(e,t.stencilPassOp),e=Yr(e,t.stencilWrite?1:0),e=Yr(e,t.cullMode),e=Yr(e,t.frontFace?1:0),e=Yr(e,t.polygonOffset?1:0)}function rn(e){var t=0;t=Yr(t,e.program.id),null!==e.inputLayout&&(t=Yr(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=Jr(t,e.bindingLayouts[r]);t=tn(t,e.megaStateDescriptor);for(var n=0;e.colorAttachmentFormats.length>n;n++)t=Yr(t,e.colorAttachmentFormats[n]||0);return Kr(t=Yr(t,e.depthStencilAttachmentFormat||0))}function nn(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=Yr(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=Yr(t,o.buffer.id),t=Yr(t,o.wordCount))}return Kr(t)}var on,an=function(){function e(t){ce(this,e),this.device=void 0,this.bindingsCache=new Zr(rr,nn),this.renderPipelinesCache=new Zr(sr,rn),this.inputLayoutsCache=new Zr(cr,zr),this.programCache=new Zr(Qr,zr),this.samplerCache=new Zr(fr,zr),this.device=t}return he(e,[{key:"createBindings",value:function(e){var t=this.bindingsCache.get(e);if(null===t){var r=pr(e);t=this.device.createBindings(r),this.bindingsCache.add(r,t)}return t}},{key:"createRenderPipeline",value:function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var r=Er(e);t=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,t)}return t}},{key:"createInputLayout",value:function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var r=mr(e);t=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,t)}return t}},{key:"createProgramSimple",value:function(e){var t,r=this.programCache.get(e);if(null===r){var n={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};r=this.device.createProgramSimple(n),this.programCache.add(n,r)}return r}},{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=De(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var r,n=De(this.renderPipelinesCache.values());try{for(n.s();!(r=n.n()).done;){r.value.destroy()}}catch(e){n.e(e)}finally{n.f()}var i,o=De(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=De(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=De(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"}(on||(on={}));var sn,un={x:0,y:0,w:1,h:1},ln=function(){function e(){ce(this,e),this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=un,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 he(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){vt(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){vt(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){vt(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}]),e}(),cn=function(){function e(t,r){ce(this,e),this.debugName=void 0,this.dimension=Ke.n2D,this.depth=1,this.numLevels=1,this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.usage=ze.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.attachment=void 0,this.age=0,this.pixelFormat=r.pixelFormat,this.width=r.width,this.height=r.height,this.sampleCount=r.sampleCount,vt(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))}return he(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){vt(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()}}]),e}(),fn=function(){function e(t,r){ce(this,e),this.dimension=Ke.n2D,this.depth=1,this.numLevels=1,this.usage=ze.RenderTarget,this.pixelFormat=void 0,this.width=0,this.height=0,this.texture=void 0,this.age=0,this.immutable=!0,this.pixelFormat=r.pixelFormat,this.width=r.width,this.height=r.height,this.texture=t.createTexture(this)}return he(e,[{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){vt(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}]),e}();sn=Symbol.species;var hn,dn=he((function e(){ce(this,e),this[sn]=void 0,this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]})),pn=function(){function e(t){ce(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 he(e,[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new cn(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new fn(this.device,e)}},{key:"beginGraphBuilder",value:function(){vt(null===this.currentGraph),this.currentGraph=new dn}},{key:"pushPass",value:function(e){var t=new ln;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 r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=Et(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return vt(void 0===t.resolveTextureOutputExternalTextures[r]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var r=this.findPassForResolveRenderTarget(e),n=r.renderTargetIDs.indexOf(e);vt(void 0===r.resolveTextureOutputIDs[n]),r.resolveTextureOutputExternalTextures[n]=t}},{key:"getRenderTargetDescription",value:function(e){return Et(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var o=t.resolveTextureInputIDs[i];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[o]]++}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if(vt(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var r=Et(this.renderTargetAliveForID[e]);return t?(vt(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(vt(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var r=e.resolveTextureRenderTargetIDs[t];vt(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=Et(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return Et(n.texture)}},{key:"determineResolveParam",value:function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;vt(!(a&&s));var u=null,l=!1;if(this.renderTargetOutputCount[n]>1&&(l=!0),a){vt(e.resolveTextureRenderTargetIDs[i]===n),vt(this.resolveTextureUseCount[i]>0),vt(this.renderTargetOutputCount[n]>0);var c=Et(this.renderTargetAliveForID[n]);if(null!==c.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=Et(e.renderTargetDescriptions[n]);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 r=t.renderTargetIDs[on.DepthStencil],n=on.Color0;on.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null;var a=this.determineResolveParam(e,t,n),s=a.store;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[on.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var l=this.determineResolveParam(e,t,on.DepthStencil),c=l.store;t.descriptor.depthStencilResolveTo=l.resolveTo,t.descriptor.depthStencilStore=c,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var f=0,h=0,d=0,p=0;t.renderTargets.length>p;p++){var _=t.renderTargets[p];_&&(0===f&&(f=_.width,h=_.height,d=_.sampleCount),vt(_.width===f),vt(_.height===h),vt(_.sampleCount===d),_.needsClear=!1)}if(f>0&&h>0){var v=h*t.viewport.y,E=f*t.viewport.w,y=h*t.viewport.h;t.viewportX=f*t.viewport.x,t.viewportY=v,t.viewportW=E,t.viewportH=y}for(var g=0;t.resolveTextureInputIDs.length>g;g++){t.resolveTextureInputTextures[g]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[g])}for(var m=0;t.renderTargetIDs.length>m;m++)this.releaseRenderTargetForID(t.renderTargetIDs[m],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)}},{key:"scheduleGraph",value:function(e){vt(0===this.renderTargetOutputCount.length),vt(0===this.renderTargetResolveCount.length),vt(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;Pt(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),Pt(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),Pt(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var o=0;this.renderTargetOutputCount.length>o;o++)vt(0===this.renderTargetOutputCount[o]);for(var a=0;this.renderTargetResolveCount.length>a;a++)vt(0===this.renderTargetResolveCount[a]);for(var s=0;this.resolveTextureUseCount.length>s;s++)vt(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)vt(void 0===this.renderTargetAliveForID[u]);for(var l=0;this.renderTargetDeadPool.length>l;l++)1>this.renderTargetDeadPool[l].age||(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;this.singleSampledTextureDeadPool.length>c;c++)1>this.singleSampledTextureDeadPool[c].age||(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){vt(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=Et(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,r=t.resolveTextureInputIDs.indexOf(e);return vt(r>=0),Et(t.resolveTextureInputTextures[r])}},{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;this.renderTargetAliveForID.length>e;e++)vt(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)vt(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].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"}(hn||(hn={}));var _n=65536;function vn(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_n,i=t.clamp(e,0,n)/n;r&&(i=1-i);var o=65535*i;return 65535&o}function En(e,t){return(16777215&e|(255&t)<<24)>>>0}function yn(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function gn(e,t){return En(yn(0,t),e)}function mn(e,t){return vt(t>=0),(4294967040&e|t>>>8&255)>>>0}function Rn(e){return En(0,e)}function Tn(e,t){return vt(t>=0),(4278190335&e|t<<8)>>>0}var An="undefined"!=typeof Float32Array?Float32Array:Array;function Sn(){var e=new An(16);return An!=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 Cn(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 On(e,t,r,n,i,o,a,s,u,l,c,f,h,d,p,_){var v=new An(16);return v[0]=e,v[1]=t,v[2]=r,v[3]=n,v[4]=i,v[5]=o,v[6]=a,v[7]=s,v[8]=u,v[9]=l,v[10]=c,v[11]=f,v[12]=h,v[13]=d,v[14]=p,v[15]=_,v}function In(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 Nn=function(e,t,r){var n=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],h=t[9],d=t[10],p=t[11],_=t[12],v=t[13],E=t[14],y=t[15],g=r[0],m=r[1],R=r[2],T=r[3];return e[0]=g*n+m*s+R*f+T*_,e[1]=g*i+m*u+R*h+T*v,e[2]=g*o+m*l+R*d+T*E,e[3]=g*a+m*c+R*p+T*y,e[4]=(g=r[4])*n+(m=r[5])*s+(R=r[6])*f+(T=r[7])*_,e[5]=g*i+m*u+R*h+T*v,e[6]=g*o+m*l+R*d+T*E,e[7]=g*a+m*c+R*p+T*y,e[8]=(g=r[8])*n+(m=r[9])*s+(R=r[10])*f+(T=r[11])*_,e[9]=g*i+m*u+R*h+T*v,e[10]=g*o+m*l+R*d+T*E,e[11]=g*a+m*c+R*p+T*y,e[12]=(g=r[12])*n+(m=r[13])*s+(R=r[14])*f+(T=r[15])*_,e[13]=g*i+m*u+R*h+T*v,e[14]=g*o+m*l+R*d+T*E,e[15]=g*a+m*c+R*p+T*y,e};function xn(e,t,r){var n=new An(3);return n[0]=e,n[1]=t,n[2]=r,n}var Pn,Dn;Pn=new An(3),An!=Float32Array&&(Pn[0]=0,Pn[1]=0,Pn[2]=0),Dn=Pn;!function(){var e=function(){var e=new An(2);return An!=Float32Array&&(e[0]=0,e[1]=0),e}()}();var Bn=On(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Mn,bn=On(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Ln(e,t,r){var n=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]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!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"}(Mn||(Mn={}));var Fn,Un=function(){function e(){ce(this,e),this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=Ft(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Ft(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:Vt(jt),program:null,topology:Ve.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return he(e,[{key:"reset",value:function(){this.sortKey=0,this.flags=Mn.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){Wt(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;e.renderPipelineDescriptor.colorAttachmentFormats.length>t;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=Ce(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~Mn.InheritedFlags|e.flags&Mn.InheritedFlags,this.sortKey=e.sortKey;var r=this.bindingDescriptors[0],n=e.bindingDescriptors[0];null!==n.bindingLayout&&this.setBindingLayout(n.bindingLayout);for(var i=0;Math.min(r.uniformBufferBindings.length,n.uniformBufferBindings.length)>i;i++)r.uniformBufferBindings[i].wordCount=e.bindingDescriptors[0].uniformBufferBindings[i].wordCount;this.setSamplerBindingsFromTextureMappings(n.samplerBindings);for(var o=0;e.dynamicUniformBufferByteOffsets.length>o;o++)this.dynamicUniformBufferByteOffsets[o]=e.dynamicUniformBufferByteOffsets[o]}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return Wt(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){vt(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers),this.renderPipelineDescriptor.bindingLayouts[0]=e,this.bindingDescriptors[0].bindingLayout=e;for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({buffer:null,wordCount:0});for(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})}},{key:"setBindingLayouts",value:function(e){vt(this.bindingDescriptors.length>=e.length),vt(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=Lt(this.flags,Mn.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=Lt(this.flags,Mn.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=Lt(this.flags,Mn.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 r=0,n=[];t.forEach((function(e){var t=e.value,i="number"==typeof t?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,Ce(i))}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)a+=Ln(s,a,n[u],n[u+1],n[u+2],n[u+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){return vt(this.dynamicUniformBufferByteOffsets.length>this.bindingDescriptors[0].bindingLayout.numUniformBuffers),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,r){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=r}},{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;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler,r.lateBinding=n.lateBinding):(r.texture=null,r.sampler=null,r.lateBinding=null)}}},{key:"hasLateSamplerBinding",value:function(e){for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){if(this.bindingDescriptors[0].samplerBindings[t].lateBinding===e)return!0}return!1}},{key:"resolveLateSamplerBinding",value:function(e,t){for(var r=0;this.bindingDescriptors[0].samplerBindings.length>r;r++){var n=this.bindingDescriptors[0].samplerBindings[r];n.lateBinding===e&&(null===t?(n.texture=null,n.sampler=null):(vt(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=Lt(this.flags,Mn.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value:function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.pixelFormat:null,null!==o&&(-1===n?n=o.sampleCount:vt(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.pixelFormat:null,null!==a&&(-1===n?n=a.sampleCount:vt(n==a.sampleCount)),vt(n>0),this.renderPipelineDescriptor.sampleCount=n}},{key:"drawOnPass",value:function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&Mn.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setInputState(this.inputState);for(var o=0;this.bindingDescriptors[0].uniformBufferBindings.length>o;o++)this.bindingDescriptors[0].uniformBufferBindings[o].buffer=Et(this.uniformBuffer.buffer);this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniforms(t)}));var a=e.createBindings(ae(ae({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(vt(!!(this.flags&Mn.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&Mn.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0}}]),e}();function wn(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(Fn||(Fn={}));var kn=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wn,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Fn.Forwards;ce(this,e),this.renderInsts=[],this.compareFunction=void 0,this.executionOrder=void 0,this.usePostSort=!1,this.compareFunction=t,this.executionOrder=r}return he(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):bt(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Mn.Draw,this.insertSorted(e)}},{key:"hasLateSamplerBinding",value:function(e){for(var t=0;this.renderInsts.length>t;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1}},{key:"resolveLateSamplerBinding",value:function(e,t){for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].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 r=0;if(this.executionOrder===Fn.Forwards)for(var n=0;this.renderInsts.length>n;n++)this.renderInsts[n].drawOnPass(e,t)&&r++;else for(var i=this.renderInsts.length-1;i>=0;i--)this.renderInsts[i].drawOnPass(e,t)&&r++;return r}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}]),e}(),Gn=function(){function e(){ce(this,e),this.pool=[],this.allocCount=0}return he(e,[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new Un),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}]),e}(),Wn=function(){function e(t){ce(this,e),this.renderCache=void 0,this.instPool=new Gn,this.templatePool=new Gn,this.simpleRenderInstList=new kn,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t}return he(e,[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r}},{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){vt(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=Mn.Template,r}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){return this.templatePool.pool[this.templatePool.allocCount-1]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),vt(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){Et(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){Et(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}]),e}(),Vn=function(){function e(){ce(this,e),this.renderCache=void 0,this.renderGraph=void 0,this.renderInstManager=void 0,this.uniformBuffer=void 0,this.device=void 0}return he(e,[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new an(e),this.renderGraph=new pn(this.device),this.renderInstManager=new Wn(this.renderCache),this.uniformBuffer=new jr(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}();Vn=f([r.singleton()],Vn);var Xn=function(){function e(t){ce(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 he(e,[{key:"setDimensions",value:function(e,t,r){this.width=e,this.height=t,this.sampleCount=r}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}]),e}();function Hn(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var jn,Yn=Hn(Rt(.88,.88,.88,1)),Kn=Hn(At),zn=Hn(Ct);function qn(e,t){var r=function(e){return e.antialiasingMode===jn.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function Zn(e,t,r){var n=function(e){if(e===on.Color0)return it.U8_RGBA_RT;if(e===on.DepthStencil)return it.D24_S8;throw Error("whoops")}(e),i=new Xn(n);return qn(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(jn||(jn={}));var Qn=function(){function e(){ce(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 he(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}(),Jn=function(){function e(){ce(this,e),this.inputTexture=null,this.outputTexture=null}return he(e,[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),vt(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new fn(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}(),$n=function(){function e(){ce(this,e),this.offscreenCanvas=void 0,this.renderingService=void 0,this.canvasConfig=void 0,this.textureCache={},this.gradientCache={}}return he(e,[{key:"getOrCreateTexture",value:function(e,r,n,i){var o=this,a="string"==typeof r?r:r.src||"";if(this.textureCache[a])this.textureCache[a].emit(Ye.LOADED);else if(this.textureCache[a]=e.createTexture(ae({pixelFormat:it.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:Ke.n2D,usage:ze.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),"string"!=typeof r)this.textureCache[a].setImageData(r),this.textureCache[a].emit(Ye.LOADED),this.renderingService.dirtify();else{var s,u=this.canvasConfig.createImage;u?s=u(r):t.isBrowser&&(s=new window.Image),s&&(s.onload=function(){o.textureCache[a].setImageData(s),o.textureCache[a].emit(Ye.LOADED),o.renderingService.dirtify(),i&&i(o.textureCache[a])},s.onerror=function(){},s.crossOrigin="Anonymous",s.src=r)}return this.textureCache[a]}},{key:"getOrCreateCanvas",value:function(){return this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var r=this.generateCacheKey(e),n=e.type,i=e.x0,o=e.y0,a=e.x1,s=e.y1,u=e.steps,l=e.width,c=e.height,f=this.gradientCache[r],h=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),d=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);if(!f){if(h.width=l,h.height=c,n===t.GradientPatternType.LinearGradient)f=d.createLinearGradient(i*l,o*c,a*l,s*c);else if(n===t.GradientPatternType.RadialGradient){f=d.createRadialGradient(i*l,o*c,0,a*l,s*c,e.r1*(Math.sqrt(l*l+c*c)/2))}u.forEach((function(e){var t,r=Ae(e,2),n=r[1];null===(t=f)||void 0===t||t.addColorStop(Number(r[0]),n)})),this.gradientCache[r]=f}h.src=r,f&&(d.fillStyle=f,d.fillRect(0,0,l,c))}},{key:"generateCacheKey",value:function(e){var t=e.x0,r=e.y0,n=e.x1,i=e.y1,o=e.r1,a=e.steps,s=e.width,u=e.height;return"gradient-".concat(e.type,"-").concat(t,"-").concat(r,"-").concat(n,"-").concat(i,"-").concat(o||0,"-").concat(s,"-").concat(u,"-").concat(a.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}();f([r.inject(t.OffscreenCanvasCreator),h("design:type",t.OffscreenCanvasCreator)],$n.prototype,"offscreenCanvas",void 0),f([r.inject(t.RenderingService),h("design:type",t.RenderingService)],$n.prototype,"renderingService",void 0),f([r.inject(t.CanvasConfig),h("design:type",Object)],$n.prototype,"canvasConfig",void 0),$n=f([r.singleton()],$n);var ei=function(){function e(){ce(this,e),this.lights=[],this.fog=void 0}return he(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}();ei=f([r.singleton()],ei);var ti=r.Syringe.defineToken("RendererFactory"),ri=r.Syringe.defineToken("ShapeRenderer"),ni=r.Syringe.defineToken("MeshFactory"),ii=1,oi=function(){function e(){ce(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 he(e,[{key:"render",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r||this.updatePendingPatches(),this.meshes.forEach((function(n){n.init(t.device,t.renderingService);var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=t.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),t.renderHelper.renderInstManager.submitRenderInst(o,e),r||n.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,r=e.renderable3D;if(r&&!r.meshes.length){var n=this.rendererFactory(e.nodeName);n&&n.meshes.forEach((function(i,o){if(r.meshes[o]=void 0,n.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=n,a.index=o,t.meshes.push(a)),a&&(a.objects.push(e),r.meshes[o]=a,a.geometryDirty=!0)}}))}}},{key:"remove",value:function(e){var t=this,r=e.renderable3D;r&&(r.meshes.forEach((function(r){if(r){var n=r.objects.indexOf(e);n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length&&t.meshes.splice(t.meshes.indexOf(r),1)}})),r.meshes=[])}},{key:"updateAttribute",value:function(e,t,r){var n=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&&n.meshes.splice(n.meshes.indexOf(c),1),o.meshes[o.meshes.indexOf(c)]=void 0),l&&((c=n.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))||((c=n.meshFactory(s)).renderer=a,c.index=u,c.init(n.device,n.renderingService),n.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]=r,c.updateAttribute([e],f,t,r);else{var h=c.id+t;n.pendingUpdatePatches[h]||(n.pendingUpdatePatches[h]={instance:c,objectIndices:[],name:t,value:r}),-1===n.pendingUpdatePatches[h].objectIndices.indexOf(f)&&n.pendingUpdatePatches[h].objectIndices.push(f)}}}))}},{key:"changeRenderOrder",value:function(e,t){var r=e.renderable3D;r&&r.meshes.length&&r.meshes.forEach((function(r){r&&r.inited&&!r.geometryDirty&&(r.renderer.shouldSubmitRenderInst(e,r.index)&&r.inited&&r.changeRenderOrder(e,t))}))}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=ii++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}}}]),e}();f([r.inject(Vn),h("design:type",Vn)],oi.prototype,"renderHelper",void 0),f([r.inject(ti),h("design:type",Function)],oi.prototype,"rendererFactory",void 0),f([r.inject(ni),h("design:type",Function)],oi.prototype,"meshFactory",void 0),oi=f([r.singleton()],oi);var ai,si=.005,ui=1,li=function(){function e(){ce(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=ui++,this.meshes=[],this.clipPathMeshCreated=!1}return he(e,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}},{key:"beforeUploadUBO",value:function(e,t,r){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}]),e}();function ci(e,t,r){var n=e.createBuffer({viewOrSize:Dt(r.byteLength,4)/4,usage:t,hint:He.Static});return n.setSubData(0,new Uint8Array(r)),n}f([r.inject(Vn),h("design:type",Vn)],li.prototype,"renderHelper",void 0),f([r.inject($n),h("design:type",$n)],li.prototype,"texturePool",void 0),f([r.inject(t.DefaultCamera),h("design:type",t.Camera)],li.prototype,"camera",void 0),f([r.inject(ei),h("design:type",ei)],li.prototype,"lightPool",void 0),f([r.inject(oi),h("design:type",oi)],li.prototype,"batchManager",void 0),li=f([r.injectable()],li),function(e){e.CHANGED="changed"}(ai||(ai={}));var fi,hi=function(e){pe(n,e);var r=me(n);function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ce(this,n),(t=r.call(this)).device=void 0,t.props=void 0,t.drawMode=Ve.Triangles,t.vertexBuffers=[],t.vertices=[],t.indexBuffer=void 0,t.indices=void 0,t.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:it.U32_R},t.vertexCount=0,t.instancedCount=0,t.indexStart=0,t.primitiveStart=0,t.dirty=!0,t.meshes=[],t.device=e,t.props=i,t}return he(n,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new t.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=ci(this.device,Xe.INDEX|Xe.COPY_DST,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this}},{key:"setVertexBuffer",value:function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={byteStride:e.byteStride,frequency:e.frequency},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=e.byteStride,u=t.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===r&&e.location===o}));u?(u.format=n,u.bufferByteOffset=i,u.byteStride=s,u.divisor=a):t.inputLayoutDescriptor.vertexAttributeDescriptors.push({format:n,bufferIndex:r,bufferByteOffset:i,location:o,byteStride:s,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=ci(this.device,Xe.VERTEX|Xe.COPY_DST,i.buffer);return this.vertexBuffers[r]=o,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value:function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e].byteStride,o=this.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.location===t}));o&&this.getVertexBuffer(e).setSubData(o.bufferByteOffset+r*i,n);this.emit(ai.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}(O.EventEmitter);!function(e){e.CHANGED="changed"}(fi||(fi={}));var di=function(e){pe(n,e);var r=me(n);function n(e,t){var i;ce(this,n),(i=r.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=Vt(jt),a=o.cullMode,s=o.depthCompare,u=o.depthWrite,l=o.stencilCompare,c=o.stencilWrite,f=o.stencilPassOp,h=o.frontFace,d=o.polygonOffset,p=o.attachmentsState;return i.device=e,i.props=ae({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilCompare:l,stencilWrite:c,stencilPassOp:f,frontFace:h,polygonOffset:d,attachmentsState:p,blendEquation:we.Add,blendEquationAlpha:we.Add,blendSrc:Ue.SrcAlpha,blendDst:Ue.OneMinusSrcAlpha,blendSrcAlpha:Ue.Zero,blendDstAlpha:Ue.One,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},t),i.compile(),i}return he(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,r){return e.samplers.push(r),""})),this.uniformNames=Gr(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var r=this,n=!1;Object.keys(e).forEach((function(i){var o,a=e[i],s=r.textures[i];s&&s!==a&&(r.textureDirty=!0),(o=a)&&o.type?(r.textures[i]=a,r.textureDirty=!0,a.on(Ye.LOADED,(function(){r.dispatchMutationEvent()}))):(r.uniforms[i]=a,n=!0),t.isNil(e[i])&&(delete r.textures[i],delete r.uniforms[i])})),n&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(fi.CHANGED)}}]),n}(O.EventEmitter),pi=function(e){pe(r,e);var t=me(r);function r(e,n){var i;return ce(this,r),(i=t.call(this,e,ae({},n))).defines=ae(ae({},i.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),i}return he(r)}(di);function _i(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function vi(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Ei,yi,gi=1,mi="FillTextureMapping";!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"}(Ei||(Ei={})),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"}(yi||(yi={}));var Ri=function(){function e(){ce(this,e),this.id=gi++,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 Hr,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1}return he(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 pi(this.device),this.material.defines=ae(ae({},_i(yi)),this.material.defines),this.geometry=new hi(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(ai.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(fi.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 r=this,n=Sn(),i=Sn(),o=[],a=[],s=[],u=[];e.forEach((function(e){var l,c=e.parsedStyle,f=c.fill,h=c.stroke,d=c.opacity,p=c.fillOpacity,_=c.strokeOpacity,v=c.lineWidth,E=c.anchor,y=c.visibility,g=c.increasedLineWidthForHitTesting,m=[0,0,0,0];f instanceof t.CSSRGB&&(m=[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255,Number(f.alpha)]);var R=[0,0,0,0];h instanceof t.CSSRGB&&(R=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]),r.clipPathTarget?(Cn(n,e.getLocalTransform()),m=[1,1,1,1],Nn(n,r.clipPathTarget.getWorldTransform(),n)):Cn(n,e.getWorldTransform()),Nn(i,r.camera.getViewTransform(),n);var T=e.isInteractive()&&(null===(l=e.renderable3D)||void 0===l?void 0:l.encodedPickingColor)||[0,0,0];o.push.apply(o,Ce(n)),a.push.apply(a,Ce(m).concat(Ce(R))),s.push(d.value,p.value,_.value,v.value,"visible"===y.value?1:0,E[0].value,E[1].value,(null==g?void 0:g.value)||0),u.push.apply(u,Ce(T).concat([e.sortable.renderOrder*si]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Ei.MODEL_MATRIX,byteStride:64,frequency:je.PerInstance,attributes:[{format:it.F32_RGBA,bufferByteOffset:0,location:yi.MODEL_MATRIX0,divisor:1},{format:it.F32_RGBA,bufferByteOffset:16,location:yi.MODEL_MATRIX1,divisor:1},{format:it.F32_RGBA,bufferByteOffset:32,location:yi.MODEL_MATRIX2,divisor:1},{format:it.F32_RGBA,bufferByteOffset:48,location:yi.MODEL_MATRIX3,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Ei.FILL_STROKE,byteStride:32,frequency:je.PerInstance,attributes:[{format:it.F32_RGBA,bufferByteOffset:0,location:yi.COLOR,divisor:1},{format:it.F32_RGBA,bufferByteOffset:16,location:yi.STROKE_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Ei.PACKED_STYLE,byteStride:32,frequency:je.PerInstance,attributes:[{format:it.F32_RGBA,bufferByteOffset:0,location:yi.PACKED_STYLE1,divisor:1},{format:it.F32_RGBA,bufferByteOffset:16,location:yi.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Ei.PICKING_COLOR,byteStride:16,frequency:je.PerInstance,attributes:[{format:it.F32_RGBA,bufferByteOffset:0,location:yi.PICKING_COLOR,divisor:1}],data:new Float32Array(u)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()}},{key:"applyRenderInst",value:function(e,t){var r=this,n=this.lightPool.getAllLights(),i=!!this.lightPool.getFog(),o=!!n.length,a=ae({},this.material.defines);if(this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=ae(ae({},this.material.defines),this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=be.Always,this.material.stencilPassOp=Ze.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=be.Equal,this.material.stencilPassOp=Ze.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 r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new Qn;t.name=e,t.texture=r.material.textures[e],r.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:ke.Clamp,wrapT:ke.Clamp,minFilter:Ge.Point,magFilter:Ge.Bilinear,mipFilter:We.Linear,minLOD:0,maxLOD:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(vi(a,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=ae(ae({},this.material.defines),_i(yi)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"number"==typeof t?r.program.setDefineString(e,"".concat(t)):r.program.setDefineBool(e,t)})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.programDescriptorSimpleWithOrig=Xr(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=gn(hn.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value:function(e,r,n,i){if("fill"===n||"stroke"===n){var o=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=[0,0,0,0];n instanceof t.CSSRGB&&(a=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]);var s=[0,0,0,0];i instanceof t.CSSRGB&&(s=[Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)]),o.push.apply(o,Ce(a).concat(Ce(s)))})),this.geometry.updateVertexBuffer(Ei.FILL_STROKE,yi.COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===mi}));if(a instanceof t.CSSRGB)0>s||(this.textureMappings.splice(s,-1),this.material.textureDirty=!0);else{var u=this.createFillGradientTextureMapping([this.instance]);0>s||this.textureMappings.splice(s,1,u),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var l=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor,n=t.increasedLineWidthForHitTesting;l.push(t.opacity.value,t.fillOpacity.value,t.strokeOpacity.value,t.lineWidth.value,"visible"===t.visibility.value?1:0,r[0].value,r[1].value,(null==n?void 0:n.value)||0)})),this.geometry.updateVertexBuffer(Ei.PACKED_STYLE,yi.PACKED_STYLE1,r,new Uint8Array(new Float32Array(l).buffer))}else if("modelMatrix"===n){var c=[];e.forEach((function(e){var t=Cn(Sn(),e.getWorldTransform());c.push.apply(c,Ce(t))})),this.geometry.updateVertexBuffer(Ei.MODEL_MATRIX,yi.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(c).buffer))}else if("pointerEvents"===n){var f=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];f.push.apply(f,Ce(r).concat([e.sortable.renderOrder*si]))})),this.geometry.updateVertexBuffer(Ei.PICKING_COLOR,yi.PICKING_COLOR,r,new Uint8Array(new Float32Array(f).buffer))}}},{key:"updateAttribute",value:function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)}},{key:"changeRenderOrder",value:function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Ei.PICKING_COLOR,yi.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(Ce(i),[t*si])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Ei.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride/4*r)}for(var o=0,a=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],l=1;e.vertices.length>l;l++)for(var c=e.inputLayoutDescriptor.vertexBufferDescriptors[l].byteStride/4,f=0;c>f;f++)e.vertices[l][o*c+f]=n[l][u*c+f];a[s]=o,o++}for(var h=function(t){var r=e.inputLayoutDescriptor.vertexBufferDescriptors[t],n=r.frequency,i=r.byteStride,o=e.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===t}));o&&e.setVertexBuffer({bufferIndex:o.bufferIndex,byteStride:i,frequency:n,attributes:[{format:o.format,bufferByteOffset:o.bufferByteOffset,location:o.location,divisor:o.divisor}],data:e.vertices[t]})},d=Ei.PICKING_COLOR+1;e.vertexBuffers.length>d;d++)h(d);for(var p=new Float32Array(3*r),_=0;r>_;)for(var v=0;3>v;v++){p[3*a[_++]+v]=1}e.setVertexBuffer({bufferIndex:Ei.BARYCENTRIC,byteStride:12,frequency:je.PerVertex,attributes:[{format:it.F32_RGB,bufferByteOffset:0,location:Number(yi.BARYCENTRIC)}],data:p}),e.setIndexBuffer(a)}},{key:"beforeUploadUBO",value:function(e,t,r){}},{key:"uploadUBO",value:function(e){var r=this,n=this.material,i=this.lightPool.getAllLights(),o=this.lightPool.getFog(),a=!!o,s=!!i.length,u=[];if(n.defines.USE_WIREFRAME){var l=t.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(a&&this.uploadFog(u,o),this.uploadMaterial(u,n),s){var c={};i.forEach((function(e){c[e.define]||(c[e.define]=-1),c[e.define]++,e.uploadUBO(u,c[e.define])}))}u.sort((function(e,t){return r.material.uniformNames.indexOf(e.name)-r.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,u),e.setMegaStateFlags({attachmentsState:[{channelWriteMask:this.material.stencilWrite?qe.None:qe.AllChannels,rgbBlendState:{blendMode:n.blendEquation,blendSrcFactor:n.blendSrc,blendDstFactor:n.blendDst},alphaBlendState:{blendMode:n.blendEquationAlpha,blendSrcFactor:n.blendSrcAlpha,blendDstFactor:n.blendDstAlpha}}],depthCompare:n.depthCompare,depthWrite:n.depthWrite,stencilCompare:n.stencilCompare,stencilWrite:n.stencilWrite,stencilPassOp:n.stencilPassOp,stencilRef:n.stencilRef,cullMode:n.cullMode,frontFace:n.frontFace,polygonOffset:n.polygonOffset}),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,u=n.density;if(o instanceof t.CSSRGB){var l=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,u]}),e.push({name:"u_FogColor",value:l})}}},{key:"uploadMaterial",value:function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,Ce(r))}},{key:"createFillGradientTextureMapping",value:function(e){var r=e[0],n=r.nodeName===t.Shape.LINE?r.parsedStyle.stroke:r.parsedStyle.fill;if(n&&n instanceof t.CSSGradientValue){var i;n.type===t.GradientPatternType.LinearGradient||n.type===t.GradientPatternType.RadialGradient?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient(ae(ae({type:n.type},n.value),{},{width:128,height:128})),i=this.texturePool.getOrCreateCanvas()):(this.program.setDefineBool("USE_PATTERN",!0),i=n.value.src);var o=new Qn;return o.name=mi,o.texture=this.texturePool.getOrCreateTexture(this.device,i,st(it.U8_RGBA_NORM,1,1,1)),o.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0}))})),this.device.setResourceName(o.texture,"Fill Texture"+this.id),o.sampler=this.renderHelper.getCache().createSampler({wrapS:ke.Repeat,wrapT:ke.Repeat,minFilter:Ge.Point,magFilter:Ge.Bilinear,mipFilter:We.Linear,minLOD:0,maxLOD:0}),o}return null}}]),e}();f([r.inject(Vn),h("design:type",Vn)],Ri.prototype,"renderHelper",void 0),f([r.inject($n),h("design:type",$n)],Ri.prototype,"texturePool",void 0),f([r.inject(t.DefaultCamera),h("design:type",t.Camera)],Ri.prototype,"camera",void 0),f([r.inject(ei),h("design:type",ei)],Ri.prototype,"lightPool",void 0),Ri=f([r.injectable()],Ri);var Ti,Ai;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(Ti||(Ti={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(Ai||(Ai={}));var Si=[t.Shape.CIRCLE,t.Shape.ELLIPSE],Ci=function(e){pe(n,e);var r=me(n);function n(){return ce(this,n),r.apply(this,arguments)}return he(n,[{key:"shouldMerge",value:function(e,t){var r=Te(_e(n.prototype),"shouldMerge",this).call(this,e,t);return!!r&&(!this.needDrawStrokeSeparately(e.parsedStyle)&&!this.needDrawStrokeSeparately(this.instance.parsedStyle)&&this.instance.parsedStyle.fill.isNone===e.parsedStyle.fill.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.000001;\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=ae(ae({},this.material.defines),_i(Ai))}},{key:"createGeometry",value:function(e){var t=this;Te(_e(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,Ce(c).concat([Si.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:Ei.POSITION,byteStride:16,frequency:je.PerVertex,attributes:[{format:it.F32_RG,bufferByteOffset:0,location:yi.POSITION},{format:it.F32_RG,bufferByteOffset:8,location:yi.UV}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Ti.PACKED_STYLE,byteStride:24,frequency:je.PerInstance,attributes:[{format:it.F32_RG,bufferByteOffset:0,location:Ai.SIZE,divisor:1},{format:it.F32_RGBA,bufferByteOffset:8,location:Ai.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(Te(_e(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=o.shouldOmitStroke(e.parsedStyle),r=Ae(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,[r[0],r[1]].concat([Si.indexOf(e.nodeName),e.parsedStyle.radius||0,t?1:0,0]))})),this.geometry.updateVertexBuffer(Ti.PACKED_STYLE,Ai.SIZE,t,new Uint8Array(new Float32Array(a).buffer))}}},{key:"getSize",value:function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i.value,i.value]}else if(r===t.Shape.ELLIPSE){n=[e.rx.value,e.ry.value]}return n}},{key:"shouldOmitStroke",value:function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e.value}));return!i||i&&(o||1>n.value)}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.stroke,r=e.lineDash,n=e.lineWidth,i=e.strokeOpacity,o=t&&!t.isNone,a=r&&r.length&&r.every((function(e){return 0!==e.value}));return o&&n.value>0&&(a||1>i.value)}}]),n}(Ri);Ci=f([r.injectable()],Ci);var Oi,Ii,Ni=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(Oi||(Oi={})),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"}(Ii||(Ii={}));var xi={butt:1,round:2,square:3},Pi=function(e){pe(n,e);var r=me(n);function n(){return ce(this,n),r.apply(this,arguments)}return he(n,[{key:"shouldMerge",value:function(e,r){var i=Te(_e(n.prototype),"shouldMerge",this).call(this,e,r);if(!i)return!1;var o=this.instance;if(o.nodeName===t.Shape.LINE&&""+o.parsedStyle.stroke!=""+e.parsedStyle.stroke)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=ae(ae({},this.material.defines),_i(Ii))}},{key:"createGeometry",value:function(e){var t=this;Te(_e(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,h=n.z1,d=n.z2,p=n.defX,_=n.defY,v=n.lineCap,E=n.isBillboard,y=t.calcDash(e),g=y.dashOffset,m=y.dashSegmentPercent,R=y.dashRatioInEachSegment;i.push(xi[v.value]),o.push(g,m,R,E?1:0),r.push(u.value-p,l.value-_,h.value,c.value-p,f.value-_,d.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:Ei.POSITION,byteStride:20,frequency:je.PerInstance,attributes:[{format:it.F32_RGB,bufferByteOffset:0,location:Ii.POSITION,divisor:0},{format:it.F32_RG,bufferByteOffset:12,location:Ii.UV,divisor:0}],data:new Float32Array(Ni)}),this.geometry.setVertexBuffer({bufferIndex:Oi.POINT,byteStride:24,frequency:je.PerInstance,attributes:[{format:it.F32_RGB,bufferByteOffset:0,location:Ii.POINTA,divisor:1},{format:it.F32_RGB,bufferByteOffset:12,location:Ii.POINTB,divisor:1}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Oi.CAP,byteStride:4,frequency:je.PerInstance,attributes:[{format:it.F32_R,bufferByteOffset:0,location:Ii.CAP,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Oi.DASH,byteStride:16,frequency:je.PerInstance,attributes:[{format:it.F32_RGBA,bufferByteOffset:0,location:Ii.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(Te(_e(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,r=t.defX,n=t.defY;a.push(t.x1.value-r,t.y1.value-n,t.z1.value,t.x2.value-r,t.y2.value-n,t.z2.value)})),this.geometry.updateVertexBuffer(Oi.POINT,Ii.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);s.push(t.dashOffset,t.dashSegmentPercent,t.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Oi.DASH,Ii.DASH,t,new Uint8Array(new Float32Array(s).buffer))}else if("lineCap"===r){var u=[];e.forEach((function(e){u.push(xi[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Oi.CAP,Ii.CAP,t,new Uint8Array(new Float32Array(u).buffer))}}},{key:"calcDash",value:function(e){var t=e.parsedStyle,r=t.lineDash,n=t.lineDashOffset,i=e.getTotalLength(),o=0,a=1,s=0;if(r&&r.length){o=(n&&n.value||0)/i;var u=r.reduce((function(e,t){return e+t.value}),0);a=u/i,s=r[1].value/u}return{dashOffset:o,dashSegmentPercent:a,dashRatioInEachSegment:s}}}]),n}(Ri);function Di(e){return function(e){if(Array.isArray(e))return Bi(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Bi(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Bi(e,t)}(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 Bi(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function Mi(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}Pi=f([r.injectable()],Pi);var bi=function(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}};function Li(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function Fi(e,t,r,n,i,o,a,s,u){var l=Li(e,r,i,a,u),c=Li(t,n,o,s,u),f=bi(e,t,r,n,u),h=bi(r,n,i,o,u),d=bi(i,o,a,s,u),p=bi(f.x,f.y,h.x,h.y,u),_=bi(h.x,h.y,d.x,d.y,u);return[[e,t,f.x,f.y,p.x,p.y,l,c],[l,c,_.x,_.y,d.x,d.y,a,s]]}function Ui(e,t,r,n,i,o,a,s,u){if(0===u)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=Mi(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var l=Fi(e,t,r,n,i,o,a,s,.5),c=[].concat(Di(l[0]),[u-1]),f=[].concat(Di(l[1]),[u-1]);return Ui.apply(void 0,Di(c))+Ui.apply(void 0,Di(f))}var wi,ki=function(e,t,r,n,i,o,a,s){return Ui(e,t,r,n,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"}(wi||(wi={}));var Gi,Wi,Vi;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(Gi||(Gi={})),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"}(Wi||(Wi={})),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"}(Vi||(Vi={}));var Xi=function(e){pe(n,e);var r=me(n);function n(){return ce(this,n),r.apply(this,arguments)}return he(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"updateAttribute",value:function(e,r,i,o){var a=this;Te(_e(n.prototype),"updateAttribute",this).call(this,e,r,i,o),e.forEach((function(e){var r=e.parsedStyle,n=r.stroke,s=r.opacity,u=r.fillOpacity,l=r.strokeOpacity,c=r.lineWidth,f=r.increasedLineWidthForHitTesting,h=r.anchor,d=r.lineDash,p=r.lineDashOffset,_=r.visibility;if("lineJoin"===i||"lineCap"===i||e.nodeName===t.Shape.CIRCLE&&"r"===i||e.nodeName===t.Shape.ELLIPSE&&("rx"===i||"ry"===i)||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("stroke"===i){var v=[0,0,0,0];n instanceof t.CSSRGB&&(v=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(de({},Vi.STROKE_COLOR,v))}else if("opacity"===i)a.material.setUniforms(de({},Vi.OPACITY,s.value));else if("fillOpacity"===i)a.material.setUniforms(de({},Vi.FILL_OPACITY,u.value));else if("strokeOpacity"===i)a.material.setUniforms(de({},Vi.STROKE_OPACITY,l.value));else if("lineWidth"===i)a.material.setUniforms(de({},Vi.STROKE_WIDTH,c.value));else if("increasedLineWidthForHitTesting"===i)a.material.setUniforms(de({},Vi.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,f.value));else if("anchor"===i||"modelMatrix"===i){var E=0,y=0,g=e.getGeometryBounds();if(g){var m=g.halfExtents;E=-m[0]*h[0].value*2,y=-m[1]*h[1].value*2}var R=Sn();Nn(R,e.getWorldTransform(),In(R,xn(E,y,0))),a.material.setUniforms(de({},Vi.MODEL_MATRIX,R))}else if("visibility"===i)a.material.setUniforms(de({},Vi.VISIBLE,"visible"===_.value?1:0));else if("lineDash"===i){var T;a.material.setUniforms((de(T={},Vi.DASH,d[0].value||0),de(T,Vi.GAP,d[1].value||0),T))}else if("lineDashOffset"===i)a.material.setUniforms(de({},Vi.DASH_OFFSET,p&&p.value||0));else if("pointerEvents"===i){var A,S=o&&e.isInteractive()&&(null===(A=e.renderable3D)||void 0===A?void 0:A.encodedPickingColor)||[0,0,0];a.material.setUniforms(de({},Vi.PICKING_COLOR,S))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(de({},Vi.Z_INDEX,t*si))}},{key:"createMaterial",value:function(e){var r,n,i,o;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=ae(ae({},this.material.defines),_i(Wi));var a=e[0],s=a.parsedStyle,u=s.fill,l=s.stroke,c=s.opacity,f=s.fillOpacity,h=s.strokeOpacity,d=s.lineWidth,p=s.increasedLineWidthForHitTesting,_=s.anchor,v=s.lineDash,E=s.lineDashOffset,y=s.visibility,g=[0,0,0,0];u instanceof t.CSSRGB&&(g=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var m=[0,0,0,0];l instanceof t.CSSRGB&&(m=[Number(l.r)/255,Number(l.g)/255,Number(l.b)/255,Number(l.alpha)]);var R=a.isInteractive()&&(null===(r=a.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],T=0,A=0,S=a.getGeometryBounds();if(S){var C=S.halfExtents;T=-C[0]*_[0].value*2,A=-C[1]*_[1].value*2}var O=Sn();Nn(O,a.getWorldTransform(),In(O,xn(T,A,0))),this.material.setUniforms((de(o={},Vi.MODEL_MATRIX,O),de(o,Vi.COLOR,g),de(o,Vi.STROKE_COLOR,m),de(o,Vi.STROKE_WIDTH,d.value),de(o,Vi.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,p.value),de(o,Vi.OPACITY,c.value),de(o,Vi.FILL_OPACITY,f.value),de(o,Vi.STROKE_OPACITY,h.value),de(o,Vi.EXPAND,1),de(o,Vi.MITER_LIMIT,5),de(o,Vi.SCALE_MODE,1),de(o,Vi.ALIGNMENT,.5),de(o,Vi.PICKING_COLOR,R),de(o,Vi.DASH,v&&(null===(n=v[0])||void 0===n?void 0:n.value)||0),de(o,Vi.GAP,v&&(null===(i=v[1])||void 0===i?void 0:i.value)||0),de(o,Vi.DASH_OFFSET,E&&E.value||0),de(o,Vi.VISIBLE,"visible"===y.value?1:0),de(o,Vi.Z_INDEX,a.sortable.renderOrder*si),o)),this.material.cullMode=Fe.None}},{key:"createGeometry",value:function(e){var t=Yi(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:Gi.PACKED,byteStride:48,frequency:je.PerInstance,attributes:[{format:it.F32_RG,bufferByteOffset:0,byteStride:12,location:Wi.PREV,divisor:1},{format:it.F32_RG,bufferByteOffset:12,byteStride:12,location:Wi.POINT1,divisor:1},{format:it.F32_R,bufferByteOffset:20,byteStride:12,location:Wi.VERTEX_JOINT,divisor:1},{format:it.F32_RG,bufferByteOffset:24,byteStride:12,location:Wi.POINT2,divisor:1},{format:it.F32_RG,bufferByteOffset:36,byteStride:12,location:Wi.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:Gi.VERTEX_NUM,byteStride:4,frequency:je.PerInstance,attributes:[{format:it.F32_R,bufferByteOffset:0,byteStride:4,location:Wi.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Gi.TRAVEL,byteStride:4,frequency:je.PerInstance,attributes:[{format:it.F32_R,bufferByteOffset:0,byteStride:4,location:Wi.TRAVEL,divisor:1}],data:new Float32Array(r)}),this.geometry.vertexCount=15,this.geometry.instancedCount=n,this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2,4,6,5,4,7,6,4,7,8]))}}]),n}(Ri);function Hi(e,t,r,n,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);8>t?t=8:t>ji&&(t=ji);return t}(ki(s,u,e,t,r,n,i,o)),c=0,f=0,h=0,d=0,p=0;a.push(s,u);for(var _=1,v=0;l>=_;++_)a.push((h=(f=(c=1-(v=_/l))*c)*c)*s+3*f*v*e+3*c*(d=v*v)*r+(p=d*v)*i,h*u+3*f*v*t+3*c*d*n+p*o)}Xi=f([r.injectable()],Xi);var ji=2048;function Yi(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.parsedStyle,i=n.lineCap,o=n.lineJoin,a=e.parsedStyle,s=a.defX,u=a.defY,l=[],c=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){if(l=e.parsedStyle.points.points.reduce((function(e,t){return e.push(t[0]-s,t[1]-u),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return c=I(l,[],2),{pointsBuffer:l,travelBuffer:[],triangles:c,instancedCount:Math.round(l.length/2)};var f;l.push(l[0],l[1]),(f=l).push.apply(f,Ce(qi(l[0],l[1],l[2],l[3])))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var h;e.nodeName!==t.Shape.PATH?(h=t.parsePath(t.convertToPath(e,!1),e),s=h.rect.x,u=h.rect.y):h=e.parsedStyle.path;var d=h,p=d.zCommandIndexes,_=Ce(h.curve).map((function(e,t){return p.includes(t)?["Z"]:e})),v=-1;if(_.forEach((function(r){var n=Se(r),i=n[0],o=n.slice(1);if("M"===i)v=l.length,l.push(o[0]-s,o[1]-u);else if("C"===i)Hi(o[0]-s,o[1]-u,o[2]-s,o[3]-u,o[4]-s,o[5]-u,l);else if("Z"===i&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var a,c=1e-4;(Math.abs(l[l.length-2]-l[v])>c||Math.abs(l[l.length-1]-l[v+1])>c)&&l.push(l[v],l[v+1]),(a=l).push.apply(a,Ce(qi(l[v],l[v+1],l[v+2],l[v+3])))}})),r)return c=I(l,[],2),{pointsBuffer:l,travelBuffer:[],triangles:c,instancedCount:Math.round(l.length/2)}}var E=Ki(o.value),y=zi(i.value),g=y;y===wi.CAP_ROUND&&(g=wi.JOINT_CAP_ROUND),y===wi.CAP_BUTT&&(g=wi.JOINT_CAP_BUTT),y===wi.CAP_SQUARE&&(g=wi.JOINT_CAP_SQUARE);for(var m=6,R=0,T=[],A=[],S=0;l.length>S;S+=2)S>1&&(R+=Math.sqrt(Math.pow(l[S]-l[S-2],2)+Math.pow(l[S+1]-l[S+1-2],2))),A.push(R),T[m++]=l[S],T[m++]=l[S+1],T[m]=E,0==S&&y!==wi.CAP_ROUND&&(T[m]+=y),l.length>S+4?l.length>S+2||(T[m]=0):T[m]+=g-E,m++;T[m++]=l[l.length-4],T[m++]=l[l.length-3],T[m++]=0,T[0]=l[0],T[1]=l[1],T[2]=0,T[3]=l[2],T[4]=l[3],T[5]=y===wi.CAP_ROUND?y:0;var C=Math.round(l.length/2);return{pointsBuffer:T,travelBuffer:A,triangles:c,instancedCount:C}}function Ki(e){var t;switch(e){case"bevel":t=wi.JOINT_BEVEL;break;case"round":t=wi.JOINT_ROUND;break;default:t=wi.JOINT_MITER}return t}function zi(e){var t;switch(e){case"square":t=wi.CAP_SQUARE;break;case"round":t=wi.CAP_ROUND;break;default:t=wi.CAP_BUTT}return t}function qi(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t,i=[r-e,n-t],o=.01;return[e+i[0]*o,t+i[1]*o]}var Zi=function(e){pe(n,e);var r=me(n);function n(){return ce(this,n),r.apply(this,arguments)}return he(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"createGeometry",value:function(e){var t=Yi(e[0],!0),r=t.triangles;this.geometry.setVertexBuffer({bufferIndex:Ei.POSITION,byteStride:8,frequency:je.PerVertex,attributes:[{format:it.F32_RG,bufferByteOffset:0,byteStride:8,location:yi.POSITION}],data:new Float32Array(t.pointsBuffer)}),this.geometry.vertexCount=r.length,this.geometry.setIndexBuffer(new Uint32Array(r))}},{key:"createMaterial",value:function(e){var r,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 i=e[0],o=i.parsedStyle,a=o.fill,s=o.opacity,u=o.fillOpacity,l=o.anchor,c=o.visibility,f=[0,0,0,0];a instanceof t.CSSRGB&&(f=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var h=i.isInteractive()&&(null===(r=i.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],d=0,p=0,_=i.getGeometryBounds();if(_){var v=_.halfExtents;d=-v[0]*l[0].value*2,p=-v[1]*l[1].value*2}var E=Sn();Nn(E,i.getWorldTransform(),In(E,xn(d,p,0))),this.material.setUniforms((de(n={},Vi.MODEL_MATRIX,E),de(n,Vi.COLOR,f),de(n,Vi.PICKING_COLOR,h),de(n,Vi.OPACITY,s.value),de(n,Vi.FILL_OPACITY,u.value),de(n,Vi.VISIBLE,"visible"===c.value?1:0),de(n,Vi.Z_INDEX,i.sortable.renderOrder*si),n))}},{key:"updateAttribute",value:function(e,r,i,o){var a=this;Te(_e(n.prototype),"updateAttribute",this).call(this,e,r,i,o),e.forEach((function(e){var r=e.parsedStyle,n=r.fill,s=r.opacity,u=r.fillOpacity,l=r.anchor,c=r.visibility;if("lineJoin"===i||"lineCap"===i||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("fill"===i){var f=[0,0,0,0];n instanceof t.CSSRGB&&(f=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(de({},Vi.COLOR,f))}else if("opacity"===i)a.material.setUniforms(de({},Vi.OPACITY,s.value));else if("fillOpacity"===i)a.material.setUniforms(de({},Vi.FILL_OPACITY,u.value));else if("anchor"===i||"modelMatrix"===i){var h=0,d=0,p=e.getGeometryBounds();if(p){var _=p.halfExtents;h=-_[0]*l[0].value*2,d=-_[1]*l[1].value*2}var v=Sn();Nn(v,e.getWorldTransform(),In(v,xn(h,d,0))),a.material.setUniforms(de({},Vi.MODEL_MATRIX,v))}else if("visibility"===i)a.material.setUniforms(de({},Vi.VISIBLE,"visible"===c.value?1:0));else if("pointerEvents"===i){var E,y=o&&e.isInteractive()&&(null===(E=e.renderable3D)||void 0===E?void 0:E.encodedPickingColor)||[0,0,0];a.material.setUniforms(de({},Vi.PICKING_COLOR,y))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(de({},Vi.Z_INDEX,t*si))}}]),n}(Ri);Zi=f([r.injectable()],Zi);var Qi=function(e){pe(r,e);var t=me(r);function r(){return ce(this,r),t.apply(this,arguments)}return he(r,[{key:"shouldMerge",value:function(e,t){var n=Te(_e(r.prototype),"shouldMerge",this).call(this,e,t);return!!n&&this.instance.parsedStyle.img===e.parsedStyle.img}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.img;this.material.defines=ae({},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 r=this.texturePool.getOrCreateTexture(this.device,t);this.material.setUniforms({u_Map:r})}},{key:"createGeometry",value:function(e){Te(_e(r.prototype),"createGeometry",this).call(this,e);var t=[],n=[],i=[];e.forEach((function(e,r){var o=4*r,a=e.parsedStyle;t.push(a.width.value,a.height.value),n.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:Ei.POSITION,byteStride:8,frequency:je.PerInstance,attributes:[{format:it.F32_RG,bufferByteOffset:0,location:yi.POSITION}],data:new Float32Array(t)}),this.geometry.setVertexBuffer({bufferIndex:Ei.UV,byteStride:8,frequency:je.PerVertex,attributes:[{format:it.F32_RG,bufferByteOffset:0,location:yi.UV}],data:new Float32Array(n)})}},{key:"updateAttribute",value:function(e,t,n,i){if(Te(_e(r.prototype),"updateAttribute",this).call(this,e,t,n,i),this.updateBatchedAttribute(e,t,n,i),"width"===n||"height"===n){var o=[];e.forEach((function(e){var t=e.parsedStyle;o.push(t.width.value,t.height.value)})),this.geometry.updateVertexBuffer(Ei.POSITION,yi.POSITION,t,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.device,i);this.material.setUniforms({u_Map:a})}}}]),r}(Ri);Qi=f([r.injectable()],Qi);function Ji(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function $i(e,t,r,n,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*o,c=((n.y+u)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[l+f];return t}var eo=function(){function e(t,r){ce(this,e),this.width=void 0,this.height=void 0,this.data=void 0,Ji(this,t,1,r)}return he(e,[{key:"resize",value:function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Ji({},{width:n,height:i},r);$i(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=o.data}}(this,e,1)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,r,n,i){$i(e,t,r,n,i,1)}}]),e}();var to=he((function e(t){ce(this,e),this.image=void 0,this.positions=void 0;var r={},n=[];for(var i in t){var o=t[i],a=r[i]={};for(var s in o){if((c=o[+s])&&0!==c.bitmap.width&&0!==c.bitmap.height)n.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),a[s]={rect:f,metrics:c.metrics}}}var u=function(e){var t,r=0,n=0,i=De(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;r+=o.w*o.h,n=Math.max(n,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(r/.95)),n),h:1/0}],u=0,l=0,c=De(e);try{for(c.s();!(a=c.n()).done;)for(var f=a.value,h=s.length-1;h>=0;h--){var d=s[h];if(d.w>=f.w&&d.h>=f.h){if(f.x=d.x,f.y=d.y,l=Math.max(l,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===d.w&&f.h===d.h){var p=s.pop();s.length>h&&(s[h]=p)}else f.h===d.h?(d.x+=f.w,d.w-=f.w):f.w===d.w?(d.y+=f.h,d.h-=f.h):(s.push({x:d.x+f.w,y:d.y,w:d.w-f.w,h:f.h}),d.y+=f.h,d.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:u,h:l,fill:r/(u*l)||0}}(n),l=new eo({width:u.w||1,height:u.h||1});for(var i in t){o=t[i];for(var s in o){var c,f;if((c=o[+s])&&0!==c.bitmap.width&&0!==c.bitmap.height)eo.copy(c.bitmap,l,{x:0,y:0},{x:(f=r[i][s].rect).x+1,y:f.y+1},c.bitmap)}}this.image=l,this.positions=r}));function ro(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}var no,io,oo,ao=function(){function e(){ce(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphAtlas=void 0,this.glyphMap={},this.glyphAtlasTexture=void 0}return he(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,r,n,i,o,a){var s=this,u=[],l=o,c=a,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=u.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),o=r&&r[n];o&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=o.metrics.advance+i)}));for(var o=l-i,a=n;u.length>a;a++)u[a].x=u[a].x-f*o;l=0,c+=r})),u}},{key:"generateAtlas",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0,n=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=ro());var u=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(o.split(""))).forEach((function(e){-1===u.indexOf(""+e.charCodeAt(0))&&s.push(e)})),s.length){var l=s.map((function(o){return e.generateSDF(t,r,n,i,o)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=ae(ae({},this.glyphMap[t]),l),this.glyphAtlas=new to(this.glyphMap);var c=this.glyphAtlas.image,f=c.width,h=c.height,d=c.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=a.createTexture(ae(ae({},st(it.ALPHA,f,h,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([d],0)}}},{key:"generateSDF",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,n=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 re({fontSize:24,fontFamily:t,fontWeight:r,fontStyle:n,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,h=s.glyphHeight,d=s.glyphLeft,p=s.glyphTop,_=s.glyphAdvance;return{id:o,bitmap:new eo({width:l,height:c},u),metrics:{width:f,height:h,left:d,top:p-24+3,advance:_}}}}]),e}();ao=f([r.injectable()],ao),function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(no||(no={})),function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(io||(io={})),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"}(oo||(oo={}));var so=function(e){pe(n,e);var r=me(n);function n(){var e;ce(this,n);for(var t=arguments.length,i=Array(t),o=0;t>o;o++)i[o]=arguments[o];return(e=r.call.apply(r,[this].concat(i))).glyphManager=void 0,e}return he(n,[{key:"shouldMerge",value:function(e,t){var r=Te(_e(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 r=this,n=this.instance.parsedStyle,i=n.textBaseline,o=n.letterSpacing,a=void 0===o?0:o,s=24/n.fontSize.value,u=[],l=[],c=[],f=0;e.forEach((function(e){var n=e.parsedStyle,o=n.metrics,h=n.dx,d=n.dy,p=o.font,_=o.lines,v=o.height,E=o.lineHeight,y=0,g=0;h&&h.unit===t.UnitType.kPixels&&(y+=h.value),d&&d.unit===t.UnitType.kPixels&&(g+=d.value);var m=0;"middle"===i.value?m=-v/2:"bottom"===i.value?m=-v:"top"===i.value||"hanging"===i.value?m=0:"alphabetic"===i.value?m=.25*E-v:"ideographic"===i.value&&(m=-v);var R=r.glyphManager.getAtlas(),T=r.buildTextBuffers({object:e,lines:_,fontStack:p,lineHeight:s*E,offsetX:s*y,offsetY:s*(m+g),letterSpacing:s*a,glyphAtlas:R,indicesOffset:f}),A=T.indexBuffer,S=T.charUVOffsetBuffer;f=T.indicesOffset,c.push.apply(c,Ce(T.charPackedBuffer)),l.push.apply(l,Ce(S)),u.push.apply(u,Ce(A))})),this.geometry.vertexCount=u.length,this.geometry.setIndexBuffer(new Uint32Array(u)),this.geometry.setVertexBuffer({bufferIndex:no.INSTANCED,byteStride:144,frequency:je.PerVertex,attributes:[{format:it.F32_RGBA,bufferByteOffset:0,location:yi.MODEL_MATRIX0},{format:it.F32_RGBA,bufferByteOffset:16,location:yi.MODEL_MATRIX1},{format:it.F32_RGBA,bufferByteOffset:32,location:yi.MODEL_MATRIX2},{format:it.F32_RGBA,bufferByteOffset:48,location:yi.MODEL_MATRIX3},{format:it.F32_RGBA,bufferByteOffset:64,location:yi.COLOR},{format:it.F32_RGBA,bufferByteOffset:80,location:yi.STROKE_COLOR},{format:it.F32_RGBA,bufferByteOffset:96,location:yi.PACKED_STYLE1},{format:it.F32_RGBA,bufferByteOffset:112,location:yi.PACKED_STYLE2},{format:it.F32_RGBA,bufferByteOffset:128,location:yi.PICKING_COLOR}],data:new Float32Array(c)}),this.geometry.setVertexBuffer({bufferIndex:no.TEX,byteStride:16,frequency:je.PerVertex,attributes:[{format:it.F32_RG,bufferByteOffset:0,location:io.TEX},{format:it.F32_RG,bufferByteOffset:8,location:io.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=Fe.Back,this.material.defines=ae(ae({},this.material.defines),_i(io));var r=this.instance.parsedStyle,n=r.fontSize,i=r.fontFamily,o=void 0===i?"":i,a=r.fontWeight,s=r.fontStyle,u=r.metrics.font,l=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(u,o,""+a,""+s,l,this.device);var c=this.glyphManager.getAtlasTexture(),f=this.glyphManager.getAtlas();this.device.setResourceName(c,"TextSDF Texture");var h=f.image,d=h.width,p=h.height;this.material.setUniforms((de(t={},oo.SDF_MAP,c),de(t,oo.SDF_MAP_SIZE,[d,p]),de(t,oo.FONT_SIZE,n.value),de(t,oo.GAMMA_SCALE,1),de(t,oo.STROKE_BLUR,.2),de(t,oo.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,r,n){"text"===r||"fontFamily"===r||"fontSize"===r||"fontWeight"===r||"fontStyle"===r||"fontVariant"===r||"textBaseline"===r||"letterSpacing"===r||"wordWrapWidth"===r||"lineHeight"===r||"wordWrap"===r||"textAlign"===r||"modelMatrix"===r||"visibility"===r||"dx"===r||"dy"===r?(this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0):"fill"!==r&&"fillOpacity"!==r&&"stroke"!==r&&"strokeOpacity"!==r&&"opacity"!==r&&"lineWidth"!==r&&"visibility"!==r&&"pointerEvents"!==r||(this.material.geometryDirty=!0)}},{key:"buildTextBuffers",value:function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,u=e.offsetX,l=e.offsetY,c=e.glyphAtlas,f=e.indicesOffset,h=n.parsedStyle,d=h.textAlign,p=h.fill,_=h.stroke,v=h.opacity,E=h.fillOpacity,y=h.strokeOpacity,g=h.lineWidth,m=h.visibility,R=[0,0,0,0];p instanceof t.CSSRGB&&(R=[Number(p.r)/255,Number(p.g)/255,Number(p.b)/255,Number(p.alpha)]);var T=[0,0,0,0];_ instanceof t.CSSRGB&&(T=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)]);var A=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=Cn(Sn(),n.getWorldTransform()),C=[],O=[],I=[],N=f,x=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var 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],h=c+s.w*i.scale,d=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:h,y:f},bl:{x:c,y:d},br:{x:h,y:d},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,d.value,s,u,l),c.positions);return x.forEach((function(e){var t=[];t.push.apply(t,Ce(S));var r=[].concat(t,Ce(R),Ce(T),[v.value,E.value,y.value,g.value,"visible"===m.value?1:0,0,0,0],Ce(A),[n.sortable.renderOrder*si]);C.push.apply(C,Ce(r).concat(Ce(r),Ce(r),Ce(r))),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}(Ri);f([r.inject(ao),h("design:type",ao)],so.prototype,"glyphManager",void 0),so=f([r.injectable()],so);var uo=function(e){pe(n,e);var r=me(n);function n(){return ce(this,n),r.apply(this,arguments)}return he(n,[{key:"shouldMerge",value:function(e,r){var i=Te(_e(n.prototype),"shouldMerge",this).call(this,e,r);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,r,i){Te(_e(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i)}},{key:"createMaterial",value:function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()}},{key:"createGeometry",value:function(e){this.geometry=this.instance.parsedStyle.geometry,Te(_e(n.prototype),"createGeometry",this).call(this,e),this.geometry.build(e),this.observeGeometryChanged()}}]),n}(Ri);uo=f([r.injectable()],uo);var lo=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Ci,Xi],e}return he(r,[{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,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e.value}));return!s||u&&o.value>0&&(1>a.value||l)}}]),r}(li);lo=f([r.injectable({token:[{token:ri,named:t.Shape.CIRCLE},{token:ri,named:t.Shape.ELLIPSE}]})],lo);var co=function(e){pe(n,e);var r=me(n);function n(){var e;ce(this,n);for(var t=arguments.length,i=Array(t),o=0;t>o;o++)i[o]=arguments[o];return(e=r.call.apply(r,[this].concat(i))).meshes=[Zi,Xi],e}return he(n,[{key:"shouldSubmitRenderInst",value:function(e,r){var n=e.parsedStyle,i=n.lineDash,o=e.nodeName;if(0===r&&(e.nodeName===t.Shape.POLYLINE||n.fill.isNone))return!1;if(1===r){if(0===n.strokeOpacity.value||0===n.lineWidth.value)return!1;var a=i&&i.length&&i.every((function(e){return 0!==e.value}));if(o===t.Shape.CIRCLE||o===t.Shape.ELLIPSE)return a}return!0}}]),n}(li);co=f([r.injectable({token:[{token:ri,named:t.Shape.POLYLINE},{token:ri,named:t.Shape.PATH},{token:ri,named:t.Shape.POLYGON},{token:ri,named:t.Shape.RECT}]})],co);var fo=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[],e}return he(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(li);fo=f([r.injectable({token:[{token:ri,named:t.Shape.GROUP}]})],fo);var ho=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Qi],e}return he(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(li);ho=f([r.injectable({token:[{token:ri,named:t.Shape.IMAGE}]})],ho);var po=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[so,so],e}return he(r,[{key:"shouldSubmitRenderInst",value:function(e,t){var r=e.parsedStyle,n=r.lineWidth;return!(!(r.stroke&&n&&n.value)&&0===t)}},{key:"beforeUploadUBO",value:function(e,t,r){t.material.setUniforms(de({},oo.HAS_STROKE,1-t.index))}}]),r}(li);po=f([r.injectable({token:[{token:ri,named:t.Shape.TEXT}]})],po);var _o=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Pi],e}return he(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(li);_o=f([r.injectable({token:{token:ri,named:t.Shape.LINE}})],_o);var vo=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[uo],e}return he(r)}(li);vo=f([r.injectable({token:[{token:ri,named:t.Shape.MESH}]})],vo);var Eo=r.Syringe.defineToken("DeviceContribution"),yo=["style"],go=function(e){pe(r,e);var t=me(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.style,i=Ee(e,yo);return ce(this,r),t.call(this,ae({type:r.tag,style:ae({intensity:Math.PI},n)},i))}return he(r)}(t.DisplayObject);go.tag="light";var mo,Ro=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(mo||(mo={}));var To,Ao,So=function(e){pe(r,e);var t=me(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.style,i=Ee(e,Ro);return ce(this,r),t.call(this,ae({type:r.tag,style:ae({type:mo.NONE,fill:"black",start:1,end:1e3,density:0},n)},i))}return he(r)}(t.DisplayObject);So.tag="fog";var Co;!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"}(Co||(Co={}));var Oo,Io,No=(To=function(){function e(){ce(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 kn,picking:new kn},this.builder=void 0}return he(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 r=this,n=function(e){var t=e.target;if(t.nodeName!==go.tag)if(t.nodeName!==So.tag){var n=new Be;t.renderable3D=n,r.batchManager.add(t)}else r.lightPool.addFog(t);else r.lightPool.addLight(t)},i=function(e){var t=e.target;t.nodeName!==go.tag?t.nodeName!==So.tag?(r.batchManager.remove(t),delete t.renderable3D):r.lightPool.removeFog(t):r.lightPool.removeLight(t)},o=function(e){r.batchManager.updateAttribute(e.target,e.attrName,e.newValue)},a=function(e){r.batchManager.changeRenderOrder(e.target,e.detail.renderOrder)};e.hooks.init.tapPromise(Ao.tag,le(se().mark((function s(){var u,l;return se().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.addEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a),r.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering=!1,u=r.contextService.getDomElement(),r.contextService.resize((l=r.canvasConfig).width,l.height),s.next=10,r.deviceContribution.createSwapChain(u);case 10:r.swapChain=s.sent,r.device=r.swapChain.getDevice(),r.renderHelper.setDevice(r.device),r.renderHelper.renderInstManager.disableSimpleMode(),r.swapChain.configureSwapChain(u.width,u.height),r.renderingContext.root.ownerDocument.defaultView.addEventListener(t.CanvasEvent.RESIZE,(function(){r.swapChain.configureSwapChain(u.width,u.height)})),r.batchManager.attach(r.device,e);case 17:case"end":return s.stop()}}),s)})))),e.hooks.destroy.tap(Ao.tag,(function(){r.renderHelper.destroy(),r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.removeEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a)})),e.hooks.beginFrame.tap(Ao.tag,(function(){var e=r.swapChain.getCanvas(),n=r.renderHelper.renderInstManager;r.builder=r.renderHelper.renderGraph.newGraphBuilder();var i=t.parseColor(r.canvasConfig.background),o=r.canvasConfig.background?Rt(Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)):St,a={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:jn.None},s=Zn(on.Color0,a,Hn(o)),u=Zn(on.DepthStencil,a,zn),l=r.builder.createRenderTargetID(s,"Main Color"),c=r.builder.createRenderTargetID(u,"Main Depth");r.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(on.Color0,l),e.attachRenderTargetID(on.DepthStencil,c),e.exec((function(e){r.renderLists.world.drawOnPassRenderer(n.renderCache,e)}))})),r.builder.resolveRenderTargetToExternalTexture(l,r.swapChain.getOnscreenTexture())})),e.hooks.endFrame.tap(Ao.tag,(function(){var e=r.renderHelper.renderInstManager,t=r.renderHelper.pushTemplateRenderInst();t.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),t.setMegaStateFlags(zt({depthWrite:!0},{rgbBlendMode:we.Add,alphaBlendMode:we.Add,rgbBlendSrcFactor:Ue.SrcAlpha,alphaBlendSrcFactor:Ue.Zero,rgbBlendDstFactor:Ue.OneMinusSrcAlpha,alphaBlendDstFactor:Ue.One}));var n=r.canvasConfig,i=n.width,o=n.height;t.setUniforms(0,[{name:Co.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:Co.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:Co.CAMERA_POSITION,value:r.camera.getPosition()},{name:Co.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:Co.VIEWPORT,value:[i,o]},{name:Co.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:Co.IS_PICKING,value:0}]),r.batchManager.render(r.renderLists.world),e.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),e.resetRenderInsts(),r.swapChain.present()}))}},{key:"loadTexture",value:function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))}}]),e}(),To.tag="RenderGraph",Ao=To);f([r.inject(t.CanvasConfig),h("design:type",Object)],No.prototype,"canvasConfig",void 0),f([r.inject(t.ContextService),h("design:type",Object)],No.prototype,"contextService",void 0),f([r.inject(t.RenderingContext),h("design:type",Object)],No.prototype,"renderingContext",void 0),f([r.inject(t.DefaultCamera),h("design:type",t.Camera)],No.prototype,"camera",void 0),f([r.inject(Vn),h("design:type",Vn)],No.prototype,"renderHelper",void 0),f([r.inject(ei),h("design:type",ei)],No.prototype,"lightPool",void 0),f([r.inject($n),h("design:type",$n)],No.prototype,"texturePool",void 0),f([r.inject(oi),h("design:type",oi)],No.prototype,"batchManager",void 0),f([r.inject(Eo),h("design:type",Object)],No.prototype,"deviceContribution",void 0),No=Ao=f([r.singleton({contrib:t.RenderingPluginContribution})],No);var xo=(Oo=function(){function e(){ce(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 r;return he(e,[{key:"apply",value:function(e){var r=this,n=function(e){var t=e.target,n=t.renderable3D;if(n){var i=r.pickingIdGenerator.getId(t);n.pickingId=i,n.encodedPickingColor=r.pickingIdGenerator.encodePickingColor(i)}};e.hooks.init.tapPromise(Io.tag,le(se().mark((function e(){return se().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n);case 1:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Io.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n)})),e.hooks.pick.tapPromise(Io.tag,function(){var e=le(se().mark((function e(n){var i,o,a,s,u,l,c,f,h;return se().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.topmost,a=(o=n.position).viewportX,s=o.viewportY,u=r.contextService.getDPR(),c=r.canvasConfig.height*u,h=s*u,!((f=a*u)>(l=r.canvasConfig.width*u)||0>f||h>c||0>h)){e.next=10;break}return n.picked=[],e.abrupt("return",n);case 10:return e.next=12,r.pickByRectangleInDepth(new t.Rectangle(t.clamp(Math.round(f),0,l-1),t.clamp(Math.round(h),0,c-1),1,1),i?1:100);case 12:return n.picked=e.sent,e.abrupt("return",n);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"pickByRectangleInDepth",value:(r=le(se().mark((function e(t){var r,n,i,o,a=arguments;return se().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=a.length>1&&void 0!==a[1]?a[1]:100,n=null,i=1,o=[];case 4:return e.next=6,this.pickByRectangle(t,n);case 6:if(!(n=e.sent)){e.next=12;break}i++,o.push(n),e.next=13;break;case 12:return e.abrupt("break",14);case 13:if(n&&r>=i){e.next=4;break}case 14:return r>1&&this.restorePickingColor(o),e.abrupt("return",o);case 16:case"end":return e.stop()}}),e,this)}))),function(e){return r.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 r=this,n=this.renderGraphPlugin.getDevice(),i=this.renderGraphPlugin.getRenderLists(),o=this.renderHelper.renderInstManager,a=this.renderHelper.renderGraph.newGraphBuilder(),s=e.x,u=e.y,l=e.width,c=e.height,f={backbufferWidth:l,backbufferHeight:c,antialiasingMode:jn.None},h=Zn(on.Color0,f,Hn(St)),d=a.createRenderTargetID(h,"Picking Color"),p=Zn(on.DepthStencil,f,zn),_=a.createRenderTargetID(p,"Picking Depth"),v=ae({},this.camera.getView());return new Promise((function(e){r.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),a.pushPass((function(t){t.setDebugName("Picking Pass"),t.attachRenderTargetID(on.Color0,d),t.attachRenderTargetID(on.DepthStencil,_),t.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)})),t.post((function(t){var i=t.getRenderTargetTexture(on.Color0),o=n.createReadback();v&&v.enabled?r.camera.setViewOffset(v.fullWidth,v.fullHeight,v.offsetX,v.offsetY,v.width,v.height):r.camera.clearViewOffset(),r.camera.setEnableUpdate(!0),o.readTexture(i,0,0,l,c,new Uint8Array(l*c*4)).then((function(t){var n,i=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(i=r.pickingIdGenerator.decodePickingColor(t)),i>-1){var a=r.pickingIdGenerator.getById(i);a&&a.isVisible()&&a.isInteractive()&&(n=a)}o.destroy(),e(n)}))}))}));var f=r.renderHelper.pushTemplateRenderInst();f.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),f.setMegaStateFlags(zt({depthWrite:!0},{rgbBlendMode:we.Add,rgbBlendSrcFactor:Ue.One,rgbBlendDstFactor:Ue.Zero,alphaBlendMode:we.Add,alphaBlendSrcFactor:Ue.One,alphaBlendDstFactor:Ue.Zero}));var h=r.canvasConfig,p=h.width,E=h.height,y=r.contextService.getDPR();r.camera.setEnableUpdate(!1),r.camera.setViewOffset(p*y,E*y,s,u,l,c),f.setUniforms(0,[{name:Co.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:Co.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:Co.CAMERA_POSITION,value:r.camera.getPosition()},{name:Co.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:Co.VIEWPORT,value:[p,E]},{name:Co.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:Co.IS_PICKING,value:1}]),t&&r.batchManager.updateAttribute(t,"pointerEvents",!1,!0),r.batchManager.render(i.picking,!0),o.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),o.resetRenderInsts()}))}}]),e}(),Oo.tag="WebGLPicker",Io=Oo);f([r.inject(t.CanvasConfig),h("design:type",Object)],xo.prototype,"canvasConfig",void 0),f([r.inject(t.SceneGraphService),h("design:type",Object)],xo.prototype,"sceneGraphService",void 0),f([r.inject(t.ContextService),h("design:type",Object)],xo.prototype,"contextService",void 0),f([r.inject(t.RenderingContext),h("design:type",Object)],xo.prototype,"renderingContext",void 0),f([r.inject(Vn),h("design:type",Vn)],xo.prototype,"renderHelper",void 0),f([r.inject(No),h("design:type",No)],xo.prototype,"renderGraphPlugin",void 0),f([r.inject(at),h("design:type",at)],xo.prototype,"pickingIdGenerator",void 0),f([r.inject(t.DefaultCamera),h("design:type",t.Camera)],xo.prototype,"camera",void 0),f([r.inject(oi),h("design:type",oi)],xo.prototype,"batchManager",void 0),xo=Io=f([r.singleton({contrib:t.RenderingPluginContribution})],xo);var Po=["style"],Do=function(e){pe(n,e);var r=me(n);function n(e){var i,o=e.style,a=Ee(e,Po);return ce(this,n),(i=r.call(this,ae({type:t.Shape.MESH,style:ae({x:"",y:"",z:"",lineWidth:0},o)},a))).cullable.enable=!1,i.style.geometry.meshes.push(ye(i)),i.style.material.meshes.push(ye(i)),i}return he(n,[{key:"destroy",value:function(){Te(_e(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}(t.DisplayObject),Bo=function(){function e(){ce(this,e)}return he(e,[{key:"update",value:function(e){return e.geometry.computeBoundingBox(),{width:0,height:0,depth:0}}}]),e}();Bo=f([r.singleton({token:{token:t.GeometryAABBUpdater,named:t.Shape.MESH}})],Bo);var Mo,bo,Lo,Fo="#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}",Uo="#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}",wo=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).vert=Fo,e.frag=Uo,e.features={},e}return he(r)}(Hr),ko="#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}",Go=function(e){pe(r,e);var t=me(r);function r(){var e;ce(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;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=Fo,e.frag=ko,e}return he(r)}(Hr),Wo=Ft(1,(function(){return new Qn}));var Vo=r.Module((function(e){e(Vn),e($n),e(ei),e(ao),e(at),e(oi),e(No),e(xo),e(Ci),e(Pi),e(Xi),e(Zi),e(Qi),e(so),e(uo),e({token:ni,useFactory:function(e){return function(t){return e.container.isBound(t)&&e.container.get(t)||null}}}),e(lo),e(co),e(ho),e(_o),e(po),e(vo),e({token:ti,useFactory:function(e){var t={};return function(r){return t[r]||e.container.isBoundNamed(ri,r)&&(t[r]=e.container.getNamed(ri,r)),t[r]||null}}})})),Xo=function(){function e(){ce(this,e),this.name="device-renderer",this.container=void 0}return he(e,[{key:"init",value:function(e){r.GlobalContainer.isBound(Bo)||r.GlobalContainer.register(Bo),this.container=e,e.load(Vo,!0)}},{key:"destroy",value:function(e){r.GlobalContainer.isBound(Bo)&&r.GlobalContainer.remove(Bo),e.unload(Vo)}},{key:"getDevice",value:function(){return this.container.get(No).getDevice()}},{key:"loadTexture",value:function(e,t,r){return this.container.get(No).loadTexture(e,t,r)}}]),e}(),Ho=Object.freeze({__proto__:null,get AntialiasingMode(){return jn},get Batch(){return li},get BlendFactor(){return Ue},get BlendMode(){return we},get BufferFrequencyHint(){return He},BufferGeometry:hi,get BufferUsage(){return Xe},get ChannelWriteMask(){return qe},get ClipSpaceNearZ(){return $e},get CompareMode(){return be},CopyProgram:wo,get CullMode(){return Fe},DeviceContribution:Eo,DeviceProgram:Hr,DynamicUniformBuffer:jr,get Endianness(){return qt},get FillMesh(){return Zi},Fog:So,get FogType(){return mo},get Format(){return it},get FormatCompFlags(){return rt},get FormatFlags(){return nt},get FormatTypeFlags(){return tt},get FrontFaceMode(){return Le},get GL(){return ot},get GeometryEvent(){return ai},HashMap:Zr,IdentityViewportCoords:un,get ImageMesh(){return Qi},get Instanced(){return Ri},get InstancedLineMesh(){return Pi},IsDepthReversed:Ot,get JOINT_TYPE(){return wi},Light:go,get LineMesh(){return Xi},Material:di,get MaterialEvent(){return fi},Mesh:Do,get MeshMesh(){return uo},get MipFilterMode(){return We},OpaqueBlack:At,OpaqueWhite:Ct,Plugin:Xo,get PrimitiveTopology(){return Ve},get QueryPoolType(){return et},get RGAttachmentSlot(){return on},RenderCache:an,get RenderGraphPlugin(){return No},get RenderHelper(){return Vn},RenderInst:Un,get RenderInstExecutionOrder(){return Fn},get RenderInstFlags(){return Mn},RenderInstList:kn,RenderInstManager:Wn,Renderable3D:Be,get RendererLayer(){return hn},get ResourceType(){return Me},get SDFMesh(){return Ci},get SamplerFormatKind(){return Qe},ShaderMaterial:pi,SingleSampledTexture:fn,get StencilOp(){return Ze},TemporalTexture:Jn,get TexFilterMode(){return Ge},get TextMesh(){return so},get TextUniform(){return oo},get TextureDimension(){return Ke},get TextureEvent(){return Ye},TextureMapping:Qn,get TexturePool(){return $n},get TextureUsage(){return ze},TransparentBlack:Tt,TransparentWhite:St,UNIFORM_SETTERS:Ur,get Uniform(){return Vi},get VertexAttributeBufferIndex(){return Ei},get VertexAttributeLocation(){return yi},get VertexBufferFrequency(){return je},get ViewportOrigin(){return Je},get WrapMode(){return ke},align:Dt,alignNonPowerOfTwo:Bt,arrayCopy:Jt,arrayEqual:Qt,assert:vt,assertExists:Et,bindingLayoutDescriptorCopy:vr,bindingLayoutDescriptorEqual:tr,bindingLayoutSamplerDescriptorCopy:_r,bindingsDescriptorCopy:pr,bindingsDescriptorEquals:rr,bisectRight:Mt,bufferBindingCopy:dr,colorCopy:gt,colorEqual:yt,colorNewCopy:mt,colorNewFromRGBA:Rt,compareDefines:vi,compareDepthValues:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ot;if((r=It(r,n))===be.Less)return t>e;if(r===be.LessEqual)return t>=e;if(r===be.Greater)return e>t;if(r===be.GreaterEqual)return e>=t;throw Error("whoops")},containerModule:Vo,copyAttachmentState:kt,copyAttachmentStateFromSimple:Xt,copyMegaState:Vt,defaultBindingLayoutSamplerDescriptor:Zt,defaultMegaState:jt,enumToObject:_i,fallbackUndefined:Nt,fillArray:Pt,fillColor:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r.a;return e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:Ln,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},fullscreenMegaState:Kt,getAttributeLocations:function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,n,i){var o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r},getDefines:function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""})),t},getFormatByteSize:function(e){return dt(ft(e))*ct(e)},getFormatCompByteSize:pt,getFormatCompFlags:ct,getFormatCompFlagsComponentCount:ut,getFormatComponentCount:function(e){return ct(e)},getFormatFlags:ht,getFormatSamplerKind:_t,getFormatTypeFlags:ft,getFormatTypeFlagsByteSize:dt,getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},getSystemEndianness:function(){return Ar},getUniformSetter:function(e,t,r){var n=Ur[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)},getUniforms:Gr,hashCodeNumberFinish:Kr,hashCodeNumberUpdate:Yr,inputLayoutBufferDescriptorCopy:gr,inputLayoutBufferDescriptorEquals:lr,inputLayoutDescriptorCopy:mr,inputLayoutDescriptorEquals:cr,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:Ut,makeAttachmentClearDescriptor:Hn,makeBackbufferDescSimple:Zn,makeDepthKey:vn,makeFormat:lt,makeMegaState:Yt,makeSortKey:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&hn.TRANSLUCENT?Rn(e):gn(e,t)},makeSortKeyOpaque:gn,makeSortKeyTranslucent:Rn,makeStaticDataBuffer:ci,makeTextureDescriptor2D:st,nArray:Ft,nullHashFunc:zr,nullify:xt,opaqueBlackFullClearRenderPassDescriptor:Kn,opaqueWhiteFullClearRenderPassDescriptor:zn,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(Sr);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}},prependLineNo:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=e.split("\n");return r.map((function(e,r){return"".concat(Ut(""+(t+r),4," ")," ").concat(e)})).join("\n")},preprocessProgramObj_GLSL:Xr,preprocessProgram_GLSL:Vr,preprocessShader_GLSL:Wr,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===$e.NegativeOne?function(e){Nn(e,Bn,e)}(e):t===$e.Zero&&function(e){Nn(e,bn,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(on.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(Kt),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);Ln(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Go,l=t.renderCache.createProgram(u);a.setProgram(l),Mo||((Mo=new hi(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:je.PerVertex,attributes:[{format:it.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),Mo.vertexCount=3,Lo=t.getCache().createInputLayout(Mo.inputLayoutDescriptor),bo=t.getDevice().createInputState(Lo,Mo.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,r){Wo[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(Wo),a.setInputLayoutAndState(Lo,bo),a.drawOnPass(t.renderCache,e)}))}))},range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:wn,renderPipelineDescriptorCopy:Er,renderPipelineDescriptorEquals:sr,reverseDepthForClearValue:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot;return t?1-e:e},reverseDepthForCompareMode:It,reverseDepthForDepthOffset:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot;return t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot;t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot;t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:hr,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:fr,segmentInstanceGeometry:Ni,setAttachmentStateSimple:zt,setBackbufferDescSimple:qn,setBitFlagEnabled:Lt,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:Wt,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_n,n=!!(e>>>31&1),i=vn(t,n,r);return n?Tn(e,i):mn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?Tn(e,t):mn(e,t)},setSortKeyLayer:En,setSortKeyOpaqueDepth:mn,setSortKeyProgramKey:yn,setSortKeyTranslucentDepth:Tn,spliceBisectRight:bt,standardFullClearRenderPassDescriptor:Yn,updateBuffer:Yi,vertexAttributeDescriptorCopy:yr,vertexAttributeDescriptorEquals:ur});function jo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Yo(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?jo(Object(r),!0).forEach((function(t){$o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):jo(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ko(){
|
|
6
6
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
7
|
-
_o=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=m(a,r);if(s){if(s===c)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function f(){}function d(){}function h(){}var p={};s(p,i,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(S([])));E&&E!==t&&r.call(E,i)&&(p=E);var v=h.prototype=f.prototype=Object.create(p);function R(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function n(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&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function m(e,t){var r=e.iterator[t.method];if(void 0===r){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 n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var i=n.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 T(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 y(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,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 n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],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(g.prototype),s(g.prototype,o,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?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 r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},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(y),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(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 r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),y(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;y(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}function Eo(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function vo(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Eo(o,n,i,a,s,"next",e)}function s(e){Eo(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Ro(){return Ro=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ro.apply(this,arguments)}function go(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,mo(e,t)}function mo(e,t){return mo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},mo(e,t)}function To(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var yo,Ao,So=r.Syringe.defineToken("WebGPUDeviceOptions");function Co(e){if(e===ye.U8_RGBA_RT)return"bgra8unorm";if(e===ye.U8_RGBA_NORM)return"rgba8unorm";if(e===ye.U8_RG_NORM)return"rg8unorm";if(e===ye.U32_R)return"r32uint";if(e===ye.D24)return"depth24plus";if(e===ye.D24_S8)return"depth24plus-stencil8";if(e===ye.D32F)return"depth32float";if(e===ye.D32F_S8)return"depth32float-stencil8";if(e===ye.BC1)return"bc1-rgba-unorm";if(e===ye.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===ye.BC2)return"bc2-rgba-unorm";if(e===ye.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===ye.BC3)return"bc3-rgba-unorm";if(e===ye.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===ye.BC4_SNORM)return"bc4-r-snorm";if(e===ye.BC4_UNORM)return"bc4-r-unorm";if(e===ye.BC5_SNORM)return"bc5-rg-snorm";if(e===ye.BC5_UNORM)return"bc5-rg-unorm";throw Error("whoops")}function Oo(e){if(e===ne.Clamp)return"clamp-to-edge";if(e===ne.Repeat)return"repeat";if(e===ne.Mirror)return"mirror-repeat";throw Error("whoops")}function Io(e){if(e===ie.Bilinear)return"linear";if(e===ie.Point)return"nearest";throw Error("whoops")}function No(e){if(e===oe.Linear)return"linear";if(e===oe.Nearest)return"nearest";if(e===oe.NoMip)return"nearest";throw Error("whoops")}function xo(e){if(e===_e.Float)return"float";if(e===_e.Depth)return"depth";throw Error("whoops")}function Po(e){if(e===fe.n2D)return"2d";if(e===fe.n2DArray)return"2d-array";if(e===fe.n3D)return"3d";if(e===fe.Cube)return"cube";throw Error("whoops")}function Do(e){return e.gpuBuffer}function Bo(e){if(e===Re.OcclusionConservative)return"occlusion";throw Error("whoops")}function Mo(e){switch(e){case ae.Triangles:return"triangle-list";case ae.Points:return"point-list";case ae.TriangleStrip:return"triangle-strip";case ae.Lines:return"line-list";case ae.LineStrip:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function Lo(e){if(e===ee.None)return"none";if(e===ee.Front)return"front";if(e===ee.Back)return"back";throw Error("whoops")}function Fo(e){if(e===$.CCW)return"ccw";if(e===$.CW)return"cw";throw Error("whoops")}function bo(e){if(e===te.Zero)return"zero";if(e===te.One)return"one";if(e===te.Src)return"src";if(e===te.OneMinusSrc)return"one-minus-src";if(e===te.Dst)return"dst";if(e===te.OneMinusDst)return"one-minus-dst";if(e===te.SrcAlpha)return"src-alpha";if(e===te.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===te.DstAlpha)return"dst-alpha";if(e===te.OneMinusDstAlpha)return"one-minus-dst-alpha";throw Error("whoops")}function Uo(e){if(e===re.Add)return"add";if(e===re.Subtract)return"subtract";if(e===re.ReverseSubtract)return"reverse-subtract";throw Error("whoops")}function wo(e){return{operation:Uo(e.blendMode),srcFactor:bo(e.blendSrcFactor),dstFactor:bo(e.blendDstFactor)}}function Go(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:Co(t),blend:{color:wo(e.rgbBlendState),alpha:wo(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[r])}))}function ko(e){if(e===J.Never)return"never";if(e===J.Less)return"less";if(e===J.Equal)return"equal";if(e===J.LessEqual)return"less-equal";if(e===J.Greater)return"greater";if(e===J.NotEqual)return"not-equal";if(e===J.GreaterEqual)return"greater-equal";if(e===J.Always)return"always";throw Error("whoops")}function Wo(e){if(e===le.PerVertex)return"vertex";if(e===le.PerInstance)return"instance";throw Error("whoops")}function Vo(e){if(e===ye.U8_R)return"uint8x2";if(e===ye.U8_RG)return"uint8x2";if(e===ye.U8_RGB)return"uint8x4";if(e===ye.U8_RGBA)return"uint8x4";if(e===ye.U8_RGBA_NORM)return"unorm8x4";if(e===ye.S8_RGB_NORM)return"snorm8x4";if(e===ye.S8_RGBA_NORM)return"snorm8x4";if(e===ye.S16_RG)return"uint16x2";if(e===ye.F32_R)return"float32";if(e===ye.F32_RG)return"float32x2";if(e===ye.F32_RGB)return"float32x3";if(e===ye.F32_RGBA)return"float32x4";throw Error("whoops")}function Xo(e,t,r,n){switch(void 0===r&&(r=!1),e){case ye.S8_R:case ye.S8_R_NORM:case ye.S8_RG_NORM:case ye.S8_RGB_NORM:case ye.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case ye.U8_R:case ye.U8_R_NORM:case ye.U8_RG:case ye.U8_RG_NORM:case ye.U8_RGB:case ye.U8_RGB_NORM:case ye.U8_RGB_SRGB:case ye.U8_RGBA:case ye.U8_RGBA_NORM:case ye.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case ye.S16_R:case ye.S16_RG:case ye.S16_RG_NORM:case ye.S16_RGB_NORM:case ye.S16_RGBA:case ye.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case ye.U16_R:case ye.U16_RGB:case ye.U16_RGBA_5551:case ye.U16_RGBA_NORM:case ye.U16_RG_NORM:case ye.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case ye.S32_R:var u=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&u.set(new Int32Array(n)),u;case ye.U32_R:case ye.U32_RG:var l=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&l.set(new Uint32Array(n)),l;case ye.F32_R:case ye.F32_RG:case ye.F32_RGB:case ye.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(yo||(yo={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Ao||(Ao={}));var Ho=function(e){function t(t){var r,n=t.id,i=t.device;return(r=e.call(this)||this).type=void 0,r.id=void 0,r.name=void 0,r.device=void 0,r.id=n,r.device=i,r}return go(t,e),t.prototype.destroy=function(){},t}(v.EventEmitter),Yo=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.Bindings,r.bindingLayout=void 0,r.gpuBindGroup=void 0,r.bindGroupLayout=void 0;var i=n.pipeline,o=n.bindingLayout;Ke(!!i);var a=r.device._createBindGroupLayout(o),s=[[],[]],u=0;if(o.storageEntries)for(var l=0;o.storageEntries.length>l;l++){var c=n.storageBufferBindings[l];Ke(c.wordCount>0);var f={buffer:Do(c.buffer),offset:0,size:c.wordCount<<2};s[0].push({binding:u++,resource:f})}for(var d=0;o.numUniformBuffers>d;d++){var h=n.uniformBufferBindings[d];Ke(h.wordCount>0);var p={buffer:Do(h.buffer),offset:0,size:h.wordCount<<2};s[0].push({binding:u++,resource:p})}u=0;for(var _=0;o.numSamplers>_;_++){var E=void 0!==o.samplerEntries?o.samplerEntries[_]:Ot,v=n.samplerBindings[_],R=null!==v.texture?v.texture:r.device.getFallbackTexture(E);Ke(E.dimension===R.dimension),Ke(E.formatKind===Ye(R.pixelFormat)),s[1].push({binding:u++,resource:R.gpuTextureView});var g=(null!==v.sampler?v.sampler:r.device.fallbackSampler).gpuSampler;s[1].push({binding:u++,resource:g})}return r.gpuBindGroup=s.map((function(e,t){return r.device.device.createBindGroup({layout:i.getBindGroupLayout(t),entries:e})})),r.bindingLayout=n.bindingLayout,r.bindGroupLayout=a,r}return go(t,e),t}(Ho);function Ko(e){return void 0!==e.byteLength}var jo,zo=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.Buffer,r.gpuBuffer=void 0,r.size=void 0,r.view=void 0,r.usage=void 0;var i=n.usage,o=n.viewOrSize,a=Ko(o)?o.byteLength+3&-4:o+3&-4;r.usage=i,r.usage&se.MAP_READ&&(r.usage=se.MAP_READ|se.COPY_DST);var s=Ko(o);if(r.size=Ko(o)?o.byteLength:o,r.view=Ko(o)?o:null,r.gpuBuffer=r.device.device.createBuffer({usage:r.usage,size:a,mappedAtCreation:s}),s){var u=r.gpuBuffer.getMappedRange();new o.constructor(u).set(o),r.gpuBuffer.unmap()}return r}go(t,e);var r=t.prototype;return r.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var u=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(u),r=0,o=0,a=s,n=s}for(var l=15728640,c=0;a-(o+c)>l;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,l),c+=l;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)},r.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(Ho),qo=function(e){function r(r){var n,i=r.descriptor;(n=e.call(this,{id:r.id,device:r.device})||this).type=Q.InputLayout,n.buffers=void 0,n.indexFormat=void 0;for(var o=[],a=0;i.vertexBufferDescriptors.length>a;a++){var s=i.vertexBufferDescriptors[a];if(!t.isNil(s)){var u=s.byteStride,l=Wo(s.frequency);o[a]={arrayStride:u,stepMode:l,attributes:[]}}}for(var c=0;i.vertexAttributeDescriptors.length>c;c++){var f=i.vertexAttributeDescriptors[c],d=je(o[f.bufferIndex]),h={shaderLocation:f.location,format:Vo(f.format),offset:f.bufferByteOffset};d.attributes.push(h)}return n.indexFormat=function(e){if(null!==e){if(e===ye.U16_R)return"uint16";if(e===ye.U32_R)return"uint32";throw Error("whoops")}}(i.indexBufferFormat),n.buffers=o,n}return go(r,e),r}(Ho),Zo=function(e){function t(t){var r,n=t.descriptor;return(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.Program,r.descriptor=void 0,r.vertexStage=null,r.fragmentStage=null,r.computeStage=null,r.descriptor=n,n.preprocessedVert&&(r.vertexStage=r.createShaderStage(n.preprocessedVert,"vertex")),n.preprocessedFrag&&(r.fragmentStage=r.createShaderStage(n.preprocessedFrag,"fragment")),n.preprocessedCompute&&(r.computeStage=r.createShaderStage(n.preprocessedCompute,"compute")),r}return go(t,e),t.prototype.createShaderStage=function(e,t){var r=e;if("compute"!==t)try{r=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),Error("whoops")}for(var n=function(){var e=o[i];if(!r.includes(e))return"continue";r=(r=r.replace("var T_"+e+": texture_2d<f32>;","var T_"+e+": texture_depth_2d;")).replace(RegExp("textureSample\\(T_"+e+"(.*)\\);$","gm"),(function(t,r){return"vec4<f32>(textureSample(T_"+e+r+"), 0.0, 0.0, 0.0);"}))},i=0,o=["u_TextureFramebufferDepth"];o.length>i;i++)n();return{module:this.device.device.createShaderModule({code:r}),entryPoint:"main"}},t}(Ho),Qo=function(){function e(){this.commandEncoder=null,this.descriptor=void 0,this.gpuRenderPassEncoder=null,this.gpuRenderPassDescriptor=void 0,this.gpuColorAttachments=void 0,this.gpuDepthStencilAttachment=void 0,this.gfxColorAttachment=[],this.gfxColorResolveTo=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}var r=e.prototype;return r.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 r=0;e.colorAttachment.length>r;r++){var n=e.colorAttachment[r],i=e.colorResolveTo[r];if(null===n&&null!==i&&(n=i,i=null),this.gfxColorAttachment[r]=n,this.gfxColorResolveTo[r]=i,null===n){this.gpuColorAttachments.length=r,this.gfxColorAttachment.length=r,this.gfxColorResolveTo.length=r;break}void 0===this.gpuColorAttachments[r]&&(this.gpuColorAttachments[r]={});var o=this.gpuColorAttachments[r];o.view=n.gpuTextureView;var a=e.colorClearColor[r];"load"===a?o.loadOp="load":(o.loadOp="clear",o.clearValue=a),o.storeOp=e.colorStore[r]?"store":"discard",o.resolveTarget=void 0,null!==i&&(n.sampleCount>1?o.resolveTarget=i.gpuTextureView:o.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var s=this.gpuDepthStencilAttachment;s.view=e.depthStencilAttachment.gpuTextureView,"load"===e.depthClearValue?s.depthLoadOp="load":(s.depthLoadOp="clear",s.depthClearValue=e.depthClearValue),"load"===e.stencilClearValue?s.stencilLoadOp="load":(s.stencilLoadOp="clear",s.stencilClearValue=e.stencilClearValue),s.depthStoreOp=e.depthStencilStore?"store":"discard",s.stencilStoreOp=e.depthStencilStore?"store":"discard",this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment,null!==this.gfxDepthStencilResolveTo&&(s.depthStoreOp="store",s.stencilStoreOp="store")}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0},r.beginRenderPass=function(e){Ke(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},r.setViewport=function(e,t,r,n){this.gpuRenderPassEncoder.setViewport(e,t,r,n,0,1)},r.setScissor=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,t,r,n)},r.setPipeline=function(e){var t=je(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},r.setInputState=function(e){if(null!==e){var r=e;if(null!==r.indexBuffer){var n=r.inputLayout,i=r.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Do(i.buffer),je(n.indexFormat),i.byteOffset)}for(var o=0;r.vertexBuffers.length>o;o++){var a=r.vertexBuffers[o];t.isNil(a)||this.gpuRenderPassEncoder.setVertexBuffer(o,Do(a.buffer),a.byteOffset)}}},r.setBindings=function(e,t,r){var n=t;this.gpuRenderPassEncoder.setBindGroup(e+0,n.gpuBindGroup[0],r.slice(0,n.bindingLayout.numUniformBuffers)),this.gpuRenderPassEncoder.setBindGroup(e+1,n.gpuBindGroup[1])},r.setStencilRef=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},r.draw=function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)},r.drawIndexed=function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)},r.drawIndexedInstanced=function(e,t,r){this.gpuRenderPassEncoder.drawIndexed(e,r,t,0,0)},r.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},r.endOcclusionQuery=function(e){this.gpuRenderPassEncoder.endOcclusionQuery()},r.beginDebugGroup=function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)},r.endDebugGroup=function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()},r.finish=function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;this.gfxColorAttachment.length>e;e++){var t=this.gfxColorAttachment[e],r=this.gfxColorResolveTo[e];null!==t&&null!==r&&1===t.sampleCount&&this.copyAttachment(r,t)}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,this.gfxDepthStencilAttachment)),this.commandEncoder.finish()},r.copyAttachment=function(e,t){Ke(1===t.sampleCount);var r={texture:t.gpuTexture},n={texture:e.gpuTexture};Ke(t.width===e.width),Ke(t.height===e.height),Ke(!!(t.usage&yo.COPY_SRC)),Ke(!!(e.usage&yo.COPY_DST)),this.commandEncoder.copyTextureToTexture(r,n,[e.width,e.height,1])},e}(),Jo=function(e){function t(t){var r,n,i,o=t.descriptor;(i=e.call(this,{id:t.id,device:t.device})||this).type=Q.Sampler,i.gpuSampler=void 0;var a=o.minLOD,s=o.mipFilter===oe.NoMip?o.minLOD:o.maxLOD,u=null!==(r=o.maxAnisotropy)&&void 0!==r?r:1;return u>1&&Ke(o.minFilter===ie.Bilinear&&o.magFilter===ie.Bilinear&&o.mipFilter===oe.Linear),i.gpuSampler=i.device.device.createSampler({addressModeU:Oo(o.wrapS),addressModeV:Oo(o.wrapT),addressModeW:Oo(null!==(n=o.wrapQ)&&void 0!==n?n:o.wrapS),lodMinClamp:a,lodMaxClamp:s,minFilter:Io(o.minFilter),magFilter:Io(o.magFilter),mipmapFilter:No(o.mipFilter),maxAnisotropy:u}),i}return go(t,e),t}(Ho),$o=function(e){function t(t){var r,n=t.descriptor,i=t.skipCreate;return(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.Texture,r.pixelFormat=void 0,r.dimension=void 0,r.format=void 0,r.width=void 0,r.height=void 0,r.depthOrArrayLayers=void 0,r.numLevels=void 0,r.sampleCount=void 0,r.usage=void 0,r.gpuTexture=void 0,r.gpuTextureView=void 0,r.device.createTextureShared({pixelFormat:n.pixelFormat,dimension:n.dimension,width:n.width,height:n.height,depthOrArrayLayers:n.depth,numLevels:n.numLevels,usage:n.usage,sampleCount:1},To(r),i),r}go(t,e);var r=t.prototype;return r.setImageData=function(e,t){},r.destroy=function(){this.gpuTexture.destroy()},t}(Ho),ea=function(e){function t(t){var r,n=t.inputLayout,i=t.vertexBuffers,o=t.indexBuffer;return(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.InputState,r.inputLayout=void 0,r.vertexBuffers=void 0,r.indexBuffer=void 0,r.inputLayout=n,r.vertexBuffers=i,r.indexBuffer=o,r}return go(t,e),t}(Ho),ta=function(e){function t(t){var r,n=t.descriptor;return(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.RenderPipeline,r.descriptor=void 0,r.isCreating=!1,r.isCreatingAsync=!1,r.gpuRenderPipeline=null,r.descriptor=n,r.device._createRenderPipeline(To(r),!1),r}return go(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(Ho),ra=function(e){function t(t){var r;return(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.Readback,r}go(t,e);var r=t.prototype;return r.readTexture=function(e,t,r,n,i,o,a,s){void 0===a&&(a=0),void 0===s&&(s=0);var u=e,l=this.getBlockInformationFromFormat(u.format),c=256*Math.ceil(Math.ceil(n/l.width)*l.length/256),f=c*i,d=this.device.createBuffer({usage:se.STORAGE|se.MAP_READ|se.COPY_DST,hint:ue.Static,viewOrSize:f}),h=this.device.device.createCommandEncoder();return h.copyTextureToBuffer({texture:u.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:d.gpuBuffer,offset:0,bytesPerRow:c},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([h.finish()]),this.readBuffer(d,f,o,a,s,u.pixelFormat)},r.readBuffer=function(e,t,r,n,i,o,a,s){var u=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=ye.U8_RGB),void 0===a&&(a=!1);var l=e,c=i||l.size,f=r||l.view,d=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||He(o),h=l;if(!(l.usage&se.MAP_READ&&l.usage&se.COPY_DST)){var p=this.device.device.createCommandEncoder();h=this.device.createBuffer({usage:se.STORAGE|se.MAP_READ|se.COPY_DST,hint:ue.Static,viewOrSize:c}),p.copyBufferToBuffer(l.gpuBuffer,t,h.gpuBuffer,0,c),this.device.device.queue.submit([p.finish()])}return new Promise((function(e,r){h.gpuBuffer.mapAsync(Ao.READ,t,c).then((function(){var r=h.gpuBuffer.getMappedRange(t,c),n=f;if(a)n=null===n?Xo(o,c,!0,r):Xo(o,n.buffer,void 0,r);else if(null===n)switch(d){case 1:(n=new Uint8Array(c)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r);break;case 4:(n=new Float32Array(c/4)).set(new Float32Array(r))}else switch(d){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r,f);break;case 4:var i=f&&f.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}h.gpuBuffer.unmap(),e(n)}),(function(e){return r(e)}))}))},r.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r},r.getBlockInformationFromFormat=function(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":case"depth24unorm-stencil8":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}},t}(Ho),na=function(){function e(){this.commandEncoder=null,this.descriptor=void 0,this.gpuComputePassDescriptor=void 0,this.gpuComputePassEncoder=null}var t=e.prototype;return t.dispatch=function(e,t,r){this.gpuComputePassEncoder.dispatch(e,t,r)},t.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},t.beginComputePass=function(e){Ke(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},t.setPipeline=function(e){var t=je(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},t.setBindings=function(e,t){this.gpuComputePassEncoder.setBindGroup(e,t.gpuBindGroup[0])},t.setComputePassDescriptor=function(e){this.descriptor=e},e}(),ia=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.ComputePipeline,r.descriptor=void 0,r.gpuComputePipeline=null,r.descriptor=n;var i=n.program.computeStage;if(null===i)return To(r);var o={compute:Ro({},i),layout:void 0};return r.gpuComputePipeline=r.device.device.createComputePipeline(o),void 0!==r.name&&(r.gpuComputePipeline.label=r.name),r}return go(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(Ho),oa=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=Q.QueryPool,r.querySet=void 0;var i=n.elemCount;return r.querySet=r.device.device.createQuerySet({type:Bo(n.type),count:i}),r}return go(t,e),t.prototype.queryResultOcclusion=function(e){return!0},t}(Ho),aa=function(){function e(e,t,r,n,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=yo.RENDER_ATTACHMENT|yo.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new Or(Dt,Sr),this.fallbackTexture2D=void 0,this.fallbackTexture2DDepth=void 0,this.fallbackTexture2DArray=void 0,this.fallbackTexture3D=void 0,this.fallbackTextureCube=void 0,this.fallbackSampler=void 0,this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Ee.UpperLeft,this.clipSpaceNearZ=ve.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.adapter=void 0,this.device=void 0,this.canvas=void 0,this.canvasContext=void 0,this.glsl_compile=void 0,this.adapter=e,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(fe.n2D,_e.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(fe.n2D,_e.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(fe.n2DArray,_e.Float),this.fallbackTexture3D=this.createFallbackTexture(fe.n3D,_e.Float),this.fallbackTextureCube=this.createFallbackTexture(fe.Cube,_e.Float),this.fallbackSampler=this.createSampler({wrapS:ne.Clamp,wrapT:ne.Clamp,minFilter:ie.Point,magFilter:ie.Point,mipFilter:oe.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}var t=e.prototype;return t.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"}))},t.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new $o({id:0,device:this,descriptor:{pixelFormat:ye.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:fe.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r},t.getDevice=function(){return this},t.getCanvas=function(){return this.canvas},t.present=function(){},t.getNextUniqueId=function(){return++this._resourceUniqueId},t.createBuffer=function(e){return new zo({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createTexture=function(e){return new $o({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createSampler=function(e){return new Jo({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createRenderTarget=function(e){var t=new $o({id:this.getNextUniqueId(),device:this,descriptor:Ro({},e,{dimension:fe.n2D,numLevels:1,depth:1,usage:de.RenderTarget})});return t.depthOrArrayLayers=1,t.type=Q.RenderTarget,t},t.createRenderTargetFromTexture=function(e){var t=e.pixelFormat,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.numLevels,s=e.gpuTexture,u=e.gpuTextureView,l=e.usage;Ke(!!(l&yo.RENDER_ATTACHMENT));var c=new $o({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:fe.n2D,numLevels:a,usage:l},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=u,c},t.createProgram=function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)},t.createProgramSimple=function(e){return new Zo({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.numLevels,o=Co(e.pixelFormat),a=function(e){if(e===fe.n2D)return"2d";if(e===fe.Cube)return"3d";if(e===fe.n2DArray)return"3d";if(e===fe.n3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&de.Sampled&&(t|=yo.TEXTURE_BINDING|yo.COPY_DST),e&de.RenderTarget&&(t|=yo.RENDER_ATTACHMENT|yo.TEXTURE_BINDING|yo.COPY_SRC|yo.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,!r){var u=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,usage:s}),l=u.createView();t.gpuTexture=u,t.gpuTextureView=l}},t.getFallbackTexture=function(e){var t=e.dimension;if(t===fe.n2D)return e.formatKind===_e.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===fe.n2DArray)return this.fallbackTexture2DArray;if(t===fe.n3D)return this.fallbackTexture3D;if(t===fe.Cube)return this.fallbackTextureCube;throw Error("whoops")},t.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,pixelFormat:t===_e.Float?ye.U8_RGBA_NORM:ye.D24,usage:de.Sampled,width:1,height:1,depth:e===fe.Cube?6:1,numLevels:1})},t.createBindings=function(e){return new Yo({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createInputLayout=function(e){return new qo({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createInputState=function(e,t,r){return new ea({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})},t.createComputePipeline=function(e){return new ia({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createRenderPipeline=function(e){return new ta({id:this.getNextUniqueId(),device:this,descriptor:Ro({},e)})},t.createQueryPool=function(e,t){return new oa({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},t._createBindGroupLayout=function(e){var t=this.bindGroupLayoutCache.get(e);return null===t&&(t=this._createBindGroupLayoutInternal(e),this.bindGroupLayoutCache.add(e,t)),t},t._createBindGroupLayoutInternal=function(e){var t,r=this,n=[[],[]];if(e.storageEntries)for(var i=0;e.storageEntries.length>i;i++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.COMPUTE,buffer:{type:e.storageEntries[i].type}});for(var o=0;e.numUniformBuffers>o;o++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}});for(var a=0;e.numSamplers>a;a++){n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:(t=void 0!==e.samplerEntries?e.samplerEntries[a]:Ot,{sampleType:xo(t.formatKind),viewDimension:Po(t.dimension)})}),n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}})}return{gpuBindGroupLayout:n.map((function(e){return r.device.createBindGroupLayout({entries:e})}))}},t._createPipelineLayout=function(e){var t=this,r=e.flatMap((function(e){return t._createBindGroupLayout(e).gpuBindGroupLayout}));return this.device.createPipelineLayout({bindGroupLayouts:r})},t._createRenderPipeline=function(e,t){if(!e.isCreating&&null===e.gpuRenderPipeline){var r=e.descriptor,n=r.program,i=n.vertexStage,o=n.fragmentStage;if(null!==i&&null!==o){var a,s=this._createPipelineLayout(r.bindingLayouts),u=(a=r.megaStateDescriptor,{topology:Mo(r.topology),cullMode:Lo(a.cullMode),frontFace:Fo(a.frontFace)}),l=Go(r.colorAttachmentFormats,r.megaStateDescriptor),c=function(e,t){if(null!==e)return{format:Co(e),depthWriteEnabled:t.depthWrite,depthCompare:ko(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(r.depthStencilAttachmentFormat,r.megaStateDescriptor),f=void 0;null!==r.inputLayout&&(f=r.inputLayout.buffers);var d=r.sampleCount;e.isCreating=!0;var h={layout:s,vertex:Ro({},i,{buffers:f}),primitive:u,depthStencil:c,multisample:{count:d},fragment:Ro({},o,{targets:l})};e.gpuRenderPipeline=this.device.createRenderPipeline(h),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}},t.createReadback=function(){return new ra({id:this.getNextUniqueId(),device:this})},t.destroyRenderTarget=function(e){e.gpuTexture.destroy()},t.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new Qo),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},t.createComputePass=function(e){var t=this.computePassPool.pop();return void 0===t&&(t=new na),t.commandEncoder=this.device.createCommandEncoder(),t.beginComputePass(e),t},t.submitPass=function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null,r instanceof Qo?this.renderPassPool.push(r):this.computePassPool.push(r)},t.copySubTexture2D=function(e,t,r,n,i,o){var a=this.device.createCommandEncoder(),s=e,u=n,l={texture:u.gpuTexture,origin:[i,o,0]},c={texture:s.gpuTexture,origin:[t,r,0]};Ke(!!(u.usage&yo.COPY_SRC)),Ke(!!(s.usage&yo.COPY_DST)),a.copyTextureToTexture(l,c,[u.width,u.height,1]),this.device.queue.submit([a.finish()])},t.queryLimits=function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}},t.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(We(e)){case ge.BC1:case ge.BC2:case ge.BC3:case ge.BC4_SNORM:case ge.BC4_UNORM:case ge.BC5_SNORM:case ge.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(We(e)){case ge.BC1:case ge.BC2:case ge.BC3:case ge.BC4_SNORM:case ge.BC4_UNORM:case ge.BC5_SNORM:case ge.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}return!0},t.queryPlatformAvailable=function(){return!0},t.queryVendorInfo=function(){return this},t.queryRenderPass=function(e){return e.descriptor},t.queryRenderTarget=function(e){return e},t.setResourceName=function(e,t){if(e.name=t,e.type===Q.Buffer)e.gpuBuffer.label=t;else if(e.type===Q.Texture){var r=e;r.gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===Q.RenderTarget){var n=e;n.gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===Q.Sampler){e.gpuSampler.label=t}else if(e.type===Q.RenderPipeline){null!==e.gpuRenderPipeline&&(e.gpuRenderPipeline.label=t)}},t.setResourceLeakCheck=function(e,t){},t.checkForLeaks=function(){},t.programPatched=function(e){},t.pushDebugGroup=function(e){},t.popDebugGroup=function(){},t.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},t.pipelineForceReady=function(e){this._createRenderPipeline(e,!1)},e}(),sa=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});sa.decode();var ua=null;function la(){return null!==ua&&ua.buffer===jo.memory.buffer||(ua=new Uint8Array(jo.memory.buffer)),ua}function ca(e,t){return sa.decode(la().subarray(e,e+t))}var fa=Array(32).fill(void 0);fa.push(void 0,null,!0,!1);var da=fa.length;function ha(e){da===fa.length&&fa.push(fa.length+1);var t=da;return da=fa[t],fa[t]=e,t}function pa(e){return fa[e]}function _a(e){var t=pa(e);return function(e){36>e||(fa[e]=da,da=e)}(e),t}var Ea=0,va=new TextEncoder("utf-8"),Ra="function"==typeof va.encodeInto?function(e,t){return va.encodeInto(e,t)}:function(e,t){var r=va.encode(e);return t.set(r),{read:e.length,written:r.length}};function ga(e,t,r){if(void 0===r){var n=va.encode(e),i=t(n.length);return la().subarray(i,i+n.length).set(n),Ea=n.length,i}for(var o=e.length,a=t(o),s=la(),u=0;o>u;u++){var l=e.charCodeAt(u);if(l>127)break;s[a+u]=l}if(u!==o){0!==u&&(e=e.slice(u)),a=r(a,o,o=u+3*e.length);var c=la().subarray(a+u,a+o);u+=Ra(e,c).written}return Ea=u,a}var ma=null;function Ta(){return null!==ma&&ma.buffer===jo.memory.buffer||(ma=new Int32Array(jo.memory.buffer)),ma}function ya(e,t,r){try{var n=jo.__wbindgen_add_to_stack_pointer(-16),i=ga(e,jo.__wbindgen_malloc,jo.__wbindgen_realloc),o=Ea,a=ga(t,jo.__wbindgen_malloc,jo.__wbindgen_realloc);jo.glsl_compile(n,i,o,a,Ea,r);var s=Ta()[n/4+0],u=Ta()[n/4+1];return ca(s,u)}finally{jo.__wbindgen_add_to_stack_pointer(16),jo.__wbindgen_free(s,u)}}function Aa(e,t){return Sa.apply(this,arguments)}function Sa(){return(Sa=vo(_o().mark((function e(t,r){var n,i;return _o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("function"==typeof Response&&t instanceof Response)){e.next=23;break}if("function"!=typeof WebAssembly.instantiateStreaming){e.next=15;break}return e.prev=2,e.next=5,WebAssembly.instantiateStreaming(t,r);case 5:case 20:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e.catch(2),"application/wasm"==t.headers.get("Content-Type")){e.next=14;break}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",e.t0),e.next=15;break;case 14:throw e.t0;case 15:return e.next=17,t.arrayBuffer();case 17:return n=e.sent,e.next=20,WebAssembly.instantiate(n,r);case 23:return e.next=25,WebAssembly.instantiate(t,r);case 25:if(!((i=e.sent)instanceof WebAssembly.Instance)){e.next=30;break}return e.abrupt("return",{instance:i,module:t});case 30:return e.abrupt("return",i);case 31:case"end":return e.stop()}}),e,null,[[2,8]])})))).apply(this,arguments)}function Ca(e){return Oa.apply(this,arguments)}function Oa(){return(Oa=vo(_o().mark((function e(t){var r,n;return _o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r={}).wbg={},r.wbg.__wbindgen_string_new=function(e,t){return ha(ca(e,t))},r.wbg.__wbindgen_object_drop_ref=function(e){_a(e)},r.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(pa(e))},r.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(pa(e),pa(t))},r.wbg.__wbindgen_throw=function(e,t){throw Error(ca(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t)),e.t0=Aa,e.next=12,t;case 12:return e.t1=e.sent,e.t2=r,e.next=16,(0,e.t0)(e.t1,e.t2);case 16:return jo=(n=e.sent).instance.exports,Ca.__wbindgen_wasm_module=n.module,e.abrupt("return",jo);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ia=function(){function e(){this.pluginOptions=void 0}return e.prototype.createSwapChain=function(){var e=vo(_o().mark((function e(t){var r,n,i,o;return _o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==navigator.gpu){e.next=2;break}return e.abrupt("return",null);case 2:return r=null,e.prev=3,e.next=6,navigator.gpu.requestAdapter();case 6:r=e.sent,e.next=12;break;case 9:e.prev=9,e.t0=e.catch(3),console.log(e.t0);case 12:if(null!==r){e.next=14;break}return e.abrupt("return",null);case 14:return n=["depth24unorm-stencil8","depth32float-stencil8","texture-compression-bc"].filter((function(e){return r.features.has(e)})),e.next=18,r.requestDevice({requiredFeatures:n});case 18:if(null!==(i=e.sent)){e.next=21;break}return e.abrupt("return",null);case 21:if(o=t.getContext("webgpu")){e.next=24;break}return e.abrupt("return",null);case 24:return e.prev=24,e.next=27,Ca("/glsl_wgsl_compiler_bg.wasm");case 27:e.next=31;break;case 29:e.prev=29,e.t1=e.catch(24);case 31:return e.abrupt("return",new aa(r,i,t,o,ya));case 32:case"end":return e.stop()}}),e,null,[[3,9],[24,29]])})));return function(t){return e.apply(this,arguments)}}(),e}();i([r.inject(So),o("design:type",Object)],Ia.prototype,"pluginOptions",void 0),Ia=i([r.singleton({token:zi})],Ia);var Na,xa,Pa=r.Module((function(e){e(Ia)})),Da=function(){function e(e){void 0===e&&(e={}),this.options=void 0,this.name="webgpu-device",this.options=e}var t=e.prototype;return t.init=function(e){e.register(So,{useValue:Ro({},this.options)}),e.load(Pa,!0)},t.destroy=function(e){e.remove(So),e.unload(Pa)},e}(),Ba=Object.freeze({__proto__:null,Plugin:Da});function Ma(){
|
|
7
|
+
Ko=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.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,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"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,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,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(A),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):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),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function zo(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function qo(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){zo(o,n,i,a,s,"next",e)}function s(e){zo(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Zo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qo(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Jo(e,t,r){return t&&Qo(e.prototype,t),r&&Qo(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function $o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ea(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&&ra(e,t)}function ta(e){return ta=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ta(e)}function ra(e,t){return ra=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ra(e,t)}function na(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ia(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return na(e)}function oa(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 r,n=ta(e);if(t){var i=ta(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return ia(this,r)}}function aa(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ta(e)););return e}function sa(){return sa="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=aa(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},sa.apply(this,arguments)}var ua,la,ca=r.Syringe.defineToken("WebGPUDeviceOptions");function fa(e){if(e===it.U8_RGBA_RT)return"bgra8unorm";if(e===it.U8_RGBA_NORM)return"rgba8unorm";if(e===it.U8_RG_NORM)return"rg8unorm";if(e===it.U32_R)return"r32uint";if(e===it.D24)return"depth24plus";if(e===it.D24_S8)return"depth24plus-stencil8";if(e===it.D32F)return"depth32float";if(e===it.D32F_S8)return"depth32float-stencil8";if(e===it.BC1)return"bc1-rgba-unorm";if(e===it.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===it.BC2)return"bc2-rgba-unorm";if(e===it.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===it.BC3)return"bc3-rgba-unorm";if(e===it.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===it.BC4_SNORM)return"bc4-r-snorm";if(e===it.BC4_UNORM)return"bc4-r-unorm";if(e===it.BC5_SNORM)return"bc5-rg-snorm";if(e===it.BC5_UNORM)return"bc5-rg-unorm";throw Error("whoops")}function ha(e){if(e===ke.Clamp)return"clamp-to-edge";if(e===ke.Repeat)return"repeat";if(e===ke.Mirror)return"mirror-repeat";throw Error("whoops")}function da(e){if(e===Ge.Bilinear)return"linear";if(e===Ge.Point)return"nearest";throw Error("whoops")}function pa(e){if(e===We.Linear)return"linear";if(e===We.Nearest)return"nearest";if(e===We.NoMip)return"nearest";throw Error("whoops")}function _a(e){if(e===Qe.Float)return"float";if(e===Qe.Depth)return"depth";throw Error("whoops")}function va(e){if(e===Ke.n2D)return"2d";if(e===Ke.n2DArray)return"2d-array";if(e===Ke.n3D)return"3d";if(e===Ke.Cube)return"cube";throw Error("whoops")}function Ea(e){return e.gpuBuffer}function ya(e){if(e===et.OcclusionConservative)return"occlusion";throw Error("whoops")}function ga(e){switch(e){case Ve.Triangles:return"triangle-list";case Ve.Points:return"point-list";case Ve.TriangleStrip:return"triangle-strip";case Ve.Lines:return"line-list";case Ve.LineStrip:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function ma(e){if(e===Fe.None)return"none";if(e===Fe.Front)return"front";if(e===Fe.Back)return"back";throw Error("whoops")}function Ra(e){if(e===Le.CCW)return"ccw";if(e===Le.CW)return"cw";throw Error("whoops")}function Ta(e){if(e===Ue.Zero)return"zero";if(e===Ue.One)return"one";if(e===Ue.Src)return"src";if(e===Ue.OneMinusSrc)return"one-minus-src";if(e===Ue.Dst)return"dst";if(e===Ue.OneMinusDst)return"one-minus-dst";if(e===Ue.SrcAlpha)return"src-alpha";if(e===Ue.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===Ue.DstAlpha)return"dst-alpha";if(e===Ue.OneMinusDstAlpha)return"one-minus-dst-alpha";throw Error("whoops")}function Aa(e){if(e===we.Add)return"add";if(e===we.Subtract)return"subtract";if(e===we.ReverseSubtract)return"reverse-subtract";throw Error("whoops")}function Sa(e){return{operation:Aa(e.blendMode),srcFactor:Ta(e.blendSrcFactor),dstFactor:Ta(e.blendDstFactor)}}function Ca(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:fa(t),blend:{color:Sa(e.rgbBlendState),alpha:Sa(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[r])}))}function Oa(e){if(e===be.Never)return"never";if(e===be.Less)return"less";if(e===be.Equal)return"equal";if(e===be.LessEqual)return"less-equal";if(e===be.Greater)return"greater";if(e===be.NotEqual)return"not-equal";if(e===be.GreaterEqual)return"greater-equal";if(e===be.Always)return"always";throw Error("whoops")}function Ia(e){if(e===je.PerVertex)return"vertex";if(e===je.PerInstance)return"instance";throw Error("whoops")}function Na(e){if(e===it.U8_R)return"uint8x2";if(e===it.U8_RG)return"uint8x2";if(e===it.U8_RGB)return"uint8x4";if(e===it.U8_RGBA)return"uint8x4";if(e===it.U8_RGBA_NORM)return"unorm8x4";if(e===it.S8_RGB_NORM)return"snorm8x4";if(e===it.S8_RGBA_NORM)return"snorm8x4";if(e===it.S16_RG)return"uint16x2";if(e===it.F32_R)return"float32";if(e===it.F32_RG)return"float32x2";if(e===it.F32_RGB)return"float32x3";if(e===it.F32_RGBA)return"float32x4";throw Error("whoops")}function xa(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3?arguments[3]:void 0;switch(e){case it.S8_R:case it.S8_R_NORM:case it.S8_RG_NORM:case it.S8_RGB_NORM:case it.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case it.U8_R:case it.U8_R_NORM:case it.U8_RG:case it.U8_RG_NORM:case it.U8_RGB:case it.U8_RGB_NORM:case it.U8_RGB_SRGB:case it.U8_RGBA:case it.U8_RGBA_NORM:case it.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case it.S16_R:case it.S16_RG:case it.S16_RG_NORM:case it.S16_RGB_NORM:case it.S16_RGBA:case it.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case it.U16_R:case it.U16_RGB:case it.U16_RGBA_5551:case it.U16_RGBA_NORM:case it.U16_RG_NORM:case it.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case it.S32_R:var u=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&u.set(new Int32Array(n)),u;case it.U32_R:case it.U32_RG:var l=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&l.set(new Uint32Array(n)),l;case it.F32_R:case it.F32_RG:case it.F32_RGB:case it.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(ua||(ua={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(la||(la={}));var Pa=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device;return Zo(this,r),(n=t.call(this)).type=void 0,n.id=void 0,n.name=void 0,n.device=void 0,n.id=i,n.device=o,n}return Jo(r,[{key:"destroy",value:function(){}}]),r}(O.EventEmitter),Da=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.Bindings,n.bindingLayout=void 0,n.gpuBindGroup=void 0,n.bindGroupLayout=void 0;var s=a.pipeline,u=a.bindingLayout;vt(!!s);var l=n.device._createBindGroupLayout(u),c=[[],[]],f=0;if(u.storageEntries)for(var h=0;u.storageEntries.length>h;h++){var d=a.storageBufferBindings[h];vt(d.wordCount>0);var p={buffer:Ea(d.buffer),offset:0,size:d.wordCount<<2};c[0].push({binding:f++,resource:p})}for(var _=0;u.numUniformBuffers>_;_++){var v=a.uniformBufferBindings[_];vt(v.wordCount>0);var E={buffer:Ea(v.buffer),offset:0,size:v.wordCount<<2};c[0].push({binding:f++,resource:E})}f=0;for(var y=0;u.numSamplers>y;y++){var g=void 0!==u.samplerEntries?u.samplerEntries[y]:Zt,m=a.samplerBindings[y],R=null!==m.texture?m.texture:n.device.getFallbackTexture(g);vt(g.dimension===R.dimension),vt(g.formatKind===_t(R.pixelFormat)),c[1].push({binding:f++,resource:R.gpuTextureView});var T=(null!==m.sampler?m.sampler:n.device.fallbackSampler).gpuSampler;c[1].push({binding:f++,resource:T})}return n.gpuBindGroup=c.map((function(e,t){return n.device.device.createBindGroup({layout:s.getBindGroupLayout(t),entries:e})})),n.bindingLayout=a.bindingLayout,n.bindGroupLayout=l,n}return Jo(r)}(Pa);function Ba(e){return void 0!==e.byteLength}var Ma,ba=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.Buffer,n.gpuBuffer=void 0,n.size=void 0,n.view=void 0,n.usage=void 0;var s=a.usage,u=a.viewOrSize,l=Ba(u)?u.byteLength+3&-4:u+3&-4;n.usage=s,n.usage&Xe.MAP_READ&&(n.usage=Xe.MAP_READ|Xe.COPY_DST);var c=Ba(u);if(n.size=Ba(u)?u.byteLength:u,n.view=Ba(u)?u:null,n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:l,mappedAtCreation:c}),c){var f=n.gpuBuffer.getMappedRange();new u.constructor(f).set(u),n.gpuBuffer.unmap()}return n}return Jo(r,[{key:"setSubData",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var u=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(u),r=0,o=0,a=s,n=s}for(var l=15728640,c=0;a-(o+c)>l;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,l),c+=l;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)}},{key:"destroy",value:function(){sa(ta(r.prototype),"destroy",this).call(this),this.gpuBuffer.destroy()}}]),r}(Pa),La=function(e){ea(n,e);var r=oa(n);function n(e){var i,o=e.id,a=e.device,s=e.descriptor;Zo(this,n),(i=r.call(this,{id:o,device:a})).type=Me.InputLayout,i.buffers=void 0,i.indexFormat=void 0;for(var u=[],l=0;s.vertexBufferDescriptors.length>l;l++){var c=s.vertexBufferDescriptors[l];if(!t.isNil(c)){var f=c.byteStride,h=Ia(c.frequency);u[l]={arrayStride:f,stepMode:h,attributes:[]}}}for(var d=0;s.vertexAttributeDescriptors.length>d;d++){var p=s.vertexAttributeDescriptors[d],_=Et(u[p.bufferIndex]),v={shaderLocation:p.location,format:Na(p.format),offset:p.bufferByteOffset};_.attributes.push(v)}return i.indexFormat=function(e){if(null!==e){if(e===it.U16_R)return"uint16";if(e===it.U32_R)return"uint32";throw Error("whoops")}}(s.indexBufferFormat),i.buffers=u,i}return Jo(n)}(Pa),Fa=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;return Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.Program,n.descriptor=void 0,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=a,a.preprocessedVert&&(n.vertexStage=n.createShaderStage(a.preprocessedVert,"vertex")),a.preprocessedFrag&&(n.fragmentStage=n.createShaderStage(a.preprocessedFrag,"fragment")),a.preprocessedCompute&&(n.computeStage=n.createShaderStage(a.preprocessedCompute,"compute")),n}return Jo(r,[{key:"createShaderStage",value:function(e,t){var r=e;if("compute"!==t)try{r=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),Error("whoops")}for(var n=function(){var e=o[i];if(!r.includes(e))return"continue";r=(r=r.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),(function(t,r){return"vec4<f32>(textureSample(T_".concat(e).concat(r,"), 0.0, 0.0, 0.0);")}))},i=0,o=["u_TextureFramebufferDepth"];o.length>i;i++)n();return{module:this.device.device.createShaderModule({code:r}),entryPoint:"main"}}}]),r}(Pa),Ua=function(){function e(){Zo(this,e),this.commandEncoder=null,this.descriptor=void 0,this.gpuRenderPassEncoder=null,this.gpuRenderPassDescriptor=void 0,this.gpuColorAttachments=void 0,this.gpuDepthStencilAttachment=void 0,this.gfxColorAttachment=[],this.gfxColorResolveTo=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return Jo(e,[{key:"setRenderPassDescriptor",value: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 r=0;e.colorAttachment.length>r;r++){var n=e.colorAttachment[r],i=e.colorResolveTo[r];if(null===n&&null!==i&&(n=i,i=null),this.gfxColorAttachment[r]=n,this.gfxColorResolveTo[r]=i,null===n){this.gpuColorAttachments.length=r,this.gfxColorAttachment.length=r,this.gfxColorResolveTo.length=r;break}void 0===this.gpuColorAttachments[r]&&(this.gpuColorAttachments[r]={});var o=this.gpuColorAttachments[r];o.view=n.gpuTextureView;var a=e.colorClearColor[r];"load"===a?o.loadOp="load":(o.loadOp="clear",o.clearValue=a),o.storeOp=e.colorStore[r]?"store":"discard",o.resolveTarget=void 0,null!==i&&(n.sampleCount>1?o.resolveTarget=i.gpuTextureView:o.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var s=this.gpuDepthStencilAttachment;s.view=e.depthStencilAttachment.gpuTextureView,"load"===e.depthClearValue?s.depthLoadOp="load":(s.depthLoadOp="clear",s.depthClearValue=e.depthClearValue),"load"===e.stencilClearValue?s.stencilLoadOp="load":(s.stencilLoadOp="clear",s.stencilClearValue=e.stencilClearValue),s.depthStoreOp=e.depthStencilStore?"store":"discard",s.stencilStoreOp=e.depthStencilStore?"store":"discard",this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment,null!==this.gfxDepthStencilResolveTo&&(s.depthStoreOp="store",s.stencilStoreOp="store")}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0}},{key:"beginRenderPass",value:function(e){vt(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)}},{key:"setViewport",value:function(e,t,r,n){this.gpuRenderPassEncoder.setViewport(e,t,r,n,0,1)}},{key:"setScissor",value:function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,t,r,n)}},{key:"setPipeline",value:function(e){var t=Et(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)}},{key:"setInputState",value:function(e){if(null!==e){var r=e;if(null!==r.indexBuffer){var n=r.inputLayout,i=r.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Ea(i.buffer),Et(n.indexFormat),i.byteOffset)}for(var o=0;r.vertexBuffers.length>o;o++){var a=r.vertexBuffers[o];t.isNil(a)||this.gpuRenderPassEncoder.setVertexBuffer(o,Ea(a.buffer),a.byteOffset)}}}},{key:"setBindings",value:function(e,t,r){var n=t;this.gpuRenderPassEncoder.setBindGroup(e+0,n.gpuBindGroup[0],r.slice(0,n.bindingLayout.numUniformBuffers)),this.gpuRenderPassEncoder.setBindGroup(e+1,n.gpuBindGroup[1])}},{key:"setStencilRef",value:function(e){this.gpuRenderPassEncoder.setStencilReference(e)}},{key:"draw",value:function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)}},{key:"drawIndexed",value:function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)}},{key:"drawIndexedInstanced",value:function(e,t,r){this.gpuRenderPassEncoder.drawIndexed(e,r,t,0,0)}},{key:"beginOcclusionQuery",value:function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)}},{key:"endOcclusionQuery",value:function(e){this.gpuRenderPassEncoder.endOcclusionQuery()}},{key:"beginDebugGroup",value:function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)}},{key:"endDebugGroup",value:function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()}},{key:"finish",value:function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;this.gfxColorAttachment.length>e;e++){var t=this.gfxColorAttachment[e],r=this.gfxColorResolveTo[e];null!==t&&null!==r&&1===t.sampleCount&&this.copyAttachment(r,t)}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,this.gfxDepthStencilAttachment)),this.commandEncoder.finish()}},{key:"copyAttachment",value:function(e,t){vt(1===t.sampleCount);var r={texture:t.gpuTexture},n={texture:e.gpuTexture};vt(t.width===e.width),vt(t.height===e.height),vt(!!(t.usage&ua.COPY_SRC)),vt(!!(e.usage&ua.COPY_DST)),this.commandEncoder.copyTextureToTexture(r,n,[e.width,e.height,1])}}]),e}(),wa=function(e){ea(r,e);var t=oa(r);function r(e){var n,i,o,a=e.id,s=e.device,u=e.descriptor;Zo(this,r),(o=t.call(this,{id:a,device:s})).type=Me.Sampler,o.gpuSampler=void 0;var l=u.minLOD,c=u.mipFilter===We.NoMip?u.minLOD:u.maxLOD,f=null!==(n=u.maxAnisotropy)&&void 0!==n?n:1;return f>1&&vt(u.minFilter===Ge.Bilinear&&u.magFilter===Ge.Bilinear&&u.mipFilter===We.Linear),o.gpuSampler=o.device.device.createSampler({addressModeU:ha(u.wrapS),addressModeV:ha(u.wrapT),addressModeW:ha(null!==(i=u.wrapQ)&&void 0!==i?i:u.wrapS),lodMinClamp:l,lodMaxClamp:c,minFilter:da(u.minFilter),magFilter:da(u.magFilter),mipmapFilter:pa(u.mipFilter),maxAnisotropy:f}),o}return Jo(r)}(Pa),ka=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor,s=e.skipCreate;return Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.Texture,n.pixelFormat=void 0,n.dimension=void 0,n.format=void 0,n.width=void 0,n.height=void 0,n.depthOrArrayLayers=void 0,n.numLevels=void 0,n.sampleCount=void 0,n.usage=void 0,n.gpuTexture=void 0,n.gpuTextureView=void 0,n.device.createTextureShared({pixelFormat:a.pixelFormat,dimension:a.dimension,width:a.width,height:a.height,depthOrArrayLayers:a.depth,numLevels:a.numLevels,usage:a.usage,sampleCount:1},na(n),s),n}return Jo(r,[{key:"setImageData",value:function(e,t){}},{key:"destroy",value:function(){this.gpuTexture.destroy()}}]),r}(Pa),Ga=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.inputLayout,s=e.vertexBuffers,u=e.indexBuffer;return Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.InputState,n.inputLayout=void 0,n.vertexBuffers=void 0,n.indexBuffer=void 0,n.inputLayout=a,n.vertexBuffers=s,n.indexBuffer=u,n}return Jo(r)}(Pa),Wa=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;return Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.RenderPipeline,n.descriptor=void 0,n.isCreating=!1,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=a,n.device._createRenderPipeline(na(n),!1),n}return Jo(r,[{key:"getBindGroupLayout",value:function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)}}]),r}(Pa),Va=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device;return Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.Readback,n}return Jo(r,[{key:"readTexture",value:function(e,t,r,n,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,u=e,l=0,c=this.getBlockInformationFromFormat(u.format),f=Math.ceil(n/c.width)*c.length,h=256*Math.ceil(f/256),d=h*i,p=this.device.createBuffer({usage:Xe.STORAGE|Xe.MAP_READ|Xe.COPY_DST,hint:He.Static,viewOrSize:d}),_=this.device.device.createCommandEncoder();return _.copyTextureToBuffer({texture:u.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:Math.max(l,0)}},{buffer:p.gpuBuffer,offset:0,bytesPerRow:h},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([_.finish()]),this.readBuffer(p,d,o,a,s,u.pixelFormat)}},{key:"readBuffer",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:it.U8_RGB,a=arguments.length>6&&void 0!==arguments[6]&&arguments[6],s=e,u=i||s.size,l=n||s.view,c=l&&l.constructor&&l.constructor.BYTES_PER_ELEMENT||pt(o),f=s;if(!(s.usage&Xe.MAP_READ&&s.usage&Xe.COPY_DST)){var h=this.device.device.createCommandEncoder();f=this.device.createBuffer({usage:Xe.STORAGE|Xe.MAP_READ|Xe.COPY_DST,hint:He.Static,viewOrSize:u}),h.copyBufferToBuffer(s.gpuBuffer,r,f.gpuBuffer,0,u),this.device.device.queue.submit([h.finish()])}return new Promise((function(e,n){f.gpuBuffer.mapAsync(la.READ,r,u).then((function(){var n=f.gpuBuffer.getMappedRange(r,u),i=l;if(a)i=null===i?xa(o,u,!0,n):xa(o,i.buffer,void 0,n);else if(null===i)switch(c){case 1:(i=new Uint8Array(u)).set(new Uint8Array(n));break;case 2:i=t.getHalfFloatAsFloatRGBAArrayBuffer(u/2,n);break;case 4:(i=new Float32Array(u/4)).set(new Float32Array(n))}else switch(c){case 1:(i=new Uint8Array(i.buffer)).set(new Uint8Array(n));break;case 2:i=t.getHalfFloatAsFloatRGBAArrayBuffer(u/2,n,l);break;case 4:var s=l&&l.constructor||Float32Array;(i=new s(i.buffer)).set(new s(n))}f.gpuBuffer.unmap(),e(i)}),(function(e){return n(e)}))}))}},{key:"getHalfFloatAsFloatRGBAArrayBuffer",value:function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r}},{key:"getBlockInformationFromFormat",value:function(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":case"depth24unorm-stencil8":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}}}]),r}(Pa),Xa=function(){function e(){Zo(this,e),this.commandEncoder=null,this.descriptor=void 0,this.gpuComputePassDescriptor=void 0,this.gpuComputePassEncoder=null}return Jo(e,[{key:"dispatch",value:function(e,t,r){this.gpuComputePassEncoder.dispatch(e,t,r)}},{key:"finish",value:function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()}},{key:"beginComputePass",value:function(e){vt(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)}},{key:"setPipeline",value:function(e){var t=Et(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)}},{key:"setBindings",value:function(e,t){this.gpuComputePassEncoder.setBindGroup(e,t.gpuBindGroup[0])}},{key:"setComputePassDescriptor",value:function(e){this.descriptor=e}}]),e}(),Ha=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.ComputePipeline,n.descriptor=void 0,n.gpuComputePipeline=null,n.descriptor=a;var s=a.program.computeStage;if(null===s)return ia(n);var u={compute:Yo({},s),layout:void 0};return n.gpuComputePipeline=n.device.device.createComputePipeline(u),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return Jo(r,[{key:"getBindGroupLayout",value:function(e){return this.gpuComputePipeline.getBindGroupLayout(e)}}]),r}(Pa),ja=function(e){ea(r,e);var t=oa(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Zo(this,r),(n=t.call(this,{id:i,device:o})).type=Me.QueryPool,n.querySet=void 0;var s=a.elemCount;return n.querySet=n.device.device.createQuerySet({type:ya(a.type),count:s}),n}return Jo(r,[{key:"queryResultOcclusion",value:function(e){return!0}}]),r}(Pa),Ya=function(){function e(t,r,n,i,o){Zo(this,e),this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=ua.RENDER_ATTACHMENT|ua.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new Zr(tr,zr),this.fallbackTexture2D=void 0,this.fallbackTexture2DDepth=void 0,this.fallbackTexture2DArray=void 0,this.fallbackTexture3D=void 0,this.fallbackTextureCube=void 0,this.fallbackSampler=void 0,this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Je.UpperLeft,this.clipSpaceNearZ=$e.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.adapter=void 0,this.device=void 0,this.canvas=void 0,this.canvasContext=void 0,this.glsl_compile=void 0,this.adapter=t,this.device=r,this.canvas=n,this.canvasContext=i,this.glsl_compile=o,this.fallbackTexture2D=this.createFallbackTexture(Ke.n2D,Qe.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(Ke.n2D,Qe.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(Ke.n2DArray,Qe.Float),this.fallbackTexture3D=this.createFallbackTexture(Ke.n3D,Qe.Float),this.fallbackTextureCube=this.createFallbackTexture(Ke.Cube,Qe.Float),this.fallbackSampler=this.createSampler({wrapS:ke.Clamp,wrapT:ke.Clamp,minFilter:Ge.Point,magFilter:Ge.Point,mipFilter:We.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}return Jo(e,[{key:"configureSwapChain",value: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"}))}},{key:"getOnscreenTexture",value:function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new ka({id:0,device:this,descriptor:{pixelFormat:it.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:Ke.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r}},{key:"getDevice",value:function(){return this}},{key:"getCanvas",value:function(){return this.canvas}},{key:"present",value:function(){}},{key:"getNextUniqueId",value:function(){return++this._resourceUniqueId}},{key:"createBuffer",value:function(e){return new ba({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createTexture",value:function(e){return new ka({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createSampler",value:function(e){return new wa({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createRenderTarget",value:function(e){var t=new ka({id:this.getNextUniqueId(),device:this,descriptor:Yo(Yo({},e),{},{dimension:Ke.n2D,numLevels:1,depth:1,usage:ze.RenderTarget})});return t.depthOrArrayLayers=1,t.type=Me.RenderTarget,t}},{key:"createRenderTargetFromTexture",value:function(e){var t=e.pixelFormat,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.numLevels,s=e.gpuTexture,u=e.gpuTextureView,l=e.usage;vt(!!(l&ua.RENDER_ATTACHMENT));var c=new ka({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:Ke.n2D,numLevels:a,usage:l},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=u,c}},{key:"createProgram",value:function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)}},{key:"createProgramSimple",value:function(e){return new Fa({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createTextureShared",value:function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.numLevels,o=fa(e.pixelFormat),a=function(e){if(e===Ke.n2D)return"2d";if(e===Ke.Cube)return"3d";if(e===Ke.n2DArray)return"3d";if(e===Ke.n3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&ze.Sampled&&(t|=ua.TEXTURE_BINDING|ua.COPY_DST),e&ze.RenderTarget&&(t|=ua.RENDER_ATTACHMENT|ua.TEXTURE_BINDING|ua.COPY_SRC|ua.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,!r){var u=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,usage:s}),l=u.createView();t.gpuTexture=u,t.gpuTextureView=l}}},{key:"getFallbackTexture",value:function(e){var t=e.dimension;if(t===Ke.n2D)return e.formatKind===Qe.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===Ke.n2DArray)return this.fallbackTexture2DArray;if(t===Ke.n3D)return this.fallbackTexture3D;if(t===Ke.Cube)return this.fallbackTextureCube;throw Error("whoops")}},{key:"createFallbackTexture",value:function(e,t){return this.createTexture({dimension:e,pixelFormat:t===Qe.Float?it.U8_RGBA_NORM:it.D24,usage:ze.Sampled,width:1,height:1,depth:e===Ke.Cube?6:1,numLevels:1})}},{key:"createBindings",value:function(e){return new Da({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createInputLayout",value:function(e){return new La({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createInputState",value:function(e,t,r){return new Ga({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})}},{key:"createComputePipeline",value:function(e){return new Ha({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createRenderPipeline",value:function(e){return new Wa({id:this.getNextUniqueId(),device:this,descriptor:Yo({},e)})}},{key:"createQueryPool",value:function(e,t){return new ja({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})}},{key:"_createBindGroupLayout",value:function(e){var t=this.bindGroupLayoutCache.get(e);return null===t&&(t=this._createBindGroupLayoutInternal(e),this.bindGroupLayoutCache.add(e,t)),t}},{key:"_createBindGroupLayoutInternal",value:function(e){var t,r=this,n=[[],[]];if(e.storageEntries)for(var i=0;e.storageEntries.length>i;i++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.COMPUTE,buffer:{type:e.storageEntries[i].type}});for(var o=0;e.numUniformBuffers>o;o++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}});for(var a=0;e.numSamplers>a;a++){n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:(t=void 0!==e.samplerEntries?e.samplerEntries[a]:Zt,{sampleType:_a(t.formatKind),viewDimension:va(t.dimension)})}),n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}})}return{gpuBindGroupLayout:n.map((function(e){return r.device.createBindGroupLayout({entries:e})}))}}},{key:"_createPipelineLayout",value:function(e){var t=this,r=e.flatMap((function(e){return t._createBindGroupLayout(e).gpuBindGroupLayout}));return this.device.createPipelineLayout({bindGroupLayouts:r})}},{key:"_createRenderPipeline",value:function(e){if(!e.isCreating&&null===e.gpuRenderPipeline){var t=e.descriptor,r=t.program,n=r.vertexStage,i=r.fragmentStage;if(null!==n&&null!==i){var o,a=this._createPipelineLayout(t.bindingLayouts),s=(o=t.megaStateDescriptor,{topology:ga(t.topology),cullMode:ma(o.cullMode),frontFace:Ra(o.frontFace)}),u=Ca(t.colorAttachmentFormats,t.megaStateDescriptor),l=function(e,t){if(null!==e)return{format:fa(e),depthWriteEnabled:t.depthWrite,depthCompare:Oa(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(t.depthStencilAttachmentFormat,t.megaStateDescriptor),c=void 0;null!==t.inputLayout&&(c=t.inputLayout.buffers);var f=t.sampleCount;e.isCreating=!0;var h={layout:a,vertex:Yo(Yo({},n),{},{buffers:c}),primitive:s,depthStencil:l,multisample:{count:f},fragment:Yo(Yo({},i),{},{targets:u})};e.gpuRenderPipeline=this.device.createRenderPipeline(h),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}}},{key:"createReadback",value:function(){return new Va({id:this.getNextUniqueId(),device:this})}},{key:"destroyRenderTarget",value:function(e){e.gpuTexture.destroy()}},{key:"createRenderPass",value:function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new Ua),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t}},{key:"createComputePass",value:function(e){var t=this.computePassPool.pop();return void 0===t&&(t=new Xa),t.commandEncoder=this.device.createCommandEncoder(),t.beginComputePass(e),t}},{key:"submitPass",value:function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null,r instanceof Ua?this.renderPassPool.push(r):this.computePassPool.push(r)}},{key:"copySubTexture2D",value:function(e,t,r,n,i,o){var a=this.device.createCommandEncoder(),s=e,u=n,l={texture:u.gpuTexture,origin:[i,o,0]},c={texture:s.gpuTexture,origin:[t,r,0]};vt(!!(u.usage&ua.COPY_SRC)),vt(!!(s.usage&ua.COPY_DST)),a.copyTextureToTexture(l,c,[u.width,u.height,1]),this.device.queue.submit([a.finish()])}},{key:"queryLimits",value:function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}}},{key:"queryTextureFormatSupported",value:function(e,t,r){if(function(e){switch(ft(e)){case tt.BC1:case tt.BC2:case tt.BC3:case tt.BC4_SNORM:case tt.BC4_UNORM:case tt.BC5_SNORM:case tt.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(ft(e)){case tt.BC1:case tt.BC2:case tt.BC3:case tt.BC4_SNORM:case tt.BC4_UNORM:case tt.BC5_SNORM:case tt.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}return!0}},{key:"queryPlatformAvailable",value:function(){return!0}},{key:"queryVendorInfo",value:function(){return this}},{key:"queryRenderPass",value:function(e){return e.descriptor}},{key:"queryRenderTarget",value:function(e){return e}},{key:"setResourceName",value:function(e,t){if(e.name=t,e.type===Me.Buffer)e.gpuBuffer.label=t;else if(e.type===Me.Texture){var r=e;r.gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===Me.RenderTarget){var n=e;n.gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===Me.Sampler){e.gpuSampler.label=t}else if(e.type===Me.RenderPipeline){null!==e.gpuRenderPipeline&&(e.gpuRenderPipeline.label=t)}}},{key:"setResourceLeakCheck",value:function(e,t){}},{key:"checkForLeaks",value:function(){}},{key:"programPatched",value:function(e){}},{key:"pushDebugGroup",value:function(e){}},{key:"popDebugGroup",value:function(){}},{key:"pipelineQueryReady",value:function(e){return null!==e.gpuRenderPipeline}},{key:"pipelineForceReady",value:function(e){this._createRenderPipeline(e,!1)}}]),e}(),Ka=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Ka.decode();var za=null;function qa(){return null!==za&&za.buffer===Ma.memory.buffer||(za=new Uint8Array(Ma.memory.buffer)),za}function Za(e,t){return Ka.decode(qa().subarray(e,e+t))}var Qa=Array(32).fill(void 0);Qa.push(void 0,null,!0,!1);var Ja=Qa.length;function $a(e){Ja===Qa.length&&Qa.push(Qa.length+1);var t=Ja;return Ja=Qa[t],Qa[t]=e,t}function es(e){return Qa[e]}function ts(e){var t=es(e);return function(e){36>e||(Qa[e]=Ja,Ja=e)}(e),t}var rs=0,ns=new TextEncoder("utf-8"),is="function"==typeof ns.encodeInto?function(e,t){return ns.encodeInto(e,t)}:function(e,t){var r=ns.encode(e);return t.set(r),{read:e.length,written:r.length}};function os(e,t,r){if(void 0===r){var n=ns.encode(e),i=t(n.length);return qa().subarray(i,i+n.length).set(n),rs=n.length,i}for(var o=e.length,a=t(o),s=qa(),u=0;o>u;u++){var l=e.charCodeAt(u);if(l>127)break;s[a+u]=l}if(u!==o){0!==u&&(e=e.slice(u)),a=r(a,o,o=u+3*e.length);var c=qa().subarray(a+u,a+o);u+=is(e,c).written}return rs=u,a}var as=null;function ss(){return null!==as&&as.buffer===Ma.memory.buffer||(as=new Int32Array(Ma.memory.buffer)),as}function us(e,t,r){try{var n=Ma.__wbindgen_add_to_stack_pointer(-16),i=os(e,Ma.__wbindgen_malloc,Ma.__wbindgen_realloc),o=rs,a=os(t,Ma.__wbindgen_malloc,Ma.__wbindgen_realloc);Ma.glsl_compile(n,i,o,a,rs,r);var s=ss()[n/4+0],u=ss()[n/4+1];return Za(s,u)}finally{Ma.__wbindgen_add_to_stack_pointer(16),Ma.__wbindgen_free(s,u)}}function ls(e,t){return cs.apply(this,arguments)}function cs(){return(cs=qo(Ko().mark((function e(t,r){var n,i;return Ko().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("function"==typeof Response&&t instanceof Response)){e.next=23;break}if("function"!=typeof WebAssembly.instantiateStreaming){e.next=15;break}return e.prev=2,e.next=5,WebAssembly.instantiateStreaming(t,r);case 5:case 20:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e.catch(2),"application/wasm"==t.headers.get("Content-Type")){e.next=14;break}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",e.t0),e.next=15;break;case 14:throw e.t0;case 15:return e.next=17,t.arrayBuffer();case 17:return n=e.sent,e.next=20,WebAssembly.instantiate(n,r);case 23:return e.next=25,WebAssembly.instantiate(t,r);case 25:if(!((i=e.sent)instanceof WebAssembly.Instance)){e.next=30;break}return e.abrupt("return",{instance:i,module:t});case 30:return e.abrupt("return",i);case 31:case"end":return e.stop()}}),e,null,[[2,8]])})))).apply(this,arguments)}function fs(e){return hs.apply(this,arguments)}function hs(){return(hs=qo(Ko().mark((function e(t){var r,n;return Ko().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r={}).wbg={},r.wbg.__wbindgen_string_new=function(e,t){return $a(Za(e,t))},r.wbg.__wbindgen_object_drop_ref=function(e){ts(e)},r.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(es(e))},r.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(es(e),es(t))},r.wbg.__wbindgen_throw=function(e,t){throw Error(Za(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t)),e.t0=ls,e.next=12,t;case 12:return e.t1=e.sent,e.t2=r,e.next=16,(0,e.t0)(e.t1,e.t2);case 16:return Ma=(n=e.sent).instance.exports,fs.__wbindgen_wasm_module=n.module,e.abrupt("return",Ma);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ds=function(){function e(){Zo(this,e),this.pluginOptions=void 0}var t;return Jo(e,[{key:"createSwapChain",value:(t=qo(Ko().mark((function e(t){var r,n,i,o;return Ko().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==navigator.gpu){e.next=2;break}return e.abrupt("return",null);case 2:return r=null,e.prev=3,e.next=6,navigator.gpu.requestAdapter();case 6:r=e.sent,e.next=12;break;case 9:e.prev=9,e.t0=e.catch(3),console.log(e.t0);case 12:if(null!==r){e.next=14;break}return e.abrupt("return",null);case 14:return n=["depth24unorm-stencil8","depth32float-stencil8","texture-compression-bc"].filter((function(e){return r.features.has(e)})),e.next=18,r.requestDevice({requiredFeatures:n});case 18:if(null!==(i=e.sent)){e.next=21;break}return e.abrupt("return",null);case 21:if(o=t.getContext("webgpu")){e.next=24;break}return e.abrupt("return",null);case 24:return e.prev=24,e.next=27,fs("/glsl_wgsl_compiler_bg.wasm");case 27:e.next=31;break;case 29:e.prev=29,e.t1=e.catch(24);case 31:return e.abrupt("return",new Ya(r,i,t,o,us));case 32:case"end":return e.stop()}}),e,null,[[3,9],[24,29]])}))),function(e){return t.apply(this,arguments)})}]),e}();f([r.inject(ca),h("design:type",Object)],ds.prototype,"pluginOptions",void 0),ds=f([r.singleton({token:Eo})],ds);var ps,_s,vs=r.Module((function(e){e(ds)})),Es=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Zo(this,e),this.options=void 0,this.name="webgpu-device",this.options=t}return Jo(e,[{key:"init",value:function(e){e.register(ca,{useValue:Yo({},this.options)}),e.load(vs,!0)}},{key:"destroy",value:function(e){e.remove(ca),e.unload(vs)}}]),e}(),ys=Object.freeze({__proto__:null,Plugin:Es});function gs(){
|
|
8
8
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
9
|
-
Ma=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=m(a,r);if(s){if(s===c)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function f(){}function d(){}function h(){}var p={};s(p,i,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(S([])));E&&E!==t&&r.call(E,i)&&(p=E);var v=h.prototype=f.prototype=Object.create(p);function R(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function n(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&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function m(e,t){var r=e.iterator[t.method];if(void 0===r){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 n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var i=n.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 T(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 y(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,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 n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],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(g.prototype),s(g.prototype,o,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?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 r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},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(y),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(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 r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),y(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;y(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}function La(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Fa(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){La(o,n,i,a,s,"next",e)}function s(e){La(o,n,i,a,s,"throw",e)}a(void 0)}))}}var ba=(Na=function(){function e(){this.contextService=void 0,this.renderingContext=void 0,this.$camera=void 0}var r=e.prototype;return r.apply=function(e){var r=this,n=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getOrCreateEl(n),o=n.ownerDocument.documentElement.attributes;Object.keys(o).forEach((function(e){i.style[e]=o[e]})),Object.keys(n.attributes).forEach((function(e){r.updateAttribute(e,n)}))}},i=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getId(n),o=r.contextService.getDomElement().parentNode;if(o){var a=o.querySelector("#"+i);a&&o.removeChild(a)}}},o=function(e){var n=e.target;n.nodeName===t.Shape.HTML&&r.updateAttribute(e.attrName,n)};e.hooks.init.tapPromise(xa.tag,Fa(Ma().mark((function e(){return Ma().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o);case 3:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(xa.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o)}))},r.getId=function(e){return e.id||"g-html-"+e.entity},r.getOrCreateEl=function(e){var t=this.getId(e),r=this.contextService.getDomElement().parentNode;if(r){var n=r.querySelector("#"+t);if(!n){n=document.createElement("div"),e.parsedStyle.$el=n,n.id=t,e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),r.appendChild(n),n.style.position="absolute",n.style.left="0",n.style.top="0",n.style["will-change"]="transform";var i=e.getWorldTransform();n.style.transform="matrix("+[i[0],i[1],i[4],i[5],i[12],i[13]].join(",")+")"}return n}return null},r.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;t.isString(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"modelMatrix":case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]=o[0].value+" "+o[1].value;var a=r.getWorldTransform();n.style.transform="matrix("+[a[0],a[1],a[4],a[5],a[12],a[13]].join(",")+")";break;case"width":var s=r.computedStyleMap().get("width");n.style.width=""+s;break;case"height":var u=r.computedStyleMap().get("height");n.style.height=""+u;break;case"zIndex":n.style["z-index"]=""+r.parsedStyle.zIndex.value;break;case"visibility":n.style.visibility=r.parsedStyle.visibility.value;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents.value;break;case"opacity":n.style.opacity=""+r.parsedStyle.opacity.value;break;case"fill":var l=r.parsedStyle.fill,c="";if(l instanceof t.CSSRGB)c=""+l;else if(l instanceof t.CSSGradientValue){if(l.type===t.GradientPatternType.LinearGradient)c="linear-gradient(to right, "+l.value.steps.map((function(e){return e[1]+" "+100*Number(e[0])+"%"})).join(",")+");"}n.style.background=c;break;case"stroke":n.style["border-color"]=""+r.parsedStyle.stroke,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]=(r.parsedStyle.lineWidth.value||0)+"px";break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.parsedStyle.filter}},e}(),Na.tag="HTMLRendering",xa=Na);i([r.inject(t.ContextService),o("design:type",Object)],ba.prototype,"contextService",void 0),i([r.inject(t.RenderingContext),o("design:type",Object)],ba.prototype,"renderingContext",void 0),ba=xa=i([r.singleton({contrib:t.RenderingPluginContribution})],ba);var Ua=r.Module((function(e){e(ba)})),wa=function(){function e(){this.name="html-renderer"}var t=e.prototype;return t.init=function(e){e.load(Ua,!0)},t.destroy=function(e){e.unload(Ua)},e}(),Ga=function(){function e(){this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.context=void 0,this.canvasConfig=void 0}var r=e.prototype;return r.init=function(){var e=this.canvasConfig,r=e.container,n=e.canvas,i=e.devicePixelRatio;if(n)this.$canvas=n,r&&n.parentElement!==r&&r.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(r&&(this.$container=t.isString(r)?document.getElementById(r):r,this.$container)){var o=document.createElement("canvas");this.$container.appendChild(o),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=o}var a=i||t.isBrowser&&window.devicePixelRatio||1;this.dpr=a=1>a?1:Math.ceil(a)},r.getDomElement=function(){return this.$canvas},r.getContext=function(){return this.context},r.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},r.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},r.resize=function(e,r){if(this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*r,t.setDOMSize(this.$canvas,e,r)}},r.getDPR=function(){return this.dpr},r.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e}();i([r.inject(t.CanvasConfig),o("design:type",Object)],Ga.prototype,"canvasConfig",void 0),Ga=i([r.singleton({token:t.ContextService})],Ga);var ka=r.Module((function(e){e(Ga)})),Wa=function(){function e(){this.name="webgpu-context-register"}var t=e.prototype;return t.init=function(e){e.load(ka,!0)},t.destroy=function(e){e.unload(ka)},e}(),Va=function(e){var t,r;function i(t){var r;return(r=e.call(this,t)||this).registerPlugin(new Wa),r.registerPlugin(new Da),r.registerPlugin(new ho),r.registerPlugin(new p),r.registerPlugin(new wa),r}return(t=i).prototype=Object.create((r=e).prototype),t.prototype.constructor=t,n(t,r),i}(t.AbstractRenderer);e.DeviceRenderer=po,e.DomInteraction=_,e.Renderer=Va,e.WebGPUDevice=Ba,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
9
|
+
gs=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.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,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(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 A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"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,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,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(A),!e)for(var t in this)"t"===t.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):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),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function ms(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Rs(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){ms(o,n,i,a,s,"next",e)}function s(e){ms(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Ts(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function As(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Ss(e,t,r){return t&&As(e.prototype,t),r&&As(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var Cs=(ps=function(){function e(){Ts(this,e),this.contextService=void 0,this.renderingContext=void 0,this.$camera=void 0}return Ss(e,[{key:"apply",value:function(e){var r=this,n=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getOrCreateEl(n),o=n.ownerDocument.documentElement.attributes;Object.keys(o).forEach((function(e){i.style[e]=o[e]})),Object.keys(n.attributes).forEach((function(e){r.updateAttribute(e,n)}))}},i=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getId(n),o=r.contextService.getDomElement().parentNode;if(o){var a=o.querySelector("#"+i);a&&o.removeChild(a)}}},o=function(e){var n=e.target;n.nodeName===t.Shape.HTML&&r.updateAttribute(e.attrName,n)};e.hooks.init.tapPromise(_s.tag,Rs(gs().mark((function e(){return gs().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o);case 3:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(_s.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o)}))}},{key:"getId",value:function(e){return e.id||"g-html-"+e.entity}},{key:"getOrCreateEl",value:function(e){var t=this.getId(e),r=this.contextService.getDomElement().parentNode;if(r){var n=r.querySelector("#"+t);if(!n){n=document.createElement("div"),e.parsedStyle.$el=n,n.id=t,e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),r.appendChild(n),n.style.position="absolute",n.style.left="0",n.style.top="0",n.style["will-change"]="transform";var i=e.getWorldTransform();n.style.transform="matrix(".concat([i[0],i[1],i[4],i[5],i[12],i[13]].join(","),")")}return n}return null}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;t.isString(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"modelMatrix":case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].value," ").concat(o[1].value);var a=r.getWorldTransform();n.style.transform="matrix(".concat([a[0],a[1],a[4],a[5],a[12],a[13]].join(","),")");break;case"width":var s=r.computedStyleMap().get("width");n.style.width=""+s;break;case"height":var u=r.computedStyleMap().get("height");n.style.height=""+u;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex.value);break;case"visibility":n.style.visibility=r.parsedStyle.visibility.value;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents.value;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity.value);break;case"fill":var l=r.parsedStyle.fill,c="";if(l instanceof t.CSSRGB)c=""+l;else if(l instanceof t.CSSGradientValue&&l.type===t.GradientPatternType.LinearGradient){var f=l.value.steps.map((function(e){return"".concat(e[1]," ").concat(100*Number(e[0]),"%")})).join(",");c="linear-gradient(to right, ".concat(f,");")}n.style.background=c;break;case"stroke":n.style["border-color"]=""+r.parsedStyle.stroke,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth.value||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.parsedStyle.filter}}}]),e}(),ps.tag="HTMLRendering",_s=ps);f([r.inject(t.ContextService),h("design:type",Object)],Cs.prototype,"contextService",void 0),f([r.inject(t.RenderingContext),h("design:type",Object)],Cs.prototype,"renderingContext",void 0),Cs=_s=f([r.singleton({contrib:t.RenderingPluginContribution})],Cs);var Os=r.Module((function(e){e(Cs)})),Is=function(){function e(){Ts(this,e),this.name="html-renderer"}return Ss(e,[{key:"init",value:function(e){e.load(Os,!0)}},{key:"destroy",value:function(e){e.unload(Os)}}]),e}(),Ns=function(){function e(){i(this,e),this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.context=void 0,this.canvasConfig=void 0}return a(e,[{key:"init",value:function(){var e=this.canvasConfig,r=e.container,n=e.canvas,i=e.devicePixelRatio;if(n)this.$canvas=n,r&&n.parentElement!==r&&r.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(r&&(this.$container=t.isString(r)?document.getElementById(r):r,this.$container)){var o=document.createElement("canvas");this.$container.appendChild(o),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=o}var a=i||t.isBrowser&&window.devicePixelRatio||1;this.dpr=a=1>a?1:Math.ceil(a)}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getContext",value:function(){return this.context}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,r){if(this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*r,t.setDOMSize(this.$canvas,e,r)}}},{key:"getDPR",value:function(){return this.dpr}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}}]),e}();f([r.inject(t.CanvasConfig),h("design:type",Object)],Ns.prototype,"canvasConfig",void 0),Ns=f([r.singleton({token:t.ContextService})],Ns);var xs=r.Module((function(e){e(Ns)})),Ps=function(){function e(){i(this,e),this.name="webgpu-context-register"}return a(e,[{key:"init",value:function(e){e.load(xs,!0)}},{key:"destroy",value:function(e){e.unload(xs)}}]),e}(),Ds=function(e){!function(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&&u(e,t)}(r,e);var t=c(r);function r(e){var n;return i(this,r),(n=t.call(this,e)).registerPlugin(new Ps),n.registerPlugin(new Es),n.registerPlugin(new Xo),n.registerPlugin(new A),n.registerPlugin(new Is),n}return a(r)}(t.AbstractRenderer);e.DeviceRenderer=Ho,e.DomInteraction=S,e.Renderer=Ds,e.WebGPUDevice=ys,Object.defineProperty(e,"__esModule",{value:!0})}));
|