UNPKG

r3f-globe

Version:

React Three Fiber component for Globe Data Visualization

21 lines 1.22 MB
// Version 1.5.0 r3f-globe - https://github.com/vasturiano/r3f-globe
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("three")):"function"==typeof define&&define.amd?define(["react","three"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).R3fGlobe=t(e.React,e.THREE)}(this,function(e,t){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function i(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){if(e){if("string"==typeof e)return r(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(e,t):void 0}}function A(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var u="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,c=u||h||Function("return this")(),d=function(){return c.Date.now()},p=/\s/;var f=/^\s+/;function m(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&p.test(e.charAt(t)););return t}(e)+1).replace(f,""):e}var g=c.Symbol,y=Object.prototype,b=y.hasOwnProperty,x=y.toString,v=g?g.toStringTag:void 0;var _=Object.prototype.toString;var w=g?g.toStringTag:void 0;function T(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":w&&w in Object(e)?function(e){var t=b.call(e,v),r=e[v];try{e[v]=void 0;var i=!0}catch(e){}var n=x.call(e);return i&&(t?e[v]=r:delete e[v]),n}(e):function(e){return _.call(e)}(e)}var M=/^[-+]0x[0-9a-f]+$/i,S=/^0b[01]+$/i,E=/^0o[0-7]+$/i,N=parseInt;function C(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==T(e)}(e))return NaN;if(A(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=A(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=m(e);var r=S.test(e);return r||E.test(e)?N(e.slice(2),r?2:8):M.test(e)?NaN:+e}var R=Math.max,B=Math.min;function P(e,t,r){var i,n,s,a,o,l,u=0,h=!1,c=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var r=i,s=n;return i=n=void 0,u=t,a=e.apply(s,r)}function m(e){var r=e-l;return void 0===l||r>=t||r<0||c&&e-u>=s}function g(){var e=d();if(m(e))return y(e);o=setTimeout(g,function(e){var r=t-(e-l);return c?B(r,s-(e-u)):r}(e))}function y(e){return o=void 0,p&&i?f(e):(i=n=void 0,a)}function b(){var e=d(),r=m(e);if(i=arguments,n=this,l=e,r){if(void 0===o)return function(e){return u=e,o=setTimeout(g,t),h?f(e):a}(l);if(c)return clearTimeout(o),o=setTimeout(g,t),f(l)}return void 0===o&&(o=setTimeout(g,t)),a}return t=C(t)||0,A(r)&&(h=!!r.leading,s=(c="maxWait"in r)?R(C(r.maxWait)||0,t):s,p="trailing"in r?!!r.trailing:p),b.cancel=function(){void 0!==o&&clearTimeout(o),u=0,i=l=n=o=void 0},b.flush=function(){return void 0===o?a:y(d())},b}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function D(e,t,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t);else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return q(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var F=D(function e(t,r){var i=r.default,n=void 0===i?null:i,s=r.triggerUpdate,a=void 0===s||s,o=r.onChange,l=void 0===o?function(e,t){}:o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name=t,this.defaultVal=n,this.triggerUpdate=a,this.onChange=l});function O(e){var t=e.stateInit,r=void 0===t?function(){return{}}:t,i=e.props,n=void 0===i?{}:i,s=e.methods,a=void 0===s?{}:s,o=e.aliases,l=void 0===o?{}:o,A=e.init,u=void 0===A?function(){}:A,h=e.update,c=void 0===h?function(){}:h,d=Object.keys(n).map(function(e){return new F(e,n[e])});return function e(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var s=!!(this instanceof e?this.constructor:void 0),o=s?i.shift():void 0,A=i[0],h=void 0===A?{}:A,p=Object.assign({},r instanceof Function?r(h):r,{initialised:!1}),f={};function m(e){return g(e,h),y(),m}var g=function(e,t){u.call(m,e,p,t),p.initialised=!0},y=P(function(){p.initialised&&(c.call(m,p,f),f={})},1);return d.forEach(function(e){m[e.name]=function(e){var t=e.name,r=e.triggerUpdate,i=void 0!==r&&r,n=e.onChange,s=void 0===n?function(e,t){}:n,a=e.defaultVal,o=void 0===a?null:a;return function(e){var r=p[t];if(!arguments.length)return r;var n=void 0===e?o:e;return p[t]=n,s.call(m,n,p,r),!f.hasOwnProperty(t)&&(f[t]=r),i&&y(),m}}(e)}),Object.keys(a).forEach(function(e){m[e]=function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return(t=a[e]).call.apply(t,[m,p].concat(i))}}),Object.entries(l).forEach(function(e){var t=I(e,2),r=t[0],i=t[1];return m[r]=m[i]}),m.resetProps=function(){return d.forEach(function(e){m[e.name](e.defaultVal)}),m},m.resetProps(),p._rerender=y,s&&o&&m(o),m}}var L=Object.freeze({Linear:Object.freeze({None:function(e){return e},In:function(e){return e},Out:function(e){return e},InOut:function(e){return e}}),Quadratic:Object.freeze({In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}}),Cubic:Object.freeze({In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}}),Quartic:Object.freeze({In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}}),Quintic:Object.freeze({In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}}),Sinusoidal:Object.freeze({In:function(e){return 1-Math.sin((1-e)*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.sin(Math.PI*(.5-e)))}}),Exponential:Object.freeze({In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))}}),Circular:Object.freeze({In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}}),Elastic:Object.freeze({In:function(e){return 0===e?0:1===e?1:-Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)},Out:function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(5*(e-.1)*Math.PI)+1},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?-.5*Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(e){var t=1.70158;return 1===e?1:e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return 0===e?0:--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)}}),Bounce:Object.freeze({In:function(e){return 1-L.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?.5*L.Bounce.In(2*e):.5*L.Bounce.Out(2*e-1)+.5}}),generatePow:function(e){return void 0===e&&(e=4),e=(e=e<Number.EPSILON?Number.EPSILON:e)>1e4?1e4:e,{In:function(t){return Math.pow(t,e)},Out:function(t){return 1-Math.pow(1-t,e)},InOut:function(t){return t<.5?Math.pow(2*t,e)/2:(1-Math.pow(2-2*t,e))/2+.5}}}}),k=function(){return performance.now()},V=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var i=0,n=t;i<n.length;i++){var s=n[i];null===(e=s._group)||void 0===e||e.remove(s),s._group=this,this._tweens[s.getId()]=s,this._tweensAddedDuringUpdate[s.getId()]=s}},e.prototype.remove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=0,i=e;r<i.length;r++){var n=i[r];n._group=void 0,delete this._tweens[n.getId()],delete this._tweensAddedDuringUpdate[n.getId()]}},e.prototype.allStopped=function(){return this.getAll().every(function(e){return!e.isPlaying()})},e.prototype.update=function(e,t){void 0===e&&(e=k()),void 0===t&&(t=!0);var r=Object.keys(this._tweens);if(0!==r.length)for(;r.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<r.length;i++){var n=this._tweens[r[i]],s=!t;n&&!1===n.update(e,s)&&!t&&this.remove(n)}r=Object.keys(this._tweensAddedDuringUpdate)}},e}(),U={Linear:function(e,t){var r=e.length-1,i=r*t,n=Math.floor(i),s=U.Utils.Linear;return t<0?s(e[0],e[1],i):t>1?s(e[r],e[r-1],r-i):s(e[n],e[n+1>r?r:n+1],i-n)},Utils:{Linear:function(e,t,r){return(t-e)*r+e}}},z=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),G=new V,j=function(){function e(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=L.Linear.None,this._interpolationFunction=U.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=z.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,"object"==typeof t?(this._group=t,t.add(this)):!0===t&&(this._group=G,G.add(this))}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(e,t){if(void 0===t&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},e.prototype.duration=function(e){return void 0===e&&(e=1e3),this._duration=e<0?0:e,this},e.prototype.dynamic=function(e){return void 0===e&&(e=!1),this._isDynamic=e,this},e.prototype.start=function(e,t){if(void 0===e&&(e=k()),void 0===t&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var r in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var n in this._valuesEnd)i[n]=this._valuesEnd[n];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,r,i,n){for(var s in r){var a=e[s],o=Array.isArray(a),l=o?"array":typeof a,A=!o&&Array.isArray(r[s]);if("undefined"!==l&&"function"!==l){if(A){if(0===(m=r[s]).length)continue;for(var u=[a],h=0,c=m.length;h<c;h+=1){var d=this._handleRelativeValue(a,m[h]);if(isNaN(d)){A=!1,console.warn("Found invalid interpolation list. Skipping.");break}u.push(d)}A&&(r[s]=u)}if("object"!==l&&!o||!a||A)(void 0===t[s]||n)&&(t[s]=a),o||(t[s]*=1),i[s]=A?r[s].slice().reverse():t[s]||0;else{t[s]=o?[]:{};var p=a;for(var f in p)t[s][f]=p[f];i[s]=o?[]:{};var m=r[s];if(!this._isDynamic){var g={};for(var f in m)g[f]=m[f];r[s]=m=g}this._setupProperties(p,t[s],m,i[s],n)}}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},e.prototype.pause=function(e){return void 0===e&&(e=k()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=e),this},e.prototype.resume=function(e){return void 0===e&&(e=k()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this):this},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return e?(e.add(this),this):(console.warn("tween.group() without args has been removed, use group.add(tween) instead."),this)},e.prototype.remove=function(){var e;return null===(e=this._group)||void 0===e||e.remove(this),this},e.prototype.delay=function(e){return void 0===e&&(e=0),this._delayTime=e,this},e.prototype.repeat=function(e){return void 0===e&&(e=0),this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return void 0===e&&(e=!1),this._yoyo=e,this},e.prototype.easing=function(e){return void 0===e&&(e=L.Linear.None),this._easingFunction=e,this},e.prototype.interpolation=function(e){return void 0===e&&(e=U.Linear),this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(t,r){var i,n,s=this;if(void 0===t&&(t=k()),void 0===r&&(r=e.autoStartOnUpdate),this._isPaused)return!0;if(!this._goToEnd&&!this._isPlaying){if(!r)return!1;this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),!1===this._onEveryStartCallbackFired&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=t-this._startTime,o=this._duration+(null!==(i=this._repeatDelayTime)&&void 0!==i?i:this._delayTime),l=this._duration+this._repeat*o,A=function(){if(0===s._duration)return 1;if(a>l)return 1;var e=Math.trunc(a/o),t=a-e*o,r=Math.min(t/s._duration,1);return 0===r&&a===s._duration?1:r}(),u=this._easingFunction(A);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,u),this._onUpdateCallback&&this._onUpdateCallback(this._object,A),0===this._duration||a>=this._duration){if(this._repeat>0){var h=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(n in isFinite(this._repeat)&&(this._repeat-=h),this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var c=0,d=this._chainedTweens.length;c<d;c++)this._chainedTweens[c].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,r,i){for(var n in r)if(void 0!==t[n]){var s=t[n]||0,a=r[n],o=Array.isArray(e[n]),l=Array.isArray(a);!o&&l?e[n]=this._interpolationFunction(a,i):"object"==typeof a&&a?this._updateProperties(e[n],s,a,i):"number"==typeof(a=this._handleRelativeValue(s,a))&&(e[n]=s+(a-s)*i)}},e.prototype._handleRelativeValue=function(e,t){return"string"!=typeof t?t:"+"===t.charAt(0)||"-"===t.charAt(0)?e+parseFloat(t):parseFloat(t)},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],r=this._valuesEnd[e];this._valuesStartRepeat[e]="string"==typeof r?this._valuesStartRepeat[e]+parseFloat(r):this._valuesEnd[e],this._valuesEnd[e]=t},e.autoStartOnUpdate=!1,e}();z.nextId;var H=G;function W(e,t,r,i,n){if(isNaN(t)||isNaN(r)||isNaN(i))return e;var s,a,o,l,A,u,h,c,d,p,f,m,g=e._root,y={data:n},b=e._x0,x=e._y0,v=e._z0,_=e._x1,w=e._y1,T=e._z1;if(!g)return e._root=y,e;for(;g.length;)if((c=t>=(a=(b+_)/2))?b=a:_=a,(d=r>=(o=(x+w)/2))?x=o:w=o,(p=i>=(l=(v+T)/2))?v=l:T=l,s=g,!(g=g[f=p<<2|d<<1|c]))return s[f]=y,e;if(A=+e._x.call(null,g.data),u=+e._y.call(null,g.data),h=+e._z.call(null,g.data),t===A&&r===u&&i===h)return y.next=g,s?s[f]=y:e._root=y,e;do{s=s?s[f]=new Array(8):e._root=new Array(8),(c=t>=(a=(b+_)/2))?b=a:_=a,(d=r>=(o=(x+w)/2))?x=o:w=o,(p=i>=(l=(v+T)/2))?v=l:T=l}while((f=p<<2|d<<1|c)==(m=(h>=l)<<2|(u>=o)<<1|A>=a));return s[m]=g,s[f]=y,e}function Q(e,t,r,i,n,s,a){this.node=e,this.x0=t,this.y0=r,this.z0=i,this.x1=n,this.y1=s,this.z1=a}H.getAll.bind(H),H.removeAll.bind(H),H.add.bind(H),H.remove.bind(H),H.update.bind(H);const $=(e,t,r,i,n,s)=>Math.sqrt((e-i)**2+(t-n)**2+(r-s)**2);function X(e){return e[0]}function Y(e){return e[1]}function K(e){return e[2]}function Z(e,t,r,i){var n=new J(null==t?X:t,null==r?Y:r,null==i?K:i,NaN,NaN,NaN,NaN,NaN,NaN);return null==e?n:n.addAll(e)}function J(e,t,r,i,n,s,a,o,l){this._x=e,this._y=t,this._z=r,this._x0=i,this._y0=n,this._z0=s,this._x1=a,this._y1=o,this._z1=l,this._root=void 0}function ee(e){for(var t={data:e.data},r=t;e=e.next;)r=r.next={data:e.data};return t}var te=Z.prototype=J.prototype;function re(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function ie(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ne(e){let t,r,i;function n(e,i,n=0,s=e.length){if(n<s){if(0!==t(i,i))return s;do{const t=n+s>>>1;r(e[t],i)<0?n=t+1:s=t}while(n<s)}return n}return 2!==e.length?(t=re,r=(t,r)=>re(e(t),r),i=(t,r)=>e(t)-r):(t=e===re||e===ie?e:se,r=e,i=e),{left:n,center:function(e,t,r=0,s=e.length){const a=n(e,t,r,s-1);return a>r&&i(e[a-1],t)>-i(e[a],t)?a-1:a},right:function(e,i,n=0,s=e.length){if(n<s){if(0!==t(i,i))return s;do{const t=n+s>>>1;r(e[t],i)<=0?n=t+1:s=t}while(n<s)}return n}}}function se(){return 0}te.copy=function(){var e,t,r=new J(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),i=this._root;if(!i)return r;if(!i.length)return r._root=ee(i),r;for(e=[{source:i,target:r._root=new Array(8)}];i=e.pop();)for(var n=0;n<8;++n)(t=i.source[n])&&(t.length?e.push({source:t,target:i.target[n]=new Array(8)}):i.target[n]=ee(t));return r},te.add=function(e){const t=+this._x.call(null,e),r=+this._y.call(null,e),i=+this._z.call(null,e);return W(this.cover(t,r,i),t,r,i,e)},te.addAll=function(e){Array.isArray(e)||(e=Array.from(e));const t=e.length,r=new Float64Array(t),i=new Float64Array(t),n=new Float64Array(t);let s=1/0,a=1/0,o=1/0,l=-1/0,A=-1/0,u=-1/0;for(let h,c,d,p,f=0;f<t;++f)isNaN(c=+this._x.call(null,h=e[f]))||isNaN(d=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(r[f]=c,i[f]=d,n[f]=p,c<s&&(s=c),c>l&&(l=c),d<a&&(a=d),d>A&&(A=d),p<o&&(o=p),p>u&&(u=p));if(s>l||a>A||o>u)return this;this.cover(s,a,o).cover(l,A,u);for(let s=0;s<t;++s)W(this,r[s],i[s],n[s],e[s]);return this},te.cover=function(e,t,r){if(isNaN(e=+e)||isNaN(t=+t)||isNaN(r=+r))return this;var i=this._x0,n=this._y0,s=this._z0,a=this._x1,o=this._y1,l=this._z1;if(isNaN(i))a=(i=Math.floor(e))+1,o=(n=Math.floor(t))+1,l=(s=Math.floor(r))+1;else{for(var A,u,h=a-i||1,c=this._root;i>e||e>=a||n>t||t>=o||s>r||r>=l;)switch(u=(r<s)<<2|(t<n)<<1|e<i,(A=new Array(8))[u]=c,c=A,h*=2,u){case 0:a=i+h,o=n+h,l=s+h;break;case 1:i=a-h,o=n+h,l=s+h;break;case 2:a=i+h,n=o-h,l=s+h;break;case 3:i=a-h,n=o-h,l=s+h;break;case 4:a=i+h,o=n+h,s=l-h;break;case 5:i=a-h,o=n+h,s=l-h;break;case 6:a=i+h,n=o-h,s=l-h;break;case 7:i=a-h,n=o-h,s=l-h}this._root&&this._root.length&&(this._root=c)}return this._x0=i,this._y0=n,this._z0=s,this._x1=a,this._y1=o,this._z1=l,this},te.data=function(){var e=[];return this.visit(function(t){if(!t.length)do{e.push(t.data)}while(t=t.next)}),e},te.extent=function(e){return arguments.length?this.cover(+e[0][0],+e[0][1],+e[0][2]).cover(+e[1][0],+e[1][1],+e[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},te.find=function(e,t,r,i){var n,s,a,o,l,A,u,h,c,d=this._x0,p=this._y0,f=this._z0,m=this._x1,g=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new Q(x,d,p,f,m,g,y)),null==i?i=1/0:(d=e-i,p=t-i,f=r-i,m=e+i,g=t+i,y=r+i,i*=i);h=b.pop();)if(!(!(x=h.node)||(s=h.x0)>m||(a=h.y0)>g||(o=h.z0)>y||(l=h.x1)<d||(A=h.y1)<p||(u=h.z1)<f))if(x.length){var v=(s+l)/2,_=(a+A)/2,w=(o+u)/2;b.push(new Q(x[7],v,_,w,l,A,u),new Q(x[6],s,_,w,v,A,u),new Q(x[5],v,a,w,l,_,u),new Q(x[4],s,a,w,v,_,u),new Q(x[3],v,_,o,l,A,w),new Q(x[2],s,_,o,v,A,w),new Q(x[1],v,a,o,l,_,w),new Q(x[0],s,a,o,v,_,w)),(c=(r>=w)<<2|(t>=_)<<1|e>=v)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-c],b[b.length-1-c]=h)}else{var T=e-+this._x.call(null,x.data),M=t-+this._y.call(null,x.data),S=r-+this._z.call(null,x.data),E=T*T+M*M+S*S;if(E<i){var N=Math.sqrt(i=E);d=e-N,p=t-N,f=r-N,m=e+N,g=t+N,y=r+N,n=x.data}}return n},te.findAllWithinRadius=function(e,t,r,i){const n=[],s=e-i,a=t-i,o=r-i,l=e+i,A=t+i,u=r+i;return this.visit((h,c,d,p,f,m,g)=>{if(!h.length)do{const s=h.data;$(e,t,r,this._x(s),this._y(s),this._z(s))<=i&&n.push(s)}while(h=h.next);return c>l||d>A||p>u||f<s||m<a||g<o}),n},te.remove=function(e){if(isNaN(s=+this._x.call(null,e))||isNaN(a=+this._y.call(null,e))||isNaN(o=+this._z.call(null,e)))return this;var t,r,i,n,s,a,o,l,A,u,h,c,d,p,f,m=this._root,g=this._x0,y=this._y0,b=this._z0,x=this._x1,v=this._y1,_=this._z1;if(!m)return this;if(m.length)for(;;){if((h=s>=(l=(g+x)/2))?g=l:x=l,(c=a>=(A=(y+v)/2))?y=A:v=A,(d=o>=(u=(b+_)/2))?b=u:_=u,t=m,!(m=m[p=d<<2|c<<1|h]))return this;if(!m.length)break;(t[p+1&7]||t[p+2&7]||t[p+3&7]||t[p+4&7]||t[p+5&7]||t[p+6&7]||t[p+7&7])&&(r=t,f=p)}for(;m.data!==e;)if(i=m,!(m=m.next))return this;return(n=m.next)&&delete m.next,i?(n?i.next=n:delete i.next,this):t?(n?t[p]=n:delete t[p],(m=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&m===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!m.length&&(r?r[f]=m:this._root=m),this):(this._root=n,this)},te.removeAll=function(e){for(var t=0,r=e.length;t<r;++t)this.remove(e[t]);return this},te.root=function(){return this._root},te.size=function(){var e=0;return this.visit(function(t){if(!t.length)do{++e}while(t=t.next)}),e},te.visit=function(e){var t,r,i,n,s,a,o,l,A=[],u=this._root;for(u&&A.push(new Q(u,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=A.pop();)if(!e(u=t.node,i=t.x0,n=t.y0,s=t.z0,a=t.x1,o=t.y1,l=t.z1)&&u.length){var h=(i+a)/2,c=(n+o)/2,d=(s+l)/2;(r=u[7])&&A.push(new Q(r,h,c,d,a,o,l)),(r=u[6])&&A.push(new Q(r,i,c,d,h,o,l)),(r=u[5])&&A.push(new Q(r,h,n,d,a,c,l)),(r=u[4])&&A.push(new Q(r,i,n,d,h,c,l)),(r=u[3])&&A.push(new Q(r,h,c,s,a,o,d)),(r=u[2])&&A.push(new Q(r,i,c,s,h,o,d)),(r=u[1])&&A.push(new Q(r,h,n,s,a,c,d)),(r=u[0])&&A.push(new Q(r,i,n,s,h,c,d))}return this},te.visitAfter=function(e){var t,r=[],i=[];for(this._root&&r.push(new Q(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=r.pop();){var n=t.node;if(n.length){var s,a=t.x0,o=t.y0,l=t.z0,A=t.x1,u=t.y1,h=t.z1,c=(a+A)/2,d=(o+u)/2,p=(l+h)/2;(s=n[0])&&r.push(new Q(s,a,o,l,c,d,p)),(s=n[1])&&r.push(new Q(s,c,o,l,A,d,p)),(s=n[2])&&r.push(new Q(s,a,d,l,c,u,p)),(s=n[3])&&r.push(new Q(s,c,d,l,A,u,p)),(s=n[4])&&r.push(new Q(s,a,o,p,c,d,h)),(s=n[5])&&r.push(new Q(s,c,o,p,A,d,h)),(s=n[6])&&r.push(new Q(s,a,d,p,c,u,h)),(s=n[7])&&r.push(new Q(s,c,d,p,A,u,h))}i.push(t)}for(;t=i.pop();)e(t.node,t.x0,t.y0,t.z0,t.x1,t.y1,t.z1);return this},te.x=function(e){return arguments.length?(this._x=e,this):this._x},te.y=function(e){return arguments.length?(this._y=e,this):this._y},te.z=function(e){return arguments.length?(this._z=e,this):this._z};const ae=ne(re).right;function oe(e,t){let r,i;if(void 0===t)for(const t of e)null!=t&&(void 0===r?t>=t&&(r=i=t):(r>t&&(r=t),i<t&&(i=t)));else{let n=-1;for(let s of e)null!=(s=t(s,++n,e))&&(void 0===r?s>=s&&(r=i=s):(r>s&&(r=s),i<s&&(i=s)))}return[r,i]}ne(function(e){return null===e?NaN:+e}).center;class le{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const t=this._partials;let r=0;for(let i=0;i<this._n&&i<32;i++){const n=t[i],s=e+n,a=Math.abs(e)<Math.abs(n)?e-(s-n):n-(s-e);a&&(t[r++]=a),e=s}return t[r]=e,this._n=r+1,this}valueOf(){const e=this._partials;let t,r,i,n=this._n,s=0;if(n>0){for(s=e[--n];n>0&&(t=s,r=e[--n],s=t+r,i=r-(s-t),!i););n>0&&(i<0&&e[n-1]<0||i>0&&e[n-1]>0)&&(r=2*i,t=s+r,r==t-s&&(s=t))}return s}}const Ae=Math.sqrt(50),ue=Math.sqrt(10),he=Math.sqrt(2);function ce(e,t,r){const i=(t-e)/Math.max(0,r),n=Math.floor(Math.log10(i)),s=i/Math.pow(10,n),a=s>=Ae?10:s>=ue?5:s>=he?2:1;let o,l,A;return n<0?(A=Math.pow(10,-n)/a,o=Math.round(e*A),l=Math.round(t*A),o/A<e&&++o,l/A>t&&--l,A=-A):(A=Math.pow(10,n)*a,o=Math.round(e/A),l=Math.round(t/A),o*A<e&&++o,l*A>t&&--l),l<o&&.5<=r&&r<2?ce(e,t,2*r):[o,l,A]}function de(e,t,r){return ce(e=+e,t=+t,r=+r)[2]}function pe(e){return Array.from(function*(e){for(const t of e)yield*t}(e))}function fe(e,t,r){e=+e,t=+t,r=(n=arguments.length)<2?(t=e,e=0,1):n<3?1:+r;for(var i=-1,n=0|Math.max(0,Math.ceil((t-e)/r)),s=new Array(n);++i<n;)s[i]=e+i*r;return s}function me(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function ge(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function ye(e,t){var r=Object.create(e.prototype);for(var i in t)r[i]=t[i];return r}function be(){}var xe=.7,ve=1/xe,_e="\\s*([+-]?\\d+)\\s*",we="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Te="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Me=/^#([0-9a-f]{3,8})$/,Se=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),Ee=new RegExp(`^rgb\\(${Te},${Te},${Te}\\)$`),Ne=new RegExp(`^rgba\\(${_e},${_e},${_e},${we}\\)$`),Ce=new RegExp(`^rgba\\(${Te},${Te},${Te},${we}\\)$`),Re=new RegExp(`^hsl\\(${we},${Te},${Te}\\)$`),Be=new RegExp(`^hsla\\(${we},${Te},${Te},${we}\\)$`),Pe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function qe(){return this.rgb().formatHex()}function De(){return this.rgb().formatRgb()}function Ie(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=Me.exec(e))?(r=t[1].length,t=parseInt(t[1],16),6===r?Fe(t):3===r?new ke(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===r?Oe(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===r?Oe(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Se.exec(e))?new ke(t[1],t[2],t[3],1):(t=Ee.exec(e))?new ke(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Ne.exec(e))?Oe(t[1],t[2],t[3],t[4]):(t=Ce.exec(e))?Oe(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=Re.exec(e))?He(t[1],t[2]/100,t[3]/100,1):(t=Be.exec(e))?He(t[1],t[2]/100,t[3]/100,t[4]):Pe.hasOwnProperty(e)?Fe(Pe[e]):"transparent"===e?new ke(NaN,NaN,NaN,0):null}function Fe(e){return new ke(e>>16&255,e>>8&255,255&e,1)}function Oe(e,t,r,i){return i<=0&&(e=t=r=NaN),new ke(e,t,r,i)}function Le(e,t,r,i){return 1===arguments.length?((n=e)instanceof be||(n=Ie(n)),n?new ke((n=n.rgb()).r,n.g,n.b,n.opacity):new ke):new ke(e,t,r,null==i?1:i);var n}function ke(e,t,r,i){this.r=+e,this.g=+t,this.b=+r,this.opacity=+i}function Ve(){return`#${je(this.r)}${je(this.g)}${je(this.b)}`}function Ue(){const e=ze(this.opacity);return`${1===e?"rgb(":"rgba("}${Ge(this.r)}, ${Ge(this.g)}, ${Ge(this.b)}${1===e?")":`, ${e})`}`}function ze(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ge(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function je(e){return((e=Ge(e))<16?"0":"")+e.toString(16)}function He(e,t,r,i){return i<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Qe(e,t,r,i)}function We(e){if(e instanceof Qe)return new Qe(e.h,e.s,e.l,e.opacity);if(e instanceof be||(e=Ie(e)),!e)return new Qe;if(e instanceof Qe)return e;var t=(e=e.rgb()).r/255,r=e.g/255,i=e.b/255,n=Math.min(t,r,i),s=Math.max(t,r,i),a=NaN,o=s-n,l=(s+n)/2;return o?(a=t===s?(r-i)/o+6*(r<i):r===s?(i-t)/o+2:(t-r)/o+4,o/=l<.5?s+n:2-s-n,a*=60):o=l>0&&l<1?0:a,new Qe(a,o,l,e.opacity)}function Qe(e,t,r,i){this.h=+e,this.s=+t,this.l=+r,this.opacity=+i}function $e(e){return(e=(e||0)%360)<0?e+360:e}function Xe(e){return Math.max(0,Math.min(1,e||0))}function Ye(e,t,r){return 255*(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)}ge(be,Ie,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:qe,formatHex:qe,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return We(this).formatHsl()},formatRgb:De,toString:De}),ge(ke,Le,ye(be,{brighter(e){return e=null==e?ve:Math.pow(ve,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?xe:Math.pow(xe,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(Ge(this.r),Ge(this.g),Ge(this.b),ze(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ve,formatHex:Ve,formatHex8:function(){return`#${je(this.r)}${je(this.g)}${je(this.b)}${je(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ue,toString:Ue})),ge(Qe,function(e,t,r,i){return 1===arguments.length?We(e):new Qe(e,t,r,null==i?1:i)},ye(be,{brighter(e){return e=null==e?ve:Math.pow(ve,e),new Qe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?xe:Math.pow(xe,e),new Qe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,i=r+(r<.5?r:1-r)*t,n=2*r-i;return new ke(Ye(e>=240?e-240:e+120,n,i),Ye(e,n,i),Ye(e<120?e+240:e-120,n,i),this.opacity)},clamp(){return new Qe($e(this.h),Xe(this.s),Xe(this.l),ze(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ze(this.opacity);return`${1===e?"hsl(":"hsla("}${$e(this.h)}, ${100*Xe(this.s)}%, ${100*Xe(this.l)}%${1===e?")":`, ${e})`}`}}));var Ke=e=>()=>e;function Ze(e){return 1===(e=+e)?Je:function(t,r){return r-t?function(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(i){return Math.pow(e+i*t,r)}}(t,r,e):Ke(isNaN(t)?r:t)}}function Je(e,t){var r=t-e;return r?function(e,t){return function(r){return e+r*t}}(e,r):Ke(isNaN(e)?t:e)}var et=function e(t){var r=Ze(t);function i(e,t){var i=r((e=Le(e)).r,(t=Le(t)).r),n=r(e.g,t.g),s=r(e.b,t.b),a=Je(e.opacity,t.opacity);return function(t){return e.r=i(t),e.g=n(t),e.b=s(t),e.opacity=a(t),e+""}}return i.gamma=e,i}(1);function tt(e,t){t||(t=[]);var r,i=e?Math.min(t.length,e.length):0,n=t.slice();return function(s){for(r=0;r<i;++r)n[r]=e[r]*(1-s)+t[r]*s;return n}}function rt(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function it(e,t){return(rt(t)?tt:nt)(e,t)}function nt(e,t){var r,i=t?t.length:0,n=e?Math.min(i,e.length):0,s=new Array(n),a=new Array(i);for(r=0;r<n;++r)s[r]=ht(e[r],t[r]);for(;r<i;++r)a[r]=t[r];return function(e){for(r=0;r<n;++r)a[r]=s[r](e);return a}}function st(e,t){var r=new Date;return e=+e,t=+t,function(i){return r.setTime(e*(1-i)+t*i),r}}function at(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}function ot(e,t){var r,i={},n={};for(r in null!==e&&"object"==typeof e||(e={}),null!==t&&"object"==typeof t||(t={}),t)r in e?i[r]=ht(e[r],t[r]):n[r]=t[r];return function(e){for(r in i)n[r]=i[r](e);return n}}var lt=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,At=new RegExp(lt.source,"g");function ut(e,t){var r,i,n,s=lt.lastIndex=At.lastIndex=0,a=-1,o=[],l=[];for(e+="",t+="";(r=lt.exec(e))&&(i=At.exec(t));)(n=i.index)>s&&(n=t.slice(s,n),o[a]?o[a]+=n:o[++a]=n),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:at(r,i)})),s=At.lastIndex;return s<t.length&&(n=t.slice(s),o[a]?o[a]+=n:o[++a]=n),o.length<2?l[0]?function(e){return function(t){return e(t)+""}}(l[0].x):function(e){return function(){return e}}(t):(t=l.length,function(e){for(var r,i=0;i<t;++i)o[(r=l[i]).i]=r.x(e);return o.join("")})}function ht(e,t){var r,i=typeof t;return null==t||"boolean"===i?Ke(t):("number"===i?at:"string"===i?(r=Ie(t))?(t=r,et):ut:t instanceof Ie?et:t instanceof Date?st:rt(t)?tt:Array.isArray(t)?nt:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?ot:at)(e,t)}function ct(e,t){return e=+e,t=+t,function(r){return Math.round(e*(1-r)+t*r)}}function dt(e){return+e}var pt=[0,1];function ft(e){return e}function mt(e,t){return(t-=e=+e)?function(r){return(r-e)/t}:(r=isNaN(t)?NaN:.5,function(){return r});var r}function gt(e,t,r){var i=e[0],n=e[1],s=t[0],a=t[1];return n<i?(i=mt(n,i),s=r(a,s)):(i=mt(i,n),s=r(s,a)),function(e){return s(i(e))}}function yt(e,t,r){var i=Math.min(e.length,t.length)-1,n=new Array(i),s=new Array(i),a=-1;for(e[i]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++a<i;)n[a]=mt(e[a],e[a+1]),s[a]=r(t[a],t[a+1]);return function(t){var r=ae(e,t,1,i)-1;return s[r](n[r](t))}}function bt(){var e,t,r,i,n,s,a=pt,o=pt,l=ht,A=ft;function u(){var e,t,r,l=Math.min(a.length,o.length);return A!==ft&&(e=a[0],t=a[l-1],e>t&&(r=e,e=t,t=r),A=function(r){return Math.max(e,Math.min(t,r))}),i=l>2?yt:gt,n=s=null,h}function h(t){return null==t||isNaN(t=+t)?r:(n||(n=i(a.map(e),o,l)))(e(A(t)))}return h.invert=function(r){return A(t((s||(s=i(o,a.map(e),at)))(r)))},h.domain=function(e){return arguments.length?(a=Array.from(e,dt),u()):a.slice()},h.range=function(e){return arguments.length?(o=Array.from(e),u()):o.slice()},h.rangeRound=function(e){return o=Array.from(e),l=ct,u()},h.clamp=function(e){return arguments.length?(A=!!e||ft,u()):A!==ft},h.interpolate=function(e){return arguments.length?(l=e,u()):l},h.unknown=function(e){return arguments.length?(r=e,h):r},function(r,i){return e=r,t=i,u()}}function xt(e,t){if((r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var r,i=e.slice(0,r);return[i.length>1?i[0]+i.slice(2):i,+e.slice(r+1)]}function vt(e){return(e=xt(Math.abs(e)))?e[1]:NaN}var _t,wt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Tt(e){if(!(t=wt.exec(e)))throw new Error("invalid format: "+e);var t;return new Mt({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function Mt(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function St(e,t){var r=xt(e,t);if(!r)return e+"";var i=r[0],n=r[1];return n<0?"0."+new Array(-n).join("0")+i:i.length>n+1?i.slice(0,n+1)+"."+i.slice(n+1):i+new Array(n-i.length+2).join("0")}Tt.prototype=Mt.prototype,Mt.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Et={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>St(100*e,t),r:St,s:function(e,t){var r=xt(e,t);if(!r)return e+"";var i=r[0],n=r[1],s=n-(_t=3*Math.max(-8,Math.min(8,Math.floor(n/3))))+1,a=i.length;return s===a?i:s>a?i+new Array(s-a+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+xt(e,Math.max(0,t+s-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Nt(e){return e}var Ct,Rt,Bt,Pt=Array.prototype.map,qt=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Dt(e){var t,r,i=void 0===e.grouping||void 0===e.thousands?Nt:(t=Pt.call(e.grouping,Number),r=e.thousands+"",function(e,i){for(var n=e.length,s=[],a=0,o=t[0],l=0;n>0&&o>0&&(l+o+1>i&&(o=Math.max(1,i-l)),s.push(e.substring(n-=o,n+o)),!((l+=o+1)>i));)o=t[a=(a+1)%t.length];return s.reverse().join(r)}),n=void 0===e.currency?"":e.currency[0]+"",s=void 0===e.currency?"":e.currency[1]+"",a=void 0===e.decimal?".":e.decimal+"",o=void 0===e.numerals?Nt:function(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}(Pt.call(e.numerals,String)),l=void 0===e.percent?"%":e.percent+"",A=void 0===e.minus?"−":e.minus+"",u=void 0===e.nan?"NaN":e.nan+"";function h(e){var t=(e=Tt(e)).fill,r=e.align,h=e.sign,c=e.symbol,d=e.zero,p=e.width,f=e.comma,m=e.precision,g=e.trim,y=e.type;"n"===y?(f=!0,y="g"):Et[y]||(void 0===m&&(m=12),g=!0,y="g"),(d||"0"===t&&"="===r)&&(d=!0,t="0",r="=");var b="$"===c?n:"#"===c&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",x="$"===c?s:/[%p]/.test(y)?l:"",v=Et[y],_=/[defgprs%]/.test(y);function w(e){var n,s,l,c=b,w=x;if("c"===y)w=v(e)+w,e="";else{var T=(e=+e)<0||1/e<0;if(e=isNaN(e)?u:v(Math.abs(e),m),g&&(e=function(e){e:for(var t,r=e.length,i=1,n=-1;i<r;++i)switch(e[i]){case".":n=t=i;break;case"0":0===n&&(n=i),t=i;break;default:if(!+e[i])break e;n>0&&(n=0)}return n>0?e.slice(0,n)+e.slice(t+1):e}(e)),T&&0===+e&&"+"!==h&&(T=!1),c=(T?"("===h?h:A:"-"===h||"("===h?"":h)+c,w=("s"===y?qt[8+_t/3]:"")+w+(T&&"("===h?")":""),_)for(n=-1,s=e.length;++n<s;)if(48>(l=e.charCodeAt(n))||l>57){w=(46===l?a+e.slice(n+1):e.slice(n))+w,e=e.slice(0,n);break}}f&&!d&&(e=i(e,1/0));var M=c.length+e.length+w.length,S=M<p?new Array(p-M+1).join(t):"";switch(f&&d&&(e=i(S+e,S.length?p-w.length:1/0),S=""),r){case"<":e=c+e+w+S;break;case"=":e=c+S+e+w;break;case"^":e=S.slice(0,M=S.length>>1)+c+e+w+S.slice(M);break;default:e=S+c+e+w}return o(e)}return m=void 0===m?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),w.toString=function(){return e+""},w}return{format:h,formatPrefix:function(e,t){var r=h(((e=Tt(e)).type="f",e)),i=3*Math.max(-8,Math.min(8,Math.floor(vt(t)/3))),n=Math.pow(10,-i),s=qt[8+i/3];return function(e){return r(n*e)+s}}}}function It(e,t,r,i){var n,s=function(e,t,r){r=+r;const i=(t=+t)<(e=+e),n=i?de(t,e,r):de(e,t,r);return(i?-1:1)*(n<0?1/-n:n)}(e,t,r);switch((i=Tt(null==i?",f":i)).type){case"s":var a=Math.max(Math.abs(e),Math.abs(t));return null!=i.precision||isNaN(n=function(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(vt(t)/3)))-vt(Math.abs(e)))}(s,a))||(i.precision=n),Bt(i,a);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(n=function(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,vt(t)-vt(e))+1}(s,Math.max(Math.abs(e),Math.abs(t))))||(i.precision=n-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(n=function(e){return Math.max(0,-vt(Math.abs(e)))}(s))||(i.precision=n-2*("%"===i.type))}return Rt(i)}function Ft(e){var t=e.domain;return e.ticks=function(e){var r=t();return function(e,t,r){if(!((r=+r)>0))return[];if((e=+e)===(t=+t))return[e];const i=t<e,[n,s,a]=i?ce(t,e,r):ce(e,t,r);if(!(s>=n))return[];const o=s-n+1,l=new Array(o);if(i)if(a<0)for(let e=0;e<o;++e)l[e]=(s-e)/-a;else for(let e=0;e<o;++e)l[e]=(s-e)*a;else if(a<0)for(let e=0;e<o;++e)l[e]=(n+e)/-a;else for(let e=0;e<o;++e)l[e]=(n+e)*a;return l}(r[0],r[r.length-1],null==e?10:e)},e.tickFormat=function(e,r){var i=t();return It(i[0],i[i.length-1],null==e?10:e,r)},e.nice=function(r){null==r&&(r=10);var i,n,s=t(),a=0,o=s.length-1,l=s[a],A=s[o],u=10;for(A<l&&(n=l,l=A,A=n,n=a,a=o,o=n);u-- >0;){if((n=de(l,A,r))===i)return s[a]=l,s[o]=A,t(s);if(n>0)l=Math.floor(l/n)*n,A=Math.ceil(A/n)*n;else{if(!(n<0))break;l=Math.ceil(l*n)/n,A=Math.floor(A*n)/n}i=n}return e},e}function Ot(){var e=bt()(ft,ft);return e.copy=function(){return t=e,Ot().domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());var t},me.apply(e,arguments),Ft(e)}function Lt(){var e,t=0,r=1,i=1,n=[.5],s=[0,1];function a(t){return null!=t&&t<=t?s[ae(n,t,0,i)]:e}function o(){var e=-1;for(n=new Array(i);++e<i;)n[e]=((e+1)*r-(e-i)*t)/(i+1);return a}return a.domain=function(e){return arguments.length?([t,r]=e,t=+t,r=+r,o()):[t,r]},a.range=function(e){return arguments.length?(i=(s=Array.from(e)).length-1,o()):s.slice()},a.invertExtent=function(e){var a=s.indexOf(e);return a<0?[NaN,NaN]:a<1?[t,n[0]]:a>=i?[n[i-1],r]:[n[a-1],n[a]]},a.unknown=function(t){return arguments.length?(e=t,a):a},a.thresholds=function(){return n.slice()},a.copy=function(){return Lt().domain([t,r]).range(s).unknown(e)},me.apply(Ft(a),arguments)}Ct=Dt({thousands:",",grouping:[3],currency:["$",""]}),Rt=Ct.format,Bt=Ct.formatPrefix;var kt=1e-6,Vt=1e-12,Ut=Math.PI,zt=Ut/2,Gt=Ut/4,jt=2*Ut,Ht=180/Ut,Wt=Ut/180,Qt=Math.abs,$t=Math.atan,Xt=Math.atan2,Yt=Math.cos,Kt=Math.ceil,Zt=Math.exp,Jt=Math.hypot,er=Math.log,tr=Math.sin,rr=Math.sign||function(e){return e>0?1:e<0?-1:0},ir=Math.sqrt,nr=Math.tan;function sr(e){return e>1?zt:e<-1?-zt:Math.asin(e)}function ar(e){return(e=tr(e/2))*e}function or(){}function lr(e,t){e&&ur.hasOwnProperty(e.type)&&ur[e.type](e,t)}var Ar={Feature:function(e,t){lr(e.geometry,t)},FeatureCollection:function(e,t){for(var r=e.features,i=-1,n=r.length;++i<n;)lr(r[i].geometry,t)}},ur={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var r=e.coordinates,i=-1,n=r.length;++i<n;)e=r[i],t.point(e[0],e[1],e[2])},LineString:function(e,t){hr(e.coordinates,t,0)},MultiLineString:function(e,t){for(var r=e.coordinates,i=-1,n=r.length;++i<n;)hr(r[i],t,0)},Polygon:function(e,t){cr(e.coordinates,t)},MultiPolygon:function(e,t){for(var r=e.coordinates,i=-1,n=r.length;++i<n;)cr(r[i],t)},GeometryCollection:function(e,t){for(var r=e.geometries,i=-1,n=r.length;++i<n;)lr(r[i],t)}};function hr(e,t,r){var i,n=-1,s=e.length-r;for(t.lineStart();++n<s;)i=e[n],t.point(i[0],i[1],i[2]);t.lineEnd()}function cr(e,t){var r=-1,i=e.length;for(t.polygonStart();++r<i;)hr(e[r],t,1);t.polygonEnd()}function dr(e,t){e&&Ar.hasOwnProperty(e.type)?Ar[e.type](e,t):lr(e,t)}var pr,fr,mr,gr,yr,br,xr,vr,_r,wr,Tr,Mr,Sr,Er,Nr,Cr,Rr=new le,Br=new le,Pr={point:or,lineStart:or,lineEnd:or,polygonStart:function(){Rr=new le,Pr.lineStart=qr,Pr.lineEnd=Dr},polygonEnd:function(){var e=+Rr;Br.add(e<0?jt+e:e),this.lineStart=this.lineEnd=this.point=or},sphere:function(){Br.add(jt)}};function qr(){Pr.point=Ir}function Dr(){Fr(pr,fr)}function Ir(e,t){Pr.point=Fr,pr=e,fr=t,mr=e*=Wt,gr=Yt(t=(t*=Wt)/2+Gt),yr=tr(t)}function Fr(e,t){var r=(e*=Wt)-mr,i=r>=0?1:-1,n=i*r,s=Yt(t=(t*=Wt)/2+Gt),a=tr(t),o=yr*a,l=gr*s+o*Yt(n),A=o*i*tr(n);Rr.add(Xt(A,l)),mr=e,gr=s,yr=a}function Or(e){return[Xt(e[1],e[0]),sr(e[2])]}function Lr(e){var t=e[0],r=e[1],i=Yt(r);return[i*Yt(t),i*tr(t),tr(r)]}function kr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Vr(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Ur(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function zr(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Gr(e){var t=ir(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var jr,Hr,Wr,Qr,$r,Xr,Yr,Kr,Zr,Jr,ei,ti,ri,ii,ni,si,ai={point:oi,lineStart:Ai,lineEnd:ui,polygonStart:function(){ai.point=hi,ai.lineStart=ci,ai.lineEnd=di,Er=new le,Pr.polygonStart()},polygonEnd:function(){Pr.polygonEnd(),ai.point=oi,ai.lineStart=Ai,ai.lineEnd=ui,Rr<0?(br=-(vr=180),xr=-(_r=90)):Er>kt?_r=90:Er<-1e-6&&(xr=-90),Cr[0]=br,Cr[1]=vr},sphere:function(){br=-(vr=180),xr=-(_r=90)}};function oi(e,t){Nr.push(Cr=[br=e,vr=e]),t<xr&&(xr=t),t>_r&&(_r=t)}function li(e,t){var r=Lr([e*Wt,t*Wt]);if(Sr){var i=Vr(Sr,r),n=Vr([i[1],-i[0],0],i);Gr(n),n=Or(n);var s,a=e-wr,o=a>0?1:-1,l=n[0]*Ht*o,A=Qt(a)>180;A^(o*wr<l&&l<o*e)?(s=n[1]*Ht)>_r&&(_r=s):A^(o*wr<(l=(l+360)%360-180)&&l<o*e)?(s=-n[1]*Ht)<xr&&(xr=s):(t<xr&&(xr=t),t>_r&&(_r=t)),A?e<wr?pi(br,e)>pi(br,vr)&&(vr=e):pi(e,vr)>pi(br,vr)&&(br=e):vr>=br?(e<br&&(br=e),e>vr&&(vr=e)):e>wr?pi(br,e)>pi(br,vr)&&(vr=e):pi(e,vr)>pi(br,vr)&&(br=e)}else Nr.push(Cr=[br=e,vr=e]);t<xr&&(xr=t),t>_r&&(_r=t),Sr=r,wr=e}function Ai(){ai.point=li}function ui(){Cr[0]=br,Cr[1]=vr,ai.point=oi,Sr=null}function hi(e,t){if(Sr){var r=e-wr;Er.add(Qt(r)>180?r+(r>0?360:-360):r)}else Tr=e,Mr=t;Pr.point(e,t),li(e,t)}function ci(){Pr.lineStart()}function di(){hi(Tr,Mr),Pr.lineEnd(),Qt(Er)>kt&&(br=-(vr=180)),Cr[0]=br,Cr[1]=vr,Sr=null}function pi(e,t){return(t-=e)<0?t+360:t}function fi(e,t){return e[0]-t[0]}function mi(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t<e[0]||e[1]<t}function gi(e){var t,r,i,n,s,a,o;if(_r=vr=-(br=xr=1/0),Nr=[],dr(e,ai),r=Nr.length){for(Nr.sort(fi),t=1,s=[i=Nr[0]];t<r;++t)mi(i,(n=Nr[t])[0])||mi(i,n[1])?(pi(i[0],n[1])>pi(i[0],i[1])&&(i[1]=n[1]),pi(n[0],i[1])>pi(i[0],i[1])&&(i[0]=n[0])):s.push(i=n);for(a=-1/0,t=0,i=s[r=s.length-1];t<=r;i=n,++t)n=s[t],(o=pi(i[1],n[0]))>a&&(a=o,br=n[0],vr=i[1])}return Nr=Cr=null,br===1/0||xr===1/0?[[NaN,NaN],[NaN,NaN]]:[[br,xr],[vr,_r]]}var yi={sphere:or,point:bi,lineStart:vi,lineEnd:Ti,polygonStart:function(){yi.lineStart=Mi,yi.lineEnd=Si},polygonEnd:function(){yi.lineStart=vi,yi.lineEnd=Ti}};function bi(e,t){e*=Wt;var r=Yt(t*=Wt);xi(r*Yt(e),r*tr(e),tr(t))}function xi(e,t,r){++jr,Wr+=(e-Wr)/jr,Qr+=(t-Qr)/jr,$r+=(r-$r)/jr}function vi(){yi.point=_i}function _i(e,t){e*=Wt;var r=Yt(t*=Wt);ii=r*Yt(e),ni=r*tr(e),si=tr(t),yi.point=wi,xi(ii,ni,si)}function wi(e,t){e*=Wt;var r=Yt(t*=Wt),i=r*Yt(e),n=r*tr(e),s=tr(t),a=Xt(ir((a=ni*s-si*n)*a+(a=si*i-ii*s)*a+(a=ii*n-ni*i)*a),ii*i+ni*n+si*s);Hr+=a,Xr+=a*(ii+(ii=i)),Yr+=a*(ni+(ni=n)),Kr+=a*(si+(si=s)),xi(ii,ni,si)}function Ti(){yi.point=bi}function Mi(){yi.point=Ei}function Si(){Ni(ti,ri),yi.point=bi}function Ei(e,t){ti=e,ri=t,e*=Wt,t*=Wt,yi.point=Ni;var r=Yt(t);ii=r*Yt(e),ni=r*tr(e),si=tr(t),xi(ii,ni,si)}function Ni(e,t){e*=Wt;var r=Yt(t*=Wt),i=r*Yt(e),n=r*tr(e),s=tr(t),a=ni*s-si*n,o=si*i-ii*s,l=ii*n-ni*i,A=Jt(a,o,l),u=sr(A),h=A&&-u/A;Zr.add(h*a),Jr.add(h*o),ei.add(h*l),Hr+=u,Xr+=u*(ii+(ii=i)),Yr+=u*(ni+(ni=n)),Kr+=u*(si+(si=s)),xi(ii,ni,si)}function Ci(e){jr=Hr=Wr=Qr=$r=Xr=Yr=Kr=0,Zr=new le,Jr=new le,ei=new le,dr(e,yi);var t=+Zr,r=+Jr,i=+ei,n=Jt(t,r,i);return n<Vt&&(t=Xr,r=Yr,i=Kr,Hr<kt&&(t=Wr,r=Qr,i=$r),(n=Jt(t,r,i))<Vt)?[NaN,NaN]:[Xt(r,t)*Ht,sr(i/n)*Ht]}function Ri(e,t){function r(r,i){return r=e(r,i),t(r[0],r[1])}return e.invert&&t.invert&&(r.invert=function(r,i){return(r=t.invert(r,i))&&e.invert(r[0],r[1])}),r}function Bi(e,t){return Qt(e)>Ut&&(e-=Math.round(e/jt)*jt),[e,t]}function Pi(e,t,r){return(e%=jt)?t||r?Ri(Di(e),Ii(t,r)):Di(e):t||r?Ii(t,r):Bi}function qi(e){return function(t,r){return Qt(t+=e)>Ut&&(t-=Math.round(t/jt)*jt),[t,r]}}function Di(e){var t=qi(e);return t.invert=qi(-e),t}function Ii(e,t){var r=Yt(e),i=tr(e),n=Yt(t),s=tr(t);function a(e,t){var a=Yt(t),o=Yt(e)*a,l=tr(e)*a,A=tr(t),u=A*r+o*i;return[Xt(l*n-u*s,o*r-A*i),sr(u*n+l*s)]}return a.invert=function(e,t){var a=Yt(t),o=Yt(e)*a,l=tr(e)*a,A=tr(t),u=A*n-l*s;return[Xt(l*n+A*s,o*r+u*i),sr(u*r-o*i)]},a}function Fi(e,t){(t=Lr(t))[0]-=e,Gr(t);var r,i=(r=-t[1])>1?0:r<-1?Ut:Math.acos(r);return((-t[2]<0?-i:i)+jt-kt)%jt}function Oi(){var e,t=[];return{point:function(t,r,i){e.push([t,r,i])},lineStart:function(){t.push(e=[])},lineEnd:or,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var r=t;return t=[],e=null,r}}}function Li(e,t){return Qt(e[0]-t[0])<kt&&Qt(e[1]-t[1])<kt}function ki(e,t,r,i){this.x=e,this.z=t,this.o=r,this.e=i,this.v=!1,this.n=this.p=null}function Vi(e,t,r,i,n){var s,a,o=[],l=[];if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,r,i=e[0],a=e[t];if(Li(i,a)){if(!i[2]&&!a[2]){for(n.lineStart(),s=0;s<t;++s)n.point((i=e[s])[0],i[1]);return void n.lineEnd()}a[0]+=2e-6}o.push(r=new ki(i,e,null,!0)),l.push(r.o=new ki(i,null,r,!1)),o.push(r=new ki(a,e,null,!1)),l.push(r.o=new ki(a,null,r,!0))}}),o.length){for(l.sort(t),Ui(o),Ui(l),s=0,a=l.length;s<a;++s)l[s].e=r=!r;for(var A,u,h=o[0];;){for(var c=h,d=!0;c.v;)if((c=c.n)===h)return;A=c.z,n.lineStart();do{if(c.v=c.o.v=!0,c.e){if(d)for(s=0,a=A.length;s<a;++s)n.point((u=A[s])[0],u[1]);else i(c.x,c.n.x,1,n);c=c.n}else{if(d)for(A=c.p.z,s=A.length-1;s>=0;--s)n.point((u=A[s])[0],u[1]);else i(c.x,c.p.x,-1,n);c=c.p}A=(c=c.o).z,d=!d}while(!c.v);n.lineEnd()}}}function Ui(e){if(t=e.length){for(var t,r,i=0,n=e[0];++i<t;)n.n=r=e[i],r.p=n,n=r;n.n=r=e[0],r.p=n}}function zi(e){return Qt(e[0])<=Ut?e[0]:rr(e[0])*((Qt(e[0])+Ut)%jt-Ut)}function Gi(e,t){var r=zi(t),i=t[1],n=tr(i),s=[tr(r),-Yt(r),0],a=0,o=0,l=new le;1===n?i=zt+kt:-1===n&&(i=-zt-kt);for(var A=0,u=e.length;A<u;++A)if(c=(h=e[A]).length)for(var h,c,d=h[c-1],p=zi(d),f=d[1]/2+Gt,m=tr(f),g=Yt(f),y=0;y<c;++y,p=x,m=_,g=w,d=b){var b=h[y],x=zi(b),v=b[1]/2+Gt,_=tr(v),w=Yt(v),T=x-p,M=T>=0?1:-1,S=M*T,E=S>Ut,N=m*_;if(l.add(Xt(N*M*tr(S),g*w+N*Yt(S))),a+=E?T+M*jt:T,E^p>=r^x>=r){var C=Vr(Lr(d),Lr(b));Gr(C);var R=Vr(s,C);Gr(R);var B=(E^T>=0?-1:1)*sr(R[2]);(i>B||i===B&&(C[0]||C[1]))&&(o+=E^T>=0?1:-1)}}return(a<-1e-6||a<kt&&l<-1e-12)^1&o}function ji(e,t,r,i){return function(n){var s,a,o,l=t(n),A=Oi(),u=t(A),h=!1,c={point:d,lineStart:f,lineEnd:m,polygonStart:function(){c.point=g,c.lineStart=y,c.lineEnd=b,a=[],s=[]},polygonEnd:function(){c.point=d,c.lineStart=f,c.lineEnd=m,a=pe(a);var e=Gi(s,i);a.length?(h||(n.polygonStart(),h=!0),Vi(a,Wi,e,r,n)):e&&(h||(n.polygonStart(),h=!0),n.lineStart(),r(null,null,1,n),n.lineEnd()),h&&(n.polygonEnd(),h=!1),a=s=null},sphere:function(){n.polygonStart(),n.lineStart(),r(null,null,1,n),n.lineEnd(),n.polygonEnd()}};function d(t,r){e(t,r)&&n.point(t,r)}function p(e,t){l.point(e,t)}function f(){c.point=p,l.lineStart()}function m(){c.point=d,l.lineEnd()}function g(e,t){o.push([e,t]),u.point(e,t)}function y(){u.lineStart(),o=[]}function b(){g(o[0][0],o[0][1]),u.lineEnd();var e,t,r,i,l=u.clean(),c=A.result(),d=c.length;if(o.pop(),s.push(o),o=null,d)if(1&l){if((t=(r=c[0]).length-1)>0){for(h||(n.polygonStart(),h=!0),n.lineStart(),e=0;e<t;++e)n.point((i=r[e])[0],i[1]);n.lineEnd()}}else d>1&&2&l&&c.push(c.pop().concat(c.shift())),a.push(c.filter(Hi))}return c}}function Hi(e){return e.length>1}function Wi(e,t){return((e=e.x)[0]<0?e[1]-zt-kt:zt-e[1])-((t=t.x)[0]<0?t[1]-zt-kt:zt-t[1])}Bi.invert=Bi;var Qi=ji(function(){return!0},function(e){var t,r=NaN,i=NaN,n=NaN;return{lineStart:function(){e.lineStart(),t=1},point:function(s,a){var o=s>0?Ut:-Ut,l=Qt(s-r);Qt(l-Ut)<kt?(e.point(r,i=(i+a)/2>0?zt:-zt),e.point(n,i),e.lineEnd(),e.lineStart(),e.point(o,i),e.point(s,i),t=0):n!==o&&l>=Ut&&(Qt(r-n)<kt&&(r-=n*kt),Qt(s-o)<kt&&(s-=o*kt),i=function(e,t,r,i){var n,s,a=tr(e-r);return Qt(a)>kt?$t((tr(t)*(s=Yt(i))*tr(r)-tr(i)*(n=Yt(t))*tr(e))/(n*s*a)):(t+i)/2}(r,i,s,a),e.point(n,i),e.lineEnd(),e.lineStart(),e.point(o,i),t=0),e.point(r=s,i=a),n=o},lineEnd:function(){e.lineEnd(),r=i=NaN},clean:function(){return 2-t}}},function(e,t,r,i){var n;if(null==e)n=r*zt,i.point(-Ut,n),i.point(0,n),i.point(Ut,n),i.point(Ut,0),i.point(Ut,-n),i.point(0,-n),i.point(-Ut,-n),i.point(-Ut,0),i.point(-Ut,n);else if(Qt(e[0]-t[0])>kt){var s=e[0]<t[0]?Ut:-Ut;n=r*s/2,i.point(-s,n),i.point(0,n),i.point(s,n)}else i.point(t[0],t[1])},[-Ut,-zt]);function $i(e){var t=Yt(e),r=2*Wt,i=t>0,n=Qt(t)>kt;function s(e,r){return Yt(e)*Yt(r)>t}function a(e,r,i){var n=[1,0,0],s=Vr(Lr(e),Lr(r)),a=kr(s,s),o=s[0],l=a-o*o;if(!l)return!i&&e;var A=t*a/l,u=-t*o/l,h=Vr(n,s),c=zr(n,A);Ur(c,zr(s,u));var d=h,p=kr(c,d),f=kr(d,d),m=p*p-f*(kr(c,c)-1);if(!(m<0)){var g=ir(m),y=zr(d,(-p-g)/f);if(Ur(y,c),y=Or(y),!i)return y;var b,x=e[0],v=r[0],_=e[1],w=r[1];v<x&&(b=x,x=v,v=b);var T=v-x,M=Qt(T-Ut)<kt;if(!M&&w<_&&(b=_,_=w,w=b),M||T<kt?M?_+w>0^y[1]<(Qt(y[0]-x)<kt?_:w):_<=y[1]&&y[1]<=w:T>Ut^(x<=y[0]&&y[0]<=v)){var S=zr(d,(-p+g)/f);return Ur(S,c),[y,Or(S)]}}}function o(t,r){var n=i?e:Ut-e,s=0;return t<-n?s|=1:t>n&&(s|=2),r<-n?s|=4:r>n&&(s|=8),s}return ji(s,function(e){var t,r,l,A,u;return{lineStart:function(){A=l=!1,u=1},point:function(h,c){var d,p=[h,c],f=s(h,c),m=i?f?0:o(h,c):f?o(h+(h<0?Ut:-Ut),c):0;if(!t&&(A=l=f)&&e.lineStart(),f!==l&&(!(d=a(t,p))||Li(t,d)||Li(p,d))&&(p[2]=1),f!==l)u=0,f?(e.lineStart(),d=a(p,t),e.point(d[0],d[1])):(d=a(t,p),e.point(d[0],d[1],2),e.lineEnd()),t=d;else if(n&&t&&i^f){var g;m&r||!(g=a(p,t,!0))||(u=0,i?(e.lineStart(),e.point(g[0][0],g[0][1]),e.point(g[1][0],g[1][1]),e.lineEnd()):(e.point(g[1][0],g[1][1]),e.lineEnd(),e.lineStart(),e.point(g[0][0],g[0][1],3)))}!f||t&&Li(t,p)||e.point(p[0],p[1]),t=p,l=f,r=m},lineEnd:function(){l&&e.lineEnd(),t=null},clean:function(){return u|(A&&l)<<1}}},function(t,i,n,s){!function(e,t,r,i,n,s){if(r){var a=Yt(t),o=tr(t),l=i*r;null==n?(n=t+i*jt,s=t-l/2):(n=Fi(a,n),s=Fi(a,s),(i>0?n<s:n>s)&&(n+=i*jt));for(var A,u=n;i>0?u>s:u<s;u-=l)A=Or([a,-o*Yt(u),-o*tr(u)]),e.point(A[0],A[1])}}(s,e,r,n,t,i)},i?[0,-e]:[-Ut,e-Ut])}var Xi,Yi,Ki,Zi,Ji=1e9,en=-Ji;function tn(e,t,r,i){function n(n,s){return e<=n&&n<=r&&t<=s&&s<=i}function s(n,s,o,A){var u=0,h=0;if(null==n||(u=a(n,o))!==(h=a(s,o))||l(n,s)<0^o>0)do{A.point(0===u||3===u?e:r,u>1?i:t)}while((u=(u+o+4)%4)!==h);else A.point(s[0],s[1])}function a(i,n){return Qt(i[0]-e)<kt?n>0?0:3:Qt(i[0]-r)<kt?n>0?2:1:Qt(i[1]-t)<kt?n>0?1:0:n>0?3:2}function o(e,t){return l(e.x,t.x)}function l(e,t){var r=a(e,1),i=a(t,1);return r!==i?r-i:0===r?t[1]-e[1]:1===r?e[0]-t[0]:2===r?e[1]-t[1]:t[0]-e[0]}return function(a){var l,A,u,h,c,d,p,f,m,g,y,b=a,x=Oi(),v={point:_,lineStart:function(){v.point=w,A&&A.push(u=[]);g=!0,m=!1,p=f=NaN},lineEnd:function(){l&&(w(h,c),d&&m&&x.rejoin(),l.push(x.result()));v.point=_,m&&b.lineEnd()},polygonStart:function(){b=x,l=[],A=[],y=!0},polygonEnd:function(){var t=function(){for(var t=0,r=0,n=A.length;r<n;++r)for(var s,a,o=A[r],l=1,u=o.length,h=o[0],c=h[0],d=h[1];l<u;++l)s=c,a=d,c=(h=o[l])[0],d=h[1],a<=i?d>i&&(c-s)*(i-a)>(d-a)*(e-s)&&++t:d<=i&&(c-s)*(i-a)<(d-a)*(e-s)&&--t;return t}(),r=y&&t,n=(l=pe(l)).length;(r||n)&&(a.polygonStart(),r&&(a.lineStart(),s(null,null,1,a),a.lineEnd()),n&&Vi(l,o,t,s,a),a.polygonEnd());b=a,l=A=u=null}};function _(e,t){n(e,t)&&b.point(e,t)}function w(s,a){var o=n(s,a);if(A&&u.push([s,a]),g)h=s,c=a,d=o,g=!1,o&&(b.lineStart(),b.point(s,a));else if(o&&m)b.point(s,a);else{var l=[p=Math.max(en,Math.min(Ji,p)),f=Math.max(en,Math.min(Ji,f))],x=[s=Math.max(en,Math.min(Ji,s)),a=Math.max(en,Math.min(Ji,a))];!function(e,t,r,i,n,s){var a,o=e[0],l=e[1],A=0,u=1,h=t[0]-o,c=t[1]-l;if(a=r-o,h||!(a>0)){if(a/=h,h<0){if(a<A)return;a<u&&(u=a)}else if(h>0){if(a>u)return;a>A&&(A=a)}if(a=n-o,h||!(a<0)){if(a/=h,h<0){if(a>u)return;a>A&&(A=a)}else if(h>0){if(a<A)return;a<u&&(u=a)}if(a=i-l,c||!(a>0)){if(a/=c,c<0){if(a<A)return;a<u&&(u=a)}else if(c>0){if(a>u)return;a>A&&(A=a)}if(a=s-l,c||!(a<0)){if(a/=c,c<0){if(a>u)return;a>A&&(A=a)}else if(c>0){if(a<A)return;a<u&&(u=a)}return A>0&&(e[0]=o+A*h,e[1]=l+A*c),u<1&&(t[0]=o+u*h,t[1]=l+u*c),!0}}}}}(l,x,e,t,r,i)?o&&(b.lineStart(),b.point(s,a),y=!1):(m||(b.lineStart(),b.point(l[0],l[1])),b.point(x[0],x[1]),o||b.lineEnd(),y=!1)}p=s,f=a,m=o}return v}}var rn={sphere:or,point:or,lineStart:function(){rn.point=sn,rn.lineEnd=nn},lineEnd:or,polygonStart:or,polygonEnd:or};function nn(){rn.point=rn.lineEnd=or}function sn(e,t){Yi=e*=Wt,Ki=tr(t*=Wt),Zi=Yt(t),rn.point=an}function an(e,t){e*=Wt;var r=tr(t*=Wt),i=Yt(t),n=Qt(e-Yi),s=Yt(n),a=i*tr(n),o=Zi*r-Ki*i*s,l=Ki*r+Zi*i*s;Xi.add(Xt(ir(a*a+o*o),l)),Yi=e,Ki=r,Zi=i}var on=[null,null],ln={type:"LineString",coordinates:on};function An(e,t){return on[0]=e,on[1]=t,function(e){return Xi=new le,dr(e,rn),+Xi}(ln)}var un={Feature:function(e,t){return cn(e.geometry,t)},FeatureCollection:function(e,t){for(var r=e.features,i=-1,n=r.length;++i<n;)if(cn(r[i].geometry,t))return!0;return!1}},hn={Sphere:function(){return!0},Point:function(e,t){return dn(e.coordinates,t)},MultiPoint:function(e,t){for(var r=e.coordinates,i=-1,n=r.length;++i<n;)if(dn(r[i],t))return!0;return!1},LineString:function(e,t){return pn(e.coordinates,t)},MultiLineString:function(e,t){for(var r=e.coordinates,i=-1,n=r.length;++i<n;)if(pn(r[i],t))return!0;return!1},Polygon:function(e,t){return fn(e.coordinates,t)},MultiPolygon:function(e,t){for(var r=e.coordinates,i=-1,n=r.length;++i<n;)if(fn(r[i],t))return!0;return!1},GeometryCollection:function(e,t){for(var r=e.geometries,i=-1,n=r.length;++i<n;)if(cn(r[i],t))return!0;return!1}};function cn(e,t){return!(!e||!hn.hasOwnProperty(e.type))&&hn[e.type](e,t)}function dn(e,t){return 0===An(e,t)}function pn(e,t){for(var r,i,n,s=0,a=e.length;s<a;s++){if(0===(i=An(e[s],t)))return!0;if(s>0&&(n=An(e[s],e[s-1]))>0&&r<=n&&i<=n&&(r+i-n)*(1-Math.pow((r-i)/n,2))<Vt*n)return!0;r=i}return!1}function fn(e,t){return!!Gi(e.map(mn),gn(t))}function mn(e){return(e=e.map(gn)).pop(),e}function gn(e){return[e[0]*Wt,e[1]*Wt]}function yn(e,t,r){var i=fe(e,t-kt,r).concat(t);return function(e){return i.map(function(t){return[e,t]})}}function bn(e,t,r){var i=fe(e,t-kt,r).concat(t);return function(e){return i.map(function(t){return[t,e]})}}function xn(){return function(){var e,t,r,i,n,s,a,o,l,A,u,h,c=10,d=c,p=90,f=360,m=2.5;function g(){return{type:"MultiLineString",coordinates:y()}}function y(){return fe(Kt(i/p)*p,r,p).map(u).concat(fe(Kt(o/f)*f,a,f).map(h)).concat(fe(Kt(t/c)*c,e,c).filter(function(e){return Qt(e%p)>kt}).map(l)).concat(fe(Kt(s/d)*d,n,d).filter(function(e){return Qt(e%f)>kt}).map(A))}return g.lines=function(){return y().map(function(e){return{type:"LineString",coordinates:e}})},g.outline=function(){return{type:"Polygon",coordinates:[u(i).concat(h(a).slice(1),u(r).reverse().slice(1),h(o).reverse().slice(1))]}},g.extent=function(e){return arguments.length?g.extentMajor(e).extentMinor(e):g.extentMinor()},g.extentMajor=function(e){return arguments.length?(i=+e[0][0],r=+e[1][0],o=+e[0][1],a=+e[1][1],i>r&&(e=i,i=r,r=e),o>a&&(e=o,o=a,a=e),g.precision(m)):[[i,o],[r,a]]},g.extentMinor=function(r){return arguments.length?(t=+r[0][0],e=+r[1][0],s=+r[0][1],n=+r[1][1],t>e&&(r=t,t=e,e=r),s>n&&(r=s,s=n,n=r),g.precision(m)):[[t,s],[e,n]]},g.step=function(e){return arguments.length?g.stepMajor(e).stepMinor(e):g.stepMinor()},g.stepMajor=function(e){return arguments.length?(p=+e[0],f=+e[1],g):[p,f]},g.stepMinor=function(e){return arguments.length?(c=+e[0],d=+e[1],g):[c,d]},g.precision=function(c){return arguments.length?(m=+c,l=yn(s,n,90),A=bn(t,e,m),u=yn(o,a,90),h=bn(i,r,m),g):m},g.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}()()}function vn(e,t){var r=e[0]*Wt,i=e[1]*Wt,n=t[0]*Wt,s=t[1]*Wt,a=Yt(i),o=tr(i),l=Yt(s),A=tr(s),u=a*Yt(r),h=a*tr(r),c=l*Yt(n),d=l*tr(n),p=2*sr(ir(ar(s-i)+a*l*ar(n-r))),f=tr(p),m=p?function(e){var t=tr(e*=p)/f,r=tr(p-e)/f,i=r*u+t*c,n=r*h+t*d,s=r*o+t*A;return[Xt(n,i)*Ht,Xt(s,ir(i*i+n*n))*Ht]}:function(){return[r*Ht,i*Ht]};return m.distance=p,m}var _n=e=>e,wn=1/0,Tn=wn,Mn=-wn,Sn=Mn,En={point:function(e,t){e<wn&&(wn=e);e>Mn&&(Mn=e);t<Tn&&(Tn=t);t>Sn&&(Sn=t)},lineStart:or,lineEnd:or,polygonStart:or,polygonEnd:or,result:function(){var e=[[wn,Tn],[Mn,Sn]];return Mn=Sn=-(Tn=wn=1/0),e}};function Nn(e){return function(t){var r=new Cn;for(var i in e)r[i]=e[i];return r.stream=t,r}}function Cn(){}function Rn(e,t,r){var i=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),null!=i&&e.clipExtent(null),dr(r,e.stream(En)),t(En.result()),null!=i&&e.clipExtent(i),e}function Bn(e,t,r){return Rn(e,function(r){var i=t[1][0]-t[0][0],n=t[1][1]-t[0][1],s=Math.min(i/(r[1][0]-r[0][0]),n/(r[1][1]-r[0][1])),a=+t[0][0]+(i-s*(r[1][0]+r[0][0]))/2,o=+t[0][1]+(n-s*(r[1][1]+r[0][1]))/2;e.scale(150*s).translate([a,o])},r)}Cn.prototype={constructor:Cn,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Pn=Yt(30*Wt);function qn(e,t){return+t?function(e,t){function r(i,n,s,a,o,l,A,u,h,c,d,p,f,m){var g=A-i,y=u-n,b=g*g+y*y;if(b>4*t&&f--){var x=a+c,v=o+d,_=l+p,w=ir(x*x+v*v+_*_),T=sr(_/=w),M=Qt(Qt(_)-1)<kt||Qt(s-h)<kt?(s+h)/2:Xt(v,x),S=e(M,T),E=S[0],N=S[1],C=E-i,R=N-n,B=y*C-g*R;(B*B/b>t||Qt((g*C+y*R)/b-.5)>.3||a*c+o*d+l*p<Pn)&&(r(i,n,s,a,o,l,E,N,M,x/=w,v/=w,_,f,m),m.point(E,N),r(E,N,M,x,v,_,A,u,h,c,d,p,f,m))}}return function(t){var i,n,s,a,o,l,A,u,h,c,d,p,f={point:m,lineStart:g,lineEnd:b,polygonStart:function(){t.polygonStart(),f.lineStart=x},polygonEnd:function(){t.polygonEnd(),f.lineStart=g}};function m(r,i){r=e(r,i),t.point(r[0],r[1])}function g(){u=NaN,f.point=y,t.lineStart()}function y(i,n){var s=Lr([i,n]),a=e(i,n);r(u,h,A,c,d,p,u=a[0],h=a[1],A=i,c=s[0],d=s[1],p=s[2],16,t),t.point(u,h)}function b(){f.point=m,t.lineEnd()}function x(){g(),f.point=v,f.lineEnd=_}function v(e,t){y(i=e,t),n=u,s=h,a=c,o=d,l=p,f.point=y}function _(){r(u,h,A,c,d,p,n,s,i,a,o,l,16,t),f.lineEnd=b,b()}return f}}(e,t):function(e){return Nn({point:function(t,r){t=e(t,r),this.stream.point(t[0],t[1])}})}(e)}var Dn=Nn({point:function(e,t){this.stream.point(e*Wt,t*Wt)}});function In(e,t,r,i,n,s){if(!s)return function(e,t,r,i,n){function s(s,a){return[t+e*(s*=i),r-e*(a*=n)]}return s.invert=function(s,a){return[(s-t)/e*i,(r-a)/e*n]},s}(e,t,r,i,n);var a=Yt(s),o=tr(s),l=a*e,A=o*e,u=a/e,h=o/e,c=(o*r-a*t)/e,d=(o*t+a*r)/e;function p(e,s){return[l*(e*=i)-A*(s*=n)+t,r-A*e-l*s]}return p.invert=function(e,t){return[i*(u*e-h*t+c),n*(d-h*e-u*t)]},p}function Fn(e){return function(e){var t,r,i,n,s,a,o,l,A,u,h=150,c=480,d=250,p=0,f=0,m=0,g=0,y=0,b=0,x=1,v=1,_=null,w=Qi,T=null,M=_n,S=.5;function E(e){return l(e[0]*Wt,e[1]*Wt)}function N(e){return(e=l.invert(e[0],e[1]))&&[e[0]*Ht,e[1]*Ht]}function C(){var e=In(h,0,0,x,v,b).apply(null,t(p,f)),i=In(h,c-e[0],d-e[1],x,v,b);return r=Pi(m,g,y),o=Ri(t,i),l=Ri(r,o),a=qn(o,S),R()}function R(){return A=u=null,E}return E.stream=function(e){return A&&u===e?A:A=Dn(function(e){return Nn({point:function(t,r){var i=e(t,r);return this.stream.point(i[0],i[1])}})}(r)(w(a(M(u=e)))))},E.preclip=function(e){return arguments.length?(w=e,_=void 0,R()):w},E.postclip=function(e){return arguments.length?(M=e,T=i=n=s=null,R()):M},E.clipAngle=function(e){return arguments.length?(w=+e?$i(_=e*Wt):(_=null,Qi),R()):_*Ht},E.clipExtent=function(e){return arguments.length?(M=null==e?(T=i=n=s=null,_n):tn(T=+e[0][0],i=+e[0][1],n=+e[1][0],s=+e[1][1]),R()):null==T?null:[[T,i],[n,s]]},E.scale=function(e){return arguments.length?(h=+e,C()):h},E.translate=function(e){return arguments.length?(c=+e[0],d=+e[1],C()):[c,d]},E.center=function(e){return arguments.length?(p=e[0]%360*Wt,f=e[1]%360*Wt,C()):[p*Ht,f*Ht]},E.rotate=function(e){return arguments.length?(m=e[0]%360*Wt,g=e[1]%360*Wt,y=e.length>2?e[2]%360*Wt:0,C()):[m*Ht,g*Ht,y*Ht]},E.angle=function(e){return arguments.length?(b=e%360*Wt,C()):b*Ht},E.reflectX=function(e){return arguments.length?(x=e?-1:1,C()):x<0},E.reflectY=function(e){return arguments.length?(v=e?-1:1,C()):v<0},E.precision=function(e){return arguments.length?(a=qn(o,S=e*e),R()):ir(S)},E.fitExtent=function(e,t){return Bn(E,e,t)},E.fitSize=function(e,t){return function(e,t,r){return Bn(e,[[0,0],t],r)}(E,e,t)},E.fitWidth=function(e,t){return function(e,t,r){return Rn(e,function(r){var i=+t,n=i/(r[1][0]-r[0][0]),s=(i-n*(r[1][0]+r[0][0]))/2,a=-n*r[0][1];e.scale(150*n).translate([s,a])},r)}(E,e,t)},E.fitHeight=function(e,t){return function(e,t,r){return Rn(e,function(r){var i=+t,n=i/(r[1][1]-r[0][1]),s=-n*r[0][0],a=(i-n*(r[1][1]+r[0][1]))/2;e.scale(150*n).translate([s,a])},r)}(E,e,t)},function(){return t=e.apply(this,arguments),E.invert=t.invert&&N,C()}}(function(){return e})()}function On(e,t){return[e,er(nr((zt+t)/2))]}function Ln(e,t){var r=Yt(t),i=1+Yt(e)*r;return[r*tr(e)/i,tr(t)/i]}function kn(){return Fn(Ln).scale(250).clipAngle(142)}function Vn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function Un(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function zn(e,t,r){return t=Xn(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Yn()?Reflect.construct(t,[],Xn(e).constructor):t.apply(e,r))}function Gn(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function jn(e,t){return e.get(Un(e,t))}function Hn(e,t,r){Gn(e,t),t.set(e,r)}function Wn(e,t,r){return e.set(Un(e,t),r),r}function Qn(e,t,r){return function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,es(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function $n(e,t,r){return(t=es(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Xn(e){return Xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Xn(e)}function Yn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Yn=function(){return!!e})()}function Kn(e,t){return Kn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Kn(e,t)}function Zn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t);else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||ts(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jn(e){return function(e){if(Array.isArray(e))return Vn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ts(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function es(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function ts(e,t){if(e){if("string"==typeof e)return Vn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vn(e,t):void 0}}On.invert=function(e,t){return[e,2*$t(Zt(t))-zt]},Ln.invert=function(e){return function(t,r){var i=ir(t*t+r*r),n=e(i),s=tr(n),a=Yt(n);return[Xt(t*s,i*a),sr(i&&r*s/i)]}}(function(e){return 2*$t(e)});var rs=function(e){e instanceof Array?e.forEach(rs):(e.map&&e.map.dispose(),e.dispose())},is=function(e){e.geometry&&e.geometry.dispose(),e.material&&rs(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(is)},ns=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),is(t)}};function ss(e,t,r){var i=(90-e)*Math.PI/180,n=(90-t)*Math.PI/180;return{x:r*Math.sin(i)*Math.cos(n),y:r*Math.cos(i),z:r*Math.sin(i)*Math.sin(n)}}function as(e){return e*Math.PI/180}var os=function(e){return 1-(On(0,(.5-e)*Math.PI)[1]/Math.PI+1)/2},ls=function(e){return Math.max(0,Math.min(1,os(e)))},As=function(e){return.5-On.invert(0,(2*(1-e)-1)*Math.PI)[1]/Math.PI},us=function(e,t,r,i){var n=Math.pow(2,e),s=Math.max(0,Math.min(n-1,Math.floor((r+180)*n/360))),a=(90-i)/180;return t&&(a=Math.max(0,Math.min(1,os(a)))),[s,Math.floor(a*n)]},hs=function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=[],o=Math.pow(2,e),l=360/o,A=180/o,u=void 0===n?o-1:n,h=void 0===s?o-1:s,c=r,d=Math.min(o-1,u);c<=d;c++)for(var p=i,f=Math.min(o-1,h);p<=f;p++){var m=p,g=A;if(t)m=0===p?p:As(p/o)*o,g=180*((p+1===o?p+1:As((p+1)/o)*o)-m)/o;var y=(c+.5)*l-180,b=90-(180*m/o+g/2),x=g;a.push({x:c,y:p,lng:y,lat:b,latLen:x})}return a},cs=new WeakMap,ds=new WeakMap,ps=new WeakMap,fs=new WeakMap,ms=new WeakMap,gs=new WeakMap,ys=new WeakMap,bs=new WeakMap,xs=new WeakSet,vs=function(e){function r(e){var i,n,s,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=a.tileUrl,l=a.minLevel,A=void 0===l?0:l,u=a.maxLevel,h=void 0===u?17:u,c=a.mercatorProjection,d=void 0===c||c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),i=zn(this,r),Gn(n=i,s=xs),s.add(n),Hn(i,cs,void 0),Hn(i,ds,void 0),Hn(i,ps,void 0),Hn(i,fs,void 0),Hn(i,ms,{}),Hn(i,gs,void 0),Hn(i,ys,void 0),Hn(i,bs,void 0),$n(i,"minLevel",void 0),$n(i,"maxLevel",void 0),$n(i,"thresholds",Jn(new Array(30)).map(function(e,t){return 8/Math.pow(2,t)})),$n(i,"curvatureResolution",5),$n(i,"tileMargin",0),$n(i,"clearTiles",function(){Object.values(jn(ms,i)).forEach(function(e){e.forEach(function(e){e.obj&&(i.remove(e.obj),ns(e.obj),delete e.obj)})}),Wn(ms,i,{})}),Wn(cs,i,e),i.tileUrl=o,Wn(ds,i,d),i.minLevel=A,i.maxLevel=h,i.level=0,i.add(Wn(bs,i,new t.Mesh(new t.SphereGeometry(.99*jn(cs,i),180,90),new t.MeshBasicMaterial({color:0})))),jn(bs,i).visible=!1,jn(bs,i).material.polygonOffset=!0,jn(bs,i).material.polygonOffsetUnits=3,jn(bs,i).material.polygonOffsetFactor=1,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Kn(e,t)}(r,e),Qn(r,[{key:"tileUrl",get:function(){return jn(ps,this)},set:function(e){Wn(ps,this,e),this.updatePov(jn(ys,this))}},{key:"level",get:function(){return jn(fs,this)},set:function(e){var t=this;jn(ms,this)[e]||Un(xs,this,_s).call(this,e);var r=jn(fs,this);if(Wn(fs,this,e),e!==r&&void 0!==r){if(jn(bs,this).visible=e>0,jn(ms,this)[e].forEach(function(e){return e.obj&&(e.obj.material.depthWrite=!0)}),r<e&&jn(ms,this)[r].forEach(function(e){return e.obj&&(e.obj.material.depthWrite=!1)}),r>e)for(var i=e+1;i<=r;i++)jn(ms,this)[i]&&jn(ms,this)[i].forEach(function(e){e.obj&&(t.remove(e.obj),ns(e.obj),delete e.obj)});Un(xs,this,ws).call(this)}}},{key:"updatePov",value:function(e){var r,i=this;if(e&&e instanceof t.Camera&&(Wn(ys,this,e),Wn(gs,this,function(n){if(!n.hullPnts){var s=360/Math.pow(2,i.level),a=n.lng,o=n.lat,l=n.latLen,A=a-s/2,u=a+s/2,h=o-l/2,c=o+l/2;n.hullPnts=[[o,a],[h,A],[c,A],[h,u],[c,u]].map(function(e){var t=Zn(e,2);return ss(t[0],t[1],jn(cs,i))}).map(function(e){var r=e.x,i=e.y,n=e.z;return new t.Vector3(r,i,n)})}return r||(r=new t.Frustum,e.updateMatrix(),e.updateMatrixWorld(),r.setFromProjectionMatrix((new t.Matrix4).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse))),n.hullPnts.some(function(e){return r.containsPoint(e.clone().applyMatrix4(i.matrixWorld))})}),this.tileUrl)){var n=(e.position.clone().distanceTo(this.getWorldPosition(new t.Vector3))-jn(cs,this))/jn(cs,this),s=this.thresholds.findIndex(function(e){return e&&e<=n});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,s<0?this.thresholds.length:s)),Un(xs,this,ws).call(this)}}}])}(t.Group);function _s(e){var t=this;if(e>7)jn(ms,this)[e]=[];else{var r=jn(ms,this)[e]=hs(e,jn(ds,this));r.forEach(function(e){return e.centroid=ss(e.lat,e.lng,jn(cs,t))}),r.octree=Z().x(function(e){return e.centroid.x}).y(function(e){return e.centroid.y}).z(function(e){return e.centroid.z}).addAll(r)}}function ws(){var e=this;if(this.tileUrl&&void 0!==this.level&&jn(ms,this).hasOwnProperty(this.level)&&(jn(gs,this)||!(this.level>6))){var r=jn(ms,this)[this.level];if(jn(ys,this)){var i=this.worldToLocal(jn(ys,this).position.clone());if(r.octree){var n,s=this.worldToLocal(jn(ys,this).position.clone()),a=3*(s.length()-jn(cs,this));r=(n=r.octree).findAllWithinRadius.apply(n,Jn(s).concat([a]))}else{var o=function(e){var t=e.x,r=e.y,i=e.z,n=Math.sqrt(t*t+r*r+i*i),s=Math.acos(r/n),a=Math.atan2(i,t);return{lat:90-180*s/Math.PI,lng:90-180*a/Math.PI-(a<-Math.PI/2?360:0),r:n}}(i),l=90*(o.r/jn(cs,this)-1),A=l/Math.cos(as(o.lat)),u=[o.lng-A,o.lng+A],h=[o.lat+l,o.lat-l],c=Zn(us(this.level,jn(ds,this),u[0],h[0]),2),d=c[0],p=c[1],f=Zn(us(this.level,jn(ds,this),u[1],h[1]),2),m=f[0],g=f[1];!r.record&&(r.record={});var y=r.record;if(y.hasOwnProperty("".concat(Math.round((d+m)/2),"_").concat(Math.round((p+g)/2)))){for(var b=[],x=d;x<=m;x++)for(var v=p;v<=g;v++){var _="".concat(x,"_").concat(v);y.hasOwnProperty(_)||(y[_]=hs(this.level,jn(ds,this),x,v,x,v)[0],r.push(y[_])),b.push(y[_])}r=b}else r=hs(this.level,jn(ds,this),d,p,m,g).map(function(e){var t="".concat(e.x,"_").concat(e.y);return y.hasOwnProperty(t)?y[t]:(y[t]=e,r.push(e),e)})}}r.filter(function(e){return!e.obj}).filter(jn(gs,this)||function(){return!0}).forEach(function(r){var i=r.x,n=r.y,s=r.lng,a=r.lat,o=r.latLen,l=360/Math.pow(2,e.level);if(!r.obj){var A=l*(1-e.tileMargin),u=o*(1-e.tileMargin),h=as(s),c=as(-a),d=new t.Mesh(new t.SphereGeometry(jn(cs,e),Math.ceil(A/e.curvatureResolution),Math.ceil(u/e.curvatureResolution),as(90-A/2)+h,as(A),as(90-u/2)+c,as(u)),new t.MeshLambertMaterial);if(jn(ds,e)){var p=Zn([a+o/2,a-o/2].map(function(e){return.5-e/180}),2),f=p[0],m=p[1];!function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=Ot().domain([1,0]).range([t,r]).clamp(!0),n=Ot().domain([ls(t),ls(r)]).range([1,0]).clamp(!0),s=function(e){return n(ls(i(e)))},a=e.array,o=0,l=a.length;o<l;o+=2)a[o+1]=s(a[o+1]);e.needsUpdate=!0}(d.geometry.attributes.uv,f,m)}r.obj=d}r.loading||(r.loading=!0,(new t.TextureLoader).load(e.tileUrl(i,n,e.level),function(i){var n=r.obj;n&&(i.colorSpace=t.SRGBColorSpace,n.material.map=i,n.material.color=null,n.material.needsUpdate=!0,e.add(n)),r.loading=!1}))})}}function Ts(e,t,r=2){const i=t&&t.length,n=i?t[0]*r:e.length;let s=Ms(e,0,n,r,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,A;if(i&&(s=function(e,t,r,i){const n=[];for(let r=0,s=t.length;r<s;r++){const a=Ms(e,t[r]*i,r<s-1?t[r+1]*i:e.length,i,!1);a===a.next&&(a.steiner=!0),n.push(Fs(a))}n.sort(Ps);for(let e=0;e<n.length;e++)r=qs(n[e],r);return r}(e,t,s,r)),e.length>80*r){o=e[0],l=e[1];let t=o,i=l;for(let s=r;s<n;s+=r){const r=e[s],n=e[s+1];r<o&&(o=r),n<l&&(l=n),r>t&&(t=r),n>i&&(i=n)}A=Math.max(t-o,i-l),A=0!==A?32767/A:0}return Es(s,a,r,o,l,A,0),a}function Ms(e,t,r,i,n){let s;if(n===function(e,t,r,i){let n=0;for(let s=t,a=r-i;s<r;s+=i)n+=(e[a]-e[s])*(e[s+1]+e[a+1]),a=s;return n}(e,t,r,i)>0)for(let n=t;n<r;n+=i)s=Qs(n/i|0,e[n],e[n+1],s);else for(let n=r-i;n>=t;n-=i)s=Qs(n/i|0,e[n],e[n+1],s);return s&&Us(s,s.next)&&($s(s),s=s.next),s}function Ss(e,t){if(!e)return e;t||(t=e);let r,i=e;do{if(r=!1,i.steiner||!Us(i,i.next)&&0!==Vs(i.prev,i,i.next))i=i.next;else{if($s(i),i=t=i.prev,i===i.next)break;r=!0}}while(r||i!==t);return t}function Es(e,t,r,i,n,s,a){if(!e)return;!a&&s&&function(e,t,r,i){let n=e;do{0===n.z&&(n.z=Is(n.x,n.y,t,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let t,r=1;do{let i,n=e;e=null;let s=null;for(t=0;n;){t++;let a=n,o=0;for(let e=0;e<r&&(o++,a=a.nextZ,a);e++);let l=r;for(;o>0||l>0&&a;)0!==o&&(0===l||!a||n.z<=a.z)?(i=n,n=n.nextZ,o--):(i=a,a=a.nextZ,l--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;n=a}s.nextZ=null,r*=2}while(t>1)}(n)}(e,i,n,s);let o=e;for(;e.prev!==e.next;){const l=e.prev,A=e.next;if(s?Cs(e,i,n,s):Ns(e))t.push(l.i,e.i,A.i),$s(e),e=A.next,o=A.next;else if((e=A)===o){a?1===a?Es(e=Rs(Ss(e),t),t,r,i,n,s,2):2===a&&Bs(e,t,r,i,n,s):Es(Ss(e),t,r,i,n,s,1);break}}}function Ns(e){const t=e.prev,r=e,i=e.next;if(Vs(t,r,i)>=0)return!1;const n=t.x,s=r.x,a=i.x,o=t.y,l=r.y,A=i.y,u=Math.min(n,s,a),h=Math.min(o,l,A),c=Math.max(n,s,a),d=Math.max(o,l,A);let p=i.next;for(;p!==t;){if(p.x>=u&&p.x<=c&&p.y>=h&&p.y<=d&&Ls(n,o,s,l,a,A,p.x,p.y)&&Vs(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Cs(e,t,r,i){const n=e.prev,s=e,a=e.next;if(Vs(n,s,a)>=0)return!1;const o=n.x,l=s.x,A=a.x,u=n.y,h=s.y,c=a.y,d=Math.min(o,l,A),p=Math.min(u,h,c),f=Math.max(o,l,A),m=Math.max(u,h,c),g=Is(d,p,t,r,i),y=Is(f,m,t,r,i);let b=e.prevZ,x=e.nextZ;for(;b&&b.z>=g&&x&&x.z<=y;){if(b.x>=d&&b.x<=f&&b.y>=p&&b.y<=m&&b!==n&&b!==a&&Ls(o,u,l,h,A,c,b.x,b.y)&&Vs(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,x.x>=d&&x.x<=f&&x.y>=p&&x.y<=m&&x!==n&&x!==a&&Ls(o,u,l,h,A,c,x.x,x.y)&&Vs(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;b&&b.z>=g;){if(b.x>=d&&b.x<=f&&b.y>=p&&b.y<=m&&b!==n&&b!==a&&Ls(o,u,l,h,A,c,b.x,b.y)&&Vs(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=d&&x.x<=f&&x.y>=p&&x.y<=m&&x!==n&&x!==a&&Ls(o,u,l,h,A,c,x.x,x.y)&&Vs(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Rs(e,t){let r=e;do{const i=r.prev,n=r.next.next;!Us(i,n)&&zs(i,r,r.next,n)&&Hs(i,n)&&Hs(n,i)&&(t.push(i.i,r.i,n.i),$s(r),$s(r.next),r=e=n),r=r.next}while(r!==e);return Ss(r)}function Bs(e,t,r,i,n,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&ks(a,e)){let o=Ws(a,e);return a=Ss(a,a.next),o=Ss(o,o.next),Es(a,t,r,i,n,s,0),void Es(o,t,r,i,n,s,0)}e=e.next}a=a.next}while(a!==e)}function Ps(e,t){let r=e.x-t.x;if(0===r&&(r=e.y-t.y,0===r)){r=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return r}function qs(e,t){const r=function(e,t){let r=t;const i=e.x,n=e.y;let s,a=-1/0;if(Us(e,r))return r;do{if(Us(e,r.next))return r.next;if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){const e=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=i&&e>a&&(a=e,s=r.x<r.next.x?r:r.next,e===i))return s}r=r.next}while(r!==t);if(!s)return null;const o=s,l=s.x,A=s.y;let u=1/0;r=s;do{if(i>=r.x&&r.x>=l&&i!==r.x&&Os(n<A?i:a,n,l,A,n<A?a:i,n,r.x,r.y)){const t=Math.abs(n-r.y)/(i-r.x);Hs(r,e)&&(t<u||t===u&&(r.x>s.x||r.x===s.x&&Ds(s,r)))&&(s=r,u=t)}r=r.next}while(r!==o);return s}(e,t);if(!r)return t;const i=Ws(r,e);return Ss(i,i.next),Ss(r,r.next)}function Ds(e,t){return Vs(e.prev,e,t.prev)<0&&Vs(t.next,e,e.next)<0}function Is(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Fs(e){let t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==e);return r}function Os(e,t,r,i,n,s,a,o){return(n-a)*(t-o)>=(e-a)*(s-o)&&(e-a)*(i-o)>=(r-a)*(t-o)&&(r-a)*(s-o)>=(n-a)*(i-o)}function Ls(e,t,r,i,n,s,a,o){return!(e===a&&t===o)&&Os(e,t,r,i,n,s,a,o)}function ks(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&zs(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(Hs(e,t)&&Hs(t,e)&&function(e,t){let r=e,i=!1;const n=(e.x+t.x)/2,s=(e.y+t.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==e);return i}(e,t)&&(Vs(e.prev,e,t.prev)||Vs(e,t.prev,t))||Us(e,t)&&Vs(e.prev,e,e.next)>0&&Vs(t.prev,t,t.next)>0)}function Vs(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Us(e,t){return e.x===t.x&&e.y===t.y}function zs(e,t,r,i){const n=js(Vs(e,t,r)),s=js(Vs(e,t,i)),a=js(Vs(r,i,e)),o=js(Vs(r,i,t));return n!==s&&a!==o||(!(0!==n||!Gs(e,r,t))||(!(0!==s||!Gs(e,i,t))||(!(0!==a||!Gs(r,e,i))||!(0!==o||!Gs(r,t,i)))))}function Gs(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function js(e){return e>0?1:e<0?-1:0}function Hs(e,t){return Vs(e.prev,e,e.next)<0?Vs(e,t,e.next)>=0&&Vs(e,e.prev,t)>=0:Vs(e,t,e.prev)<0||Vs(e,e.next,t)<0}function Ws(e,t){const r=Xs(e.i,e.x,e.y),i=Xs(t.i,t.x,t.y),n=e.next,s=t.prev;return e.next=t,t.prev=e,r.next=n,n.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function Qs(e,t,r,i){const n=Xs(e,t,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function $s(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Xs(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ys(e){const t=[],r=[],i=e[0][0].length;let n=0,s=0;for(const a of e){for(const e of a)for(let r=0;r<i;r++)t.push(e[r]);s&&(n+=s,r.push(n)),s=a.length}return{vertices:t,holes:r,dimensions:i}}function Ks(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function Zs(e,t,r){return t=Js(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,ea()?Reflect.construct(t,[],Js(e).constructor):t.apply(e,r))}function Js(e){return Js=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Js(e)}function ea(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ea=function(){return!!e})()}function ta(e,t){return ta=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ta(e,t)}function ra(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||na(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ia(e){return function(e){if(Array.isArray(e))return Ks(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||na(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function na(e,t){if(e){if("string"==typeof e)return Ks(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ks(e,t):void 0}}var sa=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=[],r=null;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(i){if(r){var n=180*An(i,r)/Math.PI;if(n>e)for(var s=vn(r,i),a=r.length>2||i.length>2?at(r[2]||0,i[2]||0):null,o=a?function(e){return[].concat(ia(s(e)),[a(e)])}:s,l=1/Math.ceil(n/e),A=l;A<1;)t.push(o(A)),A+=l}t.push(r=i)}),t},aa="undefined"!=typeof window&&window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,Float32BufferAttribute:t.Float32BufferAttribute},oa=(new aa.BufferGeometry).setAttribute?"setAttribute":"addAttribute",la=function(e){function t(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=Zs(this,t)).type="GeoJsonGeometry",r.parameters={geoJson:e,radius:i,resolution:n};var s=({Point:A,MultiPoint:function(e,t){var r={vertices:[],indices:[]};return e.map(function(e){return A(e,t)}).forEach(function(e){var t=ra(e,1)[0];Aa(r,t)}),[r]},LineString:u,MultiLineString:function(e,t){var r={vertices:[],indices:[]};return e.map(function(e){return u(e,t)}).forEach(function(e){var t=ra(e,1)[0];Aa(r,t)}),[r]},Polygon:h,MultiPolygon:function(e,t){var r={vertices:[],indices:[]},i={vertices:[],indices:[]};e.map(function(e){return h(e,t)}).forEach(function(e){var t=ra(e,2),n=t[0],s=t[1];Aa(r,n),s&&Aa(i,s)});var n=[r];return i.vertices.length&&n.push(i),n}}[e.type]||function(){return[]})(e.coordinates,i),a=[],o=[],l=0;function A(e,t){return[{vertices:ha(e[1],e[0],t+(e[2]||0)),indices:[]}]}function u(e,t){for(var r=Ys([sa(e,n).map(function(e){var r=ra(e,3),i=r[0],n=r[1],s=r[2];return ha(n,i,t+(void 0===s?0:s))})]).vertices,i=Math.round(r.length/3),s=[],a=1;a<i;a++)s.push(a-1,a);return[{vertices:r,indices:s}]}function h(e,t){for(var r=Ys(e.map(function(e){return sa(e,n).map(function(e){var r=ra(e,3),i=r[0],n=r[1],s=r[2];return ha(n,i,t+(void 0===s?0:s))})})),i=r.vertices,s=r.holes,a=s[0]||1/0,o=i.slice(0,3*a),l=i.slice(3*a),A=new Set(s),u=Math.round(i.length/3),h=[],c=[],d=1;d<u;d++)A.has(d)||(d<a?h.push(d-1,d):c.push(d-1-a,d-a));var p=[{indices:h,vertices:o}];return s.length&&p.push({indices:c,vertices:l}),p}return s.forEach(function(e){var t=a.length;Aa({indices:a,vertices:o},e),r.addGroup(t,a.length-t,l++)}),a.length&&r.setIndex(a),o.length&&r[oa]("position",new aa.Float32BufferAttribute(o,3)),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ta(e,t)}(t,e),r=t,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(aa.BufferGeometry);function Aa(e,t){var r=Math.round(e.vertices.length/3);ua(e.vertices,t.vertices),ua(e.indices,t.indices.map(function(e){return e+r}))}function ua(e,t){var r,i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=na(e))||t){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}(t);try{for(i.s();!(r=i.n()).done;){var n=r.value;e.push(n)}}catch(e){i.e(e)}finally{i.f()}}function ha(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=(90-e)*Math.PI/180,n=(90-t)*Math.PI/180;return[r*Math.sin(i)*Math.cos(n),r*Math.cos(i),r*Math.sin(i)*Math.sin(n)]}function ca(e){let r,i,n,s=-1,a=0;for(let t=0;t<e.length;++t){const o=e[t];if(void 0===r&&(r=o.array.constructor),r!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===s&&(s=o.gpuType),s!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=o.count*i}const o=new r(a),l=new t.BufferAttribute(o,i,n);let A=0;for(let t=0;t<e.length;++t){const r=e[t];if(r.isInterleavedBufferAttribute){const e=A/i;for(let t=0,n=r.count;t<n;t++)for(let n=0;n<i;n++){const i=r.getComponent(t,n);l.setComponent(t+e,n,i)}}else o.set(r.array,A);A+=r.count*i}return void 0!==s&&(l.gpuType=s),l}function da(e){const r=e.data.array.constructor,i=e.count,n=e.itemSize,s=e.normalized,a=new r(i*n);let o;o=e.isInstancedInterleavedBufferAttribute?new t.InstancedBufferAttribute(a,n,s,e.meshPerAttribute):new t.BufferAttribute(a,n,s);for(let t=0;t<i;t++)o.setX(t,e.getX(t)),n>=2&&o.setY(t,e.getY(t)),n>=3&&o.setZ(t,e.getZ(t)),n>=4&&o.setW(t,e.getW(t));return o}var pa=Object.freeze({__proto__:null,computeMikkTSpaceTangents:function(e,r,i=!0){if(!r||!r.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!e.hasAttribute("position")||!e.hasAttribute("normal")||!e.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(e){if(e.normalized||e.isInterleavedBufferAttribute){const t=new Float32Array(e.count*e.itemSize);for(let r=0,i=0;r<e.count;r++)t[i++]=e.getX(r),t[i++]=e.getY(r),e.itemSize>2&&(t[i++]=e.getZ(r));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}const s=e.index?e.toNonIndexed():e,a=r.generateTangents(n(s.attributes.position),n(s.attributes.normal),n(s.attributes.uv));if(i)for(let e=3;e<a.length;e+=4)a[e]*=-1;return s.setAttribute("tangent",new t.BufferAttribute(a,4)),e!==s&&e.copy(s),e},computeMorphedAttributes:function(e){const r=new t.Vector3,i=new t.Vector3,n=new t.Vector3,s=new t.Vector3,a=new t.Vector3,o=new t.Vector3,l=new t.Vector3,A=new t.Vector3,u=new t.Vector3;function h(e,t,h,c,d,p,f,m){r.fromBufferAttribute(t,d),i.fromBufferAttribute(t,p),n.fromBufferAttribute(t,f);const g=e.morphTargetInfluences;if(h&&g){l.set(0,0,0),A.set(0,0,0),u.set(0,0,0);for(let e=0,t=h.length;e<t;e++){const t=g[e],m=h[e];0!==t&&(s.fromBufferAttribute(m,d),a.fromBufferAttribute(m,p),o.fromBufferAttribute(m,f),c?(l.addScaledVector(s,t),A.addScaledVector(a,t),u.addScaledVector(o,t)):(l.addScaledVector(s.sub(r),t),A.addScaledVector(a.sub(i),t),u.addScaledVector(o.sub(n),t)))}r.add(l),i.add(A),n.add(u)}e.isSkinnedMesh&&(e.applyBoneTransform(d,r),e.applyBoneTransform(p,i),e.applyBoneTransform(f,n)),m[3*d+0]=r.x,m[3*d+1]=r.y,m[3*d+2]=r.z,m[3*p+0]=i.x,m[3*p+1]=i.y,m[3*p+2]=i.z,m[3*f+0]=n.x,m[3*f+1]=n.y,m[3*f+2]=n.z}const c=e.geometry,d=e.material;let p,f,m;const g=c.index,y=c.attributes.position,b=c.morphAttributes.position,x=c.morphTargetsRelative,v=c.attributes.normal,_=c.morphAttributes.position,w=c.groups,T=c.drawRange;let M,S,E,N,C,R,B;const P=new Float32Array(y.count*y.itemSize),q=new Float32Array(v.count*v.itemSize);if(null!==g)if(Array.isArray(d))for(M=0,E=w.length;M<E;M++)for(C=w[M],R=Math.max(C.start,T.start),B=Math.min(C.start+C.count,T.start+T.count),S=R,N=B;S<N;S+=3)p=g.getX(S),f=g.getX(S+1),m=g.getX(S+2),h(e,y,b,x,p,f,m,P),h(e,v,_,x,p,f,m,q);else for(R=Math.max(0,T.start),B=Math.min(g.count,T.start+T.count),M=R,E=B;M<E;M+=3)p=g.getX(M),f=g.getX(M+1),m=g.getX(M+2),h(e,y,b,x,p,f,m,P),h(e,v,_,x,p,f,m,q);else if(Array.isArray(d))for(M=0,E=w.length;M<E;M++)for(C=w[M],R=Math.max(C.start,T.start),B=Math.min(C.start+C.count,T.start+T.count),S=R,N=B;S<N;S+=3)p=S,f=S+1,m=S+2,h(e,y,b,x,p,f,m,P),h(e,v,_,x,p,f,m,q);else for(R=Math.max(0,T.start),B=Math.min(y.count,T.start+T.count),M=R,E=B;M<E;M+=3)p=M,f=M+1,m=M+2,h(e,y,b,x,p,f,m,P),h(e,v,_,x,p,f,m,q);return{positionAttribute:y,normalAttribute:v,morphedPositionAttribute:new t.Float32BufferAttribute(P,3),morphedNormalAttribute:new t.Float32BufferAttribute(q,3)}},deepCloneAttribute:function(e){return e.isInstancedInterleavedBufferAttribute||e.isInterleavedBufferAttribute?da(e):e.isInstancedBufferAttribute?(new t.InstancedBufferAttribute).copy(e):(new t.BufferAttribute).copy(e)},deinterleaveAttribute:da,deinterleaveGeometry:function(e){const t=e.attributes,r=e.morphTargets,i=new Map;for(const e in t){const r=t[e];r.isInterleavedBufferAttribute&&(i.has(r)||i.set(r,da(r)),t[e]=i.get(r))}for(const e in r){const t=r[e];t.isInterleavedBufferAttribute&&(i.has(t)||i.set(t,da(t)),r[e]=i.get(t))}},estimateBytesUsed:function(e){let t=0;for(const r in e.attributes){const i=e.getAttribute(r);t+=i.count*i.itemSize*i.array.BYTES_PER_ELEMENT}const r=e.getIndex();return t+=r?r.count*r.itemSize*r.array.BYTES_PER_ELEMENT:0,t},interleaveAttributes:function(e){let r,i=0,n=0;for(let t=0,s=e.length;t<s;++t){const s=e[t];if(void 0===r&&(r=s.array.constructor),r!==s.array.constructor)return console.error("AttributeBuffers of different types cannot be interleaved"),null;i+=s.array.length,n+=s.itemSize}const s=new t.InterleavedBuffer(new r(i),n);let a=0;const o=[],l=["getX","getY","getZ","getW"],A=["setX","setY","setZ","setW"];for(let r=0,i=e.length;r<i;r++){const i=e[r],n=i.itemSize,u=i.count,h=new t.InterleavedBufferAttribute(s,n,a,i.normalized);o.push(h),a+=n;for(let e=0;e<u;e++)for(let t=0;t<n;t++)h[A[t]](e,i[l[t]](e))}return o},mergeAttributes:ca,mergeGeometries:function(e,r=!1){const i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),a={},o={},l=e[0].morphTargetsRelative,A=new t.BufferGeometry;let u=0;for(let t=0;t<e.length;++t){const h=e[t];let c=0;if(i!==(null!==h.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+t+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in h.attributes){if(!n.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+t+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[e]&&(a[e]=[]),a[e].push(h.attributes[e]),c++}if(c!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+t+". Make sure all geometries have the same number of attributes."),null;if(l!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+t+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in h.morphAttributes){if(!s.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+t+".  .morphAttributes must be consistent throughout all geometries."),null;void 0===o[e]&&(o[e]=[]),o[e].push(h.morphAttributes[e])}if(r){let e;if(i)e=h.index.count;else{if(void 0===h.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+t+". The geometry must have either an index or a position attribute"),null;e=h.attributes.position.count}A.addGroup(u,e,t),u+=e}}if(i){let t=0;const r=[];for(let i=0;i<e.length;++i){const n=e[i].index;for(let e=0;e<n.count;++e)r.push(n.getX(e)+t);t+=e[i].attributes.position.count}A.setIndex(r)}for(const e in a){const t=ca(a[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;A.setAttribute(e,t)}for(const e in o){const t=o[e][0].length;if(0===t)break;A.morphAttributes=A.morphAttributes||{},A.morphAttributes[e]=[];for(let r=0;r<t;++r){const t=[];for(let i=0;i<o[e].length;++i)t.push(o[e][i][r]);const i=ca(t);if(!i)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;A.morphAttributes[e].push(i)}}return A},mergeGroups:function(e){if(0===e.groups.length)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),e;let t=e.groups;if(t=t.sort((e,t)=>e.materialIndex!==t.materialIndex?e.materialIndex-t.materialIndex:e.start-t.start),null===e.getIndex()){const t=e.getAttribute("position"),r=[];for(let e=0;e<t.count;e+=3)r.push(e,e+1,e+2);e.setIndex(r)}const r=e.getIndex(),i=[];for(let e=0;e<t.length;e++){const n=t[e],s=n.start,a=s+n.count;for(let e=s;e<a;e++)i.push(r.getX(e))}e.dispose(),e.setIndex(i);let n=0;for(let e=0;e<t.length;e++){const r=t[e];r.start=n,n+=r.count}let s=t[0];e.groups=[s];for(let r=1;r<t.length;r++){const i=t[r];s.materialIndex===i.materialIndex?s.count+=i.count:(s=i,e.groups.push(s))}return e},mergeVertices:function(e,t=1e-4){t=Math.max(t,Number.EPSILON);const r={},i=e.getIndex(),n=e.getAttribute("position"),s=i?i.count:n.count;let a=0;const o=Object.keys(e.attributes),l={},A={},u=[],h=["getX","getY","getZ","getW"],c=["setX","setY","setZ","setW"];for(let t=0,r=o.length;t<r;t++){const r=o[t],i=e.attributes[r];l[r]=new i.constructor(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized);const n=e.morphAttributes[r];n&&(A[r]||(A[r]=[]),n.forEach((e,t)=>{const i=new e.array.constructor(e.count*e.itemSize);A[r][t]=new e.constructor(i,e.itemSize,e.normalized)}))}const d=.5*t,p=Math.log10(1/t),f=Math.pow(10,p),m=d*f;for(let t=0;t<s;t++){const n=i?i.getX(t):t;let s="";for(let t=0,r=o.length;t<r;t++){const r=o[t],i=e.getAttribute(r),a=i.itemSize;for(let e=0;e<a;e++)s+=~~(i[h[e]](n)*f+m)+","}if(s in r)u.push(r[s]);else{for(let t=0,r=o.length;t<r;t++){const r=o[t],i=e.getAttribute(r),s=e.morphAttributes[r],u=i.itemSize,d=l[r],p=A[r];for(let e=0;e<u;e++){const t=h[e],r=c[e];if(d[r](a,i[t](n)),s)for(let e=0,i=s.length;e<i;e++)p[e][r](a,s[e][t](n))}}r[s]=a,u.push(a),a++}}const g=e.clone();for(const t in e.attributes){const e=l[t];if(g.setAttribute(t,new e.constructor(e.array.slice(0,a*e.itemSize),e.itemSize,e.normalized)),t in A)for(let e=0;e<A[t].length;e++){const r=A[t][e];g.morphAttributes[t][e]=new r.constructor(r.array.slice(0,a*r.itemSize),r.itemSize,r.normalized)}}return g.setIndex(u),g},toCreasedNormals:function(e,r=Math.PI/3){const i=Math.cos(r),n=100*(1+1e-10),s=[new t.Vector3,new t.Vector3,new t.Vector3],a=new t.Vector3,o=new t.Vector3,l=new t.Vector3,A=new t.Vector3;function u(e){return`${~~(e.x*n)},${~~(e.y*n)},${~~(e.z*n)}`}const h=e.index?e.toNonIndexed():e,c=h.attributes.position,d={};for(let e=0,r=c.count/3;e<r;e++){const r=3*e,i=s[0].fromBufferAttribute(c,r+0),n=s[1].fromBufferAttribute(c,r+1),l=s[2].fromBufferAttribute(c,r+2);a.subVectors(l,n),o.subVectors(i,n);const A=(new t.Vector3).crossVectors(a,o).normalize();for(let e=0;e<3;e++){const t=u(s[e]);t in d||(d[t]=[]),d[t].push(A)}}const p=new Float32Array(3*c.count),f=new t.BufferAttribute(p,3,!1);for(let e=0,t=c.count/3;e<t;e++){const t=3*e,r=s[0].fromBufferAttribute(c,t+0),n=s[1].fromBufferAttribute(c,t+1),h=s[2].fromBufferAttribute(c,t+2);a.subVectors(h,n),o.subVectors(r,n),l.crossVectors(a,o).normalize();for(let e=0;e<3;e++){const r=d[u(s[e])];A.set(0,0,0);for(let e=0,t=r.length;e<t;e++){const t=r[e];l.dot(t)>i&&A.add(t)}A.normalize(),f.setXYZ(t+e,A.x,A.y,A.z)}}return h.setAttribute("normal",f),h},toTrianglesDrawMode:function(e,r){if(r===t.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(r===t.TriangleFanDrawMode||r===t.TriangleStripDrawMode){let i=e.getIndex();if(null===i){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const n=i.count-2,s=[];if(r===t.TriangleFanDrawMode)for(let e=1;e<=n;e++)s.push(i.getX(0)),s.push(i.getX(e)),s.push(i.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(s.push(i.getX(e)),s.push(i.getX(e+1)),s.push(i.getX(e+2))):(s.push(i.getX(e+2)),s.push(i.getX(e+1)),s.push(i.getX(e)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=e.clone();return a.setIndex(s),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",r),e}}),fa=function(e){return"function"==typeof e?e:"string"==typeof e?function(t){return t[e]}:function(t){return e}};function ma(e){return ma="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},ma(e)}var ga=/^\s+/,ya=/\s+$/;function ba(e,t){if(t=t||{},(e=e||"")instanceof ba)return e;if(!(this instanceof ba))return new ba(e,t);var r=function(e){var t={r:0,g:0,b:0},r=1,i=null,n=null,s=null,a=!1,o=!1;"string"==typeof e&&(e=function(e){e=e.replace(ga,"").replace(ya,"").toLowerCase();var t,r=!1;if(Fa[e])e=Fa[e],r=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};if(t=Xa.rgb.exec(e))return{r:t[1],g:t[2],b:t[3]};if(t=Xa.rgba.exec(e))return{r:t[1],g:t[2],b:t[3],a:t[4]};if(t=Xa.hsl.exec(e))return{h:t[1],s:t[2],l:t[3]};if(t=Xa.hsla.exec(e))return{h:t[1],s:t[2],l:t[3],a:t[4]};if(t=Xa.hsv.exec(e))return{h:t[1],s:t[2],v:t[3]};if(t=Xa.hsva.exec(e))return{h:t[1],s:t[2],v:t[3],a:t[4]};if(t=Xa.hex8.exec(e))return{r:Ua(t[1]),g:Ua(t[2]),b:Ua(t[3]),a:Ha(t[4]),format:r?"name":"hex8"};if(t=Xa.hex6.exec(e))return{r:Ua(t[1]),g:Ua(t[2]),b:Ua(t[3]),format:r?"name":"hex"};if(t=Xa.hex4.exec(e))return{r:Ua(t[1]+""+t[1]),g:Ua(t[2]+""+t[2]),b:Ua(t[3]+""+t[3]),a:Ha(t[4]+""+t[4]),format:r?"name":"hex8"};if(t=Xa.hex3.exec(e))return{r:Ua(t[1]+""+t[1]),g:Ua(t[2]+""+t[2]),b:Ua(t[3]+""+t[3]),format:r?"name":"hex"};return!1}(e));"object"==ma(e)&&(Ya(e.r)&&Ya(e.g)&&Ya(e.b)?(l=e.r,A=e.g,u=e.b,t={r:255*ka(l,255),g:255*ka(A,255),b:255*ka(u,255)},a=!0,o="%"===String(e.r).substr(-1)?"prgb":"rgb"):Ya(e.h)&&Ya(e.s)&&Ya(e.v)?(i=Ga(e.s),n=Ga(e.v),t=function(e,t,r){e=6*ka(e,360),t=ka(t,100),r=ka(r,100);var i=Math.floor(e),n=e-i,s=r*(1-t),a=r*(1-n*t),o=r*(1-(1-n)*t),l=i%6,A=[r,a,s,s,o,r][l],u=[o,r,r,a,s,s][l],h=[s,s,o,r,r,a][l];return{r:255*A,g:255*u,b:255*h}}(e.h,i,n),a=!0,o="hsv"):Ya(e.h)&&Ya(e.s)&&Ya(e.l)&&(i=Ga(e.s),s=Ga(e.l),t=function(e,t,r){var i,n,s;function a(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e}if(e=ka(e,360),t=ka(t,100),r=ka(r,100),0===t)i=n=s=r;else{var o=r<.5?r*(1+t):r+t-r*t,l=2*r-o;i=a(l,o,e+1/3),n=a(l,o,e),s=a(l,o,e-1/3)}return{r:255*i,g:255*n,b:255*s}}(e.h,i,s),a=!0,o="hsl"),e.hasOwnProperty("a")&&(r=e.a));var l,A,u;return r=La(r),{ok:a,format:e.format||o,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:r}}(e);this._originalInput=e,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||r.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=r.ok}function xa(e,t,r){e=ka(e,255),t=ka(t,255),r=ka(r,255);var i,n,s=Math.max(e,t,r),a=Math.min(e,t,r),o=(s+a)/2;if(s==a)i=n=0;else{var l=s-a;switch(n=o>.5?l/(2-s-a):l/(s+a),s){case e:i=(t-r)/l+(t<r?6:0);break;case t:i=(r-e)/l+2;break;case r:i=(e-t)/l+4}i/=6}return{h:i,s:n,l:o}}function va(e,t,r){e=ka(e,255),t=ka(t,255),r=ka(r,255);var i,n,s=Math.max(e,t,r),a=Math.min(e,t,r),o=s,l=s-a;if(n=0===s?0:l/s,s==a)i=0;else{switch(s){case e:i=(t-r)/l+(t<r?6:0);break;case t:i=(r-e)/l+2;break;case r:i=(e-t)/l+4}i/=6}return{h:i,s:n,v:o}}function _a(e,t,r,i){var n=[za(Math.round(e).toString(16)),za(Math.round(t).toString(16)),za(Math.round(r).toString(16))];return i&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function wa(e,t,r,i){return[za(ja(i)),za(Math.round(e).toString(16)),za(Math.round(t).toString(16)),za(Math.round(r).toString(16))].join("")}function Ta(e,t){t=0===t?0:t||10;var r=ba(e).toHsl();return r.s-=t/100,r.s=Va(r.s),ba(r)}function Ma(e,t){t=0===t?0:t||10;var r=ba(e).toHsl();return r.s+=t/100,r.s=Va(r.s),ba(r)}function Sa(e){return ba(e).desaturate(100)}function Ea(e,t){t=0===t?0:t||10;var r=ba(e).toHsl();return r.l+=t/100,r.l=Va(r.l),ba(r)}function Na(e,t){t=0===t?0:t||10;var r=ba(e).toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(-t/100*255))),r.g=Math.max(0,Math.min(255,r.g-Math.round(-t/100*255))),r.b=Math.max(0,Math.min(255,r.b-Math.round(-t/100*255))),ba(r)}function Ca(e,t){t=0===t?0:t||10;var r=ba(e).toHsl();return r.l-=t/100,r.l=Va(r.l),ba(r)}function Ra(e,t){var r=ba(e).toHsl(),i=(r.h+t)%360;return r.h=i<0?360+i:i,ba(r)}function Ba(e){var t=ba(e).toHsl();return t.h=(t.h+180)%360,ba(t)}function Pa(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var r=ba(e).toHsl(),i=[ba(e)],n=360/t,s=1;s<t;s++)i.push(ba({h:(r.h+s*n)%360,s:r.s,l:r.l}));return i}function qa(e){var t=ba(e).toHsl(),r=t.h;return[ba(e),ba({h:(r+72)%360,s:t.s,l:t.l}),ba({h:(r+216)%360,s:t.s,l:t.l})]}function Da(e,t,r){t=t||6,r=r||30;var i=ba(e).toHsl(),n=360/r,s=[ba(e)];for(i.h=(i.h-(n*t>>1)+720)%360;--t;)i.h=(i.h+n)%360,s.push(ba(i));return s}function Ia(e,t){t=t||6;for(var r=ba(e).toHsv(),i=r.h,n=r.s,s=r.v,a=[],o=1/t;t--;)a.push(ba({h:i,s:n,v:s})),s=(s+o)%1;return a}ba.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,r,i=this.toRgb();return e=i.r/255,t=i.g/255,r=i.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))},setAlpha:function(e){return this._a=La(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=va(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=va(this._r,this._g,this._b),t=Math.round(360*e.h),r=Math.round(100*e.s),i=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+r+"%, "+i+"%)":"hsva("+t+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var e=xa(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=xa(this._r,this._g,this._b),t=Math.round(360*e.h),r=Math.round(100*e.s),i=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+r+"%, "+i+"%)":"hsla("+t+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(e){return _a(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,t,r,i,n){var s=[za(Math.round(e).toString(16)),za(Math.round(t).toString(16)),za(Math.round(r).toString(16)),za(ja(i))];if(n&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)&&s[3].charAt(0)==s[3].charAt(1))return s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0)+s[3].charAt(0);return s.join("")}(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*ka(this._r,255))+"%",g:Math.round(100*ka(this._g,255))+"%",b:Math.round(100*ka(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*ka(this._r,255))+"%, "+Math.round(100*ka(this._g,255))+"%, "+Math.round(100*ka(this._b,255))+"%)":"rgba("+Math.round(100*ka(this._r,255))+"%, "+Math.round(100*ka(this._g,255))+"%, "+Math.round(100*ka(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(Oa[_a(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+wa(this._r,this._g,this._b,this._a),r=t,i=this._gradientType?"GradientType = 1, ":"";if(e){var n=ba(e);r="#"+wa(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+t+",endColorstr="+r+")"},toString:function(e){var t=!!e;e=e||this._format;var r=!1,i=this._a<1&&this._a>=0;return t||!i||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(r=this.toRgbString()),"prgb"===e&&(r=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(r=this.toHexString()),"hex3"===e&&(r=this.toHexString(!0)),"hex4"===e&&(r=this.toHex8String(!0)),"hex8"===e&&(r=this.toHex8String()),"name"===e&&(r=this.toName()),"hsl"===e&&(r=this.toHslString()),"hsv"===e&&(r=this.toHsvString()),r||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return ba(this.toString())},_applyModification:function(e,t){var r=e.apply(null,[this].concat([].slice.call(t)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Ea,arguments)},brighten:function(){return this._applyModification(Na,arguments)},darken:function(){return this._applyModification(Ca,arguments)},desaturate:function(){return this._applyModification(Ta,arguments)},saturate:function(){return this._applyModification(Ma,arguments)},greyscale:function(){return this._applyModification(Sa,arguments)},spin:function(){return this._applyModification(Ra,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(Da,arguments)},complement:function(){return this._applyCombination(Ba,arguments)},monochromatic:function(){return this._applyCombination(Ia,arguments)},splitcomplement:function(){return this._applyCombination(qa,arguments)},triad:function(){return this._applyCombination(Pa,[3])},tetrad:function(){return this._applyCombination(Pa,[4])}},ba.fromRatio=function(e,t){if("object"==ma(e)){var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]="a"===i?e[i]:Ga(e[i]));e=r}return ba(e,t)},ba.equals=function(e,t){return!(!e||!t)&&ba(e).toRgbString()==ba(t).toRgbString()},ba.random=function(){return ba.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},ba.mix=function(e,t,r){r=0===r?0:r||50;var i=ba(e).toRgb(),n=ba(t).toRgb(),s=r/100;return ba({r:(n.r-i.r)*s+i.r,g:(n.g-i.g)*s+i.g,b:(n.b-i.b)*s+i.b,a:(n.a-i.a)*s+i.a})},
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
ba.readability=function(e,t){var r=ba(e),i=ba(t);return(Math.max(r.getLuminance(),i.getLuminance())+.05)/(Math.min(r.getLuminance(),i.getLuminance())+.05)},ba.isReadable=function(e,t,r){var i,n,s=ba.readability(e,t);switch(n=!1,(i=function(e){var t,r;t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(e.size||"small").toLowerCase(),"AA"!==t&&"AAA"!==t&&(t="AA");"small"!==r&&"large"!==r&&(r="small");return{level:t,size:r}}(r)).level+i.size){case"AAsmall":case"AAAlarge":n=s>=4.5;break;case"AAlarge":n=s>=3;break;case"AAAsmall":n=s>=7}return n},ba.mostReadable=function(e,t,r){var i,n,s,a,o=null,l=0;n=(r=r||{}).includeFallbackColors,s=r.level,a=r.size;for(var A=0;A<t.length;A++)(i=ba.readability(e,t[A]))>l&&(l=i,o=ba(t[A]));return ba.isReadable(e,o,{level:s,size:a})||!n?o:(r.includeFallbackColors=!1,ba.mostReadable(e,["#fff","#000"],r))};var Fa=ba.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Oa=ba.hexNames=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}(Fa);function La(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function ka(e,t){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var r=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=Math.min(t,Math.max(0,parseFloat(e))),r&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function Va(e){return Math.min(1,Math.max(0,e))}function Ua(e){return parseInt(e,16)}function za(e){return 1==e.length?"0"+e:""+e}function Ga(e){return e<=1&&(e=100*e+"%"),e}function ja(e){return Math.round(255*parseFloat(e)).toString(16)}function Ha(e){return Ua(e)/255}var Wa,Qa,$a,Xa=(Qa="[\\s|\\(]+("+(Wa="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+Wa+")[,|\\s]+("+Wa+")\\s*\\)?",$a="[\\s|\\(]+("+Wa+")[,|\\s]+("+Wa+")[,|\\s]+("+Wa+")[,|\\s]+("+Wa+")\\s*\\)?",{CSS_UNIT:new RegExp(Wa),rgb:new RegExp("rgb"+Qa),rgba:new RegExp("rgba"+$a),hsl:new RegExp("hsl"+Qa),hsla:new RegExp("hsla"+$a),hsv:new RegExp("hsv"+Qa),hsva:new RegExp("hsva"+$a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function Ya(e){return!!Xa.CSS_UNIT.exec(e)}function Ka(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function Za(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function Ja(e,t){return e.get(Za(e,t))}function eo(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function to(e,t,r){return e.set(Za(e,t),r),r}function ro(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,so(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function io(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t);else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||ao(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function no(e){return function(e){if(Array.isArray(e))return Ka(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ao(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function so(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function ao(e,t){if(e){if("string"==typeof e)return Ka(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ka(e,t):void 0}}var oo=new WeakMap,lo=new WeakMap,Ao=new WeakMap,uo=new WeakMap,ho=new WeakMap,co=new WeakMap,po=function(){return ro(function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),eo(this,oo,new Map),eo(this,lo,new Map),eo(this,Ao,function(e){return e}),eo(this,uo,function(){return{}}),eo(this,ho,function(){}),eo(this,co,function(){})},[{key:"getObj",value:function(e){return Ja(oo,this).get(Ja(Ao,this).call(this,e))}},{key:"getData",value:function(e){return Ja(lo,this).get(e)}},{key:"entries",value:function(){return no(Ja(lo,this).entries()).map(function(e){var t=io(e,2),r=t[0];return[t[1],r]})}},{key:"id",value:function(e){return to(Ao,this,fa(e)),this}},{key:"onCreateObj",value:function(e){return to(uo,this,e),this}},{key:"onUpdateObj",value:function(e){return to(ho,this,e),this}},{key:"onRemoveObj",value:function(e){return to(co,this,e),this}},{key:"digest",value:function(e){var t=this;e.filter(function(e){return!Ja(oo,t).has(Ja(Ao,t).call(t,e))}).forEach(function(e){var r=Ja(uo,t).call(t,e);Ja(oo,t).set(Ja(Ao,t).call(t,e),r),Ja(lo,t).set(r,e)});var r=new Map(e.map(function(e){return[Ja(Ao,t).call(t,e),e]}));return Ja(oo,this).forEach(function(e,i){r.has(i)?Ja(ho,t).call(t,e,r.get(i)):(Ja(co,t).call(t,e,i),Ja(oo,t).delete(i),Ja(lo,t).delete(e))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])}();function fo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mo,go={exports:{}};var yo=(mo||(mo=1,function(e){e.exports=function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var i=r(1),n=function(){function e(e,t,r){void 0===e&&(e=NaN),void 0===t&&(t=NaN),void 0===r&&(r=!1),this._minFPS=t,this._maxFPS=e,this._timeScale=1,this._currentTick=0,this._currentTime=0,this._tickDeltaTime=0,this._isRunning=!1,this._maxInterval=isNaN(this._minFPS)?NaN:1e3/this._minFPS,this._minInterval=isNaN(this._maxFPS)?NaN:1e3/this._maxFPS,this._onResume=new i.default,this._onPause=new i.default,this._onTick=new i.default,this._onTickOncePerFrame=new i.default,r||this.resume()}return e.prototype.updateOnce=function(e){e(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.resume=function(){this._isRunning||(this._isRunning=!0,this._lastTimeUpdated=this.getTimer(),this._onResume.dispatch(),this.animateOnce())},e.prototype.pause=function(){this._isRunning&&(this._isRunning=!1,this._onPause.dispatch(),window.cancelAnimationFrame(this._animationFrameHandle))},e.prototype.dispose=function(){this.pause(),this._onResume.removeAll(),this._onPause.removeAll(),this._onTick.removeAll()},Object.defineProperty(e.prototype,"currentTick",{get:function(){return this._currentTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTimeSeconds",{get:function(){return this._currentTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tickDeltaTimeSeconds",{get:function(){return this._tickDeltaTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"timeScale",{get:function(){return this._timeScale},set:function(e){this._timeScale!==e&&(this._timeScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onResume",{get:function(){return this._onResume},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onPause",{get:function(){return this._onPause},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTick",{get:function(){return this._onTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTickOncePerFrame",{get:function(){return this._onTickOncePerFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRunning",{get:function(){return this._isRunning},enumerable:!0,configurable:!0}),e.prototype.animateOnce=function(){var e=this;this._animationFrameHandle=window.requestAnimationFrame(function(){return e.onFrame()})},e.prototype.onFrame=function(){if(this._now=this.getTimer(),this._frameDeltaTime=this._now-this._lastTimeUpdated,isNaN(this._minInterval)||this._frameDeltaTime>=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},e.prototype.update=function(e,t){void 0===t&&(t=!0),this._currentTick++,this._currentTime+=e,this._tickDeltaTime=e,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),t&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.getTimer=function(){return Date.now()},e}();Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,r){!function(t,r){e.exports=r()}(0,function(){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t){var r=function(){function e(){this.functions=[]}return e.prototype.add=function(e){return-1===this.functions.indexOf(e)&&(this.functions.push(e),!0)},e.prototype.remove=function(e){var t=this.functions.indexOf(e);return t>-1&&(this.functions.splice(t,1),!0)},e.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.functions.concat().forEach(function(t){t.apply(void 0,e)})},Object.defineProperty(e.prototype,"numItems",{get:function(){return this.functions.length},enumerable:!0,configurable:!0}),e}();Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}])})}])}(go)),go.exports),bo=fo(yo);const xo=134217729;function vo(e,t,r,i,n){let s,a,o,l,A=t[0],u=i[0],h=0,c=0;u>A==u>-A?(s=A,A=t[++h]):(s=u,u=i[++c]);let d=0;if(h<e&&c<r)for(u>A==u>-A?(a=A+s,o=s-(a-A),A=t[++h]):(a=u+s,o=s-(a-u),u=i[++c]),s=a,0!==o&&(n[d++]=o);h<e&&c<r;)u>A==u>-A?(a=s+A,l=a-s,o=s-(a-l)+(A-l),A=t[++h]):(a=s+u,l=a-s,o=s-(a-l)+(u-l),u=i[++c]),s=a,0!==o&&(n[d++]=o);for(;h<e;)a=s+A,l=a-s,o=s-(a-l)+(A-l),A=t[++h],s=a,0!==o&&(n[d++]=o);for(;c<r;)a=s+u,l=a-s,o=s-(a-l)+(u-l),u=i[++c],s=a,0!==o&&(n[d++]=o);return 0===s&&0!==d||(n[d++]=s),d}function _o(e){return new Float64Array(e)}const wo=_o(4),To=_o(8),Mo=_o(12),So=_o(16),Eo=_o(4);function No(e,t,r,i,n,s){const a=(t-s)*(r-n),o=(e-n)*(i-s),l=a-o,A=Math.abs(a+o);return Math.abs(l)>=33306690738754716e-32*A?l:-function(e,t,r,i,n,s,a){let o,l,A,u,h,c,d,p,f,m,g,y,b,x,v,_,w,T;const M=e-n,S=r-n,E=t-s,N=i-s;x=M*N,c=xo*M,d=c-(c-M),p=M-d,c=xo*N,f=c-(c-N),m=N-f,v=p*m-(x-d*f-p*f-d*m),_=E*S,c=xo*E,d=c-(c-E),p=E-d,c=xo*S,f=c-(c-S),m=S-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,wo[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,wo[1]=b-(g+h)+(h-_),T=y+g,h=T-y,wo[2]=y-(T-h)+(g-h),wo[3]=T;let C=function(e,t){let r=t[0];for(let i=1;i<e;i++)r+=t[i];return r}(4,wo),R=22204460492503146e-32*a;if(C>=R||-C>=R)return C;if(h=e-M,o=e-(M+h)+(h-n),h=r-S,A=r-(S+h)+(h-n),h=t-E,l=t-(E+h)+(h-s),h=i-N,u=i-(N+h)+(h-s),0===o&&0===l&&0===A&&0===u)return C;if(R=11093356479670487e-47*a+33306690738754706e-32*Math.abs(C),C+=M*u+N*o-(E*A+S*l),C>=R||-C>=R)return C;x=o*N,c=xo*o,d=c-(c-o),p=o-d,c=xo*N,f=c-(c-N),m=N-f,v=p*m-(x-d*f-p*f-d*m),_=l*S,c=xo*l,d=c-(c-l),p=l-d,c=xo*S,f=c-(c-S),m=S-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,Eo[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,Eo[1]=b-(g+h)+(h-_),T=y+g,h=T-y,Eo[2]=y-(T-h)+(g-h),Eo[3]=T;const B=vo(4,wo,4,Eo,To);x=M*u,c=xo*M,d=c-(c-M),p=M-d,c=xo*u,f=c-(c-u),m=u-f,v=p*m-(x-d*f-p*f-d*m),_=E*A,c=xo*E,d=c-(c-E),p=E-d,c=xo*A,f=c-(c-A),m=A-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,Eo[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,Eo[1]=b-(g+h)+(h-_),T=y+g,h=T-y,Eo[2]=y-(T-h)+(g-h),Eo[3]=T;const P=vo(B,To,4,Eo,Mo);x=o*u,c=xo*o,d=c-(c-o),p=o-d,c=xo*u,f=c-(c-u),m=u-f,v=p*m-(x-d*f-p*f-d*m),_=l*A,c=xo*l,d=c-(c-l),p=l-d,c=xo*A,f=c-(c-A),m=A-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,Eo[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,Eo[1]=b-(g+h)+(h-_),T=y+g,h=T-y,Eo[2]=y-(T-h)+(g-h),Eo[3]=T;const q=vo(P,Mo,4,Eo,So);return So[q-1]}(e,t,r,i,n,s,A)}const Co=Math.pow(2,-52),Ro=new Uint32Array(512);class Bo{static from(e,t=Oo,r=Lo){const i=e.length,n=new Float64Array(2*i);for(let s=0;s<i;s++){const i=e[s];n[2*s]=t(i),n[2*s+1]=r(i)}return new Bo(n)}constructor(e){const t=e.length>>1;if(t>0&&"number"!=typeof e[0])throw new Error("Expected coords to contain numbers.");this.coords=e;const r=Math.max(2*t-5,0);this._triangles=new Uint32Array(3*r),this._halfedges=new Int32Array(3*r),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:r,_hullTri:i,_hullHash:n}=this,s=e.length>>1;let a=1/0,o=1/0,l=-1/0,A=-1/0;for(let t=0;t<s;t++){const r=e[2*t],i=e[2*t+1];r<a&&(a=r),i<o&&(o=i),r>l&&(l=r),i>A&&(A=i),this._ids[t]=t}const u=(a+l)/2,h=(o+A)/2;let c,d,p;for(let t=0,r=1/0;t<s;t++){const i=Po(u,h,e[2*t],e[2*t+1]);i<r&&(c=t,r=i)}const f=e[2*c],m=e[2*c+1];for(let t=0,r=1/0;t<s;t++){if(t===c)continue;const i=Po(f,m,e[2*t],e[2*t+1]);i<r&&i>0&&(d=t,r=i)}let g=e[2*d],y=e[2*d+1],b=1/0;for(let t=0;t<s;t++){if(t===c||t===d)continue;const r=Do(f,m,g,y,e[2*t],e[2*t+1]);r<b&&(p=t,b=r)}let x=e[2*p],v=e[2*p+1];if(b===1/0){for(let t=0;t<s;t++)this._dists[t]=e[2*t]-e[0]||e[2*t+1]-e[1];Io(this._ids,this._dists,0,s-1);const t=new Uint32Array(s);let r=0;for(let e=0,i=-1/0;e<s;e++){const n=this._ids[e],s=this._dists[n];s>i&&(t[r++]=n,i=s)}return this.hull=t.subarray(0,r),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(No(f,m,g,y,x,v)<0){const e=d,t=g,r=y;d=p,g=x,y=v,p=e,x=t,v=r}const _=function(e,t,r,i,n,s){const a=r-e,o=i-t,l=n-e,A=s-t,u=a*a+o*o,h=l*l+A*A,c=.5/(a*A-o*l);return{x:e+(A*u-o*h)*c,y:t+(a*h-l*u)*c}}(f,m,g,y,x,v);this._cx=_.x,this._cy=_.y;for(let t=0;t<s;t++)this._dists[t]=Po(e[2*t],e[2*t+1],_.x,_.y);Io(this._ids,this._dists,0,s-1),this._hullStart=c;let w=3;r[c]=t[p]=d,r[d]=t[c]=p,r[p]=t[d]=c,i[c]=0,i[d]=1,i[p]=2,n.fill(-1),n[this._hashKey(f,m)]=c,n[this._hashKey(g,y)]=d,n[this._hashKey(x,v)]=p,this.trianglesLen=0,this._addTriangle(c,d,p,-1,-1,-1);for(let s,a,o=0;o<this._ids.length;o++){const l=this._ids[o],A=e[2*l],u=e[2*l+1];if(o>0&&Math.abs(A-s)<=Co&&Math.abs(u-a)<=Co)continue;if(s=A,a=u,l===c||l===d||l===p)continue;let h=0;for(let e=0,t=this._hashKey(A,u);e<this._hashSize&&(h=n[(t+e)%this._hashSize],-1===h||h===r[h]);e++);h=t[h];let f,m=h;for(;f=r[m],No(A,u,e[2*m],e[2*m+1],e[2*f],e[2*f+1])>=0;)if(m=f,m===h){m=-1;break}if(-1===m)continue;let g=this._addTriangle(m,l,r[m],-1,-1,i[m]);i[l]=this._legalize(g+2),i[m]=g,w++;let y=r[m];for(;f=r[y],No(A,u,e[2*y],e[2*y+1],e[2*f],e[2*f+1])<0;)g=this._addTriangle(y,l,f,i[l],-1,i[y]),i[l]=this._legalize(g+2),r[y]=y,w--,y=f;if(m===h)for(;f=t[m],No(A,u,e[2*f],e[2*f+1],e[2*m],e[2*m+1])<0;)g=this._addTriangle(f,l,m,-1,i[m],i[f]),this._legalize(g+2),i[f]=g,r[m]=m,w--,m=f;this._hullStart=t[l]=m,r[m]=t[y]=l,r[l]=y,n[this._hashKey(A,u)]=l,n[this._hashKey(e[2*m],e[2*m+1])]=m}this.hull=new Uint32Array(w);for(let e=0,t=this._hullStart;e<w;e++)this.hull[e]=t,t=r[t];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(function(e,t){const r=e/(Math.abs(e)+Math.abs(t));return(t>0?3-r:1+r)/4}(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:r,coords:i}=this;let n=0,s=0;for(;;){const a=r[e],o=e-e%3;if(s=o+(e+2)%3,-1===a){if(0===n)break;e=Ro[--n];continue}const l=a-a%3,A=o+(e+1)%3,u=l+(a+2)%3,h=t[s],c=t[e],d=t[A],p=t[u];if(qo(i[2*h],i[2*h+1],i[2*c],i[2*c+1],i[2*d],i[2*d+1],i[2*p],i[2*p+1])){t[e]=p,t[a]=h;const i=r[u];if(-1===i){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,i),this._link(a,r[s]),this._link(s,u);const o=l+(a+1)%3;n<Ro.length&&(Ro[n++]=o)}else{if(0===n)break;e=Ro[--n]}}return s}_link(e,t){this._halfedges[e]=t,-1!==t&&(this._halfedges[t]=e)}_addTriangle(e,t,r,i,n,s){const a=this.trianglesLen;return this._triangles[a]=e,this._triangles[a+1]=t,this._triangles[a+2]=r,this._link(a,i),this._link(a+1,n),this._link(a+2,s),this.trianglesLen+=3,a}}function Po(e,t,r,i){const n=e-r,s=t-i;return n*n+s*s}function qo(e,t,r,i,n,s,a,o){const l=e-a,A=t-o,u=r-a,h=i-o,c=n-a,d=s-o,p=u*u+h*h,f=c*c+d*d;return l*(h*f-p*d)-A*(u*f-p*c)+(l*l+A*A)*(u*d-h*c)<0}function Do(e,t,r,i,n,s){const a=r-e,o=i-t,l=n-e,A=s-t,u=a*a+o*o,h=l*l+A*A,c=.5/(a*A-o*l),d=(A*u-o*h)*c,p=(a*h-l*u)*c;return d*d+p*p}function Io(e,t,r,i){if(i-r<=20)for(let n=r+1;n<=i;n++){const i=e[n],s=t[i];let a=n-1;for(;a>=r&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=i}else{let n=r+1,s=i;Fo(e,r+i>>1,n),t[e[r]]>t[e[i]]&&Fo(e,r,i),t[e[n]]>t[e[i]]&&Fo(e,n,i),t[e[r]]>t[e[n]]&&Fo(e,r,n);const a=e[n],o=t[a];for(;;){do{n++}while(t[e[n]]<o);do{s--}while(t[e[s]]>o);if(s<n)break;Fo(e,n,s)}e[r+1]=e[s],e[s]=a,i-n+1>=s-r?(Io(e,t,n,i),Io(e,t,r,s-1)):(Io(e,t,r,s-1),Io(e,t,n,i))}}function Fo(e,t,r){const i=e[t];e[t]=e[r],e[r]=i}function Oo(e){return e[0]}function Lo(e){return e[1]}function ko(e,t){var r,i,n,s,a,o,l,A,u,h=0,c=e[0],d=e[1],p=t.length;for(r=0;r<p;r++){i=0;var f=t[r],m=f.length-1;if((A=f[0])[0]!==f[m][0]&&A[1]!==f[m][1])throw new Error("First and last coordinates in a ring must be the same");for(s=A[0]-c,a=A[1]-d;i<m;i++){if(o=(u=f[i+1])[0]-c,l=u[1]-d,0===a&&0===l){if(o<=0&&s>=0||s<=0&&o>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(0===(n=No(s,o,a,l,0,0)))return 0;(n>0&&l>0&&a<=0||n<0&&l<=0&&a>0)&&h++}A=u,a=l,s=o}}return h%2!=0}var Vo=function(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=function(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}(e),n="Feature"===(s=t).type?s.geometry:s;var s;const a=n.type,o=t.bbox;let l=n.coordinates;if(o&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(i,o))return!1;"Polygon"===a&&(l=[l]);let A=!1;for(var u=0;u<l.length;++u){const e=ko(i,l[u]);if(0===e)return!r.ignoreBoundary;e&&(A=!0)}return A};const Uo=1e-6;class zo{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,r){const i=(e=+e)+(r=+r),n=t=+t;if(r<0)throw new Error("negative radius");null===this._x1?this._+=`M${i},${n}`:(Math.abs(this._x1-i)>Uo||Math.abs(this._y1-n)>Uo)&&(this._+="L"+i+","+n),r&&(this._+=`A${r},${r},0,1,1,${e-r},${t}A${r},${r},0,1,1,${this._x1=i},${this._y1=n}`)}rect(e,t,r,i){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+r}v${+i}h${-r}Z`}value(){return this._||null}}class Go{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class jo{constructor(e,[t,r,i,n]=[0,0,960,500]){if(!((i=+i)>=(t=+t)&&(n=+n)>=(r=+r)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(2*e.points.length),this.vectors=new Float64Array(2*e.points.length),this.xmax=i,this.xmin=t,this.ymax=n,this.ymin=r,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:r},vectors:i}=this;let n,s;const a=this.circumcenters=this._circumcenters.subarray(0,r.length/3*2);for(let i,o,l=0,A=0,u=r.length;l<u;l+=3,A+=2){const u=2*r[l],h=2*r[l+1],c=2*r[l+2],d=e[u],p=e[u+1],f=e[h],m=e[h+1],g=e[c],y=e[c+1],b=f-d,x=m-p,v=g-d,_=y-p,w=2*(b*_-x*v);if(Math.abs(w)<1e-9){if(void 0===n){n=s=0;for(const r of t)n+=e[2*r],s+=e[2*r+1];n/=t.length,s/=t.length}const r=1e9*Math.sign((n-d)*_-(s-p)*v);i=(d+g)/2-r*_,o=(p+y)/2+r*v}else{const e=1/w,t=b*b+x*x,r=v*v+_*_;i=d+(_*t-x*r)*e,o=p+(b*r-v*t)*e}a[A]=i,a[A+1]=o}let o,l,A,u=t[t.length-1],h=4*u,c=e[2*u],d=e[2*u+1];i.fill(0);for(let r=0;r<t.length;++r)u=t[r],o=h,l=c,A=d,h=4*u,c=e[2*u],d=e[2*u+1],i[o+2]=i[h]=A-d,i[o+3]=i[h+1]=c-l}render(e){const t=null==e?e=new zo:void 0,{delaunay:{halfedges:r,inedges:i,hull:n},circumcenters:s,vectors:a}=this;if(n.length<=1)return null;for(let t=0,i=r.length;t<i;++t){const i=r[t];if(i<t)continue;const n=2*Math.floor(t/3),a=2*Math.floor(i/3),o=s[n],l=s[n+1],A=s[a],u=s[a+1];this._renderSegment(o,l,A,u,e)}let o,l=n[n.length-1];for(let t=0;t<n.length;++t){o=l,l=n[t];const r=2*Math.floor(i[l]/3),A=s[r],u=s[r+1],h=4*o,c=this._project(A,u,a[h+2],a[h+3]);c&&this._renderSegment(A,u,c[0],c[1],e)}return t&&t.value()}renderBounds(e){const t=null==e?e=new zo:void 0;return e.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),t&&t.value()}renderCell(e,t){const r=null==t?t=new zo:void 0,i=this._clip(e);if(null===i||!i.length)return;t.moveTo(i[0],i[1]);let n=i.length;for(;i[0]===i[n-2]&&i[1]===i[n-1]&&n>1;)n-=2;for(let e=2;e<n;e+=2)i[e]===i[e-2]&&i[e+1]===i[e-1]||t.lineTo(i[e],i[e+1]);return t.closePath(),r&&r.value()}*cellPolygons(){const{delaunay:{points:e}}=this;for(let t=0,r=e.length/2;t<r;++t){const e=this.cellPolygon(t);e&&(e.index=t,yield e)}}cellPolygon(e){const t=new Go;return this.renderCell(e,t),t.value()}_renderSegment(e,t,r,i,n){let s;const a=this._regioncode(e,t),o=this._regioncode(r,i);0===a&&0===o?(n.moveTo(e,t),n.lineTo(r,i)):(s=this._clipSegment(e,t,r,i,a,o))&&(n.moveTo(s[0],s[1]),n.lineTo(s[2],s[3]))}contains(e,t,r){return(t=+t)==t&&(r=+r)==r&&this.delaunay._step(e,t,r)===e}*neighbors(e){const t=this._clip(e);if(t)for(const r of this.delaunay.neighbors(e)){const e=this._clip(r);if(e)e:for(let i=0,n=t.length;i<n;i+=2)for(let s=0,a=e.length;s<a;s+=2)if(t[i]===e[s]&&t[i+1]===e[s+1]&&t[(i+2)%n]===e[(s+a-2)%a]&&t[(i+3)%n]===e[(s+a-1)%a]){yield r;break e}}}_cell(e){const{circumcenters:t,delaunay:{inedges:r,halfedges:i,triangles:n}}=this,s=r[e];if(-1===s)return null;const a=[];let o=s;do{const r=Math.floor(o/3);if(a.push(t[2*r],t[2*r+1]),o=o%3==2?o-2:o+1,n[o]!==e)break;o=i[o]}while(o!==s&&-1!==o);return a}_clip(e){if(0===e&&1===this.delaunay.hull.length)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];const t=this._cell(e);if(null===t)return null;const{vectors:r}=this,i=4*e;return this._simplify(r[i]||r[i+1]?this._clipInfinite(e,t,r[i],r[i+1],r[i+2],r[i+3]):this._clipFinite(e,t))}_clipFinite(e,t){const r=t.length;let i,n,s,a,o=null,l=t[r-2],A=t[r-1],u=this._regioncode(l,A),h=0;for(let c=0;c<r;c+=2)if(i=l,n=A,l=t[c],A=t[c+1],s=u,u=this._regioncode(l,A),0===s&&0===u)a=h,h=0,o?o.push(l,A):o=[l,A];else{let t,r,c,d,p;if(0===s){if(null===(t=this._clipSegment(i,n,l,A,s,u)))continue;[r,c,d,p]=t}else{if(null===(t=this._clipSegment(l,A,i,n,u,s)))continue;[d,p,r,c]=t,a=h,h=this._edgecode(r,c),a&&h&&this._edge(e,a,h,o,o.length),o?o.push(r,c):o=[r,c]}a=h,h=this._edgecode(d,p),a&&h&&this._edge(e,a,h,o,o.length),o?o.push(d,p):o=[d,p]}if(o)a=h,h=this._edgecode(o[0],o[1]),a&&h&&this._edge(e,a,h,o,o.length);else if(this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return o}_clipSegment(e,t,r,i,n,s){const a=n<s;for(a&&([e,t,r,i,n,s]=[r,i,e,t,s,n]);;){if(0===n&&0===s)return a?[r,i,e,t]:[e,t,r,i];if(n&s)return null;let o,l,A=n||s;8&A?(o=e+(r-e)*(this.ymax-t)/(i-t),l=this.ymax):4&A?(o=e+(r-e)*(this.ymin-t)/(i-t),l=this.ymin):2&A?(l=t+(i-t)*(this.xmax-e)/(r-e),o=this.xmax):(l=t+(i-t)*(this.xmin-e)/(r-e),o=this.xmin),n?(e=o,t=l,n=this._regioncode(e,t)):(r=o,i=l,s=this._regioncode(r,i))}}_clipInfinite(e,t,r,i,n,s){let a,o=Array.from(t);if((a=this._project(o[0],o[1],r,i))&&o.unshift(a[0],a[1]),(a=this._project(o[o.length-2],o[o.length-1],n,s))&&o.push(a[0],a[1]),o=this._clipFinite(e,o))for(let t,r=0,i=o.length,n=this._edgecode(o[i-2],o[i-1]);r<i;r+=2)t=n,n=this._edgecode(o[r],o[r+1]),t&&n&&(r=this._edge(e,t,n,o,r),i=o.length);else this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(o=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return o}_edge(e,t,r,i,n){for(;t!==r;){let r,s;switch(t){case 5:t=4;continue;case 4:t=6,r=this.xmax,s=this.ymin;break;case 6:t=2;continue;case 2:t=10,r=this.xmax,s=this.ymax;break;case 10:t=8;continue;case 8:t=9,r=this.xmin,s=this.ymax;break;case 9:t=1;continue;case 1:t=5,r=this.xmin,s=this.ymin}i[n]===r&&i[n+1]===s||!this.contains(e,r,s)||(i.splice(n,0,r,s),n+=2)}return n}_project(e,t,r,i){let n,s,a,o=1/0;if(i<0){if(t<=this.ymin)return null;(n=(this.ymin-t)/i)<o&&(a=this.ymin,s=e+(o=n)*r)}else if(i>0){if(t>=this.ymax)return null;(n=(this.ymax-t)/i)<o&&(a=this.ymax,s=e+(o=n)*r)}if(r>0){if(e>=this.xmax)return null;(n=(this.xmax-e)/r)<o&&(s=this.xmax,a=t+(o=n)*i)}else if(r<0){if(e<=this.xmin)return null;(n=(this.xmin-e)/r)<o&&(s=this.xmin,a=t+(o=n)*i)}return[s,a]}_edgecode(e,t){return(e===this.xmin?1:e===this.xmax?2:0)|(t===this.ymin?4:t===this.ymax?8:0)}_regioncode(e,t){return(e<this.xmin?1:e>this.xmax?2:0)|(t<this.ymin?4:t>this.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t<e.length;t+=2){const r=(t+2)%e.length,i=(t+4)%e.length;(e[t]===e[r]&&e[r]===e[i]||e[t+1]===e[r+1]&&e[r+1]===e[i+1])&&(e.splice(r,2),t-=2)}e.length||(e=null)}return e}}const Ho=2*Math.PI,Wo=Math.pow;function Qo(e){return e[0]}function $o(e){return e[1]}function Xo(e,t,r){return[e+Math.sin(e+t)*r,t+Math.cos(e-t)*r]}class Yo{static from(e,t=Qo,r=$o,i){return new Yo("length"in e?function(e,t,r,i){const n=e.length,s=new Float64Array(2*n);for(let a=0;a<n;++a){const n=e[a];s[2*a]=t.call(i,n,a,e),s[2*a+1]=r.call(i,n,a,e)}return s}(e,t,r,i):Float64Array.from(function*(e,t,r,i){let n=0;for(const s of e)yield t.call(i,s,n,e),yield r.call(i,s,n,e),++n}(e,t,r,i)))}constructor(e){this._delaunator=new Bo(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&function(e){const{triangles:t,coords:r}=e;for(let e=0;e<t.length;e+=3){const i=2*t[e],n=2*t[e+1],s=2*t[e+2];if((r[s]-r[i])*(r[n+1]-r[i+1])-(r[n]-r[i])*(r[s+1]-r[i+1])>1e-10)return!1}return!0}(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,r)=>t[2*e]-t[2*r]||t[2*e+1]-t[2*r+1]);const e=this.collinear[0],r=this.collinear[this.collinear.length-1],i=[t[2*e],t[2*e+1],t[2*r],t[2*r+1]],n=1e-8*Math.hypot(i[3]-i[1],i[2]-i[0]);for(let e=0,r=t.length/2;e<r;++e){const r=Xo(t[2*e],t[2*e+1],n);t[2*e]=r[0],t[2*e+1]=r[1]}this._delaunator=new Bo(t)}else delete this.collinear;const r=this.halfedges=this._delaunator.halfedges,i=this.hull=this._delaunator.hull,n=this.triangles=this._delaunator.triangles,s=this.inedges.fill(-1),a=this._hullIndex.fill(-1);for(let e=0,t=r.length;e<t;++e){const t=n[e%3==2?e-2:e+1];-1!==r[e]&&-1!==s[t]||(s[t]=e)}for(let e=0,t=i.length;e<t;++e)a[i[e]]=e;i.length<=2&&i.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=i[0],s[i[0]]=1,2===i.length&&(s[i[1]]=0,this.triangles[1]=i[1],this.triangles[2]=i[1]))}voronoi(e){return new jo(this,e)}*neighbors(e){const{inedges:t,hull:r,_hullIndex:i,halfedges:n,triangles:s,collinear:a}=this;if(a){const t=a.indexOf(e);return t>0&&(yield a[t-1]),void(t<a.length-1&&(yield a[t+1]))}const o=t[e];if(-1===o)return;let l=o,A=-1;do{if(yield A=s[l],l=l%3==2?l-2:l+1,s[l]!==e)return;if(l=n[l],-1===l){const t=r[(i[e]+1)%r.length];return void(t!==A&&(yield t))}}while(l!==o)}find(e,t,r=0){if((e=+e)!=e||(t=+t)!=t)return-1;const i=r;let n;for(;(n=this._step(r,e,t))>=0&&n!==r&&n!==i;)r=n;return n}_step(e,t,r){const{inedges:i,hull:n,_hullIndex:s,halfedges:a,triangles:o,points:l}=this;if(-1===i[e]||!l.length)return(e+1)%(l.length>>1);let A=e,u=Wo(t-l[2*e],2)+Wo(r-l[2*e+1],2);const h=i[e];let c=h;do{let i=o[c];const h=Wo(t-l[2*i],2)+Wo(r-l[2*i+1],2);if(h<u&&(u=h,A=i),c=c%3==2?c-2:c+1,o[c]!==e)break;if(c=a[c],-1===c){if(c=n[(s[e]+1)%n.length],c!==i&&Wo(t-l[2*c],2)+Wo(r-l[2*c+1],2)<u)return c;break}}while(c!==h);return A}render(e){const t=null==e?e=new zo:void 0,{points:r,halfedges:i,triangles:n}=this;for(let t=0,s=i.length;t<s;++t){const s=i[t];if(s<t)continue;const a=2*n[t],o=2*n[s];e.moveTo(r[a],r[a+1]),e.lineTo(r[o],r[o+1])}return this.renderHull(e),t&&t.value()}renderPoints(e,t){void 0!==t||e&&"function"==typeof e.moveTo||(t=e,e=null),t=null==t?2:+t;const r=null==e?e=new zo:void 0,{points:i}=this;for(let r=0,n=i.length;r<n;r+=2){const n=i[r],s=i[r+1];e.moveTo(n+t,s),e.arc(n,s,t,0,Ho)}return r&&r.value()}renderHull(e){const t=null==e?e=new zo:void 0,{hull:r,points:i}=this,n=2*r[0],s=r.length;e.moveTo(i[n],i[n+1]);for(let t=1;t<s;++t){const n=2*r[t];e.lineTo(i[n],i[n+1])}return e.closePath(),t&&t.value()}hullPolygon(){const e=new Go;return this.renderHull(e),e.value()}renderTriangle(e,t){const r=null==t?t=new zo:void 0,{points:i,triangles:n}=this,s=2*n[e*=3],a=2*n[e+1],o=2*n[e+2];return t.moveTo(i[s],i[s+1]),t.lineTo(i[a],i[a+1]),t.lineTo(i[o],i[o+1]),t.closePath(),r&&r.value()}*trianglePolygons(){const{triangles:e}=this;for(let t=0,r=e.length/3;t<r;++t)yield this.trianglePolygon(t)}trianglePolygon(e){const t=new Go;return this.renderTriangle(e,t),t.value()}}const Ko=Math.PI,Zo=Ko/2,Jo=180/Ko,el=Ko/180,tl=Math.atan2,rl=Math.cos,il=Math.max,nl=Math.min,sl=Math.sin,al=Math.sign||function(e){return e>0?1:e<0?-1:0},ol=Math.sqrt;function ll(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Al(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function ul(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function hl(e){var t=ol(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function cl(e){return[tl(e[1],e[0])*Jo,(t=il(-1,nl(1,e[2])),(t>1?Zo:t<-1?-Zo:Math.asin(t))*Jo)];var t}function dl(e){const t=e[0]*el,r=e[1]*el,i=rl(r);return[i*rl(t),i*sl(t),sl(r)]}function pl(e){return ll((e=e.map(e=>dl(e)))[0],Al(e[2],e[1]))}function fl(e){const t=function(e){if(e.length<2)return{};let t=0;for(;isNaN(e[t][0]+e[t][1])&&t++<e.length;);const r=function(e){function t(t){return(t=e(t[0]*Wt,t[1]*Wt))[0]*=Ht,t[1]*=Ht,t}return e=Pi(e[0]*Wt,e[1]*Wt,e.length>2?e[2]*Wt:0),t.invert=function(t){return(t=e.invert(t[0]*Wt,t[1]*Wt))[0]*=Ht,t[1]*=Ht,t},t}(e[t]),i=kn().translate([0,0]).scale(1).rotate(r.invert([180,0]));e=e.map(i);const n=[];let s=1;for(let t=0,r=e.length;t<r;t++){let r=e[t][0]**2+e[t][1]**2;!isFinite(r)||r>1e32?n.push(t):r>s&&(s=r)}const a=1e6*ol(s);n.forEach(t=>e[t]=[a,0]),e.push([0,a]),e.push([-a,0]),e.push([0,-a]);const o=Yo.from(e);o.projection=i;const{triangles:l,halfedges:A,inedges:u}=o;for(let r=0,i=A.length;r<i;r++)if(A[r]<0){const e=r%3==2?r-2:r+1,i=r%3==0?r+2:r-1,n=A[e],s=A[i];A[n]=s,A[s]=n,A[e]=A[i]=-1,l[r]=l[e]=l[i]=t,u[l[n]]=n%3==0?n+2:n-1,u[l[s]]=s%3==0?s+2:s-1,r+=2-r%3}else l[r]>e.length-3-1&&(l[r]=t);return o}(e),r=function(e){const{triangles:t}=e;if(!t)return[];const r=[];for(let e=0,i=t.length/3;e<i;e++){const i=t[3*e],n=t[3*e+1],s=t[3*e+2];i!==n&&n!==s&&r.push([i,s,n])}return r}(t),i=function(e,t){const r=new Set;return 2===t.length?[[0,1]]:(e.forEach(e=>{if(e[0]!==e[1]&&!(pl(e.map(e=>t[e]))<0))for(let t,i=0;i<3;i++)t=(i+1)%3,r.add(oe([e[i],e[t]]).join("-"))}),Array.from(r,e=>e.split("-").map(Number)))}(r,e),n=function(e,t){const r=[];e.forEach(e=>{for(let t=0;t<3;t++){const i=e[t],n=e[(t+1)%3];r[i]=r[i]||[],r[i].push(n)}}),0===e.length&&(2===t?(r[0]=[1],r[1]=[0]):1===t&&(r[0]=[]));return r}(r,e.length),s=function(e,t){function r(e,t){let r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2];return r*r+i*i+n*n}return function(i,n,s){void 0===s&&(s=0);let a,o,l=s;const A=dl([i,n]);do{a=s,s=null,o=r(A,dl(t[a])),e[a].forEach(e=>{let i=r(A,dl(t[e]));if(i<o)return o=i,s=e,void(l=e)})}while(null!==s);return l}}(n,e),a=function(e,t){return e.map(e=>{const r=e.map(e=>t[e]).map(dl);return cl(hl(ul(ul(Al(r[1],r[0]),Al(r[2],r[1])),Al(r[0],r[2]))))})}(r,e),{polygons:o,centers:l}=function(e,t,r){const i=[],n=e.slice();if(0===t.length){if(r.length<2)return{polygons:i,centers:n};if(2===r.length){const e=dl(r[0]),t=dl(r[1]),s=hl(ul(e,t)),o=hl(Al(e,t)),l=Al(s,o),A=[s,Al(s,l),Al(Al(s,l),l),Al(Al(Al(s,l),l),l)].map(cl).map(a);return i.push(A),i.push(A.slice().reverse()),{polygons:i,centers:n}}}t.forEach((e,t)=>{for(let r=0;r<3;r++){const n=e[r],s=e[(r+1)%3],a=e[(r+2)%3];i[n]=i[n]||[],i[n].push([s,a,t,[n,s,a]])}});const s=i.map(e=>{const t=[e[0][2]];let i=e[0][1];for(let r=1;r<e.length;r++)for(let r=0;r<e.length;r++)if(e[r][0]==i){i=e[r][1],t.push(e[r][2]);break}if(t.length>2)return t;if(2==t.length){const i=ml(r[e[0][3][0]],r[e[0][3][1]],n[t[0]]),s=ml(r[e[0][3][2]],r[e[0][3][0]],n[t[0]]),o=a(i),l=a(s);return[t[0],l,t[1],o]}});function a(e){let r=-1;return n.slice(t.length,1/0).forEach((i,n)=>{i[0]===e[0]&&i[1]===e[1]&&(r=n+t.length)}),r<0&&(r=n.length,n.push(e)),r}return{polygons:s,centers:n}}(a,r,e),A=function(e){const t=[];return e.forEach(e=>{if(!e)return;let r=e[e.length-1];for(let i of e)i>r&&t.push([r,i]),r=i}),t}(o),u=function(e,t){const r=new Set,i=[];e.map(e=>{if(!(pl(e.map(e=>t[e>t.length?0:e]))>1e-12))for(let t=0;t<3;t++){let i=[e[t],e[(t+1)%3]],n=`${i[0]}-${i[1]}`;r.has(n)?r.delete(n):r.add(`${i[1]}-${i[0]}`)}});const n=new Map;let s;if(r.forEach(e=>{e=e.split("-").map(Number),n.set(e[0],e[1]),s=e[0]}),void 0===s)return i;let a=s;do{i.push(a);let e=n.get(a);n.set(a,-1),a=e}while(a>-1&&a!==s);return i}(r,e),h=function(e,t){return function(r){const i=new Map,n=new Map;return e.forEach((e,t)=>{const s=e.join("-");i.set(s,r[t]),n.set(s,!0)}),t.forEach(e=>{let t=0,r=-1;for(let n=0;n<3;n++){let s=oe([e[n],e[(n+1)%3]]).join("-");i.get(s)>t&&(t=i.get(s),r=s)}n.set(r,!1)}),e.map(e=>n.get(e.join("-")))}}(i,r);return{delaunay:t,edges:i,triangles:r,centers:l,neighbors:n,polygons:o,mesh:A,hull:u,urquhart:h,find:s}}function ml(e,t,r){e=dl(e),t=dl(t),r=dl(r);const i=al(ll(Al(t,e),r));return cl(hl(ul(e,t)).map(e=>i*e))}function gl(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function yl(e,t,r){return t=bl(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,xl()?Reflect.construct(t,[],bl(e).constructor):t.apply(e,r))}function bl(e){return bl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},bl(e)}function xl(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(xl=function(){return!!e})()}function vl(e,t){return vl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},vl(e,t)}function _l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t);else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||Tl(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function wl(e){return function(e){if(Array.isArray(e))return gl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Tl(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tl(e,t){if(e){if("string"==typeof e)return gl(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?gl(e,t):void 0}}function Ml(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).resolution,r=void 0===t?1/0:t,i=function(e,t){return e.map(function(e){var r,i=[];return e.forEach(function(e){if(r){var n=180*An(e,r)/Math.PI;if(n>t)for(var s=vn(r,e),a=1/Math.ceil(n/t),o=a;o<1;)i.push(s(o)),o+=a}i.push(r=e)}),i})}(e,r),n=pe(i),s=function(e,t){var r={type:"Polygon",coordinates:e},i=gi(r),n=_l(i,2),s=_l(n[0],2),a=s[0],o=s[1],l=_l(n[1],2),A=l[0],u=l[1];if(Math.min(Math.abs(A-a),Math.abs(u-o))<t)return[];var h=a>A||u>=89||o<=-89;return function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minLng,i=t.maxLng,n=t.minLat,s=t.maxLat,a=Math.round(Math.pow(360/e,2)/Math.PI),o=(1+Math.sqrt(5))/2,l=function(e){return e/o*360%360-180},A=function(e){return Math.acos(2*e/a-1)/Math.PI*180-90},u=function(e){return a*(Math.cos((e+90)*Math.PI/180)+1)/2},h=[void 0!==s?Math.ceil(u(s)):0,void 0!==n?Math.floor(u(n)):a-1],c=void 0===r&&void 0===i?function(){return!0}:void 0===r?function(e){return e<=i}:void 0===i?function(e){return e>=r}:i>=r?function(e){return e>=r&&e<=i}:function(e){return e>=r||e<=i},d=[],p=h[0];p<=h[1];p++){var f=l(p);c(f)&&d.push([f,A(p)])}return d}(t,{minLng:a,maxLng:A,minLat:o,maxLat:u}).filter(function(e){return Sl(e,r,h)})}(e,r),a=[].concat(wl(n),wl(s)),o={type:"Polygon",coordinates:e},l=_l(gi(o),2),A=_l(l[0],2),u=A[0],h=A[1],c=_l(l[1],2),d=c[0],p=c[1],f=u>d||p>=89||h<=-89,m=[];if(f){var g=function(e){const t=function(e){if(t.delaunay=null,t._data=e,"object"==typeof t._data&&"FeatureCollection"===t._data.type&&(t._data=t._data.features),"object"==typeof t._data){const e=t._data.map(e=>[t._vx(e),t._vy(e),e]).filter(e=>isFinite(e[0]+e[1]));t.points=e.map(e=>[e[0],e[1]]),t.valid=e.map(e=>e[2]),t.delaunay=fl(t.points)}return t};return t._vx=function(e){return"object"==typeof e&&"type"in e?Ci(e)[0]:0 in e?e[0]:void 0},t._vy=function(e){return"object"==typeof e&&"type"in e?Ci(e)[1]:1 in e?e[1]:void 0},t.x=function(e){return e?(t._vx=e,t):t._vx},t.y=function(e){return e?(t._vy=e,t):t._vy},t.polygons=function(e){if(void 0!==e&&t(e),!t.delaunay)return!1;const r={type:"FeatureCollection",features:[]};return 0===t.valid.length||(t.delaunay.polygons.forEach((e,i)=>r.features.push({type:"Feature",geometry:e?{type:"Polygon",coordinates:[[...e,e[0]].map(e=>t.delaunay.centers[e])]}:null,properties:{site:t.valid[i],sitecoordinates:t.points[i],neighbours:t.delaunay.neighbors[i]}})),1===t.valid.length&&r.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:t.valid[0],sitecoordinates:t.points[0],neighbours:[]}})),r},t.triangles=function(e){return void 0!==e&&t(e),!!t.delaunay&&{type:"FeatureCollection",features:t.delaunay.triangles.map((e,r)=>((e=e.map(e=>t.points[e])).center=t.delaunay.centers[r],e)).filter(e=>pl(e)>0).map(e=>({type:"Feature",properties:{circumcenter:e.center},geometry:{type:"Polygon",coordinates:[[...e,e[0]]]}}))}},t.links=function(e){if(void 0!==e&&t(e),!t.delaunay)return!1;const r=t.delaunay.edges.map(e=>An(t.points[e[0]],t.points[e[1]])),i=t.delaunay.urquhart(r);return{type:"FeatureCollection",features:t.delaunay.edges.map((e,n)=>({type:"Feature",properties:{source:t.valid[e[0]],target:t.valid[e[1]],length:r[n],urquhart:!!i[n]},geometry:{type:"LineString",coordinates:[t.points[e[0]],t.points[e[1]]]}}))}},t.mesh=function(e){return void 0!==e&&t(e),!!t.delaunay&&{type:"MultiLineString",coordinates:t.delaunay.edges.map(e=>[t.points[e[0]],t.points[e[1]]])}},t.cellMesh=function(e){if(void 0!==e&&t(e),!t.delaunay)return!1;const{centers:r,polygons:i}=t.delaunay,n=[];for(const e of i)if(e)for(let t=e.length,i=e[t-1],s=e[0],a=0;a<t;i=s,s=e[++a])s>i&&n.push([r[i],r[s]]);return{type:"MultiLineString",coordinates:n}},t._found=void 0,t.find=function(e,r,i){if(t._found=t.delaunay.find(e,r,t._found),!i||An([e,r],t.points[t._found])<i)return t._found},t.hull=function(e){void 0!==e&&t(e);const r=t.delaunay.hull,i=t.points;return 0===r.length?null:{type:"Polygon",coordinates:[[...r.map(e=>i[e]),i[r[0]]]]}},e?t(e):t}(a).triangles(),y=new Map(a.map(function(e,t){var r=_l(e,2),i=r[0],n=r[1];return["".concat(i,"-").concat(n),t]}));g.features.forEach(function(e){var t,r=e.geometry.coordinates[0].slice(0,3).reverse(),i=[];if(r.forEach(function(e){var t=_l(e,2),r=t[0],n=t[1],s="".concat(r,"-").concat(n);y.has(s)&&i.push(y.get(s))}),3===i.length){if(i.some(function(e){return e<n.length}))if(!Sl(e.properties.circumcenter,o,f))return;(t=m).push.apply(t,i)}})}else if(s.length)for(var b=Bo.from(a),x=function(e){var t,r=[2,1,0].map(function(t){return b.triangles[e+t]}),i=r.map(function(e){return a[e]});if(r.some(function(e){return e<n.length})){var s=[0,1].map(function(e){return function(e,t){let r=0,i=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(++r,i+=t);else{let n=-1;for(let s of e)null!=(s=t(s,++n,e))&&(s=+s)>=s&&(++r,i+=s)}if(r)return i/r}(i,function(t){return t[e]})});if(!Sl(s,o,f))return 1}(t=m).push.apply(t,wl(r))},v=0,_=b.triangles.length;v<_;v+=3)x(v);else{var w=Ys(i),T=w.vertices,M=w.holes;m=Ts(T,void 0===M?[]:M,2)}var S=Ot(oe(a,function(e){return e[0]}),[0,1]),E=Ot(oe(a,function(e){return e[1]}),[0,1]),N=a.map(function(e){var t=_l(e,2),r=t[0],i=t[1];return[S(r),E(i)]});return{contour:i,triangles:{points:a,indices:m,uvs:N}}}function Sl(e,t){return arguments.length>2&&void 0!==arguments[2]&&arguments[2]?function(e,t){return(e&&un.hasOwnProperty(e.type)?un[e.type]:cn)(e,t)}(t,e):Vo(e,t)}var El=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,Float32BufferAttribute:t.Float32BufferAttribute},Nl=(new El.BufferGeometry).setAttribute?"setAttribute":"addAttribute",Cl=function(e){function t(e,r,i,n,s,a,o){var l;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(l=yl(this,t)).type="ConicPolygonGeometry",l.parameters={polygonGeoJson:e,bottomHeight:r,topHeight:i,closedBottom:n,closedTop:s,includeSides:a,curvatureResolution:o},r=r||0,i=i||1,n=void 0===n||n,s=void 0===s||s,a=void 0===a||a;var A=Ml(e,{resolution:o=o||5}),u=A.contour,h=A.triangles,c=pe(h.uvs),d=[],p=[],f=[],m=0,g=function(e){var t=Math.round(d.length/3),r=f.length;d=d.concat(e.vertices),p=p.concat(e.uvs),f=f.concat(t?e.indices.map(function(e){return e+t}):e.indices),l.addGroup(r,f.length-r,m++)};function y(e,t){var r="function"==typeof t?t:function(){return t},i=e.map(function(e){return e.map(function(e){var t=_l(e,2),i=t[0],n=t[1];return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=(90-e)*Math.PI/180,n=(90-t)*Math.PI/180;return[r*Math.sin(i)*Math.cos(n),r*Math.cos(i),r*Math.sin(i)*Math.sin(n)]}(n,i,r(i,n))})});return Ys(i)}function b(e){return{indices:!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?h.indices:h.indices.slice().reverse(),vertices:y([h.points],e).vertices,uvs:c}}return a&&g(function(){for(var e=y(u,r),t=e.vertices,n=e.holes,s=y(u,i).vertices,a=pe([s,t]),o=Math.round(s.length/3),l=new Set(n),A=0,h=[],c=0;c<o;c++){var d=c+1;if(d===o)d=A;else if(l.has(d)){var p=d;d=A,A=p}h.push(c,c+o,d+o),h.push(d+o,d,c)}for(var f=[],m=1;m>=0;m--)for(var g=0;g<o;g+=1)f.push(g/(o-1),m);return{indices:h,vertices:a,uvs:f}}()),n&&g(b(r,!1)),s&&g(b(i,!0)),l.setIndex(f),l[Nl]("position",new El.Float32BufferAttribute(d,3)),l[Nl]("uv",new El.Float32BufferAttribute(p,2)),l.computeVertexNormals(),l}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&vl(e,t)}(t,e),r=t,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(El.BufferGeometry);function Rl(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function Bl(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t);else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||Dl(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Pl(e){return function(e){if(Array.isArray(e))return Rl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Dl(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ql(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function Dl(e,t){if(e){if("string"==typeof e)return Rl(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rl(e,t):void 0}}var Il=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=(t instanceof Array?t.length?t:[void 0]:[t]).map(function(e){return{keyAccessor:e,isProp:!(e instanceof Function)}}),s=e.reduce(function(e,t){var i=e,s=t;return n.forEach(function(e,t){var a,o=e.keyAccessor;if(e.isProp){var l=s,A=l[o],u=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.includes(i))continue;r[i]=e[i]}return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(l,[o].map(ql));a=A,s=u}else a=o(s,t);t+1<n.length?(i.hasOwnProperty(a)||(i[a]={}),i=i[a]):r?(i.hasOwnProperty(a)||(i[a]=[]),i[a].push(s)):i[a]=s}),e},{});r instanceof Function&&function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;i===n.length?Object.keys(t).forEach(function(e){return t[e]=r(t[e])}):Object.values(t).forEach(function(t){return e(t,i+1)})}(s);var a=s;return i&&(a=[],function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];r.length===n.length?a.push({keys:r,vals:t}):Object.entries(t).forEach(function(t){var i=Bl(t,2),n=i[0],s=i[1];return e(s,[].concat(Pl(r),[n]))})}(s),t instanceof Array&&0===t.length&&1===a.length&&(a[0].keys=[])),a},Fl=function(e){var t,r=void 0!==(e=e||{})?e:{},i={};for(t in r)r.hasOwnProperty(t)&&(i[t]=r[t]);var n,s,a,o,l;n="object"==typeof window,s="function"==typeof importScripts,o="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,a=o&&!n&&!s,l=!n&&!a&&!s;var A,u,h,c,d,p="";a?(p=__dirname+"/",A=function(e,t){var r;return(r=te(e))||(c||(c=require("fs")),d||(d=require("path")),e=d.normalize(e),r=c.readFileSync(e)),t?r:r.toString()},h=function(e){var t=A(e,!0);return t.buffer||(t=new Uint8Array(t)),b(t.buffer),t},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),r.inspect=function(){return"[Emscripten Module object]"}):l?("undefined"!=typeof read&&(A=function(e){var t=te(e);return t?J(t):read(e)}),h=function(e){var t;return(t=te(e))?t:"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(b("object"==typeof(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs&&scriptArgs,"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(n||s)&&(s?p=self.location.href:"undefined"!=typeof document&&document.currentScript&&(p=document.currentScript.src),p=0!==p.indexOf("blob:")?p.substr(0,p.lastIndexOf("/")+1):"",A=function(e){try{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText}catch(t){var r=te(e);if(r)return J(r);throw t}},s&&(h=function(e){try{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}catch(t){var r=te(e);if(r)return r;throw t}}),u=function(e,t,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){if(200==i.status||0==i.status&&i.response)t(i.response);else{var n=te(e);n?t(n.buffer):r()}},i.onerror=r,i.send(null)});var f=r.print||console.log.bind(console),m=r.printErr||console.warn.bind(console);for(t in i)i.hasOwnProperty(t)&&(r[t]=i[t]);i=null,r.arguments&&r.arguments,r.thisProgram&&r.thisProgram;var g=0;var y=!1;function b(e,t){e||fe("Assertion failed: "+t)}function x(e){var t=r["_"+e];return b(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function v(e,t,r,i,n){var s={string:function(e){var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);(function(e,t,r){(function(e,t,r,i){if(!(i>0))return 0;for(var n=r,s=r+i-1,a=0;a<e.length;++a){var o=e.charCodeAt(a);if(o>=55296&&o<=57343)o=65536+((1023&o)<<10)|1023&e.charCodeAt(++a);if(o<=127){if(r>=s)break;t[r++]=o}else if(o<=2047){if(r+1>=s)break;t[r++]=192|o>>6,t[r++]=128|63&o}else if(o<=65535){if(r+2>=s)break;t[r++]=224|o>>12,t[r++]=128|o>>6&63,t[r++]=128|63&o}else{if(r+3>=s)break;t[r++]=240|o>>18,t[r++]=128|o>>12&63,t[r++]=128|o>>6&63,t[r++]=128|63&o}}t[r]=0})(e,T,t,r)})(e,t=ae(r),r)}return t},array:function(e){var t=ae(e.length);return function(e,t){w.set(e,t)}(e,t),t}};var a=x(e),o=[],l=0;if(i)for(var A=0;A<i.length;A++){var u=s[r[A]];u?(0===l&&(l=le()),o[A]=u(i[A])):o[A]=i[A]}var h=a.apply(null,o);return h=function(e){return"string"===t?R(e):"boolean"===t?Boolean(e):e}(h),0!==l&&oe(l),h}var _,w,T,M,S,E,N,C="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function R(e,t){return e?function(e,t,r){for(var i=t+r,n=t;e[n]&&!(n>=i);)++n;if(n-t>16&&e.subarray&&C)return C.decode(e.subarray(t,n));for(var s="";t<n;){var a=e[t++];if(128&a){var o=63&e[t++];if(192!=(224&a)){var l=63&e[t++];if((a=224==(240&a)?(15&a)<<12|o<<6|l:(7&a)<<18|o<<12|l<<6|63&e[t++])<65536)s+=String.fromCharCode(a);else{var A=a-65536;s+=String.fromCharCode(55296|A>>10,56320|1023&A)}}else s+=String.fromCharCode((31&a)<<6|o)}else s+=String.fromCharCode(a)}return s}(T,e,t):""}function B(e,t){return e%t>0&&(e+=t-e%t),e}function P(e){_=e,r.HEAP8=w=new Int8Array(e),r.HEAP16=M=new Int16Array(e),r.HEAP32=S=new Int32Array(e),r.HEAPU8=T=new Uint8Array(e),r.HEAPU16=new Uint16Array(e),r.HEAPU32=new Uint32Array(e),r.HEAPF32=E=new Float32Array(e),r.HEAPF64=N=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var q=r.TOTAL_MEMORY||33554432;function D(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var i=t.func;"number"==typeof i?void 0===t.arg?r.dynCall_v(i):r.dynCall_vi(i,t.arg):i(void 0===t.arg?null:t.arg)}else t()}}q=(_=r.buffer?r.buffer:new ArrayBuffer(q)).byteLength,P(_),S[7152]=5271520;var I=[],F=[],O=[],L=[];function k(e){I.unshift(e)}function V(e){L.unshift(e)}var U=Math.abs,z=Math.ceil,G=Math.floor,j=Math.min,H=0,W=null;r.preloadedImages={},r.preloadedAudios={};var Q,$,X=null,Y="data:application/octet-stream;base64,";function K(e){return String.prototype.startsWith?e.startsWith(Y):0===e.indexOf(Y)}X="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAY2VsbFRvVmVydGV4AGdyYXBoLT5idWNrZXRzICE9IE5VTEwAdmVydGV4R3JhcGguYwBpbml0VmVydGV4R3JhcGgAbm9kZSAhPSBOVUxMAGFkZFZlcnRleE5vZGU=";function Z(){return w.length}function J(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];i>255&&(i&=255),t.push(String.fromCharCode(i))}return t.join("")}var ee="function"==typeof atob?atob:function(e){var t,r,i,n,s,a,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",A=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=o.indexOf(e.charAt(A++))<<2|(n=o.indexOf(e.charAt(A++)))>>4,r=(15&n)<<4|(s=o.indexOf(e.charAt(A++)))>>2,i=(3&s)<<6|(a=o.indexOf(e.charAt(A++))),l+=String.fromCharCode(t),64!==s&&(l+=String.fromCharCode(r)),64!==a&&(l+=String.fromCharCode(i))}while(A<e.length);return l};function te(e){if(K(e))return function(e){if("boolean"==typeof a&&a){var t;try{t=Buffer.from(e,"base64")}catch(r){t=new Buffer(e,"base64")}return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}try{for(var r=ee(e),i=new Uint8Array(r.length),n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}catch(e){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(Y.length))}var re=function(e,t,r){var i=new e.Int8Array(r),n=new e.Int32Array(r);new e.Uint8Array(r),new e.Float32Array(r);var s=new e.Float64Array(r),a=0|t.o,o=0|t.p,l=e.Math.floor,A=e.Math.abs,u=e.Math.sqrt,h=e.Math.pow,c=e.Math.cos,d=e.Math.sin,p=e.Math.tan,f=e.Math.acos,m=e.Math.asin,g=e.Math.atan,y=e.Math.atan2,b=e.Math.ceil,x=e.Math.imul,v=e.Math.min,_=e.Math.max,w=e.Math.clz32,T=t.b,M=t.c,S=t.d,E=t.e,N=t.f,C=t.g,R=t.h,B=t.i,P=28640;function q(e,t,r,i){return 0|D(e|=0,t|=0,r|=0,i|=0,0)}function D(e,t,r,i,s){var a,o=0,l=0,A=0,u=0;if(a=P,P=P+16|0,l=a,!(0|I(e|=0,t|=0,r|=0,i|=0,s|=0)))return P=a,0|(i=0);do{if((0|r)>=0){if((0|r)>13780509){if(0|(o=0|ct(15,l)))break;l=0|n[(A=l)>>2],A=0|n[A+4>>2]}else u=0|rr(0|r,0|(o=((0|r)<0)<<31>>31),3,0),A=0|M(),o=0|Kt(0|r,0|o,1,0),o=0|Kt(0|(o=0|rr(0|u,0|A,0|o,0|M())),0|M(),1,0),A=0|M(),n[l>>2]=o,n[l+4>>2]=A,l=o;if(dr(0|i,0,l<<3),0|s){dr(0|s,0,l<<2),o=0|F(e,t,r,i,s,l,A,0);break}(o=0|Yt(l,4))?(u=0|F(e,t,r,i,o,l,A,0),Xt(o),o=u):o=13}else o=2}while(0);return P=a,0|(u=o)}function I(e,t,r,i,s){e|=0,t|=0,r|=0,i|=0,s|=0;var a,o,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0;if(o=P,P=P+16|0,m=o+8|0,n[(f=a=o)>>2]=e,n[f+4>>2]=t,(0|r)<0)return P=o,0|(m=2);if(n[(l=i)>>2]=e,n[l+4>>2]=t,(l=!!(0|s))&&(n[s>>2]=0),0|Ge(e,t))return P=o,0|(m=9);n[m>>2]=0;e:do{if((0|r)>=1)if(l)for(d=1,c=0,p=0,f=1,l=e;;){if(!(c|p)){if(0|(l=0|O(l,t,4,m,a)))break e;if(0|Ge(l=0|n[(t=a)>>2],t=0|n[t+4>>2])){l=9;break e}}if(0|(l=0|O(l,t,0|n[26800+(p<<2)>>2],m,a)))break e;if(l=0|n[(t=a)>>2],t=0|n[t+4>>2],n[(e=i+(d<<3)|0)>>2]=l,n[e+4>>2]=t,n[s+(d<<2)>>2]=f,A=(0|(e=c+1|0))==(0|f),h=6==(0|(u=p+1|0)),0|Ge(l,t)){l=9;break e}if((0|(f=f+(h&A&1)|0))>(0|r)){l=0;break}d=d+1|0,c=A?0:e,p=A?h?0:u:p}else for(d=1,c=0,p=0,f=1,l=e;;){if(!(c|p)){if(0|(l=0|O(l,t,4,m,a)))break e;if(0|Ge(l=0|n[(t=a)>>2],t=0|n[t+4>>2])){l=9;break e}}if(0|(l=0|O(l,t,0|n[26800+(p<<2)>>2],m,a)))break e;if(l=0|n[(t=a)>>2],t=0|n[t+4>>2],n[(e=i+(d<<3)|0)>>2]=l,n[e+4>>2]=t,A=(0|(e=c+1|0))==(0|f),h=6==(0|(u=p+1|0)),0|Ge(l,t)){l=9;break e}if((0|(f=f+(h&A&1)|0))>(0|r)){l=0;break}d=d+1|0,c=A?0:e,p=A?h?0:u:p}else l=0}while(0);return P=o,0|(m=l)}function F(e,t,r,i,s,a,o,l){r|=0,i|=0,s|=0,l|=0;var A,u,h,c=0,d=0,p=0,f=0,m=0,g=0,y=0;if(h=P,P=P+16|0,A=h+8|0,u=h,c=0|nr(0|(e|=0),0|(t|=0),0|(a|=0),0|(o|=0)),p=0|M(),!(!(0|(y=0|n[(g=f=i+(c<<3)|0)>>2]))&!(0|(g=0|n[g+4>>2]))|(d=(0|y)==(0|e)&(0|g)==(0|t))))do{c=0|ir(0|(c=0|Kt(0|c,0|p,1,0)),0|M(),0|a,0|o),p=0|M(),d=(0|(g=0|n[(y=f=i+(c<<3)|0)>>2]))==(0|e)&(0|(y=0|n[y+4>>2]))==(0|t)}while(!(!(0|g)&!(0|y)|d));if(c=s+(c<<2)|0,d&&(0|n[c>>2])<=(0|l))return P=h,0|(y=0);if(n[(y=f)>>2]=e,n[y+4>>2]=t,n[c>>2]=l,(0|l)>=(0|r))return P=h,0|(y=0);switch(d=l+1|0,n[A>>2]=0,0|(c=0|O(e,t,2,A,u))){case 9:m=9;break;case 0:(c=0|F(0|n[(c=u)>>2],0|n[c+4>>2],r,i,s,a,o,d))||(m=9)}e:do{if(9==(0|m)){switch(n[A>>2]=0,0|(c=0|O(e,t,3,A,u))){case 9:break;case 0:if(0|(c=0|F(0|n[(c=u)>>2],0|n[c+4>>2],r,i,s,a,o,d)))break e;break;default:break e}switch(n[A>>2]=0,0|(c=0|O(e,t,1,A,u))){case 9:break;case 0:if(0|(c=0|F(0|n[(c=u)>>2],0|n[c+4>>2],r,i,s,a,o,d)))break e;break;default:break e}switch(n[A>>2]=0,0|(c=0|O(e,t,5,A,u))){case 9:break;case 0:if(0|(c=0|F(0|n[(c=u)>>2],0|n[c+4>>2],r,i,s,a,o,d)))break e;break;default:break e}switch(n[A>>2]=0,0|(c=0|O(e,t,4,A,u))){case 9:break;case 0:if(0|(c=0|F(0|n[(c=u)>>2],0|n[c+4>>2],r,i,s,a,o,d)))break e;break;default:break e}switch(n[A>>2]=0,0|(c=0|O(e,t,6,A,u))){case 9:break;case 0:if(0|(c=0|F(0|n[(c=u)>>2],0|n[c+4>>2],r,i,s,a,o,d)))break e;break;default:break e}return P=h,0|(y=0)}}while(0);return P=h,0|(y=c)}function O(e,t,r,i,s){e|=0,t|=0,s|=0;var a,o,l=0,A=0,u=0,h=0,c=0,d=0,p=0;if((r|=0)>>>0>6)return 0|(s=1);if(c=(0|n[(i|=0)>>2])%6|0,n[i>>2]=c,(0|c)>0){l=0;do{r=0|be(r),l=l+1|0}while((0|l)<(0|n[i>>2]))}if(c=0|ar(0|e,0|t,45),M(),(o=127&c)>>>0>121)return 0|(s=5);a=0|We(e,t),l=0|ar(0|e,0|t,52),M(),l&=15;e:do{if(l){for(;;){if(u=0|ar(0|e,0|t,0|(A=3*(15-l|0)|0)),M(),7==(0|(u&=7))){t=5;break}if(p=!(0|Ke(l)),l=l+-1|0,d=0|or(7,0,0|A),t&=~M(),e=0|or(0|n[(p?432:16)+(28*u|0)+(r<<2)>>2],0,0|A)|e&~d,t|=A=0|M(),!(r=0|n[(p?640:224)+(28*u|0)+(r<<2)>>2])){r=0;break e}if(!l){h=8;break e}}return 0|t}h=8}while(0);8==(0|h)&&(e|=0|or(0|(p=0|n[848+(28*o|0)+(r<<2)>>2]),0,45),t=M()|-1040385&t,r=0|n[4272+(28*o|0)+(r<<2)>>2],127&~p||(p=0|or(0|n[848+(28*o|0)+20>>2],0,45),t=M()|-1040385&t,r=0|n[4272+(28*o|0)+20>>2],e=0|$e(p|e,t),t=0|M(),n[i>>2]=1+(0|n[i>>2]))),u=0|ar(0|e,0|t,45),M(),u&=127;e:do{if(0|V(u)){t:do{if(1==(0|We(e,t))){if((0|o)!=(0|u)){if(0|j(u,0|n[7696+(28*o|0)>>2])){e=0|Ye(e,t),A=1,t=0|M();break}S(27795,26864,436,26872)}switch(0|a){case 3:e=0|$e(e,t),t=0|M(),n[i>>2]=1+(0|n[i>>2]),A=0;break t;case 5:e=0|Ye(e,t),t=0|M(),n[i>>2]=5+(0|n[i>>2]),A=0;break t;case 0:return 0|(p=9);default:return 0|(p=1)}}else A=0}while(0);if((0|r)>0){l=0;do{e=0|Qe(e,t),t=0|M(),l=l+1|0}while((0|l)!=(0|r))}if((0|o)!=(0|u)){if(!(0|U(u))){if(!!(0|A)|5!=(0|We(e,t)))break;n[i>>2]=1+(0|n[i>>2]);break}switch(127&c){case 8:case 118:break e}3!=(0|We(e,t))&&(n[i>>2]=1+(0|n[i>>2]))}}else if((0|r)>0){l=0;do{e=0|$e(e,t),t=0|M(),l=l+1|0}while((0|l)!=(0|r))}}while(0);return n[i>>2]=((0|n[i>>2])+r|0)%6|0,n[(p=s)>>2]=e,n[p+4>>2]=t,0|(p=0)}function L(e,t,r,i){r|=0,i|=0;var s,a,o,l=0,A=0;for(o=P,P=P+16|0,s=o,a=o+8|0,l=(l=!(0|Ge(e|=0,t|=0)))?1:2;;){if(n[a>>2]=0,!(0|O(e,t,l,a,s))&((0|n[(A=s)>>2])==(0|r)?(0|n[A+4>>2])==(0|i):0)){e=4;break}if((l=l+1|0)>>>0>=7){l=7,e=4;break}}return 4==(0|e)?(P=o,0|l):0}function k(e,t,r,i,a,o,l){t|=0,r|=0,i|=0,a|=0,o|=0,l|=0;var A,u,h,c,d,p,f,m,g,y,b=0,x=0,v=0,_=0,w=0,T=0,S=0,E=0,N=0,C=0,R=0,B=0,q=0,D=0,I=0,F=0,O=0,L=0,k=0;if(y=P,P=P+64|0,f=y+48|0,m=y+32|0,g=y+24|0,A=y+8|0,u=y,(0|(x=0|n[(e|=0)>>2]))<=0)return P=y,0|(I=0);for(h=e+4|0,c=f+8|0,d=m+8|0,p=A+8|0,b=0,q=0;;){B=(v=0|n[h>>2])+(q<<4)|0,n[f>>2]=n[B>>2],n[f+4>>2]=n[B+4>>2],n[f+8>>2]=n[B+8>>2],n[f+12>>2]=n[B+12>>2],(0|q)==(x+-1|0)?(n[m>>2]=n[v>>2],n[m+4>>2]=n[v+4>>2],n[m+8>>2]=n[v+8>>2],n[m+12>>2]=n[v+12>>2]):(B=v+(q+1<<4)|0,n[m>>2]=n[B>>2],n[m+4>>2]=n[B+4>>2],n[m+8>>2]=n[B+8>>2],n[m+12>>2]=n[B+12>>2]),x=0|te(f,m,i,g);e:do{if(x)v=0,b=x;else if(v=0|n[(x=g)>>2],(0|(x=0|n[x+4>>2]))>0|!(0|x)&v>>>0>0){R=0,B=0;t:for(;;){if(O=1/(+(v>>>0)+4294967296*+(0|x)),k=+s[f>>3],L=+((x=0|Zt(0|v,0|x,0|R,0|B))>>>0)+4294967296*+(0|M()),F=+(R>>>0)+4294967296*+(0|B),s[A>>3]=O*(k*L)+O*(+s[m>>3]*F),s[p>>3]=O*(+s[c>>3]*L)+O*(+s[d>>3]*F),0|(x=0|Ze(A,i,u))){b=x;break}T=0|nr(0|(N=0|n[(C=u)>>2]),0|(C=0|n[C+4>>2]),0|t,0|r),_=0|M(),v=0|n[(w=x=l+(T<<3)|0)>>2],w=0|n[w+4>>2];r:do{if(!(0|v)&!(0|w))D=x,I=16;else for(S=0,E=0;;){if((0|S)>(0|r)|(0|S)==(0|r)&E>>>0>t>>>0){b=1;break t}if((0|v)==(0|N)&(0|w)==(0|C))break r;if(T=0|ir(0|(x=0|Kt(0|T,0|_,1,0)),0|M(),0|t,0|r),_=0|M(),E=0|Kt(0|E,0|S,1,0),S=0|M(),!(0|(v=0|n[(w=x=l+(T<<3)|0)>>2]))&!(0|(w=0|n[w+4>>2]))){D=x,I=16;break}}}while(0);if(16!=(0|I)||(I=0,!(0|N)&!(0|C))||(n[(E=D)>>2]=N,n[E+4>>2]=C,E=o+(n[a>>2]<<3)|0,n[E>>2]=N,n[E+4>>2]=C,E=0|Kt(0|n[(E=a)>>2],0|n[E+4>>2],1,0),N=0|M(),n[(C=a)>>2]=E,n[C+4>>2]=N),R=0|Kt(0|R,0|B,1,0),B=0|M(),v=0|n[(x=g)>>2],!((0|(x=0|n[x+4>>2]))>(0|B)|(0|x)==(0|B)&v>>>0>R>>>0)){v=1;break e}}v=0}else v=1}while(0);if(q=q+1|0,!v){I=21;break}if((0|q)>=(0|(x=0|n[e>>2]))){b=0,I=21;break}}return 21==(0|I)?(P=y,0|b):0}function V(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|n[7696+(28*e|0)+16>>2])}function U(e){return 4==(0|(e|=0))|117==(0|e)|0}function z(e){return 0|n[11120+(216*(0|n[(e|=0)>>2])|0)+(72*(0|n[e+4>>2])|0)+(24*(0|n[e+8>>2])|0)+(n[e+12>>2]<<3)>>2]}function G(e){return 0|n[11120+(216*(0|n[(e|=0)>>2])|0)+(72*(0|n[e+4>>2])|0)+(24*(0|n[e+8>>2])|0)+(n[e+12>>2]<<3)+4>>2]}function j(e,t){return t|=0,(0|n[7696+(28*(e|=0)|0)+20>>2])==(0|t)?0|(t=1):0|(t=(0|n[7696+(28*e|0)+24>>2])==(0|t))}function H(e,t){return 0|n[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function W(e,t){return t|=0,(0|n[848+(28*(e|=0)|0)>>2])==(0|t)?0|(t=0):(0|n[848+(28*e|0)+4>>2])==(0|t)?0|(t=1):(0|n[848+(28*e|0)+8>>2])==(0|t)?0|(t=2):(0|n[848+(28*e|0)+12>>2])==(0|t)?0|(t=3):(0|n[848+(28*e|0)+16>>2])==(0|t)?0|(t=4):(0|n[848+(28*e|0)+20>>2])==(0|t)?0|(t=5):0|((0|n[848+(28*e|0)+24>>2])==(0|t)?6:7)}function Q(e){var t,r,i;return t=(i=+s[(e|=0)+16>>3])-(r=+s[e+24>>3]),+(i<r?t+6.283185307179586:t)}function $(e){return+s[(e|=0)+16>>3]<+s[e+24>>3]|0}function X(e){return+(+s[(e|=0)>>3]-+s[e+8>>3])}function Y(e,t){e|=0;var r,i,n=0;return(n=+s[(t|=0)>>3])>=+s[e+8>>3]&&n<=+s[e>>3]?(r=+s[e+16>>3],n=+s[e+24>>3],t=(i=+s[t+8>>3])>=n,e=i<=r&1,r<n?t&&(e=1):t||(e=0),0|(t=!!(0|e))):0|(t=0)}function K(e,t){t|=0;var r,i,n,a,o,l=0,A=0,u=0,h=0;return+s[(e|=0)>>3]<+s[t+8>>3]||+s[e+8>>3]>+s[t>>3]?0|(l=0):(n=(A=+s[e+16>>3])<(h=+s[(r=e+24|0)>>3]),u=(o=+s[(l=t+16|0)>>3])<(a=+s[(i=t+24|0)>>3]),t=h-o<a-A,e=n?u|t?1:2:0,t=u?n?1:t?2:1:0,(A=+At(A,e))<+At(+s[i>>3],t)||(h=+At(+s[r>>3],e))>+At(+s[l>>3],t)?0|(u=0):0|(u=1))}function Z(e,t){t|=0;var r,i,n,a,o,l=0,A=0,u=0,h=0;return+s[(e|=0)>>3]<+s[t>>3]||+s[e+8>>3]>+s[t+8>>3]?0|(l=0):(n=(a=+s[(l=e+16|0)>>3])<(A=+s[e+24>>3]),u=(h=+s[(r=t+16|0)>>3])<(o=+s[(i=t+24|0)>>3]),t=A-h<o-a,e=n?u|t?1:2:0,t=u?n?1:t?2:1:0,(A=+At(A,e))<=+At(+s[i>>3],t)?0|(u=(h=+At(+s[l>>3],e))>=+At(+s[r>>3],t)):0|(u=0))}function J(e,t){e|=0,t|=0;var r,i,a,o,l,A=0;a=P,P=P+176|0,n[(i=a)>>2]=4,A=+s[t>>3],s[i+8>>3]=A,o=+s[t+16>>3],s[i+16>>3]=o,s[i+24>>3]=A,A=+s[t+24>>3],s[i+32>>3]=A,l=+s[t+8>>3],s[i+40>>3]=l,s[i+48>>3]=A,s[i+56>>3]=l,s[i+64>>3]=o,r=(t=i+72|0)+96|0;do{n[t>>2]=0,t=t+4|0}while((0|t)<(0|r));cr(0|e,0|i,168),P=a}function ee(e,t,r){e|=0,t|=0,r|=0;var i,o,u,h,c,d,p,f=0,m=0,g=0,y=0,x=0,_=0,w=0;d=P,P=P+288|0,c=d+264|0,y=d+96|0,m=(f=g=d)+96|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|m));return 0|(t=0|it(t,g))?(P=d,0|(_=t)):(tt(g=0|n[(m=g)>>2],m=0|n[m+4>>2],c),rt(g,m,y),h=+ut(c,y+8|0),s[c>>3]=+s[e>>3],s[(m=c+8|0)>>3]=+s[e+16>>3],s[y>>3]=+s[e+8>>3],s[(g=y+8|0)>>3]=+s[e+24>>3],o=+ut(c,y),w=+s[m>>3]-+s[g>>3],u=+A(+w),p=+s[c>>3]-+s[y>>3],i=+A(+p),!(0==w|0==p)&&(w=+Ar(+u,+i),w=+b(+o*o/+ur(+w/+ur(+u,+i),3)/(h*(2.59807621135*h)*.8)),s[a>>3]=w,x=~~w>>>0,_=+A(w)>=1?w>0?~~+v(+l(w/4294967296),4294967295)>>>0:~~+b((w-+(~~w>>>0))/4294967296)>>>0:0,2146435072&~n[a+4>>2])?(y=!(0|x)&!(0|_),n[(t=r)>>2]=y?1:x,n[t+4>>2]=y?0:_,t=0):t=1,P=d,0|(_=t))}function te(e,t,r,i){e|=0,t|=0,r|=0,i|=0;var o,u,h,c,d=0,p=0,f=0;c=P,P=P+288|0,u=c+264|0,h=c+96|0,o=(d=p=c)+96|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|o));return 0|(r=0|it(r,p))?(P=c,0|(i=r)):(tt(d=0|n[(r=p)>>2],r=0|n[r+4>>2],u),rt(d,r,h),f=+ut(u,h+8|0),f=+b(+ +ut(e,t)/(2*f)),s[a>>3]=f,r=~~f>>>0,d=+A(f)>=1?f>0?~~+v(+l(f/4294967296),4294967295)>>>0:~~+b((f-+(~~f>>>0))/4294967296)>>>0:0,2146435072&~n[a+4>>2]?(p=!(0|r)&!(0|d),n[i>>2]=p?1:r,n[i+4>>2]=p?0:d,P=c,0|(i=0)):(P=c,0|(i=1)))}function re(e,t,r,i){t|=0,r|=0,i|=0,n[(e|=0)>>2]=t,n[e+4>>2]=r,n[e+8>>2]=i}function ie(e,t){e|=0;var r,i,a,o,l=0,u=0,h=0,c=0,d=0,p=0,f=0;n[(o=(t|=0)+8|0)>>2]=0,i=+s[e>>3],c=+A(+i),a=+s[e+8>>3],c+=.5*(d=1.1547005383792515*+A(+a)),c-=+(0|(l=~~c)),d-=+(0|(e=~~d));do{if(c<.5){if(c<.3333333333333333){if(n[t>>2]=l,d<.5*(c+1)){n[t+4>>2]=e;break}e=e+1|0,n[t+4>>2]=e;break}if(e=(1&!(d<(f=1-c)))+e|0,n[t+4>>2]=e,f<=d&d<2*c){l=l+1|0,n[t>>2]=l;break}n[t>>2]=l;break}if(!(c<.6666666666666666)){if(l=l+1|0,n[t>>2]=l,d<.5*c){n[t+4>>2]=e;break}e=e+1|0,n[t+4>>2]=e;break}if(d<1-c){if(n[t+4>>2]=e,2*c-1<d){n[t>>2]=l;break}}else e=e+1|0,n[t+4>>2]=e;l=l+1|0,n[t>>2]=l}while(0);do{if(i<0){if(1&e){l=~~(+(0|l)-(2*(+((p=0|Zt(0|l,((0|l)<0)<<31>>31,0|(p=(e+1|0)/2|0),((0|p)<0)<<31>>31))>>>0)+4294967296*+(0|M()))+1)),n[t>>2]=l;break}l=~~(+(0|l)-2*(+((p=0|Zt(0|l,((0|l)<0)<<31>>31,0|(p=(0|e)/2|0),((0|p)<0)<<31>>31))>>>0)+4294967296*+(0|M()))),n[t>>2]=l;break}}while(0);p=t+4|0,a<0&&(l=l-((1|e<<1)/2|0)|0,n[t>>2]=l,e=0-e|0,n[p>>2]=e),u=e-l|0,(0|l)<0?(h=0-l|0,n[p>>2]=u,n[o>>2]=h,n[t>>2]=0,e=u,l=0):h=0,(0|e)<0&&(l=l-e|0,n[t>>2]=l,h=h-e|0,n[o>>2]=h,n[p>>2]=0,e=0),r=l-h|0,u=e-h|0,(0|h)<0&&(n[t>>2]=r,n[p>>2]=u,n[o>>2]=0,e=u,l=r,h=0),(0|(u=(0|h)<(0|(u=(0|e)<(0|l)?e:l))?h:u))<=0||(n[t>>2]=l-u,n[p>>2]=e-u,n[o>>2]=h-u)}function ne(e){var t,r=0,i=0,s=0,a=0,o=0;r=0|n[(e|=0)>>2],i=0|n[(t=e+4|0)>>2],(0|r)<0&&(i=i-r|0,n[t>>2]=i,n[(o=e+8|0)>>2]=(0|n[o>>2])-r,n[e>>2]=0,r=0),(0|i)<0?(r=r-i|0,n[e>>2]=r,a=(0|n[(o=e+8|0)>>2])-i|0,n[o>>2]=a,n[t>>2]=0,i=0):(o=a=e+8|0,a=0|n[a>>2]),(0|a)<0&&(r=r-a|0,n[e>>2]=r,i=i-a|0,n[t>>2]=i,n[o>>2]=0,a=0),(0|(s=(0|a)<(0|(s=(0|i)<(0|r)?i:r))?a:s))<=0||(n[e>>2]=r-s,n[t>>2]=i-s,n[o>>2]=a-s)}function se(e,t){t|=0;var r,i;i=0|n[(e|=0)+8>>2],r=+((0|n[e+4>>2])-i|0),s[t>>3]=+((0|n[e>>2])-i|0)-.5*r,s[t+8>>3]=.8660254037844386*r}function ae(e,t,r){e|=0,t|=0,n[(r|=0)>>2]=(0|n[t>>2])+(0|n[e>>2]),n[r+4>>2]=(0|n[t+4>>2])+(0|n[e+4>>2]),n[r+8>>2]=(0|n[t+8>>2])+(0|n[e+8>>2])}function oe(e,t,r){e|=0,t|=0,n[(r|=0)>>2]=(0|n[e>>2])-(0|n[t>>2]),n[r+4>>2]=(0|n[e+4>>2])-(0|n[t+4>>2]),n[r+8>>2]=(0|n[e+8>>2])-(0|n[t+8>>2])}function le(e,t){t|=0;var r,i=0;i=0|x(0|n[(e|=0)>>2],t),n[e>>2]=i,r=0|x(0|n[(i=e+4|0)>>2],t),n[i>>2]=r,t=0|x(0|n[(e=e+8|0)>>2],t),n[e>>2]=t}function Ae(e){var t,r,i=0,s=0,a=0,o=0,l=0;l=(0|(r=0|n[(e|=0)>>2]))<0,e=(e=(s=(0|(o=((t=(0|(a=(0|n[e+4>>2])-(l?r:0)|0))<0)?0-a|0:0)+((0|n[e+8>>2])-(l?r:0))|0))<0)?0:o)-((a=(0|(s=(0|e)<(0|(s=(0|(i=(t?0:a)-(s?o:0)|0))<(0|(o=(l?0:r)-(t?a:0)-(s?o:0)|0))?i:o))?e:s))>0)?s:0)|0,i=i-(a?s:0)|0;e:do{switch(o-(a?s:0)|0){case 0:switch(0|i){case 0:return 0|(l=0|e?1==(0|e)?1:7:0);case 1:return 0|(l=0|e?1==(0|e)?3:7:2);default:break e}case 1:switch(0|i){case 0:return 0|(l=0|e?1==(0|e)?5:7:4);case 1:if(e)break e;return 0|(e=6);default:break e}}}while(0);return 0|(l=7)}function ue(e){var t,r,i=0,s=0,a=0,o=0,l=0,A=0,u=0;if(A=0|n[(r=(e|=0)+8|0)>>2],(t=(0|n[e>>2])-A|0)>>>0>715827881|(A=(0|n[(u=e+4|0)>>2])-A|0)>>>0>715827881){if(o=2147483647-t|0,l=-2147483648-t|0,(a=(0|t)>0)?(0|o)<(0|t):(0|l)>(0|t))return 0|(u=1);if(s=t<<1,a?(2147483647-s|0)<(0|t):(-2147483648-s|0)>(0|t))return 0|(u=1);if((0|A)>0?(2147483647-A|0)<(0|A):(-2147483648-A|0)>(0|A))return 0|(u=1);if(i=3*t|0,s=A<<1,(a?(0|o)<(0|s):(0|l)>(0|s))||((0|t)>-1?(-2147483648|i)>=(0|A):(-2147483648^i)<(0|A)))return 0|(u=1)}else s=A<<1,i=3*t|0;return a=0|Qt(.14285714285714285*+(i-A|0)),n[e>>2]=a,o=0|Qt(.14285714285714285*+(s+t|0)),n[u>>2]=o,n[r>>2]=0,i=(s=(0|o)<(0|a))?a:o,(0|(s=s?o:a))<0&&((-2147483648==(0|s)||((0|i)>0?(2147483647-i|0)<(0|s):(-2147483648-i|0)>(0|s)))&&S(27795,26892,354,26903),((0|i)>-1?(-2147483648|i)>=(0|s):(-2147483648^i)<(0|s))&&S(27795,26892,354,26903)),i=o-a|0,(0|a)<0?(s=0-a|0,n[u>>2]=i,n[r>>2]=s,n[e>>2]=0,a=0):(i=o,s=0),(0|i)<0&&(a=a-i|0,n[e>>2]=a,s=s-i|0,n[r>>2]=s,n[u>>2]=0,i=0),l=a-s|0,o=i-s|0,(0|s)<0?(n[e>>2]=l,n[u>>2]=o,n[r>>2]=0,i=o,o=l,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|i)<(0|o)?i:o))?s:a))<=0||(n[e>>2]=o-a,n[u>>2]=i-a,n[r>>2]=s-a),0|(u=0)}function he(e){var t,r=0,i=0,s=0,a=0,o=0,l=0,A=0;if(a=0|n[(t=(e|=0)+8|0)>>2],(o=(0|n[e>>2])-a|0)>>>0>715827881|(a=(0|n[(l=e+4|0)>>2])-a|0)>>>0>715827881){if((i=(0|o)>0)?(2147483647-o|0)<(0|o):(-2147483648-o|0)>(0|o))return 0|(l=1);if(r=o<<1,(s=(0|a)>0)?(2147483647-a|0)<(0|a):(-2147483648-a|0)>(0|a))return 0|(l=1);if(A=a<<1,s?(2147483647-A|0)<(0|a):(-2147483648-A|0)>(0|a))return 0|(A=1);if(i?(2147483647-r|0)<(0|a):(-2147483648-r|0)>(0|a))return 0|(A=1);if(i=3*a|0,(0|a)>-1?(-2147483648|i)>=(0|o):(-2147483648^i)<(0|o))return 0|(A=1)}else i=3*a|0,r=o<<1;return s=0|Qt(.14285714285714285*+(r+a|0)),n[e>>2]=s,a=0|Qt(.14285714285714285*+(i-o|0)),n[l>>2]=a,n[t>>2]=0,r=(i=(0|a)<(0|s))?s:a,(0|(i=i?a:s))<0&&((-2147483648==(0|i)||((0|r)>0?(2147483647-r|0)<(0|i):(-2147483648-r|0)>(0|i)))&&S(27795,26892,402,26917),((0|r)>-1?(-2147483648|r)>=(0|i):(-2147483648^r)<(0|i))&&S(27795,26892,402,26917)),r=a-s|0,(0|s)<0?(i=0-s|0,n[l>>2]=r,n[t>>2]=i,n[e>>2]=0,s=0):(r=a,i=0),(0|r)<0&&(s=s-r|0,n[e>>2]=s,i=i-r|0,n[t>>2]=i,n[l>>2]=0,r=0),o=s-i|0,a=r-i|0,(0|i)<0?(n[e>>2]=o,n[l>>2]=a,n[t>>2]=0,r=a,a=o,i=0):a=s,(0|(s=(0|i)<(0|(s=(0|r)<(0|a)?r:a))?i:s))<=0||(n[e>>2]=a-s,n[l>>2]=r-s,n[t>>2]=i-s),0|(A=0)}function ce(e){var t,r,i=0,s=0,a=0,o=0,l=0;s=0|n[(t=(e|=0)+8|0)>>2],a=0|Qt(.14285714285714285*+((3*(i=(0|n[e>>2])-s|0)|0)-(s=(0|n[(r=e+4|0)>>2])-s|0)|0)),n[e>>2]=a,i=0|Qt(.14285714285714285*+((s<<1)+i|0)),n[r>>2]=i,n[t>>2]=0,s=i-a|0,(0|a)<0?(l=0-a|0,n[r>>2]=s,n[t>>2]=l,n[e>>2]=0,i=s,a=0,s=l):s=0,(0|i)<0&&(a=a-i|0,n[e>>2]=a,s=s-i|0,n[t>>2]=s,n[r>>2]=0,i=0),l=a-s|0,o=i-s|0,(0|s)<0?(n[e>>2]=l,n[r>>2]=o,n[t>>2]=0,i=o,o=l,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|i)<(0|o)?i:o))?s:a))<=0||(n[e>>2]=o-a,n[r>>2]=i-a,n[t>>2]=s-a)}function de(e){var t,r,i=0,s=0,a=0,o=0,l=0;s=0|n[(t=(e|=0)+8|0)>>2],a=0|Qt(.14285714285714285*+(((i=(0|n[e>>2])-s|0)<<1)+(s=(0|n[(r=e+4|0)>>2])-s|0)|0)),n[e>>2]=a,i=0|Qt(.14285714285714285*+((3*s|0)-i|0)),n[r>>2]=i,n[t>>2]=0,s=i-a|0,(0|a)<0?(l=0-a|0,n[r>>2]=s,n[t>>2]=l,n[e>>2]=0,i=s,a=0,s=l):s=0,(0|i)<0&&(a=a-i|0,n[e>>2]=a,s=s-i|0,n[t>>2]=s,n[r>>2]=0,i=0),l=a-s|0,o=i-s|0,(0|s)<0?(n[e>>2]=l,n[r>>2]=o,n[t>>2]=0,i=o,o=l,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|i)<(0|o)?i:o))?s:a))<=0||(n[e>>2]=o-a,n[r>>2]=i-a,n[t>>2]=s-a)}function pe(e){var t,r,i,s=0,a=0,o=0,l=0;s=0|n[(e|=0)>>2],a=0|n[(r=e+4|0)>>2],o=0|n[(i=e+8|0)>>2],l=a+(3*s|0)|0,n[e>>2]=l,a=o+(3*a|0)|0,n[r>>2]=a,s=(3*o|0)+s|0,n[i>>2]=s,o=a-l|0,(0|l)<0?(s=s-l|0,n[r>>2]=o,n[i>>2]=s,n[e>>2]=0,a=o,o=0):o=l,(0|a)<0&&(o=o-a|0,n[e>>2]=o,s=s-a|0,n[i>>2]=s,n[r>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(n[e>>2]=t,n[r>>2]=l,n[i>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(n[e>>2]=o-a,n[r>>2]=l-a,n[i>>2]=s-a)}function fe(e){var t,r,i,s=0,a=0,o=0,l=0;l=0|n[(e|=0)>>2],o=(3*(s=0|n[(r=e+4|0)>>2])|0)+l|0,l=(a=0|n[(i=e+8|0)>>2])+(3*l|0)|0,n[e>>2]=l,n[r>>2]=o,s=(3*a|0)+s|0,n[i>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,n[r>>2]=a,n[i>>2]=s,n[e>>2]=0,l=0):a=o,(0|a)<0&&(l=l-a|0,n[e>>2]=l,s=s-a|0,n[i>>2]=s,n[r>>2]=0,a=0),t=l-s|0,o=a-s|0,(0|s)<0?(n[e>>2]=t,n[r>>2]=o,n[i>>2]=0,l=t,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|o)<(0|l)?o:l))?s:a))<=0||(n[e>>2]=l-a,n[r>>2]=o-a,n[i>>2]=s-a)}function me(e,t){e|=0;var r,i,s,a=0,o=0,l=0;((t|=0)+-1|0)>>>0>=6||(l=(0|n[15440+(12*t|0)>>2])+(0|n[e>>2])|0,n[e>>2]=l,s=e+4|0,o=(0|n[15440+(12*t|0)+4>>2])+(0|n[s>>2])|0,n[s>>2]=o,i=e+8|0,t=(0|n[15440+(12*t|0)+8>>2])+(0|n[i>>2])|0,n[i>>2]=t,a=o-l|0,(0|l)<0?(t=t-l|0,n[s>>2]=a,n[i>>2]=t,n[e>>2]=0,o=0):(a=o,o=l),(0|a)<0&&(o=o-a|0,n[e>>2]=o,t=t-a|0,n[i>>2]=t,n[s>>2]=0,a=0),r=o-t|0,l=a-t|0,(0|t)<0?(n[e>>2]=r,n[s>>2]=l,n[i>>2]=0,o=r,t=0):l=a,(0|(a=(0|t)<(0|(a=(0|l)<(0|o)?l:o))?t:a))<=0||(n[e>>2]=o-a,n[s>>2]=l-a,n[i>>2]=t-a))}function ge(e){var t,r,i,s=0,a=0,o=0,l=0;l=0|n[(e|=0)>>2],o=(s=0|n[(r=e+4|0)>>2])+l|0,l=(a=0|n[(i=e+8|0)>>2])+l|0,n[e>>2]=l,n[r>>2]=o,s=a+s|0,n[i>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,n[r>>2]=a,n[i>>2]=s,n[e>>2]=0,o=0):(a=o,o=l),(0|a)<0&&(o=o-a|0,n[e>>2]=o,s=s-a|0,n[i>>2]=s,n[r>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(n[e>>2]=t,n[r>>2]=l,n[i>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(n[e>>2]=o-a,n[r>>2]=l-a,n[i>>2]=s-a)}function ye(e){var t,r,i,s=0,a=0,o=0,l=0;s=0|n[(e|=0)>>2],o=0|n[(r=e+4|0)>>2],a=0|n[(i=e+8|0)>>2],l=o+s|0,n[e>>2]=l,o=a+o|0,n[r>>2]=o,s=a+s|0,n[i>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,n[r>>2]=a,n[i>>2]=s,n[e>>2]=0,o=0):(a=o,o=l),(0|a)<0&&(o=o-a|0,n[e>>2]=o,s=s-a|0,n[i>>2]=s,n[r>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(n[e>>2]=t,n[r>>2]=l,n[i>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(n[e>>2]=o-a,n[r>>2]=l-a,n[i>>2]=s-a)}function be(e){switch(0|(e|=0)){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1}return 0|e}function xe(e){switch(0|(e|=0)){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1}return 0|e}function ve(e){var t,r,i,s=0,a=0,o=0,l=0;s=0|n[(e|=0)>>2],a=0|n[(r=e+4|0)>>2],o=0|n[(i=e+8|0)>>2],l=a+(s<<1)|0,n[e>>2]=l,a=o+(a<<1)|0,n[r>>2]=a,s=(o<<1)+s|0,n[i>>2]=s,o=a-l|0,(0|l)<0?(s=s-l|0,n[r>>2]=o,n[i>>2]=s,n[e>>2]=0,a=o,o=0):o=l,(0|a)<0&&(o=o-a|0,n[e>>2]=o,s=s-a|0,n[i>>2]=s,n[r>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(n[e>>2]=t,n[r>>2]=l,n[i>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(n[e>>2]=o-a,n[r>>2]=l-a,n[i>>2]=s-a)}function _e(e){var t,r,i,s=0,a=0,o=0,l=0;l=0|n[(e|=0)>>2],o=((s=0|n[(r=e+4|0)>>2])<<1)+l|0,l=(a=0|n[(i=e+8|0)>>2])+(l<<1)|0,n[e>>2]=l,n[r>>2]=o,s=(a<<1)+s|0,n[i>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,n[r>>2]=a,n[i>>2]=s,n[e>>2]=0,l=0):a=o,(0|a)<0&&(l=l-a|0,n[e>>2]=l,s=s-a|0,n[i>>2]=s,n[r>>2]=0,a=0),t=l-s|0,o=a-s|0,(0|s)<0?(n[e>>2]=t,n[r>>2]=o,n[i>>2]=0,l=t,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|o)<(0|l)?o:l))?s:a))<=0||(n[e>>2]=l-a,n[r>>2]=o-a,n[i>>2]=s-a)}function we(e,t){t|=0;var r,i,s,a=0,o=0,l=0;return s=(0|(i=(0|n[(e|=0)>>2])-(0|n[t>>2])|0))<0,r=(0|(o=(0|n[e+4>>2])-(0|n[t+4>>2])-(s?i:0)|0))<0,t=(t=(e=(0|(l=(s?0-i|0:0)+(0|n[e+8>>2])-(0|n[t+8>>2])+(r?0-o|0:0)|0))<0)?0:l)-((o=(0|(e=(0|t)<(0|(e=(0|(a=(r?0:o)-(e?l:0)|0))<(0|(l=(s?0:i)-(r?o:0)-(e?l:0)|0))?a:l))?t:e))>0)?e:0)|0,a=a-(o?e:0)|0,0|((0|(e=(0|(e=l-(o?e:0)|0))>-1?e:0-e|0))>(0|(t=(0|(a=(0|a)>-1?a:0-a|0))>(0|(t=(0|t)>-1?t:0-t|0))?a:t))?e:t)}function Te(e,t){t|=0;var r;r=0|n[(e|=0)+8>>2],n[t>>2]=(0|n[e>>2])-r,n[t+4>>2]=(0|n[e+4>>2])-r}function Me(e,t){t|=0;var r,i,s,a=0,o=0,l=0;if(o=0|n[(e|=0)>>2],n[t>>2]=o,l=0|n[e+4>>2],n[(i=t+4|0)>>2]=l,n[(s=t+8|0)>>2]=0,e=(a=(0|l)<(0|o))?o:l,(0|(a=a?l:o))<0){if(-2147483648==(0|a)||((0|e)>0?(2147483647-e|0)<(0|a):(-2147483648-e|0)>(0|a)))return 0|(t=1);if((0|e)>-1?(-2147483648|e)>=(0|a):(-2147483648^e)<(0|a))return 0|(t=1)}return e=l-o|0,(0|o)<0?(a=0-o|0,n[i>>2]=e,n[s>>2]=a,n[t>>2]=0,o=0):(e=l,a=0),(0|e)<0&&(o=o-e|0,n[t>>2]=o,a=a-e|0,n[s>>2]=a,n[i>>2]=0,e=0),r=o-a|0,l=e-a|0,(0|a)<0?(n[t>>2]=r,n[i>>2]=l,n[s>>2]=0,e=l,l=r,a=0):l=o,(0|(o=(0|a)<(0|(o=(0|e)<(0|l)?e:l))?a:o))<=0||(n[t>>2]=l-o,n[i>>2]=e-o,n[s>>2]=a-o),0|(t=0)}function Se(e){var t,r,i,s;r=(s=0|n[(t=(e|=0)+8|0)>>2])-(0|n[e>>2])|0,n[e>>2]=r,e=(0|n[(i=e+4|0)>>2])-s|0,n[i>>2]=e,n[t>>2]=0-(e+r)}function Ee(e){var t,r,i=0,s=0,a=0,o=0,l=0;i=0-(s=0|n[(e|=0)>>2])|0,n[e>>2]=i,n[(t=e+8|0)>>2]=0,o=(a=0|n[(r=e+4|0)>>2])+s|0,(0|s)>0?(n[r>>2]=o,n[t>>2]=s,n[e>>2]=0,i=0,a=o):s=0,(0|a)<0?(l=i-a|0,n[e>>2]=l,s=s-a|0,n[t>>2]=s,n[r>>2]=0,o=l-s|0,i=0-s|0,(0|s)<0?(n[e>>2]=o,n[r>>2]=i,n[t>>2]=0,a=i,s=0):(a=0,o=l)):o=i,(0|(i=(0|s)<(0|(i=(0|a)<(0|o)?a:o))?s:i))<=0||(n[e>>2]=o-i,n[r>>2]=a-i,n[t>>2]=s-i)}function Ne(e,t,r){r|=0;var i,s,a=0,o=0;return s=P,P=P+16|0,i=s,o=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(a=0|ar(0|(e|=0),0|t,56),M(),a=0|function(e,t,r){e|=0,t|=0,r|=0;var i=0,s=0,a=0;if(a=P,P=P+16|0,s=a,i=0|Ge(e,t),(r+-1|0)>>>0>5)return P=a,0|(s=-1);if(i=!!(0|i),1==(0|r)&i)return P=a,0|(s=-1);do{if(!(0|Lt(e,t,s))){if(i){i=(5+(0|n[26352+(r<<2)>>2])-(0|n[s>>2])|0)%5|0;break}i=(6+(0|n[26384+(r<<2)>>2])-(0|n[s>>2])|0)%6|0;break}i=-1}while(0);return s=i,P=a,0|s}(e,o,7&a),-1==(0|a)?(n[r>>2]=0,P=s,0|(o=6)):(0|et(e,o,i)&&S(27795,26932,282,26947),t=0|ar(0|e,0|t,52),M(),t&=15,0|Ge(e,o)?Pe(i,t,a,2,r):Fe(i,t,a,2,r),P=s,0|(o=0))):(P=s,0|(o=6))}function Ce(e,t,r,i){t|=0,i|=0;var a,o=0,l=0,A=0,u=0;if(a=P,P=P+16|0,function(e,t,r){e|=0,t|=0,r|=0;var i=0,a=0,o=0;o=P,P=P+32|0,a=o,function(e,t){e|=0,t|=0;var r=0,i=0,n=0;r=+s[e>>3],i=+c(+r),r=+d(+r),s[t+16>>3]=r,r=+s[e+8>>3],n=i*+c(+r),s[t>>3]=n,r=i*+d(+r),s[t+8>>3]=r}(e,a),n[t>>2]=0,s[r>>3]=5,i=+Ot(16400,a),i<+s[r>>3]&&(n[t>>2]=0,s[r>>3]=i);i=+Ot(16424,a),i<+s[r>>3]&&(n[t>>2]=1,s[r>>3]=i);i=+Ot(16448,a),i<+s[r>>3]&&(n[t>>2]=2,s[r>>3]=i);i=+Ot(16472,a),i<+s[r>>3]&&(n[t>>2]=3,s[r>>3]=i);i=+Ot(16496,a),i<+s[r>>3]&&(n[t>>2]=4,s[r>>3]=i);i=+Ot(16520,a),i<+s[r>>3]&&(n[t>>2]=5,s[r>>3]=i);i=+Ot(16544,a),i<+s[r>>3]&&(n[t>>2]=6,s[r>>3]=i);i=+Ot(16568,a),i<+s[r>>3]&&(n[t>>2]=7,s[r>>3]=i);i=+Ot(16592,a),i<+s[r>>3]&&(n[t>>2]=8,s[r>>3]=i);i=+Ot(16616,a),i<+s[r>>3]&&(n[t>>2]=9,s[r>>3]=i);i=+Ot(16640,a),i<+s[r>>3]&&(n[t>>2]=10,s[r>>3]=i);i=+Ot(16664,a),i<+s[r>>3]&&(n[t>>2]=11,s[r>>3]=i);i=+Ot(16688,a),i<+s[r>>3]&&(n[t>>2]=12,s[r>>3]=i);i=+Ot(16712,a),i<+s[r>>3]&&(n[t>>2]=13,s[r>>3]=i);i=+Ot(16736,a),i<+s[r>>3]&&(n[t>>2]=14,s[r>>3]=i);i=+Ot(16760,a),i<+s[r>>3]&&(n[t>>2]=15,s[r>>3]=i);i=+Ot(16784,a),i<+s[r>>3]&&(n[t>>2]=16,s[r>>3]=i);i=+Ot(16808,a),i<+s[r>>3]&&(n[t>>2]=17,s[r>>3]=i);i=+Ot(16832,a),i<+s[r>>3]&&(n[t>>2]=18,s[r>>3]=i);if(i=+Ot(16856,a),!(i<+s[r>>3]))return void(P=o);n[t>>2]=19,s[r>>3]=i,P=o}(e|=0,r|=0,u=a),(l=+f(+(1-.5*+s[u>>3])))<1e-16)return n[i>>2]=0,n[i+4>>2]=0,n[i+8>>2]=0,n[i+12>>2]=0,void(P=a);if(u=0|n[r>>2],o=+ot((o=+s[15920+(24*u|0)>>3])-+ot(+function(e,t){e|=0,t|=0;var r=0,i=0,n=0,a=0,o=0;return a=+s[t>>3],i=+c(+a),n=+s[t+8>>3]-+s[e+8>>3],o=i*+d(+n),r=+s[e>>3],+ +y(+o,+(+d(+a)*+c(+r)-+c(+n)*(i*+d(+r))))}(15600+(u<<4)|0,e))),A=0|Ke(t)?+ot(o+-.3334731722518321):o,o=2.618033988749896*+p(+l),(0|t)>0){e=0;do{o*=2.6457513110645907,e=e+1|0}while((0|e)!=(0|t))}l=+c(+A)*o,s[i>>3]=l,A=+d(+A)*o,s[i+8>>3]=A,P=a}function Re(e,t,r,i,a){t|=0,r|=0,i|=0,a|=0;var o,l=0,h=0;if(l=+function(e){e|=0;var t=0,r=0;return r=+s[e>>3],t=+s[e+8>>3],+ +u(+(r*r+t*t))}(e|=0),l<1e-16)return t=15600+(t<<4)|0,n[a>>2]=n[t>>2],n[a+4>>2]=n[t+4>>2],n[a+8>>2]=n[t+8>>2],void(n[a+12>>2]=n[t+12>>2]);if(h=+y(+ +s[e+8>>3],+ +s[e>>3]),(0|r)>0){e=0;do{l*=.37796447300922725,e=e+1|0}while((0|e)!=(0|r))}o=.3333333333333333*l,i?(r=!(0|Ke(r)),l=+g(.381966011250105*(r?o:.37796447300922725*o))):(l=+g(.381966011250105*l),0|Ke(r)&&(h=+ot(h+.3334731722518321))),function(e,t,r,i){e|=0,t=+t,r=+r,i|=0;var a=0,o=0,l=0,u=0;if(r<1e-16)return n[i>>2]=n[e>>2],n[i+4>>2]=n[e+4>>2],n[i+8>>2]=n[e+8>>2],void(n[i+12>>2]=n[e+12>>2]);o=t<0?t+6.283185307179586:t,o=t>=6.283185307179586?o+-6.283185307179586:o;do{if(!(o<1e-16)){if(a=+A(+(o+-3.141592653589793))<1e-16,t=+s[e>>3],a){t-=r,s[i>>3]=t,a=i;break}if(l=+c(+r),r=+d(+r),t=l*+d(+t)+ +c(+o)*(r*+c(+t)),t=+m(+((t=t>1?1:t)<-1?-1:t)),s[i>>3]=t,+A(+(t+-1.5707963267948966))<1e-16)return s[i>>3]=1.5707963267948966,void(s[i+8>>3]=0);if(+A(+(t+1.5707963267948966))<1e-16)return s[i>>3]=-1.5707963267948966,void(s[i+8>>3]=0);if(u=1/+c(+t),o=r*+d(+o)*u,r=+s[e>>3],t=u*((l-+d(+t)*+d(+r))/+c(+r)),l=o>1?1:o,t=t>1?1:t,(t=+s[e+8>>3]+ +y(+(l<-1?-1:l),+(t<-1?-1:t)))>3.141592653589793)do{t+=-6.283185307179586}while(t>3.141592653589793);if(t<-3.141592653589793)do{t+=6.283185307179586}while(t<-3.141592653589793);return void(s[i+8>>3]=t)}t=+s[e>>3]+r,s[i>>3]=t,a=i}while(0);if(+A(+(t+-1.5707963267948966))<1e-16)return s[a>>3]=1.5707963267948966,void(s[i+8>>3]=0);if(+A(+(t+1.5707963267948966))<1e-16)return s[a>>3]=-1.5707963267948966,void(s[i+8>>3]=0);if(t=+s[e+8>>3],t>3.141592653589793)do{t+=-6.283185307179586}while(t>3.141592653589793);if(t<-3.141592653589793)do{t+=6.283185307179586}while(t<-3.141592653589793);s[i+8>>3]=t}(15600+(t<<4)|0,+ot(+s[15920+(24*t|0)>>3]-h),l,a)}function Be(e,t,r){t|=0,r|=0;var i,s;i=P,P=P+16|0,se((e|=0)+4|0,s=i),Re(s,0|n[e>>2],t,0,r),P=i}function Pe(e,t,r,i,a){e|=0,t|=0,r|=0,i|=0,a|=0;var o,l,A,u,h,c,d,p,f,m,g,y,b,x,v,_,w,T,M,E,N,C,R=0,B=0,q=0,D=0,I=0,F=0;if(C=P,P=P+272|0,D=C+240|0,M=C,E=C+224|0,N=C+208|0,g=C+176|0,y=C+160|0,b=C+192|0,x=C+144|0,v=C+128|0,_=C+112|0,w=C+96|0,T=C+80|0,n[(R=C+256|0)>>2]=t,n[D>>2]=n[e>>2],n[D+4>>2]=n[e+4>>2],n[D+8>>2]=n[e+8>>2],n[D+12>>2]=n[e+12>>2],qe(D,R,M),n[a>>2]=0,(0|(D=i+r+(5==(0|i)&1)|0))<=(0|r))P=C;else{l=E+4|0,A=g+4|0,u=r+5|0,h=16880+((o=0|n[R>>2])<<2)|0,c=16960+(o<<2)|0,d=v+8|0,p=_+8|0,f=w+8|0,m=N+4|0,q=r;e:for(;;){B=M+((0|q)%5<<4)|0,n[N>>2]=n[B>>2],n[N+4>>2]=n[B+4>>2],n[N+8>>2]=n[B+8>>2],n[N+12>>2]=n[B+12>>2];do{}while(2==(0|De(N,o,0,1)));if((0|q)>(0|r)&!!(0|Ke(t))){if(n[g>>2]=n[N>>2],n[g+4>>2]=n[N+4>>2],n[g+8>>2]=n[N+8>>2],n[g+12>>2]=n[N+12>>2],se(l,y),i=0|n[g>>2],R=0|n[17040+(80*i|0)+(n[E>>2]<<2)>>2],n[g>>2]=n[18640+(80*i|0)+(20*R|0)>>2],(0|(B=0|n[18640+(80*i|0)+(20*R|0)+16>>2]))>0){e=0;do{ge(A),e=e+1|0}while((0|e)<(0|B))}switch(B=18640+(80*i|0)+(20*R|0)+4|0,n[b>>2]=n[B>>2],n[b+4>>2]=n[B+4>>2],n[b+8>>2]=n[B+8>>2],le(b,3*(0|n[h>>2])|0),ae(A,b,A),ne(A),se(A,x),I=+(0|n[c>>2]),s[v>>3]=3*I,s[d>>3]=0,F=-1.5*I,s[_>>3]=F,s[p>>3]=2.598076211353316*I,s[w>>3]=F,s[f>>3]=-2.598076211353316*I,0|n[17040+(80*(0|n[g>>2])|0)+(n[N>>2]<<2)>>2]){case 1:e=_,i=v;break;case 3:e=w,i=_;break;case 2:e=v,i=w;break;default:e=12;break e}It(y,x,i,e,T),Re(T,0|n[g>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2])}if((0|q)<(0|u)&&(se(m,g),Re(g,0|n[N>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2])),n[E>>2]=n[N>>2],n[E+4>>2]=n[N+4>>2],n[E+8>>2]=n[N+8>>2],n[E+12>>2]=n[N+12>>2],(0|(q=q+1|0))>=(0|D)){e=3;break}}3!=(0|e)?12==(0|e)&&S(26970,27017,572,27027):P=C}}function qe(e,t,r){e|=0,t|=0,r|=0;var i,s=0,a=0,o=0,l=0,A=0;i=P,P=P+128|0,a=i,l=20240,A=(o=s=i+64|0)+60|0;do{n[o>>2]=n[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|A));l=20304,A=(o=a)+60|0;do{n[o>>2]=n[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|A));s=(A=!(0|Ke(0|n[t>>2])))?s:a,ve(a=e+4|0),_e(a),0|Ke(0|n[t>>2])&&(fe(a),n[t>>2]=1+(0|n[t>>2])),n[r>>2]=n[e>>2],ae(a,s,t=r+4|0),ne(t),n[r+16>>2]=n[e>>2],ae(a,s+12|0,t=r+20|0),ne(t),n[r+32>>2]=n[e>>2],ae(a,s+24|0,t=r+36|0),ne(t),n[r+48>>2]=n[e>>2],ae(a,s+36|0,t=r+52|0),ne(t),n[r+64>>2]=n[e>>2],ae(a,s+48|0,r=r+68|0),ne(r),P=i}function De(e,t,r,i){r|=0,i|=0;var s,a,o,l,A,u,h=0,c=0,d=0,p=0,f=0;if(u=P,P=P+32|0,A=u+12|0,a=u,f=(e|=0)+4|0,p=0|n[16960+((t|=0)<<2)>>2],p=(l=!!(0|i))?3*p|0:p,h=0|n[f>>2],s=0|n[(o=e+8|0)>>2],l){if((0|(h=s+h+(i=0|n[(c=e+12|0)>>2])|0))==(0|p))return P=u,0|(f=1);d=c}else h=s+h+(i=0|n[(d=e+12|0)>>2])|0;if((0|h)<=(0|p))return P=u,0|(f=0);do{if((0|i)>0){if(i=0|n[e>>2],(0|s)>0){c=18640+(80*i|0)+60|0,i=e;break}i=18640+(80*i|0)+40|0,r?(re(A,p,0,0),oe(f,A,a),ye(a),ae(a,A,f),c=i,i=e):(c=i,i=e)}else c=18640+(80*(0|n[e>>2])|0)+20|0,i=e}while(0);if(n[i>>2]=n[c>>2],(0|n[(h=c+16|0)>>2])>0){i=0;do{ge(f),i=i+1|0}while((0|i)<(0|n[h>>2]))}return e=c+4|0,n[A>>2]=n[e>>2],n[A+4>>2]=n[e+4>>2],n[A+8>>2]=n[e+8>>2],t=0|n[16880+(t<<2)>>2],le(A,l?3*t|0:t),ae(f,A,f),ne(f),i=l&&((0|n[o>>2])+(0|n[f>>2])+(0|n[d>>2])|0)==(0|p)?1:2,P=u,0|(f=i)}function Ie(e,t){e|=0,t|=0;var r=0;do{r=0|De(e,t,0,1)}while(2==(0|r));return 0|r}function Fe(e,t,r,i,a){e|=0,t|=0,r|=0,i|=0,a|=0;var o,l,A,u,h,c,d,p,f,m,g,y,b,x,v,_,w,T,M=0,E=0,N=0,C=0,R=0;if(T=P,P=P+240|0,x=T+208|0,v=T,_=T+192|0,w=T+176|0,f=T+160|0,m=T+144|0,g=T+128|0,y=T+112|0,b=T+96|0,n[(M=T+224|0)>>2]=t,n[x>>2]=n[e>>2],n[x+4>>2]=n[e+4>>2],n[x+8>>2]=n[e+8>>2],n[x+12>>2]=n[e+12>>2],Oe(x,M,v),n[a>>2]=0,(0|(p=i+r+(6==(0|i)&1)|0))<=(0|r))P=T;else{l=r+6|0,A=16960+((o=0|n[M>>2])<<2)|0,u=m+8|0,h=g+8|0,c=y+8|0,d=_+4|0,E=0,N=r,i=-1;e:for(;;){if(e=v+((M=(0|N)%6|0)<<4)|0,n[_>>2]=n[e>>2],n[_+4>>2]=n[e+4>>2],n[_+8>>2]=n[e+8>>2],n[_+12>>2]=n[e+12>>2],e=E,E=0|De(_,o,0,1),(0|N)>(0|r)&!!(0|Ke(t))&&(1!=(0|e)&&(0|n[_>>2])!=(0|i))){switch(se(v+((M+5|0)%6<<4)+4|0,w),se(v+(M<<4)+4|0,f),C=+(0|n[A>>2]),s[m>>3]=3*C,s[u>>3]=0,R=-1.5*C,s[g>>3]=R,s[h>>3]=2.598076211353316*C,s[y>>3]=R,s[c>>3]=-2.598076211353316*C,M=0|n[x>>2],0|n[17040+(80*M|0)+(((0|i)==(0|M)?n[_>>2]:i)<<2)>>2]){case 1:e=g,i=m;break;case 3:e=y,i=g;break;case 2:e=m,i=y;break;default:e=8;break e}It(w,f,i,e,b),0|Ft(w,b)||0|Ft(f,b)||(Re(b,0|n[x>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2]))}if((0|N)<(0|l)&&(se(d,w),Re(w,0|n[_>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2])),(0|(N=N+1|0))>=(0|p)){e=3;break}i=0|n[_>>2]}3!=(0|e)?8==(0|e)&&S(27054,27017,737,27099):P=T}}function Oe(e,t,r){e|=0,t|=0,r|=0;var i,s=0,a=0,o=0,l=0,A=0;i=P,P=P+160|0,a=i,l=20368,A=(o=s=i+80|0)+72|0;do{n[o>>2]=n[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|A));l=20448,A=(o=a)+72|0;do{n[o>>2]=n[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|A));s=(A=!(0|Ke(0|n[t>>2])))?s:a,ve(a=e+4|0),_e(a),0|Ke(0|n[t>>2])&&(fe(a),n[t>>2]=1+(0|n[t>>2])),n[r>>2]=n[e>>2],ae(a,s,t=r+4|0),ne(t),n[r+16>>2]=n[e>>2],ae(a,s+12|0,t=r+20|0),ne(t),n[r+32>>2]=n[e>>2],ae(a,s+24|0,t=r+36|0),ne(t),n[r+48>>2]=n[e>>2],ae(a,s+36|0,t=r+52|0),ne(t),n[r+64>>2]=n[e>>2],ae(a,s+48|0,t=r+68|0),ne(t),n[r+80>>2]=n[e>>2],ae(a,s+60|0,r=r+84|0),ne(r),P=i}function Le(e,t){return t=0|ar(0|(e|=0),0|(t|=0),45),M(),127&t}function ke(e,t){e|=0;var r=0,n=0,s=0,a=0;return!0&134217728==(-16777216&(t|=0))?(n=0|ar(0|e,0|t,52),M(),n&=15,r=0|ar(0|e,0|t,45),M(),(r&=127)>>>0>121?0|(e=0):!(613566756&(a=0|or(0|(s=0|ar(0|e,0|t,0|(a=3*(15^n)|0))),0|M(),0|a))&(0|Zt(-1227133514,-1171,0|a,0|(s=0|M()))))&!(4681&s&M())&&15==(0|n)|!(0|(a=0|ar(0|(0|or(0|~e,0|~t,0|(a=19+(3*n|0)|0))),0|M(),0|a)))&!(0|M())?0|i[20528+r|0]?!(0|e)&!(0|(t&=8191))?0|(a=1):(a=0|lr(0|e,0|t),M(),0|!!((63-a|0)%3|0)):0|(a=1):0|(a=0)):0|(e=0)}function Ve(e,t,r,i){e|=0,r|=0,i|=0;var s=0,a=0,o=0,l=0;if(s=0|or(0|(t|=0),0,52),a=0|M(),r=0|or(0|r,0,45),r=0|a|M()|134225919,(0|t)<1)return a=-1,i=r,n[(t=e)>>2]=a,void(n[(e=e+4|0)>>2]=i);for(a=1,s=-1;l=0|or(7,0,0|(o=3*(15-a|0)|0)),r&=~M(),s=s&~l|(o=0|or(0|i,0,0|o)),r=0|r|M(),(0|a)!=(0|t);)a=a+1|0;n[(o=l=e)>>2]=s,n[(l=l+4|0)>>2]=r}function Ue(e,t,r,i){r|=0,i|=0;var s=0,a=0;if(a=0|ar(0|(e|=0),0|(t|=0),52),M(),r>>>0>15)return 0|(i=4);if((0|(a&=15))<(0|r))return 0|(i=12);if((0|a)==(0|r))return n[i>>2]=e,n[i+4>>2]=t,0|(i=0);if(s=0|or(0|r,0,52),s|=e,e=M()|-15728641&t,(0|a)>(0|r))do{t=0|or(7,0,3*(14-r|0)|0),r=r+1|0,s|=t,e=0|M()|e}while((0|r)<(0|a));return n[i>>2]=s,n[i+4>>2]=e,0|(i=0)}function ze(e,t,r,i){r|=0,i|=0;var s=0,a=0,o=0;if(a=0|ar(0|(e|=0),0|(t|=0),52),M(),!((0|r)<16&(0|(a&=15))<=(0|r)))return 0|(i=4);s=r-a|0,r=0|ar(0|e,0|t,45),M();e:do{if(0|V(127&r)){t:do{if(0|a){for(r=1;!((o=0|or(7,0,3*(15-r|0)|0))&e|0)&!((0|M())&t);){if(!(r>>>0<a>>>0))break t;r=r+1|0}r=0|_t(7,0,s,((0|s)<0)<<31>>31),s=0|M();break e}}while(0);r=0|Kt(0|(r=0|rr(0|(r=0|_t(7,0,s,((0|s)<0)<<31>>31)),0|M(),5,0)),0|M(),-5,-1),r=0|Kt(0|(r=0|tr(0|r,0|M(),6,0)),0|M(),1,0),s=0|M()}else r=0|_t(7,0,s,((0|s)<0)<<31>>31),s=0|M()}while(0);return n[(o=i)>>2]=r,n[o+4>>2]=s,0|(o=0)}function Ge(e,t){var r=0,i=0,n=0;if(n=0|ar(0|(e|=0),0|(t|=0),45),M(),!(0|V(127&n)))return 0|(n=0);n=0|ar(0|e,0|t,52),M(),n&=15;e:do{if(n)for(i=1;;){if(r=0|ar(0|e,0|t,3*(15-i|0)|0),M(),0|(r&=7))break e;if(!(i>>>0<n>>>0)){r=0;break}i=i+1|0}else r=0}while(0);return 0|(n=1&!(0|r))}function je(e,t,r,i){return e|=0,t|=0,(0|(i|=0))<(0|(r|=0))?(i=e,T(0|(r=t)),0|i):(r=0|or(-1,-1,3+(3*(i-r|0)|0)|0),i=0|or(0|~r,0|~M(),3*(15-i|0)|0),r=~M()&t,i=~i&e,T(0|r),0|i)}function He(e,t,r,i){r|=0,i|=0;var s=0;return s=0|ar(0|(e|=0),0|(t|=0),52),M(),(0|r)<16&(0|(s&=15))<=(0|r)?((0|s)<(0|r)&&(s=0|or(-1,-1,3+(3*(r+-1-s|0)|0)|0),s=0|or(0|~s,0|~M(),3*(15-r|0)|0),t=~M()&t,e&=~s),s=0|or(0|r,0,52),r=-15728641&t|M(),n[i>>2]=e|s,n[i+4>>2]=r,0|(i=0)):0|(i=4)}function We(e,t){var r=0,i=0,n=0;if(n=0|ar(0|(e|=0),0|(t|=0),52),M(),!(n&=15))return 0|(n=0);for(i=1;;){if(r=0|ar(0|e,0|t,3*(15-i|0)|0),M(),0|(r&=7)){i=5;break}if(!(i>>>0<n>>>0)){r=0,i=5;break}i=i+1|0}return 5==(0|i)?0|r:0}function Qe(e,t){var r=0,i=0,n=0,s=0,a=0,o=0,l=0;if(l=0|ar(0|(e|=0),0|(t|=0),52),M(),!(l&=15))return l=e,T(0|(o=t)),0|l;for(o=1,r=0;;){i=0|or(7,0,0|(s=3*(15-o|0)|0)),n=0|M(),a=0|ar(0|e,0|t,0|s),M(),e=(s=0|or(0|be(7&a),0,0|s))|e&~i,t=(a=0|M())|t&~n;e:do{if(!r)if(!(s&i|0)&!(a&n|0))r=0;else if(i=0|ar(0|e,0|t,52),M(),i&=15){r=1;t:for(;;){switch(a=0|ar(0|e,0|t,3*(15-r|0)|0),M(),7&a){case 1:break t;case 0:break;default:r=1;break e}if(!(r>>>0<i>>>0)){r=1;break e}r=r+1|0}for(r=1;;){if(n=0|ar(0|e,0|t,0|(a=3*(15-r|0)|0)),M(),s=0|or(7,0,0|a),t&=~M(),e=e&~s|(a=0|or(0|be(7&n),0,0|a)),t=0|t|M(),!(r>>>0<i>>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(o>>>0<l>>>0))break;o=o+1|0}return T(0|t),0|e}function $e(e,t){var r=0,i=0,n=0,s=0,a=0;if(i=0|ar(0|(e|=0),0|(t|=0),52),M(),!(i&=15))return i=e,T(0|(r=t)),0|i;for(r=1;a=0|ar(0|e,0|t,0|(s=3*(15-r|0)|0)),M(),n=0|or(7,0,0|s),t&=~M(),e=(s=0|or(0|be(7&a),0,0|s))|e&~n,t=0|M()|t,r>>>0<i>>>0;)r=r+1|0;return T(0|t),0|e}function Xe(e,t){var r=0,i=0,n=0,s=0,a=0,o=0,l=0;if(l=0|ar(0|(e|=0),0|(t|=0),52),M(),!(l&=15))return l=e,T(0|(o=t)),0|l;for(o=1,r=0;;){i=0|or(7,0,0|(s=3*(15-o|0)|0)),n=0|M(),a=0|ar(0|e,0|t,0|s),M(),e=(s=0|or(0|xe(7&a),0,0|s))|e&~i,t=(a=0|M())|t&~n;e:do{if(!r)if(!(s&i|0)&!(a&n|0))r=0;else if(i=0|ar(0|e,0|t,52),M(),i&=15){r=1;t:for(;;){switch(a=0|ar(0|e,0|t,3*(15-r|0)|0),M(),7&a){case 1:break t;case 0:break;default:r=1;break e}if(!(r>>>0<i>>>0)){r=1;break e}r=r+1|0}for(r=1;;){if(s=0|or(7,0,0|(n=3*(15-r|0)|0)),a=t&~M(),t=0|ar(0|e,0|t,0|n),M(),e=e&~s|(t=0|or(0|xe(7&t),0,0|n)),t=0|a|M(),!(r>>>0<i>>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(o>>>0<l>>>0))break;o=o+1|0}return T(0|t),0|e}function Ye(e,t){var r=0,i=0,n=0,s=0,a=0;if(i=0|ar(0|(e|=0),0|(t|=0),52),M(),!(i&=15))return i=e,T(0|(r=t)),0|i;for(r=1;s=0|or(7,0,0|(a=3*(15-r|0)|0)),n=t&~M(),t=0|ar(0|e,0|t,0|a),M(),e=(t=0|or(0|xe(7&t),0,0|a))|e&~s,t=0|M()|n,r>>>0<i>>>0;)r=r+1|0;return T(0|t),0|e}function Ke(e){return(0|(e|=0))%2|0}function Ze(e,t,r){r|=0;var i,s=0;return i=P,P=P+16|0,s=i,(t|=0)>>>0>15?(P=i,0|(s=4)):2146435072&~n[(e|=0)+4>>2]&&2146435072&~n[e+8+4>>2]?(function(e,t,r){var i,n;i=P,P=P+16|0,Ce(e|=0,t|=0,r|=0,n=i),ie(n,r+4|0),P=i}(e,t,s),t=0|function(e,t){e|=0;var r,i=0,s=0,a=0,o=0,l=0,A=0,u=0,h=0;if(r=P,P=P+64|0,A=r+40|0,s=r+24|0,a=r+12|0,o=r,or(0|(t|=0),0,52),i=134225919|M(),!t)return(0|n[e+4>>2])>2||(0|n[e+8>>2])>2||(0|n[e+12>>2])>2?(A=0,T(0|(l=0)),P=r,0|A):(or(0|z(e),0,45),l=0|M()|i,A=-1,T(0|l),P=r,0|A);if(n[A>>2]=n[e>>2],n[A+4>>2]=n[e+4>>2],n[A+8>>2]=n[e+8>>2],n[A+12>>2]=n[e+12>>2],l=A+4|0,(0|t)>0)for(e=-1;n[s>>2]=n[l>>2],n[s+4>>2]=n[l+4>>2],n[s+8>>2]=n[l+8>>2],1&t?(ce(l),n[a>>2]=n[l>>2],n[a+4>>2]=n[l+4>>2],n[a+8>>2]=n[l+8>>2],pe(a)):(de(l),n[a>>2]=n[l>>2],n[a+4>>2]=n[l+4>>2],n[a+8>>2]=n[l+8>>2],fe(a)),oe(s,a,o),ne(o),u=0|or(7,0,0|(h=3*(15-t|0)|0)),i&=~M(),e=(h=0|or(0|Ae(o),0,0|h))|e&~u,i=0|M()|i,(0|t)>1;)t=t+-1|0;else e=-1;e:do{if((0|n[l>>2])<=2&&(0|n[A+8>>2])<=2&&(0|n[A+12>>2])<=2){if(t=0|or(0|(s=0|z(A)),0,45),t|=e,e=M()|-1040385&i,o=0|G(A),!(0|V(s))){if((0|o)<=0)break;for(a=0;;){if(s=0|ar(0|t,0|e,52),M(),s&=15)for(i=1;A=0|ar(0|t,0|e,0|(h=3*(15-i|0)|0)),M(),u=0|or(7,0,0|h),e&=~M(),t=t&~u|(h=0|or(0|be(7&A),0,0|h)),e=0|e|M(),i>>>0<s>>>0;)i=i+1|0;if((0|(a=a+1|0))==(0|o))break e}}a=0|ar(0|t,0|e,52),M(),a&=15;t:do{if(a){i=1;r:for(;;){switch(h=0|ar(0|t,0|e,3*(15-i|0)|0),M(),7&h){case 1:break r;case 0:break;default:break t}if(!(i>>>0<a>>>0))break t;i=i+1|0}if(0|j(s,0|n[A>>2]))for(i=1;u=0|or(7,0,0|(A=3*(15-i|0)|0)),h=e&~M(),e=0|ar(0|t,0|e,0|A),M(),t=t&~u|(e=0|or(0|xe(7&e),0,0|A)),e=0|h|M(),i>>>0<a>>>0;)i=i+1|0;else for(i=1;A=0|ar(0|t,0|e,0|(h=3*(15-i|0)|0)),M(),u=0|or(7,0,0|h),e&=~M(),t=t&~u|(h=0|or(0|be(7&A),0,0|h)),e=0|e|M(),i>>>0<a>>>0;)i=i+1|0}}while(0);if((0|o)>0){i=0;do{t=0|Qe(t,e),e=0|M(),i=i+1|0}while((0|i)!=(0|o))}}else t=0,e=0}while(0);return h=t,T(0|(u=e)),P=r,0|h}(s,t),s=0|M(),n[r>>2]=t,n[r+4>>2]=s,!(0|t)&!(0|s)&&S(27795,27122,959,27145),P=i,0|(s=0)):(P=i,0|(s=3))}function Je(e,t,r){var i,s=0,a=0,o=0;if(i=(r|=0)+4|0,a=0|ar(0|(e|=0),0|(t|=0),52),M(),a&=15,o=0|ar(0|e,0|t,45),M(),s=!(0|a),0|V(127&o)){if(s)return 0|(o=1);s=1}else{if(s)return 0|(o=0);s=0|n[i>>2]||0|n[r+8>>2]?1:1&!!(0|n[r+12>>2])}for(r=1;1&r?pe(i):fe(i),o=0|ar(0|e,0|t,3*(15-r|0)|0),M(),me(i,7&o),r>>>0<a>>>0;)r=r+1|0;return 0|s}function et(e,t,r){r|=0;var i,s,a=0,o=0,l=0,A=0,u=0,h=0;if(s=P,P=P+16|0,i=s,h=0|ar(0|(e|=0),0|(t|=0),45),M(),(h&=127)>>>0>121)return n[r>>2]=0,n[r+4>>2]=0,n[r+8>>2]=0,n[r+12>>2]=0,P=s,0|(h=5);e:do{if(0|V(h)&&(l=0|ar(0|e,0|t,52),M(),0|(l&=15))){a=1;t:for(;;){switch(u=0|ar(0|e,0|t,3*(15-a|0)|0),M(),7&u){case 5:break t;case 0:break;default:a=t;break e}if(!(a>>>0<l>>>0)){a=t;break e}a=a+1|0}for(o=1,a=t;A=0|or(7,0,0|(t=3*(15-o|0)|0)),u=a&~M(),a=0|ar(0|e,0|a,0|t),M(),e=e&~A|(a=0|or(0|xe(7&a),0,0|t)),a=0|u|M(),o>>>0<l>>>0;)o=o+1|0}else a=t}while(0);if(u=7696+(28*h|0)|0,n[r>>2]=n[u>>2],n[r+4>>2]=n[u+4>>2],n[r+8>>2]=n[u+8>>2],n[r+12>>2]=n[u+12>>2],!(0|Je(e,a,r)))return P=s,0|(h=0);if(A=r+4|0,n[i>>2]=n[A>>2],n[i+4>>2]=n[A+4>>2],n[i+8>>2]=n[A+8>>2],l=0|ar(0|e,0|a,52),M(),u=15&l,1&l?(fe(A),l=u+1|0):l=u,0|V(h)){e:do{if(u)for(t=1;;){if(o=0|ar(0|e,0|a,3*(15-t|0)|0),M(),0|(o&=7)){a=o;break e}if(!(t>>>0<u>>>0)){a=0;break}t=t+1|0}else a=0}while(0);a=4==(0|a)&1}else a=0;if(0|De(r,l,a,0)){if(0|V(h))do{}while(0|De(r,l,0,0));(0|l)!=(0|u)&&de(A)}else(0|l)!=(0|u)&&(n[A>>2]=n[i>>2],n[A+4>>2]=n[i+4>>2],n[A+8>>2]=n[i+8>>2]);return P=s,0|(h=0)}function tt(e,t,r){r|=0;var i,n,s=0;return n=P,P=P+16|0,0|(s=0|et(e|=0,t|=0,i=n))?(P=n,0|s):(s=0|ar(0|e,0|t,52),M(),Be(i,15&s,r),P=n,0|(s=0))}function rt(e,t,r){r|=0;var i,n=0,s=0,a=0;if(i=P,P=P+16|0,0|(n=0|et(e|=0,t|=0,a=i)))return P=i,0|(a=n);n=0|ar(0|e,0|t,45),M(),n=!(0|V(127&n)),s=0|ar(0|e,0|t,52),M(),s&=15;e:do{if(!n){if(0|s)for(n=1;;){if(!(!((0|or(7,0,3*(15-n|0)|0))&e|0)&!((0|M())&t)))break e;if(!(n>>>0<s>>>0))break;n=n+1|0}return Pe(a,s,0,5,r),P=i,0|0}}while(0);return Fe(a,s,0,6,r),P=i,0|0}function it(e,t){t|=0;var r=0,i=0,s=0,a=0,o=0,l=0,A=0;if((e|=0)>>>0>15)return 0|(l=4);if(or(0|e,0,52),l=134225919|M(),!e){r=0,i=0;do{0|V(i)&&(or(0|i,0,45),o=0|l|M(),n[(e=t+(r<<3)|0)>>2]=-1,n[e+4>>2]=o,r=r+1|0),i=i+1|0}while(122!=(0|i));return 0|(r=0)}r=0,o=0;do{if(0|V(o)){for(or(0|o,0,45),i=1,s=-1,a=0|l|M();s&=~(A=0|or(7,0,3*(15-i|0)|0)),a&=~M(),(0|i)!=(0|e);)i=i+1|0;n[(A=t+(r<<3)|0)>>2]=s,n[A+4>>2]=a,r=r+1|0}o=o+1|0}while(122!=(0|o));return 0|(r=0)}function nt(e,t,r,i){e|=0,i|=0;var s=0,a=0,o=0;s=0|ar(0|(t|=0),0|(r|=0),52),M(),!(0|t)&!(0|r)|(0|i)>15|(0|(s&=15))>(0|i)?(a=-1,t=-1,r=0,s=0):(t=0|je(t,r,s+1|0,i),o=-15728641&M(),r=0|or(0|i,0,52),a=s,t=(t=!(0|Ge(r|=t,o=0|o|M())))?-1:i,s=o),n[(o=e)>>2]=r,n[o+4>>2]=s,n[e+8>>2]=a,n[e+12>>2]=t}function st(e,t,r,i){r|=0,i|=0;var s=0,a=0;return s=0|ar(0|(e|=0),0|(t|=0),52),M(),s&=15,n[(a=i+8|0)>>2]=s,!(0|e)&!(0|t)|(0|r)>15|(0|s)>(0|r)?(n[(r=i)>>2]=0,n[r+4>>2]=0,n[a>>2]=-1,void(n[i+12>>2]=-1)):(e=0|je(e,t,s+1|0,r),a=-15728641&M(),s=0|or(0|r,0,52),s|=e,a=0|a|M(),n[(e=i)>>2]=s,n[e+4>>2]=a,e=i+12|0,0|Ge(s,a)?void(n[e>>2]=r):void(n[e>>2]=-1))}function at(e){var t,r=0,i=0,s=0,a=0,o=0,l=0,A=0,u=0;if(!(!(0|(r=0|n[(i=e|=0)>>2]))&!(0|(i=0|n[i+4>>2]))||(s=0|ar(0|r,0|i,52),M(),r=0|Kt(0|(A=0|or(1,0,3*(15^(s&=15))|0)),0|M(),0|r,0|i),i=0|M(),n[(A=e)>>2]=r,n[A+4>>2]=i,(0|s)<(0|(l=0|n[(A=e+8|0)>>2]))))){for(t=e+12|0,o=s;;){if((0|o)==(0|l)){s=5;break}if(u=(0|o)==(0|n[t>>2]),s=0|ar(0|r,0|i,0|(a=3*(15-o|0)|0)),M(),u&1==(0|(s&=7))&!0){s=7;break}if(!(7==(0|s)&!0)){s=10;break}if(r=0|Kt(0|r,0|i,0|(u=0|or(1,0,0|a)),0|M()),i=0|M(),n[(u=e)>>2]=r,n[u+4>>2]=i,!((0|o)>(0|l))){s=10;break}o=o+-1|0}if(5==(0|s))return n[(u=e)>>2]=0,n[u+4>>2]=0,n[A>>2]=-1,void(n[t>>2]=-1);if(7==(0|s))return l=0|Kt(0|r,0|i,0|(l=0|or(1,0,0|a)),0|M()),A=0|M(),n[(u=e)>>2]=l,n[u+4>>2]=A,void(n[t>>2]=o+-1)}}function ot(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function lt(e,t){return t|=0,+A(+(+s[(e|=0)>>3]-+s[t>>3]))<17453292519943298e-27?0|(t=+A(+(+s[e+8>>3]-+s[t+8>>3]))<17453292519943298e-27):0|(t=0)}function At(e,t){switch(e=+e,0|(t|=0)){case 1:e=e<0?e+6.283185307179586:e;break;case 2:e=e>0?e+-6.283185307179586:e}return+e}function ut(e,t){e|=0;var r,i,n,a=0;return i=+s[(t|=0)>>3],r=+s[e>>3],a=(n=+d(.5*(i-r)))*n+(a=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+c(+i)*+c(+r)*a),2*+y(+ +u(+a),+ +u(+(1-a)))*6371.007180918475}function ht(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20656+(e<<3)>>3],0|(t=0))}function ct(e,t){t|=0;var r=0;return(e|=0)>>>0>15?0|(t=4):(r=0|rr(0|(r=0|_t(7,0,e,((0|e)<0)<<31>>31)),0|M(),120,0),e=0|M(),n[t>>2]=2|r,n[t+4>>2]=e,0|(t=0))}function dt(e,t,r){e|=0,r|=0;var i,n,a,o,l=0,A=0,h=0,f=0,m=0,b=0;return b=+s[(t|=0)>>3],a=+s[e>>3],m=+d(.5*(b-a)),h=+s[t+8>>3],n=+s[e+8>>3],f=+d(.5*(h-n)),i=+c(+a),o=+c(+b),f=2*+y(+ +u(+(f=m*m+f*(o*i*f))),+ +u(+(1-f))),m=+s[r>>3],b=+d(.5*(m-b)),l=+s[r+8>>3],h=+d(.5*(l-h)),A=+c(+m),h=2*+y(+ +u(+(h=b*b+h*(o*A*h))),+ +u(+(1-h))),m=+d(.5*(a-m)),l=+d(.5*(n-l)),l=2*+y(+ +u(+(l=m*m+l*(i*A*l))),+ +u(+(1-l))),4*+g(+ +u(+ +p(.5*(A=.5*(f+h+l)))*+p(.5*(A-f))*+p(.5*(A-h))*+p(.5*(A-l))))}function pt(e,t,r){r|=0;var i,a,o,l=0,A=0;if(o=P,P=P+192|0,a=o,0|(A=0|tt(e|=0,t|=0,i=o+168|0)))return P=o,0|(r=A);if(0|rt(e,t,a)&&S(27795,27190,415,27199),(0|(t=0|n[a>>2]))>0){if(l=+dt(a+8|0,a+8+((1!=(0|t)&1)<<4)|0,i)+0,1!=(0|t)){e=1;do{l+=+dt(a+8+((A=e)<<4)|0,a+8+((0|(e=e+1|0))%(0|t)<<4)|0,i)}while((0|e)<(0|t))}}else l=0;return s[r>>3]=l,P=o,0|(r=0)}function ft(e){e|=0;var t,r,i=0;return(t=0|Yt(1,12))||S(27280,27235,49,27293),0|(i=0|n[(r=e+4|0)>>2])?(n[(i=i+8|0)>>2]=t,n[r>>2]=t,0|t):(0|n[e>>2]&&S(27310,27235,61,27333),n[(i=e)>>2]=t,n[r>>2]=t,0|t)}function mt(e,t){e|=0,t|=0;var r,i;return(i=0|$t(24))||S(27347,27235,78,27361),n[i>>2]=n[t>>2],n[i+4>>2]=n[t+4>>2],n[i+8>>2]=n[t+8>>2],n[i+12>>2]=n[t+12>>2],n[i+16>>2]=0,0|(r=0|n[(t=e+4|0)>>2])?(n[r+16>>2]=i,n[t>>2]=i,0|i):(0|n[e>>2]&&S(27376,27235,82,27361),n[e>>2]=i,n[t>>2]=i,0|i)}function gt(e){var t=0,r=0,i=0,s=0;if(e|=0)for(i=1;;){if(0|(t=0|n[e>>2]))do{if(0|(r=0|n[t>>2]))do{s=r,r=0|n[r+16>>2],Xt(s)}while(0|r);s=t,t=0|n[t+8>>2],Xt(s)}while(0|t);if(t=e,e=0|n[e+8>>2],i||Xt(t),!e)break;i=0}}function yt(e){var t,r,i=0,a=0,o=0,l=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0,w=0,T=0,M=0,E=0,N=0,C=0,R=0,B=0,P=0,q=0,D=0,I=0,F=0;if(0|n[(l=(e|=0)+8|0)>>2])return 0|(F=1);if(!(o=0|n[e>>2]))return 0|(F=0);i=o,a=0;do{a=a+1|0,i=0|n[i+8>>2]}while(0|i);if(a>>>0<2)return 0|(F=0);(r=0|$t(a<<2))||S(27396,27235,317,27415),(t=0|$t(a<<5))||S(27437,27235,321,27415),n[e>>2]=0,n[(N=e+4|0)>>2]=0,n[l>>2]=0,a=0,D=0,E=0,m=0;e:for(;;){if(f=0|n[o>>2]){u=0,h=f;do{if(d=+s[h+8>>3],i=h,h=0|n[h+16>>2],c=+s[(l=(p=!(0|h))?f:h)+8>>3],+A(+(d-c))>3.141592653589793){F=14;break}u+=(c-d)*(+s[i>>3]+ +s[l>>3])}while(!p);if(14==(0|F)){F=0,u=0,i=f;do{M=+s[i+8>>3],P=0|n[(q=i+16|0)>>2],T=+s[(P=0|P?P:f)+8>>3],u+=(+s[i>>3]+ +s[P>>3])*((T<0?T+6.283185307179586:T)-(M<0?M+6.283185307179586:M)),i=0|n[(0|i?q:o)>>2]}while(0|i)}u>0?(n[r+(D<<2)>>2]=o,D=D+1|0,l=E,i=m):F=19}else F=19;if(19==(0|F)){F=0;do{if(!a){if(m){l=N,h=m+8|0,i=o,a=e;break}if(0|n[e>>2]){F=27;break e}l=N,h=e,i=o,a=e;break}if(0|n[(i=a+8|0)>>2]){F=21;break e}if(!(a=0|Yt(1,12))){F=23;break e}n[i>>2]=a,l=a+4|0,h=a,i=m}while(0);if(n[h>>2]=o,n[l>>2]=o,h=t+(E<<5)|0,p=0|n[o>>2]){for(s[(f=t+(E<<5)+8|0)>>3]=17976931348623157e292,s[(m=t+(E<<5)+24|0)>>3]=17976931348623157e292,s[h>>3]=-17976931348623157e292,s[(g=t+(E<<5)+16|0)>>3]=-17976931348623157e292,_=17976931348623157e292,w=-17976931348623157e292,l=0,y=p,d=17976931348623157e292,x=17976931348623157e292,v=-17976931348623157e292,c=-17976931348623157e292;u=+s[y>>3],M=+s[y+8>>3],y=0|n[y+16>>2],T=+s[((b=!(0|y))?p:y)+8>>3],u<d&&(s[f>>3]=u,d=u),M<x&&(s[m>>3]=M,x=M),u>v?s[h>>3]=u:u=v,M>c&&(s[g>>3]=M,c=M),_=M>0&M<_?M:_,w=M<0&M>w?M:w,l|=+A(+(M-T))>3.141592653589793,!b;)v=u;l&&(s[g>>3]=w,s[m>>3]=_)}else n[h>>2]=0,n[h+4>>2]=0,n[h+8>>2]=0,n[h+12>>2]=0,n[h+16>>2]=0,n[h+20>>2]=0,n[h+24>>2]=0,n[h+28>>2]=0;l=E+1|0}if(o=0|n[(q=o+8|0)>>2],n[q>>2]=0,!o){F=45;break}E=l,m=i}if(21==(0|F))S(27213,27235,35,27247);else if(23==(0|F))S(27267,27235,37,27247);else if(27==(0|F))S(27310,27235,61,27333);else if(45==(0|F)){e:do{if((0|D)>0){for(q=!(0|l),B=l<<2,P=!(0|e),R=0,i=0;;){if(C=0|n[r+(R<<2)>>2],q)F=73;else{if(!(E=0|$t(B))){F=50;break}if(!(N=0|$t(B))){F=52;break}t:do{if(P)a=0;else{for(l=0,a=0,h=e;o=t+(l<<5)|0,0|bt(0|n[h>>2],o,0|n[C>>2])?(n[E+(a<<2)>>2]=h,n[N+(a<<2)>>2]=o,b=a+1|0):b=a,h=0|n[h+8>>2];)l=l+1|0,a=b;if((0|b)>0)if(o=0|n[E>>2],1==(0|b))a=o;else for(g=0,y=-1,a=o,m=o;;){for(p=0|n[m>>2],o=0,h=0;f=(0|(l=0|n[n[E+(h<<2)>>2]>>2]))==(0|p)?o:o+(1&bt(l,0|n[N+(h<<2)>>2],0|n[p>>2]))|0,(0|(h=h+1|0))!=(0|b);)o=f;if(a=(l=(0|f)>(0|y))?m:a,(0|(o=g+1|0))==(0|b))break t;g=o,y=l?f:y,m=0|n[E+(o<<2)>>2]}else a=0}}while(0);if(Xt(E),Xt(N),a){if(o=0|n[(l=a+4|0)>>2])a=o+8|0;else if(0|n[a>>2]){F=70;break}n[a>>2]=C,n[l>>2]=C}else F=73}if(73==(0|F)){if(F=0,0|(i=0|n[C>>2]))do{N=i,i=0|n[i+16>>2],Xt(N)}while(0|i);Xt(C),i=1}if((0|(R=R+1|0))>=(0|D)){I=i;break e}}50==(0|F)?S(27452,27235,249,27471):52==(0|F)?S(27490,27235,252,27471):70==(0|F)&&S(27310,27235,61,27333)}else I=0}while(0);return Xt(r),Xt(t),0|(F=I)}return 0}function bt(e,t,r){e|=0;var i=0,a=0,o=0,l=0,A=0,u=0,h=0,c=0;if(!(0|Y(t|=0,r|=0)))return 0|(e=0);if(t=0|$(t),i=+s[r>>3],a=t&(a=+s[r+8>>3])<0?a+6.283185307179586:a,!(e=0|n[e>>2]))return 0|(e=0);if(t){t=0,h=a,r=e;e:for(;;){for(;l=+s[r>>3],a=+s[r+8>>3],c=0|n[(r=r+16|0)>>2],o=+s[(c=0|c?c:e)>>3],A=+s[c+8>>3],l>o?(u=l,l=A):(u=o,o=l,l=a,a=A),(i=i==o|i==u?i+2220446049250313e-31:i)<o|i>u;)if(!(r=0|n[r>>2])){r=22;break e}if(((u=(A=l<0?l+6.283185307179586:l)+(i-o)/(u-o)*((l=a<0?a+6.283185307179586:a)-A))<0?u+6.283185307179586:u)>(h=A==h|l==h?h+-2220446049250313e-31:h)&&(t^=1),!(r=0|n[r>>2])){r=22;break}}if(22==(0|r))return 0|t}else{t=0,h=a,r=e;e:for(;;){for(;l=+s[r>>3],a=+s[r+8>>3],c=0|n[(r=r+16|0)>>2],o=+s[(c=0|c?c:e)>>3],A=+s[c+8>>3],l>o?(u=l,l=A):(u=o,o=l,l=a,a=A),(i=i==o|i==u?i+2220446049250313e-31:i)<o|i>u;)if(!(r=0|n[r>>2])){r=22;break e}if(l+(i-o)/(u-o)*(a-l)>(h=l==h|a==h?h+-2220446049250313e-31:h)&&(t^=1),!(r=0|n[r>>2])){r=22;break}}if(22==(0|r))return 0|t}return 0}function xt(e,t,r,s,a){r|=0,s|=0,a|=0;var o,l,A,u,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0;if(u=P,P=P+32|0,x=u+16|0,A=u,h=0|ar(0|(e|=0),0|(t|=0),52),M(),h&=15,g=0|ar(0|r,0|s,52),M(),(0|h)!=(15&g))return P=u,0|(x=12);if(f=0|ar(0|e,0|t,45),M(),f&=127,m=0|ar(0|r,0|s,45),M(),f>>>0>121|(m&=127)>>>0>121)return P=u,0|(x=5);if(g=(0|f)!=(0|m)){if(7==(0|(d=0|W(f,m))))return P=u,0|(x=1);7==(0|(p=0|W(m,f)))?S(27514,27538,161,27548):(y=d,c=p)}else y=0,c=0;o=0|V(f),l=0|V(m),n[x>>2]=0,n[x+4>>2]=0,n[x+8>>2]=0,n[x+12>>2]=0;do{if(y){if(d=(0|(m=0|n[4272+(28*f|0)+(y<<2)>>2]))>0,l)if(d){f=0,p=r,d=s;do{p=0|Xe(p,d),d=0|M(),1==(0|(c=0|xe(c)))&&(c=0|xe(1)),f=f+1|0}while((0|f)!=(0|m));m=c,f=p,p=d}else m=c,f=r,p=s;else if(d){f=0,p=r,d=s;do{p=0|Ye(p,d),d=0|M(),c=0|xe(c),f=f+1|0}while((0|f)!=(0|m));m=c,f=p,p=d}else m=c,f=r,p=s;if(Je(f,p,x),g||S(27563,27538,191,27548),(d=!!(0|o))&(c=!!(0|l))&&S(27590,27538,192,27548),d){if(7==(0|(c=0|We(e,t)))){h=5;break}if(0|i[22e3+(7*c|0)+y|0]){h=1;break}f=p=0|n[21168+(28*c|0)+(y<<2)>>2]}else if(c){if(7==(0|(c=0|We(f,p)))){h=5;break}if(0|i[22e3+(7*c|0)+m|0]){h=1;break}f=0,p=0|n[21168+(28*m|0)+(c<<2)>>2]}else f=0,p=0;if((f|p|0)<0)h=5;else{if((0|p)>0){d=x+4|0,c=0;do{ye(d),c=c+1|0}while((0|c)!=(0|p))}if(n[A>>2]=0,n[A+4>>2]=0,n[A+8>>2]=0,me(A,y),0|h)for(;0|Ke(h)?pe(A):fe(A),(0|h)>1;)h=h+-1|0;if((0|f)>0){h=0;do{ye(A),h=h+1|0}while((0|h)!=(0|f))}ae(b=x+4|0,A,b),ne(b),b=51}}else if(Je(r,s,x),!!(0|o)&!!(0|l))if((0|m)!=(0|f)&&S(27621,27538,261,27548),7==(0|(c=0|We(e,t)))|7==(0|(h=0|We(r,s))))h=5;else if(0|i[22e3+(7*c|0)+h|0])h=1;else if((0|(c=0|n[21168+(28*c|0)+(h<<2)>>2]))>0){d=x+4|0,h=0;do{ye(d),h=h+1|0}while((0|h)!=(0|c));b=51}else b=51;else b=51}while(0);return 51==(0|b)&&(h=x+4|0,n[a>>2]=n[h>>2],n[a+4>>2]=n[h+4>>2],n[a+8>>2]=n[h+8>>2],h=0),P=u,0|(x=h)}function vt(e,t,r,i){r|=0,i|=0;var s,a,o,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0;if(o=P,P=P+48|0,s=o+36|0,u=o+24|0,h=o+12|0,c=o,l=0|ar(0|(e|=0),0|(t|=0),52),M(),l&=15,p=0|ar(0|e,0|t,45),M(),(p&=127)>>>0>121)return P=o,0|(i=5);if(a=0|V(p),or(0|l,0,52),g=134225919|M(),n[(A=i)>>2]=-1,n[A+4>>2]=g,!l)return 7==(0|(l=0|Ae(r)))||127==(0|(l=0|H(p,l)))?(P=o,0|(g=1)):(f=0|or(0|l,0,45),m=0|M(),m=-1040385&n[(p=i)+4>>2]|m,n[(g=i)>>2]=n[p>>2]|f,n[g+4>>2]=m,P=o,0|(g=0));for(n[s>>2]=n[r>>2],n[s+4>>2]=n[r+4>>2],n[s+8>>2]=n[r+8>>2],r=l;;){if(A=r,r=r+-1|0,n[u>>2]=n[s>>2],n[u+4>>2]=n[s+4>>2],n[u+8>>2]=n[s+8>>2],0|Ke(A)){if(0|(l=0|ue(s))){r=13;break}n[h>>2]=n[s>>2],n[h+4>>2]=n[s+4>>2],n[h+8>>2]=n[s+8>>2],pe(h)}else{if(0|(l=0|he(s))){r=13;break}n[h>>2]=n[s>>2],n[h+4>>2]=n[s+4>>2],n[h+8>>2]=n[s+8>>2],fe(h)}if(oe(u,h,c),ne(c),b=0|n[(l=i)>>2],l=0|n[l+4>>2],y=0|or(7,0,0|(x=3*(15-A|0)|0)),l&=~M(),x=0|or(0|Ae(c),0,0|x),l=0|M()|l,n[(g=i)>>2]=x|b&~y,n[g+4>>2]=l,(0|A)<=1){r=14;break}}e:do{if(13!=(0|r)&&14==(0|r))if((0|n[s>>2])<=1&&(0|n[s+4>>2])<=1&&(0|n[s+8>>2])<=1){c=127==(0|(l=0|H(p,r=0|Ae(s))))?0:0|V(l);t:do{if(r){if(a){if(7==(0|(l=0|We(e,t)))){l=5;break e}if((0|(A=0|n[21376+(28*l|0)+(r<<2)>>2]))>0){l=r,r=0;do{l=0|be(l),r=r+1|0}while((0|r)!=(0|A))}else l=r;if(1==(0|l)){l=9;break e}127==(0|(r=0|H(p,l)))&&S(27648,27538,411,27678),0|V(r)?S(27693,27538,412,27678):(m=r,f=A,d=l)}else m=l,f=0,d=r;if((0|(h=0|n[4272+(28*p|0)+(d<<2)>>2]))<=-1&&S(27724,27538,419,27678),!c){if((0|f)<0){l=5;break e}if(0|f){l=0,r=0|n[(A=i)>>2],A=0|n[A+4>>2];do{r=0|$e(r,A),A=0|M(),n[(x=i)>>2]=r,n[x+4>>2]=A,l=l+1|0}while((0|l)<(0|f))}if((0|h)<=0){l=m,r=58;break}for(l=0,r=0|n[(A=i)>>2],A=0|n[A+4>>2];;)if(r=0|$e(r,A),A=0|M(),n[(x=i)>>2]=r,n[x+4>>2]=A,(0|(l=l+1|0))==(0|h)){l=m,r=58;break t}}if(7==(0|(u=0|W(m,p)))&&S(27514,27538,428,27678),r=0|n[(l=i)>>2],l=0|n[l+4>>2],(0|h)>0){A=0;do{r=0|$e(r,l),l=0|M(),n[(x=i)>>2]=r,n[x+4>>2]=l,A=A+1|0}while((0|A)!=(0|h))}if(7==(0|(l=0|We(r,l)))&&S(27795,27538,440,27678),r=0|U(m),(0|(r=0|n[(r?21792:21584)+(28*u|0)+(l<<2)>>2]))<0&&S(27795,27538,454,27678),r){l=0,A=0|n[(u=i)>>2],u=0|n[u+4>>2];do{A=0|Qe(A,u),u=0|M(),n[(x=i)>>2]=A,n[x+4>>2]=u,l=l+1|0}while((0|l)<(0|r));l=m,r=58}else l=m,r=58}else if(!!(0|a)&!!(0|c)){if(7==(0|(r=0|We(e,t)))|7==(0|(A=0|We(0|n[(A=i)>>2],0|n[A+4>>2])))){l=5;break e}if((0|(A=0|n[21376+(28*r|0)+(A<<2)>>2]))<0){l=5;break e}if(A){r=0,u=0|n[(h=i)>>2],h=0|n[h+4>>2];do{u=0|$e(u,h),h=0|M(),n[(x=i)>>2]=u,n[x+4>>2]=h,r=r+1|0}while((0|r)<(0|A));r=58}else r=59}else r=58}while(0);if(58==(0|r)&&c&&(r=59),59==(0|r)&&1==(0|We(0|n[(x=i)>>2],0|n[x+4>>2]))){l=9;break}y=0|n[(x=i)>>2],x=-1040385&n[x+4>>2],b=0|or(0|l,0,45),x=0|x|M(),n[(l=i)>>2]=y|b,n[l+4>>2]=x,l=0}else l=1}while(0);return P=o,0|(x=l)}function _t(e,t,r,i){e|=0,t|=0;var n=0,s=0,a=0;if(!(0|(r|=0))&!(0|(i|=0)))return s=1,T(0|(n=0)),0|s;s=e,n=t,e=1,t=0;do{e=0|rr(0|((a=!0&!(1&r))?1:s),0|(a?0:n),0|e,0|t),t=0|M(),r=0|sr(0|r,0|i,1),i=0|M(),s=0|rr(0|s,0|n,0|s,0|n),n=0|M()}while(!(!(0|r)&!(0|i)));return T(0|t),0|e}function wt(e,t,r,i){r|=0,i|=0;var a,o=0,l=0,A=0,u=0,h=0,d=0;a=P,P=P+16|0,l=a,A=0|ar(0|(e|=0),0|(t|=0),52),M(),A&=15;do{if(A){if(!(o=0|tt(e,t,l))){h=+s[l>>3],u=1/+c(+h),d=+s[25968+(A<<3)>>3],s[r>>3]=h+d,s[r+8>>3]=h-d,h=+s[l+8>>3],u*=d,s[r+16>>3]=u+h,s[r+24>>3]=h-u;break}return P=a,0|(A=o)}if(o=0|ar(0|e,0|t,45),M(),(o&=127)>>>0>121)return P=a,0|(A=5);l=22064+(o<<5)|0,n[r>>2]=n[l>>2],n[r+4>>2]=n[l+4>>2],n[r+8>>2]=n[l+8>>2],n[r+12>>2]=n[l+12>>2],n[r+16>>2]=n[l+16>>2],n[r+20>>2]=n[l+20>>2],n[r+24>>2]=n[l+24>>2],n[r+28>>2]=n[l+28>>2];break}while(0);return function(e,t){t=+t;var r,i,n,a,o,l,A,u=0,h=0;u=(a=+s[(n=16+(e|=0)|0)>>3])-(i=+s[(r=e+24|0)>>3]),u=a<i?u+6.283185307179586:u,h=+s[e>>3],u=.5*(u*t-u),h+=t=.5*((A=h-(l=+s[(o=e+8|0)>>3]))*t-A),s[e>>3]=h>1.5707963267948966?1.5707963267948966:h,t=l-t,s[o>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=(t=a+u)>3.141592653589793?t+-6.283185307179586:t,s[n>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=(t=i-u)>3.141592653589793?t+-6.283185307179586:t,s[r>>3]=t<-3.141592653589793?t+6.283185307179586:t}(r,i?1.4:1.1),(0|n[(i=26096+(A<<3)|0)>>2])==(0|e)&&(0|n[i+4>>2])==(0|t)&&(s[r>>3]=1.5707963267948966),(0|n[(A=26224+(A<<3)|0)>>2])==(0|e)&&(0|n[A+4>>2])==(0|t)&&(s[r+8>>3]=-1.5707963267948966),1.5707963267948966!=+s[r>>3]&&-1.5707963267948966!=+s[r+8>>3]?(P=a,0|(A=0)):(s[r+16>>3]=3.141592653589793,s[r+24>>3]=-3.141592653589793,P=a,0|(A=0))}function Tt(e,t,r,s){e|=0,t|=0,r|=0,s|=0;var a,o,l,A=0,u=0,h=0,c=0;l=P,P=P+48|0,a=l+40|0,o=l,Ve(u=l+32|0,0,0,0),h=0|n[u>>2],u=0|n[u+4>>2];do{if(r>>>0<=15){if(0|(A=0|Ct(s))){n[(s=o)>>2]=0,n[s+4>>2]=0,n[o+8>>2]=A,n[o+12>>2]=-1,h=o+29|0,n[(s=o+16|0)>>2]=0,n[s+4>>2]=0,n[s+8>>2]=0,i[s+12|0]=0,i[h|0]=0|i[a|0],i[h+1|0]=0|i[a+1|0],i[h+2|0]=0|i[a+2|0];break}if(A=0|Yt(1+(0|n[t+8>>2])|0,32)){Rt(t,A),n[(c=o)>>2]=h,n[c+4>>2]=u,n[o+8>>2]=0,n[o+12>>2]=r,n[o+16>>2]=s,n[o+20>>2]=t,n[o+24>>2]=A,i[o+28|0]=0,i[(h=o+29|0)|0]=0|i[a|0],i[h+1|0]=0|i[a+1|0],i[h+2|0]=0|i[a+2|0];break}n[(s=o)>>2]=0,n[s+4>>2]=0,n[o+8>>2]=13,n[o+12>>2]=-1,h=o+29|0,n[(s=o+16|0)>>2]=0,n[s+4>>2]=0,n[s+8>>2]=0,i[s+12|0]=0,i[h|0]=0|i[a|0],i[h+1|0]=0|i[a+1|0],i[h+2|0]=0|i[a+2|0];break}n[(h=o)>>2]=0,n[h+4>>2]=0,n[o+8>>2]=4,n[o+12>>2]=-1,c=o+29|0,n[(h=o+16|0)>>2]=0,n[h+4>>2]=0,n[h+8>>2]=0,i[h+12|0]=0,i[c|0]=0|i[a|0],i[c+1|0]=0|i[a+1|0],i[c+2|0]=0|i[a+2|0]}while(0);Mt(o),n[e>>2]=n[o>>2],n[e+4>>2]=n[o+4>>2],n[e+8>>2]=n[o+8>>2],n[e+12>>2]=n[o+12>>2],n[e+16>>2]=n[o+16>>2],n[e+20>>2]=n[o+20>>2],n[e+24>>2]=n[o+24>>2],n[e+28>>2]=n[o+28>>2],P=l}function Mt(e){var t,r,s,a,o=0,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0;if(a=P,P=P+336|0,t=a+168|0,r=a,!(0|(l=0|n[(A=e|=0)>>2]))&!(0|(A=0|n[A+4>>2])))P=a;else{if(0|i[(o=e+28|0)|0]?(l=0|St(l,A),A=0|M()):i[o|0]=1,!(0|n[n[(s=e+20|0)>>2]>>2]))return 0|(l=0|n[(o=e+24|0)>>2])&&Xt(l),n[(_=e)>>2]=0,n[_+4>>2]=0,n[e+8>>2]=0,n[s>>2]=0,n[e+12>>2]=-1,n[e+16>>2]=0,n[o>>2]=0,void(P=a);u=15&(o=0|n[(_=e+16|0)>>2]);e:do{if(!(0|l)&!(0|A))v=e+24|0;else{b=e+12|0,g=3==(0|u),m=255&o,p=3==(1|u),y=e+24|0,f=(u+-1|0)>>>0<3,c=3==(2|u),d=r+8|0;t:for(;;){if(h=0|ar(0|l,0|A,52),M(),(0|(h&=15))==(0|n[b>>2])){switch(15&m){case 0:case 2:case 3:if(0|(u=0|tt(l,A,t))){x=15;break t}if(0|Bt(0|n[s>>2],0|n[y>>2],t)){x=19;break t}}if(p&&(u=0|n[4+(0|n[s>>2])>>2],n[t>>2]=n[u>>2],n[t+4>>2]=n[u+4>>2],n[t+8>>2]=n[u+8>>2],n[t+12>>2]=n[u+12>>2],0|Y(26832,t))){if(0|Ze(0|n[4+(0|n[s>>2])>>2],h,r)){x=25;break}if((0|n[(u=r)>>2])==(0|l)&&(0|n[u+4>>2])==(0|A)){x=29;break}}if(f){if(0|(u=0|rt(l,A,t))){x=32;break}if(0|wt(l,A,r,0)){x=36;break}if(c&&0|Pt(0|n[s>>2],0|n[y>>2],t,r)){x=42;break}if(p&&0|Dt(0|n[s>>2],0|n[y>>2],t,r)){x=42;break}}if(g){if(o=0|wt(l,A,t,1),u=0|n[y>>2],0|o){x=45;break}if(0|K(u,t)){if(J(r,t),0|Z(t,0|n[y>>2])){x=53;break}if(0|Bt(0|n[s>>2],0|n[y>>2],d)){x=53;break}if(0|Dt(0|n[s>>2],0|n[y>>2],r,t)){x=53;break}}}}do{if((0|h)<(0|n[b>>2])){if(o=0|wt(l,A,t,1),u=0|n[y>>2],0|o){x=58;break t}if(!(0|K(u,t))){x=73;break}if(0|Z(0|n[y>>2],t)&&(J(r,t),0|Pt(0|n[s>>2],0|n[y>>2],r,t))){x=65;break t}if(0|(l=0|He(l,A,h+1|0,r))){x=67;break t}l=0|n[(A=r)>>2],A=0|n[A+4>>2]}else x=73}while(0);if(73==(0|x)&&(x=0,l=0|St(l,A),A=0|M()),!(0|l)&!(0|A)){v=y;break e}}switch(0|x){case 15:0|(o=0|n[y>>2])&&Xt(o),n[(x=e)>>2]=0,n[x+4>>2]=0,n[s>>2]=0,n[b>>2]=-1,n[_>>2]=0,n[y>>2]=0,n[e+8>>2]=u,x=20;break;case 19:n[e>>2]=l,n[e+4>>2]=A,x=20;break;case 25:S(27795,27761,470,27772);break;case 29:case 42:return n[e>>2]=l,n[e+4>>2]=A,void(P=a);case 32:return 0|(o=0|n[y>>2])&&Xt(o),n[(v=e)>>2]=0,n[v+4>>2]=0,n[s>>2]=0,n[b>>2]=-1,n[_>>2]=0,n[y>>2]=0,n[e+8>>2]=u,void(P=a);case 36:S(27795,27761,493,27772);break;case 45:0|u&&Xt(u),n[(x=e)>>2]=0,n[x+4>>2]=0,n[s>>2]=0,n[b>>2]=-1,n[_>>2]=0,n[y>>2]=0,n[e+8>>2]=o,x=55;break;case 53:n[e>>2]=l,n[e+4>>2]=A,x=55;break;case 58:0|u&&Xt(u),n[(x=e)>>2]=0,n[x+4>>2]=0,n[s>>2]=0,n[b>>2]=-1,n[_>>2]=0,n[y>>2]=0,n[e+8>>2]=o,x=71;break;case 65:n[e>>2]=l,n[e+4>>2]=A,x=71;break;case 67:return 0|(o=0|n[y>>2])&&Xt(o),n[(v=e)>>2]=0,n[v+4>>2]=0,n[s>>2]=0,n[b>>2]=-1,n[_>>2]=0,n[y>>2]=0,n[e+8>>2]=l,void(P=a)}if(20==(0|x))return void(P=a);if(55==(0|x))return void(P=a);if(71==(0|x))return void(P=a)}}while(0);0|(o=0|n[v>>2])&&Xt(o),n[(x=e)>>2]=0,n[x+4>>2]=0,n[e+8>>2]=0,n[s>>2]=0,n[e+12>>2]=-1,n[_>>2]=0,n[v>>2]=0,P=a}}function St(e,t){var r,i=0,s=0,a=0,o=0,l=0,A=0,u=0,h=0,c=0;r=P,P=P+16|0,c=r,s=0|ar(0|(e|=0),0|(t|=0),52),M(),s&=15,i=0|ar(0|e,0|t,45),M();do{if(s){for(;i=0|or(s+4095|0,0,52),a=M()|-15728641&t,i=i|e|(l=0|or(7,0,0|(o=3*(15-s|0)|0))),a|=A=0|M(),u=0|ar(0|e,0|t,0|o),M(),s=s+-1|0,!((u&=7)>>>0<6);){if(!s){h=4;break}t=a,e=i}if(4==(0|h)){i=0|ar(0|i,0|a,45),M();break}return c=0|or(((c=!(0|u)&!!(0|Ge(i,a)))?2:1)+u|0,0,0|o),h=0|M()|t&~A,c|=e&~l,T(0|h),P=r,0|c}}while(0);return(i&=127)>>>0>120?(c=0,T(0|(h=0)),P=r,0|c):(Ve(c,0,i+1|0,0),h=0|n[c+4>>2],c=0|n[c>>2],T(0|h),P=r,0|c)}function Et(e,t,r){e|=0;var i,a=0,o=0,l=0,A=0,u=0,h=0,c=0,d=0,p=0;if(!(0|Y(t|=0,r|=0)))return 0|(p=0);if(t=0|$(t),a=+s[r>>3],o=t&(o=+s[r+8>>3])<0?o+6.283185307179586:o,(0|(p=0|n[e>>2]))<=0)return 0|(p=0);if(i=0|n[e+4>>2],t){t=0,d=o,r=-1,e=0;e:for(;;){for(c=e;A=+s[i+(c<<4)>>3],o=+s[i+(c<<4)+8>>3],l=+s[i+((e=(r+2|0)%(0|p)|0)<<4)>>3],u=+s[i+(e<<4)+8>>3],A>l?(h=A,A=u):(h=l,l=A,A=o,o=u),(a=a==l|a==h?a+2220446049250313e-31:a)<l|a>h;){if((0|(r=c+1|0))>=(0|p)){r=22;break e}e=c,c=r,r=e}if(((h=(u=A<0?A+6.283185307179586:A)+(a-l)/(h-l)*((A=o<0?o+6.283185307179586:o)-u))<0?h+6.283185307179586:h)>(d=u==d|A==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=c+1|0))>=(0|p)){r=22;break}r=c}if(22==(0|r))return 0|t}else{t=0,d=o,r=-1,e=0;e:for(;;){for(c=e;A=+s[i+(c<<4)>>3],o=+s[i+(c<<4)+8>>3],l=+s[i+((e=(r+2|0)%(0|p)|0)<<4)>>3],u=+s[i+(e<<4)+8>>3],A>l?(h=A,A=u):(h=l,l=A,A=o,o=u),(a=a==l|a==h?a+2220446049250313e-31:a)<l|a>h;){if((0|(r=c+1|0))>=(0|p)){r=22;break e}e=c,c=r,r=e}if(A+(a-l)/(h-l)*(o-A)>(d=A==d|o==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=c+1|0))>=(0|p)){r=22;break}r=c}if(22==(0|r))return 0|t}return 0}function Nt(e,t){t|=0;var r,i,a,o,l,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0;if(!(i=0|n[(e|=0)>>2]))return n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,n[t+12>>2]=0,n[t+16>>2]=0,n[t+20>>2]=0,n[t+24>>2]=0,void(n[t+28>>2]=0);if(s[(a=t+8|0)>>3]=17976931348623157e292,s[(o=t+24|0)>>3]=17976931348623157e292,s[t>>3]=-17976931348623157e292,s[(l=t+16|0)>>3]=-17976931348623157e292,!((0|i)<=0)){for(r=0|n[e+4>>2],g=17976931348623157e292,y=-17976931348623157e292,b=0,e=-1,d=17976931348623157e292,p=17976931348623157e292,m=-17976931348623157e292,h=-17976931348623157e292,x=0;u=+s[r+(x<<4)>>3],f=+s[r+(x<<4)+8>>3],c=+s[r+(((0|(e=e+2|0))==(0|i)?0:e)<<4)+8>>3],u<d&&(s[a>>3]=u,d=u),f<p&&(s[o>>3]=f,p=f),u>m?s[t>>3]=u:u=m,f>h&&(s[l>>3]=f,h=f),g=f>0&f<g?f:g,y=f<0&f>y?f:y,b|=+A(+(f-c))>3.141592653589793,(0|(e=x+1|0))!=(0|i);)v=x,m=u,x=e,e=v;b&&(s[l>>3]=y,s[o>>3]=g)}}function Ct(e){return 0|((e|=0)>>>0<4?0:15)}function Rt(e,t){t|=0;var r,i=0,a=0,o=0,l=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0,w=0,T=0,M=0,S=0;if(y=0|n[(e|=0)>>2]){if(s[(b=t+8|0)>>3]=17976931348623157e292,s[(x=t+24|0)>>3]=17976931348623157e292,s[t>>3]=-17976931348623157e292,s[(v=t+16|0)>>3]=-17976931348623157e292,(0|y)>0){for(o=0|n[e+4>>2],m=17976931348623157e292,g=-17976931348623157e292,a=0,i=-1,c=17976931348623157e292,d=17976931348623157e292,f=-17976931348623157e292,u=-17976931348623157e292,_=0;l=+s[o+(_<<4)>>3],p=+s[o+(_<<4)+8>>3],h=+s[o+(((0|(M=i+2|0))==(0|y)?0:M)<<4)+8>>3],l<c&&(s[b>>3]=l,c=l),p<d&&(s[x>>3]=p,d=p),l>f?s[t>>3]=l:l=f,p>u&&(s[v>>3]=p,u=p),m=p>0&p<m?p:m,g=p<0&p>g?p:g,a|=+A(+(p-h))>3.141592653589793,(0|(i=_+1|0))!=(0|y);)M=_,f=l,_=i,i=M;a&&(s[v>>3]=g,s[x>>3]=m)}}else n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,n[t+12>>2]=0,n[t+16>>2]=0,n[t+20>>2]=0,n[t+24>>2]=0,n[t+28>>2]=0;if(!((0|(i=0|n[(M=e+8|0)>>2]))<=0)){r=e+12|0,T=0;do{if(o=0|n[r>>2],a=T,x=t+((T=T+1|0)<<5)|0,v=0|n[o+(a<<3)>>2]){if(s[(_=t+(T<<5)+8|0)>>3]=17976931348623157e292,s[(e=t+(T<<5)+24|0)>>3]=17976931348623157e292,s[x>>3]=-17976931348623157e292,s[(w=t+(T<<5)+16|0)>>3]=-17976931348623157e292,(0|v)>0){for(y=0|n[o+(a<<3)+4>>2],m=17976931348623157e292,g=-17976931348623157e292,o=0,a=-1,b=0,c=17976931348623157e292,d=17976931348623157e292,p=-17976931348623157e292,u=-17976931348623157e292;l=+s[y+(b<<4)>>3],f=+s[y+(b<<4)+8>>3],h=+s[y+(((0|(a=a+2|0))==(0|v)?0:a)<<4)+8>>3],l<c&&(s[_>>3]=l,c=l),f<d&&(s[e>>3]=f,d=f),l>p?s[x>>3]=l:l=p,f>u&&(s[w>>3]=f,u=f),m=f>0&f<m?f:m,g=f<0&f>g?f:g,o|=+A(+(f-h))>3.141592653589793,(0|(a=b+1|0))!=(0|v);)S=b,b=a,p=l,a=S;o&&(s[w>>3]=g,s[e>>3]=m)}}else n[x>>2]=0,n[x+4>>2]=0,n[x+8>>2]=0,n[x+12>>2]=0,n[x+16>>2]=0,n[x+20>>2]=0,n[x+24>>2]=0,n[x+28>>2]=0,i=0|n[M>>2]}while((0|T)<(0|i))}}function Bt(e,t,r){var i=0,s=0,a=0;if(!(0|Et(e|=0,t|=0,r|=0)))return 0|(s=0);if((0|n[(s=e+8|0)>>2])<=0)return 0|(s=1);for(i=e+12|0,e=0;;){if(a=e,e=e+1|0,0|Et((0|n[i>>2])+(a<<3)|0,t+(e<<5)|0,r)){e=0,i=6;break}if((0|e)>=(0|n[s>>2])){e=1,i=6;break}}return 6==(0|i)?0|e:0}function Pt(e,t,r,i){i|=0;var s,a,o=0,l=0,A=0,u=0,h=0;if(a=P,P=P+16|0,s=a,!(0|Et(e|=0,t|=0,A=(r|=0)+8|0)))return P=a,0|(u=0);u=e+8|0;e:do{if((0|n[u>>2])>0){for(l=e+12|0,o=0;;){if(h=o,o=o+1|0,0|Et((0|n[l>>2])+(h<<3)|0,t+(o<<5)|0,A)){o=0;break}if((0|o)>=(0|n[u>>2]))break e}return P=a,0|o}}while(0);if(0|qt(e,t,r,i))return P=a,0|(h=0);n[s>>2]=n[r>>2],n[s+4>>2]=A,o=0|n[u>>2];e:do{if((0|o)>0)for(e=e+12|0,A=0,l=o;;){if(o=0|n[e>>2],(0|n[o+(A<<3)>>2])>0){if(0|Et(s,i,0|n[o+(A<<3)+4>>2])){o=0;break e}if(o=A+1|0,0|qt((0|n[e>>2])+(A<<3)|0,t+(o<<5)|0,r,i)){o=0;break e}l=0|n[u>>2]}else o=A+1|0;if(!((0|o)<(0|l))){o=1;break}A=o}else o=1}while(0);return P=a,0|(h=o)}function qt(e,t,r,i){e|=0,r|=0;var a,o,l,A,u,h,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0,w=0,T=0,M=0,S=0;if(h=P,P=P+176|0,A=h+172|0,c=h+168|0,u=h,!(0|K(t|=0,i|=0)))return P=h,0|(e=0);if(function(e,t,r,i){var a,o,l,A,u;t|=0,r|=0,i|=0,e=(o=+s[16+(e|=0)>>3])<(u=+s[e+24>>3]),a=(A=+s[t+16>>3])<(l=+s[t+24>>3]),t=u-A<l-o,n[r>>2]=e?a|t?1:2:0,n[i>>2]=a?e?1:t?2:1:0}(t,i,A,c),cr(0|u,0|r,168),(0|n[r>>2])>0){t=0;do{_=+At(+s[(M=u+8+(t<<4)+8|0)>>3],0|n[c>>2]),s[M>>3]=_,t=t+1|0}while((0|t)<(0|n[r>>2]))}o=+s[i>>3],l=+s[i+8>>3],_=+At(+s[i+16>>3],0|n[c>>2]),a=+At(+s[i+24>>3],0|n[c>>2]);e:do{if((0|n[e>>2])>0){if(i=e+4|0,(0|(c=0|n[u>>2]))<=0)for(t=0;;)if((0|(t=t+1|0))>=(0|n[e>>2])){t=0;break e}for(r=0;;){if(t=0|n[i>>2],x=+s[t+(r<<4)>>3],v=+At(+s[t+(r<<4)+8>>3],0|n[A>>2]),t=0|n[i>>2],M=(0|(r=r+1|0))%(0|n[e>>2])|0,d=+s[t+(M<<4)>>3],p=+At(+s[t+(M<<4)+8>>3],0|n[A>>2]),!(x>=o)|!(d>=o)&&!(x<=l)|!(d<=l)&&!(v<=a)|!(p<=a)&&!(v>=_)|!(p>=_)){b=d-x,g=p-v,t=0;do{if(S=t,M=(0|(t=t+1|0))==(0|c)?0:t,d=+s[u+8+(S<<4)+8>>3],p=+s[u+8+(M<<4)+8>>3]-d,f=+s[u+8+(S<<4)>>3],!(0==(y=b*p-g*(m=+s[u+8+(M<<4)>>3]-f))||(w=v-d,T=x-f,m=(w*m-p*T)/y,m<0|m>1))&&(y=(b*w-g*T)/y)>=0&y<=1){t=1;break e}}while((0|t)<(0|c))}if((0|r)>=(0|n[e>>2])){t=0;break}}}else t=0}while(0);return P=h,0|(S=t)}function Dt(e,t,r,i){var s=0,a=0,o=0;if(0|qt(e|=0,t|=0,r|=0,i|=0))return 0|(a=1);if((0|n[(a=e+8|0)>>2])<=0)return 0|(a=0);for(s=e+12|0,e=0;;){if(o=e,e=e+1|0,0|qt((0|n[s>>2])+(o<<3)|0,t+(e<<5)|0,r,i)){e=1,s=6;break}if((0|e)>=(0|n[a>>2])){e=0,s=6;break}}return 6==(0|s)?0|e:0}function It(e,t,r,i,n){t|=0,r|=0,i|=0,n|=0;var a,o,l,A,u,h,c,d=0;A=+s[(e|=0)>>3],l=+s[t>>3]-A,o=+s[e+8>>3],a=+s[t+8>>3]-o,h=+s[r>>3],d=((d=+s[i>>3]-h)*(o-(c=+s[r+8>>3]))-(A-h)*(u=+s[i+8>>3]-c))/(l*u-a*d),s[n>>3]=A+l*d,s[n+8>>3]=o+a*d}function Ft(e,t){return t|=0,+A(+(+s[(e|=0)>>3]-+s[t>>3]))<1.1920928955078125e-7?0|(t=+A(+(+s[e+8>>3]-+s[t+8>>3]))<1.1920928955078125e-7):0|(t=0)}function Ot(e,t){t|=0;var r,i,n;return+((n=+s[(e|=0)>>3]-+s[t>>3])*n+(i=+s[e+8>>3]-+s[t+8>>3])*i+(r=+s[e+16>>3]-+s[t+16>>3])*r)}function Lt(e,t,r){r|=0;var i,s,a,o,l=0,A=0,u=0;if(o=P,P=P+32|0,u=o,0|(l=0|et(e|=0,t|=0,s=o+16|0)))return P=o,0|(r=l);i=0|Le(e,t),a=0|We(e,t),function(e,t){e=7696+(28*(e|=0)|0)|0,n[(t|=0)>>2]=n[e>>2],n[t+4>>2]=n[e+4>>2],n[t+8>>2]=n[e+8>>2],n[t+12>>2]=n[e+12>>2]}(i,u),l=0|function(e,t){e|=0;var r=0,i=0;if((t|=0)>>>0>20)return-1;do{if((0|n[11120+(216*t|0)>>2])!=(0|e))if((0|n[11120+(216*t|0)+8>>2])!=(0|e))if((0|n[11120+(216*t|0)+16>>2])!=(0|e))if((0|n[11120+(216*t|0)+24>>2])!=(0|e))if((0|n[11120+(216*t|0)+32>>2])!=(0|e))if((0|n[11120+(216*t|0)+40>>2])!=(0|e))if((0|n[11120+(216*t|0)+48>>2])!=(0|e))if((0|n[11120+(216*t|0)+56>>2])!=(0|e))if((0|n[11120+(216*t|0)+64>>2])!=(0|e))if((0|n[11120+(216*t|0)+72>>2])!=(0|e))if((0|n[11120+(216*t|0)+80>>2])!=(0|e))if((0|n[11120+(216*t|0)+88>>2])!=(0|e))if((0|n[11120+(216*t|0)+96>>2])!=(0|e))if((0|n[11120+(216*t|0)+104>>2])!=(0|e))if((0|n[11120+(216*t|0)+112>>2])!=(0|e))if((0|n[11120+(216*t|0)+120>>2])!=(0|e))if((0|n[11120+(216*t|0)+128>>2])!=(0|e)){if((0|n[11120+(216*t|0)+136>>2])!=(0|e)){if((0|n[11120+(216*t|0)+144>>2])==(0|e)){e=0,r=2,i=0;break}if((0|n[11120+(216*t|0)+152>>2])==(0|e)){e=0,r=2,i=1;break}if((0|n[11120+(216*t|0)+160>>2])==(0|e)){e=0,r=2,i=2;break}if((0|n[11120+(216*t|0)+168>>2])==(0|e)){e=1,r=2,i=0;break}if((0|n[11120+(216*t|0)+176>>2])==(0|e)){e=1,r=2,i=1;break}if((0|n[11120+(216*t|0)+184>>2])==(0|e)){e=1,r=2,i=2;break}if((0|n[11120+(216*t|0)+192>>2])==(0|e)){e=2,r=2,i=0;break}if((0|n[11120+(216*t|0)+200>>2])==(0|e)){e=2,r=2,i=1;break}if((0|n[11120+(216*t|0)+208>>2])==(0|e)){e=2,r=2,i=2;break}return-1}e=2,r=1,i=2}else e=2,r=1,i=1;else e=2,r=1,i=0;else e=1,r=1,i=2;else e=1,r=1,i=1;else e=1,r=1,i=0;else e=0,r=1,i=2;else e=0,r=1,i=1;else e=0,r=1,i=0;else e=2,r=0,i=2;else e=2,r=0,i=1;else e=2,r=0,i=0;else e=1,r=0,i=2;else e=1,r=0,i=1;else e=1,r=0,i=0;else e=0,r=0,i=2;else e=0,r=0,i=1;else e=0,r=0,i=0}while(0);return 0|n[11120+(216*t|0)+(72*r|0)+(24*e|0)+(i<<3)+4>>2]}(i,0|n[s>>2]);e:do{if(0|V(i)){switch(0|i){case 4:e=0;break;case 14:e=1;break;case 24:e=2;break;case 38:e=3;break;case 49:e=4;break;case 58:e=5;break;case 63:e=6;break;case 72:e=7;break;case 83:e=8;break;case 97:e=9;break;case 107:e=10;break;case 117:e=11;break;default:l=1;break e}if(A=0|n[26416+(24*e|0)+8>>2],t=0|n[26416+(24*e|0)+16>>2],(0|(e=0|n[s>>2]))!=(0|n[u>>2])&&(u=0|U(i))|(0|(e=0|n[s>>2]))==(0|t)&&(l=(l+1|0)%6|0),3==(0|a)&(0|e)==(0|t)){l=(l+5|0)%6|0,A=22;break}5==(0|a)&(0|e)==(0|A)?(l=(l+1|0)%6|0,A=22):A=22}else A=22}while(0);return 22==(0|A)&&(n[r>>2]=l,l=0),P=o,0|(r=l)}function kt(e,t,r,i){r|=0,i|=0;var s,a,o,l,A,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0;if(A=P,P=P+32|0,x=A+24|0,l=A+20|0,o=A+8|0,a=A+16|0,s=A,p=(p=!(0|Ge(e|=0,t|=0)))?6:5,m=0|ar(0|e,0|t,52),M(),p>>>0<=r>>>0)return P=A,0|(i=2);!(g=!(0|(m&=15)))&&!((y=0|or(7,0,3*(15^m)|0))&e|0)&!((0|M())&t)?u=r:h=4;e:do{if(4==(0|h)){if((0|((u=!!(0|Ge(e,t)))?4:5))<(0|r))return P=A,0|(i=1);if(0|Lt(e,t,x))return P=A,0|(i=1);if(h=(0|n[x>>2])+r|0,7==(0|(y=0|n[(u=u?26704+((0|h)%5<<2)|0:26736+((0|h)%6<<2)|0)>>2])))return P=A,0|(i=1);n[l>>2]=0,u=0|O(e,t,y,l,o);do{if(!u){if(f=0|n[(d=o)>>2],h=(c=(d=0|n[d+4>>2])>>>0<t>>>0|(0|d)==(0|t)&f>>>0<e>>>0)?f:e,c=c?d:t,!g&&!(f&(g=0|or(7,0,3*(15^m)|0))|0)&!(d&(0|M())))u=r;else{if(d=(r+-1+p|0)%(0|p)|0,u=0|Ge(e,t),(0|d)<0&&S(27795,27797,246,27806),(0|((p=!!(0|u))?4:5))<(0|d)&&S(27795,27797,246,27806),0|Lt(e,t,x)&&S(27795,27797,246,27806),u=(0|n[x>>2])+d|0,7==(0|(d=0|n[(u=p?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2]))&&S(27795,27797,246,27806),n[a>>2]=0,0|(u=0|O(e,t,d,a,s)))break;p=0|n[(f=s)>>2],f=0|n[f+4>>2];do{if(f>>>0<c>>>0|(0|f)==(0|c)&p>>>0<h>>>0){if(h=0|Ge(p,f)?0|L(p,f,e,t):0|n[26800+(((0|n[a>>2])+(0|n[26768+(d<<2)>>2])|0)%6<<2)>>2],u=0|Ge(p,f),(h+-1|0)>>>0>5){u=-1,h=p,c=f;break}if(1==(0|h)&(u=!!(0|u))){u=-1,h=p,c=f;break}do{if(!(0|Lt(p,f,x))){if(u){u=(5+(0|n[26352+(h<<2)>>2])-(0|n[x>>2])|0)%5|0;break}u=(6+(0|n[26384+(h<<2)>>2])-(0|n[x>>2])|0)%6|0;break}u=-1}while(0);h=p,c=f}else u=r}while(0);f=0|n[(d=o)>>2],d=0|n[d+4>>2]}if((0|h)==(0|f)&(0|c)==(0|d)){if(e=(p=!!(0|Ge(f,d)))?0|L(f,d,e,t):0|n[26800+(((0|n[l>>2])+(0|n[26768+(y<<2)>>2])|0)%6<<2)>>2],u=0|Ge(f,d),(e+-1|0)>>>0<=5&&!(1==(0|e)&(b=!!(0|u))))do{if(!(0|Lt(f,d,x))){if(b){u=(5+(0|n[26352+(e<<2)>>2])-(0|n[x>>2])|0)%5|0;break}u=(6+(0|n[26384+(e<<2)>>2])-(0|n[x>>2])|0)%6|0;break}u=-1}while(0);else u=-1;u=6==(0|(u=u+1|0))|p&5==(0|u)?0:u}t=c,e=h;break e}}while(0);return P=A,0|(i=u)}}while(0);return b=0|or(0|u,0,56),x=M()|-2130706433&t|536870912,n[i>>2]=b|e,n[i+4>>2]=x,P=A,0|(i=0)}function Vt(e,t,r){e|=0,r|=0;var i=0;(0|(t|=0))>0?(i=0|Yt(t,4),n[e>>2]=i,i||S(27819,27842,40,27856)):n[e>>2]=0,n[e+4>>2]=t,n[e+8>>2]=0,n[e+12>>2]=r}function Ut(e){var t,r,i,a=0,o=0,l=0,u=0;t=(e|=0)+4|0,r=e+12|0,i=e+8|0;e:for(;;){for(o=0|n[t>>2],a=0;;){if((0|a)>=(0|o))break e;if(l=0|n[e>>2],u=0|n[l+(a<<2)>>2])break;a=a+1|0}a=l+(~~(+A(+ +h(10,+ +(15-(0|n[r>>2])|0))*(+s[u>>3]+ +s[u+8>>3]))%+(0|o))>>>0<<2)|0,o=0|n[a>>2];t:do{if(0|o){if(l=u+32|0,(0|o)==(0|u))n[a>>2]=n[l>>2];else{if(!(a=0|n[(o=o+32|0)>>2]))break;for(;(0|a)!=(0|u);)if(!(a=0|n[(o=a+32|0)>>2]))break t;n[o>>2]=n[l>>2]}Xt(u),n[i>>2]=(0|n[i>>2])-1}}while(0)}Xt(0|n[e>>2])}function zt(e){var t,r=0,i=0;for(t=0|n[(e|=0)+4>>2],i=0;;){if((0|i)>=(0|t)){r=0,i=4;break}if(r=0|n[(0|n[e>>2])+(i<<2)>>2]){i=4;break}i=i+1|0}return 4==(0|i)?0|r:0}function Gt(e,t){t|=0;var r=0,i=0,a=0,o=0;if(r=~~(+A(+ +h(10,+ +(15-(0|n[(e|=0)+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|n[e+4>>2]))>>>0,r=(0|n[e>>2])+(r<<2)|0,!(i=0|n[r>>2]))return 0|(o=1);o=t+32|0;do{if((0|i)!=(0|t)){if(!(r=0|n[i+32>>2]))return 0|(o=1);for(a=r;;){if((0|a)==(0|t)){a=8;break}if(!(r=0|n[a+32>>2])){r=1,a=10;break}i=a,a=r}if(8==(0|a)){n[i+32>>2]=n[o>>2];break}if(10==(0|a))return 0|r}else n[r>>2]=n[o>>2]}while(0);return Xt(t),n[(o=e+8|0)>>2]=(0|n[o>>2])-1,0|(o=0)}function jt(e,t,r){e|=0,t|=0,r|=0;var i,a=0,o=0,l=0;(i=0|$t(40))||S(27872,27842,98,27885),n[i>>2]=n[t>>2],n[i+4>>2]=n[t+4>>2],n[i+8>>2]=n[t+8>>2],n[i+12>>2]=n[t+12>>2],n[(o=i+16|0)>>2]=n[r>>2],n[o+4>>2]=n[r+4>>2],n[o+8>>2]=n[r+8>>2],n[o+12>>2]=n[r+12>>2],n[i+32>>2]=0,o=~~(+A(+ +h(10,+ +(15-(0|n[e+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|n[e+4>>2]))>>>0,o=(0|n[e>>2])+(o<<2)|0,a=0|n[o>>2];do{if(a){for(;!(0|lt(a,t)&&0|lt(a+16|0,r));)if(o=0|n[a+32>>2],!(0|n[(a=0|o?o:a)+32>>2])){l=10;break}if(10==(0|l)){n[a+32>>2]=i;break}return Xt(i),0|(l=a)}n[o>>2]=i}while(0);return n[(l=e+8|0)>>2]=1+(0|n[l>>2]),0|(l=i)}function Ht(e,t,r){t|=0,r|=0;var i=0,a=0;if(a=~~(+A(+ +h(10,+ +(15-(0|n[(e|=0)+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|n[e+4>>2]))>>>0,!(a=0|n[(0|n[e>>2])+(a<<2)>>2]))return 0|(r=0);if(!r){for(e=a;;){if(0|lt(e,t)){i=10;break}if(!(e=0|n[e+32>>2])){e=0,i=10;break}}if(10==(0|i))return 0|e}for(e=a;;){if(0|lt(e,t)&&0|lt(e+16|0,r)){i=10;break}if(!(e=0|n[e+32>>2])){e=0,i=10;break}}return 10==(0|i)?0|e:0}function Wt(e,t){t|=0;var r=0;if(r=~~(+A(+ +h(10,+ +(15-(0|n[(e|=0)+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|n[e+4>>2]))>>>0,!(e=0|n[(0|n[e>>2])+(r<<2)>>2]))return 0|(r=0);for(;;){if(0|lt(e,t)){t=5;break}if(!(e=0|n[e+32>>2])){e=0,t=5;break}}return 5==(0|t)?0|e:0}function Qt(e){return 0|+pr(+(e=+e))}function $t(e){e|=0;var t,r=0,i=0,s=0,a=0,o=0,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0;t=P,P=P+16|0,p=t;do{if(e>>>0<245){if(e=(h=e>>>0<11?16:e+11&-8)>>>3,3&(i=(d=0|n[6977])>>>e))return s=0|n[(i=(e=27948+((r=(1&i^1)+e|0)<<1<<2)|0)+8|0)>>2],(0|(o=0|n[(a=s+8|0)>>2]))==(0|e)?n[6977]=d&~(1<<r):(n[o+12>>2]=e,n[i>>2]=o),_=r<<3,n[s+4>>2]=3|_,n[(_=s+_+4|0)>>2]=1|n[_>>2],P=t,0|(_=a);if(h>>>0>(c=0|n[6979])>>>0){if(0|i)return r=((r=i<<e&((r=2<<e)|0-r))&0-r)-1|0,o=0|n[(e=(r=27948+((s=((i=(r>>>=A=r>>>12&16)>>>5&8)|A|(o=(r>>>=i)>>>2&4)|(e=(r>>>=o)>>>1&2)|(s=(r>>>=e)>>>1&1))+(r>>>s)|0)<<1<<2)|0)+8|0)>>2],(0|(i=0|n[(A=o+8|0)>>2]))==(0|r)?(e=d&~(1<<s),n[6977]=e):(n[i+12>>2]=r,n[e>>2]=i,e=d),l=(_=s<<3)-h|0,n[o+4>>2]=3|h,n[(a=o+h|0)+4>>2]=1|l,n[o+_>>2]=l,0|c&&(s=0|n[6982],i=27948+((r=c>>>3)<<1<<2)|0,e&(r=1<<r)?r=0|n[(e=i+8|0)>>2]:(n[6977]=e|r,r=i,e=i+8|0),n[e>>2]=s,n[r+12>>2]=s,n[s+8>>2]=r,n[s+12>>2]=i),n[6979]=l,n[6982]=a,P=t,0|(_=A);if(o=0|n[6978]){for(i=(o&0-o)-1|0,i=u=0|n[28212+(((s=(i>>>=a=i>>>12&16)>>>5&8)|a|(l=(i>>>=s)>>>2&4)|(A=(i>>>=l)>>>1&2)|(u=(i>>>=A)>>>1&1))+(i>>>u)<<2)>>2],A=u,u=(-8&n[u+4>>2])-h|0;(e=0|n[i+16>>2])||(e=0|n[i+20>>2]);)i=e,A=(a=(l=(-8&n[e+4>>2])-h|0)>>>0<u>>>0)?e:A,u=a?l:u;if((l=A+h|0)>>>0>A>>>0){a=0|n[A+24>>2],r=0|n[A+12>>2];do{if((0|r)==(0|A)){if(!(r=0|n[(e=A+20|0)>>2])&&!(r=0|n[(e=A+16|0)>>2])){i=0;break}for(;;)if(i=0|n[(s=r+20|0)>>2])r=i,e=s;else{if(!(i=0|n[(s=r+16|0)>>2]))break;r=i,e=s}n[e>>2]=0,i=r}else i=0|n[A+8>>2],n[i+12>>2]=r,n[r+8>>2]=i,i=r}while(0);do{if(0|a){if(r=0|n[A+28>>2],(0|A)==(0|n[(e=28212+(r<<2)|0)>>2])){if(n[e>>2]=i,!i){n[6978]=o&~(1<<r);break}}else if(n[((0|n[(_=a+16|0)>>2])==(0|A)?_:a+20)>>2]=i,!i)break;n[i+24>>2]=a,0|(r=0|n[A+16>>2])&&(n[i+16>>2]=r,n[r+24>>2]=i),0|(r=0|n[A+20>>2])&&(n[i+20>>2]=r,n[r+24>>2]=i)}}while(0);return u>>>0<16?(_=u+h|0,n[A+4>>2]=3|_,n[(_=A+_+4|0)>>2]=1|n[_>>2]):(n[A+4>>2]=3|h,n[l+4>>2]=1|u,n[l+u>>2]=u,0|c&&(s=0|n[6982],i=27948+((r=c>>>3)<<1<<2)|0,(r=1<<r)&d?r=0|n[(e=i+8|0)>>2]:(n[6977]=r|d,r=i,e=i+8|0),n[e>>2]=s,n[r+12>>2]=s,n[s+8>>2]=r,n[s+12>>2]=i),n[6979]=u,n[6982]=l),P=t,0|(_=A+8|0)}d=h}else d=h}else d=h}else if(e>>>0<=4294967231)if(h=-8&(e=e+11|0),s=0|n[6978]){a=0-h|0,u=(e>>>=8)?h>>>0>16777215?31:h>>>((u=14-((A=((g=e<<(d=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|d|(u=((g<<=A)+245760|0)>>>16&2))+(g<<u>>>15)|0)+7|0)&1|u<<1:0,i=0|n[28212+(u<<2)>>2];e:do{if(i)for(e=0,A=h<<(31==(0|u)?0:25-(u>>>1)|0),o=0;;){if((l=(-8&n[i+4>>2])-h|0)>>>0<a>>>0){if(!l){e=i,a=0,g=65;break e}e=i,a=l}if(o=!(0|(g=0|n[i+20>>2]))|(0|g)==(0|(i=0|n[i+16+(A>>>31<<2)>>2]))?o:g,!i){i=o,g=61;break}A<<=1}else i=0,e=0,g=61}while(0);if(61==(0|g)){if(!(0|i)&!(0|e)){if(!(e=((e=2<<u)|0-e)&s)){d=h;break}d=(e&0-e)-1|0,e=0,i=0|n[28212+(((o=(d>>>=l=d>>>12&16)>>>5&8)|l|(A=(d>>>=o)>>>2&4)|(u=(d>>>=A)>>>1&2)|(i=(d>>>=u)>>>1&1))+(d>>>i)<<2)>>2]}i?g=65:(A=e,l=a)}if(65==(0|g))for(o=i;;){if(a=(i=(d=(-8&n[o+4>>2])-h|0)>>>0<a>>>0)?d:a,e=i?o:e,(i=0|n[o+16>>2])||(i=0|n[o+20>>2]),!i){A=e,l=a;break}o=i}if(0|A&&l>>>0<((0|n[6979])-h|0)>>>0&&(c=A+h|0)>>>0>A>>>0){o=0|n[A+24>>2],r=0|n[A+12>>2];do{if((0|r)==(0|A)){if(!(r=0|n[(e=A+20|0)>>2])&&!(r=0|n[(e=A+16|0)>>2])){r=0;break}for(;;)if(i=0|n[(a=r+20|0)>>2])r=i,e=a;else{if(!(i=0|n[(a=r+16|0)>>2]))break;r=i,e=a}n[e>>2]=0}else _=0|n[A+8>>2],n[_+12>>2]=r,n[r+8>>2]=_}while(0);do{if(o){if(e=0|n[A+28>>2],(0|A)==(0|n[(i=28212+(e<<2)|0)>>2])){if(n[i>>2]=r,!r){s&=~(1<<e),n[6978]=s;break}}else if(n[((0|n[(_=o+16|0)>>2])==(0|A)?_:o+20)>>2]=r,!r)break;n[r+24>>2]=o,0|(e=0|n[A+16>>2])&&(n[r+16>>2]=e,n[e+24>>2]=r),(e=0|n[A+20>>2])&&(n[r+20>>2]=e,n[e+24>>2]=r)}}while(0);e:do{if(l>>>0<16)_=l+h|0,n[A+4>>2]=3|_,n[(_=A+_+4|0)>>2]=1|n[_>>2];else{if(n[A+4>>2]=3|h,n[c+4>>2]=1|l,n[c+l>>2]=l,r=l>>>3,l>>>0<256){i=27948+(r<<1<<2)|0,(e=0|n[6977])&(r=1<<r)?r=0|n[(e=i+8|0)>>2]:(n[6977]=e|r,r=i,e=i+8|0),n[e>>2]=c,n[r+12>>2]=c,n[c+8>>2]=r,n[c+12>>2]=i;break}if(r=28212+((i=(r=l>>>8)?l>>>0>16777215?31:l>>>((i=14-((x=((_=r<<(v=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|v|(i=((_<<=x)+245760|0)>>>16&2))+(_<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,n[c+28>>2]=i,n[(e=c+16|0)+4>>2]=0,n[e>>2]=0,!(s&(e=1<<i))){n[6978]=s|e,n[r>>2]=c,n[c+24>>2]=r,n[c+12>>2]=c,n[c+8>>2]=c;break}r=0|n[r>>2];t:do{if((-8&n[r+4>>2])!=(0|l)){for(s=l<<(31==(0|i)?0:25-(i>>>1)|0);e=0|n[(i=r+16+(s>>>31<<2)|0)>>2];){if((-8&n[e+4>>2])==(0|l)){r=e;break t}s<<=1,r=e}n[i>>2]=c,n[c+24>>2]=r,n[c+12>>2]=c,n[c+8>>2]=c;break e}}while(0);_=0|n[(v=r+8|0)>>2],n[_+12>>2]=c,n[v>>2]=c,n[c+8>>2]=_,n[c+12>>2]=r,n[c+24>>2]=0}}while(0);return P=t,0|(_=A+8|0)}d=h}else d=h;else d=-1}while(0);if((i=0|n[6979])>>>0>=d>>>0)return r=i-d|0,e=0|n[6982],r>>>0>15?(_=e+d|0,n[6982]=_,n[6979]=r,n[_+4>>2]=1|r,n[e+i>>2]=r,n[e+4>>2]=3|d):(n[6979]=0,n[6982]=0,n[e+4>>2]=3|i,n[(_=e+i+4|0)>>2]=1|n[_>>2]),P=t,0|(_=e+8|0);if((l=0|n[6980])>>>0>d>>>0)return x=l-d|0,n[6980]=x,v=(_=0|n[6983])+d|0,n[6983]=v,n[v+4>>2]=1|x,n[_+4>>2]=3|d,P=t,0|(_=_+8|0);if(0|n[7095]?e=0|n[7097]:(n[7097]=4096,n[7096]=4096,n[7098]=-1,n[7099]=-1,n[7100]=0,n[7088]=0,n[7095]=-16&p^1431655768,e=4096),A=d+48|0,(h=(o=e+(u=d+47|0)|0)&(a=0-e|0))>>>0<=d>>>0)return P=t,0|(_=0);if(0|(e=0|n[7087])&&(p=(c=0|n[7085])+h|0)>>>0<=c>>>0|p>>>0>e>>>0)return P=t,0|(_=0);e:do{if(4&n[7088])r=0,g=143;else{i=0|n[6983];t:do{if(i){for(s=28356;!((p=0|n[s>>2])>>>0<=i>>>0&&(p+(0|n[s+4>>2])|0)>>>0>i>>>0);){if(!(e=0|n[s+8>>2])){g=128;break t}s=e}if((r=o-l&a)>>>0<2147483647)if((0|(e=0|fr(0|r)))==((0|n[s>>2])+(0|n[s+4>>2])|0)){if(-1!=(0|e)){l=r,o=e,g=145;break e}}else s=e,g=136;else r=0}else g=128}while(0);do{if(128==(0|g))if(-1!=(0|(i=0|fr(0)))&&(r=i,m=(r=((m=(f=0|n[7096])+-1|0)&r|0?(m+r&0-f)-r|0:0)+h|0)+(f=0|n[7085])|0,r>>>0>d>>>0&r>>>0<2147483647)){if(0|(p=0|n[7087])&&m>>>0<=f>>>0|m>>>0>p>>>0){r=0;break}if((0|(e=0|fr(0|r)))==(0|i)){l=r,o=i,g=145;break e}s=e,g=136}else r=0}while(0);do{if(136==(0|g)){if(i=0-r|0,!(A>>>0>r>>>0&r>>>0<2147483647&-1!=(0|s))){if(-1==(0|s)){r=0;break}l=r,o=s,g=145;break e}if((e=u-r+(e=0|n[7097])&0-e)>>>0>=2147483647){l=r,o=s,g=145;break e}if(-1==(0|fr(0|e))){fr(0|i),r=0;break}l=e+r|0,o=s,g=145;break e}}while(0);n[7088]=4|n[7088],g=143}}while(0);if(143==(0|g)&&h>>>0<2147483647&&!(-1==(0|(x=0|fr(0|h)))|1^(b=(y=(m=0|fr(0))-x|0)>>>0>(d+40|0)>>>0)|x>>>0<m>>>0&-1!=(0|x)&-1!=(0|m)^1)&&(l=b?y:r,o=x,g=145),145==(0|g)){r=(0|n[7085])+l|0,n[7085]=r,r>>>0>(0|n[7086])>>>0&&(n[7086]=r),u=0|n[6983];e:do{if(u){for(r=28356;;){if((0|o)==((e=0|n[r>>2])+(i=0|n[r+4>>2])|0)){g=154;break}if(!(s=0|n[r+8>>2]))break;r=s}if(!(154!=(0|g)||(v=r+4|0,8&n[r+12>>2]))&&o>>>0>u>>>0&e>>>0<=u>>>0){n[v>>2]=i+l,v=u+(x=7&(x=u+8|0)?0-x&7:0)|0,x=(_=(0|n[6980])+l|0)-x|0,n[6983]=v,n[6980]=x,n[v+4>>2]=1|x,n[u+_+4>>2]=40,n[6984]=n[7099];break}for(o>>>0<(0|n[6981])>>>0&&(n[6981]=o),i=o+l|0,r=28356;;){if((0|n[r>>2])==(0|i)){g=162;break}if(!(e=0|n[r+8>>2]))break;r=e}if(162==(0|g)&&!(8&n[r+12>>2])){n[r>>2]=o,n[(c=r+4|0)>>2]=(0|n[c>>2])+l,h=(c=o+(7&(c=o+8|0)?0-c&7:0)|0)+d|0,A=(r=i+(7&(r=i+8|0)?0-r&7:0)|0)-c-d|0,n[c+4>>2]=3|d;t:do{if((0|u)==(0|r))_=(0|n[6980])+A|0,n[6980]=_,n[6983]=h,n[h+4>>2]=1|_;else{if((0|n[6982])==(0|r)){_=(0|n[6979])+A|0,n[6979]=_,n[6982]=h,n[h+4>>2]=1|_,n[h+_>>2]=_;break}if(1==(3&(e=0|n[r+4>>2]))){l=-8&e,s=e>>>3;r:do{if(e>>>0<256){if(e=0|n[r+8>>2],(0|(i=0|n[r+12>>2]))==(0|e)){n[6977]=n[6977]&~(1<<s);break}n[e+12>>2]=i,n[i+8>>2]=e;break}o=0|n[r+24>>2],e=0|n[r+12>>2];do{if((0|e)==(0|r)){if(e=0|n[(s=(i=r+16|0)+4|0)>>2])i=s;else if(!(e=0|n[i>>2])){e=0;break}for(;;)if(s=0|n[(a=e+20|0)>>2])e=s,i=a;else{if(!(s=0|n[(a=e+16|0)>>2]))break;e=s,i=a}n[i>>2]=0}else _=0|n[r+8>>2],n[_+12>>2]=e,n[e+8>>2]=_}while(0);if(!o)break;s=28212+((i=0|n[r+28>>2])<<2)|0;do{if((0|n[s>>2])==(0|r)){if(n[s>>2]=e,0|e)break;n[6978]=n[6978]&~(1<<i);break r}if(n[((0|n[(_=o+16|0)>>2])==(0|r)?_:o+20)>>2]=e,!e)break r}while(0);if(n[e+24>>2]=o,0|(s=0|n[(i=r+16|0)>>2])&&(n[e+16>>2]=s,n[s+24>>2]=e),!(i=0|n[i+4>>2]))break;n[e+20>>2]=i,n[i+24>>2]=e}while(0);r=r+l|0,a=l+A|0}else a=A;if(n[(r=r+4|0)>>2]=-2&n[r>>2],n[h+4>>2]=1|a,n[h+a>>2]=a,r=a>>>3,a>>>0<256){i=27948+(r<<1<<2)|0,(e=0|n[6977])&(r=1<<r)?r=0|n[(e=i+8|0)>>2]:(n[6977]=e|r,r=i,e=i+8|0),n[e>>2]=h,n[r+12>>2]=h,n[h+8>>2]=r,n[h+12>>2]=i;break}r=a>>>8;do{if(r){if(a>>>0>16777215){s=31;break}s=a>>>((s=14-((x=((_=r<<(v=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|v|(s=((_<<=x)+245760|0)>>>16&2))+(_<<s>>>15)|0)+7|0)&1|s<<1}else s=0}while(0);if(r=28212+(s<<2)|0,n[h+28>>2]=s,n[(e=h+16|0)+4>>2]=0,n[e>>2]=0,!((e=0|n[6978])&(i=1<<s))){n[6978]=e|i,n[r>>2]=h,n[h+24>>2]=r,n[h+12>>2]=h,n[h+8>>2]=h;break}r=0|n[r>>2];r:do{if((-8&n[r+4>>2])!=(0|a)){for(s=a<<(31==(0|s)?0:25-(s>>>1)|0);e=0|n[(i=r+16+(s>>>31<<2)|0)>>2];){if((-8&n[e+4>>2])==(0|a)){r=e;break r}s<<=1,r=e}n[i>>2]=h,n[h+24>>2]=r,n[h+12>>2]=h,n[h+8>>2]=h;break t}}while(0);_=0|n[(v=r+8|0)>>2],n[_+12>>2]=h,n[v>>2]=h,n[h+8>>2]=_,n[h+12>>2]=r,n[h+24>>2]=0}}while(0);return P=t,0|(_=c+8|0)}for(r=28356;!((e=0|n[r>>2])>>>0<=u>>>0&&(_=e+(0|n[r+4>>2])|0)>>>0>u>>>0);)r=0|n[r+8>>2];r=(e=(e=(a=_+-47|0)+(7&(e=a+8|0)?0-e&7:0)|0)>>>0<(a=u+16|0)>>>0?u:e)+8|0,v=o+(x=7&(x=o+8|0)?0-x&7:0)|0,x=(i=l+-40|0)-x|0,n[6983]=v,n[6980]=x,n[v+4>>2]=1|x,n[o+i+4>>2]=40,n[6984]=n[7099],n[(i=e+4|0)>>2]=27,n[r>>2]=n[7089],n[r+4>>2]=n[7090],n[r+8>>2]=n[7091],n[r+12>>2]=n[7092],n[7089]=o,n[7090]=l,n[7092]=0,n[7091]=r,r=e+24|0;do{v=r,n[(r=r+4|0)>>2]=7}while((v+8|0)>>>0<_>>>0);if((0|e)!=(0|u)){if(o=e-u|0,n[i>>2]=-2&n[i>>2],n[u+4>>2]=1|o,n[e>>2]=o,r=o>>>3,o>>>0<256){i=27948+(r<<1<<2)|0,(e=0|n[6977])&(r=1<<r)?r=0|n[(e=i+8|0)>>2]:(n[6977]=e|r,r=i,e=i+8|0),n[e>>2]=u,n[r+12>>2]=u,n[u+8>>2]=r,n[u+12>>2]=i;break}if(i=28212+((s=(r=o>>>8)?o>>>0>16777215?31:o>>>((s=14-((x=((_=r<<(v=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|v|(s=((_<<=x)+245760|0)>>>16&2))+(_<<s>>>15)|0)+7|0)&1|s<<1:0)<<2)|0,n[u+28>>2]=s,n[u+20>>2]=0,n[a>>2]=0,!((r=0|n[6978])&(e=1<<s))){n[6978]=r|e,n[i>>2]=u,n[u+24>>2]=i,n[u+12>>2]=u,n[u+8>>2]=u;break}r=0|n[i>>2];t:do{if((-8&n[r+4>>2])!=(0|o)){for(s=o<<(31==(0|s)?0:25-(s>>>1)|0);e=0|n[(i=r+16+(s>>>31<<2)|0)>>2];){if((-8&n[e+4>>2])==(0|o)){r=e;break t}s<<=1,r=e}n[i>>2]=u,n[u+24>>2]=r,n[u+12>>2]=u,n[u+8>>2]=u;break e}}while(0);_=0|n[(v=r+8|0)>>2],n[_+12>>2]=u,n[v>>2]=u,n[u+8>>2]=_,n[u+12>>2]=r,n[u+24>>2]=0}}else!(0|(_=0|n[6981]))|o>>>0<_>>>0&&(n[6981]=o),n[7089]=o,n[7090]=l,n[7092]=0,n[6986]=n[7095],n[6985]=-1,n[6990]=27948,n[6989]=27948,n[6992]=27956,n[6991]=27956,n[6994]=27964,n[6993]=27964,n[6996]=27972,n[6995]=27972,n[6998]=27980,n[6997]=27980,n[7e3]=27988,n[6999]=27988,n[7002]=27996,n[7001]=27996,n[7004]=28004,n[7003]=28004,n[7006]=28012,n[7005]=28012,n[7008]=28020,n[7007]=28020,n[7010]=28028,n[7009]=28028,n[7012]=28036,n[7011]=28036,n[7014]=28044,n[7013]=28044,n[7016]=28052,n[7015]=28052,n[7018]=28060,n[7017]=28060,n[7020]=28068,n[7019]=28068,n[7022]=28076,n[7021]=28076,n[7024]=28084,n[7023]=28084,n[7026]=28092,n[7025]=28092,n[7028]=28100,n[7027]=28100,n[7030]=28108,n[7029]=28108,n[7032]=28116,n[7031]=28116,n[7034]=28124,n[7033]=28124,n[7036]=28132,n[7035]=28132,n[7038]=28140,n[7037]=28140,n[7040]=28148,n[7039]=28148,n[7042]=28156,n[7041]=28156,n[7044]=28164,n[7043]=28164,n[7046]=28172,n[7045]=28172,n[7048]=28180,n[7047]=28180,n[7050]=28188,n[7049]=28188,n[7052]=28196,n[7051]=28196,v=o+(x=7&(x=o+8|0)?0-x&7:0)|0,x=(_=l+-40|0)-x|0,n[6983]=v,n[6980]=x,n[v+4>>2]=1|x,n[o+_+4>>2]=40,n[6984]=n[7099]}while(0);if((r=0|n[6980])>>>0>d>>>0)return x=r-d|0,n[6980]=x,v=(_=0|n[6983])+d|0,n[6983]=v,n[v+4>>2]=1|x,n[_+4>>2]=3|d,P=t,0|(_=_+8|0)}return n[(_=27904)>>2]=12,P=t,0|(_=0)}function Xt(e){var t=0,r=0,i=0,s=0,a=0,o=0,l=0,A=0;if(e|=0){r=e+-8|0,s=0|n[6981],A=r+(t=-8&(e=0|n[e+-4>>2]))|0;do{if(1&e)l=r,o=r;else{if(i=0|n[r>>2],!(3&e))return;if(a=i+t|0,(o=r+(0-i)|0)>>>0<s>>>0)return;if((0|n[6982])==(0|o)){if(3&~(t=0|n[(e=A+4|0)>>2])){l=o,t=a;break}return n[6979]=a,n[e>>2]=-2&t,n[o+4>>2]=1|a,void(n[o+a>>2]=a)}if(r=i>>>3,i>>>0<256){if(e=0|n[o+8>>2],(0|(t=0|n[o+12>>2]))==(0|e)){n[6977]=n[6977]&~(1<<r),l=o,t=a;break}n[e+12>>2]=t,n[t+8>>2]=e,l=o,t=a;break}s=0|n[o+24>>2],e=0|n[o+12>>2];do{if((0|e)==(0|o)){if(e=0|n[(r=(t=o+16|0)+4|0)>>2])t=r;else if(!(e=0|n[t>>2])){e=0;break}for(;;)if(r=0|n[(i=e+20|0)>>2])e=r,t=i;else{if(!(r=0|n[(i=e+16|0)>>2]))break;e=r,t=i}n[t>>2]=0}else l=0|n[o+8>>2],n[l+12>>2]=e,n[e+8>>2]=l}while(0);if(s){if(t=0|n[o+28>>2],(0|n[(r=28212+(t<<2)|0)>>2])==(0|o)){if(n[r>>2]=e,!e){n[6978]=n[6978]&~(1<<t),l=o,t=a;break}}else if(n[((0|n[(l=s+16|0)>>2])==(0|o)?l:s+20)>>2]=e,!e){l=o,t=a;break}n[e+24>>2]=s,0|(r=0|n[(t=o+16|0)>>2])&&(n[e+16>>2]=r,n[r+24>>2]=e),(t=0|n[t+4>>2])?(n[e+20>>2]=t,n[t+24>>2]=e,l=o,t=a):(l=o,t=a)}else l=o,t=a}}while(0);if(!(o>>>0>=A>>>0)&&1&(i=0|n[(e=A+4|0)>>2])){if(2&i)n[e>>2]=-2&i,n[l+4>>2]=1|t,n[o+t>>2]=t,s=t;else{if((0|n[6983])==(0|A)){if(A=(0|n[6980])+t|0,n[6980]=A,n[6983]=l,n[l+4>>2]=1|A,(0|l)!=(0|n[6982]))return;return n[6982]=0,void(n[6979]=0)}if((0|n[6982])==(0|A))return A=(0|n[6979])+t|0,n[6979]=A,n[6982]=o,n[l+4>>2]=1|A,void(n[o+A>>2]=A);s=(-8&i)+t|0,r=i>>>3;do{if(i>>>0<256){if(t=0|n[A+8>>2],(0|(e=0|n[A+12>>2]))==(0|t)){n[6977]=n[6977]&~(1<<r);break}n[t+12>>2]=e,n[e+8>>2]=t;break}a=0|n[A+24>>2],e=0|n[A+12>>2];do{if((0|e)==(0|A)){if(e=0|n[(r=(t=A+16|0)+4|0)>>2])t=r;else if(!(e=0|n[t>>2])){r=0;break}for(;;)if(r=0|n[(i=e+20|0)>>2])e=r,t=i;else{if(!(r=0|n[(i=e+16|0)>>2]))break;e=r,t=i}n[t>>2]=0,r=e}else r=0|n[A+8>>2],n[r+12>>2]=e,n[e+8>>2]=r,r=e}while(0);if(0|a){if(e=0|n[A+28>>2],(0|n[(t=28212+(e<<2)|0)>>2])==(0|A)){if(n[t>>2]=r,!r){n[6978]=n[6978]&~(1<<e);break}}else if(n[((0|n[(i=a+16|0)>>2])==(0|A)?i:a+20)>>2]=r,!r)break;n[r+24>>2]=a,0|(t=0|n[(e=A+16|0)>>2])&&(n[r+16>>2]=t,n[t+24>>2]=r),0|(e=0|n[e+4>>2])&&(n[r+20>>2]=e,n[e+24>>2]=r)}}while(0);if(n[l+4>>2]=1|s,n[o+s>>2]=s,(0|l)==(0|n[6982]))return void(n[6979]=s)}if(e=s>>>3,s>>>0<256)return r=27948+(e<<1<<2)|0,(t=0|n[6977])&(e=1<<e)?e=0|n[(t=r+8|0)>>2]:(n[6977]=t|e,e=r,t=r+8|0),n[t>>2]=l,n[e+12>>2]=l,n[l+8>>2]=e,void(n[l+12>>2]=r);e=28212+((i=(e=s>>>8)?s>>>0>16777215?31:s>>>((i=14-((a=((A=e<<(o=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|o|(i=((A<<=a)+245760|0)>>>16&2))+(A<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,n[l+28>>2]=i,n[l+20>>2]=0,n[l+16>>2]=0,t=0|n[6978],r=1<<i;e:do{if(t&r){e=0|n[e>>2];t:do{if((-8&n[e+4>>2])!=(0|s)){for(i=s<<(31==(0|i)?0:25-(i>>>1)|0);t=0|n[(r=e+16+(i>>>31<<2)|0)>>2];){if((-8&n[t+4>>2])==(0|s)){e=t;break t}i<<=1,e=t}n[r>>2]=l,n[l+24>>2]=e,n[l+12>>2]=l,n[l+8>>2]=l;break e}}while(0);A=0|n[(o=e+8|0)>>2],n[A+12>>2]=l,n[o>>2]=l,n[l+8>>2]=A,n[l+12>>2]=e,n[l+24>>2]=0}else n[6978]=t|r,n[e>>2]=l,n[l+24>>2]=e,n[l+12>>2]=l,n[l+8>>2]=l}while(0);if(A=(0|n[6985])-1|0,n[6985]=A,!(0|A)){for(e=28364;e=0|n[e>>2];)e=e+8|0;n[6985]=-1}}}}function Yt(e,t){t|=0;var r=0;return(e|=0)?(r=0|x(t,e),(t|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0)==(0|t)?r:-1)):r=0,(e=0|$t(r))&&3&n[e+-4>>2]?(dr(0|e,0,0|r),0|e):0|e}function Kt(e,t,r,i){return 0|(T((t|=0)+(i|=0)+((r=(e|=0)+(r|=0)>>>0)>>>0<e>>>0|0)>>>0|0),r)}function Zt(e,t,r,i){return 0|(T(0|(i=(t|=0)-(i|=0)-((r|=0)>>>0>(e|=0)>>>0|0)>>>0)),e-r>>>0)}function Jt(e){return 0|((e|=0)?31-(0|w(e^e-1)):32)}function er(e,t,r,i,s){s|=0;var a=0,o=0,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0;if(h=e|=0,o=r|=0,l=d=i|=0,!(u=A=t|=0))return a=!!(0|s),l?a?(n[s>>2]=0|e,n[s+4>>2]=0&t,s=0,0|(T(0|(d=0)),s)):(s=0,0|(T(0|(d=0)),s)):(a&&(n[s>>2]=(h>>>0)%(o>>>0),n[s+4>>2]=0),s=(h>>>0)/(o>>>0)>>>0,0|(T(0|(d=0)),s));a=!(0|l);do{if(o){if(!a){if((a=(0|w(0|l))-(0|w(0|u))|0)>>>0<=31){o=c=a+1|0,e=h>>>(c>>>0)&(t=a-31>>31)|u<<(l=31-a|0),t&=u>>>(c>>>0),a=0,l=h<<l;break}return s?(n[s>>2]=0|e,n[s+4>>2]=A|0&t,s=0,0|(T(0|(d=0)),s)):(s=0,0|(T(0|(d=0)),s))}if((a=o-1|0)&o|0){o=l=33+(0|w(0|o))-(0|w(0|u))|0,e=(c=32-l|0)-1>>31&u>>>((p=l-32|0)>>>0)|(u<<c|h>>>(l>>>0))&(t=p>>31),t&=u>>>(l>>>0),a=h<<(f=64-l|0)&(A=c>>31),l=(u<<f|h>>>(p>>>0))&A|h<<c&l-33>>31;break}return 0|s&&(n[s>>2]=a&h,n[s+4>>2]=0),1==(0|o)?(f=0|e,0|(T(0|(p=A|0&t)),f)):(p=u>>>((f=0|Jt(0|o))>>>0)|0,f=u<<32-f|h>>>(f>>>0),0|(T(0|p),f))}if(a)return 0|s&&(n[s>>2]=(u>>>0)%(o>>>0),n[s+4>>2]=0),f=(u>>>0)/(o>>>0)>>>0,0|(T(0|(p=0)),f);if(!h)return 0|s&&(n[s>>2]=0,n[s+4>>2]=(u>>>0)%(l>>>0)),f=(u>>>0)/(l>>>0)>>>0,0|(T(0|(p=0)),f);if(!((a=l-1|0)&l))return 0|s&&(n[s>>2]=0|e,n[s+4>>2]=a&u|0&t),p=0,f=u>>>((0|Jt(0|l))>>>0),0|(T(0|p),f);if((a=(0|w(0|l))-(0|w(0|u))|0)>>>0<=30){o=t=a+1|0,e=u<<(l=31-a|0)|h>>>(t>>>0),t=u>>>(t>>>0),a=0,l=h<<l;break}return s?(n[s>>2]=0|e,n[s+4>>2]=A|0&t,f=0,0|(T(0|(p=0)),f)):(f=0,0|(T(0|(p=0)),f))}while(0);if(o){u=0|Kt(0|(c=0|r),0|(h=d|0&i),-1,-1),r=0|M(),A=l,l=0;do{i=A,A=a>>>31|A<<1,a=l|a<<1,Zt(0|u,0|r,0|(i=e<<1|i>>>31),0|(d=e>>>31|t<<1)),l=1&(p=(f=0|M())>>31|((0|f)<0?-1:0)<<1),e=0|Zt(0|i,0|d,p&c|0,(((0|f)<0?-1:0)>>31|((0|f)<0?-1:0)<<1)&h),t=0|M(),o=o-1|0}while(0|o);u=A,A=0}else u=l,A=0,l=0;return o=0,0|s&&(n[s>>2]=e,n[s+4>>2]=t),f=a<<1&-2|l,0|(T(0|(p=(0|a)>>>31|(u|o)<<1|A)),f)}function tr(e,t,r,i){r|=0;var n,s,a,o,l;return s=(i|=0)>>31|((0|i)<0?-1:0)<<1,n=((0|i)<0?-1:0)>>31|((0|i)<0?-1:0)<<1,a=0|Zt((l=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(o=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|l,0|o),e=s^l,t=n^o,0|Zt((0|er(a,0|M(),0|Zt(s^r|0,n^i|0,0|s,0|n),0|M(),0))^e,(0|M())^t,0|e,0|t)}function rr(e,t,r,i){t|=0,i|=0;var n,s;return r=0|function(e,t){var r,i,n,s=0;return e=((r=0|x(s=65535&(t|=0),n=65535&(e|=0)))>>>16)+(0|x(s,i=e>>>16))|0,t=0|x(s=t>>>16,n),0|(T((e>>>16)+(0|x(s,i))+(((65535&e)+t|0)>>>16)|0),e+t<<16|65535&r)}(n=e|=0,s=r|=0),e=0|M(),0|(T((0|x(t,s))+(0|x(i,n))+e|0&e),r)}function ir(e,t,r,i){r|=0;var s,a,o,l,A,u;return s=P,P=P+16|0,l=0|s,u=(i|=0)>>31|((0|i)<0?-1:0)<<1,A=((0|i)<0?-1:0)>>31|((0|i)<0?-1:0)<<1,er(e=0|Zt((o=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(a=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|o,0|a),t=0|M(),0|Zt(u^r|0,A^i|0,0|u,0|A),0|M(),l),i=0|Zt(n[l>>2]^o|0,n[l+4>>2]^a|0,0|o,0|a),r=0|M(),P=s,0|(T(0|r),i)}function nr(e,t,r,i){var s,a;return a=P,P=P+16|0,er(e|=0,t|=0,r|=0,i|=0,s=0|a),P=a,0|(T(0|n[s+4>>2]),n[s>>2])}function sr(e,t,r){return e|=0,t|=0,(0|(r|=0))<32?(T(t>>r|0),e>>>r|(t&(1<<r)-1)<<32-r):(T(0|((0|t)<0?-1:0)),t>>r-32)}function ar(e,t,r){return e|=0,t|=0,(0|(r|=0))<32?(T(t>>>r|0),e>>>r|(t&(1<<r)-1)<<32-r):(T(0),t>>>r-32|0)}function or(e,t,r){return e|=0,t|=0,(0|(r|=0))<32?(T(t<<r|(e&(1<<r)-1<<32-r)>>>32-r),e<<r):(T(e<<r-32),0)}function lr(e,t,r){return e|=0,32==(0|(t=0|w(t|=0)))&&(t=t+(0|w(e))|0),T(0),0|t}function Ar(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+_(+e,+t)}function ur(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+v(+e,+t)}function hr(e){return(e=+e)>=0?+l(e+.5):+b(e-.5)}function cr(e,t,r){e|=0,t|=0;var s,a,o=0;if((0|(r|=0))>=8192)return C(0|e,0|t,0|r),0|e;if(a=0|e,s=e+r|0,(3&e)==(3&t)){for(;3&e;){if(!r)return 0|a;i[e|0]=0|i[t|0],e=e+1|0,t=t+1|0,r=r-1|0}for(o=(r=-4&s)-64|0;(0|e)<=(0|o);)n[e>>2]=n[t>>2],n[e+4>>2]=n[t+4>>2],n[e+8>>2]=n[t+8>>2],n[e+12>>2]=n[t+12>>2],n[e+16>>2]=n[t+16>>2],n[e+20>>2]=n[t+20>>2],n[e+24>>2]=n[t+24>>2],n[e+28>>2]=n[t+28>>2],n[e+32>>2]=n[t+32>>2],n[e+36>>2]=n[t+36>>2],n[e+40>>2]=n[t+40>>2],n[e+44>>2]=n[t+44>>2],n[e+48>>2]=n[t+48>>2],n[e+52>>2]=n[t+52>>2],n[e+56>>2]=n[t+56>>2],n[e+60>>2]=n[t+60>>2],e=e+64|0,t=t+64|0;for(;(0|e)<(0|r);)n[e>>2]=n[t>>2],e=e+4|0,t=t+4|0}else for(r=s-4|0;(0|e)<(0|r);)i[e|0]=0|i[t|0],i[e+1|0]=0|i[t+1|0],i[e+2|0]=0|i[t+2|0],i[e+3|0]=0|i[t+3|0],e=e+4|0,t=t+4|0;for(;(0|e)<(0|s);)i[e|0]=0|i[t|0],e=e+1|0,t=t+1|0;return 0|a}function dr(e,t,r){t|=0;var s,a=0,o=0,l=0;if(s=(e|=0)+(r|=0)|0,t&=255,(0|r)>=67){for(;3&e;)i[e|0]=t,e=e+1|0;for(l=t|t<<8|t<<16|t<<24,o=(a=-4&s)-64|0;(0|e)<=(0|o);)n[e>>2]=l,n[e+4>>2]=l,n[e+8>>2]=l,n[e+12>>2]=l,n[e+16>>2]=l,n[e+20>>2]=l,n[e+24>>2]=l,n[e+28>>2]=l,n[e+32>>2]=l,n[e+36>>2]=l,n[e+40>>2]=l,n[e+44>>2]=l,n[e+48>>2]=l,n[e+52>>2]=l,n[e+56>>2]=l,n[e+60>>2]=l,e=e+64|0;for(;(0|e)<(0|a);)n[e>>2]=l,e=e+4|0}for(;(0|e)<(0|s);)i[e|0]=t,e=e+1|0;return s-r|0}function pr(e){return(e=+e)>=0?+l(e+.5):+b(e-.5)}function fr(e){e|=0;var t,r,i;return i=0|N(),(0|e)>0&(0|(t=(r=0|n[o>>2])+e|0))<(0|r)|(0|t)<0?(B(0|t),E(12),-1):(0|t)>(0|i)&&!(0|R(0|t))?(E(12),-1):(n[o>>2]=t,0|r)}return{___divdi3:tr,___muldi3:rr,___remdi3:ir,___uremdi3:nr,_areNeighborCells:function(e,t,r,i,s){s|=0;var a,o,l,A=0,u=0,h=0,c=0;if(l=P,P=P+64|0,o=l,a=l+56|0,!(!0&134217728==(2013265920&(t|=0))&!0&134217728==(2013265920&(i|=0))))return P=l,0|(s=5);if((0|(e|=0))==(0|(r|=0))&(0|t)==(0|i))return n[s>>2]=0,P=l,0|(s=0);if(u=0|ar(0|e,0|t,52),M(),u&=15,c=0|ar(0|r,0|i,52),M(),(0|u)!=(15&c))return P=l,0|(s=12);if(A=u+-1|0,u>>>0>1){Ue(e,t,A,o),Ue(r,i,A,a),h=0|n[(c=o)>>2],c=0|n[c+4>>2];e:do{if((0|h)==(0|n[a>>2])&&(0|c)==(0|n[a+4>>2])){A=0|ar(0|e,0|t,0|(u=3*(15^u)|0)),M(),A&=7,u=0|ar(0|r,0|i,0|u),M(),u&=7;do{if(!(0|A)|!(0|u))n[s>>2]=1,A=0;else if(7==(0|A))A=5;else{if(1==(0|A)|1==(0|u)&&0|Ge(h,c)){A=5;break}if((0|n[15536+(A<<2)>>2])!=(0|u)&&(0|n[15568+(A<<2)>>2])!=(0|u))break e;n[s>>2]=1,A=0}}while(0);return P=l,0|(s=A)}}while(0)}u=(A=o)+56|0;do{n[A>>2]=0,A=A+4|0}while((0|A)<(0|u));return q(e,t,1,o),A=(0|n[(t=o)>>2])==(0|r)&&(0|n[t+4>>2])==(0|i)||(0|n[(t=o+8|0)>>2])==(0|r)&&(0|n[t+4>>2])==(0|i)||(0|n[(t=o+16|0)>>2])==(0|r)&&(0|n[t+4>>2])==(0|i)||(0|n[(t=o+24|0)>>2])==(0|r)&&(0|n[t+4>>2])==(0|i)||(0|n[(t=o+32|0)>>2])==(0|r)&&(0|n[t+4>>2])==(0|i)||(0|n[(t=o+40|0)>>2])==(0|r)&&(0|n[t+4>>2])==(0|i)?1:1&((0|n[(A=o+48|0)>>2])==(0|r)?(0|n[A+4>>2])==(0|i):0),n[s>>2]=A,P=l,0|(s=0)},_bitshift64Ashr:sr,_bitshift64Lshr:ar,_bitshift64Shl:or,_calloc:Yt,_cellAreaKm2:function(e,t,r){return 0|(e=0|pt(e|=0,t|=0,r|=0))||(s[r>>3]=6371.007180918475*+s[r>>3]*6371.007180918475),0|e},_cellAreaM2:function(e,t,r){return 0|(e=0|pt(e|=0,t|=0,r|=0))||(s[r>>3]=6371.007180918475*+s[r>>3]*6371.007180918475*1e3*1e3),0|e},_cellAreaRads2:pt,_cellToBoundary:rt,_cellToCenterChild:He,_cellToChildPos:function(e,t,r,i){r|=0,i|=0;var s,a=0,o=0,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0;if(s=P,P=P+16|0,y=s,b=0|ar(0|(e|=0),0|(t|=0),52),M(),b&=15,r>>>0>15)return P=s,0|(b=4);if((0|b)<(0|r))return P=s,0|(b=12);if((0|b)!=(0|r))if(o=0|or(0|r,0,52),o|=e,A=M()|-15728641&t,(0|b)>(0|r)){u=r;do{g=0|or(7,0,3*(14-u|0)|0),u=u+1|0,o|=g,A=0|M()|A}while((0|u)<(0|b));g=o}else g=o;else g=e,A=t;m=0|ar(0|g,0|A,45),M();e:do{if(0|V(127&m)){if(u=0|ar(0|g,0|A,52),M(),0|(u&=15))for(o=1;;){if(!(!((m=0|or(7,0,3*(15-o|0)|0))&g|0)&!((0|M())&A))){h=33;break e}if(!(o>>>0<u>>>0))break;o=o+1|0}if(n[(m=i)>>2]=0,n[m+4>>2]=0,(0|b)>(0|r)){for(m=-15728641&t,f=b;;){if(p=f,(f=f+-1|0)>>>0>15|(0|b)<(0|f)){h=19;break}if((0|b)!=(0|f))if(o=0|or(0|f,0,52),o|=e,u=0|M()|m,(0|b)<(0|p))d=o;else{h=f;do{d=0|or(7,0,3*(14-h|0)|0),h=h+1|0,o|=d,u=0|M()|u}while((0|h)<(0|b));d=o}else d=e,u=t;if(c=0|ar(0|d,0|u,45),M(),0|V(127&c)){c=0|ar(0|d,0|u,52),M(),c&=15;t:do{if(c)for(h=1;;){if(o=0|ar(0|d,0|u,3*(15-h|0)|0),M(),0|(o&=7))break t;if(!(h>>>0<c>>>0)){o=0;break}h=h+1|0}else o=0}while(0);o=1&!(0|o)}else o=0;if(u=0|ar(0|e,0|t,3*(15-p|0)|0),M(),7==(0|(u&=7))){a=5,h=42;break}if(1==(0|u)&(o=!!(0|o))){a=5,h=42;break}if(0|(d=u+((!!(0|u)&o)<<31>>31)|0)&&(h=0|_t(7,0,h=b-p|0,((0|h)<0)<<31>>31),c=0|M(),o?(o=0|Kt(0|(o=0|rr(0|h,0|c,5,0)),0|M(),-5,-1),o=0|Kt(0|(o=0|tr(0|o,0|M(),6,0)),0|M(),1,0),u=0|M()):(o=h,u=c),p=0|Kt(0|o,0|u,0|(p=0|rr(0|h,0|c,0|(p=d+-1|0),((0|p)<0)<<31>>31)),0|M()),c=0|Kt(0|p,0|(d=0|M()),0|n[(c=i)>>2],0|n[c+4>>2]),d=0|M(),n[(p=i)>>2]=c,n[p+4>>2]=d),(0|f)<=(0|r)){h=37;break}}if(19==(0|h))S(27795,27122,1276,27158);else{if(37==(0|h)){a=0|n[(l=i)+4>>2],l=0|n[l>>2];break}if(42==(0|h))return P=s,0|a}}else a=0,l=0}else h=33}while(0);e:do{if(33==(0|h)){if(n[(m=i)>>2]=0,n[m+4>>2]=0,(0|b)>(0|r)){for(o=b;;){if(a=0|ar(0|e,0|t,3*(15-o|0)|0),M(),7==(0|(a&=7))){a=5;break}if(a=0|rr(0|(l=0|_t(7,0,l=b-o|0,((0|l)<0)<<31>>31)),0|M(),0|a,0),l=0|M(),l=0|Kt(0|n[(m=i)>>2],0|n[m+4>>2],0|a,0|l),a=0|M(),n[(m=i)>>2]=l,n[m+4>>2]=a,(0|(o=o+-1|0))<=(0|r))break e}return P=s,0|a}a=0,l=0}}while(0);return 0|ze(g,A,b,y)&&S(27795,27122,1236,27173),((0|a)>-1|-1==(0|a)&l>>>0>4294967295)&((0|(y=0|n[(b=y)+4>>2]))>(0|a)|((0|y)==(0|a)?(0|n[b>>2])>>>0>l>>>0:0))?(P=s,0|(b=0)):(S(27795,27122,1316,27158),0)},_cellToChildren:function(e,t,r,i){i|=0;var s,a,o=0,l=0;if(a=P,P=P+16|0,nt(s=a,e|=0,t|=0,r|=0),!(0|(e=0|n[(t=s)>>2]))&!(0|(t=0|n[t+4>>2])))return P=a,0;o=0,r=0;do{n[(l=i+(o<<3)|0)>>2]=e,n[l+4>>2]=t,o=0|Kt(0|o,0|r,1,0),r=0|M(),at(s),e=0|n[(l=s)>>2],t=0|n[l+4>>2]}while(!(!(0|e)&!(0|t)));return P=a,0},_cellToChildrenSize:ze,_cellToLatLng:tt,_cellToLocalIj:function(e,t,r,i,n,s){var a,o;return e|=0,t|=0,r|=0,i|=0,s|=0,o=P,P=P+16|0,a=o,(n|=0)?e=15:(e=0|xt(e,t,r,i,a))||(Te(a,s),e=0),P=o,0|e},_cellToParent:Ue,_cellToVertex:kt,_cellToVertexes:function(e,t,r){r|=0;var i,s=0,a=0;return a=!(0|Ge(e|=0,t|=0)),i=!(0|(s=0|kt(e,t,0,r))),a?i?0|(s=0|kt(e,t,1,r+8|0))||0|(s=0|kt(e,t,2,r+16|0))||0|(s=0|kt(e,t,3,r+24|0))||(s=0|kt(e,t,4,r+32|0))?0|(a=s):0|kt(e,t,5,r+40|0):0|(a=s):i?0|(s=0|kt(e,t,1,r+8|0))||0|(s=0|kt(e,t,2,r+16|0))||0|(s=0|kt(e,t,3,r+24|0))||0|(s=0|kt(e,t,4,r+32|0))?0|(a=s):(n[(a=r+40|0)>>2]=0,n[a+4>>2]=0,0|(a=0)):0|(a=s)},_cellsToDirectedEdge:function(e,t,r,i,s){return s|=0,7==(0|(r=0|L(e|=0,t|=0,r|=0,i|=0)))?0|(s=11):(i=0|or(0|r,0,56),t=-2130706433&t|M()|268435456,n[s>>2]=e|i,n[s+4>>2]=t,0|(s=0))},_cellsToLinkedMultiPolygon:function(e,t,r){r|=0;var i,s,a,o=0;if(a=P,P=P+32|0,i=a,e=0|function(e,t,r){e|=0,r|=0;var i,s,a=0,o=0,l=0,A=0,u=0,h=0;if(s=P,P=P+176|0,i=s,(0|(t|=0))<1)return Vt(r,0,0),P=s,0;for(u=0|ar(0|n[(u=e)>>2],0|n[u+4>>2],52),M(),Vt(r,(0|t)>6?t:6,15&u),u=0;!(0|(a=0|rt(0|n[(a=e+(u<<3)|0)>>2],0|n[a+4>>2],i)));){if((0|(a=0|n[i>>2]))>0){A=0;do{l=i+8+(A<<4)|0,(o=0|Ht(r,a=i+8+((0|(A=A+1|0))%(0|a)<<4)|0,l))?Gt(r,o):jt(r,l,a),a=0|n[i>>2]}while((0|A)<(0|a))}if((0|(u=u+1|0))>=(0|t)){a=0,h=13;break}}return 13==(0|h)?(P=s,0|a):(Ut(r),P=s,0|(h=a))}(e|=0,t|=0,s=a+16|0),0|e)return P=a,0|(r=e);if(n[r>>2]=0,n[r+4>>2]=0,n[r+8>>2]=0,0|(e=0|zt(s)))do{t=0|ft(r);do{mt(t,e),o=e+16|0,n[i>>2]=n[o>>2],n[i+4>>2]=n[o+4>>2],n[i+8>>2]=n[o+8>>2],n[i+12>>2]=n[o+12>>2],Gt(s,e),e=0|Wt(s,i)}while(0|e);e=0|zt(s)}while(0|e);return Ut(s),(e=0|yt(r))?(gt(r),P=a,0|(o=e)):(P=a,0|(o=0))},_childPosToCell:function(e,t,r,i,s,a){e|=0,t|=0,a|=0;var o,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0;if(o=P,P=P+16|0,l=o,(s|=0)>>>0>15)return P=o,0|(a=4);if(A=0|ar(0|(r|=0),0|(i|=0),52),M(),(0|(A&=15))>(0|s))return P=o,0|(a=12);if(0|ze(r,i,s,l)&&S(27795,27122,1236,27173),!(((0|t)>-1|-1==(0|t)&e>>>0>4294967295)&((0|(h=0|n[(c=l)+4>>2]))>(0|t)|((0|h)==(0|t)?(0|n[c>>2])>>>0>e>>>0:0))))return P=o,0|(a=2);c=s-A|0,s=0|or(0|s,0,52),u=M()|-15728641&i,n[(h=a)>>2]=s|r,n[h+4>>2]=u,h=0|ar(0|r,0|i,45),M();e:do{if(0|V(127&h)){if(0|A)for(l=1;;){if(!(!((h=0|or(7,0,3*(15-l|0)|0))&r|0)&!((0|M())&i)))break e;if(!(l>>>0<A>>>0))break;l=l+1|0}if((0|c)<1)return P=o,0|(a=0);for(h=15^A,i=-1,u=1,l=1;;){A=0|_t(7,0,A=c-u|0,((0|A)<0)<<31>>31),r=0|M();do{if(l){if(l=0|tr(0|(l=0|Kt(0|(l=0|rr(0|A,0|r,5,0)),0|M(),-5,-1)),0|M(),6,0),(0|t)>(0|(s=0|M()))|(0|t)==(0|s)&e>>>0>l>>>0){t=0|Zt(0|(t=0|Kt(0|e,0|t,-1,-1)),0|M(),0|l,0|s),l=0|M(),f=0|n[(d=a)>>2],d=0|n[d+4>>2],p=0|or(7,0,0|(m=3*(h+i|0)|0)),d&=~M(),m=0|or(0|(s=0|Kt(0|(i=0|tr(0|t,0|l,0|A,0|r)),0|(e=0|M()),2,0)),0|M(),0|m),d=0|M()|d,n[(s=a)>>2]=m|f&~p,n[s+4>>2]=d,e=0|Zt(0|t,0|l,0|(e=0|rr(0|i,0|e,0|A,0|r)),0|M()),l=0,t=0|M();break}p=0|n[(m=a)>>2],m=0|n[m+4>>2],f=0|or(7,0,3*(h+i|0)|0),m&=~M(),n[(l=a)>>2]=p&~f,n[l+4>>2]=m,l=1;break}s=0|n[(p=a)>>2],p=0|n[p+4>>2],d=0|or(7,0,0|(i=3*(h+i|0)|0)),p&=~M(),i=0|or(0|(m=0|tr(0|e,0|t,0|A,0|r)),0|(l=0|M()),0|i),p=0|M()|p,n[(f=a)>>2]=i|s&~d,n[f+4>>2]=p,e=0|Zt(0|e,0|t,0|(l=0|rr(0|m,0|l,0|A,0|r)),0|M()),l=0,t=0|M()}while(0);if(!((0|c)>(0|u))){t=0;break}i=~u,u=u+1|0}return P=o,0|t}}while(0);if((0|c)<1)return P=o,0|(m=0);for(s=15^A,l=1;;){if(f=0|_t(7,0,f=c-l|0,((0|f)<0)<<31>>31),m=0|M(),r=0|n[(u=a)>>2],u=0|n[u+4>>2],i=0|or(7,0,0|(A=3*(s-l|0)|0)),u&=~M(),A=0|or(0|(d=0|tr(0|e,0|t,0|f,0|m)),0|(p=0|M()),0|A),u=0|M()|u,n[(h=a)>>2]=A|r&~i,n[h+4>>2]=u,e=0|Zt(0|e,0|t,0|(m=0|rr(0|d,0|p,0|f,0|m)),0|M()),t=0|M(),(0|c)<=(0|l)){t=0;break}l=l+1|0}return P=o,0|t},_compactCells:function(e,t,r,i){t|=0;var s,a=0,o=0,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0,w=0,T=0,E=0,N=0,C=0,R=0,B=0,P=0;if(!(0|(r|=0))&!(0|(i|=0)))return 0|(P=0);if(o=0|n[(a=e|=0)>>2],!0&!(15728640&(a=0|n[a+4>>2]))){if(!((0|i)>0|!(0|i)&r>>>0>0))return 0|(P=0);if(n[(P=t)>>2]=o,n[P+4>>2]=a,1==(0|r)&!(0|i))return 0|(P=0);a=1,o=0;do{B=0|n[(R=e+(a<<3)|0)+4>>2],n[(P=t+(a<<3)|0)>>2]=n[R>>2],n[P+4>>2]=B,a=0|Kt(0|a,0|o,1,0),o=0|M()}while((0|o)<(0|i)|(0|o)==(0|i)&a>>>0<r>>>0);return 0|(a=0)}if(!(B=0|$t(s=r<<3)))return 0|(P=13);if(cr(0|B,0|e,0|s),!(R=0|Yt(r,8)))return Xt(B),0|(P=13);e:for(;;){N=0|ar(0|(h=0|n[(a=B)>>2]),0|(a=0|n[a+4>>2]),52),M(),C=(N&=15)+-1|0,E=!!(0|N),T=(0|i)>0|!(0|i)&r>>>0>0;t:do{if(E&T){if(x=0|or(0|C,0,52),v=0|M(),C>>>0>15){if(!(!(0|h)&!(0|a))){P=16;break e}for(o=0,e=0;;){if(o=0|Kt(0|o,0|e,1,0),!((0|(e=0|M()))<(0|i)|(0|e)==(0|i)&o>>>0<r>>>0))break t;if(!(!(0|(w=0|n[(l=B+(o<<3)|0)>>2]))&!(0|(l=0|n[l+4>>2])))){a=l,P=16;break e}}}for(A=h,e=a,o=0,l=0;;){if(!(!(0|A)&!(0|e))){if(!(!0&!(117440512&e))){P=21;break e}if(c=0|ar(0|A,0|e,52),M(),(0|(c&=15))<(0|C)){a=12,P=27;break e}if((0|c)!=(0|C)&&(A|=x,e=-15728641&e|v,c>>>0>=N>>>0)){u=C;do{w=0|or(7,0,3*(14-u|0)|0),u=u+1|0,A|=w,e=0|M()|e}while(u>>>0<c>>>0)}if(p=0|nr(0|A,0|e,0|r,0|i),f=0|M(),!(!(0|(d=0|n[(c=u=R+(p<<3)|0)>>2]))&!(0|(c=0|n[c+4>>2])))){y=0,b=0;do{if((0|y)>(0|i)|(0|y)==(0|i)&b>>>0>r>>>0){P=31;break e}if((0|d)==(0|A)&(-117440513&c)==(0|e)){m=0|ar(0|d,0|c,56),M(),g=(m&=7)+1|0,w=0|ar(0|d,0|c,45),M();r:do{if(0|V(127&w)){if(d=0|ar(0|d,0|c,52),M(),!(d&=15)){c=6;break}for(c=1;;){if(!(!((w=0|or(7,0,3*(15-c|0)|0))&A|0)&!((0|M())&e))){c=7;break r}if(!(c>>>0<d>>>0)){c=6;break}c=c+1|0}}else c=7}while(0);if((m+2|0)>>>0>c>>>0){P=41;break e}w=0|or(0|g,0,56),e=M()|-117440513&e,n[(_=u)>>2]=0,n[_+4>>2]=0,A|=w}else p=0|ir(0|(p=0|Kt(0|p,0|f,1,0)),0|M(),0|r,0|i),f=0|M();b=0|Kt(0|b,0|y,1,0),y=0|M(),d=0|n[(c=u=R+(p<<3)|0)>>2],c=0|n[c+4>>2]}while(!(!(0|d)&!(0|c)))}n[(w=u)>>2]=A,n[w+4>>2]=e}if(o=0|Kt(0|o,0|l,1,0),!((0|(l=0|M()))<(0|i)|(0|l)==(0|i)&o>>>0<r>>>0))break t;A=0|n[(e=B+(o<<3)|0)>>2],e=0|n[e+4>>2]}}}while(0);if(w=0|Kt(0|r,0|i,5,0),(_=0|M())>>>0<0|!(0|_)&w>>>0<11){P=85;break}if(w=0|tr(0|r,0|i,6,0),M(),!(w=0|Yt(w,8))){P=48;break}do{if(T){for(g=0,e=0,m=0,y=0;;){if(!(0|(o=0|n[(l=c=R+(g<<3)|0)>>2]))&!(0|(l=0|n[l+4>>2])))_=m;else{d=0|ar(0|o,0|l,56),M(),A=(d&=7)+1|0,p=-117440513&l,_=0|ar(0|o,0|l,45),M();t:do{if(0|V(127&_)){if(f=0|ar(0|o,0|l,52),M(),0|(f&=15))for(u=1;;){if(!(!(o&(_=0|or(7,0,3*(15-u|0)|0))|0)&!(p&(0|M()))))break t;if(!(u>>>0<f>>>0))break;u=u+1|0}o|=l=0|or(0|A,0,56),l=0|M()|p,n[(A=c)>>2]=o,n[A+4>>2]=l,A=d+2|0}}while(0);7==(0|A)?(n[(_=w+(e<<3)|0)>>2]=o,n[_+4>>2]=-117440513&l,e=0|Kt(0|e,0|m,1,0),_=0|M()):_=m}if(g=0|Kt(0|g,0|y,1,0),!((0|(y=0|M()))<(0|i)|(0|y)==(0|i)&g>>>0<r>>>0))break;m=_}if(T){if(b=C>>>0>15,x=0|or(0|C,0,52),v=0|M(),!E){for(o=0,u=0,A=0,l=0;!(0|h)&!(0|a)||(n[(C=t+(o<<3)|0)>>2]=h,n[C+4>>2]=a,o=0|Kt(0|o,0|u,1,0),u=0|M()),A=0|Kt(0|A,0|l,1,0),(0|(l=0|M()))<(0|i)|(0|l)==(0|i)&A>>>0<r>>>0;)h=0|n[(a=B+(A<<3)|0)>>2],a=0|n[a+4>>2];a=_;break}for(o=0,u=0,l=0,A=0;;){do{if(!(!(0|h)&!(0|a))){if(f=0|ar(0|h,0|a,52),M(),b|(0|(f&=15))<(0|C)){P=80;break e}if((0|f)!=(0|C)){if(c=h|x,d=-15728641&a|v,f>>>0>=N>>>0){p=C;do{E=0|or(7,0,3*(14-p|0)|0),p=p+1|0,c|=E,d=0|M()|d}while(p>>>0<f>>>0)}}else c=h,d=a;m=0|nr(0|c,0|d,0|r,0|i),p=0,f=0,y=0|M();do{if((0|p)>(0|i)|(0|p)==(0|i)&f>>>0>r>>>0){P=81;break e}if((-117440513&(g=0|n[(E=R+(m<<3)|0)+4>>2]))==(0|d)&&(0|n[E>>2])==(0|c)){P=65;break}m=0|ir(0|(E=0|Kt(0|m,0|y,1,0)),0|M(),0|r,0|i),y=0|M(),f=0|Kt(0|f,0|p,1,0),p=0|M(),E=R+(m<<3)|0}while((0|n[E>>2])!=(0|c)||(0|n[E+4>>2])!=(0|d));if(65==(0|P)&&(P=0,!0&100663296==(117440512&g)))break;n[(E=t+(o<<3)|0)>>2]=h,n[E+4>>2]=a,o=0|Kt(0|o,0|u,1,0),u=0|M()}}while(0);if(l=0|Kt(0|l,0|A,1,0),!((0|(A=0|M()))<(0|i)|(0|A)==(0|i)&l>>>0<r>>>0))break;h=0|n[(a=B+(l<<3)|0)>>2],a=0|n[a+4>>2]}a=_}else o=0,a=_}else o=0,e=0,a=0}while(0);if(dr(0|R,0,0|s),cr(0|B,0|w,e<<3),Xt(w),!(0|e)&!(0|a)){P=89;break}t=t+(o<<3)|0,i=a,r=e}if(16==(0|P))!0&!(117440512&a)?(a=4,P=27):P=21;else if(31==(0|P))S(27795,27122,529,27132);else{if(41==(0|P))return Xt(B),Xt(R),0|(P=10);if(48==(0|P))return Xt(B),Xt(R),0|(P=13);80==(0|P)?S(27795,27122,620,27132):81==(0|P)?S(27795,27122,632,27132):85==(0|P)&&(cr(0|t,0|B,r<<3),P=89)}return 21==(0|P)?(Xt(B),Xt(R),0|(P=5)):27==(0|P)?(Xt(B),Xt(R),0|(P=a)):89==(0|P)?(Xt(B),Xt(R),0|(P=0)):0},_destroyLinkedMultiPolygon:gt,_directedEdgeToBoundary:Ne,_directedEdgeToCells:function(e,t,r){e|=0;var i,s,a,o=0;return i=P,P=P+16|0,o=i,!0&268435456==(2013265920&(t|=0))?(s=-2130706433&t|134217728,n[(a=r|=0)>>2]=e,n[a+4>>2]=s,n[o>>2]=0,t=0|ar(0|e,0|t,56),M(),o=0|O(e,s,7&t,o,r+8|0),P=i,0|o):(P=i,0|(o=6))},_edgeLengthKm:function(e,t,r){r|=0;var i,a=0,o=0,l=0,A=0,h=0,p=0,f=0;if(i=P,P=P+176|0,0|(e=0|Ne(e|=0,t|=0,A=i)))return A=e,l=+s[r>>3],l*=6371.007180918475,s[r>>3]=l,P=i,0|A;if(s[r>>3]=0,(0|(e=0|n[A>>2]))<=1)return A=0,l=0,l*=6371.007180918475,s[r>>3]=l,P=i,0|A;t=e+-1|0,e=0,a=+s[A+8>>3],o=+s[A+16>>3],l=0;do{p=a,a=+s[A+8+((e=e+1|0)<<4)>>3],f=+d(.5*(a-p)),h=o,o=+s[A+8+(e<<4)+8>>3],h=f*f+(h=+d(.5*(o-h)))*(+c(+p)*+c(+a)*h),l+=2*+y(+ +u(+h),+ +u(+(1-h)))}while((0|e)!=(0|t));return s[r>>3]=l,A=0,f=l,f*=6371.007180918475,s[r>>3]=f,P=i,0|A},_edgeLengthM:function(e,t,r){r|=0;var i,a=0,o=0,l=0,A=0,h=0,p=0,f=0;if(i=P,P=P+176|0,0|(e=0|Ne(e|=0,t|=0,A=i)))return A=e,l=+s[r>>3],l*=6371.007180918475,l*=1e3,s[r>>3]=l,P=i,0|A;if(s[r>>3]=0,(0|(e=0|n[A>>2]))<=1)return A=0,l=0,l*=6371.007180918475,l*=1e3,s[r>>3]=l,P=i,0|A;t=e+-1|0,e=0,a=+s[A+8>>3],o=+s[A+16>>3],l=0;do{p=a,a=+s[A+8+((e=e+1|0)<<4)>>3],f=+d(.5*(a-p)),h=o,o=+s[A+8+(e<<4)+8>>3],h=f*f+(h=+d(.5*(o-h)))*(+c(+p)*+c(+a)*h),l+=2*+y(+ +u(+h),+ +u(+(1-h)))}while((0|e)!=(0|t));return s[r>>3]=l,A=0,f=l,f*=6371.007180918475,f*=1e3,s[r>>3]=f,P=i,0|A},_edgeLengthRads:function(e,t,r){r|=0;var i,a=0,o=0,l=0,A=0,h=0,p=0,f=0;if(i=P,P=P+176|0,0|(e=0|Ne(e|=0,t|=0,A=i)))return P=i,0|(A=e);if(s[r>>3]=0,(0|(e=0|n[A>>2]))<=1)return P=i,0|(A=0);t=e+-1|0,e=0,a=+s[A+8>>3],o=+s[A+16>>3],l=0;do{p=a,a=+s[A+8+((e=e+1|0)<<4)>>3],f=+d(.5*(a-p)),h=o,o=+s[A+8+(e<<4)+8>>3],h=f*f+(h=+d(.5*(o-h)))*(+c(+a)*+c(+p)*h),l+=2*+y(+ +u(+h),+ +u(+(1-h)))}while((0|e)<(0|t));return s[r>>3]=l,P=i,0|(A=0)},_emscripten_replace_memory:function(e){return i=new Int8Array(e),n=new Int32Array(e),s=new Float64Array(e),r=e,!0},_free:Xt,_getBaseCellNumber:Le,_getDirectedEdgeDestination:function(e,t,r){e|=0,t|=0,r|=0;var i,s,a=0;return i=P,P=P+16|0,n[(a=i)>>2]=0,!0&268435456==(2013265920&t)?(s=0|ar(0|e,0|t,56),M(),a=0|O(e,-2130706433&t|134217728,7&s,a,r),P=i,0|a):(P=i,0|(a=6))},_getDirectedEdgeOrigin:function(e,t,r){return e|=0,r|=0,!0&268435456==(2013265920&(t|=0))?(n[r>>2]=e,n[r+4>>2]=-2130706433&t|134217728,0|(r=0)):0|(r=6)},_getHexagonAreaAvgKm2:ht,_getHexagonAreaAvgM2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20784+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgKm:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20912+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgM:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[21040+(e<<3)>>3],0|(t=0))},_getIcosahedronFaces:function e(t,r,i){i|=0;var s,a=0,o=0,l=0,A=0,u=0,h=0,c=0,d=0;s=P,P=P+128|0,c=s+112|0,l=s+96|0,d=s,o=0|ar(0|(t|=0),0|(r|=0),52),M(),u=15&o,n[c>>2]=u,A=0|ar(0|t,0|r,45),M(),A&=127;e:do{if(0|V(A)){if(0|u)for(a=1;;){if(!(!((h=0|or(7,0,3*(15-a|0)|0))&t|0)&!((0|M())&r))){o=0;break e}if(!(a>>>0<u>>>0))break;a=a+1|0}if(!(1&o))return h=0|or(u+1|0,0,52),d=M()|-15728641&r,d=0|e((h|t)&~(c=0|or(7,0,3*(14-u|0)|0)),d&~M(),i),P=s,0|d;o=1}else o=0}while(0);if(!(a=0|et(t,r,l))){o?(qe(l,c,d),h=5):(Oe(l,c,d),h=6);e:do{if(0|V(A))if(u)for(a=1;;){if(!(!((A=0|or(7,0,3*(15-a|0)|0))&t|0)&!((0|M())&r))){t=2;break e}if(!(a>>>0<u>>>0)){t=5;break}a=a+1|0}else t=5;else t=2}while(0);dr(0|i,-1,t<<2);e:do{if(o)for(l=0;;){if(Ie(A=d+(l<<4)|0,0|n[c>>2]),A=0|n[A>>2],-1==(0|(u=0|n[i>>2]))|(0|u)==(0|A))a=i;else{o=0;do{if((o=o+1|0)>>>0>=t>>>0){a=1;break e}u=0|n[(a=i+(o<<2)|0)>>2]}while(!(-1==(0|u)|(0|u)==(0|A)))}if(n[a>>2]=A,(l=l+1|0)>>>0>=h>>>0){a=0;break}}else for(l=0;;){if(De(A=d+(l<<4)|0,0|n[c>>2],0,1),A=0|n[A>>2],-1==(0|(u=0|n[i>>2]))|(0|u)==(0|A))a=i;else{o=0;do{if((o=o+1|0)>>>0>=t>>>0){a=1;break e}u=0|n[(a=i+(o<<2)|0)>>2]}while(!(-1==(0|u)|(0|u)==(0|A)))}if(n[a>>2]=A,(l=l+1|0)>>>0>=h>>>0){a=0;break}}}while(0)}return P=s,0|(d=a)},_getNumCells:ct,_getPentagons:it,_getRes0Cells:function(e){e|=0;var t=0,r=0,i=0;t=0;do{or(0|t,0,45),i=134225919|M(),n[(r=e+(t<<3)|0)>>2]=-1,n[r+4>>2]=i,t=t+1|0}while(122!=(0|t));return 0},_getResolution:function(e,t){return t=0|ar(0|(e|=0),0|(t|=0),52),M(),15&t},_greatCircleDistanceKm:ut,_greatCircleDistanceM:function(e,t){e|=0;var r,i,n,a=0;return i=+s[(t|=0)>>3],r=+s[e>>3],a=(n=+d(.5*(i-r)))*n+(a=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+c(+i)*+c(+r)*a),2*+y(+ +u(+a),+ +u(+(1-a)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(e,t){e|=0;var r,i,n,a=0;return i=+s[(t|=0)>>3],r=+s[e>>3],a=(n=+d(.5*(i-r)))*n+(a=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+c(+i)*+c(+r)*a),2*+y(+ +u(+a),+ +u(+(1-a)))},_gridDisk:q,_gridDiskDistances:D,_gridDistance:function(e,t,r,i,s){r|=0,i|=0,s|=0;var a,o,l=0,A=0;return o=P,P=P+32|0,A=o,0|(a=0|xt(e|=0,t|=0,e,t,l=o+12|0))?(P=o,0|(A=a)):0|(e=0|xt(e,t,r,i,A))?(P=o,0|(A=e)):(l=0|we(l,A),n[(A=s)>>2]=l,n[A+4>>2]=((0|l)<0)<<31>>31,P=o,0|(A=0))},_gridPathCells:function(e,t,r,i,s){r|=0,i|=0,s|=0;var a,o,l=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0,w=0,T=0,E=0,N=0;if(o=P,P=P+48|0,u=o+12|0,E=o,!(l=0|xt(e|=0,t|=0,e,t,a=o+24|0))&&!(l=0|xt(e,t,r,i,u))){T=((0|(w=0|we(a,u)))<0)<<31>>31,n[a>>2]=0,n[a+4>>2]=0,n[a+8>>2]=0,n[u>>2]=0,n[u+4>>2]=0,n[u+8>>2]=0,0|xt(e,t,e,t,a)&&S(27795,27538,692,27747),0|xt(e,t,r,i,u)&&S(27795,27538,697,27747),Se(a),Se(u),p=0|w?1/+(0|w):0,r=0|n[a>>2],b=p*+((0|n[u>>2])-r|0),i=0|n[(x=a+4|0)>>2],v=p*+((0|n[u+4>>2])-i|0),l=0|n[(_=a+8|0)>>2],p*=+((0|n[u+8>>2])-l|0),n[E>>2]=r,n[(f=E+4|0)>>2]=i,n[(m=E+8|0)>>2]=l;e:do{if((0|w)<0)l=0;else for(g=0,y=0;;){N=b*(c=+(y>>>0)+4294967296*+(0|g))+ +(0|r),h=v*c+ +(0|i),c=p*c+ +(0|l),r=~~+hr(+N),u=~~+hr(+h),l=~~+hr(+c),N=+A(+(+(0|r)-N)),h=+A(+(+(0|u)-h)),c=+A(+(+(0|l)-c));do{if(!(N>h&N>c)){if(d=0-r|0,h>c){i=d-l|0;break}i=u,l=d-u|0;break}r=0-(u+l)|0,i=u}while(0);if(n[E>>2]=r,n[f>>2]=i,n[m>>2]=l,Ee(E),0|(l=0|vt(e,t,E,s+(y<<3)|0)))break e;if(!((0|g)<(0|T)|(0|g)==(0|T)&y>>>0<w>>>0)){l=0;break e}r=0|Kt(0|y,0|g,1,0),g=i=0|M(),y=r,r=0|n[a>>2],i=0|n[x>>2],l=0|n[_>>2]}}while(0);return P=o,0|(E=l)}return P=o,0|(E=l)},_gridPathCellsSize:function(e,t,r,i,s){r|=0,i|=0,s|=0;var a,o=0,l=0,A=0;return a=P,P=P+32|0,A=a,(o=0|xt(e|=0,t|=0,e,t,l=a+12|0))||(o=0|xt(e,t,r,i,A))?(P=a,0|(A=o)):(i=0|Kt(0|(i=0|we(l,A)),((0|i)<0)<<31>>31,1,0),l=0|M(),n[(A=s)>>2]=i,n[A+4>>2]=l,P=a,0|(A=0))},_gridRingUnsafe:function(e,t,r,i){e|=0,t|=0,r|=0,i|=0;var s,a,o=0,l=0,A=0,u=0,h=0,c=0,d=0,p=0,f=0;if(a=P,P=P+16|0,f=a+8|0,n[(p=s=a)>>2]=e,n[p+4>>2]=t,!r)return n[(f=i)>>2]=e,n[f+4>>2]=t,P=a,0|(f=0);n[f>>2]=0;e:do{if(0|Ge(e,t))e=9;else{if(l=(0|r)>0){o=0,p=e;do{if(0|(e=0|O(p,t,4,f,s)))break e;if(o=o+1|0,0|Ge(p=0|n[(t=s)>>2],t=0|n[t+4>>2])){e=9;break e}}while((0|o)<(0|r));if(n[(d=i)>>2]=p,n[d+4>>2]=t,d=r+-1|0,l){c=0,e=1;do{if(o=26800+(c<<2)|0,5==(0|c))for(A=0|n[o>>2],l=0,o=e;;){if(0|(e=0|O(0|n[(e=s)>>2],0|n[e+4>>2],A,f,s)))break e;if((0|l)!=(0|d)){if(u=0|n[(h=s)>>2],h=0|n[h+4>>2],n[(e=i+(o<<3)|0)>>2]=u,n[e+4>>2]=h,0|Ge(u,h)){e=9;break e}e=o+1|0}else e=o;if((0|(l=l+1|0))>=(0|r))break;o=e}else for(A=s,h=0|n[o>>2],u=0,o=e,l=0|n[A>>2],A=0|n[A+4>>2];;){if(0|(e=0|O(l,A,h,f,s)))break e;if(l=0|n[(A=s)>>2],A=0|n[A+4>>2],n[(e=i+(o<<3)|0)>>2]=l,n[e+4>>2]=A,e=o+1|0,0|Ge(l,A)){e=9;break e}if((0|(u=u+1|0))>=(0|r))break;o=e}c=c+1|0}while(c>>>0<6);A=p,o=0|n[(e=s)>>2],l=t,e=0|n[e+4>>2]}else A=p,o=p,l=t,e=t}else n[(A=i)>>2]=e,n[A+4>>2]=t,A=e,o=e,l=t,e=t;e=(0|A)==(0|o)&(0|l)==(0|e)?0:9}}while(0);return P=a,0|(f=e)},_i64Add:Kt,_i64Subtract:Zt,_isPentagon:Ge,_isResClassIII:function(e,t){return t=0|ar(0|(e|=0),0|(t|=0),52),M(),1&t},_isValidCell:ke,_isValidDirectedEdge:function(e,t){var r=0;switch(r=0|ar(0|(e|=0),0|(t|=0),56),M(),7&r){case 0:case 7:return 0|(r=0)}return r=-2130706433&t|134217728,!0&268435456==(2013265920&t)?!0&16777216==(117440512&t)&!!(0|Ge(e,r))?0|(r=0):0|(r=0|ke(e,r)):0|(r=0)},_isValidVertex:function(e,t){e|=0;var r,i,s=0,a=0;return i=P,P=P+16|0,r=i,!0&536870912==(2013265920&(t|=0))&&0|ke(e,s=-2130706433&t|134217728)?(a=0|ar(0|e,0|t,56),M(),s=(a=!(0|kt(e,s,7&a,r)))&((0|n[(s=r)>>2])==(0|e)?(0|n[s+4>>2])==(0|t):0)&1,P=i,0|s):(P=i,0|(s=0))},_latLngToCell:Ze,_llvm_ctlz_i64:lr,_llvm_maxnum_f64:Ar,_llvm_minnum_f64:ur,_llvm_round_f64:hr,_localIjToCell:function(e,t,r,i,n){var s,a;return e|=0,t|=0,r|=0,n|=0,a=P,P=P+16|0,s=a,(i|=0)?r=15:(r=0|Me(r,s))||(r=0|vt(e,t,s,n)),P=a,0|r},_malloc:$t,_maxFaceCount:function(e,t,r){r|=0;var i=0,s=0;if(s=0|ar(0|(e|=0),0|(t|=0),45),M(),!(0|V(127&s)))return s=2,n[r>>2]=s,0;if(s=0|ar(0|e,0|t,52),M(),!(s&=15))return s=5,n[r>>2]=s,0;for(i=1;;){if(!(!((0|or(7,0,3*(15-i|0)|0))&e|0)&!((0|M())&t))){i=2,e=6;break}if(!(i>>>0<s>>>0)){i=5,e=6;break}i=i+1|0}return 6==(0|e)?(n[r>>2]=i,0):0},_maxGridDiskSize:function(e,t){t|=0;var r=0,i=0,s=0;return(0|(e|=0))<0?0|(t=2):(0|e)>13780509?0|(t=0|ct(15,t)):(s=0|rr(0|e,0|(r=((0|e)<0)<<31>>31),3,0),i=0|M(),r=0|Kt(0|e,0|r,1,0),r=0|Kt(0|(r=0|rr(0|s,0|i,0|r,0|M())),0|M(),1,0),e=0|M(),n[t>>2]=r,n[t+4>>2]=e,0|(t=0))},_maxPolygonToCellsSize:function(e,t,r,i){e|=0,t|=0,i|=0;var s,a=0,o=0,l=0,A=0,u=0;if(s=P,P=P+48|0,a=s+16|0,o=s+8|0,l=s,0|(r=0|Ct(r|=0)))return P=s,0|(l=r);if(A=0|n[(u=e)+4>>2],n[(r=o)>>2]=n[u>>2],n[r+4>>2]=A,Nt(o,a),!(r=0|ee(a,t,l))){if(t=0|n[o>>2],(0|(o=0|n[e+8>>2]))>0){a=0|n[e+12>>2],r=0;do{t=(0|n[a+(r<<3)>>2])+t|0,r=r+1|0}while((0|r)<(0|o))}a=0|n[(r=l)>>2],(0|(r=0|n[r+4>>2]))<(0|(o=((0|t)<0)<<31>>31))|(0|r)==(0|o)&a>>>0<t>>>0?(n[(r=l)>>2]=t,n[r+4>>2]=o,r=o):t=a,A=0|Kt(0|t,0|r,12,0),u=0|M(),n[(r=l)>>2]=A,n[r+4>>2]=u,n[(r=i)>>2]=A,n[r+4>>2]=u,r=0}return P=s,0|(u=r)},_maxPolygonToCellsSizeExperimental:function(e,t,r,a){t|=0,r|=0,a|=0;var o,l,u=0,h=0,d=0,p=0,f=0,m=0,g=0,y=0;if(l=P,P=P+48|0,f=l+32|0,p=l+40|0,o=l,!(0|n[(e|=0)>>2]))return n[(m=a)>>2]=0,n[m+4>>2]=0,P=l,0|(m=0);Ve(f,0,0,0),u=0|n[(d=f)>>2],d=0|n[d+4>>2];do{if(t>>>0>15)n[(m=o)>>2]=0,n[m+4>>2]=0,n[o+8>>2]=4,n[o+12>>2]=-1,r=o+29|0,n[(m=o+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,i[m+12|0]=0,i[r|0]=0|i[p|0],i[r+1|0]=0|i[p+1|0],i[r+2|0]=0|i[p+2|0],r=4,m=9;else{if(0|(r=0|Ct(r))){n[(f=o)>>2]=0,n[f+4>>2]=0,n[o+8>>2]=r,n[o+12>>2]=-1,m=o+29|0,n[(f=o+16|0)>>2]=0,n[f+4>>2]=0,n[f+8>>2]=0,i[f+12|0]=0,i[m|0]=0|i[p|0],i[m+1|0]=0|i[p+1|0],i[m+2|0]=0|i[p+2|0],m=9;break}if(!(r=0|Yt(1+(0|n[e+8>>2])|0,32))){n[(m=o)>>2]=0,n[m+4>>2]=0,n[o+8>>2]=13,n[o+12>>2]=-1,r=o+29|0,n[(m=o+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,i[m+12|0]=0,i[r|0]=0|i[p|0],i[r+1|0]=0|i[p+1|0],i[r+2|0]=0|i[p+2|0],r=13,m=9;break}Rt(e,r),n[(y=o)>>2]=u,n[y+4>>2]=d,n[(d=o+8|0)>>2]=0,n[o+12>>2]=t,n[o+20>>2]=e,n[o+24>>2]=r,i[o+28|0]=0,i[(u=o+29|0)|0]=0|i[p|0],i[u+1|0]=0|i[p+1|0],i[u+2|0]=0|i[p+2|0],n[o+16>>2]=3,g=+X(r),g*=+Q(r),h=+A(+ +s[r>>3]),h=g/+c(+ +ur(+h,+ +A(+ +s[r+8>>3])))*6371.007180918475*6371.007180918475,r=0|n[(u=o+12|0)>>2];e:do{if((0|r)>0)do{if(ht(r+-1|0,f),!(h/+s[f>>3]>10))break e;r=(y=0|n[u>>2])+-1|0,n[u>>2]=r}while((0|y)>1)}while(0);if(Mt(o),n[(u=a)>>2]=0,n[u+4>>2]=0,!(!(0|(r=0|n[(u=o)>>2]))&!(0|(u=0|n[u+4>>2]))))do{ze(r,u,t,f),p=f,p=0|Kt(0|n[(e=a)>>2],0|n[e+4>>2],0|n[p>>2],0|n[p+4>>2]),e=0|M(),n[(y=a)>>2]=p,n[y+4>>2]=e,Mt(o),r=0|n[(y=o)>>2],u=0|n[y+4>>2]}while(!(!(0|r)&!(0|u)));r=0|n[d>>2]}}while(0);return P=l,0|(y=r)},_memcpy:cr,_memset:dr,_originToDirectedEdges:function(e,t,r){r|=0;var i,s=0;return i=!(0|Ge(e|=0,t|=0)),t&=-2130706433,n[(s=r)>>2]=i?e:0,n[s+4>>2]=i?285212672|t:0,n[(s=r+8|0)>>2]=e,n[s+4>>2]=301989888|t,n[(s=r+16|0)>>2]=e,n[s+4>>2]=318767104|t,n[(s=r+24|0)>>2]=e,n[s+4>>2]=335544320|t,n[(s=r+32|0)>>2]=e,n[s+4>>2]=352321536|t,n[(r=r+40|0)>>2]=e,n[r+4>>2]=369098752|t,0},_pentagonCount:function(){return 12},_polygonToCells:function(e,t,r,i){e|=0,t|=0,i|=0;var s,a,o,l,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0,y=0,b=0,x=0,v=0,_=0,w=0,T=0,S=0,E=0,N=0,C=0,R=0,B=0,q=0,D=0,O=0,L=0,V=0;if(l=P,P=P+112|0,s=l+80|0,d=l+72|0,a=l,o=l+56|0,0|(A=0|Ct(r|=0)))return P=l,0|(V=A);if(!(V=0|$t(32+(n[(p=e+8|0)>>2]<<5)|0)))return P=l,0|(V=13);if(Rt(e,V),!(A=0|Ct(r))){if(L=0|n[(O=e)+4>>2],n[(A=d)>>2]=n[O>>2],n[A+4>>2]=L,Nt(d,s),A=0|ee(s,t,a))O=0,L=0;else{if(A=0|n[d>>2],(0|(u=0|n[p>>2]))>0){h=0|n[e+12>>2],r=0;do{A=(0|n[h+(r<<3)>>2])+A|0,r=r+1|0}while((0|r)!=(0|u));r=A}else r=A;u=0|n[(A=a)>>2],(0|(A=0|n[A+4>>2]))<(0|(h=((0|r)<0)<<31>>31))|(0|A)==(0|h)&u>>>0<r>>>0?(n[(A=a)>>2]=r,n[A+4>>2]=h,A=h):r=u,O=0|Kt(0|r,0|A,12,0),L=0|M(),n[(A=a)>>2]=O,n[A+4>>2]=L,A=0}if(!A){if(!(r=0|Yt(O,8)))return Xt(V),P=l,0|(V=13);if(!(c=0|Yt(O,8)))return Xt(V),Xt(r),P=l,0|(V=13);n[(q=s)>>2]=0,n[q+4>>2]=0,D=0|n[(q=e)+4>>2],n[(A=d)>>2]=n[q>>2],n[A+4>>2]=D,A=0|k(d,O,L,t,s,r,c);e:do{if(A)Xt(r),Xt(c),Xt(V);else{t:do{if((0|n[p>>2])>0){for(h=e+12|0,u=0;A=0|k((0|n[h>>2])+(u<<3)|0,O,L,t,s,r,c),u=u+1|0,!(0|A);)if((0|u)>=(0|n[p>>2]))break t;Xt(r),Xt(c),Xt(V);break e}}while(0);(0|L)>0|!(0|L)&O>>>0>0&&dr(0|c,0,O<<3),q=0|n[(D=s)+4>>2];t:do{if((0|q)>0|!(0|q)&(0|n[D>>2])>>>0>0){C=r,R=c,B=r,q=c,D=r,A=r,S=r,E=c,N=c,r=c;r:for(;;){for(v=0,_=0,w=0,T=0,u=0,h=0;;){d=(c=a)+56|0;do{n[c>>2]=0,c=c+4|0}while((0|c)<(0|d));if(0|I(p=0|n[(t=C+(v<<3)|0)>>2],t=0|n[t+4>>2],1,a,0)){d=(c=a)+56|0;do{n[c>>2]=0,c=c+4|0}while((0|c)<(0|d));0|(c=0|Yt(7,4))&&(F(p,t,1,a,c,7,0,0),Xt(c))}for(x=0;;){y=0|n[(b=a+(x<<3)|0)>>2],b=0|n[b+4>>2];i:do{if(!(0|y)&!(0|b))c=u,d=h;else{if(f=0|nr(0|y,0|b,0|O,0|L),p=0|M(),!(!(0|(d=0|n[(t=c=i+(f<<3)|0)>>2]))&!(0|(t=0|n[t+4>>2])))){m=0,g=0;do{if((0|m)>(0|L)|(0|m)==(0|L)&g>>>0>O>>>0)break r;if((0|d)==(0|y)&(0|t)==(0|b)){c=u,d=h;break i}f=0|ir(0|(c=0|Kt(0|f,0|p,1,0)),0|M(),0|O,0|L),p=0|M(),g=0|Kt(0|g,0|m,1,0),m=0|M(),d=0|n[(t=c=i+(f<<3)|0)>>2],t=0|n[t+4>>2]}while(!(!(0|d)&!(0|t)))}if(!(0|y)&!(0|b)){c=u,d=h;break}tt(y,b,o),0|Bt(e,V,o)&&(g=0|Kt(0|u,0|h,1,0),h=0|M(),n[(m=c)>>2]=y,n[m+4>>2]=b,n[(u=R+(u<<3)|0)>>2]=y,n[u+4>>2]=b,u=g),c=u,d=h}}while(0);if((x=x+1|0)>>>0>=7)break;u=c,h=d}if(v=0|Kt(0|v,0|_,1,0),_=0|M(),w=0|Kt(0|w,0|T,1,0),T=0|M(),u=0|n[(h=s)>>2],!((0|T)<(0|(h=0|n[h+4>>2]))|(0|T)==(0|h)&w>>>0<u>>>0))break;u=c,h=d}if((0|h)>0|!(0|h)&u>>>0>0){u=0,h=0;do{n[(T=C+(u<<3)|0)>>2]=0,n[T+4>>2]=0,u=0|Kt(0|u,0|h,1,0),h=0|M(),w=0|n[(T=s)+4>>2]}while((0|h)<(0|w)|((0|h)==(0|w)?u>>>0<(0|n[T>>2])>>>0:0))}if(n[(T=s)>>2]=c,n[T+4>>2]=d,!((0|d)>0|!(0|d)&c>>>0>0))break t;x=r,v=N,_=D,w=E,T=R,r=S,N=A,E=B,S=x,A=v,D=q,q=_,B=w,R=C,C=T}Xt(B),Xt(q),Xt(V),A=1;break e}A=c}while(0);Xt(V),Xt(r),Xt(A),A=0}}while(0);return P=l,0|(V=A)}}return Xt(V),P=l,0|(V=A)},_polygonToCellsExperimental:function(e,t,r,i,s,a){i|=0,s|=0,a|=0;var o,l,A,u=0,h=0,c=0,d=0,p=0,f=0,m=0,g=0;A=P,P=P+160|0,h=A+64|0,p=A+112|0,g=A,Tt(d=A+80|0,e|=0,t|=0,r|=0),nt(h,0|n[(c=d)>>2],0|n[c+4>>2],t),o=0|n[(c=h)>>2],c=0|n[c+4>>2],u=0|n[d+8>>2],n[(f=p+4|0)>>2]=n[d>>2],n[f+4>>2]=n[d+4>>2],n[f+8>>2]=n[d+8>>2],n[f+12>>2]=n[d+12>>2],n[f+16>>2]=n[d+16>>2],n[f+20>>2]=n[d+20>>2],n[f+24>>2]=n[d+24>>2],n[f+28>>2]=n[d+28>>2],n[(f=g)>>2]=o,n[f+4>>2]=c,n[(f=g+8|0)>>2]=u,t=p,r=(e=g+12|0)+36|0;do{n[e>>2]=n[t>>2],e=e+4|0,t=t+4|0}while((0|e)<(0|r));if(n[(p=g+48|0)>>2]=n[h>>2],n[p+4>>2]=n[h+4>>2],n[p+8>>2]=n[h+8>>2],n[p+12>>2]=n[h+12>>2],!(0|o)&!(0|c))return P=A,0|(g=u);r=g+16|0,l=g+24|0,d=g+28|0,u=0,h=0,t=o,e=c;do{if(!((0|u)<(0|s)|(0|u)==(0|s)&h>>>0<i>>>0)){m=4;break}if(c=h,h=0|Kt(0|h,0|u,1,0),u=0|M(),n[(c=a+(c<<3)|0)>>2]=t,n[c+4>>2]=e,at(p),!(0|(t=0|n[(e=p)>>2]))&!(0|(e=0|n[e+4>>2]))){if(Mt(r),!(0|(e=0|n[(t=r)>>2]))&!(0|(t=0|n[t+4>>2]))){m=10;break}st(e,t,0|n[d>>2],p),t=0|n[(e=p)>>2],e=0|n[e+4>>2]}n[(c=g)>>2]=t,n[c+4>>2]=e}while(!(!(0|t)&!(0|e)));return 4==(0|m)?(0|(t=0|n[(e=g+40|0)>>2])&&Xt(t),n[(m=g+16|0)>>2]=0,n[m+4>>2]=0,n[l>>2]=0,n[g+36>>2]=0,n[d>>2]=-1,n[g+32>>2]=0,n[e>>2]=0,st(0,0,0,p),n[g>>2]=0,n[g+4>>2]=0,n[f>>2]=0,P=A,0|(g=14)):(10==(0|m)&&(n[g>>2]=0,n[g+4>>2]=0,n[f>>2]=n[l>>2]),g=0|n[f>>2],P=A,0|g)},_readInt64AsDoubleFromPointer:function(e){return+(+((0|n[(e|=0)>>2])>>>0)+4294967296*+(0|n[e+4>>2]))},_res0CellCount:function(){return 122},_round:pr,_sbrk:fr,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(e,t,r,i,s,a,o){e|=0,i|=0,s|=0,a|=0;var l,A=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0;if(l=P,P=P+16|0,m=l,!((0|(r|=0))>0|!(0|r)&(t|=0)>>>0>0))return P=l,0|(m=0);if((0|(o|=0))>=16)return P=l,0|(m=12);p=0,f=0,d=0,A=0;e:for(;;){if(c=0|ar(0|(u=0|n[(h=e+(p<<3)|0)>>2]),0|(h=0|n[h+4>>2]),52),M(),(15&c)>(0|o)){A=12,u=11;break}if(nt(m,u,h,o),!(0|(h=0|n[(c=m)>>2]))&!(0|(c=0|n[c+4>>2])))u=d;else{u=d;do{if(!((0|A)<(0|a)|(0|A)==(0|a)&u>>>0<s>>>0)){u=10;break e}n[(d=i+(u<<3)|0)>>2]=h,n[d+4>>2]=c,u=0|Kt(0|u,0|A,1,0),A=0|M(),at(m),h=0|n[(d=m)>>2],c=0|n[d+4>>2]}while(!(!(0|h)&!(0|c)))}if(p=0|Kt(0|p,0|f,1,0),!((0|(f=0|M()))<(0|r)|(0|f)==(0|r)&p>>>0<t>>>0)){A=0,u=11;break}d=u}return 10==(0|u)?(P=l,0|(m=14)):11==(0|u)?(P=l,0|A):0},_uncompactCellsSize:function(e,t,r,i,s){e|=0,t|=0,r|=0,i|=0,s|=0;var a,o,l=0,A=0,u=0,h=0,c=0,d=0;o=P,P=P+16|0,a=o;e:do{if((0|r)>0|!(0|r)&t>>>0>0){for(c=0,A=0,l=0,d=0;;){if(!(!(0|(u=0|n[(h=e+(c<<3)|0)>>2]))&!(0|(h=0|n[h+4>>2]))||(h=!(0|ze(u,h,i,a)),A=0|Kt(0|n[(u=a)>>2],0|n[u+4>>2],0|A,0|l),l=0|M(),h))){l=12;break}if(c=0|Kt(0|c,0|d,1,0),!((0|(d=0|M()))<(0|r)|(0|d)==(0|r)&c>>>0<t>>>0))break e}return P=o,0|l}A=0,l=0}while(0);return n[s>>2]=A,n[s+4>>2]=l,P=o,0|(s=0)},_vertexToLatLng:function(e,t,r){r|=0;var i,s,a,o,l=0,A=0;return o=P,P=P+192|0,s=o,a=o+168|0,l=0|ar(0|(e|=0),0|(t|=0),56),M(),l&=7,0|(i=0|et(e,A=-2130706433&t|134217728,a))?(P=o,0|(A=i)):(t=0|ar(0|e,0|t,52),M(),t&=15,0|Ge(e,A)?Pe(a,t,l,1,s):Fe(a,t,l,1,s),A=s+8|0,n[r>>2]=n[A>>2],n[r+4>>2]=n[A+4>>2],n[r+8>>2]=n[A+8>>2],n[r+12>>2]=n[A+12>>2],P=o,0|(A=0))},establishStackSpace:function(e,t){P=e|=0},stackAlloc:function(e){var t;return t=P,P=(P=P+(e|=0)|0)+15&-16,0|t},stackRestore:function(e){P=e|=0},stackSave:function(){return 0|P}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{b:function(e){g=e},c:function(){return g},d:function(e,t,r,i){fe("Assertion failed: "+R(e)+", at: "+[t?R(t):"unknown filename",r,i?R(i):"unknown function"])},e:function(e){return r.___errno_location&&(S[r.___errno_location()>>2]=e),e},f:Z,g:function(e,t,r){T.set(T.subarray(t,t+r),e)},h:function(e){var t=Z(),r=16777216,i=2130706432;if(e>i)return!1;for(var n=Math.max(t,16777216);n<e;)n=n<=536870912?B(2*n,r):Math.min(B((3*n+2147483648)/4,r),i);return!!function(e){try{var t=new ArrayBuffer(e);if(t.byteLength!=e)return;return new Int8Array(t).set(w),ie(t),P(t),1}catch(e){}}(n)},i:function(e){fe("OOM")},o:28624,p:28608},_);r.___divdi3=re.___divdi3,r.___muldi3=re.___muldi3,r.___remdi3=re.___remdi3,r.___uremdi3=re.___uremdi3,r._areNeighborCells=re._areNeighborCells,r._bitshift64Ashr=re._bitshift64Ashr,r._bitshift64Lshr=re._bitshift64Lshr,r._bitshift64Shl=re._bitshift64Shl,r._calloc=re._calloc,r._cellAreaKm2=re._cellAreaKm2,r._cellAreaM2=re._cellAreaM2,r._cellAreaRads2=re._cellAreaRads2,r._cellToBoundary=re._cellToBoundary,r._cellToCenterChild=re._cellToCenterChild,r._cellToChildPos=re._cellToChildPos,r._cellToChildren=re._cellToChildren,r._cellToChildrenSize=re._cellToChildrenSize,r._cellToLatLng=re._cellToLatLng,r._cellToLocalIj=re._cellToLocalIj,r._cellToParent=re._cellToParent,r._cellToVertex=re._cellToVertex,r._cellToVertexes=re._cellToVertexes,r._cellsToDirectedEdge=re._cellsToDirectedEdge,r._cellsToLinkedMultiPolygon=re._cellsToLinkedMultiPolygon,r._childPosToCell=re._childPosToCell,r._compactCells=re._compactCells,r._destroyLinkedMultiPolygon=re._destroyLinkedMultiPolygon,r._directedEdgeToBoundary=re._directedEdgeToBoundary,r._directedEdgeToCells=re._directedEdgeToCells,r._edgeLengthKm=re._edgeLengthKm,r._edgeLengthM=re._edgeLengthM,r._edgeLengthRads=re._edgeLengthRads;var ie=r._emscripten_replace_memory=re._emscripten_replace_memory;r._free=re._free,r._getBaseCellNumber=re._getBaseCellNumber,r._getDirectedEdgeDestination=re._getDirectedEdgeDestination,r._getDirectedEdgeOrigin=re._getDirectedEdgeOrigin,r._getHexagonAreaAvgKm2=re._getHexagonAreaAvgKm2,r._getHexagonAreaAvgM2=re._getHexagonAreaAvgM2,r._getHexagonEdgeLengthAvgKm=re._getHexagonEdgeLengthAvgKm,r._getHexagonEdgeLengthAvgM=re._getHexagonEdgeLengthAvgM,r._getIcosahedronFaces=re._getIcosahedronFaces,r._getNumCells=re._getNumCells,r._getPentagons=re._getPentagons,r._getRes0Cells=re._getRes0Cells,r._getResolution=re._getResolution,r._greatCircleDistanceKm=re._greatCircleDistanceKm,r._greatCircleDistanceM=re._greatCircleDistanceM,r._greatCircleDistanceRads=re._greatCircleDistanceRads,r._gridDisk=re._gridDisk,r._gridDiskDistances=re._gridDiskDistances,r._gridDistance=re._gridDistance,r._gridPathCells=re._gridPathCells,r._gridPathCellsSize=re._gridPathCellsSize,r._gridRingUnsafe=re._gridRingUnsafe,r._i64Add=re._i64Add,r._i64Subtract=re._i64Subtract,r._isPentagon=re._isPentagon,r._isResClassIII=re._isResClassIII,r._isValidCell=re._isValidCell,r._isValidDirectedEdge=re._isValidDirectedEdge,r._isValidVertex=re._isValidVertex,r._latLngToCell=re._latLngToCell,r._llvm_ctlz_i64=re._llvm_ctlz_i64,r._llvm_maxnum_f64=re._llvm_maxnum_f64,r._llvm_minnum_f64=re._llvm_minnum_f64,r._llvm_round_f64=re._llvm_round_f64,r._localIjToCell=re._localIjToCell,r._malloc=re._malloc,r._maxFaceCount=re._maxFaceCount,r._maxGridDiskSize=re._maxGridDiskSize,r._maxPolygonToCellsSize=re._maxPolygonToCellsSize,r._maxPolygonToCellsSizeExperimental=re._maxPolygonToCellsSizeExperimental,r._memcpy=re._memcpy,r._memset=re._memset,r._originToDirectedEdges=re._originToDirectedEdges,r._pentagonCount=re._pentagonCount,r._polygonToCells=re._polygonToCells,r._polygonToCellsExperimental=re._polygonToCellsExperimental,r._readInt64AsDoubleFromPointer=re._readInt64AsDoubleFromPointer,r._res0CellCount=re._res0CellCount,r._round=re._round,r._sbrk=re._sbrk,r._sizeOfCellBoundary=re._sizeOfCellBoundary,r._sizeOfCoordIJ=re._sizeOfCoordIJ,r._sizeOfGeoLoop=re._sizeOfGeoLoop,r._sizeOfGeoPolygon=re._sizeOfGeoPolygon,r._sizeOfH3Index=re._sizeOfH3Index,r._sizeOfLatLng=re._sizeOfLatLng,r._sizeOfLinkedGeoPolygon=re._sizeOfLinkedGeoPolygon,r._uncompactCells=re._uncompactCells,r._uncompactCellsSize=re._uncompactCellsSize,r._vertexToLatLng=re._vertexToLatLng,r.establishStackSpace=re.establishStackSpace;var ne,se,ae=r.stackAlloc=re.stackAlloc,oe=r.stackRestore=re.stackRestore,le=r.stackSave=re.stackSave;if(r.asm=re,r.cwrap=function(e,t,r,i){var n=(r=r||[]).every(function(e){return"number"===e});return"string"!==t&&n&&!i?x(e):function(){return v(e,t,r,arguments)}},r.setValue=function(e,t,r,i){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":w[e|0]=t;break;case"i16":M[e>>1]=t;break;case"i32":S[e>>2]=t;break;case"i64":$=[t>>>0,(Q=t,+U(Q)>=1?Q>0?(0|j(+G(Q/4294967296),4294967295))>>>0:~~+z((Q-+(~~Q>>>0))/4294967296)>>>0:0)],S[e>>2]=$[0],S[e+4>>2]=$[1];break;case"float":E[e>>2]=t;break;case"double":N[e>>3]=t;break;default:fe("invalid type for setValue: "+r)}},r.getValue=function(e,t,r){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return w[e|0];case"i16":return M[e>>1];case"i32":case"i64":return S[e>>2];case"float":return E[e>>2];case"double":return N[e>>3];default:fe("invalid type for getValue: "+t)}return null},X)if(K(X)||(ne=X,X=r.locateFile?r.locateFile(ne,p):p+ne),a||l){var Ae=h(X);T.set(Ae,8)}else{H++,r.monitorRunDependencies&&r.monitorRunDependencies(H);var ue=function(e){e.byteLength&&(e=new Uint8Array(e)),T.set(e,8),r.memoryInitializerRequest&&delete r.memoryInitializerRequest.response,function(){if(H--,r.monitorRunDependencies&&r.monitorRunDependencies(H),0==H&&W){var e=W;W=null,e()}}()},he=function(){u(X,ue,function(){throw"could not load memory initializer "+X})},ce=te(X);if(ce)ue(ce.buffer);else if(r.memoryInitializerRequest){var de=function(){var e=r.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var i=te(r.memoryInitializerRequestURL);if(!i)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+e.status+", retrying "+X),void he();t=i.buffer}ue(t)};r.memoryInitializerRequest.response?setTimeout(de,0):r.memoryInitializerRequest.addEventListener("load",de)}else he()}function pe(e){function t(){se||(se=!0,y||(D(F),D(O),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)V(r.postRun.shift());D(L)}()))}H>0||(!function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)k(r.preRun.shift());D(I)}(),H>0||(r.setStatus?(r.setStatus("Running..."),setTimeout(function(){setTimeout(function(){r.setStatus("")},1),t()},1)):t()))}function fe(e){throw r.onAbort&&r.onAbort(e),f(e+=""),m(e),y=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}if(W=function e(){se||pe(),se||(W=e)},r.run=pe,r.abort=fe,r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return pe(),e}("object"==typeof Fl?Fl:{}),Ol="number",Ll={0:"Success",1:"The operation failed but a more specific error is not available",2:"Argument was outside of acceptable range",3:"Latitude or longitude arguments were outside of acceptable range",4:"Resolution argument was outside of acceptable range",5:"Cell argument was not valid",6:"Directed edge argument was not valid",7:"Undirected edge argument was not valid",8:"Vertex argument was not valid",9:"Pentagon distortion was encountered",10:"Duplicate input",11:"Cell arguments were not neighbors",12:"Cell arguments had incompatible resolutions",13:"Memory allocation failed",14:"Bounds of provided memory were insufficient",15:"Mode or flags argument was not valid"},kl={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function Vl(e,t,r){var i=r&&"value"in r,n=new Error((e[t]||"Unknown error")+" (code: "+t+(i?", value: "+r.value:"")+")");return n.code=t,n}function Ul(e,t){return Vl(Ll,e,2===arguments.length?{value:t}:{})}function zl(e,t){return Vl(kl,e,2===arguments.length?{value:t}:{})}function Gl(e){if(0!==e)throw Ul(e)}
/*
   * Copyright 2018-2019, 2022 Uber Technologies, Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *         http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */var jl={};[["sizeOfH3Index",Ol],["sizeOfLatLng",Ol],["sizeOfCellBoundary",Ol],["sizeOfGeoLoop",Ol],["sizeOfGeoPolygon",Ol],["sizeOfLinkedGeoPolygon",Ol],["sizeOfCoordIJ",Ol],["readInt64AsDoubleFromPointer",Ol],["isValidCell",Ol,[Ol,Ol]],["latLngToCell",Ol,[Ol,Ol,Ol,Ol]],["cellToLatLng",Ol,[Ol,Ol,Ol]],["cellToBoundary",Ol,[Ol,Ol,Ol]],["maxGridDiskSize",Ol,[Ol,Ol]],["gridDisk",Ol,[Ol,Ol,Ol,Ol]],["gridDiskDistances",Ol,[Ol,Ol,Ol,Ol,Ol]],["gridRingUnsafe",Ol,[Ol,Ol,Ol,Ol]],["maxPolygonToCellsSize",Ol,[Ol,Ol,Ol,Ol]],["polygonToCells",Ol,[Ol,Ol,Ol,Ol]],["maxPolygonToCellsSizeExperimental",Ol,[Ol,Ol,Ol,Ol]],["polygonToCellsExperimental",Ol,[Ol,Ol,Ol,Ol,Ol,Ol]],["cellsToLinkedMultiPolygon",Ol,[Ol,Ol,Ol]],["destroyLinkedMultiPolygon",null,[Ol]],["compactCells",Ol,[Ol,Ol,Ol,Ol]],["uncompactCells",Ol,[Ol,Ol,Ol,Ol,Ol,Ol]],["uncompactCellsSize",Ol,[Ol,Ol,Ol,Ol,Ol]],["isPentagon",Ol,[Ol,Ol]],["isResClassIII",Ol,[Ol,Ol]],["getBaseCellNumber",Ol,[Ol,Ol]],["getResolution",Ol,[Ol,Ol]],["maxFaceCount",Ol,[Ol,Ol,Ol]],["getIcosahedronFaces",Ol,[Ol,Ol,Ol]],["cellToParent",Ol,[Ol,Ol,Ol,Ol]],["cellToChildren",Ol,[Ol,Ol,Ol,Ol]],["cellToCenterChild",Ol,[Ol,Ol,Ol,Ol]],["cellToChildrenSize",Ol,[Ol,Ol,Ol,Ol]],["cellToChildPos",Ol,[Ol,Ol,Ol,Ol]],["childPosToCell",Ol,[Ol,Ol,Ol,Ol,Ol,Ol]],["areNeighborCells",Ol,[Ol,Ol,Ol,Ol,Ol]],["cellsToDirectedEdge",Ol,[Ol,Ol,Ol,Ol,Ol]],["getDirectedEdgeOrigin",Ol,[Ol,Ol,Ol]],["getDirectedEdgeDestination",Ol,[Ol,Ol,Ol]],["isValidDirectedEdge",Ol,[Ol,Ol]],["directedEdgeToCells",Ol,[Ol,Ol,Ol]],["originToDirectedEdges",Ol,[Ol,Ol,Ol]],["directedEdgeToBoundary",Ol,[Ol,Ol,Ol]],["gridDistance",Ol,[Ol,Ol,Ol,Ol,Ol]],["gridPathCells",Ol,[Ol,Ol,Ol,Ol,Ol]],["gridPathCellsSize",Ol,[Ol,Ol,Ol,Ol,Ol]],["cellToLocalIj",Ol,[Ol,Ol,Ol,Ol,Ol,Ol]],["localIjToCell",Ol,[Ol,Ol,Ol,Ol,Ol]],["getHexagonAreaAvgM2",Ol,[Ol,Ol]],["getHexagonAreaAvgKm2",Ol,[Ol,Ol]],["getHexagonEdgeLengthAvgM",Ol,[Ol,Ol]],["getHexagonEdgeLengthAvgKm",Ol,[Ol,Ol]],["greatCircleDistanceM",Ol,[Ol,Ol]],["greatCircleDistanceKm",Ol,[Ol,Ol]],["greatCircleDistanceRads",Ol,[Ol,Ol]],["cellAreaM2",Ol,[Ol,Ol,Ol]],["cellAreaKm2",Ol,[Ol,Ol,Ol]],["cellAreaRads2",Ol,[Ol,Ol,Ol]],["edgeLengthM",Ol,[Ol,Ol,Ol]],["edgeLengthKm",Ol,[Ol,Ol,Ol]],["edgeLengthRads",Ol,[Ol,Ol,Ol]],["getNumCells",Ol,[Ol,Ol]],["getRes0Cells",Ol,[Ol]],["res0CellCount",Ol],["getPentagons",Ol,[Ol,Ol]],["pentagonCount",Ol],["cellToVertex",Ol,[Ol,Ol,Ol,Ol]],["cellToVertexes",Ol,[Ol,Ol,Ol]],["vertexToLatLng",Ol,[Ol,Ol,Ol]],["isValidVertex",Ol,[Ol,Ol]]].forEach(function(e){jl[e[0]]=Fl.cwrap.apply(Fl,e)});var Hl=16,Wl=jl.sizeOfH3Index(),Ql=jl.sizeOfLatLng(),$l=jl.sizeOfCellBoundary(),Xl=jl.sizeOfGeoPolygon(),Yl=jl.sizeOfGeoLoop();jl.sizeOfLinkedGeoPolygon(),jl.sizeOfCoordIJ();var Kl=Math.pow(2,32)-1;var Zl=/[^0-9a-fA-F]/;function Jl(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||Zl.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),Hl);return[parseInt(e.substring(e.length-8),Hl),t]}function eA(e){if(e>=0)return e.toString(Hl);var t=tA(8,(e&=2147483647).toString(Hl));return t=(parseInt(t[0],Hl)+8).toString(Hl)+t.substring(1)}function tA(e,t){for(var r=e-t.length,i="",n=0;n<r;n++)i+="0";return i+=t}function rA(e,t,r){for(var i=e.length,n=Fl._calloc(i,Ql),s=r?1:0,a=r?0:1,o=0;o<2*i;o+=2)Fl.HEAPF64.set([e[o/2][s],e[o/2][a]].map(uA),n/8+o);return Fl.HEAPU32.set([i,n],t/4),t}function iA(e,t){void 0===t&&(t=0);var r=Fl.getValue(e+Wl*t,"i32"),i=Fl.getValue(e+Wl*t+4,"i32");return i?function(e,t){return eA(t)+tA(8,eA(e))}(r,i):null}function nA(e){return 180*Fl.getValue(e,"double")/Math.PI}function sA(e){return[nA(e+8),nA(e)]}function aA(e,t,r){var i=Fl._malloc(Ql);Fl.HEAPF64.set([e,t].map(uA),i/8);var n=Fl._malloc(Wl);try{return Gl(jl.latLngToCell(i,r,n)),function(e){if(!e)throw zl(1002);return e}(iA(n))}finally{Fl._free(n),Fl._free(i)}}function oA(e){var t,r=Fl._malloc(Ql),i=Jl(e),n=i[0],s=i[1];try{return Gl(jl.cellToLatLng(n,s,r)),[nA(t=r),nA(t+8)]}finally{Fl._free(r)}}function lA(e,t){var r=Fl._malloc($l),i=Jl(e),n=i[0],s=i[1];try{return Gl(jl.cellToBoundary(n,s,r)),function(e){for(var t=Fl.getValue(e,"i32"),r=e+8,i=[],n=sA,s=0;s<2*t;s+=2)i.push(n(r+8*s));return i.push(i[0]),i}(r)}finally{Fl._free(r)}}function AA(e,t,r){if(function(e){if("number"!=typeof e||e<0||e>15||Math.floor(e)!==e)throw Ul(4,e)}(t),r=Boolean(r),0===e.length||0===e[0].length)return[];var i,n=function(e,t){var r,i=e.length-1,n=Fl._calloc(Xl),s=0+Yl,a=s+4;if(rA(e[0],n+0,t),i>0){r=Fl._calloc(i,Yl);for(var o=0;o<i;o++)rA(e[o+1],r+Yl*o,t)}return Fl.setValue(n+s,i,"i32"),Fl.setValue(n+a,r,"i32"),n}("number"==typeof e[0][0]?[e]:e,r),s=Fl._malloc(8);try{Gl(jl.maxPolygonToCellsSize(n,t,0,s));var a=function(e){if(e>Kl)throw zl(1001,e);return e}((i=s,jl.readInt64AsDoubleFromPointer(i))),o=Fl._calloc(a,Wl);try{return Gl(jl.polygonToCells(n,t,0,o)),function(e,t){for(var r=[],i=0;i<t;i++){var n=iA(e,i);null!==n&&r.push(n)}return r}(o,a)}finally{Fl._free(o)}}finally{Fl._free(s),function(e){var t=0+Yl,r=t+4;Fl._free(Fl.getValue(e+0+4,"i8*"));var i=Fl.getValue(e+t,"i32");if(i>0){for(var n=Fl.getValue(e+r,"i32"),s=0;s<i;s++)Fl._free(Fl.getValue(n+Yl*s+4,"i8*"));Fl._free(n)}Fl._free(e)}(n)}}function uA(e){return e*Math.PI/180}const hA="178",cA=100,dA=101,pA=102,fA=200,mA=201,gA=202,yA=203,bA=204,xA=205,vA=206,_A=207,wA=208,TA=209,MA=210,SA=301,EA=302,NA=1e3,CA=1001,RA=1002,BA=1003,PA=1004,qA=1005,DA=1006,IA=1007,FA=1008,OA=1009,LA=1010,kA=1011,VA=1012,UA=1013,zA=1014,GA=1015,jA=1016,HA=1020,WA=1022,QA=1023,$A=1026,XA=1027,YA=1028,KA=1029,ZA=1030,JA=1031,eu=1033,tu=33776,ru=33777,iu=33778,nu=33779,su=37492,au=37496,ou=37808,lu=37809,Au=37810,uu=37811,hu=37812,cu=37813,du=37814,pu=37815,fu=37816,mu=37817,gu=37818,yu=37819,bu=37820,xu=37821,vu=36492,_u="",wu="srgb",Tu="srgb-linear",Mu="linear",Su="srgb",Eu=7680,Nu=512,Cu=513,Ru=514,Bu=515,Pu=516,qu=517,Du=518,Iu=519,Fu=35044,Ou=35048,Lu=2e3,ku=2001;class Vu{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){const r=this._listeners;return void 0!==r&&(void 0!==r[e]&&-1!==r[e].indexOf(t))}removeEventListener(e,t){const r=this._listeners;if(void 0===r)return;const i=r[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){const t=this._listeners;if(void 0===t)return;const r=t[e.type];if(void 0!==r){e.target=this;const t=r.slice(0);for(let r=0,i=t.length;r<i;r++)t[r].call(this,e);e.target=null}}}const Uu=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let zu=1234567;const Gu=Math.PI/180,ju=180/Math.PI;function Hu(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(Uu[255&e]+Uu[e>>8&255]+Uu[e>>16&255]+Uu[e>>24&255]+"-"+Uu[255&t]+Uu[t>>8&255]+"-"+Uu[t>>16&15|64]+Uu[t>>24&255]+"-"+Uu[63&r|128]+Uu[r>>8&255]+"-"+Uu[r>>16&255]+Uu[r>>24&255]+Uu[255&i]+Uu[i>>8&255]+Uu[i>>16&255]+Uu[i>>24&255]).toLowerCase()}function Wu(e,t,r){return Math.max(t,Math.min(r,e))}function Qu(e,t){return(e%t+t)%t}function $u(e,t,r){return(1-r)*e+r*t}function Xu(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Yu(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Ku={DEG2RAD:Gu,RAD2DEG:ju,generateUUID:Hu,clamp:Wu,euclideanModulo:Qu,mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},inverseLerp:function(e,t,r){return e!==t?(r-e)/(t-e):0},lerp:$u,damp:function(e,t,r,i){return $u(e,t,1-Math.exp(-r*i))},pingpong:function(e,t=1){return t-Math.abs(Qu(e,2*t)-t)},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(zu=e);let t=zu+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Gu},radToDeg:function(e){return e*ju},isPowerOfTwo:function(e){return!(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,r,i,n){const s=Math.cos,a=Math.sin,o=s(r/2),l=a(r/2),A=s((t+i)/2),u=a((t+i)/2),h=s((t-i)/2),c=a((t-i)/2),d=s((i-t)/2),p=a((i-t)/2);switch(n){case"XYX":e.set(o*u,l*h,l*c,o*A);break;case"YZY":e.set(l*c,o*u,l*h,o*A);break;case"ZXZ":e.set(l*h,l*c,o*u,o*A);break;case"XZX":e.set(o*u,l*p,l*d,o*A);break;case"YXY":e.set(l*d,o*u,l*p,o*A);break;case"ZYZ":e.set(l*p,l*d,o*u,o*A);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}},normalize:Yu,denormalize:Xu};class Zu{constructor(e=0,t=0){Zu.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Wu(this.x,e.x,t.x),this.y=Wu(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Wu(this.x,e,t),this.y=Wu(this.y,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Wu(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(Wu(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const r=Math.cos(t),i=Math.sin(t),n=this.x-e.x,s=this.y-e.y;return this.x=n*r-s*i+e.x,this.y=n*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ju{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,n,s,a){let o=r[i+0],l=r[i+1],A=r[i+2],u=r[i+3];const h=n[s+0],c=n[s+1],d=n[s+2],p=n[s+3];if(0===a)return e[t+0]=o,e[t+1]=l,e[t+2]=A,void(e[t+3]=u);if(1===a)return e[t+0]=h,e[t+1]=c,e[t+2]=d,void(e[t+3]=p);if(u!==p||o!==h||l!==c||A!==d){let e=1-a;const t=o*h+l*c+A*d+u*p,r=t>=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const n=Math.sqrt(i),s=Math.atan2(n,t*r);e=Math.sin(e*s)/n,a=Math.sin(a*s)/n}const n=a*r;if(o=o*e+h*n,l=l*e+c*n,A=A*e+d*n,u=u*e+p*n,e===1-a){const e=1/Math.sqrt(o*o+l*l+A*A+u*u);o*=e,l*=e,A*=e,u*=e}}e[t]=o,e[t+1]=l,e[t+2]=A,e[t+3]=u}static multiplyQuaternionsFlat(e,t,r,i,n,s){const a=r[i],o=r[i+1],l=r[i+2],A=r[i+3],u=n[s],h=n[s+1],c=n[s+2],d=n[s+3];return e[t]=a*d+A*u+o*c-l*h,e[t+1]=o*d+A*h+l*u-a*c,e[t+2]=l*d+A*c+a*h-o*u,e[t+3]=A*d-a*u-o*h-l*c,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const r=e._x,i=e._y,n=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(r/2),A=a(i/2),u=a(n/2),h=o(r/2),c=o(i/2),d=o(n/2);switch(s){case"XYZ":this._x=h*A*u+l*c*d,this._y=l*c*u-h*A*d,this._z=l*A*d+h*c*u,this._w=l*A*u-h*c*d;break;case"YXZ":this._x=h*A*u+l*c*d,this._y=l*c*u-h*A*d,this._z=l*A*d-h*c*u,this._w=l*A*u+h*c*d;break;case"ZXY":this._x=h*A*u-l*c*d,this._y=l*c*u+h*A*d,this._z=l*A*d+h*c*u,this._w=l*A*u-h*c*d;break;case"ZYX":this._x=h*A*u-l*c*d,this._y=l*c*u+h*A*d,this._z=l*A*d-h*c*u,this._w=l*A*u+h*c*d;break;case"YZX":this._x=h*A*u+l*c*d,this._y=l*c*u+h*A*d,this._z=l*A*d-h*c*u,this._w=l*A*u-h*c*d;break;case"XZY":this._x=h*A*u-l*c*d,this._y=l*c*u-h*A*d,this._z=l*A*d+h*c*u,this._w=l*A*u+h*c*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],n=t[8],s=t[1],a=t[5],o=t[9],l=t[2],A=t[6],u=t[10],h=r+a+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(A-o)*e,this._y=(n-l)*e,this._z=(s-i)*e}else if(r>a&&r>u){const e=2*Math.sqrt(1+r-a-u);this._w=(A-o)/e,this._x=.25*e,this._y=(i+s)/e,this._z=(n+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-r-u);this._w=(n-l)/e,this._x=(i+s)/e,this._y=.25*e,this._z=(o+A)/e}else{const e=2*Math.sqrt(1+u-r-a);this._w=(s-i)/e,this._x=(n+l)/e,this._y=(o+A)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Wu(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(0===r)return this;const i=Math.min(1,t/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,i=e._y,n=e._z,s=e._w,a=t._x,o=t._y,l=t._z,A=t._w;return this._x=r*A+s*a+i*l-n*o,this._y=i*A+s*o+n*a-r*l,this._z=n*A+s*l+r*o-i*a,this._w=s*A-r*a-i*o-n*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const r=this._x,i=this._y,n=this._z,s=this._w;let a=s*e._w+r*e._x+i*e._y+n*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=r,this._y=i,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*r+t*this._x,this._y=e*i+t*this._y,this._z=e*n+t*this._z,this.normalize(),this}const l=Math.sqrt(o),A=Math.atan2(l,a),u=Math.sin((1-t)*A)/l,h=Math.sin(t*A)/l;return this._w=s*u+this._w*h,this._x=r*u+this._x*h,this._y=i*u+this._y*h,this._z=n*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),n=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),n*Math.sin(t),n*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class eh{constructor(e=0,t=0,r=0){eh.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return void 0===r&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(rh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(rh.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[3]*r+n[6]*i,this.y=n[1]*t+n[4]*r+n[7]*i,this.z=n[2]*t+n[5]*r+n[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,n=e.elements,s=1/(n[3]*t+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*t+n[4]*r+n[8]*i+n[12])*s,this.y=(n[1]*t+n[5]*r+n[9]*i+n[13])*s,this.z=(n[2]*t+n[6]*r+n[10]*i+n[14])*s,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,n=e.x,s=e.y,a=e.z,o=e.w,l=2*(s*i-a*r),A=2*(a*t-n*i),u=2*(n*r-s*t);return this.x=t+o*l+s*u-a*A,this.y=r+o*A+a*l-n*u,this.z=i+o*u+n*A-s*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*i,this.y=n[1]*t+n[5]*r+n[9]*i,this.z=n[2]*t+n[6]*r+n[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Wu(this.x,e.x,t.x),this.y=Wu(this.y,e.y,t.y),this.z=Wu(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Wu(this.x,e,t),this.y=Wu(this.y,e,t),this.z=Wu(this.z,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Wu(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,n=e.z,s=t.x,a=t.y,o=t.z;return this.x=i*o-n*a,this.y=n*s-r*o,this.z=r*a-i*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return th.copy(this).projectOnVector(e),this.sub(th)}reflect(e){return this.sub(th.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(Wu(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,r=Math.sqrt(1-t*t);return this.x=r*Math.cos(e),this.y=t,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const th=new eh,rh=new Ju;class ih{constructor(e,t,r,i,n,s,a,o,l){ih.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,r,i,n,s,a,o,l)}set(e,t,r,i,n,s,a,o,l){const A=this.elements;return A[0]=e,A[1]=i,A[2]=a,A[3]=t,A[4]=n,A[5]=o,A[6]=r,A[7]=s,A[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,n=this.elements,s=r[0],a=r[3],o=r[6],l=r[1],A=r[4],u=r[7],h=r[2],c=r[5],d=r[8],p=i[0],f=i[3],m=i[6],g=i[1],y=i[4],b=i[7],x=i[2],v=i[5],_=i[8];return n[0]=s*p+a*g+o*x,n[3]=s*f+a*y+o*v,n[6]=s*m+a*b+o*_,n[1]=l*p+A*g+u*x,n[4]=l*f+A*y+u*v,n[7]=l*m+A*b+u*_,n[2]=h*p+c*g+d*x,n[5]=h*f+c*y+d*v,n[8]=h*m+c*b+d*_,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],A=e[8];return t*s*A-t*a*l-r*n*A+r*a*o+i*n*l-i*s*o}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],A=e[8],u=A*s-a*l,h=a*o-A*n,c=l*n-s*o,d=t*u+r*h+i*c;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const p=1/d;return e[0]=u*p,e[1]=(i*l-A*r)*p,e[2]=(a*r-i*s)*p,e[3]=h*p,e[4]=(A*t-i*o)*p,e[5]=(i*n-a*t)*p,e[6]=c*p,e[7]=(r*o-l*t)*p,e[8]=(s*t-r*n)*p,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,r,i,n,s,a){const o=Math.cos(n),l=Math.sin(n);return this.set(r*o,r*l,-r*(o*s+l*a)+s+e,-i*l,i*o,-i*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(nh.makeScale(e,t)),this}rotate(e){return this.premultiply(nh.makeRotation(-e)),this}translate(e,t){return this.premultiply(nh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,r=e.elements;for(let e=0;e<9;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const nh=new ih;function sh(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function ah(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const oh={};function lh(e){e in oh||(oh[e]=!0,console.warn(e))}const Ah=(new ih).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),uh=(new ih).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function hh(){const e={enabled:!0,workingColorSpace:Tu,spaces:{},convert:function(e,t,r){return!1!==this.enabled&&t!==r&&t&&r?(this.spaces[t].transfer===Su&&(e.r=dh(e.r),e.g=dh(e.g),e.b=dh(e.b)),this.spaces[t].primaries!==this.spaces[r].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===Su&&(e.r=ph(e.r),e.g=ph(e.g),e.b=ph(e.b)),e):e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===_u?Mu:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,r){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,r){return lh("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(t,r)},toWorkingColorSpace:function(t,r){return lh("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(t,r)}},t=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],i=[.3127,.329];return e.define({[Tu]:{primaries:t,whitePoint:i,transfer:Mu,toXYZ:Ah,fromXYZ:uh,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:wu},outputColorSpaceConfig:{drawingBufferColorSpace:wu}},[wu]:{primaries:t,whitePoint:i,transfer:Su,toXYZ:Ah,fromXYZ:uh,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:wu}}}),e}const ch=hh();function dh(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function ph(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let fh;class mh{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{void 0===fh&&(fh=ah("canvas")),fh.width=e.width,fh.height=e.height;const t=fh.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),r=fh}return r.toDataURL(t)}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=ah("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),n=i.data;for(let e=0;e<n.length;e++)n[e]=255*dh(n[e]/255);return r.putImageData(i,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*dh(t[e]/255)):t[e]=dh(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let gh=0;class yh{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:gh++}),this.uuid=Hu(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,r=i.length;t<r;t++)i[t].isDataTexture?e.push(bh(i[t].image)):e.push(bh(i[t]))}else e=bh(i);r.url=e}return t||(e.images[this.uuid]=r),r}}function bh(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?mh.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let xh=0;const vh=new eh;class _h extends Vu{constructor(e=_h.DEFAULT_IMAGE,t=_h.DEFAULT_MAPPING,r=1001,i=1001,n=1006,s=1008,a=1023,o=1009,l=_h.DEFAULT_ANISOTROPY,A=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xh++}),this.uuid=Hu(),this.name="",this.source=new yh(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=n,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Zu(0,0),this.repeat=new Zu(1,1),this.center=new Zu(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ih,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=A,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(vh).x}get height(){return this.source.getSize(vh).y}get depth(){return this.source.getSize(vh).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const r=e[t];if(void 0===r){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[t]=r:console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case NA:e.x=e.x-Math.floor(e.x);break;case CA:e.x=e.x<0?0:1;break;case RA:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case NA:e.y=e.y-Math.floor(e.y);break;case CA:e.y=e.y<0?0:1;break;case RA:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}_h.DEFAULT_IMAGE=null,_h.DEFAULT_MAPPING=300,_h.DEFAULT_ANISOTROPY=1;class wh{constructor(e=0,t=0,r=0,i=1){wh.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,n=this.w,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i+s[12]*n,this.y=s[1]*t+s[5]*r+s[9]*i+s[13]*n,this.z=s[2]*t+s[6]*r+s[10]*i+s[14]*n,this.w=s[3]*t+s[7]*r+s[11]*i+s[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,i,n;const s=.01,a=.1,o=e.elements,l=o[0],A=o[4],u=o[8],h=o[1],c=o[5],d=o[9],p=o[2],f=o[6],m=o[10];if(Math.abs(A-h)<s&&Math.abs(u-p)<s&&Math.abs(d-f)<s){if(Math.abs(A+h)<a&&Math.abs(u+p)<a&&Math.abs(d+f)<a&&Math.abs(l+c+m-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,o=(c+1)/2,g=(m+1)/2,y=(A+h)/4,b=(u+p)/4,x=(d+f)/4;return e>o&&e>g?e<s?(r=0,i=.707106781,n=.707106781):(r=Math.sqrt(e),i=y/r,n=b/r):o>g?o<s?(r=.707106781,i=0,n=.707106781):(i=Math.sqrt(o),r=y/i,n=x/i):g<s?(r=.707106781,i=.707106781,n=0):(n=Math.sqrt(g),r=b/n,i=x/n),this.set(r,i,n,t),this}let g=Math.sqrt((f-d)*(f-d)+(u-p)*(u-p)+(h-A)*(h-A));return Math.abs(g)<.001&&(g=1),this.x=(f-d)/g,this.y=(u-p)/g,this.z=(h-A)/g,this.w=Math.acos((l+c+m-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Wu(this.x,e.x,t.x),this.y=Wu(this.y,e.y,t.y),this.z=Wu(this.z,e.z,t.z),this.w=Wu(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Wu(this.x,e,t),this.y=Wu(this.y,e,t),this.z=Wu(this.z,e,t),this.w=Wu(this.w,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Wu(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Th extends Vu{constructor(e=1,t=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:DA,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=r.depth,this.scissor=new wh(0,0,e,t),this.scissorTest=!1,this.viewport=new wh(0,0,e,t);const i={width:e,height:t,depth:r.depth},n=new _h(i);this.textures=[];const s=r.count;for(let e=0;e<s;e++)this.textures[e]=n.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const t={minFilter:DA,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==e.mapping&&(t.mapping=e.mapping),void 0!==e.wrapS&&(t.wrapS=e.wrapS),void 0!==e.wrapT&&(t.wrapT=e.wrapT),void 0!==e.wrapR&&(t.wrapR=e.wrapR),void 0!==e.magFilter&&(t.magFilter=e.magFilter),void 0!==e.minFilter&&(t.minFilter=e.minFilter),void 0!==e.format&&(t.format=e.format),void 0!==e.type&&(t.type=e.type),void 0!==e.anisotropy&&(t.anisotropy=e.anisotropy),void 0!==e.colorSpace&&(t.colorSpace=e.colorSpace),void 0!==e.flipY&&(t.flipY=e.flipY),void 0!==e.generateMipmaps&&(t.generateMipmaps=e.generateMipmaps),void 0!==e.internalFormat&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){this.textures[e].setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,r=1){if(this.width!==e||this.height!==t||this.depth!==r){this.width=e,this.height=t,this.depth=r;for(let i=0,n=this.textures.length;i<n;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=r,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,r=e.textures.length;t<r;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new yh(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Mh extends Th{constructor(e=1,t=1,r={}){super(e,t,r),this.isWebGLRenderTarget=!0}}class Sh extends _h{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=BA,this.minFilter=BA,this.wrapR=CA,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Eh{constructor(e=new eh(1/0,1/0,1/0),t=new eh(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t+=3)this.expandByPoint(Ch.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(Ch.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const r=Ch.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(void 0!==r){const i=r.getAttribute("position");if(!0===t&&void 0!==i&&!0!==e.isInstancedMesh)for(let t=0,r=i.count;t<r;t++)!0===e.isMesh?e.getVertexPosition(t,Ch):Ch.fromBufferAttribute(i,t),Ch.applyMatrix4(e.matrixWorld),this.expandByPoint(Ch);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),Rh.copy(e.boundingBox)):(null===r.boundingBox&&r.computeBoundingBox(),Rh.copy(r.boundingBox)),Rh.applyMatrix4(e.matrixWorld),this.union(Rh)}const i=e.children;for(let e=0,r=i.length;e<r;e++)this.expandByObject(i[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ch),Ch.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Oh),Lh.subVectors(this.max,Oh),Bh.subVectors(e.a,Oh),Ph.subVectors(e.b,Oh),qh.subVectors(e.c,Oh),Dh.subVectors(Ph,Bh),Ih.subVectors(qh,Ph),Fh.subVectors(Bh,qh);let t=[0,-Dh.z,Dh.y,0,-Ih.z,Ih.y,0,-Fh.z,Fh.y,Dh.z,0,-Dh.x,Ih.z,0,-Ih.x,Fh.z,0,-Fh.x,-Dh.y,Dh.x,0,-Ih.y,Ih.x,0,-Fh.y,Fh.x,0];return!!Uh(t,Bh,Ph,qh,Lh)&&(t=[1,0,0,0,1,0,0,0,1],!!Uh(t,Bh,Ph,qh,Lh)&&(kh.crossVectors(Dh,Ih),t=[kh.x,kh.y,kh.z],Uh(t,Bh,Ph,qh,Lh)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ch).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Ch).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Nh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Nh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Nh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Nh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Nh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Nh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Nh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Nh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Nh)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Nh=[new eh,new eh,new eh,new eh,new eh,new eh,new eh,new eh],Ch=new eh,Rh=new Eh,Bh=new eh,Ph=new eh,qh=new eh,Dh=new eh,Ih=new eh,Fh=new eh,Oh=new eh,Lh=new eh,kh=new eh,Vh=new eh;function Uh(e,t,r,i,n){for(let s=0,a=e.length-3;s<=a;s+=3){Vh.fromArray(e,s);const a=n.x*Math.abs(Vh.x)+n.y*Math.abs(Vh.y)+n.z*Math.abs(Vh.z),o=t.dot(Vh),l=r.dot(Vh),A=i.dot(Vh);if(Math.max(-Math.max(o,l,A),Math.min(o,l,A))>a)return!1}return!0}const zh=new Eh,Gh=new eh,jh=new eh;class Hh{constructor(e=new eh,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const r=this.center;void 0!==t?r.copy(t):zh.setFromPoints(e).getCenter(r);let i=0;for(let t=0,n=e.length;t<n;t++)i=Math.max(i,r.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const r=this.center.distanceToSquared(e);return t.copy(e),r>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Gh.subVectors(e,this.center);const t=Gh.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),r=.5*(e-this.radius);this.center.addScaledVector(Gh,r/e),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(jh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gh.copy(e.center).add(jh)),this.expandByPoint(Gh.copy(e.center).sub(jh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Wh=new eh,Qh=new eh,$h=new eh,Xh=new eh,Yh=new eh,Kh=new eh,Zh=new eh;class Jh{constructor(e=new eh,t=new eh(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wh)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Wh.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wh.copy(this.origin).addScaledVector(this.direction,t),Wh.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){Qh.copy(e).add(t).multiplyScalar(.5),$h.copy(t).sub(e).normalize(),Xh.copy(this.origin).sub(Qh);const n=.5*e.distanceTo(t),s=-this.direction.dot($h),a=Xh.dot(this.direction),o=-Xh.dot($h),l=Xh.lengthSq(),A=Math.abs(1-s*s);let u,h,c,d;if(A>0)if(u=s*o-a,h=s*a-o,d=n*A,u>=0)if(h>=-d)if(h<=d){const e=1/A;u*=e,h*=e,c=u*(u+s*h+2*a)+h*(s*u+h+2*o)+l}else h=n,u=Math.max(0,-(s*h+a)),c=-u*u+h*(h+2*o)+l;else h=-n,u=Math.max(0,-(s*h+a)),c=-u*u+h*(h+2*o)+l;else h<=-d?(u=Math.max(0,-(-s*n+a)),h=u>0?-n:Math.min(Math.max(-n,-o),n),c=-u*u+h*(h+2*o)+l):h<=d?(u=0,h=Math.min(Math.max(-n,-o),n),c=h*(h+2*o)+l):(u=Math.max(0,-(s*n+a)),h=u>0?n:Math.min(Math.max(-n,-o),n),c=-u*u+h*(h+2*o)+l);else h=s>0?-n:n,u=Math.max(0,-(s*h+a)),c=-u*u+h*(h+2*o)+l;return r&&r.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Qh).addScaledVector($h,h),c}intersectSphere(e,t){Wh.subVectors(e.center,this.origin);const r=Wh.dot(this.direction),i=Wh.dot(Wh)-r*r,n=e.radius*e.radius;if(i>n)return null;const s=Math.sqrt(n-i),a=r-s,o=r+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return null===r?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,n,s,a,o;const l=1/this.direction.x,A=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(r=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(r=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),A>=0?(n=(e.min.y-h.y)*A,s=(e.max.y-h.y)*A):(n=(e.max.y-h.y)*A,s=(e.min.y-h.y)*A),r>s||n>i?null:((n>r||isNaN(r))&&(r=n),(s<i||isNaN(i))&&(i=s),u>=0?(a=(e.min.z-h.z)*u,o=(e.max.z-h.z)*u):(a=(e.max.z-h.z)*u,o=(e.min.z-h.z)*u),r>o||a>i?null:((a>r||r!=r)&&(r=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(r>=0?r:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Wh)}intersectTriangle(e,t,r,i,n){Yh.subVectors(t,e),Kh.subVectors(r,e),Zh.crossVectors(Yh,Kh);let s,a=this.direction.dot(Zh);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Xh.subVectors(this.origin,e);const o=s*this.direction.dot(Kh.crossVectors(Xh,Kh));if(o<0)return null;const l=s*this.direction.dot(Yh.cross(Xh));if(l<0)return null;if(o+l>a)return null;const A=-s*Xh.dot(Zh);return A<0?null:this.at(A/a,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ec{constructor(e,t,r,i,n,s,a,o,l,A,u,h,c,d,p,f){ec.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,r,i,n,s,a,o,l,A,u,h,c,d,p,f)}set(e,t,r,i,n,s,a,o,l,A,u,h,c,d,p,f){const m=this.elements;return m[0]=e,m[4]=t,m[8]=r,m[12]=i,m[1]=n,m[5]=s,m[9]=a,m[13]=o,m[2]=l,m[6]=A,m[10]=u,m[14]=h,m[3]=c,m[7]=d,m[11]=p,m[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new ec).fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,i=1/tc.setFromMatrixColumn(e,0).length(),n=1/tc.setFromMatrixColumn(e,1).length(),s=1/tc.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*n,t[5]=r[5]*n,t[6]=r[6]*n,t[7]=0,t[8]=r[8]*s,t[9]=r[9]*s,t[10]=r[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,i=e.y,n=e.z,s=Math.cos(r),a=Math.sin(r),o=Math.cos(i),l=Math.sin(i),A=Math.cos(n),u=Math.sin(n);if("XYZ"===e.order){const e=s*A,r=s*u,i=a*A,n=a*u;t[0]=o*A,t[4]=-o*u,t[8]=l,t[1]=r+i*l,t[5]=e-n*l,t[9]=-a*o,t[2]=n-e*l,t[6]=i+r*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*A,r=o*u,i=l*A,n=l*u;t[0]=e+n*a,t[4]=i*a-r,t[8]=s*l,t[1]=s*u,t[5]=s*A,t[9]=-a,t[2]=r*a-i,t[6]=n+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*A,r=o*u,i=l*A,n=l*u;t[0]=e-n*a,t[4]=-s*u,t[8]=i+r*a,t[1]=r+i*a,t[5]=s*A,t[9]=n-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*A,r=s*u,i=a*A,n=a*u;t[0]=o*A,t[4]=i*l-r,t[8]=e*l+n,t[1]=o*u,t[5]=n*l+e,t[9]=r*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,r=s*l,i=a*o,n=a*l;t[0]=o*A,t[4]=n-e*u,t[8]=i*u+r,t[1]=u,t[5]=s*A,t[9]=-a*A,t[2]=-l*A,t[6]=r*u+i,t[10]=e-n*u}else if("XZY"===e.order){const e=s*o,r=s*l,i=a*o,n=a*l;t[0]=o*A,t[4]=-u,t[8]=l*A,t[1]=e*u+n,t[5]=s*A,t[9]=r*u-i,t[2]=i*u-r,t[6]=a*A,t[10]=n*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(ic,e,nc)}lookAt(e,t,r){const i=this.elements;return oc.subVectors(e,t),0===oc.lengthSq()&&(oc.z=1),oc.normalize(),sc.crossVectors(r,oc),0===sc.lengthSq()&&(1===Math.abs(r.z)?oc.x+=1e-4:oc.z+=1e-4,oc.normalize(),sc.crossVectors(r,oc)),sc.normalize(),ac.crossVectors(oc,sc),i[0]=sc.x,i[4]=ac.x,i[8]=oc.x,i[1]=sc.y,i[5]=ac.y,i[9]=oc.y,i[2]=sc.z,i[6]=ac.z,i[10]=oc.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,n=this.elements,s=r[0],a=r[4],o=r[8],l=r[12],A=r[1],u=r[5],h=r[9],c=r[13],d=r[2],p=r[6],f=r[10],m=r[14],g=r[3],y=r[7],b=r[11],x=r[15],v=i[0],_=i[4],w=i[8],T=i[12],M=i[1],S=i[5],E=i[9],N=i[13],C=i[2],R=i[6],B=i[10],P=i[14],q=i[3],D=i[7],I=i[11],F=i[15];return n[0]=s*v+a*M+o*C+l*q,n[4]=s*_+a*S+o*R+l*D,n[8]=s*w+a*E+o*B+l*I,n[12]=s*T+a*N+o*P+l*F,n[1]=A*v+u*M+h*C+c*q,n[5]=A*_+u*S+h*R+c*D,n[9]=A*w+u*E+h*B+c*I,n[13]=A*T+u*N+h*P+c*F,n[2]=d*v+p*M+f*C+m*q,n[6]=d*_+p*S+f*R+m*D,n[10]=d*w+p*E+f*B+m*I,n[14]=d*T+p*N+f*P+m*F,n[3]=g*v+y*M+b*C+x*q,n[7]=g*_+y*S+b*R+x*D,n[11]=g*w+y*E+b*B+x*I,n[15]=g*T+y*N+b*P+x*F,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[4],i=e[8],n=e[12],s=e[1],a=e[5],o=e[9],l=e[13],A=e[2],u=e[6],h=e[10],c=e[14];return e[3]*(+n*o*u-i*l*u-n*a*h+r*l*h+i*a*c-r*o*c)+e[7]*(+t*o*c-t*l*h+n*s*h-i*s*c+i*l*A-n*o*A)+e[11]*(+t*l*u-t*a*c-n*s*u+r*s*c+n*a*A-r*l*A)+e[15]*(-i*a*A-t*o*u+t*a*h+i*s*u-r*s*h+r*o*A)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],A=e[8],u=e[9],h=e[10],c=e[11],d=e[12],p=e[13],f=e[14],m=e[15],g=u*f*l-p*h*l+p*o*c-a*f*c-u*o*m+a*h*m,y=d*h*l-A*f*l-d*o*c+s*f*c+A*o*m-s*h*m,b=A*p*l-d*u*l+d*a*c-s*p*c-A*a*m+s*u*m,x=d*u*o-A*p*o-d*a*h+s*p*h+A*a*f-s*u*f,v=t*g+r*y+i*b+n*x;if(0===v)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/v;return e[0]=g*_,e[1]=(p*h*n-u*f*n-p*i*c+r*f*c+u*i*m-r*h*m)*_,e[2]=(a*f*n-p*o*n+p*i*l-r*f*l-a*i*m+r*o*m)*_,e[3]=(u*o*n-a*h*n-u*i*l+r*h*l+a*i*c-r*o*c)*_,e[4]=y*_,e[5]=(A*f*n-d*h*n+d*i*c-t*f*c-A*i*m+t*h*m)*_,e[6]=(d*o*n-s*f*n-d*i*l+t*f*l+s*i*m-t*o*m)*_,e[7]=(s*h*n-A*o*n+A*i*l-t*h*l-s*i*c+t*o*c)*_,e[8]=b*_,e[9]=(d*u*n-A*p*n-d*r*c+t*p*c+A*r*m-t*u*m)*_,e[10]=(s*p*n-d*a*n+d*r*l-t*p*l-s*r*m+t*a*m)*_,e[11]=(A*a*n-s*u*n-A*r*l+t*u*l+s*r*c-t*a*c)*_,e[12]=x*_,e[13]=(A*p*i-d*u*i+d*r*h-t*p*h-A*r*f+t*u*f)*_,e[14]=(d*a*i-s*p*i-d*r*o+t*p*o+s*r*f-t*a*f)*_,e[15]=(s*u*i-A*a*i+A*r*o-t*u*o-s*r*h+t*a*h)*_,this}scale(e){const t=this.elements,r=e.x,i=e.y,n=e.z;return t[0]*=r,t[4]*=i,t[8]*=n,t[1]*=r,t[5]*=i,t[9]*=n,t[2]*=r,t[6]*=i,t[10]*=n,t[3]*=r,t[7]*=i,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,i))}makeTranslation(e,t,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),i=Math.sin(t),n=1-r,s=e.x,a=e.y,o=e.z,l=n*s,A=n*a;return this.set(l*s+r,l*a-i*o,l*o+i*a,0,l*a+i*o,A*a+r,A*o-i*s,0,l*o-i*a,A*o+i*s,n*o*o+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,n,s){return this.set(1,r,n,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){const i=this.elements,n=t._x,s=t._y,a=t._z,o=t._w,l=n+n,A=s+s,u=a+a,h=n*l,c=n*A,d=n*u,p=s*A,f=s*u,m=a*u,g=o*l,y=o*A,b=o*u,x=r.x,v=r.y,_=r.z;return i[0]=(1-(p+m))*x,i[1]=(c+b)*x,i[2]=(d-y)*x,i[3]=0,i[4]=(c-b)*v,i[5]=(1-(h+m))*v,i[6]=(f+g)*v,i[7]=0,i[8]=(d+y)*_,i[9]=(f-g)*_,i[10]=(1-(h+p))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){const i=this.elements;let n=tc.set(i[0],i[1],i[2]).length();const s=tc.set(i[4],i[5],i[6]).length(),a=tc.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),e.x=i[12],e.y=i[13],e.z=i[14],rc.copy(this);const o=1/n,l=1/s,A=1/a;return rc.elements[0]*=o,rc.elements[1]*=o,rc.elements[2]*=o,rc.elements[4]*=l,rc.elements[5]*=l,rc.elements[6]*=l,rc.elements[8]*=A,rc.elements[9]*=A,rc.elements[10]*=A,t.setFromRotationMatrix(rc),r.x=n,r.y=s,r.z=a,this}makePerspective(e,t,r,i,n,s,a=2e3){const o=this.elements,l=2*n/(t-e),A=2*n/(r-i),u=(t+e)/(t-e),h=(r+i)/(r-i);let c,d;if(a===Lu)c=-(s+n)/(s-n),d=-2*s*n/(s-n);else{if(a!==ku)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);c=-s/(s-n),d=-s*n/(s-n)}return o[0]=l,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=A,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=c,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,r,i,n,s,a=2e3){const o=this.elements,l=1/(t-e),A=1/(r-i),u=1/(s-n),h=(t+e)*l,c=(r+i)*A;let d,p;if(a===Lu)d=(s+n)*u,p=-2*u;else{if(a!==ku)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);d=n*u,p=-1*u}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*A,o[9]=0,o[13]=-c,o[2]=0,o[6]=0,o[10]=p,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let e=0;e<16;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const tc=new eh,rc=new ec,ic=new eh(0,0,0),nc=new eh(1,1,1),sc=new eh,ac=new eh,oc=new eh,lc=new ec,Ac=new Ju;class uc{constructor(e=0,t=0,r=0,i=uc.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,r=!0){const i=e.elements,n=i[0],s=i[4],a=i[8],o=i[1],l=i[5],A=i[9],u=i[2],h=i[6],c=i[10];switch(t){case"XYZ":this._y=Math.asin(Wu(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-A,c),this._z=Math.atan2(-s,n)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Wu(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(a,c),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(Wu(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,c),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-Wu(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,c),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Wu(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-A,l),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(a,c));break;case"XZY":this._z=Math.asin(-Wu(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-A,c),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===r&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return lc.makeRotationFromQuaternion(e),this.setFromRotationMatrix(lc,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ac.setFromEuler(this),this.setFromQuaternion(Ac,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}uc.DEFAULT_ORDER="XYZ";class hc{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return 0!==(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let cc=0;const dc=new eh,pc=new Ju,fc=new ec,mc=new eh,gc=new eh,yc=new eh,bc=new Ju,xc=new eh(1,0,0),vc=new eh(0,1,0),_c=new eh(0,0,1),wc={type:"added"},Tc={type:"removed"},Mc={type:"childadded",child:null},Sc={type:"childremoved",child:null};class Ec extends Vu{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:cc++}),this.uuid=Hu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ec.DEFAULT_UP.clone();const e=new eh,t=new uc,r=new Ju,i=new eh(1,1,1);t._onChange(function(){r.setFromEuler(t,!1)}),r._onChange(function(){t.setFromQuaternion(r,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ec},normalMatrix:{value:new ih}}),this.matrix=new ec,this.matrixWorld=new ec,this.matrixAutoUpdate=Ec.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ec.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return pc.setFromAxisAngle(e,t),this.quaternion.multiply(pc),this}rotateOnWorldAxis(e,t){return pc.setFromAxisAngle(e,t),this.quaternion.premultiply(pc),this}rotateX(e){return this.rotateOnAxis(xc,e)}rotateY(e){return this.rotateOnAxis(vc,e)}rotateZ(e){return this.rotateOnAxis(_c,e)}translateOnAxis(e,t){return dc.copy(e).applyQuaternion(this.quaternion),this.position.add(dc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xc,e)}translateY(e){return this.translateOnAxis(vc,e)}translateZ(e){return this.translateOnAxis(_c,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(fc.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?mc.copy(e):mc.set(e,t,r);const i=this.parent;this.updateWorldMatrix(!0,!1),gc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?fc.lookAt(gc,mc,this.up):fc.lookAt(mc,gc,this.up),this.quaternion.setFromRotationMatrix(fc),i&&(fc.extractRotation(i.matrixWorld),pc.setFromRotationMatrix(fc),this.quaternion.premultiply(pc.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(wc),Mc.child=e,this.dispatchEvent(Mc),Mc.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Tc),Sc.child=e,this.dispatchEvent(Sc),Sc.child=null),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),fc.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),fc.multiply(e.parent.matrixWorld)),e.applyMatrix4(fc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(wc),Mc.child=e,this.dispatchEvent(Mc),Mc.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let r=0,i=this.children.length;r<i;r++){const i=this.children[r].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);const i=this.children;for(let n=0,s=i.length;n<s;n++)i[n].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gc,e,yc),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gc,bc,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let r=0,i=t.length;r<i;r++){t[r].updateMatrixWorld(e)}}updateWorldMatrix(e,t){const r=this.parent;if(!0===e&&null!==r&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===t){const e=this.children;for(let t=0,r=e.length;t<r;t++){e[t].updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function n(t,r){return void 0===t[r.uuid]&&(t[r.uuid]=r.toJSON(e)),r.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(e=>({...e})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const r=t.shapes;if(Array.isArray(r))for(let t=0,i=r.length;t<i;t++){const i=r[t];n(e.shapes,i)}else n(e.shapes,r)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(n(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let r=0,i=this.material.length;r<i;r++)t.push(n(e.materials,this.material[r]));i.material=t}else i.material=n(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){const r=this.animations[t];i.animations.push(n(e.animations,r))}}if(t){const t=s(e.geometries),i=s(e.materials),n=s(e.textures),a=s(e.images),o=s(e.shapes),l=s(e.skeletons),A=s(e.animations),u=s(e.nodes);t.length>0&&(r.geometries=t),i.length>0&&(r.materials=i),n.length>0&&(r.textures=n),a.length>0&&(r.images=a),o.length>0&&(r.shapes=o),l.length>0&&(r.skeletons=l),A.length>0&&(r.animations=A),u.length>0&&(r.nodes=u)}return r.object=i,r;function s(e){const t=[];for(const r in e){const i=e[r];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const r=e.children[t];this.add(r.clone())}return this}}Ec.DEFAULT_UP=new eh(0,1,0),Ec.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ec.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Nc=new eh,Cc=new eh,Rc=new eh,Bc=new eh,Pc=new eh,qc=new eh,Dc=new eh,Ic=new eh,Fc=new eh,Oc=new eh,Lc=new wh,kc=new wh,Vc=new wh;class Uc{constructor(e=new eh,t=new eh,r=new eh){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),Nc.subVectors(e,t),i.cross(Nc);const n=i.lengthSq();return n>0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)}static getBarycoord(e,t,r,i,n){Nc.subVectors(i,t),Cc.subVectors(r,t),Rc.subVectors(e,t);const s=Nc.dot(Nc),a=Nc.dot(Cc),o=Nc.dot(Rc),l=Cc.dot(Cc),A=Cc.dot(Rc),u=s*l-a*a;if(0===u)return n.set(0,0,0),null;const h=1/u,c=(l*o-a*A)*h,d=(s*A-a*o)*h;return n.set(1-c-d,d,c)}static containsPoint(e,t,r,i){return null!==this.getBarycoord(e,t,r,i,Bc)&&(Bc.x>=0&&Bc.y>=0&&Bc.x+Bc.y<=1)}static getInterpolation(e,t,r,i,n,s,a,o){return null===this.getBarycoord(e,t,r,i,Bc)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(n,Bc.x),o.addScaledVector(s,Bc.y),o.addScaledVector(a,Bc.z),o)}static getInterpolatedAttribute(e,t,r,i,n,s){return Lc.setScalar(0),kc.setScalar(0),Vc.setScalar(0),Lc.fromBufferAttribute(e,t),kc.fromBufferAttribute(e,r),Vc.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Lc,n.x),s.addScaledVector(kc,n.y),s.addScaledVector(Vc,n.z),s}static isFrontFacing(e,t,r,i){return Nc.subVectors(r,t),Cc.subVectors(e,t),Nc.cross(Cc).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Nc.subVectors(this.c,this.b),Cc.subVectors(this.a,this.b),.5*Nc.cross(Cc).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Uc.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Uc.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,n){return Uc.getInterpolation(e,this.a,this.b,this.c,t,r,i,n)}containsPoint(e){return Uc.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Uc.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,n=this.c;let s,a;Pc.subVectors(i,r),qc.subVectors(n,r),Ic.subVectors(e,r);const o=Pc.dot(Ic),l=qc.dot(Ic);if(o<=0&&l<=0)return t.copy(r);Fc.subVectors(e,i);const A=Pc.dot(Fc),u=qc.dot(Fc);if(A>=0&&u<=A)return t.copy(i);const h=o*u-A*l;if(h<=0&&o>=0&&A<=0)return s=o/(o-A),t.copy(r).addScaledVector(Pc,s);Oc.subVectors(e,n);const c=Pc.dot(Oc),d=qc.dot(Oc);if(d>=0&&c<=d)return t.copy(n);const p=c*l-o*d;if(p<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(r).addScaledVector(qc,a);const f=A*d-c*u;if(f<=0&&u-A>=0&&c-d>=0)return Dc.subVectors(n,i),a=(u-A)/(u-A+(c-d)),t.copy(i).addScaledVector(Dc,a);const m=1/(f+p+h);return s=p*m,a=h*m,t.copy(r).addScaledVector(Pc,s).addScaledVector(qc,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const zc={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Gc={h:0,s:0,l:0},jc={h:0,s:0,l:0};function Hc(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}class Wc{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(void 0===t&&void 0===r){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=wu){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,ch.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=ch.workingColorSpace){return this.r=e,this.g=t,this.b=r,ch.colorSpaceToWorking(this,i),this}setHSL(e,t,r,i=ch.workingColorSpace){if(e=Qu(e,1),t=Wu(t,0,1),r=Wu(r,0,1),0===t)this.r=this.g=this.b=r;else{const i=r<=.5?r*(1+t):r+t-r*t,n=2*r-i;this.r=Hc(n,i,e+1/3),this.g=Hc(n,i,e),this.b=Hc(n,i,e-1/3)}return ch.colorSpaceToWorking(this,i),this}setStyle(e,t=wu){function r(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,t);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],n=r.length;if(3===n)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(6===n)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=wu){const r=zc[e.toLowerCase()];return void 0!==r?this.setHex(r,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=dh(e.r),this.g=dh(e.g),this.b=dh(e.b),this}copyLinearToSRGB(e){return this.r=ph(e.r),this.g=ph(e.g),this.b=ph(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wu){return ch.workingToColorSpace(Qc.copy(this),e),65536*Math.round(Wu(255*Qc.r,0,255))+256*Math.round(Wu(255*Qc.g,0,255))+Math.round(Wu(255*Qc.b,0,255))}getHexString(e=wu){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ch.workingColorSpace){ch.workingToColorSpace(Qc.copy(this),t);const r=Qc.r,i=Qc.g,n=Qc.b,s=Math.max(r,i,n),a=Math.min(r,i,n);let o,l;const A=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=A<=.5?e/(s+a):e/(2-s-a),s){case r:o=(i-n)/e+(i<n?6:0);break;case i:o=(n-r)/e+2;break;case n:o=(r-i)/e+4}o/=6}return e.h=o,e.s=l,e.l=A,e}getRGB(e,t=ch.workingColorSpace){return ch.workingToColorSpace(Qc.copy(this),t),e.r=Qc.r,e.g=Qc.g,e.b=Qc.b,e}getStyle(e=wu){ch.workingToColorSpace(Qc.copy(this),e);const t=Qc.r,r=Qc.g,i=Qc.b;return e!==wu?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*r)},${Math.round(255*i)})`}offsetHSL(e,t,r){return this.getHSL(Gc),this.setHSL(Gc.h+e,Gc.s+t,Gc.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(Gc),e.getHSL(jc);const r=$u(Gc.h,jc.h,t),i=$u(Gc.s,jc.s,t),n=$u(Gc.l,jc.l,t);return this.setHSL(r,i,n),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,r=this.g,i=this.b,n=e.elements;return this.r=n[0]*t+n[3]*r+n[6]*i,this.g=n[1]*t+n[4]*r+n[7]*i,this.b=n[2]*t+n[5]*r+n[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Qc=new Wc;Wc.NAMES=zc;let $c=0;class Xc extends Vu{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$c++}),this.uuid=Hu(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bA,this.blendDst=xA,this.blendEquation=cA,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Wc(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Eu,this.stencilZFail=Eu,this.stencilZPass=Eu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const r=e[t];if(void 0===r){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const r in e){const i=e[r];delete i.metadata,t.push(i)}return t}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(r.dispersion=this.dispersion),void 0!==this.iridescence&&(r.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(r.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(r.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(r.combine=this.combine)),void 0!==this.envMapRotation&&(r.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(r.blending=this.blending),0!==this.side&&(r.side=this.side),!0===this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=!0),this.blendSrc!==bA&&(r.blendSrc=this.blendSrc),this.blendDst!==xA&&(r.blendDst=this.blendDst),this.blendEquation!==cA&&(r.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(r.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(r.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(r.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(r.depthFunc=this.depthFunc),!1===this.depthTest&&(r.depthTest=this.depthTest),!1===this.depthWrite&&(r.depthWrite=this.depthWrite),!1===this.colorWrite&&(r.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(r.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(r.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(r.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Eu&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Eu&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Eu&&(r.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(r.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.alphaHash&&(r.alphaHash=!0),!0===this.alphaToCoverage&&(r.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=!0),!0===this.forceSinglePass&&(r.forceSinglePass=!0),!0===this.wireframe&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=!0),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),!1===this.fog&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData),t){const t=i(e.textures),n=i(e.images);t.length>0&&(r.textures=t),n.length>0&&(r.images=n)}return r}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let r=null;if(null!==t){const e=t.length;r=new Array(e);for(let i=0;i!==e;++i)r[i]=t[i].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class Yc extends Xc{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Wc(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new uc,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Kc=Zc();function Zc(){const e=new ArrayBuffer(4),t=new Float32Array(e),r=new Uint32Array(e),i=new Uint32Array(512),n=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,n[e]=24,n[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,n[e]=-t-1,n[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,n[e]=13,n[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,n[e]=24,n[256|e]=24):(i[e]=31744,i[256|e]=64512,n[e]=13,n[256|e]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,r=0;for(;!(8388608&t);)t<<=1,r-=8388608;t&=-8388609,r+=947912704,s[e]=t|r}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:r,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:a,offsetTable:o}}function Jc(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Wu(e,-65504,65504),Kc.floatView[0]=e;const t=Kc.uint32View[0],r=t>>23&511;return Kc.baseTable[r]+((8388607&t)>>Kc.shiftTable[r])}function ed(e){const t=e>>10;return Kc.uint32View[0]=Kc.mantissaTable[Kc.offsetTable[t]+(1023&e)]+Kc.exponentTable[t],Kc.floatView[0]}const td=new eh,rd=new Zu;let id=0;class nd{constructor(e,t,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:id++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=r,this.usage=Fu,this.updateRanges=[],this.gpuType=GA,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,n=this.itemSize;i<n;i++)this.array[e+i]=t.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,r=this.count;t<r;t++)rd.fromBufferAttribute(this,t),rd.applyMatrix3(e),this.setXY(t,rd.x,rd.y);else if(3===this.itemSize)for(let t=0,r=this.count;t<r;t++)td.fromBufferAttribute(this,t),td.applyMatrix3(e),this.setXYZ(t,td.x,td.y,td.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)td.fromBufferAttribute(this,t),td.applyMatrix4(e),this.setXYZ(t,td.x,td.y,td.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)td.fromBufferAttribute(this,t),td.applyNormalMatrix(e),this.setXYZ(t,td.x,td.y,td.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)td.fromBufferAttribute(this,t),td.transformDirection(e),this.setXYZ(t,td.x,td.y,td.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=Xu(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=Yu(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Xu(t,this.array)),t}setX(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Xu(t,this.array)),t}setY(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Xu(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Xu(t,this.array)),t}setW(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array),i=Yu(i,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,n){return e*=this.itemSize,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array),i=Yu(i,this.array),n=Yu(n,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Fu&&(e.usage=this.usage),e}}class sd extends nd{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class ad extends nd{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class od extends nd{constructor(e,t,r){super(new Uint16Array(e),t,r),this.isFloat16BufferAttribute=!0}getX(e){let t=ed(this.array[e*this.itemSize]);return this.normalized&&(t=Xu(t,this.array)),t}setX(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize]=Jc(t),this}getY(e){let t=ed(this.array[e*this.itemSize+1]);return this.normalized&&(t=Xu(t,this.array)),t}setY(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize+1]=Jc(t),this}getZ(e){let t=ed(this.array[e*this.itemSize+2]);return this.normalized&&(t=Xu(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize+2]=Jc(t),this}getW(e){let t=ed(this.array[e*this.itemSize+3]);return this.normalized&&(t=Xu(t,this.array)),t}setW(e,t){return this.normalized&&(t=Yu(t,this.array)),this.array[e*this.itemSize+3]=Jc(t),this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array)),this.array[e+0]=Jc(t),this.array[e+1]=Jc(r),this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array),i=Yu(i,this.array)),this.array[e+0]=Jc(t),this.array[e+1]=Jc(r),this.array[e+2]=Jc(i),this}setXYZW(e,t,r,i,n){return e*=this.itemSize,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array),i=Yu(i,this.array),n=Yu(n,this.array)),this.array[e+0]=Jc(t),this.array[e+1]=Jc(r),this.array[e+2]=Jc(i),this.array[e+3]=Jc(n),this}}class ld extends nd{constructor(e,t,r){super(new Float32Array(e),t,r)}}let Ad=0;const ud=new ec,hd=new Ec,cd=new eh,dd=new Eh,pd=new Eh,fd=new eh;class md extends Vu{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ad++}),this.uuid=Hu(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(sh(e)?ad:sd)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(void 0!==r){const t=(new ih).getNormalMatrix(e);r.applyNormalMatrix(t),r.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return ud.makeRotationFromQuaternion(e),this.applyMatrix4(ud),this}rotateX(e){return ud.makeRotationX(e),this.applyMatrix4(ud),this}rotateY(e){return ud.makeRotationY(e),this.applyMatrix4(ud),this}rotateZ(e){return ud.makeRotationZ(e),this.applyMatrix4(ud),this}translate(e,t,r){return ud.makeTranslation(e,t,r),this.applyMatrix4(ud),this}scale(e,t,r){return ud.makeScale(e,t,r),this.applyMatrix4(ud),this}lookAt(e){return hd.lookAt(e),hd.updateMatrix(),this.applyMatrix4(hd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cd).negate(),this.translate(cd.x,cd.y,cd.z),this}setFromPoints(e){const t=this.getAttribute("position");if(void 0===t){const t=[];for(let r=0,i=e.length;r<i;r++){const i=e[r];t.push(i.x,i.y,i.z||0)}this.setAttribute("position",new ld(t,3))}else{const r=Math.min(e.length,t.count);for(let i=0;i<r;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Eh);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new eh(-1/0,-1/0,-1/0),new eh(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){const r=t[e];dd.setFromBufferAttribute(r),this.morphTargetsRelative?(fd.addVectors(this.boundingBox.min,dd.min),this.boundingBox.expandByPoint(fd),fd.addVectors(this.boundingBox.max,dd.max),this.boundingBox.expandByPoint(fd)):(this.boundingBox.expandByPoint(dd.min),this.boundingBox.expandByPoint(dd.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Hh);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new eh,1/0);if(e){const r=this.boundingSphere.center;if(dd.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){const r=t[e];pd.setFromBufferAttribute(r),this.morphTargetsRelative?(fd.addVectors(dd.min,pd.min),dd.expandByPoint(fd),fd.addVectors(dd.max,pd.max),dd.expandByPoint(fd)):(dd.expandByPoint(pd.min),dd.expandByPoint(pd.max))}dd.getCenter(r);let i=0;for(let t=0,n=e.count;t<n;t++)fd.fromBufferAttribute(e,t),i=Math.max(i,r.distanceToSquared(fd));if(t)for(let n=0,s=t.length;n<s;n++){const s=t[n],a=this.morphTargetsRelative;for(let t=0,n=s.count;t<n;t++)fd.fromBufferAttribute(s,t),a&&(cd.fromBufferAttribute(e,t),fd.add(cd)),i=Math.max(i,r.distanceToSquared(fd))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const r=t.position,i=t.normal,n=t.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new nd(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),a=[],o=[];for(let e=0;e<r.count;e++)a[e]=new eh,o[e]=new eh;const l=new eh,A=new eh,u=new eh,h=new Zu,c=new Zu,d=new Zu,p=new eh,f=new eh;function m(e,t,i){l.fromBufferAttribute(r,e),A.fromBufferAttribute(r,t),u.fromBufferAttribute(r,i),h.fromBufferAttribute(n,e),c.fromBufferAttribute(n,t),d.fromBufferAttribute(n,i),A.sub(l),u.sub(l),c.sub(h),d.sub(h);const s=1/(c.x*d.y-d.x*c.y);isFinite(s)&&(p.copy(A).multiplyScalar(d.y).addScaledVector(u,-c.y).multiplyScalar(s),f.copy(u).multiplyScalar(c.x).addScaledVector(A,-d.x).multiplyScalar(s),a[e].add(p),a[t].add(p),a[i].add(p),o[e].add(f),o[t].add(f),o[i].add(f))}let g=this.groups;0===g.length&&(g=[{start:0,count:e.count}]);for(let t=0,r=g.length;t<r;++t){const r=g[t],i=r.start;for(let t=i,n=i+r.count;t<n;t+=3)m(e.getX(t+0),e.getX(t+1),e.getX(t+2))}const y=new eh,b=new eh,x=new eh,v=new eh;function _(e){x.fromBufferAttribute(i,e),v.copy(x);const t=a[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),b.crossVectors(v,t);const r=b.dot(o[e])<0?-1:1;s.setXYZW(e,y.x,y.y,y.z,r)}for(let t=0,r=g.length;t<r;++t){const r=g[t],i=r.start;for(let t=i,n=i+r.count;t<n;t+=3)_(e.getX(t+0)),_(e.getX(t+1)),_(e.getX(t+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let r=this.getAttribute("normal");if(void 0===r)r=new nd(new Float32Array(3*t.count),3),this.setAttribute("normal",r);else for(let e=0,t=r.count;e<t;e++)r.setXYZ(e,0,0,0);const i=new eh,n=new eh,s=new eh,a=new eh,o=new eh,l=new eh,A=new eh,u=new eh;if(e)for(let h=0,c=e.count;h<c;h+=3){const c=e.getX(h+0),d=e.getX(h+1),p=e.getX(h+2);i.fromBufferAttribute(t,c),n.fromBufferAttribute(t,d),s.fromBufferAttribute(t,p),A.subVectors(s,n),u.subVectors(i,n),A.cross(u),a.fromBufferAttribute(r,c),o.fromBufferAttribute(r,d),l.fromBufferAttribute(r,p),a.add(A),o.add(A),l.add(A),r.setXYZ(c,a.x,a.y,a.z),r.setXYZ(d,o.x,o.y,o.z),r.setXYZ(p,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)i.fromBufferAttribute(t,e+0),n.fromBufferAttribute(t,e+1),s.fromBufferAttribute(t,e+2),A.subVectors(s,n),u.subVectors(i,n),A.cross(u),r.setXYZ(e+0,A.x,A.y,A.z),r.setXYZ(e+1,A.x,A.y,A.z),r.setXYZ(e+2,A.x,A.y,A.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)fd.fromBufferAttribute(e,t),fd.normalize(),e.setXYZ(t,fd.x,fd.y,fd.z)}toNonIndexed(){function e(e,t){const r=e.array,i=e.itemSize,n=e.normalized,s=new r.constructor(t.length*i);let a=0,o=0;for(let n=0,l=t.length;n<l;n++){a=e.isInterleavedBufferAttribute?t[n]*e.data.stride+e.offset:t[n]*i;for(let e=0;e<i;e++)s[o++]=r[a++]}return new nd(s,i,n)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new md,r=this.index.array,i=this.attributes;for(const n in i){const s=e(i[n],r);t.setAttribute(n,s)}const n=this.morphAttributes;for(const i in n){const s=[],a=n[i];for(let t=0,i=a.length;t<i;t++){const i=e(a[t],r);s.push(i)}t.morphAttributes[i]=s}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let e=0,r=s.length;e<r;e++){const r=s[e];t.addGroup(r.start,r.count,r.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const r in t)void 0!==t[r]&&(e[r]=t[r]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const t in r){const i=r[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let n=!1;for(const t in this.morphAttributes){const r=this.morphAttributes[t],s=[];for(let t=0,i=r.length;t<i;t++){const i=r[t];s.push(i.toJSON(e.data))}s.length>0&&(i[t]=s,n=!0)}n&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere=a.toJSON()),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const r=e.index;null!==r&&this.setIndex(r.clone());const i=e.attributes;for(const e in i){const r=i[e];this.setAttribute(e,r.clone(t))}const n=e.morphAttributes;for(const e in n){const r=[],i=n[e];for(let e=0,n=i.length;e<n;e++)r.push(i[e].clone(t));this.morphAttributes[e]=r}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let e=0,t=s.length;e<t;e++){const t=s[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const gd=new ec,yd=new Jh,bd=new Hh,xd=new eh,vd=new eh,_d=new eh,wd=new eh,Td=new eh,Md=new eh,Sd=new eh,Ed=new eh;class Nd extends Ec{constructor(e=new md,t=new Yc){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){const t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const r=this.geometry,i=r.attributes.position,n=r.morphAttributes.position,s=r.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(n&&a){Md.set(0,0,0);for(let r=0,i=n.length;r<i;r++){const i=a[r],o=n[r];0!==i&&(Td.fromBufferAttribute(o,e),s?Md.addScaledVector(Td,i):Md.addScaledVector(Td.sub(t),i))}t.add(Md)}return t}raycast(e,t){const r=this.geometry,i=this.material,n=this.matrixWorld;if(void 0!==i){if(null===r.boundingSphere&&r.computeBoundingSphere(),bd.copy(r.boundingSphere),bd.applyMatrix4(n),yd.copy(e.ray).recast(e.near),!1===bd.containsPoint(yd.origin)){if(null===yd.intersectSphere(bd,xd))return;if(yd.origin.distanceToSquared(xd)>(e.far-e.near)**2)return}gd.copy(n).invert(),yd.copy(e.ray).applyMatrix4(gd),null!==r.boundingBox&&!1===yd.intersectsBox(r.boundingBox)||this._computeIntersections(e,t,yd)}}_computeIntersections(e,t,r){let i;const n=this.geometry,s=this.material,a=n.index,o=n.attributes.position,l=n.attributes.uv,A=n.attributes.uv1,u=n.attributes.normal,h=n.groups,c=n.drawRange;if(null!==a)if(Array.isArray(s))for(let n=0,o=h.length;n<o;n++){const o=h[n],d=s[o.materialIndex];for(let n=Math.max(o.start,c.start),s=Math.min(a.count,Math.min(o.start+o.count,c.start+c.count));n<s;n+=3){i=Cd(this,d,e,r,l,A,u,a.getX(n),a.getX(n+1),a.getX(n+2)),i&&(i.faceIndex=Math.floor(n/3),i.face.materialIndex=o.materialIndex,t.push(i))}}else{for(let n=Math.max(0,c.start),o=Math.min(a.count,c.start+c.count);n<o;n+=3){i=Cd(this,s,e,r,l,A,u,a.getX(n),a.getX(n+1),a.getX(n+2)),i&&(i.faceIndex=Math.floor(n/3),t.push(i))}}else if(void 0!==o)if(Array.isArray(s))for(let n=0,a=h.length;n<a;n++){const a=h[n],d=s[a.materialIndex];for(let n=Math.max(a.start,c.start),s=Math.min(o.count,Math.min(a.start+a.count,c.start+c.count));n<s;n+=3){i=Cd(this,d,e,r,l,A,u,n,n+1,n+2),i&&(i.faceIndex=Math.floor(n/3),i.face.materialIndex=a.materialIndex,t.push(i))}}else{for(let n=Math.max(0,c.start),a=Math.min(o.count,c.start+c.count);n<a;n+=3){i=Cd(this,s,e,r,l,A,u,n,n+1,n+2),i&&(i.faceIndex=Math.floor(n/3),t.push(i))}}}}function Cd(e,t,r,i,n,s,a,o,l,A){e.getVertexPosition(o,vd),e.getVertexPosition(l,_d),e.getVertexPosition(A,wd);const u=function(e,t,r,i,n,s,a,o){let l;if(l=1===t.side?i.intersectTriangle(a,s,n,!0,o):i.intersectTriangle(n,s,a,0===t.side,o),null===l)return null;Ed.copy(o),Ed.applyMatrix4(e.matrixWorld);const A=r.ray.origin.distanceTo(Ed);return A<r.near||A>r.far?null:{distance:A,point:Ed.clone(),object:e}}(e,t,r,i,vd,_d,wd,Sd);if(u){const e=new eh;Uc.getBarycoord(Sd,vd,_d,wd,e),n&&(u.uv=Uc.getInterpolatedAttribute(n,o,l,A,e,new Zu)),s&&(u.uv1=Uc.getInterpolatedAttribute(s,o,l,A,e,new Zu)),a&&(u.normal=Uc.getInterpolatedAttribute(a,o,l,A,e,new eh),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const t={a:o,b:l,c:A,normal:new eh,materialIndex:0};Uc.getNormal(vd,_d,wd,t.normal),u.face=t,u.barycoord=e}return u}class Rd extends md{constructor(e=1,t=1,r=1,i=1,n=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:n,depthSegments:s};const a=this;i=Math.floor(i),n=Math.floor(n),s=Math.floor(s);const o=[],l=[],A=[],u=[];let h=0,c=0;function d(e,t,r,i,n,s,d,p,f,m,g){const y=s/f,b=d/m,x=s/2,v=d/2,_=p/2,w=f+1,T=m+1;let M=0,S=0;const E=new eh;for(let s=0;s<T;s++){const a=s*b-v;for(let o=0;o<w;o++){const h=o*y-x;E[e]=h*i,E[t]=a*n,E[r]=_,l.push(E.x,E.y,E.z),E[e]=0,E[t]=0,E[r]=p>0?1:-1,A.push(E.x,E.y,E.z),u.push(o/f),u.push(1-s/m),M+=1}}for(let e=0;e<m;e++)for(let t=0;t<f;t++){const r=h+t+w*e,i=h+t+w*(e+1),n=h+(t+1)+w*(e+1),s=h+(t+1)+w*e;o.push(r,i,s),o.push(i,n,s),S+=6}a.addGroup(c,S,g),c+=S,h+=M}d("z","y","x",-1,-1,r,t,e,s,n,0),d("z","y","x",1,-1,r,t,-e,s,n,1),d("x","z","y",1,1,e,r,t,i,s,2),d("x","z","y",1,-1,e,r,-t,i,s,3),d("x","y","z",1,-1,e,t,r,i,n,4),d("x","y","z",-1,-1,e,t,-r,i,n,5),this.setIndex(o),this.setAttribute("position",new ld(l,3)),this.setAttribute("normal",new ld(A,3)),this.setAttribute("uv",new ld(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rd(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Bd(e){const t={};for(const r in e){t[r]={};for(const i in e[r]){const n=e[r][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[r][i]=null):t[r][i]=n.clone():Array.isArray(n)?t[r][i]=n.slice():t[r][i]=n}}return t}class Pd extends Xc{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Bd(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const i=this.uniforms[r].value;i&&i.isTexture?t.uniforms[r]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[r]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[r]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[r]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[r]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[r]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[r]={type:"m4",value:i.toArray()}:t.uniforms[r]={value:i}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const r={};for(const e in this.extensions)!0===this.extensions[e]&&(r[e]=!0);return Object.keys(r).length>0&&(t.extensions=r),t}}class qd extends Ec{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ec,this.projectionMatrix=new ec,this.projectionMatrixInverse=new ec,this.coordinateSystem=Lu}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const Dd=new eh,Id=new Zu,Fd=new Zu;class Od extends qd{constructor(e=50,t=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*ju*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Gu*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*ju*Math.atan(Math.tan(.5*Gu*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,r){Dd.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Dd.x,Dd.y).multiplyScalar(-e/Dd.z),Dd.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Dd.x,Dd.y).multiplyScalar(-e/Dd.z)}getViewSize(e,t){return this.getViewBounds(e,Id,Fd),t.subVectors(Fd,Id)}setViewOffset(e,t,r,i,n,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Gu*this.fov)/this.zoom,r=2*t,i=this.aspect*r,n=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;n+=s.offsetX*i/e,t-=s.offsetY*r/a,i*=s.width/e,r*=s.height/a}const a=this.filmOffset;0!==a&&(n+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,t,t-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Ld=-90;class kd extends Ec{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Od(Ld,1,e,t);i.layers=this.layers,this.add(i);const n=new Od(Ld,1,e,t);n.layers=this.layers,this.add(n);const s=new Od(Ld,1,e,t);s.layers=this.layers,this.add(s);const a=new Od(Ld,1,e,t);a.layers=this.layers,this.add(a);const o=new Od(Ld,1,e,t);o.layers=this.layers,this.add(o);const l=new Od(Ld,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[r,i,n,s,a,o]=t;for(const e of t)this.remove(e);if(e===Lu)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),n.up.set(0,0,-1),n.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==ku)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[n,s,a,o,l,A]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),c=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;const p=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(t,n),e.setRenderTarget(r,1,i),e.render(t,s),e.setRenderTarget(r,2,i),e.render(t,a),e.setRenderTarget(r,3,i),e.render(t,o),e.setRenderTarget(r,4,i),e.render(t,l),r.texture.generateMipmaps=p,e.setRenderTarget(r,5,i),e.render(t,A),e.setRenderTarget(u,h,c),e.xr.enabled=d,r.texture.needsPMREMUpdate=!0}}class Vd extends _h{constructor(e=[],t=301,r,i,n,s,a,o,l,A){super(e,t,r,i,n,s,a,o,l,A),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ud extends Mh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new Vd(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Rd(5,5,5),n=new Pd({name:"CubemapFromEquirect",uniforms:Bd(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:1,blending:0});n.uniforms.tEquirect.value=t;const s=new Nd(i,n),a=t.minFilter;t.minFilter===FA&&(t.minFilter=DA);return new kd(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){const n=e.getRenderTarget();for(let n=0;n<6;n++)e.setRenderTarget(this,n),e.clear(t,r,i);e.setRenderTarget(n)}}class zd extends Ec{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Gd={type:"move"};class jd{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new zd,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new zd,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new eh,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new eh),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new zd,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new eh,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new eh),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,r){let i=null,n=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){s=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,r),n=this._getHandJoint(l,i);null!==e&&(n.matrix.fromArray(e.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),n.matrixWorldNeedsUpdate=!0,n.jointRadius=e.radius),n.visible=null!==e}const i=l.joints["index-finger-tip"],n=l.joints["thumb-tip"],a=i.position.distanceTo(n.position),o=.02,A=.005;l.inputState.pinching&&a>o+A?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-A&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(n=t.getPose(e.gripSpace,r),null!==n&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=t.getPose(e.targetRaySpace,r),null===i&&null!==n&&(i=n),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Gd)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==n),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const r=new zd;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class Hd extends Ec{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new uc,this.environmentIntensity=1,this.environmentRotation=new uc,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Wd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Fu,this.updateRanges=[],this.version=0,this.uuid=Hu()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let i=0,n=this.stride;i<n;i++)this.array[e+i]=t.array[r+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Hu()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Hu()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Qd=new eh;class $d{constructor(e,t,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,r=this.data.count;t<r;t++)Qd.fromBufferAttribute(this,t),Qd.applyMatrix4(e),this.setXYZ(t,Qd.x,Qd.y,Qd.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)Qd.fromBufferAttribute(this,t),Qd.applyNormalMatrix(e),this.setXYZ(t,Qd.x,Qd.y,Qd.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)Qd.fromBufferAttribute(this,t),Qd.transformDirection(e),this.setXYZ(t,Qd.x,Qd.y,Qd.z);return this}getComponent(e,t){let r=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(r=Xu(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=Yu(r,this.array)),this.data.array[e*this.data.stride+this.offset+t]=r,this}setX(e,t){return this.normalized&&(t=Yu(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Yu(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Yu(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Yu(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Xu(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xu(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xu(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xu(t,this.array)),t}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array),i=Yu(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Yu(t,this.array),r=Yu(r,this.array),i=Yu(i,this.array),n=Yu(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=n,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return new nd(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new $d(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Xd extends Xc{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Wc(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}class Yd extends _h{constructor(e=null,t=1,r=1,i,n,s,a,o,l=1003,A=1003,u,h){super(null,s,a,o,l,A,i,n,u,h),this.isDataTexture=!0,this.image={data:e,width:t,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Kd extends nd{constructor(e,t,r,i=1){super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Zd=new eh,Jd=new eh,ep=new ih;class tp{constructor(e=new eh(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const i=Zd.subVectors(r,t).cross(Jd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const r=e.delta(Zd),i=this.normal.dot(r);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const n=-(e.start.dot(this.normal)+this.constant)/i;return n<0||n>1?null:t.copy(e.start).addScaledVector(r,n)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const r=t||ep.getNormalMatrix(e),i=this.coplanarPoint(Zd).applyMatrix4(e),n=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(n),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const rp=new Hh,ip=new Zu(.5,.5),np=new eh;class sp{constructor(e=new tp,t=new tp,r=new tp,i=new tp,n=new tp,s=new tp){this.planes=[e,t,r,i,n,s]}set(e,t,r,i,n,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(s),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=2e3){const r=this.planes,i=e.elements,n=i[0],s=i[1],a=i[2],o=i[3],l=i[4],A=i[5],u=i[6],h=i[7],c=i[8],d=i[9],p=i[10],f=i[11],m=i[12],g=i[13],y=i[14],b=i[15];if(r[0].setComponents(o-n,h-l,f-c,b-m).normalize(),r[1].setComponents(o+n,h+l,f+c,b+m).normalize(),r[2].setComponents(o+s,h+A,f+d,b+g).normalize(),r[3].setComponents(o-s,h-A,f-d,b-g).normalize(),r[4].setComponents(o-a,h-u,f-p,b-y).normalize(),t===Lu)r[5].setComponents(o+a,h+u,f+p,b+y).normalize();else{if(t!==ku)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);r[5].setComponents(a,u,p,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),rp.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),rp.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(rp)}intersectsSprite(e){rp.center.set(0,0,0);const t=ip.distanceTo(e.center);return rp.radius=.7071067811865476+t,rp.applyMatrix4(e.matrixWorld),this.intersectsSphere(rp)}intersectsSphere(e){const t=this.planes,r=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(r)<i)return!1}return!0}intersectsBox(e){const t=this.planes;for(let r=0;r<6;r++){const i=t[r];if(np.x=i.normal.x>0?e.max.x:e.min.x,np.y=i.normal.y>0?e.max.y:e.min.y,np.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(np)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const ap=new ec,op=new sp;class lp{constructor(){this.coordinateSystem=Lu}intersectsObject(e,t){if(!t.isArrayCamera||0===t.cameras.length)return!1;for(let r=0;r<t.cameras.length;r++){const i=t.cameras[r];if(ap.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),op.setFromProjectionMatrix(ap,this.coordinateSystem),op.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let r=0;r<t.cameras.length;r++){const i=t.cameras[r];if(ap.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),op.setFromProjectionMatrix(ap,this.coordinateSystem),op.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let r=0;r<t.cameras.length;r++){const i=t.cameras[r];if(ap.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),op.setFromProjectionMatrix(ap,this.coordinateSystem),op.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let r=0;r<t.cameras.length;r++){const i=t.cameras[r];if(ap.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),op.setFromProjectionMatrix(ap,this.coordinateSystem),op.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let r=0;r<t.cameras.length;r++){const i=t.cameras[r];if(ap.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),op.setFromProjectionMatrix(ap,this.coordinateSystem),op.containsPoint(e))return!0}return!1}clone(){return new lp}}class Ap extends Xc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Wc(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}class up extends Xc{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Wc(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}class hp extends _h{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=BA,this.minFilter=BA,this.generateMipmaps=!1,this.needsUpdate=!0}}class cp extends _h{constructor(e,t,r=1014,i,n,s,a=1003,o=1003,l,A=1026,u=1){if(A!==$A&&A!==XA)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:u},i,n,s,a,o,A,r,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new yh(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class dp extends md{constructor(e=1,t=1,r=1,i=32,n=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),n=Math.floor(n);const A=[],u=[],h=[],c=[];let d=0;const p=[],f=r/2;let m=0;function g(r){const n=d,s=new Zu,p=new eh;let g=0;const y=!0===r?e:t,b=!0===r?1:-1;for(let e=1;e<=i;e++)u.push(0,f*b,0),h.push(0,b,0),c.push(.5,.5),d++;const x=d;for(let e=0;e<=i;e++){const t=e/i*o+a,r=Math.cos(t),n=Math.sin(t);p.x=y*n,p.y=f*b,p.z=y*r,u.push(p.x,p.y,p.z),h.push(0,b,0),s.x=.5*r+.5,s.y=.5*n*b+.5,c.push(s.x,s.y),d++}for(let e=0;e<i;e++){const t=n+e,i=x+e;!0===r?A.push(i,i+1,t):A.push(i+1,i,t),g+=3}l.addGroup(m,g,!0===r?1:2),m+=g}!function(){const s=new eh,g=new eh;let y=0;const b=(t-e)/r;for(let l=0;l<=n;l++){const A=[],m=l/n,y=m*(t-e)+e;for(let e=0;e<=i;e++){const t=e/i,n=t*o+a,l=Math.sin(n),p=Math.cos(n);g.x=y*l,g.y=-m*r+f,g.z=y*p,u.push(g.x,g.y,g.z),s.set(l,b,p).normalize(),h.push(s.x,s.y,s.z),c.push(t,1-m),A.push(d++)}p.push(A)}for(let r=0;r<i;r++)for(let i=0;i<n;i++){const s=p[i][r],a=p[i+1][r],o=p[i+1][r+1],l=p[i][r+1];(e>0||0!==i)&&(A.push(s,a,l),y+=3),(t>0||i!==n-1)&&(A.push(a,o,l),y+=3)}l.addGroup(m,y,0),m+=y}(),!1===s&&(e>0&&g(!0),t>0&&g(!1)),this.setIndex(A),this.setAttribute("position",new ld(u,3)),this.setAttribute("normal",new ld(h,3)),this.setAttribute("uv",new ld(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dp(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class pp extends md{constructor(e=1,t=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i};const n=e/2,s=t/2,a=Math.floor(r),o=Math.floor(i),l=a+1,A=o+1,u=e/a,h=t/o,c=[],d=[],p=[],f=[];for(let e=0;e<A;e++){const t=e*h-s;for(let r=0;r<l;r++){const i=r*u-n;d.push(i,-t,0),p.push(0,0,1),f.push(r/a),f.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<a;t++){const r=t+l*e,i=t+l*(e+1),n=t+1+l*(e+1),s=t+1+l*e;c.push(r,i,s),c.push(i,n,s)}this.setIndex(c),this.setAttribute("position",new ld(d,3)),this.setAttribute("normal",new ld(p,3)),this.setAttribute("uv",new ld(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pp(e.width,e.height,e.widthSegments,e.heightSegments)}}class fp extends md{constructor(e=1,t=32,r=16,i=0,n=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:n,thetaStart:s,thetaLength:a},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));const o=Math.min(s+a,Math.PI);let l=0;const A=[],u=new eh,h=new eh,c=[],d=[],p=[],f=[];for(let c=0;c<=r;c++){const m=[],g=c/r;let y=0;0===c&&0===s?y=.5/t:c===r&&o===Math.PI&&(y=-.5/t);for(let r=0;r<=t;r++){const o=r/t;u.x=-e*Math.cos(i+o*n)*Math.sin(s+g*a),u.y=e*Math.cos(s+g*a),u.z=e*Math.sin(i+o*n)*Math.sin(s+g*a),d.push(u.x,u.y,u.z),h.copy(u).normalize(),p.push(h.x,h.y,h.z),f.push(o+y,1-g),m.push(l++)}A.push(m)}for(let e=0;e<r;e++)for(let i=0;i<t;i++){const t=A[e][i+1],n=A[e][i],a=A[e+1][i],l=A[e+1][i+1];(0!==e||s>0)&&c.push(t,n,l),(e!==r-1||o<Math.PI)&&c.push(n,a,l)}this.setIndex(c),this.setAttribute("position",new ld(d,3)),this.setAttribute("normal",new ld(p,3)),this.setAttribute("uv",new ld(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fp(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class mp extends Xc{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Wc(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class gp extends Xc{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Wc(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Wc(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Zu(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new uc,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yp extends gp{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Zu(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Wu(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Wc(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Wc(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Wc(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class bp extends Xc{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Wc(16777215),this.specular=new Wc(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Wc(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Zu(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new uc,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xp extends Xc{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Wc(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Wc(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Zu(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class vp extends Xc{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Zu(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class _p extends Xc{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Wc(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Wc(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Zu(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new uc,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class wp extends Xc{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Wc(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Zu(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Tp extends Ap{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class Mp extends Ec{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Wc(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(t.object.target=this.target.uuid),t}}class Sp extends Mp{constructor(e,t,r){super(e,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ec.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Wc(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Ep=new ec,Np=new eh,Cp=new eh;class Rp{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Zu(512,512),this.mapType=OA,this.map=null,this.mapPass=null,this.matrix=new ec,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new sp,this._frameExtents=new Zu(1,1),this._viewportCount=1,this._viewports=[new wh(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;Np.setFromMatrixPosition(e.matrixWorld),t.position.copy(Np),Cp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Cp),t.updateMatrixWorld(),Ep.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ep),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Ep)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Bp extends Rp{constructor(){super(new Od(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,r=2*ju*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,n=e.distance||t.far;r===t.fov&&i===t.aspect&&n===t.far||(t.fov=r,t.aspect=i,t.far=n,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Pp extends Mp{constructor(e,t,r=0,i=Math.PI/3,n=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ec.DEFAULT_UP),this.updateMatrix(),this.target=new Ec,this.distance=r,this.angle=i,this.penumbra=n,this.decay=s,this.map=null,this.shadow=new Bp}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const qp=new ec,Dp=new eh,Ip=new eh;class Fp extends Rp{constructor(){super(new Od(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Zu(4,2),this._viewportCount=6,this._viewports=[new wh(2,1,1,1),new wh(0,1,1,1),new wh(3,1,1,1),new wh(1,1,1,1),new wh(3,0,1,1),new wh(1,0,1,1)],this._cubeDirections=[new eh(1,0,0),new eh(-1,0,0),new eh(0,0,1),new eh(0,0,-1),new eh(0,1,0),new eh(0,-1,0)],this._cubeUps=[new eh(0,1,0),new eh(0,1,0),new eh(0,1,0),new eh(0,1,0),new eh(0,0,1),new eh(0,0,-1)]}updateMatrices(e,t=0){const r=this.camera,i=this.matrix,n=e.distance||r.far;n!==r.far&&(r.far=n,r.updateProjectionMatrix()),Dp.setFromMatrixPosition(e.matrixWorld),r.position.copy(Dp),Ip.copy(r.position),Ip.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Ip),r.updateMatrixWorld(),i.makeTranslation(-Dp.x,-Dp.y,-Dp.z),qp.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(qp)}}class Op extends Mp{constructor(e,t,r=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Fp}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Lp extends qd{constructor(e=-1,t=1,r=1,i=-1,n=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=n,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,n,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let n=r-e,s=r+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=e*this.view.offsetX,s=n+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(n,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}class kp extends Rp{constructor(){super(new Lp(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Vp extends Mp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ec.DEFAULT_UP),this.updateMatrix(),this.target=new Ec,this.shadow=new kp}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Up extends Mp{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class zp extends Mp{constructor(e,t,r=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=r,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Gp{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new eh)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const r=e.x,i=e.y,n=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*i),t.addScaledVector(s[2],.488603*n),t.addScaledVector(s[3],.488603*r),t.addScaledVector(s[4],r*i*1.092548),t.addScaledVector(s[5],i*n*1.092548),t.addScaledVector(s[6],.315392*(3*n*n-1)),t.addScaledVector(s[7],r*n*1.092548),t.addScaledVector(s[8],.546274*(r*r-i*i)),t}getIrradianceAt(e,t){const r=e.x,i=e.y,n=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*i),t.addScaledVector(s[2],1.023328*n),t.addScaledVector(s[3],1.023328*r),t.addScaledVector(s[4],.858086*r*i),t.addScaledVector(s[5],.858086*i*n),t.addScaledVector(s[6],.743125*n*n-.247708),t.addScaledVector(s[7],.858086*r*n),t.addScaledVector(s[8],.429043*(r*r-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let r=0;r<9;r++)this.coefficients[r].addScaledVector(e.coefficients[r],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let r=0;r<9;r++)this.coefficients[r].lerp(e.coefficients[r],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const r=this.coefficients;for(let i=0;i<9;i++)r[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){const r=this.coefficients;for(let i=0;i<9;i++)r[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){const r=e.x,i=e.y,n=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*n,t[3]=.488603*r,t[4]=1.092548*r*i,t[5]=1.092548*i*n,t[6]=.315392*(3*n*n-1),t[7]=1.092548*r*n,t[8]=.546274*(r*r-i*i)}}class jp extends Mp{constructor(e=new Gp,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Hp extends Od{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Wp extends Wd{constructor(e,t,r=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class Qp{constructor(e,t,r,i){Qp.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==e&&this.set(e,t,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let r=0;r<4;r++)this.elements[r]=e[r+t];return this}set(e,t,r,i){const n=this.elements;return n[0]=e,n[2]=t,n[1]=r,n[3]=i,this}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:hA}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hA);const $p=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class Xp{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=$p,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:r,material:i,object:n}=e;if(t={material:this.getMaterialData(i),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:n.matrixWorld.clone()},n.center&&(t.center=n.center.clone()),n.morphTargetInfluences&&(t.morphTargetInfluences=n.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:r,height:i}=e.context;t.bufferWidth=r,t.bufferHeight=i}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const i=e[r];t[r]={version:i.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const i=e[r];null!=i&&("object"==typeof i&&void 0!==i.clone?!0===i.isTexture?t[r]={id:i.id,version:i.version}:t[r]=i.clone():t[r]=i)}return t}equals(e){const{object:t,material:r,geometry:i}=e,n=this.getRenderObjectData(e);if(!0!==n.worldMatrix.equals(t.matrixWorld))return n.worldMatrix.copy(t.matrixWorld),!1;const s=n.material;for(const e in s){const t=s[e],i=r[e];if(void 0!==t.equals){if(!1===t.equals(i))return t.copy(i),!1}else if(!0===i.isTexture){if(t.id!==i.id||t.version!==i.version)return t.id=i.id,t.version=i.version,!1}else if(t!==i)return s[e]=i,!1}if(s.transmission>0){const{width:t,height:r}=e.context;if(n.bufferWidth!==t||n.bufferHeight!==r)return n.bufferWidth=t,n.bufferHeight=r,!1}const a=n.geometry,o=i.attributes,l=a.attributes,A=Object.keys(l),u=Object.keys(o);if(a.id!==i.id)return a.id=i.id,!1;if(A.length!==u.length)return n.geometry.attributes=this.getAttributesData(o),!1;for(const e of A){const t=l[e],r=o[e];if(void 0===r)return delete l[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const h=i.index,c=a.indexVersion,d=h?h.version:null;if(c!==d)return a.indexVersion=d,!1;if(a.drawRange.start!==i.drawRange.start||a.drawRange.count!==i.drawRange.count)return a.drawRange.start=i.drawRange.start,a.drawRange.count=i.drawRange.count,!1;if(n.morphTargetInfluences){let e=!1;for(let r=0;r<n.morphTargetInfluences.length;r++)n.morphTargetInfluences[r]!==t.morphTargetInfluences[r]&&(e=!0);if(e)return!0}return n.center&&!1===n.center.equals(t.center)?(n.center.copy(t.center),!0):(null!==e.bundle&&(n.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:r}=t;if(this.renderId!==r)return this.renderId=r,!0;const i=!0===e.object.static,n=null!==e.bundle&&!0===e.bundle.static&&this.getRenderObjectData(e).version===e.bundle.version;if(i||n)return!1;return!0!==this.equals(e)}}function Yp(e,t=0){let r=3735928559^t,i=1103547991^t;if(e instanceof Array)for(let t,n=0;n<e.length;n++)t=e[n],r=Math.imul(r^t,2654435761),i=Math.imul(i^t,1597334677);else for(let t,n=0;n<e.length;n++)t=e.charCodeAt(n),r=Math.imul(r^t,2654435761),i=Math.imul(i^t,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&i)+(r>>>0)}const Kp=e=>Yp(e),Zp=e=>Yp(e),Jp=(...e)=>Yp(e);function ef(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:i,childNode:n}of tf(e))r.push(Yp(i.slice(0,-4)),n.getCacheKey(t));return Yp(r)}function*tf(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const i=e[r];if(!0===Array.isArray(i))for(let e=0;e<i.length;e++){const n=i[e];n&&(!0===n.isNode||t&&"function"==typeof n.toJSON)&&(yield{property:r,index:e,childNode:n})}else if(i&&!0===i.isNode)yield{property:r,childNode:i};else if("object"==typeof i)for(const e in i){const n=i[e];n&&(!0===n.isNode||t&&"function"==typeof n.toJSON)&&(yield{property:r,index:e,childNode:n})}}}const rf=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),nf=new WeakMap;function sf(e){return rf.get(e)}function af(e){if(/[iu]?vec\d/.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(e))return Float32Array;if(/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function of(e){return/float|int|uint/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?9:/mat4/.test(e)?16:void console.error("THREE.TSL: Unsupported type:",e)}function lf(e){return/float|int|uint/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?12:/mat4/.test(e)?16:void console.error("THREE.TSL: Unsupported type:",e)}function Af(e){return/float|int|uint/.test(e)?4:/vec2/.test(e)?8:/vec3/.test(e)||/vec4/.test(e)?16:/mat2/.test(e)?8:/mat3/.test(e)?48:/mat4/.test(e)?64:void console.error("THREE.TSL: Unsupported type:",e)}function uf(e){if(null==e)return null;const t=typeof e;return!0===e.isNode?"node":"number"===t?"float":"boolean"===t?"bool":"string"===t?"string":"function"===t?"shader":!0===e.isVector2?"vec2":!0===e.isVector3?"vec3":!0===e.isVector4?"vec4":!0===e.isMatrix2?"mat2":!0===e.isMatrix3?"mat3":!0===e.isMatrix4?"mat4":!0===e.isColor?"color":e instanceof ArrayBuffer?"ArrayBuffer":null}function hf(e,...t){const r=e?e.slice(-4):void 0;return 1===t.length&&("vec2"===r?t=[t[0],t[0]]:"vec3"===r?t=[t[0],t[0],t[0]]:"vec4"===r&&(t=[t[0],t[0],t[0],t[0]])),"color"===e?new Wc(...t):"vec2"===r?new Zu(...t):"vec3"===r?new eh(...t):"vec4"===r?new wh(...t):"mat2"===r?new Qp(...t):"mat3"===r?new ih(...t):"mat4"===r?new ec(...t):"bool"===e?t[0]||!1:"float"===e||"int"===e||"uint"===e?t[0]||0:"string"===e?t[0]||"":"ArrayBuffer"===e?pf(t[0]):null}function cf(e){let t=nf.get(e);return void 0===t&&(t={},nf.set(e,t)),t}function df(e){let t="";const r=new Uint8Array(e);for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return btoa(t)}function pf(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const ff={VERTEX:"vertex",FRAGMENT:"fragment"},mf={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},gf={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},yf=["fragment","vertex"],bf=["setup","analyze","generate"],xf=[...yf,"compute"],vf=["x","y","z","w"],_f={analyze:"setup",generate:"analyze"};let wf=0;class Tf extends Vu{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=mf.NONE,this.updateBeforeType=mf.NONE,this.updateAfterType=mf.NONE,this.uuid=Ku.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:wf++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,mf.FRAME)}onRenderUpdate(e){return this.onUpdate(e,mf.RENDER)}onObjectUpdate(e){return this.onUpdate(e,mf.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of tf(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Jp(ef(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const i=e.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[e.buildStage]=!0;const n=_f[e.buildStage];if(n&&!0!==i.buildStages[n]){const t=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let s=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}s=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),i=e.getDataFromNode(this);s=i.snippet,void 0===s?void 0===i.generated?(i.generated=!0,s=this.generate(e)||"",i.snippet=s):(console.warn("THREE.Node: Recursion detected.",this),s="/* Recursion detected. */"):void 0!==i.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),s=e.format(s,r,t)}else s=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),s}getSerializeChildren(){return tf(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:i,index:n,childNode:s}of t)void 0!==n?(void 0===r[i]&&(r[i]=Number.isInteger(n)?[]:{}),r[i][n]=s.toJSON(e.meta).uuid):r[i]=s.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const i=[];for(const n of e.inputNodes[r])i.push(t[n]);this[r]=i}else if("object"==typeof e.inputNodes[r]){const i={};for(const n in e.inputNodes[r]){const s=e.inputNodes[r][n];i[n]=t[s]}this[r]=i}else{const i=e.inputNodes[r];this[r]=t[i]}}}toJSON(e){const{uuid:t,type:r}=this,i=void 0===e||"string"==typeof e;i&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[t];function s(e){const t=[];for(const r in e){const i=e[r];delete i.metadata,t.push(i)}return t}if(void 0===n&&(n={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==i&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta),i){const t=s(e.textures),r=s(e.images),i=s(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),i.length>0&&(n.nodes=i)}return n}}class Mf extends Tf{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Sf extends Tf{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const i of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(i)||(r=i);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,i=this.getNodeType(e),n=r.build(e,i);return e.format(n,i,t)}}class Ef extends Tf{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),i=e.getDataFromNode(this);if(void 0!==i.propertyName)return e.format(i.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const n=super.build(e,r),s=e.getVarFromNode(this,null,r),a=e.getPropertyName(s);return e.addLineFlowCode(`${a} = ${n}`,this),i.snippet=n,i.propertyName=a,e.format(i.propertyName,r,t)}}return super.build(e,t)}}class Nf extends Ef{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,r)=>t+e.getTypeLength(r.getNodeType(e)),0))}generate(e,t){const r=this.getNodeType(e),i=e.getTypeLength(r),n=this.nodes,s=e.getComponentType(r),a=[];let o=0;for(const t of n){if(o>=i){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let n,l=t.getNodeType(e),A=e.getTypeLength(l);o+A>i&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),A=i-o,l=e.getTypeFromLength(A)),o+=A,n=t.build(e,l);const u=e.getComponentType(l);u!==s&&(n=e.format(n,u,s)),a.push(n)}const l=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(l,r,t)}}const Cf=vf.join("");class Rf extends Tf{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(vf.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,i=e.getTypeLength(r.getNodeType(e));let n=null;if(i>1){let s=null;this.getVectorLength()>=i&&(s=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,s);n=this.components.length===i&&this.components===Cf.slice(0,this.components.length)?e.format(a,s,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else n=r.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Bf extends Ef{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:i}=this,n=this.getNodeType(e),s=e.getComponentType(i.getNodeType(e)),a=e.getTypeFromLength(r.length,s),o=i.build(e,a),l=t.build(e,n),A=e.getTypeLength(n),u=[];for(let e=0;e<A;e++){const t=vf[e];t===r[0]?(u.push(o),e+=r.length-1):u.push(l+"."+t)}return`${e.getType(n)}( ${u.join(", ")} )`}}class Pf extends Ef{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:r}=this,i=this.getNodeType(e),n=r.build(e),s=e.getVarFromNode(this),a=e.getPropertyName(s);e.addLineFlowCode(a+" = "+n,this);const o=e.getTypeLength(i),l=[];let A=0;for(let e=0;e<o;e++){const r=vf[e];r===t[A]?(l.push("1.0 - "+a+"."+r),A++):l.push(a+"."+r)}return`${e.getType(i)}( ${l.join(", ")} )`}}class qf extends Tf{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return null===this.nodeType?uf(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=uf(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=df(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?hf(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const Df=/float|u?int/;class If extends qf{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const r=this.getNodeType(e);return Df.test(r)&&Df.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class Ff extends Tf{static get type(){return"MemberNode"}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}}let Of=null;const Lf=new Map;function kf(e,t){if(Lf.has(e))console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);else{if("function"!=typeof t)throw new Error(`THREE.TSL: Node element ${e} is not a function`);Lf.set(e,t)}}const Vf=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Uf=e=>Vf(e).split("").sort().join(""),zf={setup(e,t){const r=t.shift();return e(dm(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(Of.assign(r,...e),r);if(Lf.has(t)){const i=Lf.get(t);return e.isStackNode?(...e)=>r.add(i(...e)):(...e)=>i(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&Lf.has(t.slice(0,t.length-6))){const i=Lf.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],i(...e)):(...e)=>r.assign(i(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=Vf(t),cm(new Rf(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=Uf(t.slice(3).toLowerCase()),r=>cm(new Bf(e,t,cm(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=Uf(t.slice(4).toLowerCase()),()=>cm(new Pf(cm(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),cm(new Rf(e,t));if(!0===/^\d+$/.test(t))return cm(new Mf(r,new If(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>cm(new Ff(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,i)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,i):(i[t].assign(r),!0)},Gf=new WeakMap,jf=new WeakMap,Hf=function(e,t=null){for(const r in e)e[r]=cm(e[r],t);return e},Wf=function(e,t=null){const r=e.length;for(let i=0;i<r;i++)e[i]=cm(e[i],t);return e},Qf=function(e,t=null,r=null,i=null){const n=e=>cm(null!==i?Object.assign(e,i):e);let s,a,o,l=t;function A(t){let r;return r=l?/[a-z]/i.test(l)?l+"()":l:e.type,void 0!==a&&t.length<a?(console.error(`THREE.TSL: "${r}" parameter length is less than minimum required.`),t.concat(new Array(a-t.length).fill(0))):void 0!==o&&t.length>o?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?s=(...t)=>n(new e(...pm(A(t)))):null!==r?(r=cm(r),s=(...i)=>n(new e(t,...pm(A(i)),r))):s=(...r)=>n(new e(t,...pm(A(r)))),s.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),s),s.setName=e=>(l=e,s),s},$f=function(e,...t){return cm(new e(...pm(t)))};class Xf extends Tf{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,i=e.getNodeProperties(t),n=e.getClosestSubBuild(t.subBuilds)||"",s=n||"default";if(i[s])return i[s];const a=e.subBuildFn;e.subBuildFn=n;let o=null;if(t.layout){let i=jf.get(e.constructor);void 0===i&&(i=new WeakMap,jf.set(e.constructor,i));let n=i.get(t);void 0===n&&(n=cm(e.buildFunctionNode(t)),i.set(t,n)),e.addInclude(n),o=cm(n.call(r))}else{const i=t.jsFunc,n=null!==r||i.length>1?i(r||[],e):i(e);o=cm(n)}return e.subBuildFn=a,t.once&&(i[s]=o),o}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}build(e,t=null){let r=null;const i=e.getBuildStage(),n=e.getNodeProperties(this),s=e.getSubBuildOutput(this),a=this.getOutputNode(e);if("setup"===i){const t=e.getSubBuildProperty("initialized",this);if(!0!==n[t]&&(n[t]=!0,n[s]=this.getOutputNode(e),n[s].build(e),this.shaderNode.subBuilds))for(const t of e.chaining){const r=e.getDataFromNode(t,"any");r.subBuilds=r.subBuilds||new Set;for(const e of this.shaderNode.subBuilds)r.subBuilds.add(e)}r=n[s]}else"analyze"===i?a.build(e,t):"generate"===i&&(r=a.build(e,t)||"");return r}}class Yf extends Tf{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return dm(e),cm(new Xf(this,e))}setup(){return this.call()}}const Kf=[!1,!0],Zf=[0,1,2,3],Jf=[-1,-2],em=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],tm=new Map;for(const e of Kf)tm.set(e,new If(e));const rm=new Map;for(const e of Zf)rm.set(e,new If(e,"uint"));const im=new Map([...rm].map(e=>new If(e.value,"int")));for(const e of Jf)im.set(e,new If(e,"int"));const nm=new Map([...im].map(e=>new If(e.value)));for(const e of em)nm.set(e,new If(e));for(const e of em)nm.set(-e,new If(-e));const sm={bool:tm,uint:rm,ints:im,float:nm},am=new Map([...tm,...nm]),om=(e,t)=>am.has(e)?am.get(e):!0===e.isNode?e:new If(e,t),lm=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every(e=>"object"!=typeof e))&&(r=[hf(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return cm(t.get(r[0]));if(1===r.length){const t=om(r[0],e);return t.nodeType===e?cm(t):cm(new Sf(t,e))}const i=r.map(e=>om(e));return cm(new Nf(i,e))}},Am=e=>"object"==typeof e&&null!==e?e.value:e,um=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function hm(e,t){return new Proxy(new Yf(e,t),zf)}const cm=(e,t=null)=>function(e,t=null){const r=uf(e);if("node"===r){let t=Gf.get(e);return void 0===t&&(t=new Proxy(e,zf),Gf.set(e,t),Gf.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?cm(om(e,t)):"shader"===r?e.isFn?e:ym(e):e}(e,t),dm=(e,t=null)=>new Hf(e,t),pm=(e,t=null)=>new Wf(e,t),fm=(...e)=>new Qf(...e),mm=(...e)=>new $f(...e);let gm=0;const ym=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const i=new hm(e,r),n=(...e)=>{let t;dm(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const n=i.call(t);return"void"===r&&n.toStack(),n};if(n.shaderNode=i,n.id=i.id,n.isFn=!0,n.getNodeType=(...e)=>i.getNodeType(...e),n.getCacheKey=(...e)=>i.getCacheKey(...e),n.setLayout=e=>(i.setLayout(e),n),n.once=(e=null)=>(i.once=!0,i.subBuilds=e,n),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+gm++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}n.setLayout(t)}return n},bm=e=>{Of=e},xm=()=>Of,vm=(...e)=>Of.If(...e);function _m(e){return Of&&Of.add(e),e}kf("toStack",_m);const wm=new lm("color"),Tm=new lm("float",sm.float),Mm=new lm("int",sm.ints),Sm=new lm("uint",sm.uint),Em=new lm("bool",sm.bool),Nm=new lm("vec2"),Cm=new lm("ivec2"),Rm=new lm("uvec2"),Bm=new lm("bvec2"),Pm=new lm("vec3"),qm=new lm("ivec3"),Dm=new lm("uvec3"),Im=new lm("bvec3"),Fm=new lm("vec4"),Om=new lm("ivec4"),Lm=new lm("uvec4"),km=new lm("bvec4"),Vm=new lm("mat2"),Um=new lm("mat3"),zm=new lm("mat4");kf("toColor",wm),kf("toFloat",Tm),kf("toInt",Mm),kf("toUint",Sm),kf("toBool",Em),kf("toVec2",Nm),kf("toIVec2",Cm),kf("toUVec2",Rm),kf("toBVec2",Bm),kf("toVec3",Pm),kf("toIVec3",qm),kf("toUVec3",Dm),kf("toBVec3",Im),kf("toVec4",Fm),kf("toIVec4",Om),kf("toUVec4",Lm),kf("toBVec4",km),kf("toMat2",Vm),kf("toMat3",Um),kf("toMat4",zm);const Gm=fm(Mf).setParameterLength(2),jm=(e,t)=>cm(new Sf(cm(e),t));kf("element",Gm),kf("convert",jm);kf("append",e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),_m(e)));class Hm extends Tf{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const Wm=(e,t)=>cm(new Hm(e,t)),Qm=(e,t)=>cm(new Hm(e,t,!0)),$m=mm(Hm,"vec4","DiffuseColor"),Xm=mm(Hm,"vec3","EmissiveColor"),Ym=mm(Hm,"float","Roughness"),Km=mm(Hm,"float","Metalness"),Zm=mm(Hm,"float","Clearcoat"),Jm=mm(Hm,"float","ClearcoatRoughness"),eg=mm(Hm,"vec3","Sheen"),tg=mm(Hm,"float","SheenRoughness"),rg=mm(Hm,"float","Iridescence"),ig=mm(Hm,"float","IridescenceIOR"),ng=mm(Hm,"float","IridescenceThickness"),sg=mm(Hm,"float","AlphaT"),ag=mm(Hm,"float","Anisotropy"),og=mm(Hm,"vec3","AnisotropyT"),lg=mm(Hm,"vec3","AnisotropyB"),Ag=mm(Hm,"color","SpecularColor"),ug=mm(Hm,"float","SpecularF90"),hg=mm(Hm,"float","Shininess"),cg=mm(Hm,"vec4","Output"),dg=mm(Hm,"float","dashSize"),pg=mm(Hm,"float","gapSize"),fg=mm(Hm,"float","pointWidth"),mg=mm(Hm,"float","IOR"),gg=mm(Hm,"float","Transmission"),yg=mm(Hm,"float","Thickness"),bg=mm(Hm,"float","AttenuationDistance"),xg=mm(Hm,"color","AttenuationColor"),vg=mm(Hm,"float","Dispersion");class _g extends Tf{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const wg=e=>new _g(e),Tg=(e,t=0)=>new _g(e,!0,t),Mg=Tg("frame"),Sg=Tg("render"),Eg=wg("object");class Ng extends qf{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Eg}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate(t=>{const i=e(t,r);void 0!==i&&(this.value=i)},t)}generate(e,t){const r=this.getNodeType(e),i=this.getUniformHash(e);let n=e.getNodeFromHash(i);void 0===n&&(e.setHashNode(this,i),n=this);const s=n.getInputType(e),a=e.getUniformFromNode(n,s,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Cg=(e,t)=>{const r=um(t||e),i=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return cm(new Ng(i,r))};class Rg extends Ef{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const Bg=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Rg(null,r.length,r)}else{const r=e[0],i=e[1];t=new Rg(r,i)}return cm(t)};kf("toArray",(e,t)=>Bg(Array(t).fill(e)));class Pg extends Ef{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return vf.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,i=e.getNodeProperties(this);i.sourceNode=r,i.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:i}=e.getNodeProperties(this),n=this.needsSplitAssign(e),s=r.getNodeType(e),a=r.build(e),o=i.build(e,s),l=i.getNodeType(e),A=e.getDataFromNode(this);let u;if(!0===A.initialized)"void"!==t&&(u=a);else if(n){const i=e.getVarFromNode(this,null,s),n=e.getPropertyName(i);e.addLineFlowCode(`${n} = ${o}`,this);const l=r.node,A=l.node.context({assign:!0}).build(e);for(let t=0;t<l.components.length;t++){const r=l.components[t];e.addLineFlowCode(`${A}.${r} = ${n}[ ${t} ]`,this)}"void"!==t&&(u=a)}else u=`${a} = ${o}`,"void"!==t&&"void"!==l||(e.addLineFlowCode(u,this),"void"!==t&&(u=a));return A.initialized=!0,e.format(u,s,t)}}const qg=fm(Pg).setParameterLength(2);kf("assign",qg);class Dg extends Ef{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],r=this.functionNode,i=r.getInputs(e),n=this.parameters,s=(t,r)=>{const i=r.type;let n;return n="pointer"===i?"&"+t.build(e):t.build(e,i),n};if(Array.isArray(n)){if(n.length>i.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=i.length;else if(n.length<i.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<i.length;)n.push(Tm(0));for(let e=0;e<n.length;e++)t.push(s(n[e],i[e]))}else for(const e of i){const r=n[e.name];void 0!==r?t.push(s(r,e)):(console.error(`THREE.TSL: Input '${e.name}' not found in 'Fn()'.`),t.push(s(Tm(0),e)))}return`${r.build(e,"property")}( ${t.join(", ")} )`}}const Ig=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?pm(t):dm(t[0]),cm(new Dg(cm(e),t)));kf("call",Ig);const Fg={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Og extends Ef{static get type(){return"OperatorNode"}constructor(e,t,r,...i){if(super(),i.length>0){let n=new Og(e,t,r);for(let t=0;t<i.length-1;t++)n=new Og(e,n,i[t]);t=n,r=i[i.length-1]}this.op=e,this.aNode=t,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(Fg[this.op],t)}getNodeType(e){const t=this.op,r=this.aNode,i=this.bNode,n=r.getNodeType(e),s=i?i.getNodeType(e):null;if("void"===n||"void"===s)return"void";if("%"===t)return n;if("~"===t||"&"===t||"|"===t||"^"===t||">>"===t||"<<"===t)return e.getIntegerType(n);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(n),e.getTypeLength(s));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(n)){if("float"===s)return n;if(e.isVector(s))return e.getVectorFromMatrix(n);if(e.isMatrix(s))return n}else if(e.isMatrix(s)){if("float"===n)return s;if(e.isVector(n))return e.getVectorFromMatrix(s)}return e.getTypeLength(s)>e.getTypeLength(n)?s:n}generate(e,t){const r=this.op,{aNode:i,bNode:n}=this,s=this.getNodeType(e);let a=null,o=null;"void"!==s?(a=i.getNodeType(e),o=n?n.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=s,o=e.changeComponentType(o,"uint")):"%"===r?(a=s,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=s):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=s:o=s):a=o=s;const l=i.build(e,a),A=n?n.build(e,o):null,u=e.getFunctionOperator(r);if("void"!==t){const i=e.renderer.coordinateSystem===Lu;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return i&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${A} )`,s,t):e.format(`( ${l} ${r} ${A} )`,s,t);if("%"===r)return e.isInteger(o)?e.format(`( ${l} % ${A} )`,s,t):e.format(`${this.getOperatorMethod(e,s)}( ${l}, ${A} )`,s,t);if("!"===r||"~"===r)return e.format(`(${r}${l})`,a,t);if(u)return e.format(`${u}( ${l}, ${A} )`,s,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${A} ${r} ${l} )`,s,t);if("float"===a&&e.isMatrix(o))return e.format(`${l} ${r} ${A}`,s,t);{let n=`( ${l} ${r} ${A} )`;return!i&&"bool"===s&&e.isVector(a)&&e.isVector(o)&&(n=`all${n}`),e.format(n,s,t)}}if("void"!==a)return u?e.format(`${u}( ${l}, ${A} )`,s,t):e.isMatrix(a)&&"float"===o?e.format(`${A} ${r} ${l}`,s,t):e.format(`${l} ${r} ${A}`,s,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Lg=fm(Og,"+").setParameterLength(2,1/0).setName("add"),kg=fm(Og,"-").setParameterLength(2,1/0).setName("sub"),Vg=fm(Og,"*").setParameterLength(2,1/0).setName("mul"),Ug=fm(Og,"/").setParameterLength(2,1/0).setName("div"),zg=fm(Og,"%").setParameterLength(2).setName("mod"),Gg=fm(Og,"==").setParameterLength(2).setName("equal"),jg=fm(Og,"!=").setParameterLength(2).setName("notEqual"),Hg=fm(Og,"<").setParameterLength(2).setName("lessThan"),Wg=fm(Og,">").setParameterLength(2).setName("greaterThan"),Qg=fm(Og,"<=").setParameterLength(2).setName("lessThanEqual"),$g=fm(Og,">=").setParameterLength(2).setName("greaterThanEqual"),Xg=fm(Og,"&&").setParameterLength(2,1/0).setName("and"),Yg=fm(Og,"||").setParameterLength(2,1/0).setName("or"),Kg=fm(Og,"!").setParameterLength(1).setName("not"),Zg=fm(Og,"^^").setParameterLength(2).setName("xor"),Jg=fm(Og,"&").setParameterLength(2).setName("bitAnd"),ey=fm(Og,"~").setParameterLength(2).setName("bitNot"),ty=fm(Og,"|").setParameterLength(2).setName("bitOr"),ry=fm(Og,"^").setParameterLength(2).setName("bitXor"),iy=fm(Og,"<<").setParameterLength(2).setName("shiftLeft"),ny=fm(Og,">>").setParameterLength(2).setName("shiftRight"),sy=ym(([e])=>(e.addAssign(1),e)),ay=ym(([e])=>(e.subAssign(1),e)),oy=ym(([e])=>{const t=Mm(e).toConst();return e.addAssign(1),t}),ly=ym(([e])=>{const t=Mm(e).toConst();return e.subAssign(1),t});kf("add",Lg),kf("sub",kg),kf("mul",Vg),kf("div",Ug),kf("mod",zg),kf("equal",Gg),kf("notEqual",jg),kf("lessThan",Hg),kf("greaterThan",Wg),kf("lessThanEqual",Qg),kf("greaterThanEqual",$g),kf("and",Xg),kf("or",Yg),kf("not",Kg),kf("xor",Zg),kf("bitAnd",Jg),kf("bitNot",ey),kf("bitOr",ty),kf("bitXor",ry),kf("shiftLeft",iy),kf("shiftRight",ny),kf("incrementBefore",sy),kf("decrementBefore",ay),kf("increment",oy),kf("decrement",ly);const Ay=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),zg(Mm(e),Mm(t)));kf("modInt",Ay);class uy extends Ef{static get type(){return"MathNode"}constructor(e,t,r=null,i=null){if(super(),(e===uy.MAX||e===uy.MIN)&&arguments.length>3){let n=new uy(e,t,r);for(let t=2;t<arguments.length-1;t++)n=new uy(e,n,arguments[t]);t=n,r=arguments[arguments.length-1],i=null}this.method=e,this.aNode=t,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),r=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(t)?0:e.getTypeLength(t),s=e.isMatrix(r)?0:e.getTypeLength(r),a=e.isMatrix(i)?0:e.getTypeLength(i);return n>s&&n>a?t:s>a?r:a>n?i:t}getNodeType(e){const t=this.method;return t===uy.LENGTH||t===uy.DISTANCE||t===uy.DOT?"float":t===uy.CROSS?"vec3":t===uy.ALL||t===uy.ANY?"bool":t===uy.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:i}=this;let n=null;if(i===uy.ONE_MINUS)n=kg(1,t);else if(i===uy.RECIPROCAL)n=Ug(1,t);else if(i===uy.DIFFERENCE)n=Iy(kg(t,r));else if(i===uy.TRANSFORM_DIRECTION){let i=t,s=r;e.isMatrix(i.getNodeType(e))?s=Fm(Pm(s),0):i=Fm(Pm(i),0);const a=Vg(i,s).xyz;n=Ey(a)}return null!==n?n:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const i=this.getNodeType(e),n=this.getInputType(e),s=this.aNode,a=this.bNode,o=this.cNode,l=e.renderer.coordinateSystem;if(r===uy.NEGATE)return e.format("( - "+s.build(e,n)+" )",i,t);{const A=[];return r===uy.CROSS?A.push(s.build(e,i),a.build(e,i)):l===Lu&&r===uy.STEP?A.push(s.build(e,1===e.getTypeLength(s.getNodeType(e))?"float":n),a.build(e,n)):l!==Lu||r!==uy.MIN&&r!==uy.MAX?r===uy.REFRACT?A.push(s.build(e,n),a.build(e,n),o.build(e,"float")):r===uy.MIX?A.push(s.build(e,n),a.build(e,n),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":n)):(l===ku&&r===uy.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==uy.DFDX&&r!==uy.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),A.push(s.build(e,n)),null!==a&&A.push(a.build(e,n)),null!==o&&A.push(o.build(e,n))):A.push(s.build(e,n),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":n)),e.format(`${e.getMethod(r,i)}( ${A.join(", ")} )`,i,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}uy.ALL="all",uy.ANY="any",uy.RADIANS="radians",uy.DEGREES="degrees",uy.EXP="exp",uy.EXP2="exp2",uy.LOG="log",uy.LOG2="log2",uy.SQRT="sqrt",uy.INVERSE_SQRT="inversesqrt",uy.FLOOR="floor",uy.CEIL="ceil",uy.NORMALIZE="normalize",uy.FRACT="fract",uy.SIN="sin",uy.COS="cos",uy.TAN="tan",uy.ASIN="asin",uy.ACOS="acos",uy.ATAN="atan",uy.ABS="abs",uy.SIGN="sign",uy.LENGTH="length",uy.NEGATE="negate",uy.ONE_MINUS="oneMinus",uy.DFDX="dFdx",uy.DFDY="dFdy",uy.ROUND="round",uy.RECIPROCAL="reciprocal",uy.TRUNC="trunc",uy.FWIDTH="fwidth",uy.TRANSPOSE="transpose",uy.BITCAST="bitcast",uy.EQUALS="equals",uy.MIN="min",uy.MAX="max",uy.STEP="step",uy.REFLECT="reflect",uy.DISTANCE="distance",uy.DIFFERENCE="difference",uy.DOT="dot",uy.CROSS="cross",uy.POW="pow",uy.TRANSFORM_DIRECTION="transformDirection",uy.MIX="mix",uy.CLAMP="clamp",uy.REFRACT="refract",uy.SMOOTHSTEP="smoothstep",uy.FACEFORWARD="faceforward";const hy=Tm(1e-6),cy=Tm(1e6),dy=Tm(Math.PI),py=Tm(2*Math.PI),fy=fm(uy,uy.ALL).setParameterLength(1),my=fm(uy,uy.ANY).setParameterLength(1),gy=fm(uy,uy.RADIANS).setParameterLength(1),yy=fm(uy,uy.DEGREES).setParameterLength(1),by=fm(uy,uy.EXP).setParameterLength(1),xy=fm(uy,uy.EXP2).setParameterLength(1),vy=fm(uy,uy.LOG).setParameterLength(1),_y=fm(uy,uy.LOG2).setParameterLength(1),wy=fm(uy,uy.SQRT).setParameterLength(1),Ty=fm(uy,uy.INVERSE_SQRT).setParameterLength(1),My=fm(uy,uy.FLOOR).setParameterLength(1),Sy=fm(uy,uy.CEIL).setParameterLength(1),Ey=fm(uy,uy.NORMALIZE).setParameterLength(1),Ny=fm(uy,uy.FRACT).setParameterLength(1),Cy=fm(uy,uy.SIN).setParameterLength(1),Ry=fm(uy,uy.COS).setParameterLength(1),By=fm(uy,uy.TAN).setParameterLength(1),Py=fm(uy,uy.ASIN).setParameterLength(1),qy=fm(uy,uy.ACOS).setParameterLength(1),Dy=fm(uy,uy.ATAN).setParameterLength(1,2),Iy=fm(uy,uy.ABS).setParameterLength(1),Fy=fm(uy,uy.SIGN).setParameterLength(1),Oy=fm(uy,uy.LENGTH).setParameterLength(1),Ly=fm(uy,uy.NEGATE).setParameterLength(1),ky=fm(uy,uy.ONE_MINUS).setParameterLength(1),Vy=fm(uy,uy.DFDX).setParameterLength(1),Uy=fm(uy,uy.DFDY).setParameterLength(1),zy=fm(uy,uy.ROUND).setParameterLength(1),Gy=fm(uy,uy.RECIPROCAL).setParameterLength(1),jy=fm(uy,uy.TRUNC).setParameterLength(1),Hy=fm(uy,uy.FWIDTH).setParameterLength(1),Wy=fm(uy,uy.TRANSPOSE).setParameterLength(1),Qy=fm(uy,uy.BITCAST).setParameterLength(2),$y=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),Gg(e,t)),Xy=fm(uy,uy.MIN).setParameterLength(2,1/0),Yy=fm(uy,uy.MAX).setParameterLength(2,1/0),Ky=fm(uy,uy.STEP).setParameterLength(2),Zy=fm(uy,uy.REFLECT).setParameterLength(2),Jy=fm(uy,uy.DISTANCE).setParameterLength(2),eb=fm(uy,uy.DIFFERENCE).setParameterLength(2),tb=fm(uy,uy.DOT).setParameterLength(2),rb=fm(uy,uy.CROSS).setParameterLength(2),ib=fm(uy,uy.POW).setParameterLength(2),nb=fm(uy,uy.POW,2).setParameterLength(1),sb=fm(uy,uy.POW,3).setParameterLength(1),ab=fm(uy,uy.POW,4).setParameterLength(1),ob=fm(uy,uy.TRANSFORM_DIRECTION).setParameterLength(2),lb=e=>Vg(Fy(e),ib(Iy(e),1/3)),Ab=e=>tb(e,e),ub=fm(uy,uy.MIX).setParameterLength(3),hb=(e,t=0,r=1)=>cm(new uy(uy.CLAMP,cm(e),cm(t),cm(r))),cb=e=>hb(e),db=fm(uy,uy.REFRACT).setParameterLength(3),pb=fm(uy,uy.SMOOTHSTEP).setParameterLength(3),fb=fm(uy,uy.FACEFORWARD).setParameterLength(3),mb=ym(([e])=>{const t=tb(e.xy,Nm(12.9898,78.233)),r=zg(t,dy);return Ny(Cy(r).mul(43758.5453))}),gb=(e,t,r)=>ub(t,r,e),yb=(e,t,r)=>pb(t,r,e),bb=(e,t)=>Ky(t,e),xb=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),Dy(e,t)),vb=fb,_b=Ty;kf("all",fy),kf("any",my),kf("equals",$y),kf("radians",gy),kf("degrees",yy),kf("exp",by),kf("exp2",xy),kf("log",vy),kf("log2",_y),kf("sqrt",wy),kf("inverseSqrt",Ty),kf("floor",My),kf("ceil",Sy),kf("normalize",Ey),kf("fract",Ny),kf("sin",Cy),kf("cos",Ry),kf("tan",By),kf("asin",Py),kf("acos",qy),kf("atan",Dy),kf("abs",Iy),kf("sign",Fy),kf("length",Oy),kf("lengthSq",Ab),kf("negate",Ly),kf("oneMinus",ky),kf("dFdx",Vy),kf("dFdy",Uy),kf("round",zy),kf("reciprocal",Gy),kf("trunc",jy),kf("fwidth",Hy),kf("atan2",xb),kf("min",Xy),kf("max",Yy),kf("step",bb),kf("reflect",Zy),kf("distance",Jy),kf("dot",tb),kf("cross",rb),kf("pow",ib),kf("pow2",nb),kf("pow3",sb),kf("pow4",ab),kf("transformDirection",ob),kf("mix",gb),kf("clamp",hb),kf("refract",db),kf("smoothstep",yb),kf("faceForward",fb),kf("difference",eb),kf("saturate",cb),kf("cbrt",lb),kf("transpose",Wy),kf("rand",mb);class wb extends Tf{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const i=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(i))return t}return i}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,n=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=n,null!==i&&(e.getDataFromNode(i).parentNodeBlock=n);const s=e.getNodeProperties(this);s.condNode=t,s.ifNode=r.context({nodeBlock:r}),s.elseNode=i?i.context({nodeBlock:i}):null}generate(e,t){const r=this.getNodeType(e),i=e.getDataFromNode(this);if(void 0!==i.nodeProperty)return i.nodeProperty;const{condNode:n,ifNode:s,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,l="void"!==t,A=l?Wm(r).build(e):"";i.nodeProperty=A;const u=n.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let h=s.build(e,r);if(h&&(l?h=A+" = "+h+";":(h="return "+h+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),h="// "+h))),e.removeFlowTab().addFlowCode(e.tab+"\t"+h+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(l?t=A+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(A,r,t)}}const Tb=fm(wb).setParameterLength(2,3);kf("select",Tb);class Mb extends Tf{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e,t);return e.setContext(r),i}}const Sb=fm(Mb).setParameterLength(1,2),Eb=(e,t)=>Sb(e,{label:t});kf("context",Sb),kf("label",Eb);class Nb extends Tf{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:i}=this,{renderer:n}=e,s=!0===n.backend.isWebGPUBackend;let a=!1,o=!1;i&&(a=e.isDeterministic(t),o=s?i:a);const l=e.getVectorType(this.getNodeType(e)),A=t.build(e,l),u=e.getVarFromNode(this,r,l,void 0,o),h=e.getPropertyName(u);let c=h;if(o)if(s)c=a?`const ${h}`:`let ${h}`;else{const r=e.getArrayCount(t);c=`const ${e.getVar(u.type,h,r)}`}return e.addLineFlowCode(`${c} = ${A}`,this),h}}const Cb=fm(Nb),Rb=(e,t=null)=>Cb(e,t).toStack(),Bb=(e,t=null)=>Cb(e,t,!0).toStack();kf("toVar",Rb),kf("toConst",Bb);const Pb=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),Cb(e));kf("temp",Pb);class qb extends Tf{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const Db=(e,t,r=null)=>cm(new qb(cm(e),t,r));class Ib extends Tf{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const i=this.name,n=this.getNodeType(e),s=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,i,n,s,a),t.node=Db(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(ff.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(ff.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),i=this.setupVarying(e);if(void 0===r[t]){const n=this.getNodeType(e),s=e.getPropertyName(i,ff.VERTEX);e.flowNodeFromShaderStage(ff.VERTEX,r.node,n,s),r[t]=s}return e.getPropertyName(i)}}const Fb=fm(Ib).setParameterLength(1,2),Ob=e=>Fb(e);kf("toVarying",Fb),kf("toVertexStage",Ob),kf("varying",(...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Fb(...e))),kf("vertexStage",(...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Fb(...e)));const Lb=ym(([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),i=e.lessThanEqual(.04045);return ub(t,r,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),kb=ym(([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),i=e.lessThanEqual(.0031308);return ub(t,r,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Vb="WorkingColorSpace";class Ub extends Ef{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===Vb?ch.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),i=this.resolveColorSpace(e,this.target);let n=t;return!1!==ch.enabled&&r!==i&&r&&i?(ch.getTransfer(r)===Su&&(n=Fm(Lb(n.rgb),n.a)),ch.getPrimaries(r)!==ch.getPrimaries(i)&&(n=Fm(Um(ch._getMatrix(new ih,r,i)).mul(n.rgb),n.a)),ch.getTransfer(i)===Su&&(n=Fm(kb(n.rgb),n.a)),n):n}}const zb=(e,t)=>cm(new Ub(cm(e),Vb,t)),Gb=(e,t)=>cm(new Ub(cm(e),t,Vb));kf("workingToColorSpace",zb),kf("colorSpaceToWorking",Gb);let jb=class extends Mf{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,r,i)}};class Hb extends Tf{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=mf.OBJECT}setGroup(e){return this.group=e,this}element(e){return cm(new jb(this,cm(e)))}setNodeType(e){const t=Cg(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;e<t.length;e++)r=r[t[e]];return r}updateReference(e){return this.reference=null!==this.object?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}class Wb extends Hb{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(Sg)}updateReference(e){return this.reference=null!==this.renderer?this.renderer:e.renderer,this.reference}}const Qb=(e,t,r=null)=>cm(new Wb(e,t,r));class $b extends Ef{static get type(){return"ToneMappingNode"}constructor(e,t=Yb,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Jp(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(0===r)return t;let i=null;const n=e.renderer.library.getToneMappingFunction(r);return null!==n?i=Fm(n(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=t),i}}const Xb=(e,t,r)=>cm(new $b(e,cm(t),cm(r))),Yb=Qb("toneMappingExposure","float");kf("toneMapping",(e,t,r)=>Xb(t,r,e));class Kb extends qf{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=i,this.usage=Fu,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,i=e.getTypeLength(t),n=this.bufferStride||i,s=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new Wd(r,n),o=new $d(a,i,s);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),i=e.getPropertyName(r);let n=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=i,n=i;else{n=Fb(this).build(e,t)}return n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Zb=(e,t=null,r=0,i=0)=>cm(new Kb(e,t,r,i)),Jb=(e,t=null,r=0,i=0)=>Zb(e,t,r,i).setUsage(Ou),ex=(e,t=null,r=0,i=0)=>Zb(e,t,r,i).setInstanced(!0),tx=(e,t=null,r=0,i=0)=>Jb(e,t,r,i).setInstanced(!0);kf("toAttribute",e=>Zb(e.value));class rx extends Tf{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=mf.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;e<t.length;e++)r*=t[e];this.dispatchCount=Math.ceil(e/r)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){e.getNodeProperties(this).outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if("compute"===r){const t=this.computeNode.build(e,"void");""!==t&&e.addLineFlowCode(t,this)}else{const r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}const ix=(e,t,r)=>cm(new rx(cm(e),t,r));kf("compute",ix);class nx extends Tf{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const i=this.node.getNodeType(e);return e.setCache(t),i}build(e,...t){const r=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const n=this.node.build(e,...t);return e.setCache(r),n}}const sx=(e,t)=>cm(new nx(cm(e),t));kf("cache",sx);class ax extends Tf{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const ox=fm(ax).setParameterLength(2);kf("bypass",ox);class lx extends Tf{static get type(){return"RemapNode"}constructor(e,t,r,i=Tm(0),n=Tm(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=i,this.outHighNode=n,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:i,outHighNode:n,doClamp:s}=this;let a=e.sub(t).div(r.sub(t));return!0===s&&(a=a.clamp()),a.mul(n.sub(i)).add(i)}}const Ax=fm(lx,null,null,{doClamp:!1}).setParameterLength(3,5),ux=fm(lx).setParameterLength(3,5);kf("remap",Ax),kf("remapClamp",ux);class hx extends Tf{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),i=this.snippet;if("void"!==r)return e.format(i,r,t);e.addLineFlowCode(i,this)}}const cx=fm(hx).setParameterLength(1,2),dx=e=>(e?Tb(e,cx("discard")):cx("discard")).toStack();kf("discard",dx);class px extends Ef{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||0,i=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||_u;return 0!==r&&(t=t.toneMapping(r)),i!==_u&&i!==ch.workingColorSpace&&(t=t.workingToColorSpace(i)),t}}const fx=(e,t=null,r=null)=>cm(new px(cm(e),t,r));kf("renderOutput",fx);class mx extends Ef{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),i="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(i.length);let s="";return s+="// #"+i+"#\n",s+=e.flow.code.replace(/^\t/gm,"")+"\n",s+="/* ... */ "+r+" /* ... */\n",s+="// #"+n+"#\n",null!==t?t(e,s):console.log(s),r}}const gx=(e,t=null)=>cm(new mx(cm(e),t));kf("debug",gx);class yx extends Tf{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const i=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(i)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const i=e.geometry.getAttribute(t),n=e.getTypeFromAttribute(i),s=e.getAttribute(t,n);if("vertex"===e.shaderStage)return e.format(s.name,n,r);return Fb(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const bx=(e,t=null)=>cm(new yx(e,t)),xx=(e=0)=>bx("uv"+(e>0?e:""),"vec2");class vx extends Tf{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),i=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${i} )`,this.getNodeType(e),t)}}const _x=fm(vx).setParameterLength(1,2);class wx extends Ng{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=mf.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Tx=fm(wx).setParameterLength(1),Mx=new _h;class Sx extends Ng{static get type(){return"TextureNode"}constructor(e=Mx,t=null,r=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=mf.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===zA?"uvec4":this.value.type===UA?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return xx(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Cg(this.value.matrix)),this._matrixUniform.mul(Pm(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?mf.OBJECT:mf.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(Mm(_x(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let i=this.uvNode;null!==i&&!0!==e.context.forceUVContext||!e.context.getUV||(i=e.context.getUV(this,e)),i||(i=this.getDefaultUV()),!0===this.updateMatrix&&(i=this.getTransformedUV(i)),i=this.setupUV(e,i);let n=this.levelNode;null===n&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),t.uvNode=i,t.levelNode=n,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,i,n,s,a,o){const l=this.value;let A;return A=i?e.generateTextureLevel(l,t,r,i,s):n?e.generateTextureBias(l,t,r,n,s):o?e.generateTextureGrad(l,t,r,o,s):a?e.generateTextureCompare(l,t,r,a,s):!1===this.sampler?e.generateTextureLoad(l,t,r,s):e.generateTexture(l,t,r,s),A}generate(e,t){const r=this.value,i=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(t))return n+"_sampler";if(e.isReference(t))return n;{const s=e.getDataFromNode(this);let a=s.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:l,depthNode:A,gradNode:u}=i,h=this.generateUV(e,t),c=r?r.build(e,"float"):null,d=o?o.build(e,"float"):null,p=A?A.build(e,"int"):null,f=l?l.build(e,"float"):null,m=u?[u[0].build(e,"vec2"),u[1].build(e,"vec2")]:null,g=e.getVarFromNode(this);a=e.getPropertyName(g);const y=this.generateSnippet(e,n,h,c,d,p,f,m);e.addLineFlowCode(`${a} = ${y}`,this),s.snippet=y,s.propertyName=a}let o=a;const l=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=Gb(cx(o,l),r.colorSpace).setup(e).build(e,l)),e.format(o,l,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=cm(e),t.referenceNode=this.getSelf(),cm(t)}blur(e){const t=this.clone();t.biasNode=cm(e).mul(Tx(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===BA||r.magFilter===BA)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),cm(t)}level(e){const t=this.clone();return t.levelNode=cm(e),t.referenceNode=this.getSelf(),cm(t)}size(e){return _x(this,e)}bias(e){const t=this.clone();return t.biasNode=cm(e),t.referenceNode=this.getSelf(),cm(t)}compare(e){const t=this.clone();return t.compareNode=cm(e),t.referenceNode=this.getSelf(),cm(t)}grad(e,t){const r=this.clone();return r.gradNode=[cm(e),cm(t)],r.referenceNode=this.getSelf(),cm(r)}depth(e){const t=this.clone();return t.depthNode=cm(e),t.referenceNode=this.getSelf(),cm(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Ex=fm(Sx).setParameterLength(1,4).setName("texture"),Nx=(e=Mx,t=null,r=null,i=null)=>{let n;return e&&!0===e.isTextureNode?(n=cm(e.clone()),n.referenceNode=e.getSelf(),null!==t&&(n.uvNode=cm(t)),null!==r&&(n.levelNode=cm(r)),null!==i&&(n.biasNode=cm(i))):n=Ex(e,t,r,i),n},Cx=(...e)=>Nx(...e).setSampler(!1);class Rx extends Ng{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Bx=(e,t,r)=>cm(new Rx(e,t,r));class Px extends Mf{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),i=this.node.getPaddedType();return e.format(t,i,r)}}class qx extends Rx{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?uf(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=mf.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;r<e.length;r++){t[4*r]=e[r]}else if("color"===r)for(let r=0;r<e.length;r++){const i=4*r,n=e[r];t[i]=n.r,t[i+1]=n.g,t[i+2]=n.b||0}else if("mat2"===r)for(let r=0;r<e.length;r++){const i=4*r,n=e[r];t[i]=n.elements[0],t[i+1]=n.elements[1],t[i+2]=n.elements[2],t[i+3]=n.elements[3]}else if("mat3"===r)for(let r=0;r<e.length;r++){const i=16*r,n=e[r];t[i]=n.elements[0],t[i+1]=n.elements[1],t[i+2]=n.elements[2],t[i+4]=n.elements[3],t[i+5]=n.elements[4],t[i+6]=n.elements[5],t[i+8]=n.elements[6],t[i+9]=n.elements[7],t[i+10]=n.elements[8],t[i+15]=1}else if("mat4"===r)for(let r=0;r<e.length;r++){const i=16*r,n=e[r];for(let e=0;e<n.elements.length;e++)t[i+e]=n.elements[e]}else for(let r=0;r<e.length;r++){const i=4*r,n=e[r];t[i]=n.x,t[i+1]=n.y,t[i+2]=n.z||0,t[i+3]=n.w||0}}setup(e){const t=this.array.length,r=this.elementType;let i=Float32Array;const n=this.paddedType,s=e.getTypeLength(n);return"i"===r.charAt(0)&&(i=Int32Array),"u"===r.charAt(0)&&(i=Uint32Array),this.value=new i(t*s),this.bufferCount=t,this.bufferType=n,super.setup(e)}element(e){return cm(new Px(this,cm(e)))}}const Dx=(e,t)=>cm(new qx(e,t));const Ix=fm(class extends Tf{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),Fx=Cg(0,"uint").label("u_cameraIndex").setGroup(Tg("cameraIndex")).toVarying("v_cameraIndex"),Ox=Cg("float").label("cameraNear").setGroup(Sg).onRenderUpdate(({camera:e})=>e.near),Lx=Cg("float").label("cameraFar").setGroup(Sg).onRenderUpdate(({camera:e})=>e.far),kx=ym(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=Dx(r).setGroup(Sg).label("cameraProjectionMatrices").element(e.isMultiViewCamera?Ix("gl_ViewID_OVR"):Fx).toVar("cameraProjectionMatrix")}else t=Cg("mat4").label("cameraProjectionMatrix").setGroup(Sg).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),Vx=ym(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=Dx(r).setGroup(Sg).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?Ix("gl_ViewID_OVR"):Fx).toVar("cameraProjectionMatrixInverse")}else t=Cg("mat4").label("cameraProjectionMatrixInverse").setGroup(Sg).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Ux=ym(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=Dx(r).setGroup(Sg).label("cameraViewMatrices").element(e.isMultiViewCamera?Ix("gl_ViewID_OVR"):Fx).toVar("cameraViewMatrix")}else t=Cg("mat4").label("cameraViewMatrix").setGroup(Sg).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),zx=Cg("mat4").label("cameraWorldMatrix").setGroup(Sg).onRenderUpdate(({camera:e})=>e.matrixWorld),Gx=Cg("mat3").label("cameraNormalMatrix").setGroup(Sg).onRenderUpdate(({camera:e})=>e.normalMatrix),jx=Cg(new eh).label("cameraPosition").setGroup(Sg).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),Hx=new Hh;class Wx extends Tf{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=mf.OBJECT,this.uniformNode=new Ng(null)}getNodeType(){const e=this.scope;return e===Wx.WORLD_MATRIX?"mat4":e===Wx.POSITION||e===Wx.VIEW_POSITION||e===Wx.DIRECTION||e===Wx.SCALE?"vec3":e===Wx.RADIUS?"float":void 0}update(e){const t=this.object3d,r=this.uniformNode,i=this.scope;if(i===Wx.WORLD_MATRIX)r.value=t.matrixWorld;else if(i===Wx.POSITION)r.value=r.value||new eh,r.value.setFromMatrixPosition(t.matrixWorld);else if(i===Wx.SCALE)r.value=r.value||new eh,r.value.setFromMatrixScale(t.matrixWorld);else if(i===Wx.DIRECTION)r.value=r.value||new eh,t.getWorldDirection(r.value);else if(i===Wx.VIEW_POSITION){const i=e.camera;r.value=r.value||new eh,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}else if(i===Wx.RADIUS){const i=e.object.geometry;null===i.boundingSphere&&i.computeBoundingSphere(),Hx.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),r.value=Hx.radius}}generate(e){const t=this.scope;return t===Wx.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Wx.POSITION||t===Wx.VIEW_POSITION||t===Wx.DIRECTION||t===Wx.SCALE?this.uniformNode.nodeType="vec3":t===Wx.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Wx.WORLD_MATRIX="worldMatrix",Wx.POSITION="position",Wx.SCALE="scale",Wx.VIEW_POSITION="viewPosition",Wx.DIRECTION="direction",Wx.RADIUS="radius";const Qx=fm(Wx,Wx.DIRECTION).setParameterLength(1),$x=fm(Wx,Wx.WORLD_MATRIX).setParameterLength(1),Xx=fm(Wx,Wx.POSITION).setParameterLength(1),Yx=fm(Wx,Wx.SCALE).setParameterLength(1),Kx=fm(Wx,Wx.VIEW_POSITION).setParameterLength(1),Zx=fm(Wx,Wx.RADIUS).setParameterLength(1);class Jx extends Wx{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const ev=mm(Jx,Jx.DIRECTION),tv=mm(Jx,Jx.WORLD_MATRIX),rv=mm(Jx,Jx.POSITION),iv=mm(Jx,Jx.SCALE),nv=mm(Jx,Jx.VIEW_POSITION),sv=mm(Jx,Jx.RADIUS),av=Cg(new ih).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),ov=Cg(new ec).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),lv=ym(e=>e.renderer.overrideNodes.modelViewMatrix||Av).once()().toVar("modelViewMatrix"),Av=Ux.mul(tv),uv=ym(e=>(e.context.isHighPrecisionModelViewMatrix=!0,Cg("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),hv=ym(e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Cg("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),cv=bx("position","vec3"),dv=cv.toVarying("positionLocal"),pv=cv.toVarying("positionPrevious"),fv=ym(e=>tv.mul(dv).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),mv=ym(()=>dv.transformDirection(tv).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),gv=ym(e=>e.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),yv=gv.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class bv extends Tf{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";const{renderer:t,material:r}=e;return t.coordinateSystem===Lu&&1===r.side?"false":e.getFrontFacing()}}const xv=mm(bv),vv=Tm(xv).mul(2).sub(1),_v=ym(([e],{material:t})=>{const r=t.side;return 1===r?e=e.mul(-1):2===r&&(e=e.mul(vv)),e}),wv=bx("normal","vec3"),Tv=ym(e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),Pm(0,1,0)):wv,"vec3").once()().toVar("normalLocal"),Mv=gv.dFdx().cross(gv.dFdy()).normalize().toVar("normalFlat"),Sv=ym(e=>{let t;return t=!0===e.material.flatShading?Mv:Pv(Tv).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),Ev=ym(e=>{let t=Sv.transformDirection(Ux);return!0!==e.material.flatShading&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Nv=ym(({subBuildFn:e,material:t,context:r})=>{let i;return"NORMAL"===e||"VERTEX"===e?(i=Sv,!0!==t.flatShading&&(i=_v(i))):i=r.setupNormal().context({getUV:null}),i},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Cv=Nv.transformDirection(Ux).toVar("normalWorld"),Rv=ym(({subBuildFn:e,context:t})=>{let r;return r="NORMAL"===e||"VERTEX"===e?Nv:t.setupClearcoatNormal().context({getUV:null}),r},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Bv=ym(([e,t=tv])=>{const r=Um(t),i=e.div(Pm(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(i).xyz}),Pv=ym(([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const i=av.mul(e);return Ux.transformDirection(i)}),qv=ym(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Nv)).once(["NORMAL","VERTEX"])(),Dv=ym(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Cv)).once(["NORMAL","VERTEX"])(),Iv=ym(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Rv)).once(["NORMAL","VERTEX"])(),Fv=new uc,Ov=new ec,Lv=Cg(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),kv=Cg(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Vv=Cg(new ec).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(Fv.copy(r),Ov.makeRotationFromEuler(Fv)):Ov.identity(),Ov}),Uv=yv.negate().reflect(Nv),zv=yv.negate().refract(Nv,Lv),Gv=Uv.transformDirection(Ux).toVar("reflectVector"),jv=zv.transformDirection(Ux).toVar("reflectVector"),Hv=new Vd;class Wv extends Sx{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,i=null){super(e,t,r,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===SA?Gv:e.mapping===EA?jv:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Pm(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==ku&&r.isRenderTargetTexture||(t=Pm(t.x.negate(),t.yz)),Vv.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const Qv=fm(Wv).setParameterLength(1,4).setName("cubeTexture"),$v=(e=Hv,t=null,r=null,i=null)=>{let n;return e&&!0===e.isCubeTextureNode?(n=cm(e.clone()),n.referenceNode=e.getSelf(),null!==t&&(n.uvNode=cm(t)),null!==r&&(n.levelNode=cm(r)),null!==i&&(n.biasNode=cm(i))):n=Qv(e,t,r,i),n};class Xv extends Mf{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,r,i)}}class Yv extends Tf{static get type(){return"ReferenceNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=mf.OBJECT}element(e){return cm(new Xv(this,cm(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?Bx(null,e,this.count):Array.isArray(this.getValueFromReference())?Dx(null,e):"texture"===e?Nx(null):"cubeTexture"===e?$v(null):Cg(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;e<t.length;e++)r=r[t[e]];return r}updateReference(e){return this.reference=null!==this.object?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const Kv=(e,t,r)=>cm(new Yv(e,t,r)),Zv=(e,t,r,i)=>cm(new Yv(e,t,i,r));class Jv extends Yv{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const e_=(e,t,r=null)=>cm(new Jv(e,t,r)),t_=xx(),r_=gv.dFdx(),i_=gv.dFdy(),n_=t_.dFdx(),s_=t_.dFdy(),a_=Nv,o_=i_.cross(a_),l_=a_.cross(r_),A_=o_.mul(n_.x).add(l_.mul(s_.x)),u_=o_.mul(n_.y).add(l_.mul(s_.y)),h_=A_.dot(A_).max(u_.dot(u_)),c_=h_.equal(0).select(0,h_.inverseSqrt()),d_=A_.mul(c_).toVar("tangentViewFrame"),p_=u_.mul(c_).toVar("bitangentViewFrame"),f_=ym(e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),bx("tangent","vec4")))(),m_=f_.xyz.toVar("tangentLocal"),g_=ym(({subBuildFn:e,geometry:t,material:r})=>{let i;return i="VERTEX"===e||t.hasAttribute("tangent")?lv.mul(Fm(m_,0)).xyz.toVarying("v_tangentView").normalize():d_,!0!==r.flatShading&&(i=_v(i)),i},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),y_=g_.transformDirection(Ux).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),b_=ym(([e,t],{subBuildFn:r,material:i})=>{let n=e.mul(f_.w).xyz;return"NORMAL"===r&&!0!==i.flatShading&&(n=n.toVarying(t)),n}).once(["NORMAL"]),x_=b_(wv.cross(f_),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),v_=b_(Tv.cross(m_),"v_bitangentLocal").normalize().toVar("bitangentLocal"),__=ym(({subBuildFn:e,geometry:t,material:r})=>{let i;return i="VERTEX"===e||t.hasAttribute("tangent")?b_(Nv.cross(g_),"v_bitangentView").normalize():p_,!0!==r.flatShading&&(i=_v(i)),i},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),w_=b_(Cv.cross(y_),"v_bitangentWorld").normalize().toVar("bitangentWorld"),T_=Um(g_,__,Nv).toVar("TBNViewMatrix"),M_=yv.mul(T_),S_=ym(()=>{let e=lg.cross(yv);return e=e.cross(lg).normalize(),e=ub(e,Nv,ag.mul(Ym.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()();class E_ extends Ef{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=0}setup({material:e}){const{normalMapType:t,scaleNode:r}=this;let i=this.node.mul(2).sub(1);if(null!==r){let t=r;!0===e.flatShading&&(t=_v(t)),i=Pm(i.xy.mul(t),i.z)}let n=null;return 1===t?n=Pv(i):0===t?n=T_.mul(i).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),n=Nv),n}}const N_=fm(E_).setParameterLength(1,2),C_=ym(({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||xx()),forceUVContext:!0}),i=Tm(r(e=>e));return Nm(Tm(r(e=>e.add(e.dFdx()))).sub(i),Tm(r(e=>e.add(e.dFdy()))).sub(i)).mul(t)}),R_=ym(e=>{const{surf_pos:t,surf_norm:r,dHdxy:i}=e,n=t.dFdx().normalize(),s=r,a=t.dFdy().normalize().cross(s),o=s.cross(n),l=n.dot(a).mul(vv),A=l.sign().mul(i.x.mul(a).add(i.y.mul(o)));return l.abs().mul(r).sub(A).normalize()});class B_ extends Ef{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=C_({textureNode:this.textureNode,bumpScale:e});return R_({surf_pos:gv,surf_norm:Nv,dHdxy:t})}}const P_=fm(B_).setParameterLength(1,2),q_=new Map;class D_ extends Tf{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=q_.get(e);return void 0===r&&(r=e_(e,t),q_.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let i=null;if(r===D_.COLOR){const e=void 0!==t.color?this.getColor(r):Pm();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===D_.OPACITY){const e=this.getFloat(r);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===D_.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Tm(1);else if(r===D_.SPECULAR_INTENSITY){const e=this.getFloat(r);i=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===D_.SPECULAR_COLOR){const e=this.getColor(r);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===D_.ROUGHNESS){const e=this.getFloat(r);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===D_.METALNESS){const e=this.getFloat(r);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===D_.EMISSIVE){const e=this.getFloat("emissiveIntensity"),n=this.getColor(r).mul(e);i=t.emissiveMap&&!0===t.emissiveMap.isTexture?n.mul(this.getTexture(r)):n}else if(r===D_.NORMAL)t.normalMap?(i=N_(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=t.normalMapType):i=t.bumpMap?P_(this.getTexture("bump").r,this.getFloat("bumpScale")):Nv;else if(r===D_.CLEARCOAT){const e=this.getFloat(r);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===D_.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===D_.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?N_(this.getTexture(r),this.getCache(r+"Scale","vec2")):Nv;else if(r===D_.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));i=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===D_.SHEEN_ROUGHNESS){const e=this.getFloat(r);i=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===D_.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);i=Vm(yw.x,yw.y,yw.y.negate(),yw.x).mul(e.rg.mul(2).sub(Nm(1)).normalize().mul(e.b))}else i=yw;else if(r===D_.IRIDESCENCE_THICKNESS){const e=Kv("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const n=Kv("0","float",t.iridescenceThicknessRange);i=e.sub(n).mul(this.getTexture(r).g).add(n)}else i=e}else if(r===D_.TRANSMISSION){const e=this.getFloat(r);i=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===D_.THICKNESS){const e=this.getFloat(r);i=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===D_.IOR)i=this.getFloat(r);else if(r===D_.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===D_.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===D_.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(r):Tm(0);else{const t=this.getNodeType(e);i=this.getCache(r,t)}return i}}D_.ALPHA_TEST="alphaTest",D_.COLOR="color",D_.OPACITY="opacity",D_.SHININESS="shininess",D_.SPECULAR="specular",D_.SPECULAR_STRENGTH="specularStrength",D_.SPECULAR_INTENSITY="specularIntensity",D_.SPECULAR_COLOR="specularColor",D_.REFLECTIVITY="reflectivity",D_.ROUGHNESS="roughness",D_.METALNESS="metalness",D_.NORMAL="normal",D_.CLEARCOAT="clearcoat",D_.CLEARCOAT_ROUGHNESS="clearcoatRoughness",D_.CLEARCOAT_NORMAL="clearcoatNormal",D_.EMISSIVE="emissive",D_.ROTATION="rotation",D_.SHEEN="sheen",D_.SHEEN_ROUGHNESS="sheenRoughness",D_.ANISOTROPY="anisotropy",D_.IRIDESCENCE="iridescence",D_.IRIDESCENCE_IOR="iridescenceIOR",D_.IRIDESCENCE_THICKNESS="iridescenceThickness",D_.IOR="ior",D_.TRANSMISSION="transmission",D_.THICKNESS="thickness",D_.ATTENUATION_DISTANCE="attenuationDistance",D_.ATTENUATION_COLOR="attenuationColor",D_.LINE_SCALE="scale",D_.LINE_DASH_SIZE="dashSize",D_.LINE_GAP_SIZE="gapSize",D_.LINE_WIDTH="linewidth",D_.LINE_DASH_OFFSET="dashOffset",D_.POINT_SIZE="size",D_.DISPERSION="dispersion",D_.LIGHT_MAP="light",D_.AO="ao";const I_=mm(D_,D_.ALPHA_TEST),F_=mm(D_,D_.COLOR),O_=mm(D_,D_.SHININESS),L_=mm(D_,D_.EMISSIVE),k_=mm(D_,D_.OPACITY),V_=mm(D_,D_.SPECULAR),U_=mm(D_,D_.SPECULAR_INTENSITY),z_=mm(D_,D_.SPECULAR_COLOR),G_=mm(D_,D_.SPECULAR_STRENGTH),j_=mm(D_,D_.REFLECTIVITY),H_=mm(D_,D_.ROUGHNESS),W_=mm(D_,D_.METALNESS),Q_=mm(D_,D_.NORMAL),$_=mm(D_,D_.CLEARCOAT),X_=mm(D_,D_.CLEARCOAT_ROUGHNESS),Y_=mm(D_,D_.CLEARCOAT_NORMAL),K_=mm(D_,D_.ROTATION),Z_=mm(D_,D_.SHEEN),J_=mm(D_,D_.SHEEN_ROUGHNESS),ew=mm(D_,D_.ANISOTROPY),tw=mm(D_,D_.IRIDESCENCE),rw=mm(D_,D_.IRIDESCENCE_IOR),iw=mm(D_,D_.IRIDESCENCE_THICKNESS),nw=mm(D_,D_.TRANSMISSION),sw=mm(D_,D_.THICKNESS),aw=mm(D_,D_.IOR),ow=mm(D_,D_.ATTENUATION_DISTANCE),lw=mm(D_,D_.ATTENUATION_COLOR),Aw=mm(D_,D_.LINE_SCALE),uw=mm(D_,D_.LINE_DASH_SIZE),hw=mm(D_,D_.LINE_GAP_SIZE),cw=mm(D_,D_.LINE_WIDTH),dw=mm(D_,D_.LINE_DASH_OFFSET),pw=mm(D_,D_.POINT_SIZE),fw=mm(D_,D_.DISPERSION),mw=mm(D_,D_.LIGHT_MAP),gw=mm(D_,D_.AO),yw=Cg(new Zu).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),bw=ym(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class xw extends Tf{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let i,n;if(r===xw.VERTEX)i=e.getVertexIndex();else if(r===xw.INSTANCE)i=e.getInstanceIndex();else if(r===xw.DRAW)i=e.getDrawIndex();else if(r===xw.INVOCATION_LOCAL)i=e.getInvocationLocalIndex();else if(r===xw.INVOCATION_SUBGROUP)i=e.getInvocationSubgroupIndex();else{if(r!==xw.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);i=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)n=i;else{n=Fb(this).build(e,t)}return n}}xw.VERTEX="vertex",xw.INSTANCE="instance",xw.SUBGROUP="subgroup",xw.INVOCATION_LOCAL="invocationLocal",xw.INVOCATION_SUBGROUP="invocationSubgroup",xw.DRAW="draw";const vw=mm(xw,xw.VERTEX),_w=mm(xw,xw.INSTANCE),ww=mm(xw,xw.SUBGROUP),Tw=mm(xw,xw.INVOCATION_SUBGROUP),Mw=mm(xw,xw.INVOCATION_LOCAL),Sw=mm(xw,xw.DRAW);class Ew extends Tf{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=mf.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:i}=this;let{instanceMatrixNode:n,instanceColorNode:s}=this;if(null===n){if(t<=1e3)n=Bx(r.array,"mat4",Math.max(t,1)).element(_w);else{const e=new Wp(r.array,16,1);this.buffer=e;const t=r.usage===Ou?tx:ex,i=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];n=zm(...i)}this.instanceMatrixNode=n}if(i&&null===s){const e=new Kd(i.array,3),t=i.usage===Ou?tx:ex;this.bufferColor=e,s=Pm(t(e,"vec3",3,0)),this.instanceColorNode=s}const a=n.mul(dv).xyz;if(dv.assign(a),e.hasGeometryAttribute("normal")){const e=Bv(Tv,n);Tv.assign(e)}null!==this.instanceColorNode&&Qm("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==Ou&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==Ou&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Nw=fm(Ew).setParameterLength(2,3);class Cw extends Ew{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:i}=e;super(t,r,i),this.instancedMesh=e}}const Rw=fm(Cw).setParameterLength(1);class Bw extends Tf{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=_w:this.batchingIdNode=Sw);const t=ym(([e])=>{const t=Mm(_x(Cx(this.batchMesh._indirectTexture),0).x),r=Mm(e).mod(t),i=Mm(e).div(t);return Cx(this.batchMesh._indirectTexture,Cm(r,i)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(Mm(this.batchingIdNode)),i=this.batchMesh._matricesTexture,n=Mm(_x(Cx(i),0).x),s=Tm(r).mul(4).toInt().toVar(),a=s.mod(n),o=s.div(n),l=zm(Cx(i,Cm(a,o)),Cx(i,Cm(a.add(1),o)),Cx(i,Cm(a.add(2),o)),Cx(i,Cm(a.add(3),o))),A=this.batchMesh._colorsTexture;if(null!==A){const e=ym(([e])=>{const t=Mm(_x(Cx(A),0).x),r=e,i=r.mod(t),n=r.div(t);return Cx(A,Cm(i,n)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);Qm("vec3","vBatchColor").assign(t)}const u=Um(l);dv.assign(l.mul(dv));const h=Tv.div(Pm(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),c=u.mul(h).xyz;Tv.assign(c),e.hasGeometryAttribute("tangent")&&m_.mulAssign(u)}}const Pw=fm(Bw).setParameterLength(1);class qw extends Mf{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const i=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===i||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==i){const i=this.getNodeType(e);r=e.format(r,i,t)}return r}}const Dw=fm(qw).setParameterLength(2);class Iw extends Rx{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let i,n=null;t&&t.isStruct?(i="struct",n=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(i=sf(e.itemSize),r=e.count):i=t,super(e,i,r),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=gf.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Dw(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(gf.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=Zb(this.value),this._varying=Fb(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),i=r.build(e);return e.registerTransform(i,t),i}}const Fw=(e,t=null,r=0)=>cm(new Iw(e,t,r)),Ow=new WeakMap;class Lw extends Tf{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=mf.OBJECT,this.skinIndexNode=bx("skinIndex","uvec4"),this.skinWeightNode=bx("skinWeight","vec4"),this.bindMatrixNode=Kv("bindMatrix","mat4"),this.bindMatrixInverseNode=Kv("bindMatrixInverse","mat4"),this.boneMatricesNode=Zv("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=dv,this.toPositionNode=dv,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:s}=this,a=e.element(r.x),o=e.element(r.y),l=e.element(r.z),A=e.element(r.w),u=n.mul(t),h=Lg(a.mul(i.x).mul(u),o.mul(i.y).mul(u),l.mul(i.z).mul(u),A.mul(i.w).mul(u));return s.mul(h).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Tv){const{skinIndexNode:r,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:s}=this,a=e.element(r.x),o=e.element(r.y),l=e.element(r.z),A=e.element(r.w);let u=Lg(i.x.mul(a),i.y.mul(o),i.z.mul(l),i.w.mul(A));return u=s.mul(u).mul(n),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Zv("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,pv)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===cf(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&pv.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();Tv.assign(t),e.hasGeometryAttribute("tangent")&&m_.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Ow.get(t)!==e.frameId&&(Ow.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const kw=e=>cm(new Lw(e));class Vw extends Tf{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;e<t;e++){const t=this.params[e],i=!0!==t.isNode&&t.name||this.getVarName(e),n=!0!==t.isNode&&t.type||"int";r[i]=cx(i,n)}const i=e.addStack();t.returnsNode=this.params[this.params.length-1](r,e),t.stackNode=i;const n=this.params[0];return!0!==n.isNode&&"function"==typeof n.update&&(t.updateNode=ym(this.params[0].update)(r)),e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),r=this.params,i=t.stackNode;for(let i=0,n=r.length-1;i<n;i++){const n=r[i];let s,a=!1,o=null,l=null,A=null,u=null,h=null,c=null;if(n.isNode?"bool"===n.getNodeType(e)?(a=!0,u="bool",l=n.build(e,u)):(u="int",A=this.getVarName(i),o="0",l=n.build(e,u),h="<"):(u=n.type||"int",A=n.name||this.getVarName(i),o=n.start,l=n.end,h=n.condition,c=n.update,"number"==typeof o?o=e.generateConst(u,o):o&&o.isNode&&(o=o.build(e,u)),"number"==typeof l?l=e.generateConst(u,l):l&&l.isNode&&(l=l.build(e,u)),void 0!==o&&void 0===l?(o+=" - 1",l="0",h=">="):void 0!==l&&void 0===o&&(o="0",h="<"),void 0===h&&(h=Number(o)>Number(l)?">=":"<")),a)s=`while ( ${l} )`;else{const r={start:o,end:l},i=r.start,n=r.end;let a;const d=()=>h.includes("<")?"+=":"-=";if(null!=c)switch(typeof c){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=A+" "+d()+" "+e.generateConst(u,c);break;case"string":a=A+" "+c;break;default:c.isNode?a=A+" "+d()+" "+c.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else c="int"===u||"uint"===u?h.includes("<")?"++":"--":d()+" 1.",a=A+" "+c;s=`for ( ${e.getVar(u,A)+" = "+i}; ${A+" "+h+" "+n}; ${a} )`}e.addFlowCode((0===i?"\n":"")+e.tab+s+" {\n\n").addFlowTab()}const n=i.build(e,"void"),s=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+n);for(let t=0,r=this.params.length-1;t<r;t++)e.addFlowCode((0===t?"":e.tab)+"}\n\n").removeFlowTab();return e.addFlowTab(),s}}const Uw=(...e)=>cm(new Vw(pm(e,"int"))).toStack(),zw=()=>cx("break").toStack(),Gw=new WeakMap,jw=new wh,Hw=ym(({bufferMap:e,influence:t,stride:r,width:i,depth:n,offset:s})=>{const a=Mm(vw).mul(r).add(s),o=a.div(i),l=a.sub(o.mul(i));return Cx(e,Cm(l,o)).depth(n).xyz.mul(t)});class Ww extends Tf{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Cg(1),this.updateType=mf.OBJECT}setup(e){const{geometry:t}=e,r=void 0!==t.morphAttributes.position,i=t.hasAttribute("normal")&&void 0!==t.morphAttributes.normal,n=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,s=void 0!==n?n.length:0,{texture:a,stride:o,size:l}=function(e){const t=void 0!==e.morphAttributes.position,r=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,s=void 0!==n?n.length:0;let a=Gw.get(e);if(void 0===a||a.count!==s){void 0!==a&&a.texture.dispose();const o=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],A=e.morphAttributes.color||[];let u=0;!0===t&&(u=1),!0===r&&(u=2),!0===i&&(u=3);let h=e.attributes.position.count*u,c=1;const d=4096;h>d&&(c=Math.ceil(h/d),h=d);const p=new Float32Array(h*c*4*s),f=new Sh(p,h,c,s);f.type=GA,f.needsUpdate=!0;const m=4*u;for(let y=0;y<s;y++){const b=o[y],x=l[y],v=A[y],_=h*c*4*y;for(let w=0;w<b.count;w++){const T=w*m;!0===t&&(jw.fromBufferAttribute(b,w),p[_+T+0]=jw.x,p[_+T+1]=jw.y,p[_+T+2]=jw.z,p[_+T+3]=0),!0===r&&(jw.fromBufferAttribute(x,w),p[_+T+4]=jw.x,p[_+T+5]=jw.y,p[_+T+6]=jw.z,p[_+T+7]=0),!0===i&&(jw.fromBufferAttribute(v,w),p[_+T+8]=jw.x,p[_+T+9]=jw.y,p[_+T+10]=jw.z,p[_+T+11]=4===v.itemSize?jw.w:1)}}function g(){f.dispose(),Gw.delete(e),e.removeEventListener("dispose",g)}a={count:s,texture:f,stride:u,size:new Zu(h,c)},Gw.set(e,a),e.addEventListener("dispose",g)}return a}(t);!0===r&&dv.mulAssign(this.morphBaseInfluence),!0===i&&Tv.mulAssign(this.morphBaseInfluence);const A=Mm(l.width);Uw(s,({i:e})=>{const t=Tm(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Cx(this.mesh.morphTexture,Cm(Mm(e).add(1),Mm(_w))).r):t.assign(Kv("morphTargetInfluences","float").element(e).toVar()),vm(t.notEqual(0),()=>{!0===r&&dv.addAssign(Hw({bufferMap:a,influence:t,stride:o,width:A,depth:e,offset:Mm(0)})),!0===i&&Tv.addAssign(Hw({bufferMap:a,influence:t,stride:o,width:A,depth:e,offset:Mm(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}const Qw=fm(Ww).setParameterLength(1);class $w extends Tf{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Xw extends $w{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Yw extends Mb{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,i=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:Pm().toVar("directDiffuse"),directSpecular:Pm().toVar("directSpecular"),indirectDiffuse:Pm().toVar("indirectDiffuse"),indirectSpecular:Pm().toVar("indirectSpecular")};return{radiance:Pm().toVar("radiance"),irradiance:Pm().toVar("irradiance"),iblIrradiance:Pm().toVar("iblIrradiance"),ambientOcclusion:Tm(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const Kw=fm(Yw);class Zw extends $w{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let Jw,eT;class tT extends Tf{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===tT.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=mf.NONE;return this.scope!==tT.SIZE&&this.scope!==tT.VIEWPORT||(e=mf.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===tT.VIEWPORT?null!==t?eT.copy(t.viewport):(e.getViewport(eT),eT.multiplyScalar(e.getPixelRatio())):null!==t?(Jw.width=t.width,Jw.height=t.height):e.getDrawingBufferSize(Jw)}setup(){const e=this.scope;let t=null;return t=e===tT.SIZE?Cg(Jw||(Jw=new Zu)):e===tT.VIEWPORT?Cg(eT||(eT=new wh)):Nm(nT.div(iT)),t}generate(e){if(this.scope===tT.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(iT).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}tT.COORDINATE="coordinate",tT.VIEWPORT="viewport",tT.SIZE="size",tT.UV="uv";const rT=mm(tT,tT.UV),iT=mm(tT,tT.SIZE),nT=mm(tT,tT.COORDINATE),sT=mm(tT,tT.VIEWPORT),aT=sT.zw,oT=nT.sub(sT.xy),lT=oT.div(aT),AT=ym(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),iT),"vec2").once()(),uT=new Zu;class hT extends Sx{static get type(){return"ViewportTextureNode"}constructor(e=rT,t=null,r=null){null===r&&((r=new hp).minFilter=FA),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=mf.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(uT);const r=this.value;r.image.width===uT.width&&r.image.height===uT.height||(r.image.width=uT.width,r.image.height=uT.height,r.needsUpdate=!0);const i=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=i}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const cT=fm(hT).setParameterLength(0,3),dT=fm(hT,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let pT=null;class fT extends hT{static get type(){return"ViewportDepthTextureNode"}constructor(e=rT,t=null){null===pT&&(pT=new cp),super(e,t,pT)}}const mT=fm(fT).setParameterLength(0,2);class gT extends Tf{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===gT.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let i=null;if(t===gT.DEPTH_BASE)null!==r&&(i=_T().assign(r));else if(t===gT.DEPTH)i=e.isPerspectiveCamera?bT(gv.z,Ox,Lx):yT(gv.z,Ox,Lx);else if(t===gT.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=xT(r,Ox,Lx);i=yT(e,Ox,Lx)}else i=r;else i=yT(gv.z,Ox,Lx);return i}}gT.DEPTH_BASE="depthBase",gT.DEPTH="depth",gT.LINEAR_DEPTH="linearDepth";const yT=(e,t,r)=>e.add(t).div(t.sub(r)),bT=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),xT=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),vT=(e,t,r)=>{t=t.max(1e-6).toVar();const i=_y(e.negate().div(t)),n=_y(r.div(t));return i.div(n)},_T=fm(gT,gT.DEPTH_BASE),wT=mm(gT,gT.DEPTH),TT=fm(gT,gT.LINEAR_DEPTH).setParameterLength(0,1),MT=TT(mT());wT.assign=e=>_T(e);class ST extends Tf{static get type(){return"ClippingNode"}constructor(e=ST.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:i}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===ST.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===ST.HARDWARE?this.setupHardwareClipping(i,e):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return ym(()=>{const r=Tm().toVar("distanceToPlane"),i=Tm().toVar("distanceToGradient"),n=Tm(1).toVar("clipOpacity"),s=t.length;if(!1===this.hardwareClipping&&s>0){const e=Dx(t);Uw(s,({i:t})=>{const s=e.element(t);r.assign(gv.dot(s.xyz).negate().add(s.w)),i.assign(r.fwidth().div(2)),n.mulAssign(pb(i.negate(),i,r))})}const a=e.length;if(a>0){const t=Dx(e),s=Tm(1).toVar("intersectionClipOpacity");Uw(a,({i:e})=>{const n=t.element(e);r.assign(gv.dot(n.xyz).negate().add(n.w)),i.assign(r.fwidth().div(2)),s.mulAssign(pb(i.negate(),i,r).oneMinus())}),n.mulAssign(s.oneMinus())}$m.a.mulAssign(n),$m.a.equal(0).discard()})()}setupDefault(e,t){return ym(()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=Dx(t);Uw(r,({i:t})=>{const r=e.element(t);gv.dot(r.xyz).greaterThan(r.w).discard()})}const i=e.length;if(i>0){const t=Dx(e),r=Em(!0).toVar("clipped");Uw(i,({i:e})=>{const i=t.element(e);r.assign(gv.dot(i.xyz).greaterThan(i.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ym(()=>{const i=Dx(e),n=Ix(t.getClipDistance());Uw(r,({i:e})=>{const t=i.element(e),r=gv.dot(t.xyz).sub(t.w).negate();n.element(e).assign(r)})})()}}ST.ALPHA_TO_COVERAGE="alphaToCoverage",ST.DEFAULT="default",ST.HARDWARE="hardware";const ET=ym(([e])=>Ny(Vg(1e4,Cy(Vg(17,e.x).add(Vg(.1,e.y)))).mul(Lg(.1,Iy(Cy(Vg(13,e.y).add(e.x))))))),NT=ym(([e])=>ET(Nm(ET(e.xy),e.z))),CT=ym(([e])=>{const t=Yy(Oy(Vy(e.xyz)),Oy(Uy(e.xyz))),r=Tm(1).div(Tm(.05).mul(t)).toVar("pixScale"),i=Nm(xy(My(_y(r))),xy(Sy(_y(r)))),n=Nm(NT(My(i.x.mul(e.xyz))),NT(My(i.y.mul(e.xyz)))),s=Ny(_y(r)),a=Lg(Vg(s.oneMinus(),n.x),Vg(s,n.y)),o=Xy(s,s.oneMinus()),l=Pm(a.mul(a).div(Vg(2,o).mul(kg(1,o))),a.sub(Vg(.5,o)).div(kg(1,o)),kg(1,kg(1,a).mul(kg(1,a)).div(Vg(2,o).mul(kg(1,o))))),A=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return hb(A,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class RT extends yx{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new wh(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const BT=(e=0)=>cm(new RT(e)),PT=ym(([e,t])=>Xy(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),qT=ym(([e,t])=>Xy(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),DT=ym(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),IT=ym(([e,t])=>ub(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Ky(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),FT=ym(([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return Fm(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),OT=ym(([e])=>Fm(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),LT=ym(([e])=>(vm(e.a.equal(0),()=>Fm(0)),Fm(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class kT extends Xc{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+ef(this)}build(e){this.setup(e)}setupObserver(e){return new Xp(e)}setup(e){e.context.setupNormal=()=>Db(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const i=Db(this.setupVertex(e),"VERTEX"),n=this.vertexNode||i;let s;e.stack.outputNode=n,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const i=this.setupLighting(e);null!==a&&e.stack.add(a);const n=Fm(i,$m.a).max(0);s=this.setupOutput(e,n),cg.assign(s);const o=null!==this.outputNode;if(o&&(s=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&cg.assign(s),s=e,null!==r&&(s=e.merge(r))):null!==r&&(s=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=Fm(t)),s=this.setupOutput(e,t)}e.stack.outputNode=s,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let i=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?i=cm(new ST(ST.ALPHA_TO_COVERAGE)):e.stack.add(cm(new ST))}return i}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(cm(new ST(ST.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let i=this.depthNode;if(null===i){const e=t.getMRT();e&&e.has("depth")?i=e.get("depth"):!0===t.logarithmicDepthBuffer&&(i=r.isPerspectiveCamera?vT(gv.z,Ox,Lx):yT(gv.z,Ox,Lx))}null!==i&&wT.assign(i).toStack()}setupPositionView(){return lv.mul(dv).xyz}setupModelViewProjection(){return kx.mul(gv)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),bw}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&Qw(t).toStack(),!0===t.isSkinnedMesh&&kw(t).toStack(),this.displacementMap){const e=e_("displacementMap","texture"),t=e_("displacementScale","float"),r=e_("displacementBias","float");dv.addAssign(Tv.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Pw(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Rw(t).toStack(),null!==this.positionNode&&dv.assign(Db(this.positionNode,"POSITION","vec3")),dv}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Em(this.maskNode).not().discard();let r=this.colorNode?Fm(this.colorNode):F_;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul(BT())),e.instanceColor){r=Qm("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=Qm("vec3","vBatchColor").mul(r)}$m.assign(r);const i=this.opacityNode?Tm(this.opacityNode):k_;$m.a.assign($m.a.mul(i));let n=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(n=null!==this.alphaTestNode?Tm(this.alphaTestNode):I_,$m.a.lessThanEqual(n).discard()),!0===this.alphaHash&&$m.a.lessThan(CT(dv)).discard();!1===this.transparent&&1===this.blending&&!1===this.alphaToCoverage?$m.a.assign(1):null===n&&$m.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?Pm(0):$m.rgb}setupNormal(){return this.normalNode?Pm(this.normalNode):Q_}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?e_("envMap","cubeTexture"):e_("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Zw(mw)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const i=this.setupLightMap(e);if(i&&i.isLightingNode&&t.push(i),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:gw;t.push(new Xw(e))}let n=this.lightsNode||e.lightsNode;return t.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...t])),n}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:i,emissiveNode:n}=this,s=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(s&&s.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=Kw(s,t,r,i)}else null!==r&&(a=Pm(null!==i?ub(a,r,i):r));return(n&&!0===n.isNode||t.emissive&&!0===t.emissive.isColor)&&(Xm.assign(Pm(n||L_)),a=a.add(Xm)),a}setupFog(e,t){const r=e.fogNode;return r&&(cg.assign(t),t=Fm(r)),t}setupPremultipliedAlpha(e,t){return OT(t)}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=Xc.prototype.toJSON.call(this,e),i=tf(this);r.inputNodes={};for(const{property:t,childNode:n}of i)r.inputNodes[t]=n.toJSON(e).uuid;function n(e){const t=[];for(const r in e){const i=e[r];delete i.metadata,t.push(i)}return t}if(t){const t=n(e.textures),i=n(e.images),s=n(e.nodes);t.length>0&&(r.textures=t),i.length>0&&(r.images=i),s.length>0&&(r.nodes=s)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const VT=new Ap;class UT extends kT{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(VT),this.setValues(e)}}const zT=new Tp;class GT extends kT{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(zT),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Tm(this.offsetNode):dw,t=this.dashScaleNode?Tm(this.dashScaleNode):Aw,r=this.dashSizeNode?Tm(this.dashSizeNode):uw,i=this.gapSizeNode?Tm(this.gapSizeNode):hw;dg.assign(r),pg.assign(i);const n=Fb(bx("lineDistance").mul(t));(e?n.add(e):n).mod(dg.add(pg)).greaterThan(dg).discard()}}let jT=null;class HT extends hT{static get type(){return"ViewportSharedTextureNode"}constructor(e=rT,t=null){null===jT&&(jT=new hp),super(e,t,jT)}updateReference(){return this}}const WT=fm(HT).setParameterLength(0,2),QT=e=>cm(e).mul(.5).add(.5),$T=new vp;class XT extends kT{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues($T),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Tm(this.opacityNode):k_;$m.assign(Gb(Fm(QT(Nv),e),wu))}}const YT=ym(([e=mv])=>{const t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Nm(t,r)});class KT extends Ud{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new Rd(5,5,5),s=YT(mv),a=new kT;a.colorNode=Nx(t,s,0),a.side=1,a.blending=0;const o=new Nd(n,a),l=new Hd;l.add(o),t.minFilter===FA&&(t.minFilter=DA);const A=new kd(1,10,this),u=e.getMRT();return e.setMRT(null),A.update(e,l),e.setMRT(u),t.minFilter=r,t.currentGenerateMipmaps=i,o.geometry.dispose(),o.material.dispose(),this}}const ZT=new WeakMap;class JT extends Ef{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=$v(null);const t=new Vd;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=mf.RENDER}updateBefore(e){const{renderer:t,material:r}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const e=i.isTextureNode?i.value:r[i.property];if(e&&e.isTexture){const r=e.mapping;if(303===r||304===r){if(ZT.has(e)){const t=ZT.get(e);tM(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const i=new KT(r.height);i.fromEquirectangularTexture(t,e),tM(i.texture,e.mapping),this._cubeTexture=i.texture,ZT.set(e,i.texture),e.addEventListener("dispose",eM)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function eM(e){const t=e.target;t.removeEventListener("dispose",eM);const r=ZT.get(t);void 0!==r&&(ZT.delete(t),r.dispose())}function tM(e,t){303===t?e.mapping=SA:304===t&&(e.mapping=EA)}const rM=fm(JT).setParameterLength(1);class iM extends $w{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=rM(this.envNode)}}class nM extends $w{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Tm(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class sM{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class aM extends sM{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,i=e.irradianceLightMap;r.indirectDiffuse.assign(Fm(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(Fm(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign($m.rgb)}finish(e){const{material:t,context:r}=e,i=r.outgoingLight,n=e.context.environment;if(n)switch(t.combine){case 0:i.rgb.assign(ub(i.rgb,i.rgb.mul(n.rgb),G_.mul(j_)));break;case 1:i.rgb.assign(ub(i.rgb,n.rgb,G_.mul(j_)));break;case 2:i.rgb.addAssign(n.rgb.mul(G_.mul(j_)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const oM=new Yc;class lM extends kT{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(oM),this.setValues(e)}setupNormal(){return _v(Sv)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new iM(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new nM(mw)),t}setupOutgoingLight(){return $m.rgb}setupLightingModel(){return new aM}}const AM=ym(({f0:e,f90:t,dotVH:r})=>{const i=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(i.oneMinus()).add(t.mul(i))}),uM=ym(e=>e.diffuseColor.mul(1/Math.PI)),hM=ym(({dotNH:e})=>hg.mul(Tm(.5)).add(1).mul(Tm(1/Math.PI)).mul(e.pow(hg))),cM=ym(({lightDirection:e})=>{const t=e.add(yv).normalize(),r=Nv.dot(t).clamp(),i=yv.dot(t).clamp(),n=AM({f0:Ag,f90:1,dotVH:i}),s=Tm(.25),a=hM({dotNH:r});return n.mul(s).mul(a)});class dM extends aM{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const i=Nv.dot(e).clamp().mul(t);r.directDiffuse.addAssign(i.mul(uM({diffuseColor:$m.rgb}))),!0===this.specular&&r.directSpecular.addAssign(i.mul(cM({lightDirection:e})).mul(G_))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(uM({diffuseColor:$m}))),i.indirectDiffuse.mulAssign(t)}}const pM=new _p;class fM extends kT{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(pM),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new iM(t):null}setupLightingModel(){return new dM(!1)}}const mM=new bp;class gM extends kT{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(mM),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new iM(t):null}setupLightingModel(){return new dM}setupVariants(){const e=(this.shininessNode?Tm(this.shininessNode):O_).max(1e-4);hg.assign(e);const t=this.specularNode||V_;Ag.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const yM=ym(e=>{if(!1===e.geometry.hasAttribute("normal"))return Tm(0);const t=Sv.dFdx().abs().max(Sv.dFdy().abs());return t.x.max(t.y).max(t.z)}),bM=ym(e=>{const{roughness:t}=e,r=yM();let i=t.max(.0525);return i=i.add(r),i=i.min(1),i}),xM=ym(({alpha:e,dotNL:t,dotNV:r})=>{const i=e.pow2(),n=t.mul(i.add(i.oneMinus().mul(r.pow2())).sqrt()),s=r.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt());return Ug(.5,n.add(s).max(hy))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),vM=ym(({alphaT:e,alphaB:t,dotTV:r,dotBV:i,dotTL:n,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(Pm(e.mul(r),t.mul(i),a).length()),A=a.mul(Pm(e.mul(n),t.mul(s),o).length());return Ug(.5,l.add(A)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),_M=ym(({alpha:e,dotNH:t})=>{const r=e.pow2(),i=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),wM=Tm(1/Math.PI),TM=ym(({alphaT:e,alphaB:t,dotNH:r,dotTH:i,dotBH:n})=>{const s=e.mul(t),a=Pm(t.mul(i),e.mul(n),s.mul(r)),o=a.dot(a),l=s.div(o);return wM.mul(s.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),MM=ym(({lightDirection:e,f0:t,f90:r,roughness:i,f:n,normalView:s=Nv,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{const l=i.pow2(),A=e.add(yv).normalize(),u=s.dot(e).clamp(),h=s.dot(yv).clamp(),c=s.dot(A).clamp(),d=yv.dot(A).clamp();let p,f,m=AM({f0:t,f90:r,dotVH:d});if(Am(a)&&(m=rg.mix(m,n)),Am(o)){const t=og.dot(e),r=og.dot(yv),i=og.dot(A),n=lg.dot(e),s=lg.dot(yv),a=lg.dot(A);p=vM({alphaT:sg,alphaB:l,dotTV:r,dotBV:s,dotTL:t,dotBL:n,dotNV:h,dotNL:u}),f=TM({alphaT:sg,alphaB:l,dotNH:c,dotTH:i,dotBH:a})}else p=xM({alpha:l,dotNL:u,dotNV:h}),f=_M({alpha:l,dotNH:c});return m.mul(p).mul(f)}),SM=ym(({roughness:e,dotNV:t})=>{const r=Fm(-1,-.0275,-.572,.022),i=Fm(1,.0425,1.04,-.04),n=e.mul(r).add(i),s=n.x.mul(n.x).min(t.mul(-9.28).exp2()).mul(n.x).add(n.y);return Nm(-1.04,1.04).mul(s).add(n.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),EM=ym(e=>{const{dotNV:t,specularColor:r,specularF90:i,roughness:n}=e,s=SM({dotNV:t,roughness:n});return r.mul(s.x).add(i.mul(s.y))}),NM=ym(({f:e,f90:t,dotVH:r})=>{const i=r.oneMinus().saturate(),n=i.mul(i),s=i.mul(n,n).clamp(0,.9999);return e.sub(Pm(t).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),CM=ym(({roughness:e,dotNH:t})=>{const r=e.pow2(),i=Tm(1).div(r),n=t.pow2().oneMinus().max(.0078125);return Tm(2).add(i).mul(n.pow(i.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),RM=ym(({dotNV:e,dotNL:t})=>Tm(1).div(Tm(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),BM=ym(({lightDirection:e})=>{const t=e.add(yv).normalize(),r=Nv.dot(e).clamp(),i=Nv.dot(yv).clamp(),n=Nv.dot(t).clamp(),s=CM({roughness:tg,dotNH:n}),a=RM({dotNV:i,dotNL:r});return eg.mul(s).mul(a)}),PM=ym(({N:e,V:t,roughness:r})=>{const i=e.dot(t).saturate(),n=Nm(r,i.oneMinus().sqrt());return n.assign(n.mul(.984375).add(.0078125)),n}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),qM=ym(({f:e})=>{const t=e.length();return Yy(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),DM=ym(({v1:e,v2:t})=>{const r=e.dot(t),i=r.abs().toVar(),n=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),s=i.add(4.1616724).mul(i).add(3.417594).toVar(),a=n.div(s),o=r.greaterThan(0).select(a,Yy(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),IM=ym(({N:e,V:t,P:r,mInv:i,p0:n,p1:s,p2:a,p3:o})=>{const l=s.sub(n).toVar(),A=o.sub(n).toVar(),u=l.cross(A),h=Pm().toVar();return vm(u.dot(r.sub(n)).greaterThanEqual(0),()=>{const l=t.sub(e.mul(t.dot(e))).normalize(),A=e.cross(l).negate(),u=i.mul(Um(l,A,e).transpose()).toVar(),c=u.mul(n.sub(r)).normalize().toVar(),d=u.mul(s.sub(r)).normalize().toVar(),p=u.mul(a.sub(r)).normalize().toVar(),f=u.mul(o.sub(r)).normalize().toVar(),m=Pm(0).toVar();m.addAssign(DM({v1:c,v2:d})),m.addAssign(DM({v1:d,v2:p})),m.addAssign(DM({v1:p,v2:f})),m.addAssign(DM({v1:f,v2:c})),h.assign(Pm(qM({f:m})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),FM=1/6,OM=e=>Vg(FM,Vg(e,Vg(e,e.negate().add(3)).sub(3)).add(1)),LM=e=>Vg(FM,Vg(e,Vg(e,Vg(3,e).sub(6))).add(4)),kM=e=>Vg(FM,Vg(e,Vg(e,Vg(-3,e).add(3)).add(3)).add(1)),VM=e=>Vg(FM,ib(e,3)),UM=e=>OM(e).add(LM(e)),zM=e=>kM(e).add(VM(e)),GM=e=>Lg(-1,LM(e).div(OM(e).add(LM(e)))),jM=e=>Lg(1,VM(e).div(kM(e).add(VM(e)))),HM=(e,t,r)=>{const i=e.uvNode,n=Vg(i,t.zw).add(.5),s=My(n),a=Ny(n),o=UM(a.x),l=zM(a.x),A=GM(a.x),u=jM(a.x),h=GM(a.y),c=jM(a.y),d=Nm(s.x.add(A),s.y.add(h)).sub(.5).mul(t.xy),p=Nm(s.x.add(u),s.y.add(h)).sub(.5).mul(t.xy),f=Nm(s.x.add(A),s.y.add(c)).sub(.5).mul(t.xy),m=Nm(s.x.add(u),s.y.add(c)).sub(.5).mul(t.xy),g=UM(a.y).mul(Lg(o.mul(e.sample(d).level(r)),l.mul(e.sample(p).level(r)))),y=zM(a.y).mul(Lg(o.mul(e.sample(f).level(r)),l.mul(e.sample(m).level(r))));return g.add(y)},WM=ym(([e,t])=>{const r=Nm(e.size(Mm(t))),i=Nm(e.size(Mm(t.add(1)))),n=Ug(1,r),s=Ug(1,i),a=HM(e,Fm(n,r),My(t)),o=HM(e,Fm(s,i),Sy(t));return Ny(t).mix(a,o)}),QM=ym(([e,t])=>{const r=t.mul(Tx(e));return WM(e,r)}),$M=ym(([e,t,r,i,n])=>{const s=Pm(db(t.negate(),Ey(e),Ug(1,i))),a=Pm(Oy(n[0].xyz),Oy(n[1].xyz),Oy(n[2].xyz));return Ey(s).mul(r.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),XM=ym(([e,t])=>e.mul(hb(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),YM=dT(),KM=dT(),ZM=ym(([e,t,r],{material:i})=>{const n=(1===i.side?YM:KM).sample(e),s=_y(iT.x).mul(XM(t,r));return WM(n,s)}),JM=ym(([e,t,r])=>(vm(r.notEqual(0),()=>{const i=vy(t).negate().div(r);return by(i.negate().mul(e))}),Pm(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),eS=ym(([e,t,r,i,n,s,a,o,l,A,u,h,c,d,p])=>{let f,m;if(p){f=Fm().toVar(),m=Pm().toVar();const n=u.sub(1).mul(p.mul(.025)),s=Pm(u.sub(n),u,u.add(n));Uw({start:0,end:3},({i:n})=>{const u=s.element(n),p=$M(e,t,h,u,o),g=a.add(p),y=A.mul(l.mul(Fm(g,1))),b=Nm(y.xy.div(y.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Nm(b.x,b.y.oneMinus()));const x=ZM(b,r,u);f.element(n).assign(x.element(n)),f.a.addAssign(x.a),m.element(n).assign(i.element(n).mul(JM(Oy(p),c,d).element(n)))}),f.a.divAssign(3)}else{const n=$M(e,t,h,u,o),s=a.add(n),p=A.mul(l.mul(Fm(s,1))),g=Nm(p.xy.div(p.w)).toVar();g.addAssign(1),g.divAssign(2),g.assign(Nm(g.x,g.y.oneMinus())),f=ZM(g,r,u),m=i.mul(JM(Oy(n),c,d))}const g=m.rgb.mul(f.rgb),y=e.dot(t).clamp(),b=Pm(EM({dotNV:y,specularColor:n,specularF90:s,roughness:r})),x=m.r.add(m.g,m.b).div(3);return Fm(b.oneMinus().mul(g),f.a.oneMinus().mul(x).oneMinus())}),tS=Um(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),rS=(e,t)=>e.sub(t).div(e.add(t)).pow2(),iS=ym(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:i,baseF0:n})=>{const s=ub(e,t,pb(0,.03,i)),a=e.div(s).pow2().mul(r.pow2().oneMinus()).oneMinus();vm(a.lessThan(0),()=>Pm(1));const o=a.sqrt(),l=rS(s,e),A=AM({f0:l,f90:1,dotVH:r}),u=A.oneMinus(),h=s.lessThan(e).select(Math.PI,0),c=Tm(Math.PI).sub(h),d=(e=>{const t=e.sqrt();return Pm(1).add(t).div(Pm(1).sub(t))})(n.clamp(0,.9999)),p=rS(d,s.toVec3()),f=AM({f0:p,f90:1,dotVH:o}),m=Pm(d.x.lessThan(s).select(Math.PI,0),d.y.lessThan(s).select(Math.PI,0),d.z.lessThan(s).select(Math.PI,0)),g=s.mul(i,o,2),y=Pm(c).add(m),b=A.mul(f).clamp(1e-5,.9999),x=b.sqrt(),v=u.pow2().mul(f).div(Pm(1).sub(b)),_=A.add(v).toVar(),w=v.sub(u).toVar();return Uw({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{w.mulAssign(x);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),i=Pm(54856e-17,44201e-17,52481e-17),n=Pm(1681e3,1795300,2208400),s=Pm(43278e5,93046e5,66121e5),a=Tm(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=i.mul(s.mul(2*Math.PI).sqrt()).mul(n.mul(r).add(t).cos()).mul(r.pow2().negate().mul(s).exp());return o=Pm(o.x.add(a),o.y,o.z).div(1.0685e-7),tS.mul(o)})(Tm(e).mul(g),Tm(e).mul(y)).mul(2);_.addAssign(w.mul(t))}),_.max(Pm(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),nS=ym(({normal:e,viewDir:t,roughness:r})=>{const i=e.dot(t).saturate(),n=r.pow2(),s=Tb(r.lessThan(.25),Tm(-339.2).mul(n).add(Tm(161.4).mul(r)).sub(25.9),Tm(-8.48).mul(n).add(Tm(14.3).mul(r)).sub(9.95)),a=Tb(r.lessThan(.25),Tm(44).mul(n).sub(Tm(23.7).mul(r)).add(3.26),Tm(1.97).mul(n).sub(Tm(3.27).mul(r)).add(.72));return Tb(r.lessThan(.25),0,Tm(.1).mul(r).sub(.025)).add(s.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),sS=Pm(.04),aS=Tm(1);class oS extends sM{constructor(e=!1,t=!1,r=!1,i=!1,n=!1,s=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=i,this.transmission=n,this.dispersion=s,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=Pm().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Pm().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Pm().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=Pm().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Pm().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Nv.dot(yv).clamp();this.iridescenceFresnel=iS({outsideIOR:Tm(1),eta2:ig,cosTheta1:e,thinFilmThickness:ng,baseF0:Ag}),this.iridescenceF0=NM({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=fv,r=jx.sub(fv).normalize(),i=Cv,n=e.context;n.backdrop=eS(i,r,Ym,$m,Ag,ug,t,tv,Ux,kx,mg,yg,xg,bg,this.dispersion?vg:null),n.backdropAlpha=gg,$m.a.mulAssign(ub(1,n.backdrop.a,gg))}super.start(e)}computeMultiscattering(e,t,r){const i=Nv.dot(yv).clamp(),n=SM({roughness:Ym,dotNV:i}),s=(this.iridescenceF0?rg.mix(Ag,this.iridescenceF0):Ag).mul(n.x).add(r.mul(n.y)),a=n.x.add(n.y).oneMinus(),o=Ag.add(Ag.oneMinus().mul(.047619)),l=s.mul(o).div(a.mul(o).oneMinus());e.addAssign(s),t.addAssign(l.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const i=Nv.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(i.mul(BM({lightDirection:e}))),!0===this.clearcoat){const r=Rv.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(MM({lightDirection:e,f0:sS,f90:aS,roughness:Jm,normalView:Rv})))}r.directDiffuse.addAssign(i.mul(uM({diffuseColor:$m.rgb}))),r.directSpecular.addAssign(i.mul(MM({lightDirection:e,f0:Ag,f90:1,roughness:Ym,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:i,reflectedLight:n,ltc_1:s,ltc_2:a}){const o=t.add(r).sub(i),l=t.sub(r).sub(i),A=t.sub(r).add(i),u=t.add(r).add(i),h=Nv,c=yv,d=gv.toVar(),p=PM({N:h,V:c,roughness:Ym}),f=s.sample(p).toVar(),m=a.sample(p).toVar(),g=Um(Pm(f.x,0,f.y),Pm(0,1,0),Pm(f.z,0,f.w)).toVar(),y=Ag.mul(m.x).add(Ag.oneMinus().mul(m.y)).toVar();n.directSpecular.addAssign(e.mul(y).mul(IM({N:h,V:c,P:d,mInv:g,p0:o,p1:l,p2:A,p3:u}))),n.directDiffuse.addAssign(e.mul($m).mul(IM({N:h,V:c,P:d,mInv:Um(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:A,p3:u})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(uM({diffuseColor:$m})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:i}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(eg,nS({normal:Nv,viewDir:yv,roughness:tg}))),!0===this.clearcoat){const e=Rv.dot(yv).clamp(),t=EM({dotNV:e,specularColor:sS,specularF90:aS,roughness:Jm});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const n=Pm().toVar("singleScattering"),s=Pm().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(n,s,ug);const o=n.add(s),l=$m.mul(o.r.max(o.g).max(o.b).oneMinus());i.indirectSpecular.addAssign(t.mul(n)),i.indirectSpecular.addAssign(s.mul(a)),i.indirectDiffuse.addAssign(l.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,i=Nv.dot(yv).clamp().add(t),n=Ym.mul(-16).oneMinus().negate().exp2(),s=t.sub(i.pow(n).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(s)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Rv.dot(yv).clamp(),r=AM({dotVH:e,f0:sS,f90:aS}),i=t.mul(Zm.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Zm));t.assign(i)}if(!0===this.sheen){const e=eg.r.max(eg.g).max(eg.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const lS=Tm(1),AS=Tm(-2),uS=Tm(.8),hS=Tm(-1),cS=Tm(.4),dS=Tm(2),pS=Tm(.305),fS=Tm(3),mS=Tm(.21),gS=Tm(4),yS=Tm(4),bS=Tm(16),xS=ym(([e])=>{const t=Pm(Iy(e)).toVar(),r=Tm(-1).toVar();return vm(t.x.greaterThan(t.z),()=>{vm(t.x.greaterThan(t.y),()=>{r.assign(Tb(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(Tb(e.y.greaterThan(0),1,4))})}).Else(()=>{vm(t.z.greaterThan(t.y),()=>{r.assign(Tb(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(Tb(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),vS=ym(([e,t])=>{const r=Nm().toVar();return vm(t.equal(0),()=>{r.assign(Nm(e.z,e.y).div(Iy(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(Nm(e.x.negate(),e.z.negate()).div(Iy(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(Nm(e.x.negate(),e.y).div(Iy(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(Nm(e.z.negate(),e.y).div(Iy(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(Nm(e.x.negate(),e.z).div(Iy(e.y)))}).Else(()=>{r.assign(Nm(e.x,e.y).div(Iy(e.z)))}),Vg(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),_S=ym(([e])=>{const t=Tm(0).toVar();return vm(e.greaterThanEqual(uS),()=>{t.assign(lS.sub(e).mul(hS.sub(AS)).div(lS.sub(uS)).add(AS))}).ElseIf(e.greaterThanEqual(cS),()=>{t.assign(uS.sub(e).mul(dS.sub(hS)).div(uS.sub(cS)).add(hS))}).ElseIf(e.greaterThanEqual(pS),()=>{t.assign(cS.sub(e).mul(fS.sub(dS)).div(cS.sub(pS)).add(dS))}).ElseIf(e.greaterThanEqual(mS),()=>{t.assign(pS.sub(e).mul(gS.sub(fS)).div(pS.sub(mS)).add(fS))}).Else(()=>{t.assign(Tm(-2).mul(_y(Vg(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),wS=ym(([e,t])=>{const r=e.toVar();r.assign(Vg(2,r).sub(1));const i=Pm(r,1).toVar();return vm(t.equal(0),()=>{i.assign(i.zyx)}).ElseIf(t.equal(1),()=>{i.assign(i.xzy),i.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{i.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{i.assign(i.zyx),i.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{i.assign(i.xzy),i.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{i.z.mulAssign(-1)}),i}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),TS=ym(([e,t,r,i,n,s])=>{const a=Tm(r),o=Pm(t),l=hb(_S(a),AS,s),A=Ny(l),u=My(l),h=Pm(MS(e,o,u,i,n,s)).toVar();return vm(A.notEqual(0),()=>{const t=Pm(MS(e,o,u.add(1),i,n,s)).toVar();h.assign(ub(h,t,A))}),h}),MS=ym(([e,t,r,i,n,s])=>{const a=Tm(r).toVar(),o=Pm(t),l=Tm(xS(o)).toVar(),A=Tm(Yy(yS.sub(a),0)).toVar();a.assign(Yy(a,yS));const u=Tm(xy(a)).toVar(),h=Nm(vS(o,l).mul(u.sub(2)).add(1)).toVar();return vm(l.greaterThan(2),()=>{h.y.addAssign(u),l.subAssign(3)}),h.x.addAssign(l.mul(u)),h.x.addAssign(A.mul(Vg(3,bS))),h.y.addAssign(Vg(4,xy(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(n),e.sample(h).grad(Nm(),Nm())}),SS=ym(({envMap:e,mipInt:t,outputDirection:r,theta:i,axis:n,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=Ry(i),A=r.mul(l).add(n.cross(r).mul(Cy(i))).add(n.mul(n.dot(r).mul(l.oneMinus())));return MS(e,A,t,s,a,o)}),ES=ym(({n:e,latitudinal:t,poleAxis:r,outputDirection:i,weights:n,samples:s,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const c=Pm(Tb(t,r,rb(r,i))).toVar();vm(c.equal(Pm(0)),()=>{c.assign(Pm(i.z,0,i.x.negate()))}),c.assign(Ey(c));const d=Pm().toVar();return d.addAssign(n.element(0).mul(SS({theta:0,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),Uw({start:Mm(1),end:e},({i:e})=>{vm(e.greaterThanEqual(s),()=>{zw()});const t=Tm(a.mul(Tm(e))).toVar();d.addAssign(n.element(e).mul(SS({theta:t.mul(-1),axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),d.addAssign(n.element(e).mul(SS({theta:t,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),Fm(d,1)}),NS=[.125,.215,.35,.446,.526,.582],CS=20,RS=new Lp(-1,1,1,-1,0,1),BS=new Od(90,1),PS=new Wc;let qS=null,DS=0,IS=0;const FS=(1+Math.sqrt(5))/2,OS=1/FS,LS=[new eh(-FS,OS,0),new eh(FS,OS,0),new eh(-OS,0,FS),new eh(OS,0,FS),new eh(0,FS,-OS),new eh(0,FS,OS),new eh(-1,1,-1),new eh(1,1,-1),new eh(-1,1,1),new eh(1,1,1)],kS=new eh,VS=new WeakMap,US=[3,1,5,0,4,2],zS=wS(xx(),bx("faceIndex")).normalize(),GS=Pm(zS.x,zS.y,zS.z);class jS{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,i=100,n={}){const{size:s=256,position:a=kS,renderTarget:o=null}=n;if(this._setSize(s),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const s=o||this._allocateTarget();return n.renderTarget=s,this.fromSceneAsync(e,t,r,i,n),s}qS=this._renderer.getRenderTarget(),DS=this._renderer.getActiveCubeFace(),IS=this._renderer.getActiveMipmapLevel();const l=o||this._allocateTarget();return l.depthBuffer=!0,this._init(l),this._sceneToCubeUV(e,r,i,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,r=.1,i=100,n={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,i,n)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=$S(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=XS(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===SA||e.mapping===EA?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(qS,DS,IS),e.scissorTest=!1,WS(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),qS=this._renderer.getRenderTarget(),DS=this._renderer.getActiveCubeFace(),IS=this._renderer.getActiveMipmapLevel();const r=t||this._allocateTarget();return this._init(r),this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTarget(){return HS(3*Math.max(this._cubeSize,112),4*this._cubeSize)}_init(e){if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=HS(e.width,e.height);const{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=function(e){const t=[],r=[],i=[],n=[];let s=e;const a=e-4+1+NS.length;for(let o=0;o<a;o++){const a=Math.pow(2,s);r.push(a);let l=1/a;o>e-4?l=NS[o-e+4-1]:0===o&&(l=0),i.push(l);const A=1/(a-2),u=-A,h=1+A,c=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,p=6,f=3,m=2,g=1,y=new Float32Array(f*p*d),b=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let e=0;e<d;e++){const t=e%3*2/3-1,r=e>2?0:-1,i=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],n=US[e];y.set(i,f*p*n),b.set(c,m*p*n);const s=[n,n,n,n,n,n];x.set(s,g*p*n)}const v=new md;v.setAttribute("position",new nd(y,f)),v.setAttribute("uv",new nd(b,m)),v.setAttribute("faceIndex",new nd(x,g)),t.push(v),n.push(new Nd(v,null)),s>4&&s--}return{lodPlanes:t,sizeLods:r,sigmas:i,lodMeshes:n}}(t)),this._blurMaterial=function(e,t,r){const i=Dx(new Array(CS).fill(0)),n=Cg(new eh(0,1,0)),s=Cg(0),a=Tm(CS),o=Cg(0),l=Cg(1),A=Nx(null),u=Cg(0),h=Tm(1/t),c=Tm(1/r),d=Tm(e),p={n:a,latitudinal:o,weights:i,poleAxis:n,outputDirection:GS,dTheta:s,samples:l,envMap:A,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d},f=QS("blur");return f.fragmentNode=ES({...p,latitudinal:o.equal(1)}),VS.set(f,p),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new Nd(this._lodPlanes[0],e);await this._renderer.compile(t,RS)}_sceneToCubeUV(e,t,r,i,n){const s=BS;s.near=t,s.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],l=this._renderer,A=l.autoClear;l.getClearColor(PS),l.autoClear=!1;let u=this._backgroundBox;if(null===u){const e=new Yc({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1});u=new Nd(new Rd,e)}let h=!1;const c=e.background;c?c.isColor&&(u.material.color.copy(c),e.background=null,h=!0):(u.material.color.copy(PS),h=!0),l.setRenderTarget(i),l.clear(),h&&l.render(u,s);for(let t=0;t<6;t++){const r=t%3;0===r?(s.up.set(0,a[t],0),s.position.set(n.x,n.y,n.z),s.lookAt(n.x+o[t],n.y,n.z)):1===r?(s.up.set(0,0,a[t]),s.position.set(n.x,n.y,n.z),s.lookAt(n.x,n.y+o[t],n.z)):(s.up.set(0,a[t],0),s.position.set(n.x,n.y,n.z),s.lookAt(n.x,n.y,n.z+o[t]));const A=this._cubeSize;WS(i,r*A,t>2?A:0,A,A),l.render(e,s)}l.autoClear=A,e.background=c}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===SA||e.mapping===EA;i?null===this._cubemapMaterial&&(this._cubemapMaterial=$S(e)):null===this._equirectMaterial&&(this._equirectMaterial=XS(e));const n=i?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=e;const s=this._lodMeshes[0];s.material=n;const a=this._cubeSize;WS(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(s,RS)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let t=1;t<i;t++){const r=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),n=LS[(i-t-1)%LS.length];this._blur(e,t-1,t,r,n)}t.autoClear=r}_blur(e,t,r,i,n){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,r,i,"latitudinal",n),this._halfBlur(s,e,r,r,i,"longitudinal",n)}_halfBlur(e,t,r,i,n,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const A=this._lodMeshes[i];A.material=l;const u=VS.get(l),h=this._sizeLods[r]-1,c=isFinite(n)?Math.PI/(2*h):2*Math.PI/39,d=n/c,p=isFinite(n)?1+Math.floor(3*d):CS;p>CS&&console.warn(`sigmaRadians, ${n}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const f=[];let m=0;for(let e=0;e<CS;++e){const t=e/d,r=Math.exp(-t*t/2);f.push(r),0===e?m+=r:e<p&&(m+=2*r)}for(let e=0;e<f.length;e++)f[e]=f[e]/m;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=p,u.weights.array=f,u.latitudinal.value="latitudinal"===s?1:0,a&&(u.poleAxis.value=a);const{_lodMax:g}=this;u.dTheta.value=c,u.mipInt.value=g-r;const y=this._sizeLods[i];WS(t,3*y*(i>g-4?i-g+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(A,RS)}}function HS(e,t){const r=new Th(e,t,{magFilter:DA,minFilter:DA,generateMipmaps:!1,type:jA,format:QA,colorSpace:Tu});return r.texture.mapping=306,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function WS(e,t,r,i,n){e.viewport.set(t,r,i,n),e.scissor.set(t,r,i,n)}function QS(e){const t=new kT;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function $S(e){const t=QS("cubemap");return t.fragmentNode=$v(e,GS),t}function XS(e){const t=QS("equirect");return t.fragmentNode=Nx(e,YT(GS),0),t}const YS=new WeakMap;function KS(e,t,r){const i=function(e){let t=YS.get(e);void 0===t&&(t=new WeakMap,YS.set(e,t));return t}(t);let n=i.get(e);if((void 0!==n?n.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let i=0;i<r;i++)void 0!==e[i]&&t++;return t===r}(t))return null;n=r.fromCubemap(e,n)}else{if(!function(e){return null!=e&&e.height>0}(t))return null;n=r.fromEquirectangular(e,n)}n.pmremVersion=e.pmremVersion,i.set(e,n)}return n.texture}class ZS extends Ef{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const i=new _h;i.isRenderTargetTexture=!0,this._texture=Nx(i),this._width=Cg(0),this._height=Cg(0),this._maxMip=Cg(0),this.updateBeforeType=mf.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,i=this._value;r!==i.pmremVersion&&(t=!0===i.isPMREMTexture?i:KS(i,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new jS(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=Vv.mul(Pm(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),TS(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const JS=fm(ZS).setParameterLength(1,3),eE=new WeakMap;class tE extends $w{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let i=eE.get(e);void 0===i&&(i=JS(e),eE.set(e,i)),r=i}const i=!0===t.useAnisotropy||t.anisotropy>0?S_:Nv,n=r.context(rE(Ym,i)).mul(kv),s=r.context(iE(Cv)).mul(Math.PI).mul(kv),a=sx(n),o=sx(s);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const l=e.context.lightingModel.clearcoatRadiance;if(l){const e=r.context(rE(Jm,Rv)).mul(kv),t=sx(e);l.addAssign(t)}}}const rE=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=yv.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(Ux)),r),getTextureLevel:()=>e}},iE=e=>({getUV:()=>e,getTextureLevel:()=>Tm(1)}),nE=new gp;class sE extends kT{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(nE),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new tE(t):null}setupLightingModel(){return new oS}setupSpecular(){const e=ub(Pm(.04),$m.rgb,Km);Ag.assign(e),ug.assign(1)}setupVariants(){const e=this.metalnessNode?Tm(this.metalnessNode):W_;Km.assign(e);let t=this.roughnessNode?Tm(this.roughnessNode):H_;t=bM({roughness:t}),Ym.assign(t),this.setupSpecular(),$m.assign(Fm($m.rgb.mul(e.oneMinus()),$m.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const aE=new yp;class oE extends sE{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(aE),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?Tm(this.iorNode):aw;mg.assign(e),Ag.assign(ub(Xy(nb(mg.sub(1).div(mg.add(1))).mul(z_),Pm(1)).mul(U_),$m.rgb,Km)),ug.assign(ub(U_,1,Km))}setupLightingModel(){return new oS(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Tm(this.clearcoatNode):$_,t=this.clearcoatRoughnessNode?Tm(this.clearcoatRoughnessNode):X_;Zm.assign(e),Jm.assign(bM({roughness:t}))}if(this.useSheen){const e=this.sheenNode?Pm(this.sheenNode):Z_,t=this.sheenRoughnessNode?Tm(this.sheenRoughnessNode):J_;eg.assign(e),tg.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Tm(this.iridescenceNode):tw,t=this.iridescenceIORNode?Tm(this.iridescenceIORNode):rw,r=this.iridescenceThicknessNode?Tm(this.iridescenceThicknessNode):iw;rg.assign(e),ig.assign(t),ng.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Nm(this.anisotropyNode):ew).toVar();ag.assign(e.length()),vm(ag.equal(0),()=>{e.assign(Nm(1,0))}).Else(()=>{e.divAssign(Nm(ag)),ag.assign(ag.saturate())}),sg.assign(ag.pow2().mix(Ym.pow2(),1)),og.assign(T_[0].mul(e.x).add(T_[1].mul(e.y))),lg.assign(T_[1].mul(e.x).sub(T_[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Tm(this.transmissionNode):nw,t=this.thicknessNode?Tm(this.thicknessNode):sw,r=this.attenuationDistanceNode?Tm(this.attenuationDistanceNode):ow,i=this.attenuationColorNode?Pm(this.attenuationColorNode):lw;if(gg.assign(e),yg.assign(t),bg.assign(r),xg.assign(i),this.useDispersion){const e=this.dispersionNode?Tm(this.dispersionNode):fw;vg.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Pm(this.clearcoatNormalNode):Y_}setup(e){e.context.setupClearcoatNormal=()=>Db(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const lE=ym(({normal:e,lightDirection:t,builder:r})=>{const i=e.dot(t),n=Nm(i.mul(.5).add(.5),0);if(r.material.gradientMap){const e=e_("gradientMap","texture").context({getUV:()=>n});return Pm(e.r)}{const e=n.fwidth().mul(.5);return ub(Pm(.7),Pm(1),pb(Tm(.7).sub(e.x),Tm(.7).add(e.x),n.x))}});class AE extends sM{direct({lightDirection:e,lightColor:t,reflectedLight:r},i){const n=lE({normal:wv,lightDirection:e,builder:i}).mul(t);r.directDiffuse.addAssign(n.mul(uM({diffuseColor:$m.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(uM({diffuseColor:$m}))),i.indirectDiffuse.mulAssign(t)}}const uE=new xp;class hE extends kT{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(uE),this.setValues(e)}setupLightingModel(){return new AE}}const cE=ym(()=>{const e=Pm(yv.z,0,yv.x.negate()).normalize(),t=yv.cross(e);return Nm(e.dot(Nv),t.dot(Nv)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),dE=new wp;class pE extends kT{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(dE),this.setValues(e)}setupVariants(e){const t=cE;let r;r=e.material.matcap?e_("matcap","texture").context({getUV:()=>t}):Pm(ub(.2,.8,t.y)),$m.rgb.mulAssign(r.rgb)}}class fE extends Ef{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),i=t.sin();return Vm(e,i,i.negate(),e).mul(r)}{const e=t,i=zm(Fm(1,0,0,0),Fm(0,Ry(e.x),Cy(e.x).negate(),0),Fm(0,Cy(e.x),Ry(e.x),0),Fm(0,0,0,1)),n=zm(Fm(Ry(e.y),0,Cy(e.y),0),Fm(0,1,0,0),Fm(Cy(e.y).negate(),0,Ry(e.y),0),Fm(0,0,0,1)),s=zm(Fm(Ry(e.z),Cy(e.z).negate(),0,0),Fm(Cy(e.z),Ry(e.z),0,0),Fm(0,0,1,0),Fm(0,0,0,1));return i.mul(n).mul(s).mul(Fm(r,1)).xyz}}}const mE=fm(fE).setParameterLength(2),gE=new Xd;class yE extends kT{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(gE),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,i=this.sizeAttenuation,{positionNode:n,rotationNode:s,scaleNode:a}=this,o=lv.mul(Pm(n||0));let l=Nm(tv[0].xyz.length(),tv[1].xyz.length());if(null!==a&&(l=l.mul(Nm(a))),!1===i)if(r.isPerspectiveCamera)l=l.mul(o.z.negate());else{const e=Tm(2).div(kx.element(1).element(1));l=l.mul(e.mul(2))}let A=cv.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>cm(new Hb(e,t,r)))("center","vec2",t);A=A.sub(e.sub(.5))}A=A.mul(l);const u=Tm(s||K_),h=mE(A,u);return Fm(o.xy.add(h),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const bE=new up;class xE extends yE{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(bE),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return lv.mul(Pm(e||dv)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:i,sizeNode:n}=this,s=cv.xy.toVar(),a=sT.z.div(sT.w);if(r&&r.isNode){const e=Tm(r);s.assign(mE(s,e))}let o=null!==n?Nm(n):pw;return!0===this.sizeAttenuation&&(o=o.mul(o.div(gv.z.negate()))),i&&i.isNode&&(o=o.mul(Nm(i))),s.mulAssign(o.mul(2)),s.assign(s.div(sT.z)),s.y.assign(s.y.mul(a)),s.assign(s.mul(t.w)),t.addAssign(Fm(s,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class vE extends sM{constructor(){super(),this.shadowNode=Tm(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){$m.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign($m.rgb)}}const _E=new mp;class wE extends kT{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(_E),this.setValues(e)}setupLightingModel(){return new vE}}Wm("vec3"),Wm("vec3"),Wm("vec3");class TE{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class ME{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r<e.length-1;r++)if(t=t.get(e[r]),void 0===t)return;return t.get(e[e.length-1])}set(e,t){let r=this.weakMap;for(let t=0;t<e.length-1;t++){const i=e[t];!1===r.has(i)&&r.set(i,new WeakMap),r=r.get(i)}return r.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let r=0;r<e.length-1;r++)if(t=t.get(e[r]),void 0===t)return!1;return t.delete(e[e.length-1])}}let SE=0;class EE{constructor(e,t,r,i,n,s,a,o,l,A){this.id=SE++,this._nodes=e,this._geometries=t,this.renderer=r,this.object=i,this.material=n,this.scene=s,this.camera=a,this.lightsNode=o,this.context=l,this.geometry=i.geometry,this.version=n.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=A,this.clippingContextCacheKey=null!==A?A.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],i=new Set,n={};for(const s of e){let e;if(s.node&&s.node.attribute?e=s.node.attribute:(e=t.getAttribute(s.name),n[s.name]=e.version),void 0===e)continue;r.push(e);const a=e.isInterleavedBufferAttribute?e.data:e;i.add(a)}return this.attributes=r,this.attributesId=n,this.vertexBuffers=Array.from(i.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:i,drawRange:n}=this,s=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let l=1;if(!0===r.isInstancedBufferGeometry?l=r.instanceCount:void 0!==e.count&&(l=Math.max(0,e.count)),0===l)return null;if(s.instanceCount=l,!0===e.isBatchedMesh)return s;let A=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(A=2);let u=n.start*A,h=(n.start+n.count)*A;null!==i&&(u=Math.max(u,i.start*A),h=Math.min(h,(i.start+i.count)*A));const c=r.attributes.position;let d=1/0;o?d=a.count:null!=c&&(d=c.count),u=Math.max(u,0),h=Math.min(h,d);const p=h-u;return p<0||p===1/0?null:(s.vertexCount=p,s.firstVertex=u,s)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const i=e.attributes[r];t+=r+",",i.data&&(t+=i.data.stride+","),i.offset&&(t+=i.offset+","),i.itemSize&&(t+=i.itemSize+","),i.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const i=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=i.length;e<r;e++){t+=i[e].id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let r=t.customProgramCacheKey();for(const e of function(e){const t=Object.keys(e);let r=Object.getPrototypeOf(e);for(;r;){const e=Object.getOwnPropertyDescriptors(r);for(const r in e)if(void 0!==e[r]){const i=e[r];i&&"function"==typeof i.get&&t.push(r)}r=Object.getPrototypeOf(r)}return t}(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;const i=t[e];let n;if(null!==i){const e=typeof i;"number"===e?n=0!==i?"1":"0":"object"===e?(n="{",i.isTexture&&(n+=i.mapping),n+="}"):n=String(i)}else n=String(i);r+=n+","}return r+=this.clippingContextCacheKey+",",e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+","),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+",",null!==e._colorsTexture&&(r+=e._colorsTexture.uuid+",")),e.count>1&&(r+=e.uuid+","),r+=e.receiveShadow+",",Kp(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(void 0===r||e[t]!==r.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Jp(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Jp(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const NE=[];class CE{constructor(e,t,r,i,n,s){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=i,this.bindings=n,this.info=s,this.chainMaps={}}get(e,t,r,i,n,s,a,o){const l=this.getChainMap(o);NE[0]=e,NE[1]=t,NE[2]=s,NE[3]=n;let A=l.get(NE);return void 0===A?(A=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,i,n,s,a,o),l.set(NE,A)):(A.updateClipping(a),A.needsGeometryUpdate&&A.setGeometry(e.geometry),(A.version!==t.version||A.needsUpdate)&&(A.initialCacheKey!==A.getCacheKey()?(A.dispose(),A=this.get(e,t,r,i,n,s,a,o)):A.version=t.version)),NE.length=0,A}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new ME)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,i,n,s,a,o,l,A,u){const h=this.getChainMap(u),c=new EE(e,t,r,i,n,s,a,o,l,A);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.delete(c),this.nodes.delete(c),h.delete(c.getChainArray())},c}}class RE{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const BE=1,PE=2,qE=3,DE=4,IE=16;class FE extends RE{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===BE?this.backend.createAttribute(e):t===PE?this.backend.createIndexAttribute(e):t===qE?this.backend.createStorageAttribute(e):t===DE&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version<t.version||t.usage===Ou)&&(this.backend.updateAttribute(e),r.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function OE(e){return null!==e.index?e.index.version:e.attributes.position.version}function LE(e){const t=[],r=e.index,i=e.attributes.position;if(null!==r){const e=r.array;for(let r=0,i=e.length;r<i;r+=3){const i=e[r+0],n=e[r+1],s=e[r+2];t.push(i,n,n,s,s,i)}}else{for(let e=0,r=i.array.length/3-1;e<r;e+=3){const r=e+0,i=e+1,n=e+2;t.push(r,i,i,n,n,r)}}const n=new(sh(t)?ad:sd)(t,1);return n.version=OE(e),n}class kE extends RE{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const i=t.index,n=e.getAttributes();null!==i&&this.attributes.delete(i);for(const e of n)this.attributes.delete(e);const s=this.wireframes.get(t);void 0!==s&&this.attributes.delete(s),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,qE):this.updateAttribute(e,BE);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,PE);const i=e.geometry.indirect;null!==i&&this.updateAttribute(i,DE)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let i=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=LE(t),e.set(t,r)):r.version!==OE(t)&&(this.attributes.delete(r),r=LE(t),e.set(t,r)),i=r}return i}}class VE{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class UE{constructor(e){this.cacheKey=e,this.usedTimes=0}}class zE extends UE{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class GE extends UE{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let jE=0;class HE{constructor(e,t,r,i=null,n=null){this.id=jE++,this.code=e,this.stage=t,this.name=r,this.transforms=i,this.attributes=n,this.usedTimes=0}}class WE extends RE{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,i=this.get(e);if(this._needsComputeUpdate(e)){const n=i.pipeline;n&&(n.usedTimes--,n.computeProgram.usedTimes--);const s=this.nodes.getForCompute(e);let a=this.programs.compute.get(s.computeShader);void 0===a&&(n&&0===n.computeProgram.usedTimes&&this._releaseProgram(n.computeProgram),a=new HE(s.computeShader,"compute",e.name,s.transforms,s.nodeAttributes),this.programs.compute.set(s.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let l=this.caches.get(o);void 0===l&&(n&&0===n.usedTimes&&this._releasePipeline(n),l=this._getComputePipeline(e,a,o,t)),l.usedTimes++,a.usedTimes++,i.version=e.version,i.pipeline=l}return i.pipeline}getForRender(e,t=null){const{backend:r}=this,i=this.get(e);if(this._needsRenderUpdate(e)){const n=i.pipeline;n&&(n.usedTimes--,n.vertexProgram.usedTimes--,n.fragmentProgram.usedTimes--);const s=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(s.vertexShader);void 0===o&&(n&&0===n.vertexProgram.usedTimes&&this._releaseProgram(n.vertexProgram),o=new HE(s.vertexShader,"vertex",a),this.programs.vertex.set(s.vertexShader,o),r.createProgram(o));let l=this.programs.fragment.get(s.fragmentShader);void 0===l&&(n&&0===n.fragmentProgram.usedTimes&&this._releaseProgram(n.fragmentProgram),l=new HE(s.fragmentShader,"fragment",a),this.programs.fragment.set(s.fragmentShader,l),r.createProgram(l));const A=this._getRenderCacheKey(e,o,l);let u=this.caches.get(A);void 0===u?(n&&0===n.usedTimes&&this._releasePipeline(n),u=this._getRenderPipeline(e,o,l,A,t)):e.pipeline=u,u.usedTimes++,o.usedTimes++,l.usedTimes++,i.pipeline=u}return i.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,i){r=r||this._getComputeCacheKey(e,t);let n=this.caches.get(r);return void 0===n&&(n=new GE(r,t),this.caches.set(r,n),this.backend.createComputePipeline(n,i)),n}_getRenderPipeline(e,t,r,i,n){i=i||this._getRenderCacheKey(e,t,r);let s=this.caches.get(i);return void 0===s&&(s=new zE(i,t,r),this.caches.set(i,s),e.pipeline=s,this.backend.createRenderPipeline(e,n)),s}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class QE extends RE{constructor(e,t,r,i,n,s){super(),this.backend=e,this.textures=r,this.pipelines=n,this.attributes=i,this.nodes=t,this.info=s,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?DE:qE;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let i=!1,n=!0,s=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?DE:qE;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(i=!0);const o=t.update(),l=t.texture;o&&this.textures.updateTexture(l);const A=r.get(l);if(void 0!==A.externalTexture||e.isDefaultTexture?n=!1:(s=10*s+l.id,a+=l.version),!0===r.isWebGPUBackend&&void 0===A.texture&&void 0===A.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,l,t.textureNode.value,i),this.textures.updateTexture(l),i=!0),!0===l.isStorageTexture){const e=this.get(l);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(l)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(l),e.needsMipmap=!1)}}}!0===i&&this.backend.updateBindings(e,t,n?s:0,a)}}function $E(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function XE(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function YE(e){return(e.transmission>0||e.transmissionNode)&&2===e.side&&!1===e.forceSinglePass}class KE{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,i,n,s,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:i,renderOrder:e.renderOrder,z:n,group:s,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=i,o.renderOrder=e.renderOrder,o.z=n,o.group=s,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,i,n,s,a){const o=this.getNextRenderItem(e,t,r,i,n,s,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(YE(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,i,n,s,a){const o=this.getNextRenderItem(e,t,r,i,n,s,a);!0===r.transparent||r.transmission>0?(YE(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||$E),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||XE),this.transparent.length>1&&this.transparent.sort(t||XE)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const t=this.renderItems[e];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.groupOrder=null,t.renderOrder=null,t.z=null,t.group=null,t.clippingContext=null}}}const ZE=[];class JE{constructor(e){this.lighting=e,this.lists=new ME}get(e,t){const r=this.lists;ZE[0]=e,ZE[1]=t;let i=r.get(ZE);return void 0===i&&(i=new KE(this.lighting,e,t),r.set(ZE,i)),ZE.length=0,i}dispose(){this.lists=new ME}}let eN=0;class tN{constructor(){this.id=eN++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new wh,this.scissor=!1,this.scissorValue=new wh,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return rN(this)}}function rN(e){const{textures:t,activeCubeFace:r}=e,i=[r];for(const e of t)i.push(e.id);return Zp(i)}const iN=[],nN=new Hd,sN=new qd;class aN{constructor(){this.chainMaps={}}get(e,t,r=null){let i;if(iN[0]=e,iN[1]=t,null===r)i="default";else{const e=r.texture.format;i=`${r.textures.length}:${e}:${r.samples}:${r.depthBuffer}:${r.stencilBuffer}`}const n=this._getChainMap(i);let s=n.get(iN);return void 0===s&&(s=new tN,n.set(iN,s)),iN.length=0,null!==r&&(s.sampleCount=0===r.samples?1:r.samples),s}getForClear(e=null){return this.get(nN,sN,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new ME)}dispose(){this.chainMaps={}}}const oN=new eh;class lN extends RE{constructor(e,t,r){super(),this.renderer=e,this.backend=t,this.info=r}updateRenderTarget(e,t=0){const r=this.get(e),i=0===e.samples?1:e.samples,n=r.depthTextureMips||(r.depthTextureMips={}),s=e.textures,a=this.getSize(s[0]),o=a.width>>t,l=a.height>>t;let A=e.depthTexture||n[t];const u=!0===e.depthBuffer||!0===e.stencilBuffer;let h=!1;void 0===A&&u&&(A=new cp,A.format=e.stencilBuffer?XA:$A,A.type=e.stencilBuffer?HA:zA,A.image.width=o,A.image.height=l,A.image.depth=a.depth,A.isArrayTexture=!0===e.multiview&&a.depth>1,n[t]=A),r.width===a.width&&a.height===r.height||(h=!0,A&&(A.needsUpdate=!0,A.image.width=o,A.image.height=l,A.image.depth=A.isArrayTexture?A.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=s,r.depthTexture=A||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==i&&(h=!0,A&&(A.needsUpdate=!0),r.sampleCount=i);const c={sampleCount:i};if(!0!==e.isXRRenderTarget){for(let e=0;e<s.length;e++){const t=s[e];h&&(t.needsUpdate=!0),this.updateTexture(t,c)}A&&this.updateTexture(A,c)}if(!0!==r.initialized){r.initialized=!0;const t=()=>{e.removeEventListener("dispose",t);for(let e=0;e<s.length;e++)this._destroyTexture(s[e]);A&&this._destroyTexture(A),this.delete(e)};e.addEventListener("dispose",t)}}updateTexture(e,t={}){const r=this.get(e);if(!0===r.initialized&&r.version===e.version)return;const i=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,n=this.backend;if(i&&!0===r.initialized&&(n.destroySampler(e),n.destroyTexture(e)),e.isFramebufferTexture){const t=this.renderer.getRenderTarget();e.type=t?t.texture.type:OA}const{width:s,height:a,depth:o}=this.getSize(e);if(t.width=s,t.height=a,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,s,a):1,i||!0===e.isStorageTexture)n.createSampler(e),n.createTexture(e,t),r.generation=e.version;else{if(!0!==r.initialized&&n.createSampler(e),e.version>0){const i=e.image;if(void 0===i)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===i.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=i;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(n.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&n.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&n.generateMipmaps(e)}}else n.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=oN){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let i;return i=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,i}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class AN extends Wc{constructor(e,t,r,i=1){super(e,t,r),this.a=i}set(e,t,r,i=1){return this.a=i,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class uN extends Hm{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class hN extends Tf{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new hm(t);return this._currentCond=Tb(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new hm(t),i=Tb(e,r);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new hm(e),this}Switch(e){return this._expressionNode=cm(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r<e.length-1;r++)t.push(this._expressionNode.equal(cm(e[r])));const r=new hm(e[e.length-1]);let i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);const n=Tb(i,r);return null===this._currentCond?(this._currentCond=n,this.add(this._currentCond)):(this._currentCond.elseNode=n,this._currentCond=n,this)}Default(e){return this.Else(e),this}build(e,...t){const r=e.currentStack,i=xm();bm(this),e.currentStack=this;const n=e.buildStage;for(const t of this.nodes)if("setup"===n)t.build(e);else if("analyze"===n)t.build(e,this);else if("generate"===n){const r=e.getDataFromNode(t,"any").stages,i=r&&r[e.shaderStage];if(t.isVarNode&&i&&1===i.length&&i[0]&&i[0].isStackNode)continue;t.build(e,"void")}const s=this.outputNode?this.outputNode.build(e,...t):super.build(e,...t);return bm(i),e.currentStack=r,s}}const cN=fm(hN).setParameterLength(0,1);class dN extends Tf{static get type(){return"StructTypeNode"}constructor(e,t=null){var r;super("struct"),this.membersLayout=(r=e,Object.entries(r).map(([e,t])=>"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const i=r.type,n=lf(i)*e,s=t%8,a=s%Af(i),o=s+a;t+=a,0!==o&&8-o<n&&(t+=8-o),t+=n}return 8*Math.ceil(t/8)/e}getMemberType(e,t){const r=this.membersLayout.find(e=>e.name===t);return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class pN extends Tf{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,i=e.getPropertyName(t);return e.addLineFlowCode(`${i} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class fN extends Tf{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,i=[];for(let t=0;t<r.length;t++){const n="m"+t,s=r[t].getNodeType(e);i.push({name:n,type:s,index:t})}t.membersLayout=i,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){const t=e.getOutputStructName(),r=this.members,i=""!==t?t+".":"";for(let t=0;t<r.length;t++){const n=r[t].build(e);e.addLineFlowCode(`${i}m${t} = ${n}`,this)}return t}}const mN=fm(fN);function gN(e,t){for(let r=0;r<e.length;r++)if(e[r].name===t)return r;return-1}class yN extends fN{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return void 0!==this.outputNodes[e]}get(e){return this.outputNodes[e]}merge(e){const t={...this.outputNodes,...e.outputNodes};return bN(t)}setup(e){const t=this.outputNodes,r=[],i=e.renderer.getRenderTarget().textures;for(const e in t){r[gN(i,e)]=Fm(t[e])}return this.members=r,super.setup(e)}}const bN=fm(yN),xN=ym(([e])=>{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)}),vN=(e,t)=>ib(Vg(4,e.mul(kg(1,e))),t),_N=ym(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),wN=ym(([e])=>Pm(_N(e.z.add(_N(e.y.mul(1)))),_N(e.z.add(_N(e.x.mul(1)))),_N(e.y.add(_N(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),TN=ym(([e,t,r])=>{const i=Pm(e).toVar(),n=Tm(1.4).toVar(),s=Tm(0).toVar(),a=Pm(i).toVar();return Uw({start:Tm(0),end:Tm(3),type:"float",condition:"<="},()=>{const e=Pm(wN(a.mul(2))).toVar();i.addAssign(e.add(r.mul(Tm(.1).mul(t)))),a.mulAssign(1.8),n.mulAssign(1.5),i.mulAssign(1.2);const o=Tm(_N(i.z.add(_N(i.x.add(_N(i.y)))))).toVar();s.addAssign(o.div(n)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class MN extends Tf{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let i=null,n=-1;for(const r of this.functionNodes){const s=r.shaderNode.layout;if(null===s)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=s.inputs;if(t.length===a.length){let s=0;for(let r=0;r<t.length;r++){const i=t[r],n=a[r];i.getNodeType(e)===n.type?s++:s=0}s>n&&(i=r,n=s)}}this._candidateFnCall=r=i(...t)}return r}}const SN=fm(MN),EN=e=>(...t)=>SN(e,...t),NN=Cg(0).setGroup(Sg).onRenderUpdate(e=>e.time),CN=Cg(0).setGroup(Sg).onRenderUpdate(e=>e.deltaTime),RN=Cg(0,"uint").setGroup(Sg).onRenderUpdate(e=>e.frameId),BN=ym(([e,t,r=Nm(.5)])=>mE(e.sub(r),t).add(r)),PN=ym(([e,t,r=Nm(.5)])=>{const i=e.sub(r),n=i.dot(i),s=n.mul(n).mul(t);return e.add(i.mul(s))}),qN=ym(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let i;null!==e?(i=tv.toVar(),i[3][0]=e.x,i[3][1]=e.y,i[3][2]=e.z):i=tv;const n=Ux.mul(i);return Am(t)&&(n[0][0]=tv[0].length(),n[0][1]=0,n[0][2]=0),Am(r)&&(n[1][0]=0,n[1][1]=tv[1].length(),n[1][2]=0),n[2][0]=0,n[2][1]=0,n[2][2]=1,kx.mul(n).mul(dv)}),DN=ym(([e=null])=>{const t=TT();return TT(mT(e)).sub(t).lessThan(0).select(rT,e)});class IN extends Tf{static get type(){return"SpriteSheetUVNode"}constructor(e,t=xx(),r=Tm(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:i,height:n}=r,s=e.mod(i.mul(n)).floor(),a=s.mod(i),o=n.sub(s.add(1).div(i).ceil()),l=r.reciprocal(),A=Nm(a,o);return t.add(A).mul(l)}}const FN=fm(IN).setParameterLength(3),ON=ym(([e,t=null,r=null,i=Tm(1),n=dv,s=Tv])=>{let a=s.abs().normalize();a=a.div(a.dot(Pm(1)));const o=n.yz.mul(i),l=n.zx.mul(i),A=n.xy.mul(i),u=e.value,h=null!==t?t.value:u,c=null!==r?r.value:u,d=Nx(u,o).mul(a.x),p=Nx(h,l).mul(a.y),f=Nx(c,A).mul(a.z);return Lg(d,p,f)}),LN=new tp,kN=new eh,VN=new eh,UN=new eh,zN=new ec,GN=new eh(0,0,-1),jN=new wh,HN=new eh,WN=new eh,QN=new wh,$N=new Zu,XN=new Th,YN=rT.flipX();XN.depthTexture=new cp(1,1);let KN=!1;class ZN extends Sx{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||XN.texture,YN),this._reflectorBaseNode=e.reflector||new JN(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=cm(new ZN({defaultTexture:XN.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class JN extends Tf{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Ec,resolution:i=1,generateMipmaps:n=!1,bounces:s=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=i,this.generateMipmaps=n,this.bounces=s,this.depth=a,this.updateBeforeType=s?mf.RENDER:mf.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize($N),e.setSize(Math.round($N.width*r),Math.round($N.height*r))}setup(e){return this._updateResolution(XN,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new Th(0,0,{type:jA}),!0===this.generateMipmaps&&(t.texture.minFilter=1008,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new cp),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&KN)return!1;KN=!0;const{scene:t,camera:r,renderer:i,material:n}=e,{target:s}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);i.getDrawingBufferSize($N),this._updateResolution(o,i),VN.setFromMatrixPosition(s.matrixWorld),UN.setFromMatrixPosition(r.matrixWorld),zN.extractRotation(s.matrixWorld),kN.set(0,0,1),kN.applyMatrix4(zN),HN.subVectors(VN,UN);let l=!1;if(!0===HN.dot(kN)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(KN=!1);l=!0}HN.reflect(kN).negate(),HN.add(VN),zN.extractRotation(r.matrixWorld),GN.set(0,0,-1),GN.applyMatrix4(zN),GN.add(UN),WN.subVectors(VN,GN),WN.reflect(kN).negate(),WN.add(VN),a.coordinateSystem=r.coordinateSystem,a.position.copy(HN),a.up.set(0,1,0),a.up.applyMatrix4(zN),a.up.reflect(kN),a.lookAt(WN),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),LN.setFromNormalAndCoplanarPoint(kN,VN),LN.applyMatrix4(a.matrixWorldInverse),jN.set(LN.normal.x,LN.normal.y,LN.normal.z,LN.constant);const A=a.projectionMatrix;QN.x=(Math.sign(jN.x)+A.elements[8])/A.elements[0],QN.y=(Math.sign(jN.y)+A.elements[9])/A.elements[5],QN.z=-1,QN.w=(1+A.elements[10])/A.elements[14],jN.multiplyScalar(1/jN.dot(QN));A.elements[2]=jN.x,A.elements[6]=jN.y,A.elements[10]=i.coordinateSystem===ku?jN.z-0:jN.z+1-0,A.elements[14]=jN.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),n.visible=!1;const u=i.getRenderTarget(),h=i.getMRT(),c=i.autoClear;i.setMRT(null),i.setRenderTarget(o),i.autoClear=!0,l?(i.clear(),this.hasOutput=!1):(i.render(t,a),this.hasOutput=!0),i.setMRT(h),i.setRenderTarget(u),i.autoClear=c,n.visible=!0,KN=!1,this.forceUpdate=!1}}const eC=new Lp(-1,1,1,-1,0,1);class tC extends md{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new ld([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ld(t,2))}}const rC=new tC;class iC extends Nd{constructor(e=null){super(rC,e),this.camera=eC,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,eC)}render(e){e.render(this,eC)}}const nC=new Zu;class sC extends Sx{static get type(){return"RTTNode"}constructor(e,t=null,r=null,i={type:jA}){const n=new Th(t,r,i);super(n.texture,xx()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=n,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new iC(new kT),this.updateBeforeType=mf.RENDER}get autoResize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,i=t*this.pixelRatio;this.renderTarget.setSize(r,i),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoResize){const t=e.getPixelRatio(),r=e.getSize(nC),i=r.width*t,n=r.height*t;i===this.renderTarget.width&&n===this.renderTarget.height||(this.renderTarget.setSize(i,n),this.textureNeedsUpdate=!0)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Sx(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const aC=(e,...t)=>cm(new sC(cm(e),...t)),oC=ym(([e,t,r],i)=>{let n;i.renderer.coordinateSystem===ku?(e=Nm(e.x,e.y.oneMinus()).mul(2).sub(1),n=Fm(Pm(e,t),1)):n=Fm(Pm(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const s=Fm(r.mul(n));return s.xyz.div(s.w)}),lC=ym(([e,t])=>{const r=t.mul(Fm(e,1)),i=r.xy.div(r.w).mul(.5).add(.5).toVar();return Nm(i.x,i.y.oneMinus())}),AC=ym(([e,t,r])=>{const i=_x(Cx(t)),n=Cm(e.mul(i)).toVar(),s=Cx(t,n).toVar(),a=Cx(t,n.sub(Cm(2,0))).toVar(),o=Cx(t,n.sub(Cm(1,0))).toVar(),l=Cx(t,n.add(Cm(1,0))).toVar(),A=Cx(t,n.add(Cm(2,0))).toVar(),u=Cx(t,n.add(Cm(0,2))).toVar(),h=Cx(t,n.add(Cm(0,1))).toVar(),c=Cx(t,n.sub(Cm(0,1))).toVar(),d=Cx(t,n.sub(Cm(0,2))).toVar(),p=Iy(kg(Tm(2).mul(o).sub(a),s)).toVar(),f=Iy(kg(Tm(2).mul(l).sub(A),s)).toVar(),m=Iy(kg(Tm(2).mul(h).sub(u),s)).toVar(),g=Iy(kg(Tm(2).mul(c).sub(d),s)).toVar(),y=oC(e,s,r).toVar(),b=p.lessThan(f).select(y.sub(oC(e.sub(Nm(Tm(1).div(i.x),0)),o,r)),y.negate().add(oC(e.add(Nm(Tm(1).div(i.x),0)),l,r))),x=m.lessThan(g).select(y.sub(oC(e.add(Nm(0,Tm(1).div(i.y))),h,r)),y.negate().add(oC(e.sub(Nm(0,Tm(1).div(i.y))),c,r)));return Ey(rb(b,x))});class uC extends Tf{static get type(){return"SampleNode"}constructor(e){super(),this.callback=e,this.isSampleNode=!0}setup(){return this.sample(xx())}sample(e){return this.callback(e)}}class hC extends Kd{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class cC extends nd{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class dC extends Tf{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const pC=mm(dC),fC=new uc,mC=new ec;class gC extends Tf{static get type(){return"SceneNode"}constructor(e=gC.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let i;return t===gC.BACKGROUND_BLURRINESS?i=Kv("backgroundBlurriness","float",r):t===gC.BACKGROUND_INTENSITY?i=Kv("backgroundIntensity","float",r):t===gC.BACKGROUND_ROTATION?i=Cg("mat4").label("backgroundRotation").setGroup(Sg).onRenderUpdate(()=>{const e=r.background;return null!==e&&e.isTexture&&300!==e.mapping?(fC.copy(r.backgroundRotation),fC.x*=-1,fC.y*=-1,fC.z*=-1,mC.makeRotationFromEuler(fC)):mC.identity(),mC}):console.error("THREE.SceneNode: Unknown scope:",t),i}}gC.BACKGROUND_BLURRINESS="backgroundBlurriness",gC.BACKGROUND_INTENSITY="backgroundIntensity",gC.BACKGROUND_ROTATION="backgroundRotation";const yC=mm(gC,gC.BACKGROUND_BLURRINESS),bC=mm(gC,gC.BACKGROUND_INTENSITY),xC=mm(gC,gC.BACKGROUND_ROTATION);class vC extends Sx{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=gf.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(gf.READ_WRITE)}toReadOnly(){return this.setAccess(gf.READ_ONLY)}toWriteOnly(){return this.setAccess(gf.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:i,depthNode:n}=t,s=super.generate(e,"property"),a=r.build(e,"uvec2"),o=i.build(e,"vec4"),l=n?n.build(e,"int"):null,A=e.generateTextureStore(e,s,a,l,o);e.addLineFlowCode(A,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const _C=fm(vC).setParameterLength(1,3),wC=ym(({texture:e,uv:t})=>{const r=1e-4,i=Pm().toVar();return vm(t.x.lessThan(r),()=>{i.assign(Pm(1,0,0))}).ElseIf(t.y.lessThan(r),()=>{i.assign(Pm(0,1,0))}).ElseIf(t.z.lessThan(r),()=>{i.assign(Pm(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{i.assign(Pm(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{i.assign(Pm(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{i.assign(Pm(0,0,-1))}).Else(()=>{const r=.01,n=e.sample(t.add(Pm(-.01,0,0))).r.sub(e.sample(t.add(Pm(r,0,0))).r),s=e.sample(t.add(Pm(0,-.01,0))).r.sub(e.sample(t.add(Pm(0,r,0))).r),a=e.sample(t.add(Pm(0,0,-.01))).r.sub(e.sample(t.add(Pm(0,0,r))).r);i.assign(Pm(n,s,a))}),i.normalize()});class TC extends Sx{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Pm(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(Mm(_x(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return wC({texture:this,uv:e})}}const MC=fm(TC).setParameterLength(1,3);class SC extends Yv{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const EC=new WeakMap;class NC extends Ef{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=mf.OBJECT,this.updateAfterType=mf.OBJECT,this.previousModelWorldMatrix=Cg(new ec),this.previousProjectionMatrix=Cg(new ec).setGroup(Sg),this.previousCameraViewMatrix=Cg(new ec)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const i=RC(r);this.previousModelWorldMatrix.value.copy(i);const n=CC(t);n.frameId!==e&&(n.frameId=e,void 0===n.previousProjectionMatrix?(n.previousProjectionMatrix=new ec,n.previousCameraViewMatrix=new ec,n.currentProjectionMatrix=new ec,n.currentCameraViewMatrix=new ec,n.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),n.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(n.previousProjectionMatrix.copy(n.currentProjectionMatrix),n.previousCameraViewMatrix.copy(n.currentCameraViewMatrix)),n.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),n.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(n.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(n.previousCameraViewMatrix))}updateAfter({object:e}){RC(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?kx:Cg(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(lv).mul(dv),i=this.previousProjectionMatrix.mul(t).mul(pv),n=r.xy.div(r.w),s=i.xy.div(i.w);return kg(n,s)}}function CC(e){let t=EC.get(e);return void 0===t&&(t={},EC.set(e,t)),t}function RC(e,t=0){const r=CC(e);let i=r[t];return void 0===i&&(r[t]=i=new ec,r[t].copy(e.matrixWorld)),i}const BC=mm(NC),PC=ym(([e])=>FC(e.rgb)),qC=ym(([e,t=Tm(1)])=>t.mix(FC(e.rgb),e.rgb)),DC=ym(([e,t=Tm(1)])=>{const r=Lg(e.r,e.g,e.b).div(3),i=e.r.max(e.g.max(e.b)),n=i.sub(r).mul(t).mul(-3);return ub(e.rgb,i,n)}),IC=ym(([e,t=Tm(1)])=>{const r=Pm(.57735,.57735,.57735),i=t.cos();return Pm(e.rgb.mul(i).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(tb(r,e.rgb).mul(i.oneMinus())))))}),FC=(e,t=Pm(ch.getLuminanceCoefficients(new eh)))=>tb(e,t),OC=ym(([e,t=Pm(1),r=Pm(0),i=Pm(1),n=Tm(1),s=Pm(ch.getLuminanceCoefficients(new eh,Tu))])=>{const a=e.rgb.dot(Pm(s)),o=Yy(e.rgb.mul(t).add(r),0).toVar(),l=o.pow(i).toVar();return vm(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),vm(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),vm(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(n))),Fm(o.rgb,e.a)});class LC extends Ef{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const kC=fm(LC).setParameterLength(2),VC=new Zu;class UC extends Sx{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class zC extends UC{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}class GC extends Ef{static get type(){return"PassNode"}constructor(e,t,r,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const n=new cp;n.isRenderTargetTexture=!0,n.name="depth";const s=new Th(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:jA,...i});s.texture.name="output",s.depthTexture=n,this.renderTarget=s,this._textures={output:s.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Cg(0),this._cameraFar=Cg(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=mf.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],i=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[i]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=cm(new zC(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=cm(new zC(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=xT(this.getTextureNode(e),r,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,i=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=t=yT(n,r,i)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===GC.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let i,n;const s=t.getOutputRenderTarget();s&&!0===s.isXRRenderTarget?(n=1,i=t.xr.getCamera(),t.xr.updateCamera(i),VC.set(s.width,s.height)):(i=this.camera,n=t.getPixelRatio(),t.getSize(VC)),this._pixelRatio=n,this.setSize(VC.width,VC.height);const a=t.getRenderTarget(),o=t.getMRT(),l=i.layers.mask;this._cameraNear.value=i.near,this._cameraFar.value=i.far,null!==this._layers&&(i.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,i),t.setRenderTarget(a),t.setMRT(o),i.layers.mask=l}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,i=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}GC.COLOR="color",GC.DEPTH="depth";class jC extends GC{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,i,n){super(GC.COLOR,e,t),this.colorNode=r,this.thicknessNode=i,this.alphaNode=n,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((e,r,i,n,s,a,o,l)=>{if((s.isMeshToonMaterial||s.isMeshToonNodeMaterial)&&!1===s.wireframe){const A=this._getOutlineMaterial(s);t.renderObject(e,r,i,n,A,a,o,l)}t.renderObject(e,r,i,n,s,a,o,l)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new kT;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=1;const t=Tv.negate(),r=kx.mul(lv),i=Tm(1),n=r.mul(Fm(dv,1)),s=r.mul(Fm(dv.add(t),1)),a=Ey(n.sub(s));return e.vertexNode=n.add(a.mul(this.thicknessNode).mul(n.w).mul(i)),e.colorNode=Fm(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const HC=ym(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),WC=ym(([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),QC=ym(([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),i=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),$C=ym(([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)}),XC=ym(([e,t])=>{const r=Um(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=Um(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=$C(e),(e=i.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),YC=Um(Pm(1.6605,-.1246,-.0182),Pm(-.5876,1.1329,-.1006),Pm(-.0728,-.0083,1.1187)),KC=Um(Pm(.6274,.0691,.0164),Pm(.3293,.9195,.088),Pm(.0433,.0113,.8956)),ZC=ym(([e])=>{const t=Pm(e).toVar(),r=Pm(t.mul(t)).toVar(),i=Pm(r.mul(r)).toVar();return Tm(15.5).mul(i.mul(r)).sub(Vg(40.14,i.mul(t))).add(Vg(31.96,i).sub(Vg(6.868,r.mul(t))).add(Vg(.4298,r).add(Vg(.1191,t).sub(.00232))))}),JC=ym(([e,t])=>{const r=Pm(e).toVar(),i=Um(Pm(.856627153315983,.137318972929847,.11189821299995),Pm(.0951212405381588,.761241990602591,.0767994186031903),Pm(.0482516061458583,.101439036467562,.811302368396859)),n=Um(Pm(1.1271005818144368,-.1413297634984383,-.14132976349843826),Pm(-.11060664309660323,1.157823702216272,-.11060664309660294),Pm(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=Tm(-12.47393),a=Tm(4.026069);return r.mulAssign(t),r.assign(KC.mul(r)),r.assign(i.mul(r)),r.assign(Yy(r,1e-10)),r.assign(_y(r)),r.assign(r.sub(s).div(a.sub(s))),r.assign(hb(r,0,1)),r.assign(ZC(r)),r.assign(n.mul(r)),r.assign(ib(Yy(Pm(0),r),Pm(2.2))),r.assign(YC.mul(r)),r.assign(hb(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),eR=ym(([e,t])=>{const r=Tm(.76),i=Tm(.15);e=e.mul(t);const n=Xy(e.r,Xy(e.g,e.b)),s=Tb(n.lessThan(.08),n.sub(Vg(6.25,n.mul(n))),.04);e.subAssign(s);const a=Yy(e.r,Yy(e.g,e.b));vm(a.lessThan(r),()=>e);const o=kg(1,r),l=kg(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(l.div(a));const A=kg(1,Ug(1,i.mul(a.sub(l)).add(1)));return ub(e,Pm(l),A)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class tR extends Tf{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const rR=fm(tR).setParameterLength(1,3);class iR extends tR{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),i=r.name,n=r.type,s=e.getCodeFromNode(this,n);""!==i&&(s.name=i);const a=e.getPropertyName(s),o=this.getNodeFunction(e).getCode(a);return s.code=o+"\n","property"===t?a:e.format(`${a}()`,n,t)}}const nR=(e,t=[],r="")=>{for(let e=0;e<t.length;e++){const r=t[e];"function"==typeof r&&(t[e]=r.functionNode)}const i=cm(new iR(e,t,r)),n=(...e)=>i.call(...e);return n.functionNode=i,n};class sR extends Tf{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Vu,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:Tm()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=df(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?pf(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const aR=fm(sR).setParameterLength(1);class oR extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const i=t(...r);return this.set(e,i),i}}}class lR{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const AR=new oR;class uR extends Tf{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new oR,this._output=aR(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=aR(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=aR(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new lR(this),t=AR.get("THREE"),r=AR.get("TSL"),i=this.getMethod(),n=[e,this._local,AR,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=i(...n);const s=this._object.layout;if(s&&(!1===s.cache&&this._local.clear(),this._output.outputType=s.outputType||null,Array.isArray(s.elements)))for(const e of s.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:Tm()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[Kp(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return Zp(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const hR=fm(uR).setParameterLength(1,2);function cR(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||gv.z).negate()}const dR=ym(([e,t],r)=>{const i=cR(r);return pb(e,t,i)}),pR=ym(([e],t)=>{const r=cR(t);return e.mul(e,r,r).negate().exp().oneMinus()}),fR=ym(([e,t])=>Fm(t.toFloat().mix(cg.rgb,e.toVec3()),cg.a));let mR=null,gR=null;class yR extends Tf{static get type(){return"RangeNode"}constructor(e=Tm(),t=Tm()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(uf(this.minNode.value)),r=e.getTypeLength(uf(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,s=e.getTypeLength(uf(i)),a=e.getTypeLength(uf(n));mR=mR||new wh,gR=gR||new wh,mR.setScalar(0),gR.setScalar(0),1===s?mR.setScalar(i):i.isColor?mR.set(i.r,i.g,i.b,1):mR.set(i.x,i.y,i.z||0,i.w||0),1===a?gR.setScalar(n):n.isColor?gR.set(n.r,n.g,n.b,1):gR.set(n.x,n.y,n.z||0,n.w||0);const o=4,l=o*t.count,A=new Float32Array(l);for(let e=0;e<l;e++){const t=e%o,r=mR.getComponent(t),i=gR.getComponent(t);A[e]=Ku.lerp(r,i,Math.random())}const u=this.getNodeType(e);if(t.count<=4096)r=Bx(A,"vec4",t.count).element(_w).convert(u);else{const t=new Kd(A,4);e.geometry.setAttribute("__range"+this.id,t),r=ex(t).convert(u)}}else r=Tm(0);return r}}const bR=fm(yR).setParameterLength(2);class xR extends Tf{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){const r=this.getBuiltinName(e),i=this.getNodeType(e);return"compute"===e.shaderStage?e.format(r,i,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${r} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(i))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const vR=(e,t)=>cm(new xR(e,t)),_R=vR("numWorkgroups","uvec3"),wR=vR("workgroupId","uvec3"),TR=vR("globalId","uvec3"),MR=vR("localId","uvec3"),SR=vR("subgroupSize","uint");const ER=fm(class extends Tf{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class NR extends Mf{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const i=e.context.assign;if(r=super.generate(e),!0!==i){const i=this.getNodeType(e);r=e.format(r,i,t)}return r}}class CR extends Tf{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return cm(new NR(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class RR extends Tf{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,i=this.method,n=this.getNodeType(e),s=this.getInputType(e),a=this.pointerNode,o=this.valueNode,l=[];l.push(`&${a.build(e,s)}`),null!==o&&l.push(o.build(e,s));const A=`${e.getMethod(i,n)}( ${l.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=cx(A,n).toConst()),t.constNode.build(e);e.addLineFlowCode(A,this)}}RR.ATOMIC_LOAD="atomicLoad",RR.ATOMIC_STORE="atomicStore",RR.ATOMIC_ADD="atomicAdd",RR.ATOMIC_SUB="atomicSub",RR.ATOMIC_MAX="atomicMax",RR.ATOMIC_MIN="atomicMin",RR.ATOMIC_AND="atomicAnd",RR.ATOMIC_OR="atomicOr",RR.ATOMIC_XOR="atomicXor";const BR=fm(RR),PR=(e,t,r)=>BR(e,t,r).toStack();let qR;function DR(e){qR=qR||new WeakMap;let t=qR.get(e);return void 0===t&&qR.set(e,t={}),t}function IR(e){const t=DR(e);return t.shadowMatrix||(t.shadowMatrix=Cg("mat4").setGroup(Sg).onRenderUpdate(t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix)))}function FR(e,t=fv){const r=IR(e).mul(t);return r.xyz.div(r.w)}function OR(e){const t=DR(e);return t.position||(t.position=Cg(new eh).setGroup(Sg).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function LR(e){const t=DR(e);return t.targetPosition||(t.targetPosition=Cg(new eh).setGroup(Sg).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function kR(e){const t=DR(e);return t.viewPosition||(t.viewPosition=Cg(new eh).setGroup(Sg).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new eh,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}const VR=e=>Ux.transformDirection(OR(e).sub(LR(e))),UR=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},zR=new WeakMap,GR=[];class jR extends Tf{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Wm("vec3","totalDiffuse"),this.totalSpecularNode=Wm("vec3","totalSpecular"),this.outgoingLightNode=Wm("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;t<e.length;t++){const r=e[t];if(GR.push(r.id),GR.push(r.castShadow?1:0),!0===r.isSpotLight){const e=null!==r.map?r.map.id:-1,t=r.colorNode?r.colorNode.getCacheKey():-1;GR.push(e,t)}}const t=Zp(GR);return GR.length=0,t}getHash(e){if(null===this._lightNodesHash){null===this._lightNodes&&this.setupLightsNode(e);const t=[];for(const e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getNodeProperties(this);for(const r of t.nodes)r.build(e);t.outputNode.build(e)}setupLightsNode(e){const t=[],r=this._lightNodes,i=(e=>e.sort((e,t)=>e.id-t.id))(this._lights),n=e.renderer.library;for(const e of i)if(e.isNode)t.push(cm(e));else{let i=null;if(null!==r&&(i=UR(e.id,r)),null===i){const r=n.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let i=null;zR.has(e)?i=zR.get(e):(i=cm(new r(e)),zR.set(e,i)),t.push(i)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:i,reflectedLight:n}=e.context;i.direct({...r,lightNode:t,reflectedLight:n},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:i,reflectedLight:n}=e.context;i.directRectArea({...r,lightNode:t,reflectedLight:n},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const i=e.context,n=i.lightingModel,s=e.getNodeProperties(this);if(n){const{totalDiffuseNode:t,totalSpecularNode:a}=this;i.outgoingLight=r;const o=e.addStack();s.nodes=o.nodes,n.start(e);const{backdrop:l,backdropAlpha:A}=i,{directDiffuse:u,directSpecular:h,indirectDiffuse:c,indirectSpecular:d}=i.reflectedLight;let p=u.add(c);null!==l&&(p=Pm(null!==A?A.mix(p,l):l),i.material.transparent=!0),t.assign(p),a.assign(h.add(d)),r.assign(t.add(a)),n.finish(e),r=r.bypass(e.removeStack())}else s.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class HR extends Tf{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=mf.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){WR.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||fv)}}const WR=Wm("vec3","shadowPositionWorld");function QR(e,t){return t=function(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new Wc),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}const $R=new WeakMap,XR=ym(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=Nx(e,t.xy).label("t_basic");return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)}),YR=ym(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{const n=(t,r)=>{let n=Nx(e,t);return e.isArrayTexture&&(n=n.depth(i)),n.compare(r)},s=Kv("mapSize","vec2",r).setGroup(Sg),a=Kv("radius","float",r).setGroup(Sg),o=Nm(1).div(s),l=o.x.negate().mul(a),A=o.y.negate().mul(a),u=o.x.mul(a),h=o.y.mul(a),c=l.div(2),d=A.div(2),p=u.div(2),f=h.div(2);return Lg(n(t.xy.add(Nm(l,A)),t.z),n(t.xy.add(Nm(0,A)),t.z),n(t.xy.add(Nm(u,A)),t.z),n(t.xy.add(Nm(c,d)),t.z),n(t.xy.add(Nm(0,d)),t.z),n(t.xy.add(Nm(p,d)),t.z),n(t.xy.add(Nm(l,0)),t.z),n(t.xy.add(Nm(c,0)),t.z),n(t.xy,t.z),n(t.xy.add(Nm(p,0)),t.z),n(t.xy.add(Nm(u,0)),t.z),n(t.xy.add(Nm(c,f)),t.z),n(t.xy.add(Nm(0,f)),t.z),n(t.xy.add(Nm(p,f)),t.z),n(t.xy.add(Nm(l,h)),t.z),n(t.xy.add(Nm(0,h)),t.z),n(t.xy.add(Nm(u,h)),t.z)).mul(1/17)}),KR=ym(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{const n=(t,r)=>{let n=Nx(e,t);return e.isArrayTexture&&(n=n.depth(i)),n.compare(r)},s=Kv("mapSize","vec2",r).setGroup(Sg),a=Nm(1).div(s),o=a.x,l=a.y,A=t.xy,u=Ny(A.mul(s).add(.5));return A.subAssign(u.mul(a)),Lg(n(A,t.z),n(A.add(Nm(o,0)),t.z),n(A.add(Nm(0,l)),t.z),n(A.add(a),t.z),ub(n(A.add(Nm(o.negate(),0)),t.z),n(A.add(Nm(o.mul(2),0)),t.z),u.x),ub(n(A.add(Nm(o.negate(),l)),t.z),n(A.add(Nm(o.mul(2),l)),t.z),u.x),ub(n(A.add(Nm(0,l.negate())),t.z),n(A.add(Nm(0,l.mul(2))),t.z),u.y),ub(n(A.add(Nm(o,l.negate())),t.z),n(A.add(Nm(o,l.mul(2))),t.z),u.y),ub(ub(n(A.add(Nm(o.negate(),l.negate())),t.z),n(A.add(Nm(o.mul(2),l.negate())),t.z),u.x),ub(n(A.add(Nm(o.negate(),l.mul(2))),t.z),n(A.add(Nm(o.mul(2),l.mul(2))),t.z),u.x),u.y)).mul(1/9)}),ZR=ym(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const i=Tm(1).toVar();let n=Nx(e).sample(t.xy);e.isArrayTexture&&(n=n.depth(r)),n=n.rg;const s=Ky(t.z,n.x);return vm(s.notEqual(Tm(1)),()=>{const e=t.z.sub(n.x),r=Yy(0,n.y.mul(n.y));let a=r.div(r.add(e.mul(e)));a=hb(kg(a,.3).div(.95-.3)),i.assign(hb(Yy(s,a)))}),i}),JR=ym(([e,t,r])=>{let i=fv.sub(e).length();return i=i.sub(t).div(r.sub(t)),i=i.saturate(),i}),eB=e=>{let t=$R.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=Kv("near","float",t).setGroup(Sg),i=Kv("far","float",t).setGroup(Sg),n=Xx(e);return JR(n,r,i)})(e):null;t=new kT,t.colorNode=Fm(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,$R.set(e,t)}return t},tB=new ME,rB=[],iB=(e,t,r,i)=>{rB[0]=e,rB[1]=t;let n=tB.get(rB);return void 0!==n&&n.shadowType===r&&n.useVelocity===i||(n=(n,s,a,o,l,A,...u)=>{(!0===n.castShadow||n.receiveShadow&&3===r)&&(i&&(cf(n).useVelocity=!0),n.onBeforeShadow(e,n,a,t.camera,o,s.overrideMaterial,A),e.renderObject(n,s,a,o,l,A,...u),n.onAfterShadow(e,n,a,t.camera,o,s.overrideMaterial,A))},n.shadowType=r,n.useVelocity=i,tB.set(rB,n)),rB[0]=null,rB[1]=null,n},nB=ym(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:n})=>{const s=Tm(0).toVar("meanVertical"),a=Tm(0).toVar("squareMeanVertical"),o=e.lessThanEqual(Tm(1)).select(Tm(0),Tm(2).div(e.sub(1))),l=e.lessThanEqual(Tm(1)).select(Tm(0),Tm(-1));Uw({start:Mm(0),end:Mm(e),type:"int",condition:"<"},({i:e})=>{const A=l.add(Tm(e).mul(o));let u=i.sample(Lg(nT.xy,Nm(0,A).mul(t)).div(r));i.value.isArrayTexture&&(u=u.depth(n)),u=u.x,s.addAssign(u),a.addAssign(u.mul(u))}),s.divAssign(e),a.divAssign(e);const A=wy(a.sub(s.mul(s)));return Nm(s,A)}),sB=ym(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:n})=>{const s=Tm(0).toVar("meanHorizontal"),a=Tm(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(Tm(1)).select(Tm(0),Tm(2).div(e.sub(1))),l=e.lessThanEqual(Tm(1)).select(Tm(0),Tm(-1));Uw({start:Mm(0),end:Mm(e),type:"int",condition:"<"},({i:e})=>{const A=l.add(Tm(e).mul(o));let u=i.sample(Lg(nT.xy,Nm(A,0).mul(t)).div(r));i.value.isArrayTexture&&(u=u.depth(n)),s.addAssign(u.x),a.addAssign(Lg(u.y.mul(u.y),u.x.mul(u.x)))}),s.divAssign(e),a.divAssign(e);const A=wy(a.sub(s.mul(s)));return Nm(s,A)}),aB=[XR,YR,KR,ZR];let oB;const lB=new iC;class AB extends HR{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:i,shadow:n,depthLayer:s}){const a=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),o=t({depthTexture:r,shadowCoord:i,shadow:n,depthLayer:s});return a.select(o,Tm(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:i}=e,n=Kv("bias","float",r).setGroup(Sg);let s,a=t;if(r.camera.isOrthographicCamera||!0!==i.logarithmicDepthBuffer)a=a.xyz.div(a.w),s=a.z,i.coordinateSystem===ku&&(s=s.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=Kv("near","float",r.camera).setGroup(Sg),i=Kv("far","float",r.camera).setGroup(Sg);s=vT(e.negate(),t,i)}return a=Pm(a.x,a.y.oneMinus(),s.add(n)),a}getShadowFilterFn(e){return aB[e]}setupRenderTarget(e,t){const r=new cp(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=513;const i=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return i.texture.name="ShadowMap",i.texture.type=e.mapType,i.depthTexture=r,{shadowMap:i,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:i}=this,n=t.shadowMap.type,{depthTexture:s,shadowMap:a}=this.setupRenderTarget(i,e);if(i.camera.updateProjectionMatrix(),3===n&&!0!==i.isPointLightShadow){s.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ZA,type:jA,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ZA,type:jA,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ZA,type:jA,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ZA,type:jA,depthBuffer:!1}));let t=Nx(s);s.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Nx(this.vsmShadowMapVertical.texture);s.isArrayTexture&&(r=r.depth(this.depthLayer));const n=Kv("blurSamples","float",i).setGroup(Sg),o=Kv("radius","float",i).setGroup(Sg),l=Kv("mapSize","vec2",i).setGroup(Sg);let A=this.vsmMaterialVertical||(this.vsmMaterialVertical=new kT);A.fragmentNode=nB({samples:n,radius:o,size:l,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),A.name="VSMVertical",A=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new kT),A.fragmentNode=sB({samples:n,radius:o,size:l,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),A.name="VSMHorizontal"}const o=Kv("intensity","float",i).setGroup(Sg),l=Kv("normalBias","float",i).setGroup(Sg),A=IR(r).mul(WR.add(Cv.mul(l))),u=this.setupShadowCoord(e,A),h=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===h)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const c=3===n&&!0!==i.isPointLightShadow?this.vsmShadowMapHorizontal.texture:s,d=this.setupShadowFilter(e,{filterFn:h,shadowTexture:a.texture,depthTexture:c,shadowCoord:u,shadow:i,depthLayer:this.depthLayer});let p=Nx(a.texture,u);s.isArrayTexture&&(p=p.depth(this.depthLayer));const f=ub(1,d.rgb.mix(p,1),o.mul(p.a)).toVar();return this.shadowMap=a,this.shadow.map=a,f}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ym(()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:r,light:i}=this,{renderer:n,scene:s}=e;t.updateMatrices(i),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),n.render(s,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:i}=this,{renderer:n,scene:s,camera:a}=e,o=n.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const A=i.camera.layers.mask;4294967294&i.camera.layers.mask||(i.camera.layers.mask=a.layers.mask);const u=n.getRenderObjectFunction(),h=n.getMRT(),c=!!h&&h.has("velocity");oB=function(e,t,r){return r=function(e,t){return t=function(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}(t,r=QR(e,r)),r}(n,s,oB),s.overrideMaterial=eB(r),n.setRenderObjectFunction(iB(n,i,o,c)),n.setClearColor(0,0),n.setRenderTarget(t),this.renderShadow(e),n.setRenderObjectFunction(u),3===o&&!0!==i.isPointLightShadow&&this.vsmPass(n),i.camera.layers.mask=A,function(e,t,r){!function(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}(e,r),function(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}(t,r)}(n,s,oB)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),lB.material=this.vsmMaterialVertical,lB.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),lB.material=this.vsmMaterialHorizontal,lB.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const uB=(e,t)=>cm(new AB(e,t)),hB=new Wc,cB=ym(([e,t])=>{const r=e.toVar(),i=Iy(r),n=Ug(1,Yy(i.x,Yy(i.y,i.z)));i.mulAssign(n),r.mulAssign(n.mul(t.mul(2).oneMinus()));const s=Nm(r.xy).toVar(),a=t.mul(1.5).oneMinus();return vm(i.z.greaterThanEqual(a),()=>{vm(r.z.greaterThan(0),()=>{s.x.assign(kg(4,r.x))})}).ElseIf(i.x.greaterThanEqual(a),()=>{const e=Fy(r.x);s.x.assign(r.z.mul(e).add(e.mul(2)))}).ElseIf(i.y.greaterThanEqual(a),()=>{const e=Fy(r.y);s.x.assign(r.x.add(e.mul(2)).add(2)),s.y.assign(r.z.mul(e).sub(2))}),Nm(.125,.25).mul(s).add(Nm(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),dB=ym(({depthTexture:e,bd3D:t,dp:r,texelSize:i})=>Nx(e,cB(t,i.y)).compare(r)),pB=ym(({depthTexture:e,bd3D:t,dp:r,texelSize:i,shadow:n})=>{const s=Kv("radius","float",n).setGroup(Sg),a=Nm(-1,1).mul(s).mul(i.y);return Nx(e,cB(t.add(a.xyy),i.y)).compare(r).add(Nx(e,cB(t.add(a.yyy),i.y)).compare(r)).add(Nx(e,cB(t.add(a.xyx),i.y)).compare(r)).add(Nx(e,cB(t.add(a.yyx),i.y)).compare(r)).add(Nx(e,cB(t,i.y)).compare(r)).add(Nx(e,cB(t.add(a.xxy),i.y)).compare(r)).add(Nx(e,cB(t.add(a.yxy),i.y)).compare(r)).add(Nx(e,cB(t.add(a.xxx),i.y)).compare(r)).add(Nx(e,cB(t.add(a.yxx),i.y)).compare(r)).mul(1/9)}),fB=ym(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:i})=>{const n=r.xyz.toVar(),s=n.length(),a=Cg("float").setGroup(Sg).onRenderUpdate(()=>i.camera.near),o=Cg("float").setGroup(Sg).onRenderUpdate(()=>i.camera.far),l=Kv("bias","float",i).setGroup(Sg),A=Cg(i.mapSize).setGroup(Sg),u=Tm(1).toVar();return vm(s.sub(o).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),()=>{const r=s.sub(a).div(o.sub(a)).toVar();r.addAssign(l);const h=n.normalize(),c=Nm(1).div(A.mul(Nm(4,2)));u.assign(e({depthTexture:t,bd3D:h,dp:r,texelSize:c,shadow:i}))}),u}),mB=new wh,gB=new Zu,yB=new Zu;class bB extends AB{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return 0===e?dB:pB}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:i,shadowCoord:n,shadow:s}){return fB({filterFn:t,shadowTexture:r,depthTexture:i,shadowCoord:n,shadow:s})}renderShadow(e){const{shadow:t,shadowMap:r,light:i}=this,{renderer:n,scene:s}=e,a=t.getFrameExtents();yB.copy(t.mapSize),yB.multiply(a),r.setSize(yB.width,yB.height),gB.copy(t.mapSize);const o=n.autoClear,l=n.getClearColor(hB),A=n.getClearAlpha();n.autoClear=!1,n.setClearColor(t.clearColor,t.clearAlpha),n.clear();const u=t.getViewportCount();for(let e=0;e<u;e++){const a=t.getViewport(e),o=gB.x*a.x,l=yB.y-gB.y-gB.y*a.y;mB.set(o,l,gB.x*a.z,gB.y*a.w),r.viewport.copy(mB),t.updateMatrices(i,e),n.render(s,t.camera)}n.autoClear=o,n.setClearColor(l,A)}}const xB=(e,t)=>cm(new bB(e,t));class vB extends $w{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Wc,this.colorNode=e&&e.colorNode||Cg(this.color).setGroup(Sg),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=mf.FRAME}getHash(){return this.light.uuid}getLightVector(e){return kR(this.light).sub(e.context.positionView||gv)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return uB(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?cm(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const _B=ym(({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const i=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(i.mul(e.div(t).pow4().oneMinus().clamp().pow2()),i)}),wB=({color:e,lightVector:t,cutoffDistance:r,decayExponent:i})=>{const n=t.normalize(),s=t.length(),a=_B({lightDistance:s,cutoffDistance:r,decayExponent:i});return{lightDirection:n,lightColor:e.mul(a)}};class TB extends vB{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Cg(0).setGroup(Sg),this.decayExponentNode=Cg(2).setGroup(Sg)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return xB(this.light)}setupDirect(e){return wB({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const MB=ym(([e=xx()])=>{const t=e.mul(2),r=t.x.floor(),i=t.y.floor();return r.add(i).mod(2).sign()}),SB=ym(([e=xx()],{renderer:t,material:r})=>{const i=Ab(e.mul(2).sub(1));let n;if(r.alphaToCoverage&&t.samples>1){const e=Tm(i.fwidth()).toVar();n=pb(e.oneMinus(),e.add(1),i).oneMinus()}else n=Tb(i.greaterThan(1),0,1);return n}),EB=ym(([e,t,r])=>{const i=Tm(r).toVar(),n=Tm(t).toVar(),s=Em(e).toVar();return Tb(s,n,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),NB=ym(([e,t])=>{const r=Em(t).toVar(),i=Tm(e).toVar();return Tb(r,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),CB=ym(([e])=>{const t=Tm(e).toVar();return Mm(My(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),RB=ym(([e,t])=>{const r=Tm(e).toVar();return t.assign(CB(r)),r.sub(Tm(t))}),BB=EN([ym(([e,t,r,i,n,s])=>{const a=Tm(s).toVar(),o=Tm(n).toVar(),l=Tm(i).toVar(),A=Tm(r).toVar(),u=Tm(t).toVar(),h=Tm(e).toVar(),c=Tm(kg(1,o)).toVar();return kg(1,a).mul(h.mul(c).add(u.mul(o))).add(a.mul(A.mul(c).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),ym(([e,t,r,i,n,s])=>{const a=Tm(s).toVar(),o=Tm(n).toVar(),l=Pm(i).toVar(),A=Pm(r).toVar(),u=Pm(t).toVar(),h=Pm(e).toVar(),c=Tm(kg(1,o)).toVar();return kg(1,a).mul(h.mul(c).add(u.mul(o))).add(a.mul(A.mul(c).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),PB=EN([ym(([e,t,r,i,n,s,a,o,l,A,u])=>{const h=Tm(u).toVar(),c=Tm(A).toVar(),d=Tm(l).toVar(),p=Tm(o).toVar(),f=Tm(a).toVar(),m=Tm(s).toVar(),g=Tm(n).toVar(),y=Tm(i).toVar(),b=Tm(r).toVar(),x=Tm(t).toVar(),v=Tm(e).toVar(),_=Tm(kg(1,d)).toVar(),w=Tm(kg(1,c)).toVar();return Tm(kg(1,h)).toVar().mul(w.mul(v.mul(_).add(x.mul(d))).add(c.mul(b.mul(_).add(y.mul(d))))).add(h.mul(w.mul(g.mul(_).add(m.mul(d))).add(c.mul(f.mul(_).add(p.mul(d))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),ym(([e,t,r,i,n,s,a,o,l,A,u])=>{const h=Tm(u).toVar(),c=Tm(A).toVar(),d=Tm(l).toVar(),p=Pm(o).toVar(),f=Pm(a).toVar(),m=Pm(s).toVar(),g=Pm(n).toVar(),y=Pm(i).toVar(),b=Pm(r).toVar(),x=Pm(t).toVar(),v=Pm(e).toVar(),_=Tm(kg(1,d)).toVar(),w=Tm(kg(1,c)).toVar();return Tm(kg(1,h)).toVar().mul(w.mul(v.mul(_).add(x.mul(d))).add(c.mul(b.mul(_).add(y.mul(d))))).add(h.mul(w.mul(g.mul(_).add(m.mul(d))).add(c.mul(f.mul(_).add(p.mul(d))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),qB=ym(([e,t,r])=>{const i=Tm(r).toVar(),n=Tm(t).toVar(),s=Sm(e).toVar(),a=Sm(s.bitAnd(Sm(7))).toVar(),o=Tm(EB(a.lessThan(Sm(4)),n,i)).toVar(),l=Tm(Vg(2,EB(a.lessThan(Sm(4)),i,n))).toVar();return NB(o,Em(a.bitAnd(Sm(1)))).add(NB(l,Em(a.bitAnd(Sm(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),DB=ym(([e,t,r,i])=>{const n=Tm(i).toVar(),s=Tm(r).toVar(),a=Tm(t).toVar(),o=Sm(e).toVar(),l=Sm(o.bitAnd(Sm(15))).toVar(),A=Tm(EB(l.lessThan(Sm(8)),a,s)).toVar(),u=Tm(EB(l.lessThan(Sm(4)),s,EB(l.equal(Sm(12)).or(l.equal(Sm(14))),a,n))).toVar();return NB(A,Em(l.bitAnd(Sm(1)))).add(NB(u,Em(l.bitAnd(Sm(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),IB=EN([qB,DB]),FB=ym(([e,t,r])=>{const i=Tm(r).toVar(),n=Tm(t).toVar(),s=Dm(e).toVar();return Pm(IB(s.x,n,i),IB(s.y,n,i),IB(s.z,n,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),OB=ym(([e,t,r,i])=>{const n=Tm(i).toVar(),s=Tm(r).toVar(),a=Tm(t).toVar(),o=Dm(e).toVar();return Pm(IB(o.x,a,s,n),IB(o.y,a,s,n),IB(o.z,a,s,n))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),LB=EN([FB,OB]),kB=ym(([e])=>{const t=Tm(e).toVar();return Vg(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),VB=ym(([e])=>{const t=Tm(e).toVar();return Vg(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),UB=EN([kB,ym(([e])=>{const t=Pm(e).toVar();return Vg(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),zB=EN([VB,ym(([e])=>{const t=Pm(e).toVar();return Vg(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),GB=ym(([e,t])=>{const r=Mm(t).toVar(),i=Sm(e).toVar();return i.shiftLeft(r).bitOr(i.shiftRight(Mm(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),jB=ym(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(GB(r,Mm(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(GB(e,Mm(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(GB(t,Mm(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(GB(r,Mm(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(GB(e,Mm(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(GB(t,Mm(4))),t.addAssign(e)}),HB=ym(([e,t,r])=>{const i=Sm(r).toVar(),n=Sm(t).toVar(),s=Sm(e).toVar();return i.bitXorAssign(n),i.subAssign(GB(n,Mm(14))),s.bitXorAssign(i),s.subAssign(GB(i,Mm(11))),n.bitXorAssign(s),n.subAssign(GB(s,Mm(25))),i.bitXorAssign(n),i.subAssign(GB(n,Mm(16))),s.bitXorAssign(i),s.subAssign(GB(i,Mm(4))),n.bitXorAssign(s),n.subAssign(GB(s,Mm(14))),i.bitXorAssign(n),i.subAssign(GB(n,Mm(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),WB=ym(([e])=>{const t=Sm(e).toVar();return Tm(t).div(Tm(Sm(Mm(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),QB=ym(([e])=>{const t=Tm(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),$B=EN([ym(([e])=>{const t=Mm(e).toVar(),r=Sm(Sm(1)).toVar(),i=Sm(Sm(Mm(3735928559)).add(r.shiftLeft(Sm(2))).add(Sm(13))).toVar();return HB(i.add(Sm(t)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ym(([e,t])=>{const r=Mm(t).toVar(),i=Mm(e).toVar(),n=Sm(Sm(2)).toVar(),s=Sm().toVar(),a=Sm().toVar(),o=Sm().toVar();return s.assign(a.assign(o.assign(Sm(Mm(3735928559)).add(n.shiftLeft(Sm(2))).add(Sm(13))))),s.addAssign(Sm(i)),a.addAssign(Sm(r)),HB(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Mm(t).toVar(),s=Mm(e).toVar(),a=Sm(Sm(3)).toVar(),o=Sm().toVar(),l=Sm().toVar(),A=Sm().toVar();return o.assign(l.assign(A.assign(Sm(Mm(3735928559)).add(a.shiftLeft(Sm(2))).add(Sm(13))))),o.addAssign(Sm(s)),l.addAssign(Sm(n)),A.addAssign(Sm(i)),HB(o,l,A)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ym(([e,t,r,i])=>{const n=Mm(i).toVar(),s=Mm(r).toVar(),a=Mm(t).toVar(),o=Mm(e).toVar(),l=Sm(Sm(4)).toVar(),A=Sm().toVar(),u=Sm().toVar(),h=Sm().toVar();return A.assign(u.assign(h.assign(Sm(Mm(3735928559)).add(l.shiftLeft(Sm(2))).add(Sm(13))))),A.addAssign(Sm(o)),u.addAssign(Sm(a)),h.addAssign(Sm(s)),jB(A,u,h),A.addAssign(Sm(n)),HB(A,u,h)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),ym(([e,t,r,i,n])=>{const s=Mm(n).toVar(),a=Mm(i).toVar(),o=Mm(r).toVar(),l=Mm(t).toVar(),A=Mm(e).toVar(),u=Sm(Sm(5)).toVar(),h=Sm().toVar(),c=Sm().toVar(),d=Sm().toVar();return h.assign(c.assign(d.assign(Sm(Mm(3735928559)).add(u.shiftLeft(Sm(2))).add(Sm(13))))),h.addAssign(Sm(A)),c.addAssign(Sm(l)),d.addAssign(Sm(o)),jB(h,c,d),h.addAssign(Sm(a)),c.addAssign(Sm(s)),HB(h,c,d)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),XB=EN([ym(([e,t])=>{const r=Mm(t).toVar(),i=Mm(e).toVar(),n=Sm($B(i,r)).toVar(),s=Dm().toVar();return s.x.assign(n.bitAnd(Mm(255))),s.y.assign(n.shiftRight(Mm(8)).bitAnd(Mm(255))),s.z.assign(n.shiftRight(Mm(16)).bitAnd(Mm(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Mm(t).toVar(),s=Mm(e).toVar(),a=Sm($B(s,n,i)).toVar(),o=Dm().toVar();return o.x.assign(a.bitAnd(Mm(255))),o.y.assign(a.shiftRight(Mm(8)).bitAnd(Mm(255))),o.z.assign(a.shiftRight(Mm(16)).bitAnd(Mm(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),YB=ym(([e])=>{const t=Nm(e).toVar(),r=Mm().toVar(),i=Mm().toVar(),n=Tm(RB(t.x,r)).toVar(),s=Tm(RB(t.y,i)).toVar(),a=Tm(QB(n)).toVar(),o=Tm(QB(s)).toVar(),l=Tm(BB(IB($B(r,i),n,s),IB($B(r.add(Mm(1)),i),n.sub(1),s),IB($B(r,i.add(Mm(1))),n,s.sub(1)),IB($B(r.add(Mm(1)),i.add(Mm(1))),n.sub(1),s.sub(1)),a,o)).toVar();return UB(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),KB=ym(([e])=>{const t=Pm(e).toVar(),r=Mm().toVar(),i=Mm().toVar(),n=Mm().toVar(),s=Tm(RB(t.x,r)).toVar(),a=Tm(RB(t.y,i)).toVar(),o=Tm(RB(t.z,n)).toVar(),l=Tm(QB(s)).toVar(),A=Tm(QB(a)).toVar(),u=Tm(QB(o)).toVar(),h=Tm(PB(IB($B(r,i,n),s,a,o),IB($B(r.add(Mm(1)),i,n),s.sub(1),a,o),IB($B(r,i.add(Mm(1)),n),s,a.sub(1),o),IB($B(r.add(Mm(1)),i.add(Mm(1)),n),s.sub(1),a.sub(1),o),IB($B(r,i,n.add(Mm(1))),s,a,o.sub(1)),IB($B(r.add(Mm(1)),i,n.add(Mm(1))),s.sub(1),a,o.sub(1)),IB($B(r,i.add(Mm(1)),n.add(Mm(1))),s,a.sub(1),o.sub(1)),IB($B(r.add(Mm(1)),i.add(Mm(1)),n.add(Mm(1))),s.sub(1),a.sub(1),o.sub(1)),l,A,u)).toVar();return zB(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),ZB=EN([YB,KB]),JB=ym(([e])=>{const t=Nm(e).toVar(),r=Mm().toVar(),i=Mm().toVar(),n=Tm(RB(t.x,r)).toVar(),s=Tm(RB(t.y,i)).toVar(),a=Tm(QB(n)).toVar(),o=Tm(QB(s)).toVar(),l=Pm(BB(LB(XB(r,i),n,s),LB(XB(r.add(Mm(1)),i),n.sub(1),s),LB(XB(r,i.add(Mm(1))),n,s.sub(1)),LB(XB(r.add(Mm(1)),i.add(Mm(1))),n.sub(1),s.sub(1)),a,o)).toVar();return UB(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),eP=ym(([e])=>{const t=Pm(e).toVar(),r=Mm().toVar(),i=Mm().toVar(),n=Mm().toVar(),s=Tm(RB(t.x,r)).toVar(),a=Tm(RB(t.y,i)).toVar(),o=Tm(RB(t.z,n)).toVar(),l=Tm(QB(s)).toVar(),A=Tm(QB(a)).toVar(),u=Tm(QB(o)).toVar(),h=Pm(PB(LB(XB(r,i,n),s,a,o),LB(XB(r.add(Mm(1)),i,n),s.sub(1),a,o),LB(XB(r,i.add(Mm(1)),n),s,a.sub(1),o),LB(XB(r.add(Mm(1)),i.add(Mm(1)),n),s.sub(1),a.sub(1),o),LB(XB(r,i,n.add(Mm(1))),s,a,o.sub(1)),LB(XB(r.add(Mm(1)),i,n.add(Mm(1))),s.sub(1),a,o.sub(1)),LB(XB(r,i.add(Mm(1)),n.add(Mm(1))),s,a.sub(1),o.sub(1)),LB(XB(r.add(Mm(1)),i.add(Mm(1)),n.add(Mm(1))),s.sub(1),a.sub(1),o.sub(1)),l,A,u)).toVar();return zB(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),tP=EN([JB,eP]),rP=EN([ym(([e])=>{const t=Tm(e).toVar(),r=Mm(CB(t)).toVar();return WB($B(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ym(([e])=>{const t=Nm(e).toVar(),r=Mm(CB(t.x)).toVar(),i=Mm(CB(t.y)).toVar();return WB($B(r,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ym(([e])=>{const t=Pm(e).toVar(),r=Mm(CB(t.x)).toVar(),i=Mm(CB(t.y)).toVar(),n=Mm(CB(t.z)).toVar();return WB($B(r,i,n))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ym(([e])=>{const t=Fm(e).toVar(),r=Mm(CB(t.x)).toVar(),i=Mm(CB(t.y)).toVar(),n=Mm(CB(t.z)).toVar(),s=Mm(CB(t.w)).toVar();return WB($B(r,i,n,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),iP=EN([ym(([e])=>{const t=Tm(e).toVar(),r=Mm(CB(t)).toVar();return Pm(WB($B(r,Mm(0))),WB($B(r,Mm(1))),WB($B(r,Mm(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ym(([e])=>{const t=Nm(e).toVar(),r=Mm(CB(t.x)).toVar(),i=Mm(CB(t.y)).toVar();return Pm(WB($B(r,i,Mm(0))),WB($B(r,i,Mm(1))),WB($B(r,i,Mm(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ym(([e])=>{const t=Pm(e).toVar(),r=Mm(CB(t.x)).toVar(),i=Mm(CB(t.y)).toVar(),n=Mm(CB(t.z)).toVar();return Pm(WB($B(r,i,n,Mm(0))),WB($B(r,i,n,Mm(1))),WB($B(r,i,n,Mm(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ym(([e])=>{const t=Fm(e).toVar(),r=Mm(CB(t.x)).toVar(),i=Mm(CB(t.y)).toVar(),n=Mm(CB(t.z)).toVar(),s=Mm(CB(t.w)).toVar();return Pm(WB($B(r,i,n,s,Mm(0))),WB($B(r,i,n,s,Mm(1))),WB($B(r,i,n,s,Mm(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),nP=ym(([e,t,r,i])=>{const n=Tm(i).toVar(),s=Tm(r).toVar(),a=Mm(t).toVar(),o=Pm(e).toVar(),l=Tm(0).toVar(),A=Tm(1).toVar();return Uw(a,()=>{l.addAssign(A.mul(ZB(o))),A.mulAssign(n),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),sP=ym(([e,t,r,i])=>{const n=Tm(i).toVar(),s=Tm(r).toVar(),a=Mm(t).toVar(),o=Pm(e).toVar(),l=Pm(0).toVar(),A=Tm(1).toVar();return Uw(a,()=>{l.addAssign(A.mul(tP(o))),A.mulAssign(n),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),aP=ym(([e,t,r,i])=>{const n=Tm(i).toVar(),s=Tm(r).toVar(),a=Mm(t).toVar(),o=Pm(e).toVar();return Nm(nP(o,a,s,n),nP(o.add(Pm(Mm(19),Mm(193),Mm(17))),a,s,n))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),oP=ym(([e,t,r,i])=>{const n=Tm(i).toVar(),s=Tm(r).toVar(),a=Mm(t).toVar(),o=Pm(e).toVar(),l=Pm(sP(o,a,s,n)).toVar(),A=Tm(nP(o.add(Pm(Mm(19),Mm(193),Mm(17))),a,s,n)).toVar();return Fm(l,A)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),lP=ym(([e,t,r,i,n,s,a])=>{const o=Mm(a).toVar(),l=Tm(s).toVar(),A=Mm(n).toVar(),u=Mm(i).toVar(),h=Mm(r).toVar(),c=Mm(t).toVar(),d=Nm(e).toVar(),p=Pm(iP(Nm(c.add(u),h.add(A)))).toVar(),f=Nm(p.x,p.y).toVar();f.subAssign(.5),f.mulAssign(l),f.addAssign(.5);const m=Nm(Nm(Tm(c),Tm(h)).add(f)).toVar(),g=Nm(m.sub(d)).toVar();return vm(o.equal(Mm(2)),()=>Iy(g.x).add(Iy(g.y))),vm(o.equal(Mm(3)),()=>Yy(Iy(g.x),Iy(g.y))),tb(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),AP=ym(([e,t,r,i,n,s,a,o,l])=>{const A=Mm(l).toVar(),u=Tm(o).toVar(),h=Mm(a).toVar(),c=Mm(s).toVar(),d=Mm(n).toVar(),p=Mm(i).toVar(),f=Mm(r).toVar(),m=Mm(t).toVar(),g=Pm(e).toVar(),y=Pm(iP(Pm(m.add(d),f.add(c),p.add(h)))).toVar();y.subAssign(.5),y.mulAssign(u),y.addAssign(.5);const b=Pm(Pm(Tm(m),Tm(f),Tm(p)).add(y)).toVar(),x=Pm(b.sub(g)).toVar();return vm(A.equal(Mm(2)),()=>Iy(x.x).add(Iy(x.y)).add(Iy(x.z))),vm(A.equal(Mm(3)),()=>Yy(Iy(x.x),Iy(x.y),Iy(x.z))),tb(x,x)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),uP=EN([lP,AP]),hP=ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Tm(t).toVar(),s=Nm(e).toVar(),a=Mm().toVar(),o=Mm().toVar(),l=Nm(RB(s.x,a),RB(s.y,o)).toVar(),A=Tm(1e6).toVar();return Uw({start:-1,end:Mm(1),name:"x",condition:"<="},({x:e})=>{Uw({start:-1,end:Mm(1),name:"y",condition:"<="},({y:t})=>{const r=Tm(uP(l,e,t,a,o,n,i)).toVar();A.assign(Xy(A,r))})}),vm(i.equal(Mm(0)),()=>{A.assign(wy(A))}),A}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),cP=ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Tm(t).toVar(),s=Nm(e).toVar(),a=Mm().toVar(),o=Mm().toVar(),l=Nm(RB(s.x,a),RB(s.y,o)).toVar(),A=Nm(1e6,1e6).toVar();return Uw({start:-1,end:Mm(1),name:"x",condition:"<="},({x:e})=>{Uw({start:-1,end:Mm(1),name:"y",condition:"<="},({y:t})=>{const r=Tm(uP(l,e,t,a,o,n,i)).toVar();vm(r.lessThan(A.x),()=>{A.y.assign(A.x),A.x.assign(r)}).ElseIf(r.lessThan(A.y),()=>{A.y.assign(r)})})}),vm(i.equal(Mm(0)),()=>{A.assign(wy(A))}),A}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),dP=ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Tm(t).toVar(),s=Nm(e).toVar(),a=Mm().toVar(),o=Mm().toVar(),l=Nm(RB(s.x,a),RB(s.y,o)).toVar(),A=Pm(1e6,1e6,1e6).toVar();return Uw({start:-1,end:Mm(1),name:"x",condition:"<="},({x:e})=>{Uw({start:-1,end:Mm(1),name:"y",condition:"<="},({y:t})=>{const r=Tm(uP(l,e,t,a,o,n,i)).toVar();vm(r.lessThan(A.x),()=>{A.z.assign(A.y),A.y.assign(A.x),A.x.assign(r)}).ElseIf(r.lessThan(A.y),()=>{A.z.assign(A.y),A.y.assign(r)}).ElseIf(r.lessThan(A.z),()=>{A.z.assign(r)})})}),vm(i.equal(Mm(0)),()=>{A.assign(wy(A))}),A}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),pP=ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Tm(t).toVar(),s=Pm(e).toVar(),a=Mm().toVar(),o=Mm().toVar(),l=Mm().toVar(),A=Pm(RB(s.x,a),RB(s.y,o),RB(s.z,l)).toVar(),u=Tm(1e6).toVar();return Uw({start:-1,end:Mm(1),name:"x",condition:"<="},({x:e})=>{Uw({start:-1,end:Mm(1),name:"y",condition:"<="},({y:t})=>{Uw({start:-1,end:Mm(1),name:"z",condition:"<="},({z:r})=>{const s=Tm(uP(A,e,t,r,a,o,l,n,i)).toVar();u.assign(Xy(u,s))})})}),vm(i.equal(Mm(0)),()=>{u.assign(wy(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),fP=EN([hP,pP]),mP=ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Tm(t).toVar(),s=Pm(e).toVar(),a=Mm().toVar(),o=Mm().toVar(),l=Mm().toVar(),A=Pm(RB(s.x,a),RB(s.y,o),RB(s.z,l)).toVar(),u=Nm(1e6,1e6).toVar();return Uw({start:-1,end:Mm(1),name:"x",condition:"<="},({x:e})=>{Uw({start:-1,end:Mm(1),name:"y",condition:"<="},({y:t})=>{Uw({start:-1,end:Mm(1),name:"z",condition:"<="},({z:r})=>{const s=Tm(uP(A,e,t,r,a,o,l,n,i)).toVar();vm(s.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(s)}).ElseIf(s.lessThan(u.y),()=>{u.y.assign(s)})})})}),vm(i.equal(Mm(0)),()=>{u.assign(wy(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gP=EN([cP,mP]),yP=ym(([e,t,r])=>{const i=Mm(r).toVar(),n=Tm(t).toVar(),s=Pm(e).toVar(),a=Mm().toVar(),o=Mm().toVar(),l=Mm().toVar(),A=Pm(RB(s.x,a),RB(s.y,o),RB(s.z,l)).toVar(),u=Pm(1e6,1e6,1e6).toVar();return Uw({start:-1,end:Mm(1),name:"x",condition:"<="},({x:e})=>{Uw({start:-1,end:Mm(1),name:"y",condition:"<="},({y:t})=>{Uw({start:-1,end:Mm(1),name:"z",condition:"<="},({z:r})=>{const s=Tm(uP(A,e,t,r,a,o,l,n,i)).toVar();vm(s.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(s)}).ElseIf(s.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(s)}).ElseIf(s.lessThan(u.z),()=>{u.z.assign(s)})})})}),vm(i.equal(Mm(0)),()=>{u.assign(wy(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),bP=EN([dP,yP]),xP=ym(([e])=>{const t=e.y,r=e.z,i=Pm().toVar();return vm(t.lessThan(1e-4),()=>{i.assign(Pm(r,r,r))}).Else(()=>{let n=e.x;n=n.sub(My(n)).mul(6).toVar();const s=Mm(jy(n)),a=n.sub(Tm(s)),o=r.mul(t.oneMinus()),l=r.mul(t.mul(a).oneMinus()),A=r.mul(t.mul(a.oneMinus()).oneMinus());vm(s.equal(Mm(0)),()=>{i.assign(Pm(r,A,o))}).ElseIf(s.equal(Mm(1)),()=>{i.assign(Pm(l,r,o))}).ElseIf(s.equal(Mm(2)),()=>{i.assign(Pm(o,r,A))}).ElseIf(s.equal(Mm(3)),()=>{i.assign(Pm(o,l,r))}).ElseIf(s.equal(Mm(4)),()=>{i.assign(Pm(A,o,r))}).Else(()=>{i.assign(Pm(r,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),vP=ym(([e])=>{const t=Pm(e).toVar(),r=Tm(t.x).toVar(),i=Tm(t.y).toVar(),n=Tm(t.z).toVar(),s=Tm(Xy(r,Xy(i,n))).toVar(),a=Tm(Yy(r,Yy(i,n))).toVar(),o=Tm(a.sub(s)).toVar(),l=Tm().toVar(),A=Tm().toVar(),u=Tm().toVar();return u.assign(a),vm(a.greaterThan(0),()=>{A.assign(o.div(a))}).Else(()=>{A.assign(0)}),vm(A.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{vm(r.greaterThanEqual(a),()=>{l.assign(i.sub(n).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(Lg(2,n.sub(r).div(o)))}).Else(()=>{l.assign(Lg(4,r.sub(i).div(o)))}),l.mulAssign(1/6),vm(l.lessThan(0),()=>{l.addAssign(1)})}),Pm(l,A,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),_P=ym(([e])=>{const t=Pm(e).toVar(),r=Im(Wg(t,Pm(.04045))).toVar(),i=Pm(t.div(12.92)).toVar(),n=Pm(ib(Yy(t.add(Pm(.055)),Pm(0)).div(1.055),Pm(2.4))).toVar();return ub(i,n,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),wP=(e,t)=>{e=Tm(e),t=Tm(t);const r=Nm(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return pb(e.sub(r),e.add(r),t)},TP=(e,t,r,i)=>ub(e,t,r[i].clamp()),MP=(e,t,r,i,n)=>ub(e,t,wP(r,i[n])),SP=ym(([e,t,r])=>{const i=Ey(e).toVar(),n=kg(Tm(.5).mul(t.sub(r)),fv).div(i).toVar(),s=kg(Tm(-.5).mul(t.sub(r)),fv).div(i).toVar(),a=Pm().toVar();a.x=i.x.greaterThan(Tm(0)).select(n.x,s.x),a.y=i.y.greaterThan(Tm(0)).select(n.y,s.y),a.z=i.z.greaterThan(Tm(0)).select(n.z,s.z);const o=Xy(a.x,a.y,a.z).toVar();return fv.add(i.mul(o)).toVar().sub(r)}),EP=ym(([e,t])=>{const r=e.x,i=e.y,n=e.z;let s=t.element(0).mul(.886227);return s=s.add(t.element(1).mul(1.023328).mul(i)),s=s.add(t.element(2).mul(1.023328).mul(n)),s=s.add(t.element(3).mul(1.023328).mul(r)),s=s.add(t.element(4).mul(.858086).mul(r).mul(i)),s=s.add(t.element(5).mul(.858086).mul(i).mul(n)),s=s.add(t.element(6).mul(n.mul(n).mul(.743125).sub(.247708))),s=s.add(t.element(7).mul(.858086).mul(r).mul(n)),s=s.add(t.element(8).mul(.429043).mul(Vg(r,r).sub(Vg(i,i)))),s});var NP=Object.freeze({__proto__:null,BRDF_GGX:MM,BRDF_Lambert:uM,BasicPointShadowFilter:dB,BasicShadowFilter:XR,Break:zw,Const:Bb,Continue:()=>cx("continue").toStack(),DFGApprox:SM,D_GGX:_M,Discard:dx,EPSILON:hy,F_Schlick:AM,Fn:ym,INFINITY:cy,If:vm,Loop:Uw,NodeAccess:gf,NodeShaderStage:ff,NodeType:{BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},NodeUpdateType:mf,PCFShadowFilter:YR,PCFSoftShadowFilter:KR,PI:dy,PI2:py,PointShadowFilter:pB,Return:()=>cx("return").toStack(),Schlick_to_F0:NM,ScriptableNodeResources:AR,ShaderNode:hm,Stack:_m,Switch:(...e)=>Of.Switch(...e),TBNViewMatrix:T_,VSMShadowFilter:ZR,V_GGX_SmithCorrelated:xM,Var:Rb,abs:Iy,acesFilmicToneMapping:XC,acos:qy,add:Lg,addMethodChaining:kf,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:JC,all:fy,alphaT:sg,and:Xg,anisotropy:ag,anisotropyB:lg,anisotropyT:og,any:my,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),_m(e)),array:Bg,arrayBuffer:e=>cm(new If(e,"ArrayBuffer")),asin:Py,assign:qg,atan:Dy,atan2:xb,atomicAdd:(e,t)=>PR(RR.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>PR(RR.ATOMIC_AND,e,t),atomicFunc:PR,atomicLoad:e=>PR(RR.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>PR(RR.ATOMIC_MAX,e,t),atomicMin:(e,t)=>PR(RR.ATOMIC_MIN,e,t),atomicOr:(e,t)=>PR(RR.ATOMIC_OR,e,t),atomicStore:(e,t)=>PR(RR.ATOMIC_STORE,e,t),atomicSub:(e,t)=>PR(RR.ATOMIC_SUB,e,t),atomicXor:(e,t)=>PR(RR.ATOMIC_XOR,e,t),attenuationColor:xg,attenuationDistance:bg,attribute:bx,attributeArray:(e,t="float")=>{let r,i;!0===t.isStruct?(r=t.layout.getLength(),i=af("float")):(r=of(t),i=af(t));const n=new cC(e,r,i);return Fw(n,t,e)},backgroundBlurriness:yC,backgroundIntensity:bC,backgroundRotation:xC,batch:Pw,bentNormalView:S_,billboarding:qN,bitAnd:Jg,bitNot:ey,bitOr:ty,bitXor:ry,bitangentGeometry:x_,bitangentLocal:v_,bitangentView:__,bitangentWorld:w_,bitcast:Qy,blendBurn:PT,blendColor:FT,blendDodge:qT,blendOverlay:IT,blendScreen:DT,blur:ES,bool:Em,buffer:Bx,bufferAttribute:Zb,bumpMap:P_,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),PT(e)),bvec2:Bm,bvec3:Im,bvec4:km,bypass:ox,cache:sx,call:Ig,cameraFar:Lx,cameraIndex:Fx,cameraNear:Ox,cameraNormalMatrix:Gx,cameraPosition:jx,cameraProjectionMatrix:kx,cameraProjectionMatrixInverse:Vx,cameraViewMatrix:Ux,cameraWorldMatrix:zx,cbrt:lb,cdl:OC,ceil:Sy,checker:MB,cineonToneMapping:QC,clamp:hb,clearcoat:Zm,clearcoatNormalView:Rv,clearcoatRoughness:Jm,code:rR,color:wm,colorSpaceToWorking:Gb,colorToDirection:e=>cm(e).mul(2).sub(1),compute:ix,computeSkinning:(e,t=null)=>{const r=new Lw(e);return r.positionNode=Fw(new Kd(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(_w).toVar(),r.skinIndexNode=Fw(new Kd(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(_w).toVar(),r.skinWeightNode=Fw(new Kd(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(_w).toVar(),r.bindMatrixNode=Cg(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Cg(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=Bx(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,cm(r)},context:Sb,convert:jm,convertColorSpace:(e,t,r)=>cm(new Ub(cm(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():aC(e,...t),cos:Ry,cross:rb,cubeTexture:$v,cubeTextureBase:Qv,cubeToUV:cB,dFdx:Vy,dFdy:Uy,dashSize:dg,debug:gx,decrement:ly,decrementBefore:ay,defaultBuildStages:bf,defaultShaderStages:yf,defined:Am,degrees:yy,deltaTime:CN,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),fR(e,pR(t))},densityFogFactor:pR,depth:wT,depthPass:(e,t,r)=>cm(new GC(GC.DEPTH,e,t,r)),difference:eb,diffuseColor:$m,directPointLight:wB,directionToColor:QT,directionToFaceDirection:_v,dispersion:vg,distance:Jy,div:Ug,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),qT(e)),dot:tb,drawIndex:Sw,dynamicBufferAttribute:Jb,element:Gm,emissive:Xm,equal:Gg,equals:$y,equirectUV:YT,exp:by,exp2:xy,expression:cx,faceDirection:vv,faceForward:fb,faceforward:vb,float:Tm,floor:My,fog:fR,fract:Ny,frameGroup:Mg,frameId:RN,frontFacing:xv,fwidth:Hy,gain:(e,t)=>e.lessThan(.5)?vN(e.mul(2),t).div(2):kg(1,vN(Vg(kg(1,e),2),t).div(2)),gapSize:pg,getConstNodeType:um,getCurrentStack:xm,getDirection:wS,getDistanceAttenuation:_B,getGeometryRoughness:yM,getNormalFromDepth:AC,getParallaxCorrectNormal:SP,getRoughness:bM,getScreenPosition:lC,getShIrradianceAt:EP,getShadowMaterial:eB,getShadowRenderObjectFunction:iB,getTextureIndex:gN,getViewPosition:oC,globalId:TR,glsl:(e,t)=>rR(e,t,"glsl"),glslFn:(e,t)=>nR(e,t,"glsl"),grayscale:PC,greaterThan:Wg,greaterThanEqual:$g,hash:xN,highpModelNormalViewMatrix:hv,highpModelViewMatrix:uv,hue:IC,increment:oy,incrementBefore:sy,instance:Nw,instanceIndex:_w,instancedArray:(e,t="float")=>{let r,i;!0===t.isStruct?(r=t.layout.getLength(),i=af("float")):(r=of(t),i=af(t));const n=new hC(e,r,i);return Fw(n,t,e)},instancedBufferAttribute:ex,instancedDynamicBufferAttribute:tx,instancedMesh:Rw,int:Mm,inverseSqrt:Ty,inversesqrt:_b,invocationLocalIndex:Mw,invocationSubgroupIndex:Tw,ior:mg,iridescence:rg,iridescenceIOR:ig,iridescenceThickness:ng,ivec2:Cm,ivec3:qm,ivec4:Om,js:(e,t)=>rR(e,t,"js"),label:Eb,length:Oy,lengthSq:Ab,lessThan:Hg,lessThanEqual:Qg,lightPosition:OR,lightProjectionUV:FR,lightShadowMatrix:IR,lightTargetDirection:VR,lightTargetPosition:LR,lightViewPosition:kR,lightingContext:Kw,lights:(e=[])=>cm(new jR).setLights(e),linearDepth:TT,linearToneMapping:HC,localId:MR,log:vy,log2:_y,logarithmicDepthToViewZ:(e,t,r)=>{const i=e.mul(vy(r.div(t)));return Tm(Math.E).pow(i).mul(t).negate()},luminance:FC,mat2:Vm,mat3:Um,mat4:zm,matcapUV:cE,materialAO:gw,materialAlphaTest:I_,materialAnisotropy:ew,materialAnisotropyVector:yw,materialAttenuationColor:lw,materialAttenuationDistance:ow,materialClearcoat:$_,materialClearcoatNormal:Y_,materialClearcoatRoughness:X_,materialColor:F_,materialDispersion:fw,materialEmissive:L_,materialEnvIntensity:kv,materialEnvRotation:Vv,materialIOR:aw,materialIridescence:tw,materialIridescenceIOR:rw,materialIridescenceThickness:iw,materialLightMap:mw,materialLineDashOffset:dw,materialLineDashSize:uw,materialLineGapSize:hw,materialLineScale:Aw,materialLineWidth:cw,materialMetalness:W_,materialNormal:Q_,materialOpacity:k_,materialPointSize:pw,materialReference:e_,materialReflectivity:j_,materialRefractionRatio:Lv,materialRotation:K_,materialRoughness:H_,materialSheen:Z_,materialSheenRoughness:J_,materialShininess:O_,materialSpecular:V_,materialSpecularColor:z_,materialSpecularIntensity:U_,materialSpecularStrength:G_,materialThickness:sw,materialTransmission:nw,max:Yy,maxMipLevel:Tx,mediumpModelViewMatrix:Av,metalness:Km,min:Xy,mix:ub,mixElement:gb,mod:zg,modInt:Ay,modelDirection:ev,modelNormalMatrix:av,modelPosition:rv,modelRadius:sv,modelScale:iv,modelViewMatrix:lv,modelViewPosition:nv,modelViewProjection:bw,modelWorldMatrix:tv,modelWorldMatrixInverse:ov,morphReference:Qw,mrt:bN,mul:Vg,mx_aastep:wP,mx_cell_noise_float:(e=xx())=>rP(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>Tm(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=xx(),t=3,r=2,i=.5,n=1)=>nP(e,Mm(t),r,i).mul(n),mx_fractal_noise_vec2:(e=xx(),t=3,r=2,i=.5,n=1)=>aP(e,Mm(t),r,i).mul(n),mx_fractal_noise_vec3:(e=xx(),t=3,r=2,i=.5,n=1)=>sP(e,Mm(t),r,i).mul(n),mx_fractal_noise_vec4:(e=xx(),t=3,r=2,i=.5,n=1)=>oP(e,Mm(t),r,i).mul(n),mx_hsvtorgb:xP,mx_noise_float:(e=xx(),t=1,r=0)=>ZB(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=xx(),t=1,r=0)=>tP(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=xx(),t=1,r=0)=>{e=e.convert("vec2|vec3");return Fm(tP(e),ZB(e.add(Nm(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=xx())=>TP(e,t,r,"x"),mx_ramptb:(e,t,r=xx())=>TP(e,t,r,"y"),mx_rgbtohsv:vP,mx_safepower:(e,t=1)=>(e=Tm(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,i=xx())=>MP(e,t,r,i,"x"),mx_splittb:(e,t,r,i=xx())=>MP(e,t,r,i,"y"),mx_srgb_texture_to_lin_rec709:_P,mx_transform_uv:(e=1,t=0,r=xx())=>r.mul(e).add(t),mx_worley_noise_float:(e=xx(),t=1)=>fP(e.convert("vec2|vec3"),t,Mm(1)),mx_worley_noise_vec2:(e=xx(),t=1)=>gP(e.convert("vec2|vec3"),t,Mm(1)),mx_worley_noise_vec3:(e=xx(),t=1)=>bP(e.convert("vec2|vec3"),t,Mm(1)),negate:Ly,neutralToneMapping:eR,nodeArray:pm,nodeImmutable:mm,nodeObject:cm,nodeObjects:dm,nodeProxy:fm,normalFlat:Mv,normalGeometry:wv,normalLocal:Tv,normalMap:N_,normalView:Nv,normalViewGeometry:Sv,normalWorld:Cv,normalWorldGeometry:Ev,normalize:Ey,not:Kg,notEqual:jg,numWorkgroups:_R,objectDirection:Qx,objectGroup:Eg,objectPosition:Xx,objectRadius:Zx,objectScale:Yx,objectViewPosition:Kx,objectWorldMatrix:$x,oneMinus:ky,or:Yg,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=NN)=>e.fract(),oscSine:(e=NN)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=NN)=>e.fract().round(),oscTriangle:(e=NN)=>e.add(.5).fract().mul(2).sub(1).abs(),output:cg,outputStruct:mN,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),IT(e)),overloadingFn:EN,parabola:vN,parallaxDirection:M_,parallaxUV:(e,t)=>e.sub(M_.mul(t)),parameter:(e,t)=>cm(new uN(e,t)),pass:(e,t,r)=>cm(new GC(GC.COLOR,e,t,r)),passTexture:(e,t)=>cm(new UC(e,t)),pcurve:(e,t,r)=>ib(Ug(ib(e,t),Lg(ib(e,t),ib(kg(1,e),r))),1/t),perspectiveDepthToViewZ:xT,pmremTexture:JS,pointShadow:xB,pointUV:pC,pointWidth:fg,positionGeometry:cv,positionLocal:dv,positionPrevious:pv,positionView:gv,positionViewDirection:yv,positionWorld:fv,positionWorldDirection:mv,posterize:kC,pow:ib,pow2:nb,pow3:sb,pow4:ab,premultiplyAlpha:OT,property:Wm,radians:gy,rand:mb,range:bR,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),fR(e,dR(t,r))},rangeFogFactor:dR,reciprocal:Gy,reference:Kv,referenceBuffer:Zv,reflect:Zy,reflectVector:Gv,reflectView:Uv,reflector:e=>cm(new ZN(e)),refract:db,refractVector:jv,refractView:zv,reinhardToneMapping:WC,remap:Ax,remapClamp:ux,renderGroup:Sg,renderOutput:fx,rendererReference:Qb,rotate:mE,rotateUV:BN,roughness:Ym,round:zy,rtt:aC,sRGBTransferEOTF:Lb,sRGBTransferOETF:kb,sample:e=>cm(new uC(e)),sampler:e=>(!0===e.isNode?e:Nx(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Nx(e)).convert("samplerComparison"),saturate:cb,saturation:qC,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),DT(e)),screenCoordinate:nT,screenSize:iT,screenUV:rT,scriptable:hR,scriptableValue:aR,select:Tb,setCurrentStack:bm,shaderStages:xf,shadow:uB,shadowPositionWorld:WR,shapeCircle:SB,sharedUniformGroup:Tg,sheen:eg,sheenRoughness:tg,shiftLeft:iy,shiftRight:ny,shininess:hg,sign:Fy,sin:Cy,sinc:(e,t)=>Cy(dy.mul(t.mul(e).sub(1))).div(dy.mul(t.mul(e).sub(1))),skinning:kw,smoothstep:pb,smoothstepElement:yb,specularColor:Ag,specularF90:ug,spherizeUV:PN,split:(e,t)=>cm(new Rf(cm(e),t)),spritesheetUV:FN,sqrt:wy,stack:cN,step:Ky,stepElement:bb,storage:Fw,storageBarrier:()=>ER("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Fw(e,t,r).setPBO(!0)),storageTexture:_C,string:(e="")=>cm(new If(e,"string")),struct:(e,t=null)=>{const r=new dN(e,t),i=(...t)=>{let i=null;if(t.length>0)if(t[0].isNode){i={};const r=Object.keys(e);for(let e=0;e<t.length;e++)i[r[e]]=t[e]}else i=t[0];return cm(new pN(r,i))};return i.layout=r,i.isStruct=!0,i},sub:kg,subBuild:Db,subgroupIndex:ww,subgroupSize:SR,tan:By,tangentGeometry:f_,tangentLocal:m_,tangentView:g_,tangentWorld:y_,temp:Pb,texture:Nx,texture3D:MC,textureBarrier:()=>ER("texture").toStack(),textureBicubic:QM,textureBicubicLevel:WM,textureCubeUV:TS,textureLoad:Cx,textureSize:_x,textureStore:(e,t,r)=>{const i=_C(e,t,r);return null!==r&&i.toStack(),i},thickness:yg,time:NN,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),CN.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),NN.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),NN.mul(e)),toneMapping:Xb,toneMappingExposure:Yb,toonOutlinePass:(e,t,r=new Wc(0,0,0),i=.003,n=1)=>cm(new jC(e,t,cm(r),cm(i),cm(n))),transformDirection:ob,transformNormal:Bv,transformNormalToView:Pv,transformedClearcoatNormalView:Iv,transformedNormalView:qv,transformedNormalWorld:Dv,transmission:gg,transpose:Wy,triNoise3D:TN,triplanarTexture:(...e)=>ON(...e),triplanarTextures:ON,trunc:jy,uint:Sm,uniform:Cg,uniformArray:Dx,uniformCubeTexture:(e=Hv)=>Qv(e),uniformGroup:wg,uniformTexture:(e=Mx)=>Nx(e),unpremultiplyAlpha:LT,userData:(e,t,r)=>cm(new SC(e,t,r)),uv:xx,uvec2:Rm,uvec3:Dm,uvec4:Lm,varying:Fb,varyingProperty:Qm,vec2:Nm,vec3:Pm,vec4:Fm,vectorComponents:vf,velocity:BC,vertexColor:BT,vertexIndex:vw,vertexStage:Ob,vibrance:DC,viewZToLogarithmicDepth:vT,viewZToOrthographicDepth:yT,viewZToPerspectiveDepth:bT,viewport:sT,viewportCoordinate:oT,viewportDepthTexture:mT,viewportLinearDepth:MT,viewportMipTexture:dT,viewportResolution:AT,viewportSafeUV:DN,viewportSharedTexture:WT,viewportSize:aT,viewportTexture:cT,viewportUV:lT,wgsl:(e,t)=>rR(e,t,"wgsl"),wgslFn:(e,t)=>nR(e,t,"wgsl"),workgroupArray:(e,t)=>cm(new CR("Workgroup",e,t)),workgroupBarrier:()=>ER("workgroup").toStack(),workgroupId:wR,workingToColorSpace:zb,xor:Zg});const CP=new AN;class RP extends RE{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const i=this.renderer,n=this.nodes.getBackgroundNode(e)||e.background;let s=!1;if(null===n)i._clearColor.getRGB(CP),CP.a=i._clearColor.a;else if(!0===n.isColor)n.getRGB(CP),CP.a=1,s=!0;else if(!0===n.isNode){const o=this.get(e),l=n;CP.copy(i._clearColor);let A=o.backgroundMesh;if(void 0===A){const h=Sb(Fm(l).mul(bC),{getUV:()=>xC.mul(Ev),getTextureLevel:()=>yC});let c=bw;c=c.setZ(c.w);const d=new kT;function p(){n.removeEventListener("dispose",p),A.material.dispose(),A.geometry.dispose()}d.name="Background.material",d.side=1,d.depthTest=!1,d.depthWrite=!1,d.allowOverride=!1,d.fog=!1,d.lights=!1,d.vertexNode=c,d.colorNode=h,o.backgroundMeshNode=h,o.backgroundMesh=A=new Nd(new fp(1,32,32),d),A.frustumCulled=!1,A.name="Background.mesh",A.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},n.addEventListener("dispose",p)}const u=l.getCacheKey();o.backgroundCacheKey!==u&&(o.backgroundMeshNode.node=Fm(l).mul(bC),o.backgroundMeshNode.needsUpdate=!0,A.material.needsUpdate=!0,o.backgroundCacheKey=u),t.unshift(A,A.geometry,A.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",n);const a=i.xr.getEnvironmentBlendMode();if("additive"===a?CP.set(0,0,0,1):"alpha-blend"===a&&CP.set(0,0,0,0),!0===i.autoClear||!0===s){const f=r.clearColorValue;f.r=CP.r,f.g=CP.g,f.b=CP.b,f.a=CP.a,!0!==i.backend.isWebGLBackend&&!0!==i.alpha||(f.r*=f.a,f.g*=f.a,f.b*=f.a),r.depthClearValue=i._clearDepth,r.stencilClearValue=i._clearStencil,r.clearColor=!0===i.autoClearColor,r.clearDepth=!0===i.autoClearDepth,r.clearStencil=!0===i.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let BP=0;class PP{constructor(e="",t=[],r=0,i=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=i,this.id=BP++}}class qP{constructor(e,t,r,i,n,s,a,o,l,A=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=A,this.nodeAttributes=i,this.bindings=n,this.updateNodes=s,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=l,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new PP(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class DP{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class IP{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class FP{constructor(e,t,r=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=i}}class OP extends FP{constructor(e,t,r=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=i}}class LP{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let kP=0;class VP{constructor(e=null){this.id=kP++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class UP{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class zP{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class GP extends zP{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class jP extends zP{constructor(e,t=new Zu){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class HP extends zP{constructor(e,t=new eh){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class WP extends zP{constructor(e,t=new wh){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class QP extends zP{constructor(e,t=new Wc){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class $P extends zP{constructor(e,t=new Qp){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class XP extends zP{constructor(e,t=new ih){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class YP extends zP{constructor(e,t=new ec){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class KP extends GP{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class ZP extends jP{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class JP extends HP{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class eq extends WP{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class tq extends QP{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class rq extends $P{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class iq extends XP{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class nq extends YP{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const sq=new WeakMap,aq=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),oq=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class lq{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=cN(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new VP,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.currentStack=null,this.subBuildFn=null}getBindGroupsCache(){let e=sq.get(this.renderer);return void 0===e&&(e=new ME,sq.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new Th(e,t,r)}createCubeRenderTarget(e,t){return new KT(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),i=[];let n,s=!0;for(const e of t)i.push(e),s=s&&!0!==e.groupNode.shared;return s?(n=r.get(i),void 0===n&&(n=new PP(e,i,this.bindingsIndexes[e].group,i),r.set(i,n))):n=new PP(e,i,this.bindingsIndexes[e].group,i),n}getBindGroupArray(e,t){const r=this.bindings[t];let i=r[e];return void 0===i&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of xf)for(const i in r[e]){const n=r[e][i];(t[i]||(t[i]=[])).push(...n)}e=[];for(const r in t){const i=t[r],n=this._getBindGroup(r,i);e.push(n)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const r=e[t];this.bindingsIndexes[r.name].group=t,r.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){!1===this.nodes.includes(e)&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){!1===this.sequentialNodes.includes(e)&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(const e of this.nodes){e.getUpdateType()!==mf.NONE&&this.updateNodes.push(e.getSelf())}for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==mf.NONE&&this.updateBeforeNodes.push(e.getSelf()),r!==mf.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===DA||e.magFilter===IA||e.magFilter===qA||e.magFilter===FA||e.minFilter===DA||e.minFilter===IA||e.minFilter===qA||e.minFilter===FA}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return this.context,this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const r=this.getDataFromNode(e);return void 0===r.cache&&(r.cache=new VP(t?this.getCache():null)),r.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=void 0===t.usageCount?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,r=null){let i=this.generateArrayDeclaration(e,t)+"( ";for(let n=0;n<t;n++){const s=r?r[n]:null;i+=null!==s?s.build(this,e):this.generateConst(e),n<t-1&&(i+=", ")}return i+=" )",i}generateStruct(e,t,r=null){const i=[];for(const e of t){const{name:t,type:n}=e;r&&r[t]&&r[t].isNode?i.push(r[t].build(this,n)):i.push(this.generateConst(n))}return e+"( "+i.join(", ")+" )"}generateConst(e,t=null){if(null===t&&("float"===e||"int"===e||"uint"===e?t=0:"bool"===e?t=!1:"color"===e?t=new Wc:"vec2"===e?t=new Zu:"vec3"===e?t=new eh:"vec4"===e&&(t=new wh)),"float"===e)return oq(t);if("int"===e)return`${Math.round(t)}`;if("uint"===e)return t>=0?`${Math.round(t)}u`:"0u";if("bool"===e)return t?"true":"false";if("color"===e)return`${this.getType("vec3")}( ${oq(t.r)}, ${oq(t.g)}, ${oq(t.b)} )`;const r=this.getTypeLength(e),i=this.getComponentType(e),n=e=>this.generateConst(i,e);if(2===r)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)} )`;if(3===r)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)} )`;if(4===r&&"mat2"!==e)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)}, ${n(t.w)} )`;if(r>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(n).join(", ")} )`;if(r>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const i=new DP(e,t);return this.registerDeclaration(i),r.push(i),i}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===UA)return"int";if(t===zA)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=sf(e);const i="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),i+r}getTypeFromArray(e){return aq.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,i=e.itemSize,n=e.normalized;let s;return e instanceof od||!0===n||(s=this.getTypeFromArray(r)),this.getTypeFromLength(i,s)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=cN(this.stack),this.stacks.push(xm()||this.stack),bm(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,bm(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let i=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);void 0===i&&(i={},r.setData(e,i)),void 0===i[t]&&(i[t]={});let n=i[t];const s=i.any?i.any.subBuilds:null,a=this.getClosestSubBuild(s);return a&&(void 0===n.subBuildsCache&&(n.subBuildsCache={}),n=n.subBuildsCache[a]||(n.subBuildsCache[a]={}),n.subBuilds=s),n}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let i=r.bufferAttribute;if(void 0===i){const n=this.uniforms.index++;i=new DP("nodeAttribute"+n,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i}return i}getStructTypeFromNode(e,t,r=null,i=this.shaderStage){const n=this.getDataFromNode(e,i,this.globalCache);let s=n.structType;if(void 0===s){const e=this.structs.index++;null===r&&(r="StructType"+e),s=new UP(r,t),this.structs[i].push(s),n.structType=s}return s}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,i=null){const n=this.getDataFromNode(e,r,this.globalCache);let s=n.uniform;if(void 0===s){const a=this.uniforms.index++;s=new IP(i||"nodeUniform"+a,t,e),this.uniforms[r].push(s),this.registerDeclaration(s),n.uniform=s}return s}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),i=this.shaderStage,n=!1){const s=this.getDataFromNode(e,i),a=this.getSubBuildProperty("variable",s.subBuilds);let o=s[a];if(void 0===o){const l=n?"_const":"_var",A=this.vars[i]||(this.vars[i]=[]),u=this.vars[l]||(this.vars[l]=0);null===t&&(t=(n?"nodeConst":"nodeVar")+u,this.vars[l]++),"variable"!==a&&(t=this.getSubBuildProperty(t,s.subBuilds));const h=this.getArrayCount(e);o=new FP(t,r,n,h),n||A.push(o),this.registerDeclaration(o),s[a]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),i=null,n=null){const s=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",s.subBuilds);let o=s[a];if(void 0===o){const e=this.varyings,l=e.length;null===t&&(t="nodeVarying"+l),"varying"!==a&&(t=this.getSubBuildProperty(t,s.subBuilds)),o=new OP(t,r,i,n),e.push(o),this.registerDeclaration(o),s[a]=o}return o}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),i=this.getPropertyName(e);let n=1,s=i;for(;void 0!==r[s];)s=i+"_"+n++;n>1&&(e.name=s,console.warn(`THREE.TSL: Declaration name '${i}' of '${e.type}' already in use. Renamed to '${s}'.`)),r[s]=e}getCodeFromNode(e,t,r=this.shaderStage){const i=this.getDataFromNode(e);let n=i.code;if(void 0===n){const e=this.codes[r]||(this.codes[r]=[]),s=e.length;n=new LP("nodeCode"+s,t),e.push(n),i.code=n}return n}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:i}=this.getDataFromNode(e);let n=!0,s=t;for(;s;){if(!0===i.get(s)){n=!1;break}s=this.getDataFromNode(s).parentNodeBlock}if(n)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const i=this.getDataFromNode(e),n=i.flowCodes||(i.flowCodes=[]),s=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);n.push(t),s.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new iR,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new uN(e.type,e.name);e.layout=null;const i=e.call(r),n=this.flowStagesNode(i,t.type);return e.layout=t,n}flowStagesNode(e,t=null){const r=this.flow,i=this.vars,n=this.declarations,s=this.cache,a=this.buildStage,o=this.stack,l={code:""};this.flow=l,this.vars={},this.declarations={},this.cache=new VP,this.stack=cN();for(const r of bf)this.setBuildStage(r),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=i,this.declarations=n,this.cache=s,this.stack=o,this.setBuildStage(a),l}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,i={code:""};return this.flow=i,i.result=e.build(this,t),this.flow=r,i}flowNodeFromShaderStage(e,t,r=null,i=null){const n=this.tab,s=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=l;let A=null;if("generate"===this.buildStage){const n=this.flowChildNode(t,r);null!==i&&(n.code+=`${this.tab+i} = ${n.result};\n`),this.flowCode[e]=this.flowCode[e]+n.code,A=n}else A=t.build(this);return this.setShaderStage(a),this.cache=s,this.tab=n,this.context=o,A}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e,!t)return null;const r=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){const i=t[e];if(r.includes(i))return i}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r,i;return r=null!==t?this.getClosestSubBuild(t):this.subBuildFn,i=r?e?r+"_"+e:r:e,i}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new kT),e.build(this)}else this.addFlow("compute",e);for(const e of bf){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of xf){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new KP(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new ZP(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new JP(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new eq(e);if("color"===t)return new tq(e);if("mat2"===t)return new rq(e);if("mat3"===t)return new iq(e);if("mat4"===t)return new nq(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const i=this.getTypeLength(t),n=this.getTypeLength(r);return 16===i&&9===n?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===i&&4===n?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:i>4||n>4||0===n?e:i===n?`${this.getType(r)}( ${e} )`:i>n?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,n)}`,this.format(e,this.getTypeFromLength(n,this.getComponentType(t)),r)):4===n&&i>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===i?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===i&&n>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${hA} - Node System\n`}*[Symbol.iterator](){}}class Aq{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===mf.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===mf.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===mf.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===mf.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===mf.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===mf.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===mf.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===mf.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===mf.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class uq{constructor(e,t,r=null,i="",n=!1){this.type=e,this.name=t,this.count=r,this.qualifier=i,this.isConst=n}}uq.isNodeFunctionInput=!0;class hq extends vB{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:VR(this.light),lightColor:e}}}const cq=new ec,dq=new ec;let pq=null;class fq extends vB{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Cg(new eh).setGroup(Sg),this.halfWidth=Cg(new eh).setGroup(Sg),this.updateType=mf.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;dq.identity(),cq.copy(t.matrixWorld),cq.premultiply(r),dq.extractRotation(cq),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(dq),this.halfHeight.value.applyMatrix4(dq)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Nx(pq.LTC_FLOAT_1),r=Nx(pq.LTC_FLOAT_2)):(t=Nx(pq.LTC_HALF_1),r=Nx(pq.LTC_HALF_2));const{colorNode:i,light:n}=this;return{lightColor:i,lightPosition:kR(n),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){pq=e}}class mq extends vB{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Cg(0).setGroup(Sg),this.penumbraCosNode=Cg(0).setGroup(Sg),this.cutoffDistanceNode=Cg(0).setGroup(Sg),this.decayExponentNode=Cg(0).setGroup(Sg),this.colorNode=Cg(this.color).setGroup(Sg)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:i}=this;return pb(r,i,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=FR(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:i,light:n}=this,s=this.getLightVector(e),a=s.normalize(),o=a.dot(VR(n)),l=this.getSpotAttenuation(e,o),A=s.length(),u=_B({lightDistance:A,cutoffDistance:r,decayExponent:i});let h,c,d=t.mul(l).mul(u);if(n.colorNode?(c=this.getLightCoord(e),h=n.colorNode(c)):n.map&&(c=this.getLightCoord(e),h=Nx(n.map,c.xy).onRenderUpdate(()=>n.map)),h){d=c.mul(2).sub(1).abs().lessThan(1).all().select(d.mul(h),d)}return{lightColor:d,lightDirection:a}}}class gq extends mq{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let i=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);i=Nx(r,Nm(e,0),0).r}else i=super.getSpotAttenuation(t);return i}}const yq=ym(([e,t])=>{const r=e.abs().sub(t);return Oy(Yy(r,0)).add(Xy(Yy(r.x,r.y),0))});class bq extends mq{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),i=r.xyz.div(r.w),n=yq(i.xy.sub(Nm(.5)),Nm(.5)),s=Ug(-1,kg(1,qy(t)).sub(1));return cb(n.mul(-2).mul(s))}}class xq extends vB{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class vq extends vB{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=OR(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Cg(new Wc).setGroup(Sg)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:i}=this,n=Cv.dot(i).mul(.5).add(.5),s=ub(r,t,n);e.context.irradiance.addAssign(s)}}class _q extends vB{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new eh);this.lightProbe=Dx(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=EP(Cv,this.lightProbe);e.context.irradiance.addAssign(t)}}class wq{parseFunction(){console.warn("Abstract function.")}}class Tq{constructor(e,t,r="",i=""){this.type=e,this.inputs=t,this.name=r,this.precision=i}getCode(){console.warn("Abstract function.")}}Tq.isNodeFunction=!0;const Mq=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Sq=/[a-z_0-9]+/gi,Eq="#pragma main";class Nq extends Tq{constructor(e){const{type:t,inputs:r,name:i,precision:n,inputsCode:s,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Eq),r=-1!==t?e.slice(t+12):e,i=r.match(Mq);if(null!==i&&5===i.length){const n=i[4],s=[];let a=null;for(;null!==(a=Sq.exec(n));)s.push(a);const o=[];let l=0;for(;l<s.length;){const e="const"===s[l][0];!0===e&&l++;let t=s[l][0];"in"===t||"out"===t||"inout"===t?l++:t="";const r=s[l++][0];let i=Number.parseInt(s[l][0]);!1===Number.isNaN(i)?l++:i=null;const n=s[l++][0];o.push(new uq(r,n,i,t,e))}const A=r.substring(i[0].length),u=void 0!==i[3]?i[3]:"";return{type:i[2],inputs:o,name:u,precision:void 0!==i[1]?i[1]:"",inputsCode:n,blockCode:A,headerCode:-1!==t?e.slice(0,t):""}}throw new Error("FunctionNode: Function is not a GLSL code.")})(e);super(t,r,i,n),this.inputsCode=s,this.blockCode=a,this.headerCode=o}getCode(e=this.name){let t;const r=this.blockCode;if(""!==r){const{type:i,inputsCode:n,headerCode:s,precision:a}=this;let o=`${i} ${e} ( ${n.trim()} )`;""!==a&&(o=`${a} ${o}`),t=s+o+r}else t="";return t}}class Cq extends wq{parseFunction(e){return new Nq(e)}}const Rq=new WeakMap,Bq=[],Pq=[];class qq extends RE{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new Aq,this.nodeBuilderCache=new Map,this.callHashCache=new ME,this.groupsData=new ME,this.cacheLib={}}updateGroup(e){const t=e.groupNode,r=t.name;if(r===Eg.name)return!0;if(r===Sg.name){const t=this.get(e),r=this.nodeFrame.renderId;return t.renderId!==r&&(t.renderId=r,!0)}if(r===Mg.name){const t=this.get(e),r=this.nodeFrame.frameId;return t.frameId!==r&&(t.frameId=r,!0)}Bq[0]=t,Bq[1]=e;let i=this.groupsData.get(Bq);return void 0===i&&this.groupsData.set(Bq,i={}),Bq.length=0,i.version!==t.version&&(i.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r){const{nodeBuilderCache:i}=this,n=this.getForRenderCacheKey(e);if(r=i.get(n),void 0===r){const t=this.backend.createNodeBuilder(e.object,this.renderer);t.scene=e.scene,t.material=e.material,t.camera=e.camera,t.context.material=e.material,t.lightsNode=e.lightsNode,t.environmentNode=this.getEnvironmentNode(e.scene),t.fogNode=this.getFogNode(e.scene),t.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&t.enableMultiview(),t.build(),r=this._createNodeBuilderState(t),i.set(n,r)}r.usedTimes++,t.nodeBuilderState=r}return r}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r){const i=this.backend.createNodeBuilder(e,this.renderer);i.build(),r=this._createNodeBuilderState(i),t.nodeBuilderState=r}return r}_createNodeBuilderState(e){return new qP(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){Bq[0]=e,Bq[1]=t;const r=this.renderer.info.calls,i=this.callHashCache.get(Bq)||{};if(i.callId!==r){const n=this.getEnvironmentNode(e),s=this.getFogNode(e);t&&Pq.push(t.getCacheKey(!0)),n&&Pq.push(n.getCacheKey()),s&&Pq.push(s.getCacheKey()),Pq.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Pq.push(this.renderer.shadowMap.enabled?1:0),i.callId=r,i.cacheKey=Zp(Pq),this.callHashCache.set(Bq,i),Pq.length=0}return Bq.length=0,i.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const i=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||i){const n=this.getCacheNode("background",r,()=>{if(!0===r.isCubeTexture||303===r.mapping||304===r.mapping||306===r.mapping){if(e.backgroundBlurriness>0||306===r.mapping)return JS(r);{let e;return e=!0===r.isCubeTexture?$v(r):Nx(r),rM(e)}}if(!0===r.isTexture)return Nx(r,rT.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)},i);t.backgroundNode=n,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,i=!1){const n=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let s=n.get(t);return(void 0===s||i)&&(s=r(),n.set(t,s)),s}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const e=Kv("color","color",r).setGroup(Sg),t=Kv("density","float",r).setGroup(Sg);return fR(e,pR(t))}if(r.isFog){const e=Kv("color","color",r).setGroup(Sg),t=Kv("near","float",r).setGroup(Sg),i=Kv("far","float",r).setGroup(Sg);return fR(e,dR(t,i))}console.error("THREE.Renderer: Unsupported fog configuration.",r)});t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,()=>!0===r.isCubeTexture?$v(r):!0===r.isTexture?Nx(r):void console.error("Nodes: Unsupported environment configuration.",r));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,i=null,n=null){const s=this.nodeFrame;return s.renderer=e,s.scene=t,s.object=r,s.camera=i,s.material=n,s}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return Rq.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),i=e.isArrayTexture?MC(e,Pm(rT,Ix("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Nx(e,rT).renderOutput(t.toneMapping,t.currentColorSpace);return Rq.set(e,r),i}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new Aq,this.nodeBuilderCache=new Map,this.cacheLib={}}}const Dq=new tp;class Iq{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new ih,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const i=e.length;for(let n=0;n<i;n++){Dq.copy(e[n]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const i=t[r+n],s=Dq.normal;i.x=-s.x,i.y=-s.y,i.z=-s.z,i.w=Dq.constant}}updateGlobal(e,t){this.shadowPass=null!==e.overrideMaterial&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let r=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);const i=t.clippingPlanes,n=i.length;let s,a;if(this.clipIntersection?(s=this.intersectionPlanes,a=e.intersectionPlanes.length):(s=this.unionPlanes,a=e.unionPlanes.length),s.length!==a+n){s.length=a+n;for(let e=0;e<n;e++)s[a+e]=new wh;r=!0}this.projectPlanes(i,s,a),r&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return void 0===t&&(t=new Iq(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class Fq{constructor(e,t){this.bundleGroup=e,this.camera=t}}const Oq=[];class Lq{constructor(){this.bundles=new ME}get(e,t){const r=this.bundles;Oq[0]=e,Oq[1]=t;let i=r.get(Oq);return void 0===i&&(i=new Fq(e,t),r.set(Oq,i)),Oq.length=0,i}dispose(){this.bundles=new ME}}class kq{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const r=this.getMaterialNodeClass(e.type);if(null!==r){t=new r;for(const r in e)t[r]=e[r]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,r){if(r.has(t))console.warn(`Redefinition of node ${t}`);else{if("function"!=typeof e)throw new Error(`Node class ${e.name} is not a class.`);if("function"==typeof t||"object"==typeof t)throw new Error(`Base class ${t} is not a class.`);r.set(t,e)}}addClass(e,t,r){if(r.has(t))console.warn(`Redefinition of node ${t.name}`);else{if("function"!=typeof e)throw new Error(`Node class ${e.name} is not a class.`);if("function"!=typeof t)throw new Error(`Base class ${t.name} is not a class.`);r.set(t,e)}}}const Vq=new jR,Uq=[];class zq extends ME{constructor(){super()}createNode(e=[]){return(new jR).setLights(e)}getNode(e,t){if(e.isQuadMesh)return Vq;Uq[0]=e,Uq[1]=t;let r=this.get(Uq);return void 0===r&&(r=this.createNode(),this.set(Uq,r)),Uq.length=0,r}}class Gq extends Th{constructor(e=1,t=1,r={}){super(e,t,r),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}}const jq=new eh,Hq=new eh;class Wq extends Vu{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new Od,this._cameraL.viewport=new wh,this._cameraR=new Od,this._cameraR.viewport=new wh,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new Hp,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._supportsLayers=!1,this._frameBufferTargets=null,this._createXRLayer=Kq.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new Zu,this._onSessionEvent=$q.bind(this),this._onSessionEnd=Xq.bind(this),this._onInputSourcesChange=Yq.bind(this),this._onAnimationFrame=Zq.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._useLayers="undefined"!=typeof XRWebGLBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(null!==this._glProjLayer||null!==this._glBaseLayer)return this._foveation}setFoveation(e){this._foveation=e,null!==this._glProjLayer&&(this._glProjLayer.fixedFoveation=e),null!==this._glBaseLayer&&void 0!==this._glBaseLayer.fixedFoveation&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,!0===this.isPresenting&&console.warn("THREE.XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,!0===this.isPresenting&&console.warn("THREE.XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(null!==this._session)return this._session.environmentBlendMode}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,r,i,n,s,a,o={}){const l=new pp(e,t),A=new Gq(n,s,{format:QA,type:OA,depthTexture:new cp(n,s,o.stencil?HA:zA,void 0,void 0,void 0,void 0,void 0,void 0,o.stencil?XA:$A),stencilBuffer:o.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});A._autoAllocateDepthBuffer=!0;const u=new Yc({color:16777215,side:0});u.map=A.texture,u.map.offset.y=1,u.map.repeat.y=-1;const h=new Nd(l,u);h.position.copy(r),h.quaternion.copy(i);const c={type:"quad",width:e,height:t,translation:r,quaternion:i,pixelwidth:n,pixelheight:s,plane:h,material:u,rendercall:a,renderTarget:A};if(this._layers.push(c),null!==this._session){c.plane.material=new Yc({color:16777215,side:0}),c.plane.material.blending=5,c.plane.material.blendEquation=cA,c.plane.material.blendSrc=fA,c.plane.material.blendDst=fA,c.xrlayer=this._createXRLayer(c);const e=this._session.renderState.layers;e.unshift(c.xrlayer),this._session.updateRenderState({layers:e})}else A.isXRRenderTarget=!1;return h}createCylinderLayer(e,t,r,i,n,s,a,o,l={}){const A=new dp(e,e,e*t/r,64,64,!0,Math.PI-t/2,t),u=new Gq(s,a,{format:QA,type:OA,depthTexture:new cp(s,a,l.stencil?HA:zA,void 0,void 0,void 0,void 0,void 0,void 0,l.stencil?XA:$A),stencilBuffer:l.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u._autoAllocateDepthBuffer=!0;const h=new Yc({color:16777215,side:1});h.map=u.texture,h.map.offset.y=1,h.map.repeat.y=-1;const c=new Nd(A,h);c.position.copy(i),c.quaternion.copy(n);const d={type:"cylinder",radius:e,centralAngle:t,aspectratio:r,translation:i,quaternion:n,pixelwidth:s,pixelheight:a,plane:c,material:h,rendercall:o,renderTarget:u};if(this._layers.push(d),null!==this._session){d.plane.material=new Yc({color:16777215,side:1}),d.plane.material.blending=5,d.plane.material.blendEquation=cA,d.plane.material.blendSrc=fA,d.plane.material.blendDst=fA,d.xrlayer=this._createXRLayer(d);const e=this._session.renderState.layers;e.unshift(d.xrlayer),this._session.updateRenderState({layers:e})}else u.isXRRenderTarget=!1;return c}renderLayers(){const e=new eh,t=new Ju,r=this._renderer,i=this.isPresenting,n=r.getOutputRenderTarget(),s=r._frameBufferTarget;this.isPresenting=!1;const a=new Zu;r.getSize(a);const o=r._quad;for(const i of this._layers)if(i.renderTarget.isXRRenderTarget=null!==this._session,i.renderTarget._hasExternalTextures=i.renderTarget.isXRRenderTarget,i.renderTarget.isXRRenderTarget&&this._supportsLayers){i.xrlayer.transform=new XRRigidTransform(i.plane.getWorldPosition(e),i.plane.getWorldQuaternion(t));const n=this._glBinding.getSubImage(i.xrlayer,this._xrFrame);r.backend.setXRRenderTargetTextures(i.renderTarget,n.colorTexture,void 0),r._setXRLayerSize(i.renderTarget.width,i.renderTarget.height),r.setOutputRenderTarget(i.renderTarget),r.setRenderTarget(null),r._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);const{frameBufferTarget:s,quad:a}=this._frameBufferTargets.get(i.renderTarget)||{frameBufferTarget:null,quad:null};s?(r._frameBufferTarget=s,r._quad=a):(r._quad=new iC(new kT),this._frameBufferTargets.set(i.renderTarget,{frameBufferTarget:r._getFrameBufferTarget(),quad:r._quad})),i.rendercall(),r._frameBufferTarget=null}else r.setRenderTarget(i.renderTarget),i.rendercall();r.setRenderTarget(null),r.setOutputRenderTarget(n),r._frameBufferTarget=s,r._setXRLayerSize(a.x,a.y),r._quad=o,this.isPresenting=i}getSession(){return this._session}async setSession(e){const t=this._renderer,r=t.backend;this._gl=t.getContext();const i=this._gl,n=i.getContextAttributes();if(this._session=e,null!==e){if(!0===r.isWebGPUBackend)throw new Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),await r.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),!0===this._useLayers){let r=null,s=null,a=null;t.depth&&(a=t.stencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24,r=t.stencil?XA:$A,s=t.stencil?HA:zA);const o={colorFormat:i.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(o.textureType="texture-array",this._useMultiview=!0);const l=new XRWebGLBinding(e,i),A=l.createProjectionLayer(o),u=[A];this._glBinding=l,this._glProjLayer=A,t.setPixelRatio(1),t._setXRLayerSize(A.textureWidth,A.textureHeight);const h=this._useMultiview?2:1,c=new cp(A.textureWidth,A.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,r,h);if(this._xrRenderTarget=new Gq(A.textureWidth,A.textureHeight,{format:QA,type:OA,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:n.antialias?4:0,resolveDepthBuffer:!1===A.ignoreDepthValues,resolveStencilBuffer:!1===A.ignoreDepthValues,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._supportsLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._supportsLayers)for(const e of this._layers)e.plane.material=new Yc({color:16777215,side:"cylinder"===e.type?1:0}),e.plane.material.blending=5,e.plane.material.blendEquation=cA,e.plane.material.blendSrc=fA,e.plane.material.blendDst=fA,e.xrlayer=this._createXRLayer(e),u.unshift(e.xrlayer);e.updateRenderState({layers:u})}else{const r={antialias:t.samples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},n=new XRWebGLLayer(e,i,r);this._glBaseLayer=n,e.updateRenderState({baseLayer:n}),t.setPixelRatio(1),t._setXRLayerSize(n.framebufferWidth,n.framebufferHeight),this._xrRenderTarget=new Gq(n.framebufferWidth,n.framebufferHeight,{format:QA,type:OA,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===n.ignoreDepthValues,resolveStencilBuffer:!1===n.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,i=e.far,n=this._cameraXR,s=this._cameraL,a=this._cameraR;n.near=a.near=s.near=r,n.far=a.far=s.far=i,n.isMultiViewCamera=this._useMultiview,this._currentDepthNear===n.near&&this._currentDepthFar===n.far||(t.updateRenderState({depthNear:n.near,depthFar:n.far}),this._currentDepthNear=n.near,this._currentDepthFar=n.far),s.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,n.layers.mask=s.layers.mask|a.layers.mask;const o=e.parent,l=n.cameras;Qq(n,o);for(let e=0;e<l.length;e++)Qq(l[e],o);2===l.length?function(e,t,r){jq.setFromMatrixPosition(t.matrixWorld),Hq.setFromMatrixPosition(r.matrixWorld);const i=jq.distanceTo(Hq),n=t.projectionMatrix.elements,s=r.projectionMatrix.elements,a=n[14]/(n[10]-1),o=n[14]/(n[10]+1),l=(n[9]+1)/n[5],A=(n[9]-1)/n[5],u=(n[8]-1)/n[0],h=(s[8]+1)/s[0],c=a*u,d=a*h,p=i/(-u+h),f=p*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(p),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===n[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=a+p,r=o+p,n=c-f,s=d+(i-f),u=l*o/r*t,h=A*o/r*t;e.projectionMatrix.makePerspective(n,s,u,h,t,r),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(n,s,a):n.projectionMatrix.copy(s.projectionMatrix),function(e,t,r){null===r?e.matrix.copy(t.matrixWorld):(e.matrix.copy(r.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*ju*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,n,o)}_getController(e){let t=this._controllers[e];return void 0===t&&(t=new jd,this._controllers[e]=t),t}}function Qq(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function $q(e){const t=this._controllerInputSources.indexOf(e.inputSource);if(-1===t)return;const r=this._controllers[t];if(void 0!==r){const t=this.getReferenceSpace();r.update(e.inputSource,e.frame,t),r.dispatchEvent({type:e.type,data:e.inputSource})}}function Xq(){const e=this._session,t=this._renderer;e.removeEventListener("select",this._onSessionEvent),e.removeEventListener("selectstart",this._onSessionEvent),e.removeEventListener("selectend",this._onSessionEvent),e.removeEventListener("squeeze",this._onSessionEvent),e.removeEventListener("squeezestart",this._onSessionEvent),e.removeEventListener("squeezeend",this._onSessionEvent),e.removeEventListener("end",this._onSessionEnd),e.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let e=0;e<this._controllers.length;e++){const t=this._controllerInputSources[e];null!==t&&(this._controllerInputSources[e]=null,this._controllers[e].disconnect(t))}if(this._currentDepthNear=null,this._currentDepthFar=null,t._resetXRState(),this._session=null,this._xrRenderTarget=null,!0===this._supportsLayers)for(const e of this._layers)e.renderTarget=new Gq(e.pixelwidth,e.pixelheight,{format:QA,type:OA,depthTexture:new cp(e.pixelwidth,e.pixelheight,e.stencilBuffer?HA:zA,void 0,void 0,void 0,void 0,void 0,void 0,e.stencilBuffer?XA:$A),stencilBuffer:e.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),e.renderTarget.isXRRenderTarget=!1,e.plane.material=e.material,e.material.map=e.renderTarget.texture,e.material.map.offset.y=1,e.material.map.repeat.y=-1,delete e.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function Yq(e){const t=this._controllers,r=this._controllerInputSources;for(let i=0;i<e.removed.length;i++){const n=e.removed[i],s=r.indexOf(n);s>=0&&(r[s]=null,t[s].disconnect(n))}for(let i=0;i<e.added.length;i++){const n=e.added[i];let s=r.indexOf(n);if(-1===s){for(let e=0;e<t.length;e++){if(e>=r.length){r.push(n),s=e;break}if(null===r[e]){r[e]=n,s=e;break}}if(-1===s)break}const a=t[s];a&&a.connect(n)}}function Kq(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function Zq(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,s=this._glBaseLayer,a=this.getReferenceSpace(),o=t.getViewerPose(a);if(this._xrFrame=t,null!==o){const e=o.views;null!==this._glBaseLayer&&n.setXRTarget(s.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i<e.length;i++){const a=e[i];let o;if(!0===this._useLayers){const e=this._glBinding.getViewSubImage(this._glProjLayer,a);o=e.viewport,0===i&&n.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:e.depthStencilTexture)}else o=s.getViewport(a);let l=this._cameras[i];void 0===l&&(l=new Od,l.layers.enable(i),l.viewport=new wh,this._cameras[i]=l),l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.projectionMatrix.fromArray(a.projectionMatrix),l.projectionMatrixInverse.copy(l.projectionMatrix).invert(),l.viewport.set(o.x,o.y,o.width,o.height),0===i&&(r.matrix.copy(l.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)),!0===t&&r.cameras.push(l)}i.setOutputRenderTarget(this._xrRenderTarget)}for(let e=0;e<this._controllers.length;e++){const r=this._controllerInputSources[e],i=this._controllers[e];null!==r&&void 0!==i&&i.update(r,t,a)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:t}),this._xrFrame=null}const Jq=new Hd,eD=new Zu,tD=new wh,rD=new sp,iD=new lp,nD=new ec,sD=new wh;class aD{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:r=!1,alpha:i=!0,depth:n=!0,stencil:s=!1,antialias:a=!1,samples:o=0,getFallback:l=null,colorBufferType:A=jA,multiview:u=!1}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=o||!0===a?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=i,this.logarithmicDepthBuffer=r,this.outputColorSpace=wu,this.toneMapping=0,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=n,this.stencil=s,this.info=new VE,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new kq,this.lighting=new zq,this._getFallback=l,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new wh(0,0,this._width,this._height),this._scissor=new wh(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new iC(new kT),this._quad.material.name="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const h=!0===this.alpha?0:1;this._clearColor=new AN(0,0,0,h),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._colorBufferType=A,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:1},this.xr=new Wq(this,u),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,r)=>{await this.compileAsync(e,t);const i=this._renderLists.get(e,t),n=this._renderContexts.get(e,t,this._renderTarget),s=e.overrideMaterial||r.material,a=this._objects.get(r,s,e,t,i.lightsNode,n,n.clippingContext),{fragmentShader:o,vertexShader:l}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:l}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new qq(this,r),this._animation=new TE(this._nodes,this.info),this._attributes=new FE(r),this._background=new RP(this,this._nodes),this._geometries=new kE(this._attributes,this.info),this._textures=new lN(this,r,this.info),this._pipelines=new WE(r,this._nodes),this._bindings=new QE(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new CE(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new JE(this.lighting),this._bundles=new Lq,this._renderContexts=new aN,this._animation.start(),this._initialized=!0,e(this)})),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const i=this._nodes.nodeFrame,n=i.renderId,s=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,l=!0===e.isScene?e:Jq;null===r&&(r=e);const A=this._renderTarget,u=this._renderContexts.get(r,t,A),h=this._activeMipmapLevel,c=[];this._currentRenderContext=u,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=c,i.renderId++,i.update(),u.depth=this.depth,u.stencil=this.stencil,u.clippingContext||(u.clippingContext=new Iq),u.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,A);const d=this._renderLists.get(e,t);if(d.begin(),this._projectObject(e,t,0,d,u.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&d.pushLight(e)}),d.finish(),null!==A){this._textures.updateRenderTarget(A,h);const e=this._textures.get(A);u.textures=e.textures,u.depthTexture=e.depthTexture}else u.textures=null,u.depthTexture=null;this._background.update(l,d,u);const p=d.opaque,f=d.transparent,m=d.transparentDoublePass,g=d.lightsNode;!0===this.opaque&&p.length>0&&this._renderObjects(p,t,l,g),!0===this.transparent&&f.length>0&&this._renderTransparents(f,m,t,l,g),i.renderId=n,this._currentRenderContext=s,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(c)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=uv,this.overrideNodes.modelNormalViewMatrix=hv):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===uv&&this.overrideNodes.modelNormalViewMatrix===hv}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:i,camera:n,renderList:s}=e,a=this._currentRenderContext,o=this._bundles.get(i,n),l=this.backend.get(o);void 0===l.renderContexts&&(l.renderContexts=new Set);const A=i.version!==l.version,u=!1===l.renderContexts.has(a)||A;if(l.renderContexts.add(a),u){this.backend.beginBundle(a),(void 0===l.renderObjects||A)&&(l.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:u,opaque:h}=s;!0===this.opaque&&h.length>0&&this._renderObjects(h,n,t,r),!0===this.transparent&&u.length>0&&this._renderTransparents(u,e,n,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),l.version=i.version}else{const{renderObjects:e}=l;for(let t=0,r=e.length;t<r;t++){const r=e[t];this._nodes.needsRefresh(r)&&(this._nodes.updateBefore(r),this._nodes.updateForRender(r),this._bindings.updateForRender(r),this._nodes.updateAfter(r))}}this.backend.addBundle(a,o)}render(e,t){if(!1===this._initialized)return console.warn("THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead."),this.renderAsync(e,t);this._renderScene(e,t)}_getFrameBufferTarget(){const{currentToneMapping:e,currentColorSpace:t}=this;if(!1===(0!==e)&&!1===(t!==Tu))return null;const{width:r,height:i}=this.getDrawingBufferSize(eD),{depth:n,stencil:s}=this;let a=this._frameBufferTarget;null===a&&(a=new Th(r,i,{depthBuffer:n,stencilBuffer:s,type:this._colorBufferType,format:QA,colorSpace:Tu,generateMipmaps:!1,minFilter:DA,magFilter:DA,samples:this.samples}),a.isPostProcessingRenderTarget=!0,this._frameBufferTarget=a);const o=this.getOutputRenderTarget();return a.depthBuffer=n,a.stencilBuffer=s,null!==o?a.setSize(o.width,o.height,o.depth):a.setSize(r,i,1),a.viewport.copy(this._viewport),a.scissor.copy(this._scissor),a.viewport.multiplyScalar(this._pixelRatio),a.scissor.multiplyScalar(this._pixelRatio),a.scissorTest=this._scissorTest,a.multiview=null!==o&&o.multiview,a.resolveDepthBuffer=null===o||o.resolveDepthBuffer,a._autoAllocateDepthBuffer=null!==o&&o._autoAllocateDepthBuffer,a}_renderScene(e,t,r=!0){if(!0===this._isDeviceLost)return;const i=r?this._getFrameBufferTarget():null,n=this._nodes.nodeFrame,s=n.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,l=!0===e.isScene?e:Jq,A=this._renderTarget||this._outputRenderTarget,u=this._activeCubeFace,h=this._activeMipmapLevel;let c;null!==i?(c=i,this.setRenderTarget(c)):c=A;const d=this._renderContexts.get(e,t,c);this._currentRenderContext=d,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,n.renderId=this.info.calls;const p=this.coordinateSystem,f=this.xr;if(t.coordinateSystem!==p&&!1===f.isPresenting&&(t.coordinateSystem=p,t.updateProjectionMatrix(),t.isArrayCamera))for(const e of t.cameras)e.coordinateSystem=p,e.updateProjectionMatrix();!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===f.enabled&&!0===f.isPresenting&&(!0===f.cameraAutoUpdate&&f.updateCamera(t),t=f.getCamera());let m=this._viewport,g=this._scissor,y=this._pixelRatio;null!==c&&(m=c.viewport,g=c.scissor,y=1),this.getDrawingBufferSize(eD),tD.set(0,0,eD.width,eD.height);const b=void 0===m.minDepth?0:m.minDepth,x=void 0===m.maxDepth?1:m.maxDepth;d.viewportValue.copy(m).multiplyScalar(y).floor(),d.viewportValue.width>>=h,d.viewportValue.height>>=h,d.viewportValue.minDepth=b,d.viewportValue.maxDepth=x,d.viewport=!1===d.viewportValue.equals(tD),d.scissorValue.copy(g).multiplyScalar(y).floor(),d.scissor=this._scissorTest&&!1===d.scissorValue.equals(tD),d.scissorValue.width>>=h,d.scissorValue.height>>=h,d.clippingContext||(d.clippingContext=new Iq),d.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,c);const v=t.isArrayCamera?iD:rD;t.isArrayCamera||(nD.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),v.setFromProjectionMatrix(nD,p));const _=this._renderLists.get(e,t);if(_.begin(),this._projectObject(e,t,0,_,d.clippingContext),_.finish(),!0===this.sortObjects&&_.sort(this._opaqueSort,this._transparentSort),null!==c){this._textures.updateRenderTarget(c,h);const e=this._textures.get(c);d.textures=e.textures,d.depthTexture=e.depthTexture,d.width=e.width,d.height=e.height,d.renderTarget=c,d.depth=c.depthBuffer,d.stencil=c.stencilBuffer}else d.textures=null,d.depthTexture=null,d.width=this.domElement.width,d.height=this.domElement.height,d.depth=this.depth,d.stencil=this.stencil;d.width>>=h,d.height>>=h,d.activeCubeFace=u,d.activeMipmapLevel=h,d.occlusionQueryCount=_.occlusionQueryCount,this._background.update(l,_,d),d.camera=t,this.backend.beginRender(d);const{bundles:w,lightsNode:T,transparentDoublePass:M,transparent:S,opaque:E}=_;return w.length>0&&this._renderBundles(w,l,T),!0===this.opaque&&E.length>0&&this._renderObjects(E,t,l,T),!0===this.transparent&&S.length>0&&this._renderTransparents(S,M,t,l,T),this.backend.finishRender(d),n.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==i&&(this.setRenderTarget(A,u,h),this._renderOutput(c)),l.onAfterRender(this,e,t,c),d}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,i=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=i}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,i){const n=this._scissor;e.isVector4?n.copy(e):n.set(e,t,r,i)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,i,n=0,s=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,i),a.minDepth=n,a.maxDepth=s}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const i=this._renderTarget||this._getFrameBufferTarget();let n=null;if(null!==i){this._textures.updateRenderTarget(i);const e=this._textures.get(i);n=this._renderContexts.getForClear(i),n.textures=e.textures,n.depthTexture=e.depthTexture,n.width=e.width,n.height=e.height,n.renderTarget=i,n.depth=i.depthBuffer,n.stencil=i.stencilBuffer,n.clearColorValue=this.backend.getClearColor(),n.activeCubeFace=this.getActiveCubeFace(),n.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,n),null!==i&&null===this._renderTarget&&this._renderOutput(i)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Tu}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{null!==e&&e.dispose()}),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const i=this.backend,n=this._pipelines,s=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);for(const t of o){if(!1===n.has(t)){const e=()=>{t.removeEventListener("dispose",e),n.delete(t),s.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),s.updateForCompute(t);const r=s.getForCompute(t),o=n.getForCompute(t,r);i.compute(e,t,r,o)}i.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=sD.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=sD.copy(t).floor()}else t=sD.set(0,0,e.image.width,e.image.height);let r,i=this._currentRenderContext;null!==i?r=i.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),i=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,i,t)}copyTextureToTexture(e,t,r=null,i=null,n=0,s=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,i,n,s)}async readRenderTargetPixelsAsync(e,t,r,i,n,s=0,a=0){return this.backend.copyTextureToBuffer(e.textures[s],t,r,i,n,a)}_projectObject(e,t,r,i,n){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(n=n.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)i.pushLight(e);else if(e.isSprite){const s=t.isArrayCamera?iD:rD;if(!e.frustumCulled||s.intersectsSprite(e,t)){!0===this.sortObjects&&sD.setFromMatrixPosition(e.matrixWorld).applyMatrix4(nD);const{geometry:t,material:s}=e;s.visible&&i.push(e,t,s,r,sD.z,null,n)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const s=t.isArrayCamera?iD:rD;if(!e.frustumCulled||s.intersectsObject(e,t)){const{geometry:t,material:s}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),sD.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(nD)),Array.isArray(s)){const a=t.groups;for(let o=0,l=a.length;o<l;o++){const l=a[o],A=s[l.materialIndex];A&&A.visible&&i.push(e,t,A,r,sD.z,l,n)}}else s.visible&&i.push(e,t,s,r,sD.z,null,n)}}if(!0===e.isBundleGroup&&void 0!==this.backend.beginBundle){const r=i;(i=this._renderLists.get(e,t)).begin(),r.pushBundle({bundleGroup:e,camera:t,renderList:i}),i.finish()}const s=e.children;for(let e=0,a=s.length;e<a;e++)this._projectObject(s[e],t,r,i,n)}_renderBundles(e,t,r){for(const i of e)this._renderBundle(i,t,r)}_renderTransparents(e,t,r,i,n){if(t.length>0){for(const{material:e}of t)e.side=1;this._renderObjects(t,r,i,n,"backSide");for(const{material:e}of t)e.side=0;this._renderObjects(e,r,i,n);for(const{material:e}of t)e.side=2}else this._renderObjects(e,r,i,n)}_renderObjects(e,t,r,i,n=null){for(let s=0,a=e.length;s<a;s++){const{object:a,geometry:o,material:l,group:A,clippingContext:u}=e[s];this._currentRenderObjectFunction(a,r,t,o,l,A,i,u,n)}}renderObject(e,t,r,i,n,s,a,o=null,l=null){let A,u,h;if(e.onBeforeRender(this,t,r,i,n,s),!0===n.allowOverride&&null!==t.overrideMaterial){const e=t.overrideMaterial;n.positionNode&&n.positionNode.isNode&&(A=e.positionNode,e.positionNode=n.positionNode),e.alphaTest=n.alphaTest,e.alphaMap=n.alphaMap,e.transparent=n.transparent||n.transmission>0,e.isShadowPassMaterial&&(e.side=null===n.shadowSide?n.side:n.shadowSide,n.depthNode&&n.depthNode.isNode&&(h=e.depthNode,e.depthNode=n.depthNode),n.castShadowNode&&n.castShadowNode.isNode&&(u=e.colorNode,e.colorNode=n.castShadowNode),n.castShadowPositionNode&&n.castShadowPositionNode.isNode&&(A=e.positionNode,e.positionNode=n.castShadowPositionNode)),n=e}!0===n.transparent&&2===n.side&&!1===n.forceSinglePass?(n.side=1,this._handleObjectFunction(e,n,t,r,a,s,o,"backSide"),n.side=0,this._handleObjectFunction(e,n,t,r,a,s,o,l),n.side=2):this._handleObjectFunction(e,n,t,r,a,s,o,l),void 0!==A&&(t.overrideMaterial.positionNode=A),void 0!==h&&(t.overrideMaterial.depthNode=h),void 0!==u&&(t.overrideMaterial.colorNode=u),e.onAfterRender(this,t,r,i,n,s)}_renderObjectDirect(e,t,r,i,n,s,a,o){const l=this._objects.get(e,t,r,i,n,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=s;const A=this._nodes.needsRefresh(l);if(A&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(l,this.info),A&&this._nodes.updateAfter(l)}_createObjectPipeline(e,t,r,i,n,s,a,o){const l=this._objects.get(e,t,r,i,n,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=s,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}get compile(){return this.compileAsync}}class oD{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}let lD=class extends oD{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(IE-e%IE)%IE;var e}get buffer(){return this._buffer}update(){return!0}};class AD extends lD{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let uD=0;class hD extends AD{constructor(e,t){super("UniformBuffer_"+uD++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class cD extends AD{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,i=this.uniforms.length;r<i;r++){const i=this.uniforms[r],n=i.boundary,s=i.itemSize*e,a=t%IE,o=a%n,l=a+o;t+=o,0!==l&&IE-l<s&&(t+=IE-l),i.offset=t/e,t+=s}return Math.ceil(t/IE)*IE}update(){let e=!1;for(const t of this.uniforms)!0===this.updateByType(t)&&(e=!0);return e}updateByType(e){return e.isNumberUniform?this.updateNumber(e):e.isVector2Uniform?this.updateVector2(e):e.isVector3Uniform?this.updateVector3(e):e.isVector4Uniform?this.updateVector4(e):e.isColorUniform?this.updateColor(e):e.isMatrix3Uniform?this.updateMatrix3(e):e.isMatrix4Uniform?this.updateMatrix4(e):void console.error("THREE.WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1;const r=this.values,i=e.getValue(),n=e.offset,s=e.getType();if(r[n]!==i){this._getBufferForType(s)[n]=r[n]=i,t=!0}return t}updateVector2(e){let t=!1;const r=this.values,i=e.getValue(),n=e.offset,s=e.getType();if(r[n+0]!==i.x||r[n+1]!==i.y){const e=this._getBufferForType(s);e[n+0]=r[n+0]=i.x,e[n+1]=r[n+1]=i.y,t=!0}return t}updateVector3(e){let t=!1;const r=this.values,i=e.getValue(),n=e.offset,s=e.getType();if(r[n+0]!==i.x||r[n+1]!==i.y||r[n+2]!==i.z){const e=this._getBufferForType(s);e[n+0]=r[n+0]=i.x,e[n+1]=r[n+1]=i.y,e[n+2]=r[n+2]=i.z,t=!0}return t}updateVector4(e){let t=!1;const r=this.values,i=e.getValue(),n=e.offset,s=e.getType();if(r[n+0]!==i.x||r[n+1]!==i.y||r[n+2]!==i.z||r[n+4]!==i.w){const e=this._getBufferForType(s);e[n+0]=r[n+0]=i.x,e[n+1]=r[n+1]=i.y,e[n+2]=r[n+2]=i.z,e[n+3]=r[n+3]=i.w,t=!0}return t}updateColor(e){let t=!1;const r=this.values,i=e.getValue(),n=e.offset;if(r[n+0]!==i.r||r[n+1]!==i.g||r[n+2]!==i.b){const e=this.buffer;e[n+0]=r[n+0]=i.r,e[n+1]=r[n+1]=i.g,e[n+2]=r[n+2]=i.b,t=!0}return t}updateMatrix3(e){let t=!1;const r=this.values,i=e.getValue().elements,n=e.offset;if(r[n+0]!==i[0]||r[n+1]!==i[1]||r[n+2]!==i[2]||r[n+4]!==i[3]||r[n+5]!==i[4]||r[n+6]!==i[5]||r[n+8]!==i[6]||r[n+9]!==i[7]||r[n+10]!==i[8]){const e=this.buffer;e[n+0]=r[n+0]=i[0],e[n+1]=r[n+1]=i[1],e[n+2]=r[n+2]=i[2],e[n+4]=r[n+4]=i[3],e[n+5]=r[n+5]=i[4],e[n+6]=r[n+6]=i[5],e[n+8]=r[n+8]=i[6],e[n+9]=r[n+9]=i[7],e[n+10]=r[n+10]=i[8],t=!0}return t}updateMatrix4(e){let t=!1;const r=this.values,i=e.getValue().elements,n=e.offset;if(!1===function(e,t,r){for(let i=0,n=t.length;i<n;i++)if(e[r+i]!==t[i])return!1;return!0}(r,i,n)){this.buffer.set(i,n),function(e,t,r){for(let i=0,n=t.length;i<n;i++)e[r+i]=t[i]}(r,i,n),t=!0}return t}_getBufferForType(e){return"int"===e||"ivec2"===e||"ivec3"===e||"ivec4"===e?new Int32Array(this.buffer.buffer):"uint"===e||"uvec2"===e||"uvec3"===e||"uvec4"===e?new Uint32Array(this.buffer.buffer):this.buffer}}let dD=0;class pD extends cD{constructor(e,t){super(e),this.id=dD++,this.groupNode=t,this.isNodeUniformsGroup=!0}}let fD=0;class mD extends oD{constructor(e,t){super(e),this.id=fD++,this.texture=t,this.version=t?t.version:0,this.store=!1,this.generation=null,this.isSampledTexture=!0}needsBindingsUpdate(e){const{texture:t}=this;return e!==this.generation?(this.generation=e,!0):t.isVideoTexture}update(){const{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}}class gD extends mD{constructor(e,t,r,i=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r,this.access=i}needsBindingsUpdate(e){return this.textureNode.value!==this.texture||super.needsBindingsUpdate(e)}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class yD extends gD{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledCubeTexture=!0}}class bD extends gD{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledTexture3D=!0}}const xD={textureDimensions:"textureSize",equals:"equal"},vD={low:"lowp",medium:"mediump",high:"highp"},_D={swizzleAssign:!0,storageBuffer:!1},wD={perspective:"smooth",linear:"noperspective"},TD={centroid:"centroid"},MD="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\nprecision highp sampler3D;\nprecision highp samplerCube;\nprecision highp sampler2DArray;\n\nprecision highp usampler2D;\nprecision highp usampler3D;\nprecision highp usamplerCube;\nprecision highp usampler2DArray;\n\nprecision highp isampler2D;\nprecision highp isampler3D;\nprecision highp isamplerCube;\nprecision highp isampler2DArray;\n\nprecision lowp sampler2DShadow;\nprecision lowp sampler2DArrayShadow;\nprecision lowp samplerCubeShadow;\n";class SD extends lq{constructor(e,t){super(e,t,new Cq),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==_u}getMethod(e){return xD[e]||e}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),i=[];for(const e of t.inputs)i.push(this.getType(e.type)+" "+e.name);return`${this.getType(t.type)} ${t.name}( ${i.join(", ")} ) {\n\n\t${r.vars}\n\n${r.code}\n\treturn ${r.result};\n\n}`}setupPBO(e){const t=e.value;if(void 0===t.pbo){const e=t.array,r=t.count*t.itemSize,{itemSize:i}=t,n=t.array.constructor.name.toLowerCase().includes("int");let s=n?KA:YA;2===i?s=n?JA:ZA:3===i?s=n?1032:WA:4===i&&(s=n?eu:QA);const a={Float32Array:GA,Uint8Array:OA,Uint16Array:VA,Uint32Array:zA,Int8Array:LA,Int16Array:kA,Int32Array:UA,Uint8ClampedArray:OA},o=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/i))));let l=Math.ceil(r/i/o);o*l*i<r&&l++;const A=o*l*i,u=new e.constructor(A);u.set(e,0),t.array=u;const h=new Yd(t.array,o,l,s,a[t.array.constructor.name]||GA);h.needsUpdate=!0,h.isPBOTexture=!0;const c=new Sx(h,null,null);c.setPrecision("high"),t.pboNode=c,t.pbo=c.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.label)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&!0!==e.node.isTextureNode&&!0!==e.node.isBufferNode?t.charAt(0)+"_"+e.name:super.getPropertyName(e,t)}generatePBO(e){const{node:t,indexNode:r}=e,i=t.value;if(this.renderer.backend.has(i)){this.renderer.backend.get(i).pbo=i.pbo}const n=this.getUniformFromNode(i.pboNode,"texture",this.shaderStage,this.context.label),s=this.getPropertyName(n);this.increaseUsage(r);const a=r.build(this,"uint"),o=this.getDataFromNode(e);let l=o.propertyName;if(void 0===l){const r=this.getVarFromNode(e);l=this.getPropertyName(r);const n=this.getDataFromNode(t);let A=n.propertySizeName;void 0===A&&(A=l+"Size",this.getVarFromNode(t,A,"uint"),this.addLineFlowCode(`${A} = uint( textureSize( ${s}, 0 ).x )`,e),n.propertySizeName=A);const{itemSize:u}=i,h="."+vf.join("").slice(0,u),c=`ivec2(${a} % ${A}, ${a} / ${A})`,d=this.generateTextureLoad(null,s,c,null,"0");let p="vec4";i.pbo.type===zA?p="uvec4":i.pbo.type===UA&&(p="ivec4"),this.addLineFlowCode(`${l} = ${p}(${d})${h}`,e),o.propertyName=l}return l}generateTextureLoad(e,t,r,i,n="0"){return i?`texelFetch( ${t}, ivec3( ${r}, ${i} ), ${n} )`:`texelFetch( ${t}, ${r}, ${n} )`}generateTexture(e,t,r,i){return e.isDepthTexture?(i&&(r=`vec4( ${r}, ${i} )`),`texture( ${t}, ${r} ).x`):(i&&(r=`vec3( ${r}, ${i} )`),`texture( ${t}, ${r} )`)}generateTextureLevel(e,t,r,i){return`textureLod( ${t}, ${r}, ${i} )`}generateTextureBias(e,t,r,i){return`texture( ${t}, ${r}, ${i} )`}generateTextureGrad(e,t,r,i){return`textureGrad( ${t}, ${r}, ${i[0]}, ${i[1]} )`}generateTextureCompare(e,t,r,i,n,s=this.shaderStage){if("fragment"===s)return n?`texture( ${t}, vec4( ${r}, ${n}, ${i} ) )`:`texture( ${t}, vec3( ${r}, ${i} ) )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${s} shader.`)}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`${this.getVar(e.type,e.name,e.count)};`);return t.join("\n\t")}getUniforms(e){const t=this.uniforms[e],r=[],i={};for(const n of t){let t=null,s=!1;if("texture"===n.type||"texture3D"===n.type){const e=n.node.value;let r="";!0!==e.isDataTexture&&!0!==e.isData3DTexture||(e.type===zA?r="u":e.type===UA&&(r="i")),t="texture3D"===n.type&&!1===e.isArrayTexture?`${r}sampler3D ${n.name};`:e.compareFunction?!0===e.isArrayTexture?`sampler2DArrayShadow ${n.name};`:`sampler2DShadow ${n.name};`:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?`${r}sampler2DArray ${n.name};`:`${r}sampler2D ${n.name};`}else if("cubeTexture"===n.type)t=`samplerCube ${n.name};`;else if("buffer"===n.type){const e=n.node,r=this.getType(e.bufferType),i=e.bufferCount,s=i>0?i:"";t=`${e.name} {\n\t${r} ${n.name}[${s}];\n};\n`}else{t=`${this.getVectorType(n.type)} ${this.getPropertyName(n,e)};`,s=!0}const a=n.node.precision;if(null!==a&&(t=vD[a]+" "+t),s){t="\t"+t;const e=n.groupNode.name;(i[e]||(i[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let n="";for(const t in i){const r=i[t];n+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return n+=r.join("\n"),n}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==UA){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const i=r.array;!1==(i instanceof Uint32Array||i instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const i of e)t+=`layout( location = ${r++} ) in ${i.type} ${i.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],i=[];for(const e of r)if(e.output)for(const t of e.members)i.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===i.length&&i.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+i.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const i of r){"compute"===e&&(i.needsInterpolation=!0);const r=this.getType(i.type);if(i.needsInterpolation)if(i.interpolationType){t+=`${wD[i.interpolationType]||i.interpolationType} ${TD[i.interpolationSampling]||""} out ${r} ${i.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${i.name};\n`}else t+=`${r} ${i.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${wD[e.interpolationType]||e.interpolationType} ${TD[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const i=this.extensions[r]||(this.extensions[r]=new Map);!1===i.has(e)&&i.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:i}of r.values())t.push(`#extension ${e} : ${i}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=_D[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}_D[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r<e.length;r++){const i=e[r],n=this.getPropertyName(i.attributeNode);n&&(t+=`${i.varyingName} = ${n};\n\t`)}return t}_getGLSLUniformStruct(e,t){return`\nlayout( std140 ) uniform ${e} {\n${t}\n};`}_getGLSLVertexCode(e){return`#version 300 es\n\n${this.getSignature()}\n\n// extensions\n${e.extensions}\n\n// precision\n${MD}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\n\n// attributes\n${e.attributes}\n\n// codes\n${e.codes}\n\nvoid main() {\n\n\t// vars\n\t${e.vars}\n\n\t// transforms\n\t${e.transforms}\n\n\t// flow\n\t${e.flow}\n\n\tgl_PointSize = 1.0;\n\n}\n`}_getGLSLFragmentCode(e){return`#version 300 es\n\n${this.getSignature()}\n\n// extensions\n${e.extensions}\n\n// precision\n${MD}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\n\n// codes\n${e.codes}\n\n// structs\n${e.structs}\n\nvoid main() {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let r="// code\n\n";r+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1];for(const e of i){const i=this.getFlowData(e),s=e.name;s&&(r.length>0&&(r+="\n"),r+=`\t// flow -> ${s}\n\t`),r+=`${i.code}\n\t`,e===n&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${i.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${i.result};`)))}const s=e[t];s.extensions=this.getExtensions(t),s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.vars=this.getVars(t),s.structs=this.getStructs(t),s.codes=this.getCodes(t),s.transforms=this.getTransforms(t),s.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,i=null){const n=super.getUniformFromNode(e,t,r,i),s=this.getDataFromNode(e,r,this.globalCache);let a=s.uniformGPU;if(void 0===a){const i=e.groupNode,o=i.name,l=this.getBindGroupArray(o,r);if("texture"===t)a=new gD(n.name,n.node,i),l.push(a);else if("cubeTexture"===t)a=new yD(n.name,n.node,i),l.push(a);else if("texture3D"===t)a=new bD(n.name,n.node,i),l.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,n.name=`buffer${e.id}`;const t=new hD(e,i);t.name=e.name,l.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[o];void 0===s&&(s=new pD(r+"_"+o,i),e[o]=s,l.push(s)),a=this.getNodeUniform(n,t),s.addUniform(a)}s.uniformGPU=a}return n}}let ED=null,ND=null;class CD{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void lh("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void lh(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return ED=ED||new Zu,this.renderer.getDrawingBufferSize(ED)}setScissorTest(){}getClearColor(){const e=this.renderer;return ND=ND||new AN,e.getClearColor(ND),ND.getRGB(ND),ND}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:function(){const e=ah("canvas");return e.style.display="block",e}(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${hA} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let RD,BD,PD=0;class qD{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class DD{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:i}=r,n=e.array,s=e.usage||i.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let l,A=o.bufferGPU;if(void 0===A&&(A=this._createBuffer(i,t,n,s),o.bufferGPU=A,o.bufferType=t,o.version=a.version),n instanceof Float32Array)l=i.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)l=i.HALF_FLOAT;else if(n instanceof Uint16Array)l=e.isFloat16BufferAttribute?i.HALF_FLOAT:i.UNSIGNED_SHORT;else if(n instanceof Int16Array)l=i.SHORT;else if(n instanceof Uint32Array)l=i.UNSIGNED_INT;else if(n instanceof Int32Array)l=i.INT;else if(n instanceof Int8Array)l=i.BYTE;else if(n instanceof Uint8Array)l=i.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+n);l=i.UNSIGNED_BYTE}let u={bufferGPU:A,bufferType:t,type:l,byteLength:n.byteLength,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===i.INT||l===i.UNSIGNED_INT||e.gpuType===UA,id:PD++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(i,t,n,s);u=new qD(u,e)}r.set(e,u)}updateAttribute(e){const t=this.backend,{gl:r}=t,i=e.array,n=e.isInterleavedBufferAttribute?e.data:e,s=t.get(n),a=s.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,s.bufferGPU),0===o.length)r.bufferSubData(a,0,i);else{for(let e=0,t=o.length;e<t;e++){const t=o[e];r.bufferSubData(a,t.start*i.BYTES_PER_ELEMENT,i,t.start,t.count)}n.clearUpdateRanges()}r.bindBuffer(a,null),s.version=n.version}destroyAttribute(e){const t=this.backend,{gl:r}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const i=t.get(e);r.deleteBuffer(i.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,{gl:r}=t,i=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:n}=t.get(i),s=e.array,a=s.byteLength;r.bindBuffer(r.COPY_READ_BUFFER,n);const o=r.createBuffer();r.bindBuffer(r.COPY_WRITE_BUFFER,o),r.bufferData(r.COPY_WRITE_BUFFER,a,r.STREAM_READ),r.copyBufferSubData(r.COPY_READ_BUFFER,r.COPY_WRITE_BUFFER,0,0,a),await t.utils._clientWaitAsync();const l=new e.array.constructor(s.length);return r.bindBuffer(r.COPY_WRITE_BUFFER,o),r.getBufferSubData(r.COPY_WRITE_BUFFER,0,l),r.deleteBuffer(o),r.bindBuffer(r.COPY_READ_BUFFER,null),r.bindBuffer(r.COPY_WRITE_BUFFER,null),l.buffer}_createBuffer(e,t,r,i){const n=e.createBuffer();return e.bindBuffer(t,n),e.bufferData(t,r,i),e.bindBuffer(t,null),n}}class ID{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;RD={[cA]:e.FUNC_ADD,[dA]:e.FUNC_SUBTRACT,[pA]:e.FUNC_REVERSE_SUBTRACT},BD={[fA]:e.ZERO,[mA]:e.ONE,[gA]:e.SRC_COLOR,[bA]:e.SRC_ALPHA,[MA]:e.SRC_ALPHA_SATURATE,[wA]:e.DST_COLOR,[vA]:e.DST_ALPHA,[yA]:e.ONE_MINUS_SRC_COLOR,[xA]:e.ONE_MINUS_SRC_ALPHA,[TA]:e.ONE_MINUS_DST_COLOR,[_A]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=(new wh).fromArray(t),this.currentViewport=(new wh).fromArray(r),this._tempVec4=new wh}enable(e){const{enabled:t}=this;!0!==t[e]&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;!1!==t[e]&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;0!==e?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setBlending(e,t,r,i,n,s,a,o){const{gl:l}=this;if(0!==e){if(!1===this.currentBlendingEnabled&&(this.enable(l.BLEND),this.currentBlendingEnabled=!0),5===e)n=n||t,s=s||r,a=a||i,t===this.currentBlendEquation&&n===this.currentBlendEquationAlpha||(l.blendEquationSeparate(RD[t],RD[n]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=n),r===this.currentBlendSrc&&i===this.currentBlendDst&&s===this.currentBlendSrcAlpha&&a===this.currentBlendDstAlpha||(l.blendFuncSeparate(BD[r],BD[i],BD[s],BD[a]),this.currentBlendSrc=r,this.currentBlendDst=i,this.currentBlendSrcAlpha=s,this.currentBlendDstAlpha=a),this.currentBlending=e,this.currentPremultipledAlpha=!1;else if(e!==this.currentBlending||o!==this.currentPremultipledAlpha){if(this.currentBlendEquation===cA&&this.currentBlendEquationAlpha===cA||(l.blendEquation(l.FUNC_ADD),this.currentBlendEquation=cA,this.currentBlendEquationAlpha=cA),o)switch(e){case 1:l.blendFuncSeparate(l.ONE,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA);break;case 2:l.blendFunc(l.ONE,l.ONE);break;case 3:l.blendFuncSeparate(l.ZERO,l.ONE_MINUS_SRC_COLOR,l.ZERO,l.ONE);break;case 4:l.blendFuncSeparate(l.DST_COLOR,l.ONE_MINUS_SRC_ALPHA,l.ZERO,l.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA);break;case 2:l.blendFuncSeparate(l.SRC_ALPHA,l.ONE,l.ONE,l.ONE);break;case 3:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=o}}else!0===this.currentBlendingEnabled&&(this.disable(l.BLEND),this.currentBlendingEnabled=!1)}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){const{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthFunc!==e){const{gl:t}=this;switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}this.currentDepthFunc=e}}scissor(e,t,r,i){const n=this._tempVec4.set(e,t,r,i);if(!1===this.currentScissor.equals(n)){const{gl:e}=this;e.scissor(n.x,n.y,n.z,n.w),this.currentScissor.copy(n)}}viewport(e,t,r,i){const n=this._tempVec4.set(e,t,r,i);if(!1===this.currentViewport.equals(n)){const{gl:e}=this;e.viewport(n.x,n.y,n.z,n.w),this.currentViewport.copy(n)}}setScissorTest(e){const t=this.gl;e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}setStencilTest(e){const{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,r){this.currentStencilFunc===e&&this.currentStencilRef===t&&this.currentStencilFuncMask===r||(this.gl.stencilFunc(e,t,r),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=r)}setStencilOp(e,t,r){this.currentStencilFail===e&&this.currentStencilZFail===t&&this.currentStencilZPass===r||(this.gl.stencilOp(e,t,r),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=r)}setMaterial(e,t,r){const{gl:i}=this;2===e.side?this.disable(i.CULL_FACE):this.enable(i.CULL_FACE);let n=1===e.side;t&&(n=!n),this.setFlipSided(n),1===e.blending&&!1===e.transparent?this.setBlending(0):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);const s=e.stencilWrite;if(this.setStencilTest(s),s&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage&&this.backend.renderer.samples>1?this.enable(i.SAMPLE_ALPHA_TO_COVERAGE):this.disable(i.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t<r?this.enable(e+t):this.disable(e+t)}}setPolygonOffset(e,t,r){const{gl:i}=this;e?(this.enable(i.POLYGON_OFFSET_FILL),this.currentPolygonOffsetFactor===t&&this.currentPolygonOffsetUnits===r||(i.polygonOffset(t,r),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=r)):this.disable(i.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e&&(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){const r=this.gl;return(this.currentVAO!==e||this.currentIndex!==t)&&(r.bindVertexArray(e),null!==t&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0)}resetVertexState(){const e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){const{gl:r,currentBoundFramebuffers:i}=this;return i[e]!==t&&(r.bindFramebuffer(e,t),i[e]=t,e===r.DRAW_FRAMEBUFFER&&(i[r.FRAMEBUFFER]=t),e===r.FRAMEBUFFER&&(i[r.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){const{gl:r}=this;let i=[],n=!1;if(null!==e.textures){i=this.currentDrawbuffers.get(t),void 0===i&&(i=[],this.currentDrawbuffers.set(t,i));const s=e.textures;if(i.length!==s.length||i[0]!==r.COLOR_ATTACHMENT0){for(let e=0,t=s.length;e<t;e++)i[e]=r.COLOR_ATTACHMENT0+e;i.length=s.length,n=!0}}else i[0]!==r.BACK&&(i[0]=r.BACK,n=!0);n&&r.drawBuffers(i)}activeTexture(e){const{gl:t,currentTextureSlot:r,maxTextures:i}=this;void 0===e&&(e=t.TEXTURE0+i-1),r!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,r){const{gl:i,currentTextureSlot:n,currentBoundTextures:s,maxTextures:a}=this;void 0===r&&(r=null===n?i.TEXTURE0+a-1:n);let o=s[r];void 0===o&&(o={type:void 0,texture:void 0},s[r]=o),o.type===e&&o.texture===t||(n!==r&&(i.activeTexture(r),this.currentTextureSlot=r),i.bindTexture(e,t),o.type=e,o.texture=t)}bindBufferBase(e,t,r){const{gl:i}=this,n=`${e}-${t}`;return this.currentBoundBufferBases[n]!==r&&(i.bindBufferBase(e,t,r),this.currentBoundBufferBases[n]=r,!0)}unbindTexture(){const{gl:e,currentTextureSlot:t,currentBoundTextures:r}=this,i=r[t];void 0!==i&&void 0!==i.type&&(e.bindTexture(i.type,null),i.type=void 0,i.texture=void 0)}}class FD{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=""){const{gl:r,extensions:i}=this;let n;const s=ch.getTransfer(t);if(e===OA)return r.UNSIGNED_BYTE;if(1017===e)return r.UNSIGNED_SHORT_4_4_4_4;if(1018===e)return r.UNSIGNED_SHORT_5_5_5_1;if(35902===e)return r.UNSIGNED_INT_5_9_9_9_REV;if(e===LA)return r.BYTE;if(e===kA)return r.SHORT;if(e===VA)return r.UNSIGNED_SHORT;if(e===UA)return r.INT;if(e===zA)return r.UNSIGNED_INT;if(e===GA)return r.FLOAT;if(e===jA)return r.HALF_FLOAT;if(1021===e)return r.ALPHA;if(e===WA)return r.RGB;if(e===QA)return r.RGBA;if(e===$A)return r.DEPTH_COMPONENT;if(e===XA)return r.DEPTH_STENCIL;if(e===YA)return r.RED;if(e===KA)return r.RED_INTEGER;if(e===ZA)return r.RG;if(e===JA)return r.RG_INTEGER;if(e===eu)return r.RGBA_INTEGER;if(e===tu||e===ru||e===iu||e===nu)if(s===Su){if(n=i.get("WEBGL_compressed_texture_s3tc_srgb"),null===n)return null;if(e===tu)return n.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===ru)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===iu)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===nu)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(n=i.get("WEBGL_compressed_texture_s3tc"),null===n)return null;if(e===tu)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===ru)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===iu)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===nu)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===e||35841===e||35842===e||35843===e){if(n=i.get("WEBGL_compressed_texture_pvrtc"),null===n)return null;if(35840===e)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===e)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===e)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===e)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e||e===su||e===au){if(n=i.get("WEBGL_compressed_texture_etc"),null===n)return null;if(36196===e||e===su)return s===Su?n.COMPRESSED_SRGB8_ETC2:n.COMPRESSED_RGB8_ETC2;if(e===au)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:n.COMPRESSED_RGBA8_ETC2_EAC}if(e===ou||e===lu||e===Au||e===uu||e===hu||e===cu||e===du||e===pu||e===fu||e===mu||e===gu||e===yu||e===bu||e===xu){if(n=i.get("WEBGL_compressed_texture_astc"),null===n)return null;if(e===ou)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:n.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===lu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:n.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===Au)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:n.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===uu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:n.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===hu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:n.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===cu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:n.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===du)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:n.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===pu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:n.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===fu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:n.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===mu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:n.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===gu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:n.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===yu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:n.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===bu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:n.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===xu)return s===Su?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:n.COMPRESSED_RGBA_ASTC_12x12_KHR}if(e===vu){if(n=i.get("EXT_texture_compression_bptc"),null===n)return null;if(e===vu)return s===Su?n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:n.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(36283===e||36284===e||36285===e||36286===e){if(n=i.get("EXT_texture_compression_rgtc"),null===n)return null;if(e===vu)return n.COMPRESSED_RED_RGTC1_EXT;if(36284===e)return n.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===e)return n.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===e)return n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return e===HA?r.UNSIGNED_INT_24_8:void 0!==r[e]?r[e]:null}_clientWaitAsync(){const{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((r,i)=>{!function n(){const s=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(s===e.WAIT_FAILED)return e.deleteSync(t),void i();s!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(n)}()})}}let OD,LD,kD,VD=!1;class UD{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===VD&&(this._init(),VD=!0)}_init(){const e=this.gl;OD={[NA]:e.REPEAT,[CA]:e.CLAMP_TO_EDGE,[RA]:e.MIRRORED_REPEAT},LD={[BA]:e.NEAREST,[PA]:e.NEAREST_MIPMAP_NEAREST,[qA]:e.NEAREST_MIPMAP_LINEAR,[DA]:e.LINEAR,[IA]:e.LINEAR_MIPMAP_NEAREST,[FA]:e.LINEAR_MIPMAP_LINEAR},kD={[Nu]:e.NEVER,[Iu]:e.ALWAYS,[Cu]:e.LESS,[Bu]:e.LEQUAL,[Ru]:e.EQUAL,[Du]:e.GEQUAL,[Pu]:e.GREATER,[qu]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,i,n=!1){const{gl:s,extensions:a}=this;if(null!==e){if(void 0!==s[e])return s[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===s.RED&&(r===s.FLOAT&&(o=s.R32F),r===s.HALF_FLOAT&&(o=s.R16F),r===s.UNSIGNED_BYTE&&(o=s.R8),r===s.UNSIGNED_SHORT&&(o=s.R16),r===s.UNSIGNED_INT&&(o=s.R32UI),r===s.BYTE&&(o=s.R8I),r===s.SHORT&&(o=s.R16I),r===s.INT&&(o=s.R32I)),t===s.RED_INTEGER&&(r===s.UNSIGNED_BYTE&&(o=s.R8UI),r===s.UNSIGNED_SHORT&&(o=s.R16UI),r===s.UNSIGNED_INT&&(o=s.R32UI),r===s.BYTE&&(o=s.R8I),r===s.SHORT&&(o=s.R16I),r===s.INT&&(o=s.R32I)),t===s.RG&&(r===s.FLOAT&&(o=s.RG32F),r===s.HALF_FLOAT&&(o=s.RG16F),r===s.UNSIGNED_BYTE&&(o=s.RG8),r===s.UNSIGNED_SHORT&&(o=s.RG16),r===s.UNSIGNED_INT&&(o=s.RG32UI),r===s.BYTE&&(o=s.RG8I),r===s.SHORT&&(o=s.RG16I),r===s.INT&&(o=s.RG32I)),t===s.RG_INTEGER&&(r===s.UNSIGNED_BYTE&&(o=s.RG8UI),r===s.UNSIGNED_SHORT&&(o=s.RG16UI),r===s.UNSIGNED_INT&&(o=s.RG32UI),r===s.BYTE&&(o=s.RG8I),r===s.SHORT&&(o=s.RG16I),r===s.INT&&(o=s.RG32I)),t===s.RGB){const e=n?Mu:ch.getTransfer(i);r===s.FLOAT&&(o=s.RGB32F),r===s.HALF_FLOAT&&(o=s.RGB16F),r===s.UNSIGNED_BYTE&&(o=s.RGB8),r===s.UNSIGNED_SHORT&&(o=s.RGB16),r===s.UNSIGNED_INT&&(o=s.RGB32UI),r===s.BYTE&&(o=s.RGB8I),r===s.SHORT&&(o=s.RGB16I),r===s.INT&&(o=s.RGB32I),r===s.UNSIGNED_BYTE&&(o=e===Su?s.SRGB8:s.RGB8),r===s.UNSIGNED_SHORT_5_6_5&&(o=s.RGB565),r===s.UNSIGNED_SHORT_5_5_5_1&&(o=s.RGB5_A1),r===s.UNSIGNED_SHORT_4_4_4_4&&(o=s.RGB4),r===s.UNSIGNED_INT_5_9_9_9_REV&&(o=s.RGB9_E5)}if(t===s.RGB_INTEGER&&(r===s.UNSIGNED_BYTE&&(o=s.RGB8UI),r===s.UNSIGNED_SHORT&&(o=s.RGB16UI),r===s.UNSIGNED_INT&&(o=s.RGB32UI),r===s.BYTE&&(o=s.RGB8I),r===s.SHORT&&(o=s.RGB16I),r===s.INT&&(o=s.RGB32I)),t===s.RGBA){const e=n?Mu:ch.getTransfer(i);r===s.FLOAT&&(o=s.RGBA32F),r===s.HALF_FLOAT&&(o=s.RGBA16F),r===s.UNSIGNED_BYTE&&(o=s.RGBA8),r===s.UNSIGNED_SHORT&&(o=s.RGBA16),r===s.UNSIGNED_INT&&(o=s.RGBA32UI),r===s.BYTE&&(o=s.RGBA8I),r===s.SHORT&&(o=s.RGBA16I),r===s.INT&&(o=s.RGBA32I),r===s.UNSIGNED_BYTE&&(o=e===Su?s.SRGB8_ALPHA8:s.RGBA8),r===s.UNSIGNED_SHORT_4_4_4_4&&(o=s.RGBA4),r===s.UNSIGNED_SHORT_5_5_5_1&&(o=s.RGB5_A1)}return t===s.RGBA_INTEGER&&(r===s.UNSIGNED_BYTE&&(o=s.RGBA8UI),r===s.UNSIGNED_SHORT&&(o=s.RGBA16UI),r===s.UNSIGNED_INT&&(o=s.RGBA32UI),r===s.BYTE&&(o=s.RGBA8I),r===s.SHORT&&(o=s.RGBA16I),r===s.INT&&(o=s.RGBA32I)),t===s.DEPTH_COMPONENT&&(r===s.UNSIGNED_SHORT&&(o=s.DEPTH_COMPONENT16),r===s.UNSIGNED_INT&&(o=s.DEPTH_COMPONENT24),r===s.FLOAT&&(o=s.DEPTH_COMPONENT32F)),t===s.DEPTH_STENCIL&&r===s.UNSIGNED_INT_24_8&&(o=s.DEPTH24_STENCIL8),o!==s.R16F&&o!==s.R32F&&o!==s.RG16F&&o!==s.RG32F&&o!==s.RGBA16F&&o!==s.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:i,backend:n}=this,s=ch.getPrimaries(ch.workingColorSpace),a=t.colorSpace===_u?null:ch.getPrimaries(t.colorSpace),o=t.colorSpace===_u||s===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,OD[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,OD[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,OD[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,LD[t.magFilter]);const l=void 0!==t.mipmaps&&t.mipmaps.length>0,A=t.minFilter===DA&&l?FA:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,LD[A]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,kD[t.compareFunction])),!0===i.has("EXT_texture_filter_anisotropic")){if(t.magFilter===BA)return;if(t.minFilter!==qA&&t.minFilter!==FA)return;if(t.type===GA&&!1===i.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const s=i.get("EXT_texture_filter_anisotropic");r.texParameterf(e,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,n.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:i}=this,n=this.getGLTextureType(e);let s=i[n];void 0===s&&(s=t.createTexture(),r.state.bindTexture(n,s),t.texParameteri(n,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),i[n]=s),r.set(e,{textureGPU:s,glTextureType:n,isDefault:!0})}createTexture(e,t){const{gl:r,backend:i}=this,{levels:n,width:s,height:a,depth:o}=t,l=i.utils.convert(e.format,e.colorSpace),A=i.utils.convert(e.type),u=this.getInternalFormat(e.internalFormat,l,A,e.colorSpace,e.isVideoTexture),h=r.createTexture(),c=this.getGLTextureType(e);i.state.bindTexture(c,h),this.setTextureParameters(c,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,n,u,s,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,n,u,s,a,o):e.isVideoTexture||r.texStorage2D(c,n,u,s,a),i.set(e,{textureGPU:h,glTextureType:c,glFormat:l,glType:A,glInternalFormat:u})}copyBufferToTexture(e,t){const{gl:r,backend:i}=this,{textureGPU:n,glTextureType:s,glFormat:a,glType:o}=i.get(t),{width:l,height:A}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),i.state.bindTexture(s,n),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(s,0,0,0,l,A,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),i.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:i,height:n}=t,{textureGPU:s,glTextureType:a,glFormat:o,glType:l,glInternalFormat:A}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==s)if(this.backend.state.bindTexture(a,s),this.setTextureParameters(a,e),e.isCompressedTexture){const i=e.mipmaps,n=t.image;for(let t=0;t<i.length;t++){const s=i[t];e.isCompressedArrayTexture?e.format!==r.RGBA?null!==o?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,t,0,0,0,s.width,s.height,n.depth,o,s.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texSubImage3D(r.TEXTURE_2D_ARRAY,t,0,0,0,s.width,s.height,n.depth,o,l,s.data):null!==o?r.compressedTexSubImage2D(r.TEXTURE_2D,t,0,0,s.width,s.height,o,s.data):console.warn("Unsupported compressed texture format")}}else if(e.isCubeTexture){const e=t.images;for(let t=0;t<6;t++){const s=zD(e[t]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,i,n,o,l,s)}}else if(e.isDataArrayTexture||e.isArrayTexture){const e=t.image;r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,o,l,e.data)}else if(e.isData3DTexture){const e=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,o,l,e.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,A,o,l,t.image);else{const e=zD(t.image);r.texSubImage2D(a,0,0,0,i,n,o,l,e)}}generateMipmaps(e){const{gl:t,backend:r}=this,{textureGPU:i,glTextureType:n}=r.get(e);r.state.bindTexture(n,i),t.generateMipmap(n)}deallocateRenderBuffers(e){const{gl:t,backend:r}=this;if(e){const i=r.get(e);if(i.renderBufferStorageSetup=void 0,i.framebuffers){for(const e in i.framebuffers)t.deleteFramebuffer(i.framebuffers[e]);delete i.framebuffers}if(i.depthRenderbuffer&&(t.deleteRenderbuffer(i.depthRenderbuffer),delete i.depthRenderbuffer),i.stencilRenderbuffer&&(t.deleteRenderbuffer(i.stencilRenderbuffer),delete i.stencilRenderbuffer),i.msaaFrameBuffer&&(t.deleteFramebuffer(i.msaaFrameBuffer),delete i.msaaFrameBuffer),i.msaaRenderbuffers){for(let e=0;e<i.msaaRenderbuffers.length;e++)t.deleteRenderbuffer(i.msaaRenderbuffers[e]);delete i.msaaRenderbuffers}}}destroyTexture(e){const{gl:t,backend:r}=this,{textureGPU:i,renderTarget:n}=r.get(e);this.deallocateRenderBuffers(n),t.deleteTexture(i),r.delete(e)}copyTextureToTexture(e,t,r=null,i=null,n=0,s=0){const{gl:a,backend:o}=this,{state:l}=this.backend,{textureGPU:A,glTextureType:u,glType:h,glFormat:c}=o.get(t);let d,p,f,m,g,y,b,x,v;l.bindTexture(u,A);const _=e.isCompressedTexture?e.mipmaps[s]:e.image;if(null!==r)d=r.max.x-r.min.x,p=r.max.y-r.min.y,f=r.isBox3?r.max.z-r.min.z:1,m=r.min.x,g=r.min.y,y=r.isBox3?r.min.z:0;else{const t=Math.pow(2,-n);d=Math.floor(_.width*t),p=Math.floor(_.height*t),f=e.isDataArrayTexture||e.isArrayTexture?_.depth:e.isData3DTexture?Math.floor(_.depth*t):1,m=0,g=0,y=0}null!==i?(b=i.x,x=i.y,v=i.z):(b=0,x=0,v=0),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(a.UNPACK_ALIGNMENT,t.unpackAlignment);const w=a.getParameter(a.UNPACK_ROW_LENGTH),T=a.getParameter(a.UNPACK_IMAGE_HEIGHT),M=a.getParameter(a.UNPACK_SKIP_PIXELS),S=a.getParameter(a.UNPACK_SKIP_ROWS),E=a.getParameter(a.UNPACK_SKIP_IMAGES);a.pixelStorei(a.UNPACK_ROW_LENGTH,_.width),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,_.height),a.pixelStorei(a.UNPACK_SKIP_PIXELS,m),a.pixelStorei(a.UNPACK_SKIP_ROWS,g),a.pixelStorei(a.UNPACK_SKIP_IMAGES,y);const N=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isRenderTargetTexture||e.isDepthTexture){const r=o.get(e),i=o.get(t),n=o.get(r.renderTarget),s=o.get(i.renderTarget),A=n.framebuffers[r.cacheKey],u=s.framebuffers[i.cacheKey];l.bindFramebuffer(a.READ_FRAMEBUFFER,A),l.bindFramebuffer(a.DRAW_FRAMEBUFFER,u);let h=a.COLOR_BUFFER_BIT;e.isDepthTexture&&(h=a.DEPTH_BUFFER_BIT),a.blitFramebuffer(m,g,d,p,b,x,d,p,h,a.NEAREST),l.bindFramebuffer(a.READ_FRAMEBUFFER,null),l.bindFramebuffer(a.DRAW_FRAMEBUFFER,null)}else N?e.isDataTexture||e.isData3DTexture?a.texSubImage3D(u,s,b,x,v,d,p,f,c,h,_.data):t.isCompressedArrayTexture?a.compressedTexSubImage3D(u,s,b,x,v,d,p,f,c,_.data):a.texSubImage3D(u,s,b,x,v,d,p,f,c,h,_):e.isDataTexture?a.texSubImage2D(u,s,b,x,d,p,c,h,_.data):e.isCompressedTexture?a.compressedTexSubImage2D(u,s,b,x,_.width,_.height,c,_.data):a.texSubImage2D(u,s,b,x,d,p,c,h,_);a.pixelStorei(a.UNPACK_ROW_LENGTH,w),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,T),a.pixelStorei(a.UNPACK_SKIP_PIXELS,M),a.pixelStorei(a.UNPACK_SKIP_ROWS,S),a.pixelStorei(a.UNPACK_SKIP_IMAGES,E),0===s&&t.generateMipmaps&&a.generateMipmap(u),l.unbindTexture()}copyFramebufferToTexture(e,t,r){const{gl:i}=this,{state:n}=this.backend,{textureGPU:s}=this.backend.get(e),{x:a,y:o,z:l,w:A}=r,u=!0===e.isDepthTexture||t.renderTarget&&t.renderTarget.samples>0,h=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){const r=0!==a||0!==o;let u,c;if(!0===e.isDepthTexture?(u=i.DEPTH_BUFFER_BIT,c=i.DEPTH_ATTACHMENT,t.stencil&&(u|=i.STENCIL_BUFFER_BIT)):(u=i.COLOR_BUFFER_BIT,c=i.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],c=e.msaaFrameBuffer;n.bindFramebuffer(i.DRAW_FRAMEBUFFER,r),n.bindFramebuffer(i.READ_FRAMEBUFFER,c);const d=h-o-A;i.blitFramebuffer(a,d,a+l,d+A,a,d,a+l,d+A,u,i.NEAREST),n.bindFramebuffer(i.READ_FRAMEBUFFER,r),n.bindTexture(i.TEXTURE_2D,s),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,a,d,l,A),n.unbindTexture()}else{const e=i.createFramebuffer();n.bindFramebuffer(i.DRAW_FRAMEBUFFER,e),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,c,i.TEXTURE_2D,s,0),i.blitFramebuffer(0,0,l,A,0,0,l,A,u,i.NEAREST),i.deleteFramebuffer(e)}}else n.bindTexture(i.TEXTURE_2D,s),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,a,h-A-o,l,A),n.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,i=!1){const{gl:n}=this,s=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:l,width:A,height:u}=s;if(n.bindRenderbuffer(n.RENDERBUFFER,e),o&&!l){let t=n.DEPTH_COMPONENT24;if(!0===i){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(n.RENDERBUFFER,s.samples,t,A,u)}else r>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(t=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,r,t,A,u)):n.renderbufferStorage(n.RENDERBUFFER,t,A,u);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else o&&l&&(r>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,r,n.DEPTH24_STENCIL8,A,u):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,A,u),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e));n.bindRenderbuffer(n.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,i,n,s){const{backend:a,gl:o}=this,{textureGPU:l,glFormat:A,glType:u}=this.backend.get(e),h=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,h);const c=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+s:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,l,0);const d=this._getTypedArrayType(u),p=i*n*this._getBytesPerTexel(u,A),f=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,f),o.bufferData(o.PIXEL_PACK_BUFFER,p,o.STREAM_READ),o.readPixels(t,r,i,n,A,u,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const m=new d(p/d.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,f),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,m),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(h),m}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let i=0;return e===r.UNSIGNED_BYTE&&(i=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(i=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(i=4),t===r.RGBA?4*i:t===r.RGB?3*i:t===r.ALPHA?i:void 0}}function zD(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class GD{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class jD{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const HD={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class WD{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:i,object:n,type:s,info:a,index:o}=this;0!==o?r.drawElements(i,t,s,e):r.drawArrays(i,e,t),a.update(n,t,1)}renderInstances(e,t,r){const{gl:i,mode:n,type:s,index:a,object:o,info:l}=this;0!==r&&(0!==a?i.drawElementsInstanced(n,t,s,e,r):i.drawArraysInstanced(n,e,t,r),l.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:i,mode:n,object:s,info:a}=this;if(0===r)return;const o=i.get("WEBGL_multi_draw");if(null===o)for(let i=0;i<r;i++)this.render(e[i],t[i]);else{0!==this.index?o.multiDrawElementsWEBGL(n,t,0,this.type,e,0,r):o.multiDrawArraysWEBGL(n,e,0,t,0,r);let i=0;for(let e=0;e<r;e++)i+=t[e];a.update(s,i,1)}}renderMultiDrawInstances(e,t,r,i){const{extensions:n,mode:s,object:a,info:o}=this;if(0===r)return;const l=n.get("WEBGL_multi_draw");if(null===l)for(let n=0;n<r;n++)this.renderInstances(e[n],t[n],i[n]);else{0!==this.index?l.multiDrawElementsInstancedWEBGL(s,t,0,this.type,e,0,i,0,r):l.multiDrawArraysInstancedWEBGL(s,e,0,t,0,i,0,r);let n=0;for(let e=0;e<r;e++)n+=t[e]*i[e];o.update(a,n,1)}}}class QD{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.pendingResolve=!1}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}}class $D extends QD{constructor(e,t,r=2048){if(super(r),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext)return console.warn("EXT_disjoint_timer_query not supported; timestamps will be disabled."),void(this.trackTimestamp=!1);this.queries=[];for(let t=0;t<this.maxQueries;t++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return lh(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce((e,t)=>e+t,0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed)return void t(this.lastValue);let r,i=!1;const n=e=>{i||(i=!0,r&&(clearTimeout(r),r=null),t(e))},s=()=>{if(this.isDisposed)n(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void n(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(s,1));const i=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(i)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};s()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const XD=new Zu;class YD extends CD{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},i=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function n(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=n,e.domElement.addEventListener("webglcontextlost",n,!1),this.gl=i,this.extensions=new GD(this),this.capabilities=new jD(this),this.attributeUtils=new DD(this),this.textureUtils=new UD(this),this.bufferRenderer=new WD(this),this.state=new ID(this),this.utils=new FD(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return Lu}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const i=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:i.RGBA8}),null!==r){const t=e.stencilBuffer?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new $D(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(XD);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:i,width:n,height:s}=e.scissorValue;t.scissor(r,e.height-s-i,n,s)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const i=e.occlusionQueryCount;i>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(i),r.occlusionQueryObjects=new Array(i),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,i=this.get(e),n=i.previousContext;r.resetVertexState();const s=e.occlusionQueryCount;s>0&&(s>i.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e<a.length;e++){const t=a[e];t.generateMipmaps&&this.generateMipmaps(t)}this._currentContext=n;const o=e.renderTarget;if(null!==e.textures&&o){const i=this.get(o);if(o.samples>0&&!1===this._useMultisampledExtension(o)){const n=i.framebuffers[e.getCacheKey()];let s=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(s|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(s|=t.STENCIL_BUFFER_BIT));const a=i.msaaFrameBuffer,l=i.msaaRenderbuffers,A=e.textures,u=A.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),u)for(let e=0;e<A.length;e++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);for(let r=0;r<A.length;r++){if(u){const{textureGPU:e}=this.get(A[r]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,l[r]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}if(e.scissor){const{x:r,y:i,width:n,height:a}=e.scissorValue,o=e.height-a-i;t.blitFramebuffer(r,o,r+n,o+a,r,o,r+n,o+a,s,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s,t.NEAREST)}if(u)for(let e=0;e<A.length;e++){const{textureGPU:r}=this.get(A[e]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,l[e]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,r,0)}!0===this._supportsInvalidateFramebuffer&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,i.invalidationArray)}else if(!1===o.resolveDepthBuffer&&i.framebuffers){const n=i.framebuffers[e.getCacheKey()];r.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,i.depthInvalidationArray)}}if(null!==n)if(this._setFramebuffer(n),n.viewport)this.updateViewport(n);else{const{width:e,height:t}=this.getDrawingBufferSize(XD);r.viewport(0,0,e,t)}this.prepareTimestampBuffer(e)}resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueries:r,currentOcclusionQueryObjects:i}=t;if(r&&i){const e=new WeakSet,{gl:n}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;const s=()=>{let a=0;for(let t=0;t<r.length;t++){const s=r[t];null!==s&&(n.getQueryParameter(s,n.QUERY_RESULT_AVAILABLE)&&(0===n.getQueryParameter(s,n.QUERY_RESULT)&&e.add(i[t]),r[t]=null,n.deleteQuery(s),a++))}a<r.length?requestAnimationFrame(s):t.occluded=e};s()}}isOccluded(e,t){const r=this.get(e);return r.occluded&&r.occluded.has(t)}updateViewport(e){const{state:t}=this,{x:r,y:i,width:n,height:s}=e.viewportValue;t.viewport(r,e.height-s-i,n,s)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){const e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,r,i=null,n=!0){const{gl:s,renderer:a}=this;if(null===i){i={textures:null,clearColorValue:this.getClearColor()}}let o=0;if(e&&(o|=s.COLOR_BUFFER_BIT),t&&(o|=s.DEPTH_BUFFER_BIT),r&&(o|=s.STENCIL_BUFFER_BIT),0!==o){let l;l=i.clearColorValue?i.clearColorValue:this.getClearColor();const A=a.getClearDepth(),u=a.getClearStencil();if(t&&this.state.setDepthMask(!0),null===i.textures)s.clearColor(l.r,l.g,l.b,l.a),s.clear(o);else{if(n&&this._setFramebuffer(i),e)for(let e=0;e<i.textures.length;e++)0===e?s.clearBufferfv(s.COLOR,e,[l.r,l.g,l.b,l.a]):s.clearBufferfv(s.COLOR,e,[0,0,0,1]);t&&r?s.clearBufferfi(s.DEPTH_STENCIL,0,A,u):t?s.clearBufferfv(s.DEPTH,0,[A]):r&&s.clearBufferiv(s.STENCIL,0,[u])}}}beginCompute(e){const{state:t,gl:r}=this;t.bindFramebuffer(r.FRAMEBUFFER,null),this.initTimestampQuery(e)}compute(e,t,r,i){const{state:n,gl:s}=this;!1===this.discard&&(s.enable(s.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:a,transformBuffers:o,attributes:l}=this.get(i),A=this._getVaoKey(l),u=this.vaoCache[A];void 0===u?this.vaoCache[A]=this._createVao(l):n.setVertexState(u),n.useProgram(a),this._bindUniforms(r);const h=this._getTransformFeedback(o);s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,h),s.beginTransformFeedback(s.POINTS),l[0].isStorageInstancedBufferAttribute?s.drawArraysInstanced(s.POINTS,0,1,t.count):s.drawArrays(s.POINTS,0,t.count),s.endTransformFeedback(),s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,null);for(let e=0;e<o.length;e++){const t=o[e];t.pbo&&this.has(t.pbo)&&this.textureUtils.copyBufferToTexture(t.transformBuffer,t.pbo),t.switchBuffers()}}finishCompute(e){const t=this.gl;this.discard=!1,t.disable(t.RASTERIZER_DISCARD),this.prepareTimestampBuffer(e),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){const{object:t,pipeline:r,material:i,context:n,hardwareClippingPlanes:s}=e,{programGPU:a}=this.get(r),{gl:o,state:l}=this,A=this.get(n),u=e.getDrawParameters();if(null===u)return;this._bindUniforms(e.getBindings());const h=t.isMesh&&t.matrixWorld.determinant()<0;l.setMaterial(i,h,s),l.useProgram(a);const c=e.getAttributes(),d=this.get(c);let p=d.vaoGPU;if(void 0===p){const e=this._getVaoKey(c);p=this.vaoCache[e],void 0===p&&(p=this._createVao(c),this.vaoCache[e]=p,d.vaoGPU=p)}const f=e.getIndex(),m=null!==f?this.get(f).bufferGPU:null;l.setVertexState(p,m);const g=A.lastOcclusionObject;if(g!==t&&void 0!==g){if(null!==g&&!0===g.occlusionTest&&(o.endQuery(o.ANY_SAMPLES_PASSED),A.occlusionQueryIndex++),!0===t.occlusionTest){const e=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,e),A.occlusionQueries[A.occlusionQueryIndex]=e,A.occlusionQueryObjects[A.occlusionQueryIndex]=t}A.lastOcclusionObject=t}const y=this.bufferRenderer;t.isPoints?y.mode=o.POINTS:t.isLineSegments?y.mode=o.LINES:t.isLine?y.mode=o.LINE_STRIP:t.isLineLoop?y.mode=o.LINE_LOOP:!0===i.wireframe?(l.setLineWidth(i.wireframeLinewidth*this.renderer.getPixelRatio()),y.mode=o.LINES):y.mode=o.TRIANGLES;const{vertexCount:b,instanceCount:x}=u;let{firstVertex:v}=u;if(y.object=t,null!==f){v*=f.array.BYTES_PER_ELEMENT;const e=this.get(f);y.index=f.count,y.type=e.type}else y.index=0;const _=()=>{t.isBatchedMesh?null!==t._multiDrawInstances?(lh("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):lh("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):x>1?y.renderInstances(v,b,x):y.render(v,b)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),i=e.camera.cameras,n=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==i.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,n=i.length;r<n;r++){const i=o.createBuffer();e[0]=r,o.bindBuffer(o.UNIFORM_BUFFER,i),o.bufferData(o.UNIFORM_BUFFER,e,o.STATIC_DRAW),t.push(i)}r.indexesGPU=t}const s=this.get(n),a=this.renderer.getPixelRatio(),A=this._currentContext.renderTarget,u=this._isRenderCameraDepthArray(this._currentContext),h=this._currentContext.activeCubeFace;if(u){const e=this.get(A.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:t}=A;for(let e=0,r=i.length;e<r;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1);this.renderer._activeCubeFace=h,this._currentContext.activeCubeFace=h}}for(let n=0,A=i.length;n<A;n++){const A=i[n];if(t.layers.test(A.layers)){u&&(this.renderer._activeCubeFace=n,this._currentContext.activeCubeFace=n,this._setFramebuffer(this._currentContext));const t=A.viewport;if(void 0!==t){const r=t.x*a,i=t.y*a,n=t.width*a,s=t.height*a;l.viewport(Math.floor(r),Math.floor(e.context.height-s-i),Math.floor(n),Math.floor(s))}l.bindBufferBase(o.UNIFORM_BUFFER,s.index,r.indexesGPU[n]),_()}this._currentContext.activeCubeFace=h,this.renderer._activeCubeFace=h}}else _()}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,r,i,n,s){return this.textureUtils.copyTextureToBuffer(e,t,r,i,n,s)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new SD(e,t)}createProgram(e){const t=this.gl,{stage:r,code:i}=e,n="fragment"===r?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(n,i),t.compileShader(n),this.set(e,{shaderGPU:n})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const r=this.gl,i=e.pipeline,{fragmentProgram:n,vertexProgram:s}=i,a=r.createProgram(),o=this.get(n).shaderGPU,l=this.get(s).shaderGPU;if(r.attachShader(a,o),r.attachShader(a,l),r.linkProgram(a),this.set(i,{programGPU:a,fragmentShader:o,vertexShader:l}),null!==t&&this.parallel){const n=new Promise(t=>{const n=this.parallel,s=()=>{r.getProgramParameter(a,n.COMPLETION_STATUS_KHR)?(this._completeCompile(e,i),t()):requestAnimationFrame(s)};s()});return void t.push(n)}this._completeCompile(e,i)}_handleSource(e,t){const r=e.split("\n"),i=[],n=Math.max(t-6,0),s=Math.min(t+6,r.length);for(let e=n;e<s;e++){const n=e+1;i.push(`${n===t?">":" "} ${n}: ${r[e]}`)}return i.join("\n")}_getShaderErrors(e,t,r){const i=e.getShaderParameter(t,e.COMPILE_STATUS),n=e.getShaderInfoLog(t).trim();if(i&&""===n)return"";const s=/ERROR: 0:(\d+)/.exec(n);if(s){const i=parseInt(s[1]);return r.toUpperCase()+"\n\n"+n+"\n\n"+this._handleSource(e.getShaderSource(t),i)}return n}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const i=this.gl,n=i.getProgramInfoLog(e).trim();if(!1===i.getProgramParameter(e,i.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(i,e,r,t);else{const s=this._getShaderErrors(i,r,"vertex"),a=this._getShaderErrors(i,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(e,i.VALIDATE_STATUS)+"\n\nProgram Info Log: "+n+"\n"+s+"\n"+a)}else""!==n&&console.warn("THREE.WebGLProgram: Program Info Log:",n)}}_completeCompile(e,t){const{state:r,gl:i}=this,n=this.get(t),{programGPU:s,fragmentShader:a,vertexShader:o}=n;!1===i.getProgramParameter(s,i.LINK_STATUS)&&this._logProgramError(s,a,o),r.useProgram(s);const l=e.getBindings();this._setupBindings(l,s),this.set(t,{programGPU:s})}createComputePipeline(e,t){const{state:r,gl:i}=this,n={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(n);const{computeProgram:s}=e,a=i.createProgram(),o=this.get(n).shaderGPU,l=this.get(s).shaderGPU,A=s.transforms,u=[],h=[];for(let e=0;e<A.length;e++){const t=A[e];u.push(t.varyingName),h.push(t.attributeNode)}i.attachShader(a,o),i.attachShader(a,l),i.transformFeedbackVaryings(a,u,i.SEPARATE_ATTRIBS),i.linkProgram(a),!1===i.getProgramParameter(a,i.LINK_STATUS)&&this._logProgramError(a,o,l),r.useProgram(a),this._setupBindings(t,a);const c=s.attributes,d=[],p=[];for(let e=0;e<c.length;e++){const t=c[e].node.attribute;d.push(t),this.has(t)||this.attributeUtils.createAttribute(t,i.ARRAY_BUFFER)}for(let e=0;e<h.length;e++){const t=h[e].attribute;this.has(t)||this.attributeUtils.createAttribute(t,i.ARRAY_BUFFER);const r=this.get(t);p.push(r)}this.set(e,{programGPU:a,transformBuffers:p,attributes:d})}createBindings(e,t){if(!1===this._knownBindings.has(t)){this._knownBindings.add(t);let e=0,r=0;for(const i of t){this.set(i,{textures:r,uniformBuffers:e});for(const t of i.bindings)t.isUniformBuffer&&e++,t.isSampledTexture&&r++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,r=this.get(e);let i=r.uniformBuffers,n=r.textures;for(const r of e.bindings)if(r.isUniformsGroup||r.isUniformBuffer){const e=r.buffer,n=t.createBuffer();t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,e,t.DYNAMIC_DRAW),this.set(r,{index:i++,bufferGPU:n})}else if(r.isSampledTexture){const{textureGPU:e,glTextureType:t}=this.get(r.texture);this.set(r,{index:n++,textureGPU:e,glTextureType:t})}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const r=this.get(e).bufferGPU,i=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,r),t.bufferData(t.UNIFORM_BUFFER,i,t.DYNAMIC_DRAW)}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(HD).filter(t=>HD[t]===e),r=this.extensions;for(let e=0;e<t.length;e++)if(r.has(t[e]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,r=null,i=null,n=0,s=0){this.textureUtils.copyTextureToTexture(e,t,r,i,n,s)}copyFramebufferToTexture(e,t,r){this.textureUtils.copyFramebufferToTexture(e,t,r)}_setFramebuffer(e){const{gl:t,state:r}=this;let i=null;if(null!==e.textures){const n=e.renderTarget,s=this.get(n),{samples:a,depthBuffer:o,stencilBuffer:l}=n,A=!0===n.isWebGLCubeRenderTarget,u=!0===n.isRenderTarget3D,h=n.depth>1,c=!0===n.isXRRenderTarget,d=!0===c&&!0===n._hasExternalTextures;let p=s.msaaFrameBuffer,f=s.depthRenderbuffer;const m=this.extensions.get("WEBGL_multisampled_render_to_texture"),g=this.extensions.get("OVR_multiview2"),y=this._useMultisampledExtension(n),b=rN(e);let x;if(A?(s.cubeFramebuffers||(s.cubeFramebuffers={}),x=s.cubeFramebuffers[b]):c&&!1===d?x=this._xrFramebuffer:(s.framebuffers||(s.framebuffers={}),x=s.framebuffers[b]),void 0===x){x=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,x);const i=e.textures,o=[];if(A){s.cubeFramebuffers[b]=x;const{textureGPU:e}=this.get(i[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{s.framebuffers[b]=x;for(let r=0;r<i.length;r++){const s=i[r],o=this.get(s);o.renderTarget=e.renderTarget,o.cacheKey=b;const l=t.COLOR_ATTACHMENT0+r;if(n.multiview)g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,l,o.textureGPU,0,a,0,2);else if(u||h){const e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,l,o.textureGPU,0,e)}else y?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,t.TEXTURE_2D,o.textureGPU,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,l,t.TEXTURE_2D,o.textureGPU,0)}}const c=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===n._autoAllocateDepthBuffer){const r=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(r,e,0,y),s.xrDepthRenderbuffer=r,o.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,c,t.RENDERBUFFER,r)}else if(null!==e.depthTexture){o.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const r=this.get(e.depthTexture);if(r.renderTarget=e.renderTarget,r.cacheKey=b,n.multiview)g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,c,r.textureGPU,0,a,0,2);else if(d&&y)m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,c,t.TEXTURE_2D,r.textureGPU,0,a);else if(e.depthTexture.isArrayTexture){const e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,c,r.textureGPU,0,e)}else t.framebufferTexture2D(t.FRAMEBUFFER,c,t.TEXTURE_2D,r.textureGPU,0)}s.depthInvalidationArray=o}else{if(this._isRenderCameraDepthArray(e)){r.bindFramebuffer(t.FRAMEBUFFER,x);const i=this.renderer._activeCubeFace,n=this.get(e.depthTexture),s=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,s,n.textureGPU,0,i)}if((c||y||n.multiview)&&!0!==n._isOpaqueFramebuffer){r.bindFramebuffer(t.FRAMEBUFFER,x);const i=this.get(e.textures[0]);n.multiview?g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,i.textureGPU,0,a,0,2):y?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i.textureGPU,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i.textureGPU,0);const o=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===n._autoAllocateDepthBuffer){const e=s.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,o,t.RENDERBUFFER,e)}else{const r=this.get(e.depthTexture);n.multiview?g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,o,r.textureGPU,0,a,0,2):y?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,o,t.TEXTURE_2D,r.textureGPU,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,r.textureGPU,0)}}}if(a>0&&!1===y&&!n.multiview){if(void 0===p){const i=[];p=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,p);const n=[],A=e.textures;for(let r=0;r<A.length;r++){n[r]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,n[r]),i.push(t.COLOR_ATTACHMENT0+r);const s=e.textures[r],o=this.get(s);t.renderbufferStorageMultisample(t.RENDERBUFFER,a,o.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+r,t.RENDERBUFFER,n[r])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),s.msaaFrameBuffer=p,s.msaaRenderbuffers=n,o&&void 0===f){f=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(f,e,a),s.depthRenderbuffer=f;const r=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;i.push(r)}s.invalidationArray=i}i=s.msaaFrameBuffer}else i=x;r.drawBuffers(e,x)}r.bindFramebuffer(t.FRAMEBUFFER,i)}_getVaoKey(e){let t="";for(let r=0;r<e.length;r++){t+=":"+this.get(e[r]).id}return t}_createVao(e){const{gl:t}=this,r=t.createVertexArray();t.bindVertexArray(r);for(let r=0;r<e.length;r++){const i=e[r],n=this.get(i);let s,a;t.bindBuffer(t.ARRAY_BUFFER,n.bufferGPU),t.enableVertexAttribArray(r),!0===i.isInterleavedBufferAttribute?(s=i.data.stride*n.bytesPerElement,a=i.offset*n.bytesPerElement):(s=0,a=0),n.isInteger?t.vertexAttribIPointer(r,i.itemSize,n.type,s,a):t.vertexAttribPointer(r,i.itemSize,n.type,i.normalized,s,a),i.isInstancedBufferAttribute&&!i.isInterleavedBufferAttribute?t.vertexAttribDivisor(r,i.meshPerAttribute):i.isInterleavedBufferAttribute&&i.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(r,i.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),r}_getTransformFeedback(e){let t="";for(let r=0;r<e.length;r++)t+=":"+e[r].id;let r=this.transformFeedbackCache[t];if(void 0!==r)return r;const{gl:i}=this;r=i.createTransformFeedback(),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,r);for(let t=0;t<e.length;t++){const r=e[t];i.bindBufferBase(i.TRANSFORM_FEEDBACK_BUFFER,t,r.transformBuffer)}return i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=r,r}_setupBindings(e,t){const r=this.gl;for(const i of e)for(const e of i.bindings){const i=this.get(e).index;if(e.isUniformsGroup||e.isUniformBuffer){const n=r.getUniformBlockIndex(t,e.name);r.uniformBlockBinding(t,n,i)}else if(e.isSampledTexture){const n=r.getUniformLocation(t,e.name);r.uniform1i(n,i)}}}_bindUniforms(e){const{gl:t,state:r}=this;for(const i of e)for(const e of i.bindings){const i=this.get(e),n=i.index;e.isUniformsGroup||e.isUniformBuffer?r.bindBufferBase(t.UNIFORM_BUFFER,n,i.bufferGPU):e.isSampledTexture&&r.bindTexture(i.glTextureType,i.textureGPU,t.TEXTURE0+n)}}_useMultisampledExtension(e){return!0===e.multiview||e.samples>0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const KD="point-list",ZD="line-list",JD="line-strip",eI="triangle-list",tI="triangle-strip",rI="never",iI="less",nI="equal",sI="less-equal",aI="greater",oI="not-equal",lI="greater-equal",AI="always",uI="store",hI="load",cI="clear",dI="ccw",pI="none",fI="front",mI="back",gI="uint16",yI="uint32",bI="r8unorm",xI="r8snorm",vI="r8uint",_I="r8sint",wI="r16uint",TI="r16sint",MI="r16float",SI="rg8unorm",EI="rg8snorm",NI="rg8uint",CI="rg8sint",RI="r32uint",BI="r32sint",PI="r32float",qI="rg16uint",DI="rg16sint",II="rg16float",FI="rgba8unorm",OI="rgba8unorm-srgb",LI="rgba8snorm",kI="rgba8uint",VI="rgba8sint",UI="bgra8unorm",zI="bgra8unorm-srgb",GI="rgb9e5ufloat",jI="rgb10a2unorm",HI="rgb10a2unorm",WI="rg32uint",QI="rg32sint",$I="rg32float",XI="rgba16uint",YI="rgba16sint",KI="rgba16float",ZI="rgba32uint",JI="rgba32sint",eF="rgba32float",tF="depth16unorm",rF="depth24plus",iF="depth24plus-stencil8",nF="depth32float",sF="depth32float-stencil8",aF="bc1-rgba-unorm",oF="bc1-rgba-unorm-srgb",lF="bc2-rgba-unorm",AF="bc2-rgba-unorm-srgb",uF="bc3-rgba-unorm",hF="bc3-rgba-unorm-srgb",cF="bc4-r-unorm",dF="bc4-r-snorm",pF="bc5-rg-unorm",fF="bc5-rg-snorm",mF="bc6h-rgb-ufloat",gF="bc6h-rgb-float",yF="bc7-rgba-unorm",bF="bc7-rgba-srgb",xF="etc2-rgb8unorm",vF="etc2-rgb8unorm-srgb",_F="etc2-rgb8a1unorm",wF="etc2-rgb8a1unorm-srgb",TF="etc2-rgba8unorm",MF="etc2-rgba8unorm-srgb",SF="eac-r11unorm",EF="eac-r11snorm",NF="eac-rg11unorm",CF="eac-rg11snorm",RF="astc-4x4-unorm",BF="astc-4x4-unorm-srgb",PF="astc-5x4-unorm",qF="astc-5x4-unorm-srgb",DF="astc-5x5-unorm",IF="astc-5x5-unorm-srgb",FF="astc-6x5-unorm",OF="astc-6x5-unorm-srgb",LF="astc-6x6-unorm",kF="astc-6x6-unorm-srgb",VF="astc-8x5-unorm",UF="astc-8x5-unorm-srgb",zF="astc-8x6-unorm",GF="astc-8x6-unorm-srgb",jF="astc-8x8-unorm",HF="astc-8x8-unorm-srgb",WF="astc-10x5-unorm",QF="astc-10x5-unorm-srgb",$F="astc-10x6-unorm",XF="astc-10x6-unorm-srgb",YF="astc-10x8-unorm",KF="astc-10x8-unorm-srgb",ZF="astc-10x10-unorm",JF="astc-10x10-unorm-srgb",eO="astc-12x10-unorm",tO="astc-12x10-unorm-srgb",rO="astc-12x12-unorm",iO="astc-12x12-unorm-srgb",nO="clamp-to-edge",sO="repeat",aO="mirror-repeat",oO="linear",lO="nearest",AO="zero",uO="one",hO="src",cO="one-minus-src",dO="src-alpha",pO="one-minus-src-alpha",fO="dst",mO="one-minus-dst",gO="dst-alpha",yO="one-minus-dst-alpha",bO="src-alpha-saturated",xO="constant",vO="one-minus-constant",_O="add",wO="subtract",TO="reverse-subtract",MO="min",SO="max",EO=0,NO=15,CO="keep",RO="zero",BO="replace",PO="invert",qO="increment-clamp",DO="decrement-clamp",IO="increment-wrap",FO="decrement-wrap",OO="storage",LO="read-only-storage",kO="write-only",VO="read-only",UO="read-write",zO="non-filtering",GO="comparison",jO="float",HO="unfilterable-float",WO="depth",QO="sint",$O="uint",XO="2d",YO="3d",KO="2d",ZO="2d-array",JO="cube",eL="3d",tL="all",rL="vertex",iL="instance",nL={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"};class sL extends oD{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class aL extends sL{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class oL extends lD{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let lL=0;class AL extends oL{constructor(e,t){super("StorageBuffer_"+lL++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:gf.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class uL extends RE{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:oO}),this.flipYSampler=e.createSampler({minFilter:lO}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4<f32>,\n\t@location( 0 ) vTex : vec2<f32>\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2<f32>, 4 >(\n\t\tvec2<f32>( -1.0,  1.0 ),\n\t\tvec2<f32>(  1.0,  1.0 ),\n\t\tvec2<f32>( -1.0, -1.0 ),\n\t\tvec2<f32>(  1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2<f32>, 4 >(\n\t\tvec2<f32>( 0.0, 0.0 ),\n\t\tvec2<f32>( 1.0, 0.0 ),\n\t\tvec2<f32>( 0.0, 1.0 ),\n\t\tvec2<f32>( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d<f32>;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d<f32>;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:tI,stripIndexFormat:yI},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:tI,stripIndexFormat:yI},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const i=t.format,{width:n,height:s}=t.size,a=this.getTransferPipeline(i),o=this.getFlipYPipeline(i),l=this.device.createTexture({size:{width:n,height:s,depthOrArrayLayers:1},format:i,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),A=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:KO,baseArrayLayer:r}),u=l.createView({baseMipLevel:0,mipLevelCount:1,dimension:KO,baseArrayLayer:0}),h=this.device.createCommandEncoder({}),c=(e,t,r)=>{const i=e.getBindGroupLayout(0),n=this.device.createBindGroup({layout:i,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),s=h.beginRenderPass({colorAttachments:[{view:r,loadOp:cI,storeOp:uI,clearValue:[0,0,0,0]}]});s.setPipeline(e),s.setBindGroup(0,n),s.draw(4,1,0,0),s.end()};c(a,A,u),c(o,u,A),this.device.queue.submit([h.finish()]),l.destroy()}generateMipmaps(e,t,r=0){const i=this.get(e);void 0===i.useCount&&(i.useCount=0,i.layers=[]);const n=i.layers[r]||this._mipmapCreateBundles(e,t,r),s=this.device.createCommandEncoder({});this._mipmapRunBundles(s,n),this.device.queue.submit([s.finish()]),0!==i.useCount&&(i.layers[r]=n),i.useCount++}_mipmapCreateBundles(e,t,r){const i=this.getTransferPipeline(t.format),n=i.getBindGroupLayout(0);let s=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:KO,baseArrayLayer:r});const a=[];for(let o=1;o<t.mipLevelCount;o++){const l=this.device.createBindGroup({layout:n,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:s}]}),A=e.createView({baseMipLevel:o,mipLevelCount:1,dimension:KO,baseArrayLayer:r}),u={colorAttachments:[{view:A,loadOp:cI,storeOp:uI,clearValue:[0,0,0,0]}]},h=this.device.createRenderBundleEncoder({colorFormats:[t.format]});h.setPipeline(i),h.setBindGroup(0,l),h.draw(4,1,0,0),a.push({renderBundles:[h.finish()],passDescriptor:u}),s=A}return a}_mipmapRunBundles(e,t){const r=t.length;for(let i=0;i<r;i++){const r=t[i],n=e.beginRenderPass(r.passDescriptor);n.executeBundles(r.renderBundles),n.end()}}}const hL={[Nu]:"never",[Cu]:"less",[Ru]:"equal",[Bu]:"less-equal",[Pu]:"greater",[Du]:"greater-equal",[Iu]:"always",[qu]:"not-equal"},cL=[0,1,3,2,4,5];class dL{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new cp,this.depthTexture.name="depthBuffer"}createSampler(e){const t=this.backend,r=t.device,i=t.get(e),n={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};n.magFilter===oO&&n.minFilter===oO&&n.mipmapFilter===oO&&(n.maxAnisotropy=e.anisotropy),e.isDepthTexture&&null!==e.compareFunction&&(n.compare=hL[e.compareFunction]),i.sampler=r.createSampler(n)}createDefaultTexture(e){let t;const r=pL(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(r):e.isVideoTexture?this.backend.get(e).externalTexture=this._getDefaultVideoFrame():t=this._getDefaultTextureGPU(r),this.backend.get(e).texture=t}createTexture(e,t={}){const r=this.backend,i=r.get(e);if(i.initialized)throw new Error("WebGPUTextureUtils: Texture already initialized.");void 0===t.needsMipmaps&&(t.needsMipmaps=!1),void 0===t.levels&&(t.levels=1),void 0===t.depth&&(t.depth=1);const{width:n,height:s,depth:a,levels:o}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());const l=this._getDimension(e),A=e.internalFormat||t.format||pL(e,r.device);i.format=A;const{samples:u,primarySamples:h,isMSAA:c}=r.utils.getTextureSampleData(e);let d=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;!0===e.isStorageTexture&&(d|=GPUTextureUsage.STORAGE_BINDING),!0!==e.isCompressedTexture&&!0!==e.isCompressedArrayTexture&&(d|=GPUTextureUsage.RENDER_ATTACHMENT);const p={label:e.name,size:{width:n,height:s,depthOrArrayLayers:a},mipLevelCount:o,sampleCount:h,dimension:l,format:A,usage:d};if(e.isVideoTexture){const t=e.source.data,r=new VideoFrame(t);p.size.width=r.displayWidth,p.size.height=r.displayHeight,r.close(),i.externalTexture=t}else{if(void 0===A)return console.warn("WebGPURenderer: Texture format not supported."),void this.createDefaultTexture(e);e.isCubeTexture&&(p.textureBindingViewDimension=JO),i.texture=r.device.createTexture(p)}if(c){const e=Object.assign({},p);e.label=e.label+"-msaa",e.sampleCount=u,i.msaaTexture=r.device.createTexture(e)}i.initialized=!0,i.textureDescriptorGPU=p}destroyTexture(e){const t=this.backend,r=t.get(e);void 0!==r.texture&&r.texture.destroy(),void 0!==r.msaaTexture&&r.msaaTexture.destroy(),t.delete(e)}destroySampler(e){delete this.backend.get(e).sampler}generateMipmaps(e){const t=this.backend.get(e);if(e.isCubeTexture)for(let e=0;e<6;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e);else{const r=e.image.depth||1;for(let e=0;e<r;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e)}}getColorBuffer(){this.colorBuffer&&this.colorBuffer.destroy();const e=this.backend,{width:t,height:r}=e.getDrawingBufferSize();return this.colorBuffer=e.device.createTexture({label:"colorBuffer",size:{width:t,height:r,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.samples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),this.colorBuffer}getDepthBuffer(e=!0,t=!1){const r=this.backend,{width:i,height:n}=r.getDrawingBufferSize(),s=this.depthTexture,a=r.get(s).texture;let o,l;if(t?(o=XA,l=HA):e&&(o=$A,l=zA),void 0!==a){if(s.image.width===i&&s.image.height===n&&s.format===o&&s.type===l)return a;this.destroyTexture(s)}return s.name="depthBuffer",s.format=o,s.type=l,s.image.width=i,s.image.height=n,this.createTexture(s,{width:i,height:n}),r.get(s).texture}updateTexture(e,t){const r=this.backend.get(e),{textureDescriptorGPU:i}=r;if(!e.isRenderTargetTexture&&void 0!==i){if(e.isDataTexture)this._copyBufferToTexture(t.image,r.texture,i,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let n=0;n<t.image.depth;n++)this._copyBufferToTexture(t.image,r.texture,i,n,e.flipY,n);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(t.images,r.texture,i,e.flipY,e.premultiplyAlpha);else if(e.isVideoTexture){const t=e.source.data;r.externalTexture=t}else this._copyImageToTexture(t.image,r.texture,i,0,e.flipY,e.premultiplyAlpha);r.version=e.version,e.onUpdate&&e.onUpdate(e)}}async copyTextureToBuffer(e,t,r,i,n,s){const a=this.backend.device,o=this.backend.get(e),l=o.texture,A=o.textureDescriptorGPU.format,u=this._getBytesPerTexel(A);let h=i*u;h=256*Math.ceil(h/256);const c=a.createBuffer({size:i*n*u,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),d=a.createCommandEncoder();d.copyTextureToBuffer({texture:l,origin:{x:t,y:r,z:s}},{buffer:c,bytesPerRow:h},{width:i,height:n});const p=this._getTypedArrayType(A);a.queue.submit([d.finish()]),await c.mapAsync(GPUMapMode.READ);return new p(c.getMappedRange())}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(void 0===t){const r=new _h;r.minFilter=BA,r.magFilter=BA,this.createTexture(r,{width:1,height:1,format:e}),this.defaultTexture[e]=t=r}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultTexture[e];if(void 0===t){const r=new Vd;r.minFilter=BA,r.magFilter=BA,this.createTexture(r,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=r}return this.backend.get(t).texture}_getDefaultVideoFrame(){let e=this.defaultVideoFrame;if(null===e){const t={timestamp:0,codedWidth:1,codedHeight:1,format:"RGBA"};this.defaultVideoFrame=e=new VideoFrame(new Uint8Array([0,0,0,255]),t)}return e}_copyCubeMapToTexture(e,t,r,i,n){for(let s=0;s<6;s++){const a=e[s],o=!0===i?cL[s]:s;a.isDataTexture?this._copyBufferToTexture(a.image,t,r,o,i):this._copyImageToTexture(a,t,r,o,i,n)}}_copyImageToTexture(e,t,r,i,n,s){this.backend.device.queue.copyExternalImageToTexture({source:e,flipY:n},{texture:t,mipLevel:0,origin:{x:0,y:0,z:i},premultipliedAlpha:s},{width:e.width,height:e.height,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new uL(this.backend.device)),e}_generateMipmaps(e,t,r=0){this._getPassUtils().generateMipmaps(e,t,r)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,i,n,s=0){const a=this.backend.device,o=e.data,l=this._getBytesPerTexel(r.format),A=e.width*l;a.queue.writeTexture({texture:t,mipLevel:0,origin:{x:0,y:0,z:i}},o,{offset:e.width*e.height*l*s,bytesPerRow:A},{width:e.width,height:e.height,depthOrArrayLayers:1}),!0===n&&this._flipY(t,r,i)}_copyCompressedBufferToTexture(e,t,r){const i=this.backend.device,n=this._getBlockData(r.format),s=r.size.depthOrArrayLayers>1;for(let a=0;a<e.length;a++){const o=e[a],l=o.width,A=o.height,u=s?r.size.depthOrArrayLayers:1,h=Math.ceil(l/n.width)*n.byteLength,c=h*Math.ceil(A/n.height);for(let e=0;e<u;e++)i.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:e}},o.data,{offset:e*c,bytesPerRow:h,rowsPerImage:Math.ceil(A/n.height)},{width:Math.ceil(l/n.width)*n.width,height:Math.ceil(A/n.height)*n.height,depthOrArrayLayers:1})}}_getBlockData(e){return e===aF||e===oF?{byteLength:8,width:4,height:4}:e===lF||e===AF||e===uF||e===hF?{byteLength:16,width:4,height:4}:e===cF||e===dF?{byteLength:8,width:4,height:4}:e===pF||e===fF||e===mF||e===gF||e===yF||e===bF?{byteLength:16,width:4,height:4}:e===xF||e===vF||e===_F||e===wF?{byteLength:8,width:4,height:4}:e===TF||e===MF?{byteLength:16,width:4,height:4}:e===SF||e===EF?{byteLength:8,width:4,height:4}:e===NF||e===CF||e===RF||e===BF?{byteLength:16,width:4,height:4}:e===PF||e===qF?{byteLength:16,width:5,height:4}:e===DF||e===IF?{byteLength:16,width:5,height:5}:e===FF||e===OF?{byteLength:16,width:6,height:5}:e===LF||e===kF?{byteLength:16,width:6,height:6}:e===VF||e===UF?{byteLength:16,width:8,height:5}:e===zF||e===GF?{byteLength:16,width:8,height:6}:e===jF||e===HF?{byteLength:16,width:8,height:8}:e===WF||e===QF?{byteLength:16,width:10,height:5}:e===$F||e===XF?{byteLength:16,width:10,height:6}:e===YF||e===KF?{byteLength:16,width:10,height:8}:e===ZF||e===JF?{byteLength:16,width:10,height:10}:e===eO||e===tO?{byteLength:16,width:12,height:10}:e===rO||e===iO?{byteLength:16,width:12,height:12}:void 0}_convertAddressMode(e){let t=nO;return e===NA?t=sO:e===RA&&(t=aO),t}_convertFilterMode(e){let t=oO;return e!==BA&&1004!==e&&e!==qA||(t=lO),t}_getBytesPerTexel(e){return e===bI||e===xI||e===vI||e===_I?1:e===wI||e===TI||e===MI||e===SI||e===EI||e===NI||e===CI?2:e===RI||e===BI||e===PI||e===qI||e===DI||e===II||e===FI||e===OI||e===LI||e===kI||e===VI||e===UI||e===zI||e===GI||e===jI||e===HI||e===nF||e===rF||e===iF||e===sF?4:e===WI||e===QI||e===$I||e===XI||e===YI||e===KI?8:e===ZI||e===JI||e===eF?16:void 0}_getTypedArrayType(e){return e===vI?Uint8Array:e===_I?Int8Array:e===bI?Uint8Array:e===xI?Int8Array:e===NI?Uint8Array:e===CI?Int8Array:e===SI?Uint8Array:e===EI?Int8Array:e===kI?Uint8Array:e===VI?Int8Array:e===FI?Uint8Array:e===LI?Int8Array:e===wI?Uint16Array:e===TI?Int16Array:e===qI?Uint16Array:e===DI?Int16Array:e===XI?Uint16Array:e===YI?Int16Array:e===MI||e===II||e===KI?Uint16Array:e===RI?Uint32Array:e===BI?Int32Array:e===PI?Float32Array:e===WI?Uint32Array:e===QI?Int32Array:e===$I?Float32Array:e===ZI?Uint32Array:e===JI?Int32Array:e===eF?Float32Array:e===UI||e===zI?Uint8Array:e===jI||e===GI||e===HI?Uint32Array:e===nF?Float32Array:e===rF||e===iF?Uint32Array:e===sF?Float32Array:void 0}_getDimension(e){let t;return t=e.is3DTexture||e.isData3DTexture?YO:XO,t}}function pL(e,t=null){const r=e.format,i=e.type,n=e.colorSpace,s=ch.getTransfer(n);let a;if(!0===e.isCompressedTexture||!0===e.isCompressedArrayTexture)switch(r){case ru:a=s===Su?oF:aF;break;case iu:a=s===Su?AF:lF;break;case nu:a=s===Su?hF:uF;break;case su:a=s===Su?vF:xF;break;case au:a=s===Su?MF:TF;break;case ou:a=s===Su?BF:RF;break;case lu:a=s===Su?qF:PF;break;case Au:a=s===Su?IF:DF;break;case uu:a=s===Su?OF:FF;break;case hu:a=s===Su?kF:LF;break;case cu:a=s===Su?UF:VF;break;case du:a=s===Su?GF:zF;break;case pu:a=s===Su?HF:jF;break;case fu:a=s===Su?QF:WF;break;case mu:a=s===Su?XF:$F;break;case gu:a=s===Su?KF:YF;break;case yu:a=s===Su?JF:ZF;break;case bu:a=s===Su?tO:eO;break;case xu:a=s===Su?iO:rO;break;case QA:a=s===Su?OI:FI;break;default:console.error("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case QA:switch(i){case LA:a=LI;break;case kA:a=YI;break;case VA:a=XI;break;case zA:a=ZI;break;case UA:a=JI;break;case OA:a=s===Su?OI:FI;break;case jA:a=KI;break;case GA:a=eF;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",i)}break;case WA:if(35902===i)a=GI;else console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",i);break;case YA:switch(i){case LA:a=xI;break;case kA:a=TI;break;case VA:a=wI;break;case zA:a=RI;break;case UA:a=BI;break;case OA:a=bI;break;case jA:a=MI;break;case GA:a=PI;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",i)}break;case ZA:switch(i){case LA:a=EI;break;case kA:a=DI;break;case VA:a=qI;break;case zA:a=WI;break;case UA:a=QI;break;case OA:a=SI;break;case jA:a=II;break;case GA:a=$I;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",i)}break;case $A:switch(i){case VA:a=tF;break;case zA:a=rF;break;case GA:a=nF;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",i)}break;case XA:switch(i){case HA:a=iF;break;case GA:t&&!1===t.features.has(nL.Depth32FloatStencil8)&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),a=sF;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",i)}break;case KA:switch(i){case UA:a=BI;break;case zA:a=RI;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",i)}break;case JA:switch(i){case UA:a=QI;break;case zA:a=WI;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",i)}break;case eu:switch(i){case UA:a=JI;break;case zA:a=ZI;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",i)}break;default:console.error("WebGPURenderer: Unsupported texture format.",r)}return a}const fL=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,mL=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,gL={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class yL extends Tq{constructor(e){const{type:t,inputs:r,name:i,inputsCode:n,blockCode:s,outputType:a}=(e=>{const t=(e=e.trim()).match(fL);if(null!==t&&4===t.length){const r=t[2],i=[];let n=null;for(;null!==(n=mL.exec(r));)i.push({name:n[1],type:n[2]});const s=[];for(let e=0;e<i.length;e++){const{name:t,type:r}=i[e];let n=r;n.startsWith("ptr")?n="pointer":(n.startsWith("texture")&&(n=r.split("<")[0]),n=gL[n]),s.push(new uq(n,t))}const a=e.substring(t[0].length),o=t[3]||"void",l=void 0!==t[1]?t[1]:"";return{type:gL[o]||o,inputs:s,name:l,inputsCode:r,blockCode:a,outputType:o}}throw new Error("FunctionNode: Function is not a WGSL code.")})(e);super(t,r,i),this.inputsCode=n,this.blockCode=s,this.outputType=a}getCode(e=this.name){const t="void"!==this.outputType?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class bL extends wq{parseFunction(e){return new yL(e)}}const xL="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},vL={[gf.READ_ONLY]:"read",[gf.WRITE_ONLY]:"write",[gf.READ_WRITE]:"read_write"},_L={[NA]:"repeat",[CA]:"clamp",[RA]:"mirror"},wL={vertex:xL?xL.VERTEX:1,fragment:xL?xL.FRAGMENT:2,compute:xL?xL.COMPUTE:4},TL={instance:!0,swizzleAssign:!1,storageBuffer:!0},ML={"^^":"tsl_xor"},SL={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},EL={},NL={tsl_xor:new tR("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new tR("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new tR("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new tR("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new tR("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new tR("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new tR("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new tR("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new tR("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new tR("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new tR("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new tR("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new tR("\nfn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},CL={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(NL.pow_float=new tR("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),NL.pow_vec2=new tR("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[NL.pow_float]),NL.pow_vec3=new tR("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[NL.pow_float]),NL.pow_vec4=new tR("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[NL.pow_float]),CL.pow_float="tsl_pow_float",CL.pow_vec2="tsl_pow_vec2",CL.pow_vec3="tsl_pow_vec3",CL.pow_vec4="tsl_pow_vec4");let RL="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(RL+="diagnostic( off, derivative_uniformity );\n");class BL extends lq{constructor(e,t){super(e,t,new bL),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==_u}_generateTextureSample(e,t,r,i,n=this.shaderStage){return"fragment"===n?i?`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",i)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2<f32>( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,i,n){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,i):this.generateTextureLod(e,t,r,n,i)}generateWrapFunction(e){const t=`tsl_coord_${_L[e.wrapS]}S_${_L[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=EL[t];if(void 0===r){const i=[],n=e.isData3DTexture?"vec3f":"vec2f";let s=`fn ${t}( coord : ${n} ) -> ${n} {\n\n\treturn ${n}(\n`;const a=(e,t)=>{e===NA?(i.push(NL.repeatWrapping_float),s+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===CA?(i.push(NL.clampWrapping_float),s+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===RA?(i.push(NL.mirrorWrapping_float),s+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(s+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),s+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(s+=",\n",a(e.wrapR,"z")),s+="\n\t);\n\n}\n",EL[t]=r=new tR(s,i)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const i=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===i.dimensionsSnippet&&(i.dimensionsSnippet={});let n=i.dimensionsSnippet[r];if(void 0===i.dimensionsSnippet[r]){let s,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),l=o>1;a=e.isData3DTexture?"vec3<u32>":"vec2<u32>",s=l||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,n=new Nb(new hx(`textureDimensions( ${s} )`,a)),i.dimensionsSnippet[r]=n,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(i.arrayLayerCount=new Nb(new hx(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new Nb(new hx("6u","u32")))}return n.build(this)}generateFilteredTexture(e,t,r,i="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,i)}, u32( ${i} ) )`}generateTextureLod(e,t,r,i,n="0u"){const s=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,n),o=e.isData3DTexture?"vec3":"vec2",l=`${o}<u32>( ${s}( ${r} ) * ${o}<f32>( ${a} ) )`;return this.generateTextureLoad(e,t,l,i,n)}generateTextureLoad(e,t,r,i,n="0u"){let s;return!0===e.isVideoTexture?s=`textureLoad( ${t}, ${r} )`:i?s=`textureLoad( ${t}, ${r}, ${i}, u32( ${n} ) )`:(s=`textureLoad( ${t}, ${r}, u32( ${n} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(s+=".x")),s}generateTextureStore(e,t,r,i,n){let s;return s=i?`textureStore( ${t}, ${r}, ${i}, ${n} )`:`textureStore( ${t}, ${r}, ${n} )`,s}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===GA||!1===this.isSampleCompare(e)&&e.minFilter===BA&&e.magFilter===BA||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,i,n=this.shaderStage){let s=null;return s=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,i,"0",n):this._generateTextureSample(e,t,r,i,n),s}generateTextureGrad(e,t,r,i,n,s=this.shaderStage){if("fragment"===s)return`textureSampleGrad( ${t}, ${t}_sampler, ${r},  ${i[0]}, ${i[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${s} shader.`)}generateTextureCompare(e,t,r,i,n,s=this.shaderStage){if("fragment"===s)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${i} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${s} shader.`)}generateTextureLevel(e,t,r,i,n,s=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,s):this._generateTextureSampleLevel(e,t,r,i,n),a}generateTextureBias(e,t,r,i,n,s=this.shaderStage){if("fragment"===s)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${s} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=ML[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?gf.READ_ONLY:e.access}getStorageAccess(e,t){return vL[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,i=null){const n=super.getUniformFromNode(e,t,r,i),s=this.getDataFromNode(e,r,this.globalCache);if(void 0===s.uniformGPU){let a;const o=e.groupNode,l=o.name,A=this.getBindGroupArray(l,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let i=null;const s=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?i=new gD(n.name,n.node,o,s):"cubeTexture"===t?i=new yD(n.name,n.node,o,s):"texture3D"===t&&(i=new bD(n.name,n.node,o,s)),i.store=!0===e.isStorageTextureNode,i.setVisibility(wL[r]),!1===this.isUnfilterable(e.value)&&!1===i.store){const e=new aL(`${n.name}_sampler`,n.node,o);e.setVisibility(wL[r]),A.push(e,i),a=[e,i]}else A.push(i),a=[i]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const s=new("buffer"===t?hD:AL)(e,o);s.setVisibility(wL[r]),A.push(s),a=s,n.name=i||"NodeBuffer_"+n.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let i=e[l];void 0===i&&(i=new pD(l,o),i.setVisibility(wL[r]),e[l]=i,A.push(i)),a=this.getNodeUniform(n,t),i.addUniform(a)}s.uniformGPU=a}return n}getBuiltin(e,t,r,i=this.shaderStage){const n=this.builtins[i]||(this.builtins[i]=new Map);return!1===n.has(e)&&n.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),i=[];for(const e of t.inputs)i.push(e.name+" : "+this.getType(e.type));let n=`fn ${t.name}( ${i.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(n+=`\treturn ${r.result};\n`),n+="\n}\n",n}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:i,type:n}of r.values())t.push(`@builtin( ${e} ) ${i} : ${n}`);return t.join(",\n\t")}getScopedArray(e,t,r,i){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:i}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:i,bufferCount:n}of this.scopedArrays.values()){const s=this.getType(i);t.push(`var<${r}> ${e}: array< ${s}, ${n} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,i=r.length;e<i;e++){const i=r[e],n=i.name,s=this.getType(i.type);t.push(`@location( ${e} ) ${n} : ${s}`)}}return t.join(",\n\t")}getStructMembers(e){const t=[];for(const r of e.members){const i=e.output?"@location( "+r.index+" ) ":"";let n=this.getType(r.type);r.atomic&&(n="atomic< "+n+" >"),t.push(`\t${i+r.name} : ${n}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let i=`var ${t} : `;return i+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),i}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,i=this.vars[e];for(let n=0;n<r.length;n++){const s=r[n];if(s.needsInterpolation){let e=`@location( ${n} )`;if(s.interpolationType){const t=null!==s.interpolationSampling?`, ${s.interpolationSampling} )`:" )";e+=` @interpolate( ${s.interpolationType}${t}`}else/^(int|uint|ivec|uvec)/.test(s.type)&&(e+=` @interpolate( ${this.renderer.backend.compatibilityMode?"flat, either":"flat"} )`);t.push(`${e} ${s.name} : ${this.getType(s.type)}`)}else"vertex"===e&&!1===i.includes(s)&&i.push(s)}}const r=this.getBuiltins(e);r&&t.push(r);const i=t.join(",\n\t");return"vertex"===e?this._getWGSLStruct("VaryingsStruct","\t"+i):i}isCustomStruct(e){const t=e.value,r=e.node,i=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&null!==r.structTypeNode,n=r.value&&r.value.array&&"number"==typeof r.value.itemSize&&r.value.array.length>r.value.itemSize;return i&&!n}getUniforms(e){const t=this.uniforms[e],r=[],i=[],n=[],s={};for(const n of t){const t=n.groupNode.name,a=this.bindingsIndexes[t];if("texture"===n.type||"cubeTexture"===n.type||"storageTexture"===n.type||"texture3D"===n.type){const t=n.node.value;let i;!1===this.isUnfilterable(t)&&!0!==n.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${n.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${n.name}_sampler : sampler;`));let s="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(s="_multisampled"),!0===t.isCubeTexture)i="texture_cube<f32>";else if(!0===t.isDepthTexture)i=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${s}_2d<f32>`:`texture_depth${s}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===n.node.isStorageTextureNode){const r=pL(t),s=this.getStorageAccess(n.node,e),a=n.node.value.is3DTexture,o=n.node.value.isArrayTexture;i=`texture_storage_${a?"3d":"2d"+(o?"_array":"")}<${r}, ${s}>`}else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)i="texture_2d_array<f32>";else if(!0===t.is3DTexture||!0===t.isData3DTexture)i="texture_3d<f32>";else if(!0===t.isVideoTexture)i="texture_external";else{i=`texture${s}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${n.name} : ${i};`)}else if("buffer"===n.type||"storageBuffer"===n.type||"indirectStorageBuffer"===n.type){const t=n.node,r=this.getType(t.getNodeType(this)),s=t.bufferCount,o=s>0&&"buffer"===n.type?", "+s:"",l=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(n))i.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${l}> ${n.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;i.push(this._getWGSLStructBinding(n.name,e,l,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(n.type)),t=n.groupNode.name;(s[t]||(s[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${n.name} : ${e}`)}}for(const e in s){const t=s[e];n.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=i.join("\n"),a+=n.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let i="// code\n\n";i+=this.flowCode[t];const n=this.flowNodes[t],s=n[n.length-1],a=s.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of n){const n=this.getFlowData(e),l=e.name;if(l&&(i.length>0&&(i+="\n"),i+=`\t// flow -> ${l}\n`),i+=`${n.code}\n\t`,e===s&&"compute"!==t)if(i+="// result\n\n\t","vertex"===t)i+=`varyings.Vertex = ${n.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var<private> output : "+r.returnType+";",i+=`return ${n.result};`;else{let e="\t@location(0) color: vec4<f32>";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar<private> output : OutputStruct;",i+=`output.color = ${n.result};\n\n\treturn output;`}}r.flow=i}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return SL[e]||e}isAvailable(e){let t=TL[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),TL[e]=t),t}_getWGSLMethod(e){return void 0!==NL[e]&&this._include(e),CL[e]}_include(e){const t=NL[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar<private> varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${RL}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar<private> instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,i=0,n=0){const s=e+"Struct";return`${this._getWGSLStruct(s,t)}\n@binding( ${i} ) @group( ${n} )\nvar<${r}> ${e} : ${s};`}}class PL{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=iF:e.depth&&(t=rF),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?KD:e.isLineSegments||e.isMesh&&!0===t.wireframe?ZD:e.isLine?JD:e.isMesh?eI:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===OA)return UI;if(e===jA)return KI;throw new Error("Unsupported outputType")}}const qL=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"undefined"!=typeof Float16Array&&qL.set(Float16Array,["float16"]);const DL=new Map([[od,["float16"]]]),IL=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class FL{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),i=this.backend,n=i.get(r);let s=n.buffer;if(void 0===s){const a=i.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e<o.length;e++)65535===o[e]&&(o[e]=4294967295);if(r.array=o,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&3===r.itemSize){o=new o.constructor(4*r.count);for(let e=0;e<r.count;e++)o.set(r.array.subarray(3*e,3*e+3),4*e);r.itemSize=4,r.array=o,n._force3to4BytesAlignment=!0}const l=o.byteLength,A=l+(4-l%4)%4;s=a.createBuffer({label:r.name,size:A,usage:t,mappedAtCreation:!0}),new o.constructor(s.getMappedRange()).set(o),s.unmap(),n.buffer=s}}updateAttribute(e){const t=this._getBufferAttribute(e),r=this.backend,i=r.device,n=r.get(t),s=r.get(t).buffer;let a=t.array;if(!0===n._force3to4BytesAlignment){a=new a.constructor(4*t.count);for(let e=0;e<t.count;e++)a.set(t.array.subarray(3*e,3*e+3),4*e);t.array=a}const o=this._isTypedArray(a),l=t.updateRanges;if(0===l.length)i.queue.writeBuffer(s,0,a,0);else{const e=o?1:a.BYTES_PER_ELEMENT;for(let t=0,r=l.length;t<r;t++){const r=l[t];let A,u;if(!0===n._force3to4BytesAlignment){A=4*Math.floor(r.start/3)*e,u=4*Math.ceil(r.count/3)*e}else A=r.start*e,u=r.count*e;const h=A*(o?a.BYTES_PER_ELEMENT:1);i.queue.writeBuffer(s,h,a,A,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),r=new Map;for(let e=0;e<t.length;e++){const i=t[e],n=i.array.BYTES_PER_ELEMENT,s=this._getBufferAttribute(i);let a=r.get(s);if(void 0===a){let e,t;!0===i.isInterleavedBufferAttribute?(e=i.data.stride*n,t=i.data.isInstancedInterleavedBuffer?iL:rL):(e=i.itemSize*n,t=i.isInstancedBufferAttribute?iL:rL),!1!==i.normalized||i.array.constructor!==Int16Array&&i.array.constructor!==Uint16Array||(e=4),a={arrayStride:e,attributes:[],stepMode:t},r.set(s,a)}const o=this._getVertexFormat(i),l=!0===i.isInterleavedBufferAttribute?i.offset*n:0;a.attributes.push({shaderLocation:e,offset:l,format:o})}return Array.from(r.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,r=t.device,i=t.get(this._getBufferAttribute(e)).buffer,n=i.size,s=r.createBuffer({label:`${e.name}_readback`,size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder({label:`readback_encoder_${e.name}`});a.copyBufferToBuffer(i,0,s,0,n);const o=a.finish();r.queue.submit([o]),await s.mapAsync(GPUMapMode.READ);const l=s.getMappedRange(),A=new e.array.constructor(l.slice(0));return s.unmap(),A.buffer}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,i=e.array.constructor,n=e.constructor;let s;if(1===t)s=IL.get(i);else{const e=(DL.get(n)||qL.get(i))[r?1:0];if(e){const r=i.BYTES_PER_ELEMENT*t,n=4*Math.floor((r+3)/4)/i.BYTES_PER_ELEMENT;if(n%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");s=`${e}x${n}`}}return s||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),s}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class OL{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){const t=this.backend,r=t.device,i=[];let n=0;for(const r of e.bindings){const e={binding:n++,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){const t={};r.isStorageBuffer&&(4&r.visibility&&(r.access===gf.READ_WRITE||r.access===gf.WRITE_ONLY)?t.type=OO:t.type=LO),e.buffer=t}else if(r.isSampler){const i={};r.texture.isDepthTexture&&(null!==r.texture.compareFunction?i.type=GO:t.compatibilityMode&&(i.type=zO)),e.sampler=i}else if(r.isSampledTexture&&r.texture.isVideoTexture)e.externalTexture={};else if(r.isSampledTexture&&r.store){const t={};t.format=this.backend.get(r.texture).texture.format;const i=r.access;t.access=i===gf.READ_WRITE?UO:i===gf.WRITE_ONLY?kO:VO,r.texture.isArrayTexture?t.viewDimension=ZO:r.texture.is3DTexture&&(t.viewDimension=eL),e.storageTexture=t}else if(r.isSampledTexture){const i={},{primarySamples:n}=t.utils.getTextureSampleData(r.texture);if(n>1&&(i.multisampled=!0,r.texture.isDepthTexture||(i.sampleType=HO)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?i.sampleType=HO:i.sampleType=WO;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===UA?i.sampleType=QO:e===zA?i.sampleType=$O:e===GA&&(this.backend.hasFeature("float32-filterable")?i.sampleType=jO:i.sampleType=HO)}r.isSampledCubeTexture?i.viewDimension=JO:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?i.viewDimension=ZO:r.isSampledTexture3D&&(i.viewDimension=eL),e.texture=i}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);i.push(e)}return r.createBindGroupLayout({entries:i})}createBindings(e,t,r,i=0){const{backend:n,bindGroupLayoutCache:s}=this,a=n.get(e);let o,l=s.get(e.bindingsReference);void 0===l&&(l=this.createBindingsLayout(e),s.set(e.bindingsReference,l)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===i&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,l),r>0&&(a.groups[r]=o,a.versions[r]=i)),a.group=o,a.layout=l}updateBinding(e){const t=this.backend,r=t.device,i=e.buffer,n=t.get(e).buffer;r.queue.writeBuffer(n,0,i,0)}createBindGroupIndex(e,t){const r=this.backend.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=e[0],s=r.createBuffer({label:"bindingCameraIndex_"+n,size:16,usage:i});r.queue.writeBuffer(s,0,e,0);const a=[{binding:0,resource:{buffer:s}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+n,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,i=r.device;let n=0;const s=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,n=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=i.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:n});e.buffer=s}s.push({binding:n,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const i=t.attribute;e.buffer=r.get(i).buffer}s.push({binding:n,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);s.push({binding:n,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=i.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,i=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[i],void 0===a){const n=tL;let s;s=t.isSampledCubeTexture?JO:t.isSampledTexture3D?eL:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?ZO:KO,a=e[i]=e.texture.createView({aspect:n,dimension:s,mipLevelCount:r})}}s.push({binding:n,resource:a})}n++}return i.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:s})}}class LL{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:i,geometry:n,pipeline:s}=e,{vertexProgram:a,fragmentProgram:o}=s,l=this.backend,A=l.device,u=l.utils,h=l.get(s),c=[];for(const t of e.getBindings()){const e=l.get(t);c.push(e.layout)}const d=l.attributeUtils.createShaderVertexBuffers(e);let p;0===i.blending||1===i.blending&&!1===i.transparent||(p=this._getBlending(i));let f={};!0===i.stencilWrite&&(f={compare:this._getStencilCompare(i),failOp:this._getStencilOperation(i.stencilFail),depthFailOp:this._getStencilOperation(i.stencilZFail),passOp:this._getStencilOperation(i.stencilZPass)});const m=this._getColorWriteMask(i),g=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e<t.length;e++){const r=u.getTextureFormatGPU(t[e]);g.push({format:r,blend:p,writeMask:m})}}else{const t=u.getCurrentColorFormat(e.context);g.push({format:t,blend:p,writeMask:m})}const y=l.get(a).module,b=l.get(o).module,x=this._getPrimitiveState(r,n,i),v=this._getDepthCompare(i),_=u.getCurrentDepthStencilFormat(e.context),w=this._getSampleCount(e.context),T={label:`renderPipeline_${i.name||i.type}_${i.id}`,vertex:Object.assign({},y,{buffers:d}),fragment:Object.assign({},b,{targets:g}),primitive:x,multisample:{count:w,alphaToCoverageEnabled:i.alphaToCoverage&&w>1},layout:A.createPipelineLayout({bindGroupLayouts:c})},M={},S=e.context.depth,E=e.context.stencil;if(!0!==S&&!0!==E||(!0===S&&(M.format=_,M.depthWriteEnabled=i.depthWrite,M.depthCompare=v),!0===E&&(M.stencilFront=f,M.stencilBack={},M.stencilReadMask=i.stencilFuncMask,M.stencilWriteMask=i.stencilWriteMask),!0===i.polygonOffset&&(M.depthBias=i.polygonOffsetUnits,M.depthBiasSlopeScale=i.polygonOffsetFactor,M.depthBiasClamp=0),T.depthStencil=M),null===t)h.pipeline=A.createRenderPipeline(T);else{const e=new Promise(e=>{A.createRenderPipelineAsync(T).then(t=>{h.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:i,device:n}=r,s=i.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[i.getCurrentColorFormat(e)],depthStencilFormat:s,sampleCount:this._getSampleCount(e)};return n.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,i=r.device,n=r.get(e.computeProgram).module,s=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}s.pipeline=i.createComputePipeline({compute:n,layout:i.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const i=e.blending,n=e.blendSrc,s=e.blendDst,a=e.blendEquation;if(5===i){const i=null!==e.blendSrcAlpha?e.blendSrcAlpha:n,o=null!==e.blendDstAlpha?e.blendDstAlpha:s,l=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(n),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(l)}}else{const n=(e,i,n,s)=>{t={srcFactor:e,dstFactor:i,operation:_O},r={srcFactor:n,dstFactor:s,operation:_O}};if(e.premultipliedAlpha)switch(i){case 1:n(uO,pO,uO,pO);break;case 2:n(uO,uO,uO,uO);break;case 3:n(AO,cO,AO,uO);break;case 4:n(fO,pO,AO,uO)}else switch(i){case 1:n(dO,pO,uO,pO);break;case 2:n(dO,uO,uO,uO);break;case 3:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:console.error("THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true")}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case fA:t=AO;break;case 201:t=uO;break;case 202:t=hO;break;case 203:t=cO;break;case bA:t=dO;break;case xA:t=pO;break;case 208:t=fO;break;case 209:t=mO;break;case 206:t=gO;break;case 207:t=yO;break;case 210:t=bO;break;case 211:t=xO;break;case 212:t=vO;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case 512:t=rI;break;case 519:t=AI;break;case 513:t=iI;break;case 515:t=sI;break;case 514:t=nI;break;case 518:t=lI;break;case 516:t=aI;break;case 517:t=oI;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Eu:t=CO;break;case 0:t=RO;break;case 7681:t=BO;break;case 5386:t=PO;break;case 7682:t=qO;break;case 7683:t=DO;break;case 34055:t=IO;break;case 34056:t=FO;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case cA:t=_O;break;case 101:t=wO;break;case 102:t=TO;break;case 103:t=MO;break;case 104:t=SO;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const i={},n=this.backend.utils;switch(i.topology=n.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?gI:yI),r.side){case 0:i.frontFace=dI,i.cullMode=mI;break;case 1:i.frontFace=dI,i.cullMode=fI;break;case 2:i.frontFace=dI,i.cullMode=pI;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return i}_getColorWriteMask(e){return!0===e.colorWrite?NO:EO}_getDepthCompare(e){let t;if(!1===e.depthTest)t=AI;else{const r=e.depthFunc;switch(r){case 0:t=rI;break;case 1:t=AI;break;case 2:t=iI;break;case 3:t=sI;break;case 4:t=nI;break;case 5:t=lI;break;case 6:t=aI;break;case 7:t=oI;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class kL extends QD{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const i=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return lh(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const i=this.device.createCommandEncoder();i.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),i.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const n=i.finish();if(this.device.queue.submit([n]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const s=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=s[t],r=s[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class VL extends CD{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new PL(this),this.attributeUtils=new FL(this),this.bindingUtils=new OL(this),this.pipelineUtils=new LL(this),this.textureUtils=new dL(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},i="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===i)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const n=Object.values(nL),s=[];for(const e of n)i.features.has(e)&&s.push(e);const a={requiredFeatures:s,requiredLimits:t.requiredLimits};r=await i.requestDevice(a)}else r=t.device;r.lost.then(t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)});const i=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=i;const n=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(nL.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:n}),this.updateSize()}get coordinateSystem(){return ku}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,i=this.get(r);let n=i.descriptors;if(void 0===n||i.width!==r.width||i.height!==r.height||i.dimensions!==r.dimensions||i.activeMipmapLevel!==e.activeMipmapLevel||i.activeCubeFace!==e.activeCubeFace||i.samples!==r.samples){n={},i.descriptors=n;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const s=e.getCacheKey();let a=n[s];if(void 0===a){const t=e.textures,o=[];let l;const A=this._isRenderCameraDepthArray(e);for(let i=0;i<t.length;i++){const n=this.get(t[i]),s={label:`colorAttachment_${i}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:KO};if(r.isRenderTarget3D)l=e.activeCubeFace,s.baseArrayLayer=0,s.dimension=eL,s.depthOrArrayLayers=t[i].image.depth;else if(r.isRenderTarget&&t[i].image.depth>1)if(!0===A){const t=e.camera.cameras;for(let e=0;e<t.length;e++){const t={...s,baseArrayLayer:e,arrayLayerCount:1,dimension:KO},r=n.texture.createView(t);o.push({view:r,resolveTarget:void 0,depthSlice:void 0})}}else s.dimension=ZO,s.depthOrArrayLayers=t[i].image.depth;if(!0!==A){const e=n.texture.createView(s);let t,r;void 0!==n.msaaTexture?(t=n.msaaTexture.createView(),r=e):(t=e,r=void 0),o.push({view:t,resolveTarget:r,depthSlice:l})}}if(a={textureViews:o},e.depth){const t=this.get(e.depthTexture),r={};e.depthTexture.isArrayTexture&&(r.dimension=KO,r.arrayLayerCount=1,r.baseArrayLayer=e.activeCubeFace),a.depthStencilView=t.texture.createView(r)}n[s]=a,i.width=r.width,i.height=r.height,i.samples=r.samples,i.activeMipmapLevel=e.activeMipmapLevel,i.activeCubeFace=e.activeCubeFace,i.dimensions=r.dimensions}const o={colorAttachments:[]};for(let e=0;e<a.textureViews.length;e++){const r=a.textureViews[e];let i={r:0,g:0,b:0,a:1};0===e&&t.clearValue&&(i=t.clearValue),o.colorAttachments.push({view:r.view,depthSlice:r.depthSlice,resolveTarget:r.resolveTarget,loadOp:t.loadOp||hI,storeOp:t.storeOp||uI,clearValue:i})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(e){const t=this.get(e),r=this.device,i=e.occlusionQueryCount;let n,s;i>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,n=r.createQuerySet({type:"occlusion",count:i,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=n,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(i),t.lastOcclusionObject=null),s=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:hI}),this.initTimestampQuery(e,s),s.occlusionQuerySet=n;const a=s.depthStencilAttachment;if(null!==e.textures){const t=s.colorAttachments;for(let r=0;r<t.length;r++){const i=t[r];e.clearColor?(i.clearValue=0===r?e.clearColorValue:{r:0,g:0,b:0,a:1},i.loadOp=cI):i.loadOp=hI,i.storeOp=uI}}else{const t=s.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=cI):t.loadOp=hI,t.storeOp=uI}e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=cI):a.depthLoadOp=hI,a.depthStoreOp=uI),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=cI):a.stencilLoadOp=hI,a.stencilStoreOp=uI);const o=r.createCommandEncoder({label:"renderContext_"+e.id});if(!0===this._isRenderCameraDepthArray(e)){const r=e.camera.cameras;t.layerDescriptors&&t.layerDescriptors.length===r.length?this._updateDepthLayerDescriptors(e,t,r):this._createDepthLayerDescriptors(e,t,s,r),t.bundleEncoders=[],t.bundleSets=[];for(let i=0;i<r.length;i++){const r=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+i),n={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(r),t.bundleSets.push(n)}t.currentPass=null}else{const r=o.beginRenderPass(s);if(t.currentPass=r,e.viewport&&this.updateViewport(e),e.scissor){const{x:t,y:i,width:n,height:s}=e.scissorValue;r.setScissorRect(t,i,n,s)}}t.descriptor=s,t.encoder=o,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,r,i){const n=r.depthStencilAttachment;t.layerDescriptors=[];const s=this.get(e.depthTexture);s.viewCache||(s.viewCache=[]);for(let a=0;a<i.length;a++){const i={...r,colorAttachments:[{...r.colorAttachments[0],view:r.colorAttachments[a].view}]};if(r.depthStencilAttachment){const t=a;s.viewCache[t]||(s.viewCache[t]=s.texture.createView({dimension:KO,baseArrayLayer:a,arrayLayerCount:1})),i.depthStencilAttachment={view:s.viewCache[t],depthLoadOp:n.depthLoadOp||cI,depthStoreOp:n.depthStoreOp||uI,depthClearValue:n.depthClearValue||1},e.stencil&&(i.depthStencilAttachment.stencilLoadOp=n.stencilLoadOp,i.depthStencilAttachment.stencilStoreOp=n.stencilStoreOp,i.depthStencilAttachment.stencilClearValue=n.stencilClearValue)}else i.depthStencilAttachment={...n};t.layerDescriptors.push(i)}}_updateDepthLayerDescriptors(e,t,r){for(let i=0;i<r.length;i++){const r=t.layerDescriptors[i];if(r.depthStencilAttachment){const t=r.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=cI):t.depthLoadOp=hI),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=cI):t.stencilLoadOp=hI)}}}finishRender(e){const t=this.get(e),r=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const i=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e<t.bundleEncoders.length;e++){const i=t.bundleEncoders[e];r.push(i.finish())}for(let n=0;n<t.layerDescriptors.length;n++)if(n<r.length){const s=t.layerDescriptors[n],a=i.beginRenderPass(s);if(e.viewport){const{x:t,y:r,width:i,height:n,minDepth:s,maxDepth:o}=e.viewportValue;a.setViewport(t,r,i,n,s,o)}if(e.scissor){const{x:t,y:r,width:i,height:n}=e.scissorValue;a.setScissorRect(t,r,i,n)}a.executeBundles([r[n]]),a.end()}}else t.currentPass&&t.currentPass.end();if(r>0){const i=8*r;let n=this.occludedResolveCache.get(i);void 0===n&&(n=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,n));const s=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,n,0),t.encoder.copyBufferToBuffer(n,0,s,0,i),t.occlusionQueryBuffer=s,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;e<t.length;e++){const r=t[e];!0===r.generateMipmaps&&this.textureUtils.generateMipmaps(r)}}}isOccluded(e,t){const r=this.get(e);return r.occluded&&r.occluded.has(t)}async resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueryBuffer:r,currentOcclusionQueryObjects:i}=t;if(r&&i){const e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await r.mapAsync(GPUMapMode.READ);const n=r.getMappedRange(),s=new BigUint64Array(n);for(let t=0;t<i.length;t++)s[t]===BigInt(0)&&e.add(i[t]);r.destroy(),t.occluded=e}}updateViewport(e){const{currentPass:t}=this.get(e),{x:r,y:i,width:n,height:s,minDepth:a,maxDepth:o}=e.viewportValue;t.setViewport(r,i,n,s,a,o)}getClearColor(){const e=super.getClearColor();return!0===this.renderer.alpha&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,r,i=null){const n=this.device,s=this.renderer;let a,o,l,A,u=[];if(e){const e=this.getClearColor();o={r:e.r,g:e.g,b:e.b,a:e.a}}if(null===i){l=s.depth,A=s.stencil;const t=this._getDefaultRenderPassDescriptor();if(e){u=t.colorAttachments;const e=u[0];e.clearValue=o,e.loadOp=cI,e.storeOp=uI}(l||A)&&(a=t.depthStencilAttachment)}else{l=i.depth,A=i.stencil;const n={loadOp:e?cI:hI,clearValue:e?o:void 0};l&&(n.depthLoadOp=t?cI:hI,n.depthClearValue=t?s.getClearDepth():void 0,n.depthStoreOp=uI),A&&(n.stencilLoadOp=r?cI:hI,n.stencilClearValue=r?s.getClearStencil():void 0,n.stencilStoreOp=uI);const h=this._getRenderPassDescriptor(i,n);u=h.colorAttachments,a=h.depthStencilAttachment}l&&a&&void 0===a.depthLoadOp&&(t?(a.depthLoadOp=cI,a.depthClearValue=s.getClearDepth(),a.depthStoreOp=uI):(a.depthLoadOp=hI,a.depthStoreOp=uI)),A&&a&&void 0===a.stencilLoadOp&&(r?(a.stencilLoadOp=cI,a.stencilClearValue=s.getClearStencil(),a.stencilStoreOp=uI):(a.stencilLoadOp=hI,a.stencilStoreOp=uI));const h=n.createCommandEncoder({label:"clear"});h.beginRenderPass({colorAttachments:u,depthStencilAttachment:a}).end(),n.queue.submit([h.finish()])}beginCompute(e){const t=this.get(e),r={label:"computeGroup_"+e.id};this.initTimestampQuery(e,r),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(r)}compute(e,t,r,i){const{passEncoderGPU:n}=this.get(e),s=this.get(i).pipeline;this.pipelineUtils.setPipeline(n,s);for(let e=0,t=r.length;e<t;e++){const t=r[e],i=this.get(t);n.setBindGroup(e,i.group)}const a=this.device.limits.maxComputeWorkgroupsPerDimension,o=this.get(t);void 0===o.dispatchSize&&(o.dispatchSize={x:0,y:1,z:1});const{dispatchSize:l}=o;t.dispatchCount>a?(l.x=Math.min(t.dispatchCount,a),l.y=Math.ceil(t.dispatchCount/a)):l.x=t.dispatchCount,n.dispatchWorkgroups(l.x,l.y,l.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:i,context:n,pipeline:s}=e,a=e.getBindings(),o=this.get(n),l=this.get(s).pipeline,A=e.getIndex(),u=null!==A,h=e.getDrawParameters();if(null===h)return;const c=(t,r)=>{this.pipelineUtils.setPipeline(t,l),r.pipeline=l;const s=r.bindingGroups;for(let e=0,r=a.length;e<r;e++){const r=a[e],i=this.get(r);s[r.index]!==r.id&&(t.setBindGroup(r.index,i.group),s[r.index]=r.id)}if(!0===u&&r.index!==A){const e=this.get(A).buffer,i=A.array instanceof Uint16Array?gI:yI;t.setIndexBuffer(e,i),r.index=A}const h=e.getVertexBuffers();for(let e=0,i=h.length;e<i;e++){const i=h[e];if(r.attributes[e]!==i){const n=this.get(i).buffer;t.setVertexBuffer(e,n),r.attributes[e]=i}}!0===n.stencil&&!0===i.stencilWrite&&o.currentStencilRef!==i.stencilRef&&(t.setStencilReference(i.stencilRef),o.currentStencilRef=i.stencilRef)},d=(i,n)=>{if(c(i,n),!0===r.isBatchedMesh){const e=r._multiDrawStarts,n=r._multiDrawCounts,s=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&lh("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o<s;o++){const s=a?a[o]:1,l=s>1?0:o;!0===u?i.drawIndexed(n[o],s,e[o]/A.array.BYTES_PER_ELEMENT,0,l):i.draw(n[o],s,e[o],l),t.update(r,n[o],s)}}else if(!0===u){const{vertexCount:n,instanceCount:s,firstVertex:a}=h,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;i.drawIndexedIndirect(e,0)}else i.drawIndexed(n,s,a,0,0);t.update(r,n,s)}else{const{vertexCount:n,instanceCount:s,firstVertex:a}=h,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;i.drawIndirect(e,0)}else i.draw(n,s,a,0);t.update(r,n,s)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),i=e.camera.cameras,s=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==i.length){const e=this.get(s),r=[],n=new Uint32Array([0,0,0,0]);for(let t=0,s=i.length;t<s;t++){n[0]=t;const i=this.bindingUtils.createBindGroupIndex(n,e.layout);r.push(i)}t.indexesGPU=r}const a=this.renderer.getPixelRatio();for(let e=0,l=i.length;e<l;e++){const l=i[e];if(r.layers.test(l.layers)){const r=l.viewport;let i=o.currentPass,A=o.currentSets;if(o.bundleEncoders){i=o.bundleEncoders[e],A=o.bundleSets[e]}r&&i.setViewport(Math.floor(r.x*a),Math.floor(r.y*a),Math.floor(r.width*a),Math.floor(r.height*a),n.viewportValue.minDepth,n.viewportValue.maxDepth),s&&t.indexesGPU&&(i.setBindGroup(s.index,t.indexesGPU[e]),A.bindingGroups[s.index]=s.id),d(i,A)}}}else if(o.currentPass){if(void 0!==o.occlusionQuerySet){const e=o.lastOcclusionObject;e!==r&&(null!==e&&!0===e.occlusionTest&&(o.currentPass.endOcclusionQuery(),o.occlusionQueryIndex++),!0===r.occlusionTest&&(o.currentPass.beginOcclusionQuery(o.occlusionQueryIndex),o.occlusionQueryObjects[o.occlusionQueryIndex]=r),o.lastOcclusionObject=r)}d(o.currentPass,o.currentSets)}}needsRenderUpdate(e){const t=this.get(e),{object:r,material:i}=e,n=this.utils,s=n.getSampleCountRenderContext(e.context),a=n.getCurrentColorSpace(e.context),o=n.getCurrentColorFormat(e.context),l=n.getCurrentDepthStencilFormat(e.context),A=n.getPrimitiveTopology(r,i);let u=!1;return t.material===i&&t.materialVersion===i.version&&t.transparent===i.transparent&&t.blending===i.blending&&t.premultipliedAlpha===i.premultipliedAlpha&&t.blendSrc===i.blendSrc&&t.blendDst===i.blendDst&&t.blendEquation===i.blendEquation&&t.blendSrcAlpha===i.blendSrcAlpha&&t.blendDstAlpha===i.blendDstAlpha&&t.blendEquationAlpha===i.blendEquationAlpha&&t.colorWrite===i.colorWrite&&t.depthWrite===i.depthWrite&&t.depthTest===i.depthTest&&t.depthFunc===i.depthFunc&&t.stencilWrite===i.stencilWrite&&t.stencilFunc===i.stencilFunc&&t.stencilFail===i.stencilFail&&t.stencilZFail===i.stencilZFail&&t.stencilZPass===i.stencilZPass&&t.stencilFuncMask===i.stencilFuncMask&&t.stencilWriteMask===i.stencilWriteMask&&t.side===i.side&&t.alphaToCoverage===i.alphaToCoverage&&t.sampleCount===s&&t.colorSpace===a&&t.colorFormat===o&&t.depthStencilFormat===l&&t.primitiveTopology===A&&t.clippingContextCacheKey===e.clippingContextCacheKey||(t.material=i,t.materialVersion=i.version,t.transparent=i.transparent,t.blending=i.blending,t.premultipliedAlpha=i.premultipliedAlpha,t.blendSrc=i.blendSrc,t.blendDst=i.blendDst,t.blendEquation=i.blendEquation,t.blendSrcAlpha=i.blendSrcAlpha,t.blendDstAlpha=i.blendDstAlpha,t.blendEquationAlpha=i.blendEquationAlpha,t.colorWrite=i.colorWrite,t.depthWrite=i.depthWrite,t.depthTest=i.depthTest,t.depthFunc=i.depthFunc,t.stencilWrite=i.stencilWrite,t.stencilFunc=i.stencilFunc,t.stencilFail=i.stencilFail,t.stencilZFail=i.stencilZFail,t.stencilZPass=i.stencilZPass,t.stencilFuncMask=i.stencilFuncMask,t.stencilWriteMask=i.stencilWriteMask,t.side=i.side,t.alphaToCoverage=i.alphaToCoverage,t.sampleCount=s,t.colorSpace=a,t.colorFormat=o,t.depthStencilFormat=l,t.primitiveTopology=A,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){const{object:t,material:r}=e,i=this.utils,n=e.context;return[r.transparent,r.blending,r.premultipliedAlpha,r.blendSrc,r.blendDst,r.blendEquation,r.blendSrcAlpha,r.blendDstAlpha,r.blendEquationAlpha,r.colorWrite,r.depthWrite,r.depthTest,r.depthFunc,r.stencilWrite,r.stencilFunc,r.stencilFail,r.stencilZFail,r.stencilZPass,r.stencilFuncMask,r.stencilWriteMask,r.side,i.getSampleCountRenderContext(n),i.getCurrentColorSpace(n),i.getCurrentColorFormat(n),i.getCurrentDepthStencilFormat(n),i.getPrimitiveTopology(t,r),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,r,i,n,s){return this.textureUtils.copyTextureToBuffer(e,t,r,i,n,s)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const r=e.isComputeNode?"compute":"render";this.timestampQueryPool[r]||(this.timestampQueryPool[r]=new kL(this.device,r,2048));const i=this.timestampQueryPool[r],n=i.allocateQueriesForContext(e);t.timestampWrites={querySet:i.querySet,beginningOfPassWriteIndex:n,endOfPassWriteIndex:n+1}}createNodeBuilder(e,t){return new BL(e,t)}createProgram(e){this.get(e).module={module:this.device.createShaderModule({code:e.code,label:e.stage+(""!==e.name?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const r=this.get(e),i=r.currentPass.finish();this.get(t).bundleGPU=i,r.currentSets=r._currentSets,r.currentPass=r._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,r,i){this.bindingUtils.createBindings(e,t,r,i)}updateBindings(e,t,r,i){this.bindingUtils.createBindings(e,t,r,i)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,r=null,i=null,n=0,s=0){let a=0,o=0,l=0,A=0,u=0,h=0,c=e.image.width,d=e.image.height,p=1;null!==r&&(!0===r.isBox3?(A=r.min.x,u=r.min.y,h=r.min.z,c=r.max.x-r.min.x,d=r.max.y-r.min.y,p=r.max.z-r.min.z):(A=r.min.x,u=r.min.y,c=r.max.x-r.min.x,d=r.max.y-r.min.y,p=1)),null!==i&&(a=i.x,o=i.y,l=i.z||0);const f=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),m=this.get(e).texture,g=this.get(t).texture;f.copyTextureToTexture({texture:m,mipLevel:n,origin:{x:A,y:u,z:h}},{texture:g,mipLevel:s,origin:{x:a,y:o,z:l}},[c,d,p]),this.device.queue.submit([f.finish()]),0===s&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,r){const i=this.get(t);let n=null;n=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();const s=this.get(e).texture;if(n.format!==s.format)return void console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",n.format,s.format);let a;if(i.currentPass?(i.currentPass.end(),a=i.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),a.copyTextureToTexture({texture:n,origin:[r.x,r.y,0]},{texture:s},[r.z,r.w]),i.currentPass){const{descriptor:e}=i;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=hI;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=hI),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=hI),i.currentPass=a.beginRenderPass(e),i.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){const{x:e,y:r,width:n,height:s}=t.scissorValue;i.currentPass.setScissorRect(e,r,n,s)}}else this.device.queue.submit([a.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}}class UL extends Pp{constructor(e,t,r,i,n,s){super(e,t,r,i,n,s),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class zL extends Pp{constructor(e,t,r,i,n,s){super(e,t,r,i,n,s),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class GL extends kq{constructor(){super(),this.addMaterial(gM,"MeshPhongMaterial"),this.addMaterial(sE,"MeshStandardMaterial"),this.addMaterial(oE,"MeshPhysicalMaterial"),this.addMaterial(hE,"MeshToonMaterial"),this.addMaterial(lM,"MeshBasicMaterial"),this.addMaterial(fM,"MeshLambertMaterial"),this.addMaterial(XT,"MeshNormalMaterial"),this.addMaterial(pE,"MeshMatcapMaterial"),this.addMaterial(UT,"LineBasicMaterial"),this.addMaterial(GT,"LineDashedMaterial"),this.addMaterial(xE,"PointsMaterial"),this.addMaterial(yE,"SpriteMaterial"),this.addMaterial(wE,"ShadowMaterial"),this.addLight(TB,Op),this.addLight(hq,Vp),this.addLight(fq,zp),this.addLight(mq,Pp),this.addLight(xq,Up),this.addLight(vq,Sp),this.addLight(_q,jp),this.addLight(gq,UL),this.addLight(bq,zL),this.addToneMapping(HC,1),this.addToneMapping(WC,2),this.addToneMapping(QC,3),this.addToneMapping(XC,4),this.addToneMapping(JC,6),this.addToneMapping(eR,7)}}class jL extends aD{constructor(e={}){let t;e.forceWebGL?t=YD:(t=VL,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new YD(e)));super(new t(e),e),this.library=new GL,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}NP.BRDF_GGX,NP.BRDF_Lambert,NP.BasicShadowFilter,NP.Break,NP.Continue,NP.DFGApprox,NP.D_GGX,NP.Discard,NP.EPSILON,NP.F_Schlick;const HL=NP.Fn;NP.INFINITY;const WL=NP.If;NP.Switch;const QL=NP.Loop;NP.NodeShaderStage,NP.NodeType,NP.NodeUpdateType,NP.NodeAccess,NP.PCFShadowFilter,NP.PCFSoftShadowFilter,NP.PI,NP.PI2,NP.Return,NP.Schlick_to_F0,NP.ScriptableNodeResources,NP.ShaderNode,NP.TBNViewMatrix,NP.VSMShadowFilter,NP.V_GGX_SmithCorrelated,NP.abs,NP.acesFilmicToneMapping,NP.acos,NP.add,NP.addNodeElement,NP.agxToneMapping,NP.all,NP.alphaT,NP.and,NP.anisotropy,NP.anisotropyB,NP.anisotropyT,NP.any,NP.append,NP.array,NP.arrayBuffer;const $L=NP.asin;NP.assign,NP.atan,NP.atan2,NP.atomicAdd,NP.atomicAnd,NP.atomicFunc,NP.atomicMax,NP.atomicMin,NP.atomicOr,NP.atomicStore,NP.atomicSub,NP.atomicXor,NP.atomicLoad,NP.attenuationColor,NP.attenuationDistance,NP.attribute,NP.attributeArray,NP.backgroundBlurriness,NP.backgroundIntensity,NP.backgroundRotation,NP.batch,NP.bentNormalView,NP.billboarding,NP.bitAnd,NP.bitNot,NP.bitOr,NP.bitXor,NP.bitangentGeometry,NP.bitangentLocal,NP.bitangentView,NP.bitangentWorld,NP.bitcast,NP.blendBurn,NP.blendColor,NP.blendDodge,NP.blendOverlay,NP.blendScreen,NP.blur,NP.bool,NP.buffer,NP.bufferAttribute,NP.bumpMap,NP.burn,NP.bvec2,NP.bvec3,NP.bvec4,NP.bypass,NP.cache,NP.call,NP.cameraFar,NP.cameraIndex,NP.cameraNear,NP.cameraNormalMatrix,NP.cameraPosition,NP.cameraProjectionMatrix,NP.cameraProjectionMatrixInverse,NP.cameraViewMatrix,NP.cameraWorldMatrix,NP.cbrt,NP.cdl,NP.ceil,NP.checker,NP.cineonToneMapping,NP.clamp,NP.clearcoat,NP.clearcoatRoughness,NP.code,NP.color,NP.colorSpaceToWorking,NP.colorToDirection,NP.compute,NP.computeSkinning,NP.cond,NP.Const,NP.context,NP.convert,NP.convertColorSpace,NP.convertToTexture;const XL=NP.cos;NP.cross,NP.cubeTexture,NP.dFdx,NP.dFdy,NP.dashSize,NP.debug,NP.decrement,NP.decrementBefore,NP.defaultBuildStages,NP.defaultShaderStages,NP.defined,NP.degrees,NP.deltaTime,NP.densityFog,NP.densityFogFactor,NP.depth,NP.depthPass,NP.difference,NP.diffuseColor,NP.directPointLight,NP.directionToColor,NP.dispersion,NP.distance,NP.div,NP.dodge,NP.dot,NP.drawIndex,NP.dynamicBufferAttribute,NP.element,NP.emissive,NP.equal,NP.equals,NP.equirectUV;const YL=NP.exp;NP.exp2,NP.expression,NP.faceDirection,NP.faceForward,NP.faceforward;const KL=NP.float;NP.floor,NP.fog,NP.fract,NP.frameGroup,NP.frameId,NP.frontFacing,NP.fwidth,NP.gain,NP.gapSize,NP.getConstNodeType,NP.getCurrentStack,NP.getDirection,NP.getDistanceAttenuation,NP.getGeometryRoughness,NP.getNormalFromDepth,NP.getParallaxCorrectNormal,NP.getRoughness,NP.getScreenPosition,NP.getShIrradianceAt,NP.getTextureIndex,NP.getViewPosition,NP.getShadowMaterial,NP.getShadowRenderObjectFunction,NP.glsl,NP.glslFn,NP.grayscale,NP.greaterThan,NP.greaterThanEqual,NP.hash,NP.highpModelNormalViewMatrix,NP.highpModelViewMatrix,NP.hue,NP.increment,NP.incrementBefore,NP.instance;const ZL=NP.instanceIndex;NP.instancedArray,NP.instancedBufferAttribute,NP.instancedDynamicBufferAttribute,NP.instancedMesh,NP.int,NP.inverseSqrt,NP.inversesqrt,NP.invocationLocalIndex,NP.invocationSubgroupIndex,NP.ior,NP.iridescence,NP.iridescenceIOR,NP.iridescenceThickness,NP.ivec2,NP.ivec3,NP.ivec4,NP.js,NP.label,NP.length,NP.lengthSq,NP.lessThan,NP.lessThanEqual,NP.lightPosition,NP.lightShadowMatrix,NP.lightTargetDirection,NP.lightTargetPosition,NP.lightViewPosition,NP.lightingContext,NP.lights,NP.linearDepth,NP.linearToneMapping,NP.localId,NP.globalId,NP.log,NP.log2,NP.logarithmicDepthToViewZ,NP.loop,NP.luminance,NP.mediumpModelViewMatrix,NP.mat2,NP.mat3,NP.mat4,NP.matcapUV,NP.materialAO,NP.materialAlphaTest,NP.materialAnisotropy,NP.materialAnisotropyVector,NP.materialAttenuationColor,NP.materialAttenuationDistance,NP.materialClearcoat,NP.materialClearcoatNormal,NP.materialClearcoatRoughness,NP.materialColor,NP.materialDispersion,NP.materialEmissive,NP.materialIOR,NP.materialIridescence,NP.materialIridescenceIOR,NP.materialIridescenceThickness,NP.materialLightMap,NP.materialLineDashOffset,NP.materialLineDashSize,NP.materialLineGapSize,NP.materialLineScale,NP.materialLineWidth,NP.materialMetalness,NP.materialNormal,NP.materialOpacity,NP.materialPointSize,NP.materialReference,NP.materialReflectivity,NP.materialRefractionRatio,NP.materialRotation,NP.materialRoughness,NP.materialSheen,NP.materialSheenRoughness,NP.materialShininess,NP.materialSpecular,NP.materialSpecularColor,NP.materialSpecularIntensity,NP.materialSpecularStrength,NP.materialThickness,NP.materialTransmission,NP.max,NP.maxMipLevel,NP.metalness,NP.min,NP.mix,NP.mixElement,NP.mod,NP.modInt,NP.modelDirection,NP.modelNormalMatrix,NP.modelPosition,NP.modelRadius,NP.modelScale,NP.modelViewMatrix,NP.modelViewPosition,NP.modelViewProjection,NP.modelWorldMatrix,NP.modelWorldMatrixInverse,NP.morphReference,NP.mrt,NP.mul,NP.mx_aastep,NP.mx_cell_noise_float,NP.mx_contrast,NP.mx_fractal_noise_float,NP.mx_fractal_noise_vec2,NP.mx_fractal_noise_vec3,NP.mx_fractal_noise_vec4,NP.mx_hsvtorgb,NP.mx_noise_float,NP.mx_noise_vec3,NP.mx_noise_vec4,NP.mx_ramplr,NP.mx_ramptb,NP.mx_rgbtohsv,NP.mx_safepower,NP.mx_splitlr,NP.mx_splittb,NP.mx_srgb_texture_to_lin_rec709,NP.mx_transform_uv,NP.mx_worley_noise_float,NP.mx_worley_noise_vec2,NP.mx_worley_noise_vec3;const JL=NP.negate;NP.neutralToneMapping,NP.nodeArray,NP.nodeImmutable,NP.nodeObject,NP.nodeObjects,NP.nodeProxy,NP.normalFlat,NP.normalGeometry,NP.normalLocal,NP.normalMap,NP.normalView,NP.normalViewGeometry,NP.normalWorld,NP.normalWorldGeometry,NP.normalize,NP.not,NP.notEqual,NP.numWorkgroups,NP.objectDirection,NP.objectGroup,NP.objectPosition,NP.objectRadius,NP.objectScale,NP.objectViewPosition,NP.objectWorldMatrix,NP.oneMinus,NP.or,NP.orthographicDepthToViewZ,NP.oscSawtooth,NP.oscSine,NP.oscSquare,NP.oscTriangle,NP.output,NP.outputStruct,NP.overlay,NP.overloadingFn,NP.parabola,NP.parallaxDirection,NP.parallaxUV,NP.parameter,NP.pass,NP.passTexture,NP.pcurve,NP.perspectiveDepthToViewZ,NP.pmremTexture,NP.pointUV,NP.pointWidth,NP.positionGeometry,NP.positionLocal,NP.positionPrevious,NP.positionView,NP.positionViewDirection,NP.positionWorld,NP.positionWorldDirection,NP.posterize,NP.pow,NP.pow2,NP.pow3,NP.pow4,NP.premultiplyAlpha,NP.property,NP.radians,NP.rand,NP.range,NP.rangeFog,NP.rangeFogFactor,NP.reciprocal,NP.lightProjectionUV,NP.reference,NP.referenceBuffer,NP.reflect,NP.reflectVector,NP.reflectView,NP.reflector,NP.refract,NP.refractVector,NP.refractView,NP.reinhardToneMapping,NP.remainder,NP.remap,NP.remapClamp,NP.renderGroup,NP.renderOutput,NP.rendererReference,NP.rotate,NP.rotateUV,NP.roughness,NP.round,NP.rtt,NP.sRGBTransferEOTF,NP.sRGBTransferOETF,NP.sample,NP.sampler,NP.samplerComparison,NP.saturate,NP.saturation,NP.screen,NP.screenCoordinate,NP.screenSize,NP.screenUV,NP.scriptable,NP.scriptableValue,NP.select,NP.setCurrentStack,NP.shaderStages,NP.shadow,NP.pointShadow,NP.shadowPositionWorld,NP.sharedUniformGroup,NP.shapeCircle,NP.sheen,NP.sheenRoughness,NP.shiftLeft,NP.shiftRight,NP.shininess,NP.sign;const ek=NP.sin;NP.sinc,NP.skinning,NP.smoothstep,NP.smoothstepElement,NP.specularColor,NP.specularF90,NP.spherizeUV,NP.split,NP.spritesheetUV;const tk=NP.sqrt;NP.stack,NP.step;const rk=NP.storage;NP.storageBarrier,NP.storageObject,NP.storageTexture,NP.string,NP.struct,NP.sub,NP.subBuild,NP.subgroupIndex,NP.subgroupSize,NP.tan,NP.tangentGeometry,NP.tangentLocal,NP.tangentView,NP.tangentWorld,NP.temp,NP.texture,NP.texture3D,NP.textureBarrier,NP.textureBicubic,NP.textureBicubicLevel,NP.textureCubeUV,NP.textureLoad,NP.textureSize,NP.textureStore,NP.thickness,NP.time,NP.timerDelta,NP.timerGlobal,NP.timerLocal,NP.toneMapping,NP.toneMappingExposure,NP.toonOutlinePass,NP.transformDirection,NP.transformNormal,NP.transformNormalToView,NP.transformedClearcoatNormalView,NP.transformedNormalView,NP.transformedNormalWorld,NP.transmission,NP.transpose,NP.triNoise3D,NP.triplanarTexture,NP.triplanarTextures,NP.trunc,NP.tslFn,NP.uint;const ik=NP.uniform;NP.uniformCubeTexture,NP.uniformArray,NP.uniformGroup,NP.uniformTexture,NP.uniforms,NP.unpremultiplyAlpha,NP.userData,NP.uv,NP.uvec2,NP.uvec3,NP.uvec4,NP.Var,NP.varying,NP.varyingProperty,NP.vec2,NP.vec3,NP.vec4,NP.vectorComponents,NP.velocity,NP.vertexColor,NP.vertexIndex,NP.vibrance,NP.viewZToLogarithmicDepth,NP.viewZToOrthographicDepth,NP.viewZToPerspectiveDepth,NP.viewport,NP.viewportBottomLeft,NP.viewportCoordinate,NP.viewportDepthTexture,NP.viewportLinearDepth,NP.viewportMipTexture,NP.viewportResolution,NP.viewportSafeUV,NP.viewportSharedTexture,NP.viewportSize,NP.viewportTexture,NP.viewportTopLeft,NP.viewportUV,NP.wgsl,NP.wgslFn,NP.workgroupArray,NP.workgroupBarrier,NP.workgroupId,NP.workingToColorSpace,NP.xor;const nk=new t.Box3,sk=new t.Vector3;class ak extends t.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new t.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new t.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const t=this.attributes.instanceStart,r=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),r.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let r;e instanceof Float32Array?r=e:Array.isArray(e)&&(r=new Float32Array(e));const i=new t.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceStart",new t.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceEnd",new t.InterleavedBufferAttribute(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let r;e instanceof Float32Array?r=e:Array.isArray(e)&&(r=new Float32Array(e));const i=new t.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceColorStart",new t.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceColorEnd",new t.InterleavedBufferAttribute(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new t.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new t.Box3);const e=this.attributes.instanceStart,r=this.attributes.instanceEnd;void 0!==e&&void 0!==r&&(this.boundingBox.setFromBufferAttribute(e),nk.setFromBufferAttribute(r),this.boundingBox.union(nk))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new t.Sphere),null===this.boundingBox&&this.computeBoundingBox();const e=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(void 0!==e&&void 0!==r){const t=this.boundingSphere.center;this.boundingBox.getCenter(t);let i=0;for(let n=0,s=e.count;n<s;n++)sk.fromBufferAttribute(e,n),i=Math.max(i,t.distanceToSquared(sk)),sk.fromBufferAttribute(r,n),i=Math.max(i,t.distanceToSquared(sk));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}t.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new t.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},t.ShaderLib.line={uniforms:t.UniformsUtils.merge([t.UniformsLib.common,t.UniformsLib.fog,t.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class ok extends t.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:t.UniformsUtils.clone(t.ShaderLib.line.uniforms),vertexShader:t.ShaderLib.line.vertexShader,fragmentShader:t.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const lk=new t.Vector4,Ak=new t.Vector3,uk=new t.Vector3,hk=new t.Vector4,ck=new t.Vector4,dk=new t.Vector4,pk=new t.Vector3,fk=new t.Matrix4,mk=new t.Line3,gk=new t.Vector3,yk=new t.Box3,bk=new t.Sphere,xk=new t.Vector4;let vk,_k;function wk(e,t,r){return xk.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),xk.multiplyScalar(1/xk.w),xk.x=_k/r.width,xk.y=_k/r.height,xk.applyMatrix4(e.projectionMatrixInverse),xk.multiplyScalar(1/xk.w),Math.abs(Math.max(xk.x,xk.y))}class Tk extends t.Mesh{constructor(e=new ak,t=new ok({color:16777215*Math.random()})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,r=e.attributes.instanceStart,i=e.attributes.instanceEnd,n=new Float32Array(2*r.count);for(let e=0,t=0,s=r.count;e<s;e++,t+=2)Ak.fromBufferAttribute(r,e),uk.fromBufferAttribute(i,e),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Ak.distanceTo(uk);const s=new t.InstancedInterleavedBuffer(n,2,1);return e.setAttribute("instanceDistanceStart",new t.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new t.InterleavedBufferAttribute(s,1,1)),this}raycast(e,r){const i=this.material.worldUnits,n=e.camera;null!==n||i||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=void 0!==e.params.Line2&&e.params.Line2.threshold||0;vk=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;let A,u;if(_k=l.linewidth+s,null===o.boundingSphere&&o.computeBoundingSphere(),bk.copy(o.boundingSphere).applyMatrix4(a),i)A=.5*_k;else{A=wk(n,Math.max(n.near,bk.distanceToPoint(vk.origin)),l.resolution)}if(bk.radius+=A,!1!==vk.intersectsSphere(bk)){if(null===o.boundingBox&&o.computeBoundingBox(),yk.copy(o.boundingBox).applyMatrix4(a),i)u=.5*_k;else{u=wk(n,Math.max(n.near,yk.distanceToPoint(vk.origin)),l.resolution)}yk.expandByScalar(u),!1!==vk.intersectsBox(yk)&&(i?function(e,r){const i=e.matrixWorld,n=e.geometry,s=n.attributes.instanceStart,a=n.attributes.instanceEnd;for(let o=0,l=Math.min(n.instanceCount,s.count);o<l;o++){mk.start.fromBufferAttribute(s,o),mk.end.fromBufferAttribute(a,o),mk.applyMatrix4(i);const n=new t.Vector3,l=new t.Vector3;vk.distanceSqToSegment(mk.start,mk.end,l,n),l.distanceTo(n)<.5*_k&&r.push({point:l,pointOnLine:n,distance:vk.origin.distanceTo(l),object:e,face:null,faceIndex:o,uv:null,uv1:null})}}(this,r):function(e,r,i){const n=r.projectionMatrix,s=e.material.resolution,a=e.matrixWorld,o=e.geometry,l=o.attributes.instanceStart,A=o.attributes.instanceEnd,u=Math.min(o.instanceCount,l.count),h=-r.near;vk.at(1,dk),dk.w=1,dk.applyMatrix4(r.matrixWorldInverse),dk.applyMatrix4(n),dk.multiplyScalar(1/dk.w),dk.x*=s.x/2,dk.y*=s.y/2,dk.z=0,pk.copy(dk),fk.multiplyMatrices(r.matrixWorldInverse,a);for(let r=0,o=u;r<o;r++){if(hk.fromBufferAttribute(l,r),ck.fromBufferAttribute(A,r),hk.w=1,ck.w=1,hk.applyMatrix4(fk),ck.applyMatrix4(fk),hk.z>h&&ck.z>h)continue;if(hk.z>h){const e=hk.z-ck.z,t=(hk.z-h)/e;hk.lerp(ck,t)}else if(ck.z>h){const e=ck.z-hk.z,t=(ck.z-h)/e;ck.lerp(hk,t)}hk.applyMatrix4(n),ck.applyMatrix4(n),hk.multiplyScalar(1/hk.w),ck.multiplyScalar(1/ck.w),hk.x*=s.x/2,hk.y*=s.y/2,ck.x*=s.x/2,ck.y*=s.y/2,mk.start.copy(hk),mk.start.z=0,mk.end.copy(ck),mk.end.z=0;const o=mk.closestPointToPointParameter(pk,!0);mk.at(o,gk);const u=t.MathUtils.lerp(hk.z,ck.z,o),c=u>=-1&&u<=1,d=pk.distanceTo(gk)<.5*_k;if(c&&d){mk.start.fromBufferAttribute(l,r),mk.end.fromBufferAttribute(A,r),mk.start.applyMatrix4(a),mk.end.applyMatrix4(a);const n=new t.Vector3,s=new t.Vector3;vk.distanceSqToSegment(mk.start,mk.end,s,n),i.push({point:s,pointOnLine:n,distance:vk.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}}(this,n,r))}}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(lk),this.material.uniforms.resolution.value.set(lk.z,lk.w))}}class Mk extends ak{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,r=new Float32Array(2*t);for(let i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return super.setPositions(r),this}setColors(e){const t=e.length-3,r=new Float32Array(2*t);for(let i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return super.setColors(r),this}setFromPoints(e){const t=e.length-1,r=new Float32Array(6*t);for(let i=0;i<t;i++)r[6*i]=e[i].x,r[6*i+1]=e[i].y,r[6*i+2]=e[i].z||0,r[6*i+3]=e[i+1].x,r[6*i+4]=e[i+1].y,r[6*i+5]=e[i+1].z||0;return super.setPositions(r),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class Sk extends Tk{constructor(e=new Mk,t=new ok({color:16777215*Math.random()})){super(e,t),this.isLine2=!0,this.type="Line2"}}class Ek extends t.ExtrudeGeometry{constructor(e,t={}){const r=t.font;if(void 0===r)super();else{const i=r.generateShapes(e,t.size);void 0===t.depth&&(t.depth=50),void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}function Nk(e,r,i,n,s){const a=s.glyphs[e]||s.glyphs["?"];if(!a)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+s.familyName+".");const o=new t.ShapePath;let l,A,u,h,c,d,p,f;if(a.o){const e=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let t=0,s=e.length;t<s;){switch(e[t++]){case"m":l=e[t++]*r+i,A=e[t++]*r+n,o.moveTo(l,A);break;case"l":l=e[t++]*r+i,A=e[t++]*r+n,o.lineTo(l,A);break;case"q":u=e[t++]*r+i,h=e[t++]*r+n,c=e[t++]*r+i,d=e[t++]*r+n,o.quadraticCurveTo(c,d,u,h);break;case"b":u=e[t++]*r+i,h=e[t++]*r+n,c=e[t++]*r+i,d=e[t++]*r+n,p=e[t++]*r+i,f=e[t++]*r+n,o.bezierCurveTo(c,d,p,f,u,h)}}}return{offsetX:a.ha*r,path:o}}class Ck extends t.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new t.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(e){e.element instanceof e.element.ownerDocument.defaultView.Element&&null!==e.element.parentNode&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}function Rk(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function Bk(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function Pk(e,t,r,i,n,s,a){try{var o=e[s](a),l=o.value}catch(e){return void r(e)}o.done?t(l):Promise.resolve(l).then(i,n)}function qk(e,t,r){return t=zk(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,jk()?Reflect.construct(t,r||[],zk(e).constructor):t.apply(e,r))}function Dk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ik(e,t){return e.get(Bk(e,t))}function Fk(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Ok(e,t,r){return e.set(Bk(e,t),r),r}function Lk(e,t,r){if(jk())return Reflect.construct.apply(null,arguments);var i=[null];return i.push.apply(i,t),new(e.bind.apply(e,i))}function kk(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Jk(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Vk(e,t,r){return(t=Jk(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Uk(){return Uk="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=zk(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},Uk.apply(null,arguments)}function zk(e){return zk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},zk(e)}function Gk(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Xk(e,t)}function jk(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(jk=function(){return!!e})()}function Hk(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function Wk(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Hk(Object(r),!0).forEach(function(t){Vk(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hk(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Qk(){var e,t,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",n=r.toStringTag||"@@toStringTag";function s(r,i,n,s){var l=i&&i.prototype instanceof o?i:o,A=Object.create(l.prototype);return $k(A,"_invoke",function(r,i,n){var s,o,l,A=0,u=n||[],h=!1,c={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return s=t,o=0,l=e,c.n=r,a}};function d(r,i){for(o=r,l=i,t=0;!h&&A&&!n&&t<u.length;t++){var n,s=u[t],d=c.p,p=s[2];r>3?(n=p===i)&&(l=s[(o=s[4])?5:(o=3,3)],s[4]=s[5]=e):s[0]<=d&&((n=r<2&&d<s[1])?(o=0,c.v=i,c.n=s[1]):d<p&&(n=r<3||s[0]>i||i>p)&&(s[4]=r,s[5]=i,c.n=p,o=0))}if(n||r>1)return a;throw h=!0,i}return function(n,u,p){if(A>1)throw TypeError("Generator is already running");for(h&&1===u&&d(u,p),o=u,l=p;(t=o<2?e:l)||!h;){s||(o?o<3?(o>1&&(c.n=-1),d(o,l)):c.n=l:c.v=l);try{if(A=2,s){if(o||(n="next"),t=s[n]){if(!(t=t.call(s,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,o<2&&(o=0)}else 1===o&&(t=s.return)&&t.call(s),o<2&&(l=TypeError("The iterator does not provide a '"+n+"' method"),o=1);s=e}else if((t=(h=c.n<0)?l:r.call(i,c))!==a)break}catch(t){s=e,o=1,l=t}finally{A=1}}return{value:t,done:h}}}(r,n,s),!0),A}var a={};function o(){}function l(){}function A(){}t=Object.getPrototypeOf;var u=[][i]?t(t([][i]())):($k(t={},i,function(){return this}),t),h=A.prototype=o.prototype=Object.create(u);function c(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,A):(e.__proto__=A,$k(e,n,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=A,$k(h,"constructor",A),$k(A,"constructor",l),l.displayName="GeneratorFunction",$k(A,n,"GeneratorFunction"),$k(h),$k(h,n,"Generator"),$k(h,i,function(){return this}),$k(h,"toString",function(){return"[object Generator]"}),(Qk=function(){return{w:s,m:c}})()}function $k(e,t,r,i){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}$k=function(e,t,r,i){function s(t,r){$k(e,t,function(e){return this._invoke(t,r,e)})}t?n?n(e,t,{value:r,enumerable:!i,configurable:!i,writable:!i}):e[t]=r:(s("next",0),s("throw",1),s("return",2))},$k(e,t,r,i)}function Xk(e,t){return Xk=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Xk(e,t)}function Yk(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||eV(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Kk(e,t,r,i){var n=Uk(zk(e.prototype),t,r);return"function"==typeof n?function(e){return n.apply(r,e)}:n}function Zk(e){return function(e){if(Array.isArray(e))return Rk(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eV(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jk(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function eV(e,t){if(e){if("string"==typeof e)return Rk(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rk(e,t):void 0}}new t.Vector3,new t.Matrix4,new t.Matrix4,new t.Vector3,new t.Vector3;var tV=function(e){e instanceof Array?e.forEach(tV):(e.map&&e.map.dispose(),e.dispose())},rV=function(e){e.geometry&&e.geometry.dispose(),e.material&&tV(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(rV)},iV=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),rV(t)}};function nV(e,t){var r=new t;return{linkProp:function(t){return{default:r[t](),onChange:function(r,i){i[e][t](r)},triggerUpdate:!1}},linkMethod:function(t){return function(r){for(var i=r[e],n=arguments.length,s=new Array(n>1?n-1:0),a=1;a<n;a++)s[a-1]=arguments[a];var o=i[t].apply(i,s);return o===i?this:o}}}}var sV=100;function aV(){return sV}function oV(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=(90-e)*Math.PI/180,n=(90-t)*Math.PI/180,s=sV*(1+r),a=Math.sin(i);return{x:s*a*Math.cos(n),y:s*Math.cos(i),z:s*a*Math.sin(n)}}function lV(e){var t=e.x,r=e.y,i=e.z,n=Math.sqrt(t*t+r*r+i*i),s=Math.acos(r/n),a=Math.atan2(i,t);return{lat:90-180*s/Math.PI,lng:90-180*a/Math.PI-(a<-Math.PI/2?360:0),altitude:n/sV-1}}function AV(e){return e*Math.PI/180}var uV=window.THREE?window.THREE:{BackSide:t.BackSide,BufferAttribute:t.BufferAttribute,Color:t.Color,Mesh:t.Mesh,ShaderMaterial:t.ShaderMaterial};var hV=function(e){function t(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.color,s=void 0===n?"gold":n,a=i.size,o=void 0===a?2:a,l=i.coefficient,A=void 0===l?.5:l,u=i.power,h=void 0===u?1:u,c=i.hollowRadius,d=void 0===c?0:c,p=i.backside,f=void 0===p||p;Dk(this,t),r=qk(this,t);var m=function(e,t){for(var r=e.clone(),i=new Float32Array(3*e.attributes.position.count),n=0,s=i.length;n<s;n++){var a=e.attributes.normal.array[n],o=e.attributes.position.array[n];i[n]=o+a*t}return r.setAttribute("position",new uV.BufferAttribute(i,3)),r}(e,o),g=function(e,t,r,i){return new uV.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:"\nuniform float hollowRadius;\n\nvarying vec3 vVertexWorldPosition;\nvarying vec3 vVertexNormal;\nvarying float vCameraDistanceToObjCenter;\nvarying float vVertexAngularDistanceToHollowRadius;\n\nvoid main() {    \n  vVertexNormal\t= normalize(normalMatrix * normal);\n  vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n  \n  vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\n  vCameraDistanceToObjCenter = length(objCenterViewPosition);\n  \n  float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter);\n  float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition)));\n  vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle;\n\n  gl_Position\t= projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",fragmentShader:"\nuniform vec3 color;\nuniform float coefficient;\nuniform float power;\nuniform float hollowRadius;\n\nvarying vec3 vVertexNormal;\nvarying vec3 vVertexWorldPosition;\nvarying float vCameraDistanceToObjCenter;\nvarying float vVertexAngularDistanceToHollowRadius;\n\nvoid main() {\n  if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius\n  if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius\n\n  vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition;\n  vec3 viewCameraToVertex\t= (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz;\n  viewCameraToVertex = normalize(viewCameraToVertex);\n  float intensity\t= pow(\n    coefficient + dot(vVertexNormal, viewCameraToVertex),\n    power\n  );\n  gl_FragColor = vec4(color, intensity);\n}",uniforms:{coefficient:{value:e},color:{value:new uV.Color(t)},power:{value:r},hollowRadius:{value:i}}})}(A,s,h,d);return f&&(g.side=uV.BackSide),r.geometry=m,r.material=g,r}return Gk(t,e),kk(t)}(uV.Mesh),cV=window.THREE?window.THREE:{Color:t.Color,Group:t.Group,LineBasicMaterial:t.LineBasicMaterial,LineSegments:t.LineSegments,Mesh:t.Mesh,MeshPhongMaterial:t.MeshPhongMaterial,SphereGeometry:t.SphereGeometry,SRGBColorSpace:t.SRGBColorSpace,TextureLoader:t.TextureLoader},dV=O({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return void 0!==t?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},_destructor:function(e){iV(e.globeObj),iV(e.tileEngine),iV(e.graticulesObj)}},stateInit:function(){var e=new cV.MeshPhongMaterial({color:0}),t=new cV.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var r=new vs(sV),i=new cV.Group;return i.__globeObjType="globe",i.add(t),i.add(r),{globeGroup:i,globeObj:t,graticulesObj:new cV.LineSegments(new la(xn(),sV,2),new cV.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1})),defaultGlobeMaterial:e,tileEngine:r}},init:function(e,t){iV(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var r=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var i;null===(i=e.globeObj.geometry)||void 0===i||i.dispose();var n=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new cV.SphereGeometry(sV,n,n/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?(new cV.TextureLoader).load(e.globeImageUrl,function(t){t.colorSpace=cV.SRGBColorSpace,r.map=t,r.color=null,r.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!r.color&&(r.color=new cV.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&(new cV.TextureLoader).load(e.bumpImageUrl,function(e){r.bumpMap=e,r.needsUpdate=!0}):(r.bumpMap=null,r.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),iV(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var s=e.atmosphereObj=new hV(e.globeObj.geometry,{color:e.atmosphereColor,size:sV*e.atmosphereAltitude,hollowRadius:sV,coefficient:.1,power:3.5});s.visible=!!e.showAtmosphere,s.__globeObjType="atmosphere",e.scene.add(s)}e.ready||e.globeImageUrl&&!e.globeTileEngineUrl||(e.ready=!0,e.onReady())}}),pV=function(e){return isNaN(e)?parseInt(ba(e).toHex(),16):e},fV=function(e){return e&&isNaN(e)?Ie(e).opacity:1},mV=function(e){var r,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var o=Yk(a.slice(1),4),l=o[0],A=o[1],u=o[2],h=o[3];r=new t.Color("rgb(".concat(+l,",").concat(+A,",").concat(+u,")")),s=Math.min(+h,1)}else r=new t.Color(e);n&&r.convertLinearToSRGB();var c=r.toArray();return i?[].concat(Zk(c),[s]):c};var gV=window.THREE?window.THREE:{BufferAttribute:t.BufferAttribute};function yV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float32Array;if(1===t)return new gV.BufferAttribute(new r(e),t);for(var i=new gV.BufferAttribute(new r(e.length*t),t),n=0,s=e.length;n<s;n++)i.set(e[n],n*t);return i}var bV=new WeakMap,xV=new WeakMap,vV=new WeakMap,_V=function(e){function t(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.dataBindAttr,s=void 0===n?"__data":n,a=i.objBindAttr,o=void 0===a?"__threeObj":a,l=i.removeDelay,A=void 0===l?0:l;return Dk(this,t),Vk(r=qk(this,t),"scene",void 0),Fk(r,bV,void 0),Fk(r,xV,void 0),Fk(r,vV,void 0),r.scene=e,Ok(bV,r,s),Ok(xV,r,o),Ok(vV,r,A),r.onRemoveObj(function(){}),r}return Gk(t,e),kk(t,[{key:"onCreateObj",value:function(e){var r=this;return Kk(t,"onCreateObj",this)([function(t){var i=e(t);return t[Ik(xV,r)]=i,i[Ik(bV,r)]=t,r.scene.add(i),i}]),this}},{key:"onRemoveObj",value:function(e){var r=this;return Kk(t,"onRemoveObj",this)([function(i,n){var s=Kk(t,"getData",r)([i]);e(i,n);var a=function(){r.scene.remove(i),iV(i),delete s[Ik(xV,r)]};Ik(vV,r)?setTimeout(a,Ik(vV,r)):a()}]),this}}])}(po),wV=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,CylinderGeometry:t.CylinderGeometry,Matrix4:t.Matrix4,Mesh:t.Mesh,MeshLambertMaterial:t.MeshLambertMaterial,Object3D:t.Object3D,Vector3:t.Vector3},TV=Object.assign({},pa),MV=TV.BufferGeometryUtils||TV,SV=O({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var r=fa(e.pointLat),i=fa(e.pointLng),n=fa(e.pointAltitude),s=fa(e.pointRadius),a=fa(e.pointColor),o=new wV.CylinderGeometry(1,1,1,e.pointResolution);o.applyMatrix4((new wV.Matrix4).makeRotationX(Math.PI/2)),o.applyMatrix4((new wV.Matrix4).makeTranslation(0,0,-.5));var l=2*Math.PI*sV/360,A={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&iV(e.scene),e.dataMapper.scene=e.pointsMerge?new wV.Object3D:e.scene,e.dataMapper.onCreateObj(function(){var e=new wV.Mesh(o);return e.__globeObjType="point",e}).onUpdateObj(function(t,o){var u=function(r){var i=t.__currentTargetD=r,n=i.r,s=i.alt,a=i.lat,o=i.lng;Object.assign(t.position,oV(a,o));var A=e.pointsMerge?new wV.Vector3(0,0,0):e.scene.localToWorld(new wV.Vector3(0,0,0));t.lookAt(A),t.scale.x=t.scale.y=Math.min(30,n)*l,t.scale.z=Math.max(s*sV,.1)},h={alt:+n(o),r:+s(o),lat:+r(o),lng:+i(o)},c=t.__currentTargetD||Object.assign({},h,{alt:-.001});Object.keys(h).some(function(e){return c[e]!==h[e]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?u(h):e.tweenGroup.add(new j(c).to(h,e.pointsTransitionDuration).easing(L.Quadratic.InOut).onUpdate(u).start()));if(!e.pointsMerge){var d=a(o),p=d?fV(d):0,f=!!p;t.visible=f,f&&(A.hasOwnProperty(d)||(A[d]=new wV.MeshLambertMaterial({color:pV(d),transparent:p<1,opacity:p})),t.material=A[d])}}).digest(e.pointsData),e.pointsMerge){var u=e.pointsData.length?(MV.mergeGeometries||MV.mergeBufferGeometries)(e.pointsData.map(function(t){var r=e.dataMapper.getObj(t),i=r.geometry.clone();r.updateMatrix(),i.applyMatrix4(r.matrix);var n=mV(a(t));return i.setAttribute("color",yV(Array(i.getAttribute("position").count).fill(n),4)),i})):new wV.BufferGeometry,h=new wV.Mesh(u,new wV.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));h.__globeObjType="points",h.__data=e.pointsData,e.dataMapper.clear(),iV(e.scene),e.scene.add(h)}}}),EV=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:"\n    ".concat(t.ShaderChunk.common,"\n    ").concat(t.ShaderChunk.logdepthbuf_pars_vertex,"\n  \n    uniform float dashTranslate; \n\n    attribute vec4 color;\n    varying vec4 vColor;\n    \n    attribute float relDistance;\n    varying float vRelDistance;\n\n    void main() {\n      // pass through colors and distances\n      vColor = color;\n      vRelDistance = relDistance + dashTranslate;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n  \n      ").concat(t.ShaderChunk.logdepthbuf_vertex,"\n    }\n  "),fragmentShader:"\n    ".concat(t.ShaderChunk.logdepthbuf_pars_fragment,"\n\n    uniform float dashOffset; \n    uniform float dashSize;\n    uniform float gapSize; \n    \n    varying vec4 vColor;\n    varying float vRelDistance;\n    \n    void main() {\n      // ignore pixels in the gap\n      if (vRelDistance < dashOffset) discard;\n      if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;\n    \n      // set px color: [r, g, b, a], interpolated between vertices \n      gl_FragColor = vColor; \n  \n      ").concat(t.ShaderChunk.logdepthbuf_fragment,"\n    }\n  ")}},NV=function(e){return e.uniforms.surfaceRadius={type:"float",value:0},e.vertexShader=("attribute float surfaceRadius;\nvarying float vSurfaceRadius;\nvarying vec3 vPos;\n"+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join("\n")),e.fragmentShader=("uniform float surfaceRadius;\nvarying float vSurfaceRadius;\nvarying vec3 vPos;\n"+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(surfaceRadius, vSurfaceRadius)) discard;"].join("\n")),e},CV=function(e){return e.vertexShader="\n    attribute float r;\n    \n    const float PI = 3.1415926535897932384626433832795;\n    float toRad(in float a) {\n      return a * PI / 180.0;\n    }\n    \n    vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r]\n      float phi = toRad(90.0 - c.x);\n      float theta = toRad(90.0 - c.y);\n      float r = c.z;\n      return vec3( // x,y,z\n        r * sin(phi) * cos(theta),\n        r * cos(phi),\n        r * sin(phi) * sin(theta)\n      );\n    }\n    \n    vec2 Cartesian2Polar(in vec3 p) {\n      float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z);\n      float phi = acos(p.y / r);\n      float theta = atan(p.z, p.x);\n      return vec2( // lat,lng\n        90.0 - phi * 180.0 / PI,\n        90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0)\n      );\n    }\n    ".concat(e.vertexShader.replace("}","                  \n        vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r));\n        gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n      }\n    "),"\n  "),e},RV=function(e,t){return e.onBeforeCompile=function(r){e.userData.shader=t(r)},e},BV=["stroke"],PV=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,CubicBezierCurve3:t.CubicBezierCurve3,Curve:t.Curve,Group:t.Group,Line:t.Line,Mesh:t.Mesh,NormalBlending:t.NormalBlending,ShaderMaterial:t.ShaderMaterial,TubeGeometry:t.TubeGeometry,Vector3:t.Vector3},qV=bo.default||bo,DV=O({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.pause()},resumeAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),null===(t=e.ticker)||void 0===t||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new qV,sharedMaterial:new PV.ShaderMaterial(Wk(Wk({},EV()),{},{transparent:!0,blending:PV.NormalBlending}))}},init:function(e,t){iV(e),t.scene=e,t.dataMapper=new _V(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var e=new PV.Group;return e.__globeObjType="arc",e}),t.ticker.onTick.add(function(e,r){t.dataMapper.entries().map(function(e){return Yk(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],i=t.__dashAnimateStep*r,n=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=n+i})})},update:function(e){var t=fa(e.arcStartLat),r=fa(e.arcStartLng),i=fa(e.arcStartAltitude),n=fa(e.arcEndLat),s=fa(e.arcEndLng),a=fa(e.arcEndAltitude),o=fa(e.arcAltitude),l=fa(e.arcAltitudeAutoScale),A=fa(e.arcStroke),u=fa(e.arcColor),h=fa(e.arcDashLength),c=fa(e.arcDashGap),d=fa(e.arcDashInitialGap),p=fa(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(f,m){var g=A(m),y=null!=g;if(!f.children.length||y!==("Mesh"===f.children[0].type)){iV(f);var b=y?new PV.Mesh:new PV.Line(new PV.BufferGeometry);b.material=e.sharedMaterial.clone(),f.add(b)}var x=f.children[0];Object.assign(x.material.uniforms,{dashSize:{value:h(m)},gapSize:{value:c(m)},dashOffset:{value:d(m)}});var v=p(m);x.__dashAnimateStep=v>0?1e3/v:0;var _=function(e,t){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=t+1;if(e instanceof Array||e instanceof Function){var s=e instanceof Array?Ot().domain(e.map(function(t,r){return r/(e.length-1)})).range(e):e;r=function(e){return mV(s(e),!0,!0)}}else{var a=mV(e,!0,!0);r=function(){return a}}for(var o=[],l=0,A=n;l<A;l++)for(var u=r(l/(A-1)),h=0;h<i;h++)o.push(u);return yV(o,4)}(u(m),e.arcCurveResolution,y?e.arcCircularResolution+1:1),w=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[],n=0,s=e+1;n<s;n++)for(var a=n/(s-1),o=0;o<t;o++)i.push(a);return r&&i.reverse(),yV(i,1)}(e.arcCurveResolution,y?e.arcCircularResolution+1:1,!0);x.geometry.setAttribute("color",_),x.geometry.setAttribute("relDistance",w);var T=function(t){var r=f.__currentTargetD=t,i=r.stroke,n=function(e){var t=e.alt,r=e.altAutoScale,i=e.startLat,n=e.startLng,s=e.startAlt,a=e.endLat,o=e.endLng,l=e.endAlt,A=function(e){var t=Yk(e,3),r=t[0],i=oV(t[1],r,t[2]),n=i.x,s=i.y,a=i.z;return new PV.Vector3(n,s,a)},u=[n,i],h=[o,a],c=t;if(null==c&&(c=An(u,h)/2*r+Math.max(s,l)),c||s||l){var d=vn(u,h),p=function(e,t){return t+(t-e)*(e<t?.5:.25)},f=Yk([.25,.75].map(function(e){return[].concat(Zk(d(e)),[p(e<.5?s:l,c)])}),2),m=f[0],g=f[1];return Lk(PV.CubicBezierCurve3,Zk([[].concat(u,[s]),m,g,[].concat(h,[l])].map(A)))}var y=.001;return b.apply(void 0,Zk([[].concat(u,[y]),[].concat(h,[y])].map(A)));function b(e,t){var r=e.angleTo(t),i=0===r?function(){return e.clone()}:function(i){return(new PV.Vector3).addVectors(e.clone().multiplyScalar(Math.sin((1-i)*r)),t.clone().multiplyScalar(Math.sin(i*r))).divideScalar(Math.sin(r))},n=new PV.Curve;return n.getPoint=i,n}}(function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;r[i]=e[i]}return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(r,BV));y?(x.geometry&&x.geometry.dispose(),x.geometry=new PV.TubeGeometry(n,e.arcCurveResolution,i/2,e.arcCircularResolution),x.geometry.setAttribute("color",_),x.geometry.setAttribute("relDistance",w)):x.geometry.setFromPoints(n.getPoints(e.arcCurveResolution))},M={stroke:g,alt:o(m),altAutoScale:+l(m),startLat:+t(m),startLng:+r(m),startAlt:+i(m),endLat:+n(m),endLng:+s(m),endAlt:+a(m)},S=f.__currentTargetD||Object.assign({},M,{altAutoScale:-.001});Object.keys(M).some(function(e){return S[e]!==M[e]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?T(M):e.tweenGroup.add(new j(S).to(M,e.arcsTransitionDuration).easing(L.Quadratic.InOut).onUpdate(T).start()))}).digest(e.arcsData)}}),IV=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,DoubleSide:t.DoubleSide,Mesh:t.Mesh,MeshLambertMaterial:t.MeshLambertMaterial,Object3D:t.Object3D},FV=Object.assign({},pa),OV=FV.BufferGeometryUtils||FV,LV=O({props:{hexBinPointsData:{default:[]},hexBinPointLat:{default:"lat"},hexBinPointLng:{default:"lng"},hexBinPointWeight:{default:1},hexBinResolution:{default:4},hexMargin:{default:.2},hexTopCurvatureResolution:{default:5},hexTopColor:{default:function(){return"#ffffaa"}},hexSideColor:{default:function(){return"#ffffaa"}},hexAltitude:{default:function(e){return.01*e.sumWeight}},hexBinMerge:{default:!1},hexTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjHexbin"})},update:function(e,t){var r=fa(e.hexBinPointLat),i=fa(e.hexBinPointLng),n=fa(e.hexBinPointWeight),s=fa(e.hexAltitude),a=fa(e.hexTopColor),o=fa(e.hexSideColor),l=fa(e.hexMargin),A=Il(e.hexBinPointsData.map(function(t){return Wk(Wk({},t),{},{h3Idx:aA(r(t),i(t),e.hexBinResolution)})}),"h3Idx"),u=Object.entries(A).map(function(e){var t=Yk(e,2),r=t[0],i=t[1];return{h3Idx:r,points:i,sumWeight:i.reduce(function(e,t){return e+ +n(t)},0)}}),h={};if(!e.hexBinMerge&&t.hasOwnProperty("hexBinMerge")&&iV(e.scene),e.dataMapper.scene=e.hexBinMerge?new IV.Object3D:e.scene,e.dataMapper.id(function(e){return e.h3Idx}).onCreateObj(function(e){var t=new IV.Mesh;t.__hexCenter=oA(e.h3Idx),t.__hexGeoJson=lA(e.h3Idx).reverse();var r=t.__hexCenter[1];return t.__hexGeoJson.forEach(function(e){var t=e[0];Math.abs(r-t)>170&&(e[0]+=r>t?360:-360)}),t.__globeObjType="hexbin",t}).onUpdateObj(function(t,r){var i=Math.max(0,Math.min(1,+l(r))),n=Yk(t.__hexCenter,2),A=n[0],u=n[1],c=0===i?t.__hexGeoJson:t.__hexGeoJson.map(function(e){var t=Yk(e,2),r=t[0],n=t[1];return[[r,u],[n,A]].map(function(e){var t=Yk(e,2);return function(e,t,r){return e-(e-t)*r}(t[0],t[1],i)})}),d=e.hexTopCurvatureResolution;t.geometry&&t.geometry.dispose(),t.geometry=new Cl([c],0,sV,!1,!0,!0,d);var p={alt:+s(r)},f=function(e){var r=(t.__currentTargetD=e).alt;t.scale.x=t.scale.y=t.scale.z=1+r;var i=sV/(r+1);t.geometry.setAttribute("surfaceRadius",yV(Array(t.geometry.getAttribute("position").count).fill(i),1))},m=t.__currentTargetD||Object.assign({},p,{alt:-.001});Object.keys(p).some(function(e){return m[e]!==p[e]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?f(p):e.tweenGroup.add(new j(m).to(p,e.hexTransitionDuration).easing(L.Quadratic.InOut).onUpdate(f).start()));if(!e.hexBinMerge){var g=o(r),y=a(r);[g,y].forEach(function(e){if(!h.hasOwnProperty(e)){var t=fV(e);h[e]=RV(new IV.MeshLambertMaterial({color:pV(e),transparent:t<1,opacity:t,side:IV.DoubleSide}),NV)}}),t.material=[g,y].map(function(e){return h[e]})}}).digest(u),e.hexBinMerge){var c=u.length?(OV.mergeGeometries||OV.mergeBufferGeometries)(u.map(function(t){var r=e.dataMapper.getObj(t),i=r.geometry.toNonIndexed();r.updateMatrix(),i.applyMatrix4(r.matrix);var n=mV(a(t)),s=mV(o(t)),l=i.getAttribute("position").count,A=i.groups[0].count;return i.setAttribute("color",yV(Zk(new Array(l)).map(function(e,t){return t>=A?n:s}),4)),i})):new IV.BufferGeometry,d=new IV.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:IV.DoubleSide});d.onBeforeCompile=function(e){d.userData.shader=NV(e)};var p=new IV.Mesh(c,d);p.__globeObjType="hexBinPoints",p.__data=u,e.dataMapper.clear(),iV(e.scene),e.scene.add(p)}}}),kV=function(e){return e*e},VV=function(e){return e*Math.PI/180};var UV=Math.sqrt(2*Math.PI);var zV=function(e){var t=Yk(e,2),r=t[0],i=t[1],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=s.lngAccessor,o=void 0===a?function(e){return e[0]}:a,l=s.latAccessor,A=void 0===l?function(e){return e[1]}:l,u=s.weightAccessor,h=void 0===u?function(){return 1}:u,c=s.bandwidth,d=[r,i],p=c*Math.PI/180;return function(e){let t=0;for(let r of e)(r=+r)&&(t+=r);return t}(n.map(function(e){var t=h(e);if(!t)return 0;var r,i,n=function(e,t){var r=Math.sqrt,i=Math.cos,n=function(e){return kV(Math.sin(e/2))},s=VV(e[1]),a=VV(t[1]),o=VV(e[0]),l=VV(t[0]);return 2*Math.asin(r(n(a-s)+i(s)*i(a)*n(l-o)))}(d,[o(e),A(e)]);return r=n,i=p,Math.exp(-kV(r/i)/2)/(i*UV)*t}))},GV=function(){var e,t=(e=Qk().m(function e(t){var r,i,n,s,a,o,l,A,u,h,c,d,p,f,m,g,y,b,x,v,_,w,T,M,S,E,N,C,R,B,P,q,D,I,F,O,L,k,V,U,z,G,j,H=arguments;return Qk().w(function(e){for(;;)switch(e.n){case 0:if(i=H.length>1&&void 0!==H[1]?H[1]:[],s=(n=H.length>2&&void 0!==H[2]?H[2]:{}).lngAccessor,a=void 0===s?function(e){return e[0]}:s,o=n.latAccessor,l=void 0===o?function(e){return e[1]}:o,A=n.weightAccessor,u=void 0===A?function(){return 1}:A,h=n.bandwidth,null!==(r=navigator)&&void 0!==r&&r.gpu){e.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),e.a(2,t.map(function(e){return zV(e,i,{lngAccessor:a,latAccessor:l,weightAccessor:u,bandwidth:h})}));case 1:return c=HL,d=WL,p=ik,m=KL,g=ZL,y=QL,b=tk,x=ek,v=XL,_=$L,w=YL,T=JL,M=(f=rk)(new hC(new Float32Array(t.flat().map(VV)),2),"vec2",t.length),S=f(new hC(new Float32Array(i.map(function(e){return[VV(a(e)),VV(l(e)),u(e)]}).flat()),3),"vec3",i.length),E=new hC(t.length,1),N=f(E,"float",t.length),C=m(Math.PI),R=b(C.mul(2)),B=function(e){return e.mul(e)},P=function(e){return B(x(e.div(2)))},q=function(e,t){var r=m(e[1]),i=m(t[1]),n=m(e[0]),s=m(t[0]);return m(2).mul(_(b(P(i.sub(r)).add(v(r).mul(v(i)).mul(P(s.sub(n)))))))},D=function(e,t){return w(T(B(e.div(t)).div(2))).div(t.mul(R))},I=p(VV(h)),F=p(VV(4*h)),O=p(i.length),L=c(function(){var e=M.element(g),t=N.element(g);t.assign(0),y(O,function(r){var i=r.i,n=S.element(i),s=n.z;d(s,function(){var r=q(n.xy,e.xy);d(r&&r.lessThan(F),function(){t.addAssign(D(r,I).mul(s))})})})}),k=L().compute(t.length),V=new jL,e.n=2,V.computeAsync(k);case 2:return U=Array,z=Float32Array,e.n=3,V.getArrayBufferAsync(E);case 3:return G=e.v,j=new z(G),e.a(2,U.from.call(U,j))}},e)}),function(){var t=this,r=arguments;return new Promise(function(i,n){var s=e.apply(t,r);function a(e){Pk(s,i,n,a,o,"next",e)}function o(e){Pk(s,i,n,a,o,"throw",e)}a(void 0)})});return function(e){return t.apply(this,arguments)}}(),jV=window.THREE?window.THREE:{Mesh:t.Mesh,MeshLambertMaterial:t.MeshLambertMaterial,SphereGeometry:t.SphereGeometry},HV=function(e){var t=Ie(function(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+e*(1172.33-e*(10793.56-e*(33300.12-e*(38394.49-14825.05*e)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+e*(557.33+e*(1225.33-e*(3574.96-e*(1073.77+707.56*e)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+e*(3211.1-e*(15327.97-e*(27814-e*(22569.18-6838.66*e)))))))+")"}(e));return t.opacity=Math.cbrt(e),t.formatRgb()},WV=O({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return HV}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var e=new jV.Mesh(new jV.SphereGeometry(sV),RV(new jV.MeshLambertMaterial({vertexColors:!0,transparent:!0}),CV));return e.__globeObjType="heatmap",e})},update:function(e){var t=fa(e.heatmapPoints),r=fa(e.heatmapPointLat),i=fa(e.heatmapPointLng),n=fa(e.heatmapPointWeight),s=fa(e.heatmapBandwidth),a=fa(e.heatmapColorFn),o=fa(e.heatmapColorSaturation),l=fa(e.heatmapBaseAltitude),A=fa(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(u,h){var c=s(h),d=a(h),p=o(h),f=l(h),m=A(h),g=t(h).map(function(e){var t=r(e),s=i(e),a=oV(t,s);return{x:a.x,y:a.y,z:a.z,lat:t,lng:s,weight:n(e)}}),y=Math.max(.1,c/3.5),b=Math.ceil(360/(y||-1));u.geometry.parameters.widthSegments!==b&&(u.geometry.dispose(),u.geometry=new jV.SphereGeometry(sV,b,b/2));var x=function(e){for(var t=e.itemSize,r=[],i=0;i<e.count;i++)r.push(e.array.slice(i*t,(i+1)*t));return r}(u.geometry.getAttribute("position")).map(function(e){var t=Yk(e,3),r=lV({x:t[0],y:t[1],z:t[2]});return[r.lng,r.lat]});GV(x,g,{latAccessor:function(e){return e.lat},lngAccessor:function(e){return e.lng},weightAccessor:function(e){return e.weight},bandwidth:c}).then(function(t){var r=Zk(new Array(100)).map(function(e,t){return mV(d(t/99))}),i=function(e){var t=u.__currentTargetD=e,i=t.kdeVals,n=t.topAlt,s=t.saturation,a=function(e){let t;for(const r of e)null!=r&&(t<r||void 0===t&&r>=r)&&(t=r);return t}(i.map(Math.abs))||1e-15,o=Lt([0,a/s],r);u.geometry.setAttribute("color",yV(i.map(function(e){return o(Math.abs(e))}),4));var l=Ot([0,a],[sV*(1+f),sV*(1+(n||f))]);u.geometry.setAttribute("r",yV(i.map(l)))},n={kdeVals:t,topAlt:m,saturation:p},s=u.__currentTargetD||Object.assign({},n,{kdeVals:t.map(function(){return 0}),topAlt:m?f:m,saturation:.5});s.kdeVals.length!==t.length&&(s.kdeVals=t.slice()),Object.keys(n).some(function(e){return s[e]!==n[e]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?i(n):e.tweenGroup.add(new j(s).to(n,e.heatmapsTransitionDuration).easing(L.Quadratic.InOut).onUpdate(i).start()))})}).digest(e.heatmapsData)}}),QV=window.THREE?window.THREE:{DoubleSide:t.DoubleSide,Group:t.Group,LineBasicMaterial:t.LineBasicMaterial,LineSegments:t.LineSegments,Mesh:t.Mesh,MeshBasicMaterial:t.MeshBasicMaterial},$V=O({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjPolygon"}).id(function(e){return e.id}).onCreateObj(function(){var e=new QV.Group;return e.__defaultSideMaterial=RV(new QV.MeshBasicMaterial({side:QV.DoubleSide,depthWrite:!0}),NV),e.__defaultCapMaterial=new QV.MeshBasicMaterial({side:QV.DoubleSide,depthWrite:!0}),e.add(new QV.Mesh(void 0,[e.__defaultSideMaterial,e.__defaultCapMaterial])),e.add(new QV.LineSegments(void 0,new QV.LineBasicMaterial)),e.__globeObjType="polygon",e})},update:function(e){var t=fa(e.polygonGeoJsonGeometry),r=fa(e.polygonAltitude),i=fa(e.polygonCapCurvatureResolution),n=fa(e.polygonCapColor),s=fa(e.polygonCapMaterial),a=fa(e.polygonSideColor),o=fa(e.polygonSideMaterial),l=fa(e.polygonStrokeColor),A=[];e.polygonsData.forEach(function(e){var u={data:e,capColor:n(e),capMaterial:s(e),sideColor:a(e),sideMaterial:o(e),strokeColor:l(e),altitude:+r(e),capCurvatureResolution:+i(e)},h=t(e),c=e.__id||"".concat(Math.round(1e9*Math.random()));e.__id=c,"Polygon"===h.type?A.push(Wk({id:"".concat(c,"_0"),coords:h.coordinates},u)):"MultiPolygon"===h.type?A.push.apply(A,Zk(h.coordinates.map(function(e,t){return Wk({id:"".concat(c,"_").concat(t),coords:e},u)}))):console.warn("Unsupported GeoJson geometry type: ".concat(h.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(t,r){var i=r.coords,n=r.capColor,s=r.capMaterial,a=r.sideColor,o=r.sideMaterial,l=r.strokeColor,A=r.altitude,u=r.capCurvatureResolution,h=Yk(t.children,2),c=h[0],d=h[1],p=!!l;d.visible=p;var f=!(!n&&!s),m=!(!a&&!o);(function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return function(e,t){return e===t}};return Object.entries(t).every(function(t){var i=Yk(t,2),n=i[0],s=i[1];return e.hasOwnProperty(n)&&r(n)(e[n],s)})})(c.geometry.parameters||{},{polygonGeoJson:i,curvatureResolution:u,closedTop:f,includeSides:m})||(c.geometry&&c.geometry.dispose(),c.geometry=new Cl(i,0,sV,!1,f,m,u)),!p||d.geometry.parameters&&d.geometry.parameters.geoJson.coordinates===i&&d.geometry.parameters.resolution===u||(d.geometry&&d.geometry.dispose(),d.geometry=new la({type:"Polygon",coordinates:i},sV,u));var g=m?0:-1,y=f?m?1:0:-1;if(g>=0&&(c.material[g]=o||t.__defaultSideMaterial),y>=0&&(c.material[y]=s||t.__defaultCapMaterial),[[!o&&a,g],[!s&&n,y]].forEach(function(e){var t=Yk(e,2),r=t[0],i=t[1];if(r&&!(i<0)){var n=c.material[i],s=fV(r);n.color.set(pV(r)),n.transparent=s<1,n.opacity=s}}),p){var b=d.material,x=fV(l);b.color.set(pV(l)),b.transparent=x<1,b.opacity=x}var v={alt:A},_=function(e){var r=(t.__currentTargetD=e).alt;c.scale.x=c.scale.y=c.scale.z=1+r,p&&(d.scale.x=d.scale.y=d.scale.z=1+r+1e-4),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){return e};if(e.userData.shader)t(e.userData.shader.uniforms);else{var r=e.onBeforeCompile;e.onBeforeCompile=function(e){r(e),t(e.uniforms)}}}(t.__defaultSideMaterial,function(e){return e.surfaceRadius.value=sV/(r+1)})},w=t.__currentTargetD||Object.assign({},v,{alt:-.001});Object.keys(v).some(function(e){return w[e]!==v[e]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||w.alt===v.alt?_(v):e.tweenGroup.add(new j(w).to(v,e.polygonsTransitionDuration).easing(L.Quadratic.InOut).onUpdate(_).start()))}).digest(A)}});var XV=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,DoubleSide:t.DoubleSide,Mesh:t.Mesh,MeshLambertMaterial:t.MeshLambertMaterial,Vector3:t.Vector3},YV=Object.assign({},pa),KV=YV.BufferGeometryUtils||YV,ZV=O({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var e=new XV.Mesh(void 0,new XV.MeshLambertMaterial({side:XV.DoubleSide}));return e.__globeObjType="hexPolygon",e})},update:function(e){var r=fa(e.hexPolygonGeoJsonGeometry),i=fa(e.hexPolygonColor),n=fa(e.hexPolygonAltitude),s=fa(e.hexPolygonResolution),a=fa(e.hexPolygonMargin),o=fa(e.hexPolygonUseDots),l=fa(e.hexPolygonCurvatureResolution),A=fa(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(u,h){var c=r(h),d=s(h),p=n(h),f=Math.max(0,Math.min(1,+a(h))),m=o(h),g=l(h),y=A(h),b=i(h),x=fV(b);u.material.color.set(pV(b)),u.material.transparent=x<1,u.material.opacity=x;var v={alt:p,margin:f,curvatureResolution:g},_={geoJson:c,h3Res:d},w=u.__currentTargetD||Object.assign({},v,{alt:-.001}),T=u.__currentMemD||_;if(Object.keys(v).some(function(e){return w[e]!==v[e]})||Object.keys(_).some(function(e){return T[e]!==_[e]})){u.__currentMemD=_;var M=[];"Polygon"===c.type?AA(c.coordinates,d,!0).forEach(function(e){return M.push(e)}):"MultiPolygon"===c.type?c.coordinates.forEach(function(e){return AA(e,d,!0).forEach(function(e){return M.push(e)})}):console.warn("Unsupported GeoJson geometry type: ".concat(c.type,". Skipping geometry..."));var S=M.map(function(e){var t=oA(e),r=lA(e).reverse(),i=t[1];return r.forEach(function(e){var t=e[0];Math.abs(i-t)>170&&(e[0]+=i>t?360:-360)}),{h3Idx:e,hexCenter:t,hexGeoJson:r}}),E=function(e){var r=u.__currentTargetD=e,i=r.alt,n=r.margin,s=r.curvatureResolution;u.geometry&&u.geometry.dispose(),u.geometry=S.length?(KV.mergeGeometries||KV.mergeBufferGeometries)(S.map(function(e){var r=Yk(e.hexCenter,2),a=r[0],o=r[1];if(m){var l=oV(a,o,i),A=oV(e.hexGeoJson[0][1],e.hexGeoJson[0][0],i),u=.85*(1-n)*new XV.Vector3(l.x,l.y,l.z).distanceTo(new XV.Vector3(A.x,A.y,A.z)),h=new t.CircleGeometry(u,y);return h.rotateX(AV(-a)),h.rotateY(AV(o)),h.translate(l.x,l.y,l.z),h}var c=0===n?e.hexGeoJson:e.hexGeoJson.map(function(e){var t=Yk(e,2),r=t[0],i=t[1];return[[r,o],[i,a]].map(function(e){var t=Yk(e,2);return function(e,t,r){return e-(e-t)*r}(t[0],t[1],n)})});return new Cl([c],sV,sV*(1+i),!1,!0,!1,s)})):new XV.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?E(v):e.tweenGroup.add(new j(w).to(v,e.hexPolygonsTransitionDuration).easing(L.Quadratic.InOut).onUpdate(E).start())}}).digest(e.hexPolygonsData)}}),JV=window.THREE?window.THREE:{Vector3:t.Vector3};function eU(e,t){var r=Math.max(e.length,t.length),i=it.apply(void 0,Zk([e,t].map(function(e){return e.map(function(e){return[e.x,e.y,e.z]})}).map(function(e){return function(e,t){var r=e[e.length-1];return[].concat(Zk(e),Zk(Array(t-e.length).fill(r)))}(e,r)})));return function(r){return 0===r?e:1===r?t:i(r).map(function(e){var t=Yk(e,3),r=t[0],i=t[1],n=t[2];return new JV.Vector3(r,i,n)})}}var tU=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,Color:t.Color,Group:t.Group,Line:t.Line,NormalBlending:t.NormalBlending,ShaderMaterial:t.ShaderMaterial,Vector3:t.Vector3},rU=bo.default||bo,iU=O({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.pause()},resumeAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.resume()},_destructor:function(e){var t;null===(t=e.ticker)||void 0===t||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new rU,sharedMaterial:new tU.ShaderMaterial(Wk(Wk({},EV()),{},{transparent:!0,blending:tU.NormalBlending}))}},init:function(e,t){iV(e),t.scene=e,t.dataMapper=new _V(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var e=new tU.Group;return e.__globeObjType="path",e}),t.ticker.onTick.add(function(e,r){t.dataMapper.entries().map(function(e){return Yk(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],i=t.__dashAnimateStep*r;if("Line"===t.type){var n=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=n+i}else if("Line2"===t.type){for(var s=t.material.dashOffset-i,a=t.material.dashSize+t.material.gapSize;s<=-a;)s+=a;t.material.dashOffset=s}})})},update:function(e){var t=fa(e.pathPoints),r=fa(e.pathPointLat),i=fa(e.pathPointLng),n=fa(e.pathPointAlt),s=fa(e.pathStroke),a=fa(e.pathColor),o=fa(e.pathDashLength),l=fa(e.pathDashGap),A=fa(e.pathDashInitialGap),u=fa(e.pathDashAnimateTime);function h(e,t){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=t+1;if(e instanceof Array||e instanceof Function){var a=e instanceof Array?Ot().domain(e.map(function(t,r){return r/(e.length-1)})).range(e):e;r=function(e){return mV(a(e),n,!0)}}else{var o=mV(e,n,!0);r=function(){return o}}for(var l=[],A=0,u=s;A<u;A++)for(var h=r(A/(u-1)),c=0;c<i;c++)l.push(h);return yV(l,n?4:3)}e.dataMapper.onUpdateObj(function(c,d){var p=s(d),f=null!=p;if(!c.children.length||f===("Line"===c.children[0].type)){iV(c);var m=f?new Sk(new Mk,new ok):new tU.Line(new tU.BufferGeometry,e.sharedMaterial.clone());c.add(m)}var g,y,b=c.children[0],x=function(e,t,r,i,n){var s=function(e,t,r){for(var i=[],n=1;n<=r;n++)i.push(e+(t-e)*n/(r+1));return i},a=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=[],r=null;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(i){if(r){for(;Math.abs(r[1]-i[1])>180;)r[1]+=360*(r[1]<i[1]?1:-1);var n=Math.sqrt(Math.pow(i[0]-r[0],2)+Math.pow(i[1]-r[1],2));if(n>e)for(var a=Math.floor(n/e),o=s(r[0],i[0],a),l=s(r[1],i[1],a),A=s(r[2],i[2],a),u=0,h=o.length;u<h;u++)t.push([o[u],l[u],A[u]])}t.push(r=i)}),t},o=function(e){var t=Yk(e,3),r=oV(t[0],t[1],t[2]),i=r.x,n=r.y,s=r.z;return new tU.Vector3(i,n,s)};return a(e.map(function(e){return[t(e),r(e),i(e)]}),n).map(o)}(t(d),r,i,n,e.pathResolution),v=u(d);if(b.__dashAnimateStep=v>0?1e3/v:0,f){b.material.resolution=e.rendererSize;var _=o(d),w=l(d),T=A(d);b.material.dashed=w>0,b.material.dashed?b.material.defines.USE_DASH="":delete b.material.defines.USE_DASH,b.material.dashed&&(b.material.dashScale=1/(y=0,x.forEach(function(e){g&&(y+=g.distanceTo(e)),g=e}),y),b.material.dashSize=_,b.material.gapSize=w,b.material.dashOffset=-T);var M=a(d);if(M instanceof Array){var S=h(a(d),x.length-1,1,!1);b.geometry.setColors(S.array),b.material.vertexColors=!0}else{var E=M,N=fV(E);b.material.color=new tU.Color(pV(E)),b.material.transparent=N<1,b.material.opacity=N,b.material.vertexColors=!1}b.material.needsUpdate=!0}else{Object.assign(b.material.uniforms,{dashSize:{value:o(d)},gapSize:{value:l(d)},dashOffset:{value:A(d)}});var C=h(a(d),x.length),R=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[],n=0,s=e+1;n<s;n++)for(var a=n/(s-1),o=0;o<t;o++)i.push(a);return r&&i.reverse(),yV(i,1)}(x.length,1,!0);b.geometry.setAttribute("color",C),b.geometry.setAttribute("relDistance",R)}var B=eU(c.__currentTargetD&&c.__currentTargetD.points||[x[0]],x),P=function(e){var t,r=c.__currentTargetD=e,i=r.stroke,n=r.interpolK,s=c.__currentTargetD.points=B(n);f?(b.geometry.setPositions((t=[]).concat.apply(t,Zk(s.map(function(e){return[e.x,e.y,e.z]})))),b.material.linewidth=i,b.material.dashed&&b.computeLineDistances()):(b.geometry.setFromPoints(s),b.geometry.computeBoundingSphere())},q={stroke:p,interpolK:1},D=Object.assign({},c.__currentTargetD||q,{interpolK:0});Object.keys(q).some(function(e){return D[e]!==q[e]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?P(q):e.tweenGroup.add(new j(D).to(q,e.pathTransitionDuration).easing(L.Quadratic.InOut).onUpdate(P).start()))}).digest(e.pathsData)}}),nU=window.THREE?window.THREE:{Euler:t.Euler,Mesh:t.Mesh,MeshLambertMaterial:t.MeshLambertMaterial,SphereGeometry:t.SphereGeometry},sU=O({props:{tilesData:{default:[]},tileLat:{default:"lat"},tileLng:{default:"lng"},tileAltitude:{default:.01},tileWidth:{default:1},tileHeight:{default:1},tileUseGlobeProjection:{default:!0},tileMaterial:{default:function(){return new nU.MeshLambertMaterial({color:"#ffbb88",opacity:.4,transparent:!0})}},tileCurvatureResolution:{default:5},tilesTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjTile"}).onCreateObj(function(){var e=new nU.Mesh;return e.__globeObjType="tile",e})},update:function(e){var t=fa(e.tileLat),r=fa(e.tileLng),i=fa(e.tileAltitude),n=fa(e.tileWidth),s=fa(e.tileHeight),a=fa(e.tileUseGlobeProjection),o=fa(e.tileMaterial),l=fa(e.tileCurvatureResolution);e.dataMapper.onUpdateObj(function(A,u){A.material=o(u);var h=a(u),c=l(u),d=function(e){var t=A.__currentTargetD=e,r=t.lat,i=t.lng,n=t.alt,s=t.width,a=t.height,o=aU(i),l=aU(-r);A.geometry&&A.geometry.dispose(),A.geometry=new nU.SphereGeometry(sV*(1+n),Math.ceil(s/(c||-1)),Math.ceil(a/(c||-1)),aU(90-s/2)+(h?o:0),aU(s),aU(90-a/2)+(h?l:0),aU(a)),h||A.setRotationFromEuler(new nU.Euler(l,o,0,"YXZ"))},p={lat:+t(u),lng:+r(u),alt:+i(u),width:+n(u),height:+s(u)},f=A.__currentTargetD||Object.assign({},p,{width:0,height:0});Object.keys(p).some(function(e){return f[e]!==p[e]})&&(!e.tilesTransitionDuration||e.tilesTransitionDuration<0?d(p):e.tweenGroup.add(new j(f).to(p,e.tilesTransitionDuration).easing(L.Quadratic.InOut).onUpdate(d).start()))}).digest(e.tilesData)}}),aU=function(e){return e*Math.PI/180},oU=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,Color:t.Color,Points:t.Points,PointsMaterial:t.PointsMaterial},lU=O({props:{particlesData:{default:[]},particlesList:{default:function(e){return e}},particleLat:{default:"lat"},particleLng:{default:"lng"},particleAltitude:{default:.01},particlesSize:{default:.5},particlesSizeAttenuation:{default:!0},particlesColor:{default:function(){return"white"}},particlesTexture:{}},init:function(e,t){iV(e),t.scene=e,t.dataMapper=new _V(e,{objBindAttr:"__threeObjParticles"}).onCreateObj(function(){var e=new oU.Points(new oU.BufferGeometry,new oU.PointsMaterial);return e.__globeObjType="particles",e}).onUpdateObj(function(e,r){var i=fa(t.particlesList),n=fa(t.particleLat),s=fa(t.particleLng),a=fa(t.particleAltitude);e.geometry.setAttribute("position",yV(i(r).map(function(e){return Object.values(oV(n(e),s(e),a(e)))}),3))})},update:function(e,t){["particlesData","particlesList","particleLat","particleLng","particleAltitude"].some(function(e){return t.hasOwnProperty(e)})&&e.dataMapper.digest(e.particlesData);var r=fa(e.particlesColor),i=fa(e.particlesSize),n=fa(e.particlesSizeAttenuation),s=fa(e.particlesTexture);e.dataMapper.entries().forEach(function(t){var a=Yk(t,2),o=a[0],l=a[1];if(l.material.size=i(o),l.material.sizeAttenuation=n(o),e.particlesTexture)l.material.color=new oU.Color(16777215),l.material.transparent=!1,l.material.alphaTest=.5,l.material.map=s(o);else{var A=r(o),u=fV(A);l.material.color=new oU.Color(pV(A)),l.material.transparent=u<1,l.material.opacity=u,l.material.alphaTest=0}})}}),AU=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;Dk(this,t),(e=qk(this,t)).type="CircleLineGeometry",e.parameters={radius:r,segmentCount:i};for(var n=[],s=0;s<=i;s++){var a=(s/i-.25)*Math.PI*2;n.push({x:Math.cos(a)*r,y:Math.sin(a)*r,z:0})}return e.setFromPoints(n),e}return Gk(t,e),kk(t)}((window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry}).BufferGeometry),uU=window.THREE?window.THREE:{Color:t.Color,Group:t.Group,Line:t.Line,LineBasicMaterial:t.LineBasicMaterial,Vector3:t.Vector3},hU=bo.default||bo,cU=O({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.pause()},resumeAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.resume()},_destructor:function(e){var t;null===(t=e.ticker)||void 0===t||t.dispose()}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var e=new uU.Group;return e.__globeObjType="ring",e}),t.ticker=new hU,t.ticker.onTick.add(function(e){if(t.ringsData.length){var r=fa(t.ringColor),i=fa(t.ringAltitude),n=fa(t.ringMaxRadius),s=fa(t.ringPropagationSpeed),a=fa(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(e){return Yk(e,2)[1]}).forEach(function(o){var l,A,u=Yk(o,2),h=u[0],c=u[1];if((c.__nextRingTime||0)<=e){var d=a(h)/1e3;c.__nextRingTime=e+(d<=0?1/0:d);var p,f=new uU.Line(new AU(1,t.ringResolution),new uU.LineBasicMaterial),m=r(h),g=m instanceof Array||m instanceof Function;g?m instanceof Array?(p=Ot().domain(m.map(function(e,t){return t/(m.length-1)})).range(m),f.material.transparent=m.some(function(e){return fV(e)<1})):(p=m,f.material.transparent=!0):(f.material.color=new uU.Color(pV(m)),l=f.material,A=fV(m),l.opacity=A,l.transparent=A<1,l.depthWrite=A>=1);var y=sV*(1+i(h)),b=n(h),x=b*Math.PI/180,v=s(h),_=v<=0,w=function(e){var t=e.t,r=(_?1-t:t)*x;if(f.scale.x=f.scale.y=y*Math.sin(r),f.position.z=y*(1-Math.cos(r)),g){var i=p(t);f.material.color=new uU.Color(pV(i)),f.material.transparent&&(f.material.opacity=fV(i))}};if(0===v)w({t:0}),c.add(f);else{var T=1e3*Math.abs(b/v);t.tweenGroup.add(new j({t:0}).to({t:1},T).onUpdate(w).onStart(function(){return c.add(f)}).onComplete(function(){c.remove(f),rV(f)}).start())}}})}})},update:function(e){var t=fa(e.ringLat),r=fa(e.ringLng),i=fa(e.ringAltitude),n=e.scene.localToWorld(new uU.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(e,s){var a=t(s),o=r(s),l=i(s);Object.assign(e.position,oV(a,o,l)),e.lookAt(n)}).digest(e.ringsData)}}),dU={glyphs:{0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},"ο":{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},"Τ":{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},"Π":{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},"ΐ":{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},"Κ":{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},"ƒ":{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},"ό":{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},"ώ":{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},"ÿ":{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},"µ":{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},"Ι":{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},"Ύ":{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},"Ν":{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},"ς":{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},"Ψ":{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},"ι":{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},"Ά":{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},"ε":{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},"Δ":{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},"ρ":{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},"Η":{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},"Α":{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},"ν":{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},"β":{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},"Μ":{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},"Ό":{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"Ή":{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},"γ":{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},"α":{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},"Χ":{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},"Ξ":{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},"Ϋ":{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},"Ί":{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},"Β":{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},"υ":{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},"χ":{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},"ί":{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},"Ζ":{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},"δ":{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},"έ":{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},"ω":{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"ϋ":{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},"Ω":{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},"ύ":{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},"ή":{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},"Θ":{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},"Ε":{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},"σ":{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},"ζ":{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},"θ":{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},"Ο":{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},"Γ":{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},"Έ":{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"Ώ":{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},"Ϊ":{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},"Ρ":{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},"ª":{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},"Φ":{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},"Σ":{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},"λ":{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},"τ":{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},"ξ":{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},"Λ":{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},"ΰ":{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},"Υ":{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},"μ":{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},"φ":{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},"ϊ":{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},"π":{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},"ά":{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},"κ":{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},"ψ":{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},"η":{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},cssFontWeight:"normal",ascender:1189,underlinePosition:-100,cssFontStyle:"normal",boundingBox:{yMin:-334,xMin:-111,yMax:1189,xMax:1672},resolution:1e3,original_font_information:{postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:'Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r\n\r\nThe above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r\n\r\nThe Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r\n\r\nThis License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r\n\r\nThe Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r\n\r\nTHE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.',manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},descender:-334,familyName:"Helvetiker",lineHeight:1522,underlineThickness:50},pU=Wk(Wk({},window.THREE?window.THREE:{BoxGeometry:t.BoxGeometry,CircleGeometry:t.CircleGeometry,DoubleSide:t.DoubleSide,Group:t.Group,Mesh:t.Mesh,MeshLambertMaterial:t.MeshLambertMaterial,TextGeometry:Ek,Vector3:t.Vector3}),{},{Font:class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const r=[],i=function(e,t,r){const i=Array.from(e),n=t/r.resolution,s=(r.boundingBox.yMax-r.boundingBox.yMin+r.underlineThickness)*n,a=[];let o=0,l=0;for(let e=0;e<i.length;e++){const t=i[e];if("\n"===t)o=0,l-=s;else{const e=Nk(t,n,o,l,r);o+=e.offsetX,a.push(e.path)}}return a}(e,t,this.data);for(let e=0,t=i.length;e<t;e++)r.push(...i[e].toShapes());return r}},TextGeometry:Ek}),fU=O({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:dU,onChange:function(e,t){t.font=new pU.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,r,i){var n=i.tweenGroup;iV(e),r.scene=e,r.tweenGroup=n;var s=new pU.CircleGeometry(1,32);r.dataMapper=new _V(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var e=new pU.MeshLambertMaterial;e.side=t.DoubleSide;var r=new pU.Group;r.add(new pU.Mesh(s,e));var i=new pU.Mesh(void 0,e);r.add(i);var n=new pU.Mesh;return n.visible=!1,i.add(n),r.__globeObjType="label",r})},update:function(e){var t=fa(e.labelLat),r=fa(e.labelLng),i=fa(e.labelAltitude),n=fa(e.labelText),s=fa(e.labelSize),a=fa(e.labelRotation),o=fa(e.labelColor),l=fa(e.labelIncludeDot),A=fa(e.labelDotRadius),u=fa(e.labelDotOrientation),h=new Set(["right","top","bottom"]),c=2*Math.PI*sV/360;e.dataMapper.onUpdateObj(function(d,p){var f=Yk(d.children,2),m=f[0],g=f[1],y=Yk(g.children,1)[0],b=o(p),x=fV(b);g.material.color.set(pV(b)),g.material.transparent=x<1,g.material.opacity=x;var v=l(p),_=u(p);!v||!h.has(_)&&(_="bottom");var w=v?+A(p)*c:1e-12;m.scale.x=m.scale.y=w;var T=+s(p)*c;if(g.geometry&&g.geometry.dispose(),g.geometry=new pU.TextGeometry(n(p),{font:e.font,size:T,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),y.geometry&&y.geometry.dispose(),g.geometry.computeBoundingBox(),y.geometry=Lk(pU.BoxGeometry,Zk((new pU.Vector3).subVectors(g.geometry.boundingBox.max,g.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),"right"!==_&&g.geometry.center(),v){var M=w+T/2;"right"===_&&(g.position.x=M),g.position.y={right:-T/2,top:M+T/2,bottom:-M-T/2}[_]}var S=function(t){var r=d.__currentTargetD=t,i=r.lat,n=r.lng,s=r.alt,a=r.rot,o=r.scale;Object.assign(d.position,oV(i,n,s)),d.lookAt(e.scene.localToWorld(new pU.Vector3(0,0,0))),d.rotateY(Math.PI),d.rotateZ(-a*Math.PI/180),d.scale.x=d.scale.y=d.scale.z=o},E={lat:+t(p),lng:+r(p),alt:+i(p),rot:+a(p),scale:1},N=d.__currentTargetD||Object.assign({},E,{scale:1e-12});Object.keys(E).some(function(e){return N[e]!==E[e]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?S(E):e.tweenGroup.add(new j(N).to(E,e.labelsTransitionDuration).easing(L.Quadratic.InOut).onUpdate(S).start()))}).digest(e.labelsData)}}),mU=Wk(Wk({},window.THREE?window.THREE:{}),{},{CSS2DObject:Ck}),gU=O({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){e.dataMapper&&(t?[t]:e.dataMapper.entries().map(function(e){return Yk(e,2)[1]}).filter(function(e){return e})).forEach(function(t){var r=!e.isBehindGlobe||!e.isBehindGlobe(t.position);e.htmlElementVisibilityModifier?(t.visible=!0,e.htmlElementVisibilityModifier(t.element,r)):t.visible=r})}},init:function(e,t,r){var i=r.tweenGroup;iV(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new _V(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(e){var r=fa(t.htmlElement)(e),i=new mU.CSS2DObject(r);return i.__globeObjType="html",i})},update:function(e,t){var r=this,i=fa(e.htmlLat),n=fa(e.htmlLng),s=fa(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(t,a){var o=function(e){var i=t.__currentTargetD=e,n=i.alt,s=i.lat,a=i.lng;Object.assign(t.position,oV(s,a,n)),r.updateObjVisibility(t)},l={lat:+i(a),lng:+n(a),alt:+s(a)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!t.__currentTargetD?o(l):e.tweenGroup.add(new j(t.__currentTargetD).to(l,e.htmlTransitionDuration).easing(L.Quadratic.InOut).onUpdate(o).start())}).digest(e.htmlElementsData)}}),yU=window.THREE?window.THREE:{Group:t.Group,Mesh:t.Mesh,MeshLambertMaterial:t.MeshLambertMaterial,SphereGeometry:t.SphereGeometry},bU=O({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new yU.Mesh(new yU.SphereGeometry(1,16,8),new yU.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){iV(e),t.scene=e,t.dataMapper=new _V(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(e){var r=fa(t.objectThreeObject)(e);t.objectThreeObject===r&&(r=r.clone());var i=new yU.Group;return i.add(r),i.__globeObjType="object",i})},update:function(e,r){var i=fa(e.objectLat),n=fa(e.objectLng),s=fa(e.objectAltitude),a=fa(e.objectFacesSurface),o=fa(e.objectRotation);r.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,r){var l=+i(r),A=+n(r),u=+s(r);Object.assign(e.position,oV(l,A,u)),a(r)?e.setRotationFromEuler(new t.Euler(AV(-l),AV(A),0,"YXZ")):e.rotation.set(0,0,0);var h=e.children[0],c=o(r);c&&h.setRotationFromEuler(new t.Euler(AV(c.x||0),AV(c.y||0),AV(c.z||0)))}).digest(e.objectsData)}}),xU=O({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){iV(e),t.scene=e,t.dataMapper=new _V(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(e){var r=fa(t.customThreeObject)(e,sV);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||iV(e.scene);var r=fa(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,t){return r(e,t,sV)}).digest(e.customLayerData)}}),vU=window.THREE?window.THREE:{Camera:t.Camera,Group:t.Group,Vector2:t.Vector2,Vector3:t.Vector3},_U=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],wU=nV("globeLayer",dV),TU=Object.assign.apply(Object,Zk(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(e){return Vk({},e,wU.linkProp(e))}))),MU=Object.assign.apply(Object,Zk(["globeMaterial"].map(function(e){return Vk({},e,wU.linkMethod(e))}))),SU=nV("pointsLayer",SV),EU=Object.assign.apply(Object,Zk(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(e){return Vk({},e,SU.linkProp(e))}))),NU=nV("arcsLayer",DV),CU=Object.assign.apply(Object,Zk(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(e){return Vk({},e,NU.linkProp(e))}))),RU=nV("hexBinLayer",LV),BU=Object.assign.apply(Object,Zk(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(e){return Vk({},e,RU.linkProp(e))}))),PU=nV("heatmapsLayer",WV),qU=Object.assign.apply(Object,Zk(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(e){return Vk({},e,PU.linkProp(e))}))),DU=nV("hexedPolygonsLayer",ZV),IU=Object.assign.apply(Object,Zk(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(e){return Vk({},e,DU.linkProp(e))}))),FU=nV("polygonsLayer",$V),OU=Object.assign.apply(Object,Zk(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(e){return Vk({},e,FU.linkProp(e))}))),LU=nV("pathsLayer",iU),kU=Object.assign.apply(Object,Zk(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(e){return Vk({},e,LU.linkProp(e))}))),VU=nV("tilesLayer",sU),UU=Object.assign.apply(Object,Zk(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(e){return Vk({},e,VU.linkProp(e))}))),zU=nV("particlesLayer",lU),GU=Object.assign.apply(Object,Zk(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(e){return Vk({},e,zU.linkProp(e))}))),jU=nV("ringsLayer",cU),HU=Object.assign.apply(Object,Zk(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(e){return Vk({},e,jU.linkProp(e))}))),WU=nV("labelsLayer",fU),QU=Object.assign.apply(Object,Zk(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(e){return Vk({},e,WU.linkProp(e))}))),$U=nV("htmlElementsLayer",gU),XU=Object.assign.apply(Object,Zk(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(e){return Vk({},e,$U.linkProp(e))}))),YU=nV("objectsLayer",bU),KU=Object.assign.apply(Object,Zk(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(e){return Vk({},e,YU.linkProp(e))}))),ZU=nV("customLayer",xU),JU=Object.assign.apply(Object,Zk(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(e){return Vk({},e,ZU.linkProp(e))}))),ez=O({props:Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk(Wk({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new vU.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},TU),EU),CU),BU),qU),OU),IU),kU),UU),GU),HU),QU),XU),KU),JU),methods:Wk({getGlobeRadius:aV,getCoords:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return oV.apply(void 0,r)},toGeoCoords:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return lV.apply(void 0,r)},setPointOfView:function(e,t){var r,i,n,s,a=t instanceof vU.Camera?t.position:t,o=aV(),l=void 0;e.scene&&a&&(l=function(t){void 0===r&&(r=a.clone().applyMatrix4(e.scene.matrixWorld.clone().invert())),void 0===i&&(i=r.length()),void 0===n&&(n=Math.sqrt(Math.pow(i,2)-Math.pow(o,2))),void 0===s&&(s=Math.acos(n/i));var l=r.distanceTo(t);if(l<n)return!1;var A=t.length();return Math.acos((Math.pow(i,2)+Math.pow(l,2)-Math.pow(A,2))/(2*i*l))<s});e.layersThatNeedUpdatePov.forEach(function(e){return e.updatePov(t)}),e.layersThatNeedBehindGlobeChecker.forEach(function(e){return e.isBehindGlobe(l)})},pauseAnimation:function(e){return null!==e.animationFrameRequestId&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),e.pausableLayers.forEach(function(e){var t;return null===(t=e.pauseAnimation)||void 0===t?void 0:t.call(e)}),this},resumeAnimation:function(e){return null===e.animationFrameRequestId&&this._animationCycle(),e.pausableLayers.forEach(function(e){var t;return null===(t=e.resumeAnimation)||void 0===t?void 0:t.call(e)}),this},_animationCycle:function(e){e.animationFrameRequestId=requestAnimationFrame(this._animationCycle),e.tweenGroup.update()},_destructor:function(e){this.pauseAnimation(),e.destructableLayers.forEach(function(e){return e._destructor()})}},MU),stateInit:function(){var e=new V,t={tweenGroup:e},r={globeLayer:dV(t),pointsLayer:SV(t),arcsLayer:DV(t),hexBinLayer:LV(t),heatmapsLayer:WV(t),polygonsLayer:$V(t),hexedPolygonsLayer:ZV(t),pathsLayer:iU(t),tilesLayer:sU(t),particlesLayer:lU(t),ringsLayer:cU(t),labelsLayer:fU(t),htmlElementsLayer:gU(t),objectsLayer:bU(t),customLayer:xU(t)};return Wk(Wk({tweenGroup:e},r),{},{layersThatNeedUpdatePov:Object.values(r).filter(function(e){return e.hasOwnProperty("updatePov")}),layersThatNeedBehindGlobeChecker:Object.values(r).filter(function(e){return e.hasOwnProperty("isBehindGlobe")}),destructableLayers:Object.values(r).filter(function(e){return e.hasOwnProperty("_destructor")}),pausableLayers:Object.values(r).filter(function(e){return e.hasOwnProperty("pauseAnimation")})})},init:function(e,t,r){var i=r.animateIn,n=void 0===i||i,s=r.waitForGlobeReady,a=void 0===s||s;iV(e),t.scene=e,t.scene.visible=!1,_U.forEach(function(e){var r=new vU.Group;t.scene.add(r),t[e](r)});var o=function(){if(n){t.scene.scale.set(1e-6,1e-6,1e-6),t.tweenGroup.add(new j({k:1e-6}).to({k:1},600).easing(L.Quadratic.Out).onUpdate(function(e){var r=e.k;return t.scene.scale.set(r,r,r)}).start());var e=new vU.Vector3(0,1,0);t.tweenGroup.add(new j({rot:2*Math.PI}).to({rot:0},1200).easing(L.Quintic.Out).onUpdate(function(r){var i=r.rot;return t.scene.setRotationFromAxisAngle(e,i)}).start())}t.scene.visible=!0,t.onGlobeReady&&t.onGlobeReady()};a?t.globeLayer.onReady(o):o(),this._animationCycle()},update:function(e){}});var tz=function(e){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=function(r){function i(){var r;Dk(this,i);for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];return(r=qk(this,i,[].concat(s))).__kapsuleInstance=Lk(e,[].concat(Zk(t?[r]:[]),s)),r}return Gk(i,r),kk(i)}(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Object);return Object.keys(e()).forEach(function(e){return r.prototype[e]=function(){var t,r=(t=this.__kapsuleInstance)[e].apply(t,arguments);return r===this.__kapsuleInstance?this:r}}),r}(ez,(window.THREE?window.THREE:{Group:t.Group}).Group,!0);function rz(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function iz(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s,a,o=[],l=!0,A=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=s.call(r)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){A=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(A)throw n}}return o}}(e,t)||sz(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nz(e){return function(e){if(Array.isArray(e))return az(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||sz(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sz(e,t){if(e){if("string"==typeof e)return az(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?az(e,t):void 0}}function az(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var oz=["onHover","onClick"],lz=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.methodNames,n=void 0===i?[]:i,l=r.initPropNames,A=void 0===l?[]:l;return e.forwardRef(function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0,l=e.useMemo(function(){return new t(Object.fromEntries(A.filter(function(e){return r.hasOwnProperty(e)}).map(function(e){return[e,r[e]]})))},[]);e.useEffect(function(){return l._destructor instanceof Function?l._destructor:void 0},[l]);var u,h,c,d=e.useCallback(function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return l[e]instanceof Function?l[e].apply(l,r):void 0},[l]),p=Object.fromEntries(Object.entries(r).filter(function(e){var t=a(e,1)[0];return!(l[t]&&l[t]instanceof Function)})),f=e.useRef({});return Object.keys((u=r,h=[].concat(o(n),o(A),o(Object.keys(p))),c=new Set(h),Object.assign.apply(Object,[{}].concat(nz(Object.entries(u).filter(function(e){var t=iz(e,1)[0];return!c.has(t)}).map(function(e){var t=iz(e,2);return rz({},t[0],t[1])})))))).filter(function(e){return f.current[e]!==r[e]}).forEach(function(e){return d(e,r[e])}),f.current=r,e.useImperativeHandle(i,function(){return Object.fromEntries(n.map(function(e){return[e,function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return d.apply(void 0,[e].concat(r))}]}))}),e.createElement("primitive",s(s({},p),{},{object:l}))})}(tz,{initPropNames:["waitForGlobeReady","animateIn"],methodNames:["getGlobeRadius","getCoords","toGeoCoords","pauseAnimation","resumeAnimation","setPointOfView"]}),Az=function(e){var t=e.intersections,r=function(e){return e?e.hasOwnProperty("__globeObjType")?e:r(e.parent):null},i=t.find(function(e){var t=r(e.object);return t&&"atmosphere"!==t.__globeObjType});return[r(null==i?void 0:i.object),i]},uz=function(e,t){return({polygon:function(e){return e.data},particles:function(e){return t&&t.hasOwnProperty("index")&&e.length>t.index?e[t.index]:e}}[null==e?void 0:e.__globeObjType]||function(e){return e})(null==e?void 0:e.__data)};return e.forwardRef(function(t,r){var i=t.onHover,n=t.onClick,o=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;r[i]=e[i]}return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(t,oz),l=e.useRef(null),A=e.useCallback(function(e){if(i){var t=a(Az(e),2),r=t[0],n=t[1];r!==l.current&&(l.current=r,i(null==r?void 0:r.__globeObjType,uz(r,n)))}},[i]),u=e.useCallback(function(e){var t=a(Az(e),2),r=t[0],i=t[1];r&&n&&(n(null==r?void 0:r.__globeObjType,uz(r,i),e),e.stopPropagation())},[n]);return e.createElement(lz,s(s({},o),{},{ref:r,onPointerMove:i?A:void 0,onClick:n?u:void 0}))})});