Skip to content

Instantly share code, notes, and snippets.

@ZenithRogue
Created May 8, 2019 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZenithRogue/262cfa398d73a736251c21e7c996d396 to your computer and use it in GitHub Desktop.
Save ZenithRogue/262cfa398d73a736251c21e7c996d396 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
!function(e){var t={};function i(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i(i.s=228)}([function(e,t,i){var r=i(5),n=i(14),o=i(23),s=i(19),a=i(34),c=function e(t,i,c){var h,u,l,f,d=t&e.F,p=t&e.G,m=t&e.P,g=t&e.B,_=p?r:t&e.S?r[i]||(r[i]={}):(r[i]||{}).prototype,v=p?n:n[i]||(n[i]={}),y=v.prototype||(v.prototype={});for(h in p&&(c=i),c)l=((u=!d&&_&&void 0!==_[h])?_:c)[h],f=g&&u?a(l,r):m&&"function"==typeof l?a(Function.call,l):l,_&&s(_,h,l,t&e.U),v[h]!=l&&o(v,h,f),m&&y[h]!=l&&(y[h]=l)};r.core=n,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}},function(e,t,i){var r=i(9),n=r.Buffer;function o(e,t){for(var i in e)t[i]=e[i]}function s(e,t,i){return n(e,t,i)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=s),o(n,s),s.from=function(e,t,i){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,i)},s.alloc=function(e,t,i){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof i?r.fill(t,i):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,i){var r=i(6);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t){var i=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(e,t){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}e.exports=function(e){return"object"===i(e)?null!==e:"function"==typeof e}},function(e,t,i){"use strict";function r(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}i.r(t);var n=function(){function e(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),e.instance||(e.instance=this),this.changedBlocks={},this.worldSeed=null,this.worldSize=128,this.timeout=null,this.version=0,this.loadDataIfExists(),e.instance}var t,i,n;return t=e,n=[{key:"getInstance",value:function(){return void 0===e.instance&&(e.instance=new e),e.instance}}],(i=[{key:"loadDataIfExists",value:function(){var e=localStorage.getItem("savedGame");if(e){var t=JSON.parse(e);this.worldSeed=t.worldSeed,this.changedBlocks=t.changedBlocks,this.worldSize=t.worldSize,this.version=void 0!==t.version?t.version:0}0===this.version&&this.clearData()}},{key:"gameSaved",value:function(){return!!this.worldSeed}},{key:"updateData",value:function(){var e=JSON.stringify({worldSeed:this.worldSeed,changedBlocks:this.changedBlocks,worldSize:this.worldSize,version:1});localStorage.setItem("savedGame",e)}},{key:"clearData",value:function(){this.worldSeed=null,this.changedBlocks={},this.updateData()}},{key:"setWorldSeed",value:function(e){this.worldSeed=e,this.updateData()}},{key:"getWorldSeed",value:function(){return this.worldSeed}},{key:"setWorldSize",value:function(e){this.worldSize=e,this.updateData()}},{key:"getWorldSize",value:function(){return this.worldSize}},{key:"addBlockChange",value:function(e){var t=this;this.changedBlocks["p"+e.p[0]+"_"+e.p[1]+"_"+e.p[2]]={a:e.add?1:0,bt:e.bt},null===this.timeout&&(this.timeout=setTimeout(function(){Date.now();t.updateData(),t.timeout=null},3e3))}},{key:"getChangedBlocks",value:function(){var e=[];for(var t in this.changedBlocks){var i=t.substr(1).split("_").map(function(e){return parseInt(e)});e.push({p:i,add:!!this.changedBlocks[t].a,bt:this.changedBlocks[t].bt})}return e}}])&&r(t.prototype,i),n&&r(t,n),e}();t.default=n},function(e,t,i){var r=i(96)("wks"),n=i(45),o=i(5).Symbol,s="function"==typeof o;(e.exports=function(e){return r[e]||(r[e]=s&&o[e]||(s?o:n)("Symbol."+e))}).store=r},function(e,t,i){"use strict";(function(e){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
var r=i(398),n=i(399),o=i(168);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,i){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,i);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return h(this,e,t,i)}function h(e,t,i,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,i,r){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===i&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,i):new Uint8Array(t,i,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=f(e,t);return e}(e,t,i,r):"string"==typeof t?function(e,t,i){"string"==typeof i&&""!==i||(i="utf8");if(!c.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,i),n=(e=a(e,r)).write(t,i);n!==r&&(e=e.slice(0,n));return e}(e,t,i):function(e,t){if(c.isBuffer(t)){var i=0|d(t.length);return 0===(e=a(e,i)).length?e:(t.copy(e,0,0,i),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):f(e,t);if("Buffer"===t.type&&o(t.data))return f(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(u(t),e=a(e,t<0?0:0|d(t)),!c.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function f(e,t){var i=t.length<0?0:0|d(t.length);e=a(e,i);for(var r=0;r<i;r+=1)e[r]=255&t[r];return e}function d(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var i=e.length;if(0===i)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return U(e).length;default:if(r)return z(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function g(e,t,i,r,n){if(0===e.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(n)return-1;i=e.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:_(e,t,i,r,n);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):_(e,[t],i,r,n);throw new TypeError("val must be string, number or Buffer")}function _(e,t,i,r,n){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,i/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var u=-1;for(o=i;o<a;o++)if(h(e,o)===h(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===c)return u*s}else-1!==u&&(o-=o-u),u=-1}else for(i+c>a&&(i=a-c),o=i;o>=0;o--){for(var l=!0,f=0;f<c;f++)if(h(e,o+f)!==h(t,f)){l=!1;break}if(l)return o}return-1}function v(e,t,i,r){i=Number(i)||0;var n=e.length-i;r?(r=Number(r))>n&&(r=n):r=n;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[i+s]=a}return s}function y(e,t,i,r){return G(z(t,e.length-i),e,i,r)}function b(e,t,i,r){return G(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,r)}function x(e,t,i,r){return b(e,t,i,r)}function w(e,t,i,r){return G(U(t),e,i,r)}function S(e,t,i,r){return G(function(e,t){for(var i,r,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)i=e.charCodeAt(s),r=i>>8,n=i%256,o.push(n),o.push(r);return o}(t,e.length-i),e,i,r)}function T(e,t,i){return 0===t&&i===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,i))}function A(e,t,i){i=Math.min(e.length,i);for(var r=[],n=t;n<i;){var o,s,a,c,h=e[n],u=null,l=h>239?4:h>223?3:h>191?2:1;if(n+l<=i)switch(l){case 1:h<128&&(u=h);break;case 2:128==(192&(o=e[n+1]))&&(c=(31&h)<<6|63&o)>127&&(u=c);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(c=(15&h)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,l=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),n+=l}return function(e){var t=e.length;if(t<=M)return String.fromCharCode.apply(String,e);var i="",r=0;for(;r<t;)i+=String.fromCharCode.apply(String,e.slice(r,r+=M));return i}(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,i){return h(null,e,t,i)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,i){return function(e,t,i,r){return u(t),t<=0?a(e,t):void 0!==i?"string"==typeof r?a(e,t).fill(i,r):a(e,t).fill(i):a(e,t)}(null,e,t,i)},c.allocUnsafe=function(e){return l(null,e)},c.allocUnsafeSlow=function(e){return l(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,r=t.length,n=0,o=Math.min(i,r);n<o;++n)if(e[n]!==t[n]){i=e[n],r=t[n];break}return i<r?-1:r<i?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var r=c.allocUnsafe(t),n=0;for(i=0;i<e.length;++i){var s=e[i];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,n),n+=s.length}return r},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):function(e,t,i){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,i);case"utf8":case"utf-8":return A(this,t,i);case"ascii":return E(this,t,i);case"latin1":case"binary":return P(this,t,i);case"base64":return T(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,i);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",i=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,i,r,n){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||i>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=i)return 0;if(r>=n)return-1;if(t>=i)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(r>>>=0),s=(i>>>=0)-(t>>>=0),a=Math.min(o,s),h=this.slice(r,n),u=e.slice(t,i),l=0;l<a;++l)if(h[l]!==u[l]){o=h[l],s=u[l];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},c.prototype.indexOf=function(e,t,i){return g(this,e,t,i,!0)},c.prototype.lastIndexOf=function(e,t,i){return g(this,e,t,i,!1)},c.prototype.write=function(e,t,i,r){if(void 0===t)r="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)r=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-t;if((void 0===i||i>n)&&(i=n),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return v(this,e,t,i);case"utf8":case"utf-8":return y(this,e,t,i);case"ascii":return b(this,e,t,i);case"latin1":case"binary":return x(this,e,t,i);case"base64":return w(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,i);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var M=4096;function E(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(127&e[n]);return r}function P(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(e[n]);return r}function C(e,t,i){var r=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>r)&&(i=r);for(var n="",o=t;o<i;++o)n+=N(e[o]);return n}function R(e,t,i){for(var r=e.slice(t,i),n="",o=0;o<r.length;o+=2)n+=String.fromCharCode(r[o]+256*r[o+1]);return n}function I(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,i,r,n,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(i+r>e.length)throw new RangeError("Index out of range")}function O(e,t,i,r){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(e.length-i,2);n<o;++n)e[i+n]=(t&255<<8*(r?n:1-n))>>>8*(r?n:1-n)}function L(e,t,i,r){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(e.length-i,4);n<o;++n)e[i+n]=t>>>8*(r?n:3-n)&255}function F(e,t,i,r,n,o){if(i+r>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function B(e,t,i,r,o){return o||F(e,0,i,4),n.write(e,t,i,r,23,4),i+4}function k(e,t,i,r,o){return o||F(e,0,i,8),n.write(e,t,i,r,52,8),i+8}c.prototype.slice=function(e,t){var i,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(i=this.subarray(e,t)).__proto__=c.prototype;else{var n=t-e;i=new c(n,void 0);for(var o=0;o<n;++o)i[o]=this[o+e]}return i},c.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||I(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return r},c.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||I(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},c.prototype.readUInt8=function(e,t){return t||I(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||I(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||I(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||I(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return r>=(n*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||I(e,t,this.length);for(var r=t,n=1,o=this[e+--r];r>0&&(n*=256);)o+=this[e+--r]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||I(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||I(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(e,t){t||I(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(e,t){return t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||I(e,4,this.length),n.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||I(e,4,this.length),n.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||I(e,8,this.length),n.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||I(e,8,this.length),n.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,i,r){(e=+e,t|=0,i|=0,r)||D(this,e,t,i,Math.pow(2,8*i)-1,0);var n=1,o=0;for(this[t]=255&e;++o<i&&(n*=256);)this[t+o]=e/n&255;return t+i},c.prototype.writeUIntBE=function(e,t,i,r){(e=+e,t|=0,i|=0,r)||D(this,e,t,i,Math.pow(2,8*i)-1,0);var n=i-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+i},c.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);D(this,e,t,i,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<i&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+i},c.prototype.writeIntBE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);D(this,e,t,i,n-1,-n)}var o=i-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+i},c.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,i){return B(this,e,t,!0,i)},c.prototype.writeFloatBE=function(e,t,i){return B(this,e,t,!1,i)},c.prototype.writeDoubleLE=function(e,t,i){return k(this,e,t,!0,i)},c.prototype.writeDoubleBE=function(e,t,i){return k(this,e,t,!1,i)},c.prototype.copy=function(e,t,i,r){if(i||(i=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<i&&(r=i),r===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-i&&(r=e.length-t+i);var n,o=r-i;if(this===e&&i<t&&t<r)for(n=o-1;n>=0;--n)e[n+t]=this[n+i];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)e[n+t]=this[n+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+o),t);return o},c.prototype.fill=function(e,t,i,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;var o;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(o=t;o<i;++o)this[o]=e;else{var s=c.isBuffer(e)?e:z(new c(e,r).toString()),a=s.length;for(o=0;o<i-t;++o)this[o+t]=s[o%a]}return this};var V=/[^+\/0-9A-Za-z-_]/g;function N(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(e,t){var i;t=t||1/0;for(var r=e.length,n=null,o=[],s=0;s<r;++s){if((i=e.charCodeAt(s))>55295&&i<57344){if(!n){if(i>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}n=i;continue}if(i<56320){(t-=3)>-1&&o.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,i<128){if((t-=1)<0)break;o.push(i)}else if(i<2048){if((t-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function U(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(V,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function G(e,t,i,r){for(var n=0;n<r&&!(n+i>=t.length||n>=e.length);++n)t[n+i]=e[n];return n}}).call(this,i(15))},function(e,t,i){var r=i(28),n=Math.min;e.exports=function(e){return e>0?n(r(e),9007199254740991):0}},function(e,t,i){(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}function s(e,t,i){if(s.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(i=t,t=10),this._init(e||0,t||10,i||"be"))}var a;"object"===t(e)?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;try{a=i(543).Buffer}catch(e){}function c(e,t,i){for(var r=0,n=Math.min(e.length,i),o=t;o<n;o++){var s=e.charCodeAt(o)-48;r<<=4,r|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return r}function h(e,t,i,r){for(var n=0,o=Math.min(e.length,i),s=t;s<o;s++){var a=e.charCodeAt(s)-48;n*=r,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(e){return e instanceof s||null!==e&&"object"===t(e)&&e.constructor.wordSize===s.wordSize&&Array.isArray(e.words)},s.max=function(e,t){return e.cmp(t)>0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,i,r){if("number"==typeof e)return this._initNumber(e,i,r);if("object"===t(e))return this._initArray(e,i,r);"hex"===i&&(i=16),n(i===(0|i)&&i>=2&&i<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&o++,16===i?this._parseHex(e,o):this._parseBase(e,i,o),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),i,r)},s.prototype._initNumber=function(e,t,i){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),t,i)},s.prototype._initArray=function(e,t,i){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,s,a=0;if("be"===i)for(r=e.length-1,o=0;r>=0;r-=3)s=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===i)for(r=0,o=0;r<e.length;r+=3)s=e[r]|e[r+1]<<8|e[r+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},s.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var r,n,o=0;for(i=e.length-6,r=0;i>=t;i-=6)n=c(e,i,i+6),this.words[r]|=n<<o&67108863,this.words[r+1]|=n>>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==t&&(n=c(e,t,i+6),this.words[r]|=n<<o&67108863,this.words[r+1]|=n>>>26-o&4194303),this.strip()},s.prototype._parseBase=function(e,t,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=t)r++;r--,n=n/t|0;for(var o=e.length-i,s=o%r,a=Math.min(o,o-s)+i,c=0,u=i;u<a;u+=r)c=h(e,u,u+r,t),this.imuln(n),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=h(e,u,e.length,t),u=0;u<s;u++)l*=t;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},s.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},s.prototype.clone=function(){var e=new s(null);return this.copy(e),e},s.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(e,t,i){i.negative=t.negative^e.negative;var r=e.length+t.length|0;i.length=r,r=r-1|0;var n=0|e.words[0],o=0|t.words[0],s=n*o,a=67108863&s,c=s/67108864|0;i.words[0]=a;for(var h=1;h<r;h++){for(var u=c>>>26,l=67108863&c,f=Math.min(h,t.length-1),d=Math.max(0,h-e.length+1);d<=f;d++){var p=h-d|0;u+=(s=(n=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&s}i.words[h]=0|l,c=0|u}return 0!==c?i.words[h]=0|c:i.length--,i.strip()}s.prototype.toString=function(e,t){var i;if(t=0|t||1,16===(e=e||10)||"hex"===e){i="";for(var r=0,o=0,s=0;s<this.length;s++){var a=this.words[s],c=(16777215&(a<<r|o)).toString(16);i=0!==(o=a>>>24-r&16777215)||s!==this.length-1?u[6-c.length]+c+i:c+i,(r+=2)>=26&&(r-=26,s--)}for(0!==o&&(i=o.toString(16)+i);i.length%t!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(e===(0|e)&&e>=2&&e<=36){var h=l[e],d=f[e];i="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);i=(p=p.idivn(d)).isZero()?m+i:u[h-m.length]+m+i}for(this.isZero()&&(i="0"+i);i.length%t!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,i){var r=this.byteLength(),o=i||Math.max(1,r);n(r<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,c="le"===t,h=new e(o),u=this.clone();if(c){for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),h[a]=s;for(;a<o;a++)h[a]=0}else{for(a=0;a<o-r;a++)h[a]=0;for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),h[o-a-1]=s}return h},Math.clz32?s.prototype._countBits=function(e){return 32-Math.clz32(e)}:s.prototype._countBits=function(e){var t=e,i=0;return t>=4096&&(i+=13,t>>>=13),t>=64&&(i+=7,t>>>=7),t>=8&&(i+=4,t>>>=4),t>=2&&(i+=2,t>>>=2),i+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,i=0;return 0==(8191&t)&&(i+=13,t>>>=13),0==(127&t)&&(i+=7,t>>>=7),0==(15&t)&&(i+=4,t>>>=4),0==(3&t)&&(i+=2,t>>>=2),0==(1&t)&&i++,i},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var i=this._zeroBits(this.words[t]);if(e+=i,26!==i)break}return e},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},s.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},s.prototype.ior=function(e){return n(0==(this.negative|e.negative)),this.iuor(e)},s.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]&e.words[i];return this.length=t.length,this.strip()},s.prototype.iand=function(e){return n(0==(this.negative|e.negative)),this.iuand(e)},s.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,i;this.length>e.length?(t=this,i=e):(t=e,i=this);for(var r=0;r<i.length;r++)this.words[r]=t.words[r]^i.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this.strip()},s.prototype.ixor=function(e){return n(0==(this.negative|e.negative)),this.iuxor(e)},s.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),i=e%26;this._expand(t),i>0&&t--;for(var r=0;r<t;r++)this.words[r]=67108863&~this.words[r];return i>0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var i=e/26|0,r=e%26;return this._expand(i+1),this.words[i]=t?this.words[i]|1<<r:this.words[i]&~(1<<r),this.strip()},s.prototype.iadd=function(e){var t,i,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(i=this,r=e):(i=e,r=this);for(var n=0,o=0;o<r.length;o++)t=(0|i.words[o])+(0|r.words[o])+n,this.words[o]=67108863&t,n=t>>>26;for(;0!==n&&o<i.length;o++)t=(0|i.words[o])+n,this.words[o]=67108863&t,n=t>>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;o<i.length;o++)this.words[o]=i.words[o];return this},s.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var i,r,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=e):(i=e,r=this);for(var o=0,s=0;s<r.length;s++)o=(t=(0|i.words[s])-(0|r.words[s])+o)>>26,this.words[s]=67108863&t;for(;0!==o&&s<i.length;s++)o=(t=(0|i.words[s])+o)>>26,this.words[s]=67108863&t;if(0===o&&s<i.length&&i!==this)for(;s<i.length;s++)this.words[s]=i.words[s];return this.length=Math.max(this.length,s),i!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(e){return this.clone().isub(e)};var p=function(e,t,i){var r,n,o,s=e.words,a=t.words,c=i.words,h=0,u=0|s[0],l=8191&u,f=u>>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],_=8191&g,v=g>>>13,y=0|s[3],b=8191&y,x=y>>>13,w=0|s[4],S=8191&w,T=w>>>13,A=0|s[5],M=8191&A,E=A>>>13,P=0|s[6],C=8191&P,R=P>>>13,I=0|s[7],D=8191&I,O=I>>>13,L=0|s[8],F=8191&L,B=L>>>13,k=0|s[9],V=8191&k,N=k>>>13,z=0|a[0],U=8191&z,G=z>>>13,W=0|a[1],j=8191&W,H=W>>>13,X=0|a[2],Y=8191&X,K=X>>>13,q=0|a[3],Z=8191&q,Q=q>>>13,J=0|a[4],$=8191&J,ee=J>>>13,te=0|a[5],ie=8191&te,re=te>>>13,ne=0|a[6],oe=8191&ne,se=ne>>>13,ae=0|a[7],ce=8191&ae,he=ae>>>13,ue=0|a[8],le=8191&ue,fe=ue>>>13,de=0|a[9],pe=8191&de,me=de>>>13;i.negative=e.negative^t.negative,i.length=19;var ge=(h+(r=Math.imul(l,U))|0)+((8191&(n=(n=Math.imul(l,G))+Math.imul(f,U)|0))<<13)|0;h=((o=Math.imul(f,G))+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(p,U),n=(n=Math.imul(p,G))+Math.imul(m,U)|0,o=Math.imul(m,G);var _e=(h+(r=r+Math.imul(l,j)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(f,j)|0))<<13)|0;h=((o=o+Math.imul(f,H)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(_,U),n=(n=Math.imul(_,G))+Math.imul(v,U)|0,o=Math.imul(v,G),r=r+Math.imul(p,j)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,j)|0,o=o+Math.imul(m,H)|0;var ve=(h+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(f,Y)|0))<<13)|0;h=((o=o+Math.imul(f,K)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(b,U),n=(n=Math.imul(b,G))+Math.imul(x,U)|0,o=Math.imul(x,G),r=r+Math.imul(_,j)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(v,j)|0,o=o+Math.imul(v,H)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,K)|0;var ye=(h+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,Q)|0)+Math.imul(f,Z)|0))<<13)|0;h=((o=o+Math.imul(f,Q)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(S,U),n=(n=Math.imul(S,G))+Math.imul(T,U)|0,o=Math.imul(T,G),r=r+Math.imul(b,j)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(x,j)|0,o=o+Math.imul(x,H)|0,r=r+Math.imul(_,Y)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,Q)|0;var be=(h+(r=r+Math.imul(l,$)|0)|0)+((8191&(n=(n=n+Math.imul(l,ee)|0)+Math.imul(f,$)|0))<<13)|0;h=((o=o+Math.imul(f,ee)|0)+(n>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(M,U),n=(n=Math.imul(M,G))+Math.imul(E,U)|0,o=Math.imul(E,G),r=r+Math.imul(S,j)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(T,j)|0,o=o+Math.imul(T,H)|0,r=r+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,K)|0,r=r+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,Q)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,Q)|0,r=r+Math.imul(p,$)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,ee)|0;var xe=(h+(r=r+Math.imul(l,ie)|0)|0)+((8191&(n=(n=n+Math.imul(l,re)|0)+Math.imul(f,ie)|0))<<13)|0;h=((o=o+Math.imul(f,re)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(C,U),n=(n=Math.imul(C,G))+Math.imul(R,U)|0,o=Math.imul(R,G),r=r+Math.imul(M,j)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(E,j)|0,o=o+Math.imul(E,H)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,K)|0,r=r+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,Q)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,Q)|0,r=r+Math.imul(_,$)|0,n=(n=n+Math.imul(_,ee)|0)+Math.imul(v,$)|0,o=o+Math.imul(v,ee)|0,r=r+Math.imul(p,ie)|0,n=(n=n+Math.imul(p,re)|0)+Math.imul(m,ie)|0,o=o+Math.imul(m,re)|0;var we=(h+(r=r+Math.imul(l,oe)|0)|0)+((8191&(n=(n=n+Math.imul(l,se)|0)+Math.imul(f,oe)|0))<<13)|0;h=((o=o+Math.imul(f,se)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(D,U),n=(n=Math.imul(D,G))+Math.imul(O,U)|0,o=Math.imul(O,G),r=r+Math.imul(C,j)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(R,j)|0,o=o+Math.imul(R,H)|0,r=r+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,K)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,Q)|0,r=r+Math.imul(b,$)|0,n=(n=n+Math.imul(b,ee)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,ee)|0,r=r+Math.imul(_,ie)|0,n=(n=n+Math.imul(_,re)|0)+Math.imul(v,ie)|0,o=o+Math.imul(v,re)|0,r=r+Math.imul(p,oe)|0,n=(n=n+Math.imul(p,se)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,se)|0;var Se=(h+(r=r+Math.imul(l,ce)|0)|0)+((8191&(n=(n=n+Math.imul(l,he)|0)+Math.imul(f,ce)|0))<<13)|0;h=((o=o+Math.imul(f,he)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(F,U),n=(n=Math.imul(F,G))+Math.imul(B,U)|0,o=Math.imul(B,G),r=r+Math.imul(D,j)|0,n=(n=n+Math.imul(D,H)|0)+Math.imul(O,j)|0,o=o+Math.imul(O,H)|0,r=r+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,K)|0,r=r+Math.imul(M,Z)|0,n=(n=n+Math.imul(M,Q)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,Q)|0,r=r+Math.imul(S,$)|0,n=(n=n+Math.imul(S,ee)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,ee)|0,r=r+Math.imul(b,ie)|0,n=(n=n+Math.imul(b,re)|0)+Math.imul(x,ie)|0,o=o+Math.imul(x,re)|0,r=r+Math.imul(_,oe)|0,n=(n=n+Math.imul(_,se)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,se)|0,r=r+Math.imul(p,ce)|0,n=(n=n+Math.imul(p,he)|0)+Math.imul(m,ce)|0,o=o+Math.imul(m,he)|0;var Te=(h+(r=r+Math.imul(l,le)|0)|0)+((8191&(n=(n=n+Math.imul(l,fe)|0)+Math.imul(f,le)|0))<<13)|0;h=((o=o+Math.imul(f,fe)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(V,U),n=(n=Math.imul(V,G))+Math.imul(N,U)|0,o=Math.imul(N,G),r=r+Math.imul(F,j)|0,n=(n=n+Math.imul(F,H)|0)+Math.imul(B,j)|0,o=o+Math.imul(B,H)|0,r=r+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,K)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,K)|0,r=r+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,Q)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,Q)|0,r=r+Math.imul(M,$)|0,n=(n=n+Math.imul(M,ee)|0)+Math.imul(E,$)|0,o=o+Math.imul(E,ee)|0,r=r+Math.imul(S,ie)|0,n=(n=n+Math.imul(S,re)|0)+Math.imul(T,ie)|0,o=o+Math.imul(T,re)|0,r=r+Math.imul(b,oe)|0,n=(n=n+Math.imul(b,se)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,se)|0,r=r+Math.imul(_,ce)|0,n=(n=n+Math.imul(_,he)|0)+Math.imul(v,ce)|0,o=o+Math.imul(v,he)|0,r=r+Math.imul(p,le)|0,n=(n=n+Math.imul(p,fe)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,fe)|0;var Ae=(h+(r=r+Math.imul(l,pe)|0)|0)+((8191&(n=(n=n+Math.imul(l,me)|0)+Math.imul(f,pe)|0))<<13)|0;h=((o=o+Math.imul(f,me)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(V,j),n=(n=Math.imul(V,H))+Math.imul(N,j)|0,o=Math.imul(N,H),r=r+Math.imul(F,Y)|0,n=(n=n+Math.imul(F,K)|0)+Math.imul(B,Y)|0,o=o+Math.imul(B,K)|0,r=r+Math.imul(D,Z)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,Q)|0,r=r+Math.imul(C,$)|0,n=(n=n+Math.imul(C,ee)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,ee)|0,r=r+Math.imul(M,ie)|0,n=(n=n+Math.imul(M,re)|0)+Math.imul(E,ie)|0,o=o+Math.imul(E,re)|0,r=r+Math.imul(S,oe)|0,n=(n=n+Math.imul(S,se)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,se)|0,r=r+Math.imul(b,ce)|0,n=(n=n+Math.imul(b,he)|0)+Math.imul(x,ce)|0,o=o+Math.imul(x,he)|0,r=r+Math.imul(_,le)|0,n=(n=n+Math.imul(_,fe)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,fe)|0;var Me=(h+(r=r+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;h=((o=o+Math.imul(m,me)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(V,Y),n=(n=Math.imul(V,K))+Math.imul(N,Y)|0,o=Math.imul(N,K),r=r+Math.imul(F,Z)|0,n=(n=n+Math.imul(F,Q)|0)+Math.imul(B,Z)|0,o=o+Math.imul(B,Q)|0,r=r+Math.imul(D,$)|0,n=(n=n+Math.imul(D,ee)|0)+Math.imul(O,$)|0,o=o+Math.imul(O,ee)|0,r=r+Math.imul(C,ie)|0,n=(n=n+Math.imul(C,re)|0)+Math.imul(R,ie)|0,o=o+Math.imul(R,re)|0,r=r+Math.imul(M,oe)|0,n=(n=n+Math.imul(M,se)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,se)|0,r=r+Math.imul(S,ce)|0,n=(n=n+Math.imul(S,he)|0)+Math.imul(T,ce)|0,o=o+Math.imul(T,he)|0,r=r+Math.imul(b,le)|0,n=(n=n+Math.imul(b,fe)|0)+Math.imul(x,le)|0,o=o+Math.imul(x,fe)|0;var Ee=(h+(r=r+Math.imul(_,pe)|0)|0)+((8191&(n=(n=n+Math.imul(_,me)|0)+Math.imul(v,pe)|0))<<13)|0;h=((o=o+Math.imul(v,me)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(V,Z),n=(n=Math.imul(V,Q))+Math.imul(N,Z)|0,o=Math.imul(N,Q),r=r+Math.imul(F,$)|0,n=(n=n+Math.imul(F,ee)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,ee)|0,r=r+Math.imul(D,ie)|0,n=(n=n+Math.imul(D,re)|0)+Math.imul(O,ie)|0,o=o+Math.imul(O,re)|0,r=r+Math.imul(C,oe)|0,n=(n=n+Math.imul(C,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,r=r+Math.imul(M,ce)|0,n=(n=n+Math.imul(M,he)|0)+Math.imul(E,ce)|0,o=o+Math.imul(E,he)|0,r=r+Math.imul(S,le)|0,n=(n=n+Math.imul(S,fe)|0)+Math.imul(T,le)|0,o=o+Math.imul(T,fe)|0;var Pe=(h+(r=r+Math.imul(b,pe)|0)|0)+((8191&(n=(n=n+Math.imul(b,me)|0)+Math.imul(x,pe)|0))<<13)|0;h=((o=o+Math.imul(x,me)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(V,$),n=(n=Math.imul(V,ee))+Math.imul(N,$)|0,o=Math.imul(N,ee),r=r+Math.imul(F,ie)|0,n=(n=n+Math.imul(F,re)|0)+Math.imul(B,ie)|0,o=o+Math.imul(B,re)|0,r=r+Math.imul(D,oe)|0,n=(n=n+Math.imul(D,se)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,se)|0,r=r+Math.imul(C,ce)|0,n=(n=n+Math.imul(C,he)|0)+Math.imul(R,ce)|0,o=o+Math.imul(R,he)|0,r=r+Math.imul(M,le)|0,n=(n=n+Math.imul(M,fe)|0)+Math.imul(E,le)|0,o=o+Math.imul(E,fe)|0;var Ce=(h+(r=r+Math.imul(S,pe)|0)|0)+((8191&(n=(n=n+Math.imul(S,me)|0)+Math.imul(T,pe)|0))<<13)|0;h=((o=o+Math.imul(T,me)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(V,ie),n=(n=Math.imul(V,re))+Math.imul(N,ie)|0,o=Math.imul(N,re),r=r+Math.imul(F,oe)|0,n=(n=n+Math.imul(F,se)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,se)|0,r=r+Math.imul(D,ce)|0,n=(n=n+Math.imul(D,he)|0)+Math.imul(O,ce)|0,o=o+Math.imul(O,he)|0,r=r+Math.imul(C,le)|0,n=(n=n+Math.imul(C,fe)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,fe)|0;var Re=(h+(r=r+Math.imul(M,pe)|0)|0)+((8191&(n=(n=n+Math.imul(M,me)|0)+Math.imul(E,pe)|0))<<13)|0;h=((o=o+Math.imul(E,me)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,r=Math.imul(V,oe),n=(n=Math.imul(V,se))+Math.imul(N,oe)|0,o=Math.imul(N,se),r=r+Math.imul(F,ce)|0,n=(n=n+Math.imul(F,he)|0)+Math.imul(B,ce)|0,o=o+Math.imul(B,he)|0,r=r+Math.imul(D,le)|0,n=(n=n+Math.imul(D,fe)|0)+Math.imul(O,le)|0,o=o+Math.imul(O,fe)|0;var Ie=(h+(r=r+Math.imul(C,pe)|0)|0)+((8191&(n=(n=n+Math.imul(C,me)|0)+Math.imul(R,pe)|0))<<13)|0;h=((o=o+Math.imul(R,me)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(V,ce),n=(n=Math.imul(V,he))+Math.imul(N,ce)|0,o=Math.imul(N,he),r=r+Math.imul(F,le)|0,n=(n=n+Math.imul(F,fe)|0)+Math.imul(B,le)|0,o=o+Math.imul(B,fe)|0;var De=(h+(r=r+Math.imul(D,pe)|0)|0)+((8191&(n=(n=n+Math.imul(D,me)|0)+Math.imul(O,pe)|0))<<13)|0;h=((o=o+Math.imul(O,me)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,r=Math.imul(V,le),n=(n=Math.imul(V,fe))+Math.imul(N,le)|0,o=Math.imul(N,fe);var Oe=(h+(r=r+Math.imul(F,pe)|0)|0)+((8191&(n=(n=n+Math.imul(F,me)|0)+Math.imul(B,pe)|0))<<13)|0;h=((o=o+Math.imul(B,me)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863;var Le=(h+(r=Math.imul(V,pe))|0)+((8191&(n=(n=Math.imul(V,me))+Math.imul(N,pe)|0))<<13)|0;return h=((o=Math.imul(N,me))+(n>>>13)|0)+(Le>>>26)|0,Le&=67108863,c[0]=ge,c[1]=_e,c[2]=ve,c[3]=ye,c[4]=be,c[5]=xe,c[6]=we,c[7]=Se,c[8]=Te,c[9]=Ae,c[10]=Me,c[11]=Ee,c[12]=Pe,c[13]=Ce,c[14]=Re,c[15]=Ie,c[16]=De,c[17]=Oe,c[18]=Le,0!==h&&(c[19]=h,i.length++),i};function m(e,t,i){return(new g).mulp(e,t,i)}function g(e,t){this.x=e,this.y=t}Math.imul||(p=d),s.prototype.mulTo=function(e,t){var i=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):i<63?d(this,e,t):i<1024?function(e,t,i){i.negative=t.negative^e.negative,i.length=e.length+t.length;for(var r=0,n=0,o=0;o<i.length-1;o++){var s=n;n=0;for(var a=67108863&r,c=Math.min(o,t.length-1),h=Math.max(0,o-e.length+1);h<=c;h++){var u=o-h,l=(0|e.words[u])*(0|t.words[h]),f=67108863&l;a=67108863&(f=f+a|0),n+=(s=(s=s+(l/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}i.words[o]=a,r=s,s=n}return 0!==r?i.words[o]=r:i.length--,i.strip()}(this,e,t):m(this,e,t)},g.prototype.makeRBT=function(e){for(var t=new Array(e),i=s.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,i,e);return t},g.prototype.revBin=function(e,t,i){if(0===e||e===i-1)return e;for(var r=0,n=0;n<t;n++)r|=(1&e)<<t-n-1,e>>=1;return r},g.prototype.permute=function(e,t,i,r,n,o){for(var s=0;s<o;s++)r[s]=t[e[s]],n[s]=i[e[s]]},g.prototype.transform=function(e,t,i,r,n,o){this.permute(o,e,t,i,r,n);for(var s=1;s<n;s<<=1)for(var a=s<<1,c=Math.cos(2*Math.PI/a),h=Math.sin(2*Math.PI/a),u=0;u<n;u+=a)for(var l=c,f=h,d=0;d<s;d++){var p=i[u+d],m=r[u+d],g=i[u+d+s],_=r[u+d+s],v=l*g-f*_;_=l*_+f*g,g=v,i[u+d]=p+g,r[u+d]=m+_,i[u+d+s]=p-g,r[u+d+s]=m-_,d!==a&&(v=c*l-h*f,f=c*f+h*l,l=v)}},g.prototype.guessLen13b=function(e,t){var i=1|Math.max(t,e),r=1&i,n=0;for(i=i/2|0;i;i>>>=1)n++;return 1<<n+1+r},g.prototype.conjugate=function(e,t,i){if(!(i<=1))for(var r=0;r<i/2;r++){var n=e[r];e[r]=e[i-r-1],e[i-r-1]=n,n=t[r],t[r]=-t[i-r-1],t[i-r-1]=-n}},g.prototype.normalize13b=function(e,t){for(var i=0,r=0;r<t/2;r++){var n=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+i;e[r]=67108863&n,i=n<67108864?0:n/67108864|0}return e},g.prototype.convert13b=function(e,t,i,r){for(var o=0,s=0;s<t;s++)o+=0|e[s],i[2*s]=8191&o,o>>>=13,i[2*s+1]=8191&o,o>>>=13;for(s=2*t;s<r;++s)i[s]=0;n(0===o),n(0==(-8192&o))},g.prototype.stub=function(e){for(var t=new Array(e),i=0;i<e;i++)t[i]=0;return t},g.prototype.mulp=function(e,t,i){var r=2*this.guessLen13b(e.length,t.length),n=this.makeRBT(r),o=this.stub(r),s=new Array(r),a=new Array(r),c=new Array(r),h=new Array(r),u=new Array(r),l=new Array(r),f=i.words;f.length=r,this.convert13b(e.words,e.length,s,r),this.convert13b(t.words,t.length,h,r),this.transform(s,o,a,c,r,n),this.transform(h,o,u,l,r,n);for(var d=0;d<r;d++){var p=a[d]*u[d]-c[d]*l[d];c[d]=a[d]*l[d]+c[d]*u[d],a[d]=p}return this.conjugate(a,c,r),this.transform(a,c,f,o,r,n),this.conjugate(f,o,r),this.normalize13b(f,r),i.negative=e.negative^t.negative,i.length=e.length+t.length,i.strip()},s.prototype.mul=function(e){var t=new s(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},s.prototype.mulf=function(e){var t=new s(null);return t.words=new Array(this.length+e.length),m(this,e,t)},s.prototype.imul=function(e){return this.clone().mulTo(e,this)},s.prototype.imuln=function(e){n("number"==typeof e),n(e<67108864);for(var t=0,i=0;i<this.length;i++){var r=(0|this.words[i])*e,o=(67108863&r)+(67108863&t);t>>=26,t+=r/67108864|0,t+=o>>>26,this.words[i]=67108863&o}return 0!==t&&(this.words[i]=t,this.length++),this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),i=0;i<t.length;i++){var r=i/26|0,n=i%26;t[i]=(e.words[r]&1<<n)>>>n}return t}(e);if(0===t.length)return new s(1);for(var i=this,r=0;r<t.length&&0===t[r];r++,i=i.sqr());if(++r<t.length)for(var n=i.sqr();r<t.length;r++,n=n.sqr())0!==t[r]&&(i=i.mul(n));return i},s.prototype.iushln=function(e){n("number"==typeof e&&e>=0);var t,i=e%26,r=(e-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var s=0;for(t=0;t<this.length;t++){var a=this.words[t]&o,c=(0|this.words[t])-a<<i;this.words[t]=c|s,s=a>>>26-i}s&&(this.words[t]=s,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t<r;t++)this.words[t]=0;this.length+=r}return this.strip()},s.prototype.ishln=function(e){return n(0===this.negative),this.iushln(e)},s.prototype.iushrn=function(e,t,i){var r;n("number"==typeof e&&e>=0),r=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<<o,c=i;if(r-=s,r=Math.max(0,r),c){for(var h=0;h<s;h++)c.words[h]=this.words[h];c.length=s}if(0===s);else if(this.length>s)for(this.length-=s,h=0;h<this.length;h++)this.words[h]=this.words[h+s];else this.words[0]=0,this.length=1;var u=0;for(h=this.length-1;h>=0&&(0!==u||h>=r);h--){var l=0|this.words[h];this.words[h]=u<<26-o|l>>>o,u=l&a}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(e,t,i){return n(0===this.negative),this.iushrn(e,t,i)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,i=(e-t)/26,r=1<<t;return!(this.length<=i)&&!!(this.words[i]&r)},s.prototype.imaskn=function(e){n("number"==typeof e&&e>=0);var t=e%26,i=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==t&&i++,this.length=Math.min(i,this.length),0!==t){var r=67108863^67108863>>>t<<t;this.words[this.length-1]&=r}return this.strip()},s.prototype.maskn=function(e){return this.clone().imaskn(e)},s.prototype.iaddn=function(e){return n("number"==typeof e),n(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},s.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},s.prototype.addn=function(e){return this.clone().iaddn(e)},s.prototype.subn=function(e){return this.clone().isubn(e)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(e,t,i){var r,o,s=e.length+i;this._expand(s);var a=0;for(r=0;r<e.length;r++){o=(0|this.words[r+i])+a;var c=(0|e.words[r])*t;a=((o-=67108863&c)>>26)-(c/67108864|0),this.words[r+i]=67108863&o}for(;r<this.length-i;r++)a=(o=(0|this.words[r+i])+a)>>26,this.words[r+i]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,r=0;r<this.length;r++)a=(o=-(0|this.words[r])+a)>>26,this.words[r]=67108863&o;return this.negative=1,this.strip()},s.prototype._wordDiv=function(e,t){var i=(this.length,e.length),r=this.clone(),n=e,o=0|n.words[n.length-1];0!==(i=26-this._countBits(o))&&(n=n.ushln(i),r.iushln(i),o=0|n.words[n.length-1]);var a,c=r.length-n.length;if("mod"!==t){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var u=r.clone()._ishlnsubmul(n,1,c);0===u.negative&&(r=u,a&&(a.words[c]=1));for(var l=c-1;l>=0;l--){var f=67108864*(0|r.words[n.length+l])+(0|r.words[n.length+l-1]);for(f=Math.min(f/o|0,67108863),r._ishlnsubmul(n,f,l);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(n,1,l),r.isZero()||(r.negative^=1);a&&(a.words[l]=f)}return a&&a.strip(),r.strip(),"div"!==t&&0!==i&&r.iushrn(i),{div:a||null,mod:r}},s.prototype.divmod=function(e,t,i){return n(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(r=a.div.neg()),"div"!==t&&(o=a.mod.neg(),i&&0!==o.negative&&o.iadd(e)),{div:r,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(r=a.div.neg()),{div:r,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),i&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var i=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),n=e.andln(1),o=i.cmp(r);return o<0||1===n&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,i=0,r=this.length-1;r>=0;r--)i=(t*i+(0|this.words[r]))%e;return i},s.prototype.idivn=function(e){n(e<=67108863);for(var t=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*t;this.words[i]=r/e|0,t=r%e}return this.strip()},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,i=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new s(1),o=new s(0),a=new s(0),c=new s(1),h=0;t.isEven()&&i.isEven();)t.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),l=t.clone();!t.isZero();){for(var f=0,d=1;0==(t.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(r.isOdd()||o.isOdd())&&(r.iadd(u),o.isub(l)),r.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(u),c.isub(l)),a.iushrn(1),c.iushrn(1);t.cmp(i)>=0?(t.isub(i),r.isub(a),o.isub(c)):(i.isub(t),a.isub(r),c.isub(o))}return{a:a,b:c,gcd:i.iushln(h)}},s.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,i=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,o=new s(1),a=new s(0),c=i.clone();t.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(t.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(t.iushrn(h);h-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var l=0,f=1;0==(i.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(i)>=0?(t.isub(i),o.isub(a)):(i.isub(t),a.isub(o))}return(r=0===t.cmpn(1)?o:a).cmpn(0)<0&&r.iadd(e),r},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),i=e.clone();t.negative=0,i.negative=0;for(var r=0;t.isEven()&&i.isEven();r++)t.iushrn(1),i.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=t.cmp(i);if(n<0){var o=t;t=i,i=o}else if(0===n||0===i.cmpn(1))break;t.isub(i)}return i.iushln(r)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,i=(e-t)/26,r=1<<t;if(this.length<=i)return this._expand(i+1),this.words[i]|=r,this;for(var o=r,s=i;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,i=e<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)t=1;else{i&&(e=-e),n(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:r<e?-1:1}return 0!==this.negative?0|-t:t},s.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},s.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,i=this.length-1;i>=0;i--){var r=0|this.words[i],n=0|e.words[i];if(r!==n){r<n?t=-1:r>n&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new S(e)},s.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var _={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function x(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function T(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,i=e;do{this.split(i,this.tmp),t=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:i.ucmp(this.p);return 0===r?(i.words[0]=0,i.length=1):r>0?i.isub(this.p):i.strip(),i},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},o(y,v),y.prototype.split=function(e,t){for(var i=Math.min(e.length,9),r=0;r<i;r++)t.words[r]=e.words[r];if(t.length=i,e.length<=9)return e.words[0]=0,void(e.length=1);var n=e.words[9];for(t.words[t.length++]=4194303&n,r=10;r<e.length;r++){var o=0|e.words[r];e.words[r-10]=(4194303&o)<<4|n>>>22,n=o}n>>>=22,e.words[r-10]=n,0===n&&e.length>10?e.length-=10:e.length-=9},y.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,i=0;i<e.length;i++){var r=0|e.words[i];t+=977*r,e.words[i]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},o(b,v),o(x,v),o(w,v),w.prototype.imulK=function(e){for(var t=0,i=0;i<e.length;i++){var r=19*(0|e.words[i])+t,n=67108863&r;r>>>=26,e.words[i]=n,t=r}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(_[e])return _[e];var t;if("k256"===e)t=new y;else if("p224"===e)t=new b;else if("p192"===e)t=new x;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return _[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var i=e.add(t);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var i=e.iadd(t);return i.cmp(this.m)>=0&&i.isub(this.m),i},S.prototype.sub=function(e,t){this._verify2(e,t);var i=e.sub(t);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var i=e.isub(t);return i.cmpn(0)<0&&i.iadd(this.m),i},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var i=this.m.add(new s(1)).iushrn(2);return this.pow(e,i)}for(var r=this.m.subn(1),o=0;!r.isZero()&&0===r.andln(1);)o++,r.iushrn(1);n(!r.isZero());var a=new s(1).toRed(this),c=a.redNeg(),h=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new s(2*u*u).toRed(this);0!==this.pow(u,h).cmp(c);)u.redIAdd(c);for(var l=this.pow(u,r),f=this.pow(e,r.addn(1).iushrn(1)),d=this.pow(e,r),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();n(g<p);var _=this.pow(l,new s(1).iushln(p-g-1));f=f.redMul(_),l=_.redSqr(),d=d.redMul(l),p=g}return f},S.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},S.prototype.pow=function(e,t){if(t.isZero())return new s(1).toRed(this);if(0===t.cmpn(1))return e.clone();var i=new Array(16);i[0]=new s(1).toRed(this),i[1]=e;for(var r=2;r<i.length;r++)i[r]=this.mul(i[r-1],e);var n=i[0],o=0,a=0,c=t.bitLength()%26;for(0===c&&(c=26),r=t.length-1;r>=0;r--){for(var h=t.words[r],u=c-1;u>=0;u--){var l=h>>u&1;n!==i[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===r&&0===u)&&(n=this.mul(n,i[o]),a=0,o=0)):a=0}c=26}return n},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new T(e)},o(T,S),T.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},T.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},T.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var i=e.imul(t),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},T.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var i=e.mul(t),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},T.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,i(167)(e))},function(e,t,i){var r=i(4),n=i(137),o=i(39),s=Object.defineProperty;t.f=i(13)?Object.defineProperty:function(e,t,i){if(r(e),t=o(t,!0),r(i),n)try{return s(e,t,i)}catch(e){}if("get"in i||"set"in i)throw TypeError("Accessors not supported!");return"value"in i&&(e[t]=i.value),e}},function(e,t,i){e.exports=!i(3)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){var i=e.exports={version:"2.6.0"};"number"==typeof __e&&(__e=i)},function(e,t){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"===("undefined"==typeof window?"undefined":i(window))&&(r=window)}e.exports=r},function(e,t,i){e.exports={EPSILON:i(173),create:i(174),clone:i(413),angle:i(414),fromValues:i(175),copy:i(415),set:i(416),equals:i(417),exactEquals:i(418),add:i(419),subtract:i(178),sub:i(420),multiply:i(179),mul:i(421),divide:i(180),div:i(422),min:i(423),max:i(424),floor:i(425),ceil:i(426),round:i(427),scale:i(428),scaleAndAdd:i(429),distance:i(181),dist:i(430),squaredDistance:i(182),sqrDist:i(431),length:i(183),len:i(432),squaredLength:i(184),sqrLen:i(433),negate:i(434),inverse:i(435),normalize:i(176),dot:i(177),cross:i(436),lerp:i(437),random:i(438),transformMat4:i(439),transformMat3:i(440),transformQuat:i(441),rotateX:i(442),rotateY:i(443),rotateZ:i(444),forEach:i(445)}},function(e,t,i){"use strict";var r=t;r.version=i(549).version,r.utils=i(550),r.rand=i(213),r.curve=i(91),r.curves=i(555),r.ec=i(563),r.eddsa=i(567)},function(e,t,i){"use strict";(function(e){function r(t,i,r,n,o,s,a){try{var c=t[s](a),h=c.value}catch(e){return void r(e)}c.done?i(h):e.resolve(h).then(n,o)}function n(t){return function(){var i=this,n=arguments;return new e(function(e,o){var s=t.apply(i,n);function a(t){r(s,e,o,a,c,"next",t)}function c(t){r(s,e,o,a,c,"throw",t)}a(void 0)})}}function o(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var s=i(397),a=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}var i,r,a;return i=t,r=null,a=[{key:"init",value:function(){self.baseUrl=s.backendBaseUrl,self.socket=null}},{key:"getICECandidates",value:function(i){return new e(function(e,r){t.executeXhr("/get-ice-candidates/"+i,"get").then(function(t){e([JSON.parse(t).v.iceServers])})})}},{key:"getNewGame",value:function(){return new e(function(e,i){t.executeXhr("/game","get").then(function(i){var r=JSON.parse(i);e(r),setInterval(function(){t.executeXhr("/game/"+r.code+"/heartbeat","put").then(function(e){})},5e3)})})}},{key:"getGame",value:function(i){return null==i?t.getNewGame():new e(function(e,r){t.executeXhr("/game/"+i,"get").then(function(t){e(JSON.parse(t))},function(t){e(null)})})}},{key:"listenForData",value:function(){var e=n(regeneratorRuntime.mark(function e(t,i){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==self.socket){e.next=3;break}return console.log("no socket!"),e.abrupt("return");case 3:socket.addEventListener("message",function(e){var t=JSON.parse(e.data),r={payload:t.p,meta:t.m,msgEvent:t.o,to:t.m.t,from:t.m.f};i(r)});case 4:case"end":return e.stop()}},e,this)}));return function(t,i){return e.apply(this,arguments)}}()},{key:"createSignalingChannel",value:function(){var i=n(regeneratorRuntime.mark(function i(r,o){return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.abrupt("return",new e(function(){var e=n(regeneratorRuntime.mark(function e(i,n){var s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.executeXhr("/create-channel/"+r,"get");case 2:return e.next=4,t.getWebSocket(r,o);case 4:s=e.sent,self.socket=s,s.addEventListener("open",function(){i(),setInterval(function(){s.send("ping")},800)});case 7:case"end":return e.stop()}},e,this)}));return function(t,i){return e.apply(this,arguments)}}()));case 1:case"end":return i.stop()}},i,this)}));return function(e,t){return i.apply(this,arguments)}}()},{key:"joinSignalingChannel",value:function(){var i=n(regeneratorRuntime.mark(function i(r,o){return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.abrupt("return",new e(function(){var e=n(regeneratorRuntime.mark(function e(i,n){var s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getWebSocket(r,o);case 2:s=e.sent,self.socket=s,s.addEventListener("open",function(){i(),setInterval(function(){s.send("ping")},800)});case 5:case"end":return e.stop()}},e,this)}));return function(t,i){return e.apply(this,arguments)}}()));case 1:case"end":return i.stop()}},i,this)}));return function(e,t){return i.apply(this,arguments)}}()},{key:"sendSignalingTo",value:function(){var e=n(regeneratorRuntime.mark(function e(t,i,r,n){var o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==self.socket){e.next=3;break}return console.log("no socket!"),e.abrupt("return");case 3:o={t:"u",m:{f:t+"/"+r,t:i,o:"message"},p:{signal:JSON.stringify(n)}},self.socket.send(JSON.stringify(o));case 5:case"end":return e.stop()}},e,this)}));return function(t,i,r,n){return e.apply(this,arguments)}}()},{key:"getWebSocket",value:function(){var e=n(regeneratorRuntime.mark(function e(i,r){var n,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=JSON,e.next=3,t.executeXhr("/get-signaling-token/"+i+"/"+r,"get");case 3:return e.t1=e.sent,n=e.t0.parse.call(e.t0,e.t1).v,e.t2=JSON,e.next=8,t.executeXhr("/get-signaling-host/"+i+"/"+r,"get");case 8:return e.t3=e.sent,o=e.t2.parse.call(e.t2,e.t3).v,s=o+"/v2/"+n,e.abrupt("return",new WebSocket(s));case 12:case"end":return e.stop()}},e,this)}));return function(t,i){return e.apply(this,arguments)}}()},{key:"addPlayerToGame",value:function(i,r){return new e(function(e,r){t.executeXhr("/game/"+i,"put").then(function(t){e(JSON.parse(t))})})}},{key:"pathUrl",value:function(e){return self.baseUrl+e}},{key:"executeXhr",value:function(i,r){return new e(function(e,n){var o=new XMLHttpRequest,s=t.pathUrl(i);o.open(r,s),o.onreadystatechange=function(){4!==o.readyState||404!==o.status||n()},o.send(),o.onload=function(){e(o.responseText)},o.onerror=function(e){console.log(e),n(e)}})}}],r&&o(i.prototype,r),a&&o(i,a),t}();t.a=a}).call(this,i(52))},function(e,t,i){var r=i(5),n=i(23),o=i(22),s=i(45)("src"),a=Function.toString,c=(""+a).split("toString");i(14).inspectSource=function(e){return a.call(e)},(e.exports=function(e,t,i,a){var h="function"==typeof i;h&&(o(i,"name")||n(i,"name",t)),e[t]!==i&&(h&&(o(i,s)||n(i,s,e[t]?""+e[t]:c.join(String(t)))),e===r?e[t]=i:a?e[t]?e[t]=i:n(e,t,i):(delete e[t],n(e,t,i)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[s]||a.call(this)})},function(e,t,i){var r=i(37);e.exports=function(e){return Object(r(e))}},function(e,t,i){var r=i(0),n=i(3),o=i(37),s=/"/g,a=function(e,t,i,r){var n=String(o(e)),a="<"+t;return""!==i&&(a+=" "+i+'="'+String(r).replace(s,"&quot;")+'"'),a+">"+n+"</"+t+">"};e.exports=function(e,t){var i={};i[e]=t(a),r(r.P+r.F*n(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}),"String",i)}},function(e,t){var i={}.hasOwnProperty;e.exports=function(e,t){return i.call(e,t)}},function(e,t,i){var r=i(12),n=i(44);e.exports=i(13)?function(e,t,i){return r.f(e,t,n(1,i))}:function(e,t,i){return e[t]=i,e}},function(e,t,i){var r=i(64),n=i(37);e.exports=function(e){return r(n(e))}},function(e,t){function i(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=i,i.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}},function(e,t,i){"use strict";var r=i(3);e.exports=function(e,t){return!!e&&r(function(){t?e.call(null,function(){},1):e.call(null)})}},function(e,t){var i,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(i===setTimeout)return setTimeout(e,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:o}catch(e){i=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,h=[],u=!1,l=-1;function f(){u&&c&&(u=!1,c.length?h=c.concat(h):l=-1,h.length&&d())}function d(){if(!u){var e=a(f);u=!0;for(var t=h.length;t;){for(c=h,h=[];++l<t;)c&&c[l].run();l=-1,t=h.length}c=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];h.push(new p(e,t)),1!==h.length||u||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(e,t){var i=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:i)(e)}},function(e,t,i){var r=i(65),n=i(44),o=i(24),s=i(39),a=i(22),c=i(137),h=Object.getOwnPropertyDescriptor;t.f=i(13)?h:function(e,t){if(e=o(e),t=s(t,!0),c)try{return h(e,t)}catch(e){}if(a(e,t))return n(!r.f.call(e,t),e[t])}},function(e,t,i){var r=i(0),n=i(14),o=i(3);e.exports=function(e,t){var i=(n.Object||{})[e]||Object[e],s={};s[e]=t(i),r(r.S+r.F*o(function(){i(1)}),"Object",s)}},function(e,t,i){var r=i(34),n=i(64),o=i(20),s=i(10),a=i(321);e.exports=function(e,t){var i=1==e,c=2==e,h=3==e,u=4==e,l=6==e,f=5==e||l,d=t||a;return function(t,a,p){for(var m,g,_=o(t),v=n(_),y=r(a,p,3),b=s(v.length),x=0,w=i?d(t,b):c?d(t,0):void 0;b>x;x++)if((f||x in v)&&(g=y(m=v[x],x,_),e))if(i)w[x]=g;else if(g)switch(e){case 3:return!0;case 5:return m;case 6:return x;case 2:w.push(m)}else if(u)return!1;return l?-1:h||u?u:w}}},function(e,t,i){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===o.call(e)},h=function(e){if(!e||"[object Object]"!==o.call(e))return!1;var t,i=n.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!i&&!r)return!1;for(t in e);return void 0===t||n.call(e,t)},u=function(e,t){s&&"__proto__"===t.name?s(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if("__proto__"===t){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};e.exports=function e(){var t,i,n,o,s,a,f=arguments[0],d=1,p=arguments.length,m=!1;for("boolean"==typeof f&&(m=f,f=arguments[1]||{},d=2),(null==f||"object"!==r(f)&&"function"!=typeof f)&&(f={});d<p;++d)if(null!=(t=arguments[d]))for(i in t)n=l(f,i),f!==(o=l(t,i))&&(m&&o&&(h(o)||(s=c(o)))?(s?(s=!1,a=n&&c(n)?n:[]):a=n&&h(n)?n:{},u(f,{name:i,newValue:e(m,a,o)})):void 0!==o&&u(f,{name:i,newValue:o}));return f}},function(e,t,i){"use strict";var r=i(25),n=i(1);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var i=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n<e.length;n+=2)i.push(parseInt(e[n]+e[n+1],16))}else for(var r=0,n=0;n<e.length;n++){var s=e.charCodeAt(n);s<128?i[r++]=s:s<2048?(i[r++]=s>>6|192,i[r++]=63&s|128):o(e,n)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++n)),i[r++]=s>>18|240,i[r++]=s>>12&63|128,i[r++]=s>>6&63|128,i[r++]=63&s|128):(i[r++]=s>>12|224,i[r++]=s>>6&63|128,i[r++]=63&s|128)}else for(n=0;n<e.length;n++)i[n]=0|e[n];return i},t.toHex=function(e){for(var t="",i=0;i<e.length;i++)t+=a(e[i].toString(16));return t},t.htonl=s,t.toHex32=function(e,t){for(var i="",r=0;r<e.length;r++){var n=e[r];"little"===t&&(n=s(n)),i+=c(n.toString(16))}return i},t.zero2=a,t.zero8=c,t.join32=function(e,t,i,n){var o=i-t;r(o%4==0);for(var s=new Array(o/4),a=0,c=t;a<s.length;a++,c+=4){var h;h="big"===n?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],s[a]=h>>>0}return s},t.split32=function(e,t){for(var i=new Array(4*e.length),r=0,n=0;r<e.length;r++,n+=4){var o=e[r];"big"===t?(i[n]=o>>>24,i[n+1]=o>>>16&255,i[n+2]=o>>>8&255,i[n+3]=255&o):(i[n+3]=o>>>24,i[n+2]=o>>>16&255,i[n+1]=o>>>8&255,i[n]=255&o)}return i},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,i){return e+t+i>>>0},t.sum32_4=function(e,t,i,r){return e+t+i+r>>>0},t.sum32_5=function(e,t,i,r,n){return e+t+i+r+n>>>0},t.sum64=function(e,t,i,r){var n=e[t],o=r+e[t+1]>>>0,s=(o<r?1:0)+i+n;e[t]=s>>>0,e[t+1]=o},t.sum64_hi=function(e,t,i,r){return(t+r>>>0<t?1:0)+e+i>>>0},t.sum64_lo=function(e,t,i,r){return t+r>>>0},t.sum64_4_hi=function(e,t,i,r,n,o,s,a){var c=0,h=t;return c+=(h=h+r>>>0)<t?1:0,c+=(h=h+o>>>0)<o?1:0,e+i+n+s+(c+=(h=h+a>>>0)<a?1:0)>>>0},t.sum64_4_lo=function(e,t,i,r,n,o,s,a){return t+r+o+a>>>0},t.sum64_5_hi=function(e,t,i,r,n,o,s,a,c,h){var u=0,l=t;return u+=(l=l+r>>>0)<t?1:0,u+=(l=l+o>>>0)<o?1:0,u+=(l=l+a>>>0)<a?1:0,e+i+n+s+c+(u+=(l=l+h>>>0)<h?1:0)>>>0},t.sum64_5_lo=function(e,t,i,r,n,o,s,a,c,h){return t+r+o+a+h>>>0},t.rotr64_hi=function(e,t,i){return(t<<32-i|e>>>i)>>>0},t.rotr64_lo=function(e,t,i){return(e<<32-i|t>>>i)>>>0},t.shr64_hi=function(e,t,i){return e>>>i},t.shr64_lo=function(e,t,i){return(e<<32-i|t>>>i)>>>0}},function(e,t,i){var r=i(35);e.exports=function(e,t,i){if(r(e),void 0===t)return e;switch(i){case 1:return function(i){return e.call(t,i)};case 2:return function(i,r){return e.call(t,i,r)};case 3:return function(i,r,n){return e.call(t,i,r,n)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t){var i={}.toString;e.exports=function(e){return i.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,i){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}if(i(13)){var n=i(46),o=i(5),s=i(3),a=i(0),c=i(84),h=i(121),u=i(34),l=i(60),f=i(44),d=i(23),p=i(61),m=i(28),g=i(10),_=i(163),v=i(48),y=i(39),b=i(22),x=i(66),w=i(6),S=i(20),T=i(113),A=i(49),M=i(51),E=i(50).f,P=i(115),C=i(45),R=i(8),I=i(31),D=i(74),O=i(67),L=i(117),F=i(57),B=i(77),k=i(59),V=i(116),N=i(154),z=i(12),U=i(29),G=z.f,W=U.f,j=o.RangeError,H=o.TypeError,X=o.Uint8Array,Y=Array.prototype,K=h.ArrayBuffer,q=h.DataView,Z=I(0),Q=I(2),J=I(3),$=I(4),ee=I(5),te=I(6),ie=D(!0),re=D(!1),ne=L.values,oe=L.keys,se=L.entries,ae=Y.lastIndexOf,ce=Y.reduce,he=Y.reduceRight,ue=Y.join,le=Y.sort,fe=Y.slice,de=Y.toString,pe=Y.toLocaleString,me=R("iterator"),ge=R("toStringTag"),_e=C("typed_constructor"),ve=C("def_constructor"),ye=c.CONSTR,be=c.TYPED,xe=c.VIEW,we=I(1,function(e,t){return Ee(O(e,e[ve]),t)}),Se=s(function(){return 1===new X(new Uint16Array([1]).buffer)[0]}),Te=!!X&&!!X.prototype.set&&s(function(){new X(1).set({})}),Ae=function(e,t){var i=m(e);if(i<0||i%t)throw j("Wrong offset!");return i},Me=function(e){if(w(e)&&be in e)return e;throw H(e+" is not a typed array!")},Ee=function(e,t){if(!(w(e)&&_e in e))throw H("It is not a typed array constructor!");return new e(t)},Pe=function(e,t){return Ce(O(e,e[ve]),t)},Ce=function(e,t){for(var i=0,r=t.length,n=Ee(e,r);r>i;)n[i]=t[i++];return n},Re=function(e,t,i){G(e,t,{get:function(){return this._d[i]}})},Ie=function(e){var t,i,r,n,o,s,a=S(e),c=arguments.length,h=c>1?arguments[1]:void 0,l=void 0!==h,f=P(a);if(null!=f&&!T(f)){for(s=f.call(a),r=[],t=0;!(o=s.next()).done;t++)r.push(o.value);a=r}for(l&&c>2&&(h=u(h,arguments[2],2)),t=0,i=g(a.length),n=Ee(this,i);i>t;t++)n[t]=l?h(a[t],t):a[t];return n},De=function(){for(var e=0,t=arguments.length,i=Ee(this,t);t>e;)i[e]=arguments[e++];return i},Oe=!!X&&s(function(){pe.call(new X(1))}),Le=function(){return pe.apply(Oe?fe.call(Me(this)):Me(this),arguments)},Fe={copyWithin:function(e,t){return N.call(Me(this),e,t,arguments.length>2?arguments[2]:void 0)},every:function(e){return $(Me(this),e,arguments.length>1?arguments[1]:void 0)},fill:function(e){return V.apply(Me(this),arguments)},filter:function(e){return Pe(this,Q(Me(this),e,arguments.length>1?arguments[1]:void 0))},find:function(e){return ee(Me(this),e,arguments.length>1?arguments[1]:void 0)},findIndex:function(e){return te(Me(this),e,arguments.length>1?arguments[1]:void 0)},forEach:function(e){Z(Me(this),e,arguments.length>1?arguments[1]:void 0)},indexOf:function(e){return re(Me(this),e,arguments.length>1?arguments[1]:void 0)},includes:function(e){return ie(Me(this),e,arguments.length>1?arguments[1]:void 0)},join:function(e){return ue.apply(Me(this),arguments)},lastIndexOf:function(e){return ae.apply(Me(this),arguments)},map:function(e){return we(Me(this),e,arguments.length>1?arguments[1]:void 0)},reduce:function(e){return ce.apply(Me(this),arguments)},reduceRight:function(e){return he.apply(Me(this),arguments)},reverse:function(){for(var e,t=Me(this).length,i=Math.floor(t/2),r=0;r<i;)e=this[r],this[r++]=this[--t],this[t]=e;return this},some:function(e){return J(Me(this),e,arguments.length>1?arguments[1]:void 0)},sort:function(e){return le.call(Me(this),e)},subarray:function(e,t){var i=Me(this),r=i.length,n=v(e,r);return new(O(i,i[ve]))(i.buffer,i.byteOffset+n*i.BYTES_PER_ELEMENT,g((void 0===t?r:v(t,r))-n))}},Be=function(e,t){return Pe(this,fe.call(Me(this),e,t))},ke=function(e){Me(this);var t=Ae(arguments[1],1),i=this.length,r=S(e),n=g(r.length),o=0;if(n+t>i)throw j("Wrong length!");for(;o<n;)this[t+o]=r[o++]},Ve={entries:function(){return se.call(Me(this))},keys:function(){return oe.call(Me(this))},values:function(){return ne.call(Me(this))}},Ne=function(e,t){return w(e)&&e[be]&&"symbol"!=r(t)&&t in e&&String(+t)==String(t)},ze=function(e,t){return Ne(e,t=y(t,!0))?f(2,e[t]):W(e,t)},Ue=function(e,t,i){return!(Ne(e,t=y(t,!0))&&w(i)&&b(i,"value"))||b(i,"get")||b(i,"set")||i.configurable||b(i,"writable")&&!i.writable||b(i,"enumerable")&&!i.enumerable?G(e,t,i):(e[t]=i.value,e)};ye||(U.f=ze,z.f=Ue),a(a.S+a.F*!ye,"Object",{getOwnPropertyDescriptor:ze,defineProperty:Ue}),s(function(){de.call({})})&&(de=pe=function(){return ue.call(this)});var Ge=p({},Fe);p(Ge,Ve),d(Ge,me,Ve.values),p(Ge,{slice:Be,set:ke,constructor:function(){},toString:de,toLocaleString:Le}),Re(Ge,"buffer","b"),Re(Ge,"byteOffset","o"),Re(Ge,"byteLength","l"),Re(Ge,"length","e"),G(Ge,ge,{get:function(){return this[be]}}),e.exports=function(e,t,i,r){var h=e+((r=!!r)?"Clamped":"")+"Array",u="get"+e,f="set"+e,p=o[h],m=p||{},v=p&&M(p),y=!p||!c.ABV,b={},S=p&&p.prototype,T=function(e,i){G(e,i,{get:function(){return function(e,i){var r=e._d;return r.v[u](i*t+r.o,Se)}(this,i)},set:function(e){return function(e,i,n){var o=e._d;r&&(n=(n=Math.round(n))<0?0:n>255?255:255&n),o.v[f](i*t+o.o,n,Se)}(this,i,e)},enumerable:!0})};y?(p=i(function(e,i,r,n){l(e,p,h,"_d");var o,s,a,c,u=0,f=0;if(w(i)){if(!(i instanceof K||"ArrayBuffer"==(c=x(i))||"SharedArrayBuffer"==c))return be in i?Ce(p,i):Ie.call(p,i);o=i,f=Ae(r,t);var m=i.byteLength;if(void 0===n){if(m%t)throw j("Wrong length!");if((s=m-f)<0)throw j("Wrong length!")}else if((s=g(n)*t)+f>m)throw j("Wrong length!");a=s/t}else a=_(i),o=new K(s=a*t);for(d(e,"_d",{b:o,o:f,l:s,e:a,v:new q(o)});u<a;)T(e,u++)}),S=p.prototype=A(Ge),d(S,"constructor",p)):s(function(){p(1)})&&s(function(){new p(-1)})&&B(function(e){new p,new p(null),new p(1.5),new p(e)},!0)||(p=i(function(e,i,r,n){var o;return l(e,p,h),w(i)?i instanceof K||"ArrayBuffer"==(o=x(i))||"SharedArrayBuffer"==o?void 0!==n?new m(i,Ae(r,t),n):void 0!==r?new m(i,Ae(r,t)):new m(i):be in i?Ce(p,i):Ie.call(p,i):new m(_(i))}),Z(v!==Function.prototype?E(m).concat(E(v)):E(m),function(e){e in p||d(p,e,m[e])}),p.prototype=S,n||(S.constructor=p));var P=S[me],C=!!P&&("values"==P.name||null==P.name),R=Ve.values;d(p,_e,!0),d(S,be,h),d(S,xe,!0),d(S,ve,p),(r?new p(1)[ge]==h:ge in S)||G(S,ge,{get:function(){return h}}),b[h]=p,a(a.G+a.W+a.F*(p!=m),b),a(a.S,h,{BYTES_PER_ELEMENT:t}),a(a.S+a.F*s(function(){m.of.call(p,1)}),h,{from:Ie,of:De}),"BYTES_PER_ELEMENT"in S||d(S,"BYTES_PER_ELEMENT",t),a(a.P,h,Fe),k(h),a(a.P+a.F*Te,h,{set:ke}),a(a.P+a.F*!C,h,Ve),n||S.toString==de||(S.toString=de),a(a.P+a.F*s(function(){new p(1).slice()}),h,{slice:Be}),a(a.P+a.F*(s(function(){return[1,2].toLocaleString()!=new p([1,2]).toLocaleString()})||!s(function(){S.toLocaleString.call([1,2])})),h,{toLocaleString:Le}),F[h]=C?P:R,n||C||d(S,me,R)}}else e.exports=function(){}},function(e,t,i){var r=i(6);e.exports=function(e,t){if(!r(e))return e;var i,n;if(t&&"function"==typeof(i=e.toString)&&!r(n=i.call(e)))return n;if("function"==typeof(i=e.valueOf)&&!r(n=i.call(e)))return n;if(!t&&"function"==typeof(i=e.toString)&&!r(n=i.call(e)))return n;throw TypeError("Can't convert object to primitive value")}},function(e,t,i){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=i(45)("meta"),o=i(6),s=i(22),a=i(12).f,c=0,h=Object.isExtensible||function(){return!0},u=!i(3)(function(){return h(Object.preventExtensions({}))}),l=function(e){a(e,n,{value:{i:"O"+ ++c,w:{}}})},f=e.exports={KEY:n,NEED:!1,fastKey:function(e,t){if(!o(e))return"symbol"==r(e)?e:("string"==typeof e?"S":"P")+e;if(!s(e,n)){if(!h(e))return"F";if(!t)return"E";l(e)}return e[n].i},getWeak:function(e,t){if(!s(e,n)){if(!h(e))return!0;if(!t)return!1;l(e)}return e[n].w},onFreeze:function(e){return u&&f.NEED&&h(e)&&!s(e,n)&&l(e),e}}},function(e,t){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function o(e){return"object"===i(e)&&null!==e}function s(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,i,r,a,c,h;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(s(i=this._events[e]))return!1;if(n(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),i.apply(this,a)}else if(o(i))for(a=Array.prototype.slice.call(arguments,1),r=(h=i.slice()).length,c=0;c<r;c++)h[c].apply(this,a);return!0},r.prototype.addListener=function(e,t){var i;if(!n(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var i=!1;function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var i,r,s,a;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(i=this._events[e]).length,r=-1,i===t||n(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(i)){for(a=s;a-- >0;)if(i[a]===t||i[a].listener&&i[a].listener===t){r=a;break}if(r<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(i=this._events[e]))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,i){"use strict";e.exports={Timer:function(e,t){var i=t||"",r=e||1,n=[],o=[],s=0,a=0,c=0,h=0,u=!0;this.start=function(){u&&(n.length=o.length=0,u=!1),s=a=performance.now(),c++},this.add=function(e){var t=performance.now();o.indexOf(e)<0&&o.push(e);var i=o.indexOf(e);n[i]||(n[i]=0),n[i]+=t-a,a=t},this.report=function(){if(h+=performance.now()-s,c===r){var e=" total: "+(h/r).toFixed(2)+"ms (avg, "+r+" runs)";console.log(i+":",o.map(function(e,t){return e+": "+(n[t]/r).toFixed(2)+"ms "}).join(""),r>1?e:""),u=!0,c=0,h=0}}},removeUnorderedListItem:function(e,t){var i=e.indexOf(t);if(i<0)return;i===e.length-1?e.pop():e[i]=e.pop()}}},function(e,t,i){var r=i(2).Buffer,n=i(127).Transform,o=i(123).StringDecoder;function s(e){n.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}i(1)(s,n),s.prototype.update=function(e,t,i){"string"==typeof e&&(e=r.from(e,t));var n=this._update(e);return this.hashMode?this:(i&&(n=this._toString(n,i)),n)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(e,t,i){var r;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){r=e}finally{i(r)}},s.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},s.prototype._finalOrDigest=function(e){var t=this.__final()||r.alloc(0);return e&&(t=this._toString(t,e,!0)),t},s.prototype._toString=function(e,t,i){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var r=this._decoder.write(e);return i&&(r+=this._decoder.end()),r},e.exports=s},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){var i=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++i+r).toString(36))}},function(e,t){e.exports=!1},function(e,t,i){var r=i(139),n=i(99);e.exports=Object.keys||function(e){return r(e,n)}},function(e,t,i){var r=i(28),n=Math.max,o=Math.min;e.exports=function(e,t){return(e=r(e))<0?n(e+t,0):o(e,t)}},function(e,t,i){var r=i(4),n=i(140),o=i(99),s=i(98)("IE_PROTO"),a=function(){},c=function(){var e,t=i(95)("iframe"),r=o.length;for(t.style.display="none",i(101).appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("<script>document.F=Object<\/script>"),e.close(),c=e.F;r--;)delete c.prototype[o[r]];return c()};e.exports=Object.create||function(e,t){var i;return null!==e?(a.prototype=r(e),i=new a,a.prototype=null,i[s]=e):i=c(),void 0===t?i:n(i,t)}},function(e,t,i){var r=i(139),n=i(99).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return r(e,n)}},function(e,t,i){var r=i(22),n=i(20),o=i(98)("IE_PROTO"),s=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=n(e),r(e,o)?e[o]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?s:null}},function(e,t,i){e.exports=i(394).Promise},function(e,t,i){"use strict";(function(t,r){var n=i(2).Buffer,o=t.crypto||t.msCrypto;o&&o.getRandomValues?e.exports=function(e,i){if(e>65536)throw new Error("requested too many random bytes");var s=new t.Uint8Array(e);e>0&&o.getRandomValues(s);var a=n.from(s.buffer);if("function"==typeof i)return r.nextTick(function(){i(null,a)});return a}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,i(15),i(27))},function(e,t,i){"use strict";var r=i(86),n=Object.keys||function(e){var t=[];for(var i in e)t.push(i);return t};e.exports=l;var o=i(68);o.inherits=i(1);var s=i(169),a=i(122);o.inherits(l,s);for(var c=n(a.prototype),h=0;h<c.length;h++){var u=c[h];l.prototype[u]||(l.prototype[u]=a.prototype[u])}function l(e){if(!(this instanceof l))return new l(e);s.call(this,e),a.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",f)}function f(){this.allowHalfOpen||this._writableState.ended||r.nextTick(d,this)}function d(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),l.prototype._destroy=function(e,t){this.push(null),this.end(),r.nextTick(t,e)}},function(e,t,i){"use strict";var r=i(94);function n(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===e.id&&(e.id=1e4),this.isClient=t.isClient,this.isSelf=void 0!==t.isSelf&&t.isSelf,this.network=void 0!==t.network?t.network:null,this.initializeState(t),this.positionCallback="function"==typeof i?i:null,this.id=e.id+=1,!0===this.isClient&&this.sendJoined()}var t,i,o;return t=e,(i=[{key:"initializeState",value:function(e){this.state={name:e.name,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},walking:!1,spawned:!1},this.peer=e.peer}},{key:"setPosition",value:function(e,t,i){this.state.walking=e.x!==this.state.position.x||e.z!==this.state.position.z,this.state.position=e,this.state.rotation=t,this.state.spawned=i,this.positionCallback&&this.positionCallback(this.state)}},{key:"setState",value:function(e){var t=this.state.name!==e.name;this.state.position=e.position,this.state.rotation=e.rotation,this.state.walking=e.walking,this.state.spawned=e.spawned,this.state.name=e.name,(void 0===this.noaPlayer||t)&&this.state.spawned&&(void 0!==this.noaPlayer&&this.noaPlayer.remove(),this.noaPlayer=r.a.getInstance().addPlayer(0,0,0,this.state.name,this.id)),void 0!==this.noaPlayer&&(this.noaPlayer.setPosition(e.position.x,e.position.y,e.position.z),this.noaPlayer.setRotation(0,e.rotation.y,0),this.noaPlayer.walking=e.walking)}},{key:"sendJoined",value:function(){null!=this.network&&this.network.sendJoined(this.state.name)}},{key:"sendMessage",value:function(e){null!=this.network&&this.network.sendMessage(e)}},{key:"emitFireEvent",value:function(e){null!=this.network&&this.network.emitFireEvent(e)}}])&&n(t.prototype,i),o&&n(t,o),e}();t.a=o},function(e,t,i){var r=i(12).f,n=i(22),o=i(8)("toStringTag");e.exports=function(e,t,i){e&&!n(e=i?e:e.prototype,o)&&r(e,o,{configurable:!0,value:t})}},function(e,t){e.exports={}},function(e,t,i){var r=i(8)("unscopables"),n=Array.prototype;null==n[r]&&i(23)(n,r,{}),e.exports=function(e){n[r][e]=!0}},function(e,t,i){"use strict";var r=i(5),n=i(12),o=i(13),s=i(8)("species");e.exports=function(e){var t=r[e];o&&t&&!t[s]&&n.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t){e.exports=function(e,t,i,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(i+": incorrect invocation!");return e}},function(e,t,i){var r=i(19);e.exports=function(e,t,i){for(var n in t)r(e,n,t[n],i);return e}},function(e,t,i){var r=i(6);e.exports=function(e,t){if(!r(e)||e._t!==t)throw TypeError("Incompatible receiver, "+t+" required!");return e}},function(e,t,i){var r=i(2).Buffer;function n(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}n.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var i=this._block,n=this._blockSize,o=e.length,s=this._len,a=0;a<o;){for(var c=s%n,h=Math.min(o-a,n-c),u=0;u<h;u++)i[c+u]=e[a+u];a+=h,(s+=h)%n==0&&this._update(i)}return this._len+=o,this},n.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},function(e,t,i){var r=i(36);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,i){var r=i(36),n=i(8)("toStringTag"),o="Arguments"==r(function(){return arguments}());e.exports=function(e){var t,i,s;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),n))?i:o?r(t):"Object"==(s=r(t))&&"function"==typeof t.callee?"Arguments":s}},function(e,t,i){var r=i(4),n=i(35),o=i(8)("species");e.exports=function(e,t){var i,s=r(e).constructor;return void 0===s||null==(i=r(s)[o])?t:n(i)}},function(e,t,i){(function(e){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"===i(e)},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"===i(e)&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===i(e)||void 0===e},t.isBuffer=e.isBuffer}).call(this,i(9).Buffer)},function(e,t,i){"use strict";var r=i(1),n=i(126),o=i(128),s=i(129),a=i(43);function c(e){a.call(this,"digest"),this._hash=e}r(c,a),c.prototype._update=function(e){this._hash.update(e)},c.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return"md5"===(e=e.toLowerCase())?new n:"rmd160"===e||"ripemd160"===e?new o:new c(s(e))}},function(e,t,i){(function(t){e.exports=function(e,i){for(var r=Math.min(e.length,i.length),n=new t(r),o=0;o<r;++o)n[o]=e[o]^i[o];return n}}).call(this,i(9).Buffer)},function(e,t,i){"use strict";var r=i(33),n=i(25);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=o,o.prototype.update=function(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var i=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-i,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},o.prototype.digest=function(e){return this.update(this._pad()),n(null===this.pending),this._digest(e)},o.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,i=t-(e+this.padLength)%t,r=new Array(i+this.padLength);r[0]=128;for(var n=1;n<i;n++)r[n]=0;if(e<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)r[n++]=0;r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=e>>>24&255,r[n++]=e>>>16&255,r[n++]=e>>>8&255,r[n++]=255&e}else for(r[n++]=255&e,r[n++]=e>>>8&255,r[n++]=e>>>16&255,r[n++]=e>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,o=8;o<this.padLength;o++)r[n++]=0;return r}},function(e,t,i){var r=t;r.bignum=i(11),r.define=i(571).define,r.base=i(73),r.constants=i(219),r.decoders=i(577),r.encoders=i(579)},function(e,t,i){var r=t;r.Reporter=i(574).Reporter,r.DecoderBuffer=i(218).DecoderBuffer,r.EncoderBuffer=i(218).EncoderBuffer,r.Node=i(575)},function(e,t,i){var r=i(24),n=i(10),o=i(48);e.exports=function(e){return function(t,i,s){var a,c=r(t),h=n(c.length),u=o(s,h);if(e&&i!=i){for(;h>u;)if((a=c[u++])!=a)return!0}else for(;h>u;u++)if((e||u in c)&&c[u]===i)return e||u||0;return!e&&-1}}},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t,i){var r=i(0),n=i(37),o=i(3),s=i(103),a="["+s+"]",c=RegExp("^"+a+a+"*"),h=RegExp(a+a+"*$"),u=function(e,t,i){var n={},a=o(function(){return!!s[e]()||"​…"!="​…"[e]()}),c=n[e]=a?t(l):s[e];i&&(n[i]=c),r(r.P+r.F*a,"String",n)},l=u.trim=function(e,t){return e=String(n(e)),1&t&&(e=e.replace(c,"")),2&t&&(e=e.replace(h,"")),e};e.exports=u},function(e,t,i){var r=i(8)("iterator"),n=!1;try{var o=[7][r]();o.return=function(){n=!0},Array.from(o,function(){throw 2})}catch(e){}e.exports=function(e,t){if(!t&&!n)return!1;var i=!1;try{var o=[7],s=o[r]();s.next=function(){return{done:i=!0}},o[r]=function(){return s},e(o)}catch(e){}return i}},function(e,t,i){"use strict";var r=i(4);e.exports=function(){var e=r(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t}},function(e,t,i){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=i(66),o=RegExp.prototype.exec;e.exports=function(e,t){var i=e.exec;if("function"==typeof i){var s=i.call(e,t);if("object"!==r(s))throw new TypeError("RegExp exec method returned something other than an Object or null");return s}if("RegExp"!==n(e))throw new TypeError("RegExp#exec called on incompatible receiver");return o.call(e,t)}},function(e,t,i){"use strict";i(156);var r=i(19),n=i(23),o=i(3),s=i(37),a=i(8),c=i(118),h=a("species"),u=!o(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}),l=function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var i="ab".split(e);return 2===i.length&&"a"===i[0]&&"b"===i[1]}();e.exports=function(e,t,i){var f=a(e),d=!o(function(){var t={};return t[f]=function(){return 7},7!=""[e](t)}),p=d?!o(function(){var t=!1,i=/a/;return i.exec=function(){return t=!0,null},"split"===e&&(i.constructor={},i.constructor[h]=function(){return i}),i[f](""),!t}):void 0;if(!d||!p||"replace"===e&&!u||"split"===e&&!l){var m=/./[f],g=i(s,f,""[e],function(e,t,i,r,n){return t.exec===c?d&&!n?{done:!0,value:m.call(t,i,r)}:{done:!0,value:e.call(i,t,r)}:{done:!1}}),_=g[0],v=g[1];r(String.prototype,e,_),n(RegExp.prototype,f,2==t?function(e,t){return v.call(e,this,t)}:function(e){return v.call(e,this)})}}},function(e,t,i){var r=i(34),n=i(152),o=i(113),s=i(4),a=i(10),c=i(115),h={},u={};(t=e.exports=function(e,t,i,l,f){var d,p,m,g,_=f?function(){return e}:c(e),v=r(i,l,t?2:1),y=0;if("function"!=typeof _)throw TypeError(e+" is not iterable!");if(o(_)){for(d=a(e.length);d>y;y++)if((g=t?v(s(p=e[y])[0],p[1]):v(e[y]))===h||g===u)return g}else for(m=_.call(e);!(p=m.next()).done;)if((g=n(m,v,p.value,t))===h||g===u)return g}).BREAK=h,t.RETURN=u},function(e,t,i){var r=i(5).navigator;e.exports=r&&r.userAgent||""},function(e,t,i){"use strict";var r=i(5),n=i(0),o=i(19),s=i(61),a=i(40),c=i(81),h=i(60),u=i(6),l=i(3),f=i(77),d=i(56),p=i(104);e.exports=function(e,t,i,m,g,_){var v=r[e],y=v,b=g?"set":"add",x=y&&y.prototype,w={},S=function(e){var t=x[e];o(x,e,"delete"==e?function(e){return!(_&&!u(e))&&t.call(this,0===e?0:e)}:"has"==e?function(e){return!(_&&!u(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return _&&!u(e)?void 0:t.call(this,0===e?0:e)}:"add"==e?function(e){return t.call(this,0===e?0:e),this}:function(e,i){return t.call(this,0===e?0:e,i),this})};if("function"==typeof y&&(_||x.forEach&&!l(function(){(new y).entries().next()}))){var T=new y,A=T[b](_?{}:-0,1)!=T,M=l(function(){T.has(1)}),E=f(function(e){new y(e)}),P=!_&&l(function(){for(var e=new y,t=5;t--;)e[b](t,t);return!e.has(-0)});E||((y=t(function(t,i){h(t,y,e);var r=p(new v,t,y);return null!=i&&c(i,g,r[b],r),r})).prototype=x,x.constructor=y),(M||P)&&(S("delete"),S("has"),g&&S("get")),(P||A)&&S(b),_&&x.clear&&delete x.clear}else y=m.getConstructor(t,e,g,b),s(y.prototype,i),a.NEED=!0;return d(y,e),w[e]=y,n(n.G+n.W+n.F*(y!=v),w),_||m.setStrong(y,e,g),y}},function(e,t,i){for(var r,n=i(5),o=i(23),s=i(45),a=s("typed_array"),c=s("view"),h=!(!n.ArrayBuffer||!n.DataView),u=h,l=0,f="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");l<9;)(r=n[f[l++]])?(o(r.prototype,a,!0),o(r.prototype,c,!0)):u=!1;e.exports={ABV:h,CONSTR:u,TYPED:a,VIEW:c}},function(e,t,i){(t=e.exports=i(169)).Stream=t,t.Readable=t,t.Writable=i(122),t.Duplex=i(54),t.Transform=i(172),t.PassThrough=i(410)},function(e,t,i){"use strict";(function(t){!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,i,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,i)});case 3:return t.nextTick(function(){e.call(null,i,r)});case 4:return t.nextTick(function(){e.call(null,i,r,n)});default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return t.nextTick(function(){e.apply(null,o)})}}}:e.exports=t}).call(this,i(27))},function(e,t,i){e.exports=n;var r=i(16);function n(e,t){if(!(this instanceof n))return new n(e,t);var i=r.create();r.add(i,e,t),this.base=r.min(r.create(),e,i),this.vec=r.clone(t),this.max=r.max(r.create(),e,i),this.mag=r.length(this.vec)}var o=n.prototype;o.width=function(){return this.vec[0]},o.height=function(){return this.vec[1]},o.depth=function(){return this.vec[2]},o.x0=function(){return this.base[0]},o.y0=function(){return this.base[1]},o.z0=function(){return this.base[2]},o.x1=function(){return this.max[0]},o.y1=function(){return this.max[1]},o.z1=function(){return this.max[2]},o.translate=function(e){return r.add(this.max,this.max,e),r.add(this.base,this.base,e),this},o.setPosition=function(e){return r.add(this.max,e,this.vec),r.copy(this.base,e),this},o.expand=function(e){var t=r.create(),i=r.create();return r.max(t,e.max,this.max),r.min(i,e.base,this.base),r.subtract(t,t,i),new n(i,t)},o.intersects=function(e){return!(e.base[0]>this.max[0])&&(!(e.base[1]>this.max[1])&&(!(e.base[2]>this.max[2])&&(!(e.max[0]<this.base[0])&&(!(e.max[1]<this.base[1])&&!(e.max[2]<this.base[2])))))},o.touches=function(e){var t=this.union(e);return null!==t&&(0==t.width()||0==t.height()||0==t.depth())},o.union=function(e){if(!this.intersects(e))return null;var t=Math.max(e.base[0],this.base[0]),i=Math.max(e.base[1],this.base[1]),r=Math.max(e.base[2],this.base[2]);return new n([t,i,r],[Math.min(e.max[0],this.max[0])-t,Math.min(e.max[1],this.max[1])-i,Math.min(e.max[2],this.max[2])-r])}},function(e,t,i){var r=i(185),n=i(446),o="undefined"!=typeof Float64Array;function s(e,t){return e[0]-t[0]}function a(){var e,t=this.stride,i=new Array(t.length);for(e=0;e<i.length;++e)i[e]=[Math.abs(t[e]),e];i.sort(s);var r=new Array(i.length);for(e=0;e<r.length;++e)r[e]=i[e][1];return r}function c(e,t){var i=["View",t,"d",e].join("");t<0&&(i="View_Nil"+e);var n="generic"===e;if(-1===t){var o="function "+i+"(a){this.data=a;};var proto="+i+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+i+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+i+"(a){return new "+i+"(a);}";return new Function(o)()}if(0===t){o="function "+i+"(a,d) {this.data = a;this.offset = d};var proto="+i+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+i+"_copy() {return new "+i+"(this.data,this.offset)};proto.pick=function "+i+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+i+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+i+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+i+"(a,b,c,d){return new "+i+"(a,d)}";return new Function("TrivialArray",o)(h[e][0])}o=["'use strict'"];var s=r(t),c=s.map(function(e){return"i"+e}),u="this.offset+"+s.map(function(e){return"this.stride["+e+"]*i"+e}).join("+"),l=s.map(function(e){return"b"+e}).join(","),f=s.map(function(e){return"c"+e}).join(",");o.push("function "+i+"(a,"+l+","+f+",d){this.data=a","this.shape=["+l+"]","this.stride=["+f+"]","this.offset=d|0}","var proto="+i+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),o.push("Object.defineProperty(proto,'size',{get:function "+i+"_size(){return "+s.map(function(e){return"this.shape["+e+"]"}).join("*"),"}})"),1===t?o.push("proto.order=[0]"):(o.push("Object.defineProperty(proto,'order',{get:"),t<4?(o.push("function "+i+"_order(){"),2===t?o.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===t&&o.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):o.push("ORDER})")),o.push("proto.set=function "+i+"_set("+c.join(",")+",v){"),n?o.push("return this.data.set("+u+",v)}"):o.push("return this.data["+u+"]=v}"),o.push("proto.get=function "+i+"_get("+c.join(",")+"){"),n?o.push("return this.data.get("+u+")}"):o.push("return this.data["+u+"]}"),o.push("proto.index=function "+i+"_index(",c.join(),"){return "+u+"}"),o.push("proto.hi=function "+i+"_hi("+c.join(",")+"){return new "+i+"(this.data,"+s.map(function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")}).join(",")+","+s.map(function(e){return"this.stride["+e+"]"}).join(",")+",this.offset)}");var d=s.map(function(e){return"a"+e+"=this.shape["+e+"]"}),p=s.map(function(e){return"c"+e+"=this.stride["+e+"]"});o.push("proto.lo=function "+i+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+p.join(","));for(var m=0;m<t;++m)o.push("if(typeof i"+m+"==='number'&&i"+m+">=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");o.push("return new "+i+"(this.data,"+s.map(function(e){return"a"+e}).join(",")+","+s.map(function(e){return"c"+e}).join(",")+",b)}"),o.push("proto.step=function "+i+"_step("+c.join(",")+"){var "+s.map(function(e){return"a"+e+"=this.shape["+e+"]"}).join(",")+","+s.map(function(e){return"b"+e+"=this.stride["+e+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(m=0;m<t;++m)o.push("if(typeof i"+m+"==='number'){d=i"+m+"|0;if(d<0){c+=b"+m+"*(a"+m+"-1);a"+m+"=ceil(-a"+m+"/d)}else{a"+m+"=ceil(a"+m+"/d)}b"+m+"*=d}");o.push("return new "+i+"(this.data,"+s.map(function(e){return"a"+e}).join(",")+","+s.map(function(e){return"b"+e}).join(",")+",c)}");var g=new Array(t),_=new Array(t);for(m=0;m<t;++m)g[m]="a[i"+m+"]",_[m]="b[i"+m+"]";o.push("proto.transpose=function "+i+"_transpose("+c+"){"+c.map(function(e,t){return e+"=("+e+"===undefined?"+t+":"+e+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+i+"(this.data,"+g.join(",")+","+_.join(",")+",this.offset)}"),o.push("proto.pick=function "+i+"_pick("+c+"){var a=[],b=[],c=this.offset");for(m=0;m<t;++m)o.push("if(typeof i"+m+"==='number'&&i"+m+">=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");return o.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),o.push("return function construct_"+i+"(data,shape,stride,offset){return new "+i+"(data,"+s.map(function(e){return"shape["+e+"]"}).join(",")+","+s.map(function(e){return"stride["+e+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",o.join("\n"))(h[e],a)}var h={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(e,t,i,r){if(void 0===e)return(0,h.array[0])([]);"number"==typeof e&&(e=[e]),void 0===t&&(t=[e.length]);var s=t.length;if(void 0===i){i=new Array(s);for(var a=s-1,u=1;a>=0;--a)i[a]=u,u*=t[a]}if(void 0===r)for(r=0,a=0;a<s;++a)i[a]<0&&(r-=(t[a]-1)*i[a]);for(var l=function(e){if(n(e))return"buffer";if(o)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(e)?"array":"generic"}(e),f=h[l];f.length<=s+1;)f.push(c(l,f.length-1));return(0,f[s+1])(e,t,i,r)}},function(e,t,i){var r=i(2).Buffer;function n(e){r.isBuffer(e)||(e=r.from(e));for(var t=e.length/4|0,i=new Array(t),n=0;n<t;n++)i[n]=e.readUInt32BE(4*n);return i}function o(e){for(;0<e.length;e++)e[0]=0}function s(e,t,i,r,n){for(var o,s,a,c,h=i[0],u=i[1],l=i[2],f=i[3],d=e[0]^t[0],p=e[1]^t[1],m=e[2]^t[2],g=e[3]^t[3],_=4,v=1;v<n;v++)o=h[d>>>24]^u[p>>>16&255]^l[m>>>8&255]^f[255&g]^t[_++],s=h[p>>>24]^u[m>>>16&255]^l[g>>>8&255]^f[255&d]^t[_++],a=h[m>>>24]^u[g>>>16&255]^l[d>>>8&255]^f[255&p]^t[_++],c=h[g>>>24]^u[d>>>16&255]^l[p>>>8&255]^f[255&m]^t[_++],d=o,p=s,m=a,g=c;return o=(r[d>>>24]<<24|r[p>>>16&255]<<16|r[m>>>8&255]<<8|r[255&g])^t[_++],s=(r[p>>>24]<<24|r[m>>>16&255]<<16|r[g>>>8&255]<<8|r[255&d])^t[_++],a=(r[m>>>24]<<24|r[g>>>16&255]<<16|r[d>>>8&255]<<8|r[255&p])^t[_++],c=(r[g>>>24]<<24|r[d>>>16&255]<<16|r[p>>>8&255]<<8|r[255&m])^t[_++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],c=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var i=[],r=[],n=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var h=a^a<<1^a<<2^a<<3^a<<4;h=h>>>8^255&h^99,i[s]=h,r[h]=s;var u=e[s],l=e[u],f=e[l],d=257*e[h]^16843008*h;n[0][s]=d<<24|d>>>8,n[1][s]=d<<16|d>>>16,n[2][s]=d<<8|d>>>24,n[3][s]=d,d=16843009*f^65537*l^257*u^16843008*s,o[0][h]=d<<24|d>>>8,o[1][h]=d<<16|d>>>16,o[2][h]=d<<8|d>>>24,o[3][h]=d,0===s?s=a=1:(s=u^e[e[e[f^u]]],a^=e[e[a]])}return{SBOX:i,INV_SBOX:r,SUB_MIX:n,INV_SUB_MIX:o}}();function h(e){this._key=n(e),this._reset()}h.blockSize=16,h.keySize=32,h.prototype.blockSize=h.blockSize,h.prototype.keySize=h.keySize,h.prototype._reset=function(){for(var e=this._key,t=e.length,i=t+6,r=4*(i+1),n=[],o=0;o<t;o++)n[o]=e[o];for(o=t;o<r;o++){var s=n[o-1];o%t==0?(s=s<<8|s>>>24,s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s],s^=a[o/t|0]<<24):t>6&&o%t==4&&(s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s]),n[o]=n[o-t]^s}for(var h=[],u=0;u<r;u++){var l=r-u,f=n[l-(u%4?0:4)];h[u]=u<4||l<=4?f:c.INV_SUB_MIX[0][c.SBOX[f>>>24]]^c.INV_SUB_MIX[1][c.SBOX[f>>>16&255]]^c.INV_SUB_MIX[2][c.SBOX[f>>>8&255]]^c.INV_SUB_MIX[3][c.SBOX[255&f]]}this._nRounds=i,this._keySchedule=n,this._invKeySchedule=h},h.prototype.encryptBlockRaw=function(e){return s(e=n(e),this._keySchedule,c.SUB_MIX,c.SBOX,this._nRounds)},h.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),i=r.allocUnsafe(16);return i.writeUInt32BE(t[0],0),i.writeUInt32BE(t[1],4),i.writeUInt32BE(t[2],8),i.writeUInt32BE(t[3],12),i},h.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var i=s(e,this._invKeySchedule,c.INV_SUB_MIX,c.INV_SBOX,this._nRounds),o=r.allocUnsafe(16);return o.writeUInt32BE(i[0],0),o.writeUInt32BE(i[3],4),o.writeUInt32BE(i[2],8),o.writeUInt32BE(i[1],12),o},h.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},e.exports.AES=h},function(e,t,i){var r=i(2).Buffer,n=i(126);e.exports=function(e,t,i,o){if(r.isBuffer(e)||(e=r.from(e,"binary")),t&&(r.isBuffer(t)||(t=r.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var s=i/8,a=r.alloc(s),c=r.alloc(o||0),h=r.alloc(0);s>0||o>0;){var u=new n;u.update(h),u.update(e),t&&u.update(t),h=u.digest();var l=0;if(s>0){var f=a.length-s;l=Math.min(s,h.length),h.copy(a,f,0,l),s-=l}if(l<h.length&&o>0){var d=c.length-o,p=Math.min(o,h.length-l);h.copy(c,d,l,l+p),o-=p}}return h.fill(0),{key:a,iv:c}}},function(e,t,i){"use strict";var r=t;r.base=i(551),r.short=i(552),r.mont=i(553),r.edwards=i(554)},function(e,t,i){(function(t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=i(570),o=i(582),s=i(583),a=i(131),c=i(202);function h(e){var i;"object"!==r(e)||t.isBuffer(e)||(i=e.passphrase,e=e.key),"string"==typeof e&&(e=new t(e));var h,u,l=s(e,i),f=l.tag,d=l.data;switch(f){case"CERTIFICATE":u=n.certificate.decode(d,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(u||(u=n.PublicKey.decode(d,"der")),h=u.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(u.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return u.subjectPrivateKey=u.subjectPublicKey,{type:"ec",data:u};case"1.2.840.10040.4.1":return u.algorithm.params.pub_key=n.DSAparam.decode(u.subjectPublicKey.data,"der"),{type:"dsa",data:u.algorithm.params};default:throw new Error("unknown key id "+h)}throw new Error("unknown key type "+f);case"ENCRYPTED PRIVATE KEY":d=function(e,i){var r=e.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),s=o[e.algorithm.decrypt.cipher.algo.join(".")],h=e.algorithm.decrypt.cipher.iv,u=e.subjectPrivateKey,l=parseInt(s.split("-")[1],10)/8,f=c.pbkdf2Sync(i,r,n,l),d=a.createDecipheriv(s,f,h),p=[];return p.push(d.update(u)),p.push(d.final()),t.concat(p)}(d=n.EncryptedPrivateKey.decode(d,"der"),i);case"PRIVATE KEY":switch(h=(u=n.PrivateKey.decode(d,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(u.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:u.algorithm.curve,privateKey:n.ECPrivateKey.decode(u.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return u.algorithm.params.priv_key=n.DSAparam.decode(u.subjectPrivateKey,"der"),{type:"dsa",params:u.algorithm.params};default:throw new Error("unknown key id "+h)}throw new Error("unknown key type "+f);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(d,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(d,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(d,"der")};case"EC PRIVATE KEY":return{curve:(d=n.ECPrivateKey.decode(d,"der")).parameters.value,privateKey:d.privateKey};default:throw new Error("unknown key type "+f)}}e.exports=h,h.signature=n.signature}).call(this,i(9).Buffer)},function(e,t,i){(function(t,r){function n(e,i,r,n,o,s,a){try{var c=e[s](a),h=c.value}catch(e){return void r(e)}c.done?i(h):t.resolve(h).then(n,o)}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}e.exports=f;var s=i(400)("simple-peer"),a=i(403),c=i(1),h=i(53),u=i(85),l=5e3;function f(e){var i,r,n=this;if(!(n instanceof f))return new f(e);if(n._id=h(4).toString("hex").slice(0,7),n._debug("new peer %o",e),e=Object.assign({allowHalfOpen:!1},e),u.Duplex.call(n,e),n.channelName=e.initiator?e.channelName||h(20).toString("hex"):null,n._isChromium="undefined"!=typeof window&&!!window.webkitRTCPeerConnection,n.initiator=e.initiator||!1,n.channelConfig=e.channelConfig||f.channelConfig,n.config=Object.assign({},f.config,e.config),n.constraints=n._transformConstraints(e.constraints||f.constraints),n.offerConstraints=n._transformConstraints(e.offerConstraints||{}),n.answerConstraints=n._transformConstraints(e.answerConstraints||{}),n.sdpTransform=e.sdpTransform||function(e){return e},n.streams=e.streams||(e.stream?[e.stream]:[]),n.trickle=void 0===e.trickle||e.trickle,n.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,n.iceCompleteTimeout=e.iceCompleteTimeout||l,n.destroyed=!1,n.connected=!1,n.remoteAddress=void 0,n.remoteFamily=void 0,n.remotePort=void 0,n.localAddress=void 0,n.localPort=void 0,n._wrtc=e.wrtc&&"object"===o(e.wrtc)?e.wrtc:a(),!n._wrtc)throw"undefined"==typeof window?p("No WebRTC support: Specify `opts.wrtc` option in this environment","ERR_WEBRTC_SUPPORT"):p("No WebRTC support: Not a supported browser","ERR_WEBRTC_SUPPORT");n._pcReady=!1,n._channelReady=!1,n._iceComplete=!1,n._iceCompleteTimer=null,n._channel=null,n._pendingCandidates=[],n._isNegotiating=!n.initiator,n._batchedNegotiation=!1,n._queuedNegotiation=!1,n._sendersAwaitingStable=[],n._senderMap=new Map,n._firstStable=!0,n._closingInterval=null,n._remoteTracks=[],n._remoteStreams=[],n._chunk=null,n._cb=null,n._interval=null,n._pc=new n._wrtc.RTCPeerConnection(n.config,n.constraints),(n._isChromium||n._wrtc&&n._wrtc.electronDaemon)&&(i=n._wrtc.RTCPeerConnection,(r=n._pc).createOffer=function(e){var r=this;return new t(function(t,n){i.prototype.createOffer.call(r,t,n,e)})},r.createAnswer=function(e){var r=this;return new t(function(t,n){i.prototype.createAnswer.call(r,t,n,e)})},r.setLocalDescription=function(e){var r=this;return new t(function(t,n){i.prototype.setLocalDescription.call(r,e,t,n)})},r.setRemoteDescription=function(e){var r=this;return new t(function(t,n){i.prototype.setRemoteDescription.call(r,e,t,n)})}),n._isReactNativeWebrtc="number"==typeof n._pc._peerConnectionId,n._pc.oniceconnectionstatechange=function(){n._onIceStateChange()},n._pc.onicegatheringstatechange=function(){n._onIceStateChange()},n._pc.onsignalingstatechange=function(){n._onSignalingStateChange()},n._pc.onicecandidate=function(e){n._onIceCandidate(e)},n.initiator?n._setupData({channel:n._pc.createDataChannel(n.channelName,n.channelConfig)}):n._pc.ondatachannel=function(e){n._setupData(e)},"addTrack"in n._pc&&(n.streams&&n.streams.forEach(function(e){n.addStream(e)}),n._pc.ontrack=function(e){n._onTrack(e)}),n.initiator&&n._needsNegotiation(),n._onFinishBound=function(){n._onFinish()},n.once("finish",n._onFinishBound)}function d(e){return e.replace(/a=ice-options:trickle\s\n/g,"")}function p(e,t){var i=new Error(e);return i.code=t,i}function m(){}c(f,u.Duplex),f.WEBRTC_SUPPORT=!!a(),f.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}]},f.constraints={},f.channelConfig={},Object.defineProperty(f.prototype,"bufferSize",{get:function(){return this._channel&&this._channel.bufferedAmount||0}}),f.prototype.address=function(){return{port:this.localPort,family:"IPv4",address:this.localAddress}},f.prototype.signal=function(e){var t=this;if(t.destroyed)throw p("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}t._debug("signal()"),e.renegotiate&&t.initiator&&(t._debug("got request to renegotiate"),t._needsNegotiation()),e.candidate&&(t._pc.remoteDescription&&t._pc.remoteDescription.type?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e)).then(function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())}).catch(function(e){t.destroy(p(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||t.destroy(p("signal() called with invalid signal data","ERR_SIGNALING"))},f.prototype._addIceCandidate=function(e){var t=this;try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),m,function(e){t.destroy(p(e,"ERR_ADD_ICE_CANDIDATE"))})}catch(e){t.destroy(p("error adding candidate: "+e.message,"ERR_ADD_ICE_CANDIDATE"))}},f.prototype.send=function(e){this._channel.send(e)},f.prototype.addStream=function(e){var t=this;t._debug("addStream()"),e.getTracks().forEach(function(i){t.addTrack(i,e)})},f.prototype.addTrack=function(e,t){this._debug("addTrack()");var i=this._pc.addTrack(e,t),r=this._senderMap.get(e)||new Map;r.set(t,i),this._senderMap.set(e,r),this._needsNegotiation()},f.prototype.replaceTrack=function(){var e,i=(e=regeneratorRuntime.mark(function e(t,i,r){var n,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if((n=this)._debug("replaceTrack()"),o=n._senderMap.get(t),(s=o?o.get(r):null)||n.destroy(new Error("Cannot replace track that was never added.")),i&&n._senderMap.set(i,o),null==s.replaceTrack){e.next=11;break}return e.next=9,s.replaceTrack(i);case 9:e.next=12;break;case 11:n.destroy(p("replaceTrack is not supported in this browser","ERR_UNSUPPORTED_REPLACETRACK"));case 12:case"end":return e.stop()}},e,this)}),function(){var i=this,r=arguments;return new t(function(t,o){var s=e.apply(i,r);function a(e){n(s,t,o,a,c,"next",e)}function c(e){n(s,t,o,a,c,"throw",e)}a(void 0)})});return function(e,t,r){return i.apply(this,arguments)}}(),f.prototype.removeTrack=function(e,t){this._debug("removeSender()");var i=this._senderMap.get(e),r=i?i.get(t):null;r||this.destroy(new Error("Cannot remove track that was never added."));try{this._pc.removeTrack(r)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?this._sendersAwaitingStable.push(r):this.destroy(e)}},f.prototype.removeStream=function(e){var t=this;t._debug("removeSenders()"),e.getTracks().forEach(function(i){t.removeTrack(i,e)})},f.prototype._needsNegotiation=function(){var e=this;e._debug("_needsNegotiation"),e._batchedNegotiation||(e._batchedNegotiation=!0,setTimeout(function(){e._batchedNegotiation=!1,e._debug("starting batched negotiation"),e.negotiate()},0))},f.prototype.negotiate=function(){this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),this._createOffer()):this._isNegotiating||(this._debug("requesting negotiation from initiator"),this.emit("signal",{renegotiate:!0})),this._isNegotiating=!0},f.prototype.destroy=function(e){this._destroy(e,function(){})},f.prototype._destroy=function(e,t){if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.destroyed=!0,this.connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,"addTrack"in this._pc&&(this._pc.ontrack=null),this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close"),t()}},f.prototype._setupData=function(e){var t=this;if(!e.channel)return t.destroy(p("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"));t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=65536),t.channelName=t._channel.label,t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onbufferedamountlow=function(){t._onChannelBufferedAmountLow()},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()},t._channel.onerror=function(e){t.destroy(p(e,"ERR_DATA_CHANNEL"))};var i=!1;t._closingInterval=setInterval(function(){t._channel&&"closing"===t._channel.readyState?(i&&t._onChannelClose(),i=!0):i=!1},5e3)},f.prototype._read=function(){},f.prototype._write=function(e,t,i){if(this.destroyed)return i(p("cannot write after peer is destroyed","ERR_DATA_CHANNEL"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(p(e,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=i):i(null)}else this._debug("write before connect"),this._chunk=e,this._cb=i},f.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e.connected?t():e.once("connect",t))},f.prototype._startIceCompleteTimeout=function(){s("started iceComplete timeout");var e=this;e.destroyed||e._iceCompleteTimer||(e._iceCompleteTimer=setTimeout(function(){e._iceComplete||(e._iceComplete=!0,e.emit("iceTimeout"),e.emit("_iceComplete"))},this.iceCompleteTimeout))},f.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(e.offerConstraints).then(function(t){function i(){if(!e.destroyed){var i=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:i.type,sdp:i.sdp})}}e.destroyed||(e.trickle||e.allowHalfTrickle||(t.sdp=d(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){if(e._debug("createOffer success"),e.destroyed)return;e.trickle||e._iceComplete?i():e.once("_iceComplete",i)}).catch(function(t){e.destroy(p(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(p(t,"ERR_CREATE_OFFER"))})},f.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(e.answerConstraints).then(function(t){function i(){if(!e.destroyed){var i=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:i.type,sdp:i.sdp})}}e.destroyed||(e.trickle||e.allowHalfTrickle||(t.sdp=d(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){if(e.destroyed)return;e.trickle||e._iceComplete?i():e.once("_iceComplete",i)}).catch(function(t){e.destroy(p(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(p(t,"ERR_CREATE_ANSWER"))})},f.prototype._onIceStateChange=function(){if(!this.destroyed){var e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(p("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(new Error("Ice connection closed."))}},f.prototype.getStats=function(e){var t=this;0===t._pc.getStats.length?t._pc.getStats().then(function(t){var i=[];t.forEach(function(e){i.push(e)}),e(null,i)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var i=[];t.forEach(function(e){i.push(e)}),e(null,i)},function(t){e(t)}):t._pc.getStats.length>0?t._pc.getStats(function(i){if(!t.destroyed){var r=[];i.result().forEach(function(e){var t={};e.names().forEach(function(i){t[i]=e.stat(i)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,r.push(t)}),e(null,r)}},function(t){e(t)}):e(null,[])},f.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,function t(){e.destroyed||e.getStats(function(i,r){if(!e.destroyed){i&&(r=[]);var n={},o={},s={},a=!1;if(r.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(n[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(o[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(s[e.id]=e)}),r.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&h(s[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&h(e)}),a||Object.keys(s).length&&!Object.keys(o).length){if(e._connecting=!1,e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(i){return e.destroy(p(i,"ERR_DATA_CHANNEL"))}e._chunk=null,e._debug('sent chunk from "write before connect"');var c=e._cb;e._cb=null,c(null)}"number"!=typeof e._channel.bufferedAmountLowThreshold&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}else setTimeout(t,100)}function h(t){a=!0;var i=o[t.localCandidateId];i&&i.ip?(e.localAddress=i.ip,e.localPort=Number(i.port)):i&&i.ipAddress?(e.localAddress=i.ipAddress,e.localPort=Number(i.portNumber)):"string"==typeof t.googLocalAddress&&(i=t.googLocalAddress.split(":"),e.localAddress=i[0],e.localPort=Number(i[1]));var r=n[t.remoteCandidateId];r&&r.ip?(e.remoteAddress=r.ip,e.remotePort=Number(r.port)):r&&r.ipAddress?(e.remoteAddress=r.ipAddress,e.remotePort=Number(r.portNumber)):"string"==typeof t.googRemoteAddress&&(r=t.googRemoteAddress.split(":"),e.remoteAddress=r[0],e.remotePort=Number(r[1])),e.remoteFamily="IPv4",e._debug("connect local: %s:%s remote: %s:%s",e.localAddress,e.localPort,e.remoteAddress,e.remotePort)}})}())},f.prototype._onInterval=function(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()},f.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"!==e._pc.signalingState||e._firstStable||(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e._pc.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),e._firstStable=!1,e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},f.prototype._onIceCandidate=function(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())},f.prototype._onChannelMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=r.from(t)),this.push(t)}},f.prototype._onChannelBufferedAmountLow=function(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},f.prototype._onChannelOpen=function(){this.connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())},f.prototype._onChannelClose=function(){this.destroyed||(this._debug("on channel close"),this.destroy())},f.prototype._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(i){t._debug("on track"),t.emit("track",e.track,i),t._remoteTracks.push({track:e.track,stream:i}),t._remoteStreams.some(function(e){return e.id===i.id})||(t._remoteStreams.push(i),setTimeout(function(){t.emit("stream",i)},0))})},f.prototype.setConstraints=function(e){this.initiator?this.offerConstraints=this._transformConstraints(e):this.answerConstraints=this._transformConstraints(e)},f.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],s.apply(null,e)},f.prototype._transformConstraints=function(e){if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!this._isChromium){var t=Object.assign({},e.optional,e.mandatory);return void 0!==t.OfferToReceiveVideo&&(t.offerToReceiveVideo=t.OfferToReceiveVideo,delete t.OfferToReceiveVideo),void 0!==t.OfferToReceiveAudio&&(t.offerToReceiveAudio=t.OfferToReceiveAudio,delete t.OfferToReceiveAudio),t}return e.mandatory||e.optional||!this._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}}).call(this,i(52),i(9).Buffer)},function(e,t,i){"use strict";var r=i(7);function n(e){var t=2,i=256,r=10,n=document.createElement("canvas");n.width=window.innerWidth-16,n.height=i*t;var o=n.getContext("2d");o.imageSmoothingEnabled=!1;var s=document.getElementById("chat");s.appendChild(n),s.style.width=n.width+"px",s.style.height=i*t+"px";var a="",c=0,u=[],l=0,f={player:null,isOpen:!1,open:function(){r=20,c=performance.now(),f.isOpen=!0,i=512,f.resize(),document.addEventListener("keypress",f.keypress,!1),document.addEventListener("keydown",f.keydown,!1),document.exitPointerLock(),e.inputs.state.active=!1},close:function(){document.removeEventListener("keypress",f.keypress),document.removeEventListener("keydown",f.keydown);var t=document.getElementById("noa-container");setTimeout(function(){null!=t&&t.requestPointerLock()},200),r=10,f.isOpen=!1,i=256,f.resize(),e.inputs.state.active=!0},sendMessage:function(e){if(0==e.indexOf("/")){var t='Unknown command. Type "/help" for help.';if(0==e.indexOf("/ban")&&(t="Command disabled."),0==e.indexOf("/banip")&&(t="Command disabled."),0==e.indexOf("/say")&&(t="Command disabled."),0==e.indexOf("/deop")&&(t="Command disabled."),0==e.indexOf("/kick")){var i=e.substr(e.indexOf("kick")+5).trim();t=h.getInstance().kickPlayer(i)}if(0==e.indexOf("/op")&&(t="Command disabled."),0==e.indexOf("/tp")){var r=e.substr(e.indexOf("tp")+3).trim();t=h.getInstance().teleportToPlayer(r)}return 0==e.indexOf("/unban")&&(t="Command disabled."),0==e.indexOf("/setspawn")&&(t=h.getInstance().setSpawn()),0==e.indexOf("/solid")&&(t="Command disabled."),0==e.indexOf("/list")&&(t=JSON.stringify(h.getInstance().getPlayerNames()).slice(1,-1)),0==e.indexOf("/help")&&(t="Available Commands: /list /kick /tp /setspawn /help"),u.push({type:"local",message:t,from:"",timestamp:(new Date).getTime()}),void(u.length>20&&u.shift())}null!=f.player&&f.player.sendMessage(e)},keydown:function(e){if(e.shiftKey&&55==e.keyCode&&(e.preventDefault(),f.keypress(e)),13==e.keyCode){var t=a.trim();return t.length>0&&f.sendMessage(t),a="",void f.redraw()}8==e.keyCode&&a.length>0&&(a=a.substring(0,a.length-1)),f.redraw()},keypress:function(e){if(!(performance.now()<c+100)){var t=e.key,i=10;null!=f.player&&(i=f.player.state.name.length),"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_'*!\\\"#%/()=+?[]{}<>@|$;".indexOf(t)>=0&&a.length<64-(i+2)&&(a+=t),f.redraw()}},update:function(e){for(u=function(e){for(var t=e.concat(),i=0;i<t.length;++i)for(var r=i+1;r<t.length;++r)JSON.stringify(t[i])===JSON.stringify(t[r])&&t.splice(r--,1);return t}(u.concat(e));u.length>20;)u.shift();f.redraw()},tick:function(){var e=(new Date).getTime();if(!(e<l+1e3)){for(var t=!1,i=0;i<u.length;i++){u[i].timestamp+1e4<e&&(u[i].isOld=!0,t=!0)}t&&f.redraw(),l=e}},redraw:function(){o.clearRect(0,0,n.width,i*t),o.font=14*t+"px Minecraft, sans-serif",o.textBaseline="alphabetic",o.textAlign="left";var e=4*t,s=2*t;if(f.isOpen){o.fillStyle="rgba(0,0,0,0.6)",o.fillRect(0,i*t-25*t,n.width,i*t);var c=i*t-7*t;o.fillStyle="rgb(63,63,63)",o.fillText("> "+a,e+s,c+s),o.fillStyle="rgb(255,255,255)",o.fillText("> "+a,e,c)}e=0;for(var h=1,l=u.length-1;l>=0;l--)if(!u[l].isOld||f.isOpen){if(h>r)break;var d="",p="rgb(255,255,255)";switch(u[l].type){case"message":d=u[l].from+": "+u[l].message;break;case"left":d=u[l].from+" left the game",p="rgb(255,255,64)";break;case"joined":d=u[l].from+" joined the game",p="rgb(255,255,64)";break;case"local":d=u[l].message,p="rgb(255,255,64)"}var m=i*t-25*t-15*h++*t;o.fillStyle="rgb(63,63,63)",o.fillText(d,e+s,m+s),o.fillStyle=p,o.fillText(d,e,m)}},resize:function(){t=2,window.innerHeight<600&&(t=1),n.width=window.innerWidth-16,n.height=i*t,s.style.width=n.width+"px",s.style.height=i*t+"px",o.imageSmoothingEnabled=!1,f.redraw()}};return f.resize(),f}var o=function(e){return n(e)};function s(e){return function(e){if(Array.isArray(e)){for(var t=0,i=new Array(e.length);t<e.length;t++)i[t]=e[t];return i}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function a(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}window.BABYLON=i(411);var c=function(){function e(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),e.instance||(e.instance=this),e.instance}var t,n,c;return t=e,c=[{key:"getInstance",value:function(){return void 0===e.instance&&(e.instance=new e),e.instance}}],(n=[{key:"initialize",value:function(e){var t=this;this.playerSpawned=!1,this.worldGenerated=!1,this.worldInitialized=!1,this.client=null,this.network=e.network;var n=i(412),a=i(495);this.soundPlayer=i(497)();var c,h=i(499),u=i(500),l=i(501),f=i(502),d=i(503),p=i(194),m=h(),g=32,_=128,v=30,y=null,b=!1,x=!1,w=this;if(Math.round(e.seed)==e.seed){this.player=void 0!==e.player?e.player:null;var S=new URLSearchParams(window.location.search),T=S.get("size");if("small"==T&&(_=128),"normal"==T&&(_=256),"huge"==T&&(_=512),r.default.getInstance().gameSaved()?_=r.default.getInstance().getWorldSize():r.default.getInstance().setWorldSize(_),"undefined"!=typeof Worker){if(void 0===A){var A=new Worker("assets/js/RandomLevelWorker.js");A.postMessage({worldSize:_,seed:e.seed}),m.show()}A.onmessage=function(e){var t=e.data;m.task=t.string,m.percent=t.percent,m.tick(),null!=t.tiles&&(y=t.tiles,w.worldGenerated=!0,null==w.client?r.default.getInstance().gameSaved()?(w.syncSavedWorld(),xe()):xe():w.client&&(w.hostInfo?w.hostInfo.numberOfChangedBlocks<=0?xe():w.client.broadcast({type:"requestChanges",from:w.client.state.changedBlocks.length}):xe()))}}else console.log("No worker support.");var M=.5*_,E=8e3,P=24e3,C=8e3,R=24e3,I=3e3,D=12e3,O={chunkSize:g,chunkAddDistance:7,chunkRemoveDistance:8,blockTestDistance:6,playerStart:[M+.5,48,M+.5],playerHeight:1.8,texturePath:"assets/textures/",useAO:!1,stickyPointerLock:!0};this.lightDepths=new Array(_);for(var L=0;L<_;L++)this.lightDepths[L]=new Array(_);var F={music:!1,sound:!0,invert:!1,fps:!1,drawDistance:0,forward:"W",left:"A",backward:"S",right:"D",jump:"<space>",build:"B",chat:"T",fog:"F",saveLoc:"<enter>",loadLoc:"R",username:""},B=JSON.parse(localStorage.getItem("settings"));null==B||B.back||(F=B);var k={forward:F.forward,left:F.left,backward:F.backward,right:F.right,fire:"<mouse 1>","mid-fire":"<mouse 2>","alt-fire":"<mouse 3>",jump:F.jump,build:F.build,chat:F.chat,fog:F.fog,saveLoc:F.saveLoc,loadLoc:F.loadLoc,spawnSteve:"G"};O.bindings=k,O.settings=F,this.soundPlayer.musicOn=F.music,this.soundPlayer.soundOn=F.sound;var V=n(O);V.setPaused(!0),V.worldSize=_,V.worldHeight=64,V.waterLevel=v,V.time=0,V.rendering._camera.minZ=.1,V.rendering._camera.fov=70*Math.PI/180,V.rendering._scene.fogColor=new BABYLON.Color3(.9,.95,1),V.rendering._scene.fogMode=BABYLON.Scene.FOGMODE_EXP2,V.rendering._scene.fogDensity=.002,V.rendering._scene.clearColor=V.rendering._scene.fogColor,this.hostInfo?V.hostInfo=this.hostInfo:V.hostInfo={maxPlayers:this.player.network.maxPlayers};var N=u(V),z=l(N),U=f(V,e.singlePlayer),G=p(V);this.addParticles=a(V);var W=N.currentId-1;V.on("tick",function(e){if(V.time+=e,null!=w.player&&null==c.player&&(c.player=w.player),c&&c.tick(),G&&G.isOpen&&G.tick(),H&&(H.material.diffuseTexture.uOffset=2e-7*V.time),w.steveArray)for(var t=0;t<w.steveArray.length;t++){var i=w.steveArray[t];if(i.tick(e),i.state.shouldRemove)i.remove(),w.steveArray.splice(t,1)[0]=null}!function(){if(V.time>le+ue){var e=fe.slice();fe.length=0;for(var t=0;t<e.length;t++){var i,r=e[t];(i=r).func.apply(i,s(r.args))}le=V.time}if(V.time>me+pe){var e=ge.slice();ge.length=0;for(var t=0;t<e.length;t++){var n,r=e[t];(n=r).func.apply(n,s(r.args))}me=V.time}}()}),this.getBrightness=function(e,t,i){return e<0||t<0||i<0||e>=_-1||i>=_-1?t>=v?1:.6:t>=w.lightDepths[e][i]+1?1:.6},V.getBrightness=this.getBrightness,this.addBlockCheckLit=function(e,t,i){var r=this.lightDepths[e][i];if(t>=r){if(Math.floor(t/g)!=Math.floor(r/g)){var n=V.world.getBlockID(e,r,i);V.world.setBlockID(0,e,r,i),V.world.setBlockID(n,e,r,i)}this.lightDepths[e][i]=t}},this.removeBlockCheckLit=function(e,t,i){var r=this.lightDepths[e][i];if(t>=r){for(var n=0,o=t;(0==n||n==this.redflowerID||n==this.yellowflowerID||n==this.bushID||n==this.redmushroomID||n==this.brownmushroomID||n==this.glassID||n==this.leafID||n==this.emptySpongeID)&&o>=0;)o-=1,n=V.world.getBlockID(e,o,i);return Math.floor(o/g)!=Math.floor(r/g)&&(V.world.setBlockID(0,e,o,i),V.world.setBlockID(n,e,o,i)),this.lightDepths[e][i]=o,1}return.6};var j=function e(){var t=!1;if(w.hostInfo&&null!=w.hostInfo.spawnPoint&&null!=w.hostInfo.spawnPoint&&(t=!0),t)V.entities.setPosition(V.playerEntity,w.hostInfo.spawnPoint.x,w.hostInfo.spawnPoint.y,w.hostInfo.spawnPoint.z);else{for(var i=0,r=0;i<v&&r<50;){var n=Math.floor(M-_/4+Math.random()*(_/2))+.5,o=Math.floor(M-_/4+Math.random()*(_/2))+.5,s=V.pick([n,100,o],[0,-1,0],1e3,!0);null!=s&&(i=s.position[1]),++r}if(r>=50)return void setTimeout(e,100);V.entities.setPosition(V.playerEntity,s.position[0],s.position[1]+1,s.position[2])}m.hide(),w.updateResetPosition(),w.playerSpawned=!0,setTimeout(function(){V.entities.setPhysicsInterpolation(V.playerEntity,!0)},100)},H=i(504)(V),X=(i(505)(V),i(506)(V,g),i(507)),Y=i(508),K=["grass","dirt","grass_dirt","stone","wood","rock","bedrock","sand","gravel","tree_top","tree_side","lava","rock_gold","rock_bronze","rock_coal","gold","sponge","color0","color1","color2","color3","color4","color5","color6","color7","color8","color9","color10","color11","color12","color13","color14","color15"],q=["leaves_opaque","glass","water","bush","red_flower","yellow_flower","red_mushroom","brown_mushroom"];for(L=0;L<K.length;L++){var Z=null;"lava"==(Q=K[L])&&(Z=[.4,0,0,.95]),V.registry.registerMaterial(Q,Z,Q+".png")}for(L=0;L<q.length;L++){var Q;Z=null;"water"==(Q=q[L])&&(Z=[0,0,.4,.85]);V.registry.registerMaterial(Q,Z,Q+".png",!0)}V.registry.registerMaterial("empty_sponge",[0,0,0,0],null,!0);var J=[],$=[null,null,null,8,5,6,15,16];for(L=3;L<8;L++){var ee=q[L],te=X(V);(oe=V.rendering.makeStandardMaterial(ee+"Mat")).diffuseTexture=new BABYLON.Texture("assets/textures/"+ee+".png",scene,!0,!0,1),oe.diffuseTexture.hasAlpha=!0,oe.diffuseTexture.getAlphaFromRGB=!0,te.material=oe;var ie=$[L],re=V.registry.registerBlock(ie,{material:[null,ee,null,null,null,null],opaque:!1,blockMesh:te});J.push(re)}this.grassID=V.registry.registerBlock(1,{material:["grass","dirt","grass_dirt"]}),this.stoneID=V.registry.registerBlock(2,{material:"stone"}),this.dirtID=V.registry.registerBlock(3,{material:"dirt"}),this.woodID=V.registry.registerBlock(4,{material:"wood",opaque:!1,solid:!1,fluid:!0,fluidDensity:1,viscosity:.5}),this.redflowerID=J[1],this.yellowflowerID=J[2],this.waterID=V.registry.registerBlock(7,{material:"water",opaque:!1,solid:!1,fluid:!0,fluidDensity:1,viscosity:.5}),this.bushID=J[0],this.rockID=V.registry.registerBlock(9,{material:"rock"}),this.bedrockID=V.registry.registerBlock(10,{material:"bedrock"}),this.sandID=V.registry.registerBlock(11,{material:"sand"}),this.gravelID=V.registry.registerBlock(12,{material:"gravel"}),this.treeID=V.registry.registerBlock(13,{material:["tree_top","tree_top","tree_side"]}),this.leafID=V.registry.registerBlock(14,{material:"leaves_opaque",opaque:!1}),this.redmushroomID=J[3],this.brownmushroomID=J[4],this.lavaID=V.registry.registerBlock(17,{material:"lava",solid:!1,fluid:!0,fluidDensity:1,viscosity:.5}),this.rockGoldID=V.registry.registerBlock(18,{material:"rock_gold"}),this.rockbronzeID=V.registry.registerBlock(19,{material:"rock_bronze"}),this.rockcoalID=V.registry.registerBlock(20,{material:"rock_coal"}),this.goldID=V.registry.registerBlock(21,{material:"gold"}),this.spongeID=V.registry.registerBlock(22,{material:"sponge"}),this.glassID=V.registry.registerBlock(23,{material:"glass",opaque:!1}),this.colorBlockArray=[];for(L=0;L<16;L++){var ne=V.registry.registerBlock(24+L,{material:"color"+L});this.colorBlockArray.push(ne)}this.emptySpongeID=V.registry.registerBlock(40,{material:"empty_sponge",opaque:!1,solid:!1});var oe;te=Y(V);(oe=V.rendering.makeStandardMaterial(ee+"Mat")).diffuseTexture=V.waterTexture,oe.alpha=.85,oe.useAlphaFromDiffuseTexture=!0,oe.backFaceCulling=!1,oe.disableLighting=!0,oe.emissiveColor=new BABYLON.Color3(.6,.6,.6),te.material=oe,this.waterHackID=V.registry.registerBlock(41,{material:[null,"water",null,null,null,null],opaque:!1,solid:!1,fluid:!0,fluidDensity:1,viscosity:.5,blockMesh:te}),this.soundArray=[null,{id:"grass",volume:.9,pitch:1},{id:"stone",volume:1,pitch:1},{id:"grass",volume:.8,pitch:1},{id:"wood",volume:1,pitch:1},null,null,null,null,{id:"stone",volume:1,pitch:1},null,{id:"gravel",volume:.8,pitch:1},{id:"gravel",volume:.8,pitch:1},{id:"wood",volume:1,pitch:1},{id:"grass",volume:1,pitch:.4},null,null,null,{id:"stone",volume:1,pitch:1},{id:"stone",volume:1,pitch:1},{id:"stone",volume:1,pitch:1},{id:"metal",volume:.7,pitch:1},{id:"cloth",volume:1,pitch:.9},{id:"metal",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1},{id:"cloth",volume:1,pitch:1}],this.blockArray=[this.grassID,this.stoneID,this.dirtID,this.woodID,this.redflowerID,this.yellowflowerID,this.waterID,this.bushID,this.rockID,this.bedrockID,this.sandID,this.gravelID,this.treeID,this.leafID,this.redmushroomID,this.brownmushroomID,this.lavaID,this.rockGoldID,this.rockbronzeID,this.rockcoalID,this.goldID,this.spongeID,this.glassID];for(L=0;L<this.colorBlockArray.length;L++)this.blockArray.push(this.colorBlockArray[L]);var se=i(509)(V,this.blockArray);se.setBlock(W),window.addEventListener("beforeunload",function(e){!w.playerSpawned||b||x||(e.preventDefault(),e.returnValue="")}),document.addEventListener("mousewheel",Se,!1),document.addEventListener("DOMMouseScroll",Se,!1),V.inputs.down.on("fire",function(){if(V.targetedBlock){var e={targetedBlockBlockID:V.targetedBlock.blockID,targetedBlockPosition:V.targetedBlock.position,targetedBlockAdjacentPosition:V.targetedBlock.adjacent,chosenBlock:W,addMode:V.addMode};V.addMode&&(e.localPlayer=!0);var t=w.handleFireEvent(e);delete e.localPlayer,null!=w.player&&t&&w.player.emitFireEvent(e)}}),V.inputs.down.on("mid-fire",function(){if(V.targetedBlock){var e=V.targetedBlock.blockID;if(e==w.rockcoalID||e==w.rockbronzeID||e==w.rockGoldID)return;1==e&&(e=3),N.pick(e),W=e-1,se.setBlock(W)}}),V.inputs.down.on("alt-fire",function(){V.addMode?V.addMode=!1:(V.addMode=!0,se.setBlock(W)),V.resetTargetBlock(),V.emit("targetBlockChanged",V.targetedBlock)}),document.addEventListener("keydown",function(e){var t=e.keyCode;if(8==t&&e.preventDefault(),e.ctrlKey&&e.preventDefault(),!G.isOpen&&ae)if(ae=!1,27==t&&c.isOpen)c.close();else if(27==t&&(U.isOpen?U.close():(U.open(),z.isOpen&&z.close())),!U.isOpen&&(!c||!c.isOpen)&&t>=49&&t<=57){var i=t-49;N.setIndex(i),W=N.currentId-1,se.setBlock(W)}},!1),document.addEventListener("keyup",function(e){ae=!0},!1);var ae=!0;V.inputs.down.on("build",function(e,t){U.isOpen||c.isOpen||z.open()}),V.inputs.down.on("chat",function(e,t){U.isOpen||c.isOpen||(z.isOpen&&z.close(),c.open())}),V.inputs.down.on("fog",function(e,t){U.isOpen||c.isOpen||ye()}),V.inputs.down.on("saveLoc",function(e,t){U.isOpen||c.isOpen||w.updateResetPosition()}),V.inputs.down.on("loadLoc",function(e,t){U.isOpen||c.isOpen||w.applyResetPosition()}),V.inputs.down.on("spawnSteve",function(e,t){U.isOpen||c.isOpen||w.spawnSteve()});var ce=!1;document.addEventListener("pointerlockchange",function(e){var t=!1;c&&(t=c.isOpen),null!=document.pointerLockElement||!ce||z.isOpen||t||G.isOpen?(ce=!0,V.inputs.state.forward=!1,V.inputs.state.backward=!1,V.inputs.state.left=!1,V.inputs.state.right=!1,t&&ae&&c.close()):U.open()},!1),window.addEventListener("resize",function(e){U.resize(),m.resize(),G.resize(),N.resize(),c&&c.resize(),V.version&&V.version.resize(),z.resize()}),V.on("setPreviewBlock",function(e){W=e-1,se.setBlock(W)});var he={position:[O.playerStart[0],O.playerStart[1],O.playerStart[2]],rotation:[0,0,0]};this.setPlayerPosition=function(e){var t=V.playerEntity;V.entities.setPhysicsInterpolation(t,!1),V.entities.setPosition(t,e[0],e[1]+.5,e[2]),setTimeout(function(){V.entities.setPhysicsInterpolation(t,!0)},100)},this.updateResetPosition=function(){var e=V.playerEntity,t=V.entities.getPosition(e);he.position[0]=t[0],he.position[1]=t[1],he.position[2]=t[2],he.rotation[0]=0,he.rotation[1]=V.rendering._rotationHolder.rotation.y,he.rotation[2]=0,w.applyResetPosition()},this.applyResetPosition=function(){V.entities.setPhysicsInterpolation(V.playerEntity,!1);var e=V.playerEntity;V.entities.setPosition(e,he.position[0],he.position[1]+.5,he.position[2]),V.rendering._rotationHolder.rotation.x=he.rotation[0],V.rendering._rotationHolder.rotation.y=he.rotation[1],V.rendering._rotationHolder.rotation.z=he.rotation[2],setTimeout(function(){V.entities.setPhysicsInterpolation(V.playerEntity,!0)},100)},this.steveArray=[],this.spawnSteve=function(){var e=V.entities.getPositionData(V.playerEntity),t=i(510),r=e.position[0],n=e.position[1]+.5,o=e.position[2],s=t(V,r,n,o);w.steveArray.push(s)};var ue=250,le=0,fe=[],de=function(e,t){fe.push({func:e,args:t})},pe=1500,me=0,ge=[],_e=function(e,t){ge.push({func:e,args:t})};this.checkWaterBelowAdd=function(e,t,i){var r=this.waterID;this.shouldWaterHaveSurface(e,t,i)&&(r=this.waterHackID),this.setBlock(r,e,t,i);var n=V.world.getBlockID(e-1,t,i),o=V.world.getBlockID(e+1,t,i),s=V.world.getBlockID(e,t,i+1),a=V.world.getBlockID(e,t,i-1);if(n==this.waterID||n==this.waterHackID){r=this.waterID;var c=V.world.getBlockID(e-1,t+1,i);this.shouldWaterHaveSurface(e-1,t,i)&&0!=c&&(r=this.waterHackID),this.setBlock(r,e-1,t,i)}if(o==this.waterID||o==this.waterHackID){r=this.waterID;var h=V.world.getBlockID(e+1,t+1,i);this.shouldWaterHaveSurface(e+1,t,i)&&0!=h&&(r=this.waterHackID),this.setBlock(r,e+1,t,i)}if(s==this.waterID||s==this.waterHackID){r=this.waterID;var u=V.world.getBlockID(e,t+1,i+1);this.shouldWaterHaveSurface(e,t,i+1)&&0!=u&&(r=this.waterHackID),this.setBlock(r,e,t,i+1)}if(a==this.waterID||a==this.waterHackID){r=this.waterID;var l=V.world.getBlockID(e,t+1,i-1);this.shouldWaterHaveSurface(e,t,i-1)&&0!=l&&(r=this.waterHackID),this.setBlock(r,e,t,i-1)}},this.checkWaterHackBelowDestroy=function(e,t,i){V.world.getBlockID(e,t,i)==this.waterHackID&&this.addBlock(this.waterID,e,t,i);var r,n=V.world.getBlockID(e-1,t,i),o=V.world.getBlockID(e+1,t,i),s=V.world.getBlockID(e,t,i+1),a=V.world.getBlockID(e,t,i-1);if(n==this.waterID||n==this.waterHackID){r=this.waterID;var c=V.world.getBlockID(e-1,t+1,i);this.shouldWaterHaveSurface(e-1,t,i)&&0!=c&&(r=this.waterHackID),this.setBlock(r,e-1,t,i)}if(o==this.waterID||o==this.waterHackID){r=this.waterID;var h=V.world.getBlockID(e+1,t+1,i);this.shouldWaterHaveSurface(e+1,t,i)&&0!=h&&(r=this.waterHackID),this.setBlock(r,e+1,t,i)}if(s==this.waterID||s==this.waterHackID){r=this.waterID;var u=V.world.getBlockID(e,t+1,i+1);this.shouldWaterHaveSurface(e,t,i+1)&&0!=u&&(r=this.waterHackID),this.setBlock(r,e,t,i+1)}if(a==this.waterID||a==this.waterHackID){r=this.waterID;var l=V.world.getBlockID(e,t+1,i-1);this.shouldWaterHaveSurface(e,t,i-1)&&0!=l&&(r=this.waterHackID),this.setBlock(r,e,t,i-1)}},this.shouldWaterHaveSurface=function(e,t,i){var r=V.world.getBlockID(e,t+1,i),n=V.world.getBlockID(e-1,t+1,i),o=V.world.getBlockID(e+1,t+1,i),s=V.world.getBlockID(e,t+1,i+1),a=V.world.getBlockID(e,t+1,i-1);return(0==r||0==n||0==o||0==s||0==a)&&r!=this.waterID&&n!=this.waterID&&o!=this.waterID&&s!=this.waterID&&a!=this.waterID&&r!=this.waterHackID&&n!=this.waterHackID&&o!=this.waterHackID&&s!=this.waterHackID&&a!=this.waterHackID},this.addWater=function(e,t,i){if(e<0||e>=V.worldSize-1||i<0||i>=V.worldSize-1)return!1;var r=this.waterID,n=V.world.getBlockID(e,t+1,i);if(this.shouldWaterHaveSurface(e,t,i)&&0!=n&&n!=this.emptySpongeID&&(r=this.waterHackID),this.addBlock(this.waterID,e,t,i),r!=this.waterID){this.addBlock(r,e,t,i);var o=V.world.getBlockID(e-1,t,i),s=V.world.getBlockID(e+1,t,i),a=V.world.getBlockID(e,t,i+1),c=V.world.getBlockID(e,t,i-1),h=V.world.getBlockID(e-1,t+1,i),u=V.world.getBlockID(e+1,t+1,i),l=V.world.getBlockID(e,t+1,i+1),f=V.world.getBlockID(e,t+1,i-1);o==this.waterID&&0!=h&&(V.setBlock(r,e-1,t,i),this.setBlockTilesArray(r,e-1,t,i)),s==this.waterID&&0!=u&&(V.setBlock(r,e+1,t,i),this.setBlockTilesArray(r,e-1,t,i)),a==this.waterID&&0!=l&&(V.setBlock(r,e,t,i+1),this.setBlockTilesArray(r,e-1,t,i)),c==this.waterID&&0!=f&&(V.setBlock(r,e,t,i-1),this.setBlockTilesArray(r,e-1,t,i))}var d=V.world.getBlockID(e,t-1,i);return d==this.grassID&&this.flagToRemoveGrass(e,t-1,i),d==this.lavaID&&this.setBlock(this.stoneID,e,t-1,i),d==this.waterHackID&&this.setBlock(this.waterID,e,t-1,i),!0},this.addLava=function(e,t,i){this.addBlock(this.lavaID,e,t,i);var r=V.world.getBlockID(e,t-1,i);r==this.grassID&&this.flagToRemoveGrass(e,t-1,i),r==this.waterID&&this.setBlock(this.stoneID,e,t-1,i)},this.checkNeighbours=function(e,t,i,r){if(!(e<0||e>=V.worldSize-1||i<0||i>=V.worldSize-1)&&0==V.world.getBlockID(e,t,i)){var n=V.world.getBlockID(e,t+1,i),o=V.world.getBlockID(e-1,t,i),s=V.world.getBlockID(e+1,t,i),a=V.world.getBlockID(e,t,i+1),c=V.world.getBlockID(e,t,i-1);n!=w.lavaID&&o!=w.lavaID&&s!=w.lavaID&&a!=w.lavaID&&c!=w.lavaID||setTimeout(function(){w.addLava(e,t,i),_e(w.checkNeighboursAsLava,[e,t,i])},1500),n!=w.waterID&&o!=w.waterID&&s!=w.waterID&&a!=w.waterID&&c!=w.waterID&&n!=w.waterHackID&&o!=w.waterHackID&&s!=w.waterHackID&&a!=w.waterHackID&&c!=w.waterHackID||setTimeout(function(){w.addWater(e,t,i)&&de(w.checkNeighboursAsWater,[e,t,i])},150),r&&setTimeout(function(){w.checkWaterHackBelowDestroy(e,t-1,i)},160)}},this.checkNeighboursAsWater=function(e,t,i){if(!(e<=0||e>=V.worldSize-1||i<=0||i>=V.worldSize-1)){var r=V.world.getBlockID(e,t-1,i),n=V.world.getBlockID(e-1,t,i),o=V.world.getBlockID(e+1,t,i),s=V.world.getBlockID(e,t,i+1),a=V.world.getBlockID(e,t,i-1);0==r&&w.addWater(e,t-1,i)&&de(w.checkNeighboursAsWater,[e,t-1,i]),0==n&&w.addWater(e-1,t,i)&&de(w.checkNeighboursAsWater,[e-1,t,i]),0==o&&w.addWater(e+1,t,i)&&de(w.checkNeighboursAsWater,[e+1,t,i]),0==s&&w.addWater(e,t,i+1)&&de(w.checkNeighboursAsWater,[e,t,i+1]),0==a&&w.addWater(e,t,i-1)&&de(w.checkNeighboursAsWater,[e,t,i-1])}},this.checkNeighboursAsLava=function(e,t,i){if(!(e<0||e>V.worldSize-1||i<0||i>V.worldSize-1)){var r=V.world.getBlockID(e,t-1,i),n=V.world.getBlockID(e-1,t,i),o=V.world.getBlockID(e+1,t,i),s=V.world.getBlockID(e,t,i+1),a=V.world.getBlockID(e,t,i-1);0==r&&(w.addLava(e,t-1,i),_e(w.checkNeighboursAsLava,[e,t-1,i])),0==n&&(w.addLava(e-1,t,i),_e(w.checkNeighboursAsLava,[e-1,t,i])),0==o&&(w.addLava(e+1,t,i),_e(w.checkNeighboursAsLava,[e+1,t,i])),0==s&&(w.addLava(e,t,i+1),_e(w.checkNeighboursAsLava,[e,t,i+1])),0==a&&(w.addLava(e,t,i-1),_e(w.checkNeighboursAsLava,[e,t,i-1]))}},this.flagToGrowGrass=function(e,t,i){var r=E+Math.random()*(P-E);setTimeout(function(){if(V.world.getBlockID(e,t,i)==w.dirtID){var r=w.checkUpForBlocker(e,t,i);0!=r&&r!=w.redflowerID&&r!=w.yellowflowerID&&r!=w.bushID&&r!=w.redmushroomID&&r!=w.brownmushroomID&&r!=w.glassID&&r!=w.leafID||w.setBlock(w.grassID,e,t,i)}},r)},this.flagToRemoveGrass=function(e,t,i){var r=C+Math.random()*(R-C);setTimeout(function(){if(V.world.getBlockID(e,t,i)==w.grassID){var r=w.checkUpForBlocker(e,t,i);0!=r&&r!=w.redflowerID&&r!=w.yellowflowerID&&r!=w.bushID&&r!=w.redmushroomID&&r!=w.brownmushroomID&&r!=w.glassID&&r!=w.leafID&&w.setBlock(w.dirtID,e,t,i)}},r)},this.checkBelowFoilage=function(e,t,i){var r=I+Math.random()*(D-I);setTimeout(function(){var r=V.world.getBlockID(e,t,i);if(r==w.redflowerID||r==w.yellowflowerID||r==w.bushID||r==w.redmushroomID||r==w.brownmushroomID){var n=V.world.getBlockID(e,t-1,i);n!=w.grassID&&n!=w.dirtID&&(w.setBlock(0,e,t,i),de(w.checkNeighbours,[e,t,i]))}},r)},this.checkAboveFoilage=function(e,t,i){var r=I+Math.random()*(D-I);setTimeout(function(){var r=V.world.getBlockID(e,t,i);if((r==w.redflowerID||r==w.yellowflowerID||r==w.bushID||r==w.redmushroomID||r==w.brownmushroomID)&&w.getBrightness(e,t,i)<1){w.setBlock(0,e,t,i),de(w.checkNeighbours,[e,t,i]);var n=V.world.getBlockID(e,t+1,i);n!=w.sandID&&n!=w.gravelID||w.checkDownSandGravel(e,t+1,i,n)}},r)},this.checkDownForGrass=function(e,t,i){for(var r=0,n=t;(0==r||r==this.redflowerID||r==this.yellowflowerID||r==this.bushID||r==this.redmushroomID||r==this.brownmushroomID||r==this.glassID||r==this.leafID)&&n>=0;)n-=1,(r=V.world.getBlockID(e,n,i))!=this.redflowerID&&r!=this.yellowflowerID&&r!=this.bushID&&r!=this.redmushroomID&&r!=this.brownmushroomID||w.checkAboveFoilage(e,n,i);r==this.grassID&&this.flagToRemoveGrass(e,n,i)},this.checkDownForDirt=function(e,t,i){for(var r=0,n=t;(0==r||r==this.redflowerID||r==this.yellowflowerID||r==this.bushID||r==this.redmushroomID||r==this.brownmushroomID||r==this.glassID||r==this.leafID)&&n>=0;)n-=1,r=V.world.getBlockID(e,n,i);r==this.dirtID&&this.flagToGrowGrass(e,n,i)},this.checkDownSandGravel=function(e,t,i,r){for(var n=0,o=t;(0==n||n==this.waterID||n==this.waterHackID||n==this.lavaID||n==this.emptySpongeID)&&o>=0;)o-=1,n=V.world.getBlockID(e,o,i);if(0!=n){w.setBlock(0,e,t,i),w.setBlock(r,e,o+1,i);var s=V.world.getBlockID(e,t+1,i);s!=w.sandID&&s!=w.gravelID||w.checkDownSandGravel(e,t+1,i,s);w.removeBlockCheckLit(e,t,i);w.checkNeighbours(e,t,i,!1)}},this.checkUpForBlocker=function(e,t,i){for(var r=0,n=t;(0==r||r==this.redflowerID||r==this.yellowflowerID||r==this.bushID||r==this.redmushroomID||r==this.brownmushroomID||r==this.glassID||r==this.leafID)&&n<64;)n+=1,r=V.world.getBlockID(e,n,i);return r};var ve={};this.updateRemainingSponges=function(){for(var e in ve){var t=ve[e];w.checkAddSponge(t.x,t.y,t.z,!1)}},this.checkAddSponge=function(e,t,i,r){(r||null==r)&&(ve["s"+e+t+i]={x:e,y:t,z:i});for(var n=Math.max(e-2,1),o=Math.min(e+2,_-3),s=Math.max(i-2,1),a=Math.min(i+2,_-3),c=t-2;c<=t+2;c++)for(var h=n;h<=o;h++)for(var u=s;u<=a;u++){var l=V.world.getBlockID(h,c,u);l!=w.waterID&&0!=l||(w.setBlock(w.emptySpongeID,h,c,u),w.removeBlockCheckLit(h,c,u))}},this.checkRemoveSponge=function(e,t,i){delete ve["s"+e+t+i];for(var r=Math.max(e-2,1),n=Math.min(e+2,_-3),o=Math.max(i-2,1),s=Math.min(i+2,_-3),a=t-2;a<=t+2;a++)for(var c=r;c<=n;c++)for(var h=o;h<=s;h++){var u;u=c==e-2||c==e+2||h==i-2||h==i+2,V.world.getBlockID(c,a,h)==w.emptySpongeID&&(w.setBlock(0,c,a,h),u&&de(w.checkNeighbours,[c,a,h]))}w.updateRemainingSponges()};var ye=function(){V.settings.drawDistance++,V.settings.drawDistance>3&&(V.settings.drawDistance=0),be(V.settings.drawDistance),V.emit("saveSettings")};V.on("cycleDrawDistance",ye);var be=function(e){switch(V.settings.drawDistance=e,e){case 0:V.rendering.fogWorld=.002,V.rendering.fogWater=.08,V.rendering.fogLava=.2,V.rendering._camera.maxZ=800;break;case 1:V.rendering.fogWorld=.008,V.rendering.fogWater=.08,V.rendering.fogLava=.2,V.rendering._camera.maxZ=200;break;case 2:V.rendering.fogWorld=.05,V.rendering.fogWater=.1,V.rendering.fogLava=.2,V.rendering._camera.maxZ=50;break;case 3:V.rendering.fogWorld=.2,V.rendering.fogWater=.2,V.rendering.fogLava=.2,V.rendering._camera.maxZ=10}V.rendering._camLocBlock+=1};be(V.settings.drawDistance),V.on("toggleMusic",function(){V.settings.music?(V.settings.music=!1,w.soundPlayer.setMusicVolume(0)):(V.settings.music=!0,w.soundPlayer.setMusicVolume(1)),w.soundPlayer.musicOn=V.settings.music,V.emit("saveSettings")}),V.on("toggleSound",function(){V.settings.sound?V.settings.sound=!1:V.settings.sound=!0,w.soundPlayer.soundOn=V.settings.sound,V.emit("saveSettings")}),V.on("toggleInvertMouse",function(){V.settings.invert?V.settings.invert=!1:V.settings.invert=!0,V.cameraControls.inverseY=V.settings.invert,V.emit("saveSettings")}),V.on("toggleFps",function(){V.settings.fps?V.settings.fps=!1:V.settings.fps=!0,V.version.showFps=V.settings.fps,V.version.lastRedraw=0,V.version.redraw(),V.emit("saveSettings")}),V.on("saveSettings",function(){localStorage.setItem("settings",JSON.stringify(V.settings))}),setInterval(function(){if(null!=t.player){var e=V.entities.getPositionData(V.playerEntity),i=V.rendering._rotationHolder.rotation;t.player.setPosition({x:e.position[0],y:e.position[1],z:e.position[2]},i,t.playerSpawned)}},50),V.setName=function(e){w.setName&&w.setName(e)},this.onHostDisconnect=function(){x||(this.worldInitialized&&(U.isOpen&&U.close(),c.isOpen&&c.close(),z.isOpen&&z.close()),G&&G.show(3),b=!0)},this.onHostFull=function(){G&&G.show(2)},this.onKicked=function(){x=!0,G&&G.show(5)},this.addPlayer=function(e,t,r,n,o){return i(512)(V,e,t,r,n,o)},this.getPlayerPosition=function(){return V.entities.getPosition(V.playerEntity)},this.getPlayerRotation=function(){return V.rendering._rotationHolder.rotation},this.setBlock=function(e,t,i,r){var n=t.length?t:[t,i,r];this.setBlockTilesArray(e,n),V.setBlock(e,n),void 0!==this.changedBlockHandler&&null!==this.changedBlockHandler&&this.changedBlockHandler.setBlock(n,e)},this.addBlock=function(e,t,i,r){var n=t.length?t:[t,i,r],o=!!t.length&&i;return this.setBlockTilesArray(e,n),!!V.addBlock(e,n,o)&&(void 0!==this.changedBlockHandler&&null!==this.changedBlockHandler&&this.changedBlockHandler.addBlock(n,e),e!=this.leafID&&e!=this.glassID&&e!=this.redflowerID&&e!=this.yellowflowerID&&e!=this.bushID&&e!=this.redmushroomID&&e!=this.brownmushroomID&&this.addBlockCheckLit(n[0],n[1],n[2]),!0)},this.handleChangedBlocks=function(e){for(var t in e){var i=e[t];this.setBlockTilesArray(i.bt,i.p),this.worldInitialized&&(i.add?this.addBlock(i.bt,i.p):(this.setBlock(i.bt,i.p),0==i.bt&&this.removeBlockCheckLit(i.p[0],i.p[1],i.p[2])))}this.worldGenerated&&!this.worldInitialized&&xe()},this.syncSavedWorld=function(){var e=r.default.getInstance().getChangedBlocks();for(var t in e){var i=e[t];this.setBlockTilesArray(i.bt,i.p)}},this.setBlockTilesArray=function(e,t,i,r){if(y){var n=t.length?t:[t,i,r];y[(n[1]*_+n[2])*_+n[0]]=e}},this.updateChatLog=function(e){void 0!==c&&c.update(e)}}else console.log("seed must be an integer.");function xe(){!function(){for(var e=0;e<_;++e)for(var t=0;t<64;++t)for(var i=0;i<_;++i){var r=e,n=t,o=i,s=y[(n*_+o)*_+r],a=0;null!=w.lightDepths[r][o]&&(a=w.lightDepths[r][o]),0!=s&&s!=w.redflowerID&&s!=w.yellowflowerID&&s!=w.bushID&&s!=w.redmushroomID&&s!=w.brownmushroomID&&s!=w.glassID&&s!=w.leafID&&s!=w.emptySpongeID&&n>=a&&(a=n),w.lightDepths[r][o]=a}}(),V.world.on("worldDataNeeded",we),V.setPaused(!1),c=o(V),V.version=d(),V.version.showFps=V.settings.fps,V.entities.setPhysicsInterpolation(V.playerEntity,!1),setTimeout(j,100),w.worldInitialized=!0,V.hostInfo.gameFull&&(U.isOpen&&U.close(!0),G.show(2)),null!=S.get("host")?(U.isOpen&&U.close(!0),w.noWebrtcJoin?G.show(6):G.show(0)):null!=S.get("join")&&(U.isOpen&&U.close(!0),G.show(1))}function we(e,t,i,r,n){var o=e.split("|"),s=parseInt(o[0],10),a=parseInt(o[1],10),c=parseInt(o[2],10),h=s*g,u=a*g,l=c*g,f=!1;if((s<0||a<0||c<0)&&(f=!0),(s>=_/g||a>=64/g||c>=_/g)&&(f=!0),f){for(var d=w.bedrockID,p=0;p<t.shape[0];++p)for(var m=0;m<t.shape[1];++m)for(var b=0;b<t.shape[2];++b){d=0,(x=m-1+u)<=v&&(d=w.waterID),x<=v-2&&(d=w.bedrockID),t.set(p,m,b,d)}V.world.setChunkData(e,t)}else{for(d=w.bedrockID,p=0;p<t.shape[0];++p)for(m=0;m<t.shape[1];++m)for(b=0;b<t.shape[2];++b){var x,S=p-1+h,T=b-1+l;null!=(d=y[((x=m-1+u)*_+T)*_+S])&&0!=x||(d=w.bedrockID),(S<0||T<0||p+h>=_||b+l>=_)&&(d=0,x<=v&&(d=w.waterID),x<=v-2&&(d=w.bedrockID)),t.set(p,m,b,d)}V.world.setChunkData(e,t)}}function Se(e){e.ctrlKey&&e.preventDefault()}}},{key:"handleFireEvent",value:function(e){var t=e.targetedBlockBlockID,i=e.targetedBlockPosition,r=e.targetedBlockAdjacentPosition,n=e.addMode,o=e.chosenBlock,s=e.localPlayer;if("undefined"==typeof noa)return n?this.setBlockTilesArray(this.blockArray[o],r):this.setBlockTilesArray(0,i),!1;if(n){if(r[1]>=noa.worldHeight)return!1;var a=noa.world.getBlockID(r[0],r[1],r[2]);if(!this.addBlock(this.blockArray[o],r,s))return!1;var c=this.blockArray[o];return c==this.dirtID&&this.flagToGrowGrass(r[0],r[1],r[2]),this.checkDownForGrass(r[0],r[1],r[2]),(v=noa.world.getBlockID(r[0],r[1]-1,r[2]))!=this.waterID&&v!=this.waterHackID||0!=a||this.checkWaterBelowAdd(r[0],r[1]-1,r[2]),c!=this.sandID&&c!=this.gravelID||this.checkDownSandGravel(r[0],r[1],r[2],c),c==this.spongeID&&this.checkAddSponge(r[0],r[1],r[2]),c!=this.redflowerID&&c!=this.yellowflowerID&&c!=this.bushID&&c!=this.redmushroomID&&c!=this.brownmushroomID||(v!=this.dirtID&&v!=this.grassID&&this.checkBelowFoilage(r[0],r[1],r[2]),this.checkAboveFoilage(r[0],r[1],r[2])),!0}if(t!=this.bedrockID){var h=noa.registry.getBlockFaceMaterialAccessor()(t,0),u=noa.registry._textures[h];this.setBlock(0,i);var l=i,f=this.removeBlockCheckLit(l[0],l[1],l[2]),d=new BABYLON.Vector3(l[0],l[1],l[2]),p=BABYLON.Vector3.Distance(noa.rendering._cameraHolder.position,d);if(null!=u&&p<15)this.addParticles("debris",u,f).mesh.position.copyFromFloats(l[0]+.5,l[1]+.5,l[2]+.5);this.checkDownForDirt(i[0],i[1],i[2]),t==this.spongeID&&this.checkRemoveSponge(i[0],i[1],i[2]);var m=noa.world.getBlockID(l[0],l[1]+1,l[2]);t!=this.dirtID&&t!=this.grassID||m!=this.redflowerID&&m!=this.yellowflowerID&&m!=this.bushID&&m!=this.redmushroomID&&m!=this.brownmushroomID||this.checkBelowFoilage(i[0],i[1]+1,i[2]),m!=this.sandID&&m!=this.gravelID||this.checkDownSandGravel(i[0],i[1]+1,i[2],m);var g=this.soundArray[t];if(null!=g&&p<15){var _=1-p/25;this.soundPlayer.play(g.id,g.volume*_,g.pitch)}var v,y=!1;return(v=noa.world.getBlockID(l[0],l[1]-1,l[2]))!=this.waterID&&v!=this.waterHackID||(y=!0),this.checkNeighbours(i[0],i[1],i[2],y),!0}}},{key:"setChangedBlockHandler",value:function(e){this.changedBlockHandler=e}},{key:"setPlayer",value:function(e){this.player=e}},{key:"setHostInfo",value:function(e){if(this.hostInfo=e,this.hostInfo.gameFull||this.hostInfo.noSuchGame){if(!t)var t=i(194)({});this.hostInfo.noSuchGame?(t.show(4),document.body.style.overflow="hidden"):t.show(2),window.addEventListener("resize",function(e){t.resize()})}}},{key:"getPlayerNames",value:function(){return this.network.getSpawnedPlayerNames()}},{key:"kickPlayer",value:function(e){return this.network.kickPlayer(e)}},{key:"teleportToPlayer",value:function(e){for(var t in this.network.state.players)if(this.network.state.players[t].state.name===e){var i=this.network.state.players[t].state.position;return noa.entities.setPhysicsInterpolation(noa.playerEntity,!1),noa.entities.setPosition(noa.playerEntity,i.x,i.y,i.z),setTimeout(function(){noa.entities.setPhysicsInterpolation(noa.playerEntity,!0)},100),"Teleporting to "+e+" "+JSON.stringify(i)}return"No such player"}},{key:"setSpawn",value:function(){return this.network.setSpawnToCurrentPosition()}},{key:"teleportTo",value:function(e){var t=this.network.getPositionFor(e);return null===t?e+": no such player":(this.setPlayerPosition([t.x,t.y,t.z]),"teleported to "+e)}}])&&a(t.prototype,n),c&&a(t,c),e}(),h=t.a=c},function(e,t,i){var r=i(6),n=i(5).document,o=r(n)&&r(n.createElement);e.exports=function(e){return o?n.createElement(e):{}}},function(e,t,i){var r=i(14),n=i(5),o=n["__core-js_shared__"]||(n["__core-js_shared__"]={});(e.exports=function(e,t){return o[e]||(o[e]=void 0!==t?t:{})})("versions",[]).push({version:r.version,mode:i(46)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(e,t,i){t.f=i(8)},function(e,t,i){var r=i(96)("keys"),n=i(45);e.exports=function(e){return r[e]||(r[e]=n(e))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,i){var r=i(36);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,i){var r=i(5).document;e.exports=r&&r.documentElement},function(e,t,i){var r=i(6),n=i(4),o=function(e,t){if(n(e),!r(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{(r=i(34)(Function.call,i(29).f(Object.prototype,"__proto__").set,2))(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,i){return o(e,i),t?e.__proto__=i:r(e,i),e}}({},!1):void 0),check:o}},function(e,t){e.exports="\t\n\v\f\r Â áš€á Žâ€€â€â€‚â€ƒâ€„â€…â€†â€‡â€ˆâ€‰â€Šâ€¯âŸã€€\u2028\u2029\ufeff"},function(e,t,i){var r=i(6),n=i(102).set;e.exports=function(e,t,i){var o,s=t.constructor;return s!==i&&"function"==typeof s&&(o=s.prototype)!==i.prototype&&r(o)&&n&&n(e,o),e}},function(e,t,i){"use strict";var r=i(28),n=i(37);e.exports=function(e){var t=String(n(this)),i="",o=r(e);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(t+=t))1&o&&(i+=t);return i}},function(e,t){e.exports=Math.sign||function(e){return 0==(e=+e)||e!=e?e:e<0?-1:1}},function(e,t){var i=Math.expm1;e.exports=!i||i(10)>22025.465794806718||i(10)<22025.465794806718||-2e-17!=i(-2e-17)?function(e){return 0==(e=+e)?e:e>-1e-6&&e<1e-6?e+e*e/2:Math.exp(e)-1}:i},function(e,t,i){var r=i(28),n=i(37);e.exports=function(e){return function(t,i){var o,s,a=String(n(t)),c=r(i),h=a.length;return c<0||c>=h?e?"":void 0:(o=a.charCodeAt(c))<55296||o>56319||c+1===h||(s=a.charCodeAt(c+1))<56320||s>57343?e?a.charAt(c):o:e?a.slice(c,c+2):s-56320+(o-55296<<10)+65536}}},function(e,t,i){"use strict";var r=i(46),n=i(0),o=i(19),s=i(23),a=i(57),c=i(151),h=i(56),u=i(51),l=i(8)("iterator"),f=!([].keys&&"next"in[].keys()),d=function(){return this};e.exports=function(e,t,i,p,m,g,_){c(i,t,p);var v,y,b,x=function(e){if(!f&&e in A)return A[e];switch(e){case"keys":case"values":return function(){return new i(this,e)}}return function(){return new i(this,e)}},w=t+" Iterator",S="values"==m,T=!1,A=e.prototype,M=A[l]||A["@@iterator"]||m&&A[m],E=M||x(m),P=m?S?x("entries"):E:void 0,C="Array"==t&&A.entries||M;if(C&&(b=u(C.call(new e)))!==Object.prototype&&b.next&&(h(b,w,!0),r||"function"==typeof b[l]||s(b,l,d)),S&&M&&"values"!==M.name&&(T=!0,E=function(){return M.call(this)}),r&&!_||!f&&!T&&A[l]||s(A,l,E),a[t]=E,a[w]=d,m)if(v={values:S?E:x("values"),keys:g?E:x("keys"),entries:P},_)for(y in v)y in A||o(A,y,v[y]);else n(n.P+n.F*(f||T),t,v);return v}},function(e,t,i){var r=i(111),n=i(37);e.exports=function(e,t,i){if(r(t))throw TypeError("String#"+i+" doesn't accept regex!");return String(n(e))}},function(e,t,i){var r=i(6),n=i(36),o=i(8)("match");e.exports=function(e){var t;return r(e)&&(void 0!==(t=e[o])?!!t:"RegExp"==n(e))}},function(e,t,i){var r=i(8)("match");e.exports=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[r]=!1,!"/./"[e](t)}catch(e){}}return!0}},function(e,t,i){var r=i(57),n=i(8)("iterator"),o=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||o[n]===e)}},function(e,t,i){"use strict";var r=i(12),n=i(44);e.exports=function(e,t,i){t in e?r.f(e,t,n(0,i)):e[t]=i}},function(e,t,i){var r=i(66),n=i(8)("iterator"),o=i(57);e.exports=i(14).getIteratorMethod=function(e){if(null!=e)return e[n]||e["@@iterator"]||o[r(e)]}},function(e,t,i){"use strict";var r=i(20),n=i(48),o=i(10);e.exports=function(e){for(var t=r(this),i=o(t.length),s=arguments.length,a=n(s>1?arguments[1]:void 0,i),c=s>2?arguments[2]:void 0,h=void 0===c?i:n(c,i);h>a;)t[a++]=e;return t}},function(e,t,i){"use strict";var r=i(58),n=i(155),o=i(57),s=i(24);e.exports=i(109)(Array,"Array",function(e,t){this._t=s(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,i=this._i++;return!e||i>=e.length?(this._t=void 0,n(1)):n(0,"keys"==t?i:"values"==t?e[i]:[i,e[i]])},"values"),o.Arguments=o.Array,r("keys"),r("values"),r("entries")},function(e,t,i){"use strict";var r,n,o=i(78),s=RegExp.prototype.exec,a=String.prototype.replace,c=s,h=(r=/a/,n=/b*/g,s.call(r,"a"),s.call(n,"a"),0!==r.lastIndex||0!==n.lastIndex),u=void 0!==/()??/.exec("")[1];(h||u)&&(c=function(e){var t,i,r,n,c=this;return u&&(i=new RegExp("^"+c.source+"$(?!\\s)",o.call(c))),h&&(t=c.lastIndex),r=s.call(c,e),h&&r&&(c.lastIndex=c.global?r.index+r[0].length:t),u&&r&&r.length>1&&a.call(r[0],i,function(){for(n=1;n<arguments.length-2;n++)void 0===arguments[n]&&(r[n]=void 0)}),r}),e.exports=c},function(e,t,i){"use strict";var r=i(108)(!0);e.exports=function(e,t,i){return t+(i?r(e,t).length:1)}},function(e,t,i){var r,n,o,s=i(34),a=i(145),c=i(101),h=i(95),u=i(5),l=u.process,f=u.setImmediate,d=u.clearImmediate,p=u.MessageChannel,m=u.Dispatch,g=0,_={},v=function(){var e=+this;if(_.hasOwnProperty(e)){var t=_[e];delete _[e],t()}},y=function(e){v.call(e.data)};f&&d||(f=function(e){for(var t=[],i=1;arguments.length>i;)t.push(arguments[i++]);return _[++g]=function(){a("function"==typeof e?e:Function(e),t)},r(g),g},d=function(e){delete _[e]},"process"==i(36)(l)?r=function(e){l.nextTick(s(v,e,1))}:m&&m.now?r=function(e){m.now(s(v,e,1))}:p?(o=(n=new p).port2,n.port1.onmessage=y,r=s(o.postMessage,o,1)):u.addEventListener&&"function"==typeof postMessage&&!u.importScripts?(r=function(e){u.postMessage(e+"","*")},u.addEventListener("message",y,!1)):r="onreadystatechange"in h("script")?function(e){c.appendChild(h("script")).onreadystatechange=function(){c.removeChild(this),v.call(e)}}:function(e){setTimeout(s(v,e,1),0)}),e.exports={set:f,clear:d}},function(e,t,i){"use strict";var r=i(5),n=i(13),o=i(46),s=i(84),a=i(23),c=i(61),h=i(3),u=i(60),l=i(28),f=i(10),d=i(163),p=i(50).f,m=i(12).f,g=i(116),_=i(56),v="prototype",y="Wrong index!",b=r.ArrayBuffer,x=r.DataView,w=r.Math,S=r.RangeError,T=r.Infinity,A=b,M=w.abs,E=w.pow,P=w.floor,C=w.log,R=w.LN2,I=n?"_b":"buffer",D=n?"_l":"byteLength",O=n?"_o":"byteOffset";function L(e,t,i){var r,n,o,s=new Array(i),a=8*i-t-1,c=(1<<a)-1,h=c>>1,u=23===t?E(2,-24)-E(2,-77):0,l=0,f=e<0||0===e&&1/e<0?1:0;for((e=M(e))!=e||e===T?(n=e!=e?1:0,r=c):(r=P(C(e)/R),e*(o=E(2,-r))<1&&(r--,o*=2),(e+=r+h>=1?u/o:u*E(2,1-h))*o>=2&&(r++,o/=2),r+h>=c?(n=0,r=c):r+h>=1?(n=(e*o-1)*E(2,t),r+=h):(n=e*E(2,h-1)*E(2,t),r=0));t>=8;s[l++]=255&n,n/=256,t-=8);for(r=r<<t|n,a+=t;a>0;s[l++]=255&r,r/=256,a-=8);return s[--l]|=128*f,s}function F(e,t,i){var r,n=8*i-t-1,o=(1<<n)-1,s=o>>1,a=n-7,c=i-1,h=e[c--],u=127&h;for(h>>=7;a>0;u=256*u+e[c],c--,a-=8);for(r=u&(1<<-a)-1,u>>=-a,a+=t;a>0;r=256*r+e[c],c--,a-=8);if(0===u)u=1-s;else{if(u===o)return r?NaN:h?-T:T;r+=E(2,t),u-=s}return(h?-1:1)*r*E(2,u-t)}function B(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]}function k(e){return[255&e]}function V(e){return[255&e,e>>8&255]}function N(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]}function z(e){return L(e,52,8)}function U(e){return L(e,23,4)}function G(e,t,i){m(e[v],t,{get:function(){return this[i]}})}function W(e,t,i,r){var n=d(+i);if(n+t>e[D])throw S(y);var o=e[I]._b,s=n+e[O],a=o.slice(s,s+t);return r?a:a.reverse()}function j(e,t,i,r,n,o){var s=d(+i);if(s+t>e[D])throw S(y);for(var a=e[I]._b,c=s+e[O],h=r(+n),u=0;u<t;u++)a[c+u]=h[o?u:t-u-1]}if(s.ABV){if(!h(function(){b(1)})||!h(function(){new b(-1)})||h(function(){return new b,new b(1.5),new b(NaN),"ArrayBuffer"!=b.name})){for(var H,X=(b=function(e){return u(this,b),new A(d(e))})[v]=A[v],Y=p(A),K=0;Y.length>K;)(H=Y[K++])in b||a(b,H,A[H]);o||(X.constructor=b)}var q=new x(new b(2)),Z=x[v].setInt8;q.setInt8(0,2147483648),q.setInt8(1,2147483649),!q.getInt8(0)&&q.getInt8(1)||c(x[v],{setInt8:function(e,t){Z.call(this,e,t<<24>>24)},setUint8:function(e,t){Z.call(this,e,t<<24>>24)}},!0)}else b=function(e){u(this,b,"ArrayBuffer");var t=d(e);this._b=g.call(new Array(t),0),this[D]=t},x=function(e,t,i){u(this,x,"DataView"),u(e,b,"DataView");var r=e[D],n=l(t);if(n<0||n>r)throw S("Wrong offset!");if(n+(i=void 0===i?r-n:f(i))>r)throw S("Wrong length!");this[I]=e,this[O]=n,this[D]=i},n&&(G(b,"byteLength","_l"),G(x,"buffer","_b"),G(x,"byteLength","_l"),G(x,"byteOffset","_o")),c(x[v],{getInt8:function(e){return W(this,1,e)[0]<<24>>24},getUint8:function(e){return W(this,1,e)[0]},getInt16:function(e){var t=W(this,2,e,arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=W(this,2,e,arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return B(W(this,4,e,arguments[1]))},getUint32:function(e){return B(W(this,4,e,arguments[1]))>>>0},getFloat32:function(e){return F(W(this,4,e,arguments[1]),23,4)},getFloat64:function(e){return F(W(this,8,e,arguments[1]),52,8)},setInt8:function(e,t){j(this,1,e,k,t)},setUint8:function(e,t){j(this,1,e,k,t)},setInt16:function(e,t){j(this,2,e,V,t,arguments[2])},setUint16:function(e,t){j(this,2,e,V,t,arguments[2])},setInt32:function(e,t){j(this,4,e,N,t,arguments[2])},setUint32:function(e,t){j(this,4,e,N,t,arguments[2])},setFloat32:function(e,t){j(this,4,e,U,t,arguments[2])},setFloat64:function(e,t){j(this,8,e,z,t,arguments[2])}});_(b,"ArrayBuffer"),_(x,"DataView"),a(x[v],s.VIEW,!0),t.ArrayBuffer=b,t.DataView=x},function(e,t,i){"use strict";(function(t,r,n){var o=i(86);function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,i){var r=e.entry;e.entry=null;for(;r;){var n=r.callback;t.pendingcb--,n(i),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=v;var a,c=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?r:o.nextTick;v.WritableState=_;var h=i(68);h.inherits=i(1);var u={deprecate:i(409)},l=i(170),f=i(2).Buffer,d=n.Uint8Array||function(){};var p,m=i(171);function g(){}function _(e,t){a=a||i(54),e=e||{};var r=t instanceof a;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,h=e.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(h||0===h)?h:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var i=e._writableState,r=i.sync,n=i.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(i),t)!function(e,t,i,r,n){--t.pendingcb,i?(o.nextTick(n,r),o.nextTick(T,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(n(r),e._writableState.errorEmitted=!0,e.emit("error",r),T(e,t))}(e,i,r,t,n);else{var s=w(i);s||i.corked||i.bufferProcessing||!i.bufferedRequest||x(e,i),r?c(b,e,i,s,n):b(e,i,s,n)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(e){if(a=a||i(54),!(p.call(v,this)||this instanceof a))return new v(e);this._writableState=new _(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),l.call(this)}function y(e,t,i,r,n,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,i?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function b(e,t,i,r){i||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),T(e,t)}function x(e,t){t.bufferProcessing=!0;var i=t.bufferedRequest;if(e._writev&&i&&i.next){var r=t.bufferedRequestCount,n=new Array(r),o=t.corkedRequestsFree;o.entry=i;for(var a=0,c=!0;i;)n[a]=i,i.isBuf||(c=!1),i=i.next,a+=1;n.allBuffers=c,y(e,t,!0,t.length,n,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;i;){var h=i.chunk,u=i.encoding,l=i.callback;if(y(e,t,!1,t.objectMode?1:h.length,h,u,l),i=i.next,t.bufferedRequestCount--,t.writing)break}null===i&&(t.lastBufferedRequest=null)}t.bufferedRequest=i,t.bufferProcessing=!1}function w(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function S(e,t){e._final(function(i){t.pendingcb--,i&&e.emit("error",i),t.prefinished=!0,e.emit("prefinish"),T(e,t)})}function T(e,t){var i=w(t);return i&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(S,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),i}h.inherits(v,l),_.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(_.prototype,"buffer",{get:u.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===v&&(e&&e._writableState instanceof _)}})):p=function(e){return e instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(e,t,i){var r,n=this._writableState,s=!1,a=!n.objectMode&&(r=e,f.isBuffer(r)||r instanceof d);return a&&!f.isBuffer(e)&&(e=function(e){return f.from(e)}(e)),"function"==typeof t&&(i=t,t=null),a?t="buffer":t||(t=n.defaultEncoding),"function"!=typeof i&&(i=g),n.ended?function(e,t){var i=new Error("write after end");e.emit("error",i),o.nextTick(t,i)}(this,i):(a||function(e,t,i,r){var n=!0,s=!1;return null===i?s=new TypeError("May not write null values to stream"):"string"==typeof i||void 0===i||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(r,s),n=!1),n}(this,n,e,i))&&(n.pendingcb++,s=function(e,t,i,r,n,o){if(!i){var s=function(e,t,i){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=f.from(t,i));return t}(t,r,n);r!==s&&(i=!0,n="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var h=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:n,isBuf:i,callback:o,next:null},h?h.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else y(e,t,!1,a,r,n,o);return c}(this,n,a,e,t,i)),s},v.prototype.cork=function(){this._writableState.corked++},v.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||x(this,e))},v.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(e,t,i){i(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(e,t,i){var r=this._writableState;"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(e,t,i){t.ending=!0,T(e,t),i&&(t.finished?o.nextTick(i):e.once("finish",i));t.ended=!0,e.writable=!1}(this,r,i)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),v.prototype.destroy=m.destroy,v.prototype._undestroy=m.undestroy,v.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,i(27),i(407).setImmediate,i(15))},function(e,t,i){"use strict";var r=i(2).Buffer,n=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=h,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=l,t=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,i=function(e,t,i){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==i?i:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var i=e.toString("utf16le",t);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function h(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,i)}return t}function u(e,t){var i=(e.length-t)%3;return 0===i?e.toString("base64",t):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-i))}function l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,i;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<e.length?t?t+this.text(e,i):this.text(e,i):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var i=function(e,t,i){var r=t.length-1;if(r<i)return 0;var n=s(t[r]);if(n>=0)return n>0&&(e.lastNeed=n-1),n;if(--r<i||-2===n)return 0;if((n=s(t[r]))>=0)return n>0&&(e.lastNeed=n-2),n;if(--r<i||-2===n)return 0;if((n=s(t[r]))>=0)return n>0&&(2===n?n=0:e.lastNeed=n-3),n;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=i;var r=e.length-(i-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,i){"use strict";(function(e,r){var n=i(125),o=i(484);e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:o([32,0]),UINT16:o([32,0]),UINT32:o([32,0]),INT8:o([32,0]),INT16:o([32,0]),INT32:o([32,0]),FLOAT:o([32,0]),DOUBLE:o([32,0]),DATA:o([32,0]),UINT8C:o([32,0]),BUFFER:o([32,0])});var s="undefined"!=typeof Uint8ClampedArray,a=e.__TYPEDARRAY_POOL;a.UINT8C||(a.UINT8C=o([32,0])),a.BUFFER||(a.BUFFER=o([32,0]));var c=a.DATA,h=a.BUFFER;function u(e){if(e){var t=e.length||e.byteLength,i=n.log2(t);c[i].push(e)}}function l(e){e=n.nextPow2(e);var t=n.log2(e),i=c[t];return i.length>0?i.pop():new ArrayBuffer(e)}function f(e){return new Uint8Array(l(e),0,e)}function d(e){return new Uint16Array(l(2*e),0,e)}function p(e){return new Uint32Array(l(4*e),0,e)}function m(e){return new Int8Array(l(e),0,e)}function g(e){return new Int16Array(l(2*e),0,e)}function _(e){return new Int32Array(l(4*e),0,e)}function v(e){return new Float32Array(l(4*e),0,e)}function y(e){return new Float64Array(l(8*e),0,e)}function b(e){return s?new Uint8ClampedArray(l(e),0,e):f(e)}function x(e){return new DataView(l(e),0,e)}function w(e){e=n.nextPow2(e);var t=n.log2(e),i=h[t];return i.length>0?i.pop():new r(e)}t.free=function(e){if(r.isBuffer(e))h[n.log2(e.length)].push(e);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(e)&&(e=e.buffer),!e)return;var t=e.length||e.byteLength,i=0|n.log2(t);c[i].push(e)}},t.freeUint8=t.freeUint16=t.freeUint32=t.freeInt8=t.freeInt16=t.freeInt32=t.freeFloat32=t.freeFloat=t.freeFloat64=t.freeDouble=t.freeUint8Clamped=t.freeDataView=function(e){u(e.buffer)},t.freeArrayBuffer=u,t.freeBuffer=function(e){h[n.log2(e.length)].push(e)},t.malloc=function(e,t){if(void 0===t||"arraybuffer"===t)return l(e);switch(t){case"uint8":return f(e);case"uint16":return d(e);case"uint32":return p(e);case"int8":return m(e);case"int16":return g(e);case"int32":return _(e);case"float":case"float32":return v(e);case"double":case"float64":return y(e);case"uint8_clamped":return b(e);case"buffer":return w(e);case"data":case"dataview":return x(e);default:return null}return null},t.mallocArrayBuffer=l,t.mallocUint8=f,t.mallocUint16=d,t.mallocUint32=p,t.mallocInt8=m,t.mallocInt16=g,t.mallocInt32=_,t.mallocFloat32=t.mallocFloat=v,t.mallocFloat64=t.mallocDouble=y,t.mallocUint8Clamped=b,t.mallocDataView=x,t.mallocBuffer=w,t.clearCache=function(){for(var e=0;e<32;++e)a.UINT8[e].length=0,a.UINT16[e].length=0,a.UINT32[e].length=0,a.INT8[e].length=0,a.INT16[e].length=0,a.INT32[e].length=0,a.FLOAT[e].length=0,a.DOUBLE[e].length=0,a.UINT8C[e].length=0,c[e].length=0,h[e].length=0}}).call(this,i(15),i(9).Buffer)},function(e,t,i){"use strict";function r(e){var t=32;return(e&=-e)&&t--,65535&e&&(t-=16),16711935&e&&(t-=8),252645135&e&&(t-=4),858993459&e&&(t-=2),1431655765&e&&(t-=1),t}t.INT_BITS=32,t.INT_MAX=2147483647,t.INT_MIN=-1<<31,t.sign=function(e){return(e>0)-(e<0)},t.abs=function(e){var t=e>>31;return(e^t)-t},t.min=function(e,t){return t^(e^t)&-(e<t)},t.max=function(e,t){return e^(e^t)&-(e<t)},t.isPow2=function(e){return!(e&e-1||!e)},t.log2=function(e){var t,i;return t=(e>65535)<<4,t|=i=((e>>>=t)>255)<<3,t|=i=((e>>>=i)>15)<<2,(t|=i=((e>>>=i)>3)<<1)|(e>>>=i)>>1},t.log10=function(e){return e>=1e9?9:e>=1e8?8:e>=1e7?7:e>=1e6?6:e>=1e5?5:e>=1e4?4:e>=1e3?3:e>=100?2:e>=10?1:0},t.popCount=function(e){return 16843009*((e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24},t.countTrailingZeros=r,t.nextPow2=function(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)+1},t.prevPow2=function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)-(e>>>1)},t.parity=function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,27030>>>(e&=15)&1};var n=new Array(256);!function(e){for(var t=0;t<256;++t){var i=t,r=t,n=7;for(i>>>=1;i;i>>>=1)r<<=1,r|=1&i,--n;e[t]=r<<n&255}}(n),t.reverse=function(e){return n[255&e]<<24|n[e>>>8&255]<<16|n[e>>>16&255]<<8|n[e>>>24&255]},t.interleave2=function(e,t){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))<<1},t.deinterleave2=function(e,t){return(e=65535&((e=16711935&((e=252645135&((e=858993459&((e=e>>>t&1431655765)|e>>>1))|e>>>2))|e>>>4))|e>>>16))<<16>>16},t.interleave3=function(e,t,i){return e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2),(e|=(t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2))<<1)|(i=1227133513&((i=3272356035&((i=251719695&((i=4278190335&((i&=1023)|i<<16))|i<<8))|i<<4))|i<<2))<<2},t.deinterleave3=function(e,t){return(e=1023&((e=4278190335&((e=251719695&((e=3272356035&((e=e>>>t&1227133513)|e>>>2))|e>>>4))|e>>>8))|e>>>16))<<22>>22},t.nextCombination=function(e){var t=e|e-1;return t+1|(~t&-~t)-1>>>r(e)+1}},function(e,t,i){"use strict";var r=i(1),n=i(196),o=i(2).Buffer,s=new Array(16);function a(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(e,t){return e<<t|e>>>32-t}function h(e,t,i,r,n,o,s){return c(e+(t&i|~t&r)+n+o|0,s)+t|0}function u(e,t,i,r,n,o,s){return c(e+(t&r|i&~r)+n+o|0,s)+t|0}function l(e,t,i,r,n,o,s){return c(e+(t^i^r)+n+o|0,s)+t|0}function f(e,t,i,r,n,o,s){return c(e+(i^(t|~r))+n+o|0,s)+t|0}r(a,n),a.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var i=this._a,r=this._b,n=this._c,o=this._d;i=h(i,r,n,o,e[0],3614090360,7),o=h(o,i,r,n,e[1],3905402710,12),n=h(n,o,i,r,e[2],606105819,17),r=h(r,n,o,i,e[3],3250441966,22),i=h(i,r,n,o,e[4],4118548399,7),o=h(o,i,r,n,e[5],1200080426,12),n=h(n,o,i,r,e[6],2821735955,17),r=h(r,n,o,i,e[7],4249261313,22),i=h(i,r,n,o,e[8],1770035416,7),o=h(o,i,r,n,e[9],2336552879,12),n=h(n,o,i,r,e[10],4294925233,17),r=h(r,n,o,i,e[11],2304563134,22),i=h(i,r,n,o,e[12],1804603682,7),o=h(o,i,r,n,e[13],4254626195,12),n=h(n,o,i,r,e[14],2792965006,17),i=u(i,r=h(r,n,o,i,e[15],1236535329,22),n,o,e[1],4129170786,5),o=u(o,i,r,n,e[6],3225465664,9),n=u(n,o,i,r,e[11],643717713,14),r=u(r,n,o,i,e[0],3921069994,20),i=u(i,r,n,o,e[5],3593408605,5),o=u(o,i,r,n,e[10],38016083,9),n=u(n,o,i,r,e[15],3634488961,14),r=u(r,n,o,i,e[4],3889429448,20),i=u(i,r,n,o,e[9],568446438,5),o=u(o,i,r,n,e[14],3275163606,9),n=u(n,o,i,r,e[3],4107603335,14),r=u(r,n,o,i,e[8],1163531501,20),i=u(i,r,n,o,e[13],2850285829,5),o=u(o,i,r,n,e[2],4243563512,9),n=u(n,o,i,r,e[7],1735328473,14),i=l(i,r=u(r,n,o,i,e[12],2368359562,20),n,o,e[5],4294588738,4),o=l(o,i,r,n,e[8],2272392833,11),n=l(n,o,i,r,e[11],1839030562,16),r=l(r,n,o,i,e[14],4259657740,23),i=l(i,r,n,o,e[1],2763975236,4),o=l(o,i,r,n,e[4],1272893353,11),n=l(n,o,i,r,e[7],4139469664,16),r=l(r,n,o,i,e[10],3200236656,23),i=l(i,r,n,o,e[13],681279174,4),o=l(o,i,r,n,e[0],3936430074,11),n=l(n,o,i,r,e[3],3572445317,16),r=l(r,n,o,i,e[6],76029189,23),i=l(i,r,n,o,e[9],3654602809,4),o=l(o,i,r,n,e[12],3873151461,11),n=l(n,o,i,r,e[15],530742520,16),i=f(i,r=l(r,n,o,i,e[2],3299628645,23),n,o,e[0],4096336452,6),o=f(o,i,r,n,e[7],1126891415,10),n=f(n,o,i,r,e[14],2878612391,15),r=f(r,n,o,i,e[5],4237533241,21),i=f(i,r,n,o,e[12],1700485571,6),o=f(o,i,r,n,e[3],2399980690,10),n=f(n,o,i,r,e[10],4293915773,15),r=f(r,n,o,i,e[1],2240044497,21),i=f(i,r,n,o,e[8],1873313359,6),o=f(o,i,r,n,e[15],4264355552,10),n=f(n,o,i,r,e[6],2734768916,15),r=f(r,n,o,i,e[13],1309151649,21),i=f(i,r,n,o,e[4],4149444226,6),o=f(o,i,r,n,e[11],3174756917,10),n=f(n,o,i,r,e[2],718787259,15),r=f(r,n,o,i,e[9],3951481745,21),this._a=this._a+i|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=a},function(e,t,i){e.exports=n;var r=i(41).EventEmitter;function n(){r.call(this)}i(1)(n,r),n.Readable=i(85),n.Writable=i(514),n.Duplex=i(515),n.Transform=i(516),n.PassThrough=i(517),n.Stream=n,n.prototype.pipe=function(e,t){var i=this;function n(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function o(){i.readable&&i.resume&&i.resume()}i.on("data",n),e.on("drain",o),e._isStdio||t&&!1===t.end||(i.on("end",a),i.on("close",c));var s=!1;function a(){s||(s=!0,e.end())}function c(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function h(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){i.removeListener("data",n),e.removeListener("drain",o),i.removeListener("end",a),i.removeListener("close",c),i.removeListener("error",h),e.removeListener("error",h),i.removeListener("end",u),i.removeListener("close",u),e.removeListener("close",u)}return i.on("error",h),e.on("error",h),i.on("end",u),i.on("close",u),e.on("close",u),e.emit("pipe",i),e}},function(e,t,i){"use strict";var r=i(9).Buffer,n=i(1),o=i(196),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],h=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],f=[1352829926,1548603684,1836072691,2053994217,0];function d(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function p(e,t){return e<<t|e>>>32-t}function m(e,t,i,r,n,o,s,a){return p(e+(t^i^r)+o+s|0,a)+n|0}function g(e,t,i,r,n,o,s,a){return p(e+(t&i|~t&r)+o+s|0,a)+n|0}function _(e,t,i,r,n,o,s,a){return p(e+((t|~i)^r)+o+s|0,a)+n|0}function v(e,t,i,r,n,o,s,a){return p(e+(t&r|i&~r)+o+s|0,a)+n|0}function y(e,t,i,r,n,o,s,a){return p(e+(t^(i|~r))+o+s|0,a)+n|0}n(d,o),d.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var i=0|this._a,r=0|this._b,n=0|this._c,o=0|this._d,d=0|this._e,b=0|this._a,x=0|this._b,w=0|this._c,S=0|this._d,T=0|this._e,A=0;A<80;A+=1){var M,E;A<16?(M=m(i,r,n,o,d,e[a[A]],l[0],h[A]),E=y(b,x,w,S,T,e[c[A]],f[0],u[A])):A<32?(M=g(i,r,n,o,d,e[a[A]],l[1],h[A]),E=v(b,x,w,S,T,e[c[A]],f[1],u[A])):A<48?(M=_(i,r,n,o,d,e[a[A]],l[2],h[A]),E=_(b,x,w,S,T,e[c[A]],f[2],u[A])):A<64?(M=v(i,r,n,o,d,e[a[A]],l[3],h[A]),E=g(b,x,w,S,T,e[c[A]],f[3],u[A])):(M=y(i,r,n,o,d,e[a[A]],l[4],h[A]),E=m(b,x,w,S,T,e[c[A]],f[4],u[A])),i=d,d=o,o=p(n,10),n=r,r=M,b=T,T=S,S=p(w,10),w=x,x=E}var P=this._b+n+S|0;this._b=this._c+o+T|0,this._c=this._d+d+b|0,this._d=this._e+i+x|0,this._e=this._a+r+w|0,this._a=P},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=r.alloc?r.alloc(20):new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=d},function(e,t,i){(t=e.exports=function(e){e=e.toLowerCase();var i=t[e];if(!i)throw new Error(e+" is not supported (we accept pull requests)");return new i}).sha=i(518),t.sha1=i(519),t.sha224=i(520),t.sha256=i(197),t.sha384=i(521),t.sha512=i(198)},function(e,t,i){"use strict";t.utils=i(527),t.Cipher=i(528),t.DES=i(529),t.CBC=i(530),t.EDE=i(531)},function(e,t,i){var r=i(532),n=i(540),o=i(208);t.createCipher=t.Cipher=r.createCipher,t.createCipheriv=t.Cipheriv=r.createCipheriv,t.createDecipher=t.Decipher=n.createDecipher,t.createDecipheriv=t.Decipheriv=n.createDecipheriv,t.listCiphers=t.getCiphers=function(){return Object.keys(o)}},function(e,t,i){var r={ECB:i(533),CBC:i(534),CFB:i(535),CFB8:i(536),CFB1:i(537),OFB:i(538),CTR:i(206),GCM:i(206)},n=i(208);for(var o in n)n[o].module=r[n[o].mode];e.exports=n},function(e,t,i){(function(t){var r=i(11),n=i(53);function o(e,i){var n=function(e){var t=s(e);return{blinder:t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(i),o=i.modulus.byteLength(),a=(r.mont(i.modulus),new r(e).mul(n.blinder).umod(i.modulus)),c=a.toRed(r.mont(i.prime1)),h=a.toRed(r.mont(i.prime2)),u=i.coefficient,l=i.prime1,f=i.prime2,d=c.redPow(i.exponent1),p=h.redPow(i.exponent2);d=d.fromRed(),p=p.fromRed();var m=d.isub(p).imul(u).umod(l);return m.imul(f),p.iadd(m),new t(p.imul(n.unblinder).umod(i.modulus).toArray(!1,o))}function s(e){for(var t=e.modulus.byteLength(),i=new r(n(t));i.cmp(e.modulus)>=0||!i.umod(e.prime1)||!i.umod(e.prime2);)i=new r(n(t));return i}e.exports=o,o.getr=s}).call(this,i(9).Buffer)},function(e,t,i){var r=t;r.utils=i(33),r.common=i(71),r.sha=i(556),r.ripemd=i(560),r.hmac=i(561),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},function(e,t,i){"use strict";i.r(t),t.default=function(){var e=new URL(document.location).searchParams;this.isSinglePlayer=!!e.get("singlePlayer"),this.isWebRTCSupported=!1;try{(new RTCPeerConnection).ondatachannel=function(e){},this.isWebRTCSupported=!0}catch(e){}this.isWebGLSupported=!1;var t=document.createElement("canvas"),i=t.getContext("webgl")||t.getContext("experimental-webgl");i&&i instanceof WebGLRenderingContext&&(this.isWebGLSupported=!0),this.isMobile=!1,new RegExp("Android|webOS|iPhone|iPad|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile","i").test(navigator.userAgent)&&(this.isMobile=!0)}},function(e,t,i){"use strict";(function(e){var r=i(93),n=i.n(r),o=i(55),s=i(18),a=i(7);function c(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function h(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var u=function(){function t(e){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.maxChangesPerSync=1e3,this.initializeState(e),this.maxPlayers=10,this.lastUpdate=0,this.changedBlocks=[];var r=this;this.changedBlockHandler={setBlock:function(e,t){var i={add:!1,p:e.slice(),bt:t};a.default.getInstance().addBlockChange(i),r.changedBlocks.push(i)},addBlock:function(e,t){var i={add:!0,p:e.slice(),bt:t};a.default.getInstance().addBlockChange(i),r.changedBlocks.push(i)}},setInterval(function(){i.update()},50)}var i,r,u;return i=t,(r=[{key:"update",value:function(){new Date,this.lastUpdate;this.broadcastPlayers()}},{key:"initializeState",value:function(e){var t={},i=new o.a({name:e.name,network:this,isClient:!1,peer:{send:function(){}}});t[e.name]=i,this.state={name:e.name,players:t,code:null,gameStarted:!1,game:e.game,seed:e.seed,chatLog:[],spawnPoint:null},this.hostPlayer=i}},{key:"setName",value:function(e){this.getPlayer().state.name=e,this.state.name=e}},{key:"getPlayer",value:function(){return this.hostPlayer}},{key:"copyPlayers",value:function(){return Object.assign({},this.state.players)}},{key:"playersToArray",value:function(){var e=[];for(var t in this.state.players)e.push({name:t,peer:this.state.players[t].peer,state:this.state.players[t].state});return e}},{key:"getSpawnedPlayerNames",value:function(){var e=[];for(var t in this.state.players)this.state.players[t].state.spawned&&e.push(this.state.players[t].state.name);return e}},{key:"kickPlayer",value:function(e){if(this.state.name===e)return"No kicking yourself";for(var t in this.state.players)if(this.state.players[t].state.name===e){var i={message:"kicking "+e,timestamp:+new Date,type:"message",from:this.state.name};return this.handleMessage(i),this.broadcastPlayer(t,{type:"kicked"}),this.state.players[t].peer.destroy(),"Kicking "+e}return"No such player"}},{key:"setSpawnToCurrentPosition",value:function(){return this.state.spawnPoint=this.hostPlayer.state.position,"Spawn point set to "+JSON.stringify(this.hostPlayer.state.position)}},{key:"getPositionFor",value:function(e){for(var t in this.state.players)if(this.state.players[t].state.name===e)return this.state.players[t].state.position;return null}},{key:"handleData",value:function(e,t){switch(t.type){case"connected":this.handleConnected(e);break;case"playerState":this.handlePlayerState(e,t.data.state);break;case"setBlockTypeAt":this.state.game.setBlock(t.data.blockTypeId,t.data.position);break;case"fireEvent":this.state.game.handleFireEvent(t.data),this.broadcastToOthers(e,{type:"fireEvent",data:t.data});break;case"message":this.handleMessage(t.message);break;case"requestChanges":var i=this.changedBlocks.slice(t.from,t.from+this.maxChangesPerSync);i.length&&this.broadcastPlayer(e,{type:"changedBlocks",blocks:i,from:t.from});break;default:throw Error("Unkown data type ",t.type)}}},{key:"broadcastPlayer",value:function(e,t){var i=this.state.players[e].peer;i.connected&&i.send(JSON.stringify(t))}},{key:"broadcast",value:function(e){for(var t in this.state.players)this.broadcastPlayer(t,e)}},{key:"broadcastToOthers",value:function(e,t){for(var i in this.state.players)e!==i&&this.broadcastPlayer(i,t)}},{key:"broadcastPlayers",value:function(){this.broadcast({type:"players",players:this.playersToArray().map(function(e){return{name:e.state.name,id:e.name,state:e.state}})})}},{key:"handleConnected",value:function(e){this.broadcastPlayers()}},{key:"getOpenGame",value:function(t){var i=this;return new e(function(e,r){s.a.getGame(t).then(function(t){i.gameCode=t.code,console.log("got code "+i.gameCode),e(i.gameCode)})})}},{key:"initNewGame",value:function(t){var i=this;return new e(function(e,r){i.getOpenGame(t).then(function(t){i.setState({code:t}),e(t),s.a.createSignalingChannel(t,"host").then(function(){s.a.listenForData(t,function(e){void 0!==e.payload.signal&&i.handlePlayerSignaling(e,t)})})})})}},{key:"handlePlayerSignaling",value:function(e,t){var i=this,r=e.from.split("/")[1];if(void 0===this.state.players[r]){var a=new n.a({initiator:!1});a.signal(e.payload.signal),a.on("signal",function(e){s.a.sendSignalingTo(t,r,"host",e)});var c=this.copyPlayers();c[r]=new o.a({name:r,peer:a}),this.setState({players:c},function(){i.broadcastPlayers()}),a.on("connect",function(){var e=i.playersToArray().length,t=e>i.maxPlayers;i.sendWelcomeInfo(a,t,e),t&&u(!1)}),a.on("data",function(e){i.handleData(r,JSON.parse(e))});var h=this,u=function(e){var t=Object.assign({},h.state.players);void 0!==t[r]&&(void 0!==t[r].noaPlayer&&t[r].noaPlayer.remove(),e&&t[r].state.spawned&&h.sendLeftMessage(t[r].state.name),delete t[r],h.setState({players:t}),a.destroy())};a.on("close",function(){u(!0)}),a.on("error",function(e){e.code})}}},{key:"sendWelcomeInfo",value:function(e,t,i){e.send(JSON.stringify({type:"welcomeInfo",hostName:this.hostPlayer.state.name,gameFull:t,playerCount:i,maxPlayers:this.maxPlayers,worldSeed:this.state.seed,worldSize:a.default.getInstance().getWorldSize(),spawnPoint:this.state.spawnPoint,numberOfChangedBlocks:this.changedBlocks.length}))}},{key:"setState",value:function(e,t){this.state=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},r=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),r.forEach(function(t){c(e,t,i[t])})}return e}({},this.state,e),t&&"function"==typeof t&&t()}},{key:"handlePlayerState",value:function(e,t){this.state.players[e].setState(t)}},{key:"emitFireEvent",value:function(e){this.broadcast({type:"fireEvent",data:e})}},{key:"sendJoinedMessage",value:function(e){var t={message:"",timestamp:+new Date,type:"joined",from:e};this.handleMessage(t)}},{key:"sendLeftMessage",value:function(e){var t={message:"",timestamp:+new Date,type:"left",from:e};this.handleMessage(t)}},{key:"sendMessage",value:function(e){var t={message:e,timestamp:+new Date,type:"message",from:this.state.name};this.handleMessage(t)}},{key:"handleMessage",value:function(e){this.state.chatLog.push(e),this.state.game.updateChatLog(this.state.chatLog.slice(-20)),this.broadcastToOthers(this.state.name,{type:"chatLog",chatLog:this.state.chatLog.slice(-20)})}},{key:"setChangedBlocks",value:function(e){this.changedBlocks=e.splice(0)}}])&&h(i.prototype,r),u&&h(i,u),t}();t.a=u}).call(this,i(52))},function(e,t,i){e.exports=!i(13)&&!i(3)(function(){return 7!=Object.defineProperty(i(95)("div"),"a",{get:function(){return 7}}).a})},function(e,t,i){var r=i(5),n=i(14),o=i(46),s=i(97),a=i(12).f;e.exports=function(e){var t=n.Symbol||(n.Symbol=o?{}:r.Symbol||{});"_"==e.charAt(0)||e in t||a(t,e,{value:s.f(e)})}},function(e,t,i){var r=i(22),n=i(24),o=i(74)(!1),s=i(98)("IE_PROTO");e.exports=function(e,t){var i,a=n(e),c=0,h=[];for(i in a)i!=s&&r(a,i)&&h.push(i);for(;t.length>c;)r(a,i=t[c++])&&(~o(h,i)||h.push(i));return h}},function(e,t,i){var r=i(12),n=i(4),o=i(47);e.exports=i(13)?Object.defineProperties:function(e,t){n(e);for(var i,s=o(t),a=s.length,c=0;a>c;)r.f(e,i=s[c++],t[i]);return e}},function(e,t,i){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=i(24),o=i(50).f,s={}.toString,a="object"==("undefined"==typeof window?"undefined":r(window))&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){return a&&"[object Window]"==s.call(e)?function(e){try{return o(e)}catch(e){return a.slice()}}(e):o(n(e))}},function(e,t,i){"use strict";var r=i(47),n=i(75),o=i(65),s=i(20),a=i(64),c=Object.assign;e.exports=!c||i(3)(function(){var e={},t={},i=Symbol(),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach(function(e){t[e]=e}),7!=c({},e)[i]||Object.keys(c({},t)).join("")!=r})?function(e,t){for(var i=s(e),c=arguments.length,h=1,u=n.f,l=o.f;c>h;)for(var f,d=a(arguments[h++]),p=u?r(d).concat(u(d)):r(d),m=p.length,g=0;m>g;)l.call(d,f=p[g++])&&(i[f]=d[f]);return i}:c},function(e,t){e.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}},function(e,t,i){"use strict";var r=i(35),n=i(6),o=i(145),s=[].slice,a={};e.exports=Function.bind||function(e){var t=r(this),i=s.call(arguments,1),c=function r(){var n=i.concat(s.call(arguments));return this instanceof r?function(e,t,i){if(!(t in a)){for(var r=[],n=0;n<t;n++)r[n]="a["+n+"]";a[t]=Function("F,a","return new F("+r.join(",")+")")}return a[t](e,i)}(t,n.length,n):o(t,n,e)};return n(t.prototype)&&(c.prototype=t.prototype),c}},function(e,t){e.exports=function(e,t,i){var r=void 0===i;switch(t.length){case 0:return r?e():e.call(i);case 1:return r?e(t[0]):e.call(i,t[0]);case 2:return r?e(t[0],t[1]):e.call(i,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(i,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(i,t[0],t[1],t[2],t[3])}return e.apply(i,t)}},function(e,t,i){var r=i(5).parseInt,n=i(76).trim,o=i(103),s=/^[-+]?0[xX]/;e.exports=8!==r(o+"08")||22!==r(o+"0x16")?function(e,t){var i=n(String(e),3);return r(i,t>>>0||(s.test(i)?16:10))}:r},function(e,t,i){var r=i(5).parseFloat,n=i(76).trim;e.exports=1/r(i(103)+"-0")!=-1/0?function(e){var t=n(String(e),3),i=r(t);return 0===i&&"-"==t.charAt(0)?-0:i}:r},function(e,t,i){var r=i(36);e.exports=function(e,t){if("number"!=typeof e&&"Number"!=r(e))throw TypeError(t);return+e}},function(e,t,i){var r=i(6),n=Math.floor;e.exports=function(e){return!r(e)&&isFinite(e)&&n(e)===e}},function(e,t){e.exports=Math.log1p||function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:Math.log(1+e)}},function(e,t,i){"use strict";var r=i(49),n=i(44),o=i(56),s={};i(23)(s,i(8)("iterator"),function(){return this}),e.exports=function(e,t,i){e.prototype=r(s,{next:n(1,i)}),o(e,t+" Iterator")}},function(e,t,i){var r=i(4);e.exports=function(e,t,i,n){try{return n?t(r(i)[0],i[1]):t(i)}catch(t){var o=e.return;throw void 0!==o&&r(o.call(e)),t}}},function(e,t,i){var r=i(35),n=i(20),o=i(64),s=i(10);e.exports=function(e,t,i,a,c){r(t);var h=n(e),u=o(h),l=s(h.length),f=c?l-1:0,d=c?-1:1;if(i<2)for(;;){if(f in u){a=u[f],f+=d;break}if(f+=d,c?f<0:l<=f)throw TypeError("Reduce of empty array with no initial value")}for(;c?f>=0:l>f;f+=d)f in u&&(a=t(a,u[f],f,h));return a}},function(e,t,i){"use strict";var r=i(20),n=i(48),o=i(10);e.exports=[].copyWithin||function(e,t){var i=r(this),s=o(i.length),a=n(e,s),c=n(t,s),h=arguments.length>2?arguments[2]:void 0,u=Math.min((void 0===h?s:n(h,s))-c,s-a),l=1;for(c<a&&a<c+u&&(l=-1,c+=u-1,a+=u-1);u-- >0;)c in i?i[a]=i[c]:delete i[a],a+=l,c+=l;return i}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,i){"use strict";var r=i(118);i(0)({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r})},function(e,t,i){i(13)&&"g"!=/./g.flags&&i(12).f(RegExp.prototype,"flags",{configurable:!0,get:i(78)})},function(e,t,i){"use strict";var r,n,o,s,a=i(46),c=i(5),h=i(34),u=i(66),l=i(0),f=i(6),d=i(35),p=i(60),m=i(81),g=i(67),_=i(120).set,v=i(342)(),y=i(159),b=i(343),x=i(82),w=i(160),S=c.TypeError,T=c.process,A=T&&T.versions,M=A&&A.v8||"",E=c.Promise,P="process"==u(T),C=function(){},R=n=y.f,I=!!function(){try{var e=E.resolve(1),t=(e.constructor={})[i(8)("species")]=function(e){e(C,C)};return(P||"function"==typeof PromiseRejectionEvent)&&e.then(C)instanceof t&&0!==M.indexOf("6.6")&&-1===x.indexOf("Chrome/66")}catch(e){}}(),D=function(e){var t;return!(!f(e)||"function"!=typeof(t=e.then))&&t},O=function(e,t){if(!e._n){e._n=!0;var i=e._c;v(function(){for(var r=e._v,n=1==e._s,o=0,s=function(t){var i,o,s,a=n?t.ok:t.fail,c=t.resolve,h=t.reject,u=t.domain;try{a?(n||(2==e._h&&B(e),e._h=1),!0===a?i=r:(u&&u.enter(),i=a(r),u&&(u.exit(),s=!0)),i===t.promise?h(S("Promise-chain cycle")):(o=D(i))?o.call(i,c,h):c(i)):h(r)}catch(e){u&&!s&&u.exit(),h(e)}};i.length>o;)s(i[o++]);e._c=[],e._n=!1,t&&!e._h&&L(e)})}},L=function(e){_.call(c,function(){var t,i,r,n=e._v,o=F(e);if(o&&(t=b(function(){P?T.emit("unhandledRejection",n,e):(i=c.onunhandledrejection)?i({promise:e,reason:n}):(r=c.console)&&r.error&&r.error("Unhandled promise rejection",n)}),e._h=P||F(e)?2:1),e._a=void 0,o&&t.e)throw t.v})},F=function(e){return 1!==e._h&&0===(e._a||e._c).length},B=function(e){_.call(c,function(){var t;P?T.emit("rejectionHandled",e):(t=c.onrejectionhandled)&&t({promise:e,reason:e._v})})},k=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),O(t,!0))},V=function e(t){var i,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw S("Promise can't be resolved itself");(i=D(t))?v(function(){var n={_w:r,_d:!1};try{i.call(t,h(e,n,1),h(k,n,1))}catch(e){k.call(n,e)}}):(r._v=t,r._s=1,O(r,!1))}catch(e){k.call({_w:r,_d:!1},e)}}};I||(E=function(e){p(this,E,"Promise","_h"),d(e),r.call(this);try{e(h(V,this,1),h(k,this,1))}catch(e){k.call(this,e)}},(r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=i(61)(E.prototype,{then:function(e,t){var i=R(g(this,E));return i.ok="function"!=typeof e||e,i.fail="function"==typeof t&&t,i.domain=P?T.domain:void 0,this._c.push(i),this._a&&this._a.push(i),this._s&&O(this,!1),i.promise},catch:function(e){return this.then(void 0,e)}}),o=function(){var e=new r;this.promise=e,this.resolve=h(V,e,1),this.reject=h(k,e,1)},y.f=R=function(e){return e===E||e===s?new o(e):n(e)}),l(l.G+l.W+l.F*!I,{Promise:E}),i(56)(E,"Promise"),i(59)("Promise"),s=i(14).Promise,l(l.S+l.F*!I,"Promise",{reject:function(e){var t=R(this);return(0,t.reject)(e),t.promise}}),l(l.S+l.F*(a||!I),"Promise",{resolve:function(e){return w(a&&this===s?E:this,e)}}),l(l.S+l.F*!(I&&i(77)(function(e){E.all(e).catch(C)})),"Promise",{all:function(e){var t=this,i=R(t),r=i.resolve,n=i.reject,o=b(function(){var i=[],o=0,s=1;m(e,!1,function(e){var a=o++,c=!1;i.push(void 0),s++,t.resolve(e).then(function(e){c||(c=!0,i[a]=e,--s||r(i))},n)}),--s||r(i)});return o.e&&n(o.v),i.promise},race:function(e){var t=this,i=R(t),r=i.reject,n=b(function(){m(e,!1,function(e){t.resolve(e).then(i.resolve,r)})});return n.e&&r(n.v),i.promise}})},function(e,t,i){"use strict";var r=i(35);function n(e){var t,i;this.promise=new e(function(e,r){if(void 0!==t||void 0!==i)throw TypeError("Bad Promise constructor");t=e,i=r}),this.resolve=r(t),this.reject=r(i)}e.exports.f=function(e){return new n(e)}},function(e,t,i){var r=i(4),n=i(6),o=i(159);e.exports=function(e,t){if(r(e),n(t)&&t.constructor===e)return t;var i=o.f(e);return(0,i.resolve)(t),i.promise}},function(e,t,i){"use strict";var r=i(12).f,n=i(49),o=i(61),s=i(34),a=i(60),c=i(81),h=i(109),u=i(155),l=i(59),f=i(13),d=i(40).fastKey,p=i(62),m=f?"_s":"size",g=function(e,t){var i,r=d(t);if("F"!==r)return e._i[r];for(i=e._f;i;i=i.n)if(i.k==t)return i};e.exports={getConstructor:function(e,t,i,h){var u=e(function(e,r){a(e,u,t,"_i"),e._t=t,e._i=n(null),e._f=void 0,e._l=void 0,e[m]=0,null!=r&&c(r,i,e[h],e)});return o(u.prototype,{clear:function(){for(var e=p(this,t),i=e._i,r=e._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete i[r.i];e._f=e._l=void 0,e[m]=0},delete:function(e){var i=p(this,t),r=g(i,e);if(r){var n=r.n,o=r.p;delete i._i[r.i],r.r=!0,o&&(o.n=n),n&&(n.p=o),i._f==r&&(i._f=n),i._l==r&&(i._l=o),i[m]--}return!!r},forEach:function(e){p(this,t);for(var i,r=s(e,arguments.length>1?arguments[1]:void 0,3);i=i?i.n:this._f;)for(r(i.v,i.k,this);i&&i.r;)i=i.p},has:function(e){return!!g(p(this,t),e)}}),f&&r(u.prototype,"size",{get:function(){return p(this,t)[m]}}),u},def:function(e,t,i){var r,n,o=g(e,t);return o?o.v=i:(e._l=o={i:n=d(t,!0),k:t,v:i,p:r=e._l,n:void 0,r:!1},e._f||(e._f=o),r&&(r.n=o),e[m]++,"F"!==n&&(e._i[n]=o)),e},getEntry:g,setStrong:function(e,t,i){h(e,t,function(e,i){this._t=p(e,t),this._k=i,this._l=void 0},function(){for(var e=this._k,t=this._l;t&&t.r;)t=t.p;return this._t&&(this._l=t=t?t.n:this._t._f)?u(0,"keys"==e?t.k:"values"==e?t.v:[t.k,t.v]):(this._t=void 0,u(1))},i?"entries":"values",!i,!0),l(t)}}},function(e,t,i){"use strict";var r=i(61),n=i(40).getWeak,o=i(4),s=i(6),a=i(60),c=i(81),h=i(31),u=i(22),l=i(62),f=h(5),d=h(6),p=0,m=function(e){return e._l||(e._l=new g)},g=function(){this.a=[]},_=function(e,t){return f(e.a,function(e){return e[0]===t})};g.prototype={get:function(e){var t=_(this,e);if(t)return t[1]},has:function(e){return!!_(this,e)},set:function(e,t){var i=_(this,e);i?i[1]=t:this.a.push([e,t])},delete:function(e){var t=d(this.a,function(t){return t[0]===e});return~t&&this.a.splice(t,1),!!~t}},e.exports={getConstructor:function(e,t,i,o){var h=e(function(e,r){a(e,h,t,"_i"),e._t=t,e._i=p++,e._l=void 0,null!=r&&c(r,i,e[o],e)});return r(h.prototype,{delete:function(e){if(!s(e))return!1;var i=n(e);return!0===i?m(l(this,t)).delete(e):i&&u(i,this._i)&&delete i[this._i]},has:function(e){if(!s(e))return!1;var i=n(e);return!0===i?m(l(this,t)).has(e):i&&u(i,this._i)}}),h},def:function(e,t,i){var r=n(o(t),!0);return!0===r?m(e).set(t,i):r[e._i]=i,e},ufstore:m}},function(e,t,i){var r=i(28),n=i(10);e.exports=function(e){if(void 0===e)return 0;var t=r(e),i=n(t);if(t!==i)throw RangeError("Wrong length!");return i}},function(e,t,i){var r=i(50),n=i(75),o=i(4),s=i(5).Reflect;e.exports=s&&s.ownKeys||function(e){var t=r.f(o(e)),i=n.f;return i?t.concat(i(e)):t}},function(e,t,i){var r=i(10),n=i(105),o=i(37);e.exports=function(e,t,i,s){var a=String(o(e)),c=a.length,h=void 0===i?" ":String(i),u=r(t);if(u<=c||""==h)return a;var l=u-c,f=n.call(h,Math.ceil(l/h.length));return f.length>l&&(f=f.slice(0,l)),s?f+a:a+f}},function(e,t,i){var r=i(47),n=i(24),o=i(65).f;e.exports=function(e){return function(t){for(var i,s=n(t),a=r(s),c=a.length,h=0,u=[];c>h;)o.call(s,i=a[h++])&&u.push(e?[i,s[i]]:s[i]);return u}}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){var i={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==i.call(e)}},function(e,t,i){"use strict";(function(t,r){var n=i(86);e.exports=y;var o,s=i(168);y.ReadableState=v;i(41).EventEmitter;var a=function(e,t){return e.listeners(t).length},c=i(170),h=i(2).Buffer,u=t.Uint8Array||function(){};var l=i(68);l.inherits=i(1);var f=i(404),d=void 0;d=f&&f.debuglog?f.debuglog("stream"):function(){};var p,m=i(405),g=i(171);l.inherits(y,c);var _=["error","close","destroy","pause","resume"];function v(e,t){e=e||{};var r=t instanceof(o=o||i(54));this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,s=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(p||(p=i(123).StringDecoder),this.decoder=new p(e.encoding),this.encoding=e.encoding)}function y(e){if(o=o||i(54),!(this instanceof y))return new y(e);this._readableState=new v(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),c.call(this)}function b(e,t,i,r,n){var o,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var i=t.decoder.end();i&&i.length&&(t.buffer.push(i),t.length+=t.objectMode?1:i.length)}t.ended=!0,T(e)}(e,s)):(n||(o=function(e,t){var i;r=t,h.isBuffer(r)||r instanceof u||"string"==typeof t||void 0===t||e.objectMode||(i=new TypeError("Invalid non-string/buffer chunk"));var r;return i}(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===h.prototype||(t=function(e){return h.from(e)}(t)),r?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):x(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!i?(t=s.decoder.write(t),s.objectMode||0!==t.length?x(e,s,t,!1):M(e,s)):x(e,s,t,!1))):r||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(s)}function x(e,t,i,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",i),e.read(0)):(t.length+=t.objectMode?1:i.length,r?t.buffer.unshift(i):t.buffer.push(i),t.needReadable&&T(e)),M(e,t)}Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),y.prototype.destroy=g.destroy,y.prototype._undestroy=g.undestroy,y.prototype._destroy=function(e,t){this.push(null),t(e)},y.prototype.push=function(e,t){var i,r=this._readableState;return r.objectMode?i=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=h.from(e,t),t=""),i=!0),b(this,e,t,!1,i)},y.prototype.unshift=function(e){return b(this,e,null,!0,!1)},y.prototype.isPaused=function(){return!1===this._readableState.flowing},y.prototype.setEncoding=function(e){return p||(p=i(123).StringDecoder),this._readableState.decoder=new p(e),this._readableState.encoding=e,this};var w=8388608;function S(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=w?e=w:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function T(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?n.nextTick(A,e):A(e))}function A(e){d("emit readable"),e.emit("readable"),R(e)}function M(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(E,e,t))}function E(e,t){for(var i=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(d("maybeReadMore read 0"),e.read(0),i!==t.length);)i=t.length;t.readingMore=!1}function P(e){d("readable nexttick read 0"),e.read(0)}function C(e,t){t.reading||(d("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),R(e),t.flowing&&!t.reading&&e.read(0)}function R(e){var t=e._readableState;for(d("flow",t.flowing);t.flowing&&null!==e.read(););}function I(e,t){return 0===t.length?null:(t.objectMode?i=t.buffer.shift():!e||e>=t.length?(i=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):i=function(e,t,i){var r;e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():i?function(e,t){var i=t.head,r=1,n=i.data;e-=n.length;for(;i=i.next;){var o=i.data,s=e>o.length?o.length:e;if(s===o.length?n+=o:n+=o.slice(0,e),0===(e-=s)){s===o.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=o.slice(s));break}++r}return t.length-=r,n}(e,t):function(e,t){var i=h.allocUnsafe(e),r=t.head,n=1;r.data.copy(i),e-=r.data.length;for(;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(i,i.length-e,0,s),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t);return r}(e,t.buffer,t.decoder),i);var i}function D(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,n.nextTick(O,t,e))}function O(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function L(e,t){for(var i=0,r=e.length;i<r;i++)if(e[i]===t)return i;return-1}y.prototype.read=function(e){d("read",e),e=parseInt(e,10);var t=this._readableState,i=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):T(this),null;if(0===(e=S(e,t))&&t.ended)return 0===t.length&&D(this),null;var r,n=t.needReadable;return d("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&d("length less than watermark",n=!0),t.ended||t.reading?d("reading or ended",n=!1):n&&(d("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=S(i,t))),null===(r=e>0?I(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),i!==e&&t.ended&&D(this)),null!==r&&this.emit("data",r),r},y.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(e,t){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?u:y;function h(t,r){d("onunpipe"),t===i&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",_),e.removeListener("finish",v),e.removeListener("drain",l),e.removeListener("error",g),e.removeListener("unpipe",h),i.removeListener("end",u),i.removeListener("end",y),i.removeListener("data",m),f=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function u(){d("onend"),e.end()}o.endEmitted?n.nextTick(c):i.once("end",c),e.on("unpipe",h);var l=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,R(e))}}(i);e.on("drain",l);var f=!1;var p=!1;function m(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==L(o.pipes,e))&&!f&&(d("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,p=!0),i.pause())}function g(t){d("onerror",t),y(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function _(){e.removeListener("finish",v),y()}function v(){d("onfinish"),e.removeListener("close",_),y()}function y(){d("unpipe"),i.unpipe(e)}return i.on("data",m),function(e,t,i){if("function"==typeof e.prependListener)return e.prependListener(t,i);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(i):e._events[t]=[i,e._events[t]]:e.on(t,i)}(e,"error",g),e.once("close",_),e.once("finish",v),e.emit("pipe",i),o.flowing||(d("pipe resume"),i.resume()),e},y.prototype.unpipe=function(e){var t=this._readableState,i={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,i),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)r[o].emit("unpipe",this,i);return this}var s=L(t.pipes,e);return-1===s?this:(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,i),this)},y.prototype.on=function(e,t){var i=c.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&T(this):n.nextTick(P,this))}return i},y.prototype.addListener=y.prototype.on,y.prototype.resume=function(){var e=this._readableState;return e.flowing||(d("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(C,e,t))}(this,e)),this},y.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this},y.prototype.wrap=function(e){var t=this,i=this._readableState,r=!1;for(var n in e.on("end",function(){if(d("wrapped end"),i.decoder&&!i.ended){var e=i.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){(d("wrapped data"),i.decoder&&(n=i.decoder.write(n)),i.objectMode&&null==n)||(i.objectMode||n&&n.length)&&(t.push(n)||(r=!0,e.pause()))}),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var o=0;o<_.length;o++)e.on(_[o],this.emit.bind(this,_[o]));return this._read=function(t){d("wrapped _read",t),r&&(r=!1,e.resume())},this},Object.defineProperty(y.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),y._fromList=I}).call(this,i(15),i(27))},function(e,t,i){e.exports=i(41).EventEmitter},function(e,t,i){"use strict";var r=i(86);function n(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var i=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||r.nextTick(n,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(r.nextTick(n,i,e),i._writableState&&(i._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,i){"use strict";e.exports=s;var r=i(54),n=i(68);function o(e,t){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));i.writechunk=null,i.writecb=null,null!=t&&this.push(t),r(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function s(e){if(!(this instanceof s))return new s(e);r.call(this,e),this._transformState={afterTransform:o.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",a)}function a(){var e=this;"function"==typeof this._flush?this._flush(function(t,i){c(e,t,i)}):c(this,null,null)}function c(e,t,i){if(t)return e.emit("error",t);if(null!=i&&e.push(i),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}n.inherits=i(1),n.inherits(s,r),s.prototype.push=function(e,t){return this._transformState.needTransform=!1,r.prototype.push.call(this,e,t)},s.prototype._transform=function(e,t,i){throw new Error("_transform() is not implemented")},s.prototype._write=function(e,t,i){var r=this._transformState;if(r.writecb=i,r.writechunk=e,r.writeencoding=t,!r.transforming){var n=this._readableState;(r.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},s.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},s.prototype._destroy=function(e,t){var i=this;r.prototype._destroy.call(this,e,function(e){t(e),i.emit("close")})}},function(e,t){e.exports=1e-6},function(e,t){e.exports=function(){var e=new Float32Array(3);return e[0]=0,e[1]=0,e[2]=0,e}},function(e,t){e.exports=function(e,t,i){var r=new Float32Array(3);return r[0]=e,r[1]=t,r[2]=i,r}},function(e,t){e.exports=function(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o);return e}},function(e,t){e.exports=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}},function(e,t){e.exports=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}},function(e,t){e.exports=function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}},function(e,t){e.exports=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e}},function(e,t){e.exports=function(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(i*i+r*r+n*n)}},function(e,t){e.exports=function(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}},function(e,t){e.exports=function(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}},function(e,t){e.exports=function(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}},function(e,t,i){"use strict";e.exports=function(e){for(var t=new Array(e),i=0;i<e;++i)t[i]=i;return t}},function(e,t,i){(function(e,r){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})(e)}var o=/%[sdj%]/g;t.format=function(e){if(!v(e)){for(var t=[],i=0;i<arguments.length;i++)t.push(c(arguments[i]));return t.join(" ")}i=1;for(var r=arguments,n=r.length,s=String(e).replace(o,function(e){if("%%"===e)return"%";if(i>=n)return e;switch(e){case"%s":return String(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(e){return"[Circular]"}default:return e}}),a=r[i];i<n;a=r[++i])g(a)||!x(a)?s+=" "+a:s+=" "+c(a);return s},t.deprecate=function(i,n){if(y(e.process))return function(){return t.deprecate(i,n).apply(this,arguments)};if(!0===r.noDeprecation)return i;var o=!1;return function(){if(!o){if(r.throwDeprecation)throw new Error(n);r.traceDeprecation?console.trace(n):console.error(n),o=!0}return i.apply(this,arguments)}};var s,a={};function c(e,i){var r={seen:[],stylize:u};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),m(i)?r.showHidden=i:i&&t._extend(r,i),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=h),l(r,e,r.depth)}function h(e,t){var i=c.styles[t];return i?"["+c.colors[i][0]+"m"+e+"["+c.colors[i][1]+"m":e}function u(e,t){return e}function l(e,i,r){if(e.customInspect&&i&&T(i.inspect)&&i.inspect!==t.inspect&&(!i.constructor||i.constructor.prototype!==i)){var n=i.inspect(r,e);return v(n)||(n=l(e,n,r)),n}var o=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(v(t)){var i="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(i,"string")}if(_(t))return e.stylize(""+t,"number");if(m(t))return e.stylize(""+t,"boolean");if(g(t))return e.stylize("null","null")}(e,i);if(o)return o;var s=Object.keys(i),a=function(e){var t={};return e.forEach(function(e,i){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(i)),S(i)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(i);if(0===s.length){if(T(i)){var c=i.name?": "+i.name:"";return e.stylize("[Function"+c+"]","special")}if(b(i))return e.stylize(RegExp.prototype.toString.call(i),"regexp");if(w(i))return e.stylize(Date.prototype.toString.call(i),"date");if(S(i))return f(i)}var h,u="",x=!1,A=["{","}"];(p(i)&&(x=!0,A=["[","]"]),T(i))&&(u=" [Function"+(i.name?": "+i.name:"")+"]");return b(i)&&(u=" "+RegExp.prototype.toString.call(i)),w(i)&&(u=" "+Date.prototype.toUTCString.call(i)),S(i)&&(u=" "+f(i)),0!==s.length||x&&0!=i.length?r<0?b(i)?e.stylize(RegExp.prototype.toString.call(i),"regexp"):e.stylize("[Object]","special"):(e.seen.push(i),h=x?function(e,t,i,r,n){for(var o=[],s=0,a=t.length;s<a;++s)P(t,String(s))?o.push(d(e,t,i,r,String(s),!0)):o.push("");return n.forEach(function(n){n.match(/^\d+$/)||o.push(d(e,t,i,r,n,!0))}),o}(e,i,r,a,s):s.map(function(t){return d(e,i,r,a,t,x)}),e.seen.pop(),function(e,t,i){if(e.reduce(function(e,t){return 0,t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return i[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+i[1];return i[0]+t+" "+e.join(", ")+" "+i[1]}(h,u,A)):A[0]+u+A[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,i,r,n,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),P(r,n)||(s="["+n+"]"),a||(e.seen.indexOf(c.value)<0?(a=g(i)?l(e,c.value,null):l(e,c.value,i-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),y(s)){if(o&&n.match(/^\d+$/))return a;(s=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function g(e){return null===e}function _(e){return"number"==typeof e}function v(e){return"string"==typeof e}function y(e){return void 0===e}function b(e){return x(e)&&"[object RegExp]"===A(e)}function x(e){return"object"===n(e)&&null!==e}function w(e){return x(e)&&"[object Date]"===A(e)}function S(e){return x(e)&&("[object Error]"===A(e)||e instanceof Error)}function T(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function M(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(y(s)&&(s=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(s)){var i=r.pid;a[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,i,r)}}else a[e]=function(){};return a[e]},t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=p,t.isBoolean=m,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=_,t.isString=v,t.isSymbol=function(e){return"symbol"===n(e)},t.isUndefined=y,t.isRegExp=b,t.isObject=x,t.isDate=w,t.isError=S,t.isFunction=T,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===n(e)||void 0===e},t.isBuffer=i(449);var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,i;console.log("%s - %s",(e=new Date,i=[M(e.getHours()),M(e.getMinutes()),M(e.getSeconds())].join(":"),[e.getDate(),E[e.getMonth()],i].join(" ")),t.format.apply(t,arguments))},t.inherits=i(1),t._extend=function(e,t){if(!t||!x(t))return e;for(var i=Object.keys(t),r=i.length;r--;)e[i[r]]=t[i[r]];return e}}).call(this,i(15),i(27))},function(e,t,i){"use strict";var r=[],n=[],o=[],s=[],a=[],c=[],h=[],u=[],l=[],f=[],d=[],p=[];e.exports=function(e,t,i,m,g,_){for(var v=h,y=l,b=f,x=p,w=0;w<3;w++)v[w]=+i[w],b[w]=+t.max[w],y[w]=+t.base[w];_||(_=1e-10);var S=function(e,t,i,h,l,f){var p=r,m=n,g=o,_=s,v=a,y=c,b=u,x=Math.floor,w=0,S=0,T=0,A=0,M=0;if(E(),0===T)return 0;for(A=R();S<=T;){if(P(A)&&C())return w;A=R()}for(w+=T,M=0;M<3;M++)h[M]+=i[M],l[M]+=i[M];return w;function E(){if(S=0,0!==(T=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2])))for(var e=0;e<3;e++){var t=i[e]>=0;_[e]=t?1:-1;var r=t?l[e]:h[e];p[e]=t?h[e]:l[e],m[e]=I(r,_[e]),g[e]=D(p[e],_[e]),b[e]=i[e]/T,v[e]=Math.abs(1/b[e]);var n=t?m[e]+1-r:r-m[e];y[e]=v[e]<1/0?v[e]*n:1/0}}function P(t){for(var i=_[0],r=0===t?m[0]:g[0],n=m[0]+i,o=_[1],s=1===t?m[1]:g[1],a=m[1]+o,c=_[2],h=2===t?m[2]:g[2],u=m[2]+c,l=r;l!=n;l+=i)for(var f=s;f!=a;f+=o)for(var d=h;d!=u;d+=c)if(e(l,f,d))return!0;return!1}function C(){w+=S;var e=_[A],r=S/T,n=d;for(M=0;M<3;M++){var o=i[M]*r;h[M]+=o,l[M]+=o,n[M]=i[M]-o}if(e>0?l[A]=Math.round(l[A]):h[A]=Math.round(h[A]),t(w,A,e,n))return!0;for(M=0;M<3;M++)i[M]=n[M];return E(),0===T}function R(){var e=y[0]<y[1]?y[0]<y[2]?0:2:y[1]<y[2]?1:2,t=y[e]-S;for(S=y[e],m[e]+=_[e],y[e]+=v[e],M=0;M<3;M++)p[M]+=t*b[M],g[M]=D(p[M],_[M]);return e}function I(e,t){return x(e-t*f)}function D(e,t){return x(e+t*f)}}(e,m,v,y,b,_);if(!g){for(w=0;w<3;w++)x[w]=i[w]>0?b[w]-t.max[w]:y[w]-t.base[w];t.translate(x)}return S}},function(e,t,i){"use strict";var r={};e.exports=r;var n=13,o=1<<n++,s=1<<n++,a=1<<n++;r.ID_MASK=511,r.VAR_MASK=7680,r.SOLID_BIT=o,r.OPAQUE_BIT=s,r.OBJECT_BIT=a},function(e,t,i){"use strict";e.exports=function(e){return function(e){var t=new Float32Array(256),i=new Float32Array(256),r=new Float32Array(256),n=new Float32Array(256),o=new Uint8ClampedArray(1024),s=new BABYLON.DynamicTexture("waterTexture",{width:16,height:16},e.rendering._scene);s.hasAlpha=!0,s.anisotropicFilteringLevel=1,s.updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE),s.wrapU=1,s.wrapV=1;var a=s.getContext(),c=new ImageData(o,16,16),h=0;e.on("tick",function(e){++h%2!=0&&u.redraw()});var u={texture:s,tick:function(){},redraw:function(){u.update(),a.clearRect(0,0,16,16),a.putImageData(c,0,0),s.update()},update:function(){for(var e=0;e<16;e++)for(var s=0;s<16;s++){for(var a=0,c=e-1;c<=e+1;c++){var h=15&c,u=15&s;a+=t[h+16*u]}i[e+16*s]=a/3.3+.8*r[e+16*s]}for(var e=0;e<16;e++)for(var s=0;s<16;s++)r[e+16*s]+=.05*n[e+16*s],r[e+16*s]<0&&(r[e+16*s]=0),n[e+16*s]-=.1,Math.random()<.05&&(n[e+16*s]=.5);var l=i;i=t,t=l;for(var f=0;f<256;f++){var a=t[f];a>1&&(a=1),a<0&&(a=0);var d=a*a,p=32+32*d,m=50+64*d,g=196+50*d;o[4*f+0]=p,o[4*f+1]=m,o[4*f+2]=255,o[4*f+3]=g}}};return e.waterTexture=s,u}(e)}},function(e,t,i){"use strict";var r,n="undefined"!=typeof window?window.navigator.userAgent:"",o=/OS X/.test(n),s=/Opera/.test(n),a=!/like Gecko/.test(n)&&!s,c=e.exports={0:o?"<menu>":"<UNK>",1:"<mouse 1>",2:"<mouse 2>",3:"<break>",4:"<mouse 3>",5:"<mouse 4>",6:"<mouse 5>",8:"<backspace>",9:"<tab>",12:"<clear>",13:"<enter>",16:"<shift>",17:"<control>",18:"<alt>",19:"<pause>",20:"<caps-lock>",21:"<ime-hangul>",23:"<ime-junja>",24:"<ime-final>",25:"<ime-kanji>",27:"<escape>",28:"<ime-convert>",29:"<ime-nonconvert>",30:"<ime-accept>",31:"<ime-mode-change>",32:"<space>",33:"<page-up>",34:"<page-down>",35:"<end>",36:"<home>",37:"<left>",38:"<up>",39:"<right>",40:"<down>",41:"<select>",42:"<print>",43:"<execute>",44:"<snapshot>",45:"<insert>",46:"<delete>",47:"<help>",91:"<meta>",92:"<meta>",93:o?"<meta>":"<menu>",95:"<sleep>",106:"<num-*>",107:"<num-+>",108:"<num-enter>",109:"<num--\x3e",110:"<num-.>",111:"<num-/>",144:"<num-lock>",145:"<scroll-lock>",160:"<shift-left>",161:"<shift-right>",162:"<control-left>",163:"<control-right>",164:"<alt-left>",165:"<alt-right>",166:"<browser-back>",167:"<browser-forward>",168:"<browser-refresh>",169:"<browser-stop>",170:"<browser-search>",171:"<browser-favorites>",172:"<browser-home>",173:o&&a?"-":"<volume-mute>",174:"<volume-down>",175:"<volume-up>",176:"<next-track>",177:"<prev-track>",178:"<stop>",179:"<play-pause>",180:"<launch-mail>",181:"<launch-media-select>",182:"<launch-app 1>",183:"<launch-app 2>",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",223:"<meta>",224:"<meta>",226:"<alt-gr>",229:"<ime-process>",231:s?"`":"<unicode>",246:"<attention>",247:"<crsel>",248:"<exsel>",249:"<erase-eof>",250:"<play>",251:"<zoom>",252:"<no-name>",253:"<pa-1>",254:"<clear>"};for(r=58;r<65;++r)c[r]=String.fromCharCode(r);for(r=48;r<58;++r)c[r]=r-48+"";for(r=65;r<91;++r)c[r]=String.fromCharCode(r);for(r=96;r<106;++r)c[r]="<num-"+(r-96)+">";for(r=112;r<136;++r)c[r]="F"+(r-111)},function(e,t,i){e.exports=n;var r=i(16);function n(e,t){if(!(this instanceof n))return new n(e,t);var i=r.create();r.add(i,e,t),this.base=r.min(r.create(),e,i),this.vec=r.clone(t),this.max=r.max(r.create(),e,i),this.mag=r.length(this.vec)}var o=n.prototype;o.width=function(){return this.vec[0]},o.height=function(){return this.vec[1]},o.depth=function(){return this.vec[2]},o.x0=function(){return this.base[0]},o.y0=function(){return this.base[1]},o.z0=function(){return this.base[2]},o.x1=function(){return this.max[0]},o.y1=function(){return this.max[1]},o.z1=function(){return this.max[2]},o.translate=function(e){return r.add(this.max,this.max,e),r.add(this.base,this.base,e),this},o.setPosition=function(e){return r.add(this.max,e,this.vec),r.copy(this.base,e),this},o.expand=function(e){var t=r.create(),i=r.create();return r.max(t,e.max,this.max),r.min(i,e.base,this.base),r.subtract(t,t,i),new n(i,t)},o.intersects=function(e){return!(e.base[0]>this.max[0])&&(!(e.base[1]>this.max[1])&&(!(e.base[2]>this.max[2])&&(!(e.max[0]<this.base[0])&&(!(e.max[1]<this.base[1])&&!(e.max[2]<this.base[2])))))},o.touches=function(e){var t=this.union(e);return null!==t&&(0==t.width()||0==t.height()||0==t.depth())},o.union=function(e){if(!this.intersects(e))return null;var t=Math.max(e.base[0],this.base[0]),i=Math.max(e.base[1],this.base[1]),r=Math.max(e.base[2],this.base[2]);return new n([t,i,r],[Math.min(e.max[0],this.max[0])-t,Math.min(e.max[1],this.max[1])-i,Math.min(e.max[2],this.max[2])-r])}},function(e,t,i){"use strict";e.exports={init:function(e){var t=n.nextPow2(e);a.length<t&&(r.free(a),a=r.mallocInt32(t));c.length<t&&(r.free(c),c=r.mallocInt32(t));h.length<t&&(r.free(h),h=r.mallocInt32(t));u.length<t&&(r.free(u),u=r.mallocInt32(t));l.length<t&&(r.free(l),l=r.mallocInt32(t));f.length<t&&(r.free(f),f=r.mallocInt32(t));var i=8*t;d.length<i&&(r.free(d),d=r.mallocDouble(i))},sweepBipartite:function(e,t,i,r,n,l,f,g,_,v){for(var y=0,b=2*e,x=e-1,w=b-1,S=i;S<r;++S){var T=l[S],A=b*S;d[y++]=n[A+x],d[y++]=-(T+1),d[y++]=n[A+w],d[y++]=T}for(var S=f;S<g;++S){var T=v[S]+s,M=b*S;d[y++]=_[M+x],d[y++]=-T,d[y++]=_[M+w],d[y++]=T}var E=y>>>1;o(d,E);for(var P=0,C=0,S=0;S<E;++S){var R=0|d[2*S+1];if(R>=s)p(h,u,C--,R=R-s|0);else if(R>=0)p(a,c,P--,R);else if(R<=-s){R=-R-s|0;for(var I=0;I<P;++I){var D=t(a[I],R);if(void 0!==D)return D}m(h,u,C++,R)}else{R=-R-1|0;for(var I=0;I<C;++I){var D=t(R,h[I]);if(void 0!==D)return D}m(a,c,P++,R)}}},sweepComplete:function(e,t,i,r,n,s,g,_,v,y){for(var b=0,x=2*e,w=e-1,S=x-1,T=i;T<r;++T){var A=s[T]+1<<1,M=x*T;d[b++]=n[M+w],d[b++]=-A,d[b++]=n[M+S],d[b++]=A}for(var T=g;T<_;++T){var A=y[T]+1<<1,E=x*T;d[b++]=v[E+w],d[b++]=1|-A,d[b++]=v[E+S],d[b++]=1|A}var P=b>>>1;o(d,P);for(var C=0,R=0,I=0,T=0;T<P;++T){var D=0|d[2*T+1],O=1&D;if(T<P-1&&D>>1==d[2*T+3]>>1&&(O=2,T+=1),D<0){for(var L=-(D>>1)-1,F=0;F<I;++F){var B=t(l[F],L);if(void 0!==B)return B}if(0!==O)for(var F=0;F<C;++F){var B=t(a[F],L);if(void 0!==B)return B}if(1!==O)for(var F=0;F<R;++F){var B=t(h[F],L);if(void 0!==B)return B}0===O?m(a,c,C++,L):1===O?m(h,u,R++,L):2===O&&m(l,f,I++,L)}else{var L=(D>>1)-1;0===O?p(a,c,C--,L):1===O?p(h,u,R--,L):2===O&&p(l,f,I--,L)}}},scanBipartite:function(e,t,i,r,n,h,u,l,f,g,_,v){var y=0,b=2*e,x=t,w=t+e,S=1,T=1;r?T=s:S=s;for(var A=n;A<h;++A){var M=A+S,E=b*A;d[y++]=u[E+x],d[y++]=-M,d[y++]=u[E+w],d[y++]=M}for(var A=f;A<g;++A){var M=A+T,P=b*A;d[y++]=_[P+x],d[y++]=-M}var C=y>>>1;o(d,C);for(var R=0,A=0;A<C;++A){var I=0|d[2*A+1];if(I<0){var M=-I,D=!1;if(M>=s?(D=!r,M-=s):(D=!!r,M-=1),D)m(a,c,R++,M);else{var O=v[M],L=b*M,F=_[L+t+1],B=_[L+t+1+e];e:for(var k=0;k<R;++k){var V=a[k],N=b*V;if(!(B<u[N+t+1]||u[N+t+1+e]<F)){for(var z=t+2;z<e;++z)if(_[L+z+e]<u[N+z]||u[N+z+e]<_[L+z])continue e;var U,G=l[V];if(void 0!==(U=r?i(O,G):i(G,O)))return U}}}}else p(a,c,R--,I-S)}},scanComplete:function(e,t,i,r,n,c,h,u,l,f,p){for(var m=0,g=2*e,_=t,v=t+e,y=r;y<n;++y){var b=y+s,x=g*y;d[m++]=c[x+_],d[m++]=-b,d[m++]=c[x+v],d[m++]=b}for(var y=u;y<l;++y){var b=y+1,w=g*y;d[m++]=f[w+_],d[m++]=-b}var S=m>>>1;o(d,S);for(var T=0,y=0;y<S;++y){var A=0|d[2*y+1];if(A<0){var b=-A;if(b>=s)a[T++]=b-s;else{var M=p[b-=1],E=g*b,P=f[E+t+1],C=f[E+t+1+e];e:for(var R=0;R<T;++R){var I=a[R],D=h[I];if(D===M)break;var O=g*I;if(!(C<c[O+t+1]||c[O+t+1+e]<P)){for(var L=t+2;L<e;++L)if(f[E+L+e]<c[O+L]||c[O+L+e]<f[E+L])continue e;var F=i(D,M);if(void 0!==F)return F}}}}else{for(var b=A-s,R=T-1;R>=0;--R)if(a[R]===b){for(var L=R+1;L<T;++L)a[L-1]=a[L];break}--T}}}};var r=i(124),n=i(125),o=i(485),s=1<<28,a=r.mallocInt32(1024),c=r.mallocInt32(1024),h=r.mallocInt32(1024),u=r.mallocInt32(1024),l=r.mallocInt32(1024),f=r.mallocInt32(1024),d=r.mallocDouble(8192);function p(e,t,i,r){var n=t[r],o=e[i-1];e[n]=o,t[o]=n}function m(e,t,i,r){e[i]=r,t[r]=i}},function(e,t,i){"use strict";e.exports=function(e,t){var i="abcdef".split("").concat(t),n=[];e.indexOf("lo")>=0&&n.push("lo=e[k+n]");e.indexOf("hi")>=0&&n.push("hi=e[k+o]");return i.push(r.replace("_",n.join()).replace("$",e)),Function.apply(void 0,i)};var r="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},function(module,exports,__webpack_require__){"use strict";function overlay(game){var scale=2,buttonscale=scale+1,patternScale=8,width=window.innerWidth,height=window.innerHeight,mouseOverButton=null,tickRate=500,lastTick=0,blinkCount=0,blinkCopy=!1,ypos=Math.floor(.5*height)-120*scale,center=Math.floor(.5*width),urlParams=new URLSearchParams(window.location.search),url=window.location.href.split("?")[0];if(urlParams.has("size")&&urlParams.delete("size"),urlParams.has("host")){var value=urlParams.get("host");urlParams.delete("host"),urlParams.append("join",value),url+="?"+urlParams.toString(),history.pushState&&window.history.pushState({path:url},"",url)}else url=window.location.href;var copyTextarea=document.querySelector(".js-copytextarea");copyTextarea.value=url;var allowedChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_'*!\\\"#%/()=+?[]{}<>@|$;",username="";game.settings&&""!=game.settings.username&&null!=game.settings.username&&(username=game.settings.username);var state=0,canvas=document.createElement("canvas");canvas.width=width,canvas.height=height;var context=canvas.getContext("2d");context.imageSmoothingEnabled=!1;var div=document.getElementById("overlay");div.appendChild(canvas),div.style.width=width+"px",div.style.height=height+"px";var patternSize=16*patternScale,patternCanvas=document.createElement("canvas");patternCanvas.width=patternSize,patternCanvas.height=patternSize;var patternContext=patternCanvas.getContext("2d");patternContext.imageSmoothingEnabled=!1;var loaded=0,totalLoad=3,checkLoading=function(){++loaded>=totalLoad&&(patternContext.drawImage(bg,0,0,patternSize,patternSize),patternContext.fillStyle="rgba(0,0,0,0.7)",patternContext.fillRect(0,0,patternSize,patternSize),pattern=context.createPattern(patternCanvas,"repeat"),obj.redraw())},bg=new Image;bg.onload=checkLoading,bg.src="assets/textures/dirt.png";var button=new Image;button.onload=checkLoading,button.src="assets/textures/button.png";var button_over=new Image;button_over.onload=checkLoading,button_over.src="assets/textures/button_over.png";var pattern=context.createPattern(patternCanvas,"repeat"),drawText=function(e,t,i,r){context.font=12*scale+"px Minecraft",context.textBaseline="alphabetic",context.textAlign="center";var n=2*scale;context.fillStyle="rgb(63,63,63)",context.fillText(e,t+n,i+n),context.fillStyle=r||"rgb(255,255,255)",context.fillText(e,t,i)},makeButton=function(e,t,i,r){return{str:e,x:t,y:i,over:!1,func:r,widthscale:1,key:null,draw:function(){this.widthscale<1&&(context.fillStyle="rgba(0,0,0,1)",context.fillRect(center-scale+this.x*scale-.5*button.width*buttonscale*this.widthscale,ypos+this.y*scale,2*scale+button.width*buttonscale*this.widthscale,button.height*buttonscale));var e=button;this.over&&(e=button_over),context.drawImage(e,center+this.x*scale-.5*button.width*buttonscale*this.widthscale,ypos+this.y*scale,button.width*buttonscale*this.widthscale,button.height*buttonscale);var t="rgb(255,255,255)";this.over&&(t="rgb(255,255,160)"),drawText(this.str,center+this.x*scale,ypos+this.y*scale+19*scale,t)}}};function submitUsername(){var e=username.trim();e!==game.hostInfo.hostName&&e.length>0&&(game.settings.username=e,game.emit("saveSettings"),game.setName(e),obj.hide())}function copyUrl(){var e=document.querySelector(".js-copytextarea");e.focus(),e.select(),blinkCopy=!0,obj.redraw(),setTimeout(function(){blinkCopy=!1,obj.redraw()},250);try{document.execCommand("copy")}catch(e){}}function newGame(){var e=window.location.href.split("?")[0];window.location.href=e}function takeOverHost(){var e=window.location.href.split("?")[0];window.location.href=e}function newGameWebrtc(){obj.show(0)}var startButtonHost=makeButton("Start",78,170,submitUsername);startButtonHost.widthscale=.5;var startButtonClient=makeButton("Start",0,130,submitUsername),copyButton=makeButton("Copy",0,80,copyUrl),copyButtonHidden=makeButton("Copy Hidden",0,40,copyUrl),newgameButton=makeButton("Launch a new game",0,130,newGame),newgameHostButton=makeButton("Relaunch the game as a host",0,120,takeOverHost),newgameButtonNoWebrtc=makeButton("Launch a new game",0,130,newGameWebrtc),array0=[startButtonHost,copyButton,copyButtonHidden],array1=[startButtonClient],array2=[newgameButton],array3=[newgameHostButton],array4=[newgameButton],array5=[newgameButton],array6=[newgameButtonNoWebrtc],activeArray=array1,obj={isOpen:!0,show:function show(openState){state=openState,1!=state||obj.isWebRTCSupported||(state=6),activeArray=eval("array"+state),document.addEventListener("keypress",obj.keypress,!1),document.addEventListener("keydown",obj.keydown,!1),div.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mousedown",this.press,!1),obj.isOpen=!0,obj.redraw(),div.style.display="block",document.exitPointerLock(),game.inputs&&(game.inputs.state.active=!1)},hide:function(){document.removeEventListener("keypress",obj.keypress),document.removeEventListener("keydown",obj.keydown),div.removeEventListener("mousemove",this.mousemove),document.removeEventListener("mousedown",this.press),obj.isOpen=!1,div.style.display="none";var e=document.getElementById("noa-container");setTimeout(function(){null!=e&&e.requestPointerLock()},200),game.inputs&&(game.inputs.state.active=!0)},mousemove:function(e){for(var t=e.layerX,i=e.layerY,r=null,n=0;n<activeArray.length;n++){var o=activeArray[n],s=center+o.x*scale-.5*button.width*buttonscale*o.widthscale,a=ypos+o.y*scale,c=s+button.width*buttonscale*o.widthscale,h=a+button.height*buttonscale;if(t>s&&t<c&&i>a&&i<h){r=n;break}}null!=r&&r!=mouseOverButton&&(activeArray[r].over=!0,obj.redraw()),null==r&&null!=mouseOverButton&&(activeArray[mouseOverButton].over=!1,obj.redraw()),mouseOverButton=r},press:function(e){if(null!=activeArray[mouseOverButton]){var t=activeArray[mouseOverButton].func;null!=t&&t()}},keydown:function(e){13!=e.keyCode?(8==e.keyCode&&username.length>0&&(username=username.substring(0,username.length-1)),obj.redraw()):submitUsername()},keypress:function(e){var t=e.key;allowedChars.indexOf(t)>=0&&username.length<32&&(username+=t),obj.redraw()},tick:function(){var e=performance.now();e<lastTick+tickRate||(blinkCount++,obj.redraw(),lastTick=e)},redraw:function(){context.clearRect(0,0,width,height),state<=1||3==state?(context.fillStyle="rgba(0,0,0,0.6)",context.fillRect(0,0,width,height)):(context.fillStyle=pattern,context.fillRect(0,0,width,height)),context.font=14*scale+"px Minecraft, sans-serif",context.textBaseline="alphabetic",context.textAlign="center",context.strokeStyle="rgba(255,255,255,1)",context.lineWidth=scale;var e=0;if(0==state){if(drawText("Game generated!",center,ypos-10*scale),obj.isWebRTCSupported){drawText("You are the host. You can invite some ("+(game.hostInfo.maxPlayers-1)+") friends to join you.",center,ypos+24*scale);var t=300*scale,i=30*scale;copyButtonHidden.draw(),context.fillStyle="rgba(0,0,0,1)",blinkCopy&&(context.fillStyle="rgba(127,127,127,1)"),context.fillRect(.5*width-.5*t,.5*height-80*scale,t,i),context.save(),context.rect(.5*width-.5*t,.5*height-80*scale,t,i),context.clip(),drawText(url,center,ypos+60*scale),context.restore(),context.strokeRect(.5*width-.5*t,.5*height-80*scale,t,i),copyButton.draw(),e=40*scale}else drawText("Your current browser does not have support for WebRTC.",center,ypos+24*scale),drawText("That means you can only play in single player mode.",center,ypos+41*scale),drawText("Please use another browser to play multiplayer,",center,ypos+58*scale),startButtonHost.y=130;drawText("Pick a username and start the game.",center,ypos+115*scale+e);t=150*scale,i=30*scale;var r=-78*scale;context.fillStyle="rgba(0,0,0,1)",context.fillRect(r+.5*width-.5*t,.5*height+10*scale+e,t,i),context.save(),context.rect(r+.5*width-.5*t,.5*height+10*scale+e,t,i),context.clip(),drawText(username,center+r,ypos+150*scale+e);var n=context.measureText(username).width;blinkCount%2==0&&(context.fillStyle="rgba(255,255,255,1)",context.fillRect(r+center+.5*n,ypos+135*scale+e,scale,20*scale)),context.restore(),context.strokeRect(.5*width-.5*t+r,.5*height+10*scale+e,t,i),startButtonHost.draw(),drawText("Left click to place or mine blocks (right click to toggle).",center,ypos+190*scale+e)}if(1==state){var o="Welcome!";"temp"!=game.hostInfo.hostName&&(o='Welcome to "'+game.hostInfo.hostName+'".'),drawText(o,center,ypos+0*scale),drawText(" You are player "+game.hostInfo.playerCount+" of "+game.hostInfo.maxPlayers+".",center,ypos+17*scale),drawText("Pick a username and start the game.",center,ypos+115*scale+(e=-40*scale));t=300*scale,i=30*scale;context.fillStyle="rgba(0,0,0,1)",context.fillRect(.5*width-.5*t,.5*height+10*scale+e,t,i),context.save(),context.rect(.5*width-.5*t,.5*height+10*scale+e,t,i),context.clip(),drawText(username,center,ypos+150*scale+e);n=context.measureText(username).width;blinkCount%2==0&&(context.fillStyle="rgba(255,255,255,1)",context.fillRect(center+.5*n,ypos+135*scale+e,scale,20*scale)),context.restore(),context.strokeRect(.5*width-.5*t,.5*height+10*scale+e,t,i),startButtonClient.draw(),drawText("Left click to place or mine blocks (right click to toggle).",center,ypos+240*scale+e)}2==state&&(drawText("The game you are trying to join is full.",center,ypos+88*scale),drawText("Come back later or host you own game.",center,ypos+105*scale),newgameButton.draw()),3==state&&(drawText("The End!",center,ypos+4*scale),drawText("The host left the game.",center,ypos+38*scale),drawText("If you launch a new game you will become the host and be able to",center,ypos+75*scale),drawText("invite friends. The new game will be based on this world.",center,ypos+92*scale),newgameHostButton.draw()),4==state&&(drawText("The game you are trying to join doesn't exist.",center,ypos+88*scale),drawText("You can still host a new game and invite your friends.",center,ypos+105*scale),newgameButton.draw()),5==state&&(drawText("You were kicked!",center,ypos+88*scale),drawText("You can host a new game and invite your own friends.",center,ypos+105*scale),newgameButton.draw()),6==state&&(drawText("Your current browser does not have support for WebRTC.",center,ypos+71*scale),drawText("If you want to join a game, please use another browser.",center,ypos+88*scale),drawText("Or you can launch a single player game.",center,ypos+105*scale),newgameButtonNoWebrtc.draw())},resize:function(){scale=2,window.innerHeight<600&&(scale=1),buttonscale=1.5*scale,width=window.innerWidth,height=window.innerHeight,center=Math.floor(.5*width),ypos=Math.floor(.5*height)-120*scale,canvas.width=width,canvas.height=height,div.style.width=width+"px",div.style.height=height+"px",context.imageSmoothingEnabled=!1,obj.redraw()},isWebRTCSupported:!1};try{var remoteConnection=new RTCPeerConnection;remoteConnection.ondatachannel=function(e){},obj.isWebRTCSupported=!0}catch(e){}return obj.hide(),obj}module.exports=function(e){return overlay(e)}},function(e,t,i){"use strict";e.exports=function(e){var t=e.rendering._scene,i=new BABYLON.StandardMaterial("head",t),r=new BABYLON.Texture("assets/textures/stevehead.png",t,!0,!1,BABYLON.Texture.NEAREST_SAMPLINGMODE);i.diffuseTexture=r,i.specularColor=new BABYLON.Color3(0,0,0);for(var n=new Array(6),o=0;o<6;o++)n[o]=new BABYLON.Vector4(o/8,0,(o+1)/8,1);var s={width:.45,height:.45,depth:.45,faceUV:n},a=BABYLON.MeshBuilder.CreateBox("head",s,t);a.material=i,a.rotate(BABYLON.Axis.Y,Math.PI,BABYLON.Space.WORLD);var c=new BABYLON.StandardMaterial("torso",t);r=new BABYLON.Texture("assets/textures/stevetorso.png",t,!0,!1,BABYLON.Texture.NEAREST_SAMPLINGMODE);c.diffuseTexture=r,c.specularColor=new BABYLON.Color3(0,0,0);for(n=new Array(6),o=0;o<6;o++)n[o]=new BABYLON.Vector4(o/8,0,(o+1)/8,1);s={width:.45,height:.675,depth:.225,faceUV:n};var h=BABYLON.MeshBuilder.CreateBox("torso",s,t);h.material=c;var u=new BABYLON.StandardMaterial("arm",t);r=new BABYLON.Texture("assets/textures/stevearm.png",t,!0,!1,BABYLON.Texture.NEAREST_SAMPLINGMODE);u.diffuseTexture=r,u.specularColor=new BABYLON.Color3(0,0,0);for(n=new Array(6),o=0;o<6;o++)n[o]=new BABYLON.Vector4(o/8,0,(o+1)/8,1);s={width:.225,height:.675,depth:.225,faceUV:n};var l=BABYLON.MeshBuilder.CreateBox("leftArm",s,t);l.material=u;var f=BABYLON.MeshBuilder.CreateBox("rightLeg",s,t);f.material=u;var d=new BABYLON.StandardMaterial("leg",t);r=new BABYLON.Texture("assets/textures/steveleg.png",t,!0,!1,BABYLON.Texture.NEAREST_SAMPLINGMODE);d.diffuseTexture=r,d.specularColor=new BABYLON.Color3(0,0,0);for(n=new Array(6),o=0;o<6;o++)n[o]=new BABYLON.Vector4(o/8,0,(o+1)/8,1);s={width:.225,height:.675,depth:.225,faceUV:n};var p=BABYLON.MeshBuilder.CreateBox("leftLeg",s,t);p.material=d;var m=BABYLON.MeshBuilder.CreateBox("rightLeg",s,t);m.material=d,l.setPivotPoint(new BABYLON.Vector3(0,.225,0)),f.setPivotPoint(new BABYLON.Vector3(0,.225,0)),p.setPivotPoint(new BABYLON.Vector3(0,.3375,0)),m.setPivotPoint(new BABYLON.Vector3(0,.3375,0)),a.parent=h,p.parent=h,m.parent=h,l.parent=h,f.parent=h,a.setPositionWithLocalVector(new BABYLON.Vector3(0,.5625,0)),p.setPositionWithLocalVector(new BABYLON.Vector3(.1125,-.3375,0)),m.setPositionWithLocalVector(new BABYLON.Vector3(-.1125,-.3375,0)),l.setPositionWithLocalVector(new BABYLON.Vector3(.3375,.225,0)),f.setPositionWithLocalVector(new BABYLON.Vector3(-.3375,.225,0));var g=0,_=0,v=0;return h.walking=!0,h.animate=function(e){var t=.01*(g+=e),i=5e-4*g,r=65e-5*g,n=1.2,o=1;this.walking||(n=0,o=0),_+=(n-_)/4,v+=(o-v)/4,p.rotation.x=Math.sin(t)*_,m.rotation.x=-Math.sin(t)*_,l.rotation.x=-Math.sin(t)*_,f.rotation.x=Math.sin(t)*_,l.rotation.z=Math.abs(Math.sin(i))*v,f.rotation.z=-Math.abs(Math.sin(r))*v},h}},function(e,t,i){"use strict";var r=i(2).Buffer,n=i(127).Transform;function o(e){n.call(this),this._block=r.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}i(1)(o,n),o.prototype._transform=function(e,t,i){var r=null;try{this.update(e,t)}catch(e){r=e}i(r)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!r.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");r.isBuffer(e)||(e=r.from(e,t));for(var i=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)i[o++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)i[this._blockOffset++]=e[n++];for(var s=0,a=8*e.length;a>0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=o},function(e,t,i){var r=i(1),n=i(63),o=i(2).Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function c(){this.init(),this._w=a,n.call(this,64,56)}function h(e,t,i){return i^e&(t^i)}function u(e,t,i){return e&t|i&(e|t)}function l(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function f(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}r(c,n),c.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},c.prototype._update=function(e){for(var t,i=this._w,r=0|this._a,n=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,p=0|this._f,m=0|this._g,g=0|this._h,_=0;_<16;++_)i[_]=e.readInt32BE(4*_);for(;_<64;++_)i[_]=0|(((t=i[_-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+i[_-7]+d(i[_-15])+i[_-16];for(var v=0;v<64;++v){var y=g+f(c)+h(c,p,m)+s[v]+i[v]|0,b=l(r)+u(r,n,o)|0;g=m,m=p,p=c,c=a+y|0,a=o,o=n,n=r,r=y+b|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0,this._f=p+this._f|0,this._g=m+this._g|0,this._h=g+this._h|0},c.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=c},function(e,t,i){var r=i(1),n=i(63),o=i(2).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function c(){this.init(),this._w=a,n.call(this,128,112)}function h(e,t,i){return i^e&(t^i)}function u(e,t,i){return e&t|i&(e|t)}function l(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function f(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function g(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function _(e,t){return e>>>0<t>>>0?1:0}r(c,n),c.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},c.prototype._update=function(e){for(var t=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,o=0|this._dh,a=0|this._eh,c=0|this._fh,v=0|this._gh,y=0|this._hh,b=0|this._al,x=0|this._bl,w=0|this._cl,S=0|this._dl,T=0|this._el,A=0|this._fl,M=0|this._gl,E=0|this._hl,P=0;P<32;P+=2)t[P]=e.readInt32BE(4*P),t[P+1]=e.readInt32BE(4*P+4);for(;P<160;P+=2){var C=t[P-30],R=t[P-30+1],I=d(C,R),D=p(R,C),O=m(C=t[P-4],R=t[P-4+1]),L=g(R,C),F=t[P-14],B=t[P-14+1],k=t[P-32],V=t[P-32+1],N=D+B|0,z=I+F+_(N,D)|0;z=(z=z+O+_(N=N+L|0,L)|0)+k+_(N=N+V|0,V)|0,t[P]=z,t[P+1]=N}for(var U=0;U<160;U+=2){z=t[U],N=t[U+1];var G=u(i,r,n),W=u(b,x,w),j=l(i,b),H=l(b,i),X=f(a,T),Y=f(T,a),K=s[U],q=s[U+1],Z=h(a,c,v),Q=h(T,A,M),J=E+Y|0,$=y+X+_(J,E)|0;$=($=($=$+Z+_(J=J+Q|0,Q)|0)+K+_(J=J+q|0,q)|0)+z+_(J=J+N|0,N)|0;var ee=H+W|0,te=j+G+_(ee,H)|0;y=v,E=M,v=c,M=A,c=a,A=T,a=o+$+_(T=S+J|0,S)|0,o=n,S=w,n=r,w=x,r=i,x=b,i=$+te+_(b=J+ee|0,J)|0}this._al=this._al+b|0,this._bl=this._bl+x|0,this._cl=this._cl+w|0,this._dl=this._dl+S|0,this._el=this._el+T|0,this._fl=this._fl+A|0,this._gl=this._gl+M|0,this._hl=this._hl+E|0,this._ah=this._ah+i+_(this._al,b)|0,this._bh=this._bh+r+_(this._bl,x)|0,this._ch=this._ch+n+_(this._cl,w)|0,this._dh=this._dh+o+_(this._dl,S)|0,this._eh=this._eh+a+_(this._el,T)|0,this._fh=this._fh+c+_(this._fl,A)|0,this._gh=this._gh+v+_(this._gl,M)|0,this._hh=this._hh+y+_(this._hl,E)|0},c.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,i,r){e.writeInt32BE(t,r),e.writeInt32BE(i,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=c},function(e,t,i){"use strict";var r=i(1),n=i(522),o=i(43),s=i(2).Buffer,a=i(200),c=i(128),h=i(129),u=s.alloc(128);function l(e,t){o.call(this,"digest"),"string"==typeof t&&(t=s.from(t));var i="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>i)?t=("rmd160"===e?new c:h(e)).update(t).digest():t.length<i&&(t=s.concat([t,u],i));for(var r=this._ipad=s.allocUnsafe(i),n=this._opad=s.allocUnsafe(i),a=0;a<i;a++)r[a]=54^t[a],n[a]=92^t[a];this._hash="rmd160"===e?new c:h(e),this._hash.update(r)}r(l,o),l.prototype._update=function(e){this._hash.update(e)},l.prototype._final=function(){var e=this._hash.digest();return("rmd160"===this._alg?new c:h(this._alg)).update(this._opad).update(e).digest()},e.exports=function(e,t){return"rmd160"===(e=e.toLowerCase())||"ripemd160"===e?new l("rmd160",t):"md5"===e?new n(a,t):new l(e,t)}},function(e,t,i){var r=i(126);e.exports=function(e){return(new r).update(e).digest()}},function(e){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},function(e,t,i){t.pbkdf2=i(524),t.pbkdf2Sync=i(205)},function(e,t,i){(function(t){var i=Math.pow(2,30)-1;function r(e,i){if("string"!=typeof e&&!t.isBuffer(e))throw new TypeError(i+" must be a buffer or string")}e.exports=function(e,t,n,o){if(r(e,"Password"),r(t,"Salt"),"number"!=typeof n)throw new TypeError("Iterations not a number");if(n<0)throw new TypeError("Bad iterations");if("number"!=typeof o)throw new TypeError("Key length not a number");if(o<0||o>i||o!=o)throw new TypeError("Bad key length")}}).call(this,i(9).Buffer)},function(e,t,i){(function(t){var i;t.browser?i="utf-8":i=parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";e.exports=i}).call(this,i(27))},function(e,t,i){var r=i(200),n=i(128),o=i(129),s=i(203),a=i(204),c=i(2).Buffer,h=c.alloc(128),u={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(e,t,i){var s=function(e){return"rmd160"===e||"ripemd160"===e?function(e){return(new n).update(e).digest()}:"md5"===e?r:function(t){return o(e).update(t).digest()}}(e),a="sha512"===e||"sha384"===e?128:64;t.length>a?t=s(t):t.length<a&&(t=c.concat([t,h],a));for(var l=c.allocUnsafe(a+u[e]),f=c.allocUnsafe(a+u[e]),d=0;d<a;d++)l[d]=54^t[d],f[d]=92^t[d];var p=c.allocUnsafe(a+i+4);l.copy(p,0,0,a),this.ipad1=p,this.ipad2=l,this.opad=f,this.alg=e,this.blocksize=a,this.hash=s,this.size=u[e]}l.prototype.run=function(e,t){return e.copy(t,this.blocksize),this.hash(t).copy(this.opad,this.blocksize),this.hash(this.opad)},e.exports=function(e,t,i,r,n){s(e,t,i,r),c.isBuffer(e)||(e=c.from(e,a)),c.isBuffer(t)||(t=c.from(t,a));var o=new l(n=n||"sha1",e,t.length),h=c.allocUnsafe(r),f=c.allocUnsafe(t.length+4);t.copy(f,0,0,t.length);for(var d=0,p=u[n],m=Math.ceil(r/p),g=1;g<=m;g++){f.writeUInt32BE(g,t.length);for(var _=o.run(f,o.ipad1),v=_,y=1;y<i;y++){v=o.run(v,o.ipad2);for(var b=0;b<p;b++)_[b]^=v[b]}_.copy(h,d),d+=p}return h}},function(e,t,i){var r=i(70),n=i(2).Buffer,o=i(207);function s(e){var t=e._cipher.encryptBlockRaw(e._prev);return o(e._prev),t}t.encrypt=function(e,t){var i=Math.ceil(t.length/16),o=e._cache.length;e._cache=n.concat([e._cache,n.allocUnsafe(16*i)]);for(var a=0;a<i;a++){var c=s(e),h=o+16*a;e._cache.writeUInt32BE(c[0],h+0),e._cache.writeUInt32BE(c[1],h+4),e._cache.writeUInt32BE(c[2],h+8),e._cache.writeUInt32BE(c[3],h+12)}var u=e._cache.slice(0,t.length);return e._cache=e._cache.slice(t.length),r(t,u)}},function(e,t){e.exports=function(e){for(var t,i=e.length;i--;){if(255!==(t=e.readUInt8(i))){t++,e.writeUInt8(t,i);break}e.writeUInt8(0,i)}}},function(e){e.exports={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128:{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192:{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256:{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}}},function(e,t,i){var r=i(89),n=i(2).Buffer,o=i(43),s=i(1),a=i(539),c=i(70),h=i(207);function u(e,t,i,s){o.call(this);var c=n.alloc(4,0);this._cipher=new r.AES(t);var u=this._cipher.encryptBlock(c);this._ghash=new a(u),i=function(e,t,i){if(12===t.length)return e._finID=n.concat([t,n.from([0,0,0,1])]),n.concat([t,n.from([0,0,0,2])]);var r=new a(i),o=t.length,s=o%16;r.update(t),s&&(s=16-s,r.update(n.alloc(s,0))),r.update(n.alloc(8,0));var c=8*o,u=n.alloc(8);u.writeUIntBE(c,0,8),r.update(u),e._finID=r.state;var l=n.from(e._finID);return h(l),l}(this,i,u),this._prev=n.from(i),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=s,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}s(u,o),u.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=n.alloc(t,0),this._ghash.update(t))}this._called=!0;var i=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(i),this._len+=e.length,i},u.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=c(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var i=0;e.length!==t.length&&i++;for(var r=Math.min(e.length,t.length),n=0;n<r;++n)i+=e[n]^t[n];return i}(e,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=e,this._cipher.scrub()},u.prototype.getAuthTag=function(){if(this._decrypt||!n.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},u.prototype.setAuthTag=function(e){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=e},u.prototype.setAAD=function(e){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(e),this._alen+=e.length},e.exports=u},function(e,t,i){var r=i(89),n=i(2).Buffer,o=i(43);function s(e,t,i,s){o.call(this),this._cipher=new r.AES(t),this._prev=n.from(i),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=s,this._mode=e}i(1)(s,o),s.prototype._update=function(e){return this._mode.encrypt(this,e,this._decrypt)},s.prototype._final=function(){this._cipher.scrub()},e.exports=s},function(e,t,i){var r=i(53);e.exports=v,v.simpleSieve=g,v.fermatTest=_;var n=i(11),o=new n(24),s=new(i(212)),a=new n(1),c=new n(2),h=new n(5),u=(new n(16),new n(8),new n(10)),l=new n(3),f=(new n(7),new n(11)),d=new n(4),p=(new n(12),null);function m(){if(null!==p)return p;var e=[];e[0]=2;for(var t=1,i=3;i<1048576;i+=2){for(var r=Math.ceil(Math.sqrt(i)),n=0;n<t&&e[n]<=r&&i%e[n]!=0;n++);t!==n&&e[n]<=r||(e[t++]=i)}return p=e,e}function g(e){for(var t=m(),i=0;i<t.length;i++)if(0===e.modn(t[i]))return 0===e.cmpn(t[i]);return!0}function _(e){var t=n.mont(e);return 0===c.toRed(t).redPow(e.subn(1)).fromRed().cmpn(1)}function v(e,t){if(e<16)return new n(2===t||5===t?[140,123]:[140,39]);var i,p;for(t=new n(t);;){for(i=new n(r(Math.ceil(e/8)));i.bitLength()>e;)i.ishrn(1);if(i.isEven()&&i.iadd(a),i.testn(1)||i.iadd(c),t.cmp(c)){if(!t.cmp(h))for(;i.mod(u).cmp(l);)i.iadd(d)}else for(;i.mod(o).cmp(f);)i.iadd(d);if(g(p=i.shrn(1))&&g(i)&&_(p)&&_(i)&&s.test(p)&&s.test(i))return i}}},function(e,t,i){var r=i(11),n=i(213);function o(e){this.rand=e||new n.Rand}e.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),i=Math.ceil(t/8);do{var n=new r(this.rand.generate(i))}while(n.cmp(e)>=0);return n},o.prototype._randrange=function(e,t){var i=t.sub(e);return e.add(this._randbelow(i))},o.prototype.test=function(e,t,i){var n=e.bitLength(),o=r.mont(e),s=new r(1).toRed(o);t||(t=Math.max(1,n/48|0));for(var a=e.subn(1),c=0;!a.testn(c);c++);for(var h=e.shrn(c),u=a.toRed(o);t>0;t--){var l=this._randrange(new r(2),a);i&&i(l);var f=l.toRed(o).redPow(h);if(0!==f.cmp(s)&&0!==f.cmp(u)){for(var d=1;d<c;d++){if(0===(f=f.redSqr()).cmp(s))return!1;if(0===f.cmp(u))break}if(d===c)return!1}}return!0},o.prototype.getDivisor=function(e,t){var i=e.bitLength(),n=r.mont(e),o=new r(1).toRed(n);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),a=0;!s.testn(a);a++);for(var c=e.shrn(a),h=s.toRed(n);t>0;t--){var u=this._randrange(new r(2),s),l=e.gcd(u);if(0!==l.cmpn(1))return l;var f=u.toRed(n).redPow(c);if(0!==f.cmp(o)&&0!==f.cmp(h)){for(var d=1;d<a;d++){if(0===(f=f.redSqr()).cmp(o))return f.fromRed().subn(1).gcd(e);if(0===f.cmp(h))break}if(d===a)return(f=f.redSqr()).fromRed().subn(1).gcd(e)}}return!1}},function(e,t,i){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n;function o(e){this.rand=e}if(e.exports=function(e){return n||(n=new o(null)),n.generate(e)},e.exports.Rand=o,o.prototype.generate=function(e){return this._rand(e)},o.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i<t.length;i++)t[i]=this.rand.getByte();return t},"object"===("undefined"==typeof self?"undefined":r(self)))self.crypto&&self.crypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"===("undefined"==typeof window?"undefined":r(window))&&(o.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var s=i(544);if("function"!=typeof s.randomBytes)throw new Error("Not supported");o.prototype._rand=function(e){return s.randomBytes(e)}}catch(e){}},function(e,t,i){"use strict";var r=t;function n(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",i=0;i<e.length;i++)t+=n(e[i].toString(16));return t}r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var i=[];if("string"!=typeof e){for(var r=0;r<e.length;r++)i[r]=0|e[r];return i}if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),r=0;r<e.length;r+=2)i.push(parseInt(e[r]+e[r+1],16));else for(r=0;r<e.length;r++){var n=e.charCodeAt(r),o=n>>8,s=255&n;o?i.push(o,s):i.push(s)}return i},r.zero2=n,r.toHex=o,r.encode=function(e,t){return"hex"===t?o(e):e}},function(e,t,i){"use strict";var r=i(33).rotr32;function n(e,t,i){return e&t^~e&i}function o(e,t,i){return e&t^e&i^t&i}function s(e,t,i){return e^t^i}t.ft_1=function(e,t,i,r){return 0===e?n(t,i,r):1===e||3===e?s(t,i,r):2===e?o(t,i,r):void 0},t.ch32=n,t.maj32=o,t.p32=s,t.s0_256=function(e){return r(e,2)^r(e,13)^r(e,22)},t.s1_256=function(e){return r(e,6)^r(e,11)^r(e,25)},t.g0_256=function(e){return r(e,7)^r(e,18)^e>>>3},t.g1_256=function(e){return r(e,17)^r(e,19)^e>>>10}},function(e,t,i){"use strict";var r=i(33),n=i(71),o=i(215),s=i(25),a=r.sum32,c=r.sum32_4,h=r.sum32_5,u=o.ch32,l=o.maj32,f=o.s0_256,d=o.s1_256,p=o.g0_256,m=o.g1_256,g=n.BlockHash,_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=_,this.W=new Array(64)}r.inherits(v,g),e.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(e,t){for(var i=this.W,r=0;r<16;r++)i[r]=e[t+r];for(;r<i.length;r++)i[r]=c(m(i[r-2]),i[r-7],p(i[r-15]),i[r-16]);var n=this.h[0],o=this.h[1],g=this.h[2],_=this.h[3],v=this.h[4],y=this.h[5],b=this.h[6],x=this.h[7];for(s(this.k.length===i.length),r=0;r<i.length;r++){var w=h(x,d(v),u(v,y,b),this.k[r],i[r]),S=a(f(n),l(n,o,g));x=b,b=y,y=v,v=a(_,w),_=g,g=o,o=n,n=a(w,S)}this.h[0]=a(this.h[0],n),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],g),this.h[3]=a(this.h[3],_),this.h[4]=a(this.h[4],v),this.h[5]=a(this.h[5],y),this.h[6]=a(this.h[6],b),this.h[7]=a(this.h[7],x)},v.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(e,t,i){"use strict";var r=i(33),n=i(71),o=i(25),s=r.rotr64_hi,a=r.rotr64_lo,c=r.shr64_hi,h=r.shr64_lo,u=r.sum64,l=r.sum64_hi,f=r.sum64_lo,d=r.sum64_4_hi,p=r.sum64_4_lo,m=r.sum64_5_hi,g=r.sum64_5_lo,_=n.BlockHash,v=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function y(){if(!(this instanceof y))return new y;_.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function b(e,t,i,r,n){var o=e&i^~e&n;return o<0&&(o+=4294967296),o}function x(e,t,i,r,n,o){var s=t&r^~t&o;return s<0&&(s+=4294967296),s}function w(e,t,i,r,n){var o=e&i^e&n^i&n;return o<0&&(o+=4294967296),o}function S(e,t,i,r,n,o){var s=t&r^t&o^r&o;return s<0&&(s+=4294967296),s}function T(e,t){var i=s(e,t,28)^s(t,e,2)^s(t,e,7);return i<0&&(i+=4294967296),i}function A(e,t){var i=a(e,t,28)^a(t,e,2)^a(t,e,7);return i<0&&(i+=4294967296),i}function M(e,t){var i=s(e,t,14)^s(e,t,18)^s(t,e,9);return i<0&&(i+=4294967296),i}function E(e,t){var i=a(e,t,14)^a(e,t,18)^a(t,e,9);return i<0&&(i+=4294967296),i}function P(e,t){var i=s(e,t,1)^s(e,t,8)^c(e,t,7);return i<0&&(i+=4294967296),i}function C(e,t){var i=a(e,t,1)^a(e,t,8)^h(e,t,7);return i<0&&(i+=4294967296),i}function R(e,t){var i=s(e,t,19)^s(t,e,29)^c(e,t,6);return i<0&&(i+=4294967296),i}function I(e,t){var i=a(e,t,19)^a(t,e,29)^h(e,t,6);return i<0&&(i+=4294967296),i}r.inherits(y,_),e.exports=y,y.blockSize=1024,y.outSize=512,y.hmacStrength=192,y.padLength=128,y.prototype._prepareBlock=function(e,t){for(var i=this.W,r=0;r<32;r++)i[r]=e[t+r];for(;r<i.length;r+=2){var n=R(i[r-4],i[r-3]),o=I(i[r-4],i[r-3]),s=i[r-14],a=i[r-13],c=P(i[r-30],i[r-29]),h=C(i[r-30],i[r-29]),u=i[r-32],l=i[r-31];i[r]=d(n,o,s,a,c,h,u,l),i[r+1]=p(n,o,s,a,c,h,u,l)}},y.prototype._update=function(e,t){this._prepareBlock(e,t);var i=this.W,r=this.h[0],n=this.h[1],s=this.h[2],a=this.h[3],c=this.h[4],h=this.h[5],d=this.h[6],p=this.h[7],_=this.h[8],v=this.h[9],y=this.h[10],P=this.h[11],C=this.h[12],R=this.h[13],I=this.h[14],D=this.h[15];o(this.k.length===i.length);for(var O=0;O<i.length;O+=2){var L=I,F=D,B=M(_,v),k=E(_,v),V=b(_,v,y,P,C),N=x(_,v,y,P,C,R),z=this.k[O],U=this.k[O+1],G=i[O],W=i[O+1],j=m(L,F,B,k,V,N,z,U,G,W),H=g(L,F,B,k,V,N,z,U,G,W);L=T(r,n),F=A(r,n),B=w(r,n,s,a,c),k=S(r,n,s,a,c,h);var X=l(L,F,B,k),Y=f(L,F,B,k);I=C,D=R,C=y,R=P,y=_,P=v,_=l(d,p,j,H),v=f(p,p,j,H),d=c,p=h,c=s,h=a,s=r,a=n,r=l(j,H,X,Y),n=f(j,H,X,Y)}u(this.h,0,r,n),u(this.h,2,s,a),u(this.h,4,c,h),u(this.h,6,d,p),u(this.h,8,_,v),u(this.h,10,y,P),u(this.h,12,C,R),u(this.h,14,I,D)},y.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(e,t,i){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=i(1),o=i(73).Reporter,s=i(9).Buffer;function a(e,t){o.call(this,t),s.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function c(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof c||(e=new c(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=s.byteLength(e);else{if(!s.isBuffer(e))return t.error("Unsupported type: "+r(e));this.value=e,this.length=e.length}}n(a,o),t.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:o.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,o.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var i=new a(this.base);return i._reporterState=this._reporterState,i.offset=this.offset,i.length=this.offset+e,this.offset+=e,i},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.EncoderBuffer=c,c.prototype.join=function(e,t){return e||(e=new s(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(i){i.join(e,t),t+=i.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):s.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},function(e,t,i){var r=t;r._reverse=function(e){var t={};return Object.keys(e).forEach(function(i){(0|i)==i&&(i|=0);var r=e[i];t[r]=i}),t},r.der=i(576)},function(e,t,i){var r=i(1),n=i(72),o=n.base,s=n.bignum,a=n.constants.der;function c(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new h,this.tree._init(e.body)}function h(e){o.Node.call(this,"der",e)}function u(e,t){var i=e.readUInt8(t);if(e.isError(i))return i;var r=a.tagClass[i>>6],n=0==(32&i);if(31==(31&i)){var o=i;for(i=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;i<<=7,i|=127&o}}else i&=31;return{cls:r,primitive:n,tag:i,tagStr:a.tag[i]}}function l(e,t,i){var r=e.readUInt8(i);if(e.isError(r))return r;if(!t&&128===r)return null;if(0==(128&r))return r;var n=127&r;if(n>4)return e.error("length octect is too long");r=0;for(var o=0;o<n;o++){r<<=8;var s=e.readUInt8(i);if(e.isError(s))return s;r|=s}return r}e.exports=c,c.prototype.decode=function(e,t){return e instanceof o.DecoderBuffer||(e=new o.DecoderBuffer(e,t)),this.tree._decode(e,t)},r(h,o.Node),h.prototype._peekTag=function(e,t,i){if(e.isEmpty())return!1;var r=e.save(),n=u(e,'Failed to peek tag: "'+t+'"');return e.isError(n)?n:(e.restore(r),n.tag===t||n.tagStr===t||n.tagStr+"of"===t||i)},h.prototype._decodeTag=function(e,t,i){var r=u(e,'Failed to decode tag of "'+t+'"');if(e.isError(r))return r;var n=l(e,r.primitive,'Failed to get length of "'+t+'"');if(e.isError(n))return n;if(!i&&r.tag!==t&&r.tagStr!==t&&r.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(r.primitive||null!==n)return e.skip(n,'Failed to match body of: "'+t+'"');var o=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(n=e.offset-o.offset,e.restore(o),e.skip(n,'Failed to match body of: "'+t+'"'))},h.prototype._skipUntilEnd=function(e,t){for(;;){var i=u(e,t);if(e.isError(i))return i;var r,n=l(e,i.primitive,t);if(e.isError(n))return n;if(r=i.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(r))return r;if("end"===i.tagStr)break}},h.prototype._decodeList=function(e,t,i,r){for(var n=[];!e.isEmpty();){var o=this._peekTag(e,"end");if(e.isError(o))return o;var s=i.decode(e,"der",r);if(e.isError(s)&&o)break;n.push(s)}return n},h.prototype._decodeStr=function(e,t){if("bitstr"===t){var i=e.readUInt8();return e.isError(i)?i:{unused:i,data:e.raw()}}if("bmpstr"===t){var r=e.raw();if(r.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var n="",o=0;o<r.length/2;o++)n+=String.fromCharCode(r.readUInt16BE(2*o));return n}if("numstr"===t){var s=e.raw().toString("ascii");return this._isNumstr(s)?s:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var a=e.raw().toString("ascii");return this._isPrintstr(a)?a:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},h.prototype._decodeObjid=function(e,t,i){for(var r,n=[],o=0;!e.isEmpty();){var s=e.readUInt8();o<<=7,o|=127&s,0==(128&s)&&(n.push(o),o=0)}128&s&&n.push(o);var a=n[0]/40|0,c=n[0]%40;if(r=i?n:[a,c].concat(n.slice(1)),t){var h=t[r.join(" ")];void 0===h&&(h=t[r.join(".")]),void 0!==h&&(r=h)}return r},h.prototype._decodeTime=function(e,t){var i=e.raw().toString();if("gentime"===t)var r=0|i.slice(0,4),n=0|i.slice(4,6),o=0|i.slice(6,8),s=0|i.slice(8,10),a=0|i.slice(10,12),c=0|i.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");r=0|i.slice(0,2),n=0|i.slice(2,4),o=0|i.slice(4,6),s=0|i.slice(6,8),a=0|i.slice(8,10),c=0|i.slice(10,12);r=r<70?2e3+r:1900+r}return Date.UTC(r,n-1,o,s,a,c,0)},h.prototype._decodeNull=function(e){return null},h.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},h.prototype._decodeInt=function(e,t){var i=e.raw(),r=new s(i);return t&&(r=t[r.toString(10)]||r),r},h.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},function(e,t,i){var r=i(1),n=i(9).Buffer,o=i(72),s=o.base,a=o.constants.der;function c(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new h,this.tree._init(e.body)}function h(e){s.Node.call(this,"der",e)}function u(e){return e<10?"0"+e:e}e.exports=c,c.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},r(h,s.Node),h.prototype._encodeComposite=function(e,t,i,r){var o,s=function(e,t,i,r){var n;"seqof"===e?e="seq":"setof"===e&&(e="set");if(a.tagByName.hasOwnProperty(e))n=a.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return r.error("Unknown tag: "+e);n=e}if(n>=31)return r.error("Multi-octet tag encoding unsupported");t||(n|=32);return n|=a.tagClassByName[i||"universal"]<<6}(e,t,i,this.reporter);if(r.length<128)return(o=new n(2))[0]=s,o[1]=r.length,this._createEncoderBuffer([o,r]);for(var c=1,h=r.length;h>=256;h>>=8)c++;(o=new n(2+c))[0]=s,o[1]=128|c;h=1+c;for(var u=r.length;u>0;h--,u>>=8)o[h]=255&u;return this._createEncoderBuffer([o,r])},h.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var i=new n(2*e.length),r=0;r<e.length;r++)i.writeUInt16BE(e.charCodeAt(r),2*r);return this._createEncoderBuffer(i)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)?this._createEncoderBuffer(e):"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},h.prototype._encodeObjid=function(e,t,i){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var r=0;r<e.length;r++)e[r]|=0}else if(Array.isArray(e)){e=e.slice();for(r=0;r<e.length;r++)e[r]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!i){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(r=0;r<e.length;r++){var s=e[r];for(o++;s>=128;s>>=7)o++}var a=new n(o),c=a.length-1;for(r=e.length-1;r>=0;r--){s=e[r];for(a[c--]=127&s;(s>>=7)>0;)a[c--]=128|127&s}return this._createEncoderBuffer(a)},h.prototype._encodeTime=function(e,t){var i,r=new Date(e);return"gentime"===t?i=[u(r.getFullYear()),u(r.getUTCMonth()+1),u(r.getUTCDate()),u(r.getUTCHours()),u(r.getUTCMinutes()),u(r.getUTCSeconds()),"Z"].join(""):"utctime"===t?i=[u(r.getFullYear()%100),u(r.getUTCMonth()+1),u(r.getUTCDate()),u(r.getUTCHours()),u(r.getUTCMinutes()),u(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(i,"octstr")},h.prototype._encodeNull=function(){return this._createEncoderBuffer("")},h.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!n.isBuffer(e)){var i=e.toArray();!e.sign&&128&i[0]&&i.unshift(0),e=new n(i)}if(n.isBuffer(e)){var r=e.length;0===e.length&&r++;var o=new n(r);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);r=1;for(var s=e;s>=256;s>>=8)r++;for(s=(o=new Array(r)).length-1;s>=0;s--)o[s]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new n(o))},h.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},h.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},h.prototype._skipDefault=function(e,t,i){var r,n=this._baseState;if(null===n.default)return!1;var o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,i).join()),o.length!==n.defaultBuffer.length)return!1;for(r=0;r<o.length;r++)if(o[r]!==n.defaultBuffer[r])return!1;return!0}},function(e){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},function(e,t,i){var r=i(69),n=i(2).Buffer;function o(e){var t=n.allocUnsafe(4);return t.writeUInt32BE(e,0),t}e.exports=function(e,t){for(var i,s=n.alloc(0),a=0;s.length<t;)i=o(a++),s=n.concat([s,r("sha1").update(e).update(i).digest()]);return s.slice(0,t)}},function(e,t){e.exports=function(e,t){for(var i=e.length,r=-1;++r<i;)e[r]^=t[r];return e}},function(e,t,i){var r=i(11),n=i(2).Buffer;e.exports=function(e,t){return n.from(e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed().toArray())}},function(e,t,i){"use strict";(function(e){var r=i(93),n=i.n(r),o=i(55),s=i(18),a=i(7),c=i(227);function h(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function u(e){return function(e){if(Array.isArray(e)){for(var t=0,i=new Array(e.length);t<e.length;t++)i[t]=e[t];return i}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function l(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.initializeState(e),this.welcomeInfoResolve=null,this.peer=null}var i,r,f;return i=t,(r=[{key:"initializeState",value:function(e){this.state={code:e.code,name:e.name,connected:!1,connecting:!1,gameStarted:!1,error:"",host:null,players:[],game:e.game,changedBlocks:[],enqueuedChangedBlocks:[],chatLog:[]}}},{key:"handleData",value:function(e){switch(e.type){case"startGame":this.setState({gameStarted:!0});break;case"players":this.handlePlayers(e.players);break;case"changedBlocks":this.handleChangedBlocks(e);break;case"fireEvent":this.state.game.handleFireEvent(e.data);break;case"chatLog":this.handleChatLog(e.chatLog);break;case"welcomeInfo":this.handleWelcomeInfo(e);break;case"kicked":this.handleOnKicked();break;default:throw Error("Unknown input type "+e.type)}}},{key:"handleChangedBlocks",value:function(e){if(e.blocks.length||!this.state.game.playerSpawned)if(this.state.game.worldGenerated){if(this.state.enqueuedChangedBlocks.length){this.state.changedBlocks=this.state.enqueuedChangedBlocks.splice(0),this.state.game.handleChangedBlocks(this.state.changedBlocks);for(var t=0;t<this.state.changedBlocks.length;t++)a.default.getInstance().addBlockChange(this.state.changedBlocks[t])}for(var i=0;i<e.blocks.length;i++)void 0===this.state.changedBlocks[e.from+i]&&(this.state.changedBlocks[e.from+i]=e.blocks[i],a.default.getInstance().addBlockChange(e.blocks[i]));this.state.game.handleChangedBlocks(e.blocks)}else this.state.enqueuedChangedBlocks=u(this.state.enqueuedChangedBlocks).concat(u(e.blocks))}},{key:"broadcast",value:function(e){this.peer.connected&&this.peer.send(JSON.stringify(e))}},{key:"joinGame",value:function(){var t=this;return new e(function(e,i){t.setState({error:"",connecting:!0});var r=t.state,n=r.code;r.database;s.a.getGame(n).then(function(i){null==i?t.handleNoSuchGame(e,n):t.handleJoinExistingGame(n,e)})})}},{key:"handleJoinExistingGame",value:function(e,t){var i=this;s.a.getICECandidates(e).then(function(r){var o=c(8);s.a.joinSignalingChannel(e,o).then(function(){var a=new n.a({initiator:!0,trickle:!1,reconnectTimer:3e3,config:{iceServers:r}});i.peer=a,a.on("signal",function(t){s.a.sendSignalingTo(e,"host",o,t).then(function(){})}),s.a.listenForData(e,function(e){void 0!==e.payload.signal&&a.signal(e.payload.signal)}),a.on("data",function(e){i.handleData(JSON.parse(e))}),i.handleConnectionEstablished(a,t,e),i.pollWorldChanges(),i.handleHostDisconnected(a,e),a.on("error",function(e){"ERR_ICE_CONNECTION_FAILURE"===e.code&&(console.log("Host disconnected!"),console.log(e),console.log(this))})})})}},{key:"handleHostDisconnected",value:function(e,t){var i=this;e.on("close",function(){i.setState({gameStarted:!1,connected:!1,error:"Disconnected from host",code:""}),i.removeOtherPlayers()})}},{key:"handleConnectionEstablished",value:function(e,t,i){var r=this;e.on("connect",function(){setTimeout(function(){r.broadcast({type:"connected"}),r.setState({connected:!0,connecting:!1})},1e3),t(i)})}},{key:"pollWorldChanges",value:function(){var e=this;setInterval(function(){var t=e.state.changedBlocks.length?e.state.changedBlocks.length:e.state.enqueuedChangedBlocks.length;e.broadcast({type:"requestChanges",from:t})},1e3)}},{key:"handleNoSuchGame",value:function(e,t){this.handleWelcomeInfo({hostName:"no host",gameFull:!0,playerCount:0,maxPlayers:0,worldSeed:0,noSuchGame:!0,worldSize:128,numberOfChangedBlocks:0}),e(t)}},{key:"getWelcomeInfo",value:function(){var t=this;return new e(function(e,i){t.welcomeInfoResolve=e})}},{key:"getSpawnedPlayerNames",value:function(){var e=[this.state.name];for(var t in this.state.players)this.state.players[t].state.spawned&&e.push(this.state.players[t].state.name);return e}},{key:"setBlockAt",value:function(e,t){this.broadcast({type:"setBlockTypeAt",data:{position:e,blockTypeId:t}})}},{key:"emitFireEvent",value:function(e){this.broadcast({type:"fireEvent",data:e})}},{key:"sendJoined",value:function(e){var t={message:"",timestamp:+new Date,type:"joined",from:e};this.broadcast({type:"message",message:t})}},{key:"sendMessage",value:function(e){var t={message:e,timestamp:+new Date,type:"message",from:this.state.name};this.broadcast({type:"message",message:t})}},{key:"setState",value:function(e,t){"Disconnected from host"==e.error&&this.state.game.onHostDisconnect&&this.state.game.onHostDisconnect(),this.state=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},r=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),r.forEach(function(t){h(e,t,i[t])})}return e}({},this.state,e),t&&"function"==typeof t&&t()}},{key:"removeOtherPlayers",value:function(){for(var e in this.state.players)e!==this.state.name&&(this.state.players[e].noaPlayer.remove(),delete this.state.players[e])}},{key:"handlePlayers",value:function(e){if(this.state.game.playerSpawned){var t=[];for(var i in e)if(!0===e[i].state.spawned){var r=e[i].state.name;t.push(r),r!==this.state.name&&void 0===this.state.players[r]&&(this.state.players[r]=new o.a({name:r,isClient:!0})),r!==this.state.name&&this.state.players[r].setState(e[i].state)}for(var n in this.state.players)-1===t.indexOf(n)&&(this.state.players[n].noaPlayer.remove(),delete this.state.players[n])}}},{key:"kickPlayer",value:function(e){return"Command not allowed"}},{key:"setSpawnToCurrentPosition",value:function(){return"Command not allowed"}},{key:"getPositionFor",value:function(e){for(var t in this.state.players)if(this.state.players[t].state.name===e)return this.state.players[t].state.position;return null}},{key:"handleChatLog",value:function(e){this.state.game.playerSpawned&&(this.state.chatLog=e,this.state.game.updateChatLog(this.state.chatLog))}},{key:"handleOnKicked",value:function(){this.state.game.playerSpawned&&this.state.game.onKicked()}},{key:"handleWelcomeInfo",value:function(e){null!=this.welcomeInfoResolve&&this.welcomeInfoResolve(e),this.state.game.setHostInfo({hostName:e.hostName,gameFull:e.gameFull,playerCount:e.playerCount,maxPlayers:e.maxPlayers,worldSeed:e.worldSeed,worldSize:e.worldSize,spawnPoint:e.spawnPoint,noSuchGame:void 0!==e.noSuchGame&&e.noSuchGame,numberOfChangedBlocks:e.numberOfChangedBlocks}),e.gameFull&&this.peer.destroy()}}])&&l(i.prototype,r),f&&l(i,f),t}();t.a=f}).call(this,i(52))},function(e,t,i){(function(t){var r=i(513);e.exports=function(e,i){if(t.isBuffer(e)&&(i=e,e=0),"number"!=typeof e&&(e=16),!t.isBuffer(i)){var n=Math.log(Math.pow(64,e))/Math.log(2)/8;i=r.randomBytes(n)}return i.toString("base64").replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"").substr(0,e||void 0)}}).call(this,i(9).Buffer)},function(e,t,i){"use strict";i.r(t);i(229),i(396);var r=i(18),n=i(136),o=i(226),s=i(94),a=i(55),c=i(135),h=i(7);function u(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}new(function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r.a.init(),r.a.executeXhr("/game/multiplayer-enabled","get").then(function(e){var i=new s.a,r=Math.floor(99999999999999*Math.random()),n=new URL(document.location).searchParams;h.default.getInstance().gameSaved()&&(r=h.default.getInstance().getWorldSeed()),i.noWebrtcJoin=!1;var o=new c.default;if(o.isMobile)document.getElementById("mobile").style.display="block";else if(o.isWebGLSupported){var a=JSON.parse(e).multiplayerEnabled;o.isSinglePlayer||"true"!==a?t.setupAsSinglePlayer(r,i):null===n.get("join")?t.setupAsHost(n,r,i):o.isWebRTCSupported?t.setupAsClient(n,i):(t.setupAsHost(n,r,i),i.noWebrtcJoin=!0)}else document.getElementById("webgl_webrtc").style.display="block"})}var t,i,l;return t=e,(i=[{key:"setupAsClient",value:function(e,t){var i=e.get("join"),r=new o.a({code:i,game:t}),n=null;t.setName=function(e){null===n&&(n=new a.a({name:e,network:r,isSelf:!0,isClient:!0},function(e){r.broadcast({type:"playerState",data:{state:e}})}),r.setState({name:e}),t.setPlayer(n))},r.joinGame().then(function(e){h.default.getInstance().clearData()}),r.getWelcomeInfo().then(function(e){h.default.getInstance().setWorldSeed(e.worldSeed),h.default.getInstance().setWorldSize(e.worldSize),t.initialize({seed:e.worldSeed,network:r}),t.client=r})}},{key:"setupAsSinglePlayer",value:function(e,t){var i=new n.a({name:"temp",seed:e,game:t});if(h.default.getInstance().setWorldSeed(e),h.default.getInstance().gameSaved()){var r=h.default.getInstance().getChangedBlocks();i.setChangedBlocks(r)}t.initialize({seed:e,player:i.getPlayer(),network:i,singlePlayer:!0}),t.setChangedBlockHandler(i.changedBlockHandler),t.setName=function(e){i.setName(e)}}},{key:"setupAsHost",value:function(e,t,i){var r=this,o=null!==e.get("host")?e.get("host"):null,s=new n.a({name:"temp",seed:t,game:i});if(h.default.getInstance().setWorldSeed(t),h.default.getInstance().gameSaved()){var a=h.default.getInstance().getChangedBlocks();s.setChangedBlocks(a)}s.initNewGame(o).then(function(n){r.setHostUrl(e,n),i.initialize({seed:t,player:s.getPlayer(),network:s}),i.setChangedBlockHandler(s.changedBlockHandler)}),i.setName=function(e){s.setName(e)}}},{key:"setHostUrl",value:function(e,t){if("URLSearchParams"in window){var i=new URLSearchParams(window.location.search);i.set("host",t),history.pushState({},t,"?"+i.toString())}}}])&&u(t.prototype,i),l&&u(t,l),e}())},function(e,t,i){"use strict";(function(e){i(230),i(373),i(375),i(377),i(379),i(381),i(383),i(385),i(387),i(389),i(393),e._babelPolyfill&&"undefined"!=typeof console&&console.warn&&console.warn("@babel/polyfill is loaded more than once on this page. This is probably not desirable/intended and may have consequences if different versions of the polyfills are applied sequentially. If you do need to load the polyfill more than once, use @babel/polyfill/noConflict instead to bypass the warning."),e._babelPolyfill=!0}).call(this,i(15))},function(e,t,i){i(231),i(233),i(234),i(235),i(236),i(237),i(238),i(239),i(240),i(241),i(242),i(243),i(244),i(245),i(246),i(247),i(248),i(249),i(250),i(251),i(252),i(253),i(254),i(255),i(256),i(257),i(258),i(259),i(260),i(261),i(262),i(263),i(264),i(265),i(266),i(267),i(268),i(269),i(270),i(271),i(272),i(273),i(274),i(276),i(277),i(278),i(279),i(280),i(281),i(282),i(283),i(284),i(285),i(286),i(287),i(288),i(289),i(290),i(291),i(292),i(293),i(294),i(295),i(296),i(297),i(298),i(299),i(300),i(301),i(302),i(303),i(304),i(305),i(306),i(307),i(308),i(309),i(311),i(312),i(314),i(315),i(316),i(317),i(318),i(319),i(320),i(323),i(324),i(325),i(326),i(327),i(328),i(329),i(330),i(331),i(332),i(333),i(334),i(335),i(117),i(336),i(156),i(337),i(157),i(338),i(339),i(340),i(341),i(158),i(344),i(345),i(346),i(347),i(348),i(349),i(350),i(351),i(352),i(353),i(354),i(355),i(356),i(357),i(358),i(359),i(360),i(361),i(362),i(363),i(364),i(365),i(366),i(367),i(368),i(369),i(370),i(371),i(372),e.exports=i(14)},function(e,t,i){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=i(5),o=i(22),s=i(13),a=i(0),c=i(19),h=i(40).KEY,u=i(3),l=i(96),f=i(56),d=i(45),p=i(8),m=i(97),g=i(138),_=i(232),v=i(100),y=i(4),b=i(6),x=i(24),w=i(39),S=i(44),T=i(49),A=i(141),M=i(29),E=i(12),P=i(47),C=M.f,R=E.f,I=A.f,D=n.Symbol,O=n.JSON,L=O&&O.stringify,F=p("_hidden"),B=p("toPrimitive"),k={}.propertyIsEnumerable,V=l("symbol-registry"),N=l("symbols"),z=l("op-symbols"),U=Object.prototype,G="function"==typeof D,W=n.QObject,j=!W||!W.prototype||!W.prototype.findChild,H=s&&u(function(){return 7!=T(R({},"a",{get:function(){return R(this,"a",{value:7}).a}})).a})?function(e,t,i){var r=C(U,t);r&&delete U[t],R(e,t,i),r&&e!==U&&R(U,t,r)}:R,X=function(e){var t=N[e]=T(D.prototype);return t._k=e,t},Y=G&&"symbol"==r(D.iterator)?function(e){return"symbol"==r(e)}:function(e){return e instanceof D},K=function(e,t,i){return e===U&&K(z,t,i),y(e),t=w(t,!0),y(i),o(N,t)?(i.enumerable?(o(e,F)&&e[F][t]&&(e[F][t]=!1),i=T(i,{enumerable:S(0,!1)})):(o(e,F)||R(e,F,S(1,{})),e[F][t]=!0),H(e,t,i)):R(e,t,i)},q=function(e,t){y(e);for(var i,r=_(t=x(t)),n=0,o=r.length;o>n;)K(e,i=r[n++],t[i]);return e},Z=function(e){var t=k.call(this,e=w(e,!0));return!(this===U&&o(N,e)&&!o(z,e))&&(!(t||!o(this,e)||!o(N,e)||o(this,F)&&this[F][e])||t)},Q=function(e,t){if(e=x(e),t=w(t,!0),e!==U||!o(N,t)||o(z,t)){var i=C(e,t);return!i||!o(N,t)||o(e,F)&&e[F][t]||(i.enumerable=!0),i}},J=function(e){for(var t,i=I(x(e)),r=[],n=0;i.length>n;)o(N,t=i[n++])||t==F||t==h||r.push(t);return r},$=function(e){for(var t,i=e===U,r=I(i?z:x(e)),n=[],s=0;r.length>s;)!o(N,t=r[s++])||i&&!o(U,t)||n.push(N[t]);return n};G||(c((D=function(){if(this instanceof D)throw TypeError("Symbol is not a constructor!");var e=d(arguments.length>0?arguments[0]:void 0);return s&&j&&H(U,e,{configurable:!0,set:function t(i){this===U&&t.call(z,i),o(this,F)&&o(this[F],e)&&(this[F][e]=!1),H(this,e,S(1,i))}}),X(e)}).prototype,"toString",function(){return this._k}),M.f=Q,E.f=K,i(50).f=A.f=J,i(65).f=Z,i(75).f=$,s&&!i(46)&&c(U,"propertyIsEnumerable",Z,!0),m.f=function(e){return X(p(e))}),a(a.G+a.W+a.F*!G,{Symbol:D});for(var ee="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),te=0;ee.length>te;)p(ee[te++]);for(var ie=P(p.store),re=0;ie.length>re;)g(ie[re++]);a(a.S+a.F*!G,"Symbol",{for:function(e){return o(V,e+="")?V[e]:V[e]=D(e)},keyFor:function(e){if(!Y(e))throw TypeError(e+" is not a symbol!");for(var t in V)if(V[t]===e)return t},useSetter:function(){j=!0},useSimple:function(){j=!1}}),a(a.S+a.F*!G,"Object",{create:function(e,t){return void 0===t?T(e):q(T(e),t)},defineProperty:K,defineProperties:q,getOwnPropertyDescriptor:Q,getOwnPropertyNames:J,getOwnPropertySymbols:$}),O&&a(a.S+a.F*(!G||u(function(){var e=D();return"[null]"!=L([e])||"{}"!=L({a:e})||"{}"!=L(Object(e))})),"JSON",{stringify:function(e){for(var t,i,r=[e],n=1;arguments.length>n;)r.push(arguments[n++]);if(i=t=r[1],(b(t)||void 0!==e)&&!Y(e))return v(t)||(t=function(e,t){if("function"==typeof i&&(t=i.call(this,e,t)),!Y(t))return t}),r[1]=t,L.apply(O,r)}}),D.prototype[B]||i(23)(D.prototype,B,D.prototype.valueOf),f(D,"Symbol"),f(Math,"Math",!0),f(n.JSON,"JSON",!0)},function(e,t,i){var r=i(47),n=i(75),o=i(65);e.exports=function(e){var t=r(e),i=n.f;if(i)for(var s,a=i(e),c=o.f,h=0;a.length>h;)c.call(e,s=a[h++])&&t.push(s);return t}},function(e,t,i){var r=i(0);r(r.S,"Object",{create:i(49)})},function(e,t,i){var r=i(0);r(r.S+r.F*!i(13),"Object",{defineProperty:i(12).f})},function(e,t,i){var r=i(0);r(r.S+r.F*!i(13),"Object",{defineProperties:i(140)})},function(e,t,i){var r=i(24),n=i(29).f;i(30)("getOwnPropertyDescriptor",function(){return function(e,t){return n(r(e),t)}})},function(e,t,i){var r=i(20),n=i(51);i(30)("getPrototypeOf",function(){return function(e){return n(r(e))}})},function(e,t,i){var r=i(20),n=i(47);i(30)("keys",function(){return function(e){return n(r(e))}})},function(e,t,i){i(30)("getOwnPropertyNames",function(){return i(141).f})},function(e,t,i){var r=i(6),n=i(40).onFreeze;i(30)("freeze",function(e){return function(t){return e&&r(t)?e(n(t)):t}})},function(e,t,i){var r=i(6),n=i(40).onFreeze;i(30)("seal",function(e){return function(t){return e&&r(t)?e(n(t)):t}})},function(e,t,i){var r=i(6),n=i(40).onFreeze;i(30)("preventExtensions",function(e){return function(t){return e&&r(t)?e(n(t)):t}})},function(e,t,i){var r=i(6);i(30)("isFrozen",function(e){return function(t){return!r(t)||!!e&&e(t)}})},function(e,t,i){var r=i(6);i(30)("isSealed",function(e){return function(t){return!r(t)||!!e&&e(t)}})},function(e,t,i){var r=i(6);i(30)("isExtensible",function(e){return function(t){return!!r(t)&&(!e||e(t))}})},function(e,t,i){var r=i(0);r(r.S+r.F,"Object",{assign:i(142)})},function(e,t,i){var r=i(0);r(r.S,"Object",{is:i(143)})},function(e,t,i){var r=i(0);r(r.S,"Object",{setPrototypeOf:i(102).set})},function(e,t,i){"use strict";var r=i(66),n={};n[i(8)("toStringTag")]="z",n+""!="[object z]"&&i(19)(Object.prototype,"toString",function(){return"[object "+r(this)+"]"},!0)},function(e,t,i){var r=i(0);r(r.P,"Function",{bind:i(144)})},function(e,t,i){var r=i(12).f,n=Function.prototype,o=/^\s*function ([^ (]*)/;"name"in n||i(13)&&r(n,"name",{configurable:!0,get:function(){try{return(""+this).match(o)[1]}catch(e){return""}}})},function(e,t,i){"use strict";var r=i(6),n=i(51),o=i(8)("hasInstance"),s=Function.prototype;o in s||i(12).f(s,o,{value:function(e){if("function"!=typeof this||!r(e))return!1;if(!r(this.prototype))return e instanceof this;for(;e=n(e);)if(this.prototype===e)return!0;return!1}})},function(e,t,i){var r=i(0),n=i(146);r(r.G+r.F*(parseInt!=n),{parseInt:n})},function(e,t,i){var r=i(0),n=i(147);r(r.G+r.F*(parseFloat!=n),{parseFloat:n})},function(e,t,i){"use strict";var r=i(5),n=i(22),o=i(36),s=i(104),a=i(39),c=i(3),h=i(50).f,u=i(29).f,l=i(12).f,f=i(76).trim,d=r.Number,p=d,m=d.prototype,g="Number"==o(i(49)(m)),_="trim"in String.prototype,v=function(e){var t=a(e,!1);if("string"==typeof t&&t.length>2){var i,r,n,o=(t=_?t.trim():f(t,3)).charCodeAt(0);if(43===o||45===o){if(88===(i=t.charCodeAt(2))||120===i)return NaN}else if(48===o){switch(t.charCodeAt(1)){case 66:case 98:r=2,n=49;break;case 79:case 111:r=8,n=55;break;default:return+t}for(var s,c=t.slice(2),h=0,u=c.length;h<u;h++)if((s=c.charCodeAt(h))<48||s>n)return NaN;return parseInt(c,r)}}return+t};if(!d(" 0o1")||!d("0b1")||d("+0x1")){d=function(e){var t=arguments.length<1?0:e,i=this;return i instanceof d&&(g?c(function(){m.valueOf.call(i)}):"Number"!=o(i))?s(new p(v(t)),i,d):v(t)};for(var y,b=i(13)?h(p):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),x=0;b.length>x;x++)n(p,y=b[x])&&!n(d,y)&&l(d,y,u(p,y));d.prototype=m,m.constructor=d,i(19)(r,"Number",d)}},function(e,t,i){"use strict";var r=i(0),n=i(28),o=i(148),s=i(105),a=1..toFixed,c=Math.floor,h=[0,0,0,0,0,0],u="Number.toFixed: incorrect invocation!",l=function(e,t){for(var i=-1,r=t;++i<6;)r+=e*h[i],h[i]=r%1e7,r=c(r/1e7)},f=function(e){for(var t=6,i=0;--t>=0;)i+=h[t],h[t]=c(i/e),i=i%e*1e7},d=function(){for(var e=6,t="";--e>=0;)if(""!==t||0===e||0!==h[e]){var i=String(h[e]);t=""===t?i:t+s.call("0",7-i.length)+i}return t},p=function e(t,i,r){return 0===i?r:i%2==1?e(t,i-1,r*t):e(t*t,i/2,r)};r(r.P+r.F*(!!a&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!i(3)(function(){a.call({})})),"Number",{toFixed:function(e){var t,i,r,a,c=o(this,u),h=n(e),m="",g="0";if(h<0||h>20)throw RangeError(u);if(c!=c)return"NaN";if(c<=-1e21||c>=1e21)return String(c);if(c<0&&(m="-",c=-c),c>1e-21)if(i=(t=function(e){for(var t=0,i=e;i>=4096;)t+=12,i/=4096;for(;i>=2;)t+=1,i/=2;return t}(c*p(2,69,1))-69)<0?c*p(2,-t,1):c/p(2,t,1),i*=4503599627370496,(t=52-t)>0){for(l(0,i),r=h;r>=7;)l(1e7,0),r-=7;for(l(p(10,r,1),0),r=t-1;r>=23;)f(1<<23),r-=23;f(1<<r),l(1,1),f(2),g=d()}else l(0,i),l(1<<-t,0),g=d()+s.call("0",h);return g=h>0?m+((a=g.length)<=h?"0."+s.call("0",h-a)+g:g.slice(0,a-h)+"."+g.slice(a-h)):m+g}})},function(e,t,i){"use strict";var r=i(0),n=i(3),o=i(148),s=1..toPrecision;r(r.P+r.F*(n(function(){return"1"!==s.call(1,void 0)})||!n(function(){s.call({})})),"Number",{toPrecision:function(e){var t=o(this,"Number#toPrecision: incorrect invocation!");return void 0===e?s.call(t):s.call(t,e)}})},function(e,t,i){var r=i(0);r(r.S,"Number",{EPSILON:Math.pow(2,-52)})},function(e,t,i){var r=i(0),n=i(5).isFinite;r(r.S,"Number",{isFinite:function(e){return"number"==typeof e&&n(e)}})},function(e,t,i){var r=i(0);r(r.S,"Number",{isInteger:i(149)})},function(e,t,i){var r=i(0);r(r.S,"Number",{isNaN:function(e){return e!=e}})},function(e,t,i){var r=i(0),n=i(149),o=Math.abs;r(r.S,"Number",{isSafeInteger:function(e){return n(e)&&o(e)<=9007199254740991}})},function(e,t,i){var r=i(0);r(r.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},function(e,t,i){var r=i(0);r(r.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991})},function(e,t,i){var r=i(0),n=i(147);r(r.S+r.F*(Number.parseFloat!=n),"Number",{parseFloat:n})},function(e,t,i){var r=i(0),n=i(146);r(r.S+r.F*(Number.parseInt!=n),"Number",{parseInt:n})},function(e,t,i){var r=i(0),n=i(150),o=Math.sqrt,s=Math.acosh;r(r.S+r.F*!(s&&710==Math.floor(s(Number.MAX_VALUE))&&s(1/0)==1/0),"Math",{acosh:function(e){return(e=+e)<1?NaN:e>94906265.62425156?Math.log(e)+Math.LN2:n(e-1+o(e-1)*o(e+1))}})},function(e,t,i){var r=i(0),n=Math.asinh;r(r.S+r.F*!(n&&1/n(0)>0),"Math",{asinh:function e(t){return isFinite(t=+t)&&0!=t?t<0?-e(-t):Math.log(t+Math.sqrt(t*t+1)):t}})},function(e,t,i){var r=i(0),n=Math.atanh;r(r.S+r.F*!(n&&1/n(-0)<0),"Math",{atanh:function(e){return 0==(e=+e)?e:Math.log((1+e)/(1-e))/2}})},function(e,t,i){var r=i(0),n=i(106);r(r.S,"Math",{cbrt:function(e){return n(e=+e)*Math.pow(Math.abs(e),1/3)}})},function(e,t,i){var r=i(0);r(r.S,"Math",{clz32:function(e){return(e>>>=0)?31-Math.floor(Math.log(e+.5)*Math.LOG2E):32}})},function(e,t,i){var r=i(0),n=Math.exp;r(r.S,"Math",{cosh:function(e){return(n(e=+e)+n(-e))/2}})},function(e,t,i){var r=i(0),n=i(107);r(r.S+r.F*(n!=Math.expm1),"Math",{expm1:n})},function(e,t,i){var r=i(0);r(r.S,"Math",{fround:i(275)})},function(e,t,i){var r=i(106),n=Math.pow,o=n(2,-52),s=n(2,-23),a=n(2,127)*(2-s),c=n(2,-126);e.exports=Math.fround||function(e){var t,i,n=Math.abs(e),h=r(e);return n<c?h*(n/c/s+1/o-1/o)*c*s:(i=(t=(1+s/o)*n)-(t-n))>a||i!=i?h*(1/0):h*i}},function(e,t,i){var r=i(0),n=Math.abs;r(r.S,"Math",{hypot:function(e,t){for(var i,r,o=0,s=0,a=arguments.length,c=0;s<a;)c<(i=n(arguments[s++]))?(o=o*(r=c/i)*r+1,c=i):o+=i>0?(r=i/c)*r:i;return c===1/0?1/0:c*Math.sqrt(o)}})},function(e,t,i){var r=i(0),n=Math.imul;r(r.S+r.F*i(3)(function(){return-5!=n(4294967295,5)||2!=n.length}),"Math",{imul:function(e,t){var i=+e,r=+t,n=65535&i,o=65535&r;return 0|n*o+((65535&i>>>16)*o+n*(65535&r>>>16)<<16>>>0)}})},function(e,t,i){var r=i(0);r(r.S,"Math",{log10:function(e){return Math.log(e)*Math.LOG10E}})},function(e,t,i){var r=i(0);r(r.S,"Math",{log1p:i(150)})},function(e,t,i){var r=i(0);r(r.S,"Math",{log2:function(e){return Math.log(e)/Math.LN2}})},function(e,t,i){var r=i(0);r(r.S,"Math",{sign:i(106)})},function(e,t,i){var r=i(0),n=i(107),o=Math.exp;r(r.S+r.F*i(3)(function(){return-2e-17!=!Math.sinh(-2e-17)}),"Math",{sinh:function(e){return Math.abs(e=+e)<1?(n(e)-n(-e))/2:(o(e-1)-o(-e-1))*(Math.E/2)}})},function(e,t,i){var r=i(0),n=i(107),o=Math.exp;r(r.S,"Math",{tanh:function(e){var t=n(e=+e),i=n(-e);return t==1/0?1:i==1/0?-1:(t-i)/(o(e)+o(-e))}})},function(e,t,i){var r=i(0);r(r.S,"Math",{trunc:function(e){return(e>0?Math.floor:Math.ceil)(e)}})},function(e,t,i){var r=i(0),n=i(48),o=String.fromCharCode,s=String.fromCodePoint;r(r.S+r.F*(!!s&&1!=s.length),"String",{fromCodePoint:function(e){for(var t,i=[],r=arguments.length,s=0;r>s;){if(t=+arguments[s++],n(t,1114111)!==t)throw RangeError(t+" is not a valid code point");i.push(t<65536?o(t):o(55296+((t-=65536)>>10),t%1024+56320))}return i.join("")}})},function(e,t,i){var r=i(0),n=i(24),o=i(10);r(r.S,"String",{raw:function(e){for(var t=n(e.raw),i=o(t.length),r=arguments.length,s=[],a=0;i>a;)s.push(String(t[a++])),a<r&&s.push(String(arguments[a]));return s.join("")}})},function(e,t,i){"use strict";i(76)("trim",function(e){return function(){return e(this,3)}})},function(e,t,i){"use strict";var r=i(108)(!0);i(109)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,i=this._i;return i>=t.length?{value:void 0,done:!0}:(e=r(t,i),this._i+=e.length,{value:e,done:!1})})},function(e,t,i){"use strict";var r=i(0),n=i(108)(!1);r(r.P,"String",{codePointAt:function(e){return n(this,e)}})},function(e,t,i){"use strict";var r=i(0),n=i(10),o=i(110),s="".endsWith;r(r.P+r.F*i(112)("endsWith"),"String",{endsWith:function(e){var t=o(this,e,"endsWith"),i=arguments.length>1?arguments[1]:void 0,r=n(t.length),a=void 0===i?r:Math.min(n(i),r),c=String(e);return s?s.call(t,c,a):t.slice(a-c.length,a)===c}})},function(e,t,i){"use strict";var r=i(0),n=i(110);r(r.P+r.F*i(112)("includes"),"String",{includes:function(e){return!!~n(this,e,"includes").indexOf(e,arguments.length>1?arguments[1]:void 0)}})},function(e,t,i){var r=i(0);r(r.P,"String",{repeat:i(105)})},function(e,t,i){"use strict";var r=i(0),n=i(10),o=i(110),s="".startsWith;r(r.P+r.F*i(112)("startsWith"),"String",{startsWith:function(e){var t=o(this,e,"startsWith"),i=n(Math.min(arguments.length>1?arguments[1]:void 0,t.length)),r=String(e);return s?s.call(t,r,i):t.slice(i,i+r.length)===r}})},function(e,t,i){"use strict";i(21)("anchor",function(e){return function(t){return e(this,"a","name",t)}})},function(e,t,i){"use strict";i(21)("big",function(e){return function(){return e(this,"big","","")}})},function(e,t,i){"use strict";i(21)("blink",function(e){return function(){return e(this,"blink","","")}})},function(e,t,i){"use strict";i(21)("bold",function(e){return function(){return e(this,"b","","")}})},function(e,t,i){"use strict";i(21)("fixed",function(e){return function(){return e(this,"tt","","")}})},function(e,t,i){"use strict";i(21)("fontcolor",function(e){return function(t){return e(this,"font","color",t)}})},function(e,t,i){"use strict";i(21)("fontsize",function(e){return function(t){return e(this,"font","size",t)}})},function(e,t,i){"use strict";i(21)("italics",function(e){return function(){return e(this,"i","","")}})},function(e,t,i){"use strict";i(21)("link",function(e){return function(t){return e(this,"a","href",t)}})},function(e,t,i){"use strict";i(21)("small",function(e){return function(){return e(this,"small","","")}})},function(e,t,i){"use strict";i(21)("strike",function(e){return function(){return e(this,"strike","","")}})},function(e,t,i){"use strict";i(21)("sub",function(e){return function(){return e(this,"sub","","")}})},function(e,t,i){"use strict";i(21)("sup",function(e){return function(){return e(this,"sup","","")}})},function(e,t,i){var r=i(0);r(r.S,"Date",{now:function(){return(new Date).getTime()}})},function(e,t,i){"use strict";var r=i(0),n=i(20),o=i(39);r(r.P+r.F*i(3)(function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}),"Date",{toJSON:function(e){var t=n(this),i=o(t);return"number"!=typeof i||isFinite(i)?t.toISOString():null}})},function(e,t,i){var r=i(0),n=i(310);r(r.P+r.F*(Date.prototype.toISOString!==n),"Date",{toISOString:n})},function(e,t,i){"use strict";var r=i(3),n=Date.prototype.getTime,o=Date.prototype.toISOString,s=function(e){return e>9?e:"0"+e};e.exports=r(function(){return"0385-07-25T07:06:39.999Z"!=o.call(new Date(-5e13-1))})||!r(function(){o.call(new Date(NaN))})?function(){if(!isFinite(n.call(this)))throw RangeError("Invalid time value");var e=this,t=e.getUTCFullYear(),i=e.getUTCMilliseconds(),r=t<0?"-":t>9999?"+":"";return r+("00000"+Math.abs(t)).slice(r?-6:-4)+"-"+s(e.getUTCMonth()+1)+"-"+s(e.getUTCDate())+"T"+s(e.getUTCHours())+":"+s(e.getUTCMinutes())+":"+s(e.getUTCSeconds())+"."+(i>99?i:"0"+s(i))+"Z"}:o},function(e,t,i){var r=Date.prototype,n=r.toString,o=r.getTime;new Date(NaN)+""!="Invalid Date"&&i(19)(r,"toString",function(){var e=o.call(this);return e==e?n.call(this):"Invalid Date"})},function(e,t,i){var r=i(8)("toPrimitive"),n=Date.prototype;r in n||i(23)(n,r,i(313))},function(e,t,i){"use strict";var r=i(4),n=i(39);e.exports=function(e){if("string"!==e&&"number"!==e&&"default"!==e)throw TypeError("Incorrect hint");return n(r(this),"number"!=e)}},function(e,t,i){var r=i(0);r(r.S,"Array",{isArray:i(100)})},function(e,t,i){"use strict";var r=i(34),n=i(0),o=i(20),s=i(152),a=i(113),c=i(10),h=i(114),u=i(115);n(n.S+n.F*!i(77)(function(e){Array.from(e)}),"Array",{from:function(e){var t,i,n,l,f=o(e),d="function"==typeof this?this:Array,p=arguments.length,m=p>1?arguments[1]:void 0,g=void 0!==m,_=0,v=u(f);if(g&&(m=r(m,p>2?arguments[2]:void 0,2)),null==v||d==Array&&a(v))for(i=new d(t=c(f.length));t>_;_++)h(i,_,g?m(f[_],_):f[_]);else for(l=v.call(f),i=new d;!(n=l.next()).done;_++)h(i,_,g?s(l,m,[n.value,_],!0):n.value);return i.length=_,i}})},function(e,t,i){"use strict";var r=i(0),n=i(114);r(r.S+r.F*i(3)(function(){function e(){}return!(Array.of.call(e)instanceof e)}),"Array",{of:function(){for(var e=0,t=arguments.length,i=new("function"==typeof this?this:Array)(t);t>e;)n(i,e,arguments[e++]);return i.length=t,i}})},function(e,t,i){"use strict";var r=i(0),n=i(24),o=[].join;r(r.P+r.F*(i(64)!=Object||!i(26)(o)),"Array",{join:function(e){return o.call(n(this),void 0===e?",":e)}})},function(e,t,i){"use strict";var r=i(0),n=i(101),o=i(36),s=i(48),a=i(10),c=[].slice;r(r.P+r.F*i(3)(function(){n&&c.call(n)}),"Array",{slice:function(e,t){var i=a(this.length),r=o(this);if(t=void 0===t?i:t,"Array"==r)return c.call(this,e,t);for(var n=s(e,i),h=s(t,i),u=a(h-n),l=new Array(u),f=0;f<u;f++)l[f]="String"==r?this.charAt(n+f):this[n+f];return l}})},function(e,t,i){"use strict";var r=i(0),n=i(35),o=i(20),s=i(3),a=[].sort,c=[1,2,3];r(r.P+r.F*(s(function(){c.sort(void 0)})||!s(function(){c.sort(null)})||!i(26)(a)),"Array",{sort:function(e){return void 0===e?a.call(o(this)):a.call(o(this),n(e))}})},function(e,t,i){"use strict";var r=i(0),n=i(31)(0),o=i(26)([].forEach,!0);r(r.P+r.F*!o,"Array",{forEach:function(e){return n(this,e,arguments[1])}})},function(e,t,i){var r=i(322);e.exports=function(e,t){return new(r(e))(t)}},function(e,t,i){var r=i(6),n=i(100),o=i(8)("species");e.exports=function(e){var t;return n(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!n(t.prototype)||(t=void 0),r(t)&&null===(t=t[o])&&(t=void 0)),void 0===t?Array:t}},function(e,t,i){"use strict";var r=i(0),n=i(31)(1);r(r.P+r.F*!i(26)([].map,!0),"Array",{map:function(e){return n(this,e,arguments[1])}})},function(e,t,i){"use strict";var r=i(0),n=i(31)(2);r(r.P+r.F*!i(26)([].filter,!0),"Array",{filter:function(e){return n(this,e,arguments[1])}})},function(e,t,i){"use strict";var r=i(0),n=i(31)(3);r(r.P+r.F*!i(26)([].some,!0),"Array",{some:function(e){return n(this,e,arguments[1])}})},function(e,t,i){"use strict";var r=i(0),n=i(31)(4);r(r.P+r.F*!i(26)([].every,!0),"Array",{every:function(e){return n(this,e,arguments[1])}})},function(e,t,i){"use strict";var r=i(0),n=i(153);r(r.P+r.F*!i(26)([].reduce,!0),"Array",{reduce:function(e){return n(this,e,arguments.length,arguments[1],!1)}})},function(e,t,i){"use strict";var r=i(0),n=i(153);r(r.P+r.F*!i(26)([].reduceRight,!0),"Array",{reduceRight:function(e){return n(this,e,arguments.length,arguments[1],!0)}})},function(e,t,i){"use strict";var r=i(0),n=i(74)(!1),o=[].indexOf,s=!!o&&1/[1].indexOf(1,-0)<0;r(r.P+r.F*(s||!i(26)(o)),"Array",{indexOf:function(e){return s?o.apply(this,arguments)||0:n(this,e,arguments[1])}})},function(e,t,i){"use strict";var r=i(0),n=i(24),o=i(28),s=i(10),a=[].lastIndexOf,c=!!a&&1/[1].lastIndexOf(1,-0)<0;r(r.P+r.F*(c||!i(26)(a)),"Array",{lastIndexOf:function(e){if(c)return a.apply(this,arguments)||0;var t=n(this),i=s(t.length),r=i-1;for(arguments.length>1&&(r=Math.min(r,o(arguments[1]))),r<0&&(r=i+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}})},function(e,t,i){var r=i(0);r(r.P,"Array",{copyWithin:i(154)}),i(58)("copyWithin")},function(e,t,i){var r=i(0);r(r.P,"Array",{fill:i(116)}),i(58)("fill")},function(e,t,i){"use strict";var r=i(0),n=i(31)(5),o=!0;"find"in[]&&Array(1).find(function(){o=!1}),r(r.P+r.F*o,"Array",{find:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}}),i(58)("find")},function(e,t,i){"use strict";var r=i(0),n=i(31)(6),o="findIndex",s=!0;o in[]&&Array(1)[o](function(){s=!1}),r(r.P+r.F*s,"Array",{findIndex:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}}),i(58)(o)},function(e,t,i){i(59)("Array")},function(e,t,i){var r=i(5),n=i(104),o=i(12).f,s=i(50).f,a=i(111),c=i(78),h=r.RegExp,u=h,l=h.prototype,f=/a/g,d=/a/g,p=new h(f)!==f;if(i(13)&&(!p||i(3)(function(){return d[i(8)("match")]=!1,h(f)!=f||h(d)==d||"/a/i"!=h(f,"i")}))){h=function(e,t){var i=this instanceof h,r=a(e),o=void 0===t;return!i&&r&&e.constructor===h&&o?e:n(p?new u(r&&!o?e.source:e,t):u((r=e instanceof h)?e.source:e,r&&o?c.call(e):t),i?this:l,h)};for(var m=function(e){e in h||o(h,e,{configurable:!0,get:function(){return u[e]},set:function(t){u[e]=t}})},g=s(u),_=0;g.length>_;)m(g[_++]);l.constructor=h,h.prototype=l,i(19)(r,"RegExp",h)}i(59)("RegExp")},function(e,t,i){"use strict";i(157);var r=i(4),n=i(78),o=i(13),s=/./.toString,a=function(e){i(19)(RegExp.prototype,"toString",e,!0)};i(3)(function(){return"/a/b"!=s.call({source:"a",flags:"b"})})?a(function(){var e=r(this);return"/".concat(e.source,"/","flags"in e?e.flags:!o&&e instanceof RegExp?n.call(e):void 0)}):"toString"!=s.name&&a(function(){return s.call(this)})},function(e,t,i){"use strict";var r=i(4),n=i(10),o=i(119),s=i(79);i(80)("match",1,function(e,t,i,a){return[function(i){var r=e(this),n=null==i?void 0:i[t];return void 0!==n?n.call(i,r):new RegExp(i)[t](String(r))},function(e){var t=a(i,e,this);if(t.done)return t.value;var c=r(e),h=String(this);if(!c.global)return s(c,h);var u=c.unicode;c.lastIndex=0;for(var l,f=[],d=0;null!==(l=s(c,h));){var p=String(l[0]);f[d]=p,""===p&&(c.lastIndex=o(h,n(c.lastIndex),u)),d++}return 0===d?null:f}]})},function(e,t,i){"use strict";var r=i(4),n=i(20),o=i(10),s=i(28),a=i(119),c=i(79),h=Math.max,u=Math.min,l=Math.floor,f=/\$([$&`']|\d\d?|<[^>]*>)/g,d=/\$([$&`']|\d\d?)/g;i(80)("replace",2,function(e,t,i,p){return[function(r,n){var o=e(this),s=null==r?void 0:r[t];return void 0!==s?s.call(r,o,n):i.call(String(o),r,n)},function(e,t){var n=p(i,e,this,t);if(n.done)return n.value;var l=r(e),f=String(this),d="function"==typeof t;d||(t=String(t));var g=l.global;if(g){var _=l.unicode;l.lastIndex=0}for(var v=[];;){var y=c(l,f);if(null===y)break;if(v.push(y),!g)break;""===String(y[0])&&(l.lastIndex=a(f,o(l.lastIndex),_))}for(var b,x="",w=0,S=0;S<v.length;S++){y=v[S];for(var T=String(y[0]),A=h(u(s(y.index),f.length),0),M=[],E=1;E<y.length;E++)M.push(void 0===(b=y[E])?b:String(b));var P=y.groups;if(d){var C=[T].concat(M,A,f);void 0!==P&&C.push(P);var R=String(t.apply(void 0,C))}else R=m(T,f,A,M,P,t);A>=w&&(x+=f.slice(w,A)+R,w=A+T.length)}return x+f.slice(w)}];function m(e,t,r,o,s,a){var c=r+e.length,h=o.length,u=d;return void 0!==s&&(s=n(s),u=f),i.call(a,u,function(i,n){var a;switch(n.charAt(0)){case"$":return"$";case"&":return e;case"`":return t.slice(0,r);case"'":return t.slice(c);case"<":a=s[n.slice(1,-1)];break;default:var u=+n;if(0===u)return n;if(u>h){var f=l(u/10);return 0===f?n:f<=h?void 0===o[f-1]?n.charAt(1):o[f-1]+n.charAt(1):n}a=o[u-1]}return void 0===a?"":a})}})},function(e,t,i){"use strict";var r=i(4),n=i(143),o=i(79);i(80)("search",1,function(e,t,i,s){return[function(i){var r=e(this),n=null==i?void 0:i[t];return void 0!==n?n.call(i,r):new RegExp(i)[t](String(r))},function(e){var t=s(i,e,this);if(t.done)return t.value;var a=r(e),c=String(this),h=a.lastIndex;n(h,0)||(a.lastIndex=0);var u=o(a,c);return n(a.lastIndex,h)||(a.lastIndex=h),null===u?-1:u.index}]})},function(e,t,i){"use strict";var r=i(111),n=i(4),o=i(67),s=i(119),a=i(10),c=i(79),h=i(118),u=Math.min,l=[].push,f=!!function(){try{return new RegExp("x","y")}catch(e){}}();i(80)("split",2,function(e,t,i,d){var p=i;return"c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?p=function(e,t){var n=String(this);if(void 0===e&&0===t)return[];if(!r(e))return i.call(n,e,t);for(var o,s,a,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),f=0,d=void 0===t?4294967295:t>>>0,p=new RegExp(e.source,u+"g");(o=h.call(p,n))&&!((s=p.lastIndex)>f&&(c.push(n.slice(f,o.index)),o.length>1&&o.index<n.length&&l.apply(c,o.slice(1)),a=o[0].length,f=s,c.length>=d));)p.lastIndex===o.index&&p.lastIndex++;return f===n.length?!a&&p.test("")||c.push(""):c.push(n.slice(f)),c.length>d?c.slice(0,d):c}:"0".split(void 0,0).length&&(p=function(e,t){return void 0===e&&0===t?[]:i.call(this,e,t)}),[function(i,r){var n=e(this),o=null==i?void 0:i[t];return void 0!==o?o.call(i,n,r):p.call(String(n),i,r)},function(e,t){var r=d(p,e,this,t,p!==i);if(r.done)return r.value;var h=n(e),l=String(this),m=o(h,RegExp),g=h.unicode,_=(h.ignoreCase?"i":"")+(h.multiline?"m":"")+(h.unicode?"u":"")+(f?"y":"g"),v=new m(f?h:"^(?:"+h.source+")",_),y=void 0===t?4294967295:t>>>0;if(0===y)return[];if(0===l.length)return null===c(v,l)?[l]:[];for(var b=0,x=0,w=[];x<l.length;){v.lastIndex=f?x:0;var S,T=c(v,f?l:l.slice(x));if(null===T||(S=u(a(v.lastIndex+(f?0:x)),l.length))===b)x=s(l,x,g);else{if(w.push(l.slice(b,x)),w.length===y)return w;for(var A=1;A<=T.length-1;A++)if(w.push(T[A]),w.length===y)return w;x=b=S}}return w.push(l.slice(b)),w}]})},function(e,t,i){var r=i(5),n=i(120).set,o=r.MutationObserver||r.WebKitMutationObserver,s=r.process,a=r.Promise,c="process"==i(36)(s);e.exports=function(){var e,t,i,h=function(){var r,n;for(c&&(r=s.domain)&&r.exit();e;){n=e.fn,e=e.next;try{n()}catch(r){throw e?i():t=void 0,r}}t=void 0,r&&r.enter()};if(c)i=function(){s.nextTick(h)};else if(!o||r.navigator&&r.navigator.standalone)if(a&&a.resolve){var u=a.resolve(void 0);i=function(){u.then(h)}}else i=function(){n.call(r,h)};else{var l=!0,f=document.createTextNode("");new o(h).observe(f,{characterData:!0}),i=function(){f.data=l=!l}}return function(r){var n={fn:r,next:void 0};t&&(t.next=n),e||(e=n,i()),t=n}}},function(e,t){e.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},function(e,t,i){"use strict";var r=i(161),n=i(62);e.exports=i(83)("Map",function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{get:function(e){var t=r.getEntry(n(this,"Map"),e);return t&&t.v},set:function(e,t){return r.def(n(this,"Map"),0===e?0:e,t)}},r,!0)},function(e,t,i){"use strict";var r=i(161),n=i(62);e.exports=i(83)("Set",function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{add:function(e){return r.def(n(this,"Set"),e=0===e?0:e,e)}},r)},function(e,t,i){"use strict";var r,n=i(31)(0),o=i(19),s=i(40),a=i(142),c=i(162),h=i(6),u=i(3),l=i(62),f=s.getWeak,d=Object.isExtensible,p=c.ufstore,m={},g=function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},_={get:function(e){if(h(e)){var t=f(e);return!0===t?p(l(this,"WeakMap")).get(e):t?t[this._i]:void 0}},set:function(e,t){return c.def(l(this,"WeakMap"),e,t)}},v=e.exports=i(83)("WeakMap",g,_,c,!0,!0);u(function(){return 7!=(new v).set((Object.freeze||Object)(m),7).get(m)})&&(a((r=c.getConstructor(g,"WeakMap")).prototype,_),s.NEED=!0,n(["delete","has","get","set"],function(e){var t=v.prototype,i=t[e];o(t,e,function(t,n){if(h(t)&&!d(t)){this._f||(this._f=new r);var o=this._f[e](t,n);return"set"==e?this:o}return i.call(this,t,n)})}))},function(e,t,i){"use strict";var r=i(162),n=i(62);i(83)("WeakSet",function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{add:function(e){return r.def(n(this,"WeakSet"),e,!0)}},r,!1,!0)},function(e,t,i){"use strict";var r=i(0),n=i(84),o=i(121),s=i(4),a=i(48),c=i(10),h=i(6),u=i(5).ArrayBuffer,l=i(67),f=o.ArrayBuffer,d=o.DataView,p=n.ABV&&u.isView,m=f.prototype.slice,g=n.VIEW;r(r.G+r.W+r.F*(u!==f),{ArrayBuffer:f}),r(r.S+r.F*!n.CONSTR,"ArrayBuffer",{isView:function(e){return p&&p(e)||h(e)&&g in e}}),r(r.P+r.U+r.F*i(3)(function(){return!new f(2).slice(1,void 0).byteLength}),"ArrayBuffer",{slice:function(e,t){if(void 0!==m&&void 0===t)return m.call(s(this),e);for(var i=s(this).byteLength,r=a(e,i),n=a(void 0===t?i:t,i),o=new(l(this,f))(c(n-r)),h=new d(this),u=new d(o),p=0;r<n;)u.setUint8(p++,h.getUint8(r++));return o}}),i(59)("ArrayBuffer")},function(e,t,i){var r=i(0);r(r.G+r.W+r.F*!i(84).ABV,{DataView:i(121).DataView})},function(e,t,i){i(38)("Int8",1,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){i(38)("Uint8",1,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){i(38)("Uint8",1,function(e){return function(t,i,r){return e(this,t,i,r)}},!0)},function(e,t,i){i(38)("Int16",2,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){i(38)("Uint16",2,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){i(38)("Int32",4,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){i(38)("Uint32",4,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){i(38)("Float32",4,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){i(38)("Float64",8,function(e){return function(t,i,r){return e(this,t,i,r)}})},function(e,t,i){var r=i(0),n=i(35),o=i(4),s=(i(5).Reflect||{}).apply,a=Function.apply;r(r.S+r.F*!i(3)(function(){s(function(){})}),"Reflect",{apply:function(e,t,i){var r=n(e),c=o(i);return s?s(r,t,c):a.call(r,t,c)}})},function(e,t,i){var r=i(0),n=i(49),o=i(35),s=i(4),a=i(6),c=i(3),h=i(144),u=(i(5).Reflect||{}).construct,l=c(function(){function e(){}return!(u(function(){},[],e)instanceof e)}),f=!c(function(){u(function(){})});r(r.S+r.F*(l||f),"Reflect",{construct:function(e,t){o(e),s(t);var i=arguments.length<3?e:o(arguments[2]);if(f&&!l)return u(e,t,i);if(e==i){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return r.push.apply(r,t),new(h.apply(e,r))}var c=i.prototype,d=n(a(c)?c:Object.prototype),p=Function.apply.call(e,d,t);return a(p)?p:d}})},function(e,t,i){var r=i(12),n=i(0),o=i(4),s=i(39);n(n.S+n.F*i(3)(function(){Reflect.defineProperty(r.f({},1,{value:1}),1,{value:2})}),"Reflect",{defineProperty:function(e,t,i){o(e),t=s(t,!0),o(i);try{return r.f(e,t,i),!0}catch(e){return!1}}})},function(e,t,i){var r=i(0),n=i(29).f,o=i(4);r(r.S,"Reflect",{deleteProperty:function(e,t){var i=n(o(e),t);return!(i&&!i.configurable)&&delete e[t]}})},function(e,t,i){"use strict";var r=i(0),n=i(4),o=function(e){this._t=n(e),this._i=0;var t,i=this._k=[];for(t in e)i.push(t)};i(151)(o,"Object",function(){var e,t=this._k;do{if(this._i>=t.length)return{value:void 0,done:!0}}while(!((e=t[this._i++])in this._t));return{value:e,done:!1}}),r(r.S,"Reflect",{enumerate:function(e){return new o(e)}})},function(e,t,i){var r=i(29),n=i(51),o=i(22),s=i(0),a=i(6),c=i(4);s(s.S,"Reflect",{get:function e(t,i){var s,h,u=arguments.length<3?t:arguments[2];return c(t)===u?t[i]:(s=r.f(t,i))?o(s,"value")?s.value:void 0!==s.get?s.get.call(u):void 0:a(h=n(t))?e(h,i,u):void 0}})},function(e,t,i){var r=i(29),n=i(0),o=i(4);n(n.S,"Reflect",{getOwnPropertyDescriptor:function(e,t){return r.f(o(e),t)}})},function(e,t,i){var r=i(0),n=i(51),o=i(4);r(r.S,"Reflect",{getPrototypeOf:function(e){return n(o(e))}})},function(e,t,i){var r=i(0);r(r.S,"Reflect",{has:function(e,t){return t in e}})},function(e,t,i){var r=i(0),n=i(4),o=Object.isExtensible;r(r.S,"Reflect",{isExtensible:function(e){return n(e),!o||o(e)}})},function(e,t,i){var r=i(0);r(r.S,"Reflect",{ownKeys:i(164)})},function(e,t,i){var r=i(0),n=i(4),o=Object.preventExtensions;r(r.S,"Reflect",{preventExtensions:function(e){n(e);try{return o&&o(e),!0}catch(e){return!1}}})},function(e,t,i){var r=i(12),n=i(29),o=i(51),s=i(22),a=i(0),c=i(44),h=i(4),u=i(6);a(a.S,"Reflect",{set:function e(t,i,a){var l,f,d=arguments.length<4?t:arguments[3],p=n.f(h(t),i);if(!p){if(u(f=o(t)))return e(f,i,a,d);p=c(0)}if(s(p,"value")){if(!1===p.writable||!u(d))return!1;if(l=n.f(d,i)){if(l.get||l.set||!1===l.writable)return!1;l.value=a,r.f(d,i,l)}else r.f(d,i,c(0,a));return!0}return void 0!==p.set&&(p.set.call(d,a),!0)}})},function(e,t,i){var r=i(0),n=i(102);n&&r(r.S,"Reflect",{setPrototypeOf:function(e,t){n.check(e,t);try{return n.set(e,t),!0}catch(e){return!1}}})},function(e,t,i){i(374),e.exports=i(14).Array.includes},function(e,t,i){"use strict";var r=i(0),n=i(74)(!0);r(r.P,"Array",{includes:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}}),i(58)("includes")},function(e,t,i){i(376),e.exports=i(14).String.padStart},function(e,t,i){"use strict";var r=i(0),n=i(165),o=i(82);r(r.P+r.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(o),"String",{padStart:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0,!0)}})},function(e,t,i){i(378),e.exports=i(14).String.padEnd},function(e,t,i){"use strict";var r=i(0),n=i(165),o=i(82);r(r.P+r.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(o),"String",{padEnd:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0,!1)}})},function(e,t,i){i(380),e.exports=i(97).f("asyncIterator")},function(e,t,i){i(138)("asyncIterator")},function(e,t,i){i(382),e.exports=i(14).Object.getOwnPropertyDescriptors},function(e,t,i){var r=i(0),n=i(164),o=i(24),s=i(29),a=i(114);r(r.S,"Object",{getOwnPropertyDescriptors:function(e){for(var t,i,r=o(e),c=s.f,h=n(r),u={},l=0;h.length>l;)void 0!==(i=c(r,t=h[l++]))&&a(u,t,i);return u}})},function(e,t,i){i(384),e.exports=i(14).Object.values},function(e,t,i){var r=i(0),n=i(166)(!1);r(r.S,"Object",{values:function(e){return n(e)}})},function(e,t,i){i(386),e.exports=i(14).Object.entries},function(e,t,i){var r=i(0),n=i(166)(!0);r(r.S,"Object",{entries:function(e){return n(e)}})},function(e,t,i){"use strict";i(158),i(388),e.exports=i(14).Promise.finally},function(e,t,i){"use strict";var r=i(0),n=i(14),o=i(5),s=i(67),a=i(160);r(r.P+r.R,"Promise",{finally:function(e){var t=s(this,n.Promise||o.Promise),i="function"==typeof e;return this.then(i?function(i){return a(t,e()).then(function(){return i})}:e,i?function(i){return a(t,e()).then(function(){throw i})}:e)}})},function(e,t,i){i(390),i(391),i(392),e.exports=i(14)},function(e,t,i){var r=i(5),n=i(0),o=i(82),s=[].slice,a=/MSIE .\./.test(o),c=function(e){return function(t,i){var r=arguments.length>2,n=!!r&&s.call(arguments,2);return e(r?function(){("function"==typeof t?t:Function(t)).apply(this,n)}:t,i)}};n(n.G+n.B+n.F*a,{setTimeout:c(r.setTimeout),setInterval:c(r.setInterval)})},function(e,t,i){var r=i(0),n=i(120);r(r.G+r.B,{setImmediate:n.set,clearImmediate:n.clear})},function(e,t,i){for(var r=i(117),n=i(47),o=i(19),s=i(5),a=i(23),c=i(57),h=i(8),u=h("iterator"),l=h("toStringTag"),f=c.Array,d={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},p=n(d),m=0;m<p.length;m++){var g,_=p[m],v=d[_],y=s[_],b=y&&y.prototype;if(b&&(b[u]||a(b,u,f),b[l]||a(b,l,_),c[_]=f,v))for(g in r)b[g]||o(b,g,r[g],!0)}},function(e,t,i){(function(e,t){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(r){"use strict";var n,o=Object.prototype,s=o.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",h=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag",l="object"===i(e),f=r.regeneratorRuntime;if(f)l&&(e.exports=f);else{(f=r.regeneratorRuntime=l?e.exports:{}).wrap=w;var d="suspendedStart",p="suspendedYield",m="executing",g="completed",_={},v={};v[c]=function(){return this};var y=Object.getPrototypeOf,b=y&&y(y(O([])));b&&b!==o&&s.call(b,c)&&(v=b);var x=M.prototype=T.prototype=Object.create(v);A.prototype=x.constructor=M,M.constructor=A,M[u]=A.displayName="GeneratorFunction",f.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===A||"GeneratorFunction"===(t.displayName||t.name))},f.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,M):(e.__proto__=M,u in e||(e[u]="GeneratorFunction")),e.prototype=Object.create(x),e},f.awrap=function(e){return{__await:e}},E(P.prototype),P.prototype[h]=function(){return this},f.AsyncIterator=P,f.async=function(e,t,i,r){var n=new P(w(e,t,i,r));return f.isGeneratorFunction(t)?n:n.next().then(function(e){return e.done?e.value:n.next()})},E(x),x[u]="Generator",x[c]=function(){return this},x.toString=function(){return"[object Generator]"},f.keys=function(e){var t=[];for(var i in e)t.push(i);return t.reverse(),function i(){for(;t.length;){var r=t.pop();if(r in e)return i.value=r,i.done=!1,i}return i.done=!0,i}},f.values=O,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},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 i(i,r){return a.type="throw",a.arg=e,t.next=i,r&&(t.method="next",t.arg=n),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),h=s.call(o,"finallyLoc");if(c&&h){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var n=r;break}}n&&("break"===e||"continue"===e)&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var o=n?n.completion:{};return o.type=e,o.arg=t,n?(this.method="next",this.next=n.finallyLoc,_):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),I(i),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;I(i)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,i){return this.delegate={iterator:O(e),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=n),_}}}function w(e,t,i,r){var n=t&&t.prototype instanceof T?t:T,o=Object.create(n.prototype),s=new D(r||[]);return o._invoke=function(e,t,i){var r=d;return function(n,o){if(r===m)throw new Error("Generator is already running");if(r===g){if("throw"===n)throw o;return L()}for(i.method=n,i.arg=o;;){var s=i.delegate;if(s){var a=C(s,i);if(a){if(a===_)continue;return a}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===d)throw r=g,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var c=S(e,t,i);if("normal"===c.type){if(r=i.done?g:p,c.arg===_)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=g,i.method="throw",i.arg=c.arg)}}}(e,i,s),o}function S(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}function T(){}function A(){}function M(){}function E(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function P(e){var r;this._invoke=function(n,o){function a(){return new t(function(r,a){!function r(n,o,a,c){var h=S(e[n],e,o);if("throw"!==h.type){var u=h.arg,l=u.value;return l&&"object"===i(l)&&s.call(l,"__await")?t.resolve(l.__await).then(function(e){r("next",e,a,c)},function(e){r("throw",e,a,c)}):t.resolve(l).then(function(e){u.value=e,a(u)},function(e){return r("throw",e,a,c)})}c(h.arg)}(n,o,r,a)})}return r=r?r.then(a,a):a()}}function C(e,t){var i=e.iterator[t.method];if(i===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,C(e,t),"throw"===t.method))return _;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var r=S(i,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,_;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,_):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,_)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function O(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,r=function t(){for(;++i<e.length;)if(s.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=n,t.done=!0,t};return r.next=r}}return{next:L}}function L(){return{value:n,done:!0}}}(function(){return this||"object"===("undefined"==typeof self?"undefined":i(self))&&self}()||Function("return this")())}).call(this,i(167)(e),i(52))},function(e,t,i){(function(r,n){var o,s,a;function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}
/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version 3.3.1
*/
/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version 3.3.1
*/
a=function(){"use strict";function e(e){return"function"==typeof e}var t=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=0,s=void 0,a=void 0,h=function(e,t){g[o]=e,g[o+1]=t,2===(o+=2)&&(a?a(_):w())},u="undefined"!=typeof window?window:void 0,l=u||{},f=l.MutationObserver||l.WebKitMutationObserver,d="undefined"==typeof self&&void 0!==r&&"[object process]"==={}.toString.call(r),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function m(){var e=setTimeout;return function(){return e(_,1)}}var g=new Array(1e3);function _(){for(var e=0;e<o;e+=2){(0,g[e])(g[e+1]),g[e]=void 0,g[e+1]=void 0}o=0}var v,y,b,x,w=void 0;function S(e,t){var i=arguments,r=this,n=new this.constructor(M);void 0===n[A]&&W(n);var o,s=r._state;return s?(o=i[s-1],h(function(){return U(s,n,o,r._result)})):k(r,n,e,t),n}function T(e){if(e&&"object"===c(e)&&e.constructor===this)return e;var t=new this(M);return O(t,e),t}d?w=function(){return r.nextTick(_)}:f?(y=0,b=new f(_),x=document.createTextNode(""),b.observe(x,{characterData:!0}),w=function(){x.data=y=++y%2}):p?((v=new MessageChannel).port1.onmessage=_,w=function(){return v.port2.postMessage(0)}):w=void 0===u?function(){try{var e=i(395);return s=e.runOnLoop||e.runOnContext,function(){s(_)}}catch(e){return m()}}():m();var A=Math.random().toString(36).substring(16);function M(){}var E=void 0,P=1,C=2,R=new N;function I(e){try{return e.then}catch(e){return R.error=e,R}}function D(t,i,r){i.constructor===t.constructor&&r===S&&i.constructor.resolve===T?function(e,t){t._state===P?F(e,t._result):t._state===C?B(e,t._result):k(t,void 0,function(t){return O(e,t)},function(t){return B(e,t)})}(t,i):r===R?B(t,R.error):void 0===r?F(t,i):e(r)?function(e,t,i){h(function(e){var r=!1,n=function(e,t,i,r){try{e.call(t,i,r)}catch(e){return e}}(i,t,function(i){r||(r=!0,t!==i?O(e,i):F(e,i))},function(t){r||(r=!0,B(e,t))},e._label);!r&&n&&(r=!0,B(e,n))},e)}(t,i,r):F(t,i)}function O(e,t){var i;e===t?B(e,new TypeError("You cannot resolve a promise with itself")):"function"==typeof(i=t)||"object"===c(i)&&null!==i?D(e,t,I(t)):F(e,t)}function L(e){e._onerror&&e._onerror(e._result),V(e)}function F(e,t){e._state===E&&(e._result=t,e._state=P,0!==e._subscribers.length&&h(V,e))}function B(e,t){e._state===E&&(e._state=C,e._result=t,h(L,e))}function k(e,t,i,r){var n=e._subscribers,o=n.length;e._onerror=null,n[o]=t,n[o+P]=i,n[o+C]=r,0===o&&e._state&&h(V,e)}function V(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var r=void 0,n=void 0,o=e._result,s=0;s<t.length;s+=3)r=t[s],n=t[s+i],r?U(i,r,n,o):n(o);e._subscribers.length=0}}function N(){this.error=null}var z=new N;function U(t,i,r,n){var o=e(r),s=void 0,a=void 0,c=void 0,h=void 0;if(o){if((s=function(e,t){try{return e(t)}catch(e){return z.error=e,z}}(r,n))===z?(h=!0,a=s.error,s=null):c=!0,i===s)return void B(i,new TypeError("A promises callback cannot return that same promise."))}else s=n,c=!0;i._state!==E||(o&&c?O(i,s):h?B(i,a):t===P?F(i,s):t===C&&B(i,s))}var G=0;function W(e){e[A]=G++,e._state=void 0,e._result=void 0,e._subscribers=[]}function j(e,i){this._instanceConstructor=e,this.promise=new e(M),this.promise[A]||W(this.promise),t(i)?(this._input=i,this.length=i.length,this._remaining=i.length,this._result=new Array(this.length),0===this.length?F(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&F(this.promise,this._result))):B(this.promise,new Error("Array Methods must be provided an Array"))}function H(e){this[A]=G++,this._result=this._state=void 0,this._subscribers=[],M!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof H?function(e,t){try{t(function(t){O(e,t)},function(t){B(e,t)})}catch(t){B(e,t)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}function X(){var e=void 0;if(void 0!==n)e=n;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var i=null;try{i=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===i&&!t.cast)return}e.Promise=H}return j.prototype._enumerate=function(){for(var e=this.length,t=this._input,i=0;this._state===E&&i<e;i++)this._eachEntry(t[i],i)},j.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,r=i.resolve;if(r===T){var n=I(e);if(n===S&&e._state!==E)this._settledAt(e._state,t,e._result);else if("function"!=typeof n)this._remaining--,this._result[t]=e;else if(i===H){var o=new i(M);D(o,e,n),this._willSettleAt(o,t)}else this._willSettleAt(new i(function(t){return t(e)}),t)}else this._willSettleAt(r(e),t)},j.prototype._settledAt=function(e,t,i){var r=this.promise;r._state===E&&(this._remaining--,e===C?B(r,i):this._result[t]=i),0===this._remaining&&F(r,this._result)},j.prototype._willSettleAt=function(e,t){var i=this;k(e,void 0,function(e){return i._settledAt(P,t,e)},function(e){return i._settledAt(C,t,e)})},H.all=function(e){return new j(this,e).promise},H.race=function(e){var i=this;return t(e)?new i(function(t,r){for(var n=e.length,o=0;o<n;o++)i.resolve(e[o]).then(t,r)}):new i(function(e,t){return t(new TypeError("You must pass an array to race."))})},H.resolve=T,H.reject=function(e){var t=new this(M);return B(t,e),t},H._setScheduler=function(e){a=e},H._setAsap=function(e){h=e},H._asap=h,H.prototype={constructor:H,then:S,catch:function(e){return this.then(null,e)}},X(),H.polyfill=X,H.Promise=H,H},"object"===c(t)&&void 0!==e?e.exports=a():void 0===(s="function"==typeof(o=a)?o.call(t,i,t,e):o)||(e.exports=s)}).call(this,i(27),i(15))},function(e,t){},function(e,t,i){},function(e,t){e.exports={backendBaseUrl:"https://9p1bb7fwdf.execute-api.us-east-1.amazonaws.com/prod"}},function(e,t,i){"use strict";t.byteLength=function(e){var t=h(e),i=t[0],r=t[1];return 3*(i+r)/4-r},t.toByteArray=function(e){for(var t,i=h(e),r=i[0],s=i[1],a=new o(function(e,t,i){return 3*(t+i)/4-i}(0,r,s)),c=0,u=s>0?r-4:r,l=0;l<u;l+=4)t=n[e.charCodeAt(l)]<<18|n[e.charCodeAt(l+1)]<<12|n[e.charCodeAt(l+2)]<<6|n[e.charCodeAt(l+3)],a[c++]=t>>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===s&&(t=n[e.charCodeAt(l)]<<2|n[e.charCodeAt(l+1)]>>4,a[c++]=255&t);1===s&&(t=n[e.charCodeAt(l)]<<10|n[e.charCodeAt(l+1)]<<4|n[e.charCodeAt(l+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},t.fromByteArray=function(e){for(var t,i=e.length,n=i%3,o=[],s=0,a=i-n;s<a;s+=16383)o.push(u(e,s,s+16383>a?a:s+16383));1===n?(t=e[i-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[i-2]<<8)+e[i-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],n[s.charCodeAt(a)]=a;function h(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function u(e,t,i){for(var n,o,s=[],a=t;a<i;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=n)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,i,r,n){var o,s,a=8*n-r-1,c=(1<<a)-1,h=c>>1,u=-7,l=i?n-1:0,f=i?-1:1,d=e[t+l];for(l+=f,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+l],l+=f,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+e[t+l],l+=f,u-=8);if(0===o)o=1-h;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=h}return(d?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,i,r,n,o){var s,a,c,h=8*o-n-1,u=(1<<h)-1,l=u>>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=u?(a=0,s=u):s+l>=1?(a=(t*c-1)*Math.pow(2,n),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,n),s=0));n>=8;e[i+d]=255&a,d+=p,a/=256,n-=8);for(s=s<<n|a,h+=n;h>0;e[i+d]=255&s,d+=p,s/=256,h-=8);e[i+d-p]|=128*m}},function(e,t,i){(function(r){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})(e)}t.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":n(console))&&console.log&&(e=console).log.apply(e,arguments)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;var i="color: "+this.color;t.splice(1,0,i,"color: inherit");var r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(n=r))}),t.splice(n,0,i)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=i(401)(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,i(27))},function(e,t,i){function r(e){return function(e){if(Array.isArray(e)){for(var t=0,i=new Array(e.length);t<e.length;t++)i[t]=e[t];return i}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}e.exports=function(e){function t(e){for(var t=0,i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){var i;function r(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(r.enabled){var s=r,a=Number(new Date),c=a-(i||a);s.diff=c,s.prev=i,s.curr=a,i=a,t[0]=n.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var h=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,function(e,i){if("%%"===e)return e;h++;var r=n.formatters[i];if("function"==typeof r){var o=t[h];e=r.call(s,o),t.splice(h,1),h--}return e}),n.formatArgs.call(s,t),(s.log||n.log).apply(s,t)}}return r.namespace=e,r.enabled=n.enabled(e),r.useColors=n.useColors(),r.color=t(e),r.destroy=o,r.extend=s,"function"==typeof n.init&&n.init(r),n.instances.push(r),r}function o(){var e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function s(e,t){var i=n(this.namespace+(void 0===t?":":t)+e);return i.log=this.log,i}function a(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){var e=r(n.names.map(a)).concat(r(n.skips.map(a).map(function(e){return"-"+e}))).join(",");return n.enable(""),e},n.enable=function(e){var t;n.save(e),n.names=[],n.skips=[];var i=("string"==typeof e?e:"").split(/[\s,]+/),r=i.length;for(t=0;t<r;t++)i[t]&&("-"===(e=i[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){var o=n.instances[t];o.enabled=n.enabled(o.namespace)}},n.enabled=function(e){if("*"===e[e.length-1])return!0;var t,i;for(t=0,i=n.skips.length;t<i;t++)if(n.skips[t].test(e))return!1;for(t=0,i=n.names.length;t<i;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=i(402),Object.keys(e).forEach(function(t){n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r=1e3,n=60*r,o=60*n,s=24*o,a=7*s,c=365.25*s;function h(e,t,i,r){var n=t>=1.5*i;return Math.round(e/i)+" "+r+(n?"s":"")}e.exports=function(e,t){t=t||{};var u=i(e);if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var i=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*c;case"weeks":case"week":case"w":return i*a;case"days":case"day":case"d":return i*s;case"hours":case"hour":case"hrs":case"hr":case"h":return i*o;case"minutes":case"minute":case"mins":case"min":case"m":return i*n;case"seconds":case"second":case"secs":case"sec":case"s":return i*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);if(t>=s)return h(e,t,s,"day");if(t>=o)return h(e,t,o,"hour");if(t>=n)return h(e,t,n,"minute");if(t>=r)return h(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=s)return Math.round(e/s)+"d";if(t>=o)return Math.round(e/o)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t){e.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},function(e,t){},function(e,t,i){"use strict";var r=i(2).Buffer,n=i(406);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,i=""+t.data;t=t.next;)i+=e+t.data;return i},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,i,n,o=r.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,i=o,n=a,t.copy(i,n),a+=s.data.length,s=s.next;return o},e}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,i){(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,n=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(n.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new o(n.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},i(408),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,i(15))},function(e,t,i){(function(e,t){!function(e,i){"use strict";if(!e.setImmediate){var r,n,o,s,a,c=1,h={},u=!1,l=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){p(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,i=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=i,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},r=function(e){o.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(n=l.documentElement,r=function(e){var t=l.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.appendChild(t)}):r=function(e){setTimeout(p,0,e)}:(s="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&p(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),r=function(t){e.postMessage(s+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),i=0;i<t.length;i++)t[i]=arguments[i+1];var n={callback:e,args:t};return h[c]=n,r(c),c++},f.clearImmediate=d}function d(e){delete h[e]}function p(e){if(u)setTimeout(p,0,e);else{var t=h[e];if(t){u=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(i,r)}}(t)}finally{d(e),u=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,i(15),i(27))},function(e,t,i){(function(t){function i(e){try{if(!t.localStorage)return!1}catch(e){return!1}var i=t.localStorage[e];return null!=i&&"true"===String(i).toLowerCase()}e.exports=function(e,t){if(i("noDeprecation"))return e;var r=!1;return function(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,i(15))},function(e,t,i){"use strict";e.exports=o;var r=i(172),n=i(68);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}n.inherits=i(1),n.inherits(o,r),o.prototype._transform=function(e,t,i){i(null,e)}},function(e,t){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r,n,o,s,a=this&&this.__decorate||function(e,t,r,n){var o,s=arguments.length,a=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==("undefined"==typeof Reflect?"undefined":i(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(s<3?o(a):s>3?o(t,r,a):o(t,r))||a);return s>3&&a&&Object.defineProperty(t,r,a),a},c=this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);i.prototype=t.prototype,e.prototype=new i};!function(e){e.ToGammaSpace=1/2.2,e.ToLinearSpace=2.2,e.Epsilon=.001;var t=function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1.401298e-45);var r=e-t;return-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return 0===(e=+e)||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e}();e.MathTools=t;var i=function(){function i(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return i.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},i.prototype.getClassName=function(){return"Color3"},i.prototype.getHashCode=function(){var e=this.r||0;return 397*(e=397*e^(this.g||0))^(this.b||0)},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},i.prototype.toColor4=function(e){return void 0===e&&(e=1),new r(this.r,this.g,this.b,e)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},i.prototype.multiply=function(e){return new i(this.r*e.r,this.g*e.g,this.b*e.b)},i.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},i.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},i.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},i.prototype.scale=function(e){return new i(this.r*e,this.g*e,this.b*e)},i.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},i.prototype.add=function(e){return new i(this.r+e.r,this.g+e.g,this.b+e.b)},i.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},i.prototype.subtract=function(e){return new i(this.r-e.r,this.g-e.g,this.b-e.b)},i.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},i.prototype.clone=function(){return new i(this.r,this.g,this.b)},i.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},i.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},i.prototype.toHexString=function(){var e=255*this.r|0,i=255*this.g|0,r=255*this.b|0;return"#"+t.ToHex(e)+t.ToHex(i)+t.ToHex(r)},i.prototype.toLinearSpace=function(){var e=new i;return this.toLinearSpaceToRef(e),e},i.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToLinearSpace),t.g=Math.pow(this.g,e.ToLinearSpace),t.b=Math.pow(this.b,e.ToLinearSpace),this},i.prototype.toGammaSpace=function(){var e=new i;return this.toGammaSpaceToRef(e),e},i.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToGammaSpace),t.g=Math.pow(this.g,e.ToGammaSpace),t.b=Math.pow(this.b,e.ToGammaSpace),this},i.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new i(0,0,0);var t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return i.FromInts(t,r,n)},i.FromArray=function(e,t){return void 0===t&&(t=0),new i(e[t],e[t+1],e[t+2])},i.FromInts=function(e,t,r){return new i(e/255,t/255,r/255)},i.Lerp=function(e,t,r){return new i(e.r+(t.r-e.r)*r,e.g+(t.g-e.g)*r,e.b+(t.b-e.b)*r)},i.Red=function(){return new i(1,0,0)},i.Green=function(){return new i(0,1,0)},i.Blue=function(){return new i(0,0,1)},i.Black=function(){return new i(0,0,0)},i.White=function(){return new i(1,1,1)},i.Purple=function(){return new i(.5,0,.5)},i.Magenta=function(){return new i(1,0,1)},i.Yellow=function(){return new i(1,1,0)},i.Gray=function(){return new i(.5,.5,.5)},i}();e.Color3=i;var r=function(){function e(e,t,i,r){this.r=e,this.g=t,this.b=i,this.a=r}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=this.r||0;return 397*(e=397*(e=397*e^(this.g||0))^(this.b||0))^(this.a||0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.toHexString=function(){var e=255*this.r|0,i=255*this.g|0,r=255*this.b|0,n=255*this.a|0;return"#"+t.ToHex(e)+t.ToHex(i)+t.ToHex(r)+t.ToHex(n)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(i,r,n,o)},e.Lerp=function(t,i,r){var n=new e(0,0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromInts=function(t,i,r,n){return new e(t/255,i/255,r/255,n/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],r=0;r<e.length;r+=3){var n=r/3*4;i[n]=e[r],i[n+1]=e[r+1],i[n+2]=e[r+2],i[n+3]=1}return i}return e},e}();e.Color4=r;var n=function(){function i(e,t){this.x=e,this.y=t}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},i.prototype.getClassName=function(){return"Vector2"},i.prototype.getHashCode=function(){var e=this.x||0;return 397*e^(this.y||0)},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},i.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},i.prototype.addVector3=function(e){return new i(this.x+e.x,this.y+e.y)},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},i.prototype.multiplyByFloats=function(e,t){return new i(this.x*e,this.y*t)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},i.prototype.negate=function(){return new i(-this.x,-this.y)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e)},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},i.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},i.prototype.clone=function(){return new i(this.x,this.y)},i.Zero=function(){return new i(0,0)},i.FromArray=function(e,t){return void 0===t&&(t=0),new i(e[t],e[t+1])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},i.CatmullRom=function(e,t,r,n,o){var s=o*o,a=o*s;return new i(.5*(2*t.x+(-e.x+r.x)*o+(2*e.x-5*t.x+4*r.x-n.x)*s+(-e.x+3*t.x-3*r.x+n.x)*a),.5*(2*t.y+(-e.y+r.y)*o+(2*e.y-5*t.y+4*r.y-n.y)*s+(-e.y+3*t.y-3*r.y+n.y)*a))},i.Clamp=function(e,t,r){var n=e.x;n=(n=n>r.x?r.x:n)<t.x?t.x:n;var o=e.y;return new i(n,o=(o=o>r.y?r.y:o)<t.y?t.y:o)},i.Hermite=function(e,t,r,n,o){var s=o*o,a=o*s,c=2*a-3*s+1,h=-2*a+3*s,u=a-2*s+o,l=a-s;return new i(e.x*c+r.x*h+t.x*u+n.x*l,e.y*c+r.y*h+t.y*u+n.y*l)},i.Lerp=function(e,t,r){return new i(e.x+(t.x-e.x)*r,e.y+(t.y-e.y)*r)},i.Dot=function(e,t){return e.x*t.x+e.y*t.y},i.Normalize=function(e){var t=e.clone();return t.normalize(),t},i.Minimize=function(e,t){return new i(e.x<t.x?e.x:t.x,e.y<t.y?e.y:t.y)},i.Maximize=function(e,t){return new i(e.x>t.x?e.x:t.x,e.y>t.y?e.y:t.y)},i.Transform=function(e,t){var r=i.Zero();return i.TransformToRef(e,t,r),r},i.TransformToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+t.m[13];i.x=r,i.y=n},i.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=n<0?-1:1,s=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return s>0&&a>0&&s+a<2*n*o},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i.DistanceOfPointFromSegment=function(e,t,r){var n=i.DistanceSquared(t,r);if(0===n)return i.Distance(e,t);var o=r.subtract(t),s=Math.max(0,Math.min(1,i.Dot(e.subtract(t),o)/n)),a=t.add(o.multiplyByFloats(s,s));return i.Distance(e,a)},i}();e.Vector2=n;var o=function(){function i(e,t,i){this.x=e,this.y=t,this.z=i}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},i.prototype.getClassName=function(){return"Vector3"},i.prototype.getHashCode=function(){var e=this.x||0;return 397*(e=397*e^(this.y||0))^(this.z||0)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},i.prototype.toQuaternion=function(){var e=new c(0,0,0,1),t=Math.cos(.5*(this.x+this.z)),i=Math.sin(.5*(this.x+this.z)),r=Math.cos(.5*(this.z-this.x)),n=Math.sin(.5*(this.z-this.x)),o=Math.cos(.5*this.y),s=Math.sin(.5*this.y);return e.x=r*s,e.y=-n*s,e.z=i*o,e.w=t*o,e},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y,this.z+e.z)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y,this.z-e.z)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,this},i.prototype.subtractFromFloats=function(e,t,r){return new i(this.x-e,this.y-t,this.z-r)},i.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e,this.z*e)},i.prototype.scaleToRef=function(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)&&t.WithinEpsilon(this.z,i.z,r)},i.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y,this.z*e.z)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,this},i.prototype.multiplyByFloats=function(e,t,r){return new i(this.x*e,this.y*t,this.z*r)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y,this.z/e.z)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,this},i.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this},i.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},i.prototype.normalize=function(){var e=this.length();if(0===e||1===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this},i.prototype.clone=function(){return new i(this.x,this.y,this.z)},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},i.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},i.GetClipFactor=function(e,t,r,n){var o=i.Dot(e,r)-n;return o/(o-(i.Dot(t,r)-n))},i.FromArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2])},i.FromFloatArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},i.FromFloatArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},i.FromFloatsToRef=function(e,t,i,r){r.x=e,r.y=t,r.z=i},i.Zero=function(){return new i(0,0,0)},i.Up=function(){return new i(0,1,0)},i.Forward=function(){return new i(0,0,1)},i.Right=function(){return new i(1,0,0)},i.Left=function(){return new i(-1,0,0)},i.TransformCoordinates=function(e,t){var r=i.Zero();return i.TransformCoordinatesToRef(e,t,r),r},i.TransformCoordinatesToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9]+t.m[13],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]+t.m[14],s=e.x*t.m[3]+e.y*t.m[7]+e.z*t.m[11]+t.m[15];i.x=r/s,i.y=n/s,i.z=o/s},i.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=e*r.m[0]+t*r.m[4]+i*r.m[8]+r.m[12],s=e*r.m[1]+t*r.m[5]+i*r.m[9]+r.m[13],a=e*r.m[2]+t*r.m[6]+i*r.m[10]+r.m[14],c=e*r.m[3]+t*r.m[7]+i*r.m[11]+r.m[15];n.x=o/c,n.y=s/c,n.z=a/c},i.TransformNormal=function(e,t){var r=i.Zero();return i.TransformNormalToRef(e,t,r),r},i.TransformNormalToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o},i.TransformNormalFromFloatsToRef=function(e,t,i,r,n){n.x=e*r.m[0]+t*r.m[4]+i*r.m[8],n.y=e*r.m[1]+t*r.m[5]+i*r.m[9],n.z=e*r.m[2]+t*r.m[6]+i*r.m[10]},i.CatmullRom=function(e,t,r,n,o){var s=o*o,a=o*s;return new i(.5*(2*t.x+(-e.x+r.x)*o+(2*e.x-5*t.x+4*r.x-n.x)*s+(-e.x+3*t.x-3*r.x+n.x)*a),.5*(2*t.y+(-e.y+r.y)*o+(2*e.y-5*t.y+4*r.y-n.y)*s+(-e.y+3*t.y-3*r.y+n.y)*a),.5*(2*t.z+(-e.z+r.z)*o+(2*e.z-5*t.z+4*r.z-n.z)*s+(-e.z+3*t.z-3*r.z+n.z)*a))},i.Clamp=function(e,t,r){var n=e.x;n=(n=n>r.x?r.x:n)<t.x?t.x:n;var o=e.y;o=(o=o>r.y?r.y:o)<t.y?t.y:o;var s=e.z;return new i(n,o,s=(s=s>r.z?r.z:s)<t.z?t.z:s)},i.Hermite=function(e,t,r,n,o){var s=o*o,a=o*s,c=2*a-3*s+1,h=-2*a+3*s,u=a-2*s+o,l=a-s;return new i(e.x*c+r.x*h+t.x*u+n.x*l,e.y*c+r.y*h+t.y*u+n.y*l,e.z*c+r.z*h+t.z*u+n.z*l)},i.Lerp=function(e,t,r){return new i(e.x+(t.x-e.x)*r,e.y+(t.y-e.y)*r,e.z+(t.z-e.z)*r)},i.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},i.Cross=function(e,t){var r=i.Zero();return i.CrossToRef(e,t,r),r},i.CrossToRef=function(e,t,i){A.Vector3[0].x=e.y*t.z-e.z*t.y,A.Vector3[0].y=e.z*t.x-e.x*t.z,A.Vector3[0].z=e.x*t.y-e.y*t.x,i.copyFrom(A.Vector3[0])},i.Normalize=function(e){var t=i.Zero();return i.NormalizeToRef(e,t),t},i.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},i.Project=function(e,t,r,n){var o=n.width,s=n.height,a=n.x,c=n.y,u=i._viewportMatrixCache?i._viewportMatrixCache:i._viewportMatrixCache=new h;h.FromValuesToRef(o/2,0,0,0,0,-s/2,0,0,0,0,1,0,a+o/2,s/2+c,0,1,u);var l=i._matrixCache?i._matrixCache:i._matrixCache=new h;return t.multiplyToRef(r,l),l.multiplyToRef(u,l),i.TransformCoordinates(e,l)},i.UnprojectFromTransform=function(e,r,n,o,s){var a=i._matrixCache?i._matrixCache:i._matrixCache=new h;o.multiplyToRef(s,a),a.invert(),e.x=e.x/r*2-1,e.y=-(e.y/n*2-1);var c=i.TransformCoordinates(e,a),u=e.x*a.m[3]+e.y*a.m[7]+e.z*a.m[11]+a.m[15];return t.WithinEpsilon(u,1)&&(c=c.scale(1/u)),c},i.Unproject=function(e,r,n,o,s,a){var c=i._matrixCache?i._matrixCache:i._matrixCache=new h;o.multiplyToRef(s,c),c.multiplyToRef(a,c),c.invert();var u=new i(e.x/r*2-1,-(e.y/n*2-1),e.z),l=i.TransformCoordinates(u,c),f=u.x*c.m[3]+u.y*c.m[7]+u.z*c.m[11]+c.m[15];return t.WithinEpsilon(f,1)&&(l=l.scale(1/f)),l},i.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},i.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z;return i*i+r*r+n*n},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i.RotationFromAxis=function(e,t,r){var n=i.Zero();return i.RotationFromAxisToRef(e,t,r,n),n},i.RotationFromAxisToRef=function(r,n,o,s){var a=r.normalize(),c=o.normalize(),h=d.X,u=d.Y,l=0,f=0,p=0,m=0,g=0,_=0,v=0,y=-1,b=0,x=A.Vector3[0],w=0,S=A.Vector3[1];t.WithinEpsilon(c.z,0,e.Epsilon)?_=1:t.WithinEpsilon(c.x,0,e.Epsilon)?m=1:(m=-(v=c.z/c.x)*Math.sqrt(1/(1+v*v)),_=Math.sqrt(1/(1+v*v))),S.x=m,S.y=g,S.z=_,S.normalize(),i.CrossToRef(a,S,x),x.normalize(),i.Dot(c,x)<0&&(y=1),w=i.Dot(a,S),w=Math.min(1,Math.max(-1,w)),p=Math.acos(w)*y,i.Dot(S,h)<0&&(p=Math.PI+p,S=S.scaleInPlace(-1),b++);var T=A.Vector3[2],M=A.Vector3[3];m=0,g=0,_=0,y=-1,t.WithinEpsilon(c.z,0,e.Epsilon)?m=1:(m=-(v=S.z/S.x)*Math.sqrt(1/(1+v*v)),_=Math.sqrt(1/(1+v*v))),T.x=m,T.y=g,T.z=_,T.normalize(),i.CrossToRef(T,S,M),M.normalize(),i.CrossToRef(c,T,x),x.normalize(),i.Dot(S,x)<0&&(y=1),w=i.Dot(c,T),w=Math.min(1,Math.max(-1,w)),f=Math.acos(w)*y,i.Dot(M,u)<0&&(f=Math.PI+f,b++),y=-1,i.CrossToRef(h,S,x),x.normalize(),i.Dot(x,u)<0&&(y=1),w=i.Dot(S,h),w=Math.min(1,Math.max(-1,w)),l=-Math.acos(w)*y,w<0&&b<2&&(l=Math.PI+l),s.x=f,s.y=l,s.z=p},i}();e.Vector3=o;var s=function(){function i(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},i.prototype.getClassName=function(){return"Vector4"},i.prototype.getHashCode=function(){var e=this.x||0;return 397*(e=397*(e=397*e^(this.y||0))^(this.z||0))^(this.w||0)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,this},i.prototype.subtractFromFloats=function(e,t,r,n){return new i(this.x-e,this.y-t,this.z-r,this.w-n)},i.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-i,n.w=this.w-r,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z,-this.w)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e,this.z*e,this.w*e)},i.prototype.scaleToRef=function(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)&&t.WithinEpsilon(this.z,i.z,r)&&t.WithinEpsilon(this.w,i.w,r)},i.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,this},i.prototype.multiplyByFloats=function(e,t,r,n){return new i(this.x*e,this.y*t,this.z*r,this.w*n)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,this},i.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this},i.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},i.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.prototype.toVector3=function(){return new o(this.x,this.y,this.z)},i.prototype.clone=function(){return new i(this.x,this.y,this.z,this.w)},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},i.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},i.FromArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2],e[t+3])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},i.FromFloatArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},i.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},i.Zero=function(){return new i(0,0,0,0)},i.Normalize=function(e){var t=i.Zero();return i.NormalizeToRef(e,t),t},i.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},i.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},i.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i}();e.Vector4=s;var a=function(){function e(e,t){this.width=e,this.height=t}return e.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},e.prototype.getClassName=function(){return"Size"},e.prototype.getHashCode=function(){var e=this.width||0;return 397*e^(this.height||0)},e.prototype.copyFrom=function(e){this.width=e.width,this.height=e.height},e.prototype.copyFromFloats=function(e,t){this.width=e,this.height=t},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},e.prototype.clone=function(){return new e(this.width,this.height)},e.prototype.equals=function(e){return!!e&&this.width===e.width&&this.height===e.height},Object.defineProperty(e.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),e.Zero=function(){return new e(0,0)},e.prototype.add=function(t){return new e(this.width+t.width,this.height+t.height)},e.prototype.substract=function(t){return new e(this.width-t.width,this.height-t.height)},e.Lerp=function(t,i,r){return new e(t.width+(i.width-t.width)*r,t.height+(i.height-t.height)*r)},e}();e.Size=a;var c=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=this.x||0;return 397*(e=397*(e=397*e^(this.y||0))^(this.z||0))^(this.w||0)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){return new e(-this.x,-this.y,-this.z,this.w)},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.normalize=function(){var e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=o.Zero();return this.toEulerAnglesToRef(t,e),t},e.prototype.toEulerAnglesToRef=function(e,t){void 0===t&&(t="YZX");var i=this.z,r=this.x,n=this.y,o=this.w,s=o*o,a=i*i,c=r*r,h=n*n,u=n*i-r*o,l=.4999999;return u<-l?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):u>l?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*o),-a-c+h+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-c-h+s)),this},e.prototype.toRotationMatrix=function(e){var t=this.x*this.x,i=this.y*this.y,r=this.z*this.z,n=this.x*this.y,o=this.z*this.w,s=this.z*this.x,a=this.y*this.w,c=this.y*this.z,h=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+o),e.m[2]=2*(s-a),e.m[3]=0,e.m[4]=2*(n-o),e.m[5]=1-2*(r+t),e.m[6]=2*(c+h),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(c-h),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],c=r[5],h=r[9],u=r[2],l=r[6],f=r[10],d=n+c+f;d>0?(i=.5/Math.sqrt(d+1),t.w=.25/i,t.x=(l-h)*i,t.y=(s-u)*i,t.z=(a-o)*i):n>c&&n>f?(i=2*Math.sqrt(1+n-c-f),t.w=(l-h)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+u)/i):c>f?(i=2*Math.sqrt(1+c-n-f),t.w=(s-u)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(h+l)/i):(i=2*Math.sqrt(1+f-n-c),t.w=(a-o)/i,t.x=(s+u)/i,t.y=(h+l)/i,t.z=.25*i)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.Identity=function(){return new e(0,0,0,1)},e.RotationAxis=function(t,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),c=Math.cos(n),h=Math.sin(o),u=Math.cos(o),l=Math.sin(s),f=Math.cos(s);r.x=f*h*c+l*u*a,r.y=l*u*c-f*h*a,r.z=f*u*a-l*h*c,r.w=f*u*c+l*h*a},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},e.Slerp=function(t,i,r){var n=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=i,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,c=!1;if(a<0&&(c=!0,a=-a),a>.999999)o=1-s,n=c?-s:s;else{var h=Math.acos(a),u=1/Math.sin(h);o=Math.sin((1-s)*h)*u,n=c?-Math.sin(s*h)*u:Math.sin(s*h)*u}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e}();e.Quaternion=c;var h=function(){function e(){this.m=new Float32Array(16)}return e.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14]},e.prototype.determinant=function(){var e=this.m[10]*this.m[15]-this.m[11]*this.m[14],t=this.m[9]*this.m[15]-this.m[11]*this.m[13],i=this.m[9]*this.m[14]-this.m[10]*this.m[13],r=this.m[8]*this.m[15]-this.m[11]*this.m[12],n=this.m[8]*this.m[14]-this.m[10]*this.m[12],o=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*e-this.m[6]*t+this.m[7]*i)-this.m[1]*(this.m[4]*e-this.m[6]*r+this.m[7]*n)+this.m[2]*(this.m[4]*t-this.m[5]*r+this.m[7]*o)-this.m[3]*(this.m[4]*i-this.m[5]*n+this.m[6]*o)},e.prototype.toArray=function(){return this.m},e.prototype.asArray=function(){return this.toArray()},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this},e.prototype.add=function(t){var i=new e;return this.addToRef(t,i),i},e.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return this},e.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this},e.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.m[6],c=this.m[7],h=this.m[8],u=this.m[9],l=this.m[10],f=this.m[11],d=this.m[12],p=this.m[13],m=this.m[14],g=this.m[15],_=l*g-f*m,v=u*g-f*p,y=u*m-l*p,b=h*g-f*d,x=h*m-l*d,w=h*p-u*d,S=s*_-a*v+c*y,T=-(o*_-a*b+c*x),A=o*v-s*b+c*w,M=-(o*y-s*x+a*w),E=1/(t*S+i*T+r*A+n*M),P=a*g-c*m,C=s*g-c*p,R=s*m-a*p,I=o*g-c*d,D=o*m-a*d,O=o*p-s*d,L=a*f-c*l,F=s*f-c*u,B=s*l-a*u,k=o*f-c*h,V=o*l-a*h,N=o*u-s*h;return e.m[0]=S*E,e.m[4]=T*E,e.m[8]=A*E,e.m[12]=M*E,e.m[1]=-(i*_-r*v+n*y)*E,e.m[5]=(t*_-r*b+n*x)*E,e.m[9]=-(t*v-i*b+n*w)*E,e.m[13]=(t*y-i*x+r*w)*E,e.m[2]=(i*P-r*C+n*R)*E,e.m[6]=-(t*P-r*I+n*D)*E,e.m[10]=(t*C-i*I+n*O)*E,e.m[14]=-(t*R-i*D+r*O)*E,e.m[3]=-(i*L-r*F+n*B)*E,e.m[7]=(t*L-r*k+n*V)*E,e.m[11]=-(t*F-i*k+n*N)*E,e.m[15]=(t*B-i*V+r*N)*E,this},e.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this},e.prototype.getTranslation=function(){return new o(this.m[12],this.m[13],this.m[14])},e.prototype.multiply=function(t){var i=new e;return this.multiplyToRef(t,i),i},e.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},e.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),this},e.prototype.multiplyToArray=function(e,t,i){var r=this.m[0],n=this.m[1],o=this.m[2],s=this.m[3],a=this.m[4],c=this.m[5],h=this.m[6],u=this.m[7],l=this.m[8],f=this.m[9],d=this.m[10],p=this.m[11],m=this.m[12],g=this.m[13],_=this.m[14],v=this.m[15],y=e.m[0],b=e.m[1],x=e.m[2],w=e.m[3],S=e.m[4],T=e.m[5],A=e.m[6],M=e.m[7],E=e.m[8],P=e.m[9],C=e.m[10],R=e.m[11],I=e.m[12],D=e.m[13],O=e.m[14],L=e.m[15];return t[i]=r*y+n*S+o*E+s*I,t[i+1]=r*b+n*T+o*P+s*D,t[i+2]=r*x+n*A+o*C+s*O,t[i+3]=r*w+n*M+o*R+s*L,t[i+4]=a*y+c*S+h*E+u*I,t[i+5]=a*b+c*T+h*P+u*D,t[i+6]=a*x+c*A+h*C+u*O,t[i+7]=a*w+c*M+h*R+u*L,t[i+8]=l*y+f*S+d*E+p*I,t[i+9]=l*b+f*T+d*P+p*D,t[i+10]=l*x+f*A+d*C+p*O,t[i+11]=l*w+f*M+d*R+p*L,t[i+12]=m*y+g*S+_*E+v*I,t[i+13]=m*b+g*T+_*P+v*D,t[i+14]=m*x+g*A+_*C+v*O,t[i+15]=m*w+g*M+_*R+v*L,this},e.prototype.equals=function(e){return e&&this.m[0]===e.m[0]&&this.m[1]===e.m[1]&&this.m[2]===e.m[2]&&this.m[3]===e.m[3]&&this.m[4]===e.m[4]&&this.m[5]===e.m[5]&&this.m[6]===e.m[6]&&this.m[7]===e.m[7]&&this.m[8]===e.m[8]&&this.m[9]===e.m[9]&&this.m[10]===e.m[10]&&this.m[11]===e.m[11]&&this.m[12]===e.m[12]&&this.m[13]===e.m[13]&&this.m[14]===e.m[14]&&this.m[15]===e.m[15]},e.prototype.clone=function(){return e.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},e.prototype.decompose=function(i,r,n){n.x=this.m[12],n.y=this.m[13],n.z=this.m[14];var o=t.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,s=t.Sign(this.m[4]*this.m[5]*this.m[6]*this.m[7])<0?-1:1,a=t.Sign(this.m[8]*this.m[9]*this.m[10]*this.m[11])<0?-1:1;return i.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),i.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),i.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===i.x||0===i.y||0===i.z?(r.x=0,r.y=0,r.z=0,r.w=1,!1):(e.FromValuesToRef(this.m[0]/i.x,this.m[1]/i.x,this.m[2]/i.x,0,this.m[4]/i.y,this.m[5]/i.y,this.m[6]/i.y,0,this.m[8]/i.z,this.m[9]/i.z,this.m[10]/i.z,0,0,0,0,1,A.Matrix[0]),c.FromRotationMatrixToRef(A.Matrix[0],r),!0)},e.prototype.getRotationMatrix=function(){var t=e.Identity();return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var i=this.m,r=i[0]*i[1]*i[2]*i[3]<0?-1:1,n=i[4]*i[5]*i[6]*i[7]<0?-1:1,o=i[8]*i[9]*i[10]*i[11]<0?-1:1,s=r*Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),a=n*Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),c=o*Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]);e.FromValuesToRef(i[0]/s,i[1]/s,i[2]/s,0,i[4]/a,i[5]/a,i[6]/a,0,i[8]/c,i[9]/c,i[10]/c,0,0,0,0,1,t)},e.FromArray=function(t,i){var r=new e;return i||(i=0),e.FromArrayToRef(t,i,r),r},e.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t]},e.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i},e.FromValuesToRef=function(e,t,i,r,n,o,s,a,c,h,u,l,f,d,p,m,g){g.m[0]=e,g.m[1]=t,g.m[2]=i,g.m[3]=r,g.m[4]=n,g.m[5]=o,g.m[6]=s,g.m[7]=a,g.m[8]=c,g.m[9]=h,g.m[10]=u,g.m[11]=l,g.m[12]=f,g.m[13]=d,g.m[14]=p,g.m[15]=m},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new s(this.m[t+0],this.m[t+1],this.m[t+2],this.m[t+3])},e.prototype.setRow=function(e,t){if(e<0||e>3)return this;var i=4*e;return this.m[i+0]=t.x,this.m[i+1]=t.y,this.m[i+2]=t.z,this.m[i+3]=t.w,this},e.FromValues=function(t,i,r,n,o,s,a,c,h,u,l,f,d,p,m,g){var _=new e;return _.m[0]=t,_.m[1]=i,_.m[2]=r,_.m[3]=n,_.m[4]=o,_.m[5]=s,_.m[6]=a,_.m[7]=c,_.m[8]=h,_.m[9]=u,_.m[10]=l,_.m[11]=f,_.m[12]=d,_.m[13]=p,_.m[14]=m,_.m[15]=g,_},e.Compose=function(t,i,r){var n=e.FromValues(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1),o=e.Identity();return i.toRotationMatrix(o),(n=n.multiply(o)).setTranslation(r),n},e.Identity=function(){return e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t)},e.Zero=function(){return e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},e.RotationX=function(t){var i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[0]=1,t.m[15]=1,t.m[5]=r,t.m[10]=r,t.m[9]=-i,t.m[6]=i,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[7]=0,t.m[8]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[5]=1,t.m[15]=1,t.m[0]=r,t.m[2]=-i,t.m[8]=i,t.m[10]=r,t.m[1]=0,t.m[3]=0,t.m[4]=0,t.m[6]=0,t.m[7]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[10]=1,t.m[15]=1,t.m[0]=r,t.m[1]=i,t.m[4]=-i,t.m[5]=r,t.m[2]=0,t.m[3]=0,t.m[6]=0,t.m[7]=0,t.m[8]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},e.RotationAxis=function(t,i){var r=e.Zero();return e.RotationAxisToRef(t,i,r),r},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize(),i.m[0]=e.x*e.x*o+n,i.m[1]=e.x*e.y*o-e.z*r,i.m[2]=e.x*e.z*o+e.y*r,i.m[3]=0,i.m[4]=e.y*e.x*o+e.z*r,i.m[5]=e.y*e.y*o+n,i.m[6]=e.y*e.z*o-e.x*r,i.m[7]=0,i.m[8]=e.z*e.x*o-e.y*r,i.m[9]=e.z*e.y*o+e.x*r,i.m[10]=e.z*e.z*o+n,i.m[11]=0,i.m[15]=1},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){c.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},e.Scaling=function(t,i,r){var n=e.Zero();return e.ScalingToRef(t,i,r,n),n},e.ScalingToRef=function(e,t,i,r){r.m[0]=e,r.m[1]=0,r.m[2]=0,r.m[3]=0,r.m[4]=0,r.m[5]=t,r.m[6]=0,r.m[7]=0,r.m[8]=0,r.m[9]=0,r.m[10]=i,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},e.Translation=function(t,i,r){var n=e.Identity();return e.TranslationToRef(t,i,r,n),n},e.TranslationToRef=function(t,i,r,n){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1,n)},e.Lerp=function(t,i,r){for(var n=e.Zero(),o=0;o<16;o++)n.m[o]=t.m[o]*(1-r)+i.m[o]*r;return n},e.DecomposeLerp=function(t,i,r){var n=new o(0,0,0),s=new c,a=new o(0,0,0);t.decompose(n,s,a);var h=new o(0,0,0),u=new c,l=new o(0,0,0);i.decompose(h,u,l);var f=o.Lerp(n,h,r),d=c.Slerp(s,u,r),p=o.Lerp(a,l,r);return e.Compose(f,d,p)},e.LookAtLH=function(t,i,r){var n=e.Zero();return e.LookAtLHToRef(t,i,r,n),n},e.LookAtLHToRef=function(t,i,r,n){i.subtractToRef(t,this._zAxis),this._zAxis.normalize(),o.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),o.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-o.Dot(this._xAxis,t),a=-o.Dot(this._yAxis,t),c=-o.Dot(this._zAxis,t);return e.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,c,1,n)},e.LookAtRH=function(t,i,r){var n=e.Zero();return e.LookAtRHToRef(t,i,r,n),n},e.LookAtRHToRef=function(t,i,r,n){t.subtractToRef(i,this._zAxis),this._zAxis.normalize(),o.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),o.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-o.Dot(this._xAxis,t),a=-o.Dot(this._yAxis,t),c=-o.Dot(this._zAxis,t);return e.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,c,1,n)},e.OrthoLH=function(t,i,r,n){var o=e.Zero();return e.OrthoLHToRef(t,i,r,n,o),o},e.OrthoLHToRef=function(t,i,r,n,o){var s=2/t,a=2/i,c=1/(n-r),h=r/(r-n);e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,c,0,0,0,h,1,o)},e.OrthoOffCenterLH=function(t,i,r,n,o,s){var a=e.Zero();return e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterLHToRef=function(e,t,i,r,n,o,s){s.m[0]=2/(t-e),s.m[1]=s.m[2]=s.m[3]=0,s.m[5]=2/(r-i),s.m[4]=s.m[6]=s.m[7]=0,s.m[10]=1/(o-n),s.m[8]=s.m[9]=s.m[11]=0,s.m[12]=(e+t)/(e-t),s.m[13]=(r+i)/(i-r),s.m[14]=-n/(o-n),s.m[15]=1},e.OrthoOffCenterRH=function(t,i,r,n,o,s){var a=e.Zero();return e.OrthoOffCenterRHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterRHToRef=function(t,i,r,n,o,s,a){e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a.m[10]*=-1},e.PerspectiveLH=function(t,i,r,n){var o=e.Zero();return o.m[0]=2*r/t,o.m[1]=o.m[2]=o.m[3]=0,o.m[5]=2*r/i,o.m[4]=o.m[6]=o.m[7]=0,o.m[10]=-n/(r-n),o.m[8]=o.m[9]=0,o.m[11]=1,o.m[12]=o.m[13]=o.m[15]=0,o.m[14]=r*n/(r-n),o},e.PerspectiveFovLH=function(t,i,r,n){var o=e.Zero();return e.PerspectiveFovLHToRef(t,i,r,n,o),o},e.PerspectiveFovLHToRef=function(e,t,i,r,n,o){void 0===o&&(o=!0);var s=1/Math.tan(.5*e);n.m[0]=o?s/t:s,n.m[1]=n.m[2]=n.m[3]=0,n.m[5]=o?s:s*t,n.m[4]=n.m[6]=n.m[7]=0,n.m[8]=n.m[9]=0,n.m[10]=r/(r-i),n.m[11]=1,n.m[12]=n.m[13]=n.m[15]=0,n.m[14]=-i*r/(r-i)},e.PerspectiveFovRH=function(t,i,r,n){var o=e.Zero();return e.PerspectiveFovRHToRef(t,i,r,n,o),o},e.PerspectiveFovRHToRef=function(e,t,i,r,n,o){void 0===o&&(o=!0);var s=1/Math.tan(.5*e);n.m[0]=o?s/t:s,n.m[1]=n.m[2]=n.m[3]=0,n.m[5]=o?s:s*t,n.m[4]=n.m[6]=n.m[7]=0,n.m[8]=n.m[9]=0,n.m[10]=r/(i-r),n.m[11]=-1,n.m[12]=n.m[13]=n.m[15]=0,n.m[14]=i*r/(i-r)},e.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!0);var o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),c=Math.tan(e.rightDegrees*Math.PI/180),h=2/(a+c),u=2/(o+s);r.m[0]=h,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=u,r.m[6]=r.m[7]=0,r.m[8]=(a-c)*h*.5,r.m[9]=-(o-s)*u*.5,r.m[10]=-i/(t-i),r.m[11]=1,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=t*i/(t-i)},e.GetFinalMatrix=function(t,i,r,n,o,s){var a=t.width,c=t.height,h=t.x,u=t.y,l=e.FromValues(a/2,0,0,0,0,-c/2,0,0,0,0,s-o,0,h+a/2,c/2+u,o,1);return i.multiply(r).multiply(n).multiply(l)},e.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},e.GetAsMatrix3x3=function(e){return new Float32Array([e.m[0],e.m[1],e.m[2],e.m[4],e.m[5],e.m[6],e.m[8],e.m[9],e.m[10]])},e.Transpose=function(t){var i=new e;return i.m[0]=t.m[0],i.m[1]=t.m[4],i.m[2]=t.m[8],i.m[3]=t.m[12],i.m[4]=t.m[1],i.m[5]=t.m[5],i.m[6]=t.m[9],i.m[7]=t.m[13],i.m[8]=t.m[2],i.m[9]=t.m[6],i.m[10]=t.m[10],i.m[11]=t.m[14],i.m[12]=t.m[3],i.m[13]=t.m[7],i.m[14]=t.m[11],i.m[15]=t.m[15],i},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.ReflectionToRef=function(e,t){e.normalize();var i=e.normal.x,r=e.normal.y,n=e.normal.z,o=-2*i,s=-2*r,a=-2*n;t.m[0]=o*i+1,t.m[1]=s*i,t.m[2]=a*i,t.m[3]=0,t.m[4]=o*r,t.m[5]=s*r+1,t.m[6]=a*r,t.m[7]=0,t.m[8]=o*n,t.m[9]=s*n,t.m[10]=a*n+1,t.m[11]=0,t.m[12]=o*e.d,t.m[13]=s*e.d,t.m[14]=a*e.d,t.m[15]=1},e.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},e.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,c=e.y*e.w,h=e.y*e.z,u=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-c),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(h+u),t.m[7]=0,t.m[8]=2*(a+c),t.m[9]=2*(h-u),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1},e._tempQuaternion=new c,e._xAxis=o.Zero(),e._yAxis=o.Zero(),e._zAxis=o.Zero(),e}();e.Matrix=h;var u=function(){function e(e,t,i,r){this.normal=new o(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return 397*e^(this.d||0)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=h.Transpose(t),r=this.normal.x,n=this.normal.y,o=this.normal.z,s=this.d;return new e(r*i.m[0]+n*i.m[1]+o*i.m[2]+s*i.m[3],r*i.m[4]+n*i.m[5]+o*i.m[6]+s*i.m[7],r*i.m[8]+n*i.m[9]+o*i.m[10]+s*i.m[11],r*i.m[12]+n*i.m[13]+o*i.m[14]+s*i.m[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,c=i.y-e.y,h=i.z-e.z,u=o*h-s*c,l=s*a-n*h,f=n*c-o*a,d=Math.sqrt(u*u+l*l+f*f);return r=0!==d?1/d:0,this.normal.x=u*r,this.normal.y=l*r,this.normal.z=f*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return o.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return o.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return o.Dot(i,t)+r},e}();e.Plane=u;var l=function(){function e(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return e.prototype.toGlobal=function(t,i){return new e(this.x*t,this.y*i,this.width*t,this.height*i)},e}();e.Viewport=l;var f=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new u(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetPlanesToRef=function(e,t){t[0].normal.x=e.m[3]+e.m[2],t[0].normal.y=e.m[7]+e.m[6],t[0].normal.z=e.m[11]+e.m[10],t[0].d=e.m[15]+e.m[14],t[0].normalize(),t[1].normal.x=e.m[3]-e.m[2],t[1].normal.y=e.m[7]-e.m[6],t[1].normal.z=e.m[11]-e.m[10],t[1].d=e.m[15]-e.m[14],t[1].normalize(),t[2].normal.x=e.m[3]+e.m[0],t[2].normal.y=e.m[7]+e.m[4],t[2].normal.z=e.m[11]+e.m[8],t[2].d=e.m[15]+e.m[12],t[2].normalize(),t[3].normal.x=e.m[3]-e.m[0],t[3].normal.y=e.m[7]-e.m[4],t[3].normal.z=e.m[11]-e.m[8],t[3].d=e.m[15]-e.m[12],t[3].normalize(),t[4].normal.x=e.m[3]-e.m[1],t[4].normal.y=e.m[7]-e.m[5],t[4].normal.z=e.m[11]-e.m[9],t[4].d=e.m[15]-e.m[13],t[4].normalize(),t[5].normal.x=e.m[3]+e.m[1],t[5].normal.y=e.m[7]+e.m[5],t[5].normal.z=e.m[11]+e.m[9],t[5].d=e.m[15]+e.m[13],t[5].normalize()},e}();e.Frustum=f,function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"}(e.Space||(e.Space={}));var d=(e.Space,function(){function e(){}return e.X=new o(1,0,0),e.Y=new o(0,1,0),e.Z=new o(0,0,1),e}());e.Axis=d;var p=function(){function e(){}return e.interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,s=3*r-6*t,a=3*t,c=e,h=0;h<5;h++){var u=c*c;c-=(o*(u*c)+s*u+a*c-e)*(1/(3*o*u+2*s*c+a)),c=Math.min(1,Math.max(0,c))}return 3*Math.pow(1-c,2)*c*i+3*(1-c)*Math.pow(c,2)*n+Math.pow(c,3)},e}();e.BezierCurve=p,function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(e.Orientation||(e.Orientation={}));var m=e.Orientation,g=function(){function e(e){var t=this;this.degrees=function(){return 180*t._radians/Math.PI},this.radians=function(){return t._radians},this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new e(Math.atan2(r.y,r.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}();e.Angle=g;var _=function(){return function(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),o=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,s=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,a=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new n((o*(t.y-i.y)-s*(e.y-t.y))/a,((e.x-t.x)*s-(t.x-i.x)*o)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=g.BetweenTwoPoints(this.centerPoint,this.startPoint);var c=this.startAngle.degrees(),h=g.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),u=g.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-c>180&&(h-=360),h-c<-180&&(h+=360),u-h>180&&(u-=360),u-h<-180&&(u+=360),this.orientation=h-c<0?m.CW:m.CCW,this.angle=g.FromDegrees(this.orientation===m.CW?c-u:u-c)}}();e.Arc2=_;var v=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new n(e,t))}return e.prototype.addLineTo=function(e,t){if(closed)return this;var i=new n(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this},e.prototype.addArcTo=function(e,t,i,r,o){if(void 0===o&&(o=36),closed)return this;var s=this._points[this._points.length-1],a=new n(e,t),c=new n(i,r),h=new _(s,a,c),u=h.angle.radians()/o;h.orientation===m.CW&&(u*=-1);for(var l=h.startAngle.radians()+u,f=0;f<o;f++){var d=Math.cos(l)*h.radius+h.centerPoint.x,p=Math.sin(l)*h.radius+h.centerPoint.y;this.addLineTo(d,p),l+=u}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},e.prototype.getPoints=function(){return this._points},e.prototype.getPointAtLengthPosition=function(e){if(e<0||e>1)return n.Zero();for(var t=e*this.length(),i=0,r=0;r<this._points.length;r++){var o=(r+1)%this._points.length,s=this._points[r],a=this._points[o].subtract(s),c=a.length()+i;if(t>=i&&t<=c){var h=a.normalize(),u=t-i;return new n(s.x+h.x*u,s.y+h.y*u)}i=c}return n.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}();e.Path2=v;var y=function(){function i(e,t,i){this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var r=0;r<e.length;r++)this._curve[r]=e[r].clone();this._raw=i||!1,this._compute(t)}return i.prototype.getCurve=function(){return this._curve},i.prototype.getTangents=function(){return this._tangents},i.prototype.getNormals=function(){return this._normals},i.prototype.getBinormals=function(){return this._binormals},i.prototype.getDistances=function(){return this._distances},i.prototype.update=function(e,t){for(var i=0;i<e.length;i++)this._curve[i].x=e[i].x,this._curve[i].y=e[i].y,this._curve[i].z=e[i].z;return this._compute(t),this},i.prototype._compute=function(e){var t=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[t-1]=this._curve[t-1].subtract(this._curve[t-2]),this._raw||this._tangents[t-1].normalize();var i=this._tangents[0],r=this._normalVector(this._curve[0],i,e);this._normals[0]=r,this._raw||this._normals[0].normalize(),this._binormals[0]=o.Cross(i,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var n,s,a,c,h=1;h<t;h++)n=this._getLastNonNullVector(h),h<t-1&&(s=this._getFirstNonNullVector(h),this._tangents[h]=n.add(s),this._tangents[h].normalize()),this._distances[h]=this._distances[h-1]+n.length(),a=this._tangents[h],c=this._binormals[h-1],this._normals[h]=o.Cross(c,a),this._raw||this._normals[h].normalize(),this._binormals[h]=o.Cross(a,this._normals[h]),this._raw||this._binormals[h].normalize()},i.prototype._getFirstNonNullVector=function(e){for(var t=1,i=this._curve[e+t].subtract(this._curve[e]);0===i.length()&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i},i.prototype._getLastNonNullVector=function(e){for(var t=1,i=this._curve[e].subtract(this._curve[e-t]);0===i.length()&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},i.prototype._normalVector=function(i,r,n){var s,a,c=r.length();(0===c&&(c=1),null==n)?(t.WithinEpsilon(Math.abs(r.y)/c,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.x)/c,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.z)/c,1,e.Epsilon)||(a=new o(0,0,1)):a=new o(1,0,0):a=new o(0,-1,0),s=o.Cross(r,a)):(s=o.Cross(r,n),o.CrossToRef(s,r,s));return s.normalize(),s},i}();e.Path3D=y;var b=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,r,n){n=n>2?n:3;for(var s=new Array,a=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},c=0;c<=n;c++)s.push(new o(a(c/n,t.x,i.x,r.x),a(c/n,t.y,i.y,r.y),a(c/n,t.z,i.z,r.z)));return new e(s)},e.CreateCubicBezier=function(t,i,r,n,s){s=s>3?s:4;for(var a=new Array,c=function(e,t,i,r,n){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*r+e*e*e*n},h=0;h<=s;h++)a.push(new o(c(h/s,t.x,i.x,r.x,n.x),c(h/s,t.y,i.y,r.y,n.y),c(h/s,t.z,i.z,r.z,n.z)));return new e(a)},e.CreateHermiteSpline=function(t,i,r,n,s){for(var a=new Array,c=1/s,h=0;h<=s;h++)a.push(o.Hermite(t,i,r,n,h*c));return new e(a)},e.prototype.getPoints=function(){return this._points},e.prototype.length=function(){return this._length},e.prototype.continue=function(t){for(var i=this._points[this._points.length-1],r=this._points.slice(),n=t.getPoints(),o=1;o<n.length;o++)r.push(n[o].subtract(n[0]).add(i));return new e(r)},e.prototype._computeLength=function(e){for(var t=0,i=1;i<e.length;i++)t+=e[i].subtract(e[i-1]).length();return t},e}();e.Curve3=b;var x=function(){function e(){this.L00=o.Zero(),this.L1_1=o.Zero(),this.L10=o.Zero(),this.L11=o.Zero(),this.L2_2=o.Zero(),this.L2_1=o.Zero(),this.L20=o.Zero(),this.L21=o.Zero(),this.L22=o.Zero()}return e.prototype.addLight=function(e,t,i){var r=new o(t.r,t.g,t.b).scale(i);this.L00=this.L00.add(r.scale(.282095)),this.L1_1=this.L1_1.add(r.scale(.488603*e.y)),this.L10=this.L10.add(r.scale(.488603*e.z)),this.L11=this.L11.add(r.scale(.488603*e.x)),this.L2_2=this.L2_2.add(r.scale(1.092548*e.x*e.y)),this.L2_1=this.L2_1.add(r.scale(1.092548*e.y*e.z)),this.L21=this.L21.add(r.scale(1.092548*e.x*e.z)),this.L20=this.L20.add(r.scale(.315392*(3*e.z*e.z-1))),this.L22=this.L22.add(r.scale(.546274*(e.x*e.x-e.y*e.y)))},e.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},e}();e.SphericalHarmonics=x;var w=function(){function e(){this.x=o.Zero(),this.y=o.Zero(),this.z=o.Zero(),this.xx=o.Zero(),this.yy=o.Zero(),this.zz=o.Zero(),this.xy=o.Zero(),this.yz=o.Zero(),this.zx=o.Zero()}return e.prototype.addAmbient=function(e){var t=new o(e.r,e.g,e.b);this.xx=this.xx.add(t),this.yy=this.yy.add(t),this.zz=this.zz.add(t)},e.getSphericalPolynomialFromHarmonics=function(t){var i=new e;return i.x=t.L11.scale(1.02333),i.y=t.L1_1.scale(1.02333),i.z=t.L10.scale(1.02333),i.xx=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).add(t.L22.scale(.429043)),i.yy=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).subtract(t.L22.scale(.429043)),i.zz=t.L00.scale(.886277).add(t.L20.scale(.495417)),i.yz=t.L2_1.scale(.858086),i.zx=t.L21.scale(.858086),i.xy=t.L2_2.scale(.858086),i},e}();e.SphericalPolynomial=w;var S=function(){function e(e,t){void 0===e&&(e=o.Zero()),void 0===t&&(t=o.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}();e.PositionNormalVertex=S;var T=function(){function e(e,t,i){void 0===e&&(e=o.Zero()),void 0===t&&(t=o.Up()),void 0===i&&(i=n.Zero()),this.position=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e}();e.PositionNormalTextureVertex=T;var A=function(){function e(){}return e.Color3=[i.Black(),i.Black(),i.Black()],e.Vector2=[n.Zero(),n.Zero(),n.Zero()],e.Vector3=[o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero()],e.Vector4=[s.Zero(),s.Zero(),s.Zero()],e.Quaternion=[new c(0,0,0,0)],e.Matrix=[h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero()],e}();e.Tmp=A}(s||(s={})),function(e){function t(e,t){return function(i,r){i.__serializableMembers||(i.__serializableMembers={}),i.__serializableMembers[r]||(i.__serializableMembers[r]={type:e,sourceName:t})}}e.serialize=function(e){return t(0,e)},e.serializeAsTexture=function(e){return t(1,e)},e.serializeAsColor3=function(e){return t(2,e)},e.serializeAsFresnelParameters=function(e){return t(3,e)},e.serializeAsVector2=function(e){return t(4,e)},e.serializeAsVector3=function(e){return t(5,e)},e.serializeAsMeshReference=function(e){return t(6,e)},e.serializeAsColorCurves=function(e){return t(7,e)};var i=function(){function t(){}return t.Serialize=function(t,i){for(var r in i||(i={}),i.tags=e.Tags.GetTags(t),t.__serializableMembers){var n=t.__serializableMembers[r],o=n.sourceName||r,s=n.type,a=t[r];if(null!=a)switch(s){case 0:i[o]=a;break;case 1:i[o]=a.serialize();break;case 2:i[o]=a.asArray();break;case 3:i[o]=a.serialize();break;case 4:case 5:i[o]=a.asArray();break;case 6:i[o]=a.id;break;case 7:i[o]=a.serialize()}}return i},t.Parse=function(t,i,r,n){var o=t();for(var s in e.Tags.AddTagsTo(o,i.tags),o.__serializableMembers){var a=o.__serializableMembers[s],c=i[a.sourceName||s],h=a.type;if(null!=c)switch(h){case 0:o[s]=c;break;case 1:o[s]=e.Texture.Parse(c,r,n);break;case 2:o[s]=e.Color3.FromArray(c);break;case 3:o[s]=e.FresnelParameters.Parse(c);break;case 4:o[s]=e.Vector2.FromArray(c);break;case 5:o[s]=e.Vector3.FromArray(c);break;case 6:o[s]=r.getLastMeshByID(c);break;case 7:o[s]=e.ColorCurves.Parse(c)}}return o},t.Clone=function(t,i){var r=t();for(var n in e.Tags.AddTagsTo(r,i.tags),r.__serializableMembers){var o=r.__serializableMembers[n],s=i[n],a=o.type;if(null!=s)switch(a){case 0:case 6:r[n]=s;break;case 1:case 2:case 3:case 4:case 5:case 7:r[n]=s.clone()}}return r},t}();e.SerializationHelper=i}(s||(s={})),function(e){var t=function(){function e(e,t){void 0===t&&(t=!1),this.initalize(e,t)}return e.prototype.initalize=function(e,t){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this},e}();e.EventState=t;var i=function(){return function(e,t){this.callback=e,this.mask=t}}();e.Observer=i;var r=function(){function e(){this._observers=new Array,this._eventState=new t(0)}return e.prototype.add=function(e,t,r){if(void 0===t&&(t=-1),void 0===r&&(r=!1),!e)return null;var n=new i(e,t);return r?this._observers.unshift(n):this._observers.push(n),n},e.prototype.remove=function(e){var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},e.prototype.removeCallback=function(e){for(var t=0;t<this._observers.length;t++)if(this._observers[t].callback===e)return this._observers.splice(t,1),!0;return!1},e.prototype.notifyObservers=function(e,t){void 0===t&&(t=-1);var i=this._eventState;i.mask=t,i.skipNextObservers=!1;for(var r=0,n=this._observers;r<n.length;r++){var o=n[r];if(o.mask&t&&o.callback(e,i),i.skipNextObservers)return!1}return!0},e.prototype.hasObservers=function(){return this._observers.length>0},e.prototype.clear=function(){this._observers=new Array},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e}();e.Observable=r}(s||(s={})),r=s||(s={}),n=function(){function e(t,i){this.idbFactory=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,this.callbackManifestChecked=i,this.currentSceneUrl=e.ReturnFullUrlLocation(t),this.db=null,this.enableSceneOffline=!1,this.enableTexturesOffline=!1,this.manifestVersionFound=0,this.mustUpdateRessources=!1,this.hasReachedQuota=!1,e.IDBStorageEnabled?this.checkManifestFile():this.callbackManifestChecked(!0)}return e.prototype.checkManifestFile=function(){function e(){i.enableSceneOffline=!1,i.enableTexturesOffline=!1,i.callbackManifestChecked(!1)}var t=this,i=this,n=!1,o=this.currentSceneUrl+".manifest",s=new XMLHttpRequest;navigator.onLine&&(n=!0,o=o+(null==o.match(/\?/)?"?":"&")+(new Date).getTime()),s.open("GET",o,!0),s.addEventListener("load",function(){if(200===s.status||r.Tools.ValidateXHRData(s,1))try{var i=JSON.parse(s.response);t.enableSceneOffline=i.enableSceneOffline,t.enableTexturesOffline=i.enableTexturesOffline,i.version&&!isNaN(parseInt(i.version))&&(t.manifestVersionFound=i.version),t.callbackManifestChecked&&t.callbackManifestChecked(!0)}catch(t){e()}else e()},!1),s.addEventListener("error",function(i){if(n){n=!1;var r=t.currentSceneUrl+".manifest";s.open("GET",r,!0),s.send()}else e()},!1);try{s.send()}catch(e){r.Tools.Error("Error on XHR send request."),i.callbackManifestChecked(!1)}},e.prototype.openAsync=function(e,t){function i(){o.isSupported=!1,t&&t()}var n=this,o=this;if(this.idbFactory&&(this.enableSceneOffline||this.enableTexturesOffline))if(this.db)e&&e();else{this.hasReachedQuota=!1,this.isSupported=!0;var s=this.idbFactory.open("babylonjs",1);s.onerror=function(e){i()},s.onblocked=function(e){r.Tools.Error("IDB request blocked. Please reload the page."),i()},s.onsuccess=function(t){n.db=s.result,e()},s.onupgradeneeded=function(e){n.db=e.target.result;try{n.db.createObjectStore("scenes",{keyPath:"sceneUrl"}),n.db.createObjectStore("versions",{keyPath:"sceneUrl"}),n.db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(e){r.Tools.Error("Error while creating object stores. Exception: "+e.message),i()}}}else this.isSupported=!1,t&&t()},e.prototype.loadImageFromDB=function(t,i){var r=this,n=e.ReturnFullUrlLocation(t),o=function(){r.hasReachedQuota||null===r.db?i.src=t:r._saveImageIntoDBAsync(n,i)};this.mustUpdateRessources?o():this._loadImageFromDBAsync(n,i,o)},e.prototype._loadImageFromDBAsync=function(e,t,i){if(this.isSupported&&null!==this.db){var n,o=this.db.transaction(["textures"]);o.onabort=function(i){t.src=e},o.oncomplete=function(o){var s;if(n){var a=window.URL||window.webkitURL;s=a.createObjectURL(n.data,{oneTimeOnly:!0}),t.onerror=function(){r.Tools.Error("Error loading image from blob URL: "+s+" switching back to web url: "+e),t.src=e},t.src=s}else i()};var s=o.objectStore("textures").get(e);s.onsuccess=function(e){n=e.target.result},s.onerror=function(i){r.Tools.Error("Error loading texture "+e+" from DB."),t.src=e}}else r.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t.src=e},e.prototype._saveImageIntoDBAsync=function(t,i){var n=this;if(this.isSupported){var o=function(){var e;if(s){var t=window.URL||window.webkitURL;try{e=t.createObjectURL(s,{oneTimeOnly:!0})}catch(i){e=t.createObjectURL(s)}}i.src=e};if(e.IsUASupportingBlobStorage){var s,a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType="blob",a.addEventListener("load",function(){if(200===a.status){s=a.response;var r=n.db.transaction(["textures"],"readwrite");r.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(n.hasReachedQuota=!0)}catch(e){}o()},r.oncomplete=function(e){o()};var c={textureUrl:t,data:s};try{var h=r.objectStore("textures").put(c);h.onsuccess=function(e){},h.onerror=function(e){o()}}catch(r){25===r.code&&(e.IsUASupportingBlobStorage=!1),i.src=t}}else i.src=t},!1),a.addEventListener("error",function(e){r.Tools.Error("Error in XHR request in BABYLON.Database."),i.src=t},!1),a.send()}else i.src=t}else r.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i.src=t},e.prototype._checkVersionFromDB=function(e,t){var i=this;this._loadVersionFromDBAsync(e,t,function(r){i._saveVersionIntoDBAsync(e,t)})},e.prototype._loadVersionFromDBAsync=function(e,t,i){var n,o=this;if(this.isSupported)try{var s=this.db.transaction(["versions"]);s.oncomplete=function(e){n?o.manifestVersionFound>n.data?(o.mustUpdateRessources=!0,i()):t(n.data):(o.mustUpdateRessources=!0,i())},s.onabort=function(e){t(-1)};var a=s.objectStore("versions").get(e);a.onsuccess=function(e){n=e.target.result},a.onerror=function(i){r.Tools.Error("Error loading version for scene "+e+" from DB."),t(-1)}}catch(e){r.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+e.message),t(-1)}else r.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t(-1)},e.prototype._saveVersionIntoDBAsync=function(e,t){var i=this;if(this.isSupported&&!this.hasReachedQuota)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(i.hasReachedQuota=!0)}catch(e){}t(-1)},n.oncomplete=function(e){t(i.manifestVersionFound)};var o={sceneUrl:e,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(e){r.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(e){r.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+e.message),t(-1)}else t(-1)},e.prototype.loadFileFromDB=function(t,i,r,n,o){var s=this,a=e.ReturnFullUrlLocation(t),c=function(e){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,c,o):n()})},e.prototype._loadFileFromDBAsync=function(e,t,i,n){if(this.isSupported){var o;o=-1!==e.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?t(s.data):i()},a.onabort=function(e){i()};var c=a.objectStore(o).get(e);c.onsuccess=function(e){s=e.target.result},c.onerror=function(t){r.Tools.Error("Error loading file "+e+" from DB."),i()}}else r.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t()},e.prototype._saveFileIntoDBAsync=function(e,t,i,n){var o=this;if(this.isSupported){var s;s=-1!==e.indexOf(".babylon")?"scenes":"textures";var a,c=new XMLHttpRequest;c.open("GET",e,!0),n&&(c.responseType="arraybuffer"),c.onprogress=i,c.addEventListener("load",function(){if(200===c.status||r.Tools.ValidateXHRData(c,n?6:1))if(a=n?c.response:c.responseText,o.hasReachedQuota)t(a);else{var i,h=o.db.transaction([s],"readwrite");h.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(o.hasReachedQuota=!0)}catch(e){}t(a)},h.oncomplete=function(e){t(a)},i="scenes"===s?{sceneUrl:e,data:a,version:o.manifestVersionFound}:{textureUrl:e,data:a};try{var u=h.objectStore(s).put(i);u.onsuccess=function(e){},u.onerror=function(e){r.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){t(a)}}else t()},!1),c.addEventListener("error",function(e){r.Tools.Error("error on XHR request."),t()},!1),c.send()}else r.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t()},e.IsUASupportingBlobStorage=!0,e.IDBStorageEnabled=!0,e.parseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},e.ReturnFullUrlLocation=function(t){return-1===t.indexOf("http:/")?e.parseURL(window.location.href)+t:t},e}(),r.Database=n,function(e){!function(t){var i=function(){function t(){}return t.GetTGAHeader=function(e){var t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}},t.UploadContent=function(i,r){if(r.length<19)e.Tools.Error("Unable to load TGA file - Not enough data to contain header");else{var n=18,o=t.GetTGAHeader(r);if(o.id_length+n>r.length)e.Tools.Error("Unable to load TGA file - Not enough data");else{n+=o.id_length;var s=!1,a=!1,c=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:c=!0}var h,u,l,f,d,p,m,g,_=(o.flags,o.pixel_size>>3),v=o.width*o.height*_;if(a&&(u=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){h=new Uint8Array(v);for(var y,b,x,w=0,S=new Uint8Array(_);n<v&&w<v;)if(b=1+(127&(y=r[n++])),128&y){for(x=0;x<_;++x)S[x]=r[n++];for(x=0;x<b;++x)h.set(S,w+x*_);w+=_*b}else{for(b*=_,x=0;x<b;++x)h[w+x]=r[n++];w+=b}}else h=r.subarray(n,n+=a?o.width*o.height:v);switch((o.flags&t._ORIGIN_MASK)>>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:l=0,d=1,g=o.width,f=0,p=1,m=o.height;break;case t._ORIGIN_BL:l=0,d=1,g=o.width,f=o.height-1,p=-1,m=-1;break;case t._ORIGIN_UR:l=o.width-1,d=-1,g=-1,f=0,p=1,m=o.height;break;case t._ORIGIN_BR:l=o.width-1,d=-1,g=-1,f=o.height-1,p=-1,m=-1}var T=t["_getImageData"+(c?"Grey":"")+o.pixel_size+"bits"](o,u,h,f,p,m,l,d,g);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,T)}}},t._getImageData8bits=function(e,t,i,r,n,o,s,a,c){var h,u,l,f=i,d=t,p=e.width,m=e.height,g=0,_=new Uint8Array(p*m*4);for(l=r;l!==o;l+=n)for(u=s;u!==c;u+=a,g++)h=f[g],_[4*(u+p*l)+3]=255,_[4*(u+p*l)+2]=d[3*h+0],_[4*(u+p*l)+1]=d[3*h+1],_[4*(u+p*l)+0]=d[3*h+2];return _},t._getImageData16bits=function(e,t,i,r,n,o,s,a,c){var h,u,l,f=i,d=e.width,p=e.height,m=0,g=new Uint8Array(d*p*4);for(l=r;l!==o;l+=n)for(u=s;u!==c;u+=a,m+=2)h=f[m+0]+(f[m+1]<<8),g[4*(u+d*l)+0]=(31744&h)>>7,g[4*(u+d*l)+1]=(992&h)>>2,g[4*(u+d*l)+2]=(31&h)>>3,g[4*(u+d*l)+3]=32768&h?0:255;return g},t._getImageData24bits=function(e,t,i,r,n,o,s,a,c){var h,u,l=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(u=r;u!==o;u+=n)for(h=s;h!==c;h+=a,p+=3)m[4*(h+f*u)+3]=255,m[4*(h+f*u)+2]=l[p+0],m[4*(h+f*u)+1]=l[p+1],m[4*(h+f*u)+0]=l[p+2];return m},t._getImageData32bits=function(e,t,i,r,n,o,s,a,c){var h,u,l=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(u=r;u!==o;u+=n)for(h=s;h!==c;h+=a,p+=4)m[4*(h+f*u)+2]=l[p+0],m[4*(h+f*u)+1]=l[p+1],m[4*(h+f*u)+0]=l[p+2],m[4*(h+f*u)+3]=l[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,c){var h,u,l,f=i,d=e.width,p=e.height,m=0,g=new Uint8Array(d*p*4);for(l=r;l!==o;l+=n)for(u=s;u!==c;u+=a,m++)h=f[m],g[4*(u+d*l)+0]=h,g[4*(u+d*l)+1]=h,g[4*(u+d*l)+2]=h,g[4*(u+d*l)+3]=255;return g},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,c){var h,u,l=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(u=r;u!==o;u+=n)for(h=s;h!==c;h+=a,p+=2)m[4*(h+f*u)+0]=l[p+0],m[4*(h+f*u)+1]=l[p+0],m[4*(h+f*u)+2]=l[p+0],m[4*(h+f*u)+3]=l[p+1];return m},t._TYPE_NO_DATA=0,t._TYPE_INDEXED=1,t._TYPE_RGB=2,t._TYPE_GREY=3,t._TYPE_RLE_INDEXED=9,t._TYPE_RLE_RGB=10,t._TYPE_RLE_GREY=11,t._ORIGIN_MASK=48,t._ORIGIN_SHIFT=4,t._ORIGIN_BL=0,t._ORIGIN_BR=1,t._ORIGIN_UL=2,t._ORIGIN_UR=3,t}();t.TGATools=i}(e.Internals||(e.Internals={}))}(s||(s={})),function(e){var t=function(){function e(t){this.length=0,this._duplicateId=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId},e.prototype.pushNoDuplicate=function(e){return!(e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId||(this.push(e),0))},e.prototype.sort=function(e){this.data.sort(e)},e.prototype.reset=function(){this.length=0,this._duplicateId++},e.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var i=(e.data||e)[t];this.pushNoDuplicate(i)}}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e._GlobalId=0,e}();e.SmartArray=t}(s||(s={})),function(e){var t=function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach(function(e,i){return t.add(e,i)})},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:((i=t(e))&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=e(t,this._data[t]);if(i)return i}return null},e}();e.StringDictionary=t}(s||(s={})),function(e){var t,r=function(t,i){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(i):t.clone?t.clone():null:null},n=function(){function n(){}return n.Instantiate=function(e){for(var t=e.split("."),i=window||this,r=0,n=t.length;r<n;r++)i=i[t[r]];return"function"!=typeof i?null:i},n.SetImmediate=function(e){window.setImmediate?window.setImmediate(e):setTimeout(e,1)},n.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t<e);return t===e},n.GetExponentOfTwo=function(e,t){var i=1;do{i*=2}while(i<e);return i>t&&(i=t),i},n.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},n.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},n.ToDegrees=function(e){return 180*e/Math.PI},n.ToRadians=function(e){return e*Math.PI/180},n.EncodeArrayBufferTobase64=function(e){for(var t,i,r,n,o,s,a,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h="",u=0,l=new Uint8Array(e);u<l.length;)n=(t=l[u++])>>2,o=(3&t)<<4|(i=u<l.length?l[u++]:Number.NaN)>>4,s=(15&i)<<2|(r=u<l.length?l[u++]:Number.NaN)>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),h+=c.charAt(n)+c.charAt(o)+c.charAt(s)+c.charAt(a);return"data:image/png;base64,"+h},n.ExtractMinAndMaxIndexed=function(t,i,r,n,o){void 0===o&&(o=null);for(var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=r;c<r+n;c++){var h=new e.Vector3(t[3*i[c]],t[3*i[c]+1],t[3*i[c]+2]);s=e.Vector3.Minimize(h,s),a=e.Vector3.Maximize(h,a)}return o&&(s.x-=s.x*o.x+o.y,s.y-=s.y*o.x+o.y,s.z-=s.z*o.x+o.y,a.x+=a.x*o.x+o.y,a.y+=a.y*o.x+o.y,a.z+=a.z*o.x+o.y),{minimum:s,maximum:a}},n.ExtractMinAndMax=function(t,i,r,n,o){void 0===n&&(n=null);var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);o||(o=3);for(var c=i;c<i+r;c++){var h=new e.Vector3(t[c*o],t[c*o+1],t[c*o+2]);s=e.Vector3.Minimize(h,s),a=e.Vector3.Maximize(h,a)}return n&&(s.x-=s.x*n.x+n.y,s.y-=s.y*n.x+n.y,s.z-=s.z*n.x+n.y,a.x+=a.x*n.x+n.y,a.y+=a.y*n.x+n.y,a.z+=a.z*n.x+n.y),{minimum:s,maximum:a}},n.Vector2ArrayFeeder=function(t){return function(i){var r=void 0!==t.BYTES_PER_ELEMENT;if(i>=(r?t.length/2:t.length))return null;if(r){var n=t;return new e.Vector2(n[2*i+0],n[2*i+1])}return t[i]}},n.ExtractMinAndMaxVector2=function(t,i){void 0===i&&(i=null);for(var r=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),n=new e.Vector2(-Number.MAX_VALUE,-Number.MAX_VALUE),o=0,s=t(o++);s;)r=e.Vector2.Minimize(s,r),n=e.Vector2.Maximize(s,n),s=t(o++);return i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,n.x+=n.x*i.x+i.y,n.y+=n.y*i.x+i.y),{minimum:r,maximum:n}},n.MakeArray=function(e,t){if(!0===t||void 0!==e&&null!=e)return Array.isArray(e)?e:[e]},n.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},n.QueueNewFrame=function(e,t){void 0===t&&(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)},n.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},n.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},n.SetCorsBehavior=function(e,t){if(n.CorsBehavior)switch(i(n.CorsBehavior)){case"function":var r=n.CorsBehavior(e);if(r)return r;break;case"string":default:t.crossOrigin=n.CorsBehavior}},n.CleanUrl=function(e){return e.replace(/#/gm,"%23")},n.LoadImage=function(t,i,r,o){t instanceof ArrayBuffer&&(t=n.EncodeArrayBufferTobase64(t)),t=n.CleanUrl(t);var s=new Image;"data:"!==t.substr(0,5)&&n.SetCorsBehavior(t,s),s.onload=function(){i(s)},s.onerror=function(e){n.Error("Error while trying to load texture: "+t),n.UseFallbackTexture?(s.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",i(s)):r()};var a=function(){s.src=t};if("data:"!==t.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(function(){o.loadImageFromDB(t,s)},a);else if(-1===t.indexOf("file:"))a();else try{var c,h=t.substring(5).toLowerCase();try{c=URL.createObjectURL(e.FilesInput.FilesTextures[h],{oneTimeOnly:!0})}catch(t){c=URL.createObjectURL(e.FilesInput.FilesTextures[h])}s.src=c}catch(e){s.src=null}return s},n.LoadFile=function(t,i,r,o,s,a){t=n.CleanUrl(t);var c=function(){var e=new XMLHttpRequest,o=n.BaseUrl+t;e.open("GET",o,!0),s&&(e.responseType="arraybuffer"),e.onprogress=r,e.onreadystatechange=function(){if(4===e.readyState)if(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)i(s?e.response:e.responseText);else{if(!a)throw new Error("Error status: "+e.status+" - Unable to load "+o);a()}},e.send(null)};if(-1!==t.indexOf("file:")){var h=t.substring(5).toLowerCase();n.ReadFile(e.FilesInput.FilesToLoad[h],i,r,s)}else o&&o.enableSceneOffline?o.openAsync(function(){o.loadFileFromDB(t,i,r,c,s)},c):c()},n.ReadFileAsDataURL=function(e,t,i){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e)},n.ReadFile=function(e,t,i,r){var o=new FileReader;o.onerror=function(i){n.Log("Error while reading file: "+e.name),t(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},o.onload=function(e){t(e.target.result)},o.onprogress=i,r?o.readAsArrayBuffer(e):o.readAsText(e)},n.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},n.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},n.CheckExtends=function(e,t,i){e.x<t.x&&(t.x=e.x),e.y<t.y&&(t.y=e.y),e.z<t.z&&(t.z=e.z),e.x>i.x&&(i.x=e.x),e.y>i.y&&(i.y=e.y),e.z>i.z&&(i.z=e.z)},n.DeepCopy=function(e,t,n,o){for(var s in e)if(("_"!==s[0]||o&&-1!==o.indexOf(s))&&(!n||-1===n.indexOf(s))){var a=e[s],c=i(a);if("function"!==c)if("object"===c)if(a instanceof Array){if(t[s]=[],a.length>0)if("object"==i(a[0]))for(var h=0;h<a.length;h++){var u=r(a[h],t);-1===t[s].indexOf(u)&&t[s].push(u)}else t[s]=a.slice(0)}else t[s]=r(a,t);else t[s]=a}},n.IsEmpty=function(e){for(var t in e)return!1;return!0},n.RegisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.addEventListener(i.name,i.handler,!1);try{window.parent&&window.parent.addEventListener(i.name,i.handler,!1)}catch(e){}}},n.UnregisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.removeEventListener(i.name,i.handler);try{window.parent&&window.parent.removeEventListener(i.name,i.handler)}catch(e){}}},n.DumpFramebuffer=function(e,i,r,o,s){void 0===s&&(s="image/png");for(var a=4*e,c=i/2,h=r.readPixels(0,0,e,i),u=0;u<c;u++)for(var l=0;l<a;l++){var f=l+u*a,d=l+(i-u-1)*a,p=h[f];h[f]=h[d],h[d]=p}t||(t=document.createElement("canvas")),t.width=e,t.height=i;var m=t.getContext("2d"),g=m.createImageData(e,i);g.data.set(h),m.putImageData(g,0,0),n.EncodeScreenshotCanvasData(o,s)},n.EncodeScreenshotCanvasData=function(e,i){void 0===i&&(i="image/png");var r=t.toDataURL(i);if(e)e(r);else if("download"in document.createElement("a")){var n=window.document.createElement("a");n.href=r;var o=new Date,s=(o.getFullYear()+"-"+(o.getMonth()+1)).slice(-2)+"-"+o.getDate()+"_"+o.getHours()+"-"+("0"+o.getMinutes()).slice(-2);n.setAttribute("download","screenshot_"+s+".png"),window.document.body.appendChild(n),n.addEventListener("click",function(){n.parentElement.removeChild(n)}),n.click()}else{var a=window.open(""),c=a.document.createElement("img");c.src=r,a.document.body.appendChild(c)}},n.CreateScreenshot=function(e,i,r,o,s){var a,c;if(void 0===s&&(s="image/png"),r.precision)a=Math.round(e.getRenderWidth()*r.precision),c=Math.round(a/e.getAspectRatio(i));else if(r.width&&r.height)a=r.width,c=r.height;else if(r.width&&!r.height)a=r.width,c=Math.round(a/e.getAspectRatio(i));else if(r.height&&!r.width)c=r.height,a=Math.round(c*e.getAspectRatio(i));else{if(isNaN(r))return void n.Error("Invalid 'size' parameter !");c=r,a=r}t||(t=document.createElement("canvas")),t.width=a,t.height=c,t.getContext("2d").drawImage(e.getRenderingCanvas(),0,0,a,c),n.EncodeScreenshotCanvasData(o,s)},n.CreateScreenshotUsingRenderTarget=function(t,i,r,o,s){var a,c;if(void 0===s&&(s="image/png"),r.precision)a=Math.round(t.getRenderWidth()*r.precision),c=Math.round(a/t.getAspectRatio(i)),r={width:a,height:c};else if(r.width&&r.height)a=r.width,c=r.height;else if(r.width&&!r.height)a=r.width,c=Math.round(a/t.getAspectRatio(i)),r={width:a,height:c};else if(r.height&&!r.width)c=r.height,r={width:a=Math.round(c*t.getAspectRatio(i)),height:c};else{if(isNaN(r))return void n.Error("Invalid 'size' parameter !");c=r,a=r}var h=i.getScene(),u=null;h.activeCamera!==i&&(u=h.activeCamera,h.activeCamera=i);var l=new e.RenderTargetTexture("screenShot",r,h,!1,!1);l.renderList=h.meshes,l.onAfterRenderObservable.add(function(){n.DumpFramebuffer(a,c,t,o,s)}),h.incrementRenderId(),h.resetCachedMaterial(),l.render(!0),l.dispose(),u&&(h.activeCamera=u),i.getProjectionMatrix(!0)},n.ValidateXHRData=function(t,i){void 0===i&&(i=7);try{if(1&i){if(t.responseText&&t.responseText.length>0)return!0;if(1===i)return!1}if(2&i){var r=e.Internals.TGATools.GetTGAHeader(t.response);if(r.width&&r.height&&r.width>0&&r.height>0)return!0;if(2===i)return!1}if(4&i){var n=new Uint8Array(t.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(e){}return!1},n.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},Object.defineProperty(n,"NoneLogLevel",{get:function(){return n._NoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(n,"MessageLogLevel",{get:function(){return n._MessageLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(n,"WarningLogLevel",{get:function(){return n._WarningLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ErrorLogLevel",{get:function(){return n._ErrorLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(n,"AllLogLevel",{get:function(){return n._MessageLogLevel|n._WarningLogLevel|n._ErrorLogLevel},enumerable:!0,configurable:!0}),n._AddLogEntry=function(e){n._LogCache=e+n._LogCache,n.OnNewCacheEntry&&n.OnNewCacheEntry(e)},n._FormatMessage=function(e){var t=function(e){return e<10?"0"+e:""+e},i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e},n._LogDisabled=function(e){},n._LogEnabled=function(e){var t=n._FormatMessage(e);console.log("BJS - "+t);var i="<div style='color:white'>"+t+"</div><br>";n._AddLogEntry(i)},n._WarnDisabled=function(e){},n._WarnEnabled=function(e){var t=n._FormatMessage(e);console.warn("BJS - "+t);var i="<div style='color:orange'>"+t+"</div><br>";n._AddLogEntry(i)},n._ErrorDisabled=function(e){},n._ErrorEnabled=function(e){n.errorsCount++;var t=n._FormatMessage(e);console.error("BJS - "+t);var i="<div style='color:red'>"+t+"</div><br>";n._AddLogEntry(i)},Object.defineProperty(n,"LogCache",{get:function(){return n._LogCache},enumerable:!0,configurable:!0}),n.ClearLogCache=function(){n._LogCache="",n.errorsCount=0},Object.defineProperty(n,"LogLevels",{set:function(e){(e&n.MessageLogLevel)===n.MessageLogLevel?n.Log=n._LogEnabled:n.Log=n._LogDisabled,(e&n.WarningLogLevel)===n.WarningLogLevel?n.Warn=n._WarnEnabled:n.Warn=n._WarnDisabled,(e&n.ErrorLogLevel)===n.ErrorLogLevel?n.Error=n._ErrorEnabled:n.Error=n._ErrorDisabled},enumerable:!0,configurable:!0}),Object.defineProperty(n,"PerformanceNoneLogLevel",{get:function(){return n._PerformanceNoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(n,"PerformanceUserMarkLogLevel",{get:function(){return n._PerformanceUserMarkLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(n,"PerformanceConsoleLogLevel",{get:function(){return n._PerformanceConsoleLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(n,"PerformanceLogLevel",{set:function(e){return(e&n.PerformanceUserMarkLogLevel)===n.PerformanceUserMarkLogLevel?(n.StartPerformanceCounter=n._StartUserMark,void(n.EndPerformanceCounter=n._EndUserMark)):(e&n.PerformanceConsoleLogLevel)===n.PerformanceConsoleLogLevel?(n.StartPerformanceCounter=n._StartPerformanceConsole,void(n.EndPerformanceCounter=n._EndPerformanceConsole)):(n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,void(n.EndPerformanceCounter=n._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),n._StartPerformanceCounterDisabled=function(e,t){},n._EndPerformanceCounterDisabled=function(e,t){},n._StartUserMark=function(e,t){void 0===t&&(t=!0),t&&n._performance.mark&&n._performance.mark(e+"-Begin")},n._EndUserMark=function(e,t){void 0===t&&(t=!0),t&&n._performance.mark&&(n._performance.mark(e+"-End"),n._performance.measure(e,e+"-Begin",e+"-End"))},n._StartPerformanceConsole=function(e,t){void 0===t&&(t=!0),t&&(n._StartUserMark(e,t),console.time&&console.time(e))},n._EndPerformanceConsole=function(e,t){void 0===t&&(t=!0),t&&(n._EndUserMark(e,t),console.time&&console.timeEnd(e))},Object.defineProperty(n,"Now",{get:function(){return window.performance&&window.performance.now?window.performance.now():(new Date).getTime()},enumerable:!0,configurable:!0}),n.getClassName=function(e,t){void 0===t&&(t=!1);var r=null;if(!t&&e.getClassName)r=e.getClassName();else{if(e instanceof Object)r=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__;r||(r=i(e))}return r},n.first=function(e,t){for(var i=0,r=e;i<r.length;i++){var n=r[i];if(t(n))return n}},n.getFullClassName=function(e,t){void 0===t&&(t=!1);var r=null,n=null;if(!t&&e.getClassName)r=e.getClassName();else{if(e instanceof Object){var o=t?e:Object.getPrototypeOf(e);r=o.constructor.__bjsclassName__,n=o.constructor.__bjsmoduleName__}r||(r=i(e))}return r?(null!=n?n+".":"")+r:null},n.arrayOrStringFeeder=function(e){return function(t){if(t>=e.length)return null;var i=e.charCodeAt?e.charCodeAt(t):e[t];return i&&i.getHashCode&&(i=i.getHashCode()),"string"==typeof i?n.hashCodeFromStream(n.arrayOrStringFeeder(i)):i}},n.hashCodeFromStream=function(e){for(var t=0,i=0,r=e(i++);null!=r;)t=(t<<5)-t+r,t|=0,r=e(i++);return t},n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,n}();e.Tools=n;var o=function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(e,t){this._current+=e,t&&this._fetchResult()},e.prototype.beginMonitoring=function(){this._startMonitoringTime=n.Now},e.prototype.endMonitoring=function(e){void 0===e&&(e=!0),e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e}();e.PerfCounter=o,e.className=function(e,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}};var s=function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this._fn=t,this._successCallback=i,this.index=r-1,this._done=!1}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,i,r,n){void 0===n&&(n=0);var o=new e(t,i,r,n);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,i,r,n,o,s){void 0===s&&(s=0),e.Run(Math.ceil(t/i),function(e){o&&o()?e.breakLoop():setTimeout(function(){for(var n=0;n<i;++n){var s=e.index*i+n;if(s>=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()},s)},n)},e}();e.AsyncLoop=s}(s||(s={})),function(e){!function(e){var t=function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,r){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===r||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=r,this._isBlendFunctionParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1))},e}();e._AlphaState=t}(e.Internals||(e.Internals={}))}(s||(s={})),function(e){!function(e){var t=function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1))},e}();e._DepthCullingState=t}(e.Internals||(e.Internals={}))}(s||(s={})),function(e){!function(t){var i=function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t}();t._StencilState=i}(e.Internals||(e.Internals={}))}(s||(s={})),function(e){var t=function(e,t,i,r){var n=e.createShader("vertex"===i?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(e.shaderSource(n,(r?r+"\n":"")+t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(n));return n},i=function(e,t){return t===h.TEXTURETYPE_FLOAT?e.FLOAT:t===h.TEXTURETYPE_HALF_FLOAT?36193:e.UNSIGNED_BYTE},r=function(t,i,r){var n=r.NEAREST,o=r.NEAREST;return t===e.Texture.BILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR):t===e.Texture.TRILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR):t===e.Texture.NEAREST_SAMPLINGMODE&&(n=r.NEAREST,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST),{min:o,mag:n}},n=function(t,i,n,o,s,a,c,h,u,l){void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var f=n.getEngine(),d=e.Tools.GetExponentOfTwo(o,f.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,f.getCaps().maxTextureSize);f._bindTextureDirectly(i.TEXTURE_2D,t),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,void 0===a?1:a?1:0),t._baseWidth=o,t._baseHeight=s,t._width=d,t._height=p,t.isReady=!0,u(d,p);var m=r(l,!c,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,m.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,m.min),c||h||i.generateMipmap(i.TEXTURE_2D),f._bindTextureDirectly(i.TEXTURE_2D,null),f.resetTextureCache(),n._removePendingData(t),t.onLoadedCallbacks.forEach(function(e){e()}),t.onLoadedCallbacks=[]},o=function(t,i,r,n,o,s){void 0===s&&(s=null);var a;a=e.Tools.LoadImage(t,function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&o(r)},function(){n._removePendingData(a),s&&s()},n.database),n._addPendingData(a)},s=function(e,t,i,r,n){void 0===n&&(n=null);var s=[];s._internalCount=0;for(var a=0;a<6;a++)o(r[a],a,s,t,i,n)},a=function(){return function(){}}();e.InstancingAttributeInfo=a;var c=function(){return function(){}}();e.EngineCapabilities=c;var h=function(){function o(t,i,r,n){var s=this;void 0===n&&(n=!0),this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.enableOfflineSupport=!0,this.scenes=new Array,this._windowIsBackground=!1,this._webGLVersion="1.0",this._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=o.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(s._vrDisplayEnabled&&s._vrDisplayEnabled.isPresenting){s._oldSize=new e.Size(s.getRenderWidth(),s.getRenderHeight()),s._oldHardwareScaleFactor=s.getHardwareScalingLevel();var t=s._vrDisplayEnabled.getEyeParameters("left");s.setHardwareScalingLevel(1),s.setSize(2*t.renderWidth,t.renderHeight)}else s.setHardwareScalingLevel(s._oldHardwareScaleFactor),s.setSize(s._oldSize.width,s._oldSize.height),s._vrDisplayEnabled=void 0},this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1);var a=this._canRenderToFloatTexture(),h=this._canRenderToHalfFloatTexture();if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){s._windowIsBackground=!0},this._onFocus=function(){s._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var u=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.stencil,this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var l=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=l&&(this._glRenderer=this._gl.getParameter(l.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(l.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),this._caps.standardDerivatives=null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.astc=this._gl.getExtension("WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),this._caps.textureFloat=null!==this._gl.getExtension("OES_texture_float"),this._caps.textureAnisotropicFilterExtension=this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.instancedArrays=this._gl.getExtension("ANGLE_instanced_arrays"),this._caps.uintIndices=null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!0,this._caps.drawBuffersExtension=this._gl.getExtension("WEBGL_draw_buffers"),this._caps.textureFloatLinearFiltering=this._gl.getExtension("OES_texture_float_linear"),this._caps.textureLOD=this._gl.getExtension("EXT_shader_texture_lod"),this._caps.textureFloatRender=a,this._caps.textureHalfFloat=null!==this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._gl.getExtension("OES_texture_half_float_linear"),this._caps.textureHalfFloatRender=h,this._caps.astc&&this.texturesSupported.push(".astc"),this._caps.s3tc&&this.texturesSupported.push(".dds"),this._caps.pvrtc&&this.texturesSupported.push(".pvr"),this._caps.etc2&&this.texturesSupported.push(".etc2"),this._caps.etc1&&this.texturesSupported.push(".etc1"),this._gl.getShaderPrecisionFormat){var f=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==f.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?s.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?s.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?s.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(s.isFullscreen=document.msIsFullScreen),s.isFullscreen&&s._pointerLockRequested&&(t.requestPointerLock=t.requestPointerLock||t.msRequestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock&&t.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){s.isPointerLock=document.mozPointerLockElement===t||document.webkitPointerLockElement===t||document.msPointerLockElement===t||document.pointerLockElement===t},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),e.AudioEngine&&!o.audioEngine&&(o.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),r.autoEnableWebVR&&this.initWebVR();this._badOS=/AppleWebKit.*10.[\d] Mobile/.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+o.Version+") launched")}return Object.defineProperty(o,"NEVER",{get:function(){return o._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALWAYS",{get:function(){return o._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(o,"LESS",{get:function(){return o._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(o,"EQUAL",{get:function(){return o._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(o,"LEQUAL",{get:function(){return o._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(o,"GREATER",{get:function(){return o._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(o,"GEQUAL",{get:function(){return o._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(o,"NOTEQUAL",{get:function(){return o._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(o,"KEEP",{get:function(){return o._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(o,"REPLACE",{get:function(){return o._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"INCR",{get:function(){return o._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DECR",{get:function(){return o._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(o,"INVERT",{get:function(){return o._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"INCR_WRAP",{get:function(){return o._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DECR_WRAP",{get:function(){return o._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_DISABLE",{get:function(){return o._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_ONEONE",{get:function(){return o._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_ADD",{get:function(){return o._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_COMBINE",{get:function(){return o._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_SUBTRACT",{get:function(){return o._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_MULTIPLY",{get:function(){return o._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_MAXIMIZED",{get:function(){return o._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_NONE",{get:function(){return o._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_LOADED",{get:function(){return o._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_LOADING",{get:function(){return o._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_NOTLOADED",{get:function(){return o._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_ALPHA",{get:function(){return o._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_LUMINANCE",{get:function(){return o._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return o._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_RGB",{get:function(){return o._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_RGBA",{get:function(){return o._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return o._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTURETYPE_FLOAT",{get:function(){return o._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTURETYPE_HALF_FLOAT",{get:function(){return o._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"Version",{get:function(){return"2.5"},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),o.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},o.prototype.resetTextureCache=function(){for(var e=0;e<this._maxTextureChannels;e++)this._activeTexturesCache[e]=null},o.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},o.prototype.getAspectRatio=function(e,t){void 0===t&&(t=!1);var i=e.viewport;return this.getRenderWidth(t)*i.width/(this.getRenderHeight(t)*i.height)},o.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._width:this._renderingCanvas.width},o.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._height:this._renderingCanvas.height},o.prototype.getRenderingCanvas=function(){return this._renderingCanvas},o.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas.getBoundingClientRect()},o.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},o.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},o.prototype.getLoadedTexturesCache=function(){return this._loadedTexturesCache},o.prototype.getCaps=function(){return this._caps},Object.defineProperty(o.prototype,"drawCalls",{get:function(){return this._drawCalls.current},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"drawCallsPerfCounter",{get:function(){return this._drawCalls},enumerable:!0,configurable:!0}),o.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},o.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},o.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},o.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},o.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},o.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},o.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},o.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},o.prototype.getStencilMask=function(){return this._stencilState.stencilMask},o.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},o.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},o.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},o.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},o.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},o.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},o.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},o.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},o.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},o.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},o.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},o.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},o.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},o.prototype.stopRenderLoop=function(e){if(e){var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},o.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i<this._activeRenderLoops.length;i++){(0,this._activeRenderLoops[i])()}this.endFrame()}this._activeRenderLoops.length>0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},o.prototype.runRenderLoop=function(t){-1===this._activeRenderLoops.indexOf(t)&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},o.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},o.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},o.prototype.scissorClear=function(e,t,i,r,n){var o=this._gl,s=o.getParameter(o.SCISSOR_TEST),a=o.getParameter(o.SCISSOR_BOX);o.enable(o.SCISSOR_TEST),o.scissor(e,t,i,r),this.clear(n,!0,!0,!0),o.scissor(a[0],a[1],a[2],a[3]),!0===s?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},o.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this._renderingCanvas.width),n=i||(navigator.isCocoonJS?window.innerHeight:this._renderingCanvas.height),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},o.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},o.prototype.beginFrame=function(){this._measureFps()},o.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},o.prototype.resize=function(){var t=navigator.isCocoonJS?window.innerWidth:this._renderingCanvas.clientWidth,i=navigator.isCocoonJS?window.innerHeight:this._renderingCanvas.clientHeight;this.setSize(t/this._hardwareScalingLevel,i/this._hardwareScalingLevel);for(var r=0;r<this.scenes.length;r++){var n=this.scenes[r];e.DebugLayer&&n.debugLayer.isVisible()&&n.debugLayer._syncPositions()}},o.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i<this.scenes.length;i++)for(var r=this.scenes[i],n=0;n<r.cameras.length;n++){r.cameras[n]._currentRenderId=0}},o.prototype.initWebVR=function(){this.vrDisplaysPromise||this._getVRDisplays()},o.prototype.enableVR=function(e){this._vrDisplayEnabled=e,this._vrDisplayEnabled.requestPresent([{source:this.getRenderingCanvas()}]).then(this._onVRFullScreenTriggered)},o.prototype.disableVR=function(){this._vrDisplayEnabled&&this._vrDisplayEnabled.exitPresent().then(this._onVRFullScreenTriggered)},o.prototype._getVRDisplays=function(){var e=this;navigator.getVRDisplays&&(this.vrDisplaysPromise=navigator.getVRDisplays().then(function(t){var i=(t.length,0);return e._vrDisplays=t.filter(function(e){return t[i]instanceof VRDisplay}),e._vrDisplays}))},o.prototype.bindFramebuffer=function(e,t,i,r){this._currentRenderTarget=e,this.bindUnboundFramebuffer(e._framebuffer);var n=this._gl;e.isCube&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+t,e,0),n.viewport(0,0,i||e._width,r||e._height),this.wipeCaches()},o.prototype.bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},o.prototype.unBindFramebuffer=function(e,t){if(void 0===t&&(t=!1),this._currentRenderTarget=null,e.generateMipMaps&&!t){var i=this._gl;this._bindTextureDirectly(i.TEXTURE_2D,e),i.generateMipmap(i.TEXTURE_2D),this._bindTextureDirectly(i.TEXTURE_2D,null)}this.bindUnboundFramebuffer(null)},o.prototype.generateMipMapsForCubemap=function(e){if(e.generateMipMaps){var t=this._gl;this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,e),t.generateMipmap(t.TEXTURE_CUBE_MAP),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)}},o.prototype.flushFramebuffer=function(){this._gl.flush()},o.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget=null,this.bindUnboundFramebuffer(null),this.setViewport(this._cachedViewport),this.wipeCaches()},o.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},o.prototype.createVertexBuffer=function(e){var t=this._gl.createBuffer();return this.bindArrayBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},o.prototype.createDynamicVertexBuffer=function(e){var t=this._gl.createBuffer();return this.bindArrayBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},o.prototype.updateDynamicVertexBuffer=function(e,t,i,r){this.bindArrayBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t.subarray(i,i+r)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+r)),this._resetVertexBufferBinding()},o.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},o.prototype.createIndexBuffer=function(e){var t=this._gl.createBuffer();this.bindIndexBuffer(t);var i,r=!1;if(this._caps.uintIndices){for(var n=0;n<e.length;n++)if(e[n]>65535){r=!0;break}i=r?new Uint32Array(e):new Uint16Array(e)}else i=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),t.references=1,t.is32Bits=r,t},o.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},o.prototype.bindIndexBuffer=function(e){this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},o.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},o.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},o.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],c=!1;a?(a.buffer!==e&&(a.buffer=e,c=!0),a.size!==i&&(a.size=i,c=!0),a.type!==r&&(a.type=r,c=!0),a.normalized!==n&&(a.normalized=n,c=!0),a.stride!==o&&(a.stride=o,c=!0),a.offset!==s&&(a.offset=s,c=!0)):(c=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:o,offset:s,buffer:e}),c&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},o.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;for(var o=n.getAttributesCount(),s=0,a=0;a<o;a++)if(a<i.length){(c=n.getAttributeLocation(a))>=0&&(this._vertexAttribArraysEnabled[c]||(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0),this.vertexAttribPointer(e,c,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}else{var c=n.getAttributeLocation(a);this._vertexAttribArraysEnabled[c]&&(this._gl.disableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!1)}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},o.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;for(var r=i.getAttributesNames(),n=0;n<r.length;n++){var o=i.getAttributeLocation(n);if(o>=0){var s=e[r[n]];if(!s){this._vertexAttribArraysEnabled[o]&&(this._gl.disableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!1);continue}this._vertexAttribArraysEnabled[o]||(this._gl.enableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!0);var a=s.getBuffer();this.vertexAttribPointer(a,o,s.getSize(),this._gl.FLOAT,!1,4*s.getStrideSize(),4*s.getOffset()),s.getIsInstanced()&&(this._caps.instancedArrays.vertexAttribDivisorANGLE(o,1),this._currentInstanceLocations.push(o),this._currentInstanceBuffers.push(a))}}}null!=t&&this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},o.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t<i;t++){var r=this._currentInstanceBuffers[t];e!=r&&(e=r,this.bindArrayBuffer(r));var n=this._currentInstanceLocations[t];this._caps.instancedArrays.vertexAttribDivisorANGLE(n,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0},o.prototype._releaseBuffer=function(e){return e.references--,0===e.references&&(this._gl.deleteBuffer(e),!0)},o.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();return t.capacity=e,this.bindArrayBuffer(t),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),t},o.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},o.prototype.updateAndBindInstancesBuffer=function(e,t,i){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),void 0!==i[0].index){for(var r=0,n=0;n<i.length;n++){r+=4*(o=i[n]).attributeSize}for(n=0;n<i.length;n++){var o=i[n];this._vertexAttribArraysEnabled[o.index]||(this._gl.enableVertexAttribArray(o.index),this._vertexAttribArraysEnabled[o.index]=!0),this.vertexAttribPointer(e,o.index,o.attributeSize,o.attribyteType||this._gl.FLOAT,o.normalized||!1,r,o.offset),this._caps.instancedArrays.vertexAttribDivisorANGLE(o.index,1),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e)}}else for(var s=0;s<4;s++){var a=i[s];this._vertexAttribArraysEnabled[a]||(this._gl.enableVertexAttribArray(a),this._vertexAttribArraysEnabled[a]=!0),this.vertexAttribPointer(e,a,4,this._gl.FLOAT,!1,64,16*s),this._caps.instancedArrays.vertexAttribDivisorANGLE(a,1),this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(e)}},o.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl)},o.prototype.draw=function(e,t,i,r){this.applyStates(),this._drawCalls.addCount(1,!1);var n=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,o=this._uintIndicesCurrentlySet?4:2;return r?void this._caps.instancedArrays.drawElementsInstancedANGLE(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*o,r):void this._gl.drawElements(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*o)},o.prototype.drawPointClouds=function(e,t,i){return this.applyStates(),this._drawCalls.addCount(1,!1),i?void this._caps.instancedArrays.drawArraysInstancedANGLE(this._gl.POINTS,e,t,i):void this._gl.drawArrays(this._gl.POINTS,e,t)},o.prototype.drawUnIndexed=function(e,t,i,r){return this.applyStates(),this._drawCalls.addCount(1,!1),r?void this._caps.instancedArrays.drawArraysInstancedANGLE(e?this._gl.TRIANGLES:this._gl.LINES,t,i,r):void this._gl.drawArrays(e?this._gl.TRIANGLES:this._gl.LINES,t,i)},o.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],e.getProgram()&&this._gl.deleteProgram(e.getProgram()))},o.prototype.createEffect=function(t,i,r,n,o,s,a,c,h){var u=(t.vertexElement||t.vertex||t)+"+"+(t.fragmentElement||t.fragment||t)+"@"+o;if(this._compiledEffects[u])return this._compiledEffects[u];var l=new e.Effect(t,i,r,n,this,o,s,a,c,h);return l._key=u,this._compiledEffects[u]=l,l},o.prototype.createEffectForParticles=function(e,t,i,r,n,o,s){return void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===r&&(r=""),this.createEffect({vertex:"particles",fragmentElement:e},["position","color","options"],["view","projection"].concat(t),["diffuseSampler"].concat(i),r,n,o,s)},o.prototype.createShaderProgram=function(e,i,r,n){n=n||this._gl;var o=t(n,e,"vertex",r),s=t(n,i,"fragment",r),a=n.createProgram();if(n.attachShader(a,o),n.attachShader(a,s),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS)){var c=n.getProgramInfoLog(a);if(c)throw new Error(c)}return n.deleteShader(o),n.deleteShader(s),a},o.prototype.getUniforms=function(e,t){for(var i=[],r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(e,t[r]));return i},o.prototype.getAttributes=function(e,t){for(var i=[],r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(e,t[r]))}catch(e){i.push(-1)}return i},o.prototype.enableEffect=function(e){this.setProgram(e.getProgram()),this._currentEffect=e,e.onBind&&e.onBind(e)},o.prototype.setIntArray=function(e,t){e&&this._gl.uniform1iv(e,t)},o.prototype.setIntArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2iv(e,t)},o.prototype.setIntArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3iv(e,t)},o.prototype.setIntArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4iv(e,t)},o.prototype.setFloatArray=function(e,t){e&&this._gl.uniform1fv(e,t)},o.prototype.setFloatArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},o.prototype.setFloatArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},o.prototype.setFloatArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},o.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},o.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},o.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},o.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},o.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},o.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},o.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},o.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},o.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},o.prototype.setFloat2=function(e,t,i){e&&this._gl.uniform2f(e,t,i)},o.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},o.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},o.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},o.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},o.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},o.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1);var n=r?this._gl.FRONT:this._gl.BACK,o=r?this._gl.BACK:this._gl.FRONT,s=this.cullBackFaces?n:o;(this._depthCullingState.cull!==e||i||this._depthCullingState.cullFace!==s)&&(e?(this._depthCullingState.cullFace=s,this._depthCullingState.cull=!0):this._depthCullingState.cull=!1),this._depthCullingState.zOffset=t},o.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},o.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},o.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},o.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e)},o.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case o.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case o.ALPHA_COMBINE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_SUBTRACT:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0}t||this.setDepthWrite(e===o.ALPHA_DISABLE),this._alphaMode=e}},o.prototype.getAlphaMode=function(){return this._alphaMode},o.prototype.setAlphaTesting=function(e){this._alphaTest=e},o.prototype.getAlphaTesting=function(){return this._alphaTest},o.prototype.wipeCaches=function(){this.resetTextureCache(),this._currentEffect=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset(),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null},o.prototype.setSamplingMode=function(t,i){var r=this._gl;this._bindTextureDirectly(r.TEXTURE_2D,t);var n=r.NEAREST,o=r.NEAREST;i===e.Texture.BILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=r.LINEAR):i===e.Texture.TRILINEAR_SAMPLINGMODE&&(n=r.LINEAR,o=r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),this._bindTextureDirectly(r.TEXTURE_2D,null),t.samplingMode=i},o.prototype.setTextureFormatToUse=function(e){for(var t=0,i=this.texturesSupported.length;t<i;t++)if(".astc"!==this._texturesSupported[t]&&".pvr"!==this._texturesSupported[t]&&".etc1"!==this._texturesSupported[t]&&".etc2"!==this._texturesSupported[t])for(var r=0,n=e.length;r<n;r++)if(this._texturesSupported[t]===e[r].toLowerCase())return this._textureFormatInUse=this._texturesSupported[t];return this._textureFormatInUse=null},o.prototype.createTexture=function(t,i,r,o,s,a,c,h){var u=this;void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===c&&(c=null),void 0===h&&(h=null);var l,f=this._gl.createTexture(),d=!1;if("data:"===t.substr(0,5)&&(d=!0),d){var p=t;d=p.split(":"),t=p,l=d[1].substr(d[1].length-4,4).toLowerCase()}else{var m=t.lastIndexOf(".");l=t.substring(m).toLowerCase(),!this._textureFormatInUse||d||o.database||(l=this._textureFormatInUse,t=t.substring(0,m)+this._textureFormatInUse)}var g=".dds"===l,_=".tga"===l;o._addPendingData(f),f.url=t,f.noMipmap=i,f.references=1,f.samplingMode=s,f.onLoadedCallbacks=[a],this._loadedTexturesCache.push(f);var v,y=function(){o._removePendingData(f),c&&c()};if(_)v=function(t){var a=new Uint8Array(t),c=e.Internals.TGATools.GetTGAHeader(a);n(f,u._gl,o,c.width,c.height,r,i,!1,function(){e.Internals.TGATools.UploadContent(u._gl,a)},s)},d instanceof Array?v(h):e.Tools.LoadFile(t,function(e){v(e)},null,o.database,!0,y);else if(g)v=function(t){var a=e.Internals.DDSTools.GetDDSInfo(t),c=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&!i&&a.width>>a.mipmapCount-1==1;n(f,u._gl,o,a.width,a.height,r,!c,a.isFourCC,function(){e.Internals.DDSTools.UploadDDSLevels(u._gl,u.getCaps().s3tc,t,a,c,1)},s)},d instanceof Array?v(h):e.Tools.LoadFile(t,function(e){v(e)},null,o.database,!0,y);else{var b=function(t){n(f,u._gl,o,t.width,t.height,r,i,!1,function(i,r){var n=t.width===i&&t.height===r;n||(u._prepareWorkingCanvas(),u._workingCanvas.width=i,u._workingCanvas.height=r,s===e.Texture.NEAREST_SAMPLINGMODE&&(u._workingContext.imageSmoothingEnabled=!1,u._workingContext.mozImageSmoothingEnabled=!1,u._workingContext.oImageSmoothingEnabled=!1,u._workingContext.webkitImageSmoothingEnabled=!1,u._workingContext.msImageSmoothingEnabled=!1),u._workingContext.drawImage(t,0,0,t.width,t.height,0,0,i,r),s===e.Texture.NEAREST_SAMPLINGMODE&&(u._workingContext.imageSmoothingEnabled=!0,u._workingContext.mozImageSmoothingEnabled=!0,u._workingContext.oImageSmoothingEnabled=!0,u._workingContext.webkitImageSmoothingEnabled=!0,u._workingContext.msImageSmoothingEnabled=!0)),u._gl.texImage2D(u._gl.TEXTURE_2D,0,u._gl.RGBA,u._gl.RGBA,u._gl.UNSIGNED_BYTE,n?t:u._workingCanvas)},s)};d instanceof Array?e.Tools.LoadImage(h,b,y,o.database):e.Tools.LoadImage(t,b,y,o.database)}return f},o.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case o.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case o.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case o.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case o.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case o.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},o.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),e._width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e._width,e._height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,e._width,e._height,0,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},o.prototype.createRawTexture=function(e,t,i,n,o,s,a,c){void 0===c&&(c=null);var h=this._gl.createTexture();h._baseWidth=t,h._baseHeight=i,h._width=t,h._height=i,h.references=1,this.updateRawTexture(h,e,n,s,c),this._bindTextureDirectly(this._gl.TEXTURE_2D,h);var u=r(a,o,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,u.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,u.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),h.samplingMode=a,this._loadedTexturesCache.push(h),h},o.prototype.createDynamicTexture=function(t,i,r,n){var o=this._gl.createTexture();return o._baseWidth=t,o._baseHeight=i,r&&(t=e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize),i=e.Tools.GetExponentOfTwo(i,this._caps.maxTextureSize)),this.resetTextureCache(),o._width=t,o._height=i,o.isReady=!1,o.generateMipMaps=r,o.references=1,o.samplingMode=n,this.updateTextureSamplingMode(n,o),this._loadedTexturesCache.push(o),o},o.prototype.updateTextureSamplingMode=function(e,t){var i=r(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,t),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,t),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null))},o.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?1:0),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},o.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?0:1);try{void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported?this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t):(e._workingCanvas||(e._workingCanvas=document.createElement("canvas"),e._workingContext=e._workingCanvas.getContext("2d"),e._workingCanvas.width=e._width,e._workingCanvas.height=e._height),e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e._width,e._height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(t){e._isDisabled=!0}}},o.prototype.createRenderTargetTexture=function(t,n){var s=!1,a=!0,c=!1,h=o.TEXTURETYPE_UNSIGNED_INT,u=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==n&&(s=void 0===n.generateMipMaps?n:n.generateMipMaps,c=(a=void 0===n.generateDepthBuffer||n.generateDepthBuffer)&&n.generateStencilBuffer,h=void 0===n.type?h:n.type,void 0!==n.samplingMode&&(u=n.samplingMode),(h!==o.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(h!==o.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(u=e.Texture.NEAREST_SAMPLINGMODE));var l=this._gl,f=l.createTexture();this._bindTextureDirectly(l.TEXTURE_2D,f);var d,p=t.width||t,m=t.height||t,g=r(u,s,l);h!==o.TEXTURETYPE_FLOAT||this._caps.textureFloat||(h=o.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,g.mag),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,g.min),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,p,m,0,l.RGBA,i(l,h),null),c?(d=l.createRenderbuffer(),l.bindRenderbuffer(l.RENDERBUFFER,d),l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_STENCIL,p,m)):a&&(d=l.createRenderbuffer(),l.bindRenderbuffer(l.RENDERBUFFER,d),l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,p,m));var _=l.createFramebuffer();return this.bindUnboundFramebuffer(_),c?l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,d):a&&l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,d),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,f,0),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),f._framebuffer=_,a&&(f._depthBuffer=d),f._baseWidth=p,f._baseHeight=m,f._width=p,f._height=m,f.isReady=!0,f.generateMipMaps=s,f.references=1,f.samplingMode=u,f.type=h,this.resetTextureCache(),this._loadedTexturesCache.push(f),f},o.prototype.createRenderTargetCubeTexture=function(t,i){var n=this._gl,o=n.createTexture(),s=!0,a=!0,c=!1,h=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,c=(a=void 0===i.generateDepthBuffer||i.generateDepthBuffer)&&i.generateStencilBuffer,void 0!==i.samplingMode&&(h=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=h;var u,l=r(h,s,n);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,o);for(var f=0;f<6;f++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,n.RGBA,t,t,0,n.RGBA,n.UNSIGNED_BYTE,null);n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,l.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,l.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),c?(u=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,u),n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,t,t)):a&&(u=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,u),n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,t,t));var d=n.createFramebuffer();return this.bindUnboundFramebuffer(d),c?n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,u):a&&n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,u),o.generateMipMaps&&(this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,o),n.generateMipmap(n.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),n.bindRenderbuffer(n.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=d,a&&(o._depthBuffer=u),o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},o.prototype.createCubeTexture=function(t,i,r,n,o,a){var c=this;void 0===o&&(o=null),void 0===a&&(a=null);var h=this._gl,u=h.createTexture();u.isCube=!0,u.url=t,u.references=1,u.onLoadedCallbacks=[];var l=t.substr(t.length-4,4).toLowerCase();return this.getCaps().s3tc&&".dds"===l?e.Tools.LoadFile(t,function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;c._bindTextureDirectly(h.TEXTURE_CUBE_MAP,u),h.pixelStorei(h.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(c._gl,c.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||h.generateMipmap(h.TEXTURE_CUBE_MAP),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,r?h.LINEAR_MIPMAP_LINEAR:h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),c._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null),c.resetTextureCache(),u._width=i.width,u._height=i.height,u.isReady=!0},null,null,!0,a):s(0,i,function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,c._caps.maxCubemapTextureSize),r=i;c._prepareWorkingCanvas(),c._workingCanvas.width=i,c._workingCanvas.height=r;var s=[h.TEXTURE_CUBE_MAP_POSITIVE_X,h.TEXTURE_CUBE_MAP_POSITIVE_Y,h.TEXTURE_CUBE_MAP_POSITIVE_Z,h.TEXTURE_CUBE_MAP_NEGATIVE_X,h.TEXTURE_CUBE_MAP_NEGATIVE_Y,h.TEXTURE_CUBE_MAP_NEGATIVE_Z];c._bindTextureDirectly(h.TEXTURE_CUBE_MAP,u),h.pixelStorei(h.UNPACK_FLIP_Y_WEBGL,0);for(var a=0;a<s.length;a++)c._workingContext.drawImage(t[a],0,0,t[a].width,t[a].height,0,0,i,r),h.texImage2D(s[a],0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,c._workingCanvas);n||h.generateMipmap(h.TEXTURE_CUBE_MAP),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,n?h.LINEAR:h.LINEAR_MIPMAP_LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),c._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null),c.resetTextureCache(),u._width=i,u._height=r,u.isReady=!0,u.onLoadedCallbacks.forEach(function(e){e()}),o&&o()},r,a),this._loadedTexturesCache.push(u),u},o.prototype.updateTextureSize=function(e,t,i){e._width=t,e._height=i,e._size=t*i,e._baseWidth=t,e._baseHeight=i},o.prototype.createRawCubeTexture=function(t,i,r,n,s,a,c,h){var u=this,l=this._gl,f=l.createTexture();i._addPendingData(f),f.isCube=!0,f.references=1,f.url=t;var d=this._getInternalFormat(n),p=l.UNSIGNED_BYTE;s===o.TEXTURETYPE_FLOAT&&(p=l.FLOAT);var m=r,g=m,_=e.Tools.IsExponentOfTwo(m)&&e.Tools.IsExponentOfTwo(g);f._width=m,f._height=g;var v=function(t){var r=c(t),n=[l.TEXTURE_CUBE_MAP_POSITIVE_X,l.TEXTURE_CUBE_MAP_POSITIVE_Y,l.TEXTURE_CUBE_MAP_POSITIVE_Z,l.TEXTURE_CUBE_MAP_NEGATIVE_X,l.TEXTURE_CUBE_MAP_NEGATIVE_Y,l.TEXTURE_CUBE_MAP_NEGATIVE_Z];if(m=f._width,g=f._height,_=e.Tools.IsExponentOfTwo(m)&&e.Tools.IsExponentOfTwo(g),u._bindTextureDirectly(l.TEXTURE_CUBE_MAP,f),l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,0),!a&&_)if(h){var o=[];o.push(r[0]),o.push(r[3]),o.push(r[1]),o.push(r[4]),o.push(r[2]),o.push(r[5]);for(var s=h(o),v=0;v<s.length;v++){var y=m>>v;l.texImage2D(n[0],v,d,y,y,0,d,p,s[v][0]),l.texImage2D(n[1],v,d,y,y,0,d,p,s[v][2]),l.texImage2D(n[2],v,d,y,y,0,d,p,s[v][4]),l.texImage2D(n[3],v,d,y,y,0,d,p,s[v][1]),l.texImage2D(n[4],v,d,y,y,0,d,p,s[v][3]),l.texImage2D(n[5],v,d,y,y,0,d,p,s[v][5])}}else{for(var b=0;b<n.length;b++){var x=r[b];l.texImage2D(n[b],0,d,m,g,0,d,p,x)}if(l.generateMipmap(l.TEXTURE_CUBE_MAP),p===l.FLOAT&&d===l.RGB&&1282===l.getError()){e.Tools.Log("RGB32F not renderable on Firefox, trying fallback to RGBA32F.");for(b=0;b<n.length;b++){x=r[b];for(var w=new Float32Array(m*g*4),S=0;S<m;S++)for(var T=0;T<g;T++){var A=3*(T*m+S),M=4*(T*m+S);w[M+0]=x[A+0],w[M+1]=x[A+1],w[M+2]=x[A+2],w[M+3]=1}l.texImage2D(n[b],0,l.RGBA,m,g,0,l.RGBA,p,w)}l.generateMipmap(l.TEXTURE_CUBE_MAP)}}else a=!0;p===l.FLOAT&&!u._caps.textureFloatLinearFiltering||36193===p&&!u._caps.textureHalfFloatLinearFiltering?(l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,l.NEAREST)):(l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,a?l.LINEAR:l.LINEAR_MIPMAP_LINEAR)),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),u._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),f.isReady=!0,u.resetTextureCache(),i._removePendingData(f)};return e.Tools.LoadFile(t,function(e){v(e)},function(){i._removePendingData(f)},i.database,!0),f},o.prototype._releaseTexture=function(e){var t=this._gl;e._framebuffer&&t.deleteFramebuffer(e._framebuffer),e._depthBuffer&&t.deleteRenderbuffer(e._depthBuffer),t.deleteTexture(e),this.unbindAllTextures();var i=this._loadedTexturesCache.indexOf(e);-1!==i&&this._loadedTexturesCache.splice(i,1)},o.prototype.setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},o.prototype.bindSamplers=function(e){this.setProgram(e.getProgram());for(var t=e.getSamplers(),i=0;i<t.length;i++){var r=e.getUniform(t[i]);this._gl.uniform1i(r,i)}this._currentEffect=null},o.prototype.activateTexture=function(e){this._activeTexture!==e&&(this._gl.activeTexture(e),this._activeTexture=e)},o.prototype._bindTextureDirectly=function(e,t){this._activeTexturesCache[this._activeTexture]!==t&&(this._gl.bindTexture(e,t),this._activeTexturesCache[this._activeTexture]=t)},o.prototype._bindTexture=function(e,t){e<0||(this.activateTexture(this._gl["TEXTURE"+e]),this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},o.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t._textures.data[t._currentRenderTextureInd])},o.prototype.unbindAllTextures=function(){for(var e=0;e<this._caps.maxTexturesImageUnits;e++)this.activateTexture(this._gl["TEXTURE"+e]),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)},o.prototype.setTexture=function(e,t,i){e<0||(this._gl.uniform1i(t,e),this._setTexture(e,i))},o.prototype._setTexture=function(t,i){if(i&&i.isReady()){var r=!1;if(i instanceof e.VideoTexture)this.activateTexture(this._gl["TEXTURE"+t]),r=!0,i.update();else if(i.delayLoadState===o.DELAYLOADSTATE_NOTLOADED)return void i.delayLoad();var n=i.getInternalTexture();if(this._activeTexturesCache[t]!==n)if(r||this.activateTexture(this._gl["TEXTURE"+t]),n.isCube){if(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,n),n._cachedCoordinatesMode!==i.coordinatesMode){n._cachedCoordinatesMode=i.coordinatesMode;var s=i.coordinatesMode!==e.Texture.CUBIC_MODE&&i.coordinatesMode!==e.Texture.SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,s),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,s)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,i)}else{if(this._bindTextureDirectly(this._gl.TEXTURE_2D,n),n._cachedWrapU!==i.wrapU)switch(n._cachedWrapU=i.wrapU,i.wrapU){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.MIRRORED_REPEAT)}if(n._cachedWrapV!==i.wrapV)switch(n._cachedWrapV=i.wrapV,i.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.MIRRORED_REPEAT)}this._setAnisotropicLevel(this._gl.TEXTURE_2D,i)}}else null!=this._activeTexturesCache[t]&&(this.activateTexture(this._gl["TEXTURE"+t]),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null))},o.prototype.setTextureArray=function(e,t,i){if(!(e<0)){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var r=0;r<i.length;r++)this._textureUnits[r]=e+r;this._gl.uniform1iv(t,this._textureUnits);for(var n=0;n<i.length;n++)this._setTexture(e+n,i[n])}},o.prototype._setAnisotropicLevel=function(t,i){var r=this._caps.textureAnisotropicFilterExtension,n=i.anisotropicFilteringLevel;i.getInternalTexture().samplingMode===e.Texture.NEAREST_SAMPLINGMODE&&(n=1),r&&i._cachedAnisotropicFilteringLevel!==n&&(this._gl.texParameterf(t,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(n,this._caps.maxAnisotropy)),i._cachedAnisotropicFilteringLevel=n)},o.prototype.readPixels=function(e,t,i,r){var n=new Uint8Array(r*i*4);return this._gl.readPixels(e,t,i,r,this._gl.RGBA,this._gl.UNSIGNED_BYTE,n),n},o.prototype.addExternalData=function(e,t){return this._externalData.add(e,t)},o.prototype.getExternalData=function(e){return this._externalData.get(e)},o.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData.getOrAddWithFactory(e,t)},o.prototype.removeExternalData=function(e){return this._externalData.remove(e)},o.prototype.releaseInternalTexture=function(e){if(e&&(e.references--,0===e.references)){var t=this.getLoadedTexturesCache(),i=t.indexOf(e);i>-1&&t.splice(i,1),this._releaseTexture(e)}},o.prototype.unbindAllAttributes=function(){for(var e=0,t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1)},o.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();for(var e in o.audioEngine.dispose(),this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this.unbindAllAttributes(),this._gl=null,this.disableVR(),window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange)},o.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},o.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(o.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),o.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},o.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},o.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},o.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},o.prototype.getFps=function(){return this.fps},o.prototype.getDeltaTime=function(){return this.deltaTime},o.prototype._measureFps=function(){this.previousFramesDuration.push(e.Tools.Now);var t=this.previousFramesDuration.length;if(t>=2&&(this.deltaTime=this.previousFramesDuration[t-1]-this.previousFramesDuration[t-2]),t>=this.fpsRange){t>this.fpsRange&&(this.previousFramesDuration.splice(0,1),t=this.previousFramesDuration.length);for(var i=0,r=0;r<t-1;r++)i+=this.previousFramesDuration[r+1]-this.previousFramesDuration[r];this.fps=1e3/(i/(t-1))}},o.prototype._canRenderToFloatTexture=function(){return this._canRenderToTextureOfType(e.Engine.TEXTURETYPE_FLOAT,"OES_texture_float")},o.prototype._canRenderToHalfFloatTexture=function(){return this._canRenderToTextureOfType(e.Engine.TEXTURETYPE_HALF_FLOAT,"OES_texture_half_float")},o.prototype._canRenderToTextureOfType=function(t,r){var n=document.createElement("canvas");n.height=16,n.width=16;var o=n.getContext("webgl")||n.getContext("experimental-webgl");if(!o.getExtension(r))return!1;var s=this.createShaderProgram("attribute vec4 a_position;\n void main() {\n gl_Position = a_position;\n }","precision mediump float;\n uniform vec4 u_color;\n uniform sampler2D u_texture;\n\n void main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n }",null,o);o.useProgram(s);var a=o.getAttribLocation(s,"a_position"),c=o.getUniformLocation(s,"u_color"),h=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,h),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),o.STATIC_DRAW),o.enableVertexAttribArray(a),o.vertexAttribPointer(a,2,o.FLOAT,!1,0,0);var u=o.createTexture();o.bindTexture(o.TEXTURE_2D,u),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,1,1,0,o.RGBA,o.UNSIGNED_BYTE,new Uint8Array([255,255,255,255]));var l=o.createTexture();o.bindTexture(o.TEXTURE_2D,l),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,1,1,0,o.RGBA,i(o,t),null),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST);var f=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,f),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,l,0);var d=function(){o.deleteProgram(s),o.disableVertexAttribArray(a),o.deleteBuffer(h),o.deleteFramebuffer(f),o.deleteTexture(u),o.deleteTexture(l)};if(o.checkFramebufferStatus(o.FRAMEBUFFER)!==o.FRAMEBUFFER_COMPLETE)return e.Tools.Log("GL Support: can **NOT** render to "+t+" texture"),d(),!1;o.bindTexture(o.TEXTURE_2D,u),o.uniform4fv(c,[0,10,20,1]),o.drawArrays(o.TRIANGLES,0,6),o.bindTexture(o.TEXTURE_2D,l),o.bindFramebuffer(o.FRAMEBUFFER,null),o.clearColor(1,0,0,1),o.clear(o.COLOR_BUFFER_BIT),o.uniform4fv(c,[0,.1,.05,1]),o.drawArrays(o.TRIANGLES,0,6);var p=new Uint8Array(4);return o.readPixels(0,0,1,1,o.RGBA,o.UNSIGNED_BYTE,p),0!==p[0]||p[1]<248||p[2]<248||p[3]<254?(e.Tools.Log("GL Support: Was not able to actually render to "+t+" texture"),d(),!1):(d(),!0)},o.isSupported=function(){try{if(navigator.isCocoonJS)return!0;var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},o._ALPHA_DISABLE=0,o._ALPHA_ADD=1,o._ALPHA_COMBINE=2,o._ALPHA_SUBTRACT=3,o._ALPHA_MULTIPLY=4,o._ALPHA_MAXIMIZED=5,o._ALPHA_ONEONE=6,o._DELAYLOADSTATE_NONE=0,o._DELAYLOADSTATE_LOADED=1,o._DELAYLOADSTATE_LOADING=2,o._DELAYLOADSTATE_NOTLOADED=4,o._TEXTUREFORMAT_ALPHA=0,o._TEXTUREFORMAT_LUMINANCE=1,o._TEXTUREFORMAT_LUMINANCE_ALPHA=2,o._TEXTUREFORMAT_RGB=4,o._TEXTUREFORMAT_RGBA=5,o._TEXTURETYPE_UNSIGNED_INT=0,o._TEXTURETYPE_FLOAT=1,o._TEXTURETYPE_HALF_FLOAT=2,o._NEVER=512,o._ALWAYS=519,o._LESS=513,o._EQUAL=514,o._LEQUAL=515,o._GREATER=516,o._GEQUAL=518,o._NOTEQUAL=517,o._KEEP=7680,o._REPLACE=7681,o._INCR=7682,o._DECR=7683,o._INVERT=5386,o._INCR_WRAP=34055,o._DECR_WRAP=34056,o.CollisionsEpsilon=.001,o.CodeRepository="src/",o.ShadersRepository="src/Shaders/",o}();e.Engine=h}(s||(s={})),function(e){var t=function(){function t(t,i){this.state="",this.metadata=null,this.doNotSerialize=!1,this.animations=new Array,this._ranges={},this._childrenFlag=-1,this._isEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this.onDisposeObservable=new e.Observable,this.name=t,this.id=t,this._scene=i,this._initCache()}return Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){if(this._parentNode){var t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1)}this._parentNode=e,this._parentNode&&(this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this))}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._scene.getEngine()},t.prototype.getWorldMatrix=function(){return e.Matrix.Identity()},t.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},t.prototype.updateCache=function(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},t.prototype._updateCache=function(e){},t.prototype._isSynchronized=function(){return!0},t.prototype._markSyncedWithParent=function(){this._parentRenderId=this.parent._currentRenderId},t.prototype.isSynchronizedWithParent=function(){return!this.parent||this._parentRenderId===this.parent._currentRenderId&&this.parent.isSynchronized()},t.prototype.isSynchronized=function(e){var t=this.hasNewParent();return t=(t=t||!this.isSynchronizedWithParent())||!this._isSynchronized(),e&&this.updateCache(!0),!t},t.prototype.hasNewParent=function(e){return this._cache.parent!==this.parent&&(e&&(this._cache.parent=this.parent),!0)},t.prototype.isReady=function(){return this._isReady},t.prototype.isEnabled=function(){return!!this._isEnabled&&(!this.parent||this.parent.isEnabled())},t.prototype.setEnabled=function(e){this._isEnabled=e},t.prototype.isDescendantOf=function(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))},t.prototype._getDescendants=function(e,t,i){if(void 0===t&&(t=!1),this._children)for(var r=0;r<this._children.length;r++){var n=this._children[r];i&&!i(n)||e.push(n),t||n._getDescendants(e,!1,i)}},t.prototype.getDescendants=function(e,t){var i=[];return this._getDescendants(i,e,t),i},t.prototype.getChildren=function(e){return this.getDescendants(!0,e)},t.prototype.getChildMeshes=function(t,i){var r=[];return this._getDescendants(r,t,function(t){return(!i||i(t))&&t instanceof e.AbstractMesh}),r},t.prototype._setReady=function(e){if(e!==this._isReady){if(!e)return void(this._isReady=!1);this._isReady=!0,this.onReady&&this.onReady(this)}},t.prototype.getAnimationByName=function(e){for(var t=0;t<this.animations.length;t++){var i=this.animations[t];if(i.name===e)return i}return null},t.prototype.createAnimationRange=function(t,i,r){if(!this._ranges[t]){this._ranges[t]=new e.AnimationRange(t,i,r);for(var n=0,o=this.animations.length;n<o;n++)this.animations[n]&&this.animations[n].createRange(t,i,r)}},t.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.animations.length;i<r;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=void 0},t.prototype.getAnimationRange=function(e){return this._ranges[e]},t.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?void this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},t.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var i={};i.name=t,i.from=this._ranges[t].from,i.to=this._ranges[t].to,e.push(i)}return e},t.prototype.dispose=function(){this.parent=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.ParseAnimationRanges=function(e,t,i){if(t.ranges)for(var r=0;r<t.ranges.length;r++){var n=t.ranges[r];e.createAnimationRange(n.name,n.from,n.to)}},a([e.serialize()],t.prototype,"name",void 0),a([e.serialize()],t.prototype,"id",void 0),a([e.serialize()],t.prototype,"uniqueId",void 0),a([e.serialize()],t.prototype,"state",void 0),a([e.serialize()],t.prototype,"metadata",void 0),t}();e.Node=t}(s||(s={})),function(e){var t=function(){function t(e,t,i,r,n,o,s,a){this._engine=e,this._canvas=i,this._currentScene=t,this._sceneLoadedCallback=r,this._progressCallback=n,this._additionnalRenderLoopLogicCallback=o,this._textureLoadingCallback=s,this._startingProcessingFilesCallback=a}return t.prototype.monitorElementForDragNDrop=function(e){var t=this;e&&(this._elementToMonitor=e,this._elementToMonitor.addEventListener("dragenter",function(e){t.drag(e)},!1),this._elementToMonitor.addEventListener("dragover",function(e){t.drag(e)},!1),this._elementToMonitor.addEventListener("drop",function(e){t.drop(e)},!1))},t.prototype.renderFunction=function(){if(this._additionnalRenderLoopLogicCallback&&this._additionnalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var e=this._currentScene.getWaitingItemsCount();e>0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype.loadFiles=function(e){if(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(),e&&e.dataTransfer&&e.dataTransfer.files&&(this._filesToLoad=e.dataTransfer.files),e&&e.target&&e.target.files&&(this._filesToLoad=e.target.files),this._filesToLoad&&this._filesToLoad.length>0){for(var i=0;i<this._filesToLoad.length;i++)switch(this._filesToLoad[i].type){case"image/jpeg":case"image/png":case"image/bmp":t.FilesTextures[this._filesToLoad[i].name.toLowerCase()]=this._filesToLoad[i];break;case"image/targa":case"image/vnd.ms-dds":case"audio/wav":case"audio/x-wav":case"audio/mp3":case"audio/mpeg":case"audio/mpeg3":case"audio/x-mpeg-3":case"audio/ogg":t.FilesToLoad[this._filesToLoad[i].name.toLowerCase()]=this._filesToLoad[i];break;default:-1!==this._filesToLoad[i].name.indexOf(".mtl")?t.FilesToLoad[this._filesToLoad[i].name.toLowerCase()]=this._filesToLoad[i]:-1===this._filesToLoad[i].name.indexOf(".babylon")&&-1===this._filesToLoad[i].name.indexOf(".stl")&&-1===this._filesToLoad[i].name.indexOf(".obj")||-1!==this._filesToLoad[i].name.indexOf(".manifest")||-1!==this._filesToLoad[i].name.indexOf(".incremental")||-1!==this._filesToLoad[i].name.indexOf(".babylonmeshdata")||-1!==this._filesToLoad[i].name.indexOf(".babylongeometrydata")||-1!==this._filesToLoad[i].name.indexOf(".babylonbinarymeshdata")||-1!==this._filesToLoad[i].name.indexOf(".binary.babylon")||(this._sceneFileToLoad=this._filesToLoad[i])}this.reload()}},t.prototype.reload=function(){var t=this,i=this;this._sceneFileToLoad?(this._currentScene&&(e.Tools.errorsCount>0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,function(e){i._currentScene=e,i._currentScene.executeWhenReady(function(){i._currentScene.activeCamera&&0!==i._currentScene.lights.length||i._currentScene.createDefaultCameraOrLight(),i._currentScene.activeCamera.attachControl(i._canvas),i._sceneLoadedCallback&&i._sceneLoadedCallback(t._sceneFileToLoad,i._currentScene),i._engine.runRenderLoop(function(){i.renderFunction()})})},function(e){t._progressCallback&&t._progressCallback(e)})):e.Tools.Error("Please provide a valid .babylon file.")},t.FilesTextures=new Array,t.FilesToLoad=new Array,t}();e.FilesInput=t}(s||(s={})),function(e){var t=function(){return function(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}}();e.IntersectionInfo=t;var i=function(){function t(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshId=0,this.pickedSprite=null}return t.prototype.getNormal=function(t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.NormalKind))return null;var r,n=this.pickedMesh.getIndices();if(i){var o=this.pickedMesh.getVerticesData(e.VertexBuffer.NormalKind),s=e.Vector3.FromArray(o,3*n[3*this.faceId]),a=e.Vector3.FromArray(o,3*n[3*this.faceId+1]),c=e.Vector3.FromArray(o,3*n[3*this.faceId+2]);s=s.scale(this.bu),a=a.scale(this.bv),c=c.scale(1-this.bu-this.bv),r=new e.Vector3(s.x+a.x+c.x,s.y+a.y+c.y,s.z+a.z+c.z)}else{var h=this.pickedMesh.getVerticesData(e.VertexBuffer.PositionKind),u=e.Vector3.FromArray(h,3*n[3*this.faceId]),l=e.Vector3.FromArray(h,3*n[3*this.faceId+1]),f=e.Vector3.FromArray(h,3*n[3*this.faceId+2]),d=u.subtract(l),p=f.subtract(l);r=e.Vector3.Cross(d,p)}return t&&(r=e.Vector3.TransformNormal(r,this.pickedMesh.getWorldMatrix())),e.Vector3.Normalize(r)},t.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.UVKind))return null;var t=this.pickedMesh.getIndices(),i=this.pickedMesh.getVerticesData(e.VertexBuffer.UVKind),r=e.Vector2.FromArray(i,2*t[3*this.faceId]),n=e.Vector2.FromArray(i,2*t[3*this.faceId+1]),o=e.Vector2.FromArray(i,2*t[3*this.faceId+2]);return r=r.scale(1-this.bu-this.bv),n=n.scale(this.bu),o=o.scale(this.bv),new e.Vector2(r.x+n.x+o.x,r.y+n.y+o.y)},t}();e.PickingInfo=i}(s||(s={})),function(e){var t=function(){function t(t,i){this.minimum=t,this.maximum=i,this._tempRadiusVector=e.Vector3.Zero();var r=e.Vector3.Distance(t,i);this.center=e.Vector3.Lerp(t,i,.5),this.radius=.5*r,this.centerWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype._update=function(t){e.Vector3.TransformCoordinatesToRef(this.center,t,this.centerWorld),e.Vector3.TransformNormalFromFloatsToRef(1,1,1,t,this._tempRadiusVector),this.radiusWorld=Math.max(Math.abs(this._tempRadiusVector.x),Math.abs(this._tempRadiusVector.y),Math.abs(this._tempRadiusVector.z))*this.radius},t.prototype.isInFrustum=function(e){for(var t=0;t<6;t++)if(e[t].dotCoordinate(this.centerWorld)<=-this.radiusWorld)return!1;return!0},t.prototype.intersectsPoint=function(t){var i=this.centerWorld.x-t.x,r=this.centerWorld.y-t.y,n=this.centerWorld.z-t.z,o=Math.sqrt(i*i+r*r+n*n);return!(Math.abs(this.radiusWorld-o)<e.Epsilon)},t.Intersects=function(e,t){var i=e.centerWorld.x-t.centerWorld.x,r=e.centerWorld.y-t.centerWorld.y,n=e.centerWorld.z-t.centerWorld.z,o=Math.sqrt(i*i+r*r+n*n);return!(e.radiusWorld+t.radiusWorld<o)},t}();e.BoundingSphere=t}(s||(s={})),function(e){var t=function(){function t(t,i){this.minimum=t,this.maximum=i,this.vectors=new Array,this.vectorsWorld=new Array,this.vectors.push(this.minimum.clone()),this.vectors.push(this.maximum.clone()),this.vectors.push(this.minimum.clone()),this.vectors[2].x=this.maximum.x,this.vectors.push(this.minimum.clone()),this.vectors[3].y=this.maximum.y,this.vectors.push(this.minimum.clone()),this.vectors[4].z=this.maximum.z,this.vectors.push(this.maximum.clone()),this.vectors[5].z=this.minimum.z,this.vectors.push(this.maximum.clone()),this.vectors[6].x=this.minimum.x,this.vectors.push(this.maximum.clone()),this.vectors[7].y=this.minimum.y,this.center=this.maximum.add(this.minimum).scale(.5),this.extendSize=this.maximum.subtract(this.minimum).scale(.5),this.directions=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()];for(var r=0;r<this.vectors.length;r++)this.vectorsWorld[r]=e.Vector3.Zero();this.minimumWorld=e.Vector3.Zero(),this.maximumWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype.getWorldMatrix=function(){return this._worldMatrix},t.prototype.setWorldMatrix=function(e){return this._worldMatrix.copyFrom(e),this},t.prototype._update=function(t){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this.minimumWorld),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this.maximumWorld);for(var i=0;i<this.vectors.length;i++){var r=this.vectorsWorld[i];e.Vector3.TransformCoordinatesToRef(this.vectors[i],t,r),r.x<this.minimumWorld.x&&(this.minimumWorld.x=r.x),r.y<this.minimumWorld.y&&(this.minimumWorld.y=r.y),r.z<this.minimumWorld.z&&(this.minimumWorld.z=r.z),r.x>this.maximumWorld.x&&(this.maximumWorld.x=r.x),r.y>this.maximumWorld.y&&(this.maximumWorld.y=r.y),r.z>this.maximumWorld.z&&(this.maximumWorld.z=r.z)}this.maximumWorld.addToRef(this.minimumWorld,this.center),this.center.scaleInPlace(.5),e.Vector3.FromFloatArrayToRef(t.m,0,this.directions[0]),e.Vector3.FromFloatArrayToRef(t.m,4,this.directions[1]),e.Vector3.FromFloatArrayToRef(t.m,8,this.directions[2]),this._worldMatrix=t},t.prototype.isInFrustum=function(e){return t.IsInFrustum(this.vectorsWorld,e)},t.prototype.isCompletelyInFrustum=function(e){return t.IsCompletelyInFrustum(this.vectorsWorld,e)},t.prototype.intersectsPoint=function(t){var i=-e.Epsilon;return!(this.maximumWorld.x-t.x<i||i>t.x-this.minimumWorld.x||this.maximumWorld.y-t.y<i||i>t.y-this.minimumWorld.y||this.maximumWorld.z-t.z<i||i>t.z-this.minimumWorld.z)},t.prototype.intersectsSphere=function(e){return t.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)},t.prototype.intersectsMinMax=function(e,t){return!(this.maximumWorld.x<e.x||this.minimumWorld.x>t.x||this.maximumWorld.y<e.y||this.minimumWorld.y>t.y||this.maximumWorld.z<e.z||this.minimumWorld.z>t.z)},t.Intersects=function(e,t){return!(e.maximumWorld.x<t.minimumWorld.x||e.minimumWorld.x>t.maximumWorld.x||e.maximumWorld.y<t.minimumWorld.y||e.minimumWorld.y>t.maximumWorld.y||e.maximumWorld.z<t.minimumWorld.z||e.minimumWorld.z>t.maximumWorld.z)},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i);return e.Vector3.DistanceSquared(r,o)<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&t[i].dotCoordinate(e[n])<0;n++)--r;if(0===r)return!1}return!0},t}();e.BoundingBox=t}(s||(s={})),function(e){var t=function(t,i){var r=e.Vector3.Dot(i.center,t),n=Math.abs(e.Vector3.Dot(i.directions[0],t))*i.extendSize.x+Math.abs(e.Vector3.Dot(i.directions[1],t))*i.extendSize.y+Math.abs(e.Vector3.Dot(i.directions[2],t))*i.extendSize.z;return{min:r-n,max:r+n}},i=function(e,i,r){var n=t(e,i),o=t(e,r);return function(e,t,i,r){return!(e>r||i>t)}(n.min,n.max,o.min,o.max)},r=function(){function t(t,i){this.minimum=t,this.maximum=i,this._isLocked=!1,this.boundingBox=new e.BoundingBox(t,i),this.boundingSphere=new e.BoundingSphere(t,i)}return Object.defineProperty(t.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),t.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},t.prototype.isInFrustum=function(e){return!!this.boundingSphere.isInFrustum(e)&&this.boundingBox.isInFrustum(e)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e)},t.prototype.intersects=function(t,r){if(!this.boundingSphere.centerWorld||!t.boundingSphere.centerWorld)return!1;if(!e.BoundingSphere.Intersects(this.boundingSphere,t.boundingSphere))return!1;if(!e.BoundingBox.Intersects(this.boundingBox,t.boundingBox))return!1;if(!r)return!0;var n=this.boundingBox,o=t.boundingBox;return!!(i(n.directions[0],n,o)&&i(n.directions[1],n,o)&&i(n.directions[2],n,o)&&i(o.directions[0],n,o)&&i(o.directions[1],n,o)&&i(o.directions[2],n,o)&&i(e.Vector3.Cross(n.directions[0],o.directions[0]),n,o)&&i(e.Vector3.Cross(n.directions[0],o.directions[1]),n,o)&&i(e.Vector3.Cross(n.directions[0],o.directions[2]),n,o)&&i(e.Vector3.Cross(n.directions[1],o.directions[0]),n,o)&&i(e.Vector3.Cross(n.directions[1],o.directions[1]),n,o)&&i(e.Vector3.Cross(n.directions[1],o.directions[2]),n,o)&&i(e.Vector3.Cross(n.directions[2],o.directions[0]),n,o)&&i(e.Vector3.Cross(n.directions[2],o.directions[1]),n,o)&&i(e.Vector3.Cross(n.directions[2],o.directions[2]),n,o))},t}();e.BoundingInfo=r}(s||(s={})),function(e){var t=function(){function t(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i,this._show=!1}return t.prototype.intersectsBoxMinMax=function(e,t){var i,r,n,o,s=0,a=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<e.x||this.origin.x>t.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,(n=(t.x-this.origin.x)*i)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,a)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<e.y||this.origin.y>t.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,(n=(t.y-this.origin.y)*i)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,a)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<e.z||this.origin.z>t.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,(n=(t.z-this.origin.z)*i)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,a)))return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(s<0)&&n-s*s<=o},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||s+a>1)return null;var c=e.Vector3.Dot(this._edge2,this._qvec)*o;return c>this.length?null:new e.IntersectionInfo(s,a,c)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return(i=(-t.d-n)/r)<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.show=function(t,i){this._show||(this._renderFunction=this._render.bind(this),this._show=!0,this._scene=t,this._renderPoints=[this.origin,this.origin.add(this.direction.scale(this.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)),i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._show&&(this._show=!1,this._scene.unregisterBeforeRender(this._renderFunction)),this._renderLine&&(this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this._renderPoints[1];t.copyFrom(this.direction),t.scaleInPlace(this.length),t.addInPlace(this.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.intersectionSegment=function(i,r,n){var o,s,a,c,h=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),u=r.subtract(i),l=h.subtract(this.origin),f=i.subtract(this.origin),d=e.Vector3.Dot(u,u),p=e.Vector3.Dot(u,l),m=e.Vector3.Dot(l,l),g=e.Vector3.Dot(u,f),_=e.Vector3.Dot(l,f),v=d*m-p*p,y=v,b=v;v<t.smallnum?(s=0,y=1,c=_,b=m):(c=d*_-p*g,(s=p*_-m*g)<0?(s=0,c=_,b=m):s>y&&(s=y,c=_+p,b=m)),c<0?(c=0,-g<0?s=0:-g>d?s=y:(s=-g,y=d)):c>b&&(c=b,-g+p<0?s=0:-g+p>d?s=y:(s=-g+p,y=d)),o=Math.abs(s)<t.smallnum?0:s/y,a=Math.abs(c)<t.smallnum?0:c/b;var x=l.multiplyByFloats(a,a,a),w=f.add(u.multiplyByFloats(o,o,o)).subtract(x);return a>0&&a<=this.length&&w.lengthSquared()<n*n?x.length():-1},t.CreateNew=function(i,r,n,o,s,a,c){var h=e.Vector3.Unproject(new e.Vector3(i,r,0),n,o,s,a,c),u=e.Vector3.Unproject(new e.Vector3(i,r,1),n,o,s,a,c).subtract(h);return u.normalize(),new t(h,u)},t.CreateNewFromTo=function(i,r,n){void 0===n&&(n=e.Matrix.Identity());var o=r.subtract(i),s=Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z);return o.normalize(),t.Transform(new t(i,o,s),n)},t.Transform=function(i,r){var n=e.Vector3.TransformCoordinates(i.origin,r),o=e.Vector3.TransformNormal(i.direction,r);return o.normalize(),new t(n,o,i.length)},t.TransformToRef=function(t,i,r){e.Vector3.TransformCoordinatesToRef(t.origin,i,r.origin),e.Vector3.TransformNormalToRef(t.direction,i,r.direction),t.direction.normalize()},t.smallnum=1e-8,t.rayl=1e9,t}();e.Ray=t}(s||(s={})),function(e){var t=function(t){function i(r,n){var o=this;t.call(this,r,n),this.onCollideObservable=new e.Observable,this.onCollisionPositionChangeObservable=new e.Observable,this.onAfterWorldMatrixUpdateObservable=new e.Observable,this.definedFacingForward=!0,this.position=new e.Vector3(0,0,0),this._rotation=new e.Vector3(0,0,0),this._scaling=new e.Vector3(1,1,1),this.billboardMode=i.BILLBOARDMODE_NONE,this.visibility=1,this.alphaIndex=Number.MAX_VALUE,this.infiniteDistance=!1,this.isVisible=!0,this.isPickable=!0,this.showBoundingBox=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.renderingGroupId=0,this.receiveShadows=!1,this.renderOutline=!1,this.outlineColor=e.Color3.Red(),this.outlineWidth=.02,this.renderOverlay=!1,this.overlayColor=e.Color3.Red(),this.overlayAlpha=.5,this.hasVertexAlpha=!1,this.useVertexColors=!0,this.applyFog=!0,this.computeBonesUsingShaders=!0,this.scalingDeterminant=1,this.numBoneInfluencers=4,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.layerMask=268435455,this.alwaysSelectAsActiveMesh=!1,this._checkCollisions=!1,this.ellipsoid=new e.Vector3(.5,1,.5),this.ellipsoidOffset=new e.Vector3(0,0,0),this._collider=new e.Collider,this._oldPositionForCollisions=new e.Vector3(0,0,0),this._diffPositionForCollisions=new e.Vector3(0,0,0),this._newPositionForCollisions=new e.Vector3(0,0,0),this.edgesWidth=1,this.edgesColor=new e.Color4(1,0,0,1),this._localWorld=e.Matrix.Zero(),this._worldMatrix=e.Matrix.Zero(),this._rotateYByPI=e.Matrix.RotationY(Math.PI),this._absolutePosition=e.Vector3.Zero(),this._collisionsTransformMatrix=e.Matrix.Zero(),this._collisionsScalingMatrix=e.Matrix.Zero(),this._isDirty=!1,this._pivotMatrix=e.Matrix.Identity(),this._isDisposed=!1,this._renderId=0,this._intersectionsInProgress=new Array,this._isWorldMatrixFrozen=!1,this._unIndexed=!1,this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider.radius),i.subtractToRef(o._oldPositionForCollisions,o._diffPositionForCollisions),o._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(this)}return c(i,t),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return i._BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return i._BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return i._BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return i._BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return i._BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._skeleton},set:function(e){this._skeleton&&this._skeleton.needInitialSkinMatrix&&this._skeleton._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._skeleton=e,this._skeleton||(this._bonesTransformMatrices=null)},enumerable:!0,configurable:!0}),i.prototype.toString=function(t){var i="Name: "+this.name+", isInstance: "+(this instanceof e.InstancedMesh?"YES":"NO");return i+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0),this._skeleton&&(i+=", skeleton: "+this._skeleton.name),t&&(i+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],i+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingFreezeWorldMatrix?"YES":"NO")),i},Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this.physicsImpostor&&this.physicsImpostor.forceUpdate()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this.rotation.length()&&this.rotation.copyFromFloats(0,0,0)},enumerable:!0,configurable:!0}),i.prototype.updatePoseMatrix=function(e){this._poseMatrix.copyFrom(e)},i.prototype.getPoseMatrix=function(){return this._poseMatrix},i.prototype.disableEdgesRendering=function(){void 0!==this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=void 0)},i.prototype.enableEdgesRendering=function(t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.disableEdgesRendering(),this._edgesRenderer=new e.EdgesRenderer(this,t,i)},Object.defineProperty(i.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.getLOD=function(e){return this},i.prototype.getTotalVertices=function(){return 0},i.prototype.getIndices=function(){return null},i.prototype.getVerticesData=function(e){return null},i.prototype.isVerticesDataPresent=function(e){return!1},i.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},i.prototype.setBoundingInfo=function(e){this._boundingInfo=e},Object.defineProperty(i.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)},enumerable:!0,configurable:!0}),i.prototype._preActivate=function(){},i.prototype._preActivateForIntermediateRendering=function(e){},i.prototype._activate=function(e){this._renderId=e},i.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():(this._currentRenderId!==this.getScene().getRenderId()&&this.computeWorldMatrix(),this._worldMatrix)},Object.defineProperty(i.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),i.prototype.freezeWorldMatrix=function(){this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0},i.prototype.unfreezeWorldMatrix=function(){this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)},Object.defineProperty(i.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),i.prototype.rotate=function(t,r,n){var o;if(t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero()),n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}(o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache)).multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion)},i.prototype.translate=function(t,i,r){var n=t.scale(i);if(r&&r!==e.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var o=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(o)}},i.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},i.prototype.setAbsolutePosition=function(t){if(t){var i,r,n;if(void 0===t.x){if(arguments.length<3)return;i=arguments[0],r=arguments[1],n=arguments[2]}else i=t.x,r=t.y,n=t.z;if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert();var s=new e.Vector3(i,r,n);this.position=e.Vector3.TransformCoordinates(s,o)}else this.position.x=i,this.position.y=r,this.position.z=n}},i.prototype.movePOV=function(e,t,i){this.position.addInPlace(this.calcMovePOV(e,t,i))},i.prototype.calcMovePOV=function(t,i,r){var n=new e.Matrix;(this.rotationQuaternion?this.rotationQuaternion:e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(n);var o=e.Vector3.Zero(),s=this.definedFacingForward?-1:1;return e.Vector3.TransformCoordinatesFromFloatsToRef(t*s,i,r*s,n,o),o},i.prototype.rotatePOV=function(e,t,i){this.rotation.addInPlace(this.calcRotatePOV(e,t,i))},i.prototype.calcRotatePOV=function(t,i,r){var n=this.definedFacingForward?1:-1;return new e.Vector3(t*n,i,r*n)},i.prototype.setPivotMatrix=function(e){this._pivotMatrix=e,this._cache.pivotMatrixUpdated=!0},i.prototype.getPivotMatrix=function(){return this._pivotMatrix},i.prototype._isSynchronized=function(){return!(this._isDirty||this.billboardMode!==this._cache.billboardMode||this.billboardMode!==i.BILLBOARDMODE_NONE||this._cache.pivotMatrixUpdated||this.infiniteDistance||!this._cache.position.equals(this.position)||this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion)||!this._cache.rotation.equals(this.rotation)||!this._cache.scaling.equals(this.scaling))},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=e.Vector3.Zero(),this._cache.scaling=e.Vector3.Zero(),this._cache.rotation=e.Vector3.Zero(),this._cache.rotationQuaternion=new e.Quaternion(0,0,0,0),this._cache.billboardMode=-1},i.prototype.markAsDirty=function(e){"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0},i.prototype._updateBoundingInfo=function(){this._boundingInfo=this._boundingInfo||new e.BoundingInfo(this.absolutePosition,this.absolutePosition),this._boundingInfo.update(this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)},i.prototype._updateSubMeshesBoundingInfo=function(e){if(this.subMeshes)for(var t=0;t<this.subMeshes.length;t++){var i=this.subMeshes[t];i.IsGlobal||i.updateBoundingInfo(e)}},i.prototype.computeWorldMatrix=function(t){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!t&&(this._currentRenderId===this.getScene().getRenderId()||this.isSynchronized(!0)))return this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix;(this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._cache.billboardMode=this.billboardMode,this._currentRenderId=this.getScene().getRenderId(),this._isDirty=!1,e.Matrix.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,e.Tmp.Matrix[1]),this.rotationQuaternion)&&(this.rotation.length()&&(this.rotationQuaternion.multiplyInPlace(e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)),this.rotation.copyFromFloats(0,0,0)));if(this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(e.Tmp.Matrix[0]),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,e.Tmp.Matrix[0]),this._cache.rotation.copyFrom(this.rotation)),this.infiniteDistance&&!this.parent){var r=this.getScene().activeCamera;if(r){var n=r.getWorldMatrix(),o=new e.Vector3(n.m[12],n.m[13],n.m[14]);e.Matrix.TranslationToRef(this.position.x+o.x,this.position.y+o.y,this.position.z+o.z,e.Tmp.Matrix[2])}}else e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,e.Tmp.Matrix[2]);if(this._pivotMatrix.multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[4]),e.Tmp.Matrix[4].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5]),this.billboardMode!==i.BILLBOARDMODE_NONE&&this.getScene().activeCamera){e.Tmp.Vector3[0].copyFrom(this.position);var s,a=e.Tmp.Vector3[0];if(this.parent&&this.parent.getWorldMatrix)this._markSyncedWithParent(),this._meshToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),s=e.Tmp.Matrix[6]):s=this.parent.getWorldMatrix(),e.Vector3.TransformNormalToRef(a,s,e.Tmp.Vector3[1]),a=e.Tmp.Vector3[1];var c=this.getScene().activeCamera.globalPosition.clone();this.parent&&this.parent.position&&(a.addInPlace(this.parent.position),e.Matrix.TranslationToRef(a.x,a.y,a.z,e.Tmp.Matrix[2])),(this.billboardMode&i.BILLBOARDMODE_ALL)!==i.BILLBOARDMODE_ALL&&(this.billboardMode&i.BILLBOARDMODE_X&&(c.x=a.x+e.Epsilon),this.billboardMode&i.BILLBOARDMODE_Y&&(c.y=a.y+e.Epsilon),this.billboardMode&i.BILLBOARDMODE_Z&&(c.z=a.z+e.Epsilon)),e.Matrix.LookAtLHToRef(a,c,e.Vector3.Up(),e.Tmp.Matrix[3]),e.Tmp.Matrix[3].m[12]=e.Tmp.Matrix[3].m[13]=e.Tmp.Matrix[3].m[14]=0,e.Tmp.Matrix[3].invert(),e.Tmp.Matrix[5].multiplyToRef(e.Tmp.Matrix[3],this._localWorld),this._rotateYByPI.multiplyToRef(this._localWorld,e.Tmp.Matrix[5])}return e.Tmp.Matrix[5].multiplyToRef(e.Tmp.Matrix[2],this._localWorld),this.parent&&this.parent.getWorldMatrix&&this.billboardMode===i.BILLBOARDMODE_NONE?(this._markSyncedWithParent(),this._meshToBoneReferal?(this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),e.Tmp.Matrix[6]),e.Tmp.Matrix[6].multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix)):this._worldMatrix.copyFrom(this._localWorld),this._updateBoundingInfo(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=e.Matrix.Invert(this._worldMatrix)),this._worldMatrix},i.prototype.registerAfterWorldMatrixUpdate=function(e){this.onAfterWorldMatrixUpdateObservable.add(e)},i.prototype.unregisterAfterWorldMatrixUpdate=function(e){this.onAfterWorldMatrixUpdateObservable.removeCallback(e)},i.prototype.setPositionWithLocalVector=function(t){this.computeWorldMatrix(),this.position=e.Vector3.TransformNormal(t,this._localWorld)},i.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var t=this._localWorld.clone();return t.invert(),e.Vector3.TransformNormal(this.position,t)},i.prototype.locallyTranslate=function(t){this.computeWorldMatrix(!0),this.position=e.Vector3.TransformCoordinates(t,this._localWorld)},i.prototype.lookAt=function(t,r,n,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=e.Space.LOCAL);var a=i._lookAtVectorCache,c=s===e.Space.LOCAL?this.position:this.getAbsolutePosition();t.subtractToRef(c,a);var h=-Math.atan2(a.z,a.x)-Math.PI/2,u=Math.sqrt(a.x*a.x+a.z*a.z),l=Math.atan2(a.y,u);this.rotationQuaternion=this.rotationQuaternion||new e.Quaternion,e.Quaternion.RotationYawPitchRollToRef(h+r,l+n,o,this.rotationQuaternion)},i.prototype.attachToBone=function(e,t){this._meshToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1)},i.prototype.detachFromBone=function(){this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._meshToBoneReferal=null,this.parent=null},i.prototype.isInFrustum=function(e){return this._boundingInfo.isInFrustum(e)},i.prototype.isCompletelyInFrustum=function(e){return this._boundingInfo.isCompletelyInFrustum(e)},i.prototype.intersectsMesh=function(e,t){return!(!this._boundingInfo||!e._boundingInfo)&&this._boundingInfo.intersects(e._boundingInfo,t)},i.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},i.prototype.setPhysicsState=function(t,i){return t.impostor&&(i=t,t=t.impostor),this.physicsImpostor=new e.PhysicsImpostor(this,t,i,this.getScene()),this.physicsImpostor.physicsBody},i.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},i.prototype.getPhysicsMass=function(){return this.physicsImpostor.getParam("mass")},i.prototype.getPhysicsFriction=function(){return this.physicsImpostor.getParam("friction")},i.prototype.getPhysicsRestitution=function(){return this.physicsImpostor.getParam("restitution")},i.prototype.getPositionInCameraSpace=function(t){return t||(t=this.getScene().activeCamera),e.Vector3.TransformCoordinates(this.absolutePosition,t.getViewMatrix())},i.prototype.getDistanceToCamera=function(e){return e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},i.prototype.applyImpulse=function(e,t){this.physicsImpostor&&this.physicsImpostor.applyImpulse(e,t)},i.prototype.setPhysicsLinkWith=function(t,i,r,n){this.physicsImpostor&&t.physicsImpostor&&this.physicsImpostor.createJoint(t.physicsImpostor,e.PhysicsJoint.HingeJoint,{mainPivot:i,connectedPivot:r,nativeParams:n})},i.prototype.updatePhysicsBodyPosition=function(){e.Tools.Warn("updatePhysicsBodyPosition() is deprecated, please use updatePhysicsBody()"),this.updatePhysicsBody()},i.prototype.updatePhysicsBody=function(){},Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return this._checkCollisions},set:function(e){this._checkCollisions=e,this.getScene().workerCollisions&&this.getScene().collisionCoordinator.onMeshUpdated(this)},enumerable:!0,configurable:!0}),i.prototype.moveWithCollisions=function(e){this.getAbsolutePosition().subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPositionForCollisions),this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset),this._collider.radius=this.ellipsoid,this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions,e,this._collider,3,this,this._onCollisionPositionChange,this.uniqueId)},i.prototype.createOrUpdateSubmeshesOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._submeshesOctree||(this._submeshesOctree=new e.Octree(e.Octree.CreationFuncForSubMeshes,t,i)),this.computeWorldMatrix(!0);var r=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(r.minimumWorld,r.maximumWorld,this.subMeshes),this._submeshesOctree},i.prototype._collideForSubMesh=function(t,i,r){if(this._generatePointsArray(),!t._lastColliderWorldVertices||!t._lastColliderTransformMatrix.equals(i)){t._lastColliderTransformMatrix=i.clone(),t._lastColliderWorldVertices=[],t._trianglePlanes=[];for(var n=t.verticesStart,o=t.verticesStart+t.verticesCount,s=n;s<o;s++)t._lastColliderWorldVertices.push(e.Vector3.TransformCoordinates(this._positions[s],i))}r._collide(t._trianglePlanes,t._lastColliderWorldVertices,this.getIndices(),t.indexStart,t.indexStart+t.indexCount,t.verticesStart,!!t.getMaterial()),r.collisionFound&&(r.collidedMesh=this)},i.prototype._processCollisionsForSubMeshes=function(e,t){var i,r;if(this._submeshesOctree&&this.useOctreeForCollisions){var n=e.velocityWorldLength+Math.max(e.radius.x,e.radius.y,e.radius.z),o=this._submeshesOctree.intersects(e.basePointWorld,n);r=o.length,i=o.data}else r=(i=this.subMeshes).length;for(var s=0;s<r;s++){var a=i[s];r>1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}},i.prototype._checkCollision=function(t){this._boundingInfo._checkCollision(t)&&(e.Matrix.ScalingToRef(1/t.radius.x,1/t.radius.y,1/t.radius.z,this._collisionsScalingMatrix),this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix,this._collisionsTransformMatrix),this._processCollisionsForSubMeshes(t,this._collisionsTransformMatrix))},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(t,i){var r=new e.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&t.intersectsSphere(this._boundingInfo.boundingSphere)&&t.intersectsBox(this._boundingInfo.boundingBox)))return r;if(!this._generatePointsArray())return r;var n,o,s=null;if(this._submeshesOctree&&this.useOctreeForPicking){var a=e.Ray.Transform(t,this.getWorldMatrix()),c=this._submeshesOctree.intersectsRay(a);o=c.length,n=c.data}else o=(n=this.subMeshes).length;for(var h=0;h<o;h++){var u=n[h];if(!(o>1)||u.canIntersects(t)){var l=u.intersects(t,this._positions,this.getIndices(),i);if(l&&(i||!s||l.distance<s.distance)&&((s=l).subMeshId=h,i))break}}if(s){var f=this.getWorldMatrix(),d=e.Vector3.TransformCoordinates(t.origin,f),p=t.direction.clone();p=p.scale(s.distance);var m=e.Vector3.TransformNormal(p,f),g=d.add(m);return r.hit=!0,r.distance=e.Vector3.Distance(d,g),r.pickedPoint=g,r.pickedMesh=this,r.bu=s.bu,r.bv=s.bv,r.faceId=s.faceId,r.subMeshId=s.subMeshId,r}return r},i.prototype.clone=function(e,t,i){return null},i.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array},i.prototype.dispose=function(e){var i,r=this;for(this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this.skeleton=null,this.getScene().stopAnimation(this),this.physicsImpostor&&this.physicsImpostor.dispose(),i=0;i<this._intersectionsInProgress.length;i++){var n=this._intersectionsInProgress[i],o=n._intersectionsInProgress.indexOf(this);n._intersectionsInProgress.splice(o,1)}if(this._intersectionsInProgress=[],this.getScene().lights.forEach(function(e){var t=e.includedOnlyMeshes.indexOf(r);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(r))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();i&&(-1!==(t=i.getShadowMap().renderList.indexOf(r))&&i.getShadowMap().renderList.splice(t,1))}),this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this.releaseSubMeshes(),this.getScene().getEngine().unbindAllAttributes(),this.getScene().removeMesh(this),e){var s=this.getChildMeshes(!0);for(i=0;i<s.length;i++){var a=s[i];a.parent=null,a.computeWorldMatrix(!0)}}else{for(i=0;i<this.getScene().particleSystems.length;i++)this.getScene().particleSystems[i].emitter===this&&(this.getScene().particleSystems[i].dispose(),i--);var c=this.getDescendants(!0);for(i=0;i<c.length;i++)c[i].dispose()}this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this._isDisposed=!0,t.prototype.dispose.call(this)},i.prototype.getDirection=function(t){var i=e.Vector3.Zero();return this.getDirectionToRef(t,i),i},i.prototype.getDirectionToRef=function(t,i){e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),i)},i.prototype.setPivotPoint=function(t,i){void 0===i&&(i=e.Space.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var r=this.getWorldMatrix();if(i==e.Space.WORLD){var n=e.Tmp.Matrix[0];r.invertToRef(n),t=e.Vector3.TransformCoordinates(t,n)}e.Vector3.TransformCoordinatesToRef(t,r,this.position),this._pivotMatrix.m[12]=-t.x,this._pivotMatrix.m[13]=-t.y,this._pivotMatrix.m[14]=-t.z,this._cache.pivotMatrixUpdated=!0},i.prototype.getPivotPoint=function(){var t=e.Vector3.Zero();return this.getPivotPointToRef(t),t},i.prototype.getPivotPointToRef=function(e){e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14]},i.prototype.getAbsolutePivotPoint=function(){var t=e.Vector3.Zero();return this.getAbsolutePivotPointToRef(t),t},i.prototype.getAbsolutePivotPointToRef=function(t){t.x=this._pivotMatrix.m[12],t.y=this._pivotMatrix.m[13],t.z=this._pivotMatrix.m[14],this.getPivotPointToRef(t),e.Vector3.TransformCoordinatesToRef(t,this.getWorldMatrix(),t)},i._BILLBOARDMODE_NONE=0,i._BILLBOARDMODE_X=1,i._BILLBOARDMODE_Y=2,i._BILLBOARDMODE_Z=4,i._BILLBOARDMODE_ALL=7,i._rotationAxisCache=new e.Quaternion,i._lookAtVectorCache=new e.Vector3(0,0,0),i}(e.Node);e.AbstractMesh=t}(s||(s={})),function(e){var t=function(t){function i(i,r){t.call(this,i,r),this.diffuse=new e.Color3(1,1,1),this.specular=new e.Color3(1,1,1),this.intensity=1,this.range=Number.MAX_VALUE,this.includeOnlyWithLayerMask=0,this.includedOnlyMeshes=new Array,this.excludedMeshes=new Array,this.excludeWithLayerMask=0,this.lightmapMode=0,this.radius=1e-5,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,r.addLight(this)}return c(i,t),Object.defineProperty(i,"LIGHTMAP_DEFAULT",{get:function(){return i._LIGHTMAP_DEFAULT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SPECULAR",{get:function(){return i._LIGHTMAP_SPECULAR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SHADOWSONLY",{get:function(){return i._LIGHTMAP_SHADOWSONLY},enumerable:!0,configurable:!0}),i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},i.prototype.getShadowGenerator=function(){return this._shadowGenerator},i.prototype.getAbsolutePosition=function(){return e.Vector3.Zero()},i.prototype.transferToEffect=function(e,t,i){},i.prototype._getWorldMatrix=function(){return e.Matrix.Identity()},i.prototype.canAffectMesh=function(e){return!(e&&(this.includedOnlyMeshes.length>0&&-1===this.includedOnlyMeshes.indexOf(e)||this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)||0!==this.includeOnlyWithLayerMask&&0==(this.includeOnlyWithLayerMask&e.layerMask)||0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this),this.getScene().removeLight(this),t.prototype.dispose.call(this)},i.prototype.getTypeID=function(){return 0},i.prototype.clone=function(t){return e.SerializationHelper.Clone(i.GetConstructorFromName(this.getTypeID(),t,this.getScene()),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getTypeID(),this.parent&&(t.parentId=this.parent.id),this.excludedMeshes.length>0&&(t.excludedMeshesIds=[],this.excludedMeshes.forEach(function(e){t.excludedMeshesIds.push(e.id)})),this.includedOnlyMeshes.length>0&&(t.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach(function(e){t.includedOnlyMeshesIds.push(e.id)})),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.GetConstructorFromName=function(t,i,r){switch(t){case 0:return function(){return new e.PointLight(i,e.Vector3.Zero(),r)};case 1:return function(){return new e.DirectionalLight(i,e.Vector3.Zero(),r)};case 2:return function(){return new e.SpotLight(i,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r)};case 3:return function(){return new e.HemisphericLight(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=e.SerializationHelper.Parse(i.GetConstructorFromName(t.type,t.name,r),t,r);if(t.excludedMeshesIds&&(n._excludedMeshesIds=t.excludedMeshesIds),t.includedOnlyMeshesIds&&(n._includedOnlyMeshesIds=t.includedOnlyMeshesIds),t.parentId&&(n._waitingParentId=t.parentId),t.animations){for(var o=0;o<t.animations.length;o++){var s=t.animations[o];n.animations.push(e.Animation.Parse(s))}e.Node.ParseAnimationRanges(n,t,r)}return t.autoAnimate&&r.beginAnimation(n,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),n},i._LIGHTMAP_DEFAULT=0,i._LIGHTMAP_SPECULAR=1,i._LIGHTMAP_SHADOWSONLY=2,a([e.serializeAsColor3()],i.prototype,"diffuse",void 0),a([e.serializeAsColor3()],i.prototype,"specular",void 0),a([e.serialize()],i.prototype,"intensity",void 0),a([e.serialize()],i.prototype,"range",void 0),a([e.serialize()],i.prototype,"includeOnlyWithLayerMask",void 0),a([e.serialize()],i.prototype,"excludeWithLayerMask",void 0),a([e.serialize()],i.prototype,"lightmapMode",void 0),a([e.serialize()],i.prototype,"radius",void 0),i}(e.Node);e.Light=t}(s||(s={})),function(e){var t=function(t){function i(e,i,r){t.call(this,e,r),this.position=i}return c(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.computeTransformedPosition=function(){return!(!this.parent||!this.parent.getWorldMatrix||(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),0))},i.prototype.transferToEffect=function(e,t){return this.parent&&this.parent.getWorldMatrix?(this.computeTransformedPosition(),void e.setFloat4(t,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0)):void e.setFloat4(t,this.position.x,this.position.y,this.position.z,0)},i.prototype.needCube=function(){return!0},i.prototype.supportsVSM=function(){return!1},i.prototype.needRefreshPerFrame=function(){return!1},i.prototype.getShadowDirection=function(t){switch(t){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype.setShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(Math.PI/2,1,n.minZ,n.maxZ,t)},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getTypeID=function(){return 0},a([e.serializeAsVector3()],i.prototype,"position",void 0),i}(e.Light);e.PointLight=t}(s||(s={})),function(e){var t=function(t){function i(e,i,r,n,o,s){t.call(this,e,s),this.position=i,this.direction=r,this.angle=n,this.exponent=o}return c(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.angle,1,n.minZ,n.maxZ,t)},i.prototype.needCube=function(){return!1},i.prototype.supportsVSM=function(){return!0},i.prototype.needRefreshPerFrame=function(){return!1},i.prototype.getShadowDirection=function(e){return this.direction},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.computeTransformedPosition=function(){return!(!this.parent||!this.parent.getWorldMatrix||(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),0))},i.prototype.transferToEffect=function(t,i,r){var n;this.parent&&this.parent.getWorldMatrix?(this._transformedDirection||(this._transformedDirection=e.Vector3.Zero()),this.computeTransformedPosition(),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this._transformedDirection),t.setFloat4(i,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent),n=e.Vector3.Normalize(this._transformedDirection)):(t.setFloat4(i,this.position.x,this.position.y,this.position.z,this.exponent),n=e.Vector3.Normalize(this.direction)),t.setFloat4(r,n.x,n.y,n.z,Math.cos(.5*this.angle))},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getTypeID=function(){return 2},i.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),i=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,i,this.direction)},a([e.serializeAsVector3()],i.prototype,"position",void 0),a([e.serializeAsVector3()],i.prototype,"direction",void 0),a([e.serialize()],i.prototype,"angle",void 0),a([e.serialize()],i.prototype,"exponent",void 0),i}(e.Light);e.SpotLight=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n){t.call(this,i,n),this.groundColor=new e.Color3(0,0,0),this.direction=r}return c(i,t),i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i,r){var n=e.Vector3.Normalize(this.direction);t.setFloat4(i,n.x,n.y,n.z,0),t.setColor3(r,this.groundColor.scale(this.intensity))},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return 3},a([e.serializeAsColor3()],i.prototype,"groundColor",void 0),a([e.serializeAsVector3()],i.prototype,"direction",void 0),i}(e.Light);e.HemisphericLight=t}(s||(s={})),function(e){var t=function(t){function i(e,i,r){t.call(this,e,r),this.shadowOrthoScale=.5,this.autoUpdateExtends=!0,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=i.scale(-1),this.direction=i}return c(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.setShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;s<r.length;s++){var a=r[s];if(a){var c=a.getBoundingInfo();if(c)for(var h=c.boundingBox,u=0;u<h.vectorsWorld.length;u++)e.Vector3.TransformCoordinatesToRef(h.vectorsWorld[u],i,o),o.x<this._orthoLeft&&(this._orthoLeft=o.x),o.y<this._orthoBottom&&(this._orthoBottom=o.y),o.x>this._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var l=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-l*this.shadowOrthoScale,this._orthoRight+l*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,-n.maxZ,n.maxZ,t)},i.prototype.supportsVSM=function(){return!0},i.prototype.needRefreshPerFrame=function(){return!0},i.prototype.needCube=function(){return!1},i.prototype.getShadowDirection=function(e){return this.direction},i.prototype.computeTransformedPosition=function(){return!(!this.parent||!this.parent.getWorldMatrix||(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),0))},i.prototype.transferToEffect=function(t,i){return this.parent&&this.parent.getWorldMatrix?(this._transformedDirection||(this._transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this._transformedDirection),void t.setFloat4(i,this._transformedDirection.x,this._transformedDirection.y,this._transformedDirection.z,1)):void t.setFloat4(i,this.direction.x,this.direction.y,this.direction.z,1)},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getTypeID=function(){return 1},a([e.serializeAsVector3()],i.prototype,"position",void 0),a([e.serializeAsVector3()],i.prototype,"direction",void 0),a([e.serialize()],i.prototype,"shadowOrthoScale",void 0),a([e.serialize()],i.prototype,"autoUpdateExtends",void 0),i}(e.Light);e.DirectionalLight=t}(s||(s={})),function(e){var t=function(){function t(i,r){var n=this;this._filter=t.FILTER_NONE,this.blurScale=2,this._blurBoxOffset=0,this._bias=5e-5,this._lightDirection=e.Vector3.Zero(),this.forceBackFacesOnly=!1,this._darkness=0,this._transparencyShadow=!1,this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._useFullFloat=!0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this;var o,s=this._scene.getEngine().getCaps();s.textureFloat&&s.textureFloatLinearFiltering&&s.textureFloatRender?(this._useFullFloat=!0,o=e.Engine.TEXTURETYPE_FLOAT):(this._useFullFloat=!1,o=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,!1,!0,o,r.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add(function(e){n._currentFaceIndex=e}),this._shadowMap.onAfterUnbindObservable.add(function(){n.useBlurVarianceShadowMap&&(n._shadowMap2||(n._shadowMap2=new e.RenderTargetTexture(r.name+"_shadowMap",i,n._scene,!1,!0,o),n._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,n._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,n._shadowMap2.updateSamplingMode(e.Texture.TRILINEAR_SAMPLINGMODE),n._downSamplePostprocess=new e.PassPostProcess("downScale",1/n.blurScale,null,e.Texture.BILINEAR_SAMPLINGMODE,n._scene.getEngine()),n._downSamplePostprocess.onApplyObservable.add(function(e){e.setTexture("textureSampler",n._shadowMap)}),n.blurBoxOffset=1),n._scene.postProcessManager.directRender([n._downSamplePostprocess,n._boxBlurPostprocess],n._shadowMap2.getInternalTexture()))});var a=function(t){var i=t.getRenderingMesh(),r=n._scene,o=r.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=null!==o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id]&&void 0!==s.visibleInstances[t._id];if(n.isReady(t,a)){o.enableEffect(n._effect),i._bind(t,n._effect,e.Material.TriangleFillMode);var c=t.getMaterial();if(n._effect.setMatrix("viewProjection",n.getTransformMatrix()),n._effect.setVector3("lightPosition",n.getLight().position),n.getLight().needCube()&&n._effect.setFloat2("depthValues",r.activeCamera.minZ,r.activeCamera.maxZ),c&&c.needAlphaTesting()){var h=c.getAlphaTestTexture();n._effect.setTexture("diffuseSampler",h),n._effect.setMatrix("diffuseMatrix",h.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&n._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),n.forceBackFacesOnly&&o.setState(!0,0,!1,!0),i._processRendering(t,n._effect,e.Material.TriangleFillMode,s,a,function(e,t){return n._effect.setMatrix("world",t)}),n.forceBackFacesOnly&&o.setState(!0,0,!1,!1)}else n._shadowMap.resetRefreshCounter()}};this._shadowMap.customRenderFunction=function(e,t,i){var r;for(r=0;r<e.length;r++)a(e.data[r]);for(r=0;r<t.length;r++)a(t.data[r]);if(n._transparencyShadow)for(r=0;r<i.length;r++)a(i.data[r])},this._shadowMap.onClearObservable.add(function(t){n.useBlurVarianceShadowMap||n.useVarianceShadowMap?t.clear(new e.Color4(0,0,0,0),!0,!0,!0):t.clear(new e.Color4(1,1,1,1),!0,!0,!0)})}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_VARIANCESHADOWMAP",{get:function(){return t._FILTER_VARIANCESHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURVARIANCESHADOWMAP",{get:function(){return t._FILTER_BLURVARIANCESHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(t){var i=this;this._blurBoxOffset!==t&&(this._blurBoxOffset=t,this._boxBlurPostprocess&&this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=new e.PostProcess("DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1/this.blurScale,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define OFFSET "+t),this._boxBlurPostprocess.onApplyObservable.add(function(e){e.setFloat2("screenSize",i._mapSize/i.blurScale,i._mapSize/i.blurScale)}))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(t){this._filter!==t&&(this._filter=t,this.useVarianceShadowMap||this.useBlurVarianceShadowMap||this.usePoissonSampling?(this._shadowMap.anisotropicFilteringLevel=16,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)):(this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE)))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return this.filter===t.FILTER_VARIANCESHADOWMAP&&this._light.supportsVSM()},set:function(e){this.filter=e?t.FILTER_VARIANCESHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING||!this._light.supportsVSM()&&(this.filter===t.FILTER_VARIANCESHADOWMAP||this.filter===t.FILTER_BLURVARIANCESHADOWMAP)},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return this.filter===t.FILTER_BLURVARIANCESHADOWMAP&&this._light.supportsVSM()},set:function(e){this.filter=e?t.FILTER_BLURVARIANCESHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.isReady=function(t,i){var r=[];this._useFullFloat&&r.push("#define FULLFLOAT"),(this.useVarianceShadowMap||this.useBlurVarianceShadowMap)&&r.push("#define VSM"),this.getLight().needCube()&&r.push("#define CUBEMAP");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();s&&s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind))&&(1===s.getAlphaTestTexture().coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2")));o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;return e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),this._light.computeTransformedPosition()&&(i=this._light.transformedPosition),!this._light.needRefreshPerFrame()&&this._cachedPosition&&this._cachedDirection&&i.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){this._darkness=e>=1?1:e<=0?0:e},t.prototype.setTransparencyShadow=function(e){this._transparencyShadow=e},t.prototype._packHalf=function(t){var i=255*t,r=i-Math.floor(i);return new e.Vector2(t-r/255,r)},t.prototype.dispose=function(){this._shadowMap.dispose(),this._shadowMap2&&this._shadowMap2.dispose(),this._downSamplePostprocess&&this._downSamplePostprocess.dispose(),this._boxBlurPostprocess&&this._boxBlurPostprocess.dispose()},t.prototype.serialize=function(){var e={};e.lightId=this._light.id,e.mapSize=this.getShadowMap().getRenderSize(),e.useVarianceShadowMap=this.useVarianceShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.renderList=[];for(var t=0;t<this.getShadowMap().renderList.length;t++){var i=this.getShadowMap().renderList[t];e.renderList.push(i.id)}return e},t.Parse=function(e,i){for(var r=i.getLightByID(e.lightId),n=new t(e.mapSize,r),o=0;o<e.renderList.length;o++){i.getMeshesByID(e.renderList[o]).forEach(function(e){n.getShadowMap().renderList.push(e)})}return e.usePoissonSampling?n.usePoissonSampling=!0:e.useVarianceShadowMap?n.useVarianceShadowMap=!0:e.useBlurVarianceShadowMap&&(n.useBlurVarianceShadowMap=!0,e.blurScale&&(n.blurScale=e.blurScale),e.blurBoxOffset&&(n.blurBoxOffset=e.blurBoxOffset)),void 0!==e.bias&&(n.bias=e.bias),n.forceBackFacesOnly=e.forceBackFacesOnly,n},t._FILTER_NONE=0,t._FILTER_VARIANCESHADOWMAP=1,t._FILTER_POISSONSAMPLING=2,t._FILTER_BLURVARIANCESHADOWMAP=3,t}();e.ShadowGenerator=t}(s||(s={})),function(e){var t=function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),c=(-i+s)/(2*t);if(a>c){var h=c;c=a,a=h}return a>0&&a<n?(e.root=a,e.found=!0,e):c>0&&c<n?(e.root=c,e.found=!0,e):e}}(),i=function(){function i(){this.radius=new e.Vector3(1,1,1),this.retry=0,this.basePointWorld=e.Vector3.Zero(),this.velocityWorld=e.Vector3.Zero(),this.normalizedVelocity=e.Vector3.Zero(),this._collisionPoint=e.Vector3.Zero(),this._planeIntersectionPoint=e.Vector3.Zero(),this._tempVector=e.Vector3.Zero(),this._tempVector2=e.Vector3.Zero(),this._tempVector3=e.Vector3.Zero(),this._tempVector4=e.Vector3.Zero(),this._edge=e.Vector3.Zero(),this._baseToVertex=e.Vector3.Zero(),this._destinationPoint=e.Vector3.Zero(),this._slidePlaneNormal=e.Vector3.Zero(),this._displacementVector=e.Vector3.Zero()}return i.prototype._initialize=function(t,i,r){this.velocity=i,e.Vector3.NormalizeToRef(i,this.normalizedVelocity),this.basePoint=t,t.multiplyToRef(this.radius,this.basePointWorld),i.multiplyToRef(this.radius,this.velocityWorld),this.velocityWorldLength=this.velocityWorld.length(),this.epsilon=r,this.collisionFound=!1},i.prototype._checkPointInTriangle=function(t,i,r,n,o){i.subtractToRef(t,this._tempVector),r.subtractToRef(t,this._tempVector2),e.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var s=e.Vector3.Dot(this._tempVector4,o);return!(s<0)&&(n.subtractToRef(t,this._tempVector3),e.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((s=e.Vector3.Dot(this._tempVector4,o))<0)&&(e.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),(s=e.Vector3.Dot(this._tempVector4,o))>=0))},i.prototype._canDoCollision=function(t,i,r,n){var o=e.Vector3.Distance(this.basePointWorld,t),s=Math.max(this.radius.x,this.radius.y,this.radius.z);return!(o>this.velocityWorldLength+s+i||!function(e,t,i,r){return!(e.x>i.x+r||i.x-r>t.x||e.y>i.y+r||i.y-r>t.y||e.z>i.z+r||i.z-r>t.z)}(r,n,this.basePointWorld,this.velocityWorldLength+s))},i.prototype._testTriangle=function(i,r,n,o,s,a){var c,h=!1;r||(r=[]),r[i]||(r[i]=new e.Plane(0,0,0,0),r[i].copyFromPoints(n,o,s));var u=r[i];if(a||u.isFrontFacingTo(this.normalizedVelocity,0)){var l=u.signedDistanceTo(this.basePoint),f=e.Vector3.Dot(u.normal,this.velocity);if(0==f){if(Math.abs(l)>=1)return;h=!0,c=0}else{var d=(1-l)/f;if((c=(-1-l)/f)>d){var p=d;d=c,c=p}if(c>1||d<0)return;c<0&&(c=0),c>1&&(c=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,g=1;if(h||(this.basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(c,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,u.normal)&&(m=!0,g=c,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var _=this.velocity.lengthSquared(),v=_;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,x=t(v,y,b,g);x.found&&(g=x.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,(x=t(v,y,b,g)).found&&(g=x.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,(x=t(v,y,b,g)).found&&(g=x.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var w=this._edge.lengthSquared(),S=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=w*-_+S*S,y=w*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*S*T,b=w*(1-this._baseToVertex.lengthSquared())+T*T,(x=t(v,y,b,g)).found){var A=(S*x.root-T)/w;A>=0&&A<=1&&(g=x.root,m=!0,this._edge.scaleInPlace(A),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),w=this._edge.lengthSquared(),S=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=w*-_+S*S,y=w*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*S*T,b=w*(1-this._baseToVertex.lengthSquared())+T*T,(x=t(v,y,b,g)).found&&((A=(S*x.root-T)/w)>=0&&A<=1&&(g=x.root,m=!0,this._edge.scaleInPlace(A),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),w=this._edge.lengthSquared(),S=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=w*-_+S*S,y=w*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*S*T,b=w*(1-this._baseToVertex.lengthSquared())+T*T,(x=t(v,y,b,g)).found&&((A=(S*x.root-T)/w)>=0&&A<=1&&(g=x.root,m=!0,this._edge.scaleInPlace(A),s.addToRef(this._edge,this._collisionPoint)))}if(m){var M=g*this.velocity.length();(!this.collisionFound||M<this.nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this.nearestDistance=M,this.collisionFound=!0)}}},i.prototype._collide=function(e,t,i,r,n,o,s){for(var a=r;a<n;a+=3){var c=t[i[a]-o],h=t[i[a+1]-o],u=t[i[a+2]-o];this._testTriangle(a,e,u,h,c,s)}},i.prototype._getResponse=function(t,i){t.addToRef(i,this._destinationPoint),i.scaleInPlace(this.nearestDistance/i.length()),this.basePoint.addToRef(i,t),t.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this.epsilon,this._displacementVector),t.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(e.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,i)},i}();e.Collider=i}(s||(s={})),function(e){e.CollisionWorker="",function(e){e[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE"}(e.WorkerTaskType||(e.WorkerTaskType={}));var t=e.WorkerTaskType;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.UNKNOWN_ERROR=1]="UNKNOWN_ERROR"}(e.WorkerReplyType||(e.WorkerReplyType={}));var i=e.WorkerReplyType,r=function(){function r(){var n=this;this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this.onMeshUpdated=function(e){n._addUpdateMeshesList[e.uniqueId]=r.SerializeMesh(e)},this.onGeometryUpdated=function(e){n._addUpdateGeometriesList[e.id]=r.SerializeGeometry(e)},this._afterRender=function(){if(n._init&&!(0==n._toRemoveGeometryArray.length&&0==n._toRemoveMeshesArray.length&&0==Object.keys(n._addUpdateGeometriesList).length&&0==Object.keys(n._addUpdateMeshesList).length||n._runningUpdated>4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error==i.SUCCESS)switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach(function(e){n.onMeshAdded(e)}),n._scene.getGeometries().forEach(function(e){n.onGeometryAdded(e)});break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;n._collisionsCallbackArray[s.collisionId](s.collisionId,e.Vector3.FromArray(s.newPosition),n._scene.getMeshByUniqueID(s.collidedMeshUniqueId)),n._collisionsCallbackArray[s.collisionId]=void 0}else e.Tools.Warn("error returned from worker!")},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var c={payload:{collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},taskType:t.COLLIDE};this._worker.postMessage(c)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map(function(e,t){return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}}));var r=null;return t instanceof e.Mesh?r=t.geometry?t.geometry.id:null:t instanceof e.InstancedMesh&&(r=t.sourceMesh&&t.sourceMesh.geometry?t.sourceMesh.geometry.id:null),{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:t.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:t.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:t.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:t.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Int32Array(t.getIndices()||[])}},r}();e.CollisionCoordinatorWorker=r;var n=function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(!(r.retry>=n)){r._initialize(t,i,a);for(var c=0;c<this._scene.meshes.length;c++){var h=this._scene.meshes[c];h.isEnabled()&&h.checkCollisions&&h.subMeshes&&h!==s&&h._checkCollision(r)}return r.collisionFound?(0===i.x&&0===i.y&&0===i.z||r._getResponse(t,i),i.length()<=a?void o.copyFrom(t):(r.retry++,void this._collideWithWorld(t,i,r,n,o,s))):void t.addToRef(i,o)}o.copyFrom(t)},t}();e.CollisionCoordinatorLegacy=n}(s||(s={})),function(e){var t=function(t){function i(r,n,o){t.call(this,r,o),this.upVector=e.Vector3.Up(),this.orthoLeft=null,this.orthoRight=null,this.orthoBottom=null,this.orthoTop=null,this.fov=.8,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this.mode=i.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new e.Viewport(0,0,1,1),this.layerMask=268435455,this.fovMode=i.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=i.RIG_MODE_NONE,this._rigCameras=new Array,this._computedViewMatrix=e.Matrix.Identity(),this._projectionMatrix=new e.Matrix,this._doNotComputeProjectionMatrix=!1,this._postProcesses=new Array,this._transformMatrix=e.Matrix.Zero(),this._webvrViewMatrix=e.Matrix.Identity(),this._activeMeshes=new e.SmartArray(256),this._globalPosition=e.Vector3.Zero(),this._refreshFrustumPlanes=!0,o.addCamera(this),o.activeCamera||(o.activeCamera=this),this.position=n}return c(i,t),Object.defineProperty(i,"PERSPECTIVE_CAMERA",{get:function(){return i._PERSPECTIVE_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ORTHOGRAPHIC_CAMERA",{get:function(){return i._ORTHOGRAPHIC_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_VERTICAL_FIXED",{get:function(){return i._FOVMODE_VERTICAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_HORIZONTAL_FIXED",{get:function(){return i._FOVMODE_HORIZONTAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_NONE",{get:function(){return i._RIG_MODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_ANAGLYPH",{get:function(){return i._RIG_MODE_STEREOSCOPIC_ANAGLYPH},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_OVERUNDER",{get:function(){return i._RIG_MODE_STEREOSCOPIC_OVERUNDER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_VR",{get:function(){return i._RIG_MODE_VR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_WEBVR",{get:function(){return i._RIG_MODE_WEBVR},enumerable:!0,configurable:!0}),i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+this.getTypeName(),this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},Object.defineProperty(i.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.position=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this.getEngine();this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector),this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=i.getAspectRatio(this),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=i.getRenderWidth(),this._cache.renderHeight=i.getRenderHeight()},i.prototype._updateFromScene=function(){this.updateCache(),this.update()},i.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},i.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronized.call(this)&&this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent()},i.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var t=this.getEngine();return this.mode===i.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===t.getAspectRatio(this):this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight()},i.prototype.attachControl=function(e,t){},i.prototype.detachControl=function(e){},i.prototype.update=function(){this.cameraRigMode!==i.RIG_MODE_NONE&&this._updateRigCameras(),this._checkInputs()},i.prototype._checkInputs=function(){},i.prototype._cascadePostProcessesToRigCams=function(){this._postProcesses.length>0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t<i;t++){var r=this._rigCameras[t],n=r._rigPostProcess;if(n)n instanceof e.PassPostProcess&&(r.isIntermediate=0===this._postProcesses.length),r._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty();else r._postProcesses=this._postProcesses.slice(0)}},i.prototype.attachPostProcess=function(t,i){return void 0===i&&(i=null),!t.isReusable()&&this._postProcesses.indexOf(t)>-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?this._postProcesses.push(t):this._postProcesses.splice(i,0,t),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(t))},i.prototype.detachPostProcess=function(e,t){void 0===t&&(t=null);var i,r=[];if(t)for(i=(t=t instanceof Array?t:[t]).length-1;i>=0;i--)this._postProcesses[t[i]]===e?this._postProcesses.splice(void 0,1):r.push(i);else{var n=this._postProcesses.indexOf(e);-1!==n&&this._postProcesses.splice(n,1)}return this._cascadePostProcessesToRigCams(),r},i.prototype.getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this.getViewMatrix().invertToRef(this._worldMatrix),this._worldMatrix},i.prototype._getViewMatrix=function(){return e.Matrix.Identity()},i.prototype.getViewMatrix=function(t){return this._computedViewMatrix=this._computeViewMatrix(t),!t&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._refreshFrustumPlanes=!0,this.parent&&this.parent.getWorldMatrix?(this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._computedViewMatrix),this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12],this._computedViewMatrix.m[13],this._computedViewMatrix.m[14]),this._computedViewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(this.position),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},i.prototype._computeViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},i.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED),this._projectionMatrix;var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=0;e<this._postProcesses.length;++e)this._postProcesses[e].dispose(this);t.prototype.dispose.call(this)},i.prototype.setCameraRigMode=function(t,r){for(;this._rigCameras.length>0;)this._rigCameras.pop().dispose();switch(this.cameraRigMode=t,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=r.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==i.RIG_MODE_NONE&&(this._rigCameras.push(this.createRigCamera(this.name+"_L",0)),this._rigCameras.push(this.createRigCamera(this.name+"_R",1))),this.cameraRigMode){case i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.AnaglyphPostProcess(this.name+"_anaglyph",1,this._rigCameras);break;case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case i.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.StereoscopicInterlacePostProcess(this.name+"_stereoInterlace",this._rigCameras,n);break;case i.RIG_MODE_VR:var o=r.vrCameraMetrics||e.VRCameraMetrics.GetDefault();this._rigCameras[0]._cameraRigParams.vrMetrics=o,this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0]._cameraRigParams.vrHMatrix=o.leftHMatrix,this._rigCameras[0]._cameraRigParams.vrPreViewMatrix=o.leftPreViewMatrix,this._rigCameras[0].getProjectionMatrix=this._rigCameras[0]._getVRProjectionMatrix,this._rigCameras[1]._cameraRigParams.vrMetrics=o,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1]._cameraRigParams.vrHMatrix=o.rightHMatrix,this._rigCameras[1]._cameraRigParams.vrPreViewMatrix=o.rightPreViewMatrix,this._rigCameras[1].getProjectionMatrix=this._rigCameras[1]._getVRProjectionMatrix,o.compensateDistortion&&(this._rigCameras[0]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",this._rigCameras[0],!1,o),this._rigCameras[1]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",this._rigCameras[1],!0,o));break;case i.RIG_MODE_WEBVR:r.vrDisplay&&(this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix)}this._cascadePostProcessesToRigCams(),this.update()},i.prototype._getVRProjectionMatrix=function(){return e.Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRProjectionMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return[8,9,10,11].forEach(function(e){t[e]*=-1}),e.Matrix.FromArrayToRef(t,0,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRViewMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return[8,9,10,11].forEach(function(e){t[e]*=-1}),e.Matrix.FromArrayToRef(t,0,this._webvrViewMatrix),this._webvrViewMatrix},i.prototype.setCameraRigParameter=function(t,i){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[t]=i,"interaxialDistance"===t&&(this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(i/.0637))},i.prototype.createRigCamera=function(e,t){return null},i.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov;this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},i.prototype._setupInputs=function(){},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getTypeName(),this.parent&&(t.parentId=this.parent.id),this.inputs&&this.inputs.serialize(t),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.prototype.getTypeName=function(){return"Camera"},i.prototype.clone=function(t){return e.SerializationHelper.Clone(i.GetConstructorFromName(this.getTypeName(),t,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},i.prototype.getDirection=function(t){var i=e.Vector3.Zero();return this.getDirectionToRef(t,i),i},i.prototype.getDirectionToRef=function(t,i){e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),i)},i.GetConstructorFromName=function(t,i,r,n,o){switch(void 0===n&&(n=0),void 0===o&&(o=!0),t){case"ArcRotateCamera":return function(){return new e.ArcRotateCamera(i,0,0,1,e.Vector3.Zero(),r)};case"DeviceOrientationCamera":return function(){return new e.DeviceOrientationCamera(i,e.Vector3.Zero(),r)};case"FollowCamera":return function(){return new e.FollowCamera(i,e.Vector3.Zero(),r)};case"ArcFollowCamera":return function(){return new e.ArcFollowCamera(i,0,0,1,null,r)};case"GamepadCamera":return function(){return new e.GamepadCamera(i,e.Vector3.Zero(),r)};case"TouchCamera":return function(){return new e.TouchCamera(i,e.Vector3.Zero(),r)};case"VirtualJoysticksCamera":return function(){return new e.VirtualJoysticksCamera(i,e.Vector3.Zero(),r)};case"WebVRFreeCamera":return function(){return new e.WebVRFreeCamera(i,e.Vector3.Zero(),r)};case"VRDeviceOrientationFreeCamera":return function(){return new e.VRDeviceOrientationFreeCamera(i,e.Vector3.Zero(),r)};case"AnaglyphArcRotateCamera":return function(){return new e.AnaglyphArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,r)};case"AnaglyphFreeCamera":return function(){return new e.AnaglyphFreeCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphGamepadCamera":return function(){return new e.AnaglyphGamepadCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphUniversalCamera":return function(){return new e.AnaglyphUniversalCamera(i,e.Vector3.Zero(),n,r)};case"StereoscopicArcRotateCamera":return function(){return new e.StereoscopicArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,o,r)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(i,e.Vector3.Zero(),n,o,r)};case"FreeCamera":default:return function(){return new e.UniversalCamera(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=t.type,o=i.GetConstructorFromName(n,t.name,r,t.interaxial_distance,t.isStereoscopicSideBySide),s=e.SerializationHelper.Parse(o,t,r);if(t.parentId&&(s._waitingParentId=t.parentId),s.inputs&&(s.inputs.parse(t),s._setupInputs()),t.target&&s.setTarget&&s.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};s.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var c=0;c<t.animations.length;c++){var h=t.animations[c];s.animations.push(e.Animation.Parse(h))}e.Node.ParseAnimationRanges(s,t,r)}return t.autoAnimate&&r.beginAnimation(s,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),s},i._PERSPECTIVE_CAMERA=0,i._ORTHOGRAPHIC_CAMERA=1,i._FOVMODE_VERTICAL_FIXED=0,i._FOVMODE_HORIZONTAL_FIXED=1,i._RIG_MODE_NONE=0,i._RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,i._RIG_MODE_STEREOSCOPIC_OVERUNDER=13,i._RIG_MODE_VR=20,i._RIG_MODE_WEBVR=21,i.ForceAttachControlToAlwaysPreventDefault=!1,a([e.serializeAsVector3()],i.prototype,"position",void 0),a([e.serializeAsVector3()],i.prototype,"upVector",void 0),a([e.serialize()],i.prototype,"orthoLeft",void 0),a([e.serialize()],i.prototype,"orthoRight",void 0),a([e.serialize()],i.prototype,"orthoBottom",void 0),a([e.serialize()],i.prototype,"orthoTop",void 0),a([e.serialize()],i.prototype,"fov",void 0),a([e.serialize()],i.prototype,"minZ",void 0),a([e.serialize()],i.prototype,"maxZ",void 0),a([e.serialize()],i.prototype,"inertia",void 0),a([e.serialize()],i.prototype,"mode",void 0),a([e.serialize()],i.prototype,"layerMask",void 0),a([e.serialize()],i.prototype,"fovMode",void 0),a([e.serialize()],i.prototype,"cameraRigMode",void 0),a([e.serialize()],i.prototype,"interaxialDistance",void 0),a([e.serialize()],i.prototype,"isStereoscopicSideBySide",void 0),i}(e.Node);e.Camera=t}(s||(s={})),function(e){e.CameraInputTypes={};var t=function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();return this.attached[i]?void e.Tools.Warn("camera input of type "+i+" already exists on camera"):(this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),void(this.attachedElement&&t.attachControl(this.attachedElement)))},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getTypeName()===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(!this.attachedElement)for(var r in i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i,this.attached)this.attached[r],this.attached[r].attachControl(t,i)},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached)this.attached[t],this.attached[t].detachControl(e);this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){for(var e in this.checkInputs=function(){},this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getTypeName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i)for(var r in this.clear(),i){if(s=e.CameraInputTypes[r]){var n=i[r],o=e.SerializationHelper.Parse(function(){return new s},n,null);this.add(o)}}else for(var r in this.attached){var s;if(s=e.CameraInputTypes[this.attached[r].getTypeName()]){o=e.SerializationHelper.Parse(function(){return new s},t,null);this.remove(this.attached[r]),this.add(o)}}},t}();e.CameraInputsManager=t}(s||(s={})),function(e){var t=function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(o,s){var a=o.event;if((r.touchEnabled||"touch"!==a.pointerType)&&(o.type===e.PointerEventTypes.POINTERMOVE||-1!==r.buttons.indexOf(a.button)))if(o.type===e.PointerEventTypes.POINTERDOWN){try{a.srcElement.setPointerCapture(a.pointerId)}catch(e){}r.previousPosition={x:a.clientX,y:a.clientY},i||(a.preventDefault(),t.focus())}else if(o.type===e.PointerEventTypes.POINTERUP){try{a.srcElement.releasePointerCapture(a.pointerId)}catch(e){}r.previousPosition=null,i||a.preventDefault()}else if(o.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition||n.isPointerLock)return;var c=a.clientX-r.previousPosition.x,h=a.clientY-r.previousPosition.y;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=c/r.angularSensibility:r.camera.cameraRotation.y+=c/r.angularSensibility,r.camera.cameraRotation.x+=h/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}),this._onMouseMove=function(e){if(n.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=t/r.angularSensibility:r.camera.cameraRotation.y+=t/r.angularSensibility,r.camera.cameraRotation.x+=o/r.angularSensibility,r.previousPosition=null,i||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("mousemove",this._onMouseMove,!1)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},t.prototype.getTypeName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},a([e.serialize()],t.prototype,"buttons",void 0),a([e.serialize()],t.prototype,"angularSensibility",void 0),t}();e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t}(s||(s={})),function(e){var t=function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onKeyDown||(t.tabIndex=1,this._onKeyDown=function(e){-1===r.keysUp.indexOf(e.keyCode)&&-1===r.keysDown.indexOf(e.keyCode)&&-1===r.keysLeft.indexOf(e.keyCode)&&-1===r.keysRight.indexOf(e.keyCode)||(-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),i||e.preventDefault())},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null)},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var t=this.camera,i=0;i<this._keys.length;i++){var r=this._keys[i],n=t._computeLocalCameraSpeed();-1!==this.keysLeft.indexOf(r)?t._localDirection.copyFromFloats(-n,0,0):-1!==this.keysUp.indexOf(r)?t._localDirection.copyFromFloats(0,0,n):-1!==this.keysRight.indexOf(r)?t._localDirection.copyFromFloats(n,0,0):-1!==this.keysDown.indexOf(r)&&t._localDirection.copyFromFloats(0,0,-n),t.getScene().useRightHandedSystem&&(t._localDirection.z*=-1),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),e.Vector3.TransformNormalToRef(t._localDirection,t._cameraTransformMatrix,t._transformedDirection),t.cameraDirection.addInPlace(t._transformedDirection)}},t.prototype.getTypeName=function(){return"FreeCameraKeyboardMoveInput"},t.prototype._onLostFocus=function(e){this._keys=[]},t.prototype.getSimpleName=function(){return"keyboard"},a([e.serialize()],t.prototype,"keysUp",void 0),a([e.serialize()],t.prototype,"keysDown",void 0),a([e.serialize()],t.prototype,"keysLeft",void 0),a([e.serialize()],t.prototype,"keysRight",void 0),t}();e.FreeCameraKeyboardMoveInput=t,e.CameraInputTypes.FreeCameraKeyboardMoveInput=t}(s||(s={})),function(e){var t=function(){function t(){this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=[],this.touchAngularSensibility=2e5,this.touchMoveSensibility=250}return t.prototype.attachControl=function(t,i){var r,n=this;void 0===this._pointerInput&&(this._onLostFocus=function(e){n._offsetX=null,n._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),n._pointerPressed.push(s.pointerId),1!==n._pointerPressed.length)return;r={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){if(i||s.preventDefault(),-1===(a=n._pointerPressed.indexOf(s.pointerId)))return;if(n._pointerPressed.splice(a,1),0!=a)return;r=null,n._offsetX=null,n._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!r)return;var a;if(0!=(a=n._pointerPressed.indexOf(s.pointerId)))return;n._offsetX=s.clientX-r.x,n._offsetY=-(s.clientY-r.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null,this._pointerPressed=[],this._offsetX=null,this._offsetY=null,this._pointerCount=0)},t.prototype.checkInputs=function(){if(this._offsetX){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getTypeName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},a([e.serialize()],t.prototype,"touchAngularSensibility",void 0),a([e.serialize()],t.prototype,"touchMoveSensibility",void 0),t}();e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t}(s||(s={})),function(e){var t=function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=e.alpha,t._beta=e.beta,t._gamma=e.gamma},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},t.prototype.getTypeName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t}();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t}(s||(s={})),function(e){var t=function(){function t(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var t=this.camera,i=this.gamepad.leftStick,r=i.x/this.gamepadMoveSensibility,n=i.y/this.gamepadMoveSensibility;i.x=Math.abs(r)>.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick,s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0;var c=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),h=50*t._computeLocalCameraSpeed(),u=e.Vector3.TransformCoordinates(new e.Vector3(i.x*h,0,-i.y*h),c);t.cameraDirection=t.cameraDirection.add(u),t.cameraRotation=t.cameraRotation.add(new e.Vector2(o.y,o.x))}},t.prototype._onNewGameConnected=function(e){0===e.index&&(this.gamepad=e)},t.prototype.getTypeName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},a([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),a([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t}();e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t}(s||(s={})),function(e){var t=function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;t.tabIndex=1,this._onKeyDown=function(e){-1===r.keysUp.indexOf(e.keyCode)&&-1===r.keysDown.indexOf(e.keyCode)&&-1===r.keysLeft.indexOf(e.keyCode)&&-1===r.keysRight.indexOf(e.keyCode)||(-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault()))},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t];-1!==this.keysLeft.indexOf(i)?e.inertialAlphaOffset-=.01:-1!==this.keysUp.indexOf(i)?e.inertialBetaOffset-=.01:-1!==this.keysRight.indexOf(i)?e.inertialAlphaOffset+=.01:-1!==this.keysDown.indexOf(i)&&(e.inertialBetaOffset+=.01)}},t.prototype.getTypeName=function(){return"ArcRotateCameraKeyboardMoveInput"},t.prototype.getSimpleName=function(){return"keyboard"},a([e.serialize()],t.prototype,"keysUp",void 0),a([e.serialize()],t.prototype,"keysDown",void 0),a([e.serialize()],t.prototype,"keysLeft",void 0),a([e.serialize()],t.prototype,"keysRight",void 0),t}();e.ArcRotateCameraKeyboardMoveInput=t,e.CameraInputTypes.ArcRotateCameraKeyboardMoveInput=t}(s||(s={})),function(e){var t=function(){function t(){this.wheelPrecision=3}return t.prototype.attachControl=function(t,i){var r=this;this._wheel=function(t,n){if(t.type===e.PointerEventTypes.POINTERWHEEL){var o=t.event,s=0;o.wheelDelta?s=o.wheelDelta/(40*r.wheelPrecision):o.detail&&(s=-o.detail/r.wheelPrecision),s&&(r.camera.inertialRadiusOffset+=s),o.preventDefault&&(i||o.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,e.PointerEventTypes.POINTERWHEEL)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},t.prototype.getTypeName=function(){return"ArcRotateCameraMouseWheelInput"},t.prototype.getSimpleName=function(){return"mousewheel"},a([e.serialize()],t.prototype,"wheelPrecision",void 0),t}();e.ArcRotateCameraMouseWheelInput=t,e.CameraInputTypes.ArcRotateCameraMouseWheelInput=t}(s||(s={})),function(e){var t=(e.Tools.GetPointerPrefix(),function(){function t(){this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=6,this.panningSensibility=50,this._isPanClick=!1,this.pinchInwards=!0}return t.prototype.attachControl=function(t,i){var r,n,o,s=this,a=this.camera.getEngine(),c=0;this._pointerInput=function(a,h){var u=a.event;if(a.type===e.PointerEventTypes.POINTERMOVE||-1!==s.buttons.indexOf(u.button))if(a.type===e.PointerEventTypes.POINTERDOWN){try{u.srcElement.setPointerCapture(u.pointerId)}catch(e){}s._isPanClick=u.button===s.camera._panningMouseButton,r={x:u.clientX,y:u.clientY,pointerId:u.pointerId,type:u.pointerType},void 0===n?n=r:void 0===o&&(o=r),i||(u.preventDefault(),t.focus())}else if(a.type===e.PointerEventTypes.POINTERUP){try{u.srcElement.releasePointerCapture(u.pointerId)}catch(e){}r=null,c=0,n=o=void 0,i||u.preventDefault()}else if(a.type===e.PointerEventTypes.POINTERMOVE)if(i||u.preventDefault(),n&&void 0===o){if(0!==s.panningSensibility&&(u.ctrlKey&&s.camera._useCtrlForPanning||!s.camera._useCtrlForPanning&&s._isPanClick))s.camera.inertialPanningX+=-(u.clientX-r.x)/s.panningSensibility,s.camera.inertialPanningY+=(u.clientY-r.y)/s.panningSensibility;else{var l=u.clientX-r.x,f=u.clientY-r.y;s.camera.inertialAlphaOffset-=l/s.angularSensibilityX,s.camera.inertialBetaOffset-=f/s.angularSensibilityY}r.x=u.clientX,r.y=u.clientY}else if(n&&o){var d=n.pointerId===u.pointerId?n:o;d.x=u.clientX,d.y=u.clientY;var p=s.pinchInwards?1:-1,m=n.x-o.x,g=n.y-o.y,_=m*m+g*g;if(0===c)return void(c=_);_!==c&&(s.camera.inertialRadiusOffset+=(_-c)/(s.pinchPrecision*((s.angularSensibilityX+s.angularSensibilityY)/2)*p),c=_)}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||t.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){n=o=void 0,c=0,r=null},this._onMouseMove=function(e){if(a.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,r=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;s.camera.inertialAlphaOffset-=t/s.angularSensibilityX,s.camera.inertialBetaOffset-=r/s.angularSensibilityY,i||e.preventDefault()}},this._onGestureStart=function(e){void 0!==window.MSGesture&&(s._MSGestureHandler||(s._MSGestureHandler=new MSGesture,s._MSGestureHandler.target=t),s._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){s.camera.radius*=e.scale,e.preventDefault&&(i||(e.stopPropagation(),e.preventDefault()))},t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("MSPointerDown",this._onGestureStart,!1),t.addEventListener("MSGestureChange",this._onGesture,!1),t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,t.removeEventListener("contextmenu",this._onContextMenu),t.removeEventListener("mousemove",this._onMouseMove),t.removeEventListener("MSPointerDown",this._onGestureStart),t.removeEventListener("MSGestureChange",this._onGesture),t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),this._isPanClick=!1,this.pinchInwards=!0,this._onKeyDown=null,this._onKeyUp=null,this._onMouseMove=null,this._onGestureStart=null,this._onGesture=null,this._MSGestureHandler=null,this._onLostFocus=null,this._onContextMenu=null),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.getTypeName=function(){return"ArcRotateCameraPointersInput"},t.prototype.getSimpleName=function(){return"pointers"},a([e.serialize()],t.prototype,"buttons",void 0),a([e.serialize()],t.prototype,"angularSensibilityX",void 0),a([e.serialize()],t.prototype,"angularSensibilityY",void 0),a([e.serialize()],t.prototype,"pinchPrecision",void 0),a([e.serialize()],t.prototype,"panningSensibility",void 0),t}());e.ArcRotateCameraPointersInput=t,e.CameraInputTypes.ArcRotateCameraPointersInput=t}(s||(s={})),function(e){var t=function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}var n=this.gamepad.leftStick;if(0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype._onNewGameConnected=function(e){0===e.index&&(this.gamepad=e)},t.prototype.getTypeName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},a([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),a([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t}();e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t}(s||(s={})),function(e){var t=function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){this.camera,this._alpha=0|+e.alpha,this._beta=0|+e.beta,this._gamma=0|+e.gamma,this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getTypeName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n){t.call(this,i,r,n),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0),this.rotation=new e.Vector3(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.lockedTarget=null,this._currentTarget=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._camMatrix=e.Matrix.Zero(),this._cameraTransformMatrix=e.Matrix.Zero(),this._cameraRotationMatrix=e.Matrix.Zero(),this._referencePoint=new e.Vector3(0,0,1),this._defaultUpVector=new e.Vector3(0,1,0),this._transformedReferencePoint=e.Vector3.Zero(),this._lookAtTemp=e.Matrix.Zero(),this._tempMatrix=e.Matrix.Zero()}return c(i,t),i.prototype.getFrontPosition=function(e){var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},i.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.lockedTarget=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new e.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this._getLockedTargetPosition();i?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(i):this._cache.lockedTarget=i.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},i.prototype._isSynchronizedViewMatrix=function(){if(!t.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},i.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},i.prototype.setTarget=function(t){this.upVector.normalize(),e.Matrix.LookAtLHToRef(this.position,t,this._defaultUpVector,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var i=t.subtract(this.position);i.x>=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r&&(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,!this.noRotationConstraint)){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}i&&(Math.abs(this.cameraDirection.x)<e.Epsilon&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<e.Epsilon&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<e.Epsilon&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),r&&(Math.abs(this.cameraRotation.x)<e.Epsilon&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<e.Epsilon&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),t.prototype._checkInputs.call(this)},i.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix),e.Vector3.TransformNormalToRef(this._defaultUpVector,this._cameraRotationMatrix,this.upVector)):e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},i.prototype._getViewMatrix=function(){return this.lockedTarget?this._currentTarget.copyFrom(this._getLockedTargetPosition()):(this._updateCameraRotationMatrix(),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget)),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,this._currentTarget,this.upVector,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,this._currentTarget,this.upVector,this._viewMatrix),this._viewMatrix},i.prototype.createRigCamera=function(t,r){if(this.cameraRigMode!==e.Camera.RIG_MODE_NONE){var n=new i(t,this.position.clone(),this.getScene());return this.cameraRigMode!==e.Camera.RIG_MODE_VR&&this.cameraRigMode!==e.Camera.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new e.Quaternion),n._cameraRigParams={},n.rotationQuaternion=new e.Quaternion),n}return null},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,o=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*n,i.position),this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*o,r.position),i.setTarget(this.getTarget()),r.setTarget(this.getTarget());break;case e.Camera.RIG_MODE_VR:case e.Camera.RIG_MODE_WEBVR:i.rotationQuaternion?(i.rotationQuaternion.copyFrom(this.rotationQuaternion),r.rotationQuaternion.copyFrom(this.rotationQuaternion)):(i.rotation.copyFrom(this.rotation),r.rotation.copyFrom(this.rotation)),i.position.copyFrom(this.position),r.position.copyFrom(this.position)}t.prototype._updateRigCameras.call(this)},i.prototype._getRigCamPosition=function(t,i){this._rigCamTransformMatrix||(this._rigCamTransformMatrix=new e.Matrix);var r=this.getTarget();e.Matrix.Translation(-r.x,-r.y,-r.z).multiplyToRef(e.Matrix.RotationY(t),this._rigCamTransformMatrix),this._rigCamTransformMatrix=this._rigCamTransformMatrix.multiply(e.Matrix.Translation(r.x,r.y,r.z)),e.Vector3.TransformCoordinatesToRef(this.position,this._rigCamTransformMatrix,i)},i.prototype.getTypeName=function(){return"TargetCamera"},a([e.serializeAsVector3()],i.prototype,"rotation",void 0),a([e.serialize()],i.prototype,"speed",void 0),a([e.serializeAsMeshReference("lockedTargetId")],i.prototype,"lockedTarget",void 0),i}(e.Camera);e.TargetCamera=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n){var o=this;t.call(this,i,r,n),this.ellipsoid=new e.Vector3(.5,1,.5),this.checkCollisions=!1,this.applyGravity=!1,this._collider=new e.Collider,this._needMoveForGravity=!1,this._oldPosition=e.Vector3.Zero(),this._diffPosition=e.Vector3.Zero(),this._newPosition=e.Vector3.Zero(),this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider.radius);!function(t){o._newPosition.copyFrom(t),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o.position.clone(),o._diffPosition.length()>e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))}(i)},this.inputs=new e.FreeCameraInputsManager(this),this.inputs.addKeyboard().addMouse()}return c(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysUp},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysDown},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysLeft},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysRight},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},i.prototype._collideWithWorld=function(t){(this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider.radius=this.ellipsoid;var i=t;this.applyGravity&&(i=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):this.position.addInPlace(this.cameraDirection)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getTypeName=function(){return"FreeCamera"},a([e.serializeAsVector3()],i.prototype,"ellipsoid",void 0),a([e.serialize()],i.prototype,"checkCollisions",void 0),a([e.serialize()],i.prototype,"applyGravity",void 0),i}(e.TargetCamera);e.FreeCamera=t}(s||(s={})),function(e){var t=function(t){function i(e){t.call(this,e)}return c(i,t),i.prototype.addKeyboard=function(){return this.add(new e.FreeCameraKeyboardMoveInput),this},i.prototype.addMouse=function(t){return void 0===t&&(t=!0),this.add(new e.FreeCameraMouseInput(t)),this},i.prototype.addGamepad=function(){return this.add(new e.FreeCameraGamepadInput),this},i.prototype.addDeviceOrientation=function(){return this.add(new e.FreeCameraDeviceOrientationInput),this},i.prototype.addTouch=function(){return this.add(new e.FreeCameraTouchInput),this},i.prototype.addVirtualJoystick=function(){return this.add(new e.FreeCameraVirtualJoystickInput),this},i}(e.CameraInputsManager);e.FreeCameraInputsManager=t}(s||(s={})),function(e){var t=function(t){function i(e,i,r,n){t.call(this,e,i,r),this.radius=12,this.rotationOffset=0,this.heightOffset=4,this.cameraAcceleration=.05,this.maxCameraSpeed=20,this.lockedTarget=n}return c(i,t),i.prototype.getRadians=function(e){return e*Math.PI/180},i.prototype.follow=function(t){if(t){var i;if(t.rotationQuaternion){var r=new e.Matrix;t.rotationQuaternion.toRotationMatrix(r),i=Math.atan2(r.m[8],r.m[10])}else i=t.rotation.y;var n=this.getRadians(this.rotationOffset)+i,o=t.position.x+Math.sin(n)*this.radius,s=t.position.z+Math.cos(n)*this.radius,a=o-this.position.x,c=t.position.y+this.heightOffset-this.position.y,h=s-this.position.z,u=a*this.cameraAcceleration*2,l=c*this.cameraAcceleration,f=h*this.cameraAcceleration*2;(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(l>this.maxCameraSpeed||l<-this.maxCameraSpeed)&&(l=l<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+u,this.position.y+l,this.position.z+f),this.setTarget(t.position)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.lockedTarget)},i.prototype.getTypeName=function(){return"FollowCamera"},a([e.serialize()],i.prototype,"radius",void 0),a([e.serialize()],i.prototype,"rotationOffset",void 0),a([e.serialize()],i.prototype,"heightOffset",void 0),a([e.serialize()],i.prototype,"cameraAcceleration",void 0),a([e.serialize()],i.prototype,"maxCameraSpeed",void 0),a([e.serializeAsMeshReference("lockedTargetId")],i.prototype,"lockedTarget",void 0),i}(e.TargetCamera);e.FollowCamera=t;var i=function(t){function i(i,r,n,o,s,a){t.call(this,i,e.Vector3.Zero(),a),this.alpha=r,this.beta=n,this.radius=o,this.target=s,this._cartesianCoordinates=e.Vector3.Zero(),this.follow()}return c(i,t),i.prototype.follow=function(){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta),this.position=this.target.position.add(this._cartesianCoordinates),this.setTarget(this.target.position)},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i.prototype.getTypeName=function(){return"ArcFollowCamera"},i}(e.TargetCamera);e.ArcFollowCamera=i}(s||(s={})),function(e){var t=function(e){function t(t,i,r){e.call(this,t,i,r),this.inputs.addTouch(),this._setupInputs()}return c(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getTypeName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t}(e.FreeCamera);e.TouchCamera=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o,s,a){var c=this;t.call(this,i,e.Vector3.Zero(),a),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.inertialPanningX=0,this.inertialPanningY=0,this.zoomOnFactor=1,this.targetScreenOffset=e.Vector2.Zero(),this.allowUpsideDown=!0,this._viewMatrix=new e.Matrix,this.panningAxis=new e.Vector3(1,1,0),this.checkCollisions=!1,this.collisionRadius=new e.Vector3(.5,.5,.5),this._collider=new e.Collider,this._previousPosition=e.Vector3.Zero(),this._collisionVelocity=e.Vector3.Zero(),this._newPosition=e.Vector3.Zero(),this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),c.getScene().workerCollisions&&c.checkCollisions&&i.multiplyInPlace(c._collider.radius),r?(c.setPosition(i),c.onCollide&&c.onCollide(r)):c._previousPosition.copyFrom(c.position);var n=Math.cos(c.alpha),o=Math.sin(c.alpha),s=Math.cos(c.beta),a=Math.sin(c.beta);0===a&&(a=1e-4);var h=c._getTargetPosition();h.addToRef(new e.Vector3(c.radius*n*a,c.radius*s,c.radius*o*a),c._newPosition),c.position.copyFrom(c._newPosition);var u=c.upVector;c.allowUpsideDown&&c.beta<0&&(u=(u=u.clone()).negate()),e.Matrix.LookAtLHToRef(c.position,h,u,c._viewMatrix),c._viewMatrix.m[12]+=c.targetScreenOffset.x,c._viewMatrix.m[13]+=c.targetScreenOffset.y,c._collisionTriggered=!1},this.target=s||e.Vector3.Zero(),this.alpha=r,this.beta=n,this.radius=o,this.getViewMatrix(),this.inputs=new e.ArcRotateCameraInputsManager(this),this.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad()}return c(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityY},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.pinchPrecision},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.panningSensibility},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysUp},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysDown},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysLeft},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysRight},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;if(e)return e.wheelPrecision},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.target=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=e.Vector2.Zero()},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this),this._cache.target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},i.prototype._getTargetPosition=function(){if(this.target.getAbsolutePosition){var e=this.target.getAbsolutePosition();return this._targetBoundingCenter?e.add(this._targetBoundingCenter):e}return this.target},i.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronizedViewMatrix.call(this)&&this._cache.target.equals(this.target)&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset)},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.inertialRadiusOffset=0}},i.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},i.prototype._checkInputs=function(){this._collisionTriggered||(this.inputs.checkInputs(),0===this.inertialAlphaOffset&&0===this.inertialBetaOffset&&0===this.inertialRadiusOffset||(this.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset:this.alpha+=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<e.Epsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<e.Epsilon&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<e.Epsilon&&(this.inertialRadiusOffset=0)),0===this.inertialPanningX&&0===this.inertialPanningY||(this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inertialPanningX*=this.inertia,this.inertialPanningY*=this.inertia,Math.abs(this.inertialPanningX)<e.Epsilon&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<e.Epsilon&&(this.inertialPanningY=0),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),e.Vector3.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),this.target.getAbsolutePosition||this.target.addInPlace(this._transformedDirection)),this._checkLimits(),t.prototype._checkInputs.call(this))},i.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t){void 0===t&&(t=!1),this._getTargetPosition().equals(e)||(t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.center.clone():this._targetBoundingCenter=null,this.target=e,this.rebuildAnglesAndRadius())},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&this.beta<0&&(s=(s=s.clone()).negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){var r,n;void 0===i&&(i=!1),void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this.target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this.target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getTypeName=function(){return"ArcRotateCamera"},a([e.serialize()],i.prototype,"alpha",void 0),a([e.serialize()],i.prototype,"beta",void 0),a([e.serialize()],i.prototype,"radius",void 0),a([e.serializeAsVector3()],i.prototype,"target",void 0),a([e.serialize()],i.prototype,"inertialAlphaOffset",void 0),a([e.serialize()],i.prototype,"inertialBetaOffset",void 0),a([e.serialize()],i.prototype,"inertialRadiusOffset",void 0),a([e.serialize()],i.prototype,"lowerAlphaLimit",void 0),a([e.serialize()],i.prototype,"upperAlphaLimit",void 0),a([e.serialize()],i.prototype,"lowerBetaLimit",void 0),a([e.serialize()],i.prototype,"upperBetaLimit",void 0),a([e.serialize()],i.prototype,"lowerRadiusLimit",void 0),a([e.serialize()],i.prototype,"upperRadiusLimit",void 0),a([e.serialize()],i.prototype,"inertialPanningX",void 0),a([e.serialize()],i.prototype,"inertialPanningY",void 0),a([e.serialize()],i.prototype,"zoomOnFactor",void 0),a([e.serialize()],i.prototype,"allowUpsideDown",void 0),i}(e.TargetCamera);e.ArcRotateCamera=t}(s||(s={})),function(e){var t=function(t){function i(e){t.call(this,e)}return c(i,t),i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i}(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t}(s||(s={})),function(e){var t=function(){function t(e){this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;i<t.MAX_RENDERINGGROUPS;i++)this._autoClearDepthStencil[i]=!0}return t.prototype._renderParticles=function(e,t){if(0!==this._scene._activeParticleSystems.length){var i=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var r=0;r<this._scene._activeParticleSystems.length;r++){var n=this._scene._activeParticleSystems.data[r];n.renderingGroupId===e&&0!=(i.layerMask&n.layerMask)&&(this._clearDepthStencilBuffer(),n.emitter.position&&t&&-1===t.indexOf(n.emitter)||this._scene._activeParticles.addCount(n.render(),!1))}this._scene._particlesDuration.endMonitoring(!1)}},t.prototype._renderSprites=function(e){if(this._scene.spritesEnabled&&0!==this._scene.spriteManagers.length){var t=this._scene.activeCamera;this._scene._spritesDuration.beginMonitoring();for(var i=0;i<this._scene.spriteManagers.length;i++){var r=this._scene.spriteManagers[i];r.renderingGroupId===e&&0!=(t.layerMask&r.layerMask)&&(this._clearDepthStencilBuffer(),r.render())}this._scene._spritesDuration.endMonitoring(!1)}},t.prototype._clearDepthStencilBuffer=function(){this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(0,!1,!0,!0),this._depthStencilBufferAlreadyCleaned=!0)},t.prototype._renderSpritesAndParticles=function(){this._currentRenderSprites&&this._renderSprites(this._currentIndex),this._currentRenderParticles&&this._renderParticles(this._currentIndex,this._currentActiveMeshes)},t.prototype.render=function(i,r,n,o){var s=this._scene.onRenderingGroupObservable.hasObservers()?this._scene.onRenderingGroupObservable:null,a=null;s&&(this._renderinGroupInfo||(this._renderinGroupInfo=new e.RenderingGroupInfo),(a=this._renderinGroupInfo).scene=this._scene,a.camera=this._scene.activeCamera),this._currentActiveMeshes=r,this._currentRenderParticles=n,this._currentRenderSprites=o;for(var c=t.MIN_RENDERINGGROUPS;c<t.MAX_RENDERINGGROUPS;c++){this._depthStencilBufferAlreadyCleaned=c===t.MIN_RENDERINGGROUPS;var h=this._renderingGroups[c],u=!1;if(this._currentIndex=c,h){var l=0;s&&(l=Math.pow(2,c),a.renderStage=e.RenderingGroupInfo.STAGE_PRECLEAR,a.renderingGroupId=c,s.notifyObservers(a,l)),this._autoClearDepthStencil[c]&&this._clearDepthStencilBuffer(),s&&(a.renderStage=e.RenderingGroupInfo.STAGE_PREOPAQUE,s.notifyObservers(a,l)),h.onBeforeTransparentRendering||(h.onBeforeTransparentRendering=this._renderSpritesAndParticles.bind(this)),s&&(a.renderStage=e.RenderingGroupInfo.STAGE_PRETRANSPARENT,s.notifyObservers(a,l)),h.render(i)||(this._renderingGroups.splice(c,1),u=!0,this._renderSpritesAndParticles()),s&&(a.renderStage=e.RenderingGroupInfo.STAGE_POSTTRANSPARENT,s.notifyObservers(a,l))}else if(this._renderSpritesAndParticles(),s){l=Math.pow(2,c);a.renderStage=e.RenderingGroupInfo.STAGE_PRECLEAR,a.renderingGroupId=c,s.notifyObservers(a,l),a.renderStage=e.RenderingGroupInfo.STAGE_POSTTRANSPARENT,s.notifyObservers(a,l)}u&&c--}},t.prototype.reset=function(){for(var e=t.MIN_RENDERINGGROUPS;e<t.MAX_RENDERINGGROUPS;e++){var i=this._renderingGroups[e];i&&i.prepare()}},t.prototype.dispatch=function(t){var i=t.getMesh().renderingGroupId||0;this._renderingGroups[i]||(this._renderingGroups[i]=new e.RenderingGroup(i,this._scene,this._customOpaqueSortCompareFn[i],this._customAlphaTestSortCompareFn[i],this._customTransparentSortCompareFn[i])),this._renderingGroups[i].dispatch(t)},t.prototype.setRenderingOrder=function(e,t,i,r){if(void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=r,this._renderingGroups[e]){var n=this._renderingGroups[e];n.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],n.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],n.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}},t.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._autoClearDepthStencil[e]=t},t.MAX_RENDERINGGROUPS=4,t.MIN_RENDERINGGROUPS=0,t}();e.RenderingManager=t}(s||(s={})),function(e){var t=function(){function t(t,i,r,n,o){void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),this.index=t,this._opaqueSubMeshes=new e.SmartArray(256),this._transparentSubMeshes=new e.SmartArray(256),this._alphaTestSubMeshes=new e.SmartArray(256),this._scene=i,this.opaqueSortCompareFn=r,this.alphaTestSortCompareFn=n,this.transparentSortCompareFn=o}return Object.defineProperty(t.prototype,"opaqueSortCompareFn",{set:function(e){this._opaqueSortCompareFn=e,this._renderOpaque=e?this.renderOpaqueSorted:t.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alphaTestSortCompareFn",{set:function(e){this._alphaTestSortCompareFn=e,this._renderAlphaTest=e?this.renderAlphaTestSorted:t.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transparentSortCompareFn",{set:function(e){this._transparentSortCompareFn=e||t.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!0,configurable:!0}),t.prototype.render=function(t){if(t)return t(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes),!0;if(0===this._opaqueSubMeshes.length&&0===this._alphaTestSubMeshes.length&&0===this._transparentSubMeshes.length)return this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),!1;var i=this._scene.getEngine();return this._renderOpaque(this._opaqueSubMeshes),i.setAlphaTesting(!0),this._renderAlphaTest(this._alphaTestSubMeshes),i.setAlphaTesting(!1),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._renderTransparent(this._transparentSubMeshes),i.setAlphaMode(e.Engine.ALPHA_DISABLE),!0},t.prototype.renderOpaqueSorted=function(e){return t.renderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera.globalPosition,!1)},t.prototype.renderAlphaTestSorted=function(e){return t.renderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera.globalPosition,!1)},t.prototype.renderTransparentSorted=function(e){return t.renderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera.globalPosition,!0)},t.renderSorted=function(e,t,i,r){for(var n,o=0;o<e.length;o++)(n=e.data[o])._alphaIndex=n.getMesh().alphaIndex,n._distanceToCamera=n.getBoundingInfo().boundingSphere.centerWorld.subtract(i).length();var s=e.data.slice(0,e.length);for(s.sort(t),o=0;o<s.length;o++)(n=s[o]).render(r)},t.renderUnsorted=function(e){for(var t=0;t<e.length;t++){e.data[t].render(!1)}},t.defaultTransparentSortCompare=function(e,i){return e._alphaIndex>i._alphaIndex?1:e._alphaIndex<i._alphaIndex?-1:t.backToFrontSortCompare(e,i)},t.backToFrontSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset()},t.prototype.dispatch=function(e){var t=e.getMaterial(),i=e.getMesh();t.needAlphaBlending()||i.visibility<1||i.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e)},t}();e.RenderingGroup=t}(s||(s={})),function(e){var t=function(){function e(){}return Object.defineProperty(e,"POINTERDOWN",{get:function(){return e._POINTERDOWN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERUP",{get:function(){return e._POINTERUP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERMOVE",{get:function(){return e._POINTERMOVE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERWHEEL",{get:function(){return e._POINTERWHEEL},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERPICK",{get:function(){return e._POINTERPICK},enumerable:!0,configurable:!0}),e._POINTERDOWN=1,e._POINTERUP=2,e._POINTERMOVE=4,e._POINTERWHEEL=8,e._POINTERPICK=16,e}();e.PointerEventTypes=t;var i=function(){return function(e,t){this.type=e,this.event=t}}();e.PointerInfoBase=i;var r=function(t){function i(i,r,n,o){t.call(this,i,r),this.skipOnPointerObservable=!1,this.localPosition=new e.Vector2(n,o)}return c(i,t),i}(i);e.PointerInfoPre=r;var n=function(e){function t(t,i,r){e.call(this,t,i),this.pickInfo=r}return c(t,e),t}(i);e.PointerInfo=n;var o=function(){function e(){}return e.STAGE_PRECLEAR=1,e.STAGE_PREOPAQUE=2,e.STAGE_PRETRANSPARENT=3,e.STAGE_POSTTRANSPARENT=4,e}();e.RenderingGroupInfo=o;var s=function(){function i(t){this.autoClear=!0,this.clearColor=new e.Color3(.2,.2,.3),this.ambientColor=new e.Color3(0,0,0),this.forceWireframe=!1,this.forcePointsCloud=!1,this.forceShowBoundingBoxes=!1,this.animationsEnabled=!0,this.constantlyUpdateMeshUnderPointer=!1,this.useRightHandedSystem=!1,this.hoverCursor="pointer",this.metadata=null,this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.onReadyObservable=new e.Observable,this.onBeforeCameraRenderObservable=new e.Observable,this.onAfterCameraRenderObservable=new e.Observable,this.onNewCameraAddedObservable=new e.Observable,this.onCameraRemovedObservable=new e.Observable,this.onNewLightAddedObservable=new e.Observable,this.onLightRemovedObservable=new e.Observable,this.onNewGeometryAddedObservable=new e.Observable,this.onGeometryRemovedObservable=new e.Observable,this.onNewMeshAddedObservable=new e.Observable,this.onMeshRemovedObservable=new e.Observable,this.onRenderingGroupObservable=new e.Observable,this.animations=[],this.onPrePointerObservable=new e.Observable,this.onPointerObservable=new e.Observable,this.cameraToUseForPointers=null,this._startingPointerPosition=new e.Vector2(0,0),this._startingPointerTime=0,this.fogEnabled=!0,this.fogMode=i.FOGMODE_NONE,this.fogColor=new e.Color3(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.shadowsEnabled=!0,this.lightsEnabled=!0,this.lights=new Array,this.cameras=new Array,this.activeCameras=new Array,this.meshes=new Array,this._geometries=new Array,this.materials=new Array,this.multiMaterials=new Array,this.texturesEnabled=!0,this.textures=new Array,this.particlesEnabled=!0,this.particleSystems=new Array,this.spritesEnabled=!0,this.spriteManagers=new Array,this.layers=new Array,this.highlightLayers=new Array,this.skeletonsEnabled=!0,this.skeletons=new Array,this.lensFlaresEnabled=!0,this.lensFlareSystems=new Array,this.collisionsEnabled=!0,this.gravity=new e.Vector3(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=new Array,this.importedMeshesFiles=new Array,this.probesEnabled=!0,this.reflectionProbes=new Array,this._actionManagers=new Array,this._meshesForIntersections=new e.SmartArray(256),this.proceduralTexturesEnabled=!0,this._proceduralTextures=new Array,this.soundTracks=new Array,this._audioEnabled=!0,this._headphone=!1,this._totalMeshesCounter=new e.PerfCounter,this._totalLightsCounter=new e.PerfCounter,this._totalMaterialsCounter=new e.PerfCounter,this._totalTexturesCounter=new e.PerfCounter,this._totalVertices=new e.PerfCounter,this._activeIndices=new e.PerfCounter,this._activeParticles=new e.PerfCounter,this._lastFrameDuration=new e.PerfCounter,this._evaluateActiveMeshesDuration=new e.PerfCounter,this._renderTargetsDuration=new e.PerfCounter,this._particlesDuration=new e.PerfCounter,this._renderDuration=new e.PerfCounter,this._spritesDuration=new e.PerfCounter,this._activeBones=new e.PerfCounter,this._renderId=0,this._executeWhenReadyTimeoutId=-1,this._intermediateRendering=!1,this._toBeDisposed=new e.SmartArray(256),this._pendingData=[],this._activeMeshes=new e.SmartArray(256),this._processedMaterials=new e.SmartArray(256),this._renderTargets=new e.SmartArray(256),this._activeParticleSystems=new e.SmartArray(256),this._activeSkeletons=new e.SmartArray(32),this._softwareSkinnedMeshes=new e.SmartArray(32),this._activeAnimatables=new Array,this._transformMatrix=e.Matrix.Zero(),this._edgesRenderers=new e.SmartArray(16),this._uniqueIdCounter=0,this._engine=t,t.scenes.push(this),this._externalData=new e.StringDictionary,this._uid=null,this._renderingManager=new e.RenderingManager(this),this.postProcessManager=new e.PostProcessManager(this),this.postProcessRenderPipelineManager=new e.PostProcessRenderPipelineManager,this._boundingBoxRenderer=new e.BoundingBoxRenderer(this),e.OutlineRenderer&&(this._outlineRenderer=new e.OutlineRenderer(this)),this.attachControl(),e.SoundTrack&&(this.mainSoundTrack=new e.SoundTrack(this,{mainTrack:!0})),e.SimplificationQueue&&(this.simplificationQueue=new e.SimplificationQueue),this.workerCollisions=!1}return Object.defineProperty(i,"FOGMODE_NONE",{get:function(){return i._FOGMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP",{get:function(){return i._FOGMODE_EXP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP2",{get:function(){return i._FOGMODE_EXP2},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_LINEAR",{get:function(){return i._FOGMODE_LINEAR},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"unTranslatedPointer",{get:function(){return new e.Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=new e.StandardMaterial("default material",this)),this._defaultMaterial},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new e.DebugLayer(this)),this._debugLayer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"workerCollisions",{get:function(){return this._workerCollisions},set:function(t){t=t&&!!Worker,this._workerCollisions=t,this.collisionCoordinator&&this.collisionCoordinator.destroy(),this.collisionCoordinator=t?new e.CollisionCoordinatorWorker:new e.CollisionCoordinatorLegacy,this.collisionCoordinator.init(this)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"SelectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),i.prototype.getCachedMaterial=function(){return this._cachedMaterial},i.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer},i.prototype.getOutlineRenderer=function(){return this._outlineRenderer},i.prototype.getEngine=function(){return this._engine},i.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(i.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!0,configurable:!0}),i.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(i.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!0,configurable:!0}),i.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(i.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!0,configurable:!0}),i.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(i.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!0,configurable:!0}),i.prototype.getLastFrameDuration=function(){return this._lastFrameDuration.current},Object.defineProperty(i.prototype,"lastFramePerfCounter",{get:function(){return this._lastFrameDuration},enumerable:!0,configurable:!0}),i.prototype.getEvaluateActiveMeshesDuration=function(){return this._evaluateActiveMeshesDuration.current},Object.defineProperty(i.prototype,"evaluateActiveMeshesDurationPerfCounter",{get:function(){return this._evaluateActiveMeshesDuration},enumerable:!0,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.getRenderTargetsDuration=function(){return this._renderTargetsDuration.current},i.prototype.getRenderDuration=function(){return this._renderDuration.current},Object.defineProperty(i.prototype,"renderDurationPerfCounter",{get:function(){return this._renderDuration},enumerable:!0,configurable:!0}),i.prototype.getParticlesDuration=function(){return this._particlesDuration.current},Object.defineProperty(i.prototype,"particlesDurationPerfCounter",{get:function(){return this._particlesDuration},enumerable:!0,configurable:!0}),i.prototype.getSpritesDuration=function(){return this._spritesDuration.current},Object.defineProperty(i.prototype,"spriteDuractionPerfCounter",{get:function(){return this._spritesDuration},enumerable:!0,configurable:!0}),i.prototype.getAnimationRatio=function(){return this._animationRatio},i.prototype.getRenderId=function(){return this._renderId},i.prototype.incrementRenderId=function(){this._renderId++},i.prototype._updatePointerPosition=function(e){var t=this._engine.getRenderingCanvasClientRect();this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY,this.cameraToUseForPointers&&(this._pointerX=this._pointerX-this.cameraToUseForPointers.viewport.x*this._engine.getRenderWidth(),this._pointerY=this._pointerY-this.cameraToUseForPointers.viewport.y*this._engine.getRenderHeight())},i.prototype.attachControl=function(i,o,s){var a=this;void 0===i&&(i=!0),void 0===o&&(o=!0),void 0===s&&(s=!0);var c=function(e){return e.isPickable&&e.actionManager&&e.actionManager.hasPointerTriggers};this._onPointerMove=function(e){if(a._updatePointerPosition(e),a.onPrePointerObservable.hasObservers()){var i="mousewheel"===e.type||"DOMMouseScroll"===e.type?t.POINTERWHEEL:t.POINTERMOVE,o=new r(i,e,a._unTranslatedPointerX,a._unTranslatedPointerY);if(a.onPrePointerObservable.notifyObservers(o,i),o.skipOnPointerObservable)return}if(a.cameraToUseForPointers||a.activeCamera){var s=a._engine.getRenderingCanvas();a.pointerMovePredicate||(a.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&(a.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var h=a.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,a.pointerMovePredicate,!1,a.cameraToUseForPointers);if(h.hit&&h.pickedMesh?(a.setPointerOverSprite(null),a.setPointerOverMesh(h.pickedMesh),a._pointerOverMesh.actionManager&&a._pointerOverMesh.actionManager.hasPointerTriggers?a._pointerOverMesh.actionManager.hoverCursor?s.style.cursor=a._pointerOverMesh.actionManager.hoverCursor:s.style.cursor=a.hoverCursor:s.style.cursor=""):(a.setPointerOverMesh(null),(h=a.pickSprite(a._unTranslatedPointerX,a._unTranslatedPointerY,c,!1,a.cameraToUseForPointers)).hit&&h.pickedSprite?(a.setPointerOverSprite(h.pickedSprite),a._pointerOverSprite.actionManager&&a._pointerOverSprite.actionManager.hoverCursor?s.style.cursor=a._pointerOverSprite.actionManager.hoverCursor:s.style.cursor=a.hoverCursor):(a.setPointerOverSprite(null),s.style.cursor="")),a.onPointerMove&&a.onPointerMove(e,h),a.onPointerObservable.hasObservers()){i="mousewheel"===e.type||"DOMMouseScroll"===e.type?t.POINTERWHEEL:t.POINTERMOVE,o=new n(i,e,h);a.onPointerObservable.notifyObservers(o,i)}}},this._onPointerDown=function(i){if(a._updatePointerPosition(i),a.onPrePointerObservable.hasObservers()){var o=t.POINTERDOWN,s=new r(o,i,a._unTranslatedPointerX,a._unTranslatedPointerY);if(a.onPrePointerObservable.notifyObservers(s,o),s.skipOnPointerObservable)return}if(a.cameraToUseForPointers||a.activeCamera){a._startingPointerPosition.x=a._pointerX,a._startingPointerPosition.y=a._pointerY,a._startingPointerTime=(new Date).getTime(),a.pointerDownPredicate||(a.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()}),a._pickedDownMesh=null;var h=a.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,a.pointerDownPredicate,!1,a.cameraToUseForPointers);if(h.hit&&h.pickedMesh&&h.pickedMesh.actionManager){if(a._pickedDownMesh=h.pickedMesh,h.pickedMesh.actionManager.hasPickTriggers){switch(i.button){case 0:h.pickedMesh.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNew(h.pickedMesh,i));break;case 1:h.pickedMesh.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNew(h.pickedMesh,i));break;case 2:h.pickedMesh.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNew(h.pickedMesh,i))}h.pickedMesh.actionManager&&h.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNew(h.pickedMesh,i))}if(h.pickedMesh.actionManager&&h.pickedMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)){var u=a;window.setTimeout(function(){var t=u.pick(u._unTranslatedPointerX,u._unTranslatedPointerY,function(t){return t.isPickable&&t.isVisible&&t.isReady()&&t.actionManager&&t.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)},!1,u.cameraToUseForPointers);t.hit&&t.pickedMesh&&t.pickedMesh.actionManager&&0!==u._startingPointerTime&&(new Date).getTime()-u._startingPointerTime>e.ActionManager.LongPressDelay&&Math.abs(u._startingPointerPosition.x-u._pointerX)<e.ActionManager.DragMovementThreshold&&Math.abs(u._startingPointerPosition.y-u._pointerY)<e.ActionManager.DragMovementThreshold&&(u._startingPointerTime=0,t.pickedMesh.actionManager.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i)))},e.ActionManager.LongPressDelay)}}if(a.onPointerDown&&a.onPointerDown(i,h),a.onPointerObservable.hasObservers()){o=t.POINTERDOWN,s=new n(o,i,h);a.onPointerObservable.notifyObservers(s,o)}if(a._pickedDownSprite=null,a.spriteManagers.length>0&&((h=a.pickSprite(a._unTranslatedPointerX,a._unTranslatedPointerY,c,!1,a.cameraToUseForPointers)).hit&&h.pickedSprite&&h.pickedSprite.actionManager)){switch(a._pickedDownSprite=h.pickedSprite,i.button){case 0:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,a,i));break;case 1:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,a,i));break;case 2:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,a,i))}h.pickedSprite.actionManager&&h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,a,i))}}},this._onPointerUp=function(i){if(a._updatePointerPosition(i),a.onPrePointerObservable.hasObservers()){var o=t.POINTERUP,s=new r(o,i,a._unTranslatedPointerX,a._unTranslatedPointerY);if(a.onPrePointerObservable.notifyObservers(s,o),s.skipOnPointerObservable)return}if(a.cameraToUseForPointers||a.activeCamera){a.pointerUpPredicate||(a.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()});var h=a.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,a.pointerUpPredicate,!1,a.cameraToUseForPointers);if(h.hit&&h.pickedMesh){if(null!=a._pickedDownMesh&&h.pickedMesh==a._pickedDownMesh&&(a.onPointerPick&&a.onPointerPick(i,h),a.onPointerObservable.hasObservers())){o=t.POINTERPICK,s=new n(o,i,h);a.onPointerObservable.notifyObservers(s,o)}h.pickedMesh.actionManager&&(h.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(h.pickedMesh,i)),h.pickedMesh.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)<e.ActionManager.DragMovementThreshold&&Math.abs(a._startingPointerPosition.y-a._pointerY)<e.ActionManager.DragMovementThreshold&&h.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(h.pickedMesh,i)))}if(a._pickedDownMesh&&a._pickedDownMesh.actionManager&&a._pickedDownMesh!==h.pickedMesh&&a._pickedDownMesh.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNew(a._pickedDownMesh,i)),a.onPointerUp&&a.onPointerUp(i,h),a.onPointerObservable.hasObservers()){o=t.POINTERUP,s=new n(o,i,h);a.onPointerObservable.notifyObservers(s,o)}a._startingPointerTime=0,a.spriteManagers.length>0&&((h=a.pickSprite(a._unTranslatedPointerX,a._unTranslatedPointerY,c,!1,a.cameraToUseForPointers)).hit&&h.pickedSprite&&h.pickedSprite.actionManager&&(h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,a,i)),h.pickedSprite.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)<e.ActionManager.DragMovementThreshold&&Math.abs(a._startingPointerPosition.y-a._pointerY)<e.ActionManager.DragMovementThreshold&&h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,a,i))),a._pickedDownSprite&&a._pickedDownSprite.actionManager&&a._pickedDownSprite!==h.pickedSprite&&a._pickedDownSprite.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNewFromSprite(a._pickedDownSprite,a,i)))}},this._onKeyDown=function(t){a.actionManager&&a.actionManager.processTrigger(e.ActionManager.OnKeyDownTrigger,e.ActionEvent.CreateNewFromScene(a,t))},this._onKeyUp=function(t){a.actionManager&&a.actionManager.processTrigger(e.ActionManager.OnKeyUpTrigger,e.ActionEvent.CreateNewFromScene(a,t))};var h=e.Tools.GetPointerPrefix(),u=this._engine.getRenderingCanvas();s&&(u.addEventListener(h+"move",this._onPointerMove,!1),u.addEventListener("mousewheel",this._onPointerMove,!1),u.addEventListener("DOMMouseScroll",this._onPointerMove,!1)),o&&u.addEventListener(h+"down",this._onPointerDown,!1),i&&u.addEventListener(h+"up",this._onPointerUp,!1),u.tabIndex=1,u.addEventListener("keydown",this._onKeyDown,!1),u.addEventListener("keyup",this._onKeyUp,!1)},i.prototype.detachControl=function(){var t=e.Tools.GetPointerPrefix(),i=this._engine.getRenderingCanvas();i.removeEventListener(t+"move",this._onPointerMove),i.removeEventListener(t+"down",this._onPointerDown),i.removeEventListener(t+"up",this._onPointerUp),i.removeEventListener("mousewheel",this._onPointerMove),i.removeEventListener("DOMMouseScroll",this._onPointerMove),i.removeEventListener("keydown",this._onKeyDown),i.removeEventListener("keyup",this._onKeyUp)},i.prototype.isReady=function(){if(this._pendingData.length>0)return!1;var t;for(t=0;t<this._geometries.length;t++){if(this._geometries[t].delayLoadState===e.Engine.DELAYLOADSTATE_LOADING)return!1}for(t=0;t<this.meshes.length;t++){var i=this.meshes[t];if(!i.isReady())return!1;var r=i.material;if(r&&!r.isReady(i))return!1}return!0},i.prototype.resetCachedMaterial=function(){this._cachedMaterial=null},i.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},i.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},i.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},i.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},i.prototype._addPendingData=function(e){this._pendingData.push(e)},i.prototype._removePendingData=function(e){var t=this._pendingData.indexOf(e);-1!==t&&this._pendingData.splice(t,1)},i.prototype.getWaitingItemsCount=function(){return this._pendingData.length},i.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout(function(){t._checkIsReady()},150))},i.prototype._checkIsReady=function(){var e=this;return this.isReady()?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):void(this._executeWhenReadyTimeoutId=setTimeout(function(){e._checkIsReady()},150))},i.prototype.beginAnimation=function(t,i,r,n,o,s,a){if(void 0===o&&(o=1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var c=t.getAnimatables(),h=0;h<c.length;h++)this.beginAnimation(c[h],i,r,n,o,s,a);return a.reset(),a},i.prototype.beginDirectAnimation=function(t,i,r,n,o,s,a){return void 0===s&&(s=1),new e.Animatable(this,t,r,n,o,s,a,i)},i.prototype.getAnimatableByTarget=function(e){for(var t=0;t<this._activeAnimatables.length;t++)if(this._activeAnimatables[t].target===e)return this._activeAnimatables[t];return null},Object.defineProperty(i.prototype,"Animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),i.prototype.stopAnimation=function(e,t){var i=this.getAnimatableByTarget(e);i&&i.stop(t)},i.prototype._animate=function(){if(this.animationsEnabled&&0!==this._activeAnimatables.length){if(!this._animationStartDate){if(this._pendingData.length>0)return;this._animationStartDate=e.Tools.Now}for(var t=e.Tools.Now-this._animationStartDate,i=0;i<this._activeAnimatables.length;i++)this._activeAnimatables[i]._animate(t)}},i.prototype.getViewMatrix=function(){return this._viewMatrix},i.prototype.getProjectionMatrix=function(){return this._projectionMatrix},i.prototype.getTransformMatrix=function(){return this._transformMatrix},i.prototype.setTransformMatrix=function(t,i){this._viewMatrix=t,this._projectionMatrix=i,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix)},i.prototype.addMesh=function(e){e.uniqueId=this._uniqueIdCounter++,this.meshes.push(e),this.collisionCoordinator.onMeshAdded(e),this.onNewMeshAddedObservable.notifyObservers(e)},i.prototype.removeMesh=function(e){var t=this.meshes.indexOf(e);return-1!==t&&this.meshes.splice(t,1),this.collisionCoordinator.onMeshRemoved(e),this.onMeshRemovedObservable.notifyObservers(e),t},i.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},i.prototype.removeLight=function(e){var t=this.lights.indexOf(e);return-1!==t&&this.lights.splice(t,1),this.onLightRemovedObservable.notifyObservers(e),t},i.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);-1!==t&&this.cameras.splice(t,1);var i=this.activeCameras.indexOf(e);return-1!==i&&this.activeCameras.splice(i,1),this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},i.prototype.addLight=function(e){e.uniqueId=this._uniqueIdCounter++,this.lights.push(e),this.onNewLightAddedObservable.notifyObservers(e)},i.prototype.addCamera=function(e){e.uniqueId=this._uniqueIdCounter++,this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e)},i.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i)},i.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},i.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},i.prototype.getMaterialByID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].id===e)return this.materials[t];return null},i.prototype.getMaterialByName=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].name===e)return this.materials[t];return null},i.prototype.getLensFlareSystemByName=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===e)return this.lensFlareSystems[t];return null},i.prototype.getLensFlareSystemByID=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].id===e)return this.lensFlareSystems[t];return null},i.prototype.getCameraByID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null},i.prototype.getCameraByUniqueID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null},i.prototype.getCameraByName=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null},i.prototype.getBoneByID=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].id===e)return i.bones[r];return null},i.prototype.getBoneByName=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].name===e)return i.bones[r];return null},i.prototype.getLightByName=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null},i.prototype.getLightByID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getLightByUniqueID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null},i.prototype.getParticleSystemByID=function(e){for(var t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null},i.prototype.getGeometryByID=function(e){for(var t=0;t<this._geometries.length;t++)if(this._geometries[t].id===e)return this._geometries[t];return null},i.prototype.pushGeometry=function(e,t){return!(!t&&this.getGeometryByID(e.id)||(this._geometries.push(e),this.collisionCoordinator.onGeometryAdded(e),this.onNewGeometryAddedObservable.notifyObservers(e),0))},i.prototype.removeGeometry=function(e){var t=this._geometries.indexOf(e);return t>-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getMeshesByID=function(e){return this.meshes.filter(function(t){return t.id===e})},i.prototype.getMeshByUniqueID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null},i.prototype.getLastMeshByID=function(e){for(var t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);if(i)return i;var r=this.getCameraByID(e);return r||this.getBoneByID(e)},i.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);if(i)return i;var r=this.getCameraByName(e);return r||this.getBoneByName(e)},i.prototype.getMeshByName=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null},i.prototype.getSoundByName=function(t){var i;if(e.AudioEngine){for(i=0;i<this.mainSoundTrack.soundCollection.length;i++)if(this.mainSoundTrack.soundCollection[i].name===t)return this.mainSoundTrack.soundCollection[i];for(var r=0;r<this.soundTracks.length;r++)for(i=0;i<this.soundTracks[r].soundCollection.length;i++)if(this.soundTracks[r].soundCollection[i].name===t)return this.soundTracks[r].soundCollection[i]}return null},i.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonByName=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},Object.defineProperty(i.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),i.prototype.addExternalData=function(e,t){return this._externalData.add(e,t)},i.prototype.getExternalData=function(e){return this._externalData.get(e)},i.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData.getOrAddWithFactory(e,t)},i.prototype.removeExternalData=function(e){return this._externalData.remove(e)},i.prototype._evaluateSubMesh=function(e,t){if(t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){var i=e.getMaterial();t.showSubMeshesBoundingBox&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),i&&(i.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(i)&&(this._processedMaterials.push(i),this._renderTargets.concatWithNoDuplicate(i.getRenderTargetTextures())),this._activeIndices.addCount(e.indexCount,!1),this._renderingManager.dispatch(e))}},i.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},i.prototype._evaluateActiveMeshes=function(){var t,i;if(this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._boundingBoxRenderer.reset(),this._edgesRenderers.reset(),this._selectionOctree){var r=this._selectionOctree.select(this._frustumPlanes);t=r.data,i=r.length}else i=this.meshes.length,t=this.meshes;for(var n=0;n<i;n++){var o=t[n];if(!o.isBlocked&&(this._totalVertices.addCount(o.getTotalVertices(),!1),o.isReady()&&o.isEnabled())){o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers([e.ActionManager.OnIntersectionEnterTrigger,e.ActionManager.OnIntersectionExitTrigger])&&this._meshesForIntersections.pushNoDuplicate(o);var s=o.getLOD(this.activeCamera);s&&(o._preActivate(),(o.alwaysSelectAsActiveMesh||o.isVisible&&o.visibility>0&&0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),this._activeMesh(o,s)))}}if(this._particlesDuration.beginMonitoring(),e.Tools.Now,this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a<this.particleSystems.length;a++){var c=this.particleSystems[a];c.isStarted()&&(!c.emitter.position||c.emitter&&c.emitter.isEnabled())&&(this._activeParticleSystems.push(c),c.animate())}e.Tools.EndPerformanceCounter("Particles",this.particleSystems.length>0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else i=(r=t.subMeshes).length;for(var o=0;o<i;o++){var s=r[o];this._evaluateSubMesh(s,t)}}},i.prototype.updateTransformMatrix=function(e){this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},i.prototype._renderForCamera=function(t){var i=this._engine;if(e.Tools.Now,this.activeCamera=t,!this.activeCamera)throw new Error("Active camera not set");e.Tools.StartPerformanceCounter("Rendering camera "+this.activeCamera.name),i.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshesDuration.beginMonitoring(),e.Tools.StartPerformanceCounter("Active meshes evaluation"),this._evaluateActiveMeshes(),this._evaluateActiveMeshesDuration.endMonitoring(!1),e.Tools.EndPerformanceCounter("Active meshes evaluation");for(var r=0;r<this._softwareSkinnedMeshes.length;r++){var n=this._softwareSkinnedMeshes.data[r];n.applySkeleton(n.skeleton)}this._renderTargetsDuration.beginMonitoring();var o=!1;if(e.Tools.Now,this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s<this._renderTargets.length;s++){if((d=this._renderTargets.data[s])._shouldRender()){this._renderId++;var a=d.activeCamera&&d.activeCamera!==this.activeCamera;d.render(a,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._intermediateRendering=!1,this._renderId++,o=!0}var c,h,u=this._engine.getStencilBuffer(),l=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var f=0;f<this.highlightLayers.length;f++){var d,p=this.highlightLayers[f];if(p.shouldRender()&&(!p.camera||p.camera.cameraRigMode===e.Camera.RIG_MODE_NONE&&t===p.camera||p.camera.cameraRigMode!==e.Camera.RIG_MODE_NONE&&p.camera._rigCameras.indexOf(t)>-1))l=!0,(d=p._mainTexture)._shouldRender()&&(this._renderId++,d.render(!1,!1),o=!0)}this._intermediateRendering=!1,this._renderId++}if(o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring(),this.layers.length){for(i.setDepthBuffer(!1),c=0;c<this.layers.length;c++)(h=this.layers[c]).isBackground&&h.render();i.setDepthBuffer(!0)}e.Tools.StartPerformanceCounter("Main render"),l&&this._engine.setStencilBuffer(!0),this._renderingManager.render(null,null,!0,!0),l&&this._engine.setStencilBuffer(u),e.Tools.EndPerformanceCounter("Main render"),this._boundingBoxRenderer.render();for(var m=0;m<this._edgesRenderers.length;m++)this._edgesRenderers.data[m].render();if(this.lensFlaresEnabled){e.Tools.StartPerformanceCounter("Lens flares",this.lensFlareSystems.length>0);for(var g=0;g<this.lensFlareSystems.length;g++){var _=this.lensFlareSystems[g];0!=(t.layerMask&_.layerMask)&&_.render()}e.Tools.EndPerformanceCounter("Lens flares",this.lensFlareSystems.length>0)}if(this.layers.length){for(i.setDepthBuffer(!1),c=0;c<this.layers.length;c++)(h=this.layers[c]).isBackground||h.render();i.setDepthBuffer(!0)}if(l){i.setDepthBuffer(!1);for(f=0;f<this.highlightLayers.length;f++)this.highlightLayers[f].shouldRender()&&this.highlightLayers[f].render();i.setDepthBuffer(!0)}this._renderDuration.endMonitoring(!1),this.postProcessManager._finalizeFrame(t.isIntermediate),this.activeCamera._updateFromScene(),this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera),e.Tools.EndPerformanceCounter("Rendering camera "+this.activeCamera.name)},i.prototype._processSubCameras=function(t){if(t.cameraRigMode!==e.Camera.RIG_MODE_NONE){for(var i=0;i<t._rigCameras.length;i++)this._renderForCamera(t._rigCameras[i]);this.activeCamera=t,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this.activeCamera._updateFromScene()}else this._renderForCamera(t)},i.prototype._checkIntersections=function(){for(var t=0;t<this._meshesForIntersections.length;t++)for(var i=this._meshesForIntersections.data[t],r=0;r<i.actionManager.actions.length;r++){var n=i.actionManager.actions[r];if(n.trigger===e.ActionManager.OnIntersectionEnterTrigger||n.trigger===e.ActionManager.OnIntersectionExitTrigger){var o=n.getTriggerParameter(),s=o instanceof e.AbstractMesh?o:o.mesh,a=s.intersectsMesh(i,o.usePreciseIntersection),c=i._intersectionsInProgress.indexOf(s);a&&-1===c?n.trigger===e.ActionManager.OnIntersectionEnterTrigger?(n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i._intersectionsInProgress.push(s)):n.trigger===e.ActionManager.OnIntersectionExitTrigger&&i._intersectionsInProgress.push(s):!a&&c>-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(c,1))}}},i.prototype.render=function(){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),e.Tools.StartPerformanceCounter("Scene rendering"),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger,null),this.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext();var t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o<this.customRenderTargets.length;o++){var s=this.customRenderTargets[o];if(s._shouldRender()){if(this._renderId++,this.activeCamera=s.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");r.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),s.render(n!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a<this._proceduralTextures.length;a++){var c=this._proceduralTextures[a];c._shouldRender()&&c.render()}e.Tools.EndPerformanceCounter("Procedural textures",this._proceduralTextures.length>0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var h=0;h<this.lights.length;h++){var u=this.lights[h],l=u.getShadowGenerator();u.isEnabled()&&l&&-1!==l.getShadowMap().getScene().textures.indexOf(l.getShadowMap())&&this._renderTargets.push(l.getShadowMap())}if(this._depthRenderer&&this._renderTargets.push(this._depthRenderer.getDepthMap()),this.postProcessRenderPipelineManager.update(),this.activeCameras.length>0)for(var f=0;f<this.activeCameras.length;f++)f>0&&this._engine.clear(0,!1,!0,!0),this._processSubCameras(this.activeCameras[f]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var d=0;d<this._toBeDisposed.length;d++)this._toBeDisposed.data[d].dispose(),this._toBeDisposed[d]=null;this._toBeDisposed.reset(),this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),e.Tools.EndPerformanceCounter("Scene rendering"),this._lastFrameDuration.endMonitoring(),this._totalMeshesCounter.addCount(this.meshes.length,!0),this._totalLightsCounter.addCount(this.lights.length,!0),this._totalMaterialsCounter.addCount(this.materials.length,!0),this._totalTexturesCounter.addCount(this.textures.length,!0),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)},i.prototype._updateAudioParameters=function(){if(this.audioEnabled&&(0!==this.mainSoundTrack.soundCollection.length||1!==this.soundTracks.length)){var t,i=e.Engine.audioEngine;if((t=this.activeCameras.length>0?this.activeCameras[0]:this.activeCamera)&&i.canUseWebAudio){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z);var r,n=e.Matrix.Invert(t.getViewMatrix()),o=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),n);for(o.normalize(),i.audioContext.listener.setOrientation(o.x,o.y,o.z,0,1,0),r=0;r<this.mainSoundTrack.soundCollection.length;r++){var s=this.mainSoundTrack.soundCollection[r];s.useCustomAttenuation&&s.updateDistanceFromListener()}for(r=0;r<this.soundTracks.length;r++)for(var a=0;a<this.soundTracks[r].soundCollection.length;a++)(s=this.soundTracks[r].soundCollection[a]).useCustomAttenuation&&s.updateDistanceFromListener()}}},Object.defineProperty(i.prototype,"audioEnabled",{get:function(){return this._audioEnabled},set:function(t){this._audioEnabled=t,e.AudioEngine&&(this._audioEnabled?this._enableAudio():this._disableAudio())},enumerable:!0,configurable:!0}),i.prototype._disableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].pause();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].pause()},i.prototype._enableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].isPaused&&this.mainSoundTrack.soundCollection[e].play();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].isPaused&&this.soundTracks[e].soundCollection[t].play()},Object.defineProperty(i.prototype,"headphone",{get:function(){return this._headphone},set:function(t){this._headphone=t,e.AudioEngine&&(this._headphone?this._switchAudioModeForHeadphones():this._switchAudioModeForNormalSpeakers())},enumerable:!0,configurable:!0}),i.prototype._switchAudioModeForHeadphones=function(){this.mainSoundTrack.switchPanningModelToHRTF();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToHRTF()},i.prototype._switchAudioModeForNormalSpeakers=function(){this.mainSoundTrack.switchPanningModelToEqualPower();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToEqualPower()},i.prototype.enableDepthRenderer=function(){return this._depthRenderer?this._depthRenderer:(this._depthRenderer=new e.DepthRenderer(this),this._depthRenderer)},i.prototype.disableDepthRenderer=function(){this._depthRenderer&&(this._depthRenderer.dispose(),this._depthRenderer=null)},i.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},i.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},i.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this._boundingBoxRenderer.dispose(),this._depthRenderer&&this._depthRenderer.dispose(),this._debugLayer&&this._debugLayer.hide(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.detachControl(),e.AudioEngine&&this.disposeSounds();var t,i=this._engine.getRenderingCanvas();for(t=0;t<this.cameras.length;t++)this.cameras[t].detachControl(i);for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.spriteManagers.length;)this.spriteManagers[0].dispose();for(;this.layers.length;)this.layers[0].dispose();for(;this.highlightLayers.length;)this.highlightLayers[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this.postProcessManager.dispose(),this._physicsEngine&&this.disablePhysicsEngine(),(t=this._engine.scenes.indexOf(this))>-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].dispose()},i.prototype.getWorldExtends=function(){for(var t=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r=0;r<this.meshes.length;r++){var n=this.meshes[r];n.computeWorldMatrix(!0);var o=n.getBoundingInfo().boundingBox.minimumWorld,s=n.getBoundingInfo().boundingBox.maximumWorld;e.Tools.CheckExtends(o,t,i),e.Tools.CheckExtends(s,t,i)}return{min:t,max:i}},i.prototype.createOrUpdateSelectionOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._selectionOctree||(this._selectionOctree=new e.Octree(e.Octree.CreationFuncForMeshes,t,i));var r=this.getWorldExtends();return this._selectionOctree.update(r.min,r.max,this.meshes),this._selectionOctree},i.prototype.createPickingRay=function(t,i,r,n,o){void 0===o&&(o=!1);var s=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var a=n.viewport.toGlobal(s.getRenderWidth(),s.getRenderHeight());return t=t/this._engine.getHardwareScalingLevel()-a.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-a.y-a.height),e.Ray.CreateNew(t,i,a.width,a.height,r||e.Matrix.Identity(),o?e.Matrix.Identity():n.getViewMatrix(),n.getProjectionMatrix())},i.prototype.createPickingRayInCameraSpace=function(t,i,r){var n=this._engine;if(!r){if(!this.activeCamera)throw new Error("Active camera not set");r=this.activeCamera}var o=r.viewport.toGlobal(n.getRenderWidth(),n.getRenderHeight()),s=e.Matrix.Identity();return t=t/this._engine.getHardwareScalingLevel()-o.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-o.y-o.height),e.Ray.CreateNew(t,i,o.width,o.height,s,s,r.getProjectionMatrix())},i.prototype._internalPick=function(t,i,r){for(var n=null,o=0;o<this.meshes.length;o++){var s=this.meshes[o];if(i){if(!i(s))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var a=t(s.getWorldMatrix()),c=s.intersects(a,r);if(c&&c.hit&&(r||null==n||!(c.distance>=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(e,t){for(var i=new Array,r=0;r<this.meshes.length;r++){var n=this.meshes[r];if(t){if(!t(n))continue}else if(!n.isEnabled()||!n.isVisible||!n.isPickable)continue;var o=e(n.getWorldMatrix()),s=n.intersects(o,!1);s&&s.hit&&i.push(s)}return i},i.prototype._internalPickSprites=function(t,i,r,n){var o=null;if(n=n||this.activeCamera,this.spriteManagers.length>0)for(var s=0;s<this.spriteManagers.length;s++){var a=this.spriteManagers[s];if(a.isPickable){var c=a.intersects(t,n,i,r);if(c&&c.hit&&(r||null==o||!(c.distance>=o.distance))&&(o=c,r))break}}return o||new e.PickingInfo},i.prototype.pick=function(e,t,i,r,n){var o=this;return this._internalPick(function(i){return o.createPickingRay(e,t,i,n)},i,r)},i.prototype.pickSprite=function(e,t,i,r,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),i,r,n)},i.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick(function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)},i,r)},i.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick(function(i){return n.createPickingRay(e,t,i,r)},i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick(function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)},i)},i.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},i.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},i.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},i.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},i.prototype.getPhysicsEngine=function(){return this._physicsEngine},i.prototype.enablePhysics=function(t,i){if(this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,i),!0}catch(t){return e.Tools.Error(t.message),!1}},i.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=void 0)},i.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},i.prototype.setGravity=function(t){e.Tools.Warn("Deprecated, please use 'scene.getPhysicsEngine().setGravity()'"),this._physicsEngine&&this._physicsEngine.setGravity(t)},i.prototype.createCompoundImpostor=function(t,i){e.Tools.Warn("Scene.createCompoundImpostor is deprecated. Please use PhysicsImpostor parent/child"),t.parts&&(i=t,t=t.parts);var r=t[0].mesh;r.physicsImpostor=new e.PhysicsImpostor(r,t[0].impostor,i,this);for(var n=1;n<t.length;n++){var o=t[n].mesh;o.parent!==r&&(o.position=o.position.subtract(r.position),o.parent=r),o.physicsImpostor=new e.PhysicsImpostor(o,t[n].impostor,i,this)}r.physicsImpostor.forceUpdate()},i.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor.dispose(),t.physicsImpostor=null},i.prototype.createDefaultCameraOrLight=function(){if(0===this.lights.length&&new e.HemisphericLight("default light",e.Vector3.Up(),this),!this.activeCamera){var t=new e.FreeCamera("default camera",e.Vector3.Zero(),this),i=this.getWorldExtends(),r=i.min.add(i.max.subtract(i.min).scale(.5));t.position=new e.Vector3(r.x,r.y,i.min.z-(i.max.z-i.min.z)),t.setTarget(r),this.activeCamera=t}},i.prototype._getByTags=function(t,i,r){if(void 0===i)return t;var n=[];for(var o in r=r||function(e){},t){var s=t[o];e.Tags.MatchesQuery(s,i)&&(n.push(s),r(s))}return n},i.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},i.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},i.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},i.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i._FOGMODE_NONE=0,i._FOGMODE_EXP=1,i._FOGMODE_EXP2=2,i._FOGMODE_LINEAR=3,i.MinDeltaTime=1,i.MaxDeltaTime=1e3,i}();e.Scene=s}(s||(s={})),function(e){var t=function(){function t(t,i,r,n,o,s){t instanceof e.Mesh?this._engine=t.getScene().getEngine():this._engine=t,this._updatable=r,this._data=i,this._strideSize=n,o||this.create(),this._instanced=s}return t.prototype.createVertexBuffer=function(t,i,r,n){return new e.VertexBuffer(this._engine,this,t,this._updatable,!0,n||this._strideSize,this._instanced,i,r)},t.prototype.isUpdatable=function(){return this._updatable},t.prototype.getData=function(){return this._data},t.prototype.getBuffer=function(){return this._buffer},t.prototype.getStrideSize=function(){return this._strideSize},t.prototype.getIsInstanced=function(){return this._instanced},t.prototype.create=function(e){!e&&this._buffer||(e=e||this._data,this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e),this._data=e):this._buffer=this._engine.createVertexBuffer(e))},t.prototype.update=function(e){this.create(e)},t.prototype.updateDirectly=function(e,t,i){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,t,i?i*this.getStrideSize():void 0),this._data=null)},t.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},t}();e.Buffer=t}(s||(s={})),function(e){var t=function(){function t(i,r,n,o,s,a,c,h,u){if(!a)switch(n){case t.PositionKind:case t.NormalKind:a=3;break;case t.UVKind:case t.UV2Kind:case t.UV3Kind:case t.UV4Kind:case t.UV5Kind:case t.UV6Kind:a=2;break;case t.ColorKind:a=4;break;case t.MatricesIndicesKind:case t.MatricesIndicesExtraKind:a=4;break;case t.MatricesWeightsKind:case t.MatricesWeightsExtraKind:a=4}r instanceof e.Buffer?(a||(a=r.getStrideSize()),this._buffer=r,this._ownsBuffer=!1):(this._buffer=new e.Buffer(i,r,o,a,s,c),this._ownsBuffer=!0),this._stride=a,this._offset=h||0,this._size=u||a,this._kind=n}return t.prototype.getKind=function(){return this._kind},t.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},t.prototype.getData=function(){return this._buffer.getData()},t.prototype.getBuffer=function(){return this._buffer.getBuffer()},t.prototype.getStrideSize=function(){return this._stride},t.prototype.getOffset=function(){return this._offset},t.prototype.getSize=function(){return this._size},t.prototype.getIsInstanced=function(){return this._buffer.getIsInstanced()},t.prototype.create=function(e){return this._buffer.create(e)},t.prototype.update=function(e){return this._buffer.update(e)},t.prototype.updateDirectly=function(e,t){return this._buffer.updateDirectly(e,t)},t.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},Object.defineProperty(t,"PositionKind",{get:function(){return t._PositionKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"NormalKind",{get:function(){return t._NormalKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UVKind",{get:function(){return t._UVKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV2Kind",{get:function(){return t._UV2Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV3Kind",{get:function(){return t._UV3Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV4Kind",{get:function(){return t._UV4Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV5Kind",{get:function(){return t._UV5Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV6Kind",{get:function(){return t._UV6Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorKind",{get:function(){return t._ColorKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesKind",{get:function(){return t._MatricesIndicesKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsKind",{get:function(){return t._MatricesWeightsKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesExtraKind",{get:function(){return t._MatricesIndicesExtraKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsExtraKind",{get:function(){return t._MatricesWeightsExtraKind},enumerable:!0,configurable:!0}),t._PositionKind="position",t._NormalKind="normal",t._UVKind="uv",t._UV2Kind="uv2",t._UV3Kind="uv3",t._UV4Kind="uv4",t._UV5Kind="uv5",t._UV6Kind="uv6",t._ColorKind="color",t._MatricesIndicesKind="matricesIndices",t._MatricesWeightsKind="matricesWeights",t._MatricesIndicesExtraKind="matricesIndicesExtra",t._MatricesWeightsExtraKind="matricesWeightsExtra",t}();e.VertexBuffer=t}(s||(s={})),function(e){var t=function(t){function i(e,i){t.call(this,e,i.getScene()),i.instances.push(this),this._sourceMesh=i,this.position.copyFrom(i.position),this.rotation.copyFrom(i.rotation),this.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(this.rotationQuaternion=i.rotationQuaternion.clone()),this.infiniteDistance=i.infiniteDistance,this.setPivotMatrix(i.getPivotMatrix()),this.refreshBoundingInfo(),this._syncSubMeshes()}return c(i,t),Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},enumerable:!0,configurable:!0}),i.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},Object.defineProperty(i.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),i.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},i.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},i.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),i.prototype.refreshBoundingInfo=function(){var t=this._sourceMesh.getBoundingInfo();this._boundingInfo=new e.BoundingInfo(t.minimum.clone(),t.maximum.clone()),this._updateBoundingInfo()},i.prototype._preActivate=function(){this._currentLOD&&this._currentLOD._preActivate()},i.prototype._activate=function(e){this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e)},i.prototype.getLOD=function(e){return this._currentLOD=this.sourceMesh.getLOD(this.getScene().activeCamera,this.getBoundingInfo().boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},i.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh)},i.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},i.prototype.clone=function(t,i,r){var n=this._sourceMesh.createInstance(t);if(e.Tools.DeepCopy(this,n,["name","subMeshes"],[]),this.refreshBoundingInfo(),i&&(n.parent=i),!r)for(var o=0;o<this.getScene().meshes.length;o++){var s=this.getScene().meshes[o];s.parent===this&&s.clone(s.name,n)}return n.computeWorldMatrix(!0),n},i.prototype.dispose=function(e){var i=this._sourceMesh.instances.indexOf(this);this._sourceMesh.instances.splice(i,1),t.prototype.dispose.call(this,e)},i}(e.AbstractMesh);e.InstancedMesh=t}(s||(s={})),function(e){var t=function(){return function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array}}();e._InstancesBatch=t;var i=function(i){function r(n,o,s,a,c,h){if(void 0===s&&(s=null),void 0===h&&(h=!0),i.call(this,n,o),this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.onBeforeDrawObservable=new e.Observable,this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.instances=new Array,this._LODLevels=new Array,this._visibleInstances={},this._renderIdForInstances=new Array,this._batchCache=new t,this._instancesBufferSize=2048,this._sideOrientation=r._DEFAULTSIDE,this._areNormalsFrozen=!1,a){var u;if(a._geometry&&a._geometry.applyToMesh(this),e.Tools.DeepCopy(a,this,["name","material","skeleton","instances","parent"],["_poseMatrix"]),this.parent=a.parent,this.setPivotMatrix(a.getPivotMatrix()),this.id=n+"."+a.id,this.material=a.material,!c)for(u=0;u<o.meshes.length;u++){var l=o.meshes[u];l.parent===a&&l.clone(n+"."+l.name,this,c)}var f=this.getScene().getPhysicsEngine();if(h&&f){var d=f.getImpostorForPhysicsObject(a);d&&(this.physicsImpostor=d.clone(this))}for(u=0;u<o.particleSystems.length;u++){var p=o.particleSystems[u];p.emitter===a&&p.clone(p.name,this)}this.computeWorldMatrix(!0)}null!==s&&(this.parent=s)}return c(r,i),Object.defineProperty(r,"FRONTSIDE",{get:function(){return r._FRONTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BACKSIDE",{get:function(){return r._BACKSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DOUBLESIDE",{get:function(){return r._DOUBLESIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DEFAULTSIDE",{get:function(){return r._DEFAULTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"NO_CAP",{get:function(){return r._NO_CAP},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_START",{get:function(){return r._CAP_START},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_END",{get:function(){return r._CAP_END},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_ALL",{get:function(){return r._CAP_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!0,configurable:!0}),r.prototype.toString=function(t){var r=i.prototype.toString.call(this,t);if(r+=", n vertices: "+this.getTotalVertices(),r+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var n=0;n<this.animations.length;n++)r+=", animation[0]: "+this.animations[n].toString(t);return t&&(r+=", flat shading: "+(this._geometry?this.getVerticesData(e.VertexBuffer.PositionKind).length/3===this.getIndices().length?"YES":"NO":"UNKNOWN")),r},Object.defineProperty(r.prototype,"hasLODLevels",{get:function(){return this._LODLevels.length>0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort(function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0})},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;t<this._LODLevels.length;t++){var i=this._LODLevels[t];if(i.distance===e)return i.mesh}return null},r.prototype.removeLODLevel=function(e){for(var t=0;t<this._LODLevels.length;t++)this._LODLevels[t].mesh===e&&(this._LODLevels.splice(t,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},r.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var i=(t||this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.globalPosition).length();if(this._LODLevels[this._LODLevels.length-1].distance>i)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r<this._LODLevels.length;r++){var n=this._LODLevels[r];if(n.distance<i)return n.mesh&&(n.mesh._preActivate(),n.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(i,this,n.mesh),n.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this),this},Object.defineProperty(r.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),r.prototype.getTotalVertices=function(){return this._geometry?this._geometry.getTotalVertices():0},r.prototype.getVerticesData=function(e,t){return this._geometry?this._geometry.getVerticesData(e,t):null},r.prototype.getVertexBuffer=function(e){if(this._geometry)return this._geometry.getVertexBuffer(e)},r.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},r.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=[];return this._delayInfo&&this._delayInfo.forEach(function(t,i,r){e.push(t)}),e}return this._geometry.getVerticesDataKinds()},r.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},r.prototype.getIndices=function(e){return this._geometry?this._geometry.getIndices(e):[]},Object.defineProperty(r.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),r.prototype.isReady=function(){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&i.prototype.isReady.call(this)},r.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(r.prototype,"sideOrientation",{get:function(){return this._sideOrientation},set:function(e){this._sideOrientation=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),r.prototype.freezeNormals=function(){this._areNormalsFrozen=!0},r.prototype.unfreezeNormals=function(){this._areNormalsFrozen=!1},Object.defineProperty(r.prototype,"overridenInstanceCount",{set:function(e){this._overridenInstanceCount=e},enumerable:!0,configurable:!0}),r.prototype._preActivate=function(){var e=this.getScene().getRenderId();this._preActivateId!==e&&(this._preActivateId=e,this._visibleInstances=null)},r.prototype._preActivateForIntermediateRendering=function(e){this._visibleInstances&&(this._visibleInstances.intermediateDefaultRenderId=e)},r.prototype._registerInstanceForRenderId=function(e,t){this._visibleInstances||(this._visibleInstances={},this._visibleInstances.defaultRenderId=t,this._visibleInstances.selfDefaultRenderId=this._renderId),this._visibleInstances[t]||(this._visibleInstances[t]=new Array),this._visibleInstances[t].push(e)},r.prototype.refreshBoundingInfo=function(){if(!this._boundingInfo.isLocked){var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(t){var i=e.Tools.ExtractMinAndMax(t,0,this.getTotalVertices());this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}if(this.subMeshes)for(var r=0;r<this.subMeshes.length;r++)this.subMeshes[r].refreshBoundingInfo();this._updateBoundingInfo()}},r.prototype._createGlobalSubMesh=function(){var t=this.getTotalVertices();return t&&this.getIndices()?(this.releaseSubMeshes(),new e.SubMesh(0,0,t,0,this.getTotalIndices(),this)):null},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;o<t&&!(n>=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}},r.prototype.setVerticesBuffer=function(t){if(!this._geometry){var i=this.getScene();new e.Geometry(e.Geometry.RandomId(),i).applyToMesh(this)}this._geometry.setVerticesBuffer(t)},r.prototype.updateVerticesData=function(e,t,i,r){this._geometry&&(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i))},r.prototype.updateVerticesDataDirectly=function(t,i,r,n){e.Tools.Warn("Mesh.updateVerticesDataDirectly deprecated since 2.3."),this._geometry&&(n?(this.makeGeometryUnique(),this.updateVerticesDataDirectly(t,i,r,!1)):this._geometry.updateVerticesDataDirectly(t,i,r))},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}},r.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());t.releaseForMesh(this,!0),i.applyToMesh(this)}},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}},r.prototype.toLeftHanded=function(){this._geometry&&this._geometry.toLeftHanded()},r.prototype._bind=function(t,i,r){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}o.bindBuffers(this._geometry.getVertexBuffers(),n,i)},r.prototype._draw=function(t,i,r){if(this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()){this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):n.draw(!1,0,r>0?t.linesIndexCount/2:t.linesIndexCount,r);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):n.draw(!0,t.indexStart,t.indexCount,r)}}},r.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},r.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},r.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},r.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){for(var s=r.visibleInstances[t._id],a=16*(s.length+1)*4,c=this._instancesBufferSize,h=this._instancesBuffer;this._instancesBufferSize<a;)this._instancesBufferSize*=2;this._instancesData&&c==this._instancesBufferSize||(this._instancesData=new Float32Array(this._instancesBufferSize/4));var u=0,l=0,f=this.getWorldMatrix();if(r.renderSelf[t._id]&&(f.copyToArray(this._instancesData,u),u+=16,l++),s)for(var d=0;d<s.length;d++){s[d].getWorldMatrix().copyToArray(this._instancesData,u),u+=16,l++}h&&c==this._instancesBufferSize?h.updateDirectly(this._instancesData,0,l):(h&&h.dispose(),h=new e.Buffer(o,this._instancesData,!0,16,!1,!0),this._instancesBuffer=h,this.setVerticesBuffer(h.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(h.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(h.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(h.createVertexBuffer("world3",12,4))),o.bindBuffers(this.geometry.getVertexBuffers(),this.geometry.getIndexBuffer(),n),this._draw(t,i,l),o.unbindInstanceAttributes()},r.prototype._processRendering=function(e,t,i,r,n,o,s){var a=this.getScene().getEngine();if(n)this._renderWithInstances(e,i,r,t,a);else if(r.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix(),s),this._draw(e,i,this._overridenInstanceCount)),r.visibleInstances[e._id])for(var c=0;c<r.visibleInstances[e._id].length;c++){var h=r.visibleInstances[e._id][c].getWorldMatrix();o&&o(!0,h,s),this._draw(e,i)}},r.prototype.render=function(t,i){var r=this.getScene(),n=this._getInstancesRenderList(t._id);if(!n.mustReturn&&this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()){this.onBeforeRenderObservable.notifyObservers(this);var o=r.getEngine(),s=null!==o.getCaps().instancedArrays&&null!==n.visibleInstances[t._id]&&void 0!==n.visibleInstances[t._id],a=t.getMaterial();if(a&&a.isReady(this,s)){var c=o.getDepthWrite();this.renderOutline&&(o.setDepthWrite(!1),r.getOutlineRenderer().render(t,n),o.setDepthWrite(c)),a._preBind();var h=a.getEffect(),u=r.forcePointsCloud?e.Material.PointFillMode:r.forceWireframe?e.Material.WireFrameFillMode:a.fillMode;this._bind(t,h,u);var l=this.getWorldMatrix();if(a.bind(l,this),i&&o.setAlphaMode(a.alphaMode),this._processRendering(t,h,u,n,s,this._onBeforeDraw,a),a.unbind(),this.renderOutline&&c&&(o.setDepthWrite(!0),o.setColorWrite(!1),r.getOutlineRenderer().render(t,n),o.setColorWrite(!0)),this.renderOverlay){var f=o.getAlphaMode();o.setAlphaMode(e.Engine.ALPHA_COMBINE),r.getOutlineRenderer().render(t,n,!0),o.setAlphaMode(f)}this.onAfterRenderObservable.notifyObservers(this)}}},r.prototype._onBeforeDraw=function(e,t,i){e&&i.bindOnlyWorldMatrix(t)},r.prototype.getEmittedParticleSystems=function(){for(var e=new Array,t=0;t<this.getScene().particleSystems.length;t++){var i=this.getScene().particleSystems[t];i.emitter===this&&e.push(i)}return e},r.prototype.getHierarchyEmittedParticleSystems=function(){var e=new Array,t=this.getDescendants();t.push(this);for(var i=0;i<this.getScene().particleSystems.length;i++){var r=this.getScene().particleSystems[i];-1!==t.indexOf(r.emitter)&&e.push(r)}return e},r.prototype._checkDelayState=function(){var t=this.getScene();this._geometry?this._geometry.load(t):this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(this,t))},r.prototype._queueLoad=function(t,i){var r=this;i._addPendingData(t);var n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");e.Tools.LoadFile(this.delayLoadingFile,function(t){t instanceof ArrayBuffer?r._delayLoadingFunction(t,r):r._delayLoadingFunction(JSON.parse(t),r),r.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,i._removePendingData(r)},function(){},i.database,n)},r.prototype.isInFrustum=function(t){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&!!i.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0)},r.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=0;t<i.length;t++)if(i[t].id===e)return void(this.material=i[t]);var r=this.getScene().multiMaterials;for(t=0;t<r.length;t++)if(r[t].id===e)return void(this.material=r[t])},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(this.isVerticesDataPresent(e.VertexBuffer.PositionKind)){var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(r=0;r<n.length;r+=3)e.Vector3.TransformCoordinates(e.Vector3.FromArray(n,r),t).toArray(o,r);if(this.setVerticesData(e.VertexBuffer.PositionKind,o,this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()),this.isVerticesDataPresent(e.VertexBuffer.NormalKind)){for(n=this.getVerticesData(e.VertexBuffer.NormalKind),o=[],r=0;r<n.length;r+=3)e.Vector3.TransformNormal(e.Vector3.FromArray(n,r),t).normalize().toArray(o,r);this.setVerticesData(e.VertexBuffer.NormalKind,o,this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()),t.m[0]*t.m[5]*t.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=i}}},r.prototype.bakeCurrentTransformIntoVertices=function(){this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=e.Quaternion.Identity()),this._worldMatrix=e.Matrix.Identity()},r.prototype._resetPointsArrayCache=function(){this._positions=null},r.prototype._generatePointsArray=function(){if(this._positions)return!0;this._positions=[];var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return!1;for(var i=0;i<t.length;i+=3)this._positions.push(e.Vector3.FromArray(t,i));return!0},r.prototype.clone=function(e,t,i,n){return void 0===n&&(n=!0),new r(e,this.getScene(),t,this,i,n)},r.prototype.dispose=function(e){for(this._geometry&&this._geometry.releaseForMesh(this,!0),this._instancesBuffer&&(this._instancesBuffer.dispose(),this._instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(var t=this.getScene().highlightLayers,r=0;r<t.length;r++){var n=t[r];n&&(n.removeMesh(this),n.removeExcludedMesh(this))}i.prototype.dispose.call(this,e)},r.prototype.applyDisplacementMap=function(t,i,r,n){var o=this,s=this.getScene();e.Tools.LoadImage(t,function(e){var t=document.createElement("canvas"),s=t.getContext("2d"),a=e.width,c=e.height;t.width=a,t.height=c,s.drawImage(e,0,0);var h=s.getImageData(0,0,a,c).data;o.applyDisplacementMapFromBuffer(h,a,c,i,r),n&&n(o)},function(){},s.database)},r.prototype.applyDisplacementMapFromBuffer=function(t,i,r,n,o){if(this.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&this.isVerticesDataPresent(e.VertexBuffer.UVKind)){for(var s=this.getVerticesData(e.VertexBuffer.PositionKind),a=this.getVerticesData(e.VertexBuffer.NormalKind),c=this.getVerticesData(e.VertexBuffer.UVKind),h=e.Vector3.Zero(),u=e.Vector3.Zero(),l=e.Vector2.Zero(),f=0;f<s.length;f+=3){e.Vector3.FromArrayToRef(s,f,h),e.Vector3.FromArrayToRef(a,f,u),e.Vector2.FromArrayToRef(c,f/3*2,l);var d=4*((Math.abs(l.x)*i%i|0)+(Math.abs(l.y)*r%r|0)*i),p=.3*(t[d]/255)+.59*(t[d+1]/255)+.11*(t[d+2]/255);u.normalize(),u.scaleInPlace(n+(o-n)*p),(h=h.add(u)).toArray(s,f)}e.VertexData.ComputeNormals(s,this.getIndices(),a),this.updateVerticesData(e.VertexBuffer.PositionKind,s),this.updateVerticesData(e.VertexBuffer.NormalKind,a)}else e.Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing")},r.prototype.convertToFlatShadedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n=[],o=[],s=[],a=!1;for(t=0;t<r.length;t++){i=r[t];var c=this.getVertexBuffer(i);i!==e.VertexBuffer.NormalKind?(n[i]=c,o[i]=n[i].getData(),s[i]=[]):(a=c.isUpdatable(),r.splice(t,1),t--)}var h,u=this.subMeshes.slice(0),l=this.getIndices(),f=this.getTotalIndices();for(h=0;h<f;h++){var d=l[h];for(t=0;t<r.length;t++)for(var p=n[i=r[t]].getStrideSize(),m=0;m<p;m++)s[i].push(o[i][d*p+m])}var g=[],_=s[e.VertexBuffer.PositionKind];for(h=0;h<f;h+=3){l[h]=h,l[h+1]=h+1,l[h+2]=h+2;for(var v=e.Vector3.FromArray(_,3*h),y=e.Vector3.FromArray(_,3*(h+1)),b=e.Vector3.FromArray(_,3*(h+2)),x=v.subtract(y),w=b.subtract(y),S=e.Vector3.Normalize(e.Vector3.Cross(x,w)),T=0;T<3;T++)g.push(S.x),g.push(S.y),g.push(S.z)}for(this.setIndices(l),this.setVerticesData(e.VertexBuffer.NormalKind,g,a),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var A=0;A<u.length;A++){var M=u[A];new e.SubMesh(M.materialIndex,M.indexStart,M.indexCount,M.indexStart,M.indexCount,this)}this.synchronizeInstances()},r.prototype.convertToUnIndexedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n=[],o=[],s=[];for(t=0;t<r.length;t++){i=r[t];var a=this.getVertexBuffer(i);n[i]=a,o[i]=n[i].getData(),s[i]=[]}var c,h=this.subMeshes.slice(0),u=this.getIndices(),l=this.getTotalIndices();for(c=0;c<l;c++){var f=u[c];for(t=0;t<r.length;t++)for(var d=n[i=r[t]].getStrideSize(),p=0;p<d;p++)s[i].push(o[i][f*d+p])}for(c=0;c<l;c+=3)u[c]=c,u[c+1]=c+1,u[c+2]=c+2;for(this.setIndices(u),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var m=0;m<h.length;m++){var g=h[m];new e.SubMesh(g.materialIndex,g.indexStart,g.indexCount,g.indexStart,g.indexCount,this)}this._unIndexed=!0,this.synchronizeInstances()},r.prototype.flipFaces=function(t){void 0===t&&(t=!1);var i,r,n=e.VertexData.ExtractFromMesh(this);if(t&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind))for(i=0;i<n.normals.length;i++)n.normals[i]*=-1;for(i=0;i<n.indices.length;i+=3)r=n.indices[i+1],n.indices[i+1]=n.indices[i+2],n.indices[i+2]=r;n.applyToMesh(this)},r.prototype.createInstance=function(t){return new e.InstancedMesh(t,this)},r.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}},r.prototype.simplify=function(t,i,r,n){void 0===i&&(i=!0),void 0===r&&(r=e.SimplificationType.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:t,parallelProcessing:i,mesh:this,simplificationType:r,successCallback:n})},r.prototype.optimizeIndices=function(t){for(var i=this,r=this.getIndices(),n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[],s=0;s<n.length;s+=3)o.push(e.Vector3.FromArray(n,s));var a=[];e.AsyncLoop.SyncAsyncForLoop(o.length,40,function(e){for(var t=o.length-1-e,i=o[t],r=0;r<t;++r){var n=o[r];if(i.equals(n)){a[t]=r;break}}},function(){for(var e=0;e<r.length;++e)r[e]=a[r[e]]||r[e];var n=i.subMeshes.slice(0);i.setIndices(r),i.subMeshes=n,t&&t(i)})},r.Parse=function(t,i,n){var o=new r(t.name,i);if(o.id=t.id,e.Tags.AddTagsTo(o,t.tags),o.position=e.Vector3.FromArray(t.position),void 0!==t.metadata&&(o.metadata=t.metadata),t.rotationQuaternion?o.rotationQuaternion=e.Quaternion.FromArray(t.rotationQuaternion):t.rotation&&(o.rotation=e.Vector3.FromArray(t.rotation)),o.scaling=e.Vector3.FromArray(t.scaling),t.localMatrix?o.setPivotMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&o.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),o.setEnabled(t.isEnabled),o.isVisible=t.isVisible,o.infiniteDistance=t.infiniteDistance,o.showBoundingBox=t.showBoundingBox,o.showSubMeshesBoundingBox=t.showSubMeshesBoundingBox,void 0!==t.applyFog&&(o.applyFog=t.applyFog),void 0!==t.pickable&&(o.isPickable=t.pickable),void 0!==t.alphaIndex&&(o.alphaIndex=t.alphaIndex),o.receiveShadows=t.receiveShadows,o.billboardMode=t.billboardMode,void 0!==t.visibility&&(o.visibility=t.visibility),o.checkCollisions=t.checkCollisions,void 0!==t.isBlocker&&(o.isBlocker=t.isBlocker),o._shouldGenerateFlatShading=t.useFlatShading,t.freezeWorldMatrix&&(o._waitingFreezeWorldMatrix=t.freezeWorldMatrix),t.parentId&&(o._waitingParentId=t.parentId),void 0!==t.actions&&(o._waitingActions=t.actions),void 0!==t.overlayAlpha&&(o.overlayAlpha=t.overlayAlpha),void 0!==t.overlayColor&&(o.overlayColor=e.Color3.FromArray(t.overlayColor)),void 0!==t.renderOverlay&&(o.renderOverlay=t.renderOverlay),o.hasVertexAlpha=t.hasVertexAlpha,t.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+t.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(t.boundingBoxMinimum),e.Vector3.FromArray(t.boundingBoxMaximum)),t._binaryInfo&&(o._binaryInfo=t._binaryInfo),o._delayInfo=[],t.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),t.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),t.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),t.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),t.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),t.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),t.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),t.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),t.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.Geometry.ImportGeometry,e.SceneLoader.ForceFullSceneLoadingForIncremental&&o._checkDelayState()):e.Geometry.ImportGeometry(t,o),t.materialId?o.setMaterialByID(t.materialId):o.material=null,t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}e.Node.ParseAnimationRanges(o,t,i)}if(t.autoAnimate&&i.beginAnimation(o,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),t.layerMask&&!isNaN(t.layerMask)?o.layerMask=Math.abs(parseInt(t.layerMask)):o.layerMask=268435455,t.physicsImpostor&&(o.physicsImpostor=new e.PhysicsImpostor(o,t.physicsImpostor,{mass:t.physicsMass,friction:t.physicsFriction,restitution:t.physicsRestitution},i)),t.instances)for(var c=0;c<t.instances.length;c++){var h=t.instances[c],u=o.createInstance(h.name);if(e.Tags.AddTagsTo(u,h.tags),u.position=e.Vector3.FromArray(h.position),h.parentId&&(u._waitingParentId=h.parentId),h.rotationQuaternion?u.rotationQuaternion=e.Quaternion.FromArray(h.rotationQuaternion):h.rotation&&(u.rotation=e.Vector3.FromArray(h.rotation)),u.scaling=e.Vector3.FromArray(h.scaling),u.checkCollisions=o.checkCollisions,t.animations){for(s=0;s<t.animations.length;s++)a=t.animations[s],u.animations.push(e.Animation.Parse(a));e.Node.ParseAnimationRanges(u,t,i)}}return o},r.CreateRibbon=function(t,i,r,n,o,s,a,c,h){return e.MeshBuilder.CreateRibbon(t,{pathArray:i,closeArray:r,closePath:n,offset:o,updatable:a,sideOrientation:c,instance:h},s)},r.CreateDisc=function(t,i,r,n,o,s){var a={radius:i,tessellation:r,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateDisc(t,a,n)},r.CreateBox=function(t,i,r,n,o){var s={size:i,sideOrientation:o,updatable:n};return e.MeshBuilder.CreateBox(t,s,r)},r.CreateSphere=function(t,i,r,n,o,s){var a={segments:i,diameterX:r,diameterY:r,diameterZ:r,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateSphere(t,a,n)},r.CreateCylinder=function(t,i,n,o,s,a,c,h,u){void 0!==c&&c instanceof e.Scene||(void 0!==c&&(u=h||r.DEFAULTSIDE,h=c),c=a,a=1);var l={height:i,diameterTop:n,diameterBottom:o,tessellation:s,subdivisions:a,sideOrientation:u,updatable:h};return e.MeshBuilder.CreateCylinder(t,l,c)},r.CreateTorus=function(t,i,r,n,o,s,a){var c={diameter:i,thickness:r,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateTorus(t,c,o)},r.CreateTorusKnot=function(t,i,r,n,o,s,a,c,h,u){var l={radius:i,tube:r,radialSegments:n,tubularSegments:o,p:s,q:a,sideOrientation:u,updatable:h};return e.MeshBuilder.CreateTorusKnot(t,l,c)},r.CreateLines=function(t,i,r,n,o){var s={points:i,updatable:n,instance:o};return e.MeshBuilder.CreateLines(t,s,r)},r.CreateDashedLines=function(t,i,r,n,o,s,a,c){var h={points:i,dashSize:r,gapSize:n,dashNb:o,updatable:a,instance:c};return e.MeshBuilder.CreateDashedLines(t,h,s)},r.ExtrudeShape=function(t,i,n,o,s,a,c,h,u,l){var f={shape:i,path:n,scale:o,rotation:s,cap:0===a?0:a||r.NO_CAP,sideOrientation:u,instance:l,updatable:h};return e.MeshBuilder.ExtrudeShape(t,f,c)},r.ExtrudeShapeCustom=function(t,i,n,o,s,a,c,h,u,l,f,d){var p={shape:i,path:n,scaleFunction:o,rotationFunction:s,ribbonCloseArray:a,ribbonClosePath:c,cap:0===h?0:h||r.NO_CAP,sideOrientation:f,instance:d,updatable:l};return e.MeshBuilder.ExtrudeShapeCustom(t,p,u)},r.CreateLathe=function(t,i,r,n,o,s,a){var c={shape:i,radius:r,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateLathe(t,c,o)},r.CreatePlane=function(t,i,r,n,o){var s={size:i,width:i,height:i,sideOrientation:o,updatable:n};return e.MeshBuilder.CreatePlane(t,s,r)},r.CreateGround=function(t,i,r,n,o,s){var a={width:i,height:r,subdivisions:n,updatable:s};return e.MeshBuilder.CreateGround(t,a,o)},r.CreateTiledGround=function(t,i,r,n,o,s,a,c,h){var u={xmin:i,zmin:r,xmax:n,zmax:o,subdivisions:s,precision:a,updatable:h};return e.MeshBuilder.CreateTiledGround(t,u,c)},r.CreateGroundFromHeightMap=function(t,i,r,n,o,s,a,c,h,u){var l={width:r,height:n,subdivisions:o,minHeight:s,maxHeight:a,updatable:h,onReady:u};return e.MeshBuilder.CreateGroundFromHeightMap(t,i,l,c)},r.CreateTube=function(t,i,r,n,o,s,a,c,h,u){var l={path:i,radius:r,tessellation:n,radiusFunction:o,arc:1,cap:s,updatable:c,sideOrientation:h,instance:u};return e.MeshBuilder.CreateTube(t,l,a)},r.CreatePolyhedron=function(t,i,r){return e.MeshBuilder.CreatePolyhedron(t,i,r)},r.CreateIcoSphere=function(t,i,r){return e.MeshBuilder.CreateIcoSphere(t,i,r)},r.CreateDecal=function(t,i,r,n,o,s){var a={position:r,normal:n,size:o,angle:s};return e.MeshBuilder.CreateDecal(t,i,a)},r.prototype.setPositionsForCPUSkinning=function(){var t;return this._sourcePositions||(t=this.getVerticesData(e.VertexBuffer.PositionKind),this._sourcePositions=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.PositionKind,t,!0)),this._sourcePositions},r.prototype.setNormalsForCPUSkinning=function(){var t;return this._sourceNormals||(t=this.getVerticesData(e.VertexBuffer.NormalKind),this._sourceNormals=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.NormalKind,t,!0)),this._sourceNormals},r.prototype.applySkeleton=function(t){if(this.geometry&&this.geometry._softwareSkinningRenderId!=this.getScene().getRenderId()){if(this.geometry._softwareSkinningRenderId=this.getScene().getRenderId(),!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind))return this;if(!this._sourcePositions){var i=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=i}this._sourceNormals||this.setNormalsForCPUSkinning();var r=this.getVerticesData(e.VertexBuffer.PositionKind);r instanceof Float32Array||(r=new Float32Array(r));var n=this.getVerticesData(e.VertexBuffer.NormalKind);n instanceof Float32Array||(n=new Float32Array(n));for(var o,s=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),a=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),c=this.numBoneInfluencers>4,h=c?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,u=c?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,l=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,m=0,g=0;g<r.length;g+=3,m+=4){var _;for(o=0;o<4&&(_=a[m+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(l,16*s[m+o],_,p),d.addToSelf(p);if(c)for(o=0;o<4&&(_=u[m+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(l,16*h[m+o],_,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[g],this._sourcePositions[g+1],this._sourcePositions[g+2],d,f),f.toArray(r,g),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[g],this._sourceNormals[g+1],this._sourceNormals[g+2],d,f),f.toArray(n,g),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this}},r.MinMax=function(e){var t=null,i=null;return e.forEach(function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)}),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o){var s,a,c,h;if(void 0===i&&(i=!0),!n){var u=0;for(s=0;s<t.length;s++)if(t[s]&&(u+=t[s].getTotalVertices())>65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}for(s=0;s<t.length;s++)t[s]&&(t[s].computeWorldMatrix(!0),(c=e.VertexData.ExtractFromMesh(t[s],!0)).transform(t[s].getWorldMatrix()),a?a.merge(c):(a=c,h=t[s]));if(o||(o=new r(h.name+"_merged",h.getScene())),a.applyToMesh(o),o.material=h.material,o.checkCollisions=h.checkCollisions,i)for(s=0;s<t.length;s++)t[s]&&t[s].dispose();return o},r._FRONTSIDE=0,r._BACKSIDE=1,r._DOUBLESIDE=2,r._DEFAULTSIDE=0,r._NO_CAP=0,r._CAP_START=1,r._CAP_END=2,r._CAP_ALL=3,r}(e.AbstractMesh);e.Mesh=i}(s||(s={})),function(e){var t=function(){function t(e,t,i,r,n,o,s,a){void 0===a&&(a=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=n,this._renderId=0,this._mesh=o,this._renderingMesh=s||o,o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,a&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return Object.defineProperty(t.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount==this._mesh.getTotalVertices()},enumerable:!0,configurable:!0}),t.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},t.prototype.getMesh=function(){return this._mesh},t.prototype.getRenderingMesh=function(){return this._renderingMesh},t.prototype.getMaterial=function(){var t=this._renderingMesh.material;return t&&t instanceof e.MultiMaterial?t.getSubMaterial(this.materialIndex):t||this._mesh.getScene().defaultMaterial},t.prototype.refreshBoundingInfo=function(){if(this._lastColliderWorldVertices=null,!this.IsGlobal){var t=this._renderingMesh.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return void(this._boundingInfo=this._mesh._boundingInfo);var i,r=this._renderingMesh.getIndices();i=0===this.indexStart&&this.indexCount===r.length?{minimum:this._renderingMesh.getBoundingInfo().minimum.clone(),maximum:this._renderingMesh.getBoundingInfo().maximum.clone()}:e.Tools.ExtractMinAndMaxIndexed(t,r,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias),this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}},t.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},t.prototype.updateBoundingInfo=function(e){this.getBoundingInfo()||this.refreshBoundingInfo(),this.getBoundingInfo().update(e)},t.prototype.isInFrustum=function(e){return this.getBoundingInfo().isInFrustum(e)},t.prototype.isCompletelyInFrustum=function(e){return this.getBoundingInfo().isCompletelyInFrustum(e)},t.prototype.render=function(e){this._renderingMesh.render(this,e)},t.prototype.getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],r=this.indexStart;r<this.indexStart+this.indexCount;r+=3)i.push(e[r],e[r+1],e[r+1],e[r+2],e[r+2],e[r]);this._linesIndexBuffer=t.createIndexBuffer(i),this.linesIndexCount=i.length}return this._linesIndexBuffer},t.prototype.canIntersects=function(e){return e.intersectsBox(this.getBoundingInfo().boundingBox)},t.prototype.intersects=function(t,i,r,n){var o=null;if(this._mesh instanceof e.LinesMesh)for(var s=this._mesh,a=this.indexStart;a<this.indexStart+this.indexCount;a+=2){var c=i[r[a]],h=i[r[a+1]],u=t.intersectionSegment(c,h,s.intersectionThreshold);if(!(u<0)&&(n||!o||u<o.distance)&&(o=new e.IntersectionInfo(null,null,u),n))break}else for(a=this.indexStart;a<this.indexStart+this.indexCount;a+=3){c=i[r[a]],h=i[r[a+1]];var l=i[r[a+2]],f=t.intersectsTriangle(c,h,l);if(f){if(f.distance<0)continue;if((n||!o||f.distance<o.distance)&&((o=f).faceId=a/3,n))break}}return o},t.prototype.clone=function(i,r){var n=new t(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,i,r,!1);return this.IsGlobal||(n._boundingInfo=new e.BoundingInfo(this.getBoundingInfo().minimum,this.getBoundingInfo().maximum)),n},t.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},t.CreateFromIndices=function(e,i,r,n,o){for(var s=Number.MAX_VALUE,a=-Number.MAX_VALUE,c=(o=o||n).getIndices(),h=i;h<i+r;h++){var u=c[h];u<s&&(s=u),u>a&&(a=u)}return new t(e,s,a-s+1,i,r,n,o)},t}();e.SubMesh=t}(s||(s={})),function(e){var t=function(){function t(){}return t.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:null==t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreateBox(i).applyToMesh(n,i.updatable),n},t.CreateSphere=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreateSphere(i).applyToMesh(n,i.updatable),n},t.CreateDisc=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreateDisc(i).applyToMesh(n,i.updatable),n},t.CreateIcoSphere=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreateIcoSphere(i).applyToMesh(n,i.updatable),n},t.CreateRibbon=function(t,i,r){var n=i.pathArray,o=i.closeArray,s=i.closePath,a=(i.offset,this.updateSideOrientation(i.sideOrientation,r)),c=i.instance,h=i.updatable;if(c){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var u=c.getVerticesData(e.VertexBuffer.PositionKind);if(function(t){for(var i=n[0].length,r=0,o=c.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=o;s++)for(var a=0;a<n.length;a++){var h=n[a],u=h.length;i=i<u?i:u;for(var l=0;l<i;)t[r]=h[l].x,t[r+1]=h[l].y,t[r+2]=h[l].z,h[l].x<e.Tmp.Vector3[0].x&&(e.Tmp.Vector3[0].x=h[l].x),h[l].x>e.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=h[l].x),h[l].y<e.Tmp.Vector3[0].y&&(e.Tmp.Vector3[0].y=h[l].y),h[l].y>e.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=h[l].y),h[l].z<e.Tmp.Vector3[0].z&&(e.Tmp.Vector3[0].z=h[l].z),h[l].z>e.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=h[l].z),l++,r+=3;c._closePath&&(t[r]=h[0].x,t[r+1]=h[0].y,t[r+2]=h[0].z,r+=3)}}(u),c._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),c._boundingInfo.update(c._worldMatrix),c.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),!c.areNormalsFrozen){var l=c.getIndices(),f=c.getVerticesData(e.VertexBuffer.NormalKind);if(e.VertexData.ComputeNormals(u,l,f),c._closePath)for(var d=0,p=0,m=0;m<n.length;m++)d=3*c._idx[m],p=m+1<n.length?3*(c._idx[m+1]-1):f.length-3,f[d]=.5*(f[d]+f[p]),f[d+1]=.5*(f[d+1]+f[p+1]),f[d+2]=.5*(f[d+2]+f[p+2]),f[p]=f[d],f[p+1]=f[d+1],f[p+2]=f[d+2];c.updateVerticesData(e.VertexBuffer.NormalKind,f,!1,!1)}return c}var g=new e.Mesh(t,r);g.sideOrientation=a;var _=e.VertexData.CreateRibbon(i);return s&&(g._idx=_._idx),g._closePath=s,g._closeArray=o,_.applyToMesh(g,h),g},t.CreateCylinder=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreateCylinder(i).applyToMesh(n,i.updatable),n},t.CreateTorus=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreateTorus(i).applyToMesh(n,i.updatable),n},t.CreateTorusKnot=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreateTorusKnot(i).applyToMesh(n,i.updatable),n},t.CreateLineSystem=function(t,i,r){var n=i.instance,o=i.lines;if(n){return n.updateMeshPositions(function(e){for(var t=0,i=0;i<o.length;i++)for(var r=o[i],n=0;n<r.length;n++)e[t]=r[n].x,e[t+1]=r[n].y,e[t+2]=r[n].z,t+=3},!1),n}var s=new e.LinesMesh(t,r);return e.VertexData.CreateLineSystem(i).applyToMesh(s,i.updatable),s},t.CreateLines=function(e,i,r){return t.CreateLineSystem(e,{lines:[i.points],updatable:i.updatable,instance:i.instance},r)},t.CreateDashedLines=function(t,i,r){var n=i.points,o=i.instance,s=i.gapSize,a=(i.dashNb,i.dashSize);if(o){return o.updateMeshPositions(function(t){var i,r=e.Vector3.Zero(),s=t.length/6,a=0,c=0,h=0,u=0,l=0,f=0,d=0;for(f=0;f<n.length-1;f++)n[f+1].subtractToRef(n[f],r),a+=r.length();for(h=a/s,i=o.dashSize*h/(o.dashSize+o.gapSize),f=0;f<n.length-1;f++)for(n[f+1].subtractToRef(n[f],r),c=Math.floor(r.length()/h),r.normalize(),d=0;d<c&&l<t.length;)u=h*d,t[l]=n[f].x+u*r.x,t[l+1]=n[f].y+u*r.y,t[l+2]=n[f].z+u*r.z,t[l+3]=n[f].x+(u+i)*r.x,t[l+4]=n[f].y+(u+i)*r.y,t[l+5]=n[f].z+(u+i)*r.z,l+=6,d++;for(;l<t.length;)t[l]=n[f].x,t[l+1]=n[f].y,t[l+2]=n[f].z,l+=3},!1),o}var c=new e.LinesMesh(t,r);return e.VertexData.CreateDashedLines(i).applyToMesh(c,i.updatable),c.dashSize=a,c.gapSize=s,c},t.ExtrudeShape=function(i,r,n){var o=r.path,s=r.shape,a=r.scale||1,c=r.rotation||0,h=0===r.cap?0:r.cap||e.Mesh.NO_CAP,u=r.updatable,l=this.updateSideOrientation(r.sideOrientation,n),f=r.instance,d=r.invertUV||!1;return t._ExtrudeShapeGeneric(i,s,o,a,c,null,null,!1,!1,h,!1,n,u,l,f,d)},t.ExtrudeShapeCustom=function(i,r,n){var o=r.path,s=r.shape,a=r.scaleFunction||function(){return 1},c=r.rotationFunction||function(){return 0},h=r.ribbonCloseArray||!1,u=r.ribbonClosePath||!1,l=0===r.cap?0:r.cap||e.Mesh.NO_CAP,f=r.updatable,d=this.updateSideOrientation(r.sideOrientation,n),p=r.instance,m=r.invertUV||!1;return t._ExtrudeShapeGeneric(i,s,o,null,null,a,c,h,u,l,!0,n,f,d,p,m)},t.CreateLathe=function(i,r,n){var o,s=r.arc<=0||r.arc>1?1:r.arc||1,a=void 0===r.closed||r.closed,c=r.shape,h=r.radius||1,u=r.tessellation||64,l=r.updatable,f=this.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,m=new Array,g=r.invertUV||!1,_=0,v=0,y=p/u*s,b=new Array;for(_=0;_<=u;_++){b=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(b.push(new e.Vector3(0,c[0].y,0)),b.push(new e.Vector3(Math.cos(_*y)*c[0].x*h,c[0].y,Math.sin(_*y)*c[0].x*h))),v=0;v<c.length;v++)o=new e.Vector3(Math.cos(_*y)*c[v].x*h,c[v].y,Math.sin(_*y)*c[v].x*h),b.push(o);d!=e.Mesh.CAP_END&&d!=e.Mesh.CAP_ALL||(b.push(new e.Vector3(Math.cos(_*y)*c[c.length-1].x*h,c[c.length-1].y,Math.sin(_*y)*c[c.length-1].x*h)),b.push(new e.Vector3(0,c[c.length-1].y,0))),m.push(b)}return t.CreateRibbon(i,{pathArray:m,closeArray:a,sideOrientation:f,updatable:l,invertUV:g},n)},t.CreatePlane=function(t,i,r){var n=new e.Mesh(t,r);if(i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreatePlane(i).applyToMesh(n,i.updatable),i.sourcePlane){n.translate(i.sourcePlane.normal,i.sourcePlane.d);var o=Math.acos(e.Vector3.Dot(i.sourcePlane.normal,e.Axis.Z)),s=e.Vector3.Cross(e.Axis.Z,i.sourcePlane.normal);n.rotate(s,o)}return n},t.CreateGround=function(t,i,r){var n=new e.GroundMesh(t,r);return n._setReady(!1),n._subdivisionsX=i.subdivisionsX||i.subdivisions||1,n._subdivisionsY=i.subdivisionsY||i.subdivisions||1,n._width=i.width||1,n._height=i.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,e.VertexData.CreateGround(i).applyToMesh(n,i.updatable),n._setReady(!0),n},t.CreateTiledGround=function(t,i,r){var n=new e.Mesh(t,r);return e.VertexData.CreateTiledGround(i).applyToMesh(n,i.updatable),n},t.CreateGroundFromHeightMap=function(t,i,r,n){var o=r.width||10,s=r.height||10,a=r.subdivisions||1,c=r.minHeight||0,h=r.maxHeight||10,u=r.updatable,l=r.onReady,f=new e.GroundMesh(t,n);f._subdivisionsX=a,f._subdivisionsY=a,f._width=o,f._height=s,f._maxX=f._width/2,f._maxZ=f._height/2,f._minX=-f._maxX,f._minZ=-f._maxZ,f._setReady(!1);return e.Tools.LoadImage(i,function(t){var i=document.createElement("canvas"),r=i.getContext("2d"),n=t.width,d=t.height;i.width=n,i.height=d,r.drawImage(t,0,0);var p=r.getImageData(0,0,n,d).data;e.VertexData.CreateGroundFromHeightMap({width:o,height:s,subdivisions:a,minHeight:c,maxHeight:h,buffer:p,bufferWidth:n,bufferHeight:d}).applyToMesh(f,u),f._setReady(!0),l&&l(f)},function(){},n.database),f},t.CreateTube=function(i,r,n){var o=r.path,s=r.radius||1,a=r.tessellation||64,c=r.radiusFunction,h=r.cap||e.Mesh.NO_CAP,u=r.invertUV||!1,l=r.updatable,f=this.updateSideOrientation(r.sideOrientation,n),d=r.instance;r.arc=r.arc<=0||r.arc>1?1:r.arc||1;var p,m,g=function(t,i,r,n,o,s,a,c){for(var h,u,l,f,d=i.getTangents(),p=i.getNormals(),m=i.getDistances(),g=2*Math.PI,_=g/o*c,v=s||function(){return n},y=e.Tmp.Matrix[0],b=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,x=0;x<t.length;x++){u=v(x,m[x]),h=Array(),l=p[x];for(var w=0;w<o;w++)e.Matrix.RotationAxisToRef(d[x],_*w,y),f=h[w]?h[w]:e.Vector3.Zero(),e.Vector3.TransformCoordinatesToRef(l,y,f),f.scaleInPlace(u).addInPlace(t[x]),h[w]=f;r[b]=h,b++}var S=function(e,i){for(var r=Array(),n=0;n<e;n++)r.push(t[i]);return r};switch(a){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:r[0]=S(o,0),r[1]=r[2].slice(0);break;case e.Mesh.CAP_END:r[b]=r[b-1].slice(0),r[b+1]=S(o,t.length-1);break;case e.Mesh.CAP_ALL:r[0]=S(o,0),r[1]=r[2].slice(0),r[b]=r[b-1].slice(0),r[b+1]=S(o,t.length-1)}return r};if(d){var _=r.arc||d.arc;return m=g(o,p=d.path3D.update(o),d.pathArray,s,d.tessellation,c,d.cap,_),(d=t.CreateRibbon(null,{pathArray:m,instance:d})).path3D=p,d.pathArray=m,d.arc=_,d}m=g(o,p=new e.Path3D(o),new Array,s,a,c,h=h<0||h>3?0:h,r.arc);var v=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:l,sideOrientation:f,invertUV:u},n);return v.pathArray=m,v.path3D=p,v.tessellation=a,v.cap=h,v.arc=r.arc,v},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r);return i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),e.VertexData.CreatePolyhedron(i).applyToMesh(n,i.updatable),n},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),c=r.normal||e.Vector3.Up(),h=r.size||new e.Vector3(1,1,1),u=r.angle||0;if(!c){var l=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(l,f.getWorldMatrix());c=f.globalPosition.subtract(d)}var p=-Math.atan2(c.z,c.x)-Math.PI/2,m=Math.sqrt(c.x*c.x+c.z*c.z),g=Math.atan2(c.y,m),_=e.Matrix.RotationYawPitchRoll(p,g,u).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(_),y=i.getWorldMatrix().multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var x=0,w=function(t){var i=n[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(o[3*i],o[3*i+1],o[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,y),r.normal=new e.Vector3(s[3*i],s[3*i+1],s[3*i+2]),r},S=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(h,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s<t.length;s+=3){var a,c,u,l,f,d,p;switch(((a=e.Vector3.Dot(t[s].position,i)-r>0)?1:0)+((c=e.Vector3.Dot(t[s+1].position,i)-r>0)?1:0)+((u=e.Vector3.Dot(t[s+2].position,i)-r>0)?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(l=t[s+1],f=t[s+2],d=n(t[s],l),p=n(t[s],f)),c){l=t[s],f=t[s+2],d=n(t[s+1],l),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(l.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}u&&(l=t[s],f=t[s+1],d=n(t[s+2],l),p=n(t[s+2],f)),o.push(l.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(f=n(l=t[s].clone(),t[s+1]),d=n(l,t[s+2]),o.push(l),o.push(f),o.push(d)),c||(f=n(l=t[s+1].clone(),t[s+2]),d=n(l,t[s]),o.push(l),o.push(f),o.push(d)),u||(f=n(l=t[s+2].clone(),t[s]),d=n(l,t[s+1]),o.push(l),o.push(f),o.push(d))}}return o},T=0;T<n.length;T+=3){var A=new Array;if(A.push(w(T)),A.push(w(T+1)),A.push(w(T+2)),A=S(A,new e.Vector3(1,0,0)),A=S(A,new e.Vector3(-1,0,0)),A=S(A,new e.Vector3(0,1,0)),A=S(A,new e.Vector3(0,-1,0)),A=S(A,new e.Vector3(0,0,1)),0!==(A=S(A,new e.Vector3(0,0,-1))).length)for(var M=0;M<A.length;M++){var E=A[M];b.indices.push(x),E.position.toArray(b.positions,3*x),E.normal.toArray(b.normals,3*x),b.uvs.push(.5+E.position.x/h.x),b.uvs.push(.5+E.position.y/h.y),x++}}var P=new e.Mesh(t,i.getScene());return b.applyToMesh(P),P.position=a.clone(),P.rotation=new e.Vector3(g,p,u),P},t._ExtrudeShapeGeneric=function(i,r,n,o,s,a,c,h,u,l,f,d,p,m,g,_){var v,y,b=function(t,i,r,n,o,s,a,c,h,u){for(var l=r.getTangents(),f=r.getNormals(),d=r.getBinormals(),p=r.getDistances(),m=0,g=u?c:function(){return s},_=u?a:function(){return o},v=h===e.Mesh.NO_CAP||h===e.Mesh.CAP_END?0:2,y=e.Tmp.Matrix[0],b=0;b<i.length;b++){for(var x=new Array,w=g(b,p[b]),S=_(b,p[b]),T=0;T<t.length;T++){e.Matrix.RotationAxisToRef(l[b],m,y);var A=l[b].scale(t[T].z).add(f[b].scale(t[T].x)).add(d[b].scale(t[T].y)),M=x[T]?x[T]:e.Vector3.Zero();e.Vector3.TransformCoordinatesToRef(A,y,M),M.scaleInPlace(S).addInPlace(i[b]),x[T]=M}n[v]=x,m+=w,v++}var E=function(t){var i,r=Array(),n=e.Vector3.Zero();for(i=0;i<t.length;i++)n.addInPlace(t[i]);for(n.scaleInPlace(1/t.length),i=0;i<t.length;i++)r.push(n);return r};switch(h){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:n[0]=E(n[2]),n[1]=n[2].slice(0);break;case e.Mesh.CAP_END:n[v]=n[v-1],n[v+1]=E(n[v-1]);break;case e.Mesh.CAP_ALL:n[0]=E(n[2]),n[1]=n[2].slice(0),n[v]=n[v-1],n[v+1]=E(n[v-1])}return n};if(g)return v=g.path3D.update(n),y=b(r,n,g.path3D,g.pathArray,o,s,a,c,g.cap,f),e.Mesh.CreateRibbon(null,y,null,null,null,d,null,null,g);y=b(r,n,v=new e.Path3D(n),new Array,o,s,a,c,l=l<0||l>3?0:l,f);var x=t.CreateRibbon(i,{pathArray:y,closeArray:h,closePath:u,updatable:p,sideOrientation:m,invertUV:_},d);return x.pathArray=y,x.path3D=v,x.cap=l,x},t}();e.MeshBuilder=t}(s||(s={})),function(e){var t=function(){function t(t){this.hasAlpha=!1,this.getAlphaFromRGB=!1,this.level=1,this.coordinatesIndex=0,this.coordinatesMode=e.Texture.EXPLICIT_MODE,this.wrapU=e.Texture.WRAP_ADDRESSMODE,this.wrapV=e.Texture.WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=4,this.isCube=!1,this.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new e.Observable,this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._scene=t,this._scene.textures.push(this),this._uid=null}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.name},Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getTextureMatrix=function(){return null},t.prototype.getReflectionTextureMatrix=function(){return null},t.prototype.getInternalTexture=function(){return this._texture},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?new e.Size(this._texture._width,this._texture._height):this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture._baseWidth,this._texture._baseHeight):e.Size.Zero()},t.prototype.scale=function(e){},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype._removeFromCache=function(e,t){for(var i=this._scene.getEngine().getLoadedTexturesCache(),r=0;r<i.length;r++){var n=i[r];if(n.url===e&&n.noMipmap===t)return void i.splice(r,1)}},t.prototype._getFromCache=function(e,t,i){for(var r=this._scene.getEngine().getLoadedTexturesCache(),n=0;n<r.length;n++){var o=r[n];if(o.url===e&&o.noMipmap===t&&(!i||i===o.samplingMode))return o.references++,o}return null},t.prototype.delayLoad=function(){},t.prototype.clone=function(){return null},t.prototype.releaseInternalTexture=function(){this._texture&&(this._scene.getEngine().releaseInternalTexture(this._texture),delete this._texture)},t.prototype.dispose=function(){this.getScene().stopAnimation(this);var e=this._scene.textures.indexOf(this);e>=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},a([e.serialize()],t.prototype,"name",void 0),a([e.serialize()],t.prototype,"hasAlpha",void 0),a([e.serialize()],t.prototype,"getAlphaFromRGB",void 0),a([e.serialize()],t.prototype,"level",void 0),a([e.serialize()],t.prototype,"coordinatesIndex",void 0),a([e.serialize()],t.prototype,"coordinatesMode",void 0),a([e.serialize()],t.prototype,"wrapU",void 0),a([e.serialize()],t.prototype,"wrapV",void 0),a([e.serialize()],t.prototype,"anisotropicFilteringLevel",void 0),a([e.serialize()],t.prototype,"isCube",void 0),a([e.serialize()],t.prototype,"isRenderTarget",void 0),t}();e.BaseTexture=t}(s||(s={})),function(e){var t=function(t){function i(r,n,o,s,a,c,h,u,l){var f=this;if(void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=null),void 0===h&&(h=null),void 0===u&&(u=null),void 0===l&&(l=!1),t.call(this,n),this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.name=r,this.url=r,this._noMipmap=o,this._invertY=s,this._samplingMode=a,this._buffer=u,this._deleteBuffer=l,r){this._texture=this._getFromCache(r,o,a);var d=function(){f._onLoadObservarble&&f._onLoadObservarble.hasObservers()&&f.onLoadObservable.notifyObservers(!0),c&&c()};this._texture?this._texture.isReady?e.Tools.SetImmediate(function(){return d()}):this._texture.onLoadedCallbacks.push(d):n.useDelayedTextureLoading?(this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,this._delayedOnLoad=d,this._delayedOnError=h):(this._texture=n.getEngine().createTexture(r,o,s,n,this._samplingMode,d,h,this._buffer),l&&delete this._buffer)}}return c(i,t),Object.defineProperty(i.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this._samplingMode),this._texture||(this._texture=this.getScene().getEngine().createTexture(this.url,this._noMipmap,this._invertY,this.getScene(),this._samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer),this._deleteBuffer&&delete this._buffer))},i.prototype.updateSamplingMode=function(e){this._texture&&(this._samplingMode=e,this.getScene().getEngine().updateTextureSamplingMode(e,this._texture))},i.prototype._prepareRowForTextureGeneration=function(t,i,r,n){t*=this.uScale,i*=this.vScale,t-=.5*this.uScale,i-=.5*this.vScale,r-=.5,e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,this._rowGenerationMatrix,n),n.x+=.5*this.uScale+this.uOffset,n.y+=.5*this.vScale+this.vOffset,n.z+=.5},i.prototype.getTextureMatrix=function(){return this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng?this._cachedTextureMatrix:(this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._rowGenerationMatrix=new e.Matrix,this._t0=e.Vector3.Zero(),this._t1=e.Vector3.Zero(),this._t2=e.Vector3.Zero()),e.Matrix.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix.m[0]=this._t1.x,this._cachedTextureMatrix.m[1]=this._t1.y,this._cachedTextureMatrix.m[2]=this._t1.z,this._cachedTextureMatrix.m[4]=this._t2.x,this._cachedTextureMatrix.m[5]=this._t2.y,this._cachedTextureMatrix.m[6]=this._t2.z,this._cachedTextureMatrix.m[8]=this._t0.x,this._cachedTextureMatrix.m[9]=this._t0.y,this._cachedTextureMatrix.m[10]=this._t0.z,this._cachedTextureMatrix)},i.prototype.getReflectionTextureMatrix=function(){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode)return this._cachedTextureMatrix;switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._projectionModeMatrix=e.Matrix.Zero()),this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case i.PLANAR_MODE:e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case i.PROJECTION_MODE:e.Matrix.IdentityToRef(this._projectionModeMatrix),this._projectionModeMatrix.m[0]=.5,this._projectionModeMatrix.m[5]=-.5,this._projectionModeMatrix.m[10]=0,this._projectionModeMatrix.m[12]=.5,this._projectionModeMatrix.m[13]=.5,this._projectionModeMatrix.m[14]=1,this._projectionModeMatrix.m[15]=1,this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:e.Matrix.IdentityToRef(this._cachedTextureMatrix)}return this._cachedTextureMatrix},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone(function(){return new i(t._texture.url,t.getScene(),t._noMipmap,t._invertY,t._samplingMode)},this)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),i.CreateFromBase64String=function(e,t,r,n,o,s,a,c){return void 0===s&&(s=i.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===c&&(c=null),new i("data:"+t,r,n,o,s,a,c,e)},i.Parse=function(t,r,n){if(t.customType)return e.Tools.Instantiate(t.customType).Parse(t,r,n);if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var o=e.SerializationHelper.Parse(function(){if(t.mirrorPlane){var o=new e.MirrorTexture(t.name,t.renderTargetSize,r);return o._waitingRenderList=t.renderList,o.mirrorPlane=e.Plane.FromArray(t.mirrorPlane),o}if(t.isRenderTarget){var s=new e.RenderTargetTexture(t.name,t.renderTargetSize,r);return s._waitingRenderList=t.renderList,s}return t.base64String?i.CreateFromBase64String(t.base64String,t.name,r):new i(n+t.name,r)},t,r);if(t.animations)for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}return o},i.LoadFromDataString=function(e,t,r,n,o,s,a,c,h){return void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=null),void 0===h&&(h=null),"data:"!==e.substr(0,5)&&(e="data:"+e),new i(e,r,o,s,a,c,h,t,n)},i.NEAREST_SAMPLINGMODE=1,i.BILINEAR_SAMPLINGMODE=2,i.TRILINEAR_SAMPLINGMODE=3,i.EXPLICIT_MODE=0,i.SPHERICAL_MODE=1,i.PLANAR_MODE=2,i.CUBIC_MODE=3,i.PROJECTION_MODE=4,i.SKYBOX_MODE=5,i.INVCUBIC_MODE=6,i.EQUIRECTANGULAR_MODE=7,i.FIXED_EQUIRECTANGULAR_MODE=8,i.CLAMP_ADDRESSMODE=0,i.WRAP_ADDRESSMODE=1,i.MIRROR_ADDRESSMODE=2,a([e.serialize()],i.prototype,"url",void 0),a([e.serialize()],i.prototype,"uOffset",void 0),a([e.serialize()],i.prototype,"vOffset",void 0),a([e.serialize()],i.prototype,"uScale",void 0),a([e.serialize()],i.prototype,"vScale",void 0),a([e.serialize()],i.prototype,"uAng",void 0),a([e.serialize()],i.prototype,"vAng",void 0),a([e.serialize()],i.prototype,"wAng",void 0),i}(e.BaseTexture);e.Texture=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o,s,a,c){if(void 0===a&&(a=null),void 0===c&&(c=null),t.call(this,r),this.coordinatesMode=e.Texture.CUBIC_MODE,this.name=i,this.url=i,this._noMipmap=o,this.hasAlpha=!1,i||s){if(this._texture=this._getFromCache(i,o),!s){n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[];for(var h=0;h<n.length;h++)s.push(i+n[h]);this._extensions=n}this._files=s,this._texture?a&&(this._texture.isReady?e.Tools.SetImmediate(function(){return a()}):this._texture.onLoadedCallbacks.push(a)):r.useDelayedTextureLoading?this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:this._texture=r.getEngine().createCubeTexture(i,r,s,o,a,c),this.isCube=!0,this._textureMatrix=e.Matrix.Identity()}}return c(i,t),i.CreateFromImages=function(e,t,r){return new i("",t,null,r,e)},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||(this._texture=this.getScene().getEngine().createCubeTexture(this.url,this.getScene(),this._files,this._noMipmap)))},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.Parse=function(t,i,r){var n=e.SerializationHelper.Parse(function(){return new e.CubeTexture(r+t.name,i,t.extensions)},t,i);if(t.animations)for(var o=0;o<t.animations.length;o++){var s=t.animations[o];n.animations.push(e.Animation.Parse(s))}return n},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone(function(){return new i(t.url,t.getScene(),t._extensions,t._noMipmap,t._files)},this)},i}(e.BaseTexture);e.CubeTexture=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o,s,a,c,h,u,l){void 0===s&&(s=!0),void 0===a&&(a=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=!0),void 0===l&&(l=!1),t.call(this,null,n,!o),this.isCube=c,this.renderList=new Array,this.renderParticles=!0,this.renderSprites=!1,this.coordinatesMode=e.Texture.PROJECTION_MODE,this.onAfterUnbindObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.onClearObservable=new e.Observable,this._currentRefreshId=-1,this._refreshRate=1,this.name=i,this.isRenderTarget=!0,this._size=r,this._generateMipMaps=o,this._doNotChangeAspectRatio=s,h===e.Texture.NEAREST_SAMPLINGMODE&&(this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE),c?(this._texture=n.getEngine().createRenderTargetCubeTexture(r,{generateMipMaps:o,samplingMode:h,generateDepthBuffer:u,generateStencilBuffer:l}),this.coordinatesMode=e.Texture.INVCUBIC_MODE,this._textureMatrix=e.Matrix.Identity()):this._texture=n.getEngine().createRenderTargetTexture(r,{generateMipMaps:o,type:a,samplingMode:h,generateDepthBuffer:u,generateStencilBuffer:l}),this._renderingManager=new e.RenderingManager(n)}return c(i,t),Object.defineProperty(i,"REFRESHRATE_RENDER_ONCE",{get:function(){return i._REFRESHRATE_RENDER_ONCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDER_ONEVERYFRAME",{get:function(){return i._REFRESHRATE_RENDER_ONEVERYFRAME},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDER_ONEVERYTWOFRAMES",{get:function(){return i._REFRESHRATE_RENDER_ONEVERYTWOFRAMES},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!0,configurable:!0}),i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t,this._generateMipMaps)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e,t){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t)},i.prototype.render=function(e,t){var i=this.getScene();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0)),this._waitingRenderList){this.renderList=[];for(var r=0;r<this._waitingRenderList.length;r++){var n=this._waitingRenderList[r];this.renderList.push(i.getMeshByID(n))}delete this._waitingRenderList}if(this.renderListPredicate){this.renderList.splice(0);var o=this.getScene().meshes;for(r=0;r<o.length;r++){var s=o[r];this.renderListPredicate(s)&&this.renderList.push(s)}}if(!this.renderList||0!==this.renderList.length){this._renderingManager.reset();for(var a=this.renderList?this.renderList:i.getActiveMeshes().data,c=this.renderList?this.renderList.length:i.getActiveMeshes().length,h=i.getRenderId(),u=0;u<c;u++){if(s=a[u]){if(!s.isReady()){this.resetRefreshCounter();continue}if(s._preActivateForIntermediateRendering(h),s.isEnabled()&&s.isVisible&&s.subMeshes&&0!=(s.layerMask&i.activeCamera.layerMask)){s._activate(h);for(var l=0;l<s.subMeshes.length;l++){var f=s.subMeshes[l];i._activeIndices.addCount(f.indexCount,!1),this._renderingManager.dispatch(f)}}}}if(this.isCube)for(var d=0;d<6;d++)this.renderToTarget(d,a,c,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,a,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n,o){var s=this.getScene(),a=s.getEngine();n&&s.postProcessManager._prepareFrame(this._texture)||(this.isCube?a.bindFramebuffer(this._texture,t):a.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(a):a.clear(s.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||s.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),n&&s.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||s.updateTransformMatrix(!0),this.onAfterRenderObservable.notifyObservers(t),o&&e.Tools.DumpFramebuffer(this._size,this._size,a),this.isCube&&5!==t||(this.isCube&&5===t&&a.generateMipMapsForCubemap(this._texture),a.unBindFramebuffer(this._texture,this.isCube))},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var i=0;i<this.renderList.length;i++)e.renderList.push(this.renderList[i].id);return e},i._REFRESHRATE_RENDER_ONCE=0,i._REFRESHRATE_RENDER_ONEVERYFRAME=1,i._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,i}(e.Texture);e.RenderTargetTexture=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o,s,a,c){void 0===a&&(a=!0),void 0===c&&(c=!1),t.call(this,null,o,!a),this.isCube=c,this.isEnabled=!0,this._currentRefreshId=-1,this._refreshRate=1,this._vertexBuffers={},this._uniforms=new Array,this._samplers=new Array,this._textures=new Array,this._floats=new Array,this._floatsArrays={},this._colors3=new Array,this._colors4=new Array,this._vectors2=new Array,this._vectors3=new Array,this._matrices=new Array,this._fallbackTextureUsed=!1,o._proceduralTextures.push(this),this.name=i,this.isRenderTarget=!0,this._size=r,this._generateMipMaps=a,this.setFragment(n),this._fallbackTexture=s;var h=o.getEngine();c?(this._texture=h.createRenderTargetCubeTexture(r,{generateMipMaps:a}),this.setFloat("face",0)):this._texture=h.createRenderTargetTexture(r,a);var u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(h,u,e.VertexBuffer.PositionKind,!1,!1,2);var l=[];l.push(0),l.push(1),l.push(2),l.push(0),l.push(2),l.push(3),this._indexBuffer=h.createIndexBuffer(l)}return c(i,t),i.prototype.reset=function(){void 0!==this._effect&&this.getScene().getEngine()._releaseEffect(this._effect)},i.prototype.isReady=function(){var t,i=this,r=this.getScene().getEngine();return!!this._fragment&&(!!this._fallbackTextureUsed||(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,"",null,null,function(){i.releaseInternalTexture(),i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture.references++),i._fallbackTextureUsed=!0}),this._effect.isReady()))},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return!(!(this.isEnabled&&this.isReady()&&this._texture)||this._fallbackTextureUsed||(-1===this._currentRefreshId?(this._currentRefreshId=1,0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,0):(this._currentRefreshId++,1)))},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t))},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene(),i=t.getEngine();for(var r in i.enableEffect(this._effect),i.setState(!1),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o),this._effect.setFloat("face",o),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated()},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene()._proceduralTextures.indexOf(this);i>=0&&this.getScene()._proceduralTextures.splice(i,1);var r=this._vertexBuffers[e.VertexBuffer.PositionKind];r&&(r.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this.getScene().getEngine()._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)},i}(e.Texture);e.ProceduralTexture=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,r,n,o,!0),this.mirrorPlane=new e.Plane(0,1,0,1),this._transformMatrix=e.Matrix.Zero(),this._mirrorMatrix=e.Matrix.Zero(),this.onBeforeRenderObservable.add(function(){e.Matrix.ReflectionToRef(s.mirrorPlane,s._mirrorMatrix),s._savedViewMatrix=n.getViewMatrix(),s._mirrorMatrix.multiplyToRef(s._savedViewMatrix,s._transformMatrix),n.setTransformMatrix(s._transformMatrix,n.getProjectionMatrix()),n.clipPlane=s.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,s._mirrorMatrix)}),this.onAfterRenderObservable.add(function(){n.setTransformMatrix(s._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})}return c(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i}(e.RenderTargetTexture);e.MirrorTexture=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,r,n,o,!0),this.refractionPlane=new e.Plane(0,1,0,1),this.depth=2,this.onBeforeRenderObservable.add(function(){n.clipPlane=s.refractionPlane}),this.onAfterRenderObservable.add(function(){delete n.clipPlane})}return c(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i}(e.RenderTargetTexture);e.RefractionTexture=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,n,!o),this.name=i,this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._generateMipMaps=o,r.getContext?(this._canvas=r,this._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(this._canvas=document.createElement("canvas"),r.width?this._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):this._texture=n.getEngine().createDynamicTexture(r,r,o,s));var a=this.getSize();this._canvas.width=a.width,this._canvas.height=a.height,this._context=this._canvas.getContext("2d")}return c(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var c=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,c.width,c.height)),this._context.font=r,null===t){var h=this._context.measureText(e);t=(c.width-h.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i}(e.Texture);e.DynamicTexture=t}(s||(s={})),function(e){var t=function(t){function i(i,r,n,o,s,a){var c,h=this;void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,n,!o,s),this._autoLaunch=!0,this.name=i,r instanceof HTMLVideoElement?this.video=r:(c=r,this.video=document.createElement("video"),this.video.autoplay=!1,this.video.loop=!0),this._generateMipMaps=o,this._samplingMode=a,e.Tools.IsExponentOfTwo(this.video.videoWidth)&&e.Tools.IsExponentOfTwo(this.video.videoHeight)?(this.wrapU=e.Texture.WRAP_ADDRESSMODE,this.wrapV=e.Texture.WRAP_ADDRESSMODE):(this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._generateMipMaps=!1),c?(this.video.addEventListener("canplaythrough",function(){h._createTexture()}),c.forEach(function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)})):this._createTexture(),this._lastUpdate=e.Tools.Now}return c(i,t),i.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._texture.isReady=!0},i.prototype.update=function(){this._autoLaunch&&(this._autoLaunch=!1,this.video.play());var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA||(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),0))},i}(e.Texture);e.VideoTexture=t}(s||(s={})),function(e){var t=function(t){function i(e,i,r,n,o,s){t.call(this,e,r,null,n,o,s),this._animate=!0,this._time=0,this._texturePath=i,this.loadJson(i),this.refreshRate=1}return c(i,t),i.prototype.loadJson=function(t){function i(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{n.setFragment(n._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}}var r=this,n=this,o=t+"/config.json",s=new XMLHttpRequest;s.open("GET",o,!0),s.addEventListener("load",function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{r._config=JSON.parse(s.response),r.updateShaderUniforms(),r.updateTextures(),r.setFragment(r._texturePath+"/custom"),r._animate=r._config.animate,r.refreshRate=r._config.refreshrate}catch(e){i()}else i()},!1),s.addEventListener("error",function(){i()},!1);try{s.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){this._animate&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t<this._config.sampler2Ds.length;t++)this.setTexture(this._config.sampler2Ds[t].sample2Dname,new e.Texture(this._texturePath+"/"+this._config.sampler2Ds[t].textureRelativeUrl,this.getScene()))},i.prototype.updateShaderUniforms=function(){if(this._config)for(var t=0;t<this._config.uniforms.length;t++){var i=this._config.uniforms[t];switch(i.type){case"float":this.setFloat(i.name,i.value);break;case"color3":this.setColor3(i.name,new e.Color3(i.r,i.g,i.b));break;case"color4":this.setColor4(i.name,new e.Color4(i.r,i.g,i.b,i.a));break;case"vector2":this.setVector2(i.name,new e.Vector2(i.x,i.y));break;case"vector3":this.setVector3(i.name,new e.Vector3(i.x,i.y,i.z))}}this.setFloat("time",this._time)},Object.defineProperty(i.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.CustomProceduralTexture=t}(s||(s={})),function(e){var t=function(){function t(){this._defines={},this._currentRank=32,this._maxRank=-1}return t.prototype.addFallback=function(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},t.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(t.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),t.prototype.reduce=function(t){for(var i=this._defines[this._currentRank],r=0;r<i.length;r++)t=t.replace("#define "+i[r],"");return this._mesh&&this._currentRank===this._meshRank&&(this._mesh.computeBonesUsingShaders=!1,t=t.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),e.Tools.Log("Falling back to CPU skinning for "+this._mesh.name)),this._currentRank++,t},t}();e.EffectFallbacks=t;var i=function(){function t(e,t,i,r,n,o,s,a,c,h){var u,l,f=this;this._isReady=!1,this._compilationError="",this._valueCache={},this._engine=n,this.name=e,this.defines=o,this._uniformsNames=i.concat(r),this._samplers=r,this._attributesNames=t,this.onError=c,this.onCompiled=a,this._indexParameters=h,e.vertexElement?(u=document.getElementById(e.vertexElement))||(u=e.vertexElement):u=e.vertex||e,e.fragmentElement?(l=document.getElementById(e.fragmentElement))||(l=e.fragmentElement):l=e.fragment||e,this._loadVertexShader(u,function(e){f._processIncludes(e,function(e){f._loadFragmentShader(l,function(i){f._processIncludes(i,function(i){f._prepareEffect(e,i,t,o,s)})})})})}return t.prototype.isReady=function(){return this._isReady},t.prototype.getProgram=function(){return this._program},t.prototype.getAttributesNames=function(){return this._attributesNames},t.prototype.getAttributeLocation=function(e){return this._attributes[e]},t.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},t.prototype.getAttributesCount=function(){return this._attributes.length},t.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},t.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},t.prototype.getSamplers=function(){return this._samplers},t.prototype.getCompilationError=function(){return this._compilationError},t.prototype.getVertexShaderSource=function(){return this._engine.getVertexShaderSource(this._program)},t.prototype.getFragmentShaderSource=function(){return this._engine.getFragmentShaderSource(this._program)},t.prototype._loadVertexShader=function(i,r){var n;i instanceof HTMLElement?r(e.Tools.GetDOMTextContent(i)):"base64:"!==i.substr(0,7)?t.ShadersStore[i+"VertexShader"]?r(t.ShadersStore[i+"VertexShader"]):(n="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(n+".vertex.fx",r)):r(window.atob(i.substr(7)))},t.prototype._loadFragmentShader=function(i,r){var n;i instanceof HTMLElement?r(e.Tools.GetDOMTextContent(i)):"base64:"!==i.substr(0,7)?t.ShadersStore[i+"PixelShader"]?r(t.ShadersStore[i+"PixelShader"]):t.ShadersStore[i+"FragmentShader"]?r(t.ShadersStore[i+"FragmentShader"]):(n="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(n+".fragment.fx",r)):r(window.atob(i.substr(7)))},t.prototype._dumpShadersName=function(){this.name.vertexElement?(e.Tools.Error("Vertex shader:"+this.name.vertexElement),e.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(e.Tools.Error("Vertex shader:"+this.name.vertex),e.Tools.Error("Fragment shader:"+this.name.fragment)):(e.Tools.Error("Vertex shader:"+this.name),e.Tools.Error("Fragment shader:"+this.name))},t.prototype._processIncludes=function(i,r){for(var n=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,s=o.exec(i),a=new String(i);null!=s;){var c=s[1];if(!t.IncludesShadersStore[c]){var h=e.Engine.ShadersRepository+"ShadersInclude/"+c+".fx";return void e.Tools.LoadFile(h,function(e){t.IncludesShadersStore[c]=e,n._processIncludes(a,r)})}var u=t.IncludesShadersStore[c];if(s[2])for(var l=s[3].split(","),f=0;f<l.length;f+=2){var d=new RegExp(l[f],"g"),p=l[f+1];u=u.replace(d,p)}if(s[4]){var m=s[5];if(-1!==m.indexOf("..")){var g=m.split(".."),_=parseInt(g[0]),v=parseInt(g[1]),y=u.slice(0);u="",isNaN(v)&&(v=this._indexParameters[g[1]]);for(var b=_;b<=v;b++)u+=y.replace(/\{X\}/g,b)+"\n"}else u=u.replace(/\{X\}/g,m)}a=a.replace(s[0],u),s=o.exec(i)}r(a)},t.prototype._processPrecision=function(e){return-1===e.indexOf("precision highp float")?e=this._engine.getCaps().highPrecisionShaderSupported?"precision highp float;\n"+e:"precision mediump float;\n"+e:this._engine.getCaps().highPrecisionShaderSupported||(e=e.replace("precision highp float","precision mediump float")),e},t.prototype._prepareEffect=function(t,i,r,n,o){try{var s,a=this._engine;for(t=this._processPrecision(t),i=this._processPrecision(i),this._program=a.createShaderProgram(t,i,n),this._uniforms=a.getUniforms(this._program,this._uniformsNames),this._attributes=a.getAttributes(this._program,r),s=0;s<this._samplers.length;s++){null==this.getUniform(this._samplers[s])&&(this._samplers.splice(s,1),s--)}a.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this)}catch(s){this._compilationError=s.message,e.Tools.Error("Unable to compile effect: "),e.Tools.Error("Defines: "+n),e.Tools.Error("Error: "+this._compilationError),this._dumpShadersName(),o&&o.isMoreFallbacks?(e.Tools.Error("Trying next fallback."),n=o.reduce(n),this._prepareEffect(t,i,r,n,o)):this.onError&&this.onError(this,this._compilationError)}},Object.defineProperty(t.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!0,configurable:!0}),t.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},t.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),this.getUniform(e),t)},t.prototype.setTextureArray=function(e,t){if(-1===this._samplers.indexOf(e+"Ex"))for(var i=this._samplers.indexOf(e),r=1;r<t.length;r++)this._samplers.splice(i+r,0,e+"Ex");this._engine.setTextureArray(this._samplers.indexOf(e),this.getUniform(e),t)},t.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},t.prototype._cacheMatrix=function(t,i){var r=!1,n=this._valueCache[t];n&&n instanceof e.Matrix||(r=!0,n=new e.Matrix);for(var o=n.m,s=i.m,a=0;a<16;a++)o[a]!==s[a]&&(o[a]=s[a],r=!0);return this._valueCache[t]=n,r},t.prototype._cacheFloat2=function(e,t,i){var r=this._valueCache[e];if(!r)return r=[t,i],this._valueCache[e]=r,!0;var n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==i&&(r[1]=i,n=!0),n},t.prototype._cacheFloat3=function(e,t,i,r){var n=this._valueCache[e];if(!n)return n=[t,i,r],this._valueCache[e]=n,!0;var o=!1;return n[0]!==t&&(n[0]=t,o=!0),n[1]!==i&&(n[1]=i,o=!0),n[2]!==r&&(n[2]=r,o=!0),o},t.prototype._cacheFloat4=function(e,t,i,r,n){var o=this._valueCache[e];if(!o)return o=[t,i,r,n],this._valueCache[e]=o,!0;var s=!1;return o[0]!==t&&(o[0]=t,s=!0),o[1]!==i&&(o[1]=i,s=!0),o[2]!==r&&(o[2]=r,s=!0),o[3]!==n&&(o[3]=n,s=!0),s},t.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this.getUniform(e),t),this},t.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this.getUniform(e),t),this},t.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this.getUniform(e),t),this},t.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this.getUniform(e),t),this},t.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray(this.getUniform(e),t),this},t.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray2(this.getUniform(e),t),this},t.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray3(this.getUniform(e),t),this},t.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray4(this.getUniform(e),t),this},t.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this.getUniform(e),t),this},t.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this.getUniform(e),t),this},t.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this.getUniform(e),t),this},t.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this.getUniform(e),t),this},t.prototype.setMatrices=function(e,t){return this._valueCache[e]=null,this._engine.setMatrices(this.getUniform(e),t),this},t.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&this._engine.setMatrix(this.getUniform(e),t),this},t.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this.getUniform(e),t),this},t.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this.getUniform(e),t),this},t.prototype.setFloat=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t?this:(this._valueCache[e]=t,this._engine.setFloat(this.getUniform(e),t),this)},t.prototype.setBool=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t?this:(this._valueCache[e]=t,this._engine.setBool(this.getUniform(e),t?1:0),this)},t.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&this._engine.setFloat2(this.getUniform(e),t.x,t.y),this},t.prototype.setFloat2=function(e,t,i){return this._cacheFloat2(e,t,i)&&this._engine.setFloat2(this.getUniform(e),t,i),this},t.prototype.setVector3=function(e,t){return this._cacheFloat3(e,t.x,t.y,t.z)&&this._engine.setFloat3(this.getUniform(e),t.x,t.y,t.z),this},t.prototype.setFloat3=function(e,t,i,r){return this._cacheFloat3(e,t,i,r)&&this._engine.setFloat3(this.getUniform(e),t,i,r),this},t.prototype.setVector4=function(e,t){return this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&this._engine.setFloat4(this.getUniform(e),t.x,t.y,t.z,t.w),this},t.prototype.setFloat4=function(e,t,i,r,n){return this._cacheFloat4(e,t,i,r,n)&&this._engine.setFloat4(this.getUniform(e),t,i,r,n),this},t.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&this._engine.setColor3(this.getUniform(e),t),this},t.prototype.setColor4=function(e,t,i){return this._cacheFloat4(e,t.r,t.g,t.b,i)&&this._engine.setColor4(this.getUniform(e),t,i),this},t.ShadersStore={},t.IncludesShadersStore={},t}();e.Effect=i}(s||(s={})),function(e){var t=function(){function t(){}return t.PrepareDefinesForLights=function(t,i,r,n){void 0===n&&(n=4);for(var o=0,s=!1,a=!1,c=!1,h=!1,u=0;u<t.lights.length;u++){var l=t.lights[u];if(l.isEnabled()){if(l._excludedMeshesIds.length>0){for(var f=0;f<l._excludedMeshesIds.length;f++){var d=t.getMeshByID(l._excludedMeshesIds[f]);d&&l.excludedMeshes.push(d)}l._excludedMeshesIds=[]}if(l._includedOnlyMeshesIds.length>0){for(var p=0;p<l._includedOnlyMeshesIds.length;p++){var m=t.getMeshByID(l._includedOnlyMeshesIds[p]);m&&l.includedOnlyMeshes.push(m)}l._includedOnlyMeshesIds=[]}if(l.canAffectMesh(i)){var g;if(s=!0,void 0===r["LIGHT"+o]&&(a=!0),r["LIGHT"+o]=!0,void 0===r[g=l instanceof e.SpotLight?"SPOTLIGHT"+o:l instanceof e.HemisphericLight?"HEMILIGHT"+o:l instanceof e.PointLight?"POINTLIGHT"+o:"DIRLIGHT"+o]&&(a=!0),r[g]=!0,l.specular.equalsFloats(0,0,0)||void 0===r.SPECULARTERM||(r.SPECULARTERM=!0),t.shadowsEnabled){var _=l.getShadowGenerator();i&&i.receiveShadows&&_&&(void 0===r["SHADOW"+o]&&(a=!0),r["SHADOW"+o]=!0,r.SHADOWS=!0,(_.useVarianceShadowMap||_.useBlurVarianceShadowMap)&&(void 0===r["SHADOWVSM"+o]&&(a=!0),r["SHADOWVSM"+o]=!0),_.usePoissonSampling&&(void 0===r["SHADOWPCF"+o]&&(a=!0),r["SHADOWPCF"+o]=!0),c=!0)}if(l.lightmapMode!=e.Light.LIGHTMAP_DEFAULT&&(h=!0,void 0===r["LIGHTMAPEXCLUDED"+o]&&(a=!0),void 0===r["LIGHTMAPNOSPECULAR"+o]&&(a=!0),r["LIGHTMAPEXCLUDED"+o]=!0,l.lightmapMode==e.Light.LIGHTMAP_SHADOWSONLY&&(r["LIGHTMAPNOSPECULAR"+o]=!0)),++o===n)break}}}var v=t.getEngine().getCaps();return c&&v.textureFloat&&v.textureFloatLinearFiltering&&v.textureFloatRender&&(void 0===r.SHADOWFULLFLOAT&&(a=!0),r.SHADOWFULLFLOAT=!0),void 0===r.LIGHTMAPEXCLUDED&&(a=!0),h&&(r.LIGHTMAPEXCLUDED=!0),a&&r.rebuild(),s},t.PrepareUniformsAndSamplersList=function(e,t,i,r){void 0===r&&(r=4);for(var n=0;n<r&&i["LIGHT"+n];n++)e.push("vLightData"+n,"vLightDiffuse"+n,"vLightSpecular"+n,"vLightDirection"+n,"vLightGround"+n,"lightMatrix"+n,"shadowsInfo"+n),t.push("shadowSampler"+n)},t.HandleFallbacksForShadows=function(e,t,i){void 0===i&&(i=4);for(var r=0;r<i&&e["LIGHT"+r];r++)r>0&&t.addFallback(r,"LIGHT"+r),e["SHADOW"+r]&&t.addFallback(0,"SHADOW"+r),e["SHADOWPCF"+r]&&t.addFallback(0,"SHADOWPCF"+r),e["SHADOWVSM"+r]&&t.addFallback(0,"SHADOWVSM"+r)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n,o){var s=e.getShadowGenerator();return i.receiveShadows&&s&&(e.needCube()?o||(o=!0,n.setFloat2("depthValues",t.activeCamera.minZ,t.activeCamera.maxZ)):n.setMatrix("lightMatrix"+r,s.getTransformMatrix()),n.setTexture("shadowSampler"+r,s.getShadowMapForRendering()),n.setFloat3("shadowsInfo"+r,s.getDarkness(),s.blurScale/s.getShadowMap().getSize().width,s.bias)),o},t.BindLightProperties=function(t,i,r){t instanceof e.PointLight?t.transferToEffect(i,"vLightData"+r):t instanceof e.DirectionalLight?t.transferToEffect(i,"vLightData"+r):t instanceof e.SpotLight?t.transferToEffect(i,"vLightData"+r,"vLightDirection"+r):t instanceof e.HemisphericLight&&t.transferToEffect(i,"vLightData"+r,"vLightGround"+r)},t.BindLights=function(i,r,n,o,s){void 0===s&&(s=4);for(var a=0,c=!1,h=0;h<i.lights.length;h++){var u=i.lights[h];if(u.isEnabled()&&u.canAffectMesh(r)&&(t.BindLightProperties(u,n,a),u.diffuse.scaleToRef(u.intensity,e.Tmp.Color3[0]),n.setColor4("vLightDiffuse"+a,e.Tmp.Color3[0],u.range),o.SPECULARTERM&&(u.specular.scaleToRef(u.intensity,e.Tmp.Color3[1]),n.setColor3("vLightSpecular"+a,e.Tmp.Color3[1])),i.shadowsEnabled&&(c=this.BindLightShadow(u,i,r,a,n,c)),++a===s))break}},t.BindFogParameters=function(t,i,r){t.fogEnabled&&i.applyFog&&t.fogMode!==e.Scene.FOGMODE_NONE&&(r.setFloat4("vFogInfos",t.fogMode,t.fogStart,t.fogEnd,t.fogDensity),r.setColor3("vFogColor",t.fogColor))},t.BindBonesParameters=function(e,t){if(e&&e.useBones&&e.computeBonesUsingShaders){var i=e.skeleton.getTransformMatrices(e);i&&t.setMatrices("mBones",i)}},t.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},t.BindClipPlane=function(e,t){if(t.clipPlane){var i=t.clipPlane;e.setFloat4("vClipPlane",i.normal.x,i.normal.y,i.normal.z,i.d)}},t}();e.MaterialHelper=t}(s||(s={})),function(e){var t=function(){function t(){this.isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor,e.rightColor=this.rightColor,e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t}();e.FresnelParameters=t}(s||(s={})),function(e){var t=function(){function e(){}return e.prototype.rebuild=function(){this._keys&&delete this._keys,this._keys=Object.keys(this)},e.prototype.isEqual=function(e){if(this._keys.length!==e._keys.length)return!1;for(var t=0;t<this._keys.length;t++){var i=this._keys[t];if(this[i]!==e[i])return!1}return!0},e.prototype.cloneTo=function(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(var t=0;t<this._keys.length;t++){var i=this._keys[t];e[i]=this[i]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];"number"==typeof this[t]?this[t]=0:this[t]=!1}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var i=this._keys[t];"number"==typeof this[i]?e+="#define "+i+" "+this[i]+"\n":this[i]&&(e+="#define "+i+"\n")}return e},e}();e.MaterialDefines=t;var i=function(){function t(i,r,n){this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this.alpha=1,this.backFaceCulling=!0,this.doNotSerialize=!1,this.onDisposeObservable=new e.Observable,this.onBindObservable=new e.Observable,this.onUnBindObservable=new e.Observable,this.alphaMode=e.Engine.ALPHA_COMBINE,this.disableDepthWrite=!1,this.fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._wasPreviouslyReady=!1,this._fillMode=t.TriangleFillMode,this.name=i,this.id=i,this._scene=r,r.useRightHandedSystem?this.sideOrientation=t.ClockWiseSideOrientation:this.sideOrientation=t.CounterClockWiseSideOrientation,n||r.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode=e},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(){var e=this._scene.getEngine(),i=this.sideOrientation===t.ClockWiseSideOrientation;e.enableEffect(this._effect),e.setState(this.backFaceCulling,this.zOffset,!1,i)},t.prototype.bind=function(e,t){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(t),this.disableDepthWrite){var i=this._scene.getEngine();this._cachedDepthWriteState=i.getDepthWrite(),i.setDepthWrite(!1)}},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.unbind=function(){(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite)&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t<this._scene.meshes.length;t++){var i=this._scene.meshes[t];i.material===this&&e.push(i)}return e},t.prototype.dispose=function(e,t){this.getScene().stopAnimation(this);var i=this._scene.materials.indexOf(this);for(i>=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i<this._scene.meshes.length;i++){var r=this._scene.meshes[i];r.material===this&&(r.material=null)}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBindObservable.clear(),this.onUnBindObservable.clear()},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.ParseMultiMaterial=function(t,i){var r=new e.MultiMaterial(t.name,i);r.id=t.id,e.Tags.AddTagsTo(r,t.tags);for(var n=0;n<t.materials.length;n++){var o=t.materials[n];o?r.subMaterials.push(i.getMaterialByID(o)):r.subMaterials.push(null)}return r},t.Parse=function(t,i,r){return t.customType?e.Tools.Instantiate(t.customType).Parse(t,i,r):e.StandardMaterial.Parse(t,i,r)},t._TriangleFillMode=0,t._WireFrameFillMode=1,t._PointFillMode=2,t._ClockWiseSideOrientation=0,t._CounterClockWiseSideOrientation=1,a([e.serialize()],t.prototype,"id",void 0),a([e.serialize()],t.prototype,"name",void 0),a([e.serialize()],t.prototype,"checkReadyOnEveryCall",void 0),a([e.serialize()],t.prototype,"checkReadyOnlyOnce",void 0),a([e.serialize()],t.prototype,"state",void 0),a([e.serialize()],t.prototype,"alpha",void 0),a([e.serialize()],t.prototype,"backFaceCulling",void 0),a([e.serialize()],t.prototype,"sideOrientation",void 0),a([e.serialize()],t.prototype,"alphaMode",void 0),a([e.serialize()],t.prototype,"disableDepthWrite",void 0),a([e.serialize()],t.prototype,"fogEnabled",void 0),a([e.serialize()],t.prototype,"pointSize",void 0),a([e.serialize()],t.prototype,"zOffset",void 0),a([e.serialize()],t.prototype,"wireframe",null),a([e.serialize()],t.prototype,"pointsCloud",null),a([e.serialize()],t.prototype,"fillMode",null),t}();e.Material=i}(s||(s={})),function(e){var t=function(e){function t(){e.call(this),this.DIFFUSE=!1,this.AMBIENT=!1,this.OPACITY=!1,this.OPACITYRGB=!1,this.REFLECTION=!1,this.EMISSIVE=!1,this.SPECULAR=!1,this.BUMP=!1,this.PARALLAX=!1,this.PARALLAXOCCLUSION=!1,this.SPECULAROVERALPHA=!1,this.CLIPPLANE=!1,this.ALPHATEST=!1,this.ALPHAFROMDIFFUSE=!1,this.POINTSIZE=!1,this.FOG=!1,this.SPECULARTERM=!1,this.DIFFUSEFRESNEL=!1,this.OPACITYFRESNEL=!1,this.REFLECTIONFRESNEL=!1,this.REFRACTIONFRESNEL=!1,this.EMISSIVEFRESNEL=!1,this.FRESNEL=!1,this.NORMAL=!1,this.UV1=!1,this.UV2=!1,this.VERTEXCOLOR=!1,this.VERTEXALPHA=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.INSTANCES=!1,this.GLOSSINESS=!1,this.ROUGHNESS=!1,this.EMISSIVEASILLUMINATION=!1,this.LINKEMISSIVEWITHDIFFUSE=!1,this.REFLECTIONFRESNELFROMSPECULAR=!1,this.LIGHTMAP=!1,this.USELIGHTMAPASSHADOWMAP=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.LOGARITHMICDEPTH=!1,this.REFRACTION=!1,this.REFRACTIONMAP_3D=!1,this.REFLECTIONOVERALPHA=!1,this.INVERTNORMALMAPX=!1,this.INVERTNORMALMAPY=!1,this.SHADOWFULLFLOAT=!1,this.CAMERACOLORGRADING=!1,this.CAMERACOLORCURVES=!1,this.rebuild()}return c(t,e),t}(e.MaterialDefines),i=function(i){function r(r,n){var o=this;i.call(this,r,n),this.ambientColor=new e.Color3(0,0,0),this.diffuseColor=new e.Color3(1,1,1),this.specularColor=new e.Color3(1,1,1),this.emissiveColor=new e.Color3(0,0,0),this.specularPower=64,this.useAlphaFromDiffuseTexture=!1,this.useEmissiveAsIllumination=!1,this.linkEmissiveWithDiffuse=!1,this.useReflectionFresnelFromSpecular=!1,this.useSpecularOverAlpha=!1,this.useReflectionOverAlpha=!1,this.disableLighting=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.roughness=0,this.indexOfRefraction=.98,this.invertRefractionY=!0,this.useLightmapAsShadowmap=!1,this.useGlossinessFromSpecularMapAlpha=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this.cameraColorGradingTexture=null,this.cameraColorCurves=null,this._renderTargets=new e.SmartArray(16),this._worldViewProjectionMatrix=e.Matrix.Zero(),this._globalAmbientColor=new e.Color3(0,0,0),this._defines=new t,this._cachedDefines=new t,this._cachedDefines.BonesPerMesh=-1,this.getRenderTargetTextures=function(){return o._renderTargets.reset(),o.reflectionTexture&&o.reflectionTexture.isRenderTarget&&o._renderTargets.push(o.reflectionTexture),o.refractionTexture&&o.refractionTexture.isRenderTarget&&o._renderTargets.push(o.refractionTexture),o._renderTargets}}return c(r,i),Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this.opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled},r.prototype.needAlphaTesting=function(){return null!=this.diffuseTexture&&this.diffuseTexture.hasAlpha},r.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this.diffuseTexture&&this.diffuseTexture.hasAlpha&&this.useAlphaFromDiffuseTexture},r.prototype.getAlphaTestTexture=function(){return this.diffuseTexture},r.prototype._checkCache=function(e,t,i){return!t||this._defines.INSTANCES===i&&!(!t._materialDefines||!t._materialDefines.isEqual(this._defines))},r.prototype.isReady=function(i,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;var o=this.getScene(),s=o.getEngine(),a=!1,c=!1;if(this._defines.reset(),o.lightsEnabled&&!this.disableLighting&&(c=e.MaterialHelper.PrepareDefinesForLights(o,i,this._defines,this.maxSimultaneousLights)),!this.checkReadyOnEveryCall&&this._renderId===o.getRenderId()&&this._checkCache(o,i,n))return!0;if(o.texturesEnabled){if(this.diffuseTexture&&r.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;a=!0,this._defines.DIFFUSE=!0}if(this.ambientTexture&&r.AmbientTextureEnabled){if(!this.ambientTexture.isReady())return!1;a=!0,this._defines.AMBIENT=!0}if(this.opacityTexture&&r.OpacityTextureEnabled){if(!this.opacityTexture.isReady())return!1;a=!0,this._defines.OPACITY=!0,this.opacityTexture.getAlphaFromRGB&&(this._defines.OPACITYRGB=!0)}if(this.reflectionTexture&&r.ReflectionTextureEnabled){if(!this.reflectionTexture.isReady())return!1;switch(c=!0,this._defines.REFLECTION=!0,this.roughness>0&&(this._defines.ROUGHNESS=!0),this.useReflectionOverAlpha&&(this._defines.REFLECTIONOVERALPHA=!0),this.reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE&&(this._defines.INVERTCUBICMAP=!0),this._defines.REFLECTIONMAP_3D=this.reflectionTexture.isCube,this.reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:this._defines.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:this._defines.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:this._defines.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:this._defines.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:this._defines.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:this._defines.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:this._defines.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:this._defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0}}if(this.emissiveTexture&&r.EmissiveTextureEnabled){if(!this.emissiveTexture.isReady())return!1;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!0,this._defines.SPECULAR=!0,this._defines.GLOSSINESS=this.useGlossinessFromSpecularMapAlpha}if(o.getEngine().getCaps().standardDerivatives&&this.bumpTexture&&r.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;a=!0,this._defines.BUMP=!0,this.useParallax&&(this._defines.PARALLAX=!0,this.useParallaxOcclusion&&(this._defines.PARALLAXOCCLUSION=!0)),this.invertNormalMapX&&(this._defines.INVERTNORMALMAPX=!0),this.invertNormalMapY&&(this._defines.INVERTNORMALMAPY=!0)}if(this.refractionTexture&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}if(this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}if(o.clipPlane&&(this._defines.CLIPPLANE=!0),s.getAlphaTesting()&&(this._defines.ALPHATEST=!0),this._shouldUseAlphaFromDiffuseTexture()&&(this._defines.ALPHAFROMDIFFUSE=!0),this.useEmissiveAsIllumination&&(this._defines.EMISSIVEASILLUMINATION=!0),this.linkEmissiveWithDiffuse&&(this._defines.LINKEMISSIVEWITHDIFFUSE=!0),this.useLogarithmicDepth&&(this._defines.LOGARITHMICDEPTH=!0),this.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!0),(this.pointsCloud||o.forcePointsCloud)&&(this._defines.POINTSIZE=!0),o.fogEnabled&&i&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0),r.FresnelEnabled&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled||this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled||this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled||this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled)&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._defines.DIFFUSEFRESNEL=!0),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&(this._defines.OPACITYFRESNEL=!0),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._defines.REFLECTIONFRESNEL=!0,this.useReflectionFresnelFromSpecular&&(this._defines.REFLECTIONFRESNELFROMSPECULAR=!0)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._defines.REFRACTIONFRESNEL=!0),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._defines.EMISSIVEFRESNEL=!0),c=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(c&&i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(this._defines.NORMAL=!0),a&&(i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(this._defines.UV1=!0),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(this._defines.UV2=!0)),i.useVertexColors&&i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(this._defines.VERTEXCOLOR=!0,i.hasVertexAlpha&&(this._defines.VERTEXALPHA=!0)),i.useBones&&i.computeBonesUsingShaders&&(this._defines.NUM_BONE_INFLUENCERS=i.numBoneInfluencers,this._defines.BonesPerMesh=i.skeleton.bones.length+1),n&&(this._defines.INSTANCES=!0)),!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),o.resetCachedMaterial();var h=new e.EffectFallbacks;this._defines.REFLECTION&&h.addFallback(0,"REFLECTION"),this._defines.SPECULAR&&h.addFallback(0,"SPECULAR"),this._defines.BUMP&&h.addFallback(0,"BUMP"),this._defines.PARALLAX&&h.addFallback(1,"PARALLAX"),this._defines.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),this._defines.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),this._defines.FOG&&h.addFallback(1,"FOG"),this._defines.POINTSIZE&&h.addFallback(0,"POINTSIZE"),this._defines.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(this._defines,h,this.maxSimultaneousLights),this._defines.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),this._defines.DIFFUSEFRESNEL&&h.addFallback(1,"DIFFUSEFRESNEL"),this._defines.OPACITYFRESNEL&&h.addFallback(2,"OPACITYFRESNEL"),this._defines.REFLECTIONFRESNEL&&h.addFallback(3,"REFLECTIONFRESNEL"),this._defines.EMISSIVEFRESNEL&&h.addFallback(4,"EMISSIVEFRESNEL"),this._defines.FRESNEL&&h.addFallback(4,"FRESNEL");var u=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&u.push(e.VertexBuffer.NormalKind),this._defines.UV1&&u.push(e.VertexBuffer.UVKind),this._defines.UV2&&u.push(e.VertexBuffer.UV2Kind),this._defines.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,i,this._defines,h),e.MaterialHelper.PrepareAttributesForInstances(u,this._defines);var l=this._defines.toString(),f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","depthValues","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(f),this._defines.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(f,d),e.MaterialHelper.PrepareUniformsAndSamplersList(f,d,this._defines,this.maxSimultaneousLights),this._effect=o.getEngine().createEffect("default",u,f,d,l,h,this.onCompiled,this.onError,{maxSimultaneousLights:this.maxSimultaneousLights-1})}return!!this._effect.isReady()&&(this._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,i&&(i._materialDefines||(i._materialDefines=new t),this._defines.cloneTo(i._materialDefines)),!0)},r.prototype.unbind=function(){this.reflectionTexture&&this.reflectionTexture.isRenderTarget&&this._effect.setTexture("reflection2DSampler",null),this.refractionTexture&&this.refractionTexture.isRenderTarget&&this._effect.setTexture("refraction2DSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},r.prototype.bind=function(t,n){var o=this.getScene();if(this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(n,this._effect),o.getCachedMaterial()!==this){if(this._effect.setMatrix("viewProjection",o.getTransformMatrix()),r.FresnelEnabled&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._effect.setColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._effect.setColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._effect.setColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._effect.setColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._effect.setColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._effect.setColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._effect.setColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._effect.setColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._effect.setColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled){if(this.diffuseTexture&&r.DiffuseTextureEnabled&&(this._effect.setTexture("diffuseSampler",this.diffuseTexture),this._effect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._effect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),this.ambientTexture&&r.AmbientTextureEnabled&&(this._effect.setTexture("ambientSampler",this.ambientTexture),this._effect.setFloat2("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level),this._effect.setMatrix("ambientMatrix",this.ambientTexture.getTextureMatrix())),this.opacityTexture&&r.OpacityTextureEnabled&&(this._effect.setTexture("opacitySampler",this.opacityTexture),this._effect.setFloat2("vOpacityInfos",this.opacityTexture.coordinatesIndex,this.opacityTexture.level),this._effect.setMatrix("opacityMatrix",this.opacityTexture.getTextureMatrix())),this.reflectionTexture&&r.ReflectionTextureEnabled&&(this.reflectionTexture.isCube?this._effect.setTexture("reflectionCubeSampler",this.reflectionTexture):this._effect.setTexture("reflection2DSampler",this.reflectionTexture),this._effect.setMatrix("reflectionMatrix",this.reflectionTexture.getReflectionTextureMatrix()),this._effect.setFloat2("vReflectionInfos",this.reflectionTexture.level,this.roughness)),this.emissiveTexture&&r.EmissiveTextureEnabled&&(this._effect.setTexture("emissiveSampler",this.emissiveTexture),this._effect.setFloat2("vEmissiveInfos",this.emissiveTexture.coordinatesIndex,this.emissiveTexture.level),this._effect.setMatrix("emissiveMatrix",this.emissiveTexture.getTextureMatrix())),this.lightmapTexture&&r.LightmapTextureEnabled&&(this._effect.setTexture("lightmapSampler",this.lightmapTexture),this._effect.setFloat2("vLightmapInfos",this.lightmapTexture.coordinatesIndex,this.lightmapTexture.level),this._effect.setMatrix("lightmapMatrix",this.lightmapTexture.getTextureMatrix())),this.specularTexture&&r.SpecularTextureEnabled&&(this._effect.setTexture("specularSampler",this.specularTexture),this._effect.setFloat2("vSpecularInfos",this.specularTexture.coordinatesIndex,this.specularTexture.level),this._effect.setMatrix("specularMatrix",this.specularTexture.getTextureMatrix())),this.bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._effect.setTexture("bumpSampler",this.bumpTexture),this._effect.setFloat3("vBumpInfos",this.bumpTexture.coordinatesIndex,1/this.bumpTexture.level,this.parallaxScaleBias),this._effect.setMatrix("bumpMatrix",this.bumpTexture.getTextureMatrix())),this.refractionTexture&&r.RefractionTextureEnabled){var s=1;this.refractionTexture.isCube?this._effect.setTexture("refractionCubeSampler",this.refractionTexture):(this._effect.setTexture("refraction2DSampler",this.refractionTexture),this._effect.setMatrix("refractionMatrix",this.refractionTexture.getReflectionTextureMatrix()),this.refractionTexture.depth&&(s=this.refractionTexture.depth)),this._effect.setFloat4("vRefractionInfos",this.refractionTexture.level,this.indexOfRefraction,s,this.invertRefractionY?-1:1)}this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}e.MaterialHelper.BindClipPlane(this._effect,o),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this._effect.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),this._defines.SPECULARTERM&&this._effect.setColor4("vSpecularColor",this.specularColor,this.specularPower),this._effect.setColor3("vEmissiveColor",this.emissiveColor)}o.getCachedMaterial()===this&&this.isFrozen||(this._effect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*n.visibility),o.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(o,n,this._effect,this._defines,this.maxSimultaneousLights),(o.fogEnabled&&n.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this.reflectionTexture||this.refractionTexture)&&this._effect.setMatrix("view",o.getViewMatrix()),e.MaterialHelper.BindFogParameters(o,n,this._effect),e.MaterialHelper.BindLogDepth(this._defines,this._effect,o),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect)),i.prototype.bind.call(this,t,n)},r.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.ambientTexture&&this.ambientTexture.animations&&this.ambientTexture.animations.length>0&&e.push(this.ambientTexture),this.opacityTexture&&this.opacityTexture.animations&&this.opacityTexture.animations.length>0&&e.push(this.opacityTexture),this.reflectionTexture&&this.reflectionTexture.animations&&this.reflectionTexture.animations.length>0&&e.push(this.reflectionTexture),this.emissiveTexture&&this.emissiveTexture.animations&&this.emissiveTexture.animations.length>0&&e.push(this.emissiveTexture),this.specularTexture&&this.specularTexture.animations&&this.specularTexture.animations.length>0&&e.push(this.specularTexture),this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this.lightmapTexture&&this.lightmapTexture.animations&&this.lightmapTexture.animations.length>0&&e.push(this.lightmapTexture),this.refractionTexture&&this.refractionTexture.animations&&this.refractionTexture.animations.length>0&&e.push(this.refractionTexture),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),e},r.prototype.dispose=function(e,t){t&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.ambientTexture&&this.ambientTexture.dispose(),this.opacityTexture&&this.opacityTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose(),this.emissiveTexture&&this.emissiveTexture.dispose(),this.specularTexture&&this.specularTexture.dispose(),this.bumpTexture&&this.bumpTexture.dispose(),this.lightmapTexture&&this.lightmapTexture.dispose(),this.refractionTexture&&this.refractionTexture.dispose(),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.dispose()),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone(function(){return new r(t,i.getScene())},this)},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse(function(){return new r(t.name,i)},t,i,n)},r.DiffuseTextureEnabled=!0,r.AmbientTextureEnabled=!0,r.OpacityTextureEnabled=!0,r.ReflectionTextureEnabled=!0,r.EmissiveTextureEnabled=!0,r.SpecularTextureEnabled=!0,r.BumpTextureEnabled=!0,r.FresnelEnabled=!0,r.LightmapTextureEnabled=!0,r.RefractionTextureEnabled=!0,r.ColorGradingTextureEnabled=!0,a([e.serializeAsTexture()],r.prototype,"diffuseTexture",void 0),a([e.serializeAsTexture()],r.prototype,"ambientTexture",void 0),a([e.serializeAsTexture()],r.prototype,"opacityTexture",void 0),a([e.serializeAsTexture()],r.prototype,"reflectionTexture",void 0),a([e.serializeAsTexture()],r.prototype,"emissiveTexture",void 0),a([e.serializeAsTexture()],r.prototype,"specularTexture",void 0),a([e.serializeAsTexture()],r.prototype,"bumpTexture",void 0),a([e.serializeAsTexture()],r.prototype,"lightmapTexture",void 0),a([e.serializeAsTexture()],r.prototype,"refractionTexture",void 0),a([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),a([e.serializeAsColor3("diffuse")],r.prototype,"diffuseColor",void 0),a([e.serializeAsColor3("specular")],r.prototype,"specularColor",void 0),a([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),a([e.serialize()],r.prototype,"specularPower",void 0),a([e.serialize()],r.prototype,"useAlphaFromDiffuseTexture",void 0),a([e.serialize()],r.prototype,"useEmissiveAsIllumination",void 0),a([e.serialize()],r.prototype,"linkEmissiveWithDiffuse",void 0),a([e.serialize()],r.prototype,"useReflectionFresnelFromSpecular",void 0),a([e.serialize()],r.prototype,"useSpecularOverAlpha",void 0),a([e.serialize()],r.prototype,"useReflectionOverAlpha",void 0),a([e.serialize()],r.prototype,"disableLighting",void 0),a([e.serialize()],r.prototype,"useParallax",void 0),a([e.serialize()],r.prototype,"useParallaxOcclusion",void 0),a([e.serialize()],r.prototype,"parallaxScaleBias",void 0),a([e.serialize()],r.prototype,"roughness",void 0),a([e.serialize()],r.prototype,"indexOfRefraction",void 0),a([e.serialize()],r.prototype,"invertRefractionY",void 0),a([e.serialize()],r.prototype,"useLightmapAsShadowmap",void 0),a([e.serializeAsFresnelParameters()],r.prototype,"diffuseFresnelParameters",void 0),a([e.serializeAsFresnelParameters()],r.prototype,"opacityFresnelParameters",void 0),a([e.serializeAsFresnelParameters()],r.prototype,"reflectionFresnelParameters",void 0),a([e.serializeAsFresnelParameters()],r.prototype,"refractionFresnelParameters",void 0),a([e.serializeAsFresnelParameters()],r.prototype,"emissiveFresnelParameters",void 0),a([e.serialize()],r.prototype,"useGlossinessFromSpecularMapAlpha",void 0),a([e.serialize()],r.prototype,"maxSimultaneousLights",void 0),a([e.serialize()],r.prototype,"invertNormalMapX",void 0),a([e.serialize()],r.prototype,"invertNormalMapY",void 0),a([e.serializeAsTexture()],r.prototype,"cameraColorGradingTexture",void 0),a([e.serializeAsColorCurves()],r.prototype,"cameraColorCurves",void 0),a([e.serialize()],r.prototype,"useLogarithmicDepth",null),r}(e.Material);e.StandardMaterial=i}(s||(s={})),function(e){var t=function(t){function i(e,i){t.call(this,e,i,!0),this.subMaterials=new Array,i.multiMaterials.push(this)}return c(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.isReady=function(e){for(var t=0;t<this.subMaterials.length;t++){if(this.subMaterials[t]&&!this.subMaterials[t].isReady(e))return!1}return!0},i.prototype.clone=function(e,t){for(var r=new i(e,this.getScene()),n=0;n<this.subMaterials.length;n++){var o;o=t?this.subMaterials[n].clone(e+"-"+this.subMaterials[n].name):this.subMaterials[n],r.subMaterials.push(o)}return r},i.prototype.serialize=function(){var t={};t.name=this.name,t.id=this.id,t.tags=e.Tags.GetTags(this),t.materials=[];for(var i=0;i<this.subMaterials.length;i++){var r=this.subMaterials[i];r?t.materials.push(r.id):t.materials.push(null)}return t},i}(e.Material);e.MultiMaterial=t}(s||(s={})),function(e){var t=function(){function t(){}return Object.defineProperty(t,"NO_LOGGING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MINIMAL_LOGGING",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SUMMARY_LOGGING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(t,"DETAILED_LOGGING",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ForceFullSceneLoadingForIncremental",{get:function(){return t._ForceFullSceneLoadingForIncremental},set:function(e){t._ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ShowLoadingScreen",{get:function(){return t._ShowLoadingScreen},set:function(e){t._ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"loggingLevel",{get:function(){return t._loggingLevel},set:function(e){t._loggingLevel=e},enumerable:!0,configurable:!0}),t._getDefaultPlugin=function(){return t._registeredPlugins[".babylon"]},t._getPluginForExtension=function(e){var i=t._registeredPlugins[e];return i||t._getDefaultPlugin()},t._getPluginForFilename=function(e){e.name&&(e=e.name);var i=e.lastIndexOf("."),r=e.indexOf("?");-1===r&&(r=e.length);var n=e.substring(i,r).toLowerCase();return t._getPluginForExtension(n)},t._getDirectLoad=function(e){return e.substr&&"data:"===e.substr(0,5)?e.substr(5):null},t.GetPluginForExtension=function(e){return t._getPluginForExtension(e).plugin},t.RegisterPlugin=function(e){if("string"==typeof e.extensions){var i=e.extensions;t._registeredPlugins[i.toLowerCase()]={plugin:e,isBinary:!1}}else{var r=e.extensions;Object.keys(r).forEach(function(i){t._registeredPlugins[i.toLowerCase()]={plugin:e,isBinary:r[i].isBinary}})}},t.ImportMesh=function(i,r,n,o,s,a,c){if(n.substr&&"/"===n.substr(0,1))e.Tools.Error("Wrong sceneFilename parameter");else if(n.substr&&"/"===n.substr(0,1))e.Tools.Error("Wrong sceneFilename parameter");else{var h=t._getDirectLoad(n),u={};o._addPendingData(u);var l=function(l){o.database=f;var d=h?t._getDefaultPlugin():t._getPluginForFilename(n),p=d.plugin,m=d.isBinary,g=function(e){var t=[],a=[],h=[];try{if(p.importMesh){if(!p.importMesh(i,o,e,r,t,a,h))return c&&c(o,"Unable to import meshes from "+r+n),void o._removePendingData(u);s&&(o.importedMeshesFiles.push(r+n),s(t,a,h),o._removePendingData(u))}else{p.importMeshAsync(i,o,e,r,function(e,t,i){s&&(o.importedMeshesFiles.push(r+n),s(e,t,i),o._removePendingData(u))},function(){c&&c(o,"Unable to import meshes from "+r+n),o._removePendingData(u)})}}catch(e){c&&c(o,"Unable to import meshes from "+r+n,e),o._removePendingData(u)}};return h?void g(h):void e.Tools.LoadFile(r+n,function(e){g(e)},a,f,m)};if(o.getEngine().enableOfflineSupport&&!h)var f=new e.Database(r+n,l);else l()}},t.Load=function(i,r,n,o,s,a){t.Append(i,r,new e.Scene(n),o,s,a)},t.Append=function(i,r,n,o,s,a){if(!r.substr||"/"!==r.substr(0,1)){var c,h=t._getDirectLoad(r),u=h?t._getDefaultPlugin():t._getPluginForFilename(r),l=u.plugin,f=u.isBinary,d={};n._addPendingData(d),t.ShowLoadingScreen&&n.getEngine().displayLoadingUI();var p=function(e){if(n.database=c,l.load){if(!l.load(n,e,i))return a&&a(n),n._removePendingData(d),void n.getEngine().hideLoadingUI();o&&o(n),n._removePendingData(d)}else{l.loadAsync(n,e,i,function(){o&&o(n),n._removePendingData(d)},function(){a&&a(n),n._removePendingData(d),n.getEngine().hideLoadingUI()})}t.ShowLoadingScreen&&n.executeWhenReady(function(){n.getEngine().hideLoadingUI()})},m=function(t){e.Tools.LoadFile(i+r,p,s,c,f)};return h?void p(h):void(-1===i.indexOf("file:")?n.getEngine().enableOfflineSupport?c=new e.Database(i+r,m):m():e.Tools.ReadFile(r,p,s,f))}e.Tools.Error("Wrong sceneFilename parameter")},t._ForceFullSceneLoadingForIncremental=!1,t._ShowLoadingScreen=!0,t._loggingLevel=t.NO_LOGGING,t._registeredPlugins={},t}();e.SceneLoader=t}(s||(s={})),function(e){var t,i,r;e.Internals||(e.Internals={}),t=function(t,i,r,n){for(var o=0,s=i.materials.length;o<s;o++){var a=i.materials[o];if(a.id===t)return e.Material.Parse(a,r,n)}return null},i=function(e,t,i){for(var r in t=t instanceof Array?t:[t])if(e.name===t[r])return i.push(e.id),!0;return!(!e.parentId||-1===i.indexOf(e.parentId)||(i.push(e.id),0))},r=function(e,t){return e+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")},e.SceneLoader.RegisterPlugin({extensions:".babylon",importMesh:function(n,o,s,a,c,h,u){var l="importMesh has failed JSON parse";try{var f=JSON.parse(s);l="";var d,p,m,g=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING,_=[],v=[],y=[];for(d=0,p=f.meshes.length;d<p;d++){var b=f.meshes[d];if(!n||i(b,n,y)){if(n instanceof Array&&delete n[n.indexOf(b.name)],b.geometryId&&f.geometries){var x=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach(function(t){!x&&f.geometries[t]&&f.geometries[t]instanceof Array&&f.geometries[t].forEach(function(i){if(i.id===b.geometryId){switch(t){case"boxes":e.Geometry.Primitives.Box.Parse(i,o);break;case"spheres":e.Geometry.Primitives.Sphere.Parse(i,o);break;case"cylinders":e.Geometry.Primitives.Cylinder.Parse(i,o);break;case"toruses":e.Geometry.Primitives.Torus.Parse(i,o);break;case"grounds":e.Geometry.Primitives.Ground.Parse(i,o);break;case"planes":e.Geometry.Primitives.Plane.Parse(i,o);break;case"torusKnots":e.Geometry.Primitives.TorusKnot.Parse(i,o);break;case"vertexData":e.Geometry.Parse(i,o,a)}x=!0}})}),x||e.Tools.Warn("Geometry not found for mesh "+b.id)}if(b.materialId){var w=-1!==v.indexOf(b.materialId);if(!w&&f.multiMaterials)for(var S=0,T=f.multiMaterials.length;S<T;S++){var A=f.multiMaterials[S];if(A.id===b.materialId){for(var M=0,E=A.materials.length;M<E;M++){var P,C=A.materials[M];v.push(C),l+="\n\tMaterial "+(P=t(C,f,o,a)).toString(g)}v.push(A.id);var R=e.Material.ParseMultiMaterial(A,o);w=!0,l+="\n\tMulti-Material "+R.toString(g);break}}w||(v.push(b.materialId),(P=t(b.materialId,f,o,a))?l+="\n\tMaterial "+P.toString(g):e.Tools.Warn("Material not found for mesh "+b.id))}if(b.skeletonId>-1&&o.skeletons&&!(_.indexOf(b.skeletonId)>-1))for(var I=0,D=f.skeletons.length;I<D;I++){var O=f.skeletons[I];if(O.id===b.skeletonId){var L=e.Skeleton.Parse(O,o);u.push(L),_.push(O.id),l+="\n\tSkeleton "+L.toString(g)}}var F=e.Mesh.Parse(b,o,a);c.push(F),l+="\n\tMesh "+F.toString(g)}}for(d=0,p=o.meshes.length;d<p;d++)(m=o.meshes[d])._waitingParentId&&(m.parent=o.getLastEntryByID(m._waitingParentId),m._waitingParentId=void 0);for(d=0,p=o.meshes.length;d<p;d++)(m=o.meshes[d])._waitingFreezeWorldMatrix?(m.freezeWorldMatrix(),m._waitingFreezeWorldMatrix=void 0):m.computeWorldMatrix(!0);if(f.particleSystems)for(d=0,p=f.particleSystems.length;d<p;d++){var B=f.particleSystems[d];-1!==y.indexOf(B.emitterId)&&h.push(e.ParticleSystem.Parse(B,o,a))}return!0}catch(t){throw e.Tools.Log(r("importMesh",f?f.producer:"Unknown")+l),l=null,t}finally{null!==l&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(r("importMesh",f?f.producer:"Unknown")+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?l:""))}},load:function(t,i,n){var o="importScene has failed JSON parse";try{var s=JSON.parse(i);o="";var a,c,h=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING;if(t.useDelayedTextureLoading=s.useDelayedTextureLoading&&!e.SceneLoader.ForceFullSceneLoadingForIncremental,t.autoClear=s.autoClear,t.clearColor=e.Color4.FromArray(s.clearColor),t.ambientColor=e.Color3.FromArray(s.ambientColor),s.gravity&&(t.gravity=e.Vector3.FromArray(s.gravity)),s.fogMode&&0!==s.fogMode)switch(t.fogMode=s.fogMode,t.fogColor=e.Color3.FromArray(s.fogColor),t.fogStart=s.fogStart,t.fogEnd=s.fogEnd,t.fogDensity=s.fogDensity,o+="\tFog mode for scene: ",t.fogMode){case 1:o+="exp\n";break;case 2:o+="exp2\n";break;case 3:o+="linear\n"}if(s.physicsEnabled){var u;"cannon"===s.physicsEngine?u=new e.CannonJSPlugin:"oimo"===s.physicsEngine&&(u=new e.OimoJSPlugin),o="\tPhysics engine "+(s.physicsEngine?s.physicsEngine:"oimo")+" enabled\n";var l=s.physicsGravity?e.Vector3.FromArray(s.physicsGravity):null;t.enablePhysics(l,u)}for(void 0!==s.metadata&&(t.metadata=s.metadata),null!=s.collisionsEnabled&&(t.collisionsEnabled=s.collisionsEnabled),t.workerCollisions=!!s.workerCollisions,a=0,c=s.lights.length;a<c;a++){var f=s.lights[a],d=e.Light.Parse(f,t);o+=0===a?"\n\tLights:":"",o+="\n\t\t"+d.toString(h)}if(s.animations)for(a=0,c=s.animations.length;a<c;a++){var p=s.animations[a],m=e.Animation.Parse(p);t.animations.push(m),o+=0===a?"\n\tAnimations:":"",o+="\n\t\t"+m.toString(h)}if(s.autoAnimate&&t.beginAnimation(t,s.autoAnimateFrom,s.autoAnimateTo,s.autoAnimateLoop,s.autoAnimateSpeed||1),s.materials)for(a=0,c=s.materials.length;a<c;a++){var g=s.materials[a],_=e.Material.Parse(g,t,n);o+=0===a?"\n\tMaterials:":"",o+="\n\t\t"+_.toString(h)}if(s.multiMaterials)for(a=0,c=s.multiMaterials.length;a<c;a++){var v=s.multiMaterials[a],y=e.Material.ParseMultiMaterial(v,t);o+=0===a?"\n\tMultiMaterials:":"",o+="\n\t\t"+y.toString(h)}if(s.skeletons)for(a=0,c=s.skeletons.length;a<c;a++){var b=s.skeletons[a],x=e.Skeleton.Parse(b,t);o+=0===a?"\n\tSkeletons:":"",o+="\n\t\t"+x.toString(h)}var w=s.geometries;if(w){var S=w.boxes;if(S)for(a=0,c=S.length;a<c;a++){var T=S[a];e.Geometry.Primitives.Box.Parse(T,t)}var A=w.spheres;if(A)for(a=0,c=A.length;a<c;a++){var M=A[a];e.Geometry.Primitives.Sphere.Parse(M,t)}var E=w.cylinders;if(E)for(a=0,c=E.length;a<c;a++){var P=E[a];e.Geometry.Primitives.Cylinder.Parse(P,t)}var C=w.toruses;if(C)for(a=0,c=C.length;a<c;a++){var R=C[a];e.Geometry.Primitives.Torus.Parse(R,t)}var I=w.grounds;if(I)for(a=0,c=I.length;a<c;a++){var D=I[a];e.Geometry.Primitives.Ground.Parse(D,t)}var O=w.planes;if(O)for(a=0,c=O.length;a<c;a++){var L=O[a];e.Geometry.Primitives.Plane.Parse(L,t)}var F=w.torusKnots;if(F)for(a=0,c=F.length;a<c;a++){var B=F[a];e.Geometry.Primitives.TorusKnot.Parse(B,t)}var k=w.vertexData;if(k)for(a=0,c=k.length;a<c;a++){var V=k[a];e.Geometry.Parse(V,t,n)}}for(a=0,c=s.meshes.length;a<c;a++){var N=s.meshes[a],z=e.Mesh.Parse(N,t,n);o+=0===a?"\n\tMeshes:":"",o+="\n\t\t"+z.toString(h)}for(a=0,c=s.cameras.length;a<c;a++){var U=s.cameras[a],G=e.Camera.Parse(U,t);o+=0===a?"\n\tCameras:":"",o+="\n\t\t"+G.toString(h)}for(s.activeCameraID&&t.setActiveCameraByID(s.activeCameraID),a=0,c=t.cameras.length;a<c;a++)(G=t.cameras[a])._waitingParentId&&(G.parent=t.getLastEntryByID(G._waitingParentId),G._waitingParentId=void 0);for(a=0,c=t.lights.length;a<c;a++)(d=t.lights[a])._waitingParentId&&(d.parent=t.getLastEntryByID(d._waitingParentId),d._waitingParentId=void 0);var W,j=[];if(e.AudioEngine&&s.sounds)for(a=0,c=s.sounds.length;a<c;a++){var H=s.sounds[a];e.Engine.audioEngine.canUseWebAudio?(H.url||(H.url=H.name),j[H.url]?e.Sound.Parse(H,t,n,j[H.url]):(W=e.Sound.Parse(H,t,n),j[H.url]=W)):new e.Sound(H.name,null,t)}for(j=[],a=0,c=t.meshes.length;a<c;a++)(z=t.meshes[a])._waitingParentId&&(z.parent=t.getLastEntryByID(z._waitingParentId),z._waitingParentId=void 0),z._waitingActions&&(e.ActionManager.Parse(z._waitingActions,z,t),z._waitingActions=void 0);for(a=0,c=t.meshes.length;a<c;a++){var X=t.meshes[a];X._waitingFreezeWorldMatrix?(X.freezeWorldMatrix(),X._waitingFreezeWorldMatrix=void 0):X.computeWorldMatrix(!0)}if(s.particleSystems)for(a=0,c=s.particleSystems.length;a<c;a++){var Y=s.particleSystems[a];e.ParticleSystem.Parse(Y,t,n)}if(s.lensFlareSystems)for(a=0,c=s.lensFlareSystems.length;a<c;a++){var K=s.lensFlareSystems[a];e.LensFlareSystem.Parse(K,t,n)}if(s.shadowGenerators)for(a=0,c=s.shadowGenerators.length;a<c;a++){var q=s.shadowGenerators[a];e.ShadowGenerator.Parse(q,t)}return s.actions&&e.ActionManager.Parse(s.actions,null,t),!0}catch(t){throw e.Tools.Log(r("importScene",s?s.producer:"Unknown")+o),o=null,t}finally{null!==o&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(r("importScene",s?s.producer:"Unknown")+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?o:""))}}})}(s||(s={})),function(e){var t=function(){function t(t,i,r,n,o,s,a){if(void 0===s&&(s=.01),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this.onDisposeObservable=new e.Observable,this._vertexBuffers={},this._capacity=r,this._spriteTexture=new e.Texture(i,o,!0,!1,a),this._spriteTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.width&&n.height)this.cellWidth=n.width,this.cellHeight=n.height;else{if(void 0===n)return;this.cellWidth=n,this.cellHeight=n}this._epsilon=s,this._scene=o,this._scene.spriteManagers.push(this);for(var c=[],h=0,u=0;u<r;u++)c.push(h),c.push(h+1),c.push(h+2),c.push(h),c.push(h+2),c.push(h+3),h+=4;this._indexBuffer=o.getEngine().createIndexBuffer(c),this._vertexData=new Float32Array(16*r*4),this._buffer=new e.Buffer(o.getEngine(),this._vertexData,!0,16);var l=this._buffer.createVertexBuffer(e.VertexBuffer.PositionKind,0,4),f=this._buffer.createVertexBuffer("options",4,4),d=this._buffer.createVertexBuffer("cellInfo",8,4),p=this._buffer.createVertexBuffer(e.VertexBuffer.ColorKind,12,4);this._vertexBuffers[e.VertexBuffer.PositionKind]=l,this._vertexBuffers.options=f,this._vertexBuffers.cellInfo=d,this._vertexBuffers[e.VertexBuffer.ColorKind]=p,this._effectBase=this._scene.getEngine().createEffect("sprites",[e.VertexBuffer.PositionKind,"options","cellInfo",e.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._effectFog=this._scene.getEngine().createEffect("sprites",[e.VertexBuffer.PositionKind,"options","cellInfo",e.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG")}return Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"texture",{get:function(){return this._spriteTexture},set:function(e){this._spriteTexture=e},enumerable:!0,configurable:!0}),t.prototype._appendSpriteVertex=function(e,t,i,r,n){var o=16*e;0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),this._vertexData[o]=t.position.x,this._vertexData[o+1]=t.position.y,this._vertexData[o+2]=t.position.z,this._vertexData[o+3]=t.angle,this._vertexData[o+4]=t.width,this._vertexData[o+5]=t.height,this._vertexData[o+6]=i,this._vertexData[o+7]=r,this._vertexData[o+8]=t.invertU?1:0,this._vertexData[o+9]=t.invertV?1:0;var s=t.cellIndex/n>>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o,s=Math.min(this._capacity,this.sprites.length),a=e.Vector3.Zero(),c=e.Vector3.Zero(),h=Number.MAX_VALUE,u=e.Vector3.Zero(),l=i.getViewMatrix(),f=0;f<s;f++){var d=this.sprites[f];if(d){if(r){if(!r(d))continue}else if(!d.isPickable)continue;if(e.Vector3.TransformCoordinatesToRef(d.position,l,u),a.copyFromFloats(u.x-d.width/2,u.y-d.height/2,u.z),c.copyFromFloats(u.x+d.width/2,u.y+d.height/2,u.z),t.intersectsBoxMinMax(a,c)){var p=e.Vector3.Distance(u,t.origin);if(h>p&&(h=p,o=d,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=h,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&thi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment