@antv/g-webgpu 1.7.35 → 1.7.36
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/index.esm.js +111 -230
- package/dist/index.js +111 -230
- package/dist/index.umd.js +6767 -8365
- package/dist/index.umd.min.js +1 -1
- package/package.json +7 -7
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,(function(e,t){"use strict";function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),a=new C(n||[]);return i(o,"_invoke",{value:T(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function p(){}function _(){}var v={};l(v,a,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(I([])));y&&y!==t&&n.call(y,a)&&(v=y);var m=_.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(i,o,a,s){var u=f(e[i],e,o);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==typeof c&&n.call(c,"__await")?t.resolve(c.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(c).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function T(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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(a,r);if(s){if(s===h)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=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return p.prototype=_,i(m,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:p,configurable:!0}),p.displayName=l(_,u,"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__=_,l(e,u,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(R.prototype),l(R.prototype,s,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),l(m,u,"Generator"),l(m,a,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,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(O),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(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 r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.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)&&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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),h}},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;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}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,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 o(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function s(e){i(a,n,o,s,u,"next",e)}function u(e){i(a,n,o,s,u,"throw",e)}s(void 0)}))}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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,(i=void 0,"symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n.key,"string"))?i:i+""),n)}var i}function u(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(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&&f(e,t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}function h(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 d(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=c(e);if(t){var i=c(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function p(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}p((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof v?t:v).prototype),a=new x(n||[]);return i(o,"_invoke",{value:O(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h="suspendedStart",d="executing",p="completed",_={};function v(){}function E(){}function y(){}var m={};l(m,a,(function(){return this}));var g=Object.getPrototypeOf,R=g&&g(g(N([])));R&&R!==r&&n.call(R,a)&&(m=R);var T=y.prototype=v.prototype=Object.create(m);function A(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,o,a,s){var u=f(e[i],e,o);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==typeof c&&n.call(c,"__await")?t.resolve(c.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(c).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function O(e,t,r){var n=h;return function(i,o){if(n===d)throw Error("Generator is already running");if(n===p){if("throw"===i)throw o;return b()}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===h)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=f(e,t,r);if("normal"===u.type){if(n=r.done?p:"suspendedYield",u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}function C(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),_;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,_;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,_):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}function I(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 P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function N(e){if(e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}return{next:b}}function b(){return{value:t,done:!0}}return E.prototype=y,i(T,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:E,configurable:!0}),E.displayName=l(y,u,"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,l(e,u,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},A(S.prototype),l(S.prototype,s,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new S(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},A(T),l(T,u,"Generator"),l(T,a,(function(){return this})),l(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=N,x.prototype={constructor:x,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(P),!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),P(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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(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 _="undefined"!=typeof Float32Array?Float32Array:Array;function v(){var e=new _(16);return _!=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 E(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 y(e,t,r,n,i,o,a,s,u,l,c,f,h,d,p,v){var E=new _(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]=h,E[13]=d,E[14]=p,E[15]=v,E}function m(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function g(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var R=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],m=r[0],g=r[1],R=r[2],T=r[3];return e[0]=m*n+g*s+R*f+T*_,e[1]=m*i+g*u+R*h+T*v,e[2]=m*o+g*l+R*d+T*E,e[3]=m*a+g*c+R*p+T*y,e[4]=(m=r[4])*n+(g=r[5])*s+(R=r[6])*f+(T=r[7])*_,e[5]=m*i+g*u+R*h+T*v,e[6]=m*o+g*l+R*d+T*E,e[7]=m*a+g*c+R*p+T*y,e[8]=(m=r[8])*n+(g=r[9])*s+(R=r[10])*f+(T=r[11])*_,e[9]=m*i+g*u+R*h+T*v,e[10]=m*o+g*l+R*d+T*E,e[11]=m*a+g*c+R*p+T*y,e[12]=(m=r[12])*n+(g=r[13])*s+(R=r[14])*f+(T=r[15])*_,e[13]=m*i+g*u+R*h+T*v,e[14]=m*o+g*l+R*d+T*E,e[15]=m*a+g*c+R*p+T*y,e};function T(e,t,r){var n=new _(3);return n[0]=e,n[1]=t,n[2]=r,n}var A,S;A=new _(3),_!=Float32Array&&(A[0]=0,A[1]=0,A[2]=0),S=A;!function(){var e=function(){var e=new _(2);return _!=Float32Array&&(e[0]=0,e[1]=0),e}()}();function O(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function C(e,t,r,n,i,o,a,s,u,l){var c,f,h,d,p,_=e,v=t,E=r,y=n,m=s,g=u,R=120*Math.PI/180,T=Math.PI/180*(+i||0),A=[];if(l)f=l[0],h=l[1],d=l[2],p=l[3];else{v=(c=O(_,v,-T)).y;var S=((_=c.x)-(m=(c=O(m,g,-T)).x))/2,I=(v-(g=c.y))/2,P=S*S/(E*E)+I*I/(y*y);P>1&&(E*=P=Math.sqrt(P),y*=P);var x=E*E,N=y*y,b=(o===a?-1:1)*Math.sqrt(Math.abs((x*N-x*I*I-N*S*S)/(x*I*I+N*S*S)));d=b*E*I/y+(_+m)/2,f=Math.asin(((v-(p=b*-y*S/E+(v+g)/2))/y*1e9>>0)/1e9),h=Math.asin(((g-p)/y*1e9>>0)/1e9),0>(f=d>_?Math.PI-f:f)&&(f=2*Math.PI+f),0>(h=d>m?Math.PI-h:h)&&(h=2*Math.PI+h),a&&f>h&&(f-=2*Math.PI),!a&&h>f&&(h-=2*Math.PI)}var M=h-f;if(Math.abs(M)>R){var D=h,L=m,B=g;A=C(m=d+E*Math.cos(h=f+R*(a&&h>f?1:-1)),g=p+y*Math.sin(h),E,y,i,0,a,L,B,[h,D,d,p])}M=h-f;var F=Math.cos(f),w=Math.sin(f),U=Math.cos(h),k=Math.sin(h),G=Math.tan(M/4),V=4/3*E*G,W=4/3*y*G,X=[_,v],H=[_+V*w,v-W*F],j=[m+V*k,g-W*U],Y=[m,g];if(H[0]=2*X[0]-H[0],H[1]=2*X[1]-H[1],l)return H.concat(j,Y,A);for(var K=[],z=0,q=(A=H.concat(j,Y,A)).length;q>z;z+=1)K[z]=z%2?O(A[z-1],A[z],T).y:O(A[z],A[z+1],T).x;return K}var I=function(e){return null==e},P={}.toString,x=function(e,t){return P.call(e)==="[object "+t+"]"},N=function(e){return x(e,"String")},b=function(e,t,r){return t>e?t:e>r?r:e},M=function(e){return x(e,"Number")},D=p((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})),L=F,B=F;function F(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=w(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=w(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(z(a));for(s.sort(H),i=0;s.length>i;i++)r=j(s[i],r);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))?32767/l:0}return k(h,d,r,n,i,l,0),d}function w(e,t,r,n,i){var o,a;if(i===se(e,t,r,n)>0)for(o=t;r>o;o+=n)a=ie(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=ie(o,e[o],e[o+1],a);return a&&$(a,a.next)&&(oe(a),a=a.next),a}function U(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!$(n,n.next)&&0!==Q(n.prev,n,n.next))n=n.next;else{if(oe(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function k(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{0===i.z&&(i.z=K(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?V(e,n,i,o):G(e))t.push(s.i/r|0),t.push(e.i/r|0),t.push(u.i/r|0),oe(e),e=u.next,l=u.next;else if((e=u)===l){a?1===a?k(e=W(U(e),t,r),t,r,n,i,o,2):2===a&&X(e,t,r,n,i,o):k(U(e),t,r,n,i,o,1);break}}}function G(e){var t=e.prev,r=e,n=e.next;if(Q(t,r,n)>=0)return!1;for(var i=t.x,o=r.x,a=n.x,s=t.y,u=r.y,l=n.y,c=o>i?a>i?i:a:a>o?o:a,f=u>s?l>s?s:l:l>u?u:l,h=i>o?i>a?i:a:o>a?o:a,d=s>u?s>l?s:l:u>l?u:l,p=n.next;p!==t;){if(p.x>=c&&h>=p.x&&p.y>=f&&d>=p.y&&q(i,s,o,u,a,l,p.x,p.y)&&Q(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function V(e,t,r,n){var i=e.prev,o=e,a=e.next;if(Q(i,o,a)>=0)return!1;for(var s=i.x,u=o.x,l=a.x,c=i.y,f=o.y,h=a.y,d=u>s?l>s?s:l:l>u?u:l,p=f>c?h>c?c:h:h>f?f:h,_=s>u?s>l?s:l:u>l?u:l,v=c>f?c>h?c:h:f>h?f:h,E=K(d,p,t,r,n),y=K(_,v,t,r,n),m=e.prevZ,g=e.nextZ;m&&m.z>=E&&g&&y>=g.z;){if(m.x>=d&&_>=m.x&&m.y>=p&&v>=m.y&&m!==i&&m!==a&&q(s,c,u,f,l,h,m.x,m.y)&&Q(m.prev,m,m.next)>=0)return!1;if(m=m.prevZ,g.x>=d&&_>=g.x&&g.y>=p&&v>=g.y&&g!==i&&g!==a&&q(s,c,u,f,l,h,g.x,g.y)&&Q(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(;m&&m.z>=E;){if(m.x>=d&&_>=m.x&&m.y>=p&&v>=m.y&&m!==i&&m!==a&&q(s,c,u,f,l,h,m.x,m.y)&&Q(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;g&&y>=g.z;){if(g.x>=d&&_>=g.x&&g.y>=p&&v>=g.y&&g!==i&&g!==a&&q(s,c,u,f,l,h,g.x,g.y)&&Q(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function W(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!$(i,o)&&J(i,n,n.next,o)&&re(i,o)&&re(o,i)&&(t.push(i.i/r|0),t.push(n.i/r|0),t.push(o.i/r|0),oe(n),oe(n.next),n=e=o),n=n.next}while(n!==e);return U(n)}function X(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Z(a,s)){var u=ne(a,s);return a=U(a,a.next),u=U(u,u.next),k(a,t,r,n,i,o,0),void k(u,t,r,n,i,o,0)}s=s.next}a=a.next}while(a!==e)}function H(e,t){return e.x-t.x}function j(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&&(a=s,r=n.next.x>n.x?n:n.next,s===i))return r}n=n.next}while(n!==t);if(!r)return null;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||!q(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),re(n,e)&&(h>u||u===h&&(n.x>r.x||n.x===r.x&&Y(r,n)))&&(r=n,h=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=ne(r,e);return U(n,n.next),U(r,r.next)}function Y(e,t){return 0>Q(e.prev,e,t.prev)&&0>Q(t.next,e,e.next)}function K(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function z(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 q(e,t,r,n,i,o,a,s){return(i-a)*(t-s)>=(e-a)*(o-s)&&(e-a)*(n-s)>=(r-a)*(t-s)&&(r-a)*(o-s)>=(i-a)*(n-s)}function Z(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&&J(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(re(e,t)&&re(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)&&(Q(e.prev,e,t.prev)||Q(e,t.prev,t))||$(e,t)&&Q(e.prev,e,e.next)>0&&Q(t.prev,t,t.next)>0)}function Q(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function $(e,t){return e.x===t.x&&e.y===t.y}function J(e,t,r,n){var i=te(Q(e,t,r)),o=te(Q(e,t,n)),a=te(Q(r,n,e)),s=te(Q(r,n,t));return i!==o&&a!==s||(!(0!==i||!ee(e,r,t))||(!(0!==o||!ee(e,n,t))||(!(0!==a||!ee(r,e,n))||!(0!==s||!ee(r,t,n)))))}function ee(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 te(e){return e>0?1:0>e?-1:0}function re(e,t){return 0>Q(e.prev,e,e.next)?Q(e,t,e.next)>=0&&Q(e,e.prev,t)>=0:0>Q(e,t,e.prev)||0>Q(e,e.next,t)}function ne(e,t){var r=new ae(e.i,e.x,e.y),n=new ae(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 ie(e,t,r,n){var i=new ae(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 oe(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 ae(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function se(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}F.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(se(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(se(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)},F.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},L.default=B;const ue=1e20;class le{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(ue,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]=ue;else{const e=.5-r;E[n]=e>0?e*e:0,v[n]=0>e?e*e:0}}ce(E,0,0,l,c,l,this.f,this.v,this.z),ce(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 ce(e,t,r,n,i,o,a,s,u){for(let l=t;t+n>l;l++)fe(e,r*o+l,o,i,a,s,u);for(let l=r;r+i>l;l++)fe(e,l*o+t,1,n,a,s,u)}function fe(e,t,r,n,i,o,a){o[0]=0,a[0]=-ue,a[1]=ue,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]=ue}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 he(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 de(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?he(Object(r),!0).forEach((function(t){ge(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):he(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function pe(){pe=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),a=new C(n||[]);return i(o,"_invoke",{value:T(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function p(){}function _(){}var v={};l(v,a,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(I([])));y&&y!==t&&r.call(y,a)&&(v=y);var m=_.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function o(i,a,s,u){var l=f(e[i],e,a);if("throw"!==l.type){var c=l.arg,h=c.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){o("next",e,s,u)}),(function(e){o("throw",e,s,u)})):t.resolve(h).then((function(e){c.value=e,s(c)}),(function(e){return o("throw",e,s,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function T(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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(a,r);if(s){if(s===h)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=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[a];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:P}}function P(){return{value:void 0,done:!0}}return p.prototype=_,i(m,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:p,configurable:!0}),p.displayName=l(_,u,"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__=_,l(e,u,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(R.prototype),l(R.prototype,s,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),l(m,u,"Generator"),l(m,a,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,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(O),!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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),h}},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;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function _e(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 ve(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){_e(o,n,i,a,s,"next",e)}function s(e){_e(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Ee(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ye(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,ke(n.key),n)}}function me(e,t,r){return t&&ye(e.prototype,t),r&&ye(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function ge(e,t,r){return(t=ke(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Re(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&&Ae(e,t)}function Te(e){return Te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Te(e)}function Ae(e,t){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ae(e,t)}function Se(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 Oe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ce(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 Oe(e)}function Ie(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=Te(e);if(t){var i=Te(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return Ce(this,r)}}function Pe(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Te(e)););return e}function xe(){return xe="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=Pe(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},xe.apply(this,arguments)}function Ne(e,t){return De(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}(e,t)||Be(e,t)||we()}function be(e){return De(e)||Le(e)||Be(e)||we()}function Me(e){return function(e){if(Array.isArray(e))return Fe(e)}(e)||Le(e)||Be(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 De(e){if(Array.isArray(e))return e}function Le(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function Be(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}}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 we(){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 Ue(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Be(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}}}}function ke(e){var t=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===n(t)?t:t+""}var Ge=me((function e(){Ee(this,e),this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]}));Ge.tag="c-renderable-3d";var Ve,We,Xe,He,je,Ye,Ke,ze,qe,Ze,Qe,$e,Je,et,tt,rt,nt,it,ot,at,st,ut,lt,ct,ft,ht,dt,pt=function(){function e(){Ee(this,e),this.lights=[],this.fog=void 0}return me(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}(),_t=["style"],vt=function(e){Re(n,e);var r=Ie(n);function n(e){var i,o=e.style,a=Se(e,_t);return Ee(this,n),(i=r.call(this,de({type:t.Shape.MESH,style:de({x:"",y:"",z:"",lineWidth:0},o)},a))).cullable.enable=!1,i.style.geometry.meshes.push(Oe(i)),i.style.material.meshes.push(Oe(i)),i}return me(n,[{key:"destroy",value:function(){xe(Te(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),Et=function(){function e(){Ee(this,e)}return me(e,[{key:"update",value:function(e){return e.geometry.computeBoundingBox(),{width:0,height:0,depth:0}}}]),e}(),yt=function(){function e(){Ee(this,e),this.counter=0,this.id2DisplayObjectMap={}}return me(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=Ne(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 mt(e,t,r,n){return{dimension:tt.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:rt.Sampled}}function gt(e){return e}function Rt(e,t,r){return e<<16|t<<8|r}function Tt(e){return e>>>8&255}function At(e){return e>>>16&255}function St(e){return 255&e}function Ot(e){switch(e){case lt.F32:case lt.U32:case lt.S32:return 4;case lt.U16:case lt.S16:case lt.F16:return 2;case lt.U8:case lt.S8:return 1;default:throw Error("whoops")}}function Ct(e){return Ot(At(e))}function It(e){var t=St(e);if(t&ft.Depth)return ot.Depth;if(t&ft.Normalized)return ot.Float;var r=At(e);if(r===lt.F16||r===lt.F32)return ot.Float;if(r===lt.U8||r===lt.U16||r===lt.U32)return ot.Uint;if(r===lt.S8||r===lt.S16||r===lt.S32)return ot.Sint;throw Error("whoops")}function Pt(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 xt(e){if(null!=e)return e;throw Error("Missing object")}function Nt(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function bt(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 Dt(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{r:e,g:t,b:r,a:n}}!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"}(Ve||(Ve={})),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"}(We||(We={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(Xe||(Xe={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(He||(He={})),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"}(je||(je={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(Ye||(Ye={})),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"}(ze||(ze={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(qe||(qe={})),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"}(Ze||(Ze={})),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"}(Qe||(Qe={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}($e||($e={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(Je||(Je={})),function(e){e.LOADED="loaded"}(et||(et={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(tt||(tt={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(rt||(rt={})),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"}(nt||(nt={})),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"}(it||(it={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(ot||(ot={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(at||(at={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(st||(st={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(ut||(ut={})),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"}(lt||(lt={})),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"}(ct||(ct={})),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"}(ft||(ft={})),function(e){e[e.ALPHA=Rt(lt.U8,ct.A,ft.None)]="ALPHA",e[e.F16_R=Rt(lt.F16,ct.R,ft.None)]="F16_R",e[e.F16_RG=Rt(lt.F16,ct.RG,ft.None)]="F16_RG",e[e.F16_RGB=Rt(lt.F16,ct.RGB,ft.None)]="F16_RGB",e[e.F16_RGBA=Rt(lt.F16,ct.RGBA,ft.None)]="F16_RGBA",e[e.F32_R=Rt(lt.F32,ct.R,ft.None)]="F32_R",e[e.F32_RG=Rt(lt.F32,ct.RG,ft.None)]="F32_RG",e[e.F32_RGB=Rt(lt.F32,ct.RGB,ft.None)]="F32_RGB",e[e.F32_RGBA=Rt(lt.F32,ct.RGBA,ft.None)]="F32_RGBA",e[e.U8_R=Rt(lt.U8,ct.R,ft.None)]="U8_R",e[e.U8_R_NORM=Rt(lt.U8,ct.R,ft.Normalized)]="U8_R_NORM",e[e.U8_RG=Rt(lt.U8,ct.RG,ft.None)]="U8_RG",e[e.U8_RG_NORM=Rt(lt.U8,ct.RG,ft.Normalized)]="U8_RG_NORM",e[e.U8_RGB=Rt(lt.U8,ct.RGB,ft.None)]="U8_RGB",e[e.U8_RGB_NORM=Rt(lt.U8,ct.RGB,ft.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=Rt(lt.U8,ct.RGB,ft.sRGB|ft.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=Rt(lt.U8,ct.RGBA,ft.None)]="U8_RGBA",e[e.U8_RGBA_NORM=Rt(lt.U8,ct.RGBA,ft.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=Rt(lt.U8,ct.RGBA,ft.sRGB|ft.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=Rt(lt.U16,ct.R,ft.None)]="U16_R",e[e.U16_R_NORM=Rt(lt.U16,ct.R,ft.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=Rt(lt.U16,ct.RG,ft.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=Rt(lt.U16,ct.RGBA,ft.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=Rt(lt.U16,ct.RGB,ft.None)]="U16_RGB",e[e.U32_R=Rt(lt.U32,ct.R,ft.None)]="U32_R",e[e.U32_RG=Rt(lt.U32,ct.RG,ft.None)]="U32_RG",e[e.S8_R=Rt(lt.S8,ct.R,ft.None)]="S8_R",e[e.S8_R_NORM=Rt(lt.S8,ct.R,ft.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=Rt(lt.S8,ct.RG,ft.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=Rt(lt.S8,ct.RGB,ft.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=Rt(lt.S8,ct.RGBA,ft.Normalized)]="S8_RGBA_NORM",e[e.S16_R=Rt(lt.S16,ct.R,ft.None)]="S16_R",e[e.S16_RG=Rt(lt.S16,ct.RG,ft.None)]="S16_RG",e[e.S16_RG_NORM=Rt(lt.S16,ct.RG,ft.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=Rt(lt.S16,ct.RGB,ft.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=Rt(lt.S16,ct.RGBA,ft.None)]="S16_RGBA",e[e.S16_RGBA_NORM=Rt(lt.S16,ct.RGBA,ft.Normalized)]="S16_RGBA_NORM",e[e.S32_R=Rt(lt.S32,ct.R,ft.None)]="S32_R",e[e.U16_RGBA_5551=Rt(lt.U16_PACKED_5551,ct.RGBA,ft.Normalized)]="U16_RGBA_5551",e[e.BC1=Rt(lt.BC1,ct.RGBA,ft.Normalized)]="BC1",e[e.BC1_SRGB=Rt(lt.BC1,ct.RGBA,ft.Normalized|ft.sRGB)]="BC1_SRGB",e[e.BC2=Rt(lt.BC2,ct.RGBA,ft.Normalized)]="BC2",e[e.BC2_SRGB=Rt(lt.BC2,ct.RGBA,ft.Normalized|ft.sRGB)]="BC2_SRGB",e[e.BC3=Rt(lt.BC3,ct.RGBA,ft.Normalized)]="BC3",e[e.BC3_SRGB=Rt(lt.BC3,ct.RGBA,ft.Normalized|ft.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=Rt(lt.BC4_UNORM,ct.R,ft.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=Rt(lt.BC4_SNORM,ct.R,ft.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=Rt(lt.BC5_UNORM,ct.RG,ft.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=Rt(lt.BC5_SNORM,ct.RG,ft.Normalized)]="BC5_SNORM",e[e.D24=Rt(lt.D24,ct.R,ft.Depth)]="D24",e[e.D24_S8=Rt(lt.D24S8,ct.RG,ft.Depth|ft.Stencil)]="D24_S8",e[e.D32F=Rt(lt.D32F,ct.R,ft.Depth)]="D32F",e[e.D32F_S8=Rt(lt.D32FS8,ct.RG,ft.Depth|ft.Stencil)]="D32F_S8",e[e.U8_RGB_RT=Rt(lt.U8,ct.RGB,ft.RenderTarget|ft.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=Rt(lt.U8,ct.RGBA,ft.RenderTarget|ft.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=Rt(lt.U8,ct.RGBA,ft.RenderTarget|ft.Normalized|ft.sRGB)]="U8_RGBA_RT_SRGB"}(ht||(ht={})),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"}(dt||(dt={}));var Lt=Dt(0,0,0,0),Bt=Dt(0,0,0,1),Ft=Dt(1,1,1,0),wt=Dt(1,1,1,1),Ut=!0;function kt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ut;if(!t)return e;switch(e){case We.Less:return We.Greater;case We.LessEqual:return We.GreaterEqual;case We.GreaterEqual:return We.LessEqual;case We.Greater:return We.Less;default:return e}}function Gt(e,t){return null!=e?e:t}function Vt(e){return void 0===e?null:e}function Wt(e,t,r){e.length=t,e.fill(r)}function Xt(e,t){var r=t-1;return e+r&~r}function Ht(e,t){return((e+t-1)/t|0)*t}function jt(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 Yt(e,t,r){var n=jt(e,t,r);e.splice(n,0,t)}function Kt(e,t,r){return r?e|=t:e&=~t,e}function zt(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function qt(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 Zt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Qt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Zt(e.rgbBlendState,t.rgbBlendState),Zt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function $t(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=Qt(e[r],t[r])}function Jt(e,t){void 0!==t.attachmentsState&&$t(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&bt(e.blendConstant,t.blendConstant),e.depthCompare=Gt(t.depthCompare,e.depthCompare),e.depthWrite=Gt(t.depthWrite,e.depthWrite),e.stencilCompare=Gt(t.stencilCompare,e.stencilCompare),e.stencilWrite=Gt(t.stencilWrite,e.stencilWrite),e.stencilPassOp=Gt(t.stencilPassOp,e.stencilPassOp),e.stencilRef=Gt(t.stencilRef,e.stencilRef),e.cullMode=Gt(t.cullMode,e.cullMode),e.frontFace=Gt(t.frontFace,e.frontFace),e.polygonOffset=Gt(t.polygonOffset,e.polygonOffset)}function er(e){var t=Object.assign({},e);return t.attachmentsState=[],$t(t.attachmentsState,e.attachmentsState),t.blendConstant=Mt(t.blendConstant),t}function tr(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 rr={blendMode:Ye.Add,blendSrcFactor:je.One,blendDstFactor:je.Zero},nr={attachmentsState:[{channelWriteMask:nt.RGB,rgbBlendState:rr,alphaBlendState:rr}],blendConstant:Mt(Lt),depthWrite:!0,depthCompare:We.LessEqual,stencilCompare:We.Always,stencilWrite:!1,stencilPassOp:it.Keep,stencilRef:0,cullMode:He.None,frontFace:Xe.CCW,polygonOffset:!1};function ir(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nr,r=er(t);return null!==e&&Jt(r,e),r}var or=ir({depthCompare:We.Always,depthWrite:!1},nr);function ar(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],$t(e.attachmentsState,nr.attachmentsState)),tr(e.attachmentsState[0],t),e}var sr,ur={formatKind:ot.Float,dimension:tt.n2D};function lr(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 cr(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function fr(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function hr(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function dr(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function pr(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!lr(e.samplerBindings,t.samplerBindings,hr)&&(!!lr(e.uniformBufferBindings,t.uniformBufferBindings,fr)&&!!Er(e.bindingLayout,t.bindingLayout)))}function _r(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function vr(e,t){return!!_r(e.rgbBlendState,t.rgbBlendState)&&(!!_r(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Er(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function yr(e,t){return e===t}function mr(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!lr(e.attachmentsState,t.attachmentsState,vr)&&!!Nt(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)&&(!!lr(e.bindingLayouts,t.bindingLayouts,Er)&&(!!lr(e.colorAttachmentFormats,t.colorAttachmentFormats,yr)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function gr(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Rr(e,t){return I(e)?I(t):!I(t)&&(e.byteStride===t.byteStride&&e.frequency===t.frequency)}function Tr(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!lr(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Rr)&&!!lr(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,gr))}function Ar(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 Sr(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function Or(e){return{buffer:e.buffer,wordCount:e.wordCount}}function Cr(e){return{bindingLayout:e.bindingLayout,samplerBindings:cr(e.samplerBindings,Sr),uniformBufferBindings:cr(e.uniformBufferBindings,Or),pipeline:e.pipeline}}function Ir(e){return{dimension:e.dimension,formatKind:e.formatKind}}function Pr(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?cr(e.samplerEntries,Ir):void 0}}function xr(e){var t=cr(e.bindingLayouts,Pr),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:er(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function Nr(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function br(e){return I(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function Mr(e){return{vertexAttributeDescriptors:cr(e.vertexAttributeDescriptors,Nr),vertexBufferDescriptors:cr(e.vertexBufferDescriptors,br),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(sr||(sr={}));var Dr,Lr=new Uint16Array([65279]),Br=255==new DataView(Lr.buffer).getUint8(0)?sr.LITTLE_ENDIAN:sr.BIG_ENDIAN;var Fr=/([^[]*)(\[[0-9]+\])?/;function wr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function Ur(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{Pt(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 kr(e,t,r,n){e[t](r,n)}function Gr(e,t,r,n){e[t](r,!1,n)}var Vr={},Wr={},Xr={},Hr=[0];function jr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Hr[0]=e,e=Hr);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 Yr(e,t){return jr(e,t,Float32Array,Vr)}function Kr(e,t){return jr(e,t,Int32Array,Wr)}function zr(e,t){return jr(e,t,Uint32Array,Xr)}var qr=(ge(Dr={},dt.FLOAT,Ur.bind(null,"uniform1fv",Yr,1,kr)),ge(Dr,dt.FLOAT_VEC2,Ur.bind(null,"uniform2fv",Yr,2,kr)),ge(Dr,dt.FLOAT_VEC3,Ur.bind(null,"uniform3fv",Yr,3,kr)),ge(Dr,dt.FLOAT_VEC4,Ur.bind(null,"uniform4fv",Yr,4,kr)),ge(Dr,dt.INT,Ur.bind(null,"uniform1iv",Kr,1,kr)),ge(Dr,dt.INT_VEC2,Ur.bind(null,"uniform2iv",Kr,2,kr)),ge(Dr,dt.INT_VEC3,Ur.bind(null,"uniform3iv",Kr,3,kr)),ge(Dr,dt.INT_VEC4,Ur.bind(null,"uniform4iv",Kr,4,kr)),ge(Dr,dt.BOOL,Ur.bind(null,"uniform1iv",Kr,1,kr)),ge(Dr,dt.BOOL_VEC2,Ur.bind(null,"uniform2iv",Kr,2,kr)),ge(Dr,dt.BOOL_VEC3,Ur.bind(null,"uniform3iv",Kr,3,kr)),ge(Dr,dt.BOOL_VEC4,Ur.bind(null,"uniform4iv",Kr,4,kr)),ge(Dr,dt.FLOAT_MAT2,Ur.bind(null,"uniformMatrix2fv",Yr,4,Gr)),ge(Dr,dt.FLOAT_MAT3,Ur.bind(null,"uniformMatrix3fv",Yr,9,Gr)),ge(Dr,dt.FLOAT_MAT4,Ur.bind(null,"uniformMatrix4fv",Yr,16,Gr)),ge(Dr,dt.SAMPLER_2D,wr),ge(Dr,dt.SAMPLER_CUBE,wr),ge(Dr,dt.UNSIGNED_INT,Ur.bind(null,"uniform1uiv",zr,1,kr)),ge(Dr,dt.UNSIGNED_INT_VEC2,Ur.bind(null,"uniform2uiv",zr,2,kr)),ge(Dr,dt.UNSIGNED_INT_VEC3,Ur.bind(null,"uniform3uiv",zr,3,kr)),ge(Dr,dt.UNSIGNED_INT_VEC4,Ur.bind(null,"uniform4uiv",zr,4,kr)),ge(Dr,dt.FLOAT_MAT2x3,Ur.bind(null,"uniformMatrix2x3fv",Yr,6,Gr)),ge(Dr,dt.FLOAT_MAT2x4,Ur.bind(null,"uniformMatrix2x4fv",Yr,8,Gr)),ge(Dr,dt.FLOAT_MAT3x2,Ur.bind(null,"uniformMatrix3x2fv",Yr,6,Gr)),ge(Dr,dt.FLOAT_MAT3x4,Ur.bind(null,"uniformMatrix3x4fv",Yr,12,Gr)),ge(Dr,dt.FLOAT_MAT4x2,Ur.bind(null,"uniformMatrix4x2fv",Yr,8,Gr)),ge(Dr,dt.FLOAT_MAT4x3,Ur.bind(null,"uniformMatrix4x3fv",Yr,12,Gr)),ge(Dr,dt.SAMPLER_2D,wr),ge(Dr,dt.SAMPLER_CUBE,wr),ge(Dr,dt.SAMPLER_3D,wr),ge(Dr,dt.SAMPLER_2D_SHADOW,wr),ge(Dr,dt.SAMPLER_2D_ARRAY,wr),ge(Dr,dt.SAMPLER_2D_ARRAY_SHADOW,wr),ge(Dr,dt.SAMPLER_CUBE_SHADOW,wr),ge(Dr,dt.INT_SAMPLER_2D,wr),ge(Dr,dt.INT_SAMPLER_3D,wr),ge(Dr,dt.INT_SAMPLER_CUBE,wr),ge(Dr,dt.INT_SAMPLER_2D_ARRAY,wr),ge(Dr,dt.UNSIGNED_INT_SAMPLER_2D,wr),ge(Dr,dt.UNSIGNED_INT_SAMPLER_3D,wr),ge(Dr,dt.UNSIGNED_INT_SAMPLER_CUBE,wr),ge(Dr,dt.UNSIGNED_INT_SAMPLER_2D_ARRAY,wr),Dr);var Zr=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function Qr(e,t){return"#define ".concat(e," ").concat(t)}function $r(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=Ne(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 Jr(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 Qr(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===at.UpperLeft&&(c+="".concat(Qr("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===st.Zero&&(c+="".concat(Qr("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,Pt(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(Qr("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=Ue(Zr);try{for(y.s();!(E=y.n()).done;){var m=Ne(E.value,2),g=m[0],R=m[1];p=p.replace(g,R)}}catch(e){y.e(e)}finally{y.f()}}return p}function en(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=Jr(e,"vert",t,n,i),a=Jr(e,"frag",r,n,i);return{vert:t,frag:r,preprocessedVert:o,preprocessedFrag:a}}function tn(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 en(e.queryVendorInfo(),i,o,r,n)}var rn=function(){function e(){Ee(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}return me(e,[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(I(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 Vt(this.defines[e])}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&Pt("1"===t),null!==t}},{key:"ensurePreprocessed",value:function(e){""===this.preprocessedVert&&(this.preprocessedVert=Jr(e,"vert",this.both+this.vert,this.defines,this.features),this.preprocessedFrag=Jr(e,"frag",this.both+this.frag,this.defines,this.features))}}]),e}(),nn=function(){function e(t){Ee(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 me(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=Ht(e,this.uniformBufferWordAlignment),Pt(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=Ht(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=Ht(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Pt(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=Ht(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 xt(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=xt(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:Qe.UNIFORM|Qe.COPY_DST,hint:$e.Dynamic}));var t=Ht(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())xt(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 on(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function an(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function sn(e){return 0}var un=me((function e(){Ee(this,e),this.keys=[],this.values=[]})),ln=function(){function e(t,r){Ee(this,e),this.keyEqualFunc=void 0,this.keyHashFunc=void 0,this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=r}return me(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 un);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=Ue(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:pe().mark((function e(){var t,r,n,i;return pe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Ue(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 cn(e,t){return Pt(""!==e.preprocessedVert&&""!==t.preprocessedVert),Pt(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function fn(e,t){return e=on(e,t.numUniformBuffers),e=on(e,t.numSamplers)}function hn(e,t){return e=on(e,t.blendMode),e=on(e,t.blendSrcFactor),e=on(e,t.blendDstFactor)}function dn(e,t){return e=hn(e,t.rgbBlendState),e=on(e=hn(e,t.alphaBlendState),t.channelWriteMask)}function pn(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=dn(e,t.attachmentsState[r]);return e=function(e,t){return on(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=on(e,t.depthCompare),e=on(e,t.depthWrite?1:0),e=on(e,t.stencilCompare),e=on(e,t.stencilPassOp),e=on(e,t.stencilWrite?1:0),e=on(e,t.cullMode),e=on(e,t.frontFace?1:0),e=on(e,t.polygonOffset?1:0)}function _n(e){var t=0;t=on(t,e.program.id),null!==e.inputLayout&&(t=on(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=fn(t,e.bindingLayouts[r]);t=pn(t,e.megaStateDescriptor);for(var n=0;e.colorAttachmentFormats.length>n;n++)t=on(t,e.colorAttachmentFormats[n]||0);return an(t=on(t,e.depthStencilAttachmentFormat||0))}function vn(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=on(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=on(t,o.buffer.id),t=on(t,o.wordCount))}return an(t)}var En,yn=function(){function e(t){Ee(this,e),this.device=void 0,this.bindingsCache=new ln(pr,vn),this.renderPipelinesCache=new ln(mr,_n),this.inputLayoutsCache=new ln(Tr,sn),this.programCache=new ln(cn,sn),this.samplerCache=new ln(Ar,sn),this.device=t}return me(e,[{key:"createBindings",value:function(e){var t=this.bindingsCache.get(e);if(null===t){var r=Cr(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=xr(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=Ue(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=Ue(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=Ue(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=Ue(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=Ue(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"}(En||(En={}));var mn,gn={x:0,y:0,w:1,h:1},Rn=function(){function e(){Ee(this,e),this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=gn,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 me(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){Pt(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){Pt(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){Pt(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}]),e}(),Tn=function(){function e(t,r){Ee(this,e),this.debugName=void 0,this.dimension=tt.n2D,this.depth=1,this.numLevels=1,this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.usage=rt.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,Pt(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))}return me(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){Pt(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()}}]),e}(),An=function(){function e(t,r){Ee(this,e),this.dimension=tt.n2D,this.depth=1,this.numLevels=1,this.usage=rt.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 me(e,[{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){Pt(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}]),e}(),Sn=me((function e(){Ee(this,e),this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]})),On=function(){function e(t){Ee(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 me(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 Tn(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 An(this.device,e)}},{key:"beginGraphBuilder",value:function(){Pt(null===this.currentGraph),this.currentGraph=new Sn}},{key:"pushPass",value:function(e){var t=new Rn;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=xt(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Pt(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);Pt(void 0===r.resolveTextureOutputIDs[n]),r.resolveTextureOutputExternalTextures[n]=t}},{key:"getRenderTargetDescription",value:function(e){return xt(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(Pt(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=xt(this.renderTargetAliveForID[e]);return t?(Pt(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Pt(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];Pt(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=xt(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 xt(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;Pt(!(a&&s));var u=null,l=!1;if(this.renderTargetOutputCount[n]>1&&(l=!0),a){Pt(e.resolveTextureRenderTargetIDs[i]===n),Pt(this.resolveTextureUseCount[i]>0),Pt(this.renderTargetOutputCount[n]>0);var c=xt(this.renderTargetAliveForID[n]);if(null!==c.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=xt(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[En.DepthStencil],n=En.Color0;En.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[En.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var l=this.determineResolveParam(e,t,En.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),Pt(_.width===f),Pt(_.height===h),Pt(_.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 m=0;t.resolveTextureInputIDs.length>m;m++){t.resolveTextureInputTextures[m]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[m])}for(var g=0;t.renderTargetIDs.length>g;g++)this.releaseRenderTargetForID(t.renderTargetIDs[g],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)}},{key:"scheduleGraph",value:function(e){Pt(0===this.renderTargetOutputCount.length),Pt(0===this.renderTargetResolveCount.length),Pt(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++;Wt(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),Wt(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),Wt(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++)Pt(0===this.renderTargetOutputCount[o]);for(var a=0;this.renderTargetResolveCount.length>a;a++)Pt(0===this.renderTargetResolveCount[a]);for(var s=0;this.resolveTextureUseCount.length>s;s++)Pt(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)Pt(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){Pt(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=xt(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 Pt(r>=0),xt(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++)Pt(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)Pt(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"}(mn||(mn={}));var Cn=65536;function In(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Cn,n=b(e,0,r)/r;t&&(n=1-n);var i=65535*n;return 65535&i}function Pn(e,t){return(16777215&e|(255&t)<<24)>>>0}function xn(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function Nn(e,t){return Pn(xn(0,t),e)}function bn(e,t){return Pt(t>=0),(4294967040&e|t>>>8&255)>>>0}function Mn(e){return Pn(0,e)}function Dn(e,t){return Pt(t>=0),(4278190335&e|t<<8)>>>0}var Ln=y(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Bn,Fn=y(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function wn(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"}(Bn||(Bn={}));var Un,kn=function(){function e(){Ee(this,e),this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=zt(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=zt(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:er(nr),program:null,topology:Ze.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return me(e,[{key:"reset",value:function(){this.sortKey=0,this.flags=Bn.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){Jt(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=Me(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~Bn.InheritedFlags|e.flags&Bn.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 Jt(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){Pt(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){Pt(this.bindingDescriptors.length>=e.length),Pt(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=Kt(this.flags,Bn.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=Kt(this.flags,Bn.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=Kt(this.flags,Bn.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;if(M(t)||Array.isArray(t)||t instanceof Float32Array){var i=M(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,Me(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+=wn(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 Pt(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):(Pt(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=Kt(this.flags,Bn.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:Pt(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:Pt(n==a.sampleCount)),Pt(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&Bn.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=xt(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(de(de({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(Pt(!!(this.flags&Bn.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&Bn.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0}}]),e}();function Gn(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(Un||(Un={}));var Vn=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Gn,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Un.Forwards;Ee(this,e),this.renderInsts=[],this.compareFunction=void 0,this.executionOrder=void 0,this.usePostSort=!1,this.compareFunction=t,this.executionOrder=r}return me(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):Yt(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Bn.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===Un.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}(),Wn=function(){function e(){Ee(this,e),this.pool=[],this.allocCount=0}return me(e,[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new kn),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}(),Xn=function(){function e(t){Ee(this,e),this.renderCache=void 0,this.instPool=new Wn,this.templatePool=new Wn,this.simpleRenderInstList=new Vn,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t}return me(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){Pt(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|=Bn.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(),Pt(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){xt(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){xt(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}]),e}(),Hn=function(){function e(){Ee(this,e),this.renderCache=void 0,this.renderGraph=void 0,this.renderInstManager=void 0,this.uniformBuffer=void 0,this.device=void 0}return me(e,[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new yn(e),this.renderGraph=new On(this.device),this.renderInstManager=new Xn(this.renderCache),this.uniformBuffer=new nn(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}(),jn=function(){function e(t){Ee(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 me(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 Yn(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var Kn,zn=Yn(Dt(.88,.88,.88,1)),qn=Yn(Bt),Zn=Yn(wt);function Qn(e,t){var r=function(e){return e.antialiasingMode===Kn.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function $n(e,t,r){var n=function(e){if(e===En.Color0)return ht.U8_RGBA_RT;if(e===En.DepthStencil)return ht.D24_S8;throw Error("whoops")}(e),i=new jn(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"}(Kn||(Kn={}));var Jn=function(){function e(){Ee(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 me(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}(),ei=function(){function e(){Ee(this,e),this.inputTexture=null,this.outputTexture=null}return me(e,[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Pt(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new An(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}(),ti=["style"],ri=function(e){Re(r,e);var t=Ie(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.style,i=Se(e,ti);return Ee(this,r),t.call(this,de({type:r.tag,style:de({intensity:Math.PI},n)},i))}return me(r)}(t.DisplayObject);ri.tag="light";var ni,ii=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(ni||(ni={}));var oi=function(e){Re(r,e);var t=Ie(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.style,i=Se(e,ii);return Ee(this,r),t.call(this,de({type:r.tag,style:de({type:ni.NONE,fill:"black",start:1,end:1e3,density:0},n)},i))}return me(r)}(t.DisplayObject);oi.tag="fog";var ai;!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"}(ai||(ai={}));var si=function(){function e(t,r,n,i){Ee(this,e),this.renderHelper=void 0,this.lightPool=void 0,this.texturePool=void 0,this.batchManager=void 0,this.context=void 0,this.device=void 0,this.swapChain=void 0,this.renderLists={world:new Vn,picking:new Vn},this.builder=void 0,this.enableCapture=void 0,this.captureOptions=void 0,this.capturePromise=void 0,this.resolveCapturePromise=void 0,this.renderHelper=t,this.lightPool=r,this.texturePool=n,this.batchManager=i}var r;return me(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(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var t=e.target;if(t.nodeName!==ri.tag)if(t.nodeName!==oi.tag){var r=new Ge;t.renderable3D=r,n.batchManager.add(t)}else n.lightPool.addFog(t);else n.lightPool.addLight(t)},s=function(e){var t=e.target;t.nodeName!==ri.tag?t.nodeName!==oi.tag?(n.batchManager.remove(t),delete t.renderable3D):n.lightPool.removeFog(t):n.lightPool.removeLight(t)},u=function(e){n.batchManager.updateAttribute(e.target,e.attrName,e.newValue)},l=function(e){n.batchManager.updateAttribute(e.target,"modelMatrix",null)},c=function(e){n.batchManager.changeRenderOrder(e.target,e.detail.renderOrder)};i.hooks.init.tapPromise(e.tag,ve(pe().mark((function e(){var i,f;return pe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o.addEventListener(t.ElementEvent.MOUNTED,a),o.addEventListener(t.ElementEvent.UNMOUNTED,s),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,u),o.addEventListener(t.ElementEvent.BOUNDS_CHANGED,l),o.addEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,c),n.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,i=n.context.contextService.getDomElement(),n.context.contextService.resize((f=n.context.config).width,f.height),e.next=11,n.context.deviceContribution.createSwapChain(i);case 11:n.swapChain=e.sent,n.device=n.swapChain.getDevice(),n.renderHelper.setDevice(n.device),n.renderHelper.renderInstManager.disableSimpleMode(),n.swapChain.configureSwapChain(i.width,i.height),o.addEventListener(t.CanvasEvent.RESIZE,(function(){n.swapChain.configureSwapChain(i.width,i.height)})),n.batchManager.attach(de({device:n.device},r));case 18:case"end":return e.stop()}}),e)})))),i.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),o.removeEventListener(t.ElementEvent.MOUNTED,a),o.removeEventListener(t.ElementEvent.UNMOUNTED,s),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,u),o.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,l),o.removeEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,c)})),i.hooks.beginFrame.tap(e.tag,(function(){var e=n.swapChain.getCanvas(),r=n.renderHelper.renderInstManager;n.builder=n.renderHelper.renderGraph.newGraphBuilder();var i=t.parseColor(n.context.config.background),o=n.context.config.background?Dt(Number(i.r)/255*Number(i.alpha),Number(i.g)/255*Number(i.alpha),Number(i.b)/255*Number(i.alpha),Number(i.alpha)):Lt,a={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:Kn.None},s=$n(En.Color0,a,Yn(o)),u=$n(En.DepthStencil,a,Zn),l=n.builder.createRenderTargetID(s,"Main Color"),c=n.builder.createRenderTargetID(u,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(En.Color0,l),e.attachRenderTargetID(En.DepthStencil,c),e.exec((function(e){n.renderLists.world.drawOnPassRenderer(r.renderCache,e)}))})),n.builder.resolveRenderTargetToExternalTexture(l,n.swapChain.getOnscreenTexture())})),i.hooks.endFrame.tap(e.tag,(function(){var e=n.renderHelper.renderInstManager,t=n.renderHelper.pushTemplateRenderInst();t.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),t.setMegaStateFlags(ar({depthWrite:!0,blendConstant:Lt},{rgbBlendMode:Ye.Add,alphaBlendMode:Ye.Add,rgbBlendSrcFactor:je.SrcAlpha,alphaBlendSrcFactor:je.One,rgbBlendDstFactor:je.OneMinusSrcAlpha,alphaBlendDstFactor:je.OneMinusSrcAlpha}));var r=n.context.config,i=r.width,o=r.height,a=n.context.camera;if(t.setUniforms(0,[{name:ai.PROJECTION_MATRIX,value:a.getPerspective()},{name:ai.VIEW_MATRIX,value:a.getViewTransform()},{name:ai.CAMERA_POSITION,value:a.getPosition()},{name:ai.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:ai.VIEWPORT,value:[i,o]},{name:ai.IS_ORTHO,value:a.isOrtho()?1:0},{name:ai.IS_PICKING,value:0}]),n.batchManager.render(n.renderLists.world),e.popTemplateRenderInst(),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),e.resetRenderInsts(),n.swapChain.present(),n.enableCapture&&n.resolveCapturePromise){var s=n.captureOptions,u=s.type,l=s.encoderOptions,c=n.context.contextService.getDomElement().toDataURL(u,l);n.resolveCapturePromise(c),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))}},{key:"loadTexture",value:function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))}},{key:"toDataURL",value:(r=ve(pe().mark((function e(t){var r=this;return pe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.enableCapture=!0,this.captureOptions=t,this.capturePromise=new Promise((function(e){r.resolveCapturePromise=function(t){e(t)}})),e.abrupt("return",this.capturePromise);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})}]),e}();si.tag="RenderGraph";var ui=function(){function e(t,r,n,i){Ee(this,e),this.renderHelper=void 0,this.renderGraphPlugin=void 0,this.pickingIdGenerator=void 0,this.batchManager=void 0,this.context=void 0,this.renderHelper=t,this.renderGraphPlugin=r,this.pickingIdGenerator=n,this.batchManager=i}var r;return me(e,[{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var t=e.target,r=t.renderable3D;if(r){var i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)}};i.hooks.init.tapPromise(e.tag,ve(pe().mark((function e(){return pe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.addEventListener(t.ElementEvent.MOUNTED,a);case 1:case"end":return e.stop()}}),e)})))),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,a)})),i.hooks.pickSync.tap(e.tag,(function(e){return e})),i.hooks.pick.tapPromise(e.tag,function(){var e=ve(pe().mark((function e(r){var i,o,a,s,u,l,c,f,h;return pe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.topmost,a=(o=r.position).viewportX,s=o.viewportY,u=n.context.contextService.getDPR(),c=n.context.config.height*u,h=s*u,!((f=a*u)>(l=n.context.config.width*u)||0>f||h>c||0>h)){e.next=10;break}return r.picked=[],e.abrupt("return",r);case 10:return e.next=12,n.pickByRectangleInDepth(new t.Rectangle(b(Math.round(f),0,l-1),b(Math.round(h),0,c-1),1,1),i?1:100);case 12:return r.picked=e.sent,e.abrupt("return",r);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"pickByRectangleInDepth",value:(r=ve(pe().mark((function e(t){var r,n,i,o,a=arguments;return pe().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=this.context.camera,u=e.x,l=e.y,c=e.width,f=e.height,h={backbufferWidth:c,backbufferHeight:f,antialiasingMode:Kn.None},d=$n(En.Color0,h,Yn(Lt)),p=a.createRenderTargetID(d,"Picking Color"),_=$n(En.DepthStencil,h,Zn),v=a.createRenderTargetID(_,"Picking Depth"),E=de({},s.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(En.Color0,p),t.attachRenderTargetID(En.DepthStencil,v),t.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)})),t.post((function(t){var i=t.getRenderTargetTexture(En.Color0),o=n.createReadback();E&&E.enabled?s.setViewOffset(E.fullWidth,E.fullHeight,E.offsetX,E.offsetY,E.width,E.height):s.clearViewOffset(),s.setEnableUpdate(!0),o.readTexture(i,0,0,c,f,new Uint8Array(c*f*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 h=r.renderHelper.pushTemplateRenderInst();h.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),h.setMegaStateFlags(ar({depthWrite:!0},{rgbBlendMode:Ye.Add,rgbBlendSrcFactor:je.One,rgbBlendDstFactor:je.Zero,alphaBlendMode:Ye.Add,alphaBlendSrcFactor:je.One,alphaBlendDstFactor:je.Zero}));var d=r.context.config,_=d.width,y=d.height,m=r.context.contextService.getDPR();s.setEnableUpdate(!1),s.setViewOffset(_*m,y*m,u,l,c,f),h.setUniforms(0,[{name:ai.PROJECTION_MATRIX,value:s.getPerspective()},{name:ai.VIEW_MATRIX,value:s.getViewTransform()},{name:ai.CAMERA_POSITION,value:s.getPosition()},{name:ai.DEVICE_PIXEL_RATIO,value:r.context.contextService.getDPR()},{name:ai.VIEWPORT,value:[_,y]},{name:ai.IS_ORTHO,value:s.isOrtho()?1:0},{name:ai.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}();ui.tag="WebGLPicker";var li,ci=.005,fi=1,hi=function(){function e(){Ee(this,e),this.id=fi++,this.meshes=[],this.clipPathMeshCreated=!1}return me(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 di(e,t,r){var n=e.createBuffer({viewOrSize:Xt(r.byteLength,4)/4,usage:t,hint:$e.Static});return n.setSubData(0,new Uint8Array(r)),n}!function(e){e.CHANGED="changed"}(li||(li={}));var pi,_i=function(e){Re(n,e);var r=Ie(n);function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Ee(this,n),(t=r.call(this)).device=void 0,t.props=void 0,t.drawMode=Ze.Triangles,t.vertexBuffers=[],t.vertices=[],t.indexBuffer=void 0,t.indices=void 0,t.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:ht.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 me(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=di(this.device,Qe.INDEX|Qe.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=di(this.device,Qe.VERTEX|Qe.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(li.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}(D);!function(e){e.CHANGED="changed"}(pi||(pi={}));var vi=function(e){Re(r,e);var t=Ie(r);function r(e,n){var i;Ee(this,r),(i=t.call(this)).device=void 0,i.props={},i.meshes=[],i.defines={},i.uniforms={},i.uniformNames=void 0,i.uboBuffer=[],i.textures={},i.samplers=[],i.programDirty=!0,i.textureDirty=!0,i.geometryDirty=!0;var o=er(nr),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=de({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilCompare:l,stencilWrite:c,stencilPassOp:f,frontFace:h,polygonOffset:d,attachmentsState:p,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},n),i.compile(),i}return me(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:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=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=$r(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(et.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),I(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(pi.CHANGED)}}]),r}(D),Ei=function(e){Re(r,e);var t=Ie(r);function r(e,n){var i;return Ee(this,r),(i=t.call(this,e,de({},n))).defines=de(de({},i.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),i}return me(r)}(vi);function yi(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function mi(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var gi,Ri,Ti=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=Ne(e,2);return void 0!==t[1]})))},Ai=1,Si="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"}(gi||(gi={})),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"}(Ri||(Ri={}));var Oi,Ci,Ii=function(){function e(t,r,n){Ee(this,e),this.renderHelper=void 0,this.texturePool=void 0,this.lightPool=void 0,this.id=Ai++,this.renderer=void 0,this.index=-1,this.context=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 rn,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1,this.renderHelper=t,this.texturePool=r,this.lightPool=n}return me(e,[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(e){this.inited||(this.renderer.beforeInitMesh(this),this.context=e,this.material=new Ei(this.context.device),this.material.defines=de(de({},yi(Ri)),this.material.defines),this.geometry=new _i(this.context.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(li.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))}},{key:"observeMaterialChanged",value:function(){var e=this;this.material.on(pi.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))}},{key:"shouldMergeColor",value:function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return i instanceof t.CSSRGB&&o instanceof t.CSSRGB||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n]))}},{key:"shouldMerge",value:function(e,t){return!this.instance||(this.instance.nodeName===e.nodeName||this.instance.nodeName===e.renderable.proxyNodeName||this.instance.renderable.proxyNodeName===e.nodeName||this.instance.renderable.proxyNodeName===e.renderable.proxyNodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))}},{key:"createGeometry",value:function(e){var r=this,n=v(),i=v(),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,y=c.anchor,m=c.visibility,g=c.increasedLineWidthForHitTesting,T=[0,0,0,0];f instanceof t.CSSRGB&&(T=[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255,Number(f.alpha)]);var A=[0,0,0,0];h instanceof t.CSSRGB&&(A=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]),r.clipPathTarget?(E(n,e.getLocalTransform()),T=[1,1,1,1],R(n,r.clipPathTarget.getWorldTransform(),n)):E(n,e.getWorldTransform()),R(i,r.context.camera.getViewTransform(),n);var S=e.isInteractive()&&(null===(l=e.renderable3D)||void 0===l?void 0:l.encodedPickingColor)||[0,0,0];o.push.apply(o,Me(n)),a.push.apply(a,Me(T).concat(Me(A))),s.push(d,p,_,v,"visible"===m?1:0,y[0],y[1],g||0),u.push.apply(u,Me(S).concat([e.sortable.renderOrder*ci]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:gi.MODEL_MATRIX,byteStride:64,frequency:Je.PerInstance,attributes:[{format:ht.F32_RGBA,bufferByteOffset:0,location:Ri.MODEL_MATRIX0,divisor:1},{format:ht.F32_RGBA,bufferByteOffset:16,location:Ri.MODEL_MATRIX1,divisor:1},{format:ht.F32_RGBA,bufferByteOffset:32,location:Ri.MODEL_MATRIX2,divisor:1},{format:ht.F32_RGBA,bufferByteOffset:48,location:Ri.MODEL_MATRIX3,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:gi.FILL_STROKE,byteStride:32,frequency:Je.PerInstance,attributes:[{format:ht.F32_RGBA,bufferByteOffset:0,location:Ri.COLOR,divisor:1},{format:ht.F32_RGBA,bufferByteOffset:16,location:Ri.STROKE_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:gi.PACKED_STYLE,byteStride:32,frequency:Je.PerInstance,attributes:[{format:ht.F32_RGBA,bufferByteOffset:0,location:Ri.PACKED_STYLE1,divisor:1},{format:ht.F32_RGBA,bufferByteOffset:16,location:Ri.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:gi.PICKING_COLOR,byteStride:16,frequency:Je.PerInstance,attributes:[{format:ht.F32_RGBA,bufferByteOffset:0,location:Ri.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=de({},this.material.defines);if(this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=de(de({},this.material.defines),this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=We.Always,this.material.stencilPassOp=it.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=We.Equal,this.material.stencilPassOp=it.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 Jn;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:Ke.Clamp,wrapT:Ke.Clamp,minFilter:ze.Point,magFilter:ze.Bilinear,mipFilter:qe.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}(mi(a,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=de(de({},this.material.defines),yi(Ri)),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=tn(this.context.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.context.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=Nn(mn.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,Me(a).concat(Me(s)))})),this.geometry.updateVertexBuffer(gi.FILL_STROKE,Ri.COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===Si}));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;l.push(t.opacity,t.fillOpacity,t.strokeOpacity,t.lineWidth,"visible"===t.visibility?1:0,r[0],r[1],t.increasedLineWidthForHitTesting||0)})),this.geometry.updateVertexBuffer(gi.PACKED_STYLE,Ri.PACKED_STYLE1,r,new Uint8Array(new Float32Array(l).buffer))}else if("modelMatrix"===n){var c=[];e.forEach((function(e){var t=E(v(),e.getWorldTransform());c.push.apply(c,Me(t))})),this.geometry.updateVertexBuffer(gi.MODEL_MATRIX,Ri.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,Me(r).concat([e.sortable.renderOrder*ci]))})),this.geometry.updateVertexBuffer(gi.PICKING_COLOR,Ri.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(gi.PICKING_COLOR,Ri.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(Me(i),[t*ci])).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=gi.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=gi.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:gi.BARYCENTRIC,byteStride:12,frequency:Je.PerVertex,attributes:[{format:ht.F32_RGB,bufferByteOffset:0,location:Number(Ri.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);var f=n.blendEquation,h=n.blendEquationAlpha,d=n.blendSrc,p=n.blendDst,_=n.blendSrcAlpha,v=n.blendDstAlpha,E=Ti({blendConstant:n.blendConstant,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}),y=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(de({attachmentsState:[{channelWriteMask:this.material.stencilWrite?nt.None:nt.AllChannels,rgbBlendState:de(de({},y.rgbBlendState),Ti({blendMode:f,blendSrcFactor:d,blendDstFactor:p})),alphaBlendState:de(de({},y.alphaBlendState),Ti({blendMode:h,blendSrcFactor:_,blendDstFactor:v}))}]},E)),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,Me(r))}},{key:"createFillGradientTextureMapping",value:function(e){var r,n=this,i=e[0],o=i.nodeName===t.Shape.LINE?i.parsedStyle.stroke:i.parsedStyle.fill;if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,mt(ht.U8_RGBA_NORM,1,1,1));if(a){var s=new Jn;return s.name=Si,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({wrapS:Ke.Repeat,wrapT:Ke.Repeat,minFilter:ze.Point,magFilter:ze.Bilinear,mipFilter:qe.Linear,minLOD:0,maxLOD:0}),s}}return null}}]),e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(Oi||(Oi={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(Ci||(Ci={}));var Pi,xi,Ni=[t.Shape.CIRCLE,t.Shape.ELLIPSE],bi=function(e){Re(n,e);var r=Ie(n);function n(){return Ee(this,n),r.apply(this,arguments)}return me(n,[{key:"shouldMerge",value:function(e,t){var r=xe(Te(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=de(de({},this.material.defines),yi(Ci))}},{key:"createGeometry",value:function(e){var t=this;xe(Te(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,Me(c).concat([Ni.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:gi.POSITION,byteStride:16,frequency:Je.PerVertex,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:Ri.POSITION},{format:ht.F32_RG,bufferByteOffset:8,location:Ri.UV}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Oi.PACKED_STYLE,byteStride:24,frequency:Je.PerInstance,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:Ci.SIZE,divisor:1},{format:ht.F32_RGBA,bufferByteOffset:8,location:Ci.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(xe(Te(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=Ne(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,[r[0],r[1]].concat([Ni.indexOf(e.nodeName),e.parsedStyle.radius||0,t?1:0,0]))})),this.geometry.updateVertexBuffer(Oi.PACKED_STYLE,Ci.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,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}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}));return!i||i&&(o||1>n)}},{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}));return o&&n>0&&(a||1>i)}}]),n}(Ii),Mi=[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"}(Pi||(Pi={})),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"}(xi||(xi={}));var Di={butt:1,round:2,square:3},Li=function(e){Re(n,e);var r=Ie(n);function n(){return Ee(this,n),r.apply(this,arguments)}return me(n,[{key:"shouldMerge",value:function(e,t){var r=xe(Te(n.prototype),"shouldMerge",this).call(this,e,t);return!!r}},{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=de(de({},this.material.defines),yi(xi))}},{key:"createGeometry",value:function(e){var r=this;xe(Te(n.prototype),"createGeometry",this).call(this,e);var i=[],o=[],a=[],s=[],u=0;e.forEach((function(e){var n,l;if(e.nodeName===t.Shape.LINE)n=e.parsedStyle,l=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;n={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,defX:c.defX,defY:c.defY,lineCap:c.lineCap,lineDash:c.lineDash,lineDashOffset:c.lineDashOffset,isBillboard:!0,markerStart:c.markerStart,markerEnd:c.markerEnd,markerStartOffset:c.markerStartOffset,markerEndOffset:c.markerEndOffset},l=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){var h=e.parsedStyle,d=h.path.absolutePath;n={x1:d[0][1],y1:d[0][2],x2:d[1][1],y2:d[1][2],z1:0,z2:0,defX:h.defX,defY:h.defY,lineCap:h.lineCap,lineDash:h.lineDash,lineDashOffset:h.lineDashOffset,isBillboard:!1,markerStart:h.markerStart,markerEnd:h.markerEnd,markerStartOffset:h.markerStartOffset,markerEndOffset:h.markerEndOffset},l=e.getTotalLength()}var p=n.x1,_=n.y1,v=n.x2,E=n.y2,y=n.z1,m=n.z2,g=n.defX,R=n.defY,T=n.lineCap,A=n.isBillboard,S=r.calcOffset(n),O=S.startOffsetX,C=S.startOffsetY,I=S.endOffsetX,P=S.endOffsetY,x=r.calcDash(n,l),N=x.dashOffset,b=x.dashSegmentPercent,M=x.dashRatioInEachSegment;o.push(Di[T]),a.push(N,b,M,A?1:0),i.push(p-g+O,_-R+C,y,v-g+I,E-R+P,m),s.push(0+u,2+u,1+u,0+u,3+u,2+u),u+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:gi.POSITION,byteStride:20,frequency:Je.PerInstance,attributes:[{format:ht.F32_RGB,bufferByteOffset:0,location:xi.POSITION,divisor:0},{format:ht.F32_RG,bufferByteOffset:12,location:xi.UV,divisor:0}],data:new Float32Array(Mi)}),this.geometry.setVertexBuffer({bufferIndex:Pi.POINT,byteStride:24,frequency:Je.PerInstance,attributes:[{format:ht.F32_RGB,bufferByteOffset:0,location:xi.POINTA,divisor:1},{format:ht.F32_RGB,bufferByteOffset:12,location:xi.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Pi.CAP,byteStride:4,frequency:Je.PerInstance,attributes:[{format:ht.F32_R,bufferByteOffset:0,location:xi.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Pi.DASH,byteStride:16,frequency:Je.PerInstance,attributes:[{format:ht.F32_RGBA,bufferByteOffset:0,location:xi.DASH,divisor:1}],data:new Float32Array(a)})}},{key:"updateAttribute",value:function(e,r,i,o){var a=this;if(xe(Te(n.prototype),"updateAttribute",this).call(this,e,r,i,o),this.updateBatchedAttribute(e,r,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"path"===i){var s=[];e.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE&&e.renderable.proxyNodeName===t.Shape.LINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,defX:n.defX,defY:n.defY,lineCap:n.lineCap,isBillboard:!0,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH&&e.renderable.proxyNodeName===t.Shape.LINE){var o=e.parsedStyle,u=o.path.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,defX:o.defX,defY:o.defY,lineCap:o.lineCap,isBillboard:!0,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var l=r.x1,c=r.y1,f=r.x2,h=r.y2,d=r.z1,p=r.z2,_=r.defX,v=r.defY,E=a.calcOffset(r);s.push(l-_+E.startOffsetX,c-v+E.startOffsetY,d,f-_+E.endOffsetX,h-v+E.endOffsetY,p)})),this.geometry.updateVertexBuffer(Pi.POINT,xi.POINTA,r,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i){var u=[];e.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Pi.DASH,xi.DASH,r,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var l=[];e.forEach((function(e){l.push(Di[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Pi.CAP,xi.CAP,r,new Uint8Array(new Float32Array(l).buffer))}}},{key:"calcOffset",value:function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,l=e.markerEndOffset,c=0,f=0,h=0,d=0,p=0;return a&&a instanceof t.DisplayObject&&u&&(c=Math.cos(p=Math.atan2(o-n,i-r))*(u||0),f=Math.sin(p)*(u||0)),s&&s instanceof t.DisplayObject&&l&&(h=Math.cos(p=Math.atan2(n-o,r-i))*(l||0),d=Math.sin(p)*(l||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:h,endOffsetY:d}}},{key:"calcDash",value:function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}}}]),n}(Ii);function Bi(e){return function(e){if(Array.isArray(e))return Fi(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 Fi(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 Fi(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 Fi(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 wi(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}var Ui=function(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}};function ki(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function Gi(e,t,r,n,i,o,a){var s=ki(e,r,i,a),u=ki(t,n,o,a),l=Ui(e,t,r,n,a),c=Ui(r,n,i,o,a);return[[e,t,l.x,l.y,s,u],[s,u,c.x,c.y,i,o]]}function Vi(e,t,r,n,i,o,a){if(0===a)return(wi(e,t,r,n)+wi(r,n,i,o)+wi(e,t,i,o))/2;var s=Gi(e,t,r,n,i,o,.5),u=s[0],l=s[1];return u.push(a-1),l.push(a-1),Vi.apply(void 0,Bi(u))+Vi.apply(void 0,Bi(l))}var Wi=function(e,t,r,n,i,o){return Vi(e,t,r,n,i,o,3)};function Xi(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 Hi(e,t,r,n,i,o,a,s,u){var l=Xi(e,r,i,a,u),c=Xi(t,n,o,s,u),f=Ui(e,t,r,n,u),h=Ui(r,n,i,o,u),d=Ui(i,o,a,s,u),p=Ui(f.x,f.y,h.x,h.y,u),_=Ui(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 ji(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+=wi(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=Hi(e,t,r,n,i,o,a,s,.5),c=[].concat(Bi(l[0]),[u-1]),f=[].concat(Bi(l[1]),[u-1]);return ji.apply(void 0,Bi(c))+ji.apply(void 0,Bi(f))}var Yi,Ki=function(e,t,r,n,i,o,a,s){return ji(e,t,r,n,i,o,a,s,3)};function zi(e,t,r,n,i){for(var o=i[i.length-2],a=i[i.length-1],s=Wi(o,a,e,t,r,n),u=b(s/10,8,100),l=0,c=0,f=1;u>=f;++f){var h=f/u;i.push((l=o+(e-o)*h)+(e+(r-e)*h-l)*h,(c=a+(t-a)*h)+(t+(n-t)*h-c)*h)}}function qi(e,t,r,n,i,o,a){var s=a[a.length-2],u=a[a.length-1];a.length-=2;var l=Ki(s,u,e,t,r,n,i,o),c=b(l/10,8,100),f=0,h=0,d=0,p=0,_=0;a.push(s,u);for(var v=1,E=0;c>=v;++v)a.push((d=(h=(f=1-(E=v/c))*f)*f)*s+3*h*E*e+3*f*(p=E*E)*r+(_=p*E)*i,d*u+3*h*E*t+3*f*p*n+_*o)}!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"}(Yi||(Yi={}));var Zi,Qi,$i;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(Zi||(Zi={})),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"}(Qi||(Qi={})),function(e){e.MODEL_MATRIX="u_ModelMatrix",e.FILL_COLOR="u_FillColor",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 Ji=function(e){Re(n,e);var r=Ie(n);function n(){return Ee(this,n),r.apply(this,arguments)}return me(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"updateAttribute",value:function(e,r,i,o){var a=this;xe(Te(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||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===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=[0,0,0,0];n instanceof t.CSSRGB&&(E=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(ge({},$i.STROKE_COLOR,E))}else if("opacity"===i)a.material.setUniforms(ge({},$i.OPACITY,s));else if("fillOpacity"===i)a.material.setUniforms(ge({},$i.FILL_OPACITY,u));else if("strokeOpacity"===i)a.material.setUniforms(ge({},$i.STROKE_OPACITY,l));else if("lineWidth"===i)a.material.setUniforms(ge({},$i.STROKE_WIDTH,c));else if("increasedLineWidthForHitTesting"===i)a.material.setUniforms(ge({},$i.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,f||0));else if("anchor"===i||"modelMatrix"===i){var y=0,m=0,A=e.getGeometryBounds();if(A){var S=A.halfExtents;y=-S[0]*h[0]*2,m=-S[1]*h[1]*2}var O=v();R(O,e.getWorldTransform(),g(O,T(y,m,0))),a.material.setUniforms(ge({},$i.MODEL_MATRIX,O))}else if("visibility"===i)a.material.setUniforms(ge({},$i.VISIBLE,"visible"===_?1:0));else if("lineDash"===i){var C;a.material.setUniforms((ge(C={},$i.DASH,d[0]||0),ge(C,$i.GAP,d[1]||0),C))}else if("lineDashOffset"===i)a.material.setUniforms(ge({},$i.DASH_OFFSET,p||0));else if("pointerEvents"===i){var I,P=o&&e.isInteractive()&&(null===(I=e.renderable3D)||void 0===I?void 0:I.encodedPickingColor)||[0,0,0];a.material.setUniforms(ge({},$i.PICKING_COLOR,P))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(ge({},$i.Z_INDEX,t*ci))}},{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_FillColor;\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_FillColor;\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 scalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n float travel = mod(v_Travel + u_Gap * scalingFactor * 0.5 + u_DashOffset, u_Dash * scalingFactor + u_Gap * scalingFactor) - (u_Gap * scalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * scalingFactor + 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=de(de({},this.material.defines),yi(Qi));var i=e[0],o=i.parsedStyle,a=o.fill,s=o.stroke,u=o.opacity,l=o.fillOpacity,c=o.strokeOpacity,f=o.lineWidth,h=o.increasedLineWidthForHitTesting,d=o.anchor,p=o.lineDash,_=o.lineDashOffset,E=o.visibility,y=[0,0,0,0];a instanceof t.CSSRGB&&(y=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var m=[0,0,0,0];s instanceof t.CSSRGB&&(m=[Number(s.r)/255,Number(s.g)/255,Number(s.b)/255,Number(s.alpha)]);var A=i.isInteractive()&&(null===(r=i.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=0,O=0,C=i.getGeometryBounds();if(C){var I=C.halfExtents;S=-I[0]*d[0]*2,O=-I[1]*d[1]*2}var P=v();R(P,i.getWorldTransform(),g(P,T(S,O,0))),this.material.setUniforms((ge(n={},$i.MODEL_MATRIX,P),ge(n,$i.FILL_COLOR,y),ge(n,$i.STROKE_COLOR,m),ge(n,$i.STROKE_WIDTH,f),ge(n,$i.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,h||0),ge(n,$i.OPACITY,u),ge(n,$i.FILL_OPACITY,l),ge(n,$i.STROKE_OPACITY,c),ge(n,$i.EXPAND,1),ge(n,$i.MITER_LIMIT,5),ge(n,$i.SCALE_MODE,1),ge(n,$i.ALIGNMENT,.5),ge(n,$i.PICKING_COLOR,A),ge(n,$i.DASH,p&&p[0]||0),ge(n,$i.GAP,p&&p[1]||0),ge(n,$i.DASH_OFFSET,_||0),ge(n,$i.VISIBLE,"visible"===E?1:0),ge(n,$i.Z_INDEX,i.sortable.renderOrder*ci),n)),this.material.cullMode=He.None}},{key:"createGeometry",value:function(e){var t=eo(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:Zi.PACKED,byteStride:48,frequency:Je.PerInstance,attributes:[{format:ht.F32_RG,bufferByteOffset:0,byteStride:12,location:Qi.PREV,divisor:1},{format:ht.F32_RG,bufferByteOffset:12,byteStride:12,location:Qi.POINT1,divisor:1},{format:ht.F32_R,bufferByteOffset:20,byteStride:12,location:Qi.VERTEX_JOINT,divisor:1},{format:ht.F32_RG,bufferByteOffset:24,byteStride:12,location:Qi.POINT2,divisor:1},{format:ht.F32_RG,bufferByteOffset:36,byteStride:12,location:Qi.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:Zi.VERTEX_NUM,byteStride:4,frequency:Je.PerInstance,attributes:[{format:ht.F32_R,bufferByteOffset:0,byteStride:4,location:Qi.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Zi.TRAVEL,byteStride:4,frequency:Je.PerInstance,attributes:[{format:ht.F32_R,bufferByteOffset:0,byteStride:4,location:Qi.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}(Ii);function eo(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=e.parsedStyle,c=l.markerStart,f=l.markerEnd,h=l.markerStartOffset,d=l.markerEndOffset,p=[],_=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var E=e.parsedStyle.points.points,y=E.length,g=0,R=0,T=0,A=0,S=0;if(c&&c instanceof t.DisplayObject&&h&&(g=Math.cos(S=Math.atan2(E[1][1]-E[0][1],E[1][0]-E[0][0]))*(h||0),R=Math.sin(S)*(h||0)),f&&f instanceof t.DisplayObject&&d&&(T=Math.cos(S=Math.atan2(E[y-2][1]-E[y-1][1],E[y-2][0]-E[y-1][0]))*(d||0),A=Math.sin(S)*(d||0)),p[0]=E.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=g,i=R):r===y-1&&(n=T,i=A),e.push(t[0]-s+n,t[1]-u+i),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return _=L(p[0],[],2),{pointsBuffer:p[0],travelBuffer:[],triangles:_,instancedCount:Math.round(p[0].length/2)};var O;p[0].push(p[0][0],p[0][1]),(O=p[0]).push.apply(O,Me(no(p[0][0],p[0][1],p[0][2],p[0][3])))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var I;if(e.nodeName!==t.Shape.PATH){if(I=t.parsePath(t.convertToPath(e,m(v())),e),s=I.rect.x,u=I.rect.y,e.nodeName===t.Shape.RECT){var P=e.parsedStyle,x=P.width,N=P.height;0>x&&(s+=I.rect.width),0>N&&(u+=I.rect.height)}}else I=e.parsedStyle.path;var b=I,M=b.absolutePath,D=b.segments,B=0,F=0,w=0,U=0,k=0;if(c&&c instanceof t.DisplayObject&&h){var G=c.parentNode.getStartTangent(),V=Ne(G,2),W=V[0],X=V[1];B=Math.cos(k=Math.atan2(W[1]-X[1],W[0]-X[0]))*(h||0),F=Math.sin(k)*(h||0)}if(f&&f instanceof t.DisplayObject&&d){var H=f.parentNode.getEndTangent(),j=Ne(H,2),Y=j[0],K=j[1];w=Math.cos(k=Math.atan2(Y[1]-K[1],Y[0]-K[0]))*(d||0),U=Math.sin(k)*(d||0)}var z=-1,q=-1;if(M.forEach((function(r,n){var i=be(r),o=i[0],a=i.slice(1),l=M[n+1],c=0===n&&(0!==B||0!==F),f=(n===M.length-1||l&&("M"===l[0]||"Z"===l[0]))&&0!==w&&0!==U;if("M"===o)q++,p[q]=[],z=p[q].length,c?p[q].push(a[0]-s+B,a[1]-u+F,a[0]-s,a[1]-u):p[q].push(a[0]-s,a[1]-u);else if("L"===o)f?p[q].push(a[0]-s+w,a[1]-u+U):p[q].push(a[0]-s,a[1]-u);else if("Q"===o)zi(a[0]-s,a[1]-u,a[2]-s,a[3]-u,p[q]),f&&p[q].push(a[2]-s+w,a[3]-u+U);else if("A"===o){for(var h=Ne(D[n].prePoint,2),d=C(h[0],h[1],a[0],a[1],a[2],a[3],a[4],a[5],a[6],void 0),_=0;d.length>_;_+=6)qi(d[_]-s,d[_+1]-u,d[_+2]-s,d[_+3]-u,d[_+4]-s,d[_+5]-u,p[q]);f&&p[q].push(a[5]-s+w,a[6]-u+U)}else if("C"===o)qi(a[0]-s,a[1]-u,a[2]-s,a[3]-u,a[4]-s,a[5]-u,p[q]),f&&p[q].push(a[4]-s+w,a[5]-u+U);else if("Z"===o&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var v,E=1e-4;(Math.abs(p[q][p[q].length-2]-p[q][z])>E||Math.abs(p[q][p[q].length-1]-p[q][z+1])>E)&&p[q].push(p[q][z],p[q][z+1]),(v=p[q]).push.apply(v,Me(no(p[q][z],p[q][z+1],p[q][z+2],p[q][z+3])))}})),r){var Z=p.reduce((function(e,t){return e.push.apply(e,Me(t)),e}),[]);return{pointsBuffer:Z,travelBuffer:[],triangles:_=L(Z,[],2),instancedCount:Math.round(Z.length/2)}}}var Q=to(o),$=ro(i),J=$;return $===Yi.CAP_ROUND&&(J=Yi.JOINT_CAP_ROUND),$===Yi.CAP_BUTT&&(J=Yi.JOINT_CAP_BUTT),$===Yi.CAP_SQUARE&&(J=Yi.JOINT_CAP_SQUARE),p.map((function(e){for(var t=6,r=0,n=[],i=[],o=0;e.length>o;o+=2)o>1&&(r+=Math.sqrt(Math.pow(e[o]-e[o-2],2)+Math.pow(e[o+1]-e[o+1-2],2))),i.push(r),n[t++]=e[o],n[t++]=e[o+1],n[t]=Q,0==o&&$!==Yi.CAP_ROUND&&(n[t]+=$),e.length>o+4?e.length>o+2||(n[t]=0):n[t]+=J-Q,t++;return n[t++]=e[e.length-4],n[t++]=e[e.length-3],n[t++]=0,n[0]=e[0],n[1]=e[1],n[2]=0,n[3]=e[2],n[4]=e[3],n[5]=$===Yi.CAP_ROUND?$:0,{pointsBuffer:n,travelBuffer:i,triangles:_,instancedCount:Math.round(e.length/2)}})).reduce((function(e,t){var r,n;return(r=e.pointsBuffer).push.apply(r,Me(t.pointsBuffer)),(n=e.travelBuffer).push.apply(n,Me(t.travelBuffer)),e.instancedCount+=t.instancedCount,e}),{pointsBuffer:[],travelBuffer:[],triangles:_,instancedCount:0})}function to(e){var t;switch(e){case"bevel":t=Yi.JOINT_BEVEL;break;case"round":t=Yi.JOINT_ROUND;break;default:t=Yi.JOINT_MITER}return t}function ro(e){var t;switch(e){case"square":t=Yi.CAP_SQUARE;break;case"round":t=Yi.CAP_ROUND;break;default:t=Yi.CAP_BUTT}return t}function no(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 io=function(e){Re(n,e);var r=Ie(n);function n(){return Ee(this,n),r.apply(this,arguments)}return me(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"createGeometry",value:function(e){var t=e[0],r=eo(t,!0),n=r.triangles,i=r.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:gi.POSITION,byteStride:8,frequency:Je.PerVertex,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:Ri.POSITION}],data:new Float32Array(i)});var o=t.getGeometryBounds().halfExtents,a=i.map((function(e,t){return e/o[t%2]/2}));this.geometry.setVertexBuffer({bufferIndex:gi.UV,byteStride:8,frequency:Je.PerVertex,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:Ri.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))}},{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_FillColor;\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#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n gl_Position = 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_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\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\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\n vec4 u_Color = u_FillColor;\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 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 E=_.halfExtents;d=-E[0]*l[0]*2,p=-E[1]*l[1]*2}var y=v();R(y,i.getWorldTransform(),g(y,T(d,p,0))),this.material.setUniforms((ge(n={},$i.MODEL_MATRIX,y),ge(n,$i.FILL_COLOR,f),ge(n,$i.PICKING_COLOR,h),ge(n,$i.OPACITY,s),ge(n,$i.FILL_OPACITY,u),ge(n,$i.VISIBLE,"visible"===c?1:0),ge(n,$i.Z_INDEX,i.sortable.renderOrder*ci),n))}},{key:"updateAttribute",value:function(e,r,i,o){var a=this;xe(Te(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||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===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)if(n instanceof t.CSSRGB){a.material.setUniforms(ge({},$i.FILL_COLOR,[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]))}else{var f=a.textureMappings.findIndex((function(e){return e.name===Si})),h=a.createFillGradientTextureMapping([a.instance]);0>f||a.textureMappings.splice(f,1,h),a.material.textureDirty=!0}else if("opacity"===i)a.material.setUniforms(ge({},$i.OPACITY,s));else if("fillOpacity"===i)a.material.setUniforms(ge({},$i.FILL_OPACITY,u));else if("anchor"===i||"modelMatrix"===i){var d=0,p=0,_=e.getGeometryBounds();if(_){var E=_.halfExtents;d=-E[0]*l[0]*2,p=-E[1]*l[1]*2}var y=v();R(y,e.getWorldTransform(),g(y,T(d,p,0))),a.material.setUniforms(ge({},$i.MODEL_MATRIX,y))}else if("visibility"===i)a.material.setUniforms(ge({},$i.VISIBLE,"visible"===c?1:0));else if("pointerEvents"===i){var m,A=o&&e.isInteractive()&&(null===(m=e.renderable3D)||void 0===m?void 0:m.encodedPickingColor)||[0,0,0];a.material.setUniforms(ge({},$i.PICKING_COLOR,A))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(ge({},$i.Z_INDEX,t*ci))}}]),n}(Ii),oo=function(e){Re(r,e);var t=Ie(r);function r(){return Ee(this,r),t.apply(this,arguments)}return me(r,[{key:"shouldMerge",value:function(e,t){var n=xe(Te(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=de({},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.context.device,t);this.material.setUniforms({u_Map:r})}},{key:"createGeometry",value:function(e){xe(Te(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,a.height),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:gi.POSITION,byteStride:8,frequency:Je.PerInstance,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:Ri.POSITION}],data:new Float32Array(t)}),this.geometry.setVertexBuffer({bufferIndex:gi.UV,byteStride:8,frequency:Je.PerVertex,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:Ri.UV}],data:new Float32Array(n)})}},{key:"updateAttribute",value:function(e,t,n,i){if(xe(Te(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,t.height)})),this.geometry.updateVertexBuffer(gi.POSITION,Ri.POSITION,t,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:a})}}}]),r}(Ii);function ao(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 so(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 uo=function(){function e(t,r){Ee(this,e),this.width=void 0,this.height=void 0,this.data=void 0,ao(this,t,1,r)}return me(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=ao({},{width:n,height:i},r);so(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){so(e,t,r,n,i,1)}}]),e}();var lo=me((function e(t){Ee(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=Ue(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=Ue(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 uo({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)uo.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 co(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}var fo,ho,po,_o=function(){function e(){Ee(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphAtlas=void 0,this.glyphMap={},this.glyphAtlasTexture=void 0}return me(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=co());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]=de(de({},this.glyphMap[t]),l),this.glyphAtlas=new lo(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(de(de({},mt(ht.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 le({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 uo({width:l,height:c},u),metrics:{width:f,height:h,left:d,top:p-24+3,advance:_}}}}]),e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(fo||(fo={})),function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(ho||(ho={})),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"}(po||(po={}));var vo,Eo,yo,mo=function(e){Re(n,e);var r=Ie(n);function n(){var e;Ee(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=new _o,e}return me(n,[{key:"shouldMerge",value:function(e,t){var r=xe(Te(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.metrics.font===e.parsedStyle.metrics.font&&!["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(t){return i.parsedStyle[t]!==e.parsedStyle[t]}))}},{key:"createGeometry",value:function(e){var t=this,r=this.instance.parsedStyle,n=r.textBaseline,i=r.letterSpacing,o=24/r.fontSize,a=[],s=[],u=[],l=0;e.forEach((function(e){var r=e.parsedStyle,c=r.metrics,f=c.font,h=c.lines,d=c.height,p=c.lineHeight,_=r.dx||0,v=r.dy||0,E=0;"middle"===n?E=-d/2:"bottom"===n?E=-d:"top"===n||"hanging"===n?E=0:"alphabetic"===n?E=.25*p-d:"ideographic"===n&&(E=-d);var y=t.glyphManager.getAtlas(),m=t.buildTextBuffers({object:e,lines:h,fontStack:f,lineHeight:o*p,offsetX:o*_,offsetY:o*(E+v),letterSpacing:o*i,glyphAtlas:y,indicesOffset:l}),g=m.indexBuffer,R=m.charUVOffsetBuffer;l=m.indicesOffset,u.push.apply(u,Me(m.charPackedBuffer)),s.push.apply(s,Me(R)),a.push.apply(a,Me(g))})),this.geometry.vertexCount=a.length,this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.setVertexBuffer({bufferIndex:fo.INSTANCED,byteStride:144,frequency:Je.PerVertex,attributes:[{format:ht.F32_RGBA,bufferByteOffset:0,location:Ri.MODEL_MATRIX0},{format:ht.F32_RGBA,bufferByteOffset:16,location:Ri.MODEL_MATRIX1},{format:ht.F32_RGBA,bufferByteOffset:32,location:Ri.MODEL_MATRIX2},{format:ht.F32_RGBA,bufferByteOffset:48,location:Ri.MODEL_MATRIX3},{format:ht.F32_RGBA,bufferByteOffset:64,location:Ri.COLOR},{format:ht.F32_RGBA,bufferByteOffset:80,location:Ri.STROKE_COLOR},{format:ht.F32_RGBA,bufferByteOffset:96,location:Ri.PACKED_STYLE1},{format:ht.F32_RGBA,bufferByteOffset:112,location:Ri.PACKED_STYLE2},{format:ht.F32_RGBA,bufferByteOffset:128,location:Ri.PICKING_COLOR}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:fo.TEX,byteStride:16,frequency:Je.PerVertex,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:ho.TEX},{format:ht.F32_RG,bufferByteOffset:8,location:ho.OFFSET}],data:new Float32Array(s)})}},{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=He.Back,this.material.defines=de(de({},this.material.defines),yi(ho));var r=this.instance.parsedStyle,n=r.fontSize,i=r.fontFamily,o=void 0===i?"":i,a=r.fontWeight,s=void 0===a?"":a,u=r.fontStyle,l=r.metrics.font,c=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(l,o,""+s,u,c,this.context.device);var f=this.glyphManager.getAtlasTexture(),h=this.glyphManager.getAtlas();this.context.device.setResourceName(f,"TextSDF Texture");var d=h.image,p=d.width,_=d.height;this.material.setUniforms((ge(t={},po.SDF_MAP,f),ge(t,po.SDF_MAP_SIZE,[p,_]),ge(t,po.FONT_SIZE,n),ge(t,po.GAMMA_SCALE,1),ge(t,po.STROKE_BLUR,.2),ge(t,po.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,y=h.opacity,m=h.fillOpacity,g=h.strokeOpacity,R=h.lineWidth,T=h.visibility,A=[0,0,0,0];p instanceof t.CSSRGB&&(A=[Number(p.r)/255,Number(p.g)/255,Number(p.b)/255,Number(p.alpha)]);var S=[0,0,0,0];_ instanceof t.CSSRGB&&(S=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)]);var O=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],C=E(v(),n.getWorldTransform()),I=[],P=[],x=[],N=f,b=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,s,u,l),c.positions);return b.forEach((function(e){var t=[];t.push.apply(t,Me(C));var r=[].concat(t,Me(A),Me(S),[y,m,g,R,"visible"===T?1:0,0,0,0],Me(O),[n.sortable.renderOrder*ci]);I.push.apply(I,Me(r).concat(Me(r),Me(r),Me(r))),P.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),P.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),P.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),P.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),x.push(0+N,2+N,1+N),x.push(2+N,0+N,3+N),N+=4})),{indexBuffer:x,charUVOffsetBuffer:P,charPackedBuffer:I,indicesOffset:N}}}]),n}(Ii),go=function(e){Re(n,e);var r=Ie(n);function n(){return Ee(this,n),r.apply(this,arguments)}return me(n,[{key:"shouldMerge",value:function(e,r){var i=xe(Te(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){xe(Te(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,xe(Te(n.prototype),"createGeometry",this).call(this,e),this.geometry.build(e),this.observeGeometryChanged()}}]),n}(Ii),Ro=function(e){Re(r,e);var t=Ie(r);function r(){var e;Ee(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=[bi,Ji],e}return me(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}));return!s||u&&o>0&&(1>a||l)}}]),r}(hi),To=function(e){Re(n,e);var r=Ie(n);function n(){var e;Ee(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=[io,Ji,Li],e}return me(n,[{key:"shouldSubmitRenderInst",value:function(e,r){var n=e.parsedStyle,i=n.fill,o=n.stroke,a=n.opacity,s=n.strokeOpacity,u=n.lineDash,l=n.lineWidth,c=e.nodeName,f=o&&!o.isNone,h=u&&u.length&&u.every((function(e){return 0!==e})),d=this.isLine(e);if(e.renderable.proxyNodeName=d?t.Shape.LINE:null,0===r&&(e.nodeName===t.Shape.POLYLINE||i.isNone))return!1;if(1===r){if(d||0===s||0===a||0===l||!f)return!1;if(c===t.Shape.CIRCLE||c===t.Shape.ELLIPSE)return h}return 2!==r||d}},{key:"isLine",value:function(e){if(e.nodeName===t.Shape.PATH){var r=e.parsedStyle.path.absolutePath;if(2===r.length&&"M"===r[0][0]&&"L"===r[1][0])return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var n=e.parsedStyle.points.points,i=(n[1][0]-n[1][1])/(n[0][0]-n[0][1]),o=1;n.length-1>o;o++)if((n[o+1][0]-n[o+1][1])/(n[o][0]-n[o][1])!==i)return!1;return!0}return!1}}]),n}(hi),Ao=function(e){Re(r,e);var t=Ie(r);function r(){var e;Ee(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=[oo],e}return me(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(hi),So=function(e){Re(r,e);var t=Ie(r);function r(){var e;Ee(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=[mo,mo],e}return me(r,[{key:"shouldSubmitRenderInst",value:function(e,t){var r=e.parsedStyle;return!!(r.stroke&&r.lineWidth||0!==t)}},{key:"beforeUploadUBO",value:function(e,t,r){t.material.setUniforms(ge({},po.HAS_STROKE,1-t.index))}}]),r}(hi),Oo=function(e){Re(r,e);var t=Ie(r);function r(){var e;Ee(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=[Li],e}return me(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(hi),Co=function(e){Re(r,e);var t=Ie(r);function r(){var e;Ee(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=[go],e}return me(r)}(hi),Io=1,Po=function(){function e(t,r,n,i){Ee(this,e),this.renderHelper=void 0,this.rendererFactory=void 0,this.texturePool=void 0,this.lightPool=void 0,this.context=void 0,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={},this.renderHelper=t,this.rendererFactory=r,this.texturePool=n,this.lightPool=i}return me(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.context);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){this.context=e}},{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=new i(t.renderHelper,t.texturePool,t.lightPool)).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=new s(n.renderHelper,n.texturePool,n.lightPool)).renderer=a,c.index=u,c.init(n.context),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]=Io++),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}(),xo=function(){function e(t){Ee(this,e),this.context=void 0,this.textureCache={},this.context=t}return me(e,[{key:"getOrCreateTexture",value:function(e,r,n,i){var o,a=this,s="string"==typeof r?r:r.src||"";if(s&&this.textureCache[s])(o=this.textureCache[s]).emit(et.LOADED);else if(o=e.createTexture(de({pixelFormat:ht.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:tt.n2D,usage:rt.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),s&&(this.textureCache[s]=o),N(r)){var u,l=this.context.config.createImage;l?u=l(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){a.textureCache[s].setImageData(u),a.textureCache[s].emit(et.LOADED),a.context.renderingService.dirtify(),i&&i(a.textureCache[s])},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else o.setImageData(r),o.emit(et.LOADED),this.context.renderingService.dirtify();return o}},{key:"getOrCreateCanvas",value:function(){return t.runtime.offscreenCanvas.getOrCreateCanvas(this.context.config.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var r=e.gradients,n=e.instance.getGeometryBounds().halfExtents,i=2*n[0]||1,o=2*n[1]||1,a=this.context.config.offscreenCanvas,s=t.runtime.offscreenCanvas.getOrCreateCanvas(a),u=t.runtime.offscreenCanvas.getOrCreateContext(a);s.width=i,s.height=o;var l=this.context.imagePool;r.forEach((function(e){var t=l.getOrCreateGradient(de(de({type:e.type},e.value),{},{width:i,height:o}),u);u.fillStyle=t,u.fillRect(0,0,i,o)}))}},{key:"getOrCreatePattern",value:function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,l=2*u[0]||1,c=2*u[1]||1,f=this.context.config.offscreenCanvas,h=t.runtime.offscreenCanvas.getOrCreateCanvas(f),d=t.runtime.offscreenCanvas.getOrCreateContext(f);h.width=l,h.height=c;var p=(i=N(o)?this.context.imagePool.getImageSync(o,n):o)&&d.createPattern(i,a);if(s){var _=t.parsedTransformToMat4(t.parseTransform(s));p.setTransform({a:_[0],b:_[1],c:_[4],d:_[5],e:_[12],f:_[13]})}d.fillStyle=p,d.fillRect(0,0,l,c)}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}}}]),e}(),No="#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}",bo="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = texture(SAMPLER_2D(u_Texture), v_TexCoord);\n}",Mo=function(e){Re(r,e);var t=Ie(r);function r(){var e;Ee(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=No,e.frag=bo,e.features={},e}return me(r)}(rn),Do="#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){Re(r,e);var t=Ie(r);function r(){var e;Ee(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=No,e.frag=Do,e}return me(r)}(rn),Bo=zt(1,(function(){return new Jn}));var Fo=function(e){Re(n,e);var r=Ie(n);function n(){var e;Ee(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))).name="device-renderer",e}return me(n,[{key:"init",value:function(){var e;t.runtime.geometryUpdaterFactory[t.Shape.MESH]=new Et;var r=new Hn,n=new pt,i=new xo(this.context),o=new yt,a=new Ro,s=new To,u=(ge(e={},t.Shape.CIRCLE,a),ge(e,t.Shape.ELLIPSE,a),ge(e,t.Shape.POLYLINE,s),ge(e,t.Shape.PATH,s),ge(e,t.Shape.POLYGON,s),ge(e,t.Shape.RECT,s),ge(e,t.Shape.IMAGE,new Ao),ge(e,t.Shape.LINE,new Oo),ge(e,t.Shape.TEXT,new So),ge(e,t.Shape.MESH,new Co),ge(e,t.Shape.GROUP,void 0),ge(e,t.Shape.HTML,void 0),e),l=new Po(r,u,i,n),c=new si(r,n,i,l);this.addRenderingPlugin(c),this.addRenderingPlugin(new ui(r,c,o,l))}},{key:"destroy",value:function(){delete t.runtime.geometryUpdaterFactory[t.Shape.MESH]}},{key:"getRenderGraphPlugin",value:function(){return this.plugins[0]}},{key:"getDevice",value:function(){return this.getRenderGraphPlugin().getDevice()}},{key:"loadTexture",value:function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)}},{key:"toDataURL",value:function(e){return this.getRenderGraphPlugin().toDataURL(e)}}]),n}(t.AbstractRendererPlugin),wo=Object.freeze({__proto__:null,get AntialiasingMode(){return Kn},Batch:hi,get BlendFactor(){return je},get BlendMode(){return Ye},get BufferFrequencyHint(){return $e},BufferGeometry:_i,get BufferUsage(){return Qe},get ChannelWriteMask(){return nt},get ClipSpaceNearZ(){return st},get CompareMode(){return We},CopyProgram:Mo,get CullMode(){return He},DeviceProgram:rn,DynamicUniformBuffer:nn,get Endianness(){return sr},FILL_TEXTURE_MAPPING:Si,FillMesh:io,Fog:oi,get FogType(){return ni},get Format(){return ht},get FormatCompFlags(){return ct},get FormatFlags(){return ft},get FormatTypeFlags(){return lt},get FrontFaceMode(){return Xe},get GL(){return dt},get GeometryEvent(){return li},HashMap:ln,IdentityViewportCoords:gn,ImageMesh:oo,Instanced:Ii,InstancedLineMesh:Li,IsDepthReversed:Ut,get JOINT_TYPE(){return Yi},Light:ri,LineMesh:Ji,Material:vi,get MaterialEvent(){return pi},Mesh:vt,MeshMesh:go,get MipFilterMode(){return qe},OpaqueBlack:Bt,OpaqueWhite:wt,Plugin:Fo,get PrimitiveTopology(){return Ze},get QueryPoolType(){return ut},get RGAttachmentSlot(){return En},RenderCache:yn,RenderGraphPlugin:si,RenderHelper:Hn,RenderInst:kn,get RenderInstExecutionOrder(){return Un},get RenderInstFlags(){return Bn},RenderInstList:Vn,RenderInstManager:Xn,Renderable3D:Ge,get RendererLayer(){return mn},get ResourceType(){return Ve},SDFMesh:bi,get SamplerFormatKind(){return ot},ShaderMaterial:Ei,SingleSampledTexture:An,get StencilOp(){return it},TemporalTexture:ei,get TexFilterMode(){return ze},TextMesh:mo,get TextUniform(){return po},get TextureDimension(){return tt},get TextureEvent(){return et},TextureMapping:Jn,TexturePool:xo,get TextureUsage(){return rt},TransparentBlack:Lt,TransparentWhite:Ft,UNIFORM_SETTERS:qr,get Uniform(){return $i},get VertexAttributeBufferIndex(){return gi},get VertexAttributeLocation(){return Ri},get VertexBufferFrequency(){return Je},get ViewportOrigin(){return at},get WrapMode(){return Ke},align:Xt,alignNonPowerOfTwo:Ht,arrayCopy:cr,arrayEqual:lr,assert:Pt,assertExists:xt,bezierCurveTo:qi,bindingLayoutDescriptorCopy:Pr,bindingLayoutDescriptorEqual:dr,bindingLayoutSamplerDescriptorCopy:Ir,bindingsDescriptorCopy:Cr,bindingsDescriptorEquals:pr,bisectRight:jt,bufferBindingCopy:Or,colorCopy:bt,colorEqual:Nt,colorNewCopy:Mt,colorNewFromRGBA:Dt,compareDefines:mi,compareDepthValues:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ut;if((r=kt(r,n))===We.Less)return t>e;if(r===We.LessEqual)return t>=e;if(r===We.Greater)return e>t;if(r===We.GreaterEqual)return e>=t;throw Error("whoops")},copyAttachmentState:Qt,copyAttachmentStateFromSimple:tr,copyMegaState:er,defaultBindingLayoutSamplerDescriptor:ur,defaultMegaState:nr,definedProps:Ti,enumToObject:yi,fallbackUndefined:Gt,fillArray:Wt,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:wn,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:or,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 Ot(At(e))*Tt(e)},getFormatCompByteSize:Ct,getFormatCompFlags:Tt,getFormatCompFlagsComponentCount:gt,getFormatComponentCount:function(e){return Tt(e)},getFormatFlags:St,getFormatSamplerKind:It,getFormatTypeFlags:At,getFormatTypeFlagsByteSize:Ot,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 Br},getUniformSetter:function(e,t,r){var n=qr[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)},getUniforms:$r,hashCodeNumberFinish:an,hashCodeNumberUpdate:on,inputLayoutBufferDescriptorCopy:br,inputLayoutBufferDescriptorEquals:Rr,inputLayoutDescriptorCopy:Mr,inputLayoutDescriptorEquals:Tr,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:qt,makeAttachmentClearDescriptor:Yn,makeBackbufferDescSimple:$n,makeDepthKey:In,makeFormat:Rt,makeMegaState:ir,makeSortKey:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&mn.TRANSLUCENT?Mn(e):Nn(e,t)},makeSortKeyOpaque:Nn,makeSortKeyTranslucent:Mn,makeStaticDataBuffer:di,makeTextureDescriptor2D:mt,nArray:zt,nullHashFunc:sn,nullify:Vt,opaqueBlackFullClearRenderPassDescriptor:qn,opaqueWhiteFullClearRenderPassDescriptor:Zn,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(Fr);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(qt(""+(t+r),4," ")," ").concat(e)})).join("\n")},preprocessProgramObj_GLSL:tn,preprocessProgram_GLSL:en,preprocessShader_GLSL:Jr,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===st.NegativeOne?function(e){R(e,Ln,e)}(e):t===st.Zero&&function(e){R(e,Fn,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(En.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(or),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);wn(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Lo,l=t.renderCache.createProgram(u);a.setProgram(l),vo||((vo=new _i(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:Je.PerVertex,attributes:[{format:ht.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),vo.vertexCount=3,yo=t.getCache().createInputLayout(vo.inputLayoutDescriptor),Eo=t.getDevice().createInputState(yo,vo.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,r){Bo[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(Bo),a.setInputLayoutAndState(yo,Eo),a.drawOnPass(t.renderCache,e)}))}))},quadCurveTo:zi,range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:Gn,renderPipelineDescriptorCopy:xr,renderPipelineDescriptorEquals:mr,reverseDepthForClearValue:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ut;return t?1-e:e},reverseDepthForCompareMode:kt,reverseDepthForDepthOffset:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ut;return t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ut;t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ut;t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:Sr,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:Ar,segmentInstanceGeometry:Mi,setAttachmentStateSimple:ar,setBackbufferDescSimple:Qn,setBitFlagEnabled:Kt,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:Jt,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]:Cn,n=!!(e>>>31&1),i=In(t,n,r);return n?Dn(e,i):bn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?Dn(e,t):bn(e,t)},setSortKeyLayer:Pn,setSortKeyOpaqueDepth:bn,setSortKeyProgramKey:xn,setSortKeyTranslucentDepth:Dn,spliceBisectRight:Yt,standardFullClearRenderPassDescriptor:zn,updateBuffer:eo,vertexAttributeDescriptorCopy:Nr,vertexAttributeDescriptorEquals:gr});function Uo(){Uo=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),a=new C(n||[]);return i(o,"_invoke",{value:T(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function p(){}function _(){}var v={};l(v,a,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(I([])));y&&y!==t&&r.call(y,a)&&(v=y);var m=_.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function o(i,a,s,u){var l=f(e[i],e,a);if("throw"!==l.type){var c=l.arg,h=c.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){o("next",e,s,u)}),(function(e){o("throw",e,s,u)})):t.resolve(h).then((function(e){c.value=e,s(c)}),(function(e){return o("throw",e,s,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function T(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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(a,r);if(s){if(s===h)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=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[a];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:P}}function P(){return{value:void 0,done:!0}}return p.prototype=_,i(m,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:p,configurable:!0}),p.displayName=l(_,u,"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__=_,l(e,u,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(R.prototype),l(R.prototype,s,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),l(m,u,"Generator"),l(m,a,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,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(O),!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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),h}},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;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function ko(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 Go(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){ko(o,n,i,a,s,"next",e)}function s(e){ko(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Vo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Wo(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(o=void 0,o=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i.key,"string"),"symbol"===n(o)?o:o+""),i)}var o}function Xo(e,t,r){return t&&Wo(e.prototype,t),r&&Wo(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ho(e){return Ho=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ho(e)}function jo(e,t){return jo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},jo(e,t)}function Yo(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 function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Ko(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=Ho(e);if(t){var i=Ho(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return Yo(this,r)}}var zo=function(){function e(){Vo(this,e),this.context=void 0}return Xo(e,[{key:"apply",value:function(t){var r=this,n=t.renderingService,i=t.renderingContext;this.context=t;var o=i.root.ownerDocument.defaultView,a=function(e){n.hooks.pointerMove.call(e)},s=function(e){n.hooks.pointerUp.call(e)},u=function(e){n.hooks.pointerDown.call(e)},l=function(e){n.hooks.pointerOver.call(e)},c=function(e){n.hooks.pointerOut.call(e)},f=function(e){n.hooks.pointerCancel.call(e)},h=function(e){n.hooks.pointerWheel.call(e)},d=function(e){globalThis.document.addEventListener("pointermove",a,!0),e.addEventListener("pointerdown",u,!0),e.addEventListener("pointerleave",c,!0),e.addEventListener("pointerover",l,!0),globalThis.addEventListener("pointerup",s,!0)},p=function(e){e.addEventListener("touchstart",u,!0),e.addEventListener("touchend",s,!0),e.addEventListener("touchmove",a,!0),e.addEventListener("touchcancel",f,!0)},_=function(e){globalThis.document.addEventListener("mousemove",a,!0),e.addEventListener("mousedown",u,!0),e.addEventListener("mouseout",c,!0),e.addEventListener("mouseover",l,!0),globalThis.addEventListener("mouseup",s,!0)};n.hooks.init.tapPromise(e.tag,Go(Uo().mark((function e(){var t;return Uo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.context.contextService.getDomElement(),globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):o.supportsPointerEvents&&(t.style.touchAction="none"),o.supportsPointerEvents?d(t):_(t),o.supportsTouchEvents&&p(t),t.addEventListener("wheel",h,{passive:!0,capture:!0});case 5:case"end":return e.stop()}}),e)})))),n.hooks.destroy.tap(e.tag,(function(){var e=r.context.contextService.getDomElement();globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):o.supportsPointerEvents&&(e.style.touchAction=""),o.supportsPointerEvents?function(e){globalThis.document.removeEventListener("pointermove",a,!0),e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointerleave",c,!0),e.removeEventListener("pointerover",l,!0),globalThis.removeEventListener("pointerup",s,!0)}(e):function(e){globalThis.document.removeEventListener("mousemove",a,!0),e.removeEventListener("mousedown",u,!0),e.removeEventListener("mouseout",c,!0),e.removeEventListener("mouseover",l,!0),globalThis.removeEventListener("mouseup",s,!0)}(e),o.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",u,!0),e.removeEventListener("touchend",s,!0),e.removeEventListener("touchmove",a,!0),e.removeEventListener("touchcancel",f,!0)}(e),e.removeEventListener("wheel",h,!0)}))}}]),e}();zo.tag="DOMInteraction";var qo=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&&jo(e,t)}(r,e);var t=Ko(r);function r(){var e;Vo(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))).name="dom-interaction",e}return Xo(r,[{key:"init",value:function(){this.addRenderingPlugin(new zo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}]),r}(t.AbstractRendererPlugin),Zo=Object.freeze({__proto__:null,Plugin:qo});function Qo(){Qo=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),a=new C(n||[]);return i(o,"_invoke",{value:T(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function p(){}function _(){}var v={};l(v,a,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(I([])));y&&y!==t&&r.call(y,a)&&(v=y);var m=_.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function o(i,a,s,u){var l=f(e[i],e,a);if("throw"!==l.type){var c=l.arg,h=c.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){o("next",e,s,u)}),(function(e){o("throw",e,s,u)})):t.resolve(h).then((function(e){c.value=e,s(c)}),(function(e){return o("throw",e,s,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function T(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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(a,r);if(s){if(s===h)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=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[a];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:P}}function P(){return{value:void 0,done:!0}}return p.prototype=_,i(m,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:p,configurable:!0}),p.displayName=l(_,u,"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__=_,l(e,u,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(R.prototype),l(R.prototype,s,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),l(m,u,"Generator"),l(m,a,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,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(O),!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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),h}},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;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function $o(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 Jo(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){$o(o,n,i,a,s,"next",e)}function s(e){$o(o,n,i,a,s,"throw",e)}a(void 0)}))}}function ea(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ta(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(o=void 0,o=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i.key,"string"),"symbol"===n(o)?o:o+""),i)}var o}function ra(e,t,r){return t&&ta(e.prototype,t),r&&ta(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function na(e){return na=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},na(e)}function ia(e,t){return ia=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ia(e,t)}function oa(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 function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function aa(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=na(e);if(t){var i=na(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return oa(this,r)}}var sa=function(){function e(){ea(this,e),this.context=void 0,this.$camera=void 0}return ra(e,[{key:"joinTransformMatrix",value:function(e){return"matrix(".concat([e[0],e[1],e[4],e[5],e[12],e[13]].join(","),")")}},{key:"apply",value:function(r){var n=this,i=r.camera,o=r.renderingContext,a=r.renderingService,s=r.displayObjectPool;this.context=r;var u=o.root.ownerDocument.defaultView,l=function(e,t){t.style.transform=n.joinTransformMatrix(e.getWorldTransform())},c=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){n.$camera||(n.$camera=n.createCamera(i));var o=n.getOrCreateEl(r);n.$camera.appendChild(o);var a=r.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(e){o.style[e]=a[e]})),Object.keys(r.attributes).forEach((function(e){n.updateAttribute(e,r)})),l(r,o)}},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&n.$camera){var i=n.getOrCreateEl(r);i&&i.remove()}},h=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&n.updateAttribute(e.attrName,r)},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var i=n.getOrCreateEl(r);l(r,i)}},p=function(){if(n.$camera){var e=n.context.config,t=e.height;n.$camera.style.width="".concat(e.width||0,"px"),n.$camera.style.height="".concat(t||0,"px")}};a.hooks.init.tapPromise(e.tag,Jo(Qo().mark((function e(){return Qo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s.getHTMLs().length&&(n.$camera=n.createCamera(i)),u.addEventListener(t.CanvasEvent.RESIZE,p),u.addEventListener(t.ElementEvent.MOUNTED,c),u.addEventListener(t.ElementEvent.UNMOUNTED,f),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,d);case 6:case"end":return e.stop()}}),e)})))),a.hooks.endFrame.tap(e.tag,(function(){n.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(n.$camera.style.transform=n.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(e.tag,(function(){n.$camera&&n.$camera.remove(),u.removeEventListener(t.CanvasEvent.RESIZE,p),u.removeEventListener(t.ElementEvent.MOUNTED,c),u.removeEventListener(t.ElementEvent.UNMOUNTED,f),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,d)}))}},{key:"getId",value:function(e){return e.id||"g-html-"+e.entity}},{key:"createCamera",value:function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",u=a.querySelector("#"+s);if(!u){var l=(r||document).createElement("div");u=l,l.id=s,l.style.position="absolute",l.style.left="".concat(o.offsetLeft||0,"px"),l.style.top="".concat(o.offsetTop||0,"px"),l.style.transformOrigin="left top",l.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),l.style.overflow="hidden",l.style.pointerEvents="none",l.style.width="".concat(n||0,"px"),l.style.height="".concat(i||0,"px"),a.appendChild(l)}return u}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,r=this.getId(e),n=this.$camera.querySelector("#"+r);return n||(n=(t||document).createElement("div"),e.parsedStyle.$el=n,n.id=r,e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(e.getWorldTransform())),n}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;N(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].value," ").concat(o[1].value);break;case"width":var a=r.computedStyleMap().get("width");n.style.width=""+a;break;case"height":var s=r.computedStyleMap().get("height");n.style.height=""+s;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var u=r.parsedStyle.fill,l="";u instanceof t.CSSRGB?l=u.isNone?"transparent":r.getAttribute("fill"):Array.isArray(u)?l=r.getAttribute("fill"):t.isPattern(u),n.style.background=l;break;case"stroke":var c=r.parsedStyle.stroke,f="";c instanceof t.CSSRGB?f=c.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(c)?f=r.getAttribute("stroke"):t.isPattern(c),n.style["border-color"]=f,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter}}}]),e}();sa.tag="HTMLRendering";var ua=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&&ia(e,t)}(r,e);var t=aa(r);function r(){var e;ea(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))).name="html-renderer",e}return ra(r,[{key:"init",value:function(){this.addRenderingPlugin(new sa)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}]),r}(t.AbstractRendererPlugin),la=Object.freeze({__proto__:null,Plugin:ua});function ca(){ca=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),a=new C(n||[]);return i(o,"_invoke",{value:T(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function p(){}function _(){}var v={};l(v,a,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(I([])));y&&y!==t&&r.call(y,a)&&(v=y);var m=_.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function o(i,a,s,u){var l=f(e[i],e,a);if("throw"!==l.type){var c=l.arg,h=c.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){o("next",e,s,u)}),(function(e){o("throw",e,s,u)})):t.resolve(h).then((function(e){c.value=e,s(c)}),(function(e){return o("throw",e,s,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function T(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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(a,r);if(s){if(s===h)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=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[a];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:P}}function P(){return{value:void 0,done:!0}}return p.prototype=_,i(m,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:p,configurable:!0}),p.displayName=l(_,u,"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__=_,l(e,u,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(R.prototype),l(R.prototype,s,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),l(m,u,"Generator"),l(m,a,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,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(O),!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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),h}},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;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function fa(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 ha(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){fa(o,n,i,a,s,"next",e)}function s(e){fa(o,n,i,a,s,"throw",e)}a(void 0)}))}}function da(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pa(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(o=void 0,o=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i.key,"string"),"symbol"===n(o)?o:o+""),i)}var o}function _a(e,t,r){return t&&pa(e.prototype,t),r&&pa(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function va(e){return va=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},va(e)}function Ea(e,t){return Ea=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ea(e,t)}function ya(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 function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function ma(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=va(e);if(t){var i=va(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return ya(this,r)}}var ga="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Ra=function(){function e(t){da(this,e),this.canvasConfig=void 0,this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=t}return _a(e,[{key:"getImageSync",value:function(e,t){return this.imageCache[e]?t&&t():this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]}},{key:"getOrCreateImage",value:function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e,r.imageCache[e]=a)}))}},{key:"getOrCreatePatternSync",value:function(e,r,n,i,o){var a=this.generatePatternKey(e);if(a&&this.patternCache[a])return this.patternCache[a];var s,u=e.image,l=e.repetition,c=e.transform,f=!1;N(u)?s=this.getImageSync(u,o):n?(s=n,f=!0):s=u;var h,d=s&&r.createPattern(s,l);d&&(h=c?t.parsedTransformToMat4(t.parseTransform(c)):function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(function(){var e=new ga(16);return ga!=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}()),f&&function(e,t,r){var n=r[0],i=r[1],o=r[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(h,h,[1/i,1/i,1]),d.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12],f:h[13]}));return a&&d&&(this.patternCache[a]=d),d}},{key:"getOrCreateGradient",value:function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,s=e.height,u=e.cx,l=e.cy,c=e.size;if(this.gradientCache[n])return this.gradientCache[n];var f=null;if(i===t.GradientType.LinearGradient){var h=t.computeLinearGradient(a,s,e.angle);f=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(i===t.GradientType.RadialGradient){var d=t.computeRadialGradient(a,s,u,l,c),p=d.x,_=d.y;f=r.createRadialGradient(p,_,0,p,_,d.r)}return f&&(o.forEach((function(e){var r,n=e.offset;n.unit===t.UnitType.kPercentage&&(null===(r=f)||void 0===r||r.addColorStop(n.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]}},{key:"generateGradientKey",value:function(e){var t=e.width,r=e.height,n=e.steps,i=e.angle,o=e.cx,a=e.cy,s=e.size;return"gradient-".concat(e.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(t,"-").concat(r,"-").concat(n.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))}},{key:"generatePatternKey",value:function(e){var r=e.image,n=e.repetition;return N(r)?"pattern-".concat(r,"-").concat(n):r instanceof t.Rect?"pattern-".concat(r.entity,"-").concat(n):void 0}}]),e}(),Ta=function(){function e(){da(this,e)}return _a(e,[{key:"apply",value:function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var r=e.target;if(r.nodeName===t.Shape.IMAGE){var o=r.attributes.img;N(o)&&i.getImageSync(o,(function(){r.renderable.dirty=!0,n.dirtify()}))}},s=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"img"===e.attrName&&N(o)&&i.getOrCreateImage(o).then((function(){r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tapPromise(e.tag,ha(ca().mark((function e(){return ca().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.addEventListener(t.ElementEvent.MOUNTED,a),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,s);case 2:case"end":return e.stop()}}),e)})))),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,a),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,s)}))}}]),e}();Ta.tag="LoadImage";var Aa,Sa=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&&Ea(e,t)}(r,e);var t=ma(r);function r(){var e;da(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))).name="image-loader",e}return _a(r,[{key:"init",value:function(){this.context.imagePool=new Ra(this.context.config),this.addRenderingPlugin(new Ta)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}]),r}(t.AbstractRendererPlugin);function Oa(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 Ca(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Oa(Object(r),!0).forEach((function(t){Da(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Oa(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ia(){Ia=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),a=new C(n||[]);return i(o,"_invoke",{value:T(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function p(){}function _(){}var v={};l(v,a,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(I([])));y&&y!==t&&r.call(y,a)&&(v=y);var m=_.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function o(i,a,s,u){var l=f(e[i],e,a);if("throw"!==l.type){var c=l.arg,h=c.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){o("next",e,s,u)}),(function(e){o("throw",e,s,u)})):t.resolve(h).then((function(e){c.value=e,s(c)}),(function(e){return o("throw",e,s,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function T(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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(a,r);if(s){if(s===h)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=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[a];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:P}}function P(){return{value:void 0,done:!0}}return p.prototype=_,i(m,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:p,configurable:!0}),p.displayName=l(_,u,"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__=_,l(e,u,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(R.prototype),l(R.prototype,s,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),l(m,u,"Generator"),l(m,a,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,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(O),!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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),h}},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;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function Pa(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 xa(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Pa(o,n,i,a,s,"next",e)}function s(e){Pa(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Na(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ba(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,Wa(n.key),n)}}function Ma(e,t,r){return t&&ba(e.prototype,t),r&&ba(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Da(e,t,r){return(t=Wa(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function La(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&&Fa(e,t)}function Ba(e){return Ba=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ba(e)}function Fa(e,t){return Fa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fa(e,t)}function wa(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ua(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 wa(e)}function ka(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=Ba(e);if(t){var i=Ba(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return Ua(this,r)}}function Ga(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Ba(e)););return e}function Va(){return Va="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=Ga(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},Va.apply(this,arguments)}function Wa(e){var t=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===n(t)?t:t+""}var Xa=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Xa.decode();var Ha=null;function ja(){return null!==Ha&&Ha.buffer===Aa.memory.buffer||(Ha=new Uint8Array(Aa.memory.buffer)),Ha}function Ya(e,t){return Xa.decode(ja().subarray(e,e+t))}var Ka=Array(32).fill(void 0);Ka.push(void 0,null,!0,!1);var za=Ka.length;function qa(e){za===Ka.length&&Ka.push(Ka.length+1);var t=za;return za=Ka[t],Ka[t]=e,t}function Za(e){return Ka[e]}function Qa(e){var t=Za(e);return function(e){36>e||(Ka[e]=za,za=e)}(e),t}var $a=0,Ja=new TextEncoder("utf-8"),es="function"==typeof Ja.encodeInto?function(e,t){return Ja.encodeInto(e,t)}:function(e,t){var r=Ja.encode(e);return t.set(r),{read:e.length,written:r.length}};function ts(e,t,r){if(void 0===r){var n=Ja.encode(e),i=t(n.length);return ja().subarray(i,i+n.length).set(n),$a=n.length,i}for(var o=e.length,a=t(o),s=ja(),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=ja().subarray(a+u,a+o);u+=es(e,c).written}return $a=u,a}var rs,ns,is=null;function os(){return null!==is&&is.buffer===Aa.memory.buffer||(is=new Int32Array(Aa.memory.buffer)),is}function as(e,t,r){try{var n=Aa.__wbindgen_add_to_stack_pointer(-16),i=ts(e,Aa.__wbindgen_malloc,Aa.__wbindgen_realloc),o=$a,a=ts(t,Aa.__wbindgen_malloc,Aa.__wbindgen_realloc);Aa.glsl_compile(n,i,o,a,$a,r);var s=os()[n/4+0],u=os()[n/4+1];return Ya(s,u)}finally{Aa.__wbindgen_add_to_stack_pointer(16),Aa.__wbindgen_free(s,u)}}function ss(e,t){return us.apply(this,arguments)}function us(){return(us=xa(Ia().mark((function e(t,r){var n,i;return Ia().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 ls(e){return cs.apply(this,arguments)}function cs(){return(cs=xa(Ia().mark((function e(t){var r,n;return Ia().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r={}).wbg={},r.wbg.__wbindgen_string_new=function(e,t){return qa(Ya(e,t))},r.wbg.__wbindgen_object_drop_ref=function(e){Qa(e)},r.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(Za(e))},r.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(Za(e),Za(t))},r.wbg.__wbindgen_throw=function(e,t){throw Error(Ya(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t)),e.t0=ss,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 Aa=(n=e.sent).instance.exports,ls.__wbindgen_wasm_module=n.module,e.abrupt("return",Aa);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fs(e){if(e===ht.U8_RGBA_RT)return"bgra8unorm";if(e===ht.U8_RGBA_NORM)return"rgba8unorm";if(e===ht.U8_RG_NORM)return"rg8unorm";if(e===ht.U32_R)return"r32uint";if(e===ht.D24)return"depth24plus";if(e===ht.D24_S8)return"depth24plus-stencil8";if(e===ht.D32F)return"depth32float";if(e===ht.D32F_S8)return"depth32float-stencil8";if(e===ht.BC1)return"bc1-rgba-unorm";if(e===ht.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===ht.BC2)return"bc2-rgba-unorm";if(e===ht.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===ht.BC3)return"bc3-rgba-unorm";if(e===ht.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===ht.BC4_SNORM)return"bc4-r-snorm";if(e===ht.BC4_UNORM)return"bc4-r-unorm";if(e===ht.BC5_SNORM)return"bc5-rg-snorm";if(e===ht.BC5_UNORM)return"bc5-rg-unorm";throw Error("whoops")}function hs(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 ds(e){if(e===ze.Bilinear)return"linear";if(e===ze.Point)return"nearest";throw Error("whoops")}function ps(e){if(e===qe.Linear)return"linear";if(e===qe.Nearest)return"nearest";if(e===qe.NoMip)return"nearest";throw Error("whoops")}function _s(e){if(e===ot.Float)return"float";if(e===ot.Depth)return"depth";throw Error("whoops")}function vs(e){if(e===tt.n2D)return"2d";if(e===tt.n2DArray)return"2d-array";if(e===tt.n3D)return"3d";if(e===tt.Cube)return"cube";throw Error("whoops")}function Es(e){return e.gpuBuffer}function ys(e){if(e===ut.OcclusionConservative)return"occlusion";throw Error("whoops")}function ms(e){switch(e){case Ze.Triangles:return"triangle-list";case Ze.Points:return"point-list";case Ze.TriangleStrip:return"triangle-strip";case Ze.Lines:return"line-list";case Ze.LineStrip:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function gs(e){if(e===He.None)return"none";if(e===He.Front)return"front";if(e===He.Back)return"back";throw Error("whoops")}function Rs(e){if(e===Xe.CCW)return"ccw";if(e===Xe.CW)return"cw";throw Error("whoops")}function Ts(e){if(e===je.Zero)return"zero";if(e===je.One)return"one";if(e===je.Src)return"src";if(e===je.OneMinusSrc)return"one-minus-src";if(e===je.Dst)return"dst";if(e===je.OneMinusDst)return"one-minus-dst";if(e===je.SrcAlpha)return"src-alpha";if(e===je.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===je.DstAlpha)return"dst-alpha";if(e===je.OneMinusDstAlpha)return"one-minus-dst-alpha";throw Error("whoops")}function As(e){if(e===Ye.Add)return"add";if(e===Ye.Subtract)return"subtract";if(e===Ye.ReverseSubtract)return"reverse-subtract";throw Error("whoops")}function Ss(e){return{operation:As(e.blendMode),srcFactor:Ts(e.blendSrcFactor),dstFactor:Ts(e.blendDstFactor)}}function Os(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:fs(t),blend:{color:Ss(e.rgbBlendState),alpha:Ss(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[r])}))}function Cs(e){if(e===We.Never)return"never";if(e===We.Less)return"less";if(e===We.Equal)return"equal";if(e===We.LessEqual)return"less-equal";if(e===We.Greater)return"greater";if(e===We.NotEqual)return"not-equal";if(e===We.GreaterEqual)return"greater-equal";if(e===We.Always)return"always";throw Error("whoops")}function Is(e){if(e===Je.PerVertex)return"vertex";if(e===Je.PerInstance)return"instance";throw Error("whoops")}function Ps(e){if(e===ht.U8_R)return"uint8x2";if(e===ht.U8_RG)return"uint8x2";if(e===ht.U8_RGB)return"uint8x4";if(e===ht.U8_RGBA)return"uint8x4";if(e===ht.U8_RGBA_NORM)return"unorm8x4";if(e===ht.S8_RGB_NORM)return"snorm8x4";if(e===ht.S8_RGBA_NORM)return"snorm8x4";if(e===ht.S16_RG)return"uint16x2";if(e===ht.F32_R)return"float32";if(e===ht.F32_RG)return"float32x2";if(e===ht.F32_RGB)return"float32x3";if(e===ht.F32_RGBA)return"float32x4";throw Error("whoops")}function xs(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3?arguments[3]:void 0;switch(e){case ht.S8_R:case ht.S8_R_NORM:case ht.S8_RG_NORM:case ht.S8_RGB_NORM:case ht.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case ht.U8_R:case ht.U8_R_NORM:case ht.U8_RG:case ht.U8_RG_NORM:case ht.U8_RGB:case ht.U8_RGB_NORM:case ht.U8_RGB_SRGB:case ht.U8_RGBA:case ht.U8_RGBA_NORM:case ht.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case ht.S16_R:case ht.S16_RG:case ht.S16_RG_NORM:case ht.S16_RGB_NORM:case ht.S16_RGBA:case ht.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 ht.U16_R:case ht.U16_RGB:case ht.U16_RGBA_5551:case ht.U16_RGBA_NORM:case ht.U16_RG_NORM:case ht.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 ht.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 ht.U32_R:case ht.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 ht.F32_R:case ht.F32_RG:case ht.F32_RGB:case ht.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"}(rs||(rs={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(ns||(ns={}));var Ns=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device;return Na(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 Ma(r,[{key:"destroy",value:function(){}}]),r}(D),bs=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.Bindings,n.bindingLayout=void 0,n.gpuBindGroup=void 0,n.bindGroupLayout=void 0;var s=a.pipeline,u=a.bindingLayout;Pt(!!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];Pt(d.wordCount>0);var p={buffer:Es(d.buffer),offset:0,size:d.wordCount<<2};c[0].push({binding:f++,resource:p})}for(var _=0;u.numUniformBuffers>_;_++){var v=a.uniformBufferBindings[_];Pt(v.wordCount>0);var E={buffer:Es(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 m=void 0!==u.samplerEntries?u.samplerEntries[y]:ur,g=a.samplerBindings[y],R=null!==g.texture?g.texture:n.device.getFallbackTexture(m);Pt(m.dimension===R.dimension),Pt(m.formatKind===It(R.pixelFormat)),c[1].push({binding:f++,resource:R.gpuTextureView});var T=(null!==g.sampler?g.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 Ma(r)}(Ns);function Ms(e){return void 0!==e.byteLength}var Ds=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.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=Ms(u)?u.byteLength+3&-4:u+3&-4;n.usage=s,n.usage&Qe.MAP_READ&&(n.usage=Qe.MAP_READ|Qe.COPY_DST);var c=Ms(u);if(n.size=Ms(u)?u.byteLength:u,n.view=Ms(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 Ma(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(){Va(Ba(r.prototype),"destroy",this).call(this),this.gpuBuffer.destroy()}}]),r}(Ns),Ls=function(){function e(){Na(this,e),this.commandEncoder=null,this.descriptor=void 0,this.gpuComputePassDescriptor=void 0,this.gpuComputePassEncoder=null}return Ma(e,[{key:"dispatch",value:function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)}},{key:"finish",value:function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()}},{key:"beginComputePass",value:function(e){Pt(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)}},{key:"setPipeline",value:function(e){var t=xt(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}(),Bs=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.ComputePipeline,n.descriptor=void 0,n.gpuComputePipeline=null,n.descriptor=a;var s=a.program.computeStage;if(null===s)return Ua(n);var u={compute:Ca({},s),layout:"auto"};return n.gpuComputePipeline=n.device.device.createComputePipeline(u),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return Ma(r,[{key:"getBindGroupLayout",value:function(e){return this.gpuComputePipeline.getBindGroupLayout(e)}}]),r}(Ns),Fs=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.InputLayout,n.buffers=void 0,n.indexFormat=void 0;for(var s=[],u=0;a.vertexBufferDescriptors.length>u;u++){var l=a.vertexBufferDescriptors[u];if(!I(l)){var c=l.byteStride,f=Is(l.frequency);s[u]={arrayStride:c,stepMode:f,attributes:[]}}}for(var h=0;a.vertexAttributeDescriptors.length>h;h++){var d=a.vertexAttributeDescriptors[h],p=xt(s[d.bufferIndex]),_={shaderLocation:d.location,format:Ps(d.format),offset:d.bufferByteOffset};p.attributes.push(_)}return n.indexFormat=function(e){if(null!==e){if(e===ht.U16_R)return"uint16";if(e===ht.U32_R)return"uint32";throw Error("whoops")}}(a.indexBufferFormat),n.buffers=s,n}return Ma(r)}(Ns),ws=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.inputLayout,s=e.vertexBuffers,u=e.indexBuffer;return Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.InputState,n.inputLayout=void 0,n.vertexBuffers=void 0,n.indexBuffer=void 0,n.inputLayout=a,n.vertexBuffers=s,n.indexBuffer=u,n}return Ma(r)}(Ns),Us=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;return Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.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 Ma(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}(Ns),ks=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.QueryPool,n.querySet=void 0;var s=a.elemCount;return n.querySet=n.device.device.createQuerySet({type:ys(a.type),count:s}),n}return Ma(r,[{key:"queryResultOcclusion",value:function(e){return!0}}]),r}(Ns),Gs=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device;return Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.Readback,n}return Ma(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:Qe.STORAGE|Qe.MAP_READ|Qe.COPY_DST,hint:$e.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]:ht.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||Ct(o),f=s;if(!(s.usage&Qe.MAP_READ&&s.usage&Qe.COPY_DST)){var h=this.device.device.createCommandEncoder();f=this.device.createBuffer({usage:Qe.STORAGE|Qe.MAP_READ|Qe.COPY_DST,hint:$e.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(ns.READ,r,u).then((function(){var n=f.gpuBuffer.getMappedRange(r,u),i=l;if(a)i=null===i?xs(o,u,!0,n):xs(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":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}(Ns),Vs=function(){function e(){Na(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 Ma(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){Pt(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=xt(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)}},{key:"setInputState",value:function(e){if(null!==e){var t=e;if(null!==t.indexBuffer){var r=t.inputLayout,n=t.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Es(n.buffer),xt(r.indexFormat),n.byteOffset)}for(var i=0;t.vertexBuffers.length>i;i++){var o=t.vertexBuffers[i];I(o)||this.gpuRenderPassEncoder.setVertexBuffer(i,Es(o.buffer),o.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){Pt(1===t.sampleCount);var r={texture:t.gpuTexture},n={texture:e.gpuTexture};Pt(t.width===e.width),Pt(t.height===e.height),Pt(!!(t.usage&rs.COPY_SRC)),Pt(!!(e.usage&rs.COPY_DST)),this.commandEncoder.copyTextureToTexture(r,n,[e.width,e.height,1])}}]),e}(),Ws=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;return Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.RenderPipeline,n.descriptor=void 0,n.isCreating=!1,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=a,n.device._createRenderPipeline(wa(n),!1),n}return Ma(r,[{key:"getBindGroupLayout",value:function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)}}]),r}(Ns),Xs=function(e){La(r,e);var t=ka(r);function r(e){var n,i,o,a=e.id,s=e.device,u=e.descriptor;Na(this,r),(o=t.call(this,{id:a,device:s})).type=Ve.Sampler,o.gpuSampler=void 0;var l=u.minLOD,c=u.mipFilter===qe.NoMip?u.minLOD:u.maxLOD,f=null!==(n=u.maxAnisotropy)&&void 0!==n?n:1;return f>1&&Pt(u.minFilter===ze.Bilinear&&u.magFilter===ze.Bilinear&&u.mipFilter===qe.Linear),o.gpuSampler=o.device.device.createSampler({addressModeU:hs(u.wrapS),addressModeV:hs(u.wrapT),addressModeW:hs(null!==(i=u.wrapQ)&&void 0!==i?i:u.wrapS),lodMinClamp:l,lodMaxClamp:c,minFilter:ds(u.minFilter),magFilter:ds(u.magFilter),mipmapFilter:ps(u.mipFilter),maxAnisotropy:f}),o}return Ma(r)}(Ns),Hs=function(e){La(r,e);var t=ka(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor,s=e.skipCreate;return Na(this,r),(n=t.call(this,{id:i,device:o})).type=Ve.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},wa(n),s),n}return Ma(r,[{key:"setImageData",value:function(e,t){}},{key:"destroy",value:function(){this.gpuTexture.destroy()}}]),r}(Ns),js=function(){function e(t,r,n,i,o){Na(this,e),this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=rs.RENDER_ATTACHMENT|rs.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new ln(dr,sn),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=at.UpperLeft,this.clipSpaceNearZ=st.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(tt.n2D,ot.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(tt.n2D,ot.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(tt.n2DArray,ot.Float),this.fallbackTexture3D=this.createFallbackTexture(tt.n3D,ot.Float),this.fallbackTextureCube=this.createFallbackTexture(tt.Cube,ot.Float),this.fallbackSampler=this.createSampler({wrapS:Ke.Clamp,wrapT:Ke.Clamp,minFilter:ze.Point,magFilter:ze.Point,mipFilter:qe.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}return Ma(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 Hs({id:0,device:this,descriptor:{pixelFormat:ht.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:tt.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 Ds({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createTexture",value:function(e){return new Hs({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createSampler",value:function(e){return new Xs({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createRenderTarget",value:function(e){var t=new Hs({id:this.getNextUniqueId(),device:this,descriptor:Ca(Ca({},e),{},{dimension:tt.n2D,numLevels:1,depth:1,usage:rt.RenderTarget})});return t.depthOrArrayLayers=1,t.type=Ve.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;Pt(!!(l&rs.RENDER_ATTACHMENT));var c=new Hs({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:tt.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 Us({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=fs(e.pixelFormat),a=function(e){if(e===tt.n2D)return"2d";if(e===tt.Cube)return"3d";if(e===tt.n2DArray)return"3d";if(e===tt.n3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&rt.Sampled&&(t|=rs.TEXTURE_BINDING|rs.COPY_DST),e&rt.RenderTarget&&(t|=rs.RENDER_ATTACHMENT|rs.TEXTURE_BINDING|rs.COPY_SRC|rs.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===tt.n2D)return e.formatKind===ot.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===tt.n2DArray)return this.fallbackTexture2DArray;if(t===tt.n3D)return this.fallbackTexture3D;if(t===tt.Cube)return this.fallbackTextureCube;throw Error("whoops")}},{key:"createFallbackTexture",value:function(e,t){return this.createTexture({dimension:e,pixelFormat:t===ot.Float?ht.U8_RGBA_NORM:ht.D24,usage:rt.Sampled,width:1,height:1,depth:e===tt.Cube?6:1,numLevels:1})}},{key:"createBindings",value:function(e){return new bs({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createInputLayout",value:function(e){return new Fs({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createInputState",value:function(e,t,r){return new ws({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})}},{key:"createComputePipeline",value:function(e){return new Bs({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createRenderPipeline",value:function(e){return new Ws({id:this.getNextUniqueId(),device:this,descriptor:Ca({},e)})}},{key:"createQueryPool",value:function(e,t){return new ks({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]:ur,{sampleType:_s(t.formatKind),viewDimension:vs(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:ms(t.topology),cullMode:gs(o.cullMode),frontFace:Rs(o.frontFace)}),u=Os(t.colorAttachmentFormats,t.megaStateDescriptor),l=function(e,t){if(null!==e)return{format:fs(e),depthWriteEnabled:t.depthWrite,depthCompare:Cs(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:Ca(Ca({},n),{},{buffers:c}),primitive:s,depthStencil:l,multisample:{count:f},fragment:Ca(Ca({},i),{},{targets:u})};e.gpuRenderPipeline=this.device.createRenderPipeline(h),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}}},{key:"createReadback",value:function(){return new Gs({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 Vs),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 Ls),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 Vs?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]};Pt(!!(u.usage&rs.COPY_SRC)),Pt(!!(s.usage&rs.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(At(e)){case lt.BC1:case lt.BC2:case lt.BC3:case lt.BC4_SNORM:case lt.BC4_UNORM:case lt.BC5_SNORM:case lt.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(At(e)){case lt.BC1:case lt.BC2:case lt.BC3:case lt.BC4_SNORM:case lt.BC4_UNORM:case lt.BC5_SNORM:case lt.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}switch(e){case ht.U16_RGBA_NORM:case ht.F32_RGBA:return!1}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===Ve.Buffer)e.gpuBuffer.label=t;else if(e.type===Ve.Texture){var r=e;r.gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===Ve.RenderTarget){var n=e;n.gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===Ve.Sampler){e.gpuSampler.label=t}else if(e.type===Ve.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}(),Ys=function(){function e(t){Na(this,e),this.pluginOptions=void 0,this.pluginOptions=t}var t;return Ma(e,[{key:"createSwapChain",value:(t=xa(Ia().mark((function e(t){var r,n,i,o;return Ia().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==globalThis.navigator.gpu){e.next=2;break}return e.abrupt("return",null);case 2:return r=null,e.prev=3,e.next=6,globalThis.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=["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,ls("/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 js(r,i,t,o,as));case 32:case"end":return e.stop()}}),e,null,[[3,9],[24,29]])}))),function(e){return t.apply(this,arguments)})}]),e}(),Ks=function(e){La(r,e);var t=ka(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Na(this,r),(e=t.call(this)).options=void 0,e.name="webgpu-device",e.options=n,e}return Ma(r,[{key:"init",value:function(){this.context.deviceContribution=new Ys(Ca({},this.options))}},{key:"destroy",value:function(){delete this.context.deviceContribution}}]),r}(t.AbstractRendererPlugin),zs=Object.freeze({__proto__:null,Plugin:Ks}),qs=function(){function e(t){a(this,e),this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.canvasConfig=void 0,this.deviceRendererPlugin=void 0,this.canvasConfig=t.config,this.deviceRendererPlugin=t.deviceRendererPlugin}var n;return u(e,[{key:"init",value:function(){var e=o(r().mark((function e(){var t,n,i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=(t=this.canvasConfig).container,(i=t.canvas)?(this.$canvas=i,n&&i.parentElement!==n&&n.appendChild(i),this.$container=i.parentElement,this.canvasConfig.container=this.$container):n&&(this.$container=N(n)?document.getElementById(n):n,this.$container&&(o=document.createElement("canvas"),this.$container.appendChild(o),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=o)),this.resize(this.canvasConfig.width,this.canvasConfig.height);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getContext",value:function(){return this.deviceRendererPlugin.getDevice().canvasContext}},{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){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}}},{key:"getDPR",value:function(){return this.dpr}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(n=o(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","");case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]),e}(),Zs=function(e){l(r,e);var t=d(r);function r(e){var n;return a(this,r),(n=t.call(this)).rendererPlugin=void 0,n.name="webgpu-context-register",n.rendererPlugin=e,n}return u(r,[{key:"init",value:function(){this.context.ContextService=qs,this.context.deviceRendererPlugin=this.rendererPlugin}},{key:"destroy",value:function(){delete this.context.ContextService}}]),r}(t.AbstractRendererPlugin),Qs=function(e){l(r,e);var t=d(r);function r(e){var n;a(this,r),n=t.call(this,e);var i=new Fo;return n.registerPlugin(new Zs(i)),n.registerPlugin(new Sa),n.registerPlugin(new Ks),n.registerPlugin(i),n.registerPlugin(new qo),n.registerPlugin(new ua),n}return u(r)}(t.AbstractRenderer);e.DeviceRenderer=wo,e.DomInteraction=Zo,e.HTMLRenderer=la,e.Renderer=Qs,e.WebGPUDevice=zs,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,(function(e,t){"use strict";function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),a=new O(n||[]);return i(o,"_invoke",{value:T(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var h={};function d(){}function p(){}function _(){}var E={};c(E,a,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(I([])));m&&m!==t&&n.call(m,a)&&(E=m);var g=_.prototype=d.prototype=Object.create(E);function R(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function r(i,o,a,s){var u=f(e[i],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function T(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 N()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(a,r);if(s){if(s===h)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=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function A(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,A(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:N}}function N(){return{value:void 0,done:!0}}return p.prototype=_,i(g,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:p,configurable:!0}),p.displayName=c(_,u,"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__=_,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},R(y.prototype),c(y.prototype,s,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new y(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,O.prototype={constructor:O,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(C),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(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 r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.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)&&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,h):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),h},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),C(r),h}},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;C(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function n(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 i(e){return function(){var t=this,r=arguments;return new Promise((function(i,o){var a=e.apply(t,r);function s(e){n(a,i,o,s,u,"next",e)}function u(e){n(a,i,o,s,u,"throw",e)}s(void 0)}))}}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,a(e,t)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function s(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}s((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=Object.create((t&&t.prototype instanceof E?t:E).prototype),a=new x(n||[]);return i(o,"_invoke",{value:C(e,r,a)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var h="suspendedStart",d="executing",p="completed",_={};function E(){}function v(){}function m(){}var g={};c(g,a,(function(){return this}));var R=Object.getPrototypeOf,y=R&&R(R(P([])));y&&y!==r&&n.call(y,a)&&(g=y);var T=m.prototype=E.prototype=Object.create(g);function A(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,o,a,s){var u=f(e[i],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function C(e,t,r){var n=h;return function(i,o){if(n===d)throw Error("Generator is already running");if(n===p){if("throw"===i)throw o;return M()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=O(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===h)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=f(e,t,r);if("normal"===u.type){if(n=r.done?p:"suspendedYield",u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}function O(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,O(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),_;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,_;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,_):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}function I(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 N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function P(e){if(e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}return{next:M}}function M(){return{value:t,done:!0}}return v.prototype=m,i(T,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:v,configurable:!0}),v.displayName=c(m,u,"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,m):(e.__proto__=m,c(e,u,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},A(S.prototype),c(S.prototype,s,(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),c(T,u,"Generator"),c(T,a,(function(){return this})),c(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=P,x.prototype={constructor:x,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(N),!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"),c=n.call(a,"finallyLoc");if(u&&c){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(!c)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),N(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;N(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(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 u="undefined"!=typeof Float32Array?Float32Array:Array;function c(){var e=new u(16);return u!=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 l(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 f(e,t,r,n,i,o,a,s,c,l,f,h,d,p,_,E){var v=new u(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]=c,v[9]=l,v[10]=f,v[11]=h,v[12]=d,v[13]=p,v[14]=_,v[15]=E,v}function h(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 d=function(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],u=t[5],c=t[6],l=t[7],f=t[8],h=t[9],d=t[10],p=t[11],_=t[12],E=t[13],v=t[14],m=t[15],g=r[0],R=r[1],y=r[2],T=r[3];return e[0]=g*n+R*s+y*f+T*_,e[1]=g*i+R*u+y*h+T*E,e[2]=g*o+R*c+y*d+T*v,e[3]=g*a+R*l+y*p+T*m,e[4]=(g=r[4])*n+(R=r[5])*s+(y=r[6])*f+(T=r[7])*_,e[5]=g*i+R*u+y*h+T*E,e[6]=g*o+R*c+y*d+T*v,e[7]=g*a+R*l+y*p+T*m,e[8]=(g=r[8])*n+(R=r[9])*s+(y=r[10])*f+(T=r[11])*_,e[9]=g*i+R*u+y*h+T*E,e[10]=g*o+R*c+y*d+T*v,e[11]=g*a+R*l+y*p+T*m,e[12]=(g=r[12])*n+(R=r[13])*s+(y=r[14])*f+(T=r[15])*_,e[13]=g*i+R*u+y*h+T*E,e[14]=g*o+R*c+y*d+T*v,e[15]=g*a+R*l+y*p+T*m,e};function p(e,t,r){var n=new u(3);return n[0]=e,n[1]=t,n[2]=r,n}var _,E;_=new u(3),u!=Float32Array&&(_[0]=0,_[1]=0,_[2]=0),E=_;!function(){var e=function(){var e=new u(2);return u!=Float32Array&&(e[0]=0,e[1]=0),e}()}();function v(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function m(e,t,r,n,i,o,a,s,u,c){var l,f,h,d,p,_=e,E=t,g=r,R=n,y=s,T=u,A=120*Math.PI/180,S=Math.PI/180*(+i||0),C=[];if(c)f=c[0],h=c[1],d=c[2],p=c[3];else{E=(l=v(_,E,-S)).y;var O=((_=l.x)-(y=(l=v(y,T,-S)).x))/2,I=(E-(T=l.y))/2,N=O*O/(g*g)+I*I/(R*R);N>1&&(g*=N=Math.sqrt(N),R*=N);var x=g*g,P=R*R,M=(o===a?-1:1)*Math.sqrt(Math.abs((x*P-x*I*I-P*O*O)/(x*I*I+P*O*O)));d=M*g*I/R+(_+y)/2,f=Math.asin(((E-(p=M*-R*O/g+(E+T)/2))/R*1e9>>0)/1e9),h=Math.asin(((T-p)/R*1e9>>0)/1e9),0>(f=d>_?Math.PI-f:f)&&(f=2*Math.PI+f),0>(h=d>y?Math.PI-h:h)&&(h=2*Math.PI+h),a&&f>h&&(f-=2*Math.PI),!a&&h>f&&(h-=2*Math.PI)}var D=h-f;if(Math.abs(D)>A){var L=h,B=y,b=T;C=m(y=d+g*Math.cos(h=f+A*(a&&h>f?1:-1)),T=p+R*Math.sin(h),g,R,i,0,a,B,b,[h,L,d,p])}D=h-f;var F=Math.cos(f),U=Math.sin(f),w=Math.cos(h),G=Math.sin(h),k=Math.tan(D/4),V=4/3*g*k,W=4/3*R*k,X=[_,E],H=[_+V*U,E-W*F],Y=[y+V*G,T-W*w],K=[y,T];if(H[0]=2*X[0]-H[0],H[1]=2*X[1]-H[1],c)return H.concat(Y,K,C);for(var j=[],z=0,q=(C=H.concat(Y,K,C)).length;q>z;z+=1)j[z]=z%2?v(C[z-1],C[z],S).y:v(C[z],C[z+1],S).x;return j}var g=function(e){return null==e},R={}.toString,y=function(e,t){return R.call(e)==="[object "+t+"]"},T=function(e){return y(e,"String")},A=function(e,t,r){return t>e?t:e>r?r:e},S=function(e){return y(e,"Number")},C=s((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,c,l=this._events[s],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,a),!0}for(c=1,u=Array(f-1);f>c;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var h,d=l.length;for(c=0;d>c;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,i);break;default:if(!u)for(h=1,u=Array(f-1);f>h;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].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,c=[],l=s.length;l>u;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c: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})),O=N,I=N;function N(e,t,r){r=r||2;var n,i,o,a,s,u,c,l=t&&t.length,f=l?t[0]*r:e.length,h=x(e,0,f,r,!0),d=[];if(!h||h.next===h.prev)return d;if(l&&(h=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=x(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(k(a));for(s.sort(F),i=0;s.length>i;i++)r=U(s[i],r);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);c=0!==(c=Math.max(o-n,a-i))?32767/c:0}return M(h,d,r,n,i,c,0),d}function x(e,t,r,n,i){var o,a;if(i===J(e,t,r,n)>0)for(o=t;r>o;o+=n)a=Z(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=Z(o,e[o],e[o+1],a);return a&&H(a,a.next)&&(Q(a),a=a.next),a}function P(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!H(n,n.next)&&0!==X(n.prev,n,n.next))n=n.next;else{if(Q(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function M(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{0===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,c=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;c>t&&(s++,n=n.nextZ);t++);for(u=c;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,c*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,c=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?L(e,n,i,o):D(e))t.push(s.i/r|0),t.push(e.i/r|0),t.push(u.i/r|0),Q(e),e=u.next,c=u.next;else if((e=u)===c){a?1===a?M(e=B(P(e),t,r),t,r,n,i,o,2):2===a&&b(e,t,r,n,i,o):M(P(e),t,r,n,i,o,1);break}}}function D(e){var t=e.prev,r=e,n=e.next;if(X(t,r,n)>=0)return!1;for(var i=t.x,o=r.x,a=n.x,s=t.y,u=r.y,c=n.y,l=o>i?a>i?i:a:a>o?o:a,f=u>s?c>s?s:c:c>u?u:c,h=i>o?i>a?i:a:o>a?o:a,d=s>u?s>c?s:c:u>c?u:c,p=n.next;p!==t;){if(p.x>=l&&h>=p.x&&p.y>=f&&d>=p.y&&V(i,s,o,u,a,c,p.x,p.y)&&X(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function L(e,t,r,n){var i=e.prev,o=e,a=e.next;if(X(i,o,a)>=0)return!1;for(var s=i.x,u=o.x,c=a.x,l=i.y,f=o.y,h=a.y,d=u>s?c>s?s:c:c>u?u:c,p=f>l?h>l?l:h:h>f?f:h,_=s>u?s>c?s:c:u>c?u:c,E=l>f?l>h?l:h:f>h?f:h,v=G(d,p,t,r,n),m=G(_,E,t,r,n),g=e.prevZ,R=e.nextZ;g&&g.z>=v&&R&&m>=R.z;){if(g.x>=d&&_>=g.x&&g.y>=p&&E>=g.y&&g!==i&&g!==a&&V(s,l,u,f,c,h,g.x,g.y)&&X(g.prev,g,g.next)>=0)return!1;if(g=g.prevZ,R.x>=d&&_>=R.x&&R.y>=p&&E>=R.y&&R!==i&&R!==a&&V(s,l,u,f,c,h,R.x,R.y)&&X(R.prev,R,R.next)>=0)return!1;R=R.nextZ}for(;g&&g.z>=v;){if(g.x>=d&&_>=g.x&&g.y>=p&&E>=g.y&&g!==i&&g!==a&&V(s,l,u,f,c,h,g.x,g.y)&&X(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;R&&m>=R.z;){if(R.x>=d&&_>=R.x&&R.y>=p&&E>=R.y&&R!==i&&R!==a&&V(s,l,u,f,c,h,R.x,R.y)&&X(R.prev,R,R.next)>=0)return!1;R=R.nextZ}return!0}function B(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!H(i,o)&&Y(i,n,n.next,o)&&z(i,o)&&z(o,i)&&(t.push(i.i/r|0),t.push(n.i/r|0),t.push(o.i/r|0),Q(n),Q(n.next),n=e=o),n=n.next}while(n!==e);return P(n)}function b(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&W(a,s)){var u=q(a,s);return a=P(a,a.next),u=P(u,u.next),M(a,t,r,n,i,o,0),void M(u,t,r,n,i,o,0)}s=s.next}a=a.next}while(a!==e)}function F(e,t){return e.x-t.x}function U(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&&(a=s,r=n.next.x>n.x?n:n.next,s===i))return r}n=n.next}while(n!==t);if(!r)return null;var u,c=r,l=r.x,f=r.y,h=1/0;n=r;do{n.x>i||l>n.x||i===n.x||!V(f>o?i:a,o,l,f,f>o?a:i,o,n.x,n.y)||(u=Math.abs(o-n.y)/(i-n.x),z(n,e)&&(h>u||u===h&&(n.x>r.x||n.x===r.x&&w(r,n)))&&(r=n,h=u)),n=n.next}while(n!==c);return r}(e,t);if(!r)return t;var n=q(r,e);return P(n,n.next),P(r,r.next)}function w(e,t){return 0>X(e.prev,e,t.prev)&&0>X(t.next,e,e.next)}function G(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function k(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)&&(e-a)*(n-s)>=(r-a)*(t-s)&&(r-a)*(o-s)>=(i-a)*(n-s)}function W(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)&&(z(e,t)&&z(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)&&(X(e.prev,e,t.prev)||X(e,t.prev,t))||H(e,t)&&X(e.prev,e,e.next)>0&&X(t.prev,t,t.next)>0)}function X(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function H(e,t){return e.x===t.x&&e.y===t.y}function Y(e,t,r,n){var i=j(X(e,t,r)),o=j(X(e,t,n)),a=j(X(r,n,e)),s=j(X(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 j(e){return e>0?1:0>e?-1:0}function z(e,t){return 0>X(e.prev,e,e.next)?X(e,t,e.next)>=0&&X(e,e.prev,t)>=0:0>X(e,t,e.prev)||0>X(e,e.next,t)}function q(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 Z(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 Q(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=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function J(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}N.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(J(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(J(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 c=n[a]*r,l=n[a+1]*r,f=n[a+2]*r;u+=Math.abs((e[c]-e[f])*(e[l+1]-e[c+1])-(e[c]-e[l])*(e[f+1]-e[c+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},N.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},O.default=I;const ee=1e20;class te{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),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${o} ${e}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.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)),c=s+2*this.buffer,l=u+2*this.buffer,f=Math.max(c*l,0),h=new Uint8ClampedArray(f),d={data:h,width:c,height:l,glyphWidth:s,glyphHeight:u,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===u)return d;const{ctx:p,buffer:_,gridInner:E,gridOuter:v}=this;p.clearRect(_,_,s,u),p.fillText(e,_,_+a);const m=p.getImageData(_,_,s,u);v.fill(ee,0,f),E.fill(0,0,f);for(let e=0;u>e;e++)for(let t=0;s>t;t++){const r=m.data[4*(e*s+t)+3]/255;if(0===r)continue;const n=(e+_)*c+t+_;if(1===r)v[n]=0,E[n]=ee;else{const e=.5-r;v[n]=e>0?e*e:0,E[n]=0>e?e*e:0}}re(v,0,0,c,l,c,this.f,this.v,this.z),re(E,_,_,s,u,c,this.f,this.v,this.z);for(let e=0;f>e;e++){h[e]=Math.round(255-255*((Math.sqrt(v[e])-Math.sqrt(E[e]))/this.radius+this.cutoff))}return d}}function re(e,t,r,n,i,o,a,s,u){for(let c=t;t+n>c;c++)ne(e,r*o+c,o,i,a,s,u);for(let c=r;r+i>c;c++)ne(e,c*o+t,1,n,a,s,u)}function ne(e,t,r,n,i,o,a){o[0]=0,a[0]=-ee,a[1]=ee,i[0]=e[t];for(let s=1,u=0,c=0;n>s;s++){i[s]=e[t+s*r];const n=s*s;do{const e=o[u];c=(i[s]-i[e]+n-e*e)/(s-e)/2}while(a[u]>=c&&--u>-1);u++,o[u]=s,a[u]=c,a[u+1]=ee}for(let s=0,u=0;n>s;s++){for(;s>a[u+1];)u++;const n=o[u],c=s-n;e[t+s*r]=i[n]+c*c}}function ie(){ie=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},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 c(e,t,r,i){var o=Object.create((t&&t.prototype instanceof h?t:h).prototype),a=new C(i||[]);return n(o,"_invoke",{value:y(e,r,a)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var E=Object.getPrototypeOf,v=E&&E(E(O([])));v&&v!==t&&r.call(v,o)&&(_=v);var m=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 R(e,t){function i(n,o,a,s){var u=l(e[n],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){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,s)}))}s(u.arg)}var o;n(this,"_invoke",{value: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 y(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=l(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)}}}function T(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(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 d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),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(m),e},e.awrap=function(e){return{__await:e}},g(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(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),u(m,s,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},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 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 ae(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 se(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,(i=void 0,"symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n.key,"string"))?i:i+""),n)}var i}function ue(e,t,r){return t&&se(e.prototype,t),r&&se(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function ce(){return ce=Object.assign?Object.assign.bind():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},ce.apply(this,arguments)}function le(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,fe(e,t)}function fe(e,t){return fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},fe(e,t)}function he(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 de(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function pe(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 _e(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 pe(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)?pe(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.")}var Ee=function(){this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]};Ee.tag="c-renderable-3d";var ve,me,ge,Re,ye,Te,Ae,Se,Ce,Oe,Ie,Ne,xe,Pe,Me,De,Le,Be,be,Fe,Ue,we,Ge,ke,Ve,We,Xe,He=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}(),Ye=["style"],Ke=function(e){function r(r){var n,i=r.style,o=he(r,Ye);return(n=e.call(this,ce({type:t.Shape.MESH,style:ce({x:"",y:"",z:"",lineWidth:0},i)},o))||this).cullable.enable=!1,n.style.geometry.meshes.push(de(n)),n.style.material.meshes.push(de(n)),n}return le(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),je=function(){function e(){}return e.prototype.update=function(e){return e.geometry.computeBoundingBox(),{width:0,height:0,depth:0}},e}(),ze=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 qe(e,t,r,n){return{dimension:Me.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:De.Sampled}}function Ze(e){return e}function Qe(e,t,r){return e<<16|t<<8|r}function $e(e){return e>>>8&255}function Je(e){return e>>>16&255}function et(e){return 255&e}function tt(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 rt(e){return tt(Je(e))}function nt(e){var t=et(e);if(t&Ve.Depth)return be.Depth;if(t&Ve.Normalized)return be.Float;var r=Je(e);if(r===Ge.F16||r===Ge.F32)return be.Float;if(r===Ge.U8||r===Ge.U16||r===Ge.U32)return be.Uint;if(r===Ge.S8||r===Ge.S16||r===Ge.S32)return be.Sint;throw Error("whoops")}function it(e,t){if(void 0===t&&(t=""),!e)throw console.error(Error().stack),Error("Assert fail: "+t)}function ot(e){if(null!=e)return e;throw Error("Missing object")}function at(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function st(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function ut(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function ct(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!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"}(ve||(ve={})),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"}(me||(me={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(ge||(ge={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(Re||(Re={})),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"}(ye||(ye={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(Te||(Te={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(Ae||(Ae={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(Se||(Se={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(Ce||(Ce={})),function(e){e[e.Points=0]="Points",e[e.Triangles=1]="Triangles",e[e.TriangleStrip=2]="TriangleStrip",e[e.Lines=3]="Lines",e[e.LineStrip=4]="LineStrip"}(Oe||(Oe={})),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"}(Ie||(Ie={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(Ne||(Ne={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(xe||(xe={})),function(e){e.LOADED="loaded"}(Pe||(Pe={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(Me||(Me={})),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"}(Le||(Le={})),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"}(Be||(Be={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(be||(be={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(Fe||(Fe={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(Ue||(Ue={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(we||(we={})),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"}(ke||(ke={})),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"}(Ve||(Ve={})),function(e){e[e.ALPHA=Qe(Ge.U8,ke.A,Ve.None)]="ALPHA",e[e.F16_R=Qe(Ge.F16,ke.R,Ve.None)]="F16_R",e[e.F16_RG=Qe(Ge.F16,ke.RG,Ve.None)]="F16_RG",e[e.F16_RGB=Qe(Ge.F16,ke.RGB,Ve.None)]="F16_RGB",e[e.F16_RGBA=Qe(Ge.F16,ke.RGBA,Ve.None)]="F16_RGBA",e[e.F32_R=Qe(Ge.F32,ke.R,Ve.None)]="F32_R",e[e.F32_RG=Qe(Ge.F32,ke.RG,Ve.None)]="F32_RG",e[e.F32_RGB=Qe(Ge.F32,ke.RGB,Ve.None)]="F32_RGB",e[e.F32_RGBA=Qe(Ge.F32,ke.RGBA,Ve.None)]="F32_RGBA",e[e.U8_R=Qe(Ge.U8,ke.R,Ve.None)]="U8_R",e[e.U8_R_NORM=Qe(Ge.U8,ke.R,Ve.Normalized)]="U8_R_NORM",e[e.U8_RG=Qe(Ge.U8,ke.RG,Ve.None)]="U8_RG",e[e.U8_RG_NORM=Qe(Ge.U8,ke.RG,Ve.Normalized)]="U8_RG_NORM",e[e.U8_RGB=Qe(Ge.U8,ke.RGB,Ve.None)]="U8_RGB",e[e.U8_RGB_NORM=Qe(Ge.U8,ke.RGB,Ve.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=Qe(Ge.U8,ke.RGB,Ve.sRGB|Ve.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=Qe(Ge.U8,ke.RGBA,Ve.None)]="U8_RGBA",e[e.U8_RGBA_NORM=Qe(Ge.U8,ke.RGBA,Ve.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=Qe(Ge.U8,ke.RGBA,Ve.sRGB|Ve.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=Qe(Ge.U16,ke.R,Ve.None)]="U16_R",e[e.U16_R_NORM=Qe(Ge.U16,ke.R,Ve.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=Qe(Ge.U16,ke.RG,Ve.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=Qe(Ge.U16,ke.RGBA,Ve.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=Qe(Ge.U16,ke.RGB,Ve.None)]="U16_RGB",e[e.U32_R=Qe(Ge.U32,ke.R,Ve.None)]="U32_R",e[e.U32_RG=Qe(Ge.U32,ke.RG,Ve.None)]="U32_RG",e[e.S8_R=Qe(Ge.S8,ke.R,Ve.None)]="S8_R",e[e.S8_R_NORM=Qe(Ge.S8,ke.R,Ve.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=Qe(Ge.S8,ke.RG,Ve.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=Qe(Ge.S8,ke.RGB,Ve.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=Qe(Ge.S8,ke.RGBA,Ve.Normalized)]="S8_RGBA_NORM",e[e.S16_R=Qe(Ge.S16,ke.R,Ve.None)]="S16_R",e[e.S16_RG=Qe(Ge.S16,ke.RG,Ve.None)]="S16_RG",e[e.S16_RG_NORM=Qe(Ge.S16,ke.RG,Ve.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=Qe(Ge.S16,ke.RGB,Ve.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=Qe(Ge.S16,ke.RGBA,Ve.None)]="S16_RGBA",e[e.S16_RGBA_NORM=Qe(Ge.S16,ke.RGBA,Ve.Normalized)]="S16_RGBA_NORM",e[e.S32_R=Qe(Ge.S32,ke.R,Ve.None)]="S32_R",e[e.U16_RGBA_5551=Qe(Ge.U16_PACKED_5551,ke.RGBA,Ve.Normalized)]="U16_RGBA_5551",e[e.BC1=Qe(Ge.BC1,ke.RGBA,Ve.Normalized)]="BC1",e[e.BC1_SRGB=Qe(Ge.BC1,ke.RGBA,Ve.Normalized|Ve.sRGB)]="BC1_SRGB",e[e.BC2=Qe(Ge.BC2,ke.RGBA,Ve.Normalized)]="BC2",e[e.BC2_SRGB=Qe(Ge.BC2,ke.RGBA,Ve.Normalized|Ve.sRGB)]="BC2_SRGB",e[e.BC3=Qe(Ge.BC3,ke.RGBA,Ve.Normalized)]="BC3",e[e.BC3_SRGB=Qe(Ge.BC3,ke.RGBA,Ve.Normalized|Ve.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=Qe(Ge.BC4_UNORM,ke.R,Ve.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=Qe(Ge.BC4_SNORM,ke.R,Ve.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=Qe(Ge.BC5_UNORM,ke.RG,Ve.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=Qe(Ge.BC5_SNORM,ke.RG,Ve.Normalized)]="BC5_SNORM",e[e.D24=Qe(Ge.D24,ke.R,Ve.Depth)]="D24",e[e.D24_S8=Qe(Ge.D24S8,ke.RG,Ve.Depth|Ve.Stencil)]="D24_S8",e[e.D32F=Qe(Ge.D32F,ke.R,Ve.Depth)]="D32F",e[e.D32F_S8=Qe(Ge.D32FS8,ke.RG,Ve.Depth|Ve.Stencil)]="D32F_S8",e[e.U8_RGB_RT=Qe(Ge.U8,ke.RGB,Ve.RenderTarget|Ve.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=Qe(Ge.U8,ke.RGBA,Ve.RenderTarget|Ve.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=Qe(Ge.U8,ke.RGBA,Ve.RenderTarget|Ve.Normalized|Ve.sRGB)]="U8_RGBA_RT_SRGB"}(We||(We={})),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"}(Xe||(Xe={}));var lt=ct(0,0,0,0),ft=ct(0,0,0,1),ht=ct(1,1,1,0),dt=ct(1,1,1,1),pt=!0;function _t(e,t){if(void 0===t&&(t=pt),!t)return e;switch(e){case me.Less:return me.Greater;case me.LessEqual:return me.GreaterEqual;case me.GreaterEqual:return me.LessEqual;case me.Greater:return me.Less;default:return e}}function Et(e,t){return null!=e?e:t}function vt(e){return void 0===e?null:e}function mt(e,t,r){e.length=t,e.fill(r)}function gt(e,t){var r=t-1;return e+r&~r}function Rt(e,t){return((e+t-1)/t|0)*t}function yt(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 Tt(e,t,r){var n=yt(e,t,r);e.splice(n,0,t)}function At(e,t,r){return r?e|=t:e&=~t,e}function St(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function Ct(e,t,r){for(void 0===r&&(r="0");t>e.length;)e=""+r+e;return e}function Ot(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function It(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Ot(e.rgbBlendState,t.rgbBlendState),Ot(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Nt(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=It(e[r],t[r])}function xt(e,t){void 0!==t.attachmentsState&&Nt(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&st(e.blendConstant,t.blendConstant),e.depthCompare=Et(t.depthCompare,e.depthCompare),e.depthWrite=Et(t.depthWrite,e.depthWrite),e.stencilCompare=Et(t.stencilCompare,e.stencilCompare),e.stencilWrite=Et(t.stencilWrite,e.stencilWrite),e.stencilPassOp=Et(t.stencilPassOp,e.stencilPassOp),e.stencilRef=Et(t.stencilRef,e.stencilRef),e.cullMode=Et(t.cullMode,e.cullMode),e.frontFace=Et(t.frontFace,e.frontFace),e.polygonOffset=Et(t.polygonOffset,e.polygonOffset)}function Pt(e){var t=Object.assign({},e);return t.attachmentsState=[],Nt(t.attachmentsState,e.attachmentsState),t.blendConstant=ut(t.blendConstant),t}function Mt(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 Dt={blendMode:Te.Add,blendSrcFactor:ye.One,blendDstFactor:ye.Zero},Lt={attachmentsState:[{channelWriteMask:Le.RGB,rgbBlendState:Dt,alphaBlendState:Dt}],blendConstant:ut(lt),depthWrite:!0,depthCompare:me.LessEqual,stencilCompare:me.Always,stencilWrite:!1,stencilPassOp:Be.Keep,stencilRef:0,cullMode:Re.None,frontFace:ge.CCW,polygonOffset:!1};function Bt(e,t){void 0===e&&(e=null),void 0===t&&(t=Lt);var r=Pt(t);return null!==e&&xt(r,e),r}var bt=Bt({depthCompare:me.Always,depthWrite:!1},Lt);function Ft(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Nt(e.attachmentsState,Lt.attachmentsState)),Mt(e.attachmentsState[0],t),e}var Ut,wt={formatKind:be.Float,dimension:Me.n2D};function Gt(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 kt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function Vt(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function Wt(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function Xt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Ht(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!Gt(e.samplerBindings,t.samplerBindings,Wt)&&(!!Gt(e.uniformBufferBindings,t.uniformBufferBindings,Vt)&&!!jt(e.bindingLayout,t.bindingLayout)))}function Yt(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function Kt(e,t){return!!Yt(e.rgbBlendState,t.rgbBlendState)&&(!!Yt(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function jt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function zt(e,t){return e===t}function qt(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!Gt(e.attachmentsState,t.attachmentsState,Kt)&&!!at(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)&&(!!Gt(e.bindingLayouts,t.bindingLayouts,jt)&&(!!Gt(e.colorAttachmentFormats,t.colorAttachmentFormats,zt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function Zt(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Qt(e,t){return g(e)?g(t):!g(t)&&(e.byteStride===t.byteStride&&e.frequency===t.frequency)}function $t(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Gt(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Qt)&&!!Gt(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,Zt))}function Jt(e,t){return e.wrapS===t.wrapS&&e.wrapT===t.wrapT&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipFilter===t.mipFilter&&e.minLOD===t.minLOD&&e.maxLOD===t.maxLOD&&e.maxAnisotropy===t.maxAnisotropy&&e.compareMode===t.compareMode}function er(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function tr(e){return{buffer:e.buffer,wordCount:e.wordCount}}function rr(e){return{bindingLayout:e.bindingLayout,samplerBindings:kt(e.samplerBindings,er),uniformBufferBindings:kt(e.uniformBufferBindings,tr),pipeline:e.pipeline}}function nr(e){return{dimension:e.dimension,formatKind:e.formatKind}}function ir(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?kt(e.samplerEntries,nr):void 0}}function or(e){var t=kt(e.bindingLayouts,ir),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:Pt(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function ar(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function sr(e){return g(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function ur(e){return{vertexAttributeDescriptors:kt(e.vertexAttributeDescriptors,ar),vertexBufferDescriptors:kt(e.vertexBufferDescriptors,sr),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(Ut||(Ut={}));var cr,lr=new Uint16Array([65279]),fr=255==new DataView(lr.buffer).getUint8(0)?Ut.LITTLE_ENDIAN:Ut.BIG_ENDIAN;var hr=/([^[]*)(\[[0-9]+\])?/;function dr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function pr(e,t,r,n){var i=null,o=null;return function(a,s,u){var c=t(u,r),l=c.length,f=!1;if(null===i)i=new Float32Array(l),o=l,f=!0;else{it(o===l,"Uniform length cannot change.");for(var h=0;l>h;++h)if(c[h]!==i[h]){f=!0;break}}return f&&(n(a,e,s,c),i.set(c)),f}}function _r(e,t,r,n){e[t](r,n)}function Er(e,t,r,n){e[t](r,!1,n)}var vr={},mr={},gr={},Rr=[0];function yr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Rr[0]=e,e=Rr);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 Tr(e,t){return yr(e,t,Float32Array,vr)}function Ar(e,t){return yr(e,t,Int32Array,mr)}function Sr(e,t){return yr(e,t,Uint32Array,gr)}var Cr=((cr={})[Xe.FLOAT]=pr.bind(null,"uniform1fv",Tr,1,_r),cr[Xe.FLOAT_VEC2]=pr.bind(null,"uniform2fv",Tr,2,_r),cr[Xe.FLOAT_VEC3]=pr.bind(null,"uniform3fv",Tr,3,_r),cr[Xe.FLOAT_VEC4]=pr.bind(null,"uniform4fv",Tr,4,_r),cr[Xe.INT]=pr.bind(null,"uniform1iv",Ar,1,_r),cr[Xe.INT_VEC2]=pr.bind(null,"uniform2iv",Ar,2,_r),cr[Xe.INT_VEC3]=pr.bind(null,"uniform3iv",Ar,3,_r),cr[Xe.INT_VEC4]=pr.bind(null,"uniform4iv",Ar,4,_r),cr[Xe.BOOL]=pr.bind(null,"uniform1iv",Ar,1,_r),cr[Xe.BOOL_VEC2]=pr.bind(null,"uniform2iv",Ar,2,_r),cr[Xe.BOOL_VEC3]=pr.bind(null,"uniform3iv",Ar,3,_r),cr[Xe.BOOL_VEC4]=pr.bind(null,"uniform4iv",Ar,4,_r),cr[Xe.FLOAT_MAT2]=pr.bind(null,"uniformMatrix2fv",Tr,4,Er),cr[Xe.FLOAT_MAT3]=pr.bind(null,"uniformMatrix3fv",Tr,9,Er),cr[Xe.FLOAT_MAT4]=pr.bind(null,"uniformMatrix4fv",Tr,16,Er),cr[Xe.SAMPLER_2D]=dr,cr[Xe.SAMPLER_CUBE]=dr,cr[Xe.UNSIGNED_INT]=pr.bind(null,"uniform1uiv",Sr,1,_r),cr[Xe.UNSIGNED_INT_VEC2]=pr.bind(null,"uniform2uiv",Sr,2,_r),cr[Xe.UNSIGNED_INT_VEC3]=pr.bind(null,"uniform3uiv",Sr,3,_r),cr[Xe.UNSIGNED_INT_VEC4]=pr.bind(null,"uniform4uiv",Sr,4,_r),cr[Xe.FLOAT_MAT2x3]=pr.bind(null,"uniformMatrix2x3fv",Tr,6,Er),cr[Xe.FLOAT_MAT2x4]=pr.bind(null,"uniformMatrix2x4fv",Tr,8,Er),cr[Xe.FLOAT_MAT3x2]=pr.bind(null,"uniformMatrix3x2fv",Tr,6,Er),cr[Xe.FLOAT_MAT3x4]=pr.bind(null,"uniformMatrix3x4fv",Tr,12,Er),cr[Xe.FLOAT_MAT4x2]=pr.bind(null,"uniformMatrix4x2fv",Tr,8,Er),cr[Xe.FLOAT_MAT4x3]=pr.bind(null,"uniformMatrix4x3fv",Tr,12,Er),cr[Xe.SAMPLER_2D]=dr,cr[Xe.SAMPLER_CUBE]=dr,cr[Xe.SAMPLER_3D]=dr,cr[Xe.SAMPLER_2D_SHADOW]=dr,cr[Xe.SAMPLER_2D_ARRAY]=dr,cr[Xe.SAMPLER_2D_ARRAY_SHADOW]=dr,cr[Xe.SAMPLER_CUBE_SHADOW]=dr,cr[Xe.INT_SAMPLER_2D]=dr,cr[Xe.INT_SAMPLER_3D]=dr,cr[Xe.INT_SAMPLER_CUBE]=dr,cr[Xe.INT_SAMPLER_2D_ARRAY]=dr,cr[Xe.UNSIGNED_INT_SAMPLER_2D]=dr,cr[Xe.UNSIGNED_INT_SAMPLER_3D]=dr,cr[Xe.UNSIGNED_INT_SAMPLER_CUBE]=dr,cr[Xe.UNSIGNED_INT_SAMPLER_2D_ARRAY]=dr,cr);var Or=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function Ir(e,t){return"#define "+e+" "+t}function Nr(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)}))},c=0;5>c;c++)u(c);else s.uniforms.forEach((function(e){t.push(o+"."+e.name)}))}o&&t.push(o)}})),""})),t}function xr(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 Ir(e,n[e])})).join("\n"));var u=a.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",c=a.filter((function(e){return!e.startsWith("precision")})).join("\n"),l="";if(e.viewportOrigin===Fe.UpperLeft&&(l+=Ir("VIEWPORT_ORIGIN_TL","1")+"\n"),e.clipSpaceNearZ===Ue.Zero&&(l+=Ir("CLIPSPACE_NEAR_ZERO","1")+"\n"),e.explicitBindingLocations){var f=0,h=0,d=0;c=c.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout("+(r?r+", ":"")+"set = "+f+", binding = "+h+++") uniform "+n})),f++,h=0,it(e.separateSamplerTextures),c=(c=c.replace(/uniform sampler2D (.*);/g,(function(e,r){return"frag"===t?"\nlayout(set = "+f+", binding = "+h+++") uniform texture2D T_"+r+";\nlayout(set = "+f+", binding = "+h+++") uniform sampler S_"+r+";\n":""}))).replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = "+d+++") "+t})),l+=Ir("gl_VertexID","gl_VertexIndex")+"\n"}c=e.separateSamplerTextures?(c=(c=(c=c.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+")"})):(c=(c=(c=c.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"+l+"\n"+s+"\n"+c+"\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,m=_e(Or);!(v=m()).done;){var g=v.value;p=p.replace(g[0],g[1])}}return p}function Pr(e,t,r,n,i){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:xr(e,"vert",t,n),preprocessedFrag:xr(e,"frag",r,n)}}function Mr(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 Pr(e.queryVendorInfo(),n,i,r)}var Dr=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}var t=e.prototype;return t.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},t.setDefineString=function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(g(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},t.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},t.getDefineString=function(e){return vt(this.defines[e])},t.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&it("1"===t),null!==t},t.ensurePreprocessed=function(e){""===this.preprocessedVert&&(this.preprocessedVert=xr(e,"vert",this.both+this.vert,this.defines),this.preprocessedFrag=xr(e,"frag",this.both+this.frag,this.defines))},e}(),Lr=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=Rt(e,this.uniformBufferWordAlignment),it(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=Rt(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=Rt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){it(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=Rt(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 ot(this.shadowBufferF32)},t.prepareToRender=function(){if(null!==this.shadowBufferF32){var e=ot(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:Ie.UNIFORM|Ie.COPY_DST,hint:Ne.Dynamic}));var t=Rt(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())ot(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 Br(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function br(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Fr(e){return 0}var Ur=function(){this.keys=[],this.values=[]},wr=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 Ur);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=_e(this.buckets.values());!(e=r()).done;){t+=e.value.values.length}return t},t.values=ie().mark((function e(){var t,r,n,i;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=_e(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 Gr(e,t){return it(""!==e.preprocessedVert&&""!==t.preprocessedVert),it(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function kr(e,t){return e=Br(e,t.numUniformBuffers),e=Br(e,t.numSamplers)}function Vr(e,t){return e=Br(e,t.blendMode),e=Br(e,t.blendSrcFactor),e=Br(e,t.blendDstFactor)}function Wr(e,t){return e=Vr(e,t.rgbBlendState),e=Br(e=Vr(e,t.alphaBlendState),t.channelWriteMask)}function Xr(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=Wr(e,t.attachmentsState[r]);return e=function(e,t){return Br(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Br(e,t.depthCompare),e=Br(e,t.depthWrite?1:0),e=Br(e,t.stencilCompare),e=Br(e,t.stencilPassOp),e=Br(e,t.stencilWrite?1:0),e=Br(e,t.cullMode),e=Br(e,t.frontFace?1:0),e=Br(e,t.polygonOffset?1:0)}function Hr(e){var t=0;t=Br(t,e.program.id),null!==e.inputLayout&&(t=Br(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=kr(t,e.bindingLayouts[r]);t=Xr(t,e.megaStateDescriptor);for(var n=0;e.colorAttachmentFormats.length>n;n++)t=Br(t,e.colorAttachmentFormats[n]||0);return br(t=Br(t,e.depthStencilAttachmentFormat||0))}function Yr(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=Br(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=Br(t,o.buffer.id),t=Br(t,o.wordCount))}return br(t)}var Kr,jr=function(){function e(e){this.device=void 0,this.bindingsCache=new wr(Ht,Yr),this.renderPipelinesCache=new wr(qt,Hr),this.inputLayoutsCache=new wr($t,Fr),this.programCache=new wr(Gr,Fr),this.samplerCache=new wr(Jt,Fr),this.device=e}var t=e.prototype;return t.createBindings=function(e){var t=this.bindingsCache.get(e);if(null===t){var r=rr(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=or(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=ur(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=_e(this.bindingsCache.values());!(e=t()).done;){e.value.destroy()}for(var r,n=_e(this.renderPipelinesCache.values());!(r=n()).done;){r.value.destroy()}for(var i,o=_e(this.inputLayoutsCache.values());!(i=o()).done;){i.value.destroy()}for(var a,s=_e(this.programCache.values());!(a=s()).done;){a.value.destroy()}for(var u,c=_e(this.samplerCache.values());!(u=c()).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"}(Kr||(Kr={}));var zr,qr={x:0,y:0,w:1,h:1},Zr=function(){function e(){this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=qr,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){it(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){it(null===this.execFunc),this.execFunc=e},t.post=function(e){it(null===this.postFunc),this.postFunc=e},t.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),Qr=function(){function e(e,t){this.debugName=void 0,this.dimension=Me.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,it(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){it(this.matchesDescription(e)),this.age=0},t.destroy=function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()},e}(),$r=function(){function e(e,t){this.dimension=Me.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){it(this.matchesDescription(e)),this.age=0},t.destroy=function(){this.texture.destroy()},e}(),Jr=function(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},en=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 Qr(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 $r(this.device,e)},t.beginGraphBuilder=function(){it(null===this.currentGraph),this.currentGraph=new Jr},t.pushPass=function(e){var t=new Zr;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=ot(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return it(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);it(void 0===r.resolveTextureOutputIDs[n]),r.resolveTextureOutputExternalTextures[n]=t},t.getRenderTargetDescription=function(e){return ot(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(it(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=ot(this.renderTargetAliveForID[e]);return t?(it(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(it(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];it(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=ot(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 ot(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;it(!(a&&s));var u=null,c=!1;if(this.renderTargetOutputCount[n]>1&&(c=!0),a){it(e.resolveTextureRenderTargetIDs[i]===n),it(this.resolveTextureUseCount[i]>0),it(this.renderTargetOutputCount[n]>0);var l=ot(this.renderTargetAliveForID[n]);if(null!==l.texture&&1===this.renderTargetOutputCount[n])u=null,c=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=ot(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(f),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,l.debugName+" (Resolve "+i+")")}u=this.singleSampledTextureForResolveTextureID[i].texture}}else u=s?o:null;return{resolveTo:u,store:c}},t.schedulePass=function(e,t){for(var r=t.renderTargetIDs[Kr.DepthStencil],n=Kr.Color0;Kr.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[Kr.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var c=this.determineResolveParam(e,t,Kr.DepthStencil),l=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=l,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),it(_.width===f),it(_.height===h),it(_.sampleCount===d),_.needsClear=!1)}if(f>0&&h>0){var E=h*t.viewport.y,v=f*t.viewport.w,m=h*t.viewport.h;t.viewportX=f*t.viewport.x,t.viewportY=E,t.viewportW=v,t.viewportH=m}for(var g=0;t.resolveTextureInputIDs.length>g;g++){t.resolveTextureInputTextures[g]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[g])}for(var R=0;t.renderTargetIDs.length>R;R++)this.releaseRenderTargetForID(t.renderTargetIDs[R],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},t.scheduleGraph=function(e){it(0===this.renderTargetOutputCount.length),it(0===this.renderTargetResolveCount.length),it(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++;mt(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),mt(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),mt(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++)it(0===this.renderTargetOutputCount[o]);for(var a=0;this.renderTargetResolveCount.length>a;a++)it(0===this.renderTargetResolveCount[a]);for(var s=0;this.resolveTextureUseCount.length>s;s++)it(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)it(void 0===this.renderTargetAliveForID[u]);for(var c=0;this.renderTargetDeadPool.length>c;c++)1>this.renderTargetDeadPool[c].age||(this.renderTargetDeadPool[c].destroy(),this.renderTargetDeadPool.splice(c--,1));for(var l=0;this.singleSampledTextureDeadPool.length>l;l++)1>this.singleSampledTextureDeadPool[l].age||(this.singleSampledTextureDeadPool[l].destroy(),this.singleSampledTextureDeadPool.splice(l--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},t.execPass=function(e){it(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=ot(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 it(r>=0),ot(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++)it(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)it(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"}(zr||(zr={}));function tn(e,t,r){void 0===r&&(r=65536);var n=A(e,0,r)/r;return t&&(n=1-n),65535&65535*n}function rn(e,t){return(16777215&e|(255&t)<<24)>>>0}function nn(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function on(e,t){return rn(nn(0,t),e)}function an(e,t){return it(t>=0),(4294967040&e|t>>>8&255)>>>0}function sn(e){return rn(0,e)}function un(e,t){return it(t>=0),(4278190335&e|t<<8)>>>0}var cn=f(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var ln,fn=f(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function hn(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"}(ln||(ln={}));var dn,pn=function(){function e(){this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=St(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=St(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:Pt(Lt),program:null,topology:Oe.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}var t=e.prototype;return t.reset=function(){this.sortKey=0,this.flags=ln.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null},t.setFromTemplate=function(e){xt(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&~ln.InheritedFlags|e.flags&ln.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 xt(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){it(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){it(this.bindingDescriptors.length>=e.length),it(1===e.length),this.setBindingLayout(e[0])},t.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=At(this.flags,ln.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},t.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=At(this.flags,ln.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},t.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=At(this.flags,ln.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;if(S(t)||Array.isArray(t)||t instanceof Float32Array){var i=S(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+=hn(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 it(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):(it(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}},t.setAllowSkippingIfPipelineNotReady=function(e){this.flags=At(this.flags,ln.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:it(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:it(n==a.sampleCount)),it(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&ln.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=ot(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(ce({},this.bindingDescriptors[0],{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(it(!!(this.flags&ln.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&ln.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0},e}();function _n(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(dn||(dn={}));var En=function(){function e(e,t){void 0===e&&(e=_n),void 0===t&&(t=dn.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):Tt(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()},t.submitRenderInst=function(e){e.flags|=ln.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===dn.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}(),vn=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 pn),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}(),mn=function(){function e(e){this.renderCache=void 0,this.instPool=new vn,this.templatePool=new vn,this.simpleRenderInstList=new En,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){it(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|=ln.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(),it(0===this.templatePool.allocCount)},t.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},t.disableSimpleMode=function(){this.simpleRenderInstList=null},t.drawOnPassRenderer=function(e){ot(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},t.drawOnPassRendererNoReset=function(e){ot(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),gn=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 jr(e),this.renderGraph=new en(this.device),this.renderInstManager=new mn(this.renderCache),this.uniformBuffer=new Lr(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}(),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 yn(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var Tn,An=yn(ct(.88,.88,.88,1)),Sn=yn(ft),Cn=yn(dt);function On(e,t){var r=function(e){return e.antialiasingMode===Tn.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function In(e,t,r){var n=function(e){if(e===Kr.Color0)return We.U8_RGBA_RT;if(e===Kr.DepthStencil)return We.D24_S8;throw Error("whoops")}(e),i=new Rn(n);return On(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"}(Tn||(Tn={}));var Nn=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}(),xn=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),it(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new $r(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}(),Pn=["style"],Mn=function(e){function t(r){var n=void 0===r?{}:r,i=n.style,o=he(n,Pn);return e.call(this,ce({type:t.tag,style:ce({intensity:Math.PI},i)},o))||this}return le(t,e),t}(t.DisplayObject);Mn.tag="light";var Dn,Ln=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(Dn||(Dn={}));var Bn=function(e){function t(r){var n=void 0===r?{}:r,i=n.style,o=he(n,Ln);return e.call(this,ce({type:t.tag,style:ce({type:Dn.NONE,fill:"black",start:1,end:1e3,density:0},i)},o))||this}return le(t,e),t}(t.DisplayObject);Bn.tag="fog";var bn;!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"}(bn||(bn={}));var Fn=function(){function e(e,t,r,n){this.renderHelper=void 0,this.lightPool=void 0,this.texturePool=void 0,this.batchManager=void 0,this.context=void 0,this.device=void 0,this.swapChain=void 0,this.renderLists={world:new En,picking:new En},this.builder=void 0,this.enableCapture=void 0,this.captureOptions=void 0,this.capturePromise=void 0,this.resolveCapturePromise=void 0,this.renderHelper=e,this.lightPool=t,this.texturePool=r,this.batchManager=n}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(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var t=e.target;if(t.nodeName!==Mn.tag)if(t.nodeName!==Bn.tag){var r=new Ee;t.renderable3D=r,n.batchManager.add(t)}else n.lightPool.addFog(t);else n.lightPool.addLight(t)},s=function(e){var t=e.target;t.nodeName!==Mn.tag?t.nodeName!==Bn.tag?(n.batchManager.remove(t),delete t.renderable3D):n.lightPool.removeFog(t):n.lightPool.removeLight(t)},u=function(e){n.batchManager.updateAttribute(e.target,e.attrName,e.newValue)},c=function(e){n.batchManager.updateAttribute(e.target,"modelMatrix",null)},l=function(e){n.batchManager.changeRenderOrder(e.target,e.detail.renderOrder)};i.hooks.init.tapPromise(e.tag,ae(ie().mark((function e(){var i,f;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o.addEventListener(t.ElementEvent.MOUNTED,a),o.addEventListener(t.ElementEvent.UNMOUNTED,s),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,u),o.addEventListener(t.ElementEvent.BOUNDS_CHANGED,c),o.addEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,l),n.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,i=n.context.contextService.getDomElement(),n.context.contextService.resize((f=n.context.config).width,f.height),e.next=11,n.context.deviceContribution.createSwapChain(i);case 11:n.swapChain=e.sent,n.device=n.swapChain.getDevice(),n.renderHelper.setDevice(n.device),n.renderHelper.renderInstManager.disableSimpleMode(),n.swapChain.configureSwapChain(i.width,i.height),o.addEventListener(t.CanvasEvent.RESIZE,(function(){n.swapChain.configureSwapChain(i.width,i.height)})),n.batchManager.attach(ce({device:n.device},r));case 18:case"end":return e.stop()}}),e)})))),i.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),o.removeEventListener(t.ElementEvent.MOUNTED,a),o.removeEventListener(t.ElementEvent.UNMOUNTED,s),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,u),o.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,c),o.removeEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,l)})),i.hooks.beginFrame.tap(e.tag,(function(){var e=n.swapChain.getCanvas(),r=n.renderHelper.renderInstManager;n.builder=n.renderHelper.renderGraph.newGraphBuilder();var i=t.parseColor(n.context.config.background),o=n.context.config.background?ct(Number(i.r)/255*Number(i.alpha),Number(i.g)/255*Number(i.alpha),Number(i.b)/255*Number(i.alpha),Number(i.alpha)):lt,a={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:Tn.None},s=In(Kr.Color0,a,yn(o)),u=In(Kr.DepthStencil,a,Cn),c=n.builder.createRenderTargetID(s,"Main Color"),l=n.builder.createRenderTargetID(u,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Kr.Color0,c),e.attachRenderTargetID(Kr.DepthStencil,l),e.exec((function(e){n.renderLists.world.drawOnPassRenderer(r.renderCache,e)}))})),n.builder.resolveRenderTargetToExternalTexture(c,n.swapChain.getOnscreenTexture())})),i.hooks.endFrame.tap(e.tag,(function(){var e=n.renderHelper.renderInstManager,t=n.renderHelper.pushTemplateRenderInst();t.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),t.setMegaStateFlags(Ft({depthWrite:!0,blendConstant:lt},{rgbBlendMode:Te.Add,alphaBlendMode:Te.Add,rgbBlendSrcFactor:ye.SrcAlpha,alphaBlendSrcFactor:ye.One,rgbBlendDstFactor:ye.OneMinusSrcAlpha,alphaBlendDstFactor:ye.OneMinusSrcAlpha}));var r=n.context.config,i=r.width,o=r.height,a=n.context.camera;if(t.setUniforms(0,[{name:bn.PROJECTION_MATRIX,value:a.getPerspective()},{name:bn.VIEW_MATRIX,value:a.getViewTransform()},{name:bn.CAMERA_POSITION,value:a.getPosition()},{name:bn.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:bn.VIEWPORT,value:[i,o]},{name:bn.IS_ORTHO,value:a.isOrtho()?1:0},{name:bn.IS_PICKING,value:0}]),n.batchManager.render(n.renderLists.world),e.popTemplateRenderInst(),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),e.resetRenderInsts(),n.swapChain.present(),n.enableCapture&&n.resolveCapturePromise){var s=n.captureOptions,u=s.type,c=s.encoderOptions,l=n.context.contextService.getDomElement().toDataURL(u,c);n.resolveCapturePromise(l),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))},r.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},r.toDataURL=function(){var e=ae(ie().mark((function e(t){var r=this;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.enableCapture=!0,this.captureOptions=t,this.capturePromise=new Promise((function(e){r.resolveCapturePromise=function(t){e(t)}})),e.abrupt("return",this.capturePromise);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();Fn.tag="RenderGraph";var Un=function(){function e(e,t,r,n){this.renderHelper=void 0,this.renderGraphPlugin=void 0,this.pickingIdGenerator=void 0,this.batchManager=void 0,this.context=void 0,this.renderHelper=e,this.renderGraphPlugin=t,this.pickingIdGenerator=r,this.batchManager=n}var r=e.prototype;return r.apply=function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var t=e.target,r=t.renderable3D;if(r){var i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)}};i.hooks.init.tapPromise(e.tag,ae(ie().mark((function e(){return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.addEventListener(t.ElementEvent.MOUNTED,a);case 1:case"end":return e.stop()}}),e)})))),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,a)})),i.hooks.pickSync.tap(e.tag,(function(e){return e})),i.hooks.pick.tapPromise(e.tag,function(){var e=ae(ie().mark((function e(r){var i,o,a,s,u,c,l,f,h;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.topmost,a=(o=r.position).viewportX,s=o.viewportY,u=n.context.contextService.getDPR(),l=n.context.config.height*u,h=s*u,!((f=a*u)>(c=n.context.config.width*u)||0>f||h>l||0>h)){e.next=10;break}return r.picked=[],e.abrupt("return",r);case 10:return e.next=12,n.pickByRectangleInDepth(new t.Rectangle(A(Math.round(f),0,c-1),A(Math.round(h),0,l-1),1,1),i?1:100);case 12:return r.picked=e.sent,e.abrupt("return",r);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())},r.pickByRectangleInDepth=function(){var e=ae(ie().mark((function e(t,r){var n,i,o;return ie().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=this.context.camera,u=e.x,c=e.y,l=e.width,f=e.height,h={backbufferWidth:l,backbufferHeight:f,antialiasingMode:Tn.None},d=In(Kr.Color0,h,yn(lt)),p=a.createRenderTargetID(d,"Picking Color"),_=In(Kr.DepthStencil,h,Cn),E=a.createRenderTargetID(_,"Picking Depth"),v=ce({},s.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(Kr.Color0,p),t.attachRenderTargetID(Kr.DepthStencil,E),t.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)})),t.post((function(t){var i=t.getRenderTargetTexture(Kr.Color0),o=n.createReadback();v&&v.enabled?s.setViewOffset(v.fullWidth,v.fullHeight,v.offsetX,v.offsetY,v.width,v.height):s.clearViewOffset(),s.setEnableUpdate(!0),o.readTexture(i,0,0,l,f,new Uint8Array(l*f*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 h=r.renderHelper.pushTemplateRenderInst();h.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),h.setMegaStateFlags(Ft({depthWrite:!0},{rgbBlendMode:Te.Add,rgbBlendSrcFactor:ye.One,rgbBlendDstFactor:ye.Zero,alphaBlendMode:Te.Add,alphaBlendSrcFactor:ye.One,alphaBlendDstFactor:ye.Zero}));var d=r.context.config,_=d.width,m=d.height,g=r.context.contextService.getDPR();s.setEnableUpdate(!1),s.setViewOffset(_*g,m*g,u,c,l,f),h.setUniforms(0,[{name:bn.PROJECTION_MATRIX,value:s.getPerspective()},{name:bn.VIEW_MATRIX,value:s.getViewTransform()},{name:bn.CAMERA_POSITION,value:s.getPosition()},{name:bn.DEVICE_PIXEL_RATIO,value:r.context.contextService.getDPR()},{name:bn.VIEWPORT,value:[_,m]},{name:bn.IS_ORTHO,value:s.isOrtho()?1:0},{name:bn.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}();Un.tag="WebGLPicker";var wn,Gn=.005,kn=1,Vn=function(){function e(){this.id=kn++,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 Wn(e,t,r){var n=e.createBuffer({viewOrSize:gt(r.byteLength,4)/4,usage:t,hint:Ne.Static});return n.setSubData(0,new Uint8Array(r)),n}!function(e){e.CHANGED="changed"}(wn||(wn={}));var Xn,Hn=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=Oe.Triangles,n.vertexBuffers=[],n.vertices=[],n.indexBuffer=void 0,n.indices=void 0,n.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:We.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}le(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=Wn(this.device,Ie.INDEX|Ie.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=Wn(this.device,Ie.VERTEX|Ie.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(wn.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}(C);!function(e){e.CHANGED="changed"}(Xn||(Xn={}));var Yn=function(e){function t(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=Pt(Lt),o=i.cullMode,a=i.depthCompare,s=i.depthWrite,u=i.stencilCompare,c=i.stencilWrite,l=i.stencilPassOp,f=i.frontFace,h=i.polygonOffset,d=i.attachmentsState;return n.device=t,n.props=ce({cullMode:o,depthTest:!0,depthCompare:a,depthWrite:s,stencilCompare:u,stencilWrite:c,stencilPassOp:l,frontFace:f,polygonOffset:h,attachmentsState:d,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}le(t,e);var r=t.prototype;return r.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=Nr(this.props.fragmentShader)},r.setUniforms=function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(Pe.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),g(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()},r.dispatchMutationEvent=function(){this.emit(Xn.CHANGED)},ue(t,[{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:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=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())}}]),t}(C),Kn=function(e){function t(t,r){var n;return(n=e.call(this,t,ce({},r))||this).defines=ce({},n.defines,{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return le(t,e),t}(Yn);function jn(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function zn(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var qn,Zn,Qn=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){return void 0!==e[1]})))},$n=1,Jn="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"}(qn||(qn={})),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"}(Zn||(Zn={}));var ei,ti,ri=function(){function e(e,t,r){this.renderHelper=void 0,this.texturePool=void 0,this.lightPool=void 0,this.id=$n++,this.renderer=void 0,this.index=-1,this.context=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 Dr,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1,this.renderHelper=e,this.texturePool=t,this.lightPool=r}var r=e.prototype;return r.init=function(e){this.inited||(this.renderer.beforeInitMesh(this),this.context=e,this.material=new Kn(this.context.device),this.material.defines=ce({},jn(Zn),this.material.defines),this.geometry=new Hn(this.context.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(wn.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},r.observeMaterialChanged=function(){var e=this;this.material.on(Xn.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},r.shouldMergeColor=function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return i instanceof t.CSSRGB&&o instanceof t.CSSRGB||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n]))},r.shouldMerge=function(e,t){return!this.instance||(this.instance.nodeName===e.nodeName||this.instance.nodeName===e.renderable.proxyNodeName||this.instance.renderable.proxyNodeName===e.nodeName||this.instance.renderable.proxyNodeName===e.renderable.proxyNodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))},r.createGeometry=function(e){var r=this,n=c(),i=c(),o=[],a=[],s=[],u=[];e.forEach((function(e){var c,f=e.parsedStyle,h=f.fill,p=f.stroke,_=f.opacity,E=f.fillOpacity,v=f.strokeOpacity,m=f.lineWidth,g=f.anchor,R=f.visibility,y=f.increasedLineWidthForHitTesting,T=[0,0,0,0];h instanceof t.CSSRGB&&(T=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]);var A=[0,0,0,0];p instanceof t.CSSRGB&&(A=[Number(p.r)/255,Number(p.g)/255,Number(p.b)/255,Number(p.alpha)]),r.clipPathTarget?(l(n,e.getLocalTransform()),T=[1,1,1,1],d(n,r.clipPathTarget.getWorldTransform(),n)):l(n,e.getWorldTransform()),d(i,r.context.camera.getViewTransform(),n);var S=e.isInteractive()&&(null===(c=e.renderable3D)||void 0===c?void 0:c.encodedPickingColor)||[0,0,0];o.push.apply(o,n),a.push.apply(a,T.concat(A)),s.push(_,E,v,m,"visible"===R?1:0,g[0],g[1],y||0),u.push.apply(u,S.concat([e.sortable.renderOrder*Gn]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:qn.MODEL_MATRIX,byteStride:64,frequency:xe.PerInstance,attributes:[{format:We.F32_RGBA,bufferByteOffset:0,location:Zn.MODEL_MATRIX0,divisor:1},{format:We.F32_RGBA,bufferByteOffset:16,location:Zn.MODEL_MATRIX1,divisor:1},{format:We.F32_RGBA,bufferByteOffset:32,location:Zn.MODEL_MATRIX2,divisor:1},{format:We.F32_RGBA,bufferByteOffset:48,location:Zn.MODEL_MATRIX3,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:qn.FILL_STROKE,byteStride:32,frequency:xe.PerInstance,attributes:[{format:We.F32_RGBA,bufferByteOffset:0,location:Zn.COLOR,divisor:1},{format:We.F32_RGBA,bufferByteOffset:16,location:Zn.STROKE_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:qn.PACKED_STYLE,byteStride:32,frequency:xe.PerInstance,attributes:[{format:We.F32_RGBA,bufferByteOffset:0,location:Zn.PACKED_STYLE1,divisor:1},{format:We.F32_RGBA,bufferByteOffset:16,location:Zn.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:qn.PICKING_COLOR,byteStride:16,frequency:xe.PerInstance,attributes:[{format:We.F32_RGBA,bufferByteOffset:0,location:Zn.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=ce({},this.material.defines);if(this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=ce({},this.material.defines,this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=me.Always,this.material.stencilPassOp=Be.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=me.Equal,this.material.stencilPassOp=Be.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 Nn;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:Ae.Clamp,wrapT:Ae.Clamp,minFilter:Se.Point,magFilter:Se.Bilinear,mipFilter:Ce.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}(zn(a,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=ce({},this.material.defines,jn(Zn)),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=Mr(this.context.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),c=this.renderHelper.getCache().createProgramSimple(this.programDescriptorSimpleWithOrig),l=!!this.geometry.indexBuffer;this.inputStateDirty&&(this.inputState&&this.inputState.destroy(),this.inputState=this.context.device.createInputState(u,this.geometry.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),l?{buffer:this.geometry.indexBuffer,byteOffset:0}:null,c),this.inputStateDirty=!1),e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(c),e.setInputLayoutAndState(u,this.inputState),this.renderer.beforeUploadUBO(e,this,this.index),this.uploadUBO(e),l?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=on(zr.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(qn.FILL_STROKE,Zn.COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===Jn}));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 f=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor;f.push(t.opacity,t.fillOpacity,t.strokeOpacity,t.lineWidth,"visible"===t.visibility?1:0,r[0],r[1],t.increasedLineWidthForHitTesting||0)})),this.geometry.updateVertexBuffer(qn.PACKED_STYLE,Zn.PACKED_STYLE1,r,new Uint8Array(new Float32Array(f).buffer))}else if("modelMatrix"===n){var h=[];e.forEach((function(e){var t=l(c(),e.getWorldTransform());h.push.apply(h,t)})),this.geometry.updateVertexBuffer(qn.MODEL_MATRIX,Zn.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(h).buffer))}else if("pointerEvents"===n){var d=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];d.push.apply(d,r.concat([e.sortable.renderOrder*Gn]))})),this.geometry.updateVertexBuffer(qn.PICKING_COLOR,Zn.PICKING_COLOR,r,new Uint8Array(new Float32Array(d).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(qn.PICKING_COLOR,Zn.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(i,[t*Gn])).buffer))},r.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=qn.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],c=1;e.vertices.length>c;c++)for(var l=e.inputLayoutDescriptor.vertexBufferDescriptors[c].byteStride/4,f=0;l>f;f++)e.vertices[c][o*l+f]=n[c][u*l+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=qn.PICKING_COLOR+1;e.vertexBuffers.length>d;d++)h(d);for(var p=new Float32Array(3*r),_=0;r>_;)for(var E=0;3>E;E++){p[3*a[_++]+E]=1}e.setVertexBuffer({bufferIndex:qn.BARYCENTRIC,byteStride:12,frequency:xe.PerVertex,attributes:[{format:We.F32_RGB,bufferByteOffset:0,location:Number(Zn.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 c=t.parseColor(n.wireframeColor);u.push({name:"u_WireframeLineColor",value:[Number(c.r)/255,Number(c.g)/255,Number(c.b)/255]}),u.push({name:"u_WireframeLineWidth",value:n.wireframeLineWidth})}if(a&&this.uploadFog(u,o),this.uploadMaterial(u,n),s){var l={};i.forEach((function(e){l[e.define]||(l[e.define]=-1),l[e.define]++,e.uploadUBO(u,l[e.define])}))}u.sort((function(e,t){return r.material.uniformNames.indexOf(e.name)-r.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,u);var f=n.blendEquation,h=n.blendEquationAlpha,d=n.blendSrc,p=n.blendDst,_=n.blendSrcAlpha,E=n.blendDstAlpha,v=Qn({blendConstant:n.blendConstant,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}),m=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(ce({attachmentsState:[{channelWriteMask:this.material.stencilWrite?Le.None:Le.AllChannels,rgbBlendState:ce({},m.rgbBlendState,Qn({blendMode:f,blendSrcFactor:d,blendDstFactor:p})),alphaBlendState:ce({},m.alphaBlendState,Qn({blendMode:h,blendSrcFactor:_,blendDstFactor:E}))}]},v)),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 c=[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:c})}},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,n=this,i=e[0],o=i.nodeName===t.Shape.LINE?i.parsedStyle.stroke:i.parsedStyle.fill;if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,qe(We.U8_RGBA_NORM,1,1,1));if(a){var s=new Nn;return s.name=Jn,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({wrapS:Ae.Repeat,wrapT:Ae.Repeat,minFilter:Se.Point,magFilter:Se.Bilinear,mipFilter:Ce.Linear,minLOD:0,maxLOD:0}),s}}return null},ue(e,[{key:"instance",get:function(){return this.objects[0]}}]),e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(ei||(ei={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(ti||(ti={}));var ni,ii,oi=[t.Shape.CIRCLE,t.Shape.ELLIPSE],ai=function(e){function r(){return e.apply(this,arguments)||this}le(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.parsedStyle)&&!this.needDrawStrokeSeparately(this.instance.parsedStyle)&&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.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=ce({},this.material.defines,jn(ti))},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,c=r.shouldOmitStroke(a.parsedStyle),l=r.getSize(e.parsedStyle,a.nodeName);i.push.apply(i,l.concat([oi.indexOf(a.nodeName),u||0,c?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:qn.POSITION,byteStride:16,frequency:xe.PerVertex,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:Zn.POSITION},{format:We.F32_RG,bufferByteOffset:8,location:Zn.UV}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:ei.PACKED_STYLE,byteStride:24,frequency:xe.PerInstance,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:ti.SIZE,divisor:1},{format:We.F32_RGBA,bufferByteOffset:8,location:ti.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([oi.indexOf(e.nodeName),e.parsedStyle.radius||0,t?1:0,0]))})),this.geometry.updateVertexBuffer(ei.PACKED_STYLE,ti.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,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}return n},n.shouldOmitStroke=function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(o||1>n)},n.needDrawStrokeSeparately=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}));return o&&n>0&&(a||1>i)},r}(ri),si=[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"}(ni||(ni={})),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 ui={butt:1,round:2,square:3},ci=function(e){function r(){return e.apply(this,arguments)||this}le(r,e);var n=r.prototype;return n.shouldMerge=function(t,r){var n=e.prototype.shouldMerge.call(this,t,r);return!!n},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=ce({},this.material.defines,jn(ii))},n.createGeometry=function(r){var n=this;e.prototype.createGeometry.call(this,r);var i=[],o=[],a=[],s=[],u=0;r.forEach((function(e){var r,c;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,c=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var l=e.parsedStyle,f=l.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,defX:l.defX,defY:l.defY,lineCap:l.lineCap,lineDash:l.lineDash,lineDashOffset:l.lineDashOffset,isBillboard:!0,markerStart:l.markerStart,markerEnd:l.markerEnd,markerStartOffset:l.markerStartOffset,markerEndOffset:l.markerEndOffset},c=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){var h=e.parsedStyle,d=h.path.absolutePath;r={x1:d[0][1],y1:d[0][2],x2:d[1][1],y2:d[1][2],z1:0,z2:0,defX:h.defX,defY:h.defY,lineCap:h.lineCap,lineDash:h.lineDash,lineDashOffset:h.lineDashOffset,isBillboard:!1,markerStart:h.markerStart,markerEnd:h.markerEnd,markerStartOffset:h.markerStartOffset,markerEndOffset:h.markerEndOffset},c=e.getTotalLength()}var p=r.x1,_=r.y1,E=r.x2,v=r.y2,m=r.z1,g=r.z2,R=r.defX,y=r.defY,T=r.lineCap,A=r.isBillboard,S=n.calcOffset(r),C=S.startOffsetX,O=S.startOffsetY,I=S.endOffsetX,N=S.endOffsetY,x=n.calcDash(r,c),P=x.dashOffset,M=x.dashSegmentPercent,D=x.dashRatioInEachSegment;o.push(ui[T]),a.push(P,M,D,A?1:0),i.push(p-R+C,_-y+O,m,E-R+I,v-y+N,g),s.push(0+u,2+u,1+u,0+u,3+u,2+u),u+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:qn.POSITION,byteStride:20,frequency:xe.PerInstance,attributes:[{format:We.F32_RGB,bufferByteOffset:0,location:ii.POSITION,divisor:0},{format:We.F32_RG,bufferByteOffset:12,location:ii.UV,divisor:0}],data:new Float32Array(si)}),this.geometry.setVertexBuffer({bufferIndex:ni.POINT,byteStride:24,frequency:xe.PerInstance,attributes:[{format:We.F32_RGB,bufferByteOffset:0,location:ii.POINTA,divisor:1},{format:We.F32_RGB,bufferByteOffset:12,location:ii.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ni.CAP,byteStride:4,frequency:xe.PerInstance,attributes:[{format:We.F32_R,bufferByteOffset:0,location:ii.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:ni.DASH,byteStride:16,frequency:xe.PerInstance,attributes:[{format:We.F32_RGBA,bufferByteOffset:0,location:ii.DASH,divisor:1}],data:new Float32Array(a)})},n.updateAttribute=function(r,n,i,o){var a=this;if(e.prototype.updateAttribute.call(this,r,n,i,o),this.updateBatchedAttribute(r,n,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"path"===i){var s=[];r.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE&&e.renderable.proxyNodeName===t.Shape.LINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,defX:n.defX,defY:n.defY,lineCap:n.lineCap,isBillboard:!0,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH&&e.renderable.proxyNodeName===t.Shape.LINE){var o=e.parsedStyle,u=o.path.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,defX:o.defX,defY:o.defY,lineCap:o.lineCap,isBillboard:!0,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var c=r.x1,l=r.y1,f=r.x2,h=r.y2,d=r.z1,p=r.z2,_=r.defX,E=r.defY,v=a.calcOffset(r);s.push(c-_+v.startOffsetX,l-E+v.startOffsetY,d,f-_+v.endOffsetX,h-E+v.endOffsetY,p)})),this.geometry.updateVertexBuffer(ni.POINT,ii.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i){var u=[];r.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(ni.DASH,ii.DASH,n,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var c=[];r.forEach((function(e){c.push(ui[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(ni.CAP,ii.CAP,n,new Uint8Array(new Float32Array(c).buffer))}},n.calcOffset=function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,c=e.markerEndOffset,l=0,f=0,h=0,d=0,p=0;return a&&a instanceof t.DisplayObject&&u&&(l=Math.cos(p=Math.atan2(o-n,i-r))*(u||0),f=Math.sin(p)*(u||0)),s&&s instanceof t.DisplayObject&&c&&(h=Math.cos(p=Math.atan2(n-o,r-i))*(c||0),d=Math.sin(p)*(c||0)),{startOffsetX:l,startOffsetY:f,endOffsetX:h,endOffsetY:d}},n.calcDash=function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}},r}(ri);function li(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}var fi=function(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}};function hi(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function di(e,t,r,n,i,o,a){var s=hi(e,r,i,a),u=hi(t,n,o,a),c=fi(e,t,r,n,a),l=fi(r,n,i,o,a);return[[e,t,c.x,c.y,s,u],[s,u,l.x,l.y,i,o]]}function pi(e,t,r,n,i,o,a){if(0===a)return(li(e,t,r,n)+li(r,n,i,o)+li(e,t,i,o))/2;var s=di(e,t,r,n,i,o,.5),u=s[0],c=s[1];return u.push(a-1),c.push(a-1),pi.apply(void 0,u)+pi.apply(void 0,c)}var _i=function(e,t,r,n,i,o){return pi(e,t,r,n,i,o,3)};function Ei(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 vi(e,t,r,n,i,o,a,s,u){var c=Ei(e,r,i,a,u),l=Ei(t,n,o,s,u),f=fi(e,t,r,n,u),h=fi(r,n,i,o,u),d=fi(i,o,a,s,u),p=fi(f.x,f.y,h.x,h.y,u),_=fi(h.x,h.y,d.x,d.y,u);return[[e,t,f.x,f.y,p.x,p.y,c,l],[c,l,_.x,_.y,d.x,d.y,a,s]]}function mi(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+=li(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var c=vi(e,t,r,n,i,o,a,s,.5),l=[].concat(c[0],[u-1]),f=[].concat(c[1],[u-1]);return mi.apply(void 0,l)+mi.apply(void 0,f)}var gi,Ri=function(e,t,r,n,i,o,a,s){return mi(e,t,r,n,i,o,a,s,3)};function yi(e,t,r,n,i){for(var o=i[i.length-2],a=i[i.length-1],s=_i(o,a,e,t,r,n),u=A(s/10,8,100),c=0,l=0,f=1;u>=f;++f){var h=f/u;i.push((c=o+(e-o)*h)+(e+(r-e)*h-c)*h,(l=a+(t-a)*h)+(t+(n-t)*h-l)*h)}}function Ti(e,t,r,n,i,o,a){var s=a[a.length-2],u=a[a.length-1];a.length-=2;var c=Ri(s,u,e,t,r,n,i,o),l=A(c/10,8,100),f=0,h=0,d=0,p=0,_=0;a.push(s,u);for(var E=1,v=0;l>=E;++E)a.push((d=(h=(f=1-(v=E/l))*f)*f)*s+3*h*v*e+3*f*(p=v*v)*r+(_=p*v)*i,d*u+3*h*v*t+3*f*p*n+_*o)}!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"}(gi||(gi={}));var Ai,Si,Ci;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(Ai||(Ai={})),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"}(Si||(Si={})),function(e){e.MODEL_MATRIX="u_ModelMatrix",e.FILL_COLOR="u_FillColor",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"}(Ci||(Ci={}));var Oi=function(e){function r(){return e.apply(this,arguments)||this}le(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,f=r.lineWidth,_=r.increasedLineWidthForHitTesting,E=r.anchor,v=r.lineDash,m=r.lineDashOffset,g=r.visibility;if("lineJoin"===i||"lineCap"===i||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===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 R,y=[0,0,0,0];n instanceof t.CSSRGB&&(y=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(((R={})[Ci.STROKE_COLOR]=y,R))}else if("opacity"===i){var T;a.material.setUniforms(((T={})[Ci.OPACITY]=s,T))}else if("fillOpacity"===i){var A;a.material.setUniforms(((A={})[Ci.FILL_OPACITY]=u,A))}else if("strokeOpacity"===i){var S;a.material.setUniforms(((S={})[Ci.STROKE_OPACITY]=l,S))}else if("lineWidth"===i){var C;a.material.setUniforms(((C={})[Ci.STROKE_WIDTH]=f,C))}else if("increasedLineWidthForHitTesting"===i){var O;a.material.setUniforms(((O={})[Ci.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=_||0,O))}else if("anchor"===i||"modelMatrix"===i){var I,N=0,x=0,P=e.getGeometryBounds();if(P){var M=P.halfExtents;N=-M[0]*E[0]*2,x=-M[1]*E[1]*2}var D=c();d(D,e.getWorldTransform(),h(D,p(N,x,0))),a.material.setUniforms(((I={})[Ci.MODEL_MATRIX]=D,I))}else if("visibility"===i){var L;a.material.setUniforms(((L={})[Ci.VISIBLE]="visible"===g?1:0,L))}else if("lineDash"===i){var B;a.material.setUniforms(((B={})[Ci.DASH]=v[0]||0,B[Ci.GAP]=v[1]||0,B))}else if("lineDashOffset"===i){var b;a.material.setUniforms(((b={})[Ci.DASH_OFFSET]=m||0,b))}else if("pointerEvents"===i){var F,U,w=o&&e.isInteractive()&&(null===(F=e.renderable3D)||void 0===F?void 0:F.encodedPickingColor)||[0,0,0];a.material.setUniforms(((U={})[Ci.PICKING_COLOR]=w,U))}}))},n.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[Ci.Z_INDEX]=t*Gn,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_FillColor;\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_FillColor;\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 scalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n float travel = mod(v_Travel + u_Gap * scalingFactor * 0.5 + u_DashOffset, u_Dash * scalingFactor + u_Gap * scalingFactor) - (u_Gap * scalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * scalingFactor + 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=ce({},this.material.defines,jn(Si));var i=e[0],o=i.parsedStyle,a=o.fill,s=o.stroke,u=o.opacity,l=o.fillOpacity,f=o.strokeOpacity,_=o.lineWidth,E=o.increasedLineWidthForHitTesting,v=o.anchor,m=o.lineDash,g=o.lineDashOffset,R=o.visibility,y=[0,0,0,0];a instanceof t.CSSRGB&&(y=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var T=[0,0,0,0];s instanceof t.CSSRGB&&(T=[Number(s.r)/255,Number(s.g)/255,Number(s.b)/255,Number(s.alpha)]);var A=i.isInteractive()&&(null===(r=i.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=0,C=0,O=i.getGeometryBounds();if(O){var I=O.halfExtents;S=-I[0]*v[0]*2,C=-I[1]*v[1]*2}var N=c();d(N,i.getWorldTransform(),h(N,p(S,C,0))),this.material.setUniforms(((n={})[Ci.MODEL_MATRIX]=N,n[Ci.FILL_COLOR]=y,n[Ci.STROKE_COLOR]=T,n[Ci.STROKE_WIDTH]=_,n[Ci.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=E||0,n[Ci.OPACITY]=u,n[Ci.FILL_OPACITY]=l,n[Ci.STROKE_OPACITY]=f,n[Ci.EXPAND]=1,n[Ci.MITER_LIMIT]=5,n[Ci.SCALE_MODE]=1,n[Ci.ALIGNMENT]=.5,n[Ci.PICKING_COLOR]=A,n[Ci.DASH]=m&&m[0]||0,n[Ci.GAP]=m&&m[1]||0,n[Ci.DASH_OFFSET]=g||0,n[Ci.VISIBLE]="visible"===R?1:0,n[Ci.Z_INDEX]=i.sortable.renderOrder*Gn,n)),this.material.cullMode=Re.None},n.createGeometry=function(e){var t=Ii(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:Ai.PACKED,byteStride:48,frequency:xe.PerInstance,attributes:[{format:We.F32_RG,bufferByteOffset:0,byteStride:12,location:Si.PREV,divisor:1},{format:We.F32_RG,bufferByteOffset:12,byteStride:12,location:Si.POINT1,divisor:1},{format:We.F32_R,bufferByteOffset:20,byteStride:12,location:Si.VERTEX_JOINT,divisor:1},{format:We.F32_RG,bufferByteOffset:24,byteStride:12,location:Si.POINT2,divisor:1},{format:We.F32_RG,bufferByteOffset:36,byteStride:12,location:Si.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:Ai.VERTEX_NUM,byteStride:4,frequency:xe.PerInstance,attributes:[{format:We.F32_R,bufferByteOffset:0,byteStride:4,location:Si.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Ai.TRAVEL,byteStride:4,frequency:xe.PerInstance,attributes:[{format:We.F32_R,bufferByteOffset:0,byteStride:4,location:Si.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}(ri);function Ii(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=e.parsedStyle,f=l.markerStart,h=l.markerEnd,d=l.markerStartOffset,p=l.markerEndOffset,_=[],E=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var v=e.parsedStyle.points.points,g=v.length,R=0,y=0,T=0,A=0,S=0;if(f&&f instanceof t.DisplayObject&&d&&(R=Math.cos(S=Math.atan2(v[1][1]-v[0][1],v[1][0]-v[0][0]))*(d||0),y=Math.sin(S)*(d||0)),h&&h instanceof t.DisplayObject&&p&&(T=Math.cos(S=Math.atan2(v[g-2][1]-v[g-1][1],v[g-2][0]-v[g-1][0]))*(p||0),A=Math.sin(S)*(p||0)),_[0]=v.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=R,i=y):r===g-1&&(n=T,i=A),e.push(t[0]-s+n,t[1]-u+i),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return E=O(_[0],[],2),{pointsBuffer:_[0],travelBuffer:[],triangles:E,instancedCount:Math.round(_[0].length/2)};var C;_[0].push(_[0][0],_[0][1]),(C=_[0]).push.apply(C,Ni(_[0][0],_[0][1],_[0][2],_[0][3]))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var I;if(e.nodeName!==t.Shape.PATH){if(I=t.parsePath(t.convertToPath(e,function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(c())),e),s=I.rect.x,u=I.rect.y,e.nodeName===t.Shape.RECT){var N=e.parsedStyle;0>N.width&&(s+=I.rect.width),0>N.height&&(u+=I.rect.height)}}else I=e.parsedStyle.path;var x=I.absolutePath,P=I.segments,M=0,D=0,L=0,B=0,b=0;if(f&&f instanceof t.DisplayObject&&d){var F=f.parentNode.getStartTangent(),U=F[0],w=F[1];M=Math.cos(b=Math.atan2(U[1]-w[1],U[0]-w[0]))*(d||0),D=Math.sin(b)*(d||0)}if(h&&h instanceof t.DisplayObject&&p){var G=h.parentNode.getEndTangent(),k=G[0],V=G[1];L=Math.cos(b=Math.atan2(k[1]-V[1],k[0]-V[0]))*(p||0),B=Math.sin(b)*(p||0)}var W=-1,X=-1;if(x.forEach((function(r,n){var i=r[0],o=r.slice(1),a=x[n+1],c=0===n&&(0!==M||0!==D),l=(n===x.length-1||a&&("M"===a[0]||"Z"===a[0]))&&0!==L&&0!==B;if("M"===i)X++,_[X]=[],W=_[X].length,c?_[X].push(o[0]-s+M,o[1]-u+D,o[0]-s,o[1]-u):_[X].push(o[0]-s,o[1]-u);else if("L"===i)l?_[X].push(o[0]-s+L,o[1]-u+B):_[X].push(o[0]-s,o[1]-u);else if("Q"===i)yi(o[0]-s,o[1]-u,o[2]-s,o[3]-u,_[X]),l&&_[X].push(o[2]-s+L,o[3]-u+B);else if("A"===i){for(var f=P[n].prePoint,h=m(f[0],f[1],o[0],o[1],o[2],o[3],o[4],o[5],o[6],void 0),d=0;h.length>d;d+=6)Ti(h[d]-s,h[d+1]-u,h[d+2]-s,h[d+3]-u,h[d+4]-s,h[d+5]-u,_[X]);l&&_[X].push(o[5]-s+L,o[6]-u+B)}else if("C"===i)Ti(o[0]-s,o[1]-u,o[2]-s,o[3]-u,o[4]-s,o[5]-u,_[X]),l&&_[X].push(o[4]-s+L,o[5]-u+B);else if("Z"===i&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var p,E=1e-4;(Math.abs(_[X][_[X].length-2]-_[X][W])>E||Math.abs(_[X][_[X].length-1]-_[X][W+1])>E)&&_[X].push(_[X][W],_[X][W+1]),(p=_[X]).push.apply(p,Ni(_[X][W],_[X][W+1],_[X][W+2],_[X][W+3]))}})),r){var H=_.reduce((function(e,t){return e.push.apply(e,t),e}),[]);return{pointsBuffer:H,travelBuffer:[],triangles:E=O(H,[],2),instancedCount:Math.round(H.length/2)}}}var Y=function(e){var t;switch(e){case"bevel":t=gi.JOINT_BEVEL;break;case"round":t=gi.JOINT_ROUND;break;default:t=gi.JOINT_MITER}return t}(o),K=function(e){var t;switch(e){case"square":t=gi.CAP_SQUARE;break;case"round":t=gi.CAP_ROUND;break;default:t=gi.CAP_BUTT}return t}(i),j=K;return K===gi.CAP_ROUND&&(j=gi.JOINT_CAP_ROUND),K===gi.CAP_BUTT&&(j=gi.JOINT_CAP_BUTT),K===gi.CAP_SQUARE&&(j=gi.JOINT_CAP_SQUARE),_.map((function(e){for(var t=6,r=0,n=[],i=[],o=0;e.length>o;o+=2)o>1&&(r+=Math.sqrt(Math.pow(e[o]-e[o-2],2)+Math.pow(e[o+1]-e[o+1-2],2))),i.push(r),n[t++]=e[o],n[t++]=e[o+1],n[t]=Y,0==o&&K!==gi.CAP_ROUND&&(n[t]+=K),e.length>o+4?e.length>o+2||(n[t]=0):n[t]+=j-Y,t++;return n[t++]=e[e.length-4],n[t++]=e[e.length-3],n[t++]=0,n[0]=e[0],n[1]=e[1],n[2]=0,n[3]=e[2],n[4]=e[3],n[5]=K===gi.CAP_ROUND?K:0,{pointsBuffer:n,travelBuffer:i,triangles:E,instancedCount:Math.round(e.length/2)}})).reduce((function(e,t){var r,n;return(r=e.pointsBuffer).push.apply(r,t.pointsBuffer),(n=e.travelBuffer).push.apply(n,t.travelBuffer),e.instancedCount+=t.instancedCount,e}),{pointsBuffer:[],travelBuffer:[],triangles:E,instancedCount:0})}function Ni(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 xi=function(e){function r(){return e.apply(this,arguments)||this}le(r,e);var n=r.prototype;return n.shouldMerge=function(e,t){return!1},n.createGeometry=function(e){var t=e[0],r=Ii(t,!0),n=r.triangles,i=r.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:qn.POSITION,byteStride:8,frequency:xe.PerVertex,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:Zn.POSITION}],data:new Float32Array(i)});var o=t.getGeometryBounds().halfExtents,a=i.map((function(e,t){return e/o[t%2]/2}));this.geometry.setVertexBuffer({bufferIndex:qn.UV,byteStride:8,frequency:xe.PerVertex,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:Zn.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))},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_FillColor;\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#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n gl_Position = 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_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\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\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\n vec4 u_Color = u_FillColor;\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 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,f=o.visibility,_=[0,0,0,0];a instanceof t.CSSRGB&&(_=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var E=i.isInteractive()&&(null===(r=i.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],v=0,m=0,g=i.getGeometryBounds();if(g){var R=g.halfExtents;v=-R[0]*l[0]*2,m=-R[1]*l[1]*2}var y=c();d(y,i.getWorldTransform(),h(y,p(v,m,0))),this.material.setUniforms(((n={})[Ci.MODEL_MATRIX]=y,n[Ci.FILL_COLOR]=_,n[Ci.PICKING_COLOR]=E,n[Ci.OPACITY]=s,n[Ci.FILL_OPACITY]=u,n[Ci.VISIBLE]="visible"===f?1:0,n[Ci.Z_INDEX]=i.sortable.renderOrder*Gn,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,f=r.visibility;if("lineJoin"===i||"lineCap"===i||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===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)if(n instanceof t.CSSRGB){var _;a.material.setUniforms(((_={})[Ci.FILL_COLOR]=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)],_))}else{var E=a.textureMappings.findIndex((function(e){return e.name===Jn})),v=a.createFillGradientTextureMapping([a.instance]);0>E||a.textureMappings.splice(E,1,v),a.material.textureDirty=!0}else if("opacity"===i){var m;a.material.setUniforms(((m={})[Ci.OPACITY]=s,m))}else if("fillOpacity"===i){var g;a.material.setUniforms(((g={})[Ci.FILL_OPACITY]=u,g))}else if("anchor"===i||"modelMatrix"===i){var R,y=0,T=0,A=e.getGeometryBounds();if(A){var S=A.halfExtents;y=-S[0]*l[0]*2,T=-S[1]*l[1]*2}var C=c();d(C,e.getWorldTransform(),h(C,p(y,T,0))),a.material.setUniforms(((R={})[Ci.MODEL_MATRIX]=C,R))}else if("visibility"===i){var O;a.material.setUniforms(((O={})[Ci.VISIBLE]="visible"===f?1:0,O))}else if("pointerEvents"===i){var I,N,x=o&&e.isInteractive()&&(null===(I=e.renderable3D)||void 0===I?void 0:I.encodedPickingColor)||[0,0,0];a.material.setUniforms(((N={})[Ci.PICKING_COLOR]=x,N))}}))},n.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[Ci.Z_INDEX]=t*Gn,r))},r}(ri),Pi=function(e){function t(){return e.apply(this,arguments)||this}le(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=ce({},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.context.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,a.height),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:qn.POSITION,byteStride:8,frequency:xe.PerInstance,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:Zn.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:qn.UV,byteStride:8,frequency:xe.PerVertex,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:Zn.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,t.height)})),this.geometry.updateVertexBuffer(qn.POSITION,Zn.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:a})}},t}(ri);function Mi(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 Di(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 c=((r.y+u)*e.width+r.x)*o,l=((n.y+u)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[l+f]=a[c+f];return t}var Li=function(){function e(e,t){this.width=void 0,this.height=void 0,this.data=void 0,Mi(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=Mi({},{width:n,height:i},r);Di(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){Di(e,t,r,n,i,1)},e}();var Bi=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((c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height)r.push(l={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:l,metrics:c.metrics}}}var s=function(e){for(var t,r=0,n=0,i=_e(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,c=0,l=_e(e);!(a=l()).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,c=Math.max(c,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}}return{w:u,h:c,fill:r/(u*c)||0}}(r),u=new Li({width:s.w||1,height:s.h||1});for(var n in e){i=e[n];for(var a in i){var c,l;if((c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height)Li.copy(c.bitmap,u,{x:0,y:0},{x:(l=t[n][a].rect).x+1,y:l.y+1},c.bitmap)}}this.image=u,this.positions=t};var bi,Fi,Ui,wi=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=[],c=o,l=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:c,y:l,scale:1,fontStack:t}),c+=o.metrics.advance+i)}));for(var o=c-i,a=n;u.length>a;a++)u[a].x=u[a].x-f*o;c=0,l+=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 c=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]=ce({},this.glyphMap[e],c),this.glyphAtlas=new Bi(this.glyphMap);var l=this.glyphAtlas.image,f=l.width,h=l.height,d=l.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=o.createTexture(ce({},qe(We.ALPHA,f,h,1),{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([d],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 te({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,c=s.glyphHeight,l=s.glyphLeft,f=s.glyphTop,h=s.glyphAdvance;return{id:o,bitmap:new Li({width:s.width,height:s.height},s.data),metrics:{width:u,height:c,left:l,top:f-24+3,advance:h}}},e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(bi||(bi={})),function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(Fi||(Fi={})),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"}(Ui||(Ui={}));var Gi,ki,Vi,Wi=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=new wi,t}le(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.metrics.font===t.parsedStyle.metrics.font&&!["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(e){return i.parsedStyle[e]!==t.parsedStyle[e]}))},n.createGeometry=function(e){var t=this,r=this.instance.parsedStyle,n=r.textBaseline,i=r.letterSpacing,o=24/r.fontSize,a=[],s=[],u=[],c=0;e.forEach((function(e){var r=e.parsedStyle,l=r.metrics,f=l.font,h=l.lines,d=l.height,p=l.lineHeight,_=r.dx||0,E=r.dy||0,v=0;"middle"===n?v=-d/2:"bottom"===n?v=-d:"top"===n||"hanging"===n?v=0:"alphabetic"===n?v=.25*p-d:"ideographic"===n&&(v=-d);var m=t.glyphManager.getAtlas(),g=t.buildTextBuffers({object:e,lines:h,fontStack:f,lineHeight:o*p,offsetX:o*_,offsetY:o*(v+E),letterSpacing:o*i,glyphAtlas:m,indicesOffset:c}),R=g.indexBuffer,y=g.charUVOffsetBuffer;c=g.indicesOffset,u.push.apply(u,g.charPackedBuffer),s.push.apply(s,y),a.push.apply(a,R)})),this.geometry.vertexCount=a.length,this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.setVertexBuffer({bufferIndex:bi.INSTANCED,byteStride:144,frequency:xe.PerVertex,attributes:[{format:We.F32_RGBA,bufferByteOffset:0,location:Zn.MODEL_MATRIX0},{format:We.F32_RGBA,bufferByteOffset:16,location:Zn.MODEL_MATRIX1},{format:We.F32_RGBA,bufferByteOffset:32,location:Zn.MODEL_MATRIX2},{format:We.F32_RGBA,bufferByteOffset:48,location:Zn.MODEL_MATRIX3},{format:We.F32_RGBA,bufferByteOffset:64,location:Zn.COLOR},{format:We.F32_RGBA,bufferByteOffset:80,location:Zn.STROKE_COLOR},{format:We.F32_RGBA,bufferByteOffset:96,location:Zn.PACKED_STYLE1},{format:We.F32_RGBA,bufferByteOffset:112,location:Zn.PACKED_STYLE2},{format:We.F32_RGBA,bufferByteOffset:128,location:Zn.PICKING_COLOR}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:bi.TEX,byteStride:16,frequency:xe.PerVertex,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:Fi.TEX},{format:We.F32_RG,bufferByteOffset:8,location:Fi.OFFSET}],data:new Float32Array(s)})},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=Re.Back,this.material.defines=ce({},this.material.defines,jn(Fi));var r=this.instance.parsedStyle,n=r.fontSize,i=r.fontFamily,o=void 0===i?"":i,a=r.fontWeight,s=void 0===a?"":a,u=r.fontStyle,c=r.metrics.font,l=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(c,o,""+s,u,l,this.context.device);var f=this.glyphManager.getAtlasTexture(),h=this.glyphManager.getAtlas();this.context.device.setResourceName(f,"TextSDF Texture");var d=h.image,p=d.width,_=d.height;this.material.setUniforms(((t={})[Ui.SDF_MAP]=f,t[Ui.SDF_MAP_SIZE]=[p,_],t[Ui.FONT_SIZE]=n,t[Ui.GAMMA_SCALE]=1,t[Ui.STROKE_BLUR]=.2,t[Ui.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,f=e.offsetY,h=e.glyphAtlas,d=e.indicesOffset,p=n.parsedStyle,_=p.textAlign,E=p.fill,v=p.stroke,m=p.opacity,g=p.fillOpacity,R=p.strokeOpacity,y=p.lineWidth,T=p.visibility,A=[0,0,0,0];E instanceof t.CSSRGB&&(A=[Number(E.r)/255,Number(E.g)/255,Number(E.b)/255,Number(E.alpha)]);var S=[0,0,0,0];v instanceof t.CSSRGB&&(S=[Number(v.r)/255,Number(v.g)/255,Number(v.b)/255,Number(v.alpha)]);var C=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],O=l(c(),n.getWorldTransform()),I=[],N=[],x=[],P=d,M=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,c=[i.x+u,i.y],l=(a.metrics.left-4)*i.scale-u+c[0],f=(-a.metrics.top-4)*i.scale+c[1],h=l+s.w*i.scale,d=f+s.h*i.scale;r.push({tl:{x:l,y:f},tr:{x:h,y:f},bl:{x:l,y:d},br:{x:h,y:d},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,_,s,u,f),h.positions);return M.forEach((function(e){var t=[];t.push.apply(t,O);var r=[].concat(t,A,S,[m,g,R,y,"visible"===T?1:0,0,0,0],C,[n.sortable.renderOrder*Gn]);I.push.apply(I,r.concat(r,r,r)),N.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),N.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),N.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),N.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),x.push(0+P,2+P,1+P),x.push(2+P,0+P,3+P),P+=4})),{indexBuffer:x,charUVOffsetBuffer:N,charPackedBuffer:I,indicesOffset:P}},r}(ri),Xi=function(e){function r(){return e.apply(this,arguments)||this}le(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}(ri),Hi=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=[ai,Oi],t}le(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,c=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&o>0&&(1>a||c)},t}(Vn),Yi=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=[xi,Oi,ci],t}le(r,e);var n=r.prototype;return n.shouldSubmitRenderInst=function(e,r){var n=e.parsedStyle,i=n.fill,o=n.stroke,a=n.opacity,s=n.strokeOpacity,u=n.lineDash,c=n.lineWidth,l=e.nodeName,f=o&&!o.isNone,h=u&&u.length&&u.every((function(e){return 0!==e})),d=this.isLine(e);if(e.renderable.proxyNodeName=d?t.Shape.LINE:null,0===r&&(e.nodeName===t.Shape.POLYLINE||i.isNone))return!1;if(1===r){if(d||0===s||0===a||0===c||!f)return!1;if(l===t.Shape.CIRCLE||l===t.Shape.ELLIPSE)return h}return 2!==r||d},n.isLine=function(e){if(e.nodeName===t.Shape.PATH){var r=e.parsedStyle.path.absolutePath;if(2===r.length&&"M"===r[0][0]&&"L"===r[1][0])return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var n=e.parsedStyle.points.points,i=(n[1][0]-n[1][1])/(n[0][0]-n[0][1]),o=1;n.length-1>o;o++)if((n[o+1][0]-n[o+1][1])/(n[o][0]-n[o][1])!==i)return!1;return!0}return!1},r}(Vn),Ki=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=[Pi],t}return le(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Vn),ji=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=[Wi,Wi],t}le(t,e);var r=t.prototype;return r.shouldSubmitRenderInst=function(e,t){var r=e.parsedStyle;return!!(r.stroke&&r.lineWidth||0!==t)},r.beforeUploadUBO=function(e,t,r){var n;t.material.setUniforms(((n={})[Ui.HAS_STROKE]=1-t.index,n))},t}(Vn),zi=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=[ci],t}return le(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Vn),qi=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=[Xi],t}return le(t,e),t}(Vn),Zi=1,Qi=function(){function e(e,t,r,n){this.renderHelper=void 0,this.rendererFactory=void 0,this.texturePool=void 0,this.lightPool=void 0,this.context=void 0,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={},this.renderHelper=e,this.rendererFactory=t,this.texturePool=r,this.lightPool=n}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.context);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){this.context=e},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=new i(t.renderHelper,t.texturePool,t.lightPool)).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 c=a.shouldSubmitRenderInst(e,u),l=o.meshes.find((function(e){return e&&e.index===u&&e.constructor===s}));if(c!==!!l&&(l&&(l.objects.splice(l.objects.indexOf(e),1),l.geometryDirty=!0,0===l.objects.length&&i.meshes.splice(i.meshes.indexOf(l),1),o.meshes[o.meshes.indexOf(l)]=void 0),c&&((l=i.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))||((l=new s(i.renderHelper,i.texturePool,i.lightPool)).renderer=a,l.index=u,l.init(i.context),i.meshes.push(l)),l&&(l.objects.push(e),o.meshes[u]=l))),c&&l&&l.inited&&!l.geometryDirty){var f=l.objects.indexOf(e);if(n)e.parsedStyle[t]=r,l.updateAttribute([e],f,t,r);else{var h=l.id+t;i.pendingUpdatePatches[h]||(i.pendingUpdatePatches[h]={instance:l,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[h].objectIndices.indexOf(f)&&i.pendingUpdatePatches[h].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]=Zi++),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=function(){function e(e){this.context=void 0,this.textureCache={},this.context=e}var r=e.prototype;return r.getOrCreateTexture=function(e,r,n,i){var o,a=this,s="string"==typeof r?r:r.src||"";if(s&&this.textureCache[s])(o=this.textureCache[s]).emit(Pe.LOADED);else if(o=e.createTexture(ce({pixelFormat:We.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:Me.n2D,usage:De.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),s&&(this.textureCache[s]=o),T(r)){var u,c=this.context.config.createImage;c?u=c(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){a.textureCache[s].setImageData(u),a.textureCache[s].emit(Pe.LOADED),a.context.renderingService.dirtify(),i&&i(a.textureCache[s])},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else o.setImageData(r),o.emit(Pe.LOADED),this.context.renderingService.dirtify();return o},r.getOrCreateCanvas=function(){return t.runtime.offscreenCanvas.getOrCreateCanvas(this.context.config.offscreenCanvas)},r.getOrCreateGradient=function(e){var r=e.gradients,n=e.instance.getGeometryBounds().halfExtents,i=2*n[0]||1,o=2*n[1]||1,a=this.context.config.offscreenCanvas,s=t.runtime.offscreenCanvas.getOrCreateCanvas(a),u=t.runtime.offscreenCanvas.getOrCreateContext(a);s.width=i,s.height=o;var c=this.context.imagePool;r.forEach((function(e){var t=c.getOrCreateGradient(ce({type:e.type},e.value,{width:i,height:o}),u);u.fillStyle=t,u.fillRect(0,0,i,o)}))},r.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,c=2*u[0]||1,l=2*u[1]||1,f=this.context.config.offscreenCanvas,h=t.runtime.offscreenCanvas.getOrCreateCanvas(f),d=t.runtime.offscreenCanvas.getOrCreateContext(f);h.width=c,h.height=l;var p=(i=T(o)?this.context.imagePool.getImageSync(o,n):o)&&d.createPattern(i,a);if(s){var _=t.parsedTransformToMat4(t.parseTransform(s));p.setTransform({a:_[0],b:_[1],c:_[4],d:_[5],e:_[12],f:_[13]})}d.fillStyle=p,d.fillRect(0,0,c,l)},r.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}(),Ji="#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}",eo="#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}",to=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=Ji,t.frag=eo,t.features={},t}return le(t,e),t}(Dr),ro="#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}",no=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=Ji,t.frag=ro,t}return le(t,e),t}(Dr),io=St(1,(function(){return new Nn}));var oo=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).name="device-renderer",t}le(r,e);var n=r.prototype;return n.init=function(){var e;t.runtime.geometryUpdaterFactory[t.Shape.MESH]=new je;var r=new gn,n=new He,i=new $i(this.context),o=new ze,a=new Hi,s=new Yi,u=((e={})[t.Shape.CIRCLE]=a,e[t.Shape.ELLIPSE]=a,e[t.Shape.POLYLINE]=s,e[t.Shape.PATH]=s,e[t.Shape.POLYGON]=s,e[t.Shape.RECT]=s,e[t.Shape.IMAGE]=new Ki,e[t.Shape.LINE]=new zi,e[t.Shape.TEXT]=new ji,e[t.Shape.MESH]=new qi,e[t.Shape.GROUP]=void 0,e[t.Shape.HTML]=void 0,e),c=new Qi(r,u,i,n),l=new Fn(r,n,i,c);this.addRenderingPlugin(l),this.addRenderingPlugin(new Un(r,l,o,c))},n.destroy=function(){delete t.runtime.geometryUpdaterFactory[t.Shape.MESH]},n.getRenderGraphPlugin=function(){return this.plugins[0]},n.getDevice=function(){return this.getRenderGraphPlugin().getDevice()},n.loadTexture=function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)},n.toDataURL=function(e){return this.getRenderGraphPlugin().toDataURL(e)},r}(t.AbstractRendererPlugin),ao=Object.freeze({__proto__:null,get AntialiasingMode(){return Tn},Batch:Vn,get BlendFactor(){return ye},get BlendMode(){return Te},get BufferFrequencyHint(){return Ne},BufferGeometry:Hn,get BufferUsage(){return Ie},get ChannelWriteMask(){return Le},get ClipSpaceNearZ(){return Ue},get CompareMode(){return me},CopyProgram:to,get CullMode(){return Re},DeviceProgram:Dr,DynamicUniformBuffer:Lr,get Endianness(){return Ut},FILL_TEXTURE_MAPPING:Jn,FillMesh:xi,Fog:Bn,get FogType(){return Dn},get Format(){return We},get FormatCompFlags(){return ke},get FormatFlags(){return Ve},get FormatTypeFlags(){return Ge},get FrontFaceMode(){return ge},get GL(){return Xe},get GeometryEvent(){return wn},HashMap:wr,IdentityViewportCoords:qr,ImageMesh:Pi,Instanced:ri,InstancedLineMesh:ci,IsDepthReversed:pt,get JOINT_TYPE(){return gi},Light:Mn,LineMesh:Oi,Material:Yn,get MaterialEvent(){return Xn},Mesh:Ke,MeshMesh:Xi,get MipFilterMode(){return Ce},OpaqueBlack:ft,OpaqueWhite:dt,Plugin:oo,get PrimitiveTopology(){return Oe},get QueryPoolType(){return we},get RGAttachmentSlot(){return Kr},RenderCache:jr,RenderGraphPlugin:Fn,RenderHelper:gn,RenderInst:pn,get RenderInstExecutionOrder(){return dn},get RenderInstFlags(){return ln},RenderInstList:En,RenderInstManager:mn,Renderable3D:Ee,get RendererLayer(){return zr},get ResourceType(){return ve},SDFMesh:ai,get SamplerFormatKind(){return be},ShaderMaterial:Kn,SingleSampledTexture:$r,get StencilOp(){return Be},TemporalTexture:xn,get TexFilterMode(){return Se},TextMesh:Wi,get TextUniform(){return Ui},get TextureDimension(){return Me},get TextureEvent(){return Pe},TextureMapping:Nn,TexturePool:$i,get TextureUsage(){return De},TransparentBlack:lt,TransparentWhite:ht,UNIFORM_SETTERS:Cr,get Uniform(){return Ci},get VertexAttributeBufferIndex(){return qn},get VertexAttributeLocation(){return Zn},get VertexBufferFrequency(){return xe},get ViewportOrigin(){return Fe},get WrapMode(){return Ae},align:gt,alignNonPowerOfTwo:Rt,arrayCopy:kt,arrayEqual:Gt,assert:it,assertExists:ot,bezierCurveTo:Ti,bindingLayoutDescriptorCopy:ir,bindingLayoutDescriptorEqual:Xt,bindingLayoutSamplerDescriptorCopy:nr,bindingsDescriptorCopy:rr,bindingsDescriptorEquals:Ht,bisectRight:yt,bufferBindingCopy:tr,colorCopy:st,colorEqual:at,colorNewCopy:ut,colorNewFromRGBA:ct,compareDefines:zn,compareDepthValues:function(e,t,r,n){if(void 0===n&&(n=pt),(r=_t(r,n))===me.Less)return t>e;if(r===me.LessEqual)return t>=e;if(r===me.Greater)return e>t;if(r===me.GreaterEqual)return e>=t;throw Error("whoops")},copyAttachmentState:It,copyAttachmentStateFromSimple:Mt,copyMegaState:Pt,defaultBindingLayoutSamplerDescriptor:wt,defaultMegaState:Lt,definedProps:Qn,enumToObject:jn,fallbackUndefined:Et,fillArray:mt,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:hn,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:bt,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 tt(Je(e))*$e(e)},getFormatCompByteSize:rt,getFormatCompFlags:$e,getFormatCompFlagsComponentCount:Ze,getFormatComponentCount:function(e){return $e(e)},getFormatFlags:et,getFormatSamplerKind:nt,getFormatTypeFlags:Je,getFormatTypeFlagsByteSize:tt,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 fr},getUniformSetter:function(e,t,r){var n=Cr[r.type];if(!n)throw Error("Unknown GLSL uniform type "+r.type);return n().bind(null,e,t)},getUniforms:Nr,hashCodeNumberFinish:br,hashCodeNumberUpdate:Br,inputLayoutBufferDescriptorCopy:sr,inputLayoutBufferDescriptorEquals:Qt,inputLayoutDescriptorCopy:ur,inputLayoutDescriptorEquals:$t,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:Ct,makeAttachmentClearDescriptor:yn,makeBackbufferDescSimple:In,makeDepthKey:tn,makeFormat:Qe,makeMegaState:Bt,makeSortKey:function(e,t){return void 0===t&&(t=0),e&zr.TRANSLUCENT?sn(e):on(e,t)},makeSortKeyOpaque:on,makeSortKeyTranslucent:sn,makeStaticDataBuffer:Wn,makeTextureDescriptor2D:qe,nArray:St,nullHashFunc:Fr,nullify:vt,opaqueBlackFullClearRenderPassDescriptor:Sn,opaqueWhiteFullClearRenderPassDescriptor:Cn,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(hr);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 Ct(""+(t+r),4," ")+" "+e})).join("\n")},preprocessProgramObj_GLSL:Mr,preprocessProgram_GLSL:Pr,preprocessShader_GLSL:xr,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===Ue.NegativeOne?function(e){d(e,cn,e)}(e):t===Ue.Zero&&function(e){d(e,fn,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Kr.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(bt),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);hn(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new no,c=t.renderCache.createProgram(u);a.setProgram(c),Gi||((Gi=new Hn(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:xe.PerVertex,attributes:[{format:We.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),Gi.vertexCount=3,Vi=t.getCache().createInputLayout(Gi.inputLayoutDescriptor),ki=t.getDevice().createInputState(Vi,Gi.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,c)),i.exec((function(e,r){io[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(io),a.setInputLayoutAndState(Vi,ki),a.drawOnPass(t.renderCache,e)}))}))},quadCurveTo:yi,range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:_n,renderPipelineDescriptorCopy:or,renderPipelineDescriptorEquals:qt,reverseDepthForClearValue:function(e,t){return void 0===t&&(t=pt),t?1-e:e},reverseDepthForCompareMode:_t,reverseDepthForDepthOffset:function(e,t){return void 0===t&&(t=pt),t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e,t){void 0===t&&(t=pt),t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e,t){void 0===t&&(t=pt),t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:er,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:Jt,segmentInstanceGeometry:si,setAttachmentStateSimple:Ft,setBackbufferDescSimple:On,setBitFlagEnabled:At,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:xt,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=tn(t,n,r);return n?un(e,i):an(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?un(e,t):an(e,t)},setSortKeyLayer:rn,setSortKeyOpaqueDepth:an,setSortKeyProgramKey:nn,setSortKeyTranslucentDepth:un,spliceBisectRight:Tt,standardFullClearRenderPassDescriptor:An,updateBuffer:Ii,vertexAttributeDescriptorCopy:ar,vertexAttributeDescriptorEquals:Zt});function so(){so=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},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 c(e,t,r,i){var o=Object.create((t&&t.prototype instanceof h?t:h).prototype),a=new C(i||[]);return n(o,"_invoke",{value:y(e,r,a)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var E=Object.getPrototypeOf,v=E&&E(E(O([])));v&&v!==t&&r.call(v,o)&&(_=v);var m=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 R(e,t){function i(n,o,a,s){var u=l(e[n],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){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,s)}))}s(u.arg)}var o;n(this,"_invoke",{value: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 y(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=l(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)}}}function T(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(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 d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),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(m),e},e.awrap=function(e){return{__await:e}},g(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(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),u(m,s,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},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 uo(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 co(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){uo(o,n,i,a,s,"next",e)}function s(e){uo(o,n,i,a,s,"throw",e)}a(void 0)}))}}function lo(e,t){return lo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},lo(e,t)}var fo=function(){function e(){this.context=void 0}return e.prototype.apply=function(t){var r=this,n=t.renderingService,i=t.renderingContext;this.context=t;var o=i.root.ownerDocument.defaultView,a=function(e){n.hooks.pointerMove.call(e)},s=function(e){n.hooks.pointerUp.call(e)},u=function(e){n.hooks.pointerDown.call(e)},c=function(e){n.hooks.pointerOver.call(e)},l=function(e){n.hooks.pointerOut.call(e)},f=function(e){n.hooks.pointerCancel.call(e)},h=function(e){n.hooks.pointerWheel.call(e)},d=function(e){globalThis.document.addEventListener("pointermove",a,!0),e.addEventListener("pointerdown",u,!0),e.addEventListener("pointerleave",l,!0),e.addEventListener("pointerover",c,!0),globalThis.addEventListener("pointerup",s,!0)},p=function(e){e.addEventListener("touchstart",u,!0),e.addEventListener("touchend",s,!0),e.addEventListener("touchmove",a,!0),e.addEventListener("touchcancel",f,!0)},_=function(e){globalThis.document.addEventListener("mousemove",a,!0),e.addEventListener("mousedown",u,!0),e.addEventListener("mouseout",l,!0),e.addEventListener("mouseover",c,!0),globalThis.addEventListener("mouseup",s,!0)};n.hooks.init.tapPromise(e.tag,co(so().mark((function e(){var t;return so().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.context.contextService.getDomElement(),globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):o.supportsPointerEvents&&(t.style.touchAction="none"),o.supportsPointerEvents?d(t):_(t),o.supportsTouchEvents&&p(t),t.addEventListener("wheel",h,{passive:!0,capture:!0});case 5:case"end":return e.stop()}}),e)})))),n.hooks.destroy.tap(e.tag,(function(){var e=r.context.contextService.getDomElement();globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):o.supportsPointerEvents&&(e.style.touchAction=""),o.supportsPointerEvents?function(e){globalThis.document.removeEventListener("pointermove",a,!0),e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointerleave",l,!0),e.removeEventListener("pointerover",c,!0),globalThis.removeEventListener("pointerup",s,!0)}(e):function(e){globalThis.document.removeEventListener("mousemove",a,!0),e.removeEventListener("mousedown",u,!0),e.removeEventListener("mouseout",l,!0),e.removeEventListener("mouseover",c,!0),globalThis.removeEventListener("mouseup",s,!0)}(e),o.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",u,!0),e.removeEventListener("touchend",s,!0),e.removeEventListener("touchmove",a,!0),e.removeEventListener("touchcancel",f,!0)}(e),e.removeEventListener("wheel",h,!0)}))},e}();fo.tag="DOMInteraction";var ho=function(e){var t,r;function n(){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).name="dom-interaction",t}(t=n).prototype=Object.create((r=e).prototype),t.prototype.constructor=t,lo(t,r);var i=n.prototype;return i.init=function(){this.addRenderingPlugin(new fo)},i.destroy=function(){this.removeAllRenderingPlugins()},n}(t.AbstractRendererPlugin),po=Object.freeze({__proto__:null,Plugin:ho});function _o(){_o=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},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 c(e,t,r,i){var o=Object.create((t&&t.prototype instanceof h?t:h).prototype),a=new C(i||[]);return n(o,"_invoke",{value:y(e,r,a)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var E=Object.getPrototypeOf,v=E&&E(E(O([])));v&&v!==t&&r.call(v,o)&&(_=v);var m=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 R(e,t){function i(n,o,a,s){var u=l(e[n],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){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,s)}))}s(u.arg)}var o;n(this,"_invoke",{value: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 y(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=l(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)}}}function T(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(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 d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),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(m),e},e.awrap=function(e){return{__await:e}},g(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(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),u(m,s,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},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 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 mo(e,t){return mo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},mo(e,t)}var go=function(){function e(){this.context=void 0,this.$camera=void 0}var r=e.prototype;return r.joinTransformMatrix=function(e){return"matrix("+[e[0],e[1],e[4],e[5],e[12],e[13]].join(",")+")"},r.apply=function(r){var n=this,i=r.camera,o=r.renderingContext,a=r.renderingService,s=r.displayObjectPool;this.context=r;var u=o.root.ownerDocument.defaultView,c=function(e,t){t.style.transform=n.joinTransformMatrix(e.getWorldTransform())},l=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){n.$camera||(n.$camera=n.createCamera(i));var o=n.getOrCreateEl(r);n.$camera.appendChild(o);var a=r.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(e){o.style[e]=a[e]})),Object.keys(r.attributes).forEach((function(e){n.updateAttribute(e,r)})),c(r,o)}},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&n.$camera){var i=n.getOrCreateEl(r);i&&i.remove()}},h=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&n.updateAttribute(e.attrName,r)},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var i=n.getOrCreateEl(r);c(r,i)}},p=function(){if(n.$camera){var e=n.context.config,t=e.height;n.$camera.style.width=(e.width||0)+"px",n.$camera.style.height=(t||0)+"px"}};a.hooks.init.tapPromise(e.tag,vo(_o().mark((function e(){return _o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s.getHTMLs().length&&(n.$camera=n.createCamera(i)),u.addEventListener(t.CanvasEvent.RESIZE,p),u.addEventListener(t.ElementEvent.MOUNTED,l),u.addEventListener(t.ElementEvent.UNMOUNTED,f),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,d);case 6:case"end":return e.stop()}}),e)})))),a.hooks.endFrame.tap(e.tag,(function(){n.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(n.$camera.style.transform=n.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(e.tag,(function(){n.$camera&&n.$camera.remove(),u.removeEventListener(t.CanvasEvent.RESIZE,p),u.removeEventListener(t.ElementEvent.MOUNTED,l),u.removeEventListener(t.ElementEvent.UNMOUNTED,f),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,d)}))},r.getId=function(e){return e.id||"g-html-"+e.entity},r.createCamera=function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",u=a.querySelector("#"+s);if(!u){var c=(r||document).createElement("div");u=c,c.id=s,c.style.position="absolute",c.style.left=(o.offsetLeft||0)+"px",c.style.top=(o.offsetTop||0)+"px",c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.overflow="hidden",c.style.pointerEvents="none",c.style.width=(n||0)+"px",c.style.height=(i||0)+"px",a.appendChild(c)}return u}return null},r.getOrCreateEl=function(e){var t=this.context.config.document,r=this.getId(e),n=this.$camera.querySelector("#"+r);return n||(n=(t||document).createElement("div"),e.parsedStyle.$el=n,n.id=r,e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(e.getWorldTransform())),n},r.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;T(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]=o[0].value+" "+o[1].value;break;case"width":var a=r.computedStyleMap().get("width");n.style.width=""+a;break;case"height":var s=r.computedStyleMap().get("height");n.style.height=""+s;break;case"zIndex":n.style["z-index"]=""+r.parsedStyle.zIndex;break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents;break;case"opacity":n.style.opacity=""+r.parsedStyle.opacity;break;case"fill":var u=r.parsedStyle.fill,c="";u instanceof t.CSSRGB?c=u.isNone?"transparent":r.getAttribute("fill"):Array.isArray(u)?c=r.getAttribute("fill"):t.isPattern(u),n.style.background=c;break;case"stroke":var l=r.parsedStyle.stroke,f="";l instanceof t.CSSRGB?f=l.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(l)?f=r.getAttribute("stroke"):t.isPattern(l),n.style["border-color"]=f,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]=(r.parsedStyle.lineWidth||0)+"px";break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter}},e}();go.tag="HTMLRendering";var Ro=function(e){var t,r;function n(){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).name="html-renderer",t}(t=n).prototype=Object.create((r=e).prototype),t.prototype.constructor=t,mo(t,r);var i=n.prototype;return i.init=function(){this.addRenderingPlugin(new go)},i.destroy=function(){this.removeAllRenderingPlugins()},n}(t.AbstractRendererPlugin),yo=Object.freeze({__proto__:null,Plugin:Ro});function To(){To=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},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 c(e,t,r,i){var o=Object.create((t&&t.prototype instanceof h?t:h).prototype),a=new C(i||[]);return n(o,"_invoke",{value:y(e,r,a)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var E=Object.getPrototypeOf,v=E&&E(E(O([])));v&&v!==t&&r.call(v,o)&&(_=v);var m=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 R(e,t){function i(n,o,a,s){var u=l(e[n],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){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,s)}))}s(u.arg)}var o;n(this,"_invoke",{value: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 y(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=l(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)}}}function T(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(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 d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),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(m),e},e.awrap=function(e){return{__await:e}},g(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(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),u(m,s,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},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 Ao(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 So(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Ao(o,n,i,a,s,"next",e)}function s(e){Ao(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Co(e,t){return Co=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Co(e,t)}var Oo="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Io=function(){function e(e){this.canvasConfig=void 0,this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=e}var r=e.prototype;return r.getImageSync=function(e,t){return this.imageCache[e]?t&&t():this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]},r.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e,r.imageCache[e]=a)}))},r.getOrCreatePatternSync=function(e,r,n,i,o){var a=this.generatePatternKey(e);if(a&&this.patternCache[a])return this.patternCache[a];var s,u=e.image,c=e.repetition,l=e.transform,f=!1;T(u)?s=this.getImageSync(u,o):n?(s=n,f=!0):s=u;var h,d=s&&r.createPattern(s,c);d&&(h=l?t.parsedTransformToMat4(t.parseTransform(l)):function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(function(){var e=new Oo(16);return Oo!=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}()),f&&function(e,t,r){var n=r[0],i=r[1],o=r[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(h,h,[1/i,1/i,1]),d.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12],f:h[13]}));return a&&d&&(this.patternCache[a]=d),d},r.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,s=e.height,u=e.cx,c=e.cy,l=e.size;if(this.gradientCache[n])return this.gradientCache[n];var f=null;if(i===t.GradientType.LinearGradient){var h=t.computeLinearGradient(a,s,e.angle);f=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(i===t.GradientType.RadialGradient){var d=t.computeRadialGradient(a,s,u,c,l),p=d.x,_=d.y;f=r.createRadialGradient(p,_,0,p,_,d.r)}return f&&(o.forEach((function(e){var r,n=e.offset;n.unit===t.UnitType.kPercentage&&(null===(r=f)||void 0===r||r.addColorStop(n.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]},r.generateGradientKey=function(e){var t=e.angle,r=e.cx,n=e.cy,i=e.size;return"gradient-"+e.type+"-"+((null==t?void 0:""+t)||0)+"-"+((null==r?void 0:""+r)||0)+"-"+((null==n?void 0:""+n)||0)+"-"+((null==i?void 0:""+i)||0)+"-"+e.width+"-"+e.height+"-"+e.steps.map((function(e){return""+e.offset+e.color})).join("-")},r.generatePatternKey=function(e){var r=e.image,n=e.repetition;return T(r)?"pattern-"+r+"-"+n:r instanceof t.Rect?"pattern-"+r.entity+"-"+n:void 0},e}(),No=function(){function e(){}return e.prototype.apply=function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var r=e.target;if(r.nodeName===t.Shape.IMAGE){var o=r.attributes.img;T(o)&&i.getImageSync(o,(function(){r.renderable.dirty=!0,n.dirtify()}))}},s=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"img"===e.attrName&&T(o)&&i.getOrCreateImage(o).then((function(){r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tapPromise(e.tag,So(To().mark((function e(){return To().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o.addEventListener(t.ElementEvent.MOUNTED,a),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,s);case 2:case"end":return e.stop()}}),e)})))),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,a),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,s)}))},e}();No.tag="LoadImage";var xo,Po=function(e){var t,r;function n(){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).name="image-loader",t}(t=n).prototype=Object.create((r=e).prototype),t.prototype.constructor=t,Co(t,r);var i=n.prototype;return i.init=function(){this.context.imagePool=new Io(this.context.config),this.addRenderingPlugin(new No)},i.destroy=function(){this.removeAllRenderingPlugins()},n}(t.AbstractRendererPlugin);function Mo(){Mo=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},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 c(e,t,r,i){var o=Object.create((t&&t.prototype instanceof h?t:h).prototype),a=new C(i||[]);return n(o,"_invoke",{value:y(e,r,a)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var E=Object.getPrototypeOf,v=E&&E(E(O([])));v&&v!==t&&r.call(v,o)&&(_=v);var m=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 R(e,t){function i(n,o,a,s){var u=l(e[n],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){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,s)}))}s(u.arg)}var o;n(this,"_invoke",{value: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 y(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=l(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)}}}function T(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(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 d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),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(m),e},e.awrap=function(e){return{__await:e}},g(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(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),u(m,s,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},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 Do(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 Lo(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Do(o,n,i,a,s,"next",e)}function s(e){Do(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Bo(){return Bo=Object.assign?Object.assign.bind():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},Bo.apply(this,arguments)}function bo(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Fo(e,t)}function Fo(e,t){return Fo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fo(e,t)}function Uo(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var wo=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});wo.decode();var Go=null;function ko(){return null!==Go&&Go.buffer===xo.memory.buffer||(Go=new Uint8Array(xo.memory.buffer)),Go}function Vo(e,t){return wo.decode(ko().subarray(e,e+t))}var Wo=Array(32).fill(void 0);Wo.push(void 0,null,!0,!1);var Xo=Wo.length;function Ho(e){Xo===Wo.length&&Wo.push(Wo.length+1);var t=Xo;return Xo=Wo[t],Wo[t]=e,t}function Yo(e){return Wo[e]}function Ko(e){var t=Yo(e);return function(e){36>e||(Wo[e]=Xo,Xo=e)}(e),t}var jo=0,zo=new TextEncoder("utf-8"),qo="function"==typeof zo.encodeInto?function(e,t){return zo.encodeInto(e,t)}:function(e,t){var r=zo.encode(e);return t.set(r),{read:e.length,written:r.length}};function Zo(e,t,r){if(void 0===r){var n=zo.encode(e),i=t(n.length);return ko().subarray(i,i+n.length).set(n),jo=n.length,i}for(var o=e.length,a=t(o),s=ko(),u=0;o>u;u++){var c=e.charCodeAt(u);if(c>127)break;s[a+u]=c}if(u!==o){0!==u&&(e=e.slice(u)),a=r(a,o,o=u+3*e.length);var l=ko().subarray(a+u,a+o);u+=qo(e,l).written}return jo=u,a}var Qo,$o,Jo=null;function ea(){return null!==Jo&&Jo.buffer===xo.memory.buffer||(Jo=new Int32Array(xo.memory.buffer)),Jo}function ta(e,t,r){try{var n=xo.__wbindgen_add_to_stack_pointer(-16),i=Zo(e,xo.__wbindgen_malloc,xo.__wbindgen_realloc),o=jo,a=Zo(t,xo.__wbindgen_malloc,xo.__wbindgen_realloc);xo.glsl_compile(n,i,o,a,jo,r);var s=ea()[n/4+0],u=ea()[n/4+1];return Vo(s,u)}finally{xo.__wbindgen_add_to_stack_pointer(16),xo.__wbindgen_free(s,u)}}function ra(e,t){return na.apply(this,arguments)}function na(){return(na=Lo(Mo().mark((function e(t,r){var n,i;return Mo().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 ia(e){return oa.apply(this,arguments)}function oa(){return(oa=Lo(Mo().mark((function e(t){var r,n;return Mo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r={}).wbg={},r.wbg.__wbindgen_string_new=function(e,t){return Ho(Vo(e,t))},r.wbg.__wbindgen_object_drop_ref=function(e){Ko(e)},r.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(Yo(e))},r.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(Yo(e),Yo(t))},r.wbg.__wbindgen_throw=function(e,t){throw Error(Vo(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t)),e.t0=ra,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 xo=(n=e.sent).instance.exports,ia.__wbindgen_wasm_module=n.module,e.abrupt("return",xo);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function aa(e){if(e===We.U8_RGBA_RT)return"bgra8unorm";if(e===We.U8_RGBA_NORM)return"rgba8unorm";if(e===We.U8_RG_NORM)return"rg8unorm";if(e===We.U32_R)return"r32uint";if(e===We.D24)return"depth24plus";if(e===We.D24_S8)return"depth24plus-stencil8";if(e===We.D32F)return"depth32float";if(e===We.D32F_S8)return"depth32float-stencil8";if(e===We.BC1)return"bc1-rgba-unorm";if(e===We.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===We.BC2)return"bc2-rgba-unorm";if(e===We.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===We.BC3)return"bc3-rgba-unorm";if(e===We.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===We.BC4_SNORM)return"bc4-r-snorm";if(e===We.BC4_UNORM)return"bc4-r-unorm";if(e===We.BC5_SNORM)return"bc5-rg-snorm";if(e===We.BC5_UNORM)return"bc5-rg-unorm";throw Error("whoops")}function sa(e){if(e===Ae.Clamp)return"clamp-to-edge";if(e===Ae.Repeat)return"repeat";if(e===Ae.Mirror)return"mirror-repeat";throw Error("whoops")}function ua(e){if(e===Se.Bilinear)return"linear";if(e===Se.Point)return"nearest";throw Error("whoops")}function ca(e){if(e===Ce.Linear)return"linear";if(e===Ce.Nearest)return"nearest";if(e===Ce.NoMip)return"nearest";throw Error("whoops")}function la(e){if(e===be.Float)return"float";if(e===be.Depth)return"depth";throw Error("whoops")}function fa(e){if(e===Me.n2D)return"2d";if(e===Me.n2DArray)return"2d-array";if(e===Me.n3D)return"3d";if(e===Me.Cube)return"cube";throw Error("whoops")}function ha(e){return e.gpuBuffer}function da(e){if(e===we.OcclusionConservative)return"occlusion";throw Error("whoops")}function pa(e){switch(e){case Oe.Triangles:return"triangle-list";case Oe.Points:return"point-list";case Oe.TriangleStrip:return"triangle-strip";case Oe.Lines:return"line-list";case Oe.LineStrip:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function _a(e){if(e===Re.None)return"none";if(e===Re.Front)return"front";if(e===Re.Back)return"back";throw Error("whoops")}function Ea(e){if(e===ge.CCW)return"ccw";if(e===ge.CW)return"cw";throw Error("whoops")}function va(e){if(e===ye.Zero)return"zero";if(e===ye.One)return"one";if(e===ye.Src)return"src";if(e===ye.OneMinusSrc)return"one-minus-src";if(e===ye.Dst)return"dst";if(e===ye.OneMinusDst)return"one-minus-dst";if(e===ye.SrcAlpha)return"src-alpha";if(e===ye.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===ye.DstAlpha)return"dst-alpha";if(e===ye.OneMinusDstAlpha)return"one-minus-dst-alpha";throw Error("whoops")}function ma(e){if(e===Te.Add)return"add";if(e===Te.Subtract)return"subtract";if(e===Te.ReverseSubtract)return"reverse-subtract";throw Error("whoops")}function ga(e){return{operation:ma(e.blendMode),srcFactor:va(e.blendSrcFactor),dstFactor:va(e.blendDstFactor)}}function Ra(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:aa(t),blend:{color:ga(e.rgbBlendState),alpha:ga(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[r])}))}function ya(e){if(e===me.Never)return"never";if(e===me.Less)return"less";if(e===me.Equal)return"equal";if(e===me.LessEqual)return"less-equal";if(e===me.Greater)return"greater";if(e===me.NotEqual)return"not-equal";if(e===me.GreaterEqual)return"greater-equal";if(e===me.Always)return"always";throw Error("whoops")}function Ta(e){if(e===xe.PerVertex)return"vertex";if(e===xe.PerInstance)return"instance";throw Error("whoops")}function Aa(e){if(e===We.U8_R)return"uint8x2";if(e===We.U8_RG)return"uint8x2";if(e===We.U8_RGB)return"uint8x4";if(e===We.U8_RGBA)return"uint8x4";if(e===We.U8_RGBA_NORM)return"unorm8x4";if(e===We.S8_RGB_NORM)return"snorm8x4";if(e===We.S8_RGBA_NORM)return"snorm8x4";if(e===We.S16_RG)return"uint16x2";if(e===We.F32_R)return"float32";if(e===We.F32_RG)return"float32x2";if(e===We.F32_RGB)return"float32x3";if(e===We.F32_RGBA)return"float32x4";throw Error("whoops")}function Sa(e,t,r,n){switch(void 0===r&&(r=!1),e){case We.S8_R:case We.S8_R_NORM:case We.S8_RG_NORM:case We.S8_RGB_NORM:case We.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case We.U8_R:case We.U8_R_NORM:case We.U8_RG:case We.U8_RG_NORM:case We.U8_RGB:case We.U8_RGB_NORM:case We.U8_RGB_SRGB:case We.U8_RGBA:case We.U8_RGBA_NORM:case We.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case We.S16_R:case We.S16_RG:case We.S16_RG_NORM:case We.S16_RGB_NORM:case We.S16_RGBA:case We.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 We.U16_R:case We.U16_RGB:case We.U16_RGBA_5551:case We.U16_RGBA_NORM:case We.U16_RG_NORM:case We.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 We.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 We.U32_R:case We.U32_RG:var c=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&c.set(new Uint32Array(n)),c;case We.F32_R:case We.F32_RG:case We.F32_RGB:case We.F32_RGBA:var l=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&l.set(new Float32Array(n)),l}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"}(Qo||(Qo={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}($o||($o={}));var Ca=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 bo(t,e),t.prototype.destroy=function(){},t}(C),Oa=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.Bindings,r.bindingLayout=void 0,r.gpuBindGroup=void 0,r.bindGroupLayout=void 0;var i=n.pipeline,o=n.bindingLayout;it(!!i);var a=r.device._createBindGroupLayout(o),s=[[],[]],u=0;if(o.storageEntries)for(var c=0;o.storageEntries.length>c;c++){var l=n.storageBufferBindings[c];it(l.wordCount>0);var f={buffer:ha(l.buffer),offset:0,size:l.wordCount<<2};s[0].push({binding:u++,resource:f})}for(var h=0;o.numUniformBuffers>h;h++){var d=n.uniformBufferBindings[h];it(d.wordCount>0);var p={buffer:ha(d.buffer),offset:0,size:d.wordCount<<2};s[0].push({binding:u++,resource:p})}u=0;for(var _=0;o.numSamplers>_;_++){var E=void 0!==o.samplerEntries?o.samplerEntries[_]:wt,v=n.samplerBindings[_],m=null!==v.texture?v.texture:r.device.getFallbackTexture(E);it(E.dimension===m.dimension),it(E.formatKind===nt(m.pixelFormat)),s[1].push({binding:u++,resource:m.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 bo(t,e),t}(Ca);function Ia(e){return void 0!==e.byteLength}var Na=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.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=Ia(o)?o.byteLength+3&-4:o+3&-4;r.usage=i,r.usage&Ie.MAP_READ&&(r.usage=Ie.MAP_READ|Ie.COPY_DST);var s=Ia(o);if(r.size=Ia(o)?o.byteLength:o,r.view=Ia(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}bo(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 c=15728640,l=0;a-(o+l)>c;)this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,c),l+=c;this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,n-l)},r.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(Ca),xa=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.dispatchWorkgroups(e,t,r)},t.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},t.beginComputePass=function(e){it(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},t.setPipeline=function(e){var t=ot(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}(),Pa=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.ComputePipeline,r.descriptor=void 0,r.gpuComputePipeline=null,r.descriptor=n;var i=n.program.computeStage;if(null===i)return Uo(r);var o={compute:Bo({},i),layout:"auto"};return r.gpuComputePipeline=r.device.device.createComputePipeline(o),void 0!==r.name&&(r.gpuComputePipeline.label=r.name),r}return bo(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(Ca),Ma=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.InputLayout,r.buffers=void 0,r.indexFormat=void 0;for(var i=[],o=0;n.vertexBufferDescriptors.length>o;o++){var a=n.vertexBufferDescriptors[o];if(!g(a)){var s=a.byteStride,u=Ta(a.frequency);i[o]={arrayStride:s,stepMode:u,attributes:[]}}}for(var c=0;n.vertexAttributeDescriptors.length>c;c++){var l=n.vertexAttributeDescriptors[c],f=ot(i[l.bufferIndex]),h={shaderLocation:l.location,format:Aa(l.format),offset:l.bufferByteOffset};f.attributes.push(h)}return r.indexFormat=function(e){if(null!==e){if(e===We.U16_R)return"uint16";if(e===We.U32_R)return"uint32";throw Error("whoops")}}(n.indexBufferFormat),r.buffers=i,r}return bo(t,e),t}(Ca),Da=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=ve.InputState,r.inputLayout=void 0,r.vertexBuffers=void 0,r.indexBuffer=void 0,r.inputLayout=n,r.vertexBuffers=i,r.indexBuffer=o,r}return bo(t,e),t}(Ca),La=function(e){function t(t){var r,n=t.descriptor;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.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 bo(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}(Ca),Ba=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.QueryPool,r.querySet=void 0;var i=n.elemCount;return r.querySet=r.device.device.createQuerySet({type:da(n.type),count:i}),r}return bo(t,e),t.prototype.queryResultOcclusion=function(e){return!0},t}(Ca),ba=function(e){function t(t){var r;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.Readback,r}bo(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,c=this.getBlockInformationFromFormat(u.format),l=256*Math.ceil(Math.ceil(n/c.width)*c.length/256),f=l*i,h=this.device.createBuffer({usage:Ie.STORAGE|Ie.MAP_READ|Ie.COPY_DST,hint:Ne.Static,viewOrSize:f}),d=this.device.device.createCommandEncoder();return d.copyTextureToBuffer({texture:u.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:h.gpuBuffer,offset:0,bytesPerRow:l},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([d.finish()]),this.readBuffer(h,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=We.U8_RGB),void 0===a&&(a=!1);var c=e,l=i||c.size,f=r||c.view,h=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||rt(o),d=c;if(!(c.usage&Ie.MAP_READ&&c.usage&Ie.COPY_DST)){var p=this.device.device.createCommandEncoder();d=this.device.createBuffer({usage:Ie.STORAGE|Ie.MAP_READ|Ie.COPY_DST,hint:Ne.Static,viewOrSize:l}),p.copyBufferToBuffer(c.gpuBuffer,t,d.gpuBuffer,0,l),this.device.device.queue.submit([p.finish()])}return new Promise((function(e,r){d.gpuBuffer.mapAsync($o.READ,t,l).then((function(){var r=d.gpuBuffer.getMappedRange(t,l),n=f;if(a)n=null===n?Sa(o,l,!0,r):Sa(o,n.buffer,void 0,r);else if(null===n)switch(h){case 1:(n=new Uint8Array(l)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(l/2,r);break;case 4:(n=new Float32Array(l/4)).set(new Float32Array(r))}else switch(h){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(l/2,r,f);break;case 4:var i=f&&f.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}d.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":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}(Ca),Fa=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 t=e.prototype;return t.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},t.beginRenderPass=function(e){it(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},t.setViewport=function(e,t,r,n){this.gpuRenderPassEncoder.setViewport(e,t,r,n,0,1)},t.setScissor=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,t,r,n)},t.setPipeline=function(e){var t=ot(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},t.setInputState=function(e){if(null!==e){var t=e;if(null!==t.indexBuffer){var r=t.inputLayout,n=t.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(ha(n.buffer),ot(r.indexFormat),n.byteOffset)}for(var i=0;t.vertexBuffers.length>i;i++){var o=t.vertexBuffers[i];g(o)||this.gpuRenderPassEncoder.setVertexBuffer(i,ha(o.buffer),o.byteOffset)}}},t.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])},t.setStencilRef=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},t.draw=function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)},t.drawIndexed=function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)},t.drawIndexedInstanced=function(e,t,r){this.gpuRenderPassEncoder.drawIndexed(e,r,t,0,0)},t.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},t.endOcclusionQuery=function(e){this.gpuRenderPassEncoder.endOcclusionQuery()},t.beginDebugGroup=function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)},t.endDebugGroup=function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()},t.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()},t.copyAttachment=function(e,t){it(1===t.sampleCount);var r={texture:t.gpuTexture},n={texture:e.gpuTexture};it(t.width===e.width),it(t.height===e.height),it(!!(t.usage&Qo.COPY_SRC)),it(!!(e.usage&Qo.COPY_DST)),this.commandEncoder.copyTextureToTexture(r,n,[e.width,e.height,1])},e}(),Ua=function(e){function t(t){var r,n=t.descriptor;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ve.RenderPipeline,r.descriptor=void 0,r.isCreating=!1,r.isCreatingAsync=!1,r.gpuRenderPipeline=null,r.descriptor=n,r.device._createRenderPipeline(Uo(r),!1),r}return bo(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(Ca),wa=function(e){function t(t){var r,n,i,o=t.descriptor;(i=e.call(this,{id:t.id,device:t.device})||this).type=ve.Sampler,i.gpuSampler=void 0;var a=o.minLOD,s=o.mipFilter===Ce.NoMip?o.minLOD:o.maxLOD,u=null!==(r=o.maxAnisotropy)&&void 0!==r?r:1;return u>1&&it(o.minFilter===Se.Bilinear&&o.magFilter===Se.Bilinear&&o.mipFilter===Ce.Linear),i.gpuSampler=i.device.device.createSampler({addressModeU:sa(o.wrapS),addressModeV:sa(o.wrapT),addressModeW:sa(null!==(n=o.wrapQ)&&void 0!==n?n:o.wrapS),lodMinClamp:a,lodMaxClamp:s,minFilter:ua(o.minFilter),magFilter:ua(o.magFilter),mipmapFilter:ca(o.mipFilter),maxAnisotropy:u}),i}return bo(t,e),t}(Ca),Ga=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=ve.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},Uo(r),i),r}bo(t,e);var r=t.prototype;return r.setImageData=function(e,t){},r.destroy=function(){this.gpuTexture.destroy()},t}(Ca),ka=function(){function e(e,t,r,n,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Qo.RENDER_ATTACHMENT|Qo.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new wr(Xt,Fr),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=Fe.UpperLeft,this.clipSpaceNearZ=Ue.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(Me.n2D,be.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(Me.n2D,be.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(Me.n2DArray,be.Float),this.fallbackTexture3D=this.createFallbackTexture(Me.n3D,be.Float),this.fallbackTextureCube=this.createFallbackTexture(Me.Cube,be.Float),this.fallbackSampler=this.createSampler({wrapS:Ae.Clamp,wrapT:Ae.Clamp,minFilter:Se.Point,magFilter:Se.Point,mipFilter:Ce.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}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 Ga({id:0,device:this,descriptor:{pixelFormat:We.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:Me.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 Na({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createTexture=function(e){return new Ga({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createSampler=function(e){return new wa({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createRenderTarget=function(e){var t=new Ga({id:this.getNextUniqueId(),device:this,descriptor:Bo({},e,{dimension:Me.n2D,numLevels:1,depth:1,usage:De.RenderTarget})});return t.depthOrArrayLayers=1,t.type=ve.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,c=e.usage;it(!!(c&Qo.RENDER_ATTACHMENT));var l=new Ga({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:Me.n2D,numLevels:a,usage:c},skipCreate:!0});return l.depthOrArrayLayers=i,l.sampleCount=o,l.gpuTexture=s,l.gpuTextureView=u,l},t.createProgram=function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)},t.createProgramSimple=function(e){return new La({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=aa(e.pixelFormat),a=function(e){if(e===Me.n2D)return"2d";if(e===Me.Cube)return"3d";if(e===Me.n2DArray)return"3d";if(e===Me.n3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&De.Sampled&&(t|=Qo.TEXTURE_BINDING|Qo.COPY_DST),e&De.RenderTarget&&(t|=Qo.RENDER_ATTACHMENT|Qo.TEXTURE_BINDING|Qo.COPY_SRC|Qo.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}),c=u.createView();t.gpuTexture=u,t.gpuTextureView=c}},t.getFallbackTexture=function(e){var t=e.dimension;if(t===Me.n2D)return e.formatKind===be.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===Me.n2DArray)return this.fallbackTexture2DArray;if(t===Me.n3D)return this.fallbackTexture3D;if(t===Me.Cube)return this.fallbackTextureCube;throw Error("whoops")},t.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,pixelFormat:t===be.Float?We.U8_RGBA_NORM:We.D24,usage:De.Sampled,width:1,height:1,depth:e===Me.Cube?6:1,numLevels:1})},t.createBindings=function(e){return new Oa({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createInputLayout=function(e){return new Ma({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createInputState=function(e,t,r){return new Da({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})},t.createComputePipeline=function(e){return new Pa({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createRenderPipeline=function(e){return new Ua({id:this.getNextUniqueId(),device:this,descriptor:Bo({},e)})},t.createQueryPool=function(e,t){return new Ba({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]:wt,{sampleType:la(t.formatKind),viewDimension:fa(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:pa(r.topology),cullMode:_a(a.cullMode),frontFace:Ea(a.frontFace)}),c=Ra(r.colorAttachmentFormats,r.megaStateDescriptor),l=function(e,t){if(null!==e)return{format:aa(e),depthWriteEnabled:t.depthWrite,depthCompare:ya(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 h=r.sampleCount;e.isCreating=!0;var d={layout:s,vertex:Bo({},i,{buffers:f}),primitive:u,depthStencil:l,multisample:{count:h},fragment:Bo({},o,{targets:c})};e.gpuRenderPipeline=this.device.createRenderPipeline(d),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}},t.createReadback=function(){return new ba({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 Fa),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},t.createComputePass=function(e){var t=this.computePassPool.pop();return void 0===t&&(t=new xa),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 Fa?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,c={texture:u.gpuTexture,origin:[i,o,0]},l={texture:s.gpuTexture,origin:[t,r,0]};it(!!(u.usage&Qo.COPY_SRC)),it(!!(s.usage&Qo.COPY_DST)),a.copyTextureToTexture(c,l,[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(Je(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(Je(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}switch(e){case We.U16_RGBA_NORM:case We.F32_RGBA:return!1}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===ve.Buffer)e.gpuBuffer.label=t;else if(e.type===ve.Texture){var r=e;r.gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===ve.RenderTarget){var n=e;n.gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===ve.Sampler){e.gpuSampler.label=t}else if(e.type===ve.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}(),Va=function(){function e(e){this.pluginOptions=void 0,this.pluginOptions=e}return e.prototype.createSwapChain=function(){var e=Lo(Mo().mark((function e(t){var r,n,i,o;return Mo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==globalThis.navigator.gpu){e.next=2;break}return e.abrupt("return",null);case 2:return r=null,e.prev=3,e.next=6,globalThis.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=["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,ia("/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 ka(r,i,t,o,ta));case 32:case"end":return e.stop()}}),e,null,[[3,9],[24,29]])})));return function(t){return e.apply(this,arguments)}}(),e}(),Wa=function(e){function t(t){var r;return void 0===t&&(t={}),(r=e.call(this)||this).options=void 0,r.name="webgpu-device",r.options=t,r}bo(t,e);var r=t.prototype;return r.init=function(){this.context.deviceContribution=new Va(Bo({},this.options))},r.destroy=function(){delete this.context.deviceContribution},t}(t.AbstractRendererPlugin),Xa=Object.freeze({__proto__:null,Plugin:Wa}),Ha=function(){function e(e){this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.canvasConfig=void 0,this.deviceRendererPlugin=void 0,this.canvasConfig=e.config,this.deviceRendererPlugin=e.deviceRendererPlugin}var n=e.prototype;return n.init=function(){var e=i(r().mark((function e(){var t,n,i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=(t=this.canvasConfig).container,(i=t.canvas)?(this.$canvas=i,n&&i.parentElement!==n&&n.appendChild(i),this.$container=i.parentElement,this.canvasConfig.container=this.$container):n&&(this.$container=T(n)?document.getElementById(n):n,this.$container&&(o=document.createElement("canvas"),this.$container.appendChild(o),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=o)),this.resize(this.canvasConfig.width,this.canvasConfig.height);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.getDomElement=function(){return this.$canvas},n.getContext=function(){return this.deviceRendererPlugin.getDevice().canvasContext},n.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},n.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},n.resize=function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}},n.getDPR=function(){return this.dpr},n.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},n.toDataURL=function(){var e=i(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","");case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e}(),Ya=function(e){function t(t){var r;return(r=e.call(this)||this).rendererPlugin=void 0,r.name="webgpu-context-register",r.rendererPlugin=t,r}o(t,e);var r=t.prototype;return r.init=function(){this.context.ContextService=Ha,this.context.deviceRendererPlugin=this.rendererPlugin},r.destroy=function(){delete this.context.ContextService},t}(t.AbstractRendererPlugin),Ka=function(e){function t(t){var r;r=e.call(this,t)||this;var n=new oo;return r.registerPlugin(new Ya(n)),r.registerPlugin(new Po),r.registerPlugin(new Wa),r.registerPlugin(n),r.registerPlugin(new ho),r.registerPlugin(new Ro),r}return o(t,e),t}(t.AbstractRenderer);e.DeviceRenderer=ao,e.DomInteraction=po,e.HTMLRenderer=yo,e.Renderer=Ka,e.WebGPUDevice=Xa,Object.defineProperty(e,"__esModule",{value:!0})}));
|