// Version 2.45.1 three-globe - https://github.com/vasturiano/three-globe !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("three")):"function"==typeof define&&define.amd?define(["three"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ThreeGlobe=t(e.THREE)}(this,function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r3?(n=p===i)&&(l=s[(o=s[4])?5:(o=3,3)],s[4]=s[5]=e):s[0]<=d&&((n=r<2&&di||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]())):(b(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,b(e,n,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=A,b(h,"constructor",A),b(A,"constructor",l),l.displayName="GeneratorFunction",b(A,n,"GeneratorFunction"),b(h),b(h,n,"Generator"),b(h,i,function(){return this}),b(h,"toString",function(){return"[object Generator]"}),(y=function(){return{w:s,m:c}})()}function b(e,t,r,i){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}b=function(e,t,r,i){function s(t,r){b(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))},b(e,t,r,i)}function x(e,t){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},x(e,t)}function v(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)||M(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 _(e,t,r,i){var n=c(d(e.prototype),t,r);return"function"==typeof n?function(e){return n.apply(r,e)}:n}function w(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||M(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 T(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 M(e,r){if(e){if("string"==typeof e)return t(e,r);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)?t(e,r):void 0}}function S(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var N="object"==typeof global&&global&&global.Object===Object&&global,E="object"==typeof self&&self&&self.Object===Object&&self,C=N||E||Function("return this")(),R=function(){return C.Date.now()},B=/\s/;var P=/^\s+/;function D(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&B.test(e.charAt(t)););return t}(e)+1).replace(P,""):e}var I=C.Symbol,F=Object.prototype,q=F.hasOwnProperty,L=F.toString,O=I?I.toStringTag:void 0;var k=Object.prototype.toString;var U=I?I.toStringTag:void 0;function V(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":U&&U in Object(e)?function(e){var t=q.call(e,O),r=e[O];try{e[O]=void 0;var i=!0}catch(e){}var n=L.call(e);return i&&(t?e[O]=r:delete e[O]),n}(e):function(e){return k.call(e)}(e)}var z=/^[-+]0x[0-9a-f]+$/i,G=/^0b[01]+$/i,j=/^0o[0-7]+$/i,W=parseInt;function H(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]"==V(e)}(e))return NaN;if(S(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=S(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=D(e);var r=G.test(e);return r||j.test(e)?W(e.slice(2),r?2:8):z.test(e)?NaN:+e}var $=Math.max,Q=Math.min;function X(e,t,r){var i,n,s,a,o,l,A=0,u=!1,h=!1,c=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function d(t){var r=i,s=n;return i=n=void 0,A=t,a=e.apply(s,r)}function p(e){var r=e-l;return void 0===l||r>=t||r<0||h&&e-A>=s}function f(){var e=R();if(p(e))return m(e);o=setTimeout(f,function(e){var r=t-(e-l);return h?Q(r,s-(e-A)):r}(e))}function m(e){return o=void 0,c&&i?d(e):(i=n=void 0,a)}function g(){var e=R(),r=p(e);if(i=arguments,n=this,l=e,r){if(void 0===o)return function(e){return A=e,o=setTimeout(f,t),u?d(e):a}(l);if(h)return clearTimeout(o),o=setTimeout(f,t),d(l)}return void 0===o&&(o=setTimeout(f,t)),a}return t=H(t)||0,S(r)&&(u=!!r.leading,s=(h="maxWait"in r)?$(H(r.maxWait)||0,t):s,c="trailing"in r?!!r.trailing:c),g.cancel=function(){void 0!==o&&clearTimeout(o),A=0,i=l=n=o=void 0},g.flush=function(){return void 0===o?a:m(R())},g}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r1e4?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}}}}),re=function(){return performance.now()},ie=function(){function e(){for(var e=[],t=0;t0;){this._tweensAddedDuringUpdate={};for(var i=0;i1?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}}},se=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),ae=new ie,oe=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=te.Linear.None,this._interpolationFunction=ne.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=se.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=ae,ae.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=re()),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;hl)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;c1?n-1:0),a=1;a2&&void 0!==arguments[2]?arguments[2]:0,i=(90-e)*Math.PI/180,n=(90-t)*Math.PI/180,s=de*(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 me(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/de-1}}function ge(e){return e*Math.PI/180}function ye(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 be(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}const xe=(e,t,r,i,n,s)=>Math.sqrt((e-i)**2+(t-n)**2+(r-s)**2);function ve(e){return e[0]}function _e(e){return e[1]}function we(e){return e[2]}function Te(e,t,r,i){var n=new Me(null==t?ve:t,null==r?_e:r,null==i?we:i,NaN,NaN,NaN,NaN,NaN,NaN);return null==e?n:n.addAll(e)}function Me(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 Se(e){for(var t={data:e.data},r=t;e=e.next;)r=r.next={data:e.data};return t}var Ne=Te.prototype=Me.prototype;function Ee(e,t){return null==e||null==t?NaN:et?1:e>=t?0:NaN}function Ce(e,t){return null==e||null==t?NaN:te?1:t>=e?0:NaN}function Re(e){let t,r,i;function n(e,i,n=0,s=e.length){if(n>>1;r(e[t],i)<0?n=t+1:s=t}while(nEe(e(t),r),i=(t,r)=>e(t)-r):(t=e===Ee||e===Ce?e:Be,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>>1;r(e[t],i)<=0?n=t+1:s=t}while(nl&&(l=c),dA&&(A=d),pu&&(u=p));if(s>l||a>A||o>u)return this;this.cover(s,a,o).cover(l,A,u);for(let s=0;se||e>=a||n>t||t>=o||s>r||r>=l;)switch(u=(rm||(a=h.y0)>g||(o=h.z0)>y||(l=h.x1)=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),N=T*T+M*M+S*S;if(N{if(!h.length)do{const s=h.data;xe(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=(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)},Ne.removeAll=function(e){for(var t=0,r=e.length;t=t&&(r=i=t):(r>t&&(r=t),i=s&&(r=i=s):(r>s&&(r=s),i0){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 Fe=Math.sqrt(50),qe=Math.sqrt(10),Le=Math.sqrt(2);function Oe(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>=Fe?10:s>=qe?5:s>=Le?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/At&&--l,A=-A):(A=Math.pow(10,n)*a,o=Math.round(e/A),l=Math.round(t/A),o*At&&--l),l>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===r?At(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===r?At(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=Ke.exec(e))?new ht(t[1],t[2],t[3],1):(t=Je.exec(e))?new ht(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=et.exec(e))?At(t[1],t[2],t[3],t[4]):(t=tt.exec(e))?At(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=rt.exec(e))?gt(t[1],t[2]/100,t[3]/100,1):(t=it.exec(e))?gt(t[1],t[2]/100,t[3]/100,t[4]):nt.hasOwnProperty(e)?lt(nt[e]):"transparent"===e?new ht(NaN,NaN,NaN,0):null}function lt(e){return new ht(e>>16&255,e>>8&255,255&e,1)}function At(e,t,r,i){return i<=0&&(e=t=r=NaN),new ht(e,t,r,i)}function ut(e,t,r,i){return 1===arguments.length?((n=e)instanceof We||(n=ot(n)),n?new ht((n=n.rgb()).r,n.g,n.b,n.opacity):new ht):new ht(e,t,r,null==i?1:i);var n}function ht(e,t,r,i){this.r=+e,this.g=+t,this.b=+r,this.opacity=+i}function ct(){return`#${mt(this.r)}${mt(this.g)}${mt(this.b)}`}function dt(){const e=pt(this.opacity);return`${1===e?"rgb(":"rgba("}${ft(this.r)}, ${ft(this.g)}, ${ft(this.b)}${1===e?")":`, ${e})`}`}function pt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ft(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function mt(e){return((e=ft(e))<16?"0":"")+e.toString(16)}function gt(e,t,r,i){return i<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new bt(e,t,r,i)}function yt(e){if(e instanceof bt)return new bt(e.h,e.s,e.l,e.opacity);if(e instanceof We||(e=ot(e)),!e)return new bt;if(e instanceof bt)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*(r0&&l<1?0:a,new bt(a,o,l,e.opacity)}function bt(e,t,r,i){this.h=+e,this.s=+t,this.l=+r,this.opacity=+i}function xt(e){return(e=(e||0)%360)<0?e+360:e}function vt(e){return Math.max(0,Math.min(1,e||0))}function _t(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(We,ot,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:st,formatHex:st,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return yt(this).formatHsl()},formatRgb:at,toString:at}),Ge(ht,ut,je(We,{brighter(e){return e=null==e?$e:Math.pow($e,e),new ht(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?He:Math.pow(He,e),new ht(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ht(ft(this.r),ft(this.g),ft(this.b),pt(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:ct,formatHex:ct,formatHex8:function(){return`#${mt(this.r)}${mt(this.g)}${mt(this.b)}${mt(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:dt,toString:dt})),Ge(bt,function(e,t,r,i){return 1===arguments.length?yt(e):new bt(e,t,r,null==i?1:i)},je(We,{brighter(e){return e=null==e?$e:Math.pow($e,e),new bt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?He:Math.pow(He,e),new bt(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 ht(_t(e>=240?e-240:e+120,n,i),_t(e,n,i),_t(e<120?e+240:e-120,n,i),this.opacity)},clamp(){return new bt(xt(this.h),vt(this.s),vt(this.l),pt(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=pt(this.opacity);return`${1===e?"hsl(":"hsla("}${xt(this.h)}, ${100*vt(this.s)}%, ${100*vt(this.l)}%${1===e?")":`, ${e})`}`}}));var wt=e=>()=>e;function Tt(e){return 1===(e=+e)?Mt: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):wt(isNaN(t)?r:t)}}function Mt(e,t){var r=t-e;return r?function(e,t){return function(r){return e+r*t}}(e,r):wt(isNaN(e)?t:e)}var St=function e(t){var r=Tt(t);function i(e,t){var i=r((e=ut(e)).r,(t=ut(t)).r),n=r(e.g,t.g),s=r(e.b,t.b),a=Mt(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 Nt(e,t){t||(t=[]);var r,i=e?Math.min(t.length,e.length):0,n=t.slice();return function(s){for(r=0;rs&&(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:Pt(r,i)})),s=Ft.lastIndex;return st&&(r=e,e=t,t=r),A=function(r){return Math.max(e,Math.min(t,r))}),i=l>2?jt: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),Pt)))(r)))},h.domain=function(e){return arguments.length?(a=Array.from(e,kt),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=Ot,u()},h.clamp=function(e){return arguments.length?(A=!!e||Vt,u()):A!==Vt},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 Ht(e,t){if(!isFinite(e)||0===e)return null;var r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),i=e.slice(0,r);return[i.length>1?i[0]+i.slice(2):i,+e.slice(r+1)]}function $t(e){return(e=Ht(Math.abs(e)))?e[1]:NaN}var Qt,Xt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Yt(e){if(!(t=Xt.exec(e)))throw new Error("invalid format: "+e);var t;return new Zt({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 Zt(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 Kt(e,t){var r=Ht(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")}Yt.prototype=Zt.prototype,Zt.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 Jt={"%":(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)=>Kt(100*e,t),r:Kt,s:function(e,t){var r=Ht(e,t);if(!r)return Qt=void 0,e.toPrecision(t);var i=r[0],n=r[1],s=n-(Qt=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")+Ht(e,Math.max(0,t+s-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function er(e){return e}var tr,rr,ir,nr=Array.prototype.map,sr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ar(e){var t,r,i=void 0===e.grouping||void 0===e.thousands?er:(t=nr.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?er:function(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}(nr.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,t){var r=(e=Yt(e)).fill,h=e.align,c=e.sign,d=e.symbol,p=e.zero,f=e.width,m=e.comma,g=e.precision,y=e.trim,b=e.type;"n"===b?(m=!0,b="g"):Jt[b]||(void 0===g&&(g=12),y=!0,b="g"),(p||"0"===r&&"="===h)&&(p=!0,r="0",h="=");var x=(t&&void 0!==t.prefix?t.prefix:"")+("$"===d?n:"#"===d&&/[boxX]/.test(b)?"0"+b.toLowerCase():""),v=("$"===d?s:/[%p]/.test(b)?l:"")+(t&&void 0!==t.suffix?t.suffix:""),_=Jt[b],w=/[defgprs%]/.test(b);function T(e){var t,n,s,l=x,d=v;if("c"===b)d=_(e)+d,e="";else{var T=(e=+e)<0||1/e<0;if(e=isNaN(e)?u:_(Math.abs(e),g),y&&(e=function(e){e:for(var t,r=e.length,i=1,n=-1;i0&&(n=0)}return n>0?e.slice(0,n)+e.slice(t+1):e}(e)),T&&0===+e&&"+"!==c&&(T=!1),l=(T?"("===c?c:A:"-"===c||"("===c?"":c)+l,d=("s"!==b||isNaN(e)||void 0===Qt?"":sr[8+Qt/3])+d+(T&&"("===c?")":""),w)for(t=-1,n=e.length;++t(s=e.charCodeAt(t))||s>57){d=(46===s?a+e.slice(t+1):e.slice(t))+d,e=e.slice(0,t);break}}m&&!p&&(e=i(e,1/0));var M=l.length+e.length+d.length,S=M>1)+l+e+d+S.slice(M);break;default:e=S+l+e+d}return o(e)}return g=void 0===g?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),T.toString=function(){return e+""},T}return{format:h,formatPrefix:function(e,t){var r=3*Math.max(-8,Math.min(8,Math.floor($t(t)/3))),i=Math.pow(10,-r),n=h(((e=Yt(e)).type="f",e),{suffix:sr[8+r/3]});return function(e){return n(i*e)}}}}function or(e,t,r,i){var n,s=function(e,t,r){r=+r;const i=(t=+t)<(e=+e),n=i?ke(t,e,r):ke(e,t,r);return(i?-1:1)*(n<0?1/-n:n)}(e,t,r);switch((i=Yt(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($t(t)/3)))-$t(Math.abs(e)))}(s,a))||(i.precision=n),ir(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,$t(t)-$t(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,-$t(Math.abs(e)))}(s))||(i.precision=n-2*("%"===i.type))}return rr(i)}function lr(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=n))return[];const o=s-n+1,l=new Array(o);if(i)if(a<0)for(let e=0;e0;){if((n=ke(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 Ar(){var e=Wt()(Vt,Vt);return e.copy=function(){return t=e,Ar().domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());var t},ze.apply(e,arguments),lr(e)}function ur(){var e,t=0,r=1,i=1,n=[.5],s=[0,1];function a(t){return null!=t&&t<=t?s[Pe(n,t,0,i)]:e}function o(){var e=-1;for(n=new Array(i);++e=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 ur().domain([t,r]).range(s).unknown(e)},ze.apply(lr(a),arguments)}tr=ar({thousands:",",grouping:[3],currency:["$",""]}),rr=tr.format,ir=tr.formatPrefix;var hr=1e-6,cr=1e-12,dr=Math.PI,pr=dr/2,fr=dr/4,mr=2*dr,gr=180/dr,yr=dr/180,br=Math.abs,xr=Math.atan,vr=Math.atan2,_r=Math.cos,wr=Math.ceil,Tr=Math.exp,Mr=Math.hypot,Sr=Math.log,Nr=Math.sin,Er=Math.sign||function(e){return e>0?1:e<0?-1:0},Cr=Math.sqrt,Rr=Math.tan;function Br(e){return e>1?pr:e<-1?-pr:Math.asin(e)}function Pr(e){return(e=Nr(e/2))*e}function Dr(){}function Ir(e,t){e&&qr.hasOwnProperty(e.type)&&qr[e.type](e,t)}var Fr={Feature:function(e,t){Ir(e.geometry,t)},FeatureCollection:function(e,t){for(var r=e.features,i=-1,n=r.length;++i=0?1:-1,n=i*r,s=_r(t=(t*=yr)/2+fr),a=Nr(t),o=jr*a,l=Gr*s+o*_r(n),A=o*i*Nr(n);ri.add(vr(A,l)),zr=e,Gr=s,jr=a}function Ai(e){return[vr(e[1],e[0]),Br(e[2])]}function ui(e){var t=e[0],r=e[1],i=_r(r);return[i*_r(t),i*Nr(t),Nr(r)]}function hi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ci(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 di(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function pi(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function fi(e){var t=Cr(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var mi,gi,yi,bi,xi,vi,_i,wi,Ti,Mi,Si,Ni,Ei,Ci,Ri,Bi,Pi={point:Di,lineStart:Fi,lineEnd:qi,polygonStart:function(){Pi.point=Li,Pi.lineStart=Oi,Pi.lineEnd=ki,Jr=new Ie,ni.polygonStart()},polygonEnd:function(){ni.polygonEnd(),Pi.point=Di,Pi.lineStart=Fi,Pi.lineEnd=qi,ri<0?(Wr=-($r=180),Hr=-(Qr=90)):Jr>hr?Qr=90:Jr<-1e-6&&(Hr=-90),ti[0]=Wr,ti[1]=$r},sphere:function(){Wr=-($r=180),Hr=-(Qr=90)}};function Di(e,t){ei.push(ti=[Wr=e,$r=e]),tQr&&(Qr=t)}function Ii(e,t){var r=ui([e*yr,t*yr]);if(Kr){var i=ci(Kr,r),n=ci([i[1],-i[0],0],i);fi(n),n=Ai(n);var s,a=e-Xr,o=a>0?1:-1,l=n[0]*gr*o,A=br(a)>180;A^(o*XrQr&&(Qr=s):A^(o*Xr<(l=(l+360)%360-180)&&lQr&&(Qr=t)),A?eUi(Wr,$r)&&($r=e):Ui(e,$r)>Ui(Wr,$r)&&(Wr=e):$r>=Wr?(e$r&&($r=e)):e>Xr?Ui(Wr,e)>Ui(Wr,$r)&&($r=e):Ui(e,$r)>Ui(Wr,$r)&&(Wr=e)}else ei.push(ti=[Wr=e,$r=e]);tQr&&(Qr=t),Kr=r,Xr=e}function Fi(){Pi.point=Ii}function qi(){ti[0]=Wr,ti[1]=$r,Pi.point=Di,Kr=null}function Li(e,t){if(Kr){var r=e-Xr;Jr.add(br(r)>180?r+(r>0?360:-360):r)}else Yr=e,Zr=t;ni.point(e,t),Ii(e,t)}function Oi(){ni.lineStart()}function ki(){Li(Yr,Zr),ni.lineEnd(),br(Jr)>hr&&(Wr=-($r=180)),ti[0]=Wr,ti[1]=$r,Kr=null}function Ui(e,t){return(t-=e)<0?t+360:t}function Vi(e,t){return e[0]-t[0]}function zi(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tUi(i[0],i[1])&&(i[1]=n[1]),Ui(n[0],i[1])>Ui(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=Ui(i[1],n[0]))>a&&(a=o,Wr=n[0],$r=i[1])}return ei=ti=null,Wr===1/0||Hr===1/0?[[NaN,NaN],[NaN,NaN]]:[[Wr,Hr],[$r,Qr]]}var ji={sphere:Dr,point:Wi,lineStart:$i,lineEnd:Yi,polygonStart:function(){ji.lineStart=Zi,ji.lineEnd=Ki},polygonEnd:function(){ji.lineStart=$i,ji.lineEnd=Yi}};function Wi(e,t){e*=yr;var r=_r(t*=yr);Hi(r*_r(e),r*Nr(e),Nr(t))}function Hi(e,t,r){++mi,yi+=(e-yi)/mi,bi+=(t-bi)/mi,xi+=(r-xi)/mi}function $i(){ji.point=Qi}function Qi(e,t){e*=yr;var r=_r(t*=yr);Ci=r*_r(e),Ri=r*Nr(e),Bi=Nr(t),ji.point=Xi,Hi(Ci,Ri,Bi)}function Xi(e,t){e*=yr;var r=_r(t*=yr),i=r*_r(e),n=r*Nr(e),s=Nr(t),a=vr(Cr((a=Ri*s-Bi*n)*a+(a=Bi*i-Ci*s)*a+(a=Ci*n-Ri*i)*a),Ci*i+Ri*n+Bi*s);gi+=a,vi+=a*(Ci+(Ci=i)),_i+=a*(Ri+(Ri=n)),wi+=a*(Bi+(Bi=s)),Hi(Ci,Ri,Bi)}function Yi(){ji.point=Wi}function Zi(){ji.point=Ji}function Ki(){en(Ni,Ei),ji.point=Wi}function Ji(e,t){Ni=e,Ei=t,e*=yr,t*=yr,ji.point=en;var r=_r(t);Ci=r*_r(e),Ri=r*Nr(e),Bi=Nr(t),Hi(Ci,Ri,Bi)}function en(e,t){e*=yr;var r=_r(t*=yr),i=r*_r(e),n=r*Nr(e),s=Nr(t),a=Ri*s-Bi*n,o=Bi*i-Ci*s,l=Ci*n-Ri*i,A=Mr(a,o,l),u=Br(A),h=A&&-u/A;Ti.add(h*a),Mi.add(h*o),Si.add(h*l),gi+=u,vi+=u*(Ci+(Ci=i)),_i+=u*(Ri+(Ri=n)),wi+=u*(Bi+(Bi=s)),Hi(Ci,Ri,Bi)}function tn(e){mi=gi=yi=bi=xi=vi=_i=wi=0,Ti=new Ie,Mi=new Ie,Si=new Ie,kr(e,ji);var t=+Ti,r=+Mi,i=+Si,n=Mr(t,r,i);return ndr&&(e-=Math.round(e/mr)*mr),[e,t]}function sn(e,t,r){return(e%=mr)?t||r?rn(on(e),ln(t,r)):on(e):t||r?ln(t,r):nn}function an(e){return function(t,r){return br(t+=e)>dr&&(t-=Math.round(t/mr)*mr),[t,r]}}function on(e){var t=an(e);return t.invert=an(-e),t}function ln(e,t){var r=_r(e),i=Nr(e),n=_r(t),s=Nr(t);function a(e,t){var a=_r(t),o=_r(e)*a,l=Nr(e)*a,A=Nr(t),u=A*r+o*i;return[vr(l*n-u*s,o*r-A*i),Br(u*n+l*s)]}return a.invert=function(e,t){var a=_r(t),o=_r(e)*a,l=Nr(e)*a,A=Nr(t),u=A*n-l*s;return[vr(l*n+A*s,o*r+u*i),Br(u*r-o*i)]},a}function An(e,t){(t=ui(t))[0]-=e,fi(t);var r,i=(r=-t[1])>1?0:r<-1?dr:Math.acos(r);return((-t[2]<0?-i:i)+mr-hr)%mr}function un(){var e,t=[];return{point:function(t,r,i){e.push([t,r,i])},lineStart:function(){t.push(e=[])},lineEnd:Dr,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var r=t;return t=[],e=null,r}}}function hn(e,t){return br(e[0]-t[0])=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 pn(e){if(t=e.length){for(var t,r,i=0,n=e[0];++i=0?1:-1,S=M*T,N=S>dr,E=m*_;if(l.add(vr(E*M*Nr(S),g*w+E*_r(S))),a+=N?T+M*mr:T,N^p>=r^x>=r){var C=ci(ui(d),ui(b));fi(C);var R=ci(s,C);fi(R);var B=(N^T>=0?-1:1)*Br(R[2]);(i>B||i===B&&(C[0]||C[1]))&&(o+=N^T>=0?1:-1)}}return(a<-1e-6||a0){for(h||(n.polygonStart(),h=!0),n.lineStart(),e=0;e1&&2&l&&c.push(c.pop().concat(c.shift())),a.push(c.filter(yn))}return c}}function yn(e){return e.length>1}function bn(e,t){return((e=e.x)[0]<0?e[1]-pr-hr:pr-e[1])-((t=t.x)[0]<0?t[1]-pr-hr:pr-t[1])}nn.invert=nn;var xn=gn(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?dr:-dr,l=br(s-r);br(l-dr)0?pr:-pr),e.point(n,i),e.lineEnd(),e.lineStart(),e.point(o,i),e.point(s,i),t=0):n!==o&&l>=dr&&(br(r-n)hr?xr((Nr(t)*(s=_r(i))*Nr(r)-Nr(i)*(n=_r(t))*Nr(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*pr,i.point(-dr,n),i.point(0,n),i.point(dr,n),i.point(dr,0),i.point(dr,-n),i.point(0,-n),i.point(-dr,-n),i.point(-dr,0),i.point(-dr,n);else if(br(e[0]-t[0])>hr){var s=e[0]0,n=br(t)>hr;function s(e,r){return _r(e)*_r(r)>t}function a(e,r,i){var n=[1,0,0],s=ci(ui(e),ui(r)),a=hi(s,s),o=s[0],l=a-o*o;if(!l)return!i&&e;var A=t*a/l,u=-t*o/l,h=ci(n,s),c=pi(n,A);di(c,pi(s,u));var d=h,p=hi(c,d),f=hi(d,d),m=p*p-f*(hi(c,c)-1);if(!(m<0)){var g=Cr(m),y=pi(d,(-p-g)/f);if(di(y,c),y=Ai(y),!i)return y;var b,x=e[0],v=r[0],_=e[1],w=r[1];v0^y[1]<(br(y[0]-x)dr^(x<=y[0]&&y[0]<=v)){var S=pi(d,(-p+g)/f);return di(S,c),[y,Ai(S)]}}}function o(t,r){var n=i?e:dr-e,s=0;return t<-n?s|=1:t>n&&(s|=2),r<-n?s|=4:r>n&&(s|=8),s}return gn(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?dr:-dr),c):0;if(!t&&(A=l=f)&&e.lineStart(),f!==l&&(!(d=a(t,p))||hn(t,d)||hn(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&&hn(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=_r(t),o=Nr(t),l=i*r;null==n?(n=t+i*mr,s=t-l/2):(n=An(a,n),s=An(a,s),(i>0?ns)&&(n+=i*mr));for(var A,u=n;i>0?u>s:u0)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 br(i[0]-e)0?0:3:br(i[0]-r)0?2:1:br(i[1]-t)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=un(),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;ri&&(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=Ue(l)).length;(r||n)&&(a.polygonStart(),r&&(a.lineStart(),s(null,null,1,a),a.lineEnd()),n&&dn(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(Nn,Math.min(Sn,p)),f=Math.max(Nn,Math.min(Sn,f))],x=[s=Math.max(Nn,Math.min(Sn,s)),a=Math.max(Nn,Math.min(Sn,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(a0){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(a0)){if(a/=c,c<0){if(a0){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(a0&&(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 Cn={sphere:Dr,point:Dr,lineStart:function(){Cn.point=Bn,Cn.lineEnd=Rn},lineEnd:Dr,polygonStart:Dr,polygonEnd:Dr};function Rn(){Cn.point=Cn.lineEnd=Dr}function Bn(e,t){wn=e*=yr,Tn=Nr(t*=yr),Mn=_r(t),Cn.point=Pn}function Pn(e,t){e*=yr;var r=Nr(t*=yr),i=_r(t),n=br(e-wn),s=_r(n),a=i*Nr(n),o=Mn*r-Tn*i*s,l=Tn*r+Mn*i*s;_n.add(vr(Cr(a*a+o*o),l)),wn=e,Tn=r,Mn=i}var Dn=[null,null],In={type:"LineString",coordinates:Dn};function Fn(e,t){return Dn[0]=e,Dn[1]=t,function(e){return _n=new Ie,kr(e,Cn),+_n}(In)}var qn={Feature:function(e,t){return On(e.geometry,t)},FeatureCollection:function(e,t){for(var r=e.features,i=-1,n=r.length;++i0&&(n=Fn(e[s],e[s-1]))>0&&r<=n&&i<=n&&(r+i-n)*(1-Math.pow((r-i)/n,2))hr}).map(l)).concat(Ve(wr(s/d)*d,n,d).filter(function(e){return br(e%f)>hr}).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=jn(s,n,90),A=Wn(t,e,m),u=jn(o,a,90),h=Wn(i,r,m),g):m},g.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}()()}function $n(e,t){var r=e[0]*yr,i=e[1]*yr,n=t[0]*yr,s=t[1]*yr,a=_r(i),o=Nr(i),l=_r(s),A=Nr(s),u=a*_r(r),h=a*Nr(r),c=l*_r(n),d=l*Nr(n),p=2*Br(Cr(Pr(s-i)+a*l*Pr(n-r))),f=Nr(p),m=p?function(e){var t=Nr(e*=p)/f,r=Nr(p-e)/f,i=r*u+t*c,n=r*h+t*d,s=r*o+t*A;return[vr(n,i)*gr,vr(s,Cr(i*i+n*n))*gr]}:function(){return[r*gr,i*gr]};return m.distance=p,m}var Qn=e=>e,Xn=1/0,Yn=Xn,Zn=-Xn,Kn=Zn,Jn={point:function(e,t){eZn&&(Zn=e);tKn&&(Kn=t)},lineStart:Dr,lineEnd:Dr,polygonStart:Dr,polygonEnd:Dr,result:function(){var e=[[Xn,Yn],[Zn,Kn]];return Zn=Kn=-(Yn=Xn=1/0),e}};function es(e){return function(t){var r=new ts;for(var i in e)r[i]=e[i];return r.stream=t,r}}function ts(){}function rs(e,t,r){var i=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),null!=i&&e.clipExtent(null),kr(r,e.stream(Jn)),t(Jn.result()),null!=i&&e.clipExtent(i),e}function is(e,t,r){return rs(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)}ts.prototype={constructor:ts,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 ns=_r(30*yr);function ss(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=Cr(x*x+v*v+_*_),T=Br(_/=w),M=br(br(_)-1)t||br((g*C+y*R)/b-.5)>.3||a*c+o*d+l*p2?e[2]%360*yr:0,C()):[m*gr,g*gr,y*gr]},N.angle=function(e){return arguments.length?(b=e%360*yr,C()):b*gr},N.reflectX=function(e){return arguments.length?(x=e?-1:1,C()):x<0},N.reflectY=function(e){return arguments.length?(v=e?-1:1,C()):v<0},N.precision=function(e){return arguments.length?(a=ss(o,S=e*e),R()):Cr(S)},N.fitExtent=function(e,t){return is(N,e,t)},N.fitSize=function(e,t){return function(e,t,r){return is(e,[[0,0],t],r)}(N,e,t)},N.fitWidth=function(e,t){return function(e,t,r){return rs(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)}(N,e,t)},N.fitHeight=function(e,t){return function(e,t,r){return rs(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)}(N,e,t)},function(){return t=e.apply(this,arguments),N.invert=t.invert&&E,C()}}(function(){return e})()}function As(e,t){return[e,Sr(Rr((pr+t)/2))]}function us(e,t){var r=_r(t),i=1+_r(e)*r;return[r*Nr(e)/i,Nr(t)/i]}function hs(){return ls(us).scale(250).clipAngle(142)}function cs(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r2&&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:Fs(p/o)*o,g=180*((p+1===o?p+1:Fs((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},Os=new WeakMap,ks=new WeakMap,Us=new WeakMap,Vs=new WeakMap,zs=new WeakMap,Gs=new WeakMap,js=new WeakMap,Ws=new WeakMap,Hs=new WeakSet,$s=function(t){function r(t){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=ps(this,r),fs(n=i,s=Hs),s.add(n),gs(i,Os,void 0),gs(i,ks,void 0),gs(i,Us,void 0),gs(i,Vs,void 0),gs(i,zs,{}),gs(i,Gs,void 0),gs(i,js,void 0),gs(i,Ws,void 0),xs(i,"minLevel",void 0),xs(i,"maxLevel",void 0),xs(i,"thresholds",Ms(new Array(30)).map(function(e,t){return 8/Math.pow(2,t)})),xs(i,"curvatureResolution",5),xs(i,"tileMargin",0),xs(i,"clearTiles",function(){Object.values(ms(zs,i)).forEach(function(e){e.forEach(function(e){e.obj&&(i.remove(e.obj),Rs(e.obj),delete e.obj)})}),ys(zs,i,{})}),ys(Os,i,t),i.tileUrl=o,ys(ks,i,d),i.minLevel=A,i.maxLevel=h,i.level=0,i.add(ys(Ws,i,new e.Mesh(new e.SphereGeometry(.99*ms(Os,i),180,90),new e.MeshBasicMaterial({color:0})))),ms(Ws,i).visible=!1,ms(Ws,i).material.polygonOffset=!0,ms(Ws,i).material.polygonOffsetUnits=3,ms(Ws,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&&ws(e,t)}(r,t),bs(r,[{key:"tileUrl",get:function(){return ms(Us,this)},set:function(e){ys(Us,this,e),this.updatePov(ms(js,this))}},{key:"level",get:function(){return ms(Vs,this)},set:function(e){var t,r=this;ms(zs,this)[e]||ds(Hs,this,Qs).call(this,e);var i=ms(Vs,this);if(ys(Vs,this,e),e!==i&&void 0!==i){if(ms(Ws,this).visible=e>0,ms(zs,this)[e].forEach(function(e){return e.obj&&(e.obj.material.depthWrite=!0)}),ie)for(var n=e+1;n<=i;n++)ms(zs,this)[n]&&ms(zs,this)[n].forEach(function(e){e.obj&&(r.remove(e.obj),Rs(e.obj),delete e.obj)});ds(Hs,this,Xs).call(this)}}},{key:"updatePov",value:function(t){var r,i=this;if(t&&t instanceof e.Camera&&(ys(js,this,t),ys(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=Ts(e,2);return Bs(t[0],t[1],ms(Os,i))}).map(function(t){var r=t.x,i=t.y,n=t.z;return new e.Vector3(r,i,n)})}return r||(r=new e.Frustum,t.updateMatrix(),t.updateMatrixWorld(),r.setFromProjectionMatrix((new e.Matrix4).multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse))),n.hullPnts.some(function(e){return r.containsPoint(e.clone().applyMatrix4(i.matrixWorld))})}),this.tileUrl)){var n=(t.position.clone().distanceTo(this.getWorldPosition(new e.Vector3))-ms(Os,this))/ms(Os,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)),ds(Hs,this,Xs).call(this)}}}])}(e.Group);function Qs(e){var t=this;if(e>7)ms(zs,this)[e]=[];else{var r=ms(zs,this)[e]=Ls(e,ms(ks,this));r.forEach(function(e){return e.centroid=Bs(e.lat,e.lng,ms(Os,t))}),r.octree=Te().x(function(e){return e.centroid.x}).y(function(e){return e.centroid.y}).z(function(e){return e.centroid.z}).addAll(r)}}function Xs(){var t=this;if(this.tileUrl&&void 0!==this.level&&ms(zs,this).hasOwnProperty(this.level)&&(ms(Gs,this)||!(this.level>6))){var r=ms(zs,this)[this.level];if(ms(js,this)){var i=this.worldToLocal(ms(js,this).position.clone());if(r.octree){var n,s=this.worldToLocal(ms(js,this).position.clone()),a=3*(s.length()-ms(Os,this));r=(n=r.octree).findAllWithinRadius.apply(n,Ms(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/ms(Os,this)-1),A=l/Math.cos(Ps(o.lat)),u=[o.lng-A,o.lng+A],h=[o.lat+l,o.lat-l],c=Ts(qs(this.level,ms(ks,this),u[0],h[0]),2),d=c[0],p=c[1],f=Ts(qs(this.level,ms(ks,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[_]=Ls(this.level,ms(ks,this),x,v,x,v)[0],r.push(y[_])),b.push(y[_])}r=b}else r=Ls(this.level,ms(ks,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(ms(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,t.level);if(!r.obj){var A=l*(1-t.tileMargin),u=o*(1-t.tileMargin),h=Ps(s),c=Ps(-a),d=new e.Mesh(new e.SphereGeometry(ms(Os,t),Math.ceil(A/t.curvatureResolution),Math.ceil(u/t.curvatureResolution),Ps(90-A/2)+h,Ps(A),Ps(90-u/2)+c,Ps(u)),new e.MeshLambertMaterial);if(ms(ks,t)){var p=Ts([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=Ar().domain([1,0]).range([t,r]).clamp(!0),n=Ar().domain([Is(t),Is(r)]).range([1,0]).clamp(!0),s=function(e){return n(Is(i(e)))},a=e.array,o=0,l=a.length;o80*r){o=e[0],l=e[1];let t=o,i=l;for(let s=r;st&&(t=r),n>i&&(i=n)}A=Math.max(t-o,i-l),A=0!==A?32767/A:0}return Js(s,a,r,o,l,A,0),a}function Zs(e,t,r,i,n){let s;if(n===function(e,t,r,i){let n=0;for(let s=t,a=r-i;s0)for(let n=t;n=t;n-=i)s=ba(n/i|0,e[n],e[n+1],s);return s&&da(s,s.next)&&(xa(s),s=s.next),s}function Ks(e,t){if(!e)return e;t||(t=e);let r,i=e;do{if(r=!1,i.steiner||!da(i,i.next)&&0!==ca(i.prev,i,i.next))i=i.next;else{if(xa(i),i=t=i.prev,i===i.next)break;r=!0}}while(r||i!==t);return t}function Js(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=oa(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;e0||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?ta(e,i,n,s):ea(e))t.push(l.i,e.i,A.i),xa(e),e=A.next,o=A.next;else if((e=A)===o){a?1===a?Js(e=ra(Ks(e),t),t,r,i,n,s,2):2===a&&ia(e,t,r,i,n,s):Js(Ks(e),t,r,i,n,s,1);break}}}function ea(e){const t=e.prev,r=e,i=e.next;if(ca(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&&ua(n,o,s,l,a,A,p.x,p.y)&&ca(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function ta(e,t,r,i){const n=e.prev,s=e,a=e.next;if(ca(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=oa(d,p,t,r,i),y=oa(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&&ua(o,u,l,h,A,c,b.x,b.y)&&ca(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&&ua(o,u,l,h,A,c,x.x,x.y)&&ca(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&&ua(o,u,l,h,A,c,b.x,b.y)&&ca(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&&ua(o,u,l,h,A,c,x.x,x.y)&&ca(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function ra(e,t){let r=e;do{const i=r.prev,n=r.next.next;!da(i,n)&&pa(i,r,r.next,n)&&ga(i,n)&&ga(n,i)&&(t.push(i.i,r.i,n.i),xa(r),xa(r.next),r=e=n),r=r.next}while(r!==e);return Ks(r)}function ia(e,t,r,i,n,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&ha(a,e)){let o=ya(a,e);return a=Ks(a,a.next),o=Ks(o,o.next),Js(a,t,r,i,n,s,0),void Js(o,t,r,i,n,s,0)}e=e.next}a=a.next}while(a!==e)}function na(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 sa(e,t){const r=function(e,t){let r=t;const i=e.x,n=e.y;let s,a=-1/0;if(da(e,r))return r;do{if(da(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.x&&r.x>=l&&i!==r.x&&Aa(ns.x||r.x===s.x&&aa(s,r)))&&(s=r,u=t)}r=r.next}while(r!==o);return s}(e,t);if(!r)return t;const i=ya(r,e);return Ks(i,i.next),Ks(r,r.next)}function aa(e,t){return ca(e.prev,e,t.prev)<0&&ca(t.next,e,e.next)<0}function oa(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 la(e){let t=e,r=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(i-o)>=(r-a)*(t-o)&&(r-a)*(s-o)>=(n-a)*(i-o)}function ua(e,t,r,i,n,s,a,o){return!(e===a&&t===o)&&Aa(e,t,r,i,n,s,a,o)}function ha(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&&pa(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(ga(e,t)&&ga(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)&&(ca(e.prev,e,t.prev)||ca(e,t.prev,t))||da(e,t)&&ca(e.prev,e,e.next)>0&&ca(t.prev,t,t.next)>0)}function ca(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function da(e,t){return e.x===t.x&&e.y===t.y}function pa(e,t,r,i){const n=ma(ca(e,t,r)),s=ma(ca(e,t,i)),a=ma(ca(r,i,e)),o=ma(ca(r,i,t));return n!==s&&a!==o||(!(0!==n||!fa(e,r,t))||(!(0!==s||!fa(e,i,t))||(!(0!==a||!fa(r,e,i))||!(0!==o||!fa(r,t,i)))))}function fa(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 ma(e){return e>0?1:e<0?-1:0}function ga(e,t){return ca(e.prev,e,e.next)<0?ca(e,t,e.next)>=0&&ca(e,e.prev,t)>=0:ca(e,t,e.prev)<0||ca(e,e.next,t)<0}function ya(e,t){const r=va(e.i,e.x,e.y),i=va(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 ba(e,t,r,i){const n=va(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 xa(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 va(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function _a(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;re.length)&&(t=e.length);for(var r=0,i=Array(t);r1&&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*Fn(i,r)/Math.PI;if(n>e)for(var s=$n(r,i),a=r.length>2||i.length>2?Pt(r[2]||0,i[2]||0):null,o=a?function(e){return[].concat(Ca(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},Pa="undefined"!=typeof window&&window.THREE?window.THREE:{BufferGeometry:e.BufferGeometry,Float32BufferAttribute:e.Float32BufferAttribute},Da=(new Pa.BufferGeometry).setAttribute?"setAttribute":"addAttribute",Ia=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=Ta(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=Ea(e,1)[0];Fa(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=Ea(e,1)[0];Fa(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=Ea(e,2),n=t[0],s=t[1];Fa(r,n),s&&Fa(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:La(e[1],e[0],t+(e[2]||0)),indices:[]}]}function u(e,t){for(var r=_a([Ba(e,n).map(function(e){var r=Ea(e,3),i=r[0],n=r[1],s=r[2];return La(n,i,t+(void 0===s?0:s))})]).vertices,i=Math.round(r.length/3),s=[],a=1;a=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 La(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)]}var Oa=window.THREE?window.THREE:{BackSide:e.BackSide,BufferAttribute:e.BufferAttribute,Color:e.Color,Mesh:e.Mesh,ShaderMaterial:e.ShaderMaterial};var ka=function(e){function t(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.color,o=void 0===a?"gold":a,l=i.size,A=void 0===l?2:l,u=i.coefficient,h=void 0===u?.5:u,c=i.power,d=void 0===c?1:c,p=i.hollowRadius,f=void 0===p?0:p,m=i.backside,g=void 0===m||m;s(this,t),r=n(this,t);var y=function(e,t){for(var r=e.clone(),i=new Float32Array(3*e.attributes.position.count),n=0,s=i.length;n=2&&o.setY(e,t.getY(e)),n>=3&&o.setZ(e,t.getZ(e)),n>=4&&o.setW(e,t.getW(e));return o}var ja=Object.freeze({__proto__:null,computeMikkTSpaceTangents:function(t,r,i=!0){if(!r||!r.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!t.hasAttribute("position")||!t.hasAttribute("normal")||!t.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;r2&&(t[i++]=e.getZ(r));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}const s=t.index?t.toNonIndexed():t,a=r.generateTangents(n(s.attributes.position),n(s.attributes.normal),n(s.attributes.uv));if(i)for(let e=3;ee.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{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;ti&&A.add(t)}A.normalize(),f.setXYZ(t+e,A.x,A.y,A.z)}}return h.setAttribute("normal",f),h},toTrianglesDrawMode:function(t,r){if(r===e.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(r===e.TriangleFanDrawMode||r===e.TriangleStripDrawMode){let i=t.getIndex();if(null===i){const e=[],r=t.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t1&&(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=mo(e,360),t=mo(t,100),r=mo(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=fo(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 Ya(e,t,r){e=mo(e,255),t=mo(t,255),r=mo(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>1)+720)%360;--t;)i.h=(i.h+n)%360,s.push(Xa(i));return s}function ho(e,t){t=t||6;for(var r=Xa(e).toHsv(),i=r.h,n=r.s,s=r.v,a=[],o=1/t;t--;)a.push(Xa({h:i,s:n,v:s})),s=(s+o)%1;return a}Xa.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=fo(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=Za(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=Za(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=Ya(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Ya(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 Ka(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=[bo(Math.round(e).toString(16)),bo(Math.round(t).toString(16)),bo(Math.round(r).toString(16)),bo(vo(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*mo(this._r,255))+"%",g:Math.round(100*mo(this._g,255))+"%",b:Math.round(100*mo(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*mo(this._r,255))+"%, "+Math.round(100*mo(this._g,255))+"%, "+Math.round(100*mo(this._b,255))+"%)":"rgba("+Math.round(100*mo(this._r,255))+"%, "+Math.round(100*mo(this._g,255))+"%, "+Math.round(100*mo(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(po[Ka(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+Ja(this._r,this._g,this._b,this._a),r=t,i=this._gradientType?"GradientType = 1, ":"";if(e){var n=Xa(e);r="#"+Ja(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 Xa(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(io,arguments)},brighten:function(){return this._applyModification(no,arguments)},darken:function(){return this._applyModification(so,arguments)},desaturate:function(){return this._applyModification(eo,arguments)},saturate:function(){return this._applyModification(to,arguments)},greyscale:function(){return this._applyModification(ro,arguments)},spin:function(){return this._applyModification(ao,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(uo,arguments)},complement:function(){return this._applyCombination(oo,arguments)},monochromatic:function(){return this._applyCombination(ho,arguments)},splitcomplement:function(){return this._applyCombination(Ao,arguments)},triad:function(){return this._applyCombination(lo,[3])},tetrad:function(){return this._applyCombination(lo,[4])}},Xa.fromRatio=function(e,t){if("object"==Ha(e)){var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]="a"===i?e[i]:xo(e[i]));e=r}return Xa(e,t)},Xa.equals=function(e,t){return!(!e||!t)&&Xa(e).toRgbString()==Xa(t).toRgbString()},Xa.random=function(){return Xa.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Xa.mix=function(e,t,r){r=0===r?0:r||50;var i=Xa(e).toRgb(),n=Xa(t).toRgb(),s=r/100;return Xa({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})}, // =4.5;break;case"AAlarge":n=s>=3;break;case"AAAsmall":n=s>=7}return n},Xa.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;Al&&(l=i,o=Xa(t[A]));return Xa.isReadable(e,o,{level:s,size:a})||!n?o:(r.includeFallbackColors=!1,Xa.mostReadable(e,["#fff","#000"],r))};var co=Xa.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"},po=Xa.hexNames=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}(co);function fo(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function mo(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 go(e){return Math.min(1,Math.max(0,e))}function yo(e){return parseInt(e,16)}function bo(e){return 1==e.length?"0"+e:""+e}function xo(e){return e<=1&&(e=100*e+"%"),e}function vo(e){return Math.round(255*parseFloat(e)).toString(16)}function _o(e){return yo(e)/255}var wo,To,Mo,So=(To="[\\s|\\(]+("+(wo="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+wo+")[,|\\s]+("+wo+")\\s*\\)?",Mo="[\\s|\\(]+("+wo+")[,|\\s]+("+wo+")[,|\\s]+("+wo+")[,|\\s]+("+wo+")\\s*\\)?",{CSS_UNIT:new RegExp(wo),rgb:new RegExp("rgb"+To),rgba:new RegExp("rgba"+Mo),hsl:new RegExp("hsl"+To),hsla:new RegExp("hsla"+Mo),hsv:new RegExp("hsv"+To),hsva:new RegExp("hsva"+Mo),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 No(e){return!!So.CSS_UNIT.exec(e)}var Eo=function(e){return isNaN(e)?parseInt(Xa(e).toHex(),16):e},Co=function(e){return e&&isNaN(e)?ot(e).opacity:1},Ro=function(t){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(t.trim().toLowerCase());if(a){var o=v(a.slice(1),4),l=o[0],A=o[1],u=o[2],h=o[3];r=new e.Color("rgb(".concat(+l,",").concat(+A,",").concat(+u,")")),s=Math.min(+h,1)}else r=new e.Color(t);n&&r.convertLinearToSRGB();var c=r.toArray();return i?[].concat(w(c),[s]):c};var Bo=window.THREE?window.THREE:{BufferAttribute:e.BufferAttribute};function Po(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 Bo.BufferAttribute(new r(e),t);for(var i=new Bo.BufferAttribute(new r(e.length*t),t),n=0,s=e.length;ne.length)&&(t=e.length);for(var r=0,i=Array(t);r1&&void 0!==arguments[1]?arguments[1]:{},a=i.dataBindAttr,A=void 0===a?"__data":a,u=i.objBindAttr,c=void 0===u?"__threeObj":u,d=i.removeDelay,p=void 0===d?0:d;return s(this,t),h(r=n(this,t),"scene",void 0),o(r,Yo,void 0),o(r,Zo,void 0),o(r,Ko,void 0),r.scene=e,l(Yo,r,A),l(Zo,r,c),l(Ko,r,p),r.onRemoveObj(function(){}),r}return p(t,e),u(t,[{key:"onCreateObj",value:function(e){var r=this;return _(t,"onCreateObj",this)([function(t){var i=e(t);return t[a(Zo,r)]=i,i[a(Yo,r)]=t,r.scene.add(i),i}]),this}},{key:"onRemoveObj",value:function(e){var r=this;return _(t,"onRemoveObj",this)([function(i,n){var s=_(t,"getData",r)([i]);e(i,n);var o=function(){r.scene.remove(i),he(i),delete s[a(Zo,r)]};a(Ko,r)?setTimeout(o,a(Ko,r)):o()}]),this}}])}(Xo),el=window.THREE?window.THREE:{BufferGeometry:e.BufferGeometry,CylinderGeometry:e.CylinderGeometry,Matrix4:e.Matrix4,Mesh:e.Mesh,MeshLambertMaterial:e.MeshLambertMaterial,Object3D:e.Object3D,Vector3:e.Vector3},tl=Object.assign({},ja),rl=tl.BufferGeometryUtils||tl,il=ee({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;he(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new Jo(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var r=Wa(e.pointLat),i=Wa(e.pointLng),n=Wa(e.pointAltitude),s=Wa(e.pointRadius),a=Wa(e.pointColor),o=new el.CylinderGeometry(1,1,1,e.pointResolution);o.applyMatrix4((new el.Matrix4).makeRotationX(Math.PI/2)),o.applyMatrix4((new el.Matrix4).makeTranslation(0,0,-.5));var l=2*Math.PI*de/360,A={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&he(e.scene),e.dataMapper.scene=e.pointsMerge?new el.Object3D:e.scene,e.dataMapper.onCreateObj(function(){var e=new el.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,fe(a,o));var A=e.pointsMerge?new el.Vector3(0,0,0):e.scene.localToWorld(new el.Vector3(0,0,0));t.lookAt(A),t.scale.x=t.scale.y=Math.min(30,n)*l,t.scale.z=Math.max(s*de,.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 oe(c).to(h,e.pointsTransitionDuration).easing(te.Quadratic.InOut).onUpdate(u).onComplete(function(){e.tweenGroup.remove(this)}).start()));if(!e.pointsMerge){var d=a(o),p=d?Co(d):0,f=!!p;t.visible=f,f&&(A.hasOwnProperty(d)||(A[d]=new el.MeshLambertMaterial({color:Eo(d),transparent:p<1,opacity:p})),t.material=A[d])}}).digest(e.pointsData),e.pointsMerge){var u=e.pointsData.length?(rl.mergeGeometries||rl.mergeBufferGeometries)(e.pointsData.map(function(t){var r=e.dataMapper.getObj(t),i=r.geometry.clone();r.updateMatrix(),i.applyMatrix4(r.matrix);var n=Ro(a(t));return i.setAttribute("color",Po(Array(i.getAttribute("position").count).fill(n),4)),i})):new el.BufferGeometry,h=new el.Mesh(u,new el.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));h.__globeObjType="points",h.__data=e.pointsData,e.dataMapper.clear(),he(e.scene),e.scene.add(h)}}});function nl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var sl,al={exports:{}};var ol=(sl||(sl=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 dashSize) discard;\n \n // set px color: [r, g, b, a], interpolated between vertices \n gl_FragColor = vColor; \n \n ").concat(e.ShaderChunk.logdepthbuf_fragment,"\n }\n ")}},ul=function(e){return e.uniforms.uSurfaceRadius={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 uSurfaceRadius;\nvarying float vSurfaceRadius;\nvarying vec3 vPos;\n"+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join("\n")),e},hl=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},cl=function(e,t){return e.onBeforeCompile=function(r){e.userData.shader=t(r)},e},dl=["stroke"],pl=window.THREE?window.THREE:{BufferGeometry:e.BufferGeometry,CubicBezierCurve3:e.CubicBezierCurve3,Curve:e.Curve,Group:e.Group,Line:e.Line,Mesh:e.Mesh,NormalBlending:e.NormalBlending,ShaderMaterial:e.ShaderMaterial,TubeGeometry:e.TubeGeometry,Vector3:e.Vector3},fl=ll.default||ll,ml=ee({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 fl,sharedMaterial:new pl.ShaderMaterial(g(g({},Al()),{},{transparent:!0,blending:pl.NormalBlending}))}},init:function(e,t){he(e),t.scene=e,t.dataMapper=new Jo(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var e=new pl.Group;return e.__globeObjType="arc",e}),t.ticker.onTick.add(function(e,r){t.dataMapper.entries().map(function(e){return v(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=Wa(e.arcStartLat),r=Wa(e.arcStartLng),i=Wa(e.arcStartAltitude),n=Wa(e.arcEndLat),s=Wa(e.arcEndLng),a=Wa(e.arcEndAltitude),o=Wa(e.arcAltitude),l=Wa(e.arcAltitudeAutoScale),u=Wa(e.arcStroke),h=Wa(e.arcColor),c=Wa(e.arcDashLength),d=Wa(e.arcDashGap),p=Wa(e.arcDashInitialGap),f=Wa(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(m,g){var y=u(g),b=null!=y;if(!m.children.length||b!==("Mesh"===m.children[0].type)){he(m);var x=b?new pl.Mesh:new pl.Line(new pl.BufferGeometry);x.material=e.sharedMaterial.clone(),m.add(x)}var _=m.children[0];Object.assign(_.material.uniforms,{dashSize:{value:c(g)},gapSize:{value:d(g)},dashOffset:{value:p(g)}});var T=f(g);_.__dashAnimateStep=T>0?1e3/T:0;var M=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?Ar().domain(e.map(function(t,r){return r/(e.length-1)})).range(e):e;r=function(e){return Ro(s(e),!0,!0)}}else{var a=Ro(e,!0,!0);r=function(){return a}}for(var o=[],l=0,A=n;l1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[],n=0,s=e+1;nA==u>-A?(s=A,A=t[++h]):(s=u,u=i[++c]);let d=0;if(hA==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);hA==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=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,N=t-s,E=i-s;x=M*E,c=gl*M,d=c-(c-M),p=M-d,c=gl*E,f=c-(c-E),m=E-f,v=p*m-(x-d*f-p*f-d*m),_=N*S,c=gl*N,d=c-(c-N),p=N-d,c=gl*S,f=c-(c-S),m=S-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,xl[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,xl[1]=b-(g+h)+(h-_),T=y+g,h=T-y,xl[2]=y-(T-h)+(g-h),xl[3]=T;let C=function(e,t){let r=t[0];for(let i=1;i=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-N,l=t-(N+h)+(h-s),h=i-E,u=i-(E+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+E*o-(N*A+S*l),C>=R||-C>=R)return C;x=o*E,c=gl*o,d=c-(c-o),p=o-d,c=gl*E,f=c-(c-E),m=E-f,v=p*m-(x-d*f-p*f-d*m),_=l*S,c=gl*l,d=c-(c-l),p=l-d,c=gl*S,f=c-(c-S),m=S-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,Tl[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,Tl[1]=b-(g+h)+(h-_),T=y+g,h=T-y,Tl[2]=y-(T-h)+(g-h),Tl[3]=T;const B=yl(4,xl,4,Tl,vl);x=M*u,c=gl*M,d=c-(c-M),p=M-d,c=gl*u,f=c-(c-u),m=u-f,v=p*m-(x-d*f-p*f-d*m),_=N*A,c=gl*N,d=c-(c-N),p=N-d,c=gl*A,f=c-(c-A),m=A-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,Tl[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,Tl[1]=b-(g+h)+(h-_),T=y+g,h=T-y,Tl[2]=y-(T-h)+(g-h),Tl[3]=T;const P=yl(B,vl,4,Tl,_l);x=o*u,c=gl*o,d=c-(c-o),p=o-d,c=gl*u,f=c-(c-u),m=u-f,v=p*m-(x-d*f-p*f-d*m),_=l*A,c=gl*l,d=c-(c-l),p=l-d,c=gl*A,f=c-(c-A),m=A-f,w=p*m-(_-d*f-p*f-d*m),g=v-w,h=v-g,Tl[0]=v-(g+h)+(h-w),y=x+g,h=y-x,b=x-(y-h)+(g-h),g=b-_,h=b-g,Tl[1]=b-(g+h)+(h-_),T=y+g,h=T-y,Tl[2]=y-(T-h)+(g-h),Tl[3]=T;const D=yl(P,_l,4,Tl,wl);return wl[D-1]}(e,t,r,i,n,s,A)}const Sl=Math.pow(2,-52),Nl=new Uint32Array(512);class El{static from(e,t=Il,r=Fl){const i=e.length,n=new Float64Array(2*i);for(let s=0;s>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;tl&&(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;t0&&(d=t,r=i)}let g=e[2*d],y=e[2*d+1],b=1/0;for(let t=0;ti&&(t[r++]=n,i=s)}return this.hull=t.subarray(0,r),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(Ml(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;t0&&Math.abs(A-s)<=Sl&&Math.abs(u-a)<=Sl)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=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],Ml(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],Ml(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;e0?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=Nl[--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(Rl(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=r&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=i}else{let n=r+1,s=i;Dl(e,r+i>>1,n),t[e[r]]>t[e[i]]&&Dl(e,r,i),t[e[n]]>t[e[i]]&&Dl(e,n,i),t[e[r]]>t[e[n]]&&Dl(e,r,n);const a=e[n],o=t[a];for(;;){do{n++}while(t[e[n]]o);if(s=s-r?(Pl(e,t,n,i),Pl(e,t,r,s-1)):(Pl(e,t,r,s-1),Pl(e,t,n,i))}}function Dl(e,t,r){const i=e[t];e[t]=e[r],e[r]=i}function Il(e){return e[0]}function Fl(e){return e[1]}function ql(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=0||s<=0&&o>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(0===(n=Ml(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 Ll=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;uOl||Math.abs(this._y1-n)>Ol)&&(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 Ul{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 Vl{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;l1;)n-=2;for(let e=2;e0){if(t>=this.ymax)return null;(n=(this.ymax-t)/i)0){if(e>=this.xmax)return null;(n=(this.xmax-e)/r)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t2&&function(e){const{triangles:t,coords:r}=e;for(let e=0;e1e-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;e0&&(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 Vl(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=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=Gl(t-l[2*e],2)+Gl(r-l[2*e+1],2);const h=i[e];let c=h;do{let i=o[c];const h=Gl(t-l[2*i],2)+Gl(r-l[2*i+1],2);if(h0?1:e<0?-1:0},nA=Math.sqrt;function sA(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function aA(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 oA(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function lA(e){var t=nA(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function AA(e){return[Kl(e[1],e[0])*Yl,(t=eA(-1,tA(1,e[2])),(t>1?Xl:t<-1?-Xl:Math.asin(t))*Yl)];var t}function uA(e){const t=e[0]*Zl,r=e[1]*Zl,i=Jl(r);return[i*Jl(t),i*rA(t),rA(r)]}function hA(e){return sA((e=e.map(e=>uA(e)))[0],aA(e[2],e[1]))}function cA(e){const t=function(e){if(e.length<2)return{};let t=0;for(;isNaN(e[t][0]+e[t][1])&&t++2?e[2]*yr:0),t.invert=function(t){return(t=e.invert(t[0]*yr,t[1]*yr))[0]*=gr,t[1]*=gr,t},t}(e[t]),i=hs().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;t1e32?n.push(t):r>s&&(s=r)}const a=1e6*nA(s);n.forEach(t=>e[t]=[a,0]),e.push([0,a]),e.push([-a,0]),e.push([0,-a]);const o=$l.from(e);o.projection=i;const{triangles:l,halfedges:A,inedges:u}=o;for(let r=0,i=A.length;re.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{if(e[0]!==e[1]&&!(hA(e.map(e=>t[e]))<0))for(let t,i=0;i<3;i++)t=(i+1)%3,r.add(De([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=uA([i,n]);do{a=s,s=null,o=r(A,uA(t[a])),e[a].forEach(e=>{let i=r(A,uA(t[e]));if(i{const r=e.map(e=>t[e]).map(uA);return AA(lA(oA(oA(aA(r[1],r[0]),aA(r[2],r[1])),aA(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=uA(r[0]),t=uA(r[1]),s=lA(oA(e,t)),o=lA(aA(e,t)),l=aA(s,o),A=[s,aA(s,l),aA(aA(s,l),l),aA(aA(aA(s,l),l),l)].map(AA).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;r2)return t;if(2==t.length){const i=dA(r[e[0][3][0]],r[e[0][3][1]],n[t[0]]),s=dA(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(!(hA(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=De([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 dA(e,t,r){e=uA(e),t=uA(t),r=uA(r);const i=iA(sA(aA(t,e),r));return AA(lA(oA(e,t)).map(e=>i*e))}function pA(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r1&&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*Fn(e,r)/Math.PI;if(n>t)for(var s=$n(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=Ue(i),s=function(e,t){var r={type:"Polygon",coordinates:e},i=Gi(r),n=bA(i,2),s=bA(n[0],2),a=s[0],o=s[1],l=bA(n[1],2),A=l[0],u=l[1];if(Math.min(Math.abs(A-a),Math.abs(u-o))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 wA(e,r,h)})}(e,r),a=[].concat(xA(n),xA(s)),o={type:"Polygon",coordinates:e},l=bA(Gi(o),2),A=bA(l[0],2),u=A[0],h=A[1],c=bA(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=cA(t.points)}return t};return t._vx=function(e){return"object"==typeof e&&"type"in e?tn(e)[0]:0 in e?e[0]:void 0},t._vy=function(e){return"object"==typeof e&&"type"in e?tn(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=>hA(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=>Fn(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;ai&&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||Fn([e,r],t.points[t._found])i[e]),i[r[0]]]]}},e?t(e):t}(a).triangles(),y=new Map(a.map(function(e,t){var r=bA(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=bA(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=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(!wA(s,o,f))return 1}(t=m).push.apply(t,xA(r))},v=0,_=b.triangles.length;v<_;v+=3)x(v);else{var w=_a(i),T=w.vertices,M=w.holes;m=Ys(T,void 0===M?[]:M,2)}var S=Ar(De(a,function(e){return e[0]}),[0,1]),N=Ar(De(a,function(e){return e[1]}),[0,1]),E=a.map(function(e){var t=bA(e,2),r=t[0],i=t[1];return[S(r),N(i)]});return{contour:i,triangles:{points:a,indices:m,uvs:E}}}function wA(e,t){return arguments.length>2&&void 0!==arguments[2]&&arguments[2]?function(e,t){return(e&&qn.hasOwnProperty(e.type)?qn[e.type]:On)(e,t)}(t,e):Ll(e,t)}var TA=window.THREE?window.THREE:{BufferGeometry:e.BufferGeometry,Float32BufferAttribute:e.Float32BufferAttribute},MA=(new TA.BufferGeometry).setAttribute?"setAttribute":"addAttribute",SA=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=fA(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=_A(e,{resolution:o=o||5}),u=A.contour,h=A.triangles,c=Ue(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=bA(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 _a(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=Ue([s,t]),o=Math.round(s.length/3),l=new Set(n),A=0,h=[],c=0;c=0;m--)for(var g=0;ge.length)&&(t=e.length);for(var r=0,i=Array(t);r0&&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;i1&&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=EA(t,2),n=i[0],s=i[1];return e(s,[].concat(CA(r),[n]))})}(s),t instanceof Array&&0===t.length&&1===a.length&&(a[0].keys=[])),a},DA=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=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);)++n;if(n-t>16&&e.subarray&&C)return C.decode(e.subarray(t,n));for(var s="";t>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=N=new Float32Array(e),r.HEAPF64=E=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var D=r.TOTAL_MEMORY||33554432;function I(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()}}D=(_=r.buffer?r.buffer:new ArrayBuffer(D)).byteLength,P(_),S[7156]=5271536;var F=[],q=[],L=[],O=[];function k(e){F.unshift(e)}function U(e){O.unshift(e)}var V=Math.abs,z=Math.ceil,G=Math.floor,j=Math.min,W=0,H=null;r.preloadedImages={},r.preloadedAudios={};var $,Q,X=null,Y="data:application/octet-stream;base64,";function Z(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+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";function K(){return w.length}function J(e){for(var t=[],r=0;r255&&(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=0){if((0|r)>13780509){if(0|(o=0|ft(15,l)))break;l=0|n[(A=l)>>2],A=0|n[A+4>>2]}else u=0|ar(0|r,0|(o=((0|r)<0)<<31>>31),3,0),A=0|M(),o=0|tr(0|r,0|o,1,0),o=0|tr(0|(o=0|ar(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(gr(0|i,0,l<<3),0|s){gr(0|s,0,l<<2),o=0|q(e,t,r,i,s,l,A,0);break}(o=0|er(l,4))?(u=0|q(e,t,r,i,o,l,A,0),Jt(o),o=u):o=13}else o=2}while(0);return P=a,0|(u=o)}function F(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|He(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|L(l,t,4,m,a)))break e;if(0|He(l=0|n[(t=a)>>2],t=0|n[t+4>>2])){l=9;break e}}if(0|(l=0|L(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|He(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|L(l,t,4,m,a)))break e;if(0|He(l=0|n[(t=a)>>2],t=0|n[t+4>>2])){l=9;break e}}if(0|(l=0|L(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|He(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 q(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|lr(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|or(0|(c=0|tr(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|L(e,t,2,A,u))){case 9:m=9;break;case 0:(c=0|q(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|L(e,t,3,A,u))){case 9:break;case 0:if(0|(c=0|q(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|L(e,t,1,A,u))){case 9:break;case 0:if(0|(c=0|q(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|L(e,t,5,A,u))){case 9:break;case 0:if(0|(c=0|q(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|L(e,t,4,A,u))){case 9:break;case 0:if(0|(c=0|q(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|L(e,t,6,A,u))){case 9:break;case 0:if(0|(c=0|q(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 L(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|ve(r),l=l+1|0}while((0|l)<(0|n[i>>2]))}if(c=0|ur(0|e,0|t,45),M(),(o=127&c)>>>0>121)return 0|(s=5);a=0|Xe(e,t),l=0|ur(0|e,0|t,52),M(),l&=15;e:do{if(l){for(;;){if(u=0|ur(0|e,0|t,0|(A=3*(15-l|0)|0)),M(),7==(0|(u&=7))){t=5;break}if(p=!(0|et(l)),l=l+-1|0,d=0|hr(7,0,0|A),t&=~M(),e=0|hr(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|hr(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|hr(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|Ze(p|e,t),t=0|M(),n[i>>2]=1+(0|n[i>>2]))),u=0|ur(0|e,0|t,45),M(),u&=127;e:do{if(0|z(u)){t:do{if(1==(0|Xe(e,t))){if((0|o)!=(0|u)){if(0|H(u,0|n[7696+(28*o|0)>>2])){e=0|Je(e,t),A=1,t=0|M();break}S(27795,26864,533,26872)}switch(0|a){case 3:e=0|Ze(e,t),t=0|M(),n[i>>2]=1+(0|n[i>>2]),A=0;break t;case 5:e=0|Je(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|Ye(e,t),t=0|M(),l=l+1|0}while((0|l)!=(0|r))}if((0|o)!=(0|u)){if(!(0|G(u))){if(!!(0|A)|5!=(0|Xe(e,t)))break;n[i>>2]=1+(0|n[i>>2]);break}switch(127&c){case 8:case 118:break e}3!=(0|Xe(e,t))&&(n[i>>2]=1+(0|n[i>>2]))}}else if((0|r)>0){l=0;do{e=0|Ze(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 O(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,(0|r)<0)return P=a,0|(f=2);if(!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|He(e,t))e=9;else{o=0,p=e;do{if(0|(e=0|L(p,t,4,f,s)))break e;if(o=o+1|0,0|He(p=0|n[(t=s)>>2],t=0|n[t+4>>2])){e=9;break e}}while((0|o)<(0|r));n[(d=i)>>2]=p,n[d+4>>2]=t,d=r+-1|0,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|L(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|He(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|L(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|He(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);e=(0|p)==(0|n[(e=s)>>2])&&(0|t)==(0|n[e+4>>2])?0:9}}while(0);return P=a,0|(f=e)}function k(e,t,r,i){e|=0,t|=0,i|=0;var s,a=0,o=0,l=0,A=0,u=0,h=0,c=0,d=0;if(s=P,P=P+16|0,l=s,!(r|=0))return n[i>>2]=e,n[i+4>>2]=t,P=s,0|(i=0);do{if((0|r)>=0){if((0|r)>13780509){if(0|(a=0|ft(15,l)))break;a=0|n[(o=l)>>2],o=0|n[o+4>>2]}else c=0|ar(0|r,0|(a=((0|r)<0)<<31>>31),3,0),o=0|M(),a=0|tr(0|r,0|a,1,0),a=0|tr(0|(a=0|ar(0|c,0|o,0|a,0|M())),0|M(),1,0),o=0|M(),n[(c=l)>>2]=a,n[c+4>>2]=o;if(h=0|er(a,8)){if(!(c=0|er(a,4))){Jt(h),a=13;break}if(0|(a=0|q(e,t,r,h,c,a,o,0))){Jt(h),Jt(c);break}if(t=0|n[l>>2],(0|(l=0|n[l+4>>2]))>0|!(0|l)&t>>>0>0){a=0,A=0,u=0;do{!(0|(o=0|n[(e=h+(A<<3)|0)>>2]))&!(0|(e=0|n[e+4>>2]))||(0|n[c+(A<<2)>>2])!=(0|r)||(n[(d=i+(a<<3)|0)>>2]=o,n[d+4>>2]=e,a=a+1|0),A=0|tr(0|A,0|u,1,0),u=0|M()}while((0|u)<(0|l)|(0|u)==(0|l)&A>>>0>>0)}Jt(h),Jt(c),a=0}else a=13}else a=2}while(0);return P=s,0|(d=a)}function U(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|He(e|=0,t|=0)))?1:2;;){if(n[a>>2]=0,!(0|L(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 V(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,N=0,E=0,C=0,R=0,B=0,D=0,I=0,F=0,q=0,L=0,O=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|(F=0);for(h=e+4|0,c=f+8|0,d=m+8|0,p=A+8|0,b=0,D=0;;){B=(v=0|n[h>>2])+(D<<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|D)==(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+(D+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|ie(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(L=1/(+(v>>>0)+4294967296*+(0|x)),k=+s[f>>3],O=+((x=0|rr(0|v,0|x,0|R,0|B))>>>0)+4294967296*+(0|M()),q=+(R>>>0)+4294967296*+(0|B),s[A>>3]=L*(k*O)+L*(+s[m>>3]*q),s[p>>3]=L*(+s[c>>3]*O)+L*(+s[d>>3]*q),0|(x=0|tt(A,i,u))){b=x;break}T=0|lr(0|(E=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))I=x,F=16;else for(S=0,N=0;;){if((0|S)>(0|r)|(0|S)==(0|r)&N>>>0>t>>>0){b=1;break t}if((0|v)==(0|E)&(0|w)==(0|C))break r;if(T=0|or(0|(x=0|tr(0|T,0|_,1,0)),0|M(),0|t,0|r),_=0|M(),N=0|tr(0|N,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]))){I=x,F=16;break}}}while(0);if(16!=(0|F)||(F=0,!(0|E)&!(0|C))||(n[(N=I)>>2]=E,n[N+4>>2]=C,N=o+(n[a>>2]<<3)|0,n[N>>2]=E,n[N+4>>2]=C,N=0|tr(0|n[(N=a)>>2],0|n[N+4>>2],1,0),E=0|M(),n[(C=a)>>2]=N,n[C+4>>2]=E),R=0|tr(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(D=D+1|0,!v){F=21;break}if((0|D)>=(0|(x=0|n[e>>2]))){b=0,F=21;break}}return 21==(0|F)?(P=y,0|b):0}function z(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|n[7696+(28*e|0)+16>>2])}function G(e){return 4==(0|(e|=0))|117==(0|e)|0}function j(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 W(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 H(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 $(e,t){return 0|n[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function Q(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 X(e){var t,r,i;return t=(i=+s[(e|=0)+16>>3])-(r=+s[e+24>>3]),+(i>3]<+s[e+24>>3]|0}function Z(e){return+(+s[(e|=0)>>3]-+s[e+8>>3])}function K(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>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>3],t)||(h=+ct(+s[r>>3],e))>+ct(+s[l>>3],t)?0|(u=0):0|(u=1))}function ee(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>3],t)?0|(u=(h=+ct(+s[l>>3],e))>=+ct(+s[r>>3],t)):0|(u=0))}function te(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));mr(0|e,0|i,168),P=a}function re(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|at(t,g))?(P=d,0|(_=t)):(nt(g=0|n[(m=g)>>2],m=0|n[m+4>>2],c),st(g,m,y),h=+dt(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=+dt(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=+dr(+u,+i),w=+b(+o*o/+pr(+w/+pr(+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 ie(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|at(r,p))?(P=c,0|(i=r)):(nt(d=0|n[(r=p)>>2],r=0|n[r+4>>2],u),st(d,r,h),f=+dt(u,h+8|0),f=+b(+ +dt(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 ne(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 se(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>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|rr(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|rr(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 ae(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 oe(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 le(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 Ae(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 ue(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 he(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 ce(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|Zt(.14285714285714285*+(i-A|0)),n[e>>2]=a,o=0|Zt(.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 de(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|Zt(.14285714285714285*+(r+a|0)),n[e>>2]=s,a=0|Zt(.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 pe(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|Zt(.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|Zt(.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 fe(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|Zt(.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|Zt(.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 me(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 ge(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 ye(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 be(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 xe(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 ve(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 _e(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 we(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 Te(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 Me(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 Se(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 Ne(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 Ee(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 Ce(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 Re(e,t){var r=0;switch(r=0|ur(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|He(e,r))?0|(r=0):0|(r=0|ze(e,r)):0|(r=0)}function Be(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|ur(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|He(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|Vt(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|it(e,o,i)&&S(27795,26932,282,26947),t=0|ur(0|e,0|t,52),M(),t&=15,0|He(e,o)?Fe(i,t,a,2,r):ke(i,t,a,2,r),P=s,0|(o=0))):(P=s,0|(o=6))}function Pe(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=+Ut(16400,a),i<+s[r>>3]&&(n[t>>2]=0,s[r>>3]=i);i=+Ut(16424,a),i<+s[r>>3]&&(n[t>>2]=1,s[r>>3]=i);i=+Ut(16448,a),i<+s[r>>3]&&(n[t>>2]=2,s[r>>3]=i);i=+Ut(16472,a),i<+s[r>>3]&&(n[t>>2]=3,s[r>>3]=i);i=+Ut(16496,a),i<+s[r>>3]&&(n[t>>2]=4,s[r>>3]=i);i=+Ut(16520,a),i<+s[r>>3]&&(n[t>>2]=5,s[r>>3]=i);i=+Ut(16544,a),i<+s[r>>3]&&(n[t>>2]=6,s[r>>3]=i);i=+Ut(16568,a),i<+s[r>>3]&&(n[t>>2]=7,s[r>>3]=i);i=+Ut(16592,a),i<+s[r>>3]&&(n[t>>2]=8,s[r>>3]=i);i=+Ut(16616,a),i<+s[r>>3]&&(n[t>>2]=9,s[r>>3]=i);i=+Ut(16640,a),i<+s[r>>3]&&(n[t>>2]=10,s[r>>3]=i);i=+Ut(16664,a),i<+s[r>>3]&&(n[t>>2]=11,s[r>>3]=i);i=+Ut(16688,a),i<+s[r>>3]&&(n[t>>2]=12,s[r>>3]=i);i=+Ut(16712,a),i<+s[r>>3]&&(n[t>>2]=13,s[r>>3]=i);i=+Ut(16736,a),i<+s[r>>3]&&(n[t>>2]=14,s[r>>3]=i);i=+Ut(16760,a),i<+s[r>>3]&&(n[t>>2]=15,s[r>>3]=i);i=+Ut(16784,a),i<+s[r>>3]&&(n[t>>2]=16,s[r>>3]=i);i=+Ut(16808,a),i<+s[r>>3]&&(n[t>>2]=17,s[r>>3]=i);i=+Ut(16832,a),i<+s[r>>3]&&(n[t>>2]=18,s[r>>3]=i);if(i=+Ut(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=+ut((o=+s[15920+(24*u|0)>>3])-+ut(+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|et(t)?+ut(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 De(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|et(r)),l=+g(.381966011250105*(r?o:.37796447300922725*o))):(l=+g(.381966011250105*l),0|et(r)&&(h=+ut(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,+ut(+s[15920+(24*t|0)>>3]-h),l,a)}function Ie(e,t,r){t|=0,r|=0;var i,s;i=P,P=P+16|0,oe((e|=0)+4|0,s=i),De(s,0|n[e>>2],t,0,r),P=i}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,N,E,C,R=0,B=0,D=0,I=0,F=0,q=0;if(C=P,P=P+272|0,I=C+240|0,M=C,N=C+224|0,E=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[I>>2]=n[e>>2],n[I+4>>2]=n[e+4>>2],n[I+8>>2]=n[e+8>>2],n[I+12>>2]=n[e+12>>2],qe(I,R,M),n[a>>2]=0,(0|(I=i+r+(5==(0|i)&1)|0))<=(0|r))P=C;else{l=N+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=E+4|0,D=r;e:for(;;){B=M+((0|D)%5<<4)|0,n[E>>2]=n[B>>2],n[E+4>>2]=n[B+4>>2],n[E+8>>2]=n[B+8>>2],n[E+12>>2]=n[B+12>>2];do{}while(2==(0|Le(E,o,0,1)));if((0|D)>(0|r)&!!(0|et(t))){if(n[g>>2]=n[E>>2],n[g+4>>2]=n[E+4>>2],n[g+8>>2]=n[E+8>>2],n[g+12>>2]=n[E+12>>2],oe(l,y),i=0|n[g>>2],R=0|n[17040+(80*i|0)+(n[N>>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{be(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],ue(b,3*(0|n[h>>2])|0),le(A,b,A),ae(A),oe(A,x),F=+(0|n[c>>2]),s[v>>3]=3*F,s[d>>3]=0,q=-1.5*F,s[_>>3]=q,s[p>>3]=2.598076211353316*F,s[w>>3]=q,s[f>>3]=-2.598076211353316*F,0|n[17040+(80*(0|n[g>>2])|0)+(n[E>>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}Ot(y,x,i,e,T),De(T,0|n[g>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2])}if((0|D)<(0|u)&&(oe(m,g),De(g,0|n[E>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2])),n[N>>2]=n[E>>2],n[N+4>>2]=n[E+4>>2],n[N+8>>2]=n[E+8>>2],n[N+12>>2]=n[E+12>>2],(0|(D=D+1|0))>=(0|I)){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|et(0|n[t>>2])))?s:a,we(a=e+4|0),Te(a),0|et(0|n[t>>2])&&(ge(a),n[t>>2]=1+(0|n[t>>2])),n[r>>2]=n[e>>2],le(a,s,t=r+4|0),ae(t),n[r+16>>2]=n[e>>2],le(a,s+12|0,t=r+20|0),ae(t),n[r+32>>2]=n[e>>2],le(a,s+24|0,t=r+36|0),ae(t),n[r+48>>2]=n[e>>2],le(a,s+36|0,t=r+52|0),ae(t),n[r+64>>2]=n[e>>2],le(a,s+48|0,r=r+68|0),ae(r),P=i}function Le(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?(ne(A,p,0,0),Ae(f,A,a),xe(a),le(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{be(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],ue(A,l?3*t|0:t),le(f,A,f),ae(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 Oe(e,t){e|=0,t|=0;var r=0;do{r=0|Le(e,t,0,1)}while(2==(0|r));return 0|r}function ke(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,N=0,E=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],Ue(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,N=0,E=r,i=-1;e:for(;;){if(e=v+((M=(0|E)%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=N,N=0|Le(_,o,0,1),(0|E)>(0|r)&!!(0|et(t))&&(1!=(0|e)&&(0|n[_>>2])!=(0|i))){switch(oe(v+((M+5|0)%6<<4)+4|0,w),oe(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}Ot(w,f,i,e,b),0|kt(w,b)||0|kt(f,b)||(De(b,0|n[x>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2]))}if((0|E)<(0|l)&&(oe(d,w),De(w,0|n[_>>2],o,1,a+8+(n[a>>2]<<4)|0),n[a>>2]=1+(0|n[a>>2])),(0|(E=E+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 Ue(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|et(0|n[t>>2])))?s:a,we(a=e+4|0),Te(a),0|et(0|n[t>>2])&&(ge(a),n[t>>2]=1+(0|n[t>>2])),n[r>>2]=n[e>>2],le(a,s,t=r+4|0),ae(t),n[r+16>>2]=n[e>>2],le(a,s+12|0,t=r+20|0),ae(t),n[r+32>>2]=n[e>>2],le(a,s+24|0,t=r+36|0),ae(t),n[r+48>>2]=n[e>>2],le(a,s+36|0,t=r+52|0),ae(t),n[r+64>>2]=n[e>>2],le(a,s+48|0,t=r+68|0),ae(t),n[r+80>>2]=n[e>>2],le(a,s+60|0,r=r+84|0),ae(r),P=i}function Ve(e,t){return t=0|ur(0|(e|=0),0|(t|=0),45),M(),127&t}function ze(e,t){e|=0;var r=0,n=0,s=0,a=0;return!0&134217728==(-16777216&(t|=0))?(n=0|ur(0|e,0|t,52),M(),n&=15,r=0|ur(0|e,0|t,45),M(),(r&=127)>>>0>121?0|(e=0):!(613566756&(a=0|hr(0|(s=0|ur(0|e,0|t,0|(a=3*(15^n)|0))),0|M(),0|a))&(0|rr(-1227133514,-1171,0|a,0|(s=0|M()))))&!(4681&s&M())&&15==(0|n)|!(0|(a=0|ur(0|(0|hr(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|cr(0|e,0|t),M(),0|!!((63-a|0)%3|0)):0|(a=1):0|(a=0)):0|(e=0)}function Ge(e,t,r,i){e|=0,r|=0,i|=0;var s=0,a=0,o=0,l=0;if(s=0|hr(0|(t|=0),0,52),a=0|M(),r=0|hr(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|hr(7,0,0|(o=3*(15-a|0)|0)),r&=~M(),s=s&~l|(o=0|hr(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 je(e,t,r,i){r|=0,i|=0;var s=0,a=0;if(a=0|ur(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|hr(0|r,0,52),s|=e,e=M()|-15728641&t,(0|a)>(0|r))do{t=0|hr(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 We(e,t,r,i){r|=0,i|=0;var s=0,a=0,o=0;if(a=0|ur(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|ur(0|e,0|t,45),M();e:do{if(0|z(127&r)){t:do{if(0|a){for(r=1;!((o=0|hr(7,0,3*(15-r|0)|0))&e|0)&!((0|M())&t);){if(!(r>>>0>>0))break t;r=r+1|0}r=0|Mt(7,0,s,((0|s)<0)<<31>>31),s=0|M();break e}}while(0);r=0|tr(0|(r=0|ar(0|(r=0|Mt(7,0,s,((0|s)<0)<<31>>31)),0|M(),5,0)),0|M(),-5,-1),r=0|tr(0|(r=0|sr(0|r,0|M(),6,0)),0|M(),1,0),s=0|M()}else r=0|Mt(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 He(e,t){var r=0,i=0,n=0;if(n=0|ur(0|(e|=0),0|(t|=0),45),M(),!(0|z(127&n)))return 0|(n=0);n=0|ur(0|e,0|t,52),M(),n&=15;e:do{if(n)for(i=1;;){if(r=0|ur(0|e,0|t,3*(15-i|0)|0),M(),0|(r&=7))break e;if(!(i>>>0>>0)){r=0;break}i=i+1|0}else r=0}while(0);return 0|(n=1&!(0|r))}function $e(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|hr(-1,-1,3+(3*(i-r|0)|0)|0),i=0|hr(0|~r,0|~M(),3*(15-i|0)|0),r=~M()&t,i=~i&e,T(0|r),0|i)}function Qe(e,t,r,i){r|=0,i|=0;var s=0;return s=0|ur(0|(e|=0),0|(t|=0),52),M(),(0|r)<16&(0|(s&=15))<=(0|r)?((0|s)<(0|r)&&(s=0|hr(-1,-1,3+(3*(r+-1-s|0)|0)|0),s=0|hr(0|~s,0|~M(),3*(15-r|0)|0),t=~M()&t,e&=~s),s=0|hr(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 Xe(e,t){var r=0,i=0,n=0;if(n=0|ur(0|(e|=0),0|(t|=0),52),M(),!(n&=15))return 0|(n=0);for(i=1;;){if(r=0|ur(0|e,0|t,3*(15-i|0)|0),M(),0|(r&=7)){i=5;break}if(!(i>>>0>>0)){r=0,i=5;break}i=i+1|0}return 5==(0|i)?0|r:0}function Ye(e,t){var r=0,i=0,n=0,s=0,a=0,o=0,l=0;if(l=0|ur(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|hr(7,0,0|(s=3*(15-o|0)|0)),n=0|M(),a=0|ur(0|e,0|t,0|s),M(),e=(s=0|hr(0|ve(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|ur(0|e,0|t,52),M(),i&=15){r=1;t:for(;;){switch(a=0|ur(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>>0)){r=1;break e}r=r+1|0}for(r=1;;){if(n=0|ur(0|e,0|t,0|(a=3*(15-r|0)|0)),M(),s=0|hr(7,0,0|a),t&=~M(),e=e&~s|(a=0|hr(0|ve(7&n),0,0|a)),t=0|t|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(o>>>0>>0))break;o=o+1|0}return T(0|t),0|e}function Ze(e,t){var r=0,i=0,n=0,s=0,a=0;if(i=0|ur(0|(e|=0),0|(t|=0),52),M(),!(i&=15))return i=e,T(0|(r=t)),0|i;for(r=1;a=0|ur(0|e,0|t,0|(s=3*(15-r|0)|0)),M(),n=0|hr(7,0,0|s),t&=~M(),e=(s=0|hr(0|ve(7&a),0,0|s))|e&~n,t=0|M()|t,r>>>0>>0;)r=r+1|0;return T(0|t),0|e}function Ke(e,t){var r=0,i=0,n=0,s=0,a=0,o=0,l=0;if(l=0|ur(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|hr(7,0,0|(s=3*(15-o|0)|0)),n=0|M(),a=0|ur(0|e,0|t,0|s),M(),e=(s=0|hr(0|_e(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|ur(0|e,0|t,52),M(),i&=15){r=1;t:for(;;){switch(a=0|ur(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>>0)){r=1;break e}r=r+1|0}for(r=1;;){if(s=0|hr(7,0,0|(n=3*(15-r|0)|0)),a=t&~M(),t=0|ur(0|e,0|t,0|n),M(),e=e&~s|(t=0|hr(0|_e(7&t),0,0|n)),t=0|a|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(o>>>0>>0))break;o=o+1|0}return T(0|t),0|e}function Je(e,t){var r=0,i=0,n=0,s=0,a=0;if(i=0|ur(0|(e|=0),0|(t|=0),52),M(),!(i&=15))return i=e,T(0|(r=t)),0|i;for(r=1;s=0|hr(7,0,0|(a=3*(15-r|0)|0)),n=t&~M(),t=0|ur(0|e,0|t,0|a),M(),e=(t=0|hr(0|_e(7&t),0,0|a))|e&~s,t=0|M()|n,r>>>0>>0;)r=r+1|0;return T(0|t),0|e}function et(e){return(0|(e|=0))%2|0}function tt(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,Pe(e|=0,t|=0,r|=0,n=i),se(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,hr(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):(hr(0|j(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?(pe(l),n[a>>2]=n[l>>2],n[a+4>>2]=n[l+4>>2],n[a+8>>2]=n[l+8>>2],me(a)):(fe(l),n[a>>2]=n[l>>2],n[a+4>>2]=n[l+4>>2],n[a+8>>2]=n[l+8>>2],ge(a)),Ae(s,a,o),ae(o),u=0|hr(7,0,0|(h=3*(15-t|0)|0)),i&=~M(),e=(h=0|hr(0|he(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|hr(0|(s=0|j(A)),0,45),t|=e,e=M()|-1040385&i,o=0|W(A),!(0|z(s))){if((0|o)<=0)break;for(a=0;;){if(s=0|ur(0|t,0|e,52),M(),s&=15)for(i=1;A=0|ur(0|t,0|e,0|(h=3*(15-i|0)|0)),M(),u=0|hr(7,0,0|h),e&=~M(),t=t&~u|(h=0|hr(0|ve(7&A),0,0|h)),e=0|e|M(),i>>>0>>0;)i=i+1|0;if((0|(a=a+1|0))==(0|o))break e}}a=0|ur(0|t,0|e,52),M(),a&=15;t:do{if(a){i=1;r:for(;;){switch(h=0|ur(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>>0))break t;i=i+1|0}if(0|H(s,0|n[A>>2]))for(i=1;u=0|hr(7,0,0|(A=3*(15-i|0)|0)),h=e&~M(),e=0|ur(0|t,0|e,0|A),M(),t=t&~u|(e=0|hr(0|_e(7&e),0,0|A)),e=0|h|M(),i>>>0>>0;)i=i+1|0;else for(i=1;A=0|ur(0|t,0|e,0|(h=3*(15-i|0)|0)),M(),u=0|hr(7,0,0|h),e&=~M(),t=t&~u|(h=0|hr(0|ve(7&A),0,0|h)),e=0|e|M(),i>>>0>>0;)i=i+1|0}}while(0);if((0|o)>0){i=0;do{t=0|Ye(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,1050,27145),P=i,0|(s=0)):(P=i,0|(s=3))}function rt(e,t,r){var i,s=0,a=0,o=0;if(i=(r|=0)+4|0,a=0|ur(0|(e|=0),0|(t|=0),52),M(),a&=15,o=0|ur(0|e,0|t,45),M(),s=!(0|a),0|z(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?me(i):ge(i),o=0|ur(0|e,0|t,3*(15-r|0)|0),M(),ye(i,7&o),r>>>0>>0;)r=r+1|0;return 0|s}function it(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|ur(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|z(h)&&(l=0|ur(0|e,0|t,52),M(),0|(l&=15))){a=1;t:for(;;){switch(u=0|ur(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>>0)){a=t;break e}a=a+1|0}for(o=1,a=t;A=0|hr(7,0,0|(t=3*(15-o|0)|0)),u=a&~M(),a=0|ur(0|e,0|a,0|t),M(),e=e&~A|(a=0|hr(0|_e(7&a),0,0|t)),a=0|u|M(),o>>>0>>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|rt(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|ur(0|e,0|a,52),M(),u=15&l,1&l?(ge(A),l=u+1|0):l=u,0|z(h)){e:do{if(u)for(t=1;;){if(o=0|ur(0|e,0|a,3*(15-t|0)|0),M(),0|(o&=7)){a=o;break e}if(!(t>>>0>>0)){a=0;break}t=t+1|0}else a=0}while(0);a=4==(0|a)&1}else a=0;if(0|Le(r,l,a,0)){if(0|z(h))do{}while(0|Le(r,l,0,0));(0|l)!=(0|u)&&fe(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 nt(e,t,r){r|=0;var i,n,s=0;return n=P,P=P+16|0,0|(s=0|it(e|=0,t|=0,i=n))?(P=n,0|s):(s=0|ur(0|e,0|t,52),M(),Ie(i,15&s,r),P=n,0|(s=0))}function st(e,t,r){r|=0;var i,n=0,s=0,a=0;if(i=P,P=P+16|0,0|(n=0|it(e|=0,t|=0,a=i)))return P=i,0|(a=n);n=0|ur(0|e,0|t,45),M(),n=!(0|z(127&n)),s=0|ur(0|e,0|t,52),M(),s&=15;e:do{if(!n){if(0|s)for(n=1;;){if(!(!((0|hr(7,0,3*(15-n|0)|0))&e|0)&!((0|M())&t)))break e;if(!(n>>>0>>0))break;n=n+1|0}return Fe(a,s,0,5,r),P=i,0|0}}while(0);return ke(a,s,0,6,r),P=i,0|0}function at(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(hr(0|e,0,52),l=134225919|M(),!e){r=0,i=0;do{0|z(i)&&(hr(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|z(o)){for(hr(0|o,0,45),i=1,s=-1,a=0|l|M();s&=~(A=0|hr(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 ot(e,t,r,i){e|=0,i|=0;var s=0,a=0,o=0;s=0|ur(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|$e(t,r,s+1|0,i),o=-15728641&M(),r=0|hr(0|i,0,52),a=s,t=(t=!(0|He(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 lt(e,t,r,i){r|=0,i|=0;var s=0,a=0;return s=0|ur(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|$e(e,t,s+1|0,r),a=-15728641&M(),s=0|hr(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|He(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|ur(0|r,0|i,52),M(),r=0|tr(0|(A=0|hr(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|ur(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|tr(0|r,0|i,0|(u=0|hr(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|tr(0|r,0|i,0|(l=0|hr(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 ut(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function ht(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 ct(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 dt(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 pt(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20656+(e<<3)>>3],0|(t=0))}function ft(e,t){t|=0;var r=0;return(e|=0)>>>0>15?0|(t=4):(r=0|ar(0|(r=0|Mt(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 mt(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 gt(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|nt(e|=0,t|=0,i=o+168|0)))return P=o,0|(r=A);if(0|st(e,t,a)&&S(27795,27190,415,27199),(0|(t=0|n[a>>2]))>0){if(l=+mt(a+8|0,a+8+((1!=(0|t)&1)<<4)|0,i)+0,1!=(0|t)){e=1;do{l+=+mt(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 yt(e){e|=0;var t,r,i=0;return(t=0|er(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 bt(e,t){e|=0,t|=0;var r,i;return(i=0|Kt(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 xt(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],Jt(s)}while(0|r);s=t,t=0|n[t+8>>2],Jt(s)}while(0|t);if(t=e,e=0|n[e+8>>2],i||Jt(t),!e)break;i=0}}function vt(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,N=0,E=0,C=0,R=0,B=0,P=0,D=0,I=0,F=0,q=0;if(0|n[(l=(e|=0)+8|0)>>2])return 0|(q=1);if(!(o=0|n[e>>2]))return 0|(q=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|(q=0);(r=0|Kt(a<<2))||S(27396,27235,317,27415),(t=0|Kt(a<<5))||S(27437,27235,321,27415),n[e>>2]=0,n[(E=e+4|0)>>2]=0,n[l>>2]=0,a=0,I=0,N=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){q=14;break}u+=(c-d)*(+s[i>>3]+ +s[l>>3])}while(!p);if(14==(0|q)){q=0,u=0,i=f;do{M=+s[i+8>>3],P=0|n[(D=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?D:o)>>2]}while(0|i)}u>0?(n[r+(I<<2)>>2]=o,I=I+1|0,l=N,i=m):q=19}else q=19;if(19==(0|q)){q=0;do{if(!a){if(m){l=E,h=m+8|0,i=o,a=e;break}if(0|n[e>>2]){q=27;break e}l=E,h=e,i=o,a=e;break}if(0|n[(i=a+8|0)>>2]){q=21;break e}if(!(a=0|er(1,12))){q=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+(N<<5)|0,p=0|n[o>>2]){for(s[(f=t+(N<<5)+8|0)>>3]=17976931348623157e292,s[(m=t+(N<<5)+24|0)>>3]=17976931348623157e292,s[h>>3]=-17976931348623157e292,s[(g=t+(N<<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>3]=u,d=u),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=N+1|0}if(o=0|n[(D=o+8|0)>>2],n[D>>2]=0,!o){q=45;break}N=l,m=i}if(21==(0|q))S(27213,27235,35,27247);else if(23==(0|q))S(27267,27235,37,27247);else if(27==(0|q))S(27310,27235,61,27333);else if(45==(0|q)){e:do{if((0|I)>0){for(D=!(0|l),B=l<<2,P=!(0|e),R=0,i=0;;){if(C=0|n[r+(R<<2)>>2],D)q=73;else{if(!(N=0|Kt(B))){q=50;break}if(!(E=0|Kt(B))){q=52;break}t:do{if(P)a=0;else{for(l=0,a=0,h=e;o=t+(l<<5)|0,0|_t(0|n[h>>2],o,0|n[C>>2])?(n[N+(a<<2)>>2]=h,n[E+(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[N>>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[N+(h<<2)>>2]>>2]))==(0|p)?o:o+(1&_t(l,0|n[E+(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[N+(o<<2)>>2]}else a=0}}while(0);if(Jt(N),Jt(E),a){if(o=0|n[(l=a+4|0)>>2])a=o+8|0;else if(0|n[a>>2]){q=70;break}n[a>>2]=C,n[l>>2]=C}else q=73}if(73==(0|q)){if(q=0,0|(i=0|n[C>>2]))do{E=i,i=0|n[i+16>>2],Jt(E)}while(0|i);Jt(C),i=1}if((0|(R=R+1|0))>=(0|I)){F=i;break e}}50==(0|q)?S(27452,27235,249,27471):52==(0|q)?S(27490,27235,252,27471):70==(0|q)&&S(27310,27235,61,27333)}else F=0}while(0);return Jt(r),Jt(t),0|(q=F)}return 0}function _t(e,t,r){e|=0;var i=0,a=0,o=0,l=0,A=0,u=0,h=0,c=0;if(!(0|K(t|=0,r|=0)))return 0|(e=0);if(t=0|Y(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)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)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 wt(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|ur(0|(e|=0),0|(t|=0),52),M(),h&=15,g=0|ur(0|r,0|s,52),M(),(0|h)!=(15&g))return P=u,0|(x=12);if(f=0|ur(0|e,0|t,45),M(),f&=127,m=0|ur(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|Q(f,m))))return P=u,0|(x=1);7==(0|(p=0|Q(m,f)))?S(27514,27538,161,27548):(y=d,c=p)}else y=0,c=0;o=0|z(f),l=0|z(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|Ke(p,d),d=0|M(),1==(0|(c=0|_e(c)))&&(c=0|_e(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|Je(p,d),d=0|M(),c=0|_e(c),f=f+1|0}while((0|f)!=(0|m));m=c,f=p,p=d}else m=c,f=r,p=s;if(rt(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|Xe(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|Xe(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{xe(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,ye(A,y),0|h)for(;0|et(h)?me(A):ge(A),(0|h)>1;)h=h+-1|0;if((0|f)>0){h=0;do{xe(A),h=h+1|0}while((0|h)!=(0|f))}le(b=x+4|0,A,b),ae(b),b=51}}else if(rt(r,s,x),!!(0|o)&!!(0|l))if((0|m)!=(0|f)&&S(27621,27538,261,27548),7==(0|(c=0|Xe(e,t)))|7==(0|(h=0|Xe(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{xe(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 Tt(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|ur(0|(e|=0),0|(t|=0),52),M(),l&=15,p=0|ur(0|e,0|t,45),M(),(p&=127)>>>0>121)return P=o,0|(i=5);if(a=0|z(p),hr(0|l,0,52),g=134225919|M(),n[(A=i)>>2]=-1,n[A+4>>2]=g,!l)return 7==(0|(l=0|he(r)))||127==(0|(l=0|$(p,l)))?(P=o,0|(g=1)):(f=0|hr(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|et(A)){if(0|(l=0|ce(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],me(h)}else{if(0|(l=0|de(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],ge(h)}if(Ae(u,h,c),ae(c),b=0|n[(l=i)>>2],l=0|n[l+4>>2],y=0|hr(7,0,0|(x=3*(15-A|0)|0)),l&=~M(),x=0|hr(0|he(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|$(p,r=0|he(s))))?0:0|z(l);t:do{if(r){if(a){if(7==(0|(l=0|Xe(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|ve(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|$(p,l)))&&S(27648,27538,411,27678),0|z(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|Ze(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|Ze(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|Q(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|Ze(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|Xe(r,l)))&&S(27795,27538,440,27678),r=0|G(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|Ye(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|Xe(e,t)))|7==(0|(A=0|Xe(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|Ze(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|Xe(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|hr(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 Mt(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|ar(0|((a=!0&!(1&r))?1:s),0|(a?0:n),0|e,0|t),t=0|M(),r=0|Ar(0|r,0|i,1),i=0|M(),s=0|ar(0|s,0|n,0|s,0|n),n=0|M()}while(!(!(0|r)&!(0|i)));return T(0|t),0|e}function St(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|ur(0|(e|=0),0|(t|=0),52),M(),A&=15;do{if(A){if(!(o=0|nt(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|ur(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>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 Nt(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,Ge(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|Pt(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|er(1+(0|n[t+8>>2])|0,32)){Dt(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);Et(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 Et(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|Ct(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])&&Jt(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|ur(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|nt(l,A,t))){x=15;break t}if(0|It(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|K(26832,t))){if(0|tt(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|st(l,A,t))){x=32;break}if(0|St(l,A,r,0)){x=36;break}if(c&&0|Ft(0|n[s>>2],0|n[y>>2],t,r)){x=42;break}if(p&&0|Lt(0|n[s>>2],0|n[y>>2],t,r)){x=42;break}}if(g){if(o=0|St(l,A,t,1),u=0|n[y>>2],0|o){x=45;break}if(0|J(u,t)){if(te(r,t),0|ee(t,0|n[y>>2])){x=53;break}if(0|It(0|n[s>>2],0|n[y>>2],d)){x=53;break}if(0|Lt(0|n[s>>2],0|n[y>>2],r,t)){x=53;break}}}}do{if((0|h)<(0|n[b>>2])){if(o=0|St(l,A,t,1),u=0|n[y>>2],0|o){x=58;break t}if(!(0|J(u,t))){x=73;break}if(0|ee(0|n[y>>2],t)&&(te(r,t),0|Ft(0|n[s>>2],0|n[y>>2],r,t))){x=65;break t}if(0|(l=0|Qe(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|Ct(l,A),A=0|M()),!(0|l)&!(0|A)){v=y;break e}}switch(0|x){case 15:0|(o=0|n[y>>2])&&Jt(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])&&Jt(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&&Jt(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&&Jt(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])&&Jt(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])&&Jt(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 Ct(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|ur(0|(e|=0),0|(t|=0),52),M(),s&=15,i=0|ur(0|e,0|t,45),M();do{if(s){for(;i=0|hr(s+4095|0,0,52),a=M()|-15728641&t,i=i|e|(l=0|hr(7,0,0|(o=3*(15-s|0)|0))),a|=A=0|M(),u=0|ur(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|ur(0|i,0|a,45),M();break}return c=0|hr(((c=!(0|u)&!!(0|He(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):(Ge(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 Rt(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|K(t|=0,r|=0)))return 0|(p=0);if(t=0|Y(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)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)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 Bt(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>3]=u,d=u),f>3]=f,p=f),u>m?s[t>>3]=u:u=m,f>h&&(s[l>>3]=f,h=f),g=f>0&fy?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 Pt(e){return 0|((e|=0)>>>0<4?0:15)}function Dt(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>3]=l,c=l),p>3]=p,d=p),l>f?s[t>>3]=l:l=f,p>u&&(s[v>>3]=p,u=p),m=p>0&pg?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>3]=l,c=l),f>3]=f,d=f),l>p?s[x>>3]=l:l=p,f>u&&(s[w>>3]=f,u=f),m=f>0&fg?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 It(e,t,r){var i=0,s=0,a=0;if(!(0|Rt(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|Rt((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 Ft(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|Rt(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|Rt((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|Rt(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|J(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>2]=e?a|t?1:2:0,n[i>>2]=a?e?1:t?2:1:0}(t,i,A,c),mr(0|u,0|r,168),(0|n[r>>2])>0){t=0;do{_=+ct(+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],_=+ct(+s[i+16>>3],0|n[c>>2]),a=+ct(+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=+ct(+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=+ct(+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 Lt(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 Ot(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 kt(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 Ut(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 Vt(e,t,r){r|=0;var i,s,a,o,l=0,A=0,u=0,h=0;if(o=P,P=P+32|0,h=o,0|(l=0|it(e|=0,t|=0,s=o+16|0)))return P=o,0|(r=l);i=0|Ve(e,t),a=0|Xe(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,h),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]);do{if(0|z(i)){switch(0|i){case 4:A=0;break;case 14:A=1;break;case 24:A=2;break;case 38:A=3;break;case 49:A=4;break;case 58:A=5;break;case 63:A=6;break;case 72:A=7;break;case 83:A=8;break;case 97:A=9;break;case 107:A=10;break;case 117:A=11;break;default:S(27795,27797,75,27806)}if(u=0|n[26416+(24*A|0)+8>>2],t=0|n[26416+(24*A|0)+16>>2],(0|(e=0|n[s>>2]))!=(0|n[h>>2])&&(h=0|G(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;break}5==(0|a)&(0|e)==(0|u)&&(l=(l+1|0)%6|0)}}while(0);return n[r>>2]=l,P=o,0|(r=0)}function zt(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|He(e|=0,t|=0)))?6:5,m=0|ur(0|e,0|t,52),M(),p>>>0<=r>>>0)return P=A,0|(i=2);!(g=!(0|(m&=15)))&&!((y=0|hr(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|He(e,t)))?4:5))<(0|r))return P=A,0|(i=1);if(0|Vt(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|L(e,t,y,l,o);do{if(!u){if(f=0|n[(d=o)>>2],h=(c=(d=0|n[d+4>>2])>>>0>>0|(0|d)==(0|t)&f>>>0>>0)?f:e,c=c?d:t,!g&&!(f&(g=0|hr(7,0,3*(15^m)|0))|0)&!(d&(0|M())))u=r;else{if(d=(r+-1+p|0)%(0|p)|0,u=0|He(e,t),(0|d)<0&&S(27795,27797,248,27822),(0|((p=!!(0|u))?4:5))<(0|d)&&S(27795,27797,248,27822),0|Vt(e,t,x)&&S(27795,27797,248,27822),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,248,27822),n[a>>2]=0,0|(u=0|L(e,t,d,a,s)))break;p=0|n[(f=s)>>2],f=0|n[f+4>>2];do{if(f>>>0>>0|(0|f)==(0|c)&p>>>0>>0){if(h=0|He(p,f)?0|U(p,f,e,t):0|n[26800+(((0|n[a>>2])+(0|n[26768+(d<<2)>>2])|0)%6<<2)>>2],u=0|He(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|Vt(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|He(f,d)))?0|U(f,d,e,t):0|n[26800+(((0|n[l>>2])+(0|n[26768+(y<<2)>>2])|0)%6<<2)>>2],u=0|He(f,d),(e+-1|0)>>>0<=5&&!(1==(0|e)&(b=!!(0|u))))do{if(!(0|Vt(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|hr(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 Gt(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|ze(e,s=-2130706433&t|134217728)?(a=0|ur(0|e,0|t,56),M(),s=(a=!(0|zt(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))}function jt(e,t,r){e|=0,r|=0;var i=0;(0|(t|=0))>0?(i=0|er(t,4),n[e>>2]=i,i||S(27835,27858,40,27872)):n[e>>2]=0,n[e+4>>2]=t,n[e+8>>2]=0,n[e+12>>2]=r}function Wt(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]}Jt(u),n[i>>2]=(0|n[i>>2])-1}}while(0)}Jt(0|n[e>>2])}function Ht(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 $t(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 Jt(t),n[(o=e+8|0)>>2]=(0|n[o>>2])-1,0|(o=0)}function Qt(e,t,r){e|=0,t|=0,r|=0;var i,a=0,o=0,l=0;(i=0|Kt(40))||S(27888,27858,98,27901),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|ht(a,t)&&0|ht(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 Jt(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 Xt(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|ht(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|ht(e,t)&&0|ht(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 Yt(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|ht(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 Zt(e){return 0|+yr(+(e=+e))}function Kt(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[6981])>>>e))return s=0|n[(i=(e=27964+((r=(1&i^1)+e|0)<<1<<2)|0)+8|0)>>2],(0|(o=0|n[(a=s+8|0)>>2]))==(0|e)?n[6981]=d&~(1<>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[6983])>>>0){if(0|i)return r=((r=i<>>=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<>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[6986],i=27964+((r=c>>>3)<<1<<2)|0,e&(r=1<>2]:(n[6981]=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[6983]=l,n[6986]=a,P=t,0|(_=A);if(o=0|n[6982]){for(i=(o&0-o)-1|0,i=u=0|n[28228+(((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>>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=28228+(r<<2)|0)>>2])){if(n[e>>2]=i,!i){n[6982]=o&~(1<>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[6986],i=27964+((r=c>>>3)<<1<<2)|0,(r=1<>2]:(n[6981]=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[6983]=u,n[6986]=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[6982]){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<>>15)|0)+7|0)&1|u<<1:0,i=0|n[28228+(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>>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<>>=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>>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[6983])-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=28228+(e<<2)|0)>>2])){if(n[i>>2]=r,!r){s&=~(1<>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=27964+(r<<1<<2)|0,(e=0|n[6981])&(r=1<>2]:(n[6981]=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=28228+((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))+(_<>>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<>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[6983])>>>0>=d>>>0)return r=i-d|0,e=0|n[6986],r>>>0>15?(_=e+d|0,n[6986]=_,n[6983]=r,n[_+4>>2]=1|r,n[e+i>>2]=r,n[e+4>>2]=3|d):(n[6983]=0,n[6986]=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[6984])>>>0>d>>>0)return x=l-d|0,n[6984]=x,v=(_=0|n[6987])+d|0,n[6987]=v,n[v+4>>2]=1|x,n[_+4>>2]=3|d,P=t,0|(_=_+8|0);if(0|n[7099]?e=0|n[7101]:(n[7101]=4096,n[7100]=4096,n[7102]=-1,n[7103]=-1,n[7104]=0,n[7092]=0,n[7099]=-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[7091])&&(p=(c=0|n[7089])+h|0)>>>0<=c>>>0|p>>>0>e>>>0)return P=t,0|(_=0);e:do{if(4&n[7092])r=0,g=143;else{i=0|n[6987];t:do{if(i){for(s=28372;!((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|br(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|br(0)))&&(r=i,m=(r=((m=(f=0|n[7100])+-1|0)&r|0?(m+r&0-f)-r|0:0)+h|0)+(f=0|n[7089])|0,r>>>0>d>>>0&r>>>0<2147483647)){if(0|(p=0|n[7091])&&m>>>0<=f>>>0|m>>>0>p>>>0){r=0;break}if((0|(e=0|br(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[7101])&0-e)>>>0>=2147483647){l=r,o=s,g=145;break e}if(-1==(0|br(0|e))){br(0|i),r=0;break}l=e+r|0,o=s,g=145;break e}}while(0);n[7092]=4|n[7092],g=143}}while(0);if(143==(0|g)&&h>>>0<2147483647&&!(-1==(0|(x=0|br(0|h)))|1^(b=(y=(m=0|br(0))-x|0)>>>0>(d+40|0)>>>0)|x>>>0>>0&-1!=(0|x)&-1!=(0|m)^1)&&(l=b?y:r,o=x,g=145),145==(0|g)){r=(0|n[7089])+l|0,n[7089]=r,r>>>0>(0|n[7090])>>>0&&(n[7090]=r),u=0|n[6987];e:do{if(u){for(r=28372;;){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[6984])+l|0)-x|0,n[6987]=v,n[6984]=x,n[v+4>>2]=1|x,n[u+_+4>>2]=40,n[6988]=n[7103];break}for(o>>>0<(0|n[6985])>>>0&&(n[6985]=o),i=o+l|0,r=28372;;){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[6984])+A|0,n[6984]=_,n[6987]=h,n[h+4>>2]=1|_;else{if((0|n[6986])==(0|r)){_=(0|n[6983])+A|0,n[6983]=_,n[6986]=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[6981]=n[6981]&~(1<>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=28228+((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[6982]=n[6982]&~(1<>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=27964+(r<<1<<2)|0,(e=0|n[6981])&(r=1<>2]:(n[6981]=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))+(_<>>15)|0)+7|0)&1|s<<1}else s=0}while(0);if(r=28228+(s<<2)|0,n[h+28>>2]=s,n[(e=h+16|0)+4>>2]=0,n[e>>2]=0,!((e=0|n[6982])&(i=1<>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=28372;!((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[6987]=v,n[6984]=x,n[v+4>>2]=1|x,n[o+i+4>>2]=40,n[6988]=n[7103],n[(i=e+4|0)>>2]=27,n[r>>2]=n[7093],n[r+4>>2]=n[7094],n[r+8>>2]=n[7095],n[r+12>>2]=n[7096],n[7093]=o,n[7094]=l,n[7096]=0,n[7095]=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=27964+(r<<1<<2)|0,(e=0|n[6981])&(r=1<>2]:(n[6981]=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=28228+((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))+(_<>>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[6982])&(e=1<>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[6985]))|o>>>0<_>>>0&&(n[6985]=o),n[7093]=o,n[7094]=l,n[7096]=0,n[6990]=n[7099],n[6989]=-1,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,n[7054]=28204,n[7053]=28204,n[7056]=28212,n[7055]=28212,v=o+(x=7&(x=o+8|0)?0-x&7:0)|0,x=(_=l+-40|0)-x|0,n[6987]=v,n[6984]=x,n[v+4>>2]=1|x,n[o+_+4>>2]=40,n[6988]=n[7103]}while(0);if((r=0|n[6984])>>>0>d>>>0)return x=r-d|0,n[6984]=x,v=(_=0|n[6987])+d|0,n[6987]=v,n[v+4>>2]=1|x,n[_+4>>2]=3|d,P=t,0|(_=_+8|0)}return n[(_=27920)>>2]=12,P=t,0|(_=0)}function Jt(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[6985],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>>0)return;if((0|n[6986])==(0|o)){if(3&~(t=0|n[(e=A+4|0)>>2])){l=o,t=a;break}return n[6983]=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[6981]=n[6981]&~(1<>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=28228+(t<<2)|0)>>2])==(0|o)){if(n[r>>2]=e,!e){n[6982]=n[6982]&~(1<>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[6987])==(0|A)){if(A=(0|n[6984])+t|0,n[6984]=A,n[6987]=l,n[l+4>>2]=1|A,(0|l)!=(0|n[6986]))return;return n[6986]=0,void(n[6983]=0)}if((0|n[6986])==(0|A))return A=(0|n[6983])+t|0,n[6983]=A,n[6986]=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[6981]=n[6981]&~(1<>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=28228+(e<<2)|0)>>2])==(0|A)){if(n[t>>2]=r,!r){n[6982]=n[6982]&~(1<>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[6986]))return void(n[6983]=s)}if(e=s>>>3,s>>>0<256)return r=27964+(e<<1<<2)|0,(t=0|n[6981])&(e=1<>2]:(n[6981]=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=28228+((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<>>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[6982],r=1<>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[6982]=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[6989])-1|0,n[6989]=A,!(0|A)){for(e=28380;e=0|n[e>>2];)e=e+8|0;n[6989]=-1}}}}function er(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|Kt(r))&&3&n[e+-4>>2]?(gr(0|e,0,0|r),0|e):0|e}function tr(e,t,r,i){return 0|(T((t|=0)+(i|=0)+((r=(e|=0)+(r|=0)>>>0)>>>0>>0|0)>>>0|0),r)}function rr(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 ir(e){return 0|((e|=0)?31-(0|w(e^e-1)):32)}function nr(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<>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<>>(l>>>0))&(t=p>>31),t&=u>>>(l>>>0),a=h<<(f=64-l|0)&(A=c>>31),l=(u<>>(p>>>0))&A|h<>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|ir(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|ir(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<>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|tr(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,rr(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|rr(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 sr(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|rr((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|rr((0|nr(a,0|M(),0|rr(s^r|0,n^i|0,0|s,0|n),0|M(),0))^e,(0|M())^t,0|e,0|t)}function ar(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 or(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,nr(e=0|rr((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|rr(u^r|0,A^i|0,0|u,0|A),0|M(),l),i=0|rr(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 lr(e,t,r,i){var s,a;return a=P,P=P+16|0,nr(e|=0,t|=0,r|=0,i|=0,s=0|a),P=a,0|(T(0|n[s+4>>2]),n[s>>2])}function Ar(e,t,r){return e|=0,t|=0,(0|(r|=0))<32?(T(t>>r|0),e>>>r|(t&(1<>r-32)}function ur(e,t,r){return e|=0,t|=0,(0|(r|=0))<32?(T(t>>>r|0),e>>>r|(t&(1<>>r-32|0)}function hr(e,t,r){return e|=0,t|=0,(0|(r|=0))<32?(T(t<>>32-r),e<=0?+l(e+.5):+b(e-.5)}function mr(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 gr(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 yr(e){return(e=+e)>=0?+l(e+.5):+b(e-.5)}function br(e){e|=0;var t,r,i;return i=0|E(),(0|e)>0&(0|(t=(r=0|n[o>>2])+e|0))<(0|r)|(0|t)<0?(B(0|t),N(12),-1):(0|t)>(0|i)&&!(0|R(0|t))?(N(12),-1):(n[o>>2]=t,0|r)}return{___divdi3:sr,___muldi3:ar,___remdi3:or,___uremdi3:lr,_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|ur(0|e,0|t,52),M(),u&=15,c=0|ur(0|r,0|i,52),M(),(0|u)!=(15&c))return P=l,0|(s=12);if(A=u+-1|0,u>>>0>1){je(e,t,A,o),je(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|ur(0|e,0|t,0|(u=3*(15^u)|0)),M(),A&=7,u=0|ur(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|He(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 D(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:Ar,_bitshift64Lshr:ur,_bitshift64Shl:hr,_calloc:er,_cellAreaKm2:function(e,t,r){return 0|(e=0|gt(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|gt(e|=0,t|=0,r|=0))||(s[r>>3]=6371.007180918475*+s[r>>3]*6371.007180918475*1e3*1e3),0|e},_cellAreaRads2:gt,_cellToBoundary:st,_cellToCenterChild:Qe,_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|ur(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|hr(0|r,0,52),o|=e,A=M()|-15728641&t,(0|b)>(0|r)){u=r;do{g=0|hr(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|ur(0|g,0|A,45),M();e:do{if(0|z(127&m)){if(u=0|ur(0|g,0|A,52),M(),0|(u&=15))for(o=1;;){if(!(!((m=0|hr(7,0,3*(15-o|0)|0))&g|0)&!((0|M())&A))){h=33;break e}if(!(o>>>0>>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|hr(0|f,0,52),o|=e,u=0|M()|m,(0|b)<(0|p))d=o;else{h=f;do{d=0|hr(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|ur(0|d,0|u,45),M(),0|z(127&c)){c=0|ur(0|d,0|u,52),M(),c&=15;t:do{if(c)for(h=1;;){if(o=0|ur(0|d,0|u,3*(15-h|0)|0),M(),0|(o&=7))break t;if(!(h>>>0>>0)){o=0;break}h=h+1|0}else o=0}while(0);o=1&!(0|o)}else o=0;if(u=0|ur(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|Mt(7,0,h=b-p|0,((0|h)<0)<<31>>31),c=0|M(),o?(o=0|tr(0|(o=0|ar(0|h,0|c,5,0)),0|M(),-5,-1),o=0|tr(0|(o=0|sr(0|o,0|M(),6,0)),0|M(),1,0),u=0|M()):(o=h,u=c),p=0|tr(0|o,0|u,0|(p=0|ar(0|h,0|c,0|(p=d+-1|0),((0|p)<0)<<31>>31)),0|M()),c=0|tr(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,1367,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|ur(0|e,0|t,3*(15-o|0)|0),M(),7==(0|(a&=7))){a=5;break}if(a=0|ar(0|(l=0|Mt(7,0,l=b-o|0,((0|l)<0)<<31>>31)),0|M(),0|a,0),l=0|M(),l=0|tr(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|We(g,A,b,y)&&S(27795,27122,1327,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,1407,27158),0)},_cellToChildren:function(e,t,r,i){i|=0;var s,a,o=0,l=0;if(a=P,P=P+16|0,ot(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|tr(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:We,_cellToLatLng:nt,_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|wt(e,t,r,i,a))||(Se(a,s),e=0),P=o,0|e},_cellToParent:je,_cellToVertex:zt,_cellToVertexes:function(e,t,r){r|=0;var i,s=0,a=0;return a=!(0|He(e|=0,t|=0)),i=!(0|(s=0|zt(e,t,0,r))),a?i?0|(s=0|zt(e,t,1,r+8|0))||0|(s=0|zt(e,t,2,r+16|0))||0|(s=0|zt(e,t,3,r+24|0))||(s=0|zt(e,t,4,r+32|0))?0|(a=s):0|zt(e,t,5,r+40|0):0|(a=s):i?0|(s=0|zt(e,t,1,r+8|0))||0|(s=0|zt(e,t,2,r+16|0))||0|(s=0|zt(e,t,3,r+24|0))||0|(s=0|zt(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|U(e|=0,t|=0,r|=0,i|=0)))?0|(s=11):(i=0|hr(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 jt(r,0,0),P=s,0;for(u=0|ur(0|n[(u=e)>>2],0|n[u+4>>2],52),M(),jt(r,(0|t)>6?t:6,15&u),u=0;!(0|(a=0|st(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|Xt(r,a=i+8+((0|(A=A+1|0))%(0|a)<<4)|0,l))?$t(r,o):Qt(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):(Wt(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|Ht(s)))do{t=0|yt(r);do{bt(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],$t(s,e),e=0|Yt(s,i)}while(0|e);e=0|Ht(s)}while(0|e);return Wt(s),(e=0|vt(r))?(xt(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|ur(0|(r|=0),0|(i|=0),52),M(),(0|(A&=15))>(0|s))return P=o,0|(a=12);if(0|We(r,i,s,l)&&S(27795,27122,1327,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|hr(0|s,0,52),u=M()|-15728641&i,n[(h=a)>>2]=s|r,n[h+4>>2]=u,h=0|ur(0|r,0|i,45),M();e:do{if(0|z(127&h)){if(0|A)for(l=1;;){if(!(!((h=0|hr(7,0,3*(15-l|0)|0))&r|0)&!((0|M())&i)))break e;if(!(l>>>0>>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|Mt(7,0,A=c-u|0,((0|A)<0)<<31>>31),r=0|M();do{if(l){if(l=0|sr(0|(l=0|tr(0|(l=0|ar(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|rr(0|(t=0|tr(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|hr(7,0,0|(m=3*(h+i|0)|0)),d&=~M(),m=0|hr(0|(s=0|tr(0|(i=0|sr(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|rr(0|t,0|l,0|(e=0|ar(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|hr(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|hr(7,0,0|(i=3*(h+i|0)|0)),p&=~M(),i=0|hr(0|(m=0|sr(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|rr(0|e,0|t,0|(l=0|ar(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|Mt(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|hr(7,0,0|(A=3*(s-l|0)|0)),u&=~M(),A=0|hr(0|(d=0|sr(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|rr(0|e,0|t,0|(m=0|ar(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,N=0,E=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|tr(0|a,0|o,1,0),o=0|M()}while((0|o)<(0|i)|(0|o)==(0|i)&a>>>0>>0);return 0|(a=0)}if(!(B=0|Kt(s=r<<3)))return 0|(P=13);if(mr(0|B,0|e,0|s),!(R=0|er(r,8)))return Jt(B),0|(P=13);e:for(;;){E=0|ur(0|(h=0|n[(a=B)>>2]),0|(a=0|n[a+4>>2]),52),M(),C=(E&=15)+-1|0,N=!!(0|E),T=(0|i)>0|!(0|i)&r>>>0>0;t:do{if(N&T){if(x=0|hr(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|tr(0|o,0|e,1,0),!((0|(e=0|M()))<(0|i)|(0|e)==(0|i)&o>>>0>>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|ur(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>=E>>>0)){u=C;do{w=0|hr(7,0,3*(14-u|0)|0),u=u+1|0,A|=w,e=0|M()|e}while(u>>>0>>0)}if(p=0|lr(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|ur(0|d,0|c,56),M(),g=(m&=7)+1|0,w=0|ur(0|d,0|c,45),M();r:do{if(0|z(127&w)){if(d=0|ur(0|d,0|c,52),M(),!(d&=15)){c=6;break}for(c=1;;){if(!(!((w=0|hr(7,0,3*(15-c|0)|0))&A|0)&!((0|M())&e))){c=7;break r}if(!(c>>>0>>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|hr(0|g,0,56),e=M()|-117440513&e,n[(_=u)>>2]=0,n[_+4>>2]=0,A|=w}else p=0|or(0|(p=0|tr(0|p,0|f,1,0)),0|M(),0|r,0|i),f=0|M();b=0|tr(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|tr(0|o,0|l,1,0),!((0|(l=0|M()))<(0|i)|(0|l)==(0|i)&o>>>0>>0))break t;A=0|n[(e=B+(o<<3)|0)>>2],e=0|n[e+4>>2]}}}while(0);if(w=0|tr(0|r,0|i,5,0),(_=0|M())>>>0<0|!(0|_)&w>>>0<11){P=85;break}if(w=0|sr(0|r,0|i,6,0),M(),!(w=0|er(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|ur(0|o,0|l,56),M(),A=(d&=7)+1|0,p=-117440513&l,_=0|ur(0|o,0|l,45),M();t:do{if(0|z(127&_)){if(f=0|ur(0|o,0|l,52),M(),0|(f&=15))for(u=1;;){if(!(!(o&(_=0|hr(7,0,3*(15-u|0)|0))|0)&!(p&(0|M()))))break t;if(!(u>>>0>>0))break;u=u+1|0}o|=l=0|hr(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|tr(0|e,0|m,1,0),_=0|M()):_=m}if(g=0|tr(0|g,0|y,1,0),!((0|(y=0|M()))<(0|i)|(0|y)==(0|i)&g>>>0>>0))break;m=_}if(T){if(b=C>>>0>15,x=0|hr(0|C,0,52),v=0|M(),!N){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|tr(0|o,0|u,1,0),u=0|M()),A=0|tr(0|A,0|l,1,0),(0|(l=0|M()))<(0|i)|(0|l)==(0|i)&A>>>0>>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|ur(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>=E>>>0){p=C;do{N=0|hr(7,0,3*(14-p|0)|0),p=p+1|0,c|=N,d=0|M()|d}while(p>>>0>>0)}}else c=h,d=a;m=0|lr(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[(N=R+(m<<3)|0)+4>>2]))==(0|d)&&(0|n[N>>2])==(0|c)){P=65;break}m=0|or(0|(N=0|tr(0|m,0|y,1,0)),0|M(),0|r,0|i),y=0|M(),f=0|tr(0|f,0|p,1,0),p=0|M(),N=R+(m<<3)|0}while((0|n[N>>2])!=(0|c)||(0|n[N+4>>2])!=(0|d));if(65==(0|P)&&(P=0,!0&100663296==(117440512&g)))break;n[(N=t+(o<<3)|0)>>2]=h,n[N+4>>2]=a,o=0|tr(0|o,0|u,1,0),u=0|M()}}while(0);if(l=0|tr(0|l,0|A,1,0),!((0|(A=0|M()))<(0|i)|(0|A)==(0|i)&l>>>0>>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(gr(0|R,0,0|s),mr(0|B,0|w,e<<3),Jt(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,620,27132);else{if(41==(0|P))return Jt(B),Jt(R),0|(P=10);if(48==(0|P))return Jt(B),Jt(R),0|(P=13);80==(0|P)?S(27795,27122,711,27132):81==(0|P)?S(27795,27122,723,27132):85==(0|P)&&(mr(0|t,0|B,r<<3),P=89)}return 21==(0|P)?(Jt(B),Jt(R),0|(P=5)):27==(0|P)?(Jt(B),Jt(R),0|(P=a)):89==(0|P)?(Jt(B),Jt(R),0|(P=0)):0},_constructCell:function(e,t,r,s){r|=0,s|=0;var a=0,o=0,l=0,A=0,u=0,h=0;if((e|=0)>>>0>15)return 0|(s=4);if((t|=0)>>>0>121)return 0|(s=17);l=0|hr(0|e,0,52),a=0|M(),A=0|hr(0|t,0,45),a=0|a|M()|134225919;e:do{if((0|e)>=1){for(A=1,l=!!(0|i[20528+t|0]),o=-1;;){if((t=0|n[r+(A+-1<<2)>>2])>>>0>6){a=18,t=10;break}if(!(!(0|t)|1^l)){if(1==(0|t)){a=19,t=10;break}l=0}if(u=0|hr(7,0,0|(h=3*(15-A|0)|0)),a&=~M(),o=(t=0|hr(0|t,((0|t)<0)<<31>>31,0|h))|o&~u,a=0|M()|a,!((0|A)<(0|e)))break e;A=A+1|0}if(10==(0|t))return 0|a}else o=-1}while(0);return n[(h=s)>>2]=o,n[h+4>>2]=a,0|(h=0)},_destroyLinkedMultiPolygon:xt,_directedEdgeToBoundary:Be,_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|ur(0|e,0|t,56),M(),o=0|L(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|Be(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|Be(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|Be(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:Jt,_getBaseCellNumber:Ve,_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|ur(0|e,0|t,56),M(),a=0|L(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:pt,_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|ur(0|(t|=0),0|(r|=0),52),M(),u=15&o,n[c>>2]=u,A=0|ur(0|t,0|r,45),M(),A&=127;e:do{if(0|z(A)){if(0|u)for(a=1;;){if(!(!((h=0|hr(7,0,3*(15-a|0)|0))&t|0)&!((0|M())&r))){o=0;break e}if(!(a>>>0>>0))break;a=a+1|0}if(!(1&o))return h=0|hr(u+1|0,0,52),d=M()|-15728641&r,d=0|e((h|t)&~(c=0|hr(7,0,3*(14-u|0)|0)),d&~M(),i),P=s,0|d;o=1}else o=0}while(0);if(!(a=0|it(t,r,l))){o?(qe(l,c,d),h=5):(Ue(l,c,d),h=6);e:do{if(0|z(A))if(u)for(a=1;;){if(!(!((A=0|hr(7,0,3*(15-a|0)|0))&t|0)&!((0|M())&r))){t=2;break e}if(!(a>>>0>>0)){t=5;break}a=a+1|0}else t=5;else t=2}while(0);gr(0|i,-1,t<<2);e:do{if(o)for(l=0;;){if(Oe(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(Le(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)},_getIndexDigit:function(e,t,r,i){return i|=0,((r|=0)+-1|0)>>>0>14?0|(i=4):(r=0|ur(0|(e|=0),0|(t|=0),3*(15-r|0)|0),M(),n[i>>2]=7&r,0|(i=0))},_getNumCells:ft,_getPentagons:at,_getRes0Cells:function(e){e|=0;var t=0,r=0,i=0;t=0;do{hr(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|ur(0|(e|=0),0|(t|=0),52),M(),15&t},_greatCircleDistanceKm:dt,_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:D,_gridDiskDistances:I,_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|wt(e|=0,t|=0,e,t,l=o+12|0))?(P=o,0|(A=a)):0|(e=0|wt(e,t,r,i,A))?(P=o,0|(A=e)):(l=0|Me(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,N=0,E=0;if(o=P,P=P+48|0,u=o+12|0,N=o,!(l=0|wt(e|=0,t|=0,e,t,a=o+24|0))&&!(l=0|wt(e,t,r,i,u))){T=((0|(w=0|Me(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|wt(e,t,e,t,a)&&S(27795,27538,692,27747),0|wt(e,t,r,i,u)&&S(27795,27538,697,27747),Ee(a),Ee(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[N>>2]=r,n[(f=N+4|0)>>2]=i,n[(m=N+8|0)>>2]=l;e:do{if((0|w)<0)l=0;else for(g=0,y=0;;){E=b*(c=+(y>>>0)+4294967296*+(0|g))+ +(0|r),h=v*c+ +(0|i),c=p*c+ +(0|l),r=~~+fr(+E),u=~~+fr(+h),l=~~+fr(+c),E=+A(+(+(0|r)-E)),h=+A(+(+(0|u)-h)),c=+A(+(+(0|l)-c));do{if(!(E>h&E>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[N>>2]=r,n[f>>2]=i,n[m>>2]=l,Ce(N),0|(l=0|Tt(e,t,N,s+(y<<3)|0)))break e;if(!((0|g)<(0|T)|(0|g)==(0|T)&y>>>0>>0)){l=0;break e}r=0|tr(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|(N=l)}return P=o,0|(N=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|wt(e|=0,t|=0,e,t,l=a+12|0))||(o=0|wt(e,t,r,i,A))?(P=a,0|(A=o)):(i=0|tr(0|(i=0|Me(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))},_gridRing:function(e,t,r,i){return 0|O(e|=0,t|=0,r|=0,i|=0)?(gr(0|i,0,48*r|0),0|(i=0|k(e,t,r,i))):0|(i=0)},_gridRingUnsafe:O,_i64Add:tr,_i64Subtract:rr,_isPentagon:He,_isResClassIII:function(e,t){return t=0|ur(0|(e|=0),0|(t|=0),52),M(),1&t},_isValidCell:ze,_isValidDirectedEdge:Re,_isValidIndex:function(e,t){e|=0;var r=0,n=0,s=0,a=0;if(!0&134217728==(-16777216&(t|=0))&&(n=0|ur(0|e,0|t,52),M(),n&=15,r=0|ur(0|e,0|t,45),M(),(r&=127)>>>0<=121)&&!(613566756&(a=0|hr(0|(s=0|ur(0|e,0|t,0|(a=3*(15^n)|0))),0|M(),0|a))&(0|rr(-1227133514,-1171,0|a,0|(s=0|M()))))&!(4681&s&M())&&15==(0|n)|!(0|(a=0|ur(0|(0|hr(0|~e,0|~t,0|(a=19+(3*n|0)|0))),0|M(),0|a)))&!(0|M())){if(!(0|i[20528+r|0]))return 0|(a=1);if(!(0|e)&!(0|(r=8191&t)))return 0|(a=1);if(a=0|cr(0|e,0|r),M(),(63-a|0)%3|0)return 0|(a=1)}return 0|Re(e,t)?0|(a=1):0|(a=1&!!(0|Gt(e,t)))},_isValidVertex:Gt,_latLngToCell:tt,_llvm_ctlz_i64:cr,_llvm_maxnum_f64:dr,_llvm_minnum_f64:pr,_llvm_round_f64:fr,_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|Ne(r,s))||(r=0|Tt(e,t,s,n)),P=a,0|r},_malloc:Kt,_maxFaceCount:function(e,t,r){r|=0;var i=0,s=0;if(s=0|ur(0|(e|=0),0|(t|=0),45),M(),!(0|z(127&s)))return s=2,n[r>>2]=s,0;if(s=0|ur(0|e,0|t,52),M(),!(s&=15))return s=5,n[r>>2]=s,0;for(i=1;;){if(!(!((0|hr(7,0,3*(15-i|0)|0))&e|0)&!((0|M())&t))){i=2,e=6;break}if(!(i>>>0>>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|ft(15,t)):(s=0|ar(0|e,0|(r=((0|e)<0)<<31>>31),3,0),i=0|M(),r=0|tr(0|e,0|r,1,0),r=0|tr(0|(r=0|ar(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|Pt(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,Bt(o,a),!(r=0|re(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>>0?(n[(r=l)>>2]=t,n[r+4>>2]=o,r=o):t=a,A=0|tr(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);Ge(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|Pt(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|er(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}Dt(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=+Z(r),g*=+X(r),h=+A(+ +s[r>>3]),h=g/+c(+ +pr(+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(pt(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(Et(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{We(r,u,t,f),p=f,p=0|tr(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,Et(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:mr,_memset:gr,_originToDirectedEdges:function(e,t,r){r|=0;var i,s=0;return i=!(0|He(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,N=0,E=0,C=0,R=0,B=0,D=0,I=0,L=0,O=0,k=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|Pt(r|=0)))return P=l,0|(k=A);if(!(k=0|Kt(32+(n[(p=e+8|0)>>2]<<5)|0)))return P=l,0|(k=13);if(Dt(e,k),!(A=0|Pt(r))){if(O=0|n[(L=e)+4>>2],n[(A=d)>>2]=n[L>>2],n[A+4>>2]=O,Bt(d,s),A=0|re(s,t,a))L=0,O=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>>0?(n[(A=a)>>2]=r,n[A+4>>2]=h,A=h):r=u,L=0|tr(0|r,0|A,12,0),O=0|M(),n[(A=a)>>2]=L,n[A+4>>2]=O,A=0}if(!A){if(!(r=0|er(L,8)))return Jt(k),P=l,0|(k=13);if(!(c=0|er(L,8)))return Jt(k),Jt(r),P=l,0|(k=13);n[(D=s)>>2]=0,n[D+4>>2]=0,I=0|n[(D=e)+4>>2],n[(A=d)>>2]=n[D>>2],n[A+4>>2]=I,A=0|V(d,L,O,t,s,r,c);e:do{if(A)Jt(r),Jt(c),Jt(k);else{t:do{if((0|n[p>>2])>0){for(h=e+12|0,u=0;A=0|V((0|n[h>>2])+(u<<3)|0,L,O,t,s,r,c),u=u+1|0,!(0|A);)if((0|u)>=(0|n[p>>2]))break t;Jt(r),Jt(c),Jt(k);break e}}while(0);(0|O)>0|!(0|O)&L>>>0>0&&gr(0|c,0,L<<3),D=0|n[(I=s)+4>>2];t:do{if((0|D)>0|!(0|D)&(0|n[I>>2])>>>0>0){C=r,R=c,B=r,D=c,I=r,A=r,S=r,N=c,E=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|F(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|er(7,4))&&(q(p,t,1,a,c,7,0,0),Jt(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|lr(0|y,0|b,0|L,0|O),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|O)|(0|m)==(0|O)&g>>>0>L>>>0)break r;if((0|d)==(0|y)&(0|t)==(0|b)){c=u,d=h;break i}f=0|or(0|(c=0|tr(0|f,0|p,1,0)),0|M(),0|L,0|O),p=0|M(),g=0|tr(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}nt(y,b,o),0|It(e,k,o)&&(g=0|tr(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|tr(0|v,0|_,1,0),_=0|M(),w=0|tr(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>>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|tr(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=E,_=I,w=N,T=R,r=S,E=A,N=B,S=x,A=v,I=D,D=_,B=w,R=C,C=T}Jt(B),Jt(D),Jt(k),A=1;break e}A=c}while(0);Jt(k),Jt(r),Jt(A),A=0}}while(0);return P=l,0|(k=A)}}return Jt(k),P=l,0|(k=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,Nt(d=A+80|0,e|=0,t|=0,r|=0),ot(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>>0)){m=4;break}if(c=h,h=0|tr(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(Et(r),!(0|(e=0|n[(t=r)>>2]))&!(0|(t=0|n[t+4>>2]))){m=10;break}lt(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])&&Jt(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,lt(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:yr,_sbrk:br,_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|ur(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(ot(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>>0)){u=10;break e}n[(d=i+(u<<3)|0)>>2]=h,n[d+4>>2]=c,u=0|tr(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|tr(0|p,0|f,1,0),!((0|(f=0|M()))<(0|r)|(0|f)==(0|r)&p>>>0>>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|We(u,h,i,a)),A=0|tr(0|n[(u=a)>>2],0|n[u+4>>2],0|A,0|l),l=0|M(),h))){l=12;break}if(c=0|tr(0|c,0|d,1,0),!((0|(d=0|M()))<(0|r)|(0|d)==(0|r)&c>>>0>>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|ur(0|(e|=0),0|(t|=0),56),M(),l&=7,0|(i=0|it(e,A=-2130706433&t|134217728,a))?(P=o,0|(A=i)):(t=0|ur(0|e,0|t,52),M(),t&=15,0|He(e,A)?Fe(a,t,l,1,s):ke(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:K,g:function(e,t,r){T.set(T.subarray(t,t+r),e)},h:function(e){var t=K(),r=16777216,i=2130706432;if(e>i)return!1;for(var n=Math.max(t,16777216);n>1]=t;break;case"i32":S[e>>2]=t;break;case"i64":Q=[t>>>0,($=t,+V($)>=1?$>0?(0|j(+G($/4294967296),4294967295))>>>0:~~+z(($-+(~~$>>>0))/4294967296)>>>0:0)],S[e>>2]=Q[0],S[e+4>>2]=Q[1];break;case"float":N[e>>2]=t;break;case"double":E[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 N[e>>2];case"double":return E[e>>3];default:fe("invalid type for getValue: "+t)}return null},X)if(Z(X)||(ne=X,X=r.locateFile?r.locateFile(ne,p):p+ne),a||l){var Ae=h(X);T.set(Ae,8)}else{W++,r.monitorRunDependencies&&r.monitorRunDependencies(W);var ue=function(e){e.byteLength&&(e=new Uint8Array(e)),T.set(e,8),r.memoryInitializerRequest&&delete r.memoryInitializerRequest.response,function(){if(W--,r.monitorRunDependencies&&r.monitorRunDependencies(W),0==W&&H){var e=H;H=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||(I(q),I(L),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)U(r.postRun.shift());I(O)}()))}W>0||(!function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)k(r.preRun.shift());I(F)}(),W>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(H=function e(){se||pe(),se||(H=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 DA?DA:{}),IA="number",FA={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",16:"Index argument was not valid",17:"Base cell number was outside of acceptable range",18:"Child indexing digits invalid",19:"Child indexing digits refer to a deleted subsequence"},qA={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function LA(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 OA(e,t){return LA(FA,e,2===arguments.length?{value:t}:{})}function kA(e,t){return LA(qA,e,2===arguments.length?{value:t}:{})}function UA(e){if(0!==e)throw OA(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 VA={};[["sizeOfH3Index",IA],["sizeOfLatLng",IA],["sizeOfCellBoundary",IA],["sizeOfGeoLoop",IA],["sizeOfGeoPolygon",IA],["sizeOfLinkedGeoPolygon",IA],["sizeOfCoordIJ",IA],["readInt64AsDoubleFromPointer",IA],["isValidCell",IA,[IA,IA]],["isValidIndex",IA,[IA,IA]],["latLngToCell",IA,[IA,IA,IA,IA]],["cellToLatLng",IA,[IA,IA,IA]],["cellToBoundary",IA,[IA,IA,IA]],["maxGridDiskSize",IA,[IA,IA]],["gridDisk",IA,[IA,IA,IA,IA]],["gridDiskDistances",IA,[IA,IA,IA,IA,IA]],["gridRing",IA,[IA,IA,IA,IA]],["gridRingUnsafe",IA,[IA,IA,IA,IA]],["maxPolygonToCellsSize",IA,[IA,IA,IA,IA]],["polygonToCells",IA,[IA,IA,IA,IA]],["maxPolygonToCellsSizeExperimental",IA,[IA,IA,IA,IA]],["polygonToCellsExperimental",IA,[IA,IA,IA,IA,IA,IA]],["cellsToLinkedMultiPolygon",IA,[IA,IA,IA]],["destroyLinkedMultiPolygon",null,[IA]],["compactCells",IA,[IA,IA,IA,IA]],["uncompactCells",IA,[IA,IA,IA,IA,IA,IA]],["uncompactCellsSize",IA,[IA,IA,IA,IA,IA]],["isPentagon",IA,[IA,IA]],["isResClassIII",IA,[IA,IA]],["getBaseCellNumber",IA,[IA,IA]],["getResolution",IA,[IA,IA]],["getIndexDigit",IA,[IA,IA,IA]],["constructCell",IA,[IA,IA,IA,IA]],["maxFaceCount",IA,[IA,IA,IA]],["getIcosahedronFaces",IA,[IA,IA,IA]],["cellToParent",IA,[IA,IA,IA,IA]],["cellToChildren",IA,[IA,IA,IA,IA]],["cellToCenterChild",IA,[IA,IA,IA,IA]],["cellToChildrenSize",IA,[IA,IA,IA,IA]],["cellToChildPos",IA,[IA,IA,IA,IA]],["childPosToCell",IA,[IA,IA,IA,IA,IA,IA]],["areNeighborCells",IA,[IA,IA,IA,IA,IA]],["cellsToDirectedEdge",IA,[IA,IA,IA,IA,IA]],["getDirectedEdgeOrigin",IA,[IA,IA,IA]],["getDirectedEdgeDestination",IA,[IA,IA,IA]],["isValidDirectedEdge",IA,[IA,IA]],["directedEdgeToCells",IA,[IA,IA,IA]],["originToDirectedEdges",IA,[IA,IA,IA]],["directedEdgeToBoundary",IA,[IA,IA,IA]],["gridDistance",IA,[IA,IA,IA,IA,IA]],["gridPathCells",IA,[IA,IA,IA,IA,IA]],["gridPathCellsSize",IA,[IA,IA,IA,IA,IA]],["cellToLocalIj",IA,[IA,IA,IA,IA,IA,IA]],["localIjToCell",IA,[IA,IA,IA,IA,IA]],["getHexagonAreaAvgM2",IA,[IA,IA]],["getHexagonAreaAvgKm2",IA,[IA,IA]],["getHexagonEdgeLengthAvgM",IA,[IA,IA]],["getHexagonEdgeLengthAvgKm",IA,[IA,IA]],["greatCircleDistanceM",IA,[IA,IA]],["greatCircleDistanceKm",IA,[IA,IA]],["greatCircleDistanceRads",IA,[IA,IA]],["cellAreaM2",IA,[IA,IA,IA]],["cellAreaKm2",IA,[IA,IA,IA]],["cellAreaRads2",IA,[IA,IA,IA]],["edgeLengthM",IA,[IA,IA,IA]],["edgeLengthKm",IA,[IA,IA,IA]],["edgeLengthRads",IA,[IA,IA,IA]],["getNumCells",IA,[IA,IA]],["getRes0Cells",IA,[IA]],["res0CellCount",IA],["getPentagons",IA,[IA,IA]],["pentagonCount",IA],["cellToVertex",IA,[IA,IA,IA,IA]],["cellToVertexes",IA,[IA,IA,IA]],["vertexToLatLng",IA,[IA,IA,IA]],["isValidVertex",IA,[IA,IA]]].forEach(function(e){VA[e[0]]=DA.cwrap.apply(DA,e)});var zA=16,GA=VA.sizeOfH3Index(),jA=VA.sizeOfLatLng(),WA=VA.sizeOfCellBoundary(),HA=VA.sizeOfGeoPolygon(),$A=VA.sizeOfGeoLoop();VA.sizeOfLinkedGeoPolygon(),VA.sizeOfCoordIJ();var QA=Math.pow(2,32)-1;var XA=/[^0-9a-fA-F]/;function YA(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||XA.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),zA);return[parseInt(e.substring(e.length-8),zA),t]}function ZA(e){if(e>=0)return e.toString(zA);var t=KA(8,(e&=2147483647).toString(zA));return t=(parseInt(t[0],zA)+8).toString(zA)+t.substring(1)}function KA(e,t){for(var r=e-t.length,i="",n=0;n15||Math.floor(e)!==e)throw OA(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=DA._calloc(HA),s=0+$A,a=s+4;if(JA(e[0],n+0,t),i>0){r=DA._calloc(i,$A);for(var o=0;oQA)throw kA(1001,e);return e}((i=s,VA.readInt64AsDoubleFromPointer(i))),o=DA._calloc(a,GA);try{return UA(VA.polygonToCells(n,t,0,o)),function(e,t){for(var r=[],i=0;i0){for(var n=DA.getValue(e+r,"i32"),s=0;s170&&(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=v(t.__hexCenter,2),A=n[0],u=n[1],c=0===i?t.__hexGeoJson:t.__hexGeoJson.map(function(e){var t=v(e,2),r=t[0],n=t[1];return[[r,u],[n,A]].map(function(e){var t=v(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 SA([c],0,de,!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=de/(r+1);t.geometry.setAttribute("surfaceRadius",Po(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 oe(m).to(p,e.hexTransitionDuration).easing(te.Quadratic.InOut).onUpdate(f).onComplete(function(){e.tweenGroup.remove(this)}).start()));if(!e.hexBinMerge){var g=o(r),y=a(r);[g,y].forEach(function(e){if(!h.hasOwnProperty(e)){var t=Co(e);h[e]=cl(new lu.MeshLambertMaterial({color:Eo(e),transparent:t<1,opacity:t,side:lu.DoubleSide}),ul)}}),t.material=[g,y].map(function(e){return h[e]})}}).digest(u),e.hexBinMerge){var c=u.length?(uu.mergeGeometries||uu.mergeBufferGeometries)(u.map(function(t){var r=e.dataMapper.getObj(t),i=r.geometry.toNonIndexed();r.updateMatrix(),i.applyMatrix4(r.matrix);var n=Ro(a(t)),s=Ro(o(t)),l=i.getAttribute("position").count,A=i.groups[0].count;return i.setAttribute("color",Po(w(new Array(l)).map(function(e,t){return t>=A?n:s}),4)),i})):new lu.BufferGeometry,d=new lu.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:lu.DoubleSide});d.onBeforeCompile=function(e){d.userData.shader=ul(e)};var p=new lu.Mesh(c,d);p.__globeObjType="hexBinPoints",p.__data=u,e.dataMapper.clear(),he(e.scene),e.scene.add(p)}}});const cu="183",du=0,pu=1,fu=2,mu=100,gu=101,yu=102,bu=200,xu=201,vu=202,_u=203,wu=204,Tu=205,Mu=206,Su=207,Nu=208,Eu=209,Cu=210,Ru=0,Bu=1,Pu=2,Du=3,Iu=4,Fu=5,qu=6,Lu=7,Ou=301,ku=302,Uu=1e3,Vu=1001,zu=1002,Gu=1003,ju=1004,Wu=1005,Hu=1006,$u=1007,Qu=1008,Xu=1009,Yu=1010,Zu=1011,Ku=1012,Ju=1013,eh=1014,th=1015,rh=1016,ih=1017,nh=1018,sh=1020,ah=35902,oh=35899,lh=1022,Ah=1023,uh=1026,hh=1027,ch=1028,dh=1029,ph=1030,fh=1031,mh=1033,gh=33776,yh=33777,bh=33778,xh=33779,vh=35840,_h=35841,wh=35842,Th=35843,Mh=36196,Sh=37492,Nh=37496,Eh=37488,Ch=37489,Rh=37490,Bh=37491,Ph=37808,Dh=37809,Ih=37810,Fh=37811,qh=37812,Lh=37813,Oh=37814,kh=37815,Uh=37816,Vh=37817,zh=37818,Gh=37819,jh=37820,Wh=37821,Hh=36492,$h=36283,Qh=36284,Xh=36285,Yh=36286,Zh="",Kh="srgb",Jh="srgb-linear",ec="linear",tc="srgb",rc=7680,ic=512,nc=513,sc=514,ac=515,oc=516,lc=517,Ac=518,uc=519,hc=35044,cc=35048,dc=2e3,pc=2001,fc="compute",mc="render",gc="depthTextureCompare";function yc(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function bc(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const xc={};function vc(...e){const t="THREE."+e.shift();console.log(t,...e)}function _c(e){const t=e[0];if("string"==typeof t&&t.startsWith("TSL:")){const t=e[1];t&&t.isStackTrace?e[0]+=" "+t.getLocation():e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function wc(...e){const t="THREE."+(e=_c(e)).shift();{const r=e[0];r&&r.isStackTrace?console.warn(r.getError(t)):console.warn(t,...e)}}function Tc(...e){const t="THREE."+(e=_c(e)).shift();{const r=e[0];r&&r.isStackTrace?console.error(r.getError(t)):console.error(t,...e)}}function Mc(...e){const t=e.join(" ");t in xc||(xc[t]=!0,wc(...e))}const Sc={[Ru]:1,[Pu]:6,[Iu]:7,[Du]:5,[Bu]:0,[qu]:2,[Lu]:4,[Fu]:3};class Nc{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>8&255]+Ec[e>>16&255]+Ec[e>>24&255]+"-"+Ec[255&t]+Ec[t>>8&255]+"-"+Ec[t>>16&15|64]+Ec[t>>24&255]+"-"+Ec[63&r|128]+Ec[r>>8&255]+"-"+Ec[r>>16&255]+Ec[r>>24&255]+Ec[255&i]+Ec[i>>8&255]+Ec[i>>16&255]+Ec[i>>24&255]).toLowerCase()}function Dc(e,t,r){return Math.max(t,Math.min(r,e))}function Ic(e,t){return(e%t+t)%t}function Fc(e,t,r){return(1-r)*e+r*t}function qc(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 Lc(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 Oc={DEG2RAD:Rc,RAD2DEG:Bc,generateUUID:Pc,clamp:Dc,euclideanModulo:Ic,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:Fc,damp:function(e,t,r,i){return Fc(e,t,1-Math.exp(-r*i))},pingpong:function(e,t=1){return t-Math.abs(Ic(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&&(Cc=e);let t=Cc+=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*Rc},radToDeg:function(e){return e*Bc},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:wc("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}},normalize:Lc,denormalize:qc};class kc{constructor(e=0,t=0){kc.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=Dc(this.x,e.x,t.x),this.y=Dc(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Dc(this.x,e,t),this.y=Dc(this.y,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dc(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(Dc(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 Uc{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],h=n[s+0],c=n[s+1],d=n[s+2],p=n[s+3];if(u!==p||o!==h||l!==c||A!==d){let e=o*h+l*c+A*d+u*p;e<0&&(h=-h,c=-c,d=-d,p=-p,e=-e);let t=1-a;if(e<.9995){const r=Math.acos(e),i=Math.sin(r);t=Math.sin(t*r)/i,o=o*t+h*(a=Math.sin(a*r)/i),l=l*t+c*a,A=A*t+d*a,u=u*t+p*a}else{o=o*t+h*a,l=l*t+c*a,A=A*t+d*a,u=u*t+p*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:wc("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(Dc(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){let r=e._x,i=e._y,n=e._z,s=e._w,a=this.dot(e);a<0&&(r=-r,i=-i,n=-n,s=-s,a=-a);let o=1-t;if(a<.9995){const e=Math.acos(a),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+r*t,this._y=this._y*o+i*t,this._z=this._z*o+n*t,this._w=this._w*o+s*t,this._onChangeCallback()}else this._x=this._x*o+r*t,this._y=this._y*o+i*t,this._z=this._z*o+n*t,this._w=this._w*o+s*t,this.normalize();return 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 Vc{constructor(e=0,t=0,r=0){Vc.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(Gc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Gc.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=Dc(this.x,e.x,t.x),this.y=Dc(this.y,e.y,t.y),this.z=Dc(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Dc(this.x,e,t),this.y=Dc(this.y,e,t),this.z=Dc(this.z,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dc(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 zc.copy(this).projectOnVector(e),this.sub(zc)}reflect(e){return this.sub(zc.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(Dc(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 zc=new Vc,Gc=new Uc;class jc{constructor(e,t,r,i,n,s,a,o,l){jc.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(Wc.makeScale(e,t)),this}rotate(e){return this.premultiply(Wc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Wc.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 Wc=new jc,Hc=(new jc).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$c=(new jc).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Qc(){const e={enabled:!0,workingColorSpace:Jh,spaces:{},convert:function(e,t,r){return!1!==this.enabled&&t!==r&&t&&r?(this.spaces[t].transfer===tc&&(e.r=Yc(e.r),e.g=Yc(e.g),e.b=Yc(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===tc&&(e.r=Zc(e.r),e.g=Zc(e.g),e.b=Zc(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===Zh?ec:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},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 Mc("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(t,r)},toWorkingColorSpace:function(t,r){return Mc("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({[Jh]:{primaries:t,whitePoint:i,transfer:ec,toXYZ:Hc,fromXYZ:$c,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:Kh},outputColorSpaceConfig:{drawingBufferColorSpace:Kh}},[Kh]:{primaries:t,whitePoint:i,transfer:tc,toXYZ:Hc,fromXYZ:$c,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:Kh}}}),e}const Xc=Qc();function Yc(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Zc(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let Kc;class Jc{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===Kc&&(Kc=bc("canvas")),Kc.width=e.width,Kc.height=e.height;const t=Kc.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),r=Kc}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=bc("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;e1),this.pmremVersion=0}get width(){return this.source.getSize(nd).x}get height(){return this.source.getSize(nd).y}get depth(){return this.source.getSize(nd).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){wc(`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:wc(`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 Uu:e.x=e.x-Math.floor(e.x);break;case Vu:e.x=e.x<0?0:1;break;case zu: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 Uu:e.y=e.y-Math.floor(e.y);break;case Vu:e.y=e.y<0?0:1;break;case zu: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++}}sd.DEFAULT_IMAGE=null,sd.DEFAULT_MAPPING=300,sd.DEFAULT_ANISOTROPY=1;class ad{constructor(e=0,t=0,r=0,i=1){ad.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)o&&e>g?eg?o1);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>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),null!==this.pivot&&(i.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),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;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(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),null!==e.pivot&&(this.pivot=e.pivot.clone()),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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;to+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(Od)))}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 Ld;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}const Ud={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},Vd={h:0,s:0,l:0},zd={h:0,s:0,l:0};function Gd(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 jd{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=Kh){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Xc.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=Xc.workingColorSpace){return this.r=e,this.g=t,this.b=r,Xc.colorSpaceToWorking(this,i),this}setHSL(e,t,r,i=Xc.workingColorSpace){if(e=Ic(e,1),t=Dc(t,0,1),r=Dc(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=Gd(n,i,e+1/3),this.g=Gd(n,i,e),this.b=Gd(n,i,e-1/3)}return Xc.colorSpaceToWorking(this,i),this}setStyle(e,t=Kh){function r(t){void 0!==t&&parseFloat(t)<1&&wc("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:wc("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);wc("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Kh){const r=Ud[e.toLowerCase()];return void 0!==r?this.setHex(r,t):wc("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=Yc(e.r),this.g=Yc(e.g),this.b=Yc(e.b),this}copyLinearToSRGB(e){return this.r=Zc(e.r),this.g=Zc(e.g),this.b=Zc(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Kh){return Xc.workingToColorSpace(Wd.copy(this),e),65536*Math.round(Dc(255*Wd.r,0,255))+256*Math.round(Dc(255*Wd.g,0,255))+Math.round(Dc(255*Wd.b,0,255))}getHexString(e=Kh){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Xc.workingColorSpace){Xc.workingToColorSpace(Wd.copy(this),t);const r=Wd.r,i=Wd.g,n=Wd.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+(i0&&(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}}const $d=new Vc,Qd=new Vc,Xd=new Vc,Yd=new Vc,Zd=new Vc,Kd=new Vc,Jd=new Vc,ep=new Vc,tp=new Vc,rp=new Vc,ip=new ad,np=new ad,sp=new ad;class ap{constructor(e=new Vc,t=new Vc,r=new Vc){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),$d.subVectors(e,t),i.cross($d);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){$d.subVectors(i,t),Qd.subVectors(r,t),Xd.subVectors(e,t);const s=$d.dot($d),a=$d.dot(Qd),o=$d.dot(Xd),l=Qd.dot(Qd),A=Qd.dot(Xd),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,Yd)&&(Yd.x>=0&&Yd.y>=0&&Yd.x+Yd.y<=1)}static getInterpolation(e,t,r,i,n,s,a,o){return null===this.getBarycoord(e,t,r,i,Yd)?(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,Yd.x),o.addScaledVector(s,Yd.y),o.addScaledVector(a,Yd.z),o)}static getInterpolatedAttribute(e,t,r,i,n,s){return ip.setScalar(0),np.setScalar(0),sp.setScalar(0),ip.fromBufferAttribute(e,t),np.fromBufferAttribute(e,r),sp.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(ip,n.x),s.addScaledVector(np,n.y),s.addScaledVector(sp,n.z),s}static isFrontFacing(e,t,r,i){return $d.subVectors(r,t),Qd.subVectors(e,t),$d.cross(Qd).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 $d.subVectors(this.c,this.b),Qd.subVectors(this.a,this.b),.5*$d.cross(Qd).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ap.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ap.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,n){return ap.getInterpolation(e,this.a,this.b,this.c,t,r,i,n)}containsPoint(e){return ap.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ap.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;Zd.subVectors(i,r),Kd.subVectors(n,r),ep.subVectors(e,r);const o=Zd.dot(ep),l=Kd.dot(ep);if(o<=0&&l<=0)return t.copy(r);tp.subVectors(e,i);const A=Zd.dot(tp),u=Kd.dot(tp);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(Zd,s);rp.subVectors(e,n);const c=Zd.dot(rp),d=Kd.dot(rp);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(Kd,a);const f=A*d-c*u;if(f<=0&&u-A>=0&&c-d>=0)return Jd.subVectors(n,i),a=(u-A)/(u-A+(c-d)),t.copy(i).addScaledVector(Jd,a);const m=1/(f+p+h);return s=p*m,a=h*m,t.copy(r).addScaledVector(Zd,s).addScaledVector(Kd,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class op{constructor(e=new Vc(1/0,1/0,1/0),t=new Vc(-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=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,Ap),Ap.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(gp),yp.subVectors(this.max,gp),hp.subVectors(e.a,gp),cp.subVectors(e.b,gp),dp.subVectors(e.c,gp),pp.subVectors(cp,hp),fp.subVectors(dp,cp),mp.subVectors(hp,dp);let t=[0,-pp.z,pp.y,0,-fp.z,fp.y,0,-mp.z,mp.y,pp.z,0,-pp.x,fp.z,0,-fp.x,mp.z,0,-mp.x,-pp.y,pp.x,0,-fp.y,fp.x,0,-mp.y,mp.x,0];return!!vp(t,hp,cp,dp,yp)&&(t=[1,0,0,0,1,0,0,0,1],!!vp(t,hp,cp,dp,yp)&&(bp.crossVectors(pp,fp),t=[bp.x,bp.y,bp.z],vp(t,hp,cp,dp,yp)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ap).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Ap).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()||(lp[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),lp[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),lp[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),lp[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),lp[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),lp[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),lp[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),lp[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(lp)),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 lp=[new Vc,new Vc,new Vc,new Vc,new Vc,new Vc,new Vc,new Vc],Ap=new Vc,up=new op,hp=new Vc,cp=new Vc,dp=new Vc,pp=new Vc,fp=new Vc,mp=new Vc,gp=new Vc,yp=new Vc,bp=new Vc,xp=new Vc;function vp(e,t,r,i,n){for(let s=0,a=e.length-3;s<=a;s+=3){xp.fromArray(e,s);const a=n.x*Math.abs(xp.x)+n.y*Math.abs(xp.y)+n.z*Math.abs(xp.z),o=t.dot(xp),l=r.dot(xp),A=i.dot(xp);if(Math.max(-Math.max(o,l,A),Math.min(o,l,A))>a)return!1}return!0}const _p=wp();function wp(){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 Tp(e){Math.abs(e)>65504&&wc("DataUtils.toHalfFloat(): Value out of range."),e=Dc(e,-65504,65504),_p.floatView[0]=e;const t=_p.uint32View[0],r=t>>23&511;return _p.baseTable[r]+((8388607&t)>>_p.shiftTable[r])}function Mp(e){const t=e>>10;return _p.uint32View[0]=_p.mantissaTable[_p.offsetTable[t]+(1023&e)]+_p.exponentTable[t],_p.floatView[0]}const Sp=new Vc,Np=new kc;let Ep=0;class Cp{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:Ep++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=r,this.usage=hc,this.updateRanges=[],this.gpuType=th,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;ithis.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;Fp.subVectors(e,this.center);const t=Fp.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),r=.5*(e-this.radius);this.center.addScaledVector(Fp,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):(qp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Fp.copy(e.center).add(qp)),this.expandByPoint(Fp.copy(e.center).sub(qp))),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}}let Op=0;const kp=new Ad,Up=new qd,Vp=new Vc,zp=new op,Gp=new op,jp=new Vc;class Wp extends Nc{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Op++}),this.uuid=Pc(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(function(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}(e)?Bp:Rp)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,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 jc).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 kp.makeRotationFromQuaternion(e),this.applyMatrix4(kp),this}rotateX(e){return kp.makeRotationX(e),this.applyMatrix4(kp),this}rotateY(e){return kp.makeRotationY(e),this.applyMatrix4(kp),this}rotateZ(e){return kp.makeRotationZ(e),this.applyMatrix4(kp),this}translate(e,t,r){return kp.makeTranslation(e,t,r),this.applyMatrix4(kp),this}scale(e,t,r){return kp.makeScale(e,t,r),this.applyMatrix4(kp),this}lookAt(e){return Up.lookAt(e),Up.updateMatrix(),this.applyMatrix4(Up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vp).negate(),this.translate(Vp.x,Vp.y,Vp.z),this}setFromPoints(e){const t=this.getAttribute("position");if(void 0===t){const t=[];for(let r=0,i=e.length;rt.count&&wc("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 op);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return Tc("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Vc(-1/0,-1/0,-1/0),new Vc(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e0&&(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;t0&&(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;e0!=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){wc(`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:wc(`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()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),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!==wu&&(r.blendSrc=this.blendSrc),this.blendDst!==Tu&&(r.blendDst=this.blendDst),this.blendEquation!==mu&&(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!==rc&&(r.stencilFail=this.stencilFail),this.stencilZFail!==rc&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==rc&&(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),!1===this.allowOverride&&(r.allowOverride=!1),!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.allowOverride=e.allowOverride,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 Zp extends Yp{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new jd(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}}const Kp=new Vc,Jp=new Vc,ef=new Vc,tf=new Vc,rf=new Vc,nf=new Vc,sf=new Vc;class af{constructor(e=new Vc,t=new Vc(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,Kp)),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=Kp.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kp.copy(this.origin).addScaledVector(this.direction,t),Kp.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){Jp.copy(e).add(t).multiplyScalar(.5),ef.copy(t).sub(e).normalize(),tf.copy(this.origin).sub(Jp);const n=.5*e.distanceTo(t),s=-this.direction.dot(ef),a=tf.dot(this.direction),o=-tf.dot(ef),l=tf.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(Jp).addScaledVector(ef,h),c}intersectSphere(e,t){Kp.subVectors(e.center,this.origin);const r=Kp.dot(this.direction),i=Kp.dot(Kp)-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=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=0?r:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Kp)}intersectTriangle(e,t,r,i,n){rf.subVectors(t,e),nf.subVectors(r,e),sf.crossVectors(rf,nf);let s,a=this.direction.dot(sf);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}tf.subVectors(this.origin,e);const o=s*this.direction.dot(nf.crossVectors(tf,nf));if(o<0)return null;const l=s*this.direction.dot(rf.cross(tf));if(l<0)return null;if(o+l>a)return null;const A=-s*tf.dot(sf);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 of extends Yp{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new jd(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 bd,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 lf=new Ad,Af=new af,uf=new Lp,hf=new Vc,cf=new Vc,df=new Vc,pf=new Vc,ff=new Vc,mf=new Vc,gf=new Vc,yf=new Vc;class bf extends qd{constructor(e=new Wp,t=new of){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(e.far-e.near)**2)return}lf.copy(n).invert(),Af.copy(e.ray).applyMatrix4(lf),null!==r.boundingBox&&!1===Af.intersectsBox(r.boundingBox)||this._computeIntersections(e,t,Af)}}_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;nr.far?null:{distance:A,point:yf.clone(),object:e}}(e,t,r,i,cf,df,pf,gf);if(u){const e=new Vc;ap.getBarycoord(gf,cf,df,pf,e),n&&(u.uv=ap.getInterpolatedAttribute(n,o,l,A,e,new kc)),s&&(u.uv1=ap.getInterpolatedAttribute(s,o,l,A,e,new kc)),a&&(u.normal=ap.getInterpolatedAttribute(a,o,l,A,e,new Vc),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const t={a:o,b:l,c:A,normal:new Vc,materialIndex:0};ap.getNormal(cf,df,pf,t.normal),u.face=t,u.barycoord=e}return u}class vf extends sd{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 _f extends Cp{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 wf=new Vc,Tf=new Vc,Mf=new jc;class Sf{constructor(e=new Vc(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=wf.subVectors(r,t).cross(Tf.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(wf),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||Mf.getNormalMatrix(e),i=this.coplanarPoint(wf).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 Nf=new Lp,Ef=new kc(.5,.5),Cf=new Vc;class Rf{constructor(e=new Sf,t=new Sf,r=new Sf,i=new Sf,n=new Sf,s=new Sf){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,r=!1){const i=this.planes,n=e.elements,s=n[0],a=n[1],o=n[2],l=n[3],A=n[4],u=n[5],h=n[6],c=n[7],d=n[8],p=n[9],f=n[10],m=n[11],g=n[12],y=n[13],b=n[14],x=n[15];if(i[0].setComponents(l-s,c-A,m-d,x-g).normalize(),i[1].setComponents(l+s,c+A,m+d,x+g).normalize(),i[2].setComponents(l+a,c+u,m+p,x+y).normalize(),i[3].setComponents(l-a,c-u,m-p,x-y).normalize(),r)i[4].setComponents(o,h,f,b).normalize(),i[5].setComponents(l-o,c-h,m-f,x-b).normalize();else if(i[4].setComponents(l-o,c-h,m-f,x-b).normalize(),t===dc)i[5].setComponents(l+o,c+h,m+f,x+b).normalize();else{if(t!==pc)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);i[5].setComponents(o,h,f,b).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Nf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Nf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Nf)}intersectsSprite(e){Nf.center.set(0,0,0);const t=Ef.distanceTo(e.center);return Nf.radius=.7071067811865476+t,Nf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Nf)}intersectsSphere(e){const t=this.planes,r=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(r)0?e.max.x:e.min.x,Cf.y=i.normal.y>0?e.max.y:e.min.y,Cf.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Cf)<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 Bf=new Ad,Pf=new Rf;class Df{constructor(){this.coordinateSystem=dc}intersectsObject(e,t){if(!t.isArrayCamera||0===t.cameras.length)return!1;for(let r=0;r0?1:-1,A.push(N.x,N.y,N.z),u.push(o/f),u.push(1-s/m),M+=1}}for(let e=0;e0||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 Dp(u,3)),this.setAttribute("normal",new Dp(h,3)),this.setAttribute("uv",new Dp(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vf(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class zf extends Wp{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;e0)&&c.push(t,n,l),(e!==r-1||o0!=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 $f extends Yp{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new jd(16777215),this.specular=new jd(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jd(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new kc(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new bd,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 Qf extends Yp{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new jd(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jd(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new kc(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 Xf extends Yp{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new kc(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 Yf extends Yp{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new jd(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jd(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new kc(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new bd,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 Zf extends Yp{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new jd(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new kc(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Kf extends If{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 Jf extends qd{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new jd(e),this.intensity=t}dispose(){this.dispatchEvent({type:"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,t}}class em extends Jf{constructor(e,t,r){super(e,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(qd.DEFAULT_UP),this.updateMatrix(),this.groundColor=new jd(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const tm=new Ad,rm=new Vc,im=new Vc;class nm{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new kc(512,512),this.mapType=Xu,this.map=null,this.mapPass=null,this.matrix=new Ad,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Rf,this._frameExtents=new kc(1,1),this._viewportCount=1,this._viewports=[new ad(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;rm.setFromMatrixPosition(e.matrixWorld),t.position.copy(rm),im.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(im),t.updateMatrixWorld(),tm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tm,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===pc||t.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(tm)}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.biasNode=e.biasNode,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}}const sm=new Vc,am=new Uc,om=new Vc;class lm extends qd{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ad,this.projectionMatrix=new Ad,this.projectionMatrixInverse=new Ad,this.coordinateSystem=dc,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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.matrixWorld.decompose(sm,am,om),1===om.x&&1===om.y&&1===om.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(sm,am,om.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(sm,am,om),1===om.x&&1===om.y&&1===om.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(sm,am,om.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const Am=new Vc,um=new kc,hm=new kc;class cm extends lm{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*Bc*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Rc*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Bc*Math.atan(Math.tan(.5*Rc*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){Am.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Am.x,Am.y).multiplyScalar(-e/Am.z),Am.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Am.x,Am.y).multiplyScalar(-e/Am.z)}getViewSize(e,t){return this.getViewBounds(e,um,hm),t.subVectors(hm,um)}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*Rc*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.reversedDepth),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}}class dm extends nm{constructor(){super(new cm(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,r=2*Bc*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 pm extends Jf{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(qd.DEFAULT_UP),this.updateMatrix(),this.target=new qd,this.distance=r,this.angle=i,this.penumbra=n,this.decay=s,this.map=null,this.shadow=new dm}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.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.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class fm extends nm{constructor(){super(new cm(90,1,.5,500)),this.isPointLightShadow=!0}}class mm extends Jf{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 fm}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.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}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class gm extends lm{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.reversedDepth),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 ym extends nm{constructor(){super(new gm(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class bm extends Jf{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(qd.DEFAULT_UP),this.updateMatrix(),this.target=new qd,this.shadow=new ym}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class xm extends Jf{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class vm extends Jf{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 _m{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Vc)}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 wm extends Jf{constructor(e=new _m,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}const Tm=-90;class Mm extends qd{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new cm(Tm,1,e,t);i.layers=this.layers,this.add(i);const n=new cm(Tm,1,e,t);n.layers=this.layers,this.add(n);const s=new cm(Tm,1,e,t);s.layers=this.layers,this.add(s);const a=new cm(Tm,1,e,t);a.layers=this.layers,this.add(a);const o=new cm(Tm,1,e,t);o.layers=this.layers,this.add(o);const l=new cm(Tm,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===dc)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!==pc)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;let f=!1;f=!0===e.isWebGLRenderer?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(r,0,i),f&&!1===e.autoClear&&e.clearDepth(),e.render(t,n),e.setRenderTarget(r,1,i),f&&!1===e.autoClear&&e.clearDepth(),e.render(t,s),e.setRenderTarget(r,2,i),f&&!1===e.autoClear&&e.clearDepth(),e.render(t,a),e.setRenderTarget(r,3,i),f&&!1===e.autoClear&&e.clearDepth(),e.render(t,o),e.setRenderTarget(r,4,i),f&&!1===e.autoClear&&e.clearDepth(),e.render(t,l),r.texture.generateMipmaps=p,e.setRenderTarget(r,5,i),f&&!1===e.autoClear&&e.clearDepth(),e.render(t,A),e.setRenderTarget(u,h,c),e.xr.enabled=d,r.texture.needsPMREMUpdate=!0}}class Sm extends cm{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Nm extends Hp{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 Em{constructor(e,t,r,i){Em.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}}function Cm(e,t,r,i){const n=function(e){switch(e){case Xu:case Yu:return{byteLength:1,components:1};case Ku:case Zu:case rh:return{byteLength:2,components:1};case ih:case nh:return{byteLength:2,components:4};case eh:case Ju:case th:return{byteLength:4,components:1};case ah:case oh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${e}.`)}(i);switch(r){case 1021:return e*t;case ch:case dh:return e*t/n.components*n.byteLength;case ph:case fh:return e*t*2/n.components*n.byteLength;case lh:return e*t*3/n.components*n.byteLength;case Ah:case mh:return e*t*4/n.components*n.byteLength;case gh:case yh:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case bh:case xh:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case _h:case Th:return Math.max(e,16)*Math.max(t,8)/4;case vh:case wh:return Math.max(e,8)*Math.max(t,8)/2;case Mh:case Sh:case Eh:case Ch:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Nh:case Rh:case Bh:case Ph:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Dh:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case Ih:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case Fh:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case qh:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case Lh:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Oh:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case kh:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case Uh:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case Vh:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case zh:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case Gh:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case jh:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case Wh:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case Hh:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case $h:case Qh:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Xh:case Yh:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${r} format.`)}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:cu}})),"undefined"!=typeof window&&(window.__THREE__?wc("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=cu);const Rm=["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"],Bm=new WeakMap;class Pm{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=Rm,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),indexId:r.index?r.index.id:null,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}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const i=e[r];t[r]={id:i.id,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!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}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,t){const{object:r,material:i,geometry:n}=e,s=this.getRenderObjectData(e);if(!0!==s.worldMatrix.equals(r.matrixWorld))return s.worldMatrix.copy(r.matrixWorld),!1;const a=s.material;for(const e in a){const t=a[e],r=i[e];if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){const{width:t,height:r}=e.context;if(s.bufferWidth!==t||s.bufferHeight!==r)return s.bufferWidth=t,s.bufferHeight=r,!1}const o=s.geometry,l=n.attributes,A=o.attributes,u=Object.keys(A),h=Object.keys(l);if(o.id!==n.id)return o.id=n.id,!1;if(u.length!==h.length)return s.geometry.attributes=this.getAttributesData(l),!1;for(const e of u){const t=A[e],r=l[e];if(void 0===r)return delete A[e],!1;if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}const c=n.index,d=o.indexId,p=o.indexVersion,f=c?c.id:null,m=c?c.version:null;if(d!==f||p!==m)return o.indexId=f,o.indexVersion=m,!1;if(o.drawRange.start!==n.drawRange.start||o.drawRange.count!==n.drawRange.count)return o.drawRange.start=n.drawRange.start,o.drawRange.count=n.drawRange.count,!1;if(s.morphTargetInfluences){let e=!1;for(let t=0;t{const r=e.match(t);if(!r)return null;const i=r[1]||r[2]||"",n=r[3].split("?")[0],s=parseInt(r[4],10),a=parseInt(r[5],10);return{fn:i,file:n.split("/").pop(),line:s,column:a}}).filter(e=>e&&!Dm.some(t=>t.test(e.file)))}(e||(new Error).stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(0===this.stack.length)return e;return`${e}\n${this.stack.map(e=>{const t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join("\n")}`}}function Fm(e,t=0){let r=3735928559^t,i=1103547991^t;if(e instanceof Array)for(let t,n=0;n>>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 qm=e=>Fm(e),Lm=e=>Fm(e),Om=(...e)=>Fm(e),km=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Um=new WeakMap;function Vm(e){return km.get(e)}function zm(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 Gm(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 Tc(`TSL: Unsupported type: ${e}`,new Im)}function jm(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 Tc(`TSL: Unsupported type: ${e}`,new Im)}function Wm(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)||/mat4/.test(e)?16:void Tc(`TSL: Unsupported type: ${e}`,new Im)}function Hm(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 $m(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 jd(...t):"vec2"===r?new kc(...t):"vec3"===r?new Vc(...t):"vec4"===r?new ad(...t):"mat2"===r?new Em(...t):"mat3"===r?new jc(...t):"mat4"===r?new Ad(...t):"bool"===e?t[0]||!1:"float"===e||"int"===e||"uint"===e?t[0]||0:"string"===e?t[0]||"":"ArrayBuffer"===e?(i=t[0],Uint8Array.from(atob(i),e=>e.charCodeAt(0)).buffer):null;var i}function Qm(e){let t=Um.get(e);return void 0===t&&(t={},Um.set(e,t)),t}const Xm={VERTEX:"vertex",FRAGMENT:"fragment"},Ym={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Zm={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Km=["fragment","vertex"],Jm=["setup","analyze","generate"],eg=[...Km,"compute"],tg=["x","y","z","w"],rg={analyze:"setup",generate:"analyze"};let ig=0;class ng extends Nc{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Ym.NONE,this.updateBeforeType=Ym.NONE,this.updateAfterType=Ym.NONE,this.uuid=Oc.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:ig++}),this.stackTrace=null,!0===ng.captureStackTrace&&(this.stackTrace=new Im)}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),this}onFrameUpdate(e){return this.onUpdate(e,Ym.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Ym.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Ym.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const r of Object.getOwnPropertyNames(this)){const i=this[r];if(!0!==r.startsWith("_")&&!e.has(i))if(!0===Array.isArray(i))for(let e=0;e0&&(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}}ng.captureStackTrace=!1;class sg extends ng{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)}getMemberType(e,t){return this.node.getMemberType(e,t)}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 ag extends ng{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 og extends ng{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 lg extends og{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){Tc(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`,this.stackTrace);break}let n,l=t.getNodeType(e),A=e.getTypeLength(l);o+A>i&&(Tc(`TSL: Length of '${r}()' data exceeds maximum length of output type.`,this.stackTrace),A=i-o,l=e.getTypeFromLength(A)),o+=A,n=t.build(e,l);if(e.getComponentType(l)!==s){const t=e.getTypeFromLength(A,s);n=e.format(n,l,t)}a.push(n)}const l=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(l,r,t)}}const Ag=tg.join("");class ug extends ng{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(tg.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))}getScope(){return this.node.getScope()}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===Ag.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 hg extends og{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(e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"))(e).split("").sort().join("");ng.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==gg?gg.assign(this,...e):Tc("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Im),this;{const t=yg.get("assign");return this.addToStack(t(...e))}},ng.prototype.toVarIntent=function(){return this},ng.prototype.get=function(e){return new mg(this,e)};const vg={};function _g(e,t,r){vg[e]=vg[t]=vg[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new ug(this,e),this._cache[e]=t),t},set(t){this[e].assign(Qg(t))}};const i=e.toUpperCase(),n=t.toUpperCase(),s=r.toUpperCase();ng.prototype["set"+i]=ng.prototype["set"+n]=ng.prototype["set"+s]=function(t){const r=xg(e);return new hg(this,r,Qg(t))},ng.prototype["flip"+i]=ng.prototype["flip"+n]=ng.prototype["flip"+s]=function(){const t=xg(e);return new cg(this,t)}}const wg=["x","y","z","w"],Tg=["r","g","b","a"],Mg=["s","t","p","q"];for(let e=0;e<4;e++){let t=wg[e],r=Tg[e],i=Mg[e];_g(t,r,i);for(let n=0;n<4;n++){t=wg[e]+wg[n],r=Tg[e]+Tg[n],i=Mg[e]+Mg[n],_g(t,r,i);for(let s=0;s<4;s++){t=wg[e]+wg[n]+wg[s],r=Tg[e]+Tg[n]+Tg[s],i=Mg[e]+Mg[n]+Mg[s],_g(t,r,i);for(let a=0;a<4;a++)t=wg[e]+wg[n]+wg[s]+wg[a],r=Tg[e]+Tg[n]+Tg[s]+Tg[a],i=Mg[e]+Mg[n]+Mg[s]+Mg[a],_g(t,r,i)}}}for(let e=0;e<32;e++)vg[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new sg(this,new fg(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(Qg(t))}};Object.defineProperties(ng.prototype,vg);const Sg=new WeakMap,Ng=function(e,t=null){for(const r in e)e[r]=Qg(e[r],t);return e},Eg=function(e,t=null){const r=e.length;for(let i=0;io?(Tc(`TSL: "${r}" parameter length exceeds limit.`,new Im),t.slice(0,o)):t}return null===t?s=(...t)=>n(new e(...Zg(A(t)))):null!==r?(r=Qg(r),s=(...i)=>n(new e(t,...Zg(A(i)),r))):s=(...r)=>n(new e(t,...Zg(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},Rg=function(e,...t){return new e(...Zg(t))};class Bg extends ng{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:r}=this,i=e.getNodeProperties(t),n=e.getClosestSubBuild(t.subBuilds)||"",s=n||"default";if(i[s])return i[s];const a=e.subBuildFn,o=e.fnCall;e.subBuildFn=n,e.fnCall=this;let l=null;if(t.layout){let i=Sg.get(e.constructor);void 0===i&&(i=new WeakMap,Sg.set(e.constructor,i));let n=i.get(t);void 0===n&&(n=Qg(e.buildFunctionNode(t)),i.set(t,n)),e.addInclude(n);const s=r?function(e){let t;Yg(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];return t}(r):null;l=Qg(n.call(s))}else{const i=new Proxy(e,{get:(e,t,r)=>{let i;return i=Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r),i}}),n=r?function(e){let t=0;return Yg(e),new Proxy(e,{get:(r,i,n)=>{let s;if("length"===i)return s=e.length,s;if(Symbol.iterator===i)s=function*(){for(const t of e)yield Qg(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){const r=e[0];s=void 0===r[i]?r[t++]:Reflect.get(r,i,n)}else e[0]instanceof ng&&(s=void 0===e[i]?e[t++]:Reflect.get(e,i,n));else s=Reflect.get(r,i,n);s=Qg(s)}return s}})}(r):null,s=Array.isArray(r)?r.length>0:null!==r,a=t.jsFunc,o=s||a.length>1?a(n,i):a(i);l=Qg(o)}return e.subBuildFn=a,e.fnCall=o,t.once&&(i[s]=l),l}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),o=e.fnCall;if(e.fnCall=this,"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 e.fnCall=o,r}}class Pg extends ng{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new Bg(this,e)}setup(){return this.call()}}const Dg=[!1,!0],Ig=[0,1,2,3],Fg=[-1,-2],qg=[.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],Lg=new Map;for(const e of Dg)Lg.set(e,new fg(e));const Og=new Map;for(const e of Ig)Og.set(e,new fg(e,"uint"));const kg=new Map([...Og].map(e=>new fg(e.value,"int")));for(const e of Fg)kg.set(e,new fg(e,"int"));const Ug=new Map([...kg].map(e=>new fg(e.value)));for(const e of qg)Ug.set(e,new fg(e));for(const e of qg)Ug.set(-e,new fg(-e));const Vg={bool:Lg,uint:Og,ints:kg,float:Ug},zg=new Map([...Lg,...Ug]),Gg=(e,t)=>zg.has(e)?zg.get(e):!0===e.isNode?e:new fg(e,t),jg=function(e,t=null){return(...r)=>{for(const t of r)if(void 0===t)return Tc(`TSL: Invalid parameter for the type "${e}".`,new Im),new fg(0,e);if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every(e=>{const t=typeof e;return"object"!==t&&"function"!==t}))&&(r=[$m(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Xg(t.get(r[0]));if(1===r.length){const t=Gg(r[0],e);return t.nodeType===e?Xg(t):Xg(new ag(t,e))}const i=r.map(e=>Gg(e));return Xg(new lg(i,e))}},Wg=e=>"object"==typeof e&&null!==e?e.value:e,Hg=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function $g(e,t){return new Pg(e,t)}const Qg=(e,t=null)=>function(e,t=null){const r=Hm(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Qg(Gg(e,t)):"shader"===r?e.isFn?e:iy(e):e}(e,t),Xg=(e,t=null)=>Qg(e,t).toVarIntent(),Yg=(e,t=null)=>new Ng(e,t),Zg=(e,t=null)=>new Eg(e,t),Kg=(e,t=null,r=null,i=null)=>new Cg(e,t,r,i),Jg=(e,...t)=>new Rg(e,...t),ey=(e,t=null,r=null,i={})=>new Cg(e,t,r,{...i,intent:!0});let ty=0;class ry extends ng{constructor(e,t=null){super();let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:Tc("TSL: Invalid layout type.",new Im),t=null)),this.shaderNode=new $g(e,r),null!==t&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if("object"!=typeof e.inputs){const r={name:"fn"+ty++,type:t,inputs:[]};for(const t in e)"return"!==t&&r.inputs.push({name:t,type:e[t]});e=r}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return"void"===this.shaderNode.nodeType&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return Tc('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function iy(e,t=null){const r=new ry(e,t);return new Proxy(()=>{},{apply:(e,t,i)=>r.call(...i),get:(e,t,i)=>Reflect.get(r,t,i),set:(e,t,i,n)=>Reflect.set(r,t,i,n)})}const ny=e=>{gg=e},sy=()=>gg,ay=(...e)=>gg.If(...e);function oy(e){return gg&&gg.addToStack(e),e}bg("toStack",oy);const ly=new jg("color"),Ay=new jg("float",Vg.float),uy=new jg("int",Vg.ints),hy=new jg("uint",Vg.uint),cy=new jg("bool",Vg.bool),dy=new jg("vec2"),py=new jg("ivec2"),fy=new jg("uvec2"),my=new jg("bvec2"),gy=new jg("vec3"),yy=new jg("ivec3"),by=new jg("uvec3"),xy=new jg("bvec3"),vy=new jg("vec4"),_y=new jg("ivec4"),wy=new jg("uvec4"),Ty=new jg("bvec4"),My=new jg("mat2"),Sy=new jg("mat3"),Ny=new jg("mat4");bg("toColor",ly),bg("toFloat",Ay),bg("toInt",uy),bg("toUint",hy),bg("toBool",cy),bg("toVec2",dy),bg("toIVec2",py),bg("toUVec2",fy),bg("toBVec2",my),bg("toVec3",gy),bg("toIVec3",yy),bg("toUVec3",by),bg("toBVec3",xy),bg("toVec4",vy),bg("toIVec4",_y),bg("toUVec4",wy),bg("toBVec4",Ty),bg("toMat2",My),bg("toMat3",Sy),bg("toMat4",Ny);const Ey=Kg(sg).setParameterLength(2),Cy=(e,t)=>new ag(Qg(e),t);bg("element",Ey),bg("convert",Cy);bg("append",e=>(wc("TSL: .append() has been renamed to .toStack().",new Im),oy(e)));class Ry extends ng{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}customCacheKey(){return qm(this.type+":"+(this.name||"")+":"+(this.varying?"1":"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 By=(e,t)=>new Ry(e,t),Py=(e,t)=>new Ry(e,t,!0),Dy=Jg(Ry,"vec4","DiffuseColor"),Iy=Jg(Ry,"vec3","DiffuseContribution"),Fy=Jg(Ry,"vec3","EmissiveColor"),qy=Jg(Ry,"float","Roughness"),Ly=Jg(Ry,"float","Metalness"),Oy=Jg(Ry,"float","Clearcoat"),ky=Jg(Ry,"float","ClearcoatRoughness"),Uy=Jg(Ry,"vec3","Sheen"),Vy=Jg(Ry,"float","SheenRoughness"),zy=Jg(Ry,"float","Iridescence"),Gy=Jg(Ry,"float","IridescenceIOR"),jy=Jg(Ry,"float","IridescenceThickness"),Wy=Jg(Ry,"float","AlphaT"),Hy=Jg(Ry,"float","Anisotropy"),$y=Jg(Ry,"vec3","AnisotropyT"),Qy=Jg(Ry,"vec3","AnisotropyB"),Xy=Jg(Ry,"color","SpecularColor"),Yy=Jg(Ry,"color","SpecularColorBlended"),Zy=Jg(Ry,"float","SpecularF90"),Ky=Jg(Ry,"float","Shininess"),Jy=Jg(Ry,"vec4","Output"),eb=Jg(Ry,"float","dashSize"),tb=Jg(Ry,"float","gapSize"),rb=Jg(Ry,"float","pointWidth"),ib=Jg(Ry,"float","IOR"),nb=Jg(Ry,"float","Transmission"),sb=Jg(Ry,"float","Thickness"),ab=Jg(Ry,"float","AttenuationDistance"),ob=Jg(Ry,"color","AttenuationColor"),lb=Jg(Ry,"float","Dispersion");class Ab extends ng{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 ub=e=>new Ab(e),hb=(e,t=0)=>new Ab(e,!0,t),cb=hb("frame"),db=hb("render"),pb=ub("object");class fb extends dg{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=pb}setName(e){return this.name=e,this}label(e){return wc('TSL: "label()" has been deprecated. Use "setName()" instead.',new Im),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{const r=e(t,this);void 0!==r&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return"bool"===t&&(t="uint"),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.nodeName),o=e.getPropertyName(a);void 0!==e.context.nodeName&&delete e.context.nodeName;let l=o;if("bool"===r){const t=e.getDataFromNode(this);let i=t.propertyName;if(void 0===i){const n=e.getVarFromNode(this,null,"bool");i=e.getPropertyName(n),t.propertyName=i,l=e.format(o,s,r),e.addLineFlowCode(`${i} = ${l}`,this)}l=i}return e.format(l,r,t)}}const mb=(e,t)=>{const r=Hg(t||e);if(r===e&&(e=$m(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new fb(e,r)};class gb extends og{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return null===this.nodeType?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return null===this.nodeType?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const yb=(...e)=>{let t;if(1===e.length){const r=e[0];t=new gb(null,r.length,r)}else{const r=e[0],i=e[1];t=new gb(r,i)}return Qg(t)};bg("toArray",(e,t)=>yb(Array(t).fill(e)));class bb extends og{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 tg.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,i=t.getScope();e.getDataFromNode(i).assign=!0;const n=e.getNodeProperties(this);n.sourceNode=r,n.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:i}=e.getNodeProperties(this),n=this.needsSplitAssign(e),s=r.build(e),a=r.getNodeType(e),o=i.build(e,a),l=i.getNodeType(e),A=e.getDataFromNode(this);let u;if(!0===A.initialized)"void"!==t&&(u=s);else if(n){const i=e.getVarFromNode(this,null,a),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{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)Tc("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=i.length;else if(n.length(t=t.length>1||t[0]&&!0===t[0].isNode?Zg(t):Yg(t[0]),new vb(Qg(e),t));bg("call",_b);const wb={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Tb extends og{static get type(){return"OperatorNode"}constructor(e,t,r,...i){if(super(),i.length>0){let n=new Tb(e,t,r);for(let t=0;t>"===r||"<<"===r)return e.getIntegerType(s);if("!"===r||"&&"===r||"||"===r||"^^"===r)return"bool";if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r){const t=Math.max(e.getTypeLength(s),e.getTypeLength(a));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(s)){if("float"===a)return s;if(e.isVector(a))return e.getVectorFromMatrix(s);if(e.isMatrix(a))return s}else if(e.isMatrix(a)){if("float"===s)return a;if(e.isVector(s))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(s)?a:s}generate(e,t){const r=this.op,{aNode:i,bNode:n}=this,s=this.getNodeType(e,t);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===dc;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 Mb=ey(Tb,"+").setParameterLength(2,1/0).setName("add"),Sb=ey(Tb,"-").setParameterLength(2,1/0).setName("sub"),Nb=ey(Tb,"*").setParameterLength(2,1/0).setName("mul"),Eb=ey(Tb,"/").setParameterLength(2,1/0).setName("div"),Cb=ey(Tb,"%").setParameterLength(2).setName("mod"),Rb=ey(Tb,"==").setParameterLength(2).setName("equal"),Bb=ey(Tb,"!=").setParameterLength(2).setName("notEqual"),Pb=ey(Tb,"<").setParameterLength(2).setName("lessThan"),Db=ey(Tb,">").setParameterLength(2).setName("greaterThan"),Ib=ey(Tb,"<=").setParameterLength(2).setName("lessThanEqual"),Fb=ey(Tb,">=").setParameterLength(2).setName("greaterThanEqual"),qb=ey(Tb,"&&").setParameterLength(2,1/0).setName("and"),Lb=ey(Tb,"||").setParameterLength(2,1/0).setName("or"),Ob=ey(Tb,"!").setParameterLength(1).setName("not"),kb=ey(Tb,"^^").setParameterLength(2).setName("xor"),Ub=ey(Tb,"&").setParameterLength(2).setName("bitAnd"),Vb=ey(Tb,"~").setParameterLength(1).setName("bitNot"),zb=ey(Tb,"|").setParameterLength(2).setName("bitOr"),Gb=ey(Tb,"^").setParameterLength(2).setName("bitXor"),jb=ey(Tb,"<<").setParameterLength(2).setName("shiftLeft"),Wb=ey(Tb,">>").setParameterLength(2).setName("shiftRight"),Hb=iy(([e])=>(e.addAssign(1),e)),$b=iy(([e])=>(e.subAssign(1),e)),Qb=iy(([e])=>{const t=uy(e).toConst();return e.addAssign(1),t}),Xb=iy(([e])=>{const t=uy(e).toConst();return e.subAssign(1),t});bg("add",Mb),bg("sub",Sb),bg("mul",Nb),bg("div",Eb),bg("mod",Cb),bg("equal",Rb),bg("notEqual",Bb),bg("lessThan",Pb),bg("greaterThan",Db),bg("lessThanEqual",Ib),bg("greaterThanEqual",Fb),bg("and",qb),bg("or",Lb),bg("not",Ob),bg("xor",kb),bg("bitAnd",Ub),bg("bitNot",Vb),bg("bitOr",zb),bg("bitXor",Gb),bg("shiftLeft",jb),bg("shiftRight",Wb),bg("incrementBefore",Hb),bg("decrementBefore",$b),bg("increment",Qb),bg("decrement",Xb);const Yb=(e,t)=>(wc('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new Im),Cb(uy(e),uy(t)));bg("modInt",Yb);class Zb extends og{static get type(){return"MathNode"}constructor(e,t,r=null,i=null){if(super(),(e===Zb.MAX||e===Zb.MIN)&&arguments.length>3){let n=new Zb(e,t,r);for(let t=2;ts&&n>a?t:s>a?r:a>n?i:t}getNodeType(e){const t=this.method;return t===Zb.LENGTH||t===Zb.DISTANCE||t===Zb.DOT?"float":t===Zb.CROSS?"vec3":t===Zb.ALL||t===Zb.ANY?"bool":t===Zb.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===Zb.ONE_MINUS)n=Sb(1,t);else if(i===Zb.RECIPROCAL)n=Eb(1,t);else if(i===Zb.DIFFERENCE)n=Tx(Sb(t,r));else if(i===Zb.TRANSFORM_DIRECTION){let i=t,s=r;e.isMatrix(i.getNodeType(e))?s=vy(gy(s),0):i=vy(gy(i),0);const a=Nb(i,s).xyz;n=mx(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===Zb.NEGATE)return e.format("( - "+s.build(e,n)+" )",i,t);{const A=[];return r===Zb.CROSS?A.push(s.build(e,i),a.build(e,i)):l===dc&&r===Zb.STEP?A.push(s.build(e,1===e.getTypeLength(s.getNodeType(e))?"float":n),a.build(e,n)):l!==dc||r!==Zb.MIN&&r!==Zb.MAX?r===Zb.REFRACT?A.push(s.build(e,n),a.build(e,n),o.build(e,"float")):r===Zb.MIX?A.push(s.build(e,n),a.build(e,n),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":n)):(l===pc&&r===Zb.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Zb.DFDX&&r!==Zb.DFDY||(wc(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),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}}Zb.ALL="all",Zb.ANY="any",Zb.RADIANS="radians",Zb.DEGREES="degrees",Zb.EXP="exp",Zb.EXP2="exp2",Zb.LOG="log",Zb.LOG2="log2",Zb.SQRT="sqrt",Zb.INVERSE_SQRT="inversesqrt",Zb.FLOOR="floor",Zb.CEIL="ceil",Zb.NORMALIZE="normalize",Zb.FRACT="fract",Zb.SIN="sin",Zb.COS="cos",Zb.TAN="tan",Zb.ASIN="asin",Zb.ACOS="acos",Zb.ATAN="atan",Zb.ABS="abs",Zb.SIGN="sign",Zb.LENGTH="length",Zb.NEGATE="negate",Zb.ONE_MINUS="oneMinus",Zb.DFDX="dFdx",Zb.DFDY="dFdy",Zb.ROUND="round",Zb.RECIPROCAL="reciprocal",Zb.TRUNC="trunc",Zb.FWIDTH="fwidth",Zb.TRANSPOSE="transpose",Zb.DETERMINANT="determinant",Zb.INVERSE="inverse",Zb.EQUALS="equals",Zb.MIN="min",Zb.MAX="max",Zb.STEP="step",Zb.REFLECT="reflect",Zb.DISTANCE="distance",Zb.DIFFERENCE="difference",Zb.DOT="dot",Zb.CROSS="cross",Zb.POW="pow",Zb.TRANSFORM_DIRECTION="transformDirection",Zb.MIX="mix",Zb.CLAMP="clamp",Zb.REFRACT="refract",Zb.SMOOTHSTEP="smoothstep",Zb.FACEFORWARD="faceforward";const Kb=Ay(1e-6),Jb=Ay(1e6),ex=Ay(Math.PI),tx=Ay(2*Math.PI),rx=Ay(2*Math.PI),ix=Ay(.5*Math.PI),nx=ey(Zb,Zb.ALL).setParameterLength(1),sx=ey(Zb,Zb.ANY).setParameterLength(1),ax=ey(Zb,Zb.RADIANS).setParameterLength(1),ox=ey(Zb,Zb.DEGREES).setParameterLength(1),lx=ey(Zb,Zb.EXP).setParameterLength(1),Ax=ey(Zb,Zb.EXP2).setParameterLength(1),ux=ey(Zb,Zb.LOG).setParameterLength(1),hx=ey(Zb,Zb.LOG2).setParameterLength(1),cx=ey(Zb,Zb.SQRT).setParameterLength(1),dx=ey(Zb,Zb.INVERSE_SQRT).setParameterLength(1),px=ey(Zb,Zb.FLOOR).setParameterLength(1),fx=ey(Zb,Zb.CEIL).setParameterLength(1),mx=ey(Zb,Zb.NORMALIZE).setParameterLength(1),gx=ey(Zb,Zb.FRACT).setParameterLength(1),yx=ey(Zb,Zb.SIN).setParameterLength(1),bx=ey(Zb,Zb.COS).setParameterLength(1),xx=ey(Zb,Zb.TAN).setParameterLength(1),vx=ey(Zb,Zb.ASIN).setParameterLength(1),_x=ey(Zb,Zb.ACOS).setParameterLength(1),wx=ey(Zb,Zb.ATAN).setParameterLength(1,2),Tx=ey(Zb,Zb.ABS).setParameterLength(1),Mx=ey(Zb,Zb.SIGN).setParameterLength(1),Sx=ey(Zb,Zb.LENGTH).setParameterLength(1),Nx=ey(Zb,Zb.NEGATE).setParameterLength(1),Ex=ey(Zb,Zb.ONE_MINUS).setParameterLength(1),Cx=ey(Zb,Zb.DFDX).setParameterLength(1),Rx=ey(Zb,Zb.DFDY).setParameterLength(1),Bx=ey(Zb,Zb.ROUND).setParameterLength(1),Px=ey(Zb,Zb.RECIPROCAL).setParameterLength(1),Dx=ey(Zb,Zb.TRUNC).setParameterLength(1),Ix=ey(Zb,Zb.FWIDTH).setParameterLength(1),Fx=ey(Zb,Zb.TRANSPOSE).setParameterLength(1),qx=ey(Zb,Zb.DETERMINANT).setParameterLength(1),Lx=ey(Zb,Zb.INVERSE).setParameterLength(1),Ox=ey(Zb,Zb.MIN).setParameterLength(2,1/0),kx=ey(Zb,Zb.MAX).setParameterLength(2,1/0),Ux=ey(Zb,Zb.STEP).setParameterLength(2),Vx=ey(Zb,Zb.REFLECT).setParameterLength(2),zx=ey(Zb,Zb.DISTANCE).setParameterLength(2),Gx=ey(Zb,Zb.DIFFERENCE).setParameterLength(2),jx=ey(Zb,Zb.DOT).setParameterLength(2),Wx=ey(Zb,Zb.CROSS).setParameterLength(2),Hx=ey(Zb,Zb.POW).setParameterLength(2),$x=e=>Nb(e,e),Qx=e=>Nb(e,e,e),Xx=e=>Nb(e,e,e,e),Yx=ey(Zb,Zb.TRANSFORM_DIRECTION).setParameterLength(2),Zx=e=>Nb(Mx(e),Hx(Tx(e),1/3)),Kx=e=>jx(e,e),Jx=ey(Zb,Zb.MIX).setParameterLength(3),ev=(e,t=0,r=1)=>new Zb(Zb.CLAMP,Qg(e),Qg(t),Qg(r)),tv=e=>ev(e),rv=ey(Zb,Zb.REFRACT).setParameterLength(3),iv=ey(Zb,Zb.SMOOTHSTEP).setParameterLength(3),nv=ey(Zb,Zb.FACEFORWARD).setParameterLength(3),sv=iy(([e])=>{const t=jx(e.xy,dy(12.9898,78.233)),r=Cb(t,ex);return gx(yx(r).mul(43758.5453))}),av=(e,t,r)=>Jx(t,r,e),ov=(e,t,r)=>iv(t,r,e),lv=(e,t)=>Ux(t,e),Av=nv,uv=dx;bg("all",nx),bg("any",sx),bg("radians",ax),bg("degrees",ox),bg("exp",lx),bg("exp2",Ax),bg("log",ux),bg("log2",hx),bg("sqrt",cx),bg("inverseSqrt",dx),bg("floor",px),bg("ceil",fx),bg("normalize",mx),bg("fract",gx),bg("sin",yx),bg("cos",bx),bg("tan",xx),bg("asin",vx),bg("acos",_x),bg("atan",wx),bg("abs",Tx),bg("sign",Mx),bg("length",Sx),bg("lengthSq",Kx),bg("negate",Nx),bg("oneMinus",Ex),bg("dFdx",Cx),bg("dFdy",Rx),bg("round",Bx),bg("reciprocal",Px),bg("trunc",Dx),bg("fwidth",Ix),bg("min",Ox),bg("max",kx),bg("step",lv),bg("reflect",Vx),bg("distance",zx),bg("dot",jx),bg("cross",Wx),bg("pow",Hx),bg("pow2",$x),bg("pow3",Qx),bg("pow4",Xx),bg("transformDirection",Yx),bg("mix",av),bg("clamp",ev),bg("refract",rv),bg("smoothstep",ov),bg("faceForward",nv),bg("difference",Gx),bg("saturate",tv),bg("cbrt",Zx),bg("transpose",Fx),bg("determinant",qx),bg("inverse",Lx),bg("rand",sv);class hv extends ng{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 e.flowBuildStage(this,"setup"),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,r=this.ifNode.isolate(),i=this.elseNode?this.elseNode.isolate():null,n=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=n,null!==i&&(e.getDataFromNode(i).parentNodeBlock=n);const s=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=s?r:r.context({nodeBlock:r}),a.elseNode=i?s?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?By(r).build(e):"";i.nodeProperty=A;const u=n.build(e,"bool");if(e.context.uniformFlow&&null!==a){const i=s.build(e,r),n=a.build(e,r),o=e.getTernary(u,i,n);return e.format(o,r,t)}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&&(wc("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),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&&(wc("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),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 cv=Kg(hv).setParameterLength(2,3);bg("select",cv);class dv extends ng{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{!0===t.isContextNode&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),i=this.node.build(e,t);return e.setContext(r),i}}const pv=(e=null,t={})=>{let r=e;return null!==r&&!0===r.isNode||(t=r||t,r=null),new dv(r,t)},fv=e=>pv(e,{uniformFlow:!0}),mv=(e,t)=>pv(e,{nodeName:t});function gv(e,t,r=null){return pv(r,{getShadow:({light:r,shadowColorNode:i})=>t===r?i.mul(e):i})}function yv(e,t=null){return pv(t,{getAO:(t,{material:r})=>!0===r.transparent?t:null!==t?t.mul(e):e})}function bv(e,t){return wc('TSL: "label()" has been deprecated. Use "setName()" instead.'),mv(e,t)}bg("context",pv),bg("label",bv),bg("uniformFlow",fv),bg("setName",mv),bg("builtinShadowContext",(e,t,r)=>gv(t,r,e)),bg("builtinAOContext",(e,t)=>yv(t,e));class xv extends ng{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,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(!1===this._hasStack(t)&&"setup"===t.buildStage&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&t.fnCall&&t.fnCall.shaderNode){if(t.getDataFromNode(this.node.shaderNode).hasLoop){t.getDataFromNode(this).forceDeclaration=!0,e=!0}}const r=t.getBaseStack();e?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&!0!==this.isAssign(t)?this.node.build(...e):super.build(...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=this.getNodeType(e);if("void"==l){!0!==this.isIntent(e)&&Tc('TSL: ".toVar()" can not be used with void type.',this.stackTrace);return t.build(e)}const A=e.getVectorType(l),u=t.build(e,A),h=e.getVarFromNode(this,r,A,void 0,o),c=e.getPropertyName(h);let d=c;if(o)if(s)d=a?`const ${c}`:`let ${c}`;else{const r=t.getArrayCount(e);d=`const ${e.getVar(h.type,c,r)}`}return e.addLineFlowCode(`${d} = ${u}`,this),c}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}const vv=Kg(xv),_v=(e,t=null)=>vv(e,t).toStack(),wv=(e,t=null)=>vv(e,t,!0).toStack(),Tv=e=>vv(e).setIntent(!0).toStack();bg("toVar",_v),bg("toConst",wv),bg("toVarIntent",Tv);class Mv extends ng{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 Sv=(e,t,r=null)=>new Mv(Qg(e),t,r);class Nv extends ng{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=Sv(e,"VERTEX"),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=Sv(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Xm.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Xm.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,Xm.VERTEX);e.flowNodeFromShaderStage(Xm.VERTEX,r.node,n,s),r[t]=s}return e.getPropertyName(i)}}const Ev=Kg(Nv).setParameterLength(1,2),Cv=e=>Ev(e);bg("toVarying",Ev),bg("toVertexStage",Cv);const Rv=iy(([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),i=e.lessThanEqual(.04045);return Jx(t,r,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Bv=iy(([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),i=e.lessThanEqual(.0031308);return Jx(t,r,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Pv="WorkingColorSpace";class Dv extends og{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===Pv?Xc.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!==Xc.enabled&&r!==i&&r&&i?(Xc.getTransfer(r)===tc&&(n=vy(Rv(n.rgb),n.a)),Xc.getPrimaries(r)!==Xc.getPrimaries(i)&&(n=vy(Sy(Xc._getMatrix(new jc,r,i)).mul(n.rgb),n.a)),Xc.getTransfer(i)===tc&&(n=vy(Bv(n.rgb),n.a)),n):n}}const Iv=(e,t)=>new Dv(Qg(e),Pv,t),Fv=(e,t)=>new Dv(Qg(e),t,Pv);bg("workingToColorSpace",Iv),bg("colorSpaceToWorking",Fv);let qv=class extends sg{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 Lv extends ng{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=Ym.OBJECT}setGroup(e){return this.group=e,this}element(e){return new qv(this,Qg(e))}setNodeType(e){const t=mb(null,e);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;enew Ov(e,t,r);class Uv extends og{static get type(){return"ToneMappingNode"}constructor(e,t=zv,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Om(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return 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=vy(n(t.rgb,this.exposureNode),t.a):(Tc("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=t),i}}const Vv=(e,t,r)=>new Uv(e,Qg(t),Qg(r)),zv=kv("toneMappingExposure","float");bg("toneMapping",(e,t,r)=>Vv(t,r,e));const Gv=new WeakMap;function jv(e,t){let r=Gv.get(e);return void 0===r&&(r=new Hp(e,t),Gv.set(e,r)),r}class Wv extends dg{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=hc,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(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=e.getTypeLength(t),i=this.value,n=this.bufferStride||r,s=this.bufferOffset;let a;a=!0===i.isInterleavedBuffer?i:!0===i.isBufferAttribute?jv(i.array,n):jv(i,n);const o=new Qp(a,r,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=Ev(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}}function Hv(e,t=null,r=0,i=0,n=35044,s=!1){return"mat3"===t||null===t&&9===e.itemSize?Sy(new Wv(e,"vec3",9,0).setUsage(n).setInstanced(s),new Wv(e,"vec3",9,3).setUsage(n).setInstanced(s),new Wv(e,"vec3",9,6).setUsage(n).setInstanced(s)):"mat4"===t||null===t&&16===e.itemSize?Ny(new Wv(e,"vec4",16,0).setUsage(n).setInstanced(s),new Wv(e,"vec4",16,4).setUsage(n).setInstanced(s),new Wv(e,"vec4",16,8).setUsage(n).setInstanced(s),new Wv(e,"vec4",16,12).setUsage(n).setInstanced(s)):new Wv(e,t,r,i).setUsage(n)}const $v=(e,t=null,r=0,i=0)=>Hv(e,t,r,i),Qv=(e,t=null,r=0,i=0)=>Hv(e,t,r,i,hc,!0),Xv=(e,t=null,r=0,i=0)=>Hv(e,t,r,i,cc,!0);bg("toAttribute",e=>$v(e.value));class Yv extends ng{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=Ym.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return wc('TSL: "label()" has been deprecated. Use "setName()" instead.',new Im),this.setName(e)}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 Zv=(e,t=[64])=>{(0===t.length||t.length>3)&&Tc("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new Im);for(let e=0;eZv(e,r).setCount(t);bg("compute",Kv),bg("computeKernel",Zv);class Jv extends ng{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!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}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const e_=e=>new Jv(Qg(e));function t_(e,t=!0){return wc('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),e_(e).setParent(t)}bg("cache",t_),bg("isolate",e_);class r_ extends ng{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 i_=Kg(r_).setParameterLength(2);bg("bypass",i_);class n_ extends ng{static get type(){return"RemapNode"}constructor(e,t,r,i=Ay(0),n=Ay(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 s_=Kg(n_,null,null,{doClamp:!1}).setParameterLength(3,5),a_=Kg(n_).setParameterLength(3,5);bg("remap",s_),bg("remapClamp",a_);class o_ extends ng{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 l_=Kg(o_).setParameterLength(1,2),A_=e=>(e?cv(e,l_("discard")):l_("discard")).toStack();bg("discard",A_);class u_ extends og{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}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)||Zh;return 0!==r&&(t=t.toneMapping(r)),i!==Zh&&i!==Xc.workingColorSpace&&(t=t.workingToColorSpace(i)),t}}const h_=(e,t=null,r=null)=>new u_(Qg(e),t,r);bg("renderOutput",h_);class c_ extends og{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);if(null!==t)t(e,r);else{const t="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(t.length);let n="";n+="// #"+t+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",vc(n)}return r}}const d_=(e,t=null)=>new c_(Qg(e),t).toStack();bg("debug",d_);class p_{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class f_ extends ng{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=Ym.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==p_&&Mc('TSL: ".toInspector()" is only available with WebGPU.'),t}}function m_(e,t="",r=null){return(e=Qg(e)).before(new f_(e,t,r))}bg("toInspector",m_);class g_ extends ng{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 Ev(this).build(e,r)}return wc(`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 y_=(e,t=null)=>new g_(e,t),b_=(e=0)=>y_("uv"+(e>0?e:""),"vec2");class x_ extends ng{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 v_=Kg(x_).setParameterLength(1,2);class __ extends fb{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Ym.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 w_=Kg(__).setParameterLength(1);class T_ extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const M_=new sd;class S_ extends fb{static get type(){return"TextureNode"}constructor(e=M_,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.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Ym.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=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===eh?"uvec4":this.value.type===Ju?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return b_(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=mb(this.value.matrix)),this._matrixUniform.mul(gy(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=mb(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(uy(v_(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new T_("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const i=iy(()=>{let t=this.uvNode;return null!==t&&!0!==e.context.forceUVContext||!e.context.getUV||(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),!0===this.updateMatrix&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?Ym.OBJECT:Ym.NONE,t})();let n=this.levelNode;null===n&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this));let s=null,a=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(gc))s=this.compareNode;else{const e=r.compareFunction;null===e||513===e||e===ac||e===oc||e===Ac?a=this.compareNode:(s=this.compareNode,Mc('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=i,t.levelNode=n,t.biasNode=this.biasNode,t.compareNode=s,t.compareStepNode=a,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,i,n,s,a,o,l){const A=this.value;let u;return u=n?e.generateTextureBias(A,t,r,n,s,l):o?e.generateTextureGrad(A,t,r,o,s,l):a?e.generateTextureCompare(A,t,r,a,s,l):!1===this.sampler?e.generateTextureLoad(A,t,r,i,s,l):i?e.generateTextureLevel(A,t,r,i,s,l):e.generateTexture(A,t,r,s,l),u}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),a=this.getNodeType(e);let o=s.propertyName;if(void 0===o){const{uvNode:t,levelNode:l,biasNode:A,compareNode:u,compareStepNode:h,depthNode:c,gradNode:d,offsetNode:p}=i,f=this.generateUV(e,t),m=l?l.build(e,"float"):null,g=A?A.build(e,"float"):null,y=c?c.build(e,"int"):null,b=u?u.build(e,"float"):null,x=h?h.build(e,"float"):null,v=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,_=p?this.generateOffset(e,p):null,w=e.getVarFromNode(this);o=e.getPropertyName(w);let T=this.generateSnippet(e,n,f,m,g,y,b,v,_);if(null!==x){const t=r.compareFunction;T=t===oc||t===Ac?Ux(l_(T,a),l_(x,"float")).build(e,a):Ux(l_(x,"float"),l_(T,a)).build(e,a)}e.addLineFlowCode(`${o} = ${T}`,this),s.snippet=T,s.propertyName=o}let l=o;return e.needsToWorkingColorSpace(r)&&(l=Fv(l_(l,a),r.colorSpace).setup(e).build(e,a)),e.format(l,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=Qg(e),t.referenceNode=this.getBase(),Qg(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Qg(e).mul(w_(t)),t.referenceNode=this.getBase();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===Gu||r.magFilter===Gu)&&(wc("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Qg(t)}level(e){const t=this.clone();return t.levelNode=Qg(e),t.referenceNode=this.getBase(),Qg(t)}size(e){return v_(this,e)}bias(e){const t=this.clone();return t.biasNode=Qg(e),t.referenceNode=this.getBase(),Qg(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Qg(e),t.referenceNode=this.getBase(),Qg(t)}grad(e,t){const r=this.clone();return r.gradNode=[Qg(e),Qg(t)],r.referenceNode=this.getBase(),Qg(r)}depth(e){const t=this.clone();return t.depthNode=Qg(e),t.referenceNode=this.getBase(),Qg(t)}offset(e){const t=this.clone();return t.offsetNode=Qg(e),t.referenceNode=this.getBase(),Qg(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();const r=this._flipYUniform;null!==r&&(r.value=e.image instanceof ImageBitmap&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}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.offsetNode=this.offsetNode,e}}const N_=Kg(S_).setParameterLength(1,4).setName("texture"),E_=(e=M_,t=null,r=null,i=null)=>{let n;return e&&!0===e.isTextureNode?(n=Qg(e.clone()),n.referenceNode=e.getBase(),null!==t&&(n.uvNode=Qg(t)),null!==r&&(n.levelNode=Qg(r)),null!==i&&(n.biasNode=Qg(i))):n=N_(e,t,r,i),n},C_=(...e)=>E_(...e).setSampler(!1);class R_ extends fb{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const B_=(e,t,r)=>new R_(e,t,r);class P_ extends sg{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 D_ extends R_{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Hm(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Ym.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;rnew D_(e,t);const F_=Kg(class extends ng{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1);let q_,L_;class O_ extends ng{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===O_.DPR?"float":this.scope===O_.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Ym.NONE;return this.scope!==O_.SIZE&&this.scope!==O_.VIEWPORT&&this.scope!==O_.DPR||(e=Ym.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===O_.VIEWPORT?null!==t?L_.copy(t.viewport):(e.getViewport(L_),L_.multiplyScalar(e.getPixelRatio())):this.scope===O_.DPR?this._output.value=e.getPixelRatio():null!==t?(q_.width=t.width,q_.height=t.height):e.getDrawingBufferSize(q_)}setup(){const e=this.scope;let t=null;return t=e===O_.SIZE?mb(q_||(q_=new kc)):e===O_.VIEWPORT?mb(L_||(L_=new ad)):e===O_.DPR?mb(1):dy(z_.div(V_)),this._output=t,t}generate(e){if(this.scope===O_.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(V_).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}O_.COORDINATE="coordinate",O_.VIEWPORT="viewport",O_.SIZE="size",O_.UV="uv",O_.DPR="dpr";const k_=Jg(O_,O_.DPR),U_=Jg(O_,O_.UV),V_=Jg(O_,O_.SIZE),z_=Jg(O_,O_.COORDINATE),G_=Jg(O_,O_.VIEWPORT),j_=G_.zw,W_=z_.sub(G_.xy),H_=W_.div(j_),$_=iy(()=>(wc('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new Im),V_),"vec2").once()();let Q_=null,X_=null,Y_=null,Z_=null,K_=null,J_=null,ew=null,tw=null,rw=null,iw=null,nw=null,sw=null,aw=null,ow=null;const lw=mb(0,"uint").setName("u_cameraIndex").setGroup(hb("cameraIndex")).toVarying("v_cameraIndex"),Aw=mb("float").setName("cameraNear").setGroup(db).onRenderUpdate(({camera:e})=>e.near),uw=mb("float").setName("cameraFar").setGroup(db).onRenderUpdate(({camera:e})=>e.far),hw=iy(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);null===X_?X_=I_(r).setGroup(db).setName("cameraProjectionMatrices"):X_.array=r,t=X_.element(e.isMultiViewCamera?F_("gl_ViewID_OVR"):lw).toConst("cameraProjectionMatrix")}else null===Q_&&(Q_=mb(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(db).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Q_;return t}).once()(),cw=iy(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);null===Z_?Z_=I_(r).setGroup(db).setName("cameraProjectionMatricesInverse"):Z_.array=r,t=Z_.element(e.isMultiViewCamera?F_("gl_ViewID_OVR"):lw).toConst("cameraProjectionMatrixInverse")}else null===Y_&&(Y_=mb(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(db).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=Y_;return t}).once()(),dw=iy(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);null===J_?J_=I_(r).setGroup(db).setName("cameraViewMatrices"):J_.array=r,t=J_.element(e.isMultiViewCamera?F_("gl_ViewID_OVR"):lw).toConst("cameraViewMatrix")}else null===K_&&(K_=mb(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(db).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=K_;return t}).once()(),pw=iy(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorld);null===tw?tw=I_(r).setGroup(db).setName("cameraWorldMatrices"):tw.array=r,t=tw.element(e.isMultiViewCamera?F_("gl_ViewID_OVR"):lw).toConst("cameraWorldMatrix")}else null===ew&&(ew=mb(e.matrixWorld).setName("cameraWorldMatrix").setGroup(db).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=ew;return t}).once()(),fw=iy(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.normalMatrix);null===iw?iw=I_(r).setGroup(db).setName("cameraNormalMatrices"):iw.array=r,t=iw.element(e.isMultiViewCamera?F_("gl_ViewID_OVR"):lw).toConst("cameraNormalMatrix")}else null===rw&&(rw=mb(e.normalMatrix).setName("cameraNormalMatrix").setGroup(db).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=rw;return t}).once()(),mw=iy(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(let t=0,i=e.cameras.length;t{const r=e.cameras,i=t.array;for(let e=0,t=r.length;et.value.setFromMatrixPosition(e.matrixWorld))),t=nw;return t}).once()(),gw=iy(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.viewport);null===ow?ow=I_(r,"vec4").setGroup(db).setName("cameraViewports"):ow.array=r,t=ow.element(lw).toConst("cameraViewport")}else null===aw&&(aw=vy(0,0,V_.x,V_.y).toConst("cameraViewport")),t=aw;return t}).once()(),yw=new Lp;class bw extends ng{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Ym.OBJECT,this.uniformNode=new fb(null)}getNodeType(){const e=this.scope;return e===bw.WORLD_MATRIX?"mat4":e===bw.POSITION||e===bw.VIEW_POSITION||e===bw.DIRECTION||e===bw.SCALE?"vec3":e===bw.RADIUS?"float":void 0}update(e){const t=this.object3d,r=this.uniformNode,i=this.scope;if(i===bw.WORLD_MATRIX)r.value=t.matrixWorld;else if(i===bw.POSITION)r.value=r.value||new Vc,r.value.setFromMatrixPosition(t.matrixWorld);else if(i===bw.SCALE)r.value=r.value||new Vc,r.value.setFromMatrixScale(t.matrixWorld);else if(i===bw.DIRECTION)r.value=r.value||new Vc,t.getWorldDirection(r.value);else if(i===bw.VIEW_POSITION){const i=e.camera;r.value=r.value||new Vc,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}else if(i===bw.RADIUS){const i=e.object.geometry;null===i.boundingSphere&&i.computeBoundingSphere(),yw.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),r.value=yw.radius}}generate(e){const t=this.scope;return t===bw.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===bw.POSITION||t===bw.VIEW_POSITION||t===bw.DIRECTION||t===bw.SCALE?this.uniformNode.nodeType="vec3":t===bw.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}}bw.WORLD_MATRIX="worldMatrix",bw.POSITION="position",bw.SCALE="scale",bw.VIEW_POSITION="viewPosition",bw.DIRECTION="direction",bw.RADIUS="radius";const xw=Kg(bw,bw.DIRECTION).setParameterLength(1),vw=Kg(bw,bw.WORLD_MATRIX).setParameterLength(1),_w=Kg(bw,bw.POSITION).setParameterLength(1),ww=Kg(bw,bw.SCALE).setParameterLength(1),Tw=Kg(bw,bw.VIEW_POSITION).setParameterLength(1),Mw=Kg(bw,bw.RADIUS).setParameterLength(1);class Sw extends bw{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Nw=Jg(Sw,Sw.DIRECTION),Ew=Jg(Sw,Sw.WORLD_MATRIX),Cw=Jg(Sw,Sw.POSITION),Rw=Jg(Sw,Sw.SCALE),Bw=Jg(Sw,Sw.VIEW_POSITION),Pw=Jg(Sw,Sw.RADIUS),Dw=mb(new jc).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),Iw=mb(new Ad).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),Fw=iy(e=>e.context.modelViewMatrix||qw).once()().toVar("modelViewMatrix"),qw=dw.mul(Ew),Lw=iy(e=>(e.context.isHighPrecisionModelViewMatrix=!0,mb("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),Ow=iy(e=>{const t=e.context.isHighPrecisionModelViewMatrix;return mb("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),kw=iy(e=>"fragment"!==e.shaderStage?(Mc("TSL: `clipSpace` is only available in fragment stage."),vy()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),Uw=y_("position","vec3"),Vw=Uw.toVarying("positionLocal"),zw=Uw.toVarying("positionPrevious"),Gw=iy(e=>Ew.mul(Vw).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),jw=iy(()=>Vw.transformDirection(Ew).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Ww=iy(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){const e=cw.mul(kw);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),Hw=iy(e=>{let t;return t=e.camera.isOrthographicCamera?gy(0,0,1):Ww.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class $w extends ng{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";const{material:t}=e;return 1===t.side?"false":e.getFrontFacing()}}const Qw=Jg($w),Xw=Ay(Qw).mul(2).sub(1),Yw=iy(([e],{material:t})=>{const r=t.side;return 1===r?e=e.mul(-1):2===r&&(e=e.mul(Xw)),e}),Zw=y_("normal","vec3"),Kw=iy(e=>!1===e.geometry.hasAttribute("normal")?(wc('TSL: Vertex attribute "normal" not found on geometry.'),gy(0,1,0)):Zw,"vec3").once()().toVar("normalLocal"),Jw=Ww.dFdx().cross(Ww.dFdy()).normalize().toVar("normalFlat"),eT=iy(e=>{let t;return t=e.isFlatShading()?Jw:aT(Kw).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),tT=iy(e=>{let t=eT.transformDirection(dw);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),rT=iy(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=eT,!0!==e.isFlatShading()&&(t=Yw(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),iT=rT.transformDirection(dw).toVar("normalWorld"),nT=iy(({subBuildFn:e,context:t})=>{let r;return r="NORMAL"===e||"VERTEX"===e?rT:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),r},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),sT=iy(([e,t=Ew])=>{const r=Sy(t),i=e.div(gy(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(i).xyz}),aT=iy(([e],t)=>{const r=t.context.modelNormalViewMatrix;if(r)return r.transformDirection(e);const i=Dw.mul(e);return dw.transformDirection(i)}),oT=iy(()=>(wc('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),rT)).once(["NORMAL","VERTEX"])(),lT=iy(()=>(wc('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),iT)).once(["NORMAL","VERTEX"])(),AT=iy(()=>(wc('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),nT)).once(["NORMAL","VERTEX"])(),uT=new bd,hT=new Ad,cT=mb(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),dT=mb(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),pT=mb(new Ad).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?(uT.copy(r),hT.makeRotationFromEuler(uT)):hT.identity(),hT}),fT=Hw.negate().reflect(rT),mT=Hw.negate().refract(rT,cT),gT=fT.transformDirection(dw).toVar("reflectVector"),yT=mT.transformDirection(dw).toVar("reflectVector"),bT=new Lf;class xT extends S_{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,i=null){super(e,t,r,i),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Ou?gT:e.mapping===ku?yT:(Tc('CubeTextureNode: Mapping "%s" not supported.',e.mapping),gy(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===pc?gy(t.x,t.y.negate(),t.z):t:(e.renderer.coordinateSystem!==pc&&r.isRenderTargetTexture||(t=gy(t.x.negate(),t.yz)),pT.mul(t))}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}const vT=Kg(xT).setParameterLength(1,4).setName("cubeTexture"),_T=(e=bT,t=null,r=null,i=null)=>{let n;return e&&!0===e.isCubeTextureNode?(n=Qg(e.clone()),n.referenceNode=e,null!==t&&(n.uvNode=Qg(t)),null!==r&&(n.levelNode=Qg(r)),null!==i&&(n.biasNode=Qg(i))):n=vT(e,t,r,i),n};class wT extends sg{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 TT extends ng{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=Ym.OBJECT}element(e){return new wT(this,Qg(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return wc('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;t=null!==this.count?B_(null,e,this.count):Array.isArray(this.getValueFromReference())?I_(null,e):"texture"===e?E_(null):"cubeTexture"===e?_T(null):mb(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),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;enew TT(e,t,r),ST=(e,t,r,i)=>new TT(e,t,i,r);class NT extends TT{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 ET=(e,t,r=null)=>new NT(e,t,r),CT=b_(),RT=Ww.dFdx(),BT=Ww.dFdy(),PT=CT.dFdx(),DT=CT.dFdy(),IT=rT,FT=BT.cross(IT),qT=IT.cross(RT),LT=FT.mul(PT.x).add(qT.mul(DT.x)),OT=FT.mul(PT.y).add(qT.mul(DT.y)),kT=LT.dot(LT).max(OT.dot(OT)),UT=kT.equal(0).select(0,kT.inverseSqrt()),VT=LT.mul(UT).toVar("tangentViewFrame"),zT=OT.mul(UT).toVar("bitangentViewFrame"),GT=y_("tangent","vec4"),jT=GT.xyz.toVar("tangentLocal"),WT=iy(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?Fw.mul(vy(jT,0)).xyz.toVarying("v_tangentView").normalize():VT,!0!==e.isFlatShading()&&(t=Yw(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),HT=WT.transformDirection(dw).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),$T=iy(([e,t],r)=>{let i=e.mul(GT.w).xyz;return"NORMAL"===r.subBuildFn&&!0!==r.isFlatShading()&&(i=i.toVarying(t)),i}).once(["NORMAL"]),QT=$T(Zw.cross(GT),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),XT=$T(Kw.cross(jT),"v_bitangentLocal").normalize().toVar("bitangentLocal"),YT=iy(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?$T(rT.cross(WT),"v_bitangentView").normalize():zT,!0!==e.isFlatShading()&&(t=Yw(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),ZT=$T(iT.cross(HT),"v_bitangentWorld").normalize().toVar("bitangentWorld"),KT=Sy(WT,YT,rT).toVar("TBNViewMatrix"),JT=Hw.mul(KT),eM=iy(()=>{let e=Qy.cross(Hw);return e=e.cross(Qy).normalize(),e=Jx(e,rT,Hy.mul(qy.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),tM=e=>Qg(e).mul(.5).add(.5),rM=e=>gy(e,cx(tv(Ay(1).sub(jx(e,e)))));class iM extends og{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=""}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:i}=this;let n=this.node.mul(2).sub(1);if(0===t?"rg"===i?n=rM(n.xy):"ga"===i?n=rM(n.yw):""!==i&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${i}`):""!==i&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${i}'`),null!==r){let t=r;!0===e.isFlatShading()&&(t=Yw(t)),n=gy(n.xy.mul(t),n.z)}let s=null;return 1===t?s=aT(n):0===t?s=KT.mul(n).normalize():(Tc(`NodeMaterial: Unsupported normal map type: ${t}`),s=rT),s}}const nM=Kg(iM).setParameterLength(1,2),sM=iy(({textureNode:e,bumpScale:t})=>{const r=t=>e.isolate().context({getUV:e=>t(e.uvNode||b_()),forceUVContext:!0}),i=Ay(r(e=>e));return dy(Ay(r(e=>e.add(e.dFdx()))).sub(i),Ay(r(e=>e.add(e.dFdy()))).sub(i)).mul(t)}),aM=iy(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(Xw),A=l.sign().mul(i.x.mul(a).add(i.y.mul(o)));return l.abs().mul(r).sub(A).normalize()});class oM extends og{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=sM({textureNode:this.textureNode,bumpScale:e});return aM({surf_pos:Ww,surf_norm:rT,dHdxy:t})}}const lM=Kg(oM).setParameterLength(1,2),AM=new Map;class uM extends ng{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=AM.get(e);return void 0===r&&(r=ET(e,t),AM.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===uM.COLOR){const e=void 0!==t.color?this.getColor(r):gy();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===uM.OPACITY){const e=this.getFloat(r);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===uM.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Ay(1);else if(r===uM.SPECULAR_INTENSITY){const e=this.getFloat(r);i=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===uM.SPECULAR_COLOR){const e=this.getColor(r);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===uM.ROUGHNESS){const e=this.getFloat(r);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===uM.METALNESS){const e=this.getFloat(r);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===uM.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===uM.NORMAL)t.normalMap?(i=nM(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=t.normalMapType,t.normalMap.format!=ph&&t.normalMap.format!=Xh&&t.normalMap.format!=Rh||(i.unpackNormalMode="rg")):i=t.bumpMap?lM(this.getTexture("bump").r,this.getFloat("bumpScale")):rT;else if(r===uM.CLEARCOAT){const e=this.getFloat(r);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===uM.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===uM.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?nM(this.getTexture(r),this.getCache(r+"Scale","vec2")):rT;else if(r===uM.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===uM.SHEEN_ROUGHNESS){const e=this.getFloat(r);i=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===uM.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);i=My(QM.x,QM.y,QM.y.negate(),QM.x).mul(e.rg.mul(2).sub(dy(1)).normalize().mul(e.b))}else i=QM;else if(r===uM.IRIDESCENCE_THICKNESS){const e=MT("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const n=MT("0","float",t.iridescenceThicknessRange);i=e.sub(n).mul(this.getTexture(r).g).add(n)}else i=e}else if(r===uM.TRANSMISSION){const e=this.getFloat(r);i=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===uM.THICKNESS){const e=this.getFloat(r);i=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===uM.IOR)i=this.getFloat(r);else if(r===uM.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===uM.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===uM.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(r):Ay(0);else{const t=this.getNodeType(e);i=this.getCache(r,t)}return i}}uM.ALPHA_TEST="alphaTest",uM.COLOR="color",uM.OPACITY="opacity",uM.SHININESS="shininess",uM.SPECULAR="specular",uM.SPECULAR_STRENGTH="specularStrength",uM.SPECULAR_INTENSITY="specularIntensity",uM.SPECULAR_COLOR="specularColor",uM.REFLECTIVITY="reflectivity",uM.ROUGHNESS="roughness",uM.METALNESS="metalness",uM.NORMAL="normal",uM.CLEARCOAT="clearcoat",uM.CLEARCOAT_ROUGHNESS="clearcoatRoughness",uM.CLEARCOAT_NORMAL="clearcoatNormal",uM.EMISSIVE="emissive",uM.ROTATION="rotation",uM.SHEEN="sheen",uM.SHEEN_ROUGHNESS="sheenRoughness",uM.ANISOTROPY="anisotropy",uM.IRIDESCENCE="iridescence",uM.IRIDESCENCE_IOR="iridescenceIOR",uM.IRIDESCENCE_THICKNESS="iridescenceThickness",uM.IOR="ior",uM.TRANSMISSION="transmission",uM.THICKNESS="thickness",uM.ATTENUATION_DISTANCE="attenuationDistance",uM.ATTENUATION_COLOR="attenuationColor",uM.LINE_SCALE="scale",uM.LINE_DASH_SIZE="dashSize",uM.LINE_GAP_SIZE="gapSize",uM.LINE_WIDTH="linewidth",uM.LINE_DASH_OFFSET="dashOffset",uM.POINT_SIZE="size",uM.DISPERSION="dispersion",uM.LIGHT_MAP="light",uM.AO="ao";const hM=Jg(uM,uM.ALPHA_TEST),cM=Jg(uM,uM.COLOR),dM=Jg(uM,uM.SHININESS),pM=Jg(uM,uM.EMISSIVE),fM=Jg(uM,uM.OPACITY),mM=Jg(uM,uM.SPECULAR),gM=Jg(uM,uM.SPECULAR_INTENSITY),yM=Jg(uM,uM.SPECULAR_COLOR),bM=Jg(uM,uM.SPECULAR_STRENGTH),xM=Jg(uM,uM.REFLECTIVITY),vM=Jg(uM,uM.ROUGHNESS),_M=Jg(uM,uM.METALNESS),wM=Jg(uM,uM.NORMAL),TM=Jg(uM,uM.CLEARCOAT),MM=Jg(uM,uM.CLEARCOAT_ROUGHNESS),SM=Jg(uM,uM.CLEARCOAT_NORMAL),NM=Jg(uM,uM.ROTATION),EM=Jg(uM,uM.SHEEN),CM=Jg(uM,uM.SHEEN_ROUGHNESS),RM=Jg(uM,uM.ANISOTROPY),BM=Jg(uM,uM.IRIDESCENCE),PM=Jg(uM,uM.IRIDESCENCE_IOR),DM=Jg(uM,uM.IRIDESCENCE_THICKNESS),IM=Jg(uM,uM.TRANSMISSION),FM=Jg(uM,uM.THICKNESS),qM=Jg(uM,uM.IOR),LM=Jg(uM,uM.ATTENUATION_DISTANCE),OM=Jg(uM,uM.ATTENUATION_COLOR),kM=Jg(uM,uM.LINE_SCALE),UM=Jg(uM,uM.LINE_DASH_SIZE),VM=Jg(uM,uM.LINE_GAP_SIZE),zM=Jg(uM,uM.LINE_WIDTH),GM=Jg(uM,uM.LINE_DASH_OFFSET),jM=Jg(uM,uM.POINT_SIZE),WM=Jg(uM,uM.DISPERSION),HM=Jg(uM,uM.LIGHT_MAP),$M=Jg(uM,uM.AO),QM=mb(new kc).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))}),XM=iy(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class YM extends sg{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 ZM=Kg(YM).setParameterLength(2);class KM extends R_{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=Vm(e.itemSize),r=e.count):i=t,super(e,i,r),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=Zm.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 ZM(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Zm.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=$v(this.value),this._varying=Ev(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 JM=(e,t=null,r=0)=>new KM(e,t,r);class eS extends ng{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===eS.VERTEX)i=e.getVertexIndex();else if(r===eS.INSTANCE)i=e.getInstanceIndex();else if(r===eS.DRAW)i=e.getDrawIndex();else if(r===eS.INVOCATION_LOCAL)i=e.getInvocationLocalIndex();else if(r===eS.INVOCATION_SUBGROUP)i=e.getInvocationSubgroupIndex();else{if(r!==eS.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);i=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)n=i;else{n=Ev(this).build(e,t)}return n}}eS.VERTEX="vertex",eS.INSTANCE="instance",eS.SUBGROUP="subgroup",eS.INVOCATION_LOCAL="invocationLocal",eS.INVOCATION_SUBGROUP="invocationSubgroup",eS.DRAW="draw";const tS=Jg(eS,eS.VERTEX),rS=Jg(eS,eS.INSTANCE),iS=Jg(eS,eS.SUBGROUP),nS=Jg(eS,eS.INVOCATION_SUBGROUP),sS=Jg(eS,eS.INVOCATION_LOCAL),aS=Jg(eS,eS.DRAW);class oS extends ng{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=Ym.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}get isStorageColor(){const{instanceColor:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}setup(e){let{instanceMatrixNode:t,instanceColorNode:r}=this;null===t&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:i,isStorageColor:n}=this;if(i&&null===r){if(n)r=JM(i,"vec3",Math.max(i.count,1)).element(rS);else{const e=new _f(i.array,3),t=i.usage===cc?Xv:Qv;this.bufferColor=e,r=gy(t(e,"vec3",3,0))}this.instanceColorNode=r}const s=t.mul(Vw).xyz;if(Vw.assign(s),e.needsPreviousData()&&zw.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const e=sT(Kw,t);Kw.assign(e)}null!==this.instanceColorNode&&Py("vec3","vInstanceColor").assign(this.instanceColorNode)}update(e){null!==this.buffer&&!0!==this.isStorageMatrix&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&null!==this.bufferColor&&!0!==this.isStorageColor&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),null!==this.previousInstanceMatrixNode&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return null===this.previousInstanceMatrixNode&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(zw).xyz}_createInstanceMatrixNode(e,t){let r;const{instanceMatrix:i}=this,{count:n}=i;if(this.isStorageMatrix)r=JM(i,"mat4",Math.max(n,1)).element(rS);else{if(16*n*4<=t.getUniformBufferLimit())r=B_(i.array,"mat4",Math.max(n,1)).element(rS);else{const t=new Nm(i.array,16,1);!0===e&&(this.buffer=t);const n=i.usage===cc?Xv:Qv,s=[n(t,"vec4",16,0),n(t,"vec4",16,4),n(t,"vec4",16,8),n(t,"vec4",16,12)];r=Ny(...s)}}return r}}const lS=Kg(oS).setParameterLength(2,3);class AS extends oS{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:i}=e;super(t,r,i),this.instancedMesh=e}}const uS=Kg(AS).setParameterLength(1);class hS extends ng{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=rS:this.batchingIdNode=aS);const t=iy(([e])=>{const t=uy(v_(C_(this.batchMesh._indirectTexture),0).x).toConst(),r=uy(e).mod(t).toConst(),i=uy(e).div(t).toConst();return C_(this.batchMesh._indirectTexture,py(r,i)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(uy(this.batchingIdNode)),i=this.batchMesh._matricesTexture,n=uy(v_(C_(i),0).x).toConst(),s=Ay(r).mul(4).toInt().toConst(),a=s.mod(n).toConst(),o=s.div(n).toConst(),l=Ny(C_(i,py(a,o)),C_(i,py(a.add(1),o)),C_(i,py(a.add(2),o)),C_(i,py(a.add(3),o))),A=this.batchMesh._colorsTexture;if(null!==A){const e=iy(([e])=>{const t=uy(v_(C_(A),0).x).toConst(),r=e,i=r.mod(t).toConst(),n=r.div(t).toConst();return C_(A,py(i,n)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);Py("vec3","vBatchColor").assign(t)}const u=Sy(l);Vw.assign(l.mul(Vw));const h=Kw.div(gy(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),c=u.mul(h).xyz;Kw.assign(c),e.hasGeometryAttribute("tangent")&&jT.mulAssign(u)}}const cS=Kg(hS).setParameterLength(1),dS=new WeakMap;class pS extends ng{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Ym.OBJECT,this.skinIndexNode=y_("skinIndex","uvec4"),this.skinWeightNode=y_("skinWeight","vec4"),this.bindMatrixNode=MT("bindMatrix","mat4"),this.bindMatrixInverseNode=MT("bindMatrixInverse","mat4"),this.boneMatricesNode=ST("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vw,this.toPositionNode=Vw,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=Mb(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}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=Kw,r=jT){const{skinIndexNode:i,skinWeightNode:n,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),A=e.element(i.z),u=e.element(i.w);let h=Mb(n.x.mul(o),n.y.mul(l),n.z.mul(A),n.w.mul(u));h=a.mul(h).mul(s);return{skinNormal:h.transformDirection(t).xyz,skinTangent:h.transformDirection(r).xyz}}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=ST("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,zw)}setup(e){e.needsPreviousData()&&zw.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:t,skinTangent:r}=this.getSkinnedNormalAndTangent();Kw.assign(t),e.hasGeometryAttribute("tangent")&&jT.assign(r)}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;dS.get(t)!==e.frameId&&(dS.set(t,e.frameId),null!==this.previousBoneMatricesNode&&(null===t.previousBoneMatrices&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const fS=e=>new pS(e);class mS extends ng{static get type(){return"LoopNode"}constructor(e=[]){super("void"),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;eNumber(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):(Tc("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),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");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode("\n"+e.tab+n);for(let t=0,r=this.params.length-1;tnew mS(Zg(e,"int")).toStack(),yS=()=>l_("break").toStack(),bS=new WeakMap,xS=new ad,vS=iy(({bufferMap:e,influence:t,stride:r,width:i,depth:n,offset:s})=>{const a=uy(tS).mul(r).add(s),o=a.div(i),l=a.sub(o.mul(i));return C_(e,py(l,o)).depth(n).xyz.mul(t)});class _S extends ng{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=mb(1),this.updateType=Ym.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=bS.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 ld(p,h,c,s);f.type=th,f.needsUpdate=!0;const m=4*u;for(let y=0;y{const t=Ay(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(C_(this.mesh.morphTexture,py(uy(e).add(1),uy(rS))).r):t.assign(MT("morphTargetInfluences","float").element(e).toVar()),ay(t.notEqual(0),()=>{!0===r&&Vw.addAssign(vS({bufferMap:a,influence:t,stride:o,width:A,depth:e,offset:uy(0)})),!0===i&&Kw.addAssign(vS({bufferMap:a,influence:t,stride:o,width:A,depth:e,offset:uy(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 wS=Kg(_S).setParameterLength(1);class TS extends ng{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class MS extends TS{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class SS extends dv{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:gy().toVar("directDiffuse"),directSpecular:gy().toVar("directSpecular"),indirectDiffuse:gy().toVar("indirectDiffuse"),indirectSpecular:gy().toVar("indirectSpecular")};return{radiance:gy().toVar("radiance"),irradiance:gy().toVar("irradiance"),iblIrradiance:gy().toVar("iblIrradiance"),ambientOcclusion:Ay(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 NS=Kg(SS);class ES extends TS{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const CS=new kc;class RS extends S_{static get type(){return"ViewportTextureNode"}constructor(e=U_,t=null,r=null){let i=null;null===r?(i=new qf,i.minFilter=Qu,r=i):i=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=Ym.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),null===e)return t;if(!1===r.has(e)){const i=t.clone();r.set(e,i)}return r.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget();null===r?t.getDrawingBufferSize(CS):CS.set(r.width,r.height);const i=this.getTextureForReference(r);i.image.width===CS.width&&i.image.height===CS.height||(i.image.width=CS.width,i.image.height=CS.height,i.needsUpdate=!0);const n=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=n}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const BS=Kg(RS).setParameterLength(0,3),PS=Kg(RS,null,null,{generateMipmaps:!0}).setParameterLength(0,3),DS=PS(),IS=(e=U_,t=null)=>DS.sample(e,t);let FS=null;class qS extends RS{static get type(){return"ViewportDepthTextureNode"}constructor(e=U_,t=null){null===FS&&(FS=new Of),super(e,t,FS)}getTextureForReference(){return FS}}const LS=Kg(qS).setParameterLength(0,2);class OS extends ng{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===OS.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let i=null;if(t===OS.DEPTH_BASE)null!==r&&(i=WS().assign(r));else if(t===OS.DEPTH)i=e.isPerspectiveCamera?VS(Ww.z,Aw,uw):kS(Ww.z,Aw,uw);else if(t===OS.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=GS(r,Aw,uw);i=kS(e,Aw,uw)}else i=r;else i=kS(Ww.z,Aw,uw);return i}}OS.DEPTH_BASE="depthBase",OS.DEPTH="depth",OS.LINEAR_DEPTH="linearDepth";const kS=(e,t,r)=>e.add(t).div(t.sub(r)),US=iy(([e,t,r],i)=>!0===i.renderer.reversedDepthBuffer?r.sub(t).mul(e).sub(r):t.sub(r).mul(e).sub(t)),VS=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),zS=(e,t,r)=>t.mul(e.add(r)).div(e.mul(t.sub(r))),GS=iy(([e,t,r],i)=>!0===i.renderer.reversedDepthBuffer?t.mul(r).div(t.sub(r).mul(e).sub(t)):t.mul(r).div(r.sub(t).mul(e).sub(r))),jS=(e,t,r)=>{t=t.max(1e-6).toVar();const i=hx(e.negate().div(t)),n=hx(r.div(t));return i.div(n)},WS=Kg(OS,OS.DEPTH_BASE),HS=Jg(OS,OS.DEPTH),$S=Kg(OS,OS.LINEAR_DEPTH).setParameterLength(0,1),QS=$S(LS());HS.assign=e=>WS(e);class XS extends ng{static get type(){return"ClippingNode"}constructor(e=XS.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===XS.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===XS.HARDWARE?this.setupHardwareClipping(i,e):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return iy(()=>{const r=Ay().toVar("distanceToPlane"),i=Ay().toVar("distanceToGradient"),n=Ay(1).toVar("clipOpacity"),s=t.length;if(!1===this.hardwareClipping&&s>0){const e=I_(t).setGroup(db);gS(s,({i:t})=>{const s=e.element(t);r.assign(Ww.dot(s.xyz).negate().add(s.w)),i.assign(r.fwidth().div(2)),n.mulAssign(iv(i.negate(),i,r))})}const a=e.length;if(a>0){const t=I_(e).setGroup(db),s=Ay(1).toVar("intersectionClipOpacity");gS(a,({i:e})=>{const n=t.element(e);r.assign(Ww.dot(n.xyz).negate().add(n.w)),i.assign(r.fwidth().div(2)),s.mulAssign(iv(i.negate(),i,r).oneMinus())}),n.mulAssign(s.oneMinus())}Dy.a.mulAssign(n),Dy.a.equal(0).discard()})()}setupDefault(e,t){return iy(()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=I_(t).setGroup(db);gS(r,({i:t})=>{const r=e.element(t);Ww.dot(r.xyz).greaterThan(r.w).discard()})}const i=e.length;if(i>0){const t=I_(e).setGroup(db),r=cy(!0).toVar("clipped");gS(i,({i:e})=>{const i=t.element(e);r.assign(Ww.dot(i.xyz).greaterThan(i.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),iy(()=>{const i=I_(e).setGroup(db),n=F_(t.getClipDistance());gS(r,({i:e})=>{const t=i.element(e),r=Ww.dot(t.xyz).sub(t.w).negate();n.element(e).assign(r)})})()}}XS.ALPHA_TO_COVERAGE="alphaToCoverage",XS.DEFAULT="default",XS.HARDWARE="hardware";const YS=iy(([e])=>gx(Nb(1e4,yx(Nb(17,e.x).add(Nb(.1,e.y)))).mul(Mb(.1,Tx(yx(Nb(13,e.y).add(e.x))))))),ZS=iy(([e])=>YS(dy(YS(e.xy),e.z))),KS=iy(([e])=>{const t=kx(Sx(Cx(e.xyz)),Sx(Rx(e.xyz))),r=Ay(1).div(Ay(.05).mul(t)).toVar("pixScale"),i=dy(Ax(px(hx(r))),Ax(fx(hx(r)))),n=dy(ZS(px(i.x.mul(e.xyz))),ZS(px(i.y.mul(e.xyz)))),s=gx(hx(r)),a=Mb(Nb(s.oneMinus(),n.x),Nb(s,n.y)),o=Ox(s,s.oneMinus()),l=gy(a.mul(a).div(Nb(2,o).mul(Sb(1,o))),a.sub(Nb(.5,o)).div(Sb(1,o)),Sb(1,Sb(1,a).mul(Sb(1,a)).div(Nb(2,o).mul(Sb(1,o))))),A=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return ev(A,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class JS extends g_{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 ad(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const eN=(e=0)=>new JS(e),tN=iy(([e,t])=>Ox(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),rN=iy(([e,t])=>Ox(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),iN=iy(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),nN=iy(([e,t])=>Jx(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Ux(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),sN=iy(([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return vy(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"}]}),aN=iy(([e])=>vy(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),oN=iy(([e])=>(ay(e.a.equal(0),()=>vy(0)),vy(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class lN extends Yp{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.maskShadowNode=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,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(!0===t.startsWith("_"))continue;const r=this[t];r&&!0===r.isNode&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(qm(t.slice(0,-4)),r.getCacheKey());return this.type+Lm(e)}build(e){this.setup(e)}setupObserver(e){return new Pm(e)}setup(e){e.context.setupNormal=()=>Sv(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();!0===t.contextNode.isContextNode?e.context={...e.context,...t.contextNode.getFlowContextData()}:Tc('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),null!==this.contextNode&&(!0===this.contextNode.isContextNode?e.context={...e.context,...this.contextNode.getFlowContextData()}:Tc('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();const i=this.setupVertex(e),n=Sv(this.vertexNode||i,"VERTEX");let s;e.context.clipSpace=n,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.addToStack(a);const n=vy(i,Dy.a).max(0);s=this.setupOutput(e,n),Jy.assign(s);const o=null!==this.outputNode;if(o&&(s=this.outputNode),e.context.getOutput&&(s=e.context.getOutput(s,e)),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&Jy.assign(s),s=e,null!==r&&(s=e.merge(r))):null!==r&&(s=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=vy(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.currentSamples;this.alphaToCoverage&&t>1?i=new XS(XS.ALPHA_TO_COVERAGE):e.stack.addToStack(new XS)}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.addToStack(new XS(XS.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?jS(Ww.z,Aw,uw):kS(Ww.z,Aw,uw))}null!==i&&HS.assign(i).toStack()}setupPositionView(){return Fw.mul(Vw).xyz}setupModelViewProjection(){return hw.mul(Ww)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),XM}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&wS(t).toStack(),!0===t.isSkinnedMesh&&fS(t).toStack(),this.displacementMap){const e=ET("displacementMap","texture"),t=ET("displacementScale","float"),r=ET("displacementBias","float");Vw.addAssign(Kw.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&cS(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&uS(t).toStack(),null!==this.positionNode&&Vw.assign(Sv(this.positionNode,"POSITION","vec3")),Vw}setupDiffuseColor(e){const{object:t,geometry:r}=e;null!==this.maskNode&&cy(this.maskNode).not().discard();let i=this.colorNode?vy(this.colorNode):cM;if(!0===this.vertexColors&&r.hasAttribute("color")&&(i=i.mul(eN())),t.instanceColor){i=Py("vec3","vInstanceColor").mul(i)}if(t.isBatchedMesh&&t._colorsTexture){i=Py("vec3","vBatchColor").mul(i)}Dy.assign(i);const n=this.opacityNode?Ay(this.opacityNode):fM;Dy.a.assign(Dy.a.mul(n));let s=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(s=null!==this.alphaTestNode?Ay(this.alphaTestNode):hM,!0===this.alphaToCoverage?(Dy.a=iv(s,s.add(Ix(Dy.a)),Dy.a),Dy.a.lessThanEqual(0).discard()):Dy.a.lessThanEqual(s).discard()),!0===this.alphaHash&&Dy.a.lessThan(KS(Vw)).discard(),e.isOpaque()&&Dy.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?gy(0):Dy.rgb}setupNormal(){return this.normalNode?gy(this.normalNode):wM}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ET("envMap","cubeTexture"):ET("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ES(HM)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const i=this.setupLightMap(e);i&&i.isLightingNode&&t.push(i);let n=this.aoNode;null===n&&e.material.aoMap&&(n=$M),e.context.getAO&&(n=e.context.getAO(n,e)),n&&t.push(new MS(n));let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}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=NS(s,t,r,i)}else null!==r&&(a=gy(null!==i?Jx(a,r,i):r));return(n&&!0===n.isNode||t.emissive&&!0===t.emissive.isColor)&&(Fy.assign(gy(n||pM)),a=a.add(Fy)),a}setupFog(e,t){const r=e.fogNode;return r&&(Jy.assign(t),t=vy(r.toVar())),t}setupPremultipliedAlpha(e,t){return aN(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=Yp.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:t,childNode:i}of this._getNodeChildren())r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const i=e[r];delete i.metadata,t.push(i)}return t}if(t){const t=i(e.textures),n=i(e.images),s=i(e.nodes);t.length>0&&(r.textures=t),n.length>0&&(r.images=n),s.length>0&&(r.nodes=s)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,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.maskShadowNode=e.maskShadowNode,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,this.contextNode=e.contextNode,super.copy(e)}}const AN=new If;class uN extends lN{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(AN),this.setValues(e)}}const hN=new Kf;class cN extends lN{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(hN),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Ay(this.offsetNode):GM,t=this.dashScaleNode?Ay(this.dashScaleNode):kM,r=this.dashSizeNode?Ay(this.dashSizeNode):UM,i=this.gapSizeNode?Ay(this.gapSizeNode):VM;eb.assign(r),tb.assign(i);const n=Ev(y_("lineDistance").mul(t));(e?n.add(e):n).mod(eb.add(tb)).greaterThan(eb).discard()}}const dN=new Xf;class pN extends lN{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(dN),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Ay(this.opacityNode):fM;Dy.assign(Fv(vy(tM(rT),e),Kh))}}const fN=iy(([e=jw])=>{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 dy(t,r)});class mN extends od{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new Lf(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!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 Uf(5,5,5),s=fN(jw),a=new lN;a.colorNode=E_(t,s,0),a.side=1,a.blending=0;const o=new bf(n,a),l=new Hd;l.add(o),t.minFilter===Qu&&(t.minFilter=Hu);const A=new Mm(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}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)}}const gN=new WeakMap;class yN extends og{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=_T(null);const t=new Lf;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Ym.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(gN.has(e)){const t=gN.get(e);xN(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const i=new mN(r.height);i.fromEquirectangularTexture(t,e),xN(i.texture,e.mapping),this._cubeTexture=i.texture,gN.set(e,i.texture),e.addEventListener("dispose",bN)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function bN(e){const t=e.target;t.removeEventListener("dispose",bN);const r=gN.get(t);void 0!==r&&(gN.delete(t),r.dispose())}function xN(e,t){303===t?e.mapping=Ou:304===t&&(e.mapping=ku)}const vN=Kg(yN).setParameterLength(1);class _N extends TS{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=vN(this.envNode)}}class wN extends TS{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Ay(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class TN{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class MN extends TN{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,i=e.irradianceLightMap;r.indirectDiffuse.assign(vy(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(vy(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Dy.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(Jx(i.rgb,i.rgb.mul(n.rgb),bM.mul(xM)));break;case 1:i.rgb.assign(Jx(i.rgb,n.rgb,bM.mul(xM)));break;case 2:i.rgb.addAssign(n.rgb.mul(bM.mul(xM)));break;default:wc("BasicLightingModel: Unsupported .combine value:",t.combine)}}}const SN=new of;class NN extends lN{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(SN),this.setValues(e)}setupNormal(){return Yw(eT)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _N(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new wN(HM)),t}setupOutgoingLight(){return Dy.rgb}setupLightingModel(){return new MN}}const EN=iy(({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))}),CN=iy(e=>e.diffuseColor.mul(1/Math.PI)),RN=iy(({dotNH:e})=>Ky.mul(Ay(.5)).add(1).mul(Ay(1/Math.PI)).mul(e.pow(Ky))),BN=iy(({lightDirection:e})=>{const t=e.add(Hw).normalize(),r=rT.dot(t).clamp(),i=Hw.dot(t).clamp(),n=EN({f0:Xy,f90:1,dotVH:i}),s=Ay(.25),a=RN({dotNH:r});return n.mul(s).mul(a)});class PN extends MN{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const i=rT.dot(e).clamp().mul(t);r.directDiffuse.addAssign(i.mul(CN({diffuseColor:Dy.rgb}))),!0===this.specular&&r.directSpecular.addAssign(i.mul(BN({lightDirection:e})).mul(bM))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(CN({diffuseColor:Dy}))),i.indirectDiffuse.mulAssign(t)}}const DN=new Yf;class IN extends lN{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(DN),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _N(t):null}setupLightingModel(){return new PN(!1)}}const FN=new $f;class qN extends lN{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(FN),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _N(t):null}setupLightingModel(){return new PN}setupVariants(){const e=(this.shininessNode?Ay(this.shininessNode):dM).max(1e-4);Ky.assign(e);const t=this.specularNode||mM;Xy.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const LN=iy(e=>{if(!1===e.geometry.hasAttribute("normal"))return Ay(0);const t=eT.dFdx().abs().max(eT.dFdy().abs());return t.x.max(t.y).max(t.z)}),ON=iy(e=>{const{roughness:t}=e,r=LN();let i=t.max(.0525);return i=i.add(r),i=i.min(1),i}),kN=iy(({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 Eb(.5,n.add(s).max(Kb))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),UN=iy(({alphaT:e,alphaB:t,dotTV:r,dotBV:i,dotTL:n,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(gy(e.mul(r),t.mul(i),a).length()),A=a.mul(gy(e.mul(n),t.mul(s),o).length());return Eb(.5,l.add(A))}).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"}]}),VN=iy(({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"}]}),zN=Ay(1/Math.PI),GN=iy(({alphaT:e,alphaB:t,dotNH:r,dotTH:i,dotBH:n})=>{const s=e.mul(t),a=gy(t.mul(i),e.mul(n),s.mul(r)),o=a.dot(a),l=s.div(o);return zN.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"}]}),jN=iy(({lightDirection:e,f0:t,f90:r,roughness:i,f:n,normalView:s=rT,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{const l=i.pow2(),A=e.add(Hw).normalize(),u=s.dot(e).clamp(),h=s.dot(Hw).clamp(),c=s.dot(A).clamp(),d=Hw.dot(A).clamp();let p,f,m=EN({f0:t,f90:r,dotVH:d});if(Wg(a)&&(m=zy.mix(m,n)),Wg(o)){const t=$y.dot(e),r=$y.dot(Hw),i=$y.dot(A),n=Qy.dot(e),s=Qy.dot(Hw),a=Qy.dot(A);p=UN({alphaT:Wy,alphaB:l,dotTV:r,dotBV:s,dotTL:t,dotBL:n,dotNV:h,dotNL:u}),f=GN({alphaT:Wy,alphaB:l,dotNH:c,dotTH:i,dotBH:a})}else p=kN({alpha:l,dotNL:u,dotNV:h}),f=VN({alpha:l,dotNH:c});return m.mul(p).mul(f)}),WN=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let HN=null;const $N=iy(({roughness:e,dotNV:t})=>{null===HN&&(HN=new vf(WN,16,16,ph,rh),HN.name="DFG_LUT",HN.minFilter=Hu,HN.magFilter=Hu,HN.wrapS=Vu,HN.wrapT=Vu,HN.generateMipmaps=!1,HN.needsUpdate=!0);const r=dy(e,t);return E_(HN,r).rg}),QN=iy(({lightDirection:e,f0:t,f90:r,roughness:i,f:n,USE_IRIDESCENCE:s,USE_ANISOTROPY:a})=>{const o=jN({lightDirection:e,f0:t,f90:r,roughness:i,f:n,USE_IRIDESCENCE:s,USE_ANISOTROPY:a}),l=rT.dot(e).clamp(),A=rT.dot(Hw).clamp(),u=$N({roughness:i,dotNV:A}),h=$N({roughness:i,dotNV:l}),c=t.mul(u.x).add(r.mul(u.y)),d=t.mul(h.x).add(r.mul(h.y)),p=u.x.add(u.y),f=h.x.add(h.y),m=Ay(1).sub(p),g=Ay(1).sub(f),y=t.add(t.oneMinus().mul(.047619)),b=c.mul(d).mul(y).div(Ay(1).sub(m.mul(g).mul(y).mul(y)).add(Kb)),x=m.mul(g),v=b.mul(x);return o.add(v)}),XN=iy(e=>{const{dotNV:t,specularColor:r,specularF90:i,roughness:n}=e,s=$N({dotNV:t,roughness:n});return r.mul(s.x).add(i.mul(s.y))}),YN=iy(({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(gy(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"}]}),ZN=iy(({roughness:e,dotNH:t})=>{const r=e.pow2(),i=Ay(1).div(r),n=t.pow2().oneMinus().max(.0078125);return Ay(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"}]}),KN=iy(({dotNV:e,dotNL:t})=>Ay(1).div(Ay(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),JN=iy(({lightDirection:e})=>{const t=e.add(Hw).normalize(),r=rT.dot(e).clamp(),i=rT.dot(Hw).clamp(),n=rT.dot(t).clamp(),s=ZN({roughness:Vy,dotNH:n}),a=KN({dotNV:i,dotNL:r});return Uy.mul(s).mul(a)}),eE=iy(({N:e,V:t,roughness:r})=>{const i=e.dot(t).saturate(),n=dy(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"}]}),tE=iy(({f:e})=>{const t=e.length();return kx(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),rE=iy(({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,kx(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"}]}),iE=iy(({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=gy().toVar();return ay(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(Sy(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=gy(0).toVar();m.addAssign(rE({v1:c,v2:d})),m.addAssign(rE({v1:d,v2:p})),m.addAssign(rE({v1:p,v2:f})),m.addAssign(rE({v1:f,v2:c})),h.assign(gy(tE({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"}]}),nE=1/6,sE=e=>Nb(nE,Nb(e,Nb(e,e.negate().add(3)).sub(3)).add(1)),aE=e=>Nb(nE,Nb(e,Nb(e,Nb(3,e).sub(6))).add(4)),oE=e=>Nb(nE,Nb(e,Nb(e,Nb(-3,e).add(3)).add(3)).add(1)),lE=e=>Nb(nE,Hx(e,3)),AE=e=>sE(e).add(aE(e)),uE=e=>oE(e).add(lE(e)),hE=e=>Mb(-1,aE(e).div(sE(e).add(aE(e)))),cE=e=>Mb(1,lE(e).div(oE(e).add(lE(e)))),dE=(e,t,r)=>{const i=e.uvNode,n=Nb(i,t.zw).add(.5),s=px(n),a=gx(n),o=AE(a.x),l=uE(a.x),A=hE(a.x),u=cE(a.x),h=hE(a.y),c=cE(a.y),d=dy(s.x.add(A),s.y.add(h)).sub(.5).mul(t.xy),p=dy(s.x.add(u),s.y.add(h)).sub(.5).mul(t.xy),f=dy(s.x.add(A),s.y.add(c)).sub(.5).mul(t.xy),m=dy(s.x.add(u),s.y.add(c)).sub(.5).mul(t.xy),g=AE(a.y).mul(Mb(o.mul(e.sample(d).level(r)),l.mul(e.sample(p).level(r)))),y=uE(a.y).mul(Mb(o.mul(e.sample(f).level(r)),l.mul(e.sample(m).level(r))));return g.add(y)},pE=iy(([e,t])=>{const r=dy(e.size(uy(t))),i=dy(e.size(uy(t.add(1)))),n=Eb(1,r),s=Eb(1,i),a=dE(e,vy(n,r),px(t)),o=dE(e,vy(s,i),fx(t));return gx(t).mix(a,o)}),fE=iy(([e,t])=>{const r=t.mul(w_(e));return pE(e,r)}),mE=iy(([e,t,r,i,n])=>{const s=gy(rv(t.negate(),mx(e),Eb(1,i))),a=gy(Sx(n[0].xyz),Sx(n[1].xyz),Sx(n[2].xyz));return mx(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"}]}),gE=iy(([e,t])=>e.mul(ev(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),yE=PS(),bE=IS(),xE=iy(([e,t,r],{material:i})=>{const n=(1===i.side?yE:bE).sample(e),s=hx(V_.x).mul(gE(t,r));return pE(n,s)}),vE=iy(([e,t,r])=>(ay(r.notEqual(0),()=>{const i=ux(t).negate().div(r);return lx(i.negate().mul(e))}),gy(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),_E=iy(([e,t,r,i,n,s,a,o,l,A,u,h,c,d,p])=>{let f,m;if(p){f=vy().toVar(),m=gy().toVar();const n=u.sub(1).mul(p.mul(.025)),s=gy(u.sub(n),u,u.add(n));gS({start:0,end:3},({i:n})=>{const u=s.element(n),p=mE(e,t,h,u,o),g=a.add(p),y=A.mul(l.mul(vy(g,1))),b=dy(y.xy.div(y.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(dy(b.x,b.y.oneMinus()));const x=xE(b,r,u);f.element(n).assign(x.element(n)),f.a.addAssign(x.a),m.element(n).assign(i.element(n).mul(vE(Sx(p),c,d).element(n)))}),f.a.divAssign(3)}else{const n=mE(e,t,h,u,o),s=a.add(n),p=A.mul(l.mul(vy(s,1))),g=dy(p.xy.div(p.w)).toVar();g.addAssign(1),g.divAssign(2),g.assign(dy(g.x,g.y.oneMinus())),f=xE(g,r,u),m=i.mul(vE(Sx(n),c,d))}const g=m.rgb.mul(f.rgb),y=e.dot(t).clamp(),b=gy(XN({dotNV:y,specularColor:n,specularF90:s,roughness:r})),x=m.r.add(m.g,m.b).div(3);return vy(b.oneMinus().mul(g),f.a.oneMinus().mul(x).oneMinus())}),wE=Sy(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),TE=(e,t)=>e.sub(t).div(e.add(t)).pow2(),ME=iy(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:i,baseF0:n})=>{const s=Jx(e,t,iv(0,.03,i)),a=e.div(s).pow2().mul(r.pow2().oneMinus()).oneMinus();ay(a.lessThan(0),()=>gy(1));const o=a.sqrt(),l=TE(s,e),A=EN({f0:l,f90:1,dotVH:r}),u=A.oneMinus(),h=s.lessThan(e).select(Math.PI,0),c=Ay(Math.PI).sub(h),d=(e=>{const t=e.sqrt();return gy(1).add(t).div(gy(1).sub(t))})(n.clamp(0,.9999)),p=TE(d,s.toVec3()),f=EN({f0:p,f90:1,dotVH:o}),m=gy(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=gy(c).add(m),b=A.mul(f).clamp(1e-5,.9999),x=b.sqrt(),v=u.pow2().mul(f).div(gy(1).sub(b)),_=A.add(v).toVar(),w=v.sub(u).toVar();return gS({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=gy(54856e-17,44201e-17,52481e-17),n=gy(1681e3,1795300,2208400),s=gy(43278e5,93046e5,66121e5),a=Ay(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=gy(o.x.add(a),o.y,o.z).div(1.0685e-7),wE.mul(o)})(Ay(e).mul(g),Ay(e).mul(y)).mul(2);_.addAssign(w.mul(t))}),_.max(gy(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"}]}),SE=iy(({normal:e,viewDir:t,roughness:r})=>{const i=e.dot(t).saturate(),n=r.mul(r),s=r.add(.1).reciprocal(),a=Ay(-1.9362).add(r.mul(1.0678)).add(n.mul(.4573)).sub(s.mul(.8469)),o=Ay(-.6014).add(r.mul(.5538)).sub(n.mul(.467)).sub(s.mul(.1255));return a.mul(i).add(o).exp().saturate()}),NE=gy(.04),EE=Ay(1);class CE extends TN{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,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=gy().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=gy().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=gy().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=gy().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=gy().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=rT.dot(Hw).clamp(),t=ME({outsideIOR:Ay(1),eta2:Gy,cosTheta1:e,thinFilmThickness:jy,baseF0:Xy}),r=ME({outsideIOR:Ay(1),eta2:Gy,cosTheta1:e,thinFilmThickness:jy,baseF0:Dy.rgb});this.iridescenceFresnel=Jx(t,r,Ly),this.iridescenceF0Dielectric=YN({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=YN({f:r,f90:1,dotVH:e}),this.iridescenceF0=Jx(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,Ly)}if(!0===this.transmission){const t=Gw,r=mw.sub(Gw).normalize(),i=iT,n=e.context;n.backdrop=_E(i,r,qy,Iy,Yy,Zy,t,Ew,dw,hw,ib,sb,ob,ab,this.dispersion?lb:null),n.backdropAlpha=nb,Dy.a.mulAssign(Jx(1,n.backdrop.a,nb))}super.start(e)}computeMultiscattering(e,t,r,i,n=null){const s=rT.dot(Hw).clamp(),a=$N({roughness:qy,dotNV:s}),o=n?zy.mix(i,n):i,l=o.mul(a.x).add(r.mul(a.y)),A=a.x.add(a.y).oneMinus(),u=o.add(o.oneMinus().mul(.047619)),h=l.mul(u).div(A.mul(u).oneMinus());e.addAssign(l),t.addAssign(h.mul(A))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const i=rT.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(i.mul(JN({lightDirection:e})));const t=SE({normal:rT,viewDir:Hw,roughness:Vy}),r=SE({normal:rT,viewDir:e,roughness:Vy}),n=Uy.r.max(Uy.g).max(Uy.b).mul(t.max(r)).oneMinus();i.mulAssign(n)}if(!0===this.clearcoat){const r=nT.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(jN({lightDirection:e,f0:NE,f90:EE,roughness:ky,normalView:nT})))}r.directDiffuse.addAssign(i.mul(CN({diffuseColor:Iy}))),r.directSpecular.addAssign(i.mul(QN({lightDirection:e,f0:Yy,f90:1,roughness:qy,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=rT,c=Hw,d=Ww.toVar(),p=eE({N:h,V:c,roughness:qy}),f=s.sample(p).toVar(),m=a.sample(p).toVar(),g=Sy(gy(f.x,0,f.y),gy(0,1,0),gy(f.z,0,f.w)).toVar(),y=Yy.mul(m.x).add(Zy.sub(Yy).mul(m.y)).toVar();if(n.directSpecular.addAssign(e.mul(y).mul(iE({N:h,V:c,P:d,mInv:g,p0:o,p1:l,p2:A,p3:u}))),n.directDiffuse.addAssign(e.mul(Iy).mul(iE({N:h,V:c,P:d,mInv:Sy(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:A,p3:u}))),!0===this.clearcoat){const t=nT,r=eE({N:t,V:c,roughness:ky}),i=s.sample(r),n=a.sample(r),h=Sy(gy(i.x,0,i.y),gy(0,1,0),gy(i.z,0,i.w)),p=NE.mul(n.x).add(EE.sub(NE).mul(n.y));this.clearcoatSpecularDirect.addAssign(e.mul(p).mul(iE({N:t,V:c,P:d,mInv:h,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,i=t.mul(CN({diffuseColor:Iy})).toVar();if(!0===this.sheen){const e=SE({normal:rT,viewDir:Hw,roughness:Vy}),t=Uy.r.max(Uy.g).max(Uy.b).mul(e).oneMinus();i.mulAssign(t)}r.indirectDiffuse.addAssign(i)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:i}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Uy,SE({normal:rT,viewDir:Hw,roughness:Vy}))),!0===this.clearcoat){const e=nT.dot(Hw).clamp(),t=XN({dotNV:e,specularColor:NE,specularF90:EE,roughness:ky});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const n=gy().toVar("singleScatteringDielectric"),s=gy().toVar("multiScatteringDielectric"),a=gy().toVar("singleScatteringMetallic"),o=gy().toVar("multiScatteringMetallic");this.computeMultiscattering(n,s,Zy,Xy,this.iridescenceF0Dielectric),this.computeMultiscattering(a,o,Zy,Dy.rgb,this.iridescenceF0Metallic);const l=Jx(n,a,Ly),A=Jx(s,o,Ly),u=n.add(s),h=Iy.mul(u.oneMinus()),c=r.mul(1/Math.PI),d=t.mul(l).add(A.mul(c)).toVar(),p=h.mul(c).toVar();if(!0===this.sheen){const e=SE({normal:rT,viewDir:Hw,roughness:Vy}),t=Uy.r.max(Uy.g).max(Uy.b).mul(e).oneMinus();d.mulAssign(t),p.mulAssign(t)}i.indirectSpecular.addAssign(d),i.indirectDiffuse.addAssign(p)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,i=rT.dot(Hw).clamp().add(t),n=qy.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=nT.dot(Hw).clamp(),r=EN({dotVH:e,f0:NE,f90:EE}),i=t.mul(Oy.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Oy));t.assign(i)}if(!0===this.sheen){const e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}const RE=Ay(1),BE=Ay(-2),PE=Ay(.8),DE=Ay(-1),IE=Ay(.4),FE=Ay(2),qE=Ay(.305),LE=Ay(3),OE=Ay(.21),kE=Ay(4),UE=Ay(4),VE=Ay(16),zE=iy(([e])=>{const t=gy(Tx(e)).toVar(),r=Ay(-1).toVar();return ay(t.x.greaterThan(t.z),()=>{ay(t.x.greaterThan(t.y),()=>{r.assign(cv(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(cv(e.y.greaterThan(0),1,4))})}).Else(()=>{ay(t.z.greaterThan(t.y),()=>{r.assign(cv(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(cv(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),GE=iy(([e,t])=>{const r=dy().toVar();return ay(t.equal(0),()=>{r.assign(dy(e.z,e.y).div(Tx(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(dy(e.x.negate(),e.z.negate()).div(Tx(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(dy(e.x.negate(),e.y).div(Tx(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(dy(e.z.negate(),e.y).div(Tx(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(dy(e.x.negate(),e.z).div(Tx(e.y)))}).Else(()=>{r.assign(dy(e.x,e.y).div(Tx(e.z)))}),Nb(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),jE=iy(([e])=>{const t=Ay(0).toVar();return ay(e.greaterThanEqual(PE),()=>{t.assign(RE.sub(e).mul(DE.sub(BE)).div(RE.sub(PE)).add(BE))}).ElseIf(e.greaterThanEqual(IE),()=>{t.assign(PE.sub(e).mul(FE.sub(DE)).div(PE.sub(IE)).add(DE))}).ElseIf(e.greaterThanEqual(qE),()=>{t.assign(IE.sub(e).mul(LE.sub(FE)).div(IE.sub(qE)).add(FE))}).ElseIf(e.greaterThanEqual(OE),()=>{t.assign(qE.sub(e).mul(kE.sub(LE)).div(qE.sub(OE)).add(LE))}).Else(()=>{t.assign(Ay(-2).mul(hx(Nb(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),WE=iy(([e,t])=>{const r=e.toVar();r.assign(Nb(2,r).sub(1));const i=gy(r,1).toVar();return ay(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"}]}),HE=iy(([e,t,r,i,n,s])=>{const a=Ay(r),o=gy(t),l=ev(jE(a),BE,s),A=gx(l),u=px(l),h=gy($E(e,o,u,i,n,s)).toVar();return ay(A.notEqual(0),()=>{const t=gy($E(e,o,u.add(1),i,n,s)).toVar();h.assign(Jx(h,t,A))}),h}),$E=iy(([e,t,r,i,n,s])=>{const a=Ay(r).toVar(),o=gy(t),l=Ay(zE(o)).toVar(),A=Ay(kx(UE.sub(a),0)).toVar();a.assign(kx(a,UE));const u=Ay(Ax(a)).toVar(),h=dy(GE(o,l).mul(u.sub(2)).add(1)).toVar();return ay(l.greaterThan(2),()=>{h.y.addAssign(u),l.subAssign(3)}),h.x.addAssign(l.mul(u)),h.x.addAssign(A.mul(Nb(3,VE))),h.y.addAssign(Nb(4,Ax(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(n),e.sample(h).grad(dy(),dy())}),QE=iy(({envMap:e,mipInt:t,outputDirection:r,theta:i,axis:n,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=bx(i),A=r.mul(l).add(n.cross(r).mul(yx(i))).add(n.mul(n.dot(r).mul(l.oneMinus())));return $E(e,A,t,s,a,o)}),XE=iy(({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=gy(cv(t,r,Wx(r,i))).toVar();ay(c.equal(gy(0)),()=>{c.assign(gy(i.z,0,i.x.negate()))}),c.assign(mx(c));const d=gy().toVar();return d.addAssign(n.element(0).mul(QE({theta:0,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),gS({start:uy(1),end:e},({i:e})=>{ay(e.greaterThanEqual(s),()=>{yS()});const t=Ay(a.mul(Ay(e))).toVar();d.addAssign(n.element(e).mul(QE({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(QE({theta:t,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),vy(d,1)}),YE=iy(([e])=>{const t=hy(e).toVar();return t.assign(t.shiftLeft(hy(16)).bitOr(t.shiftRight(hy(16)))),t.assign(t.bitAnd(hy(1431655765)).shiftLeft(hy(1)).bitOr(t.bitAnd(hy(2863311530)).shiftRight(hy(1)))),t.assign(t.bitAnd(hy(858993459)).shiftLeft(hy(2)).bitOr(t.bitAnd(hy(3435973836)).shiftRight(hy(2)))),t.assign(t.bitAnd(hy(252645135)).shiftLeft(hy(4)).bitOr(t.bitAnd(hy(4042322160)).shiftRight(hy(4)))),t.assign(t.bitAnd(hy(16711935)).shiftLeft(hy(8)).bitOr(t.bitAnd(hy(4278255360)).shiftRight(hy(8)))),Ay(t).mul(2.3283064365386963e-10)}),ZE=iy(([e,t])=>dy(Ay(e).div(Ay(t)),YE(e))),KE=iy(([e,t,r])=>{const i=r.mul(r).toConst(),n=gy(1,0,0).toConst(),s=Wx(t,n).toConst(),a=cx(e.x).toConst(),o=Nb(2,3.14159265359).mul(e.y).toConst(),l=a.mul(bx(o)).toConst(),A=a.mul(yx(o)).toVar(),u=Nb(.5,t.z.add(1)).toConst();A.assign(u.oneMinus().mul(cx(l.mul(l).oneMinus())).add(u.mul(A)));const h=n.mul(l).add(s.mul(A)).add(t.mul(cx(kx(0,l.mul(l).add(A.mul(A)).oneMinus()))));return mx(gy(i.mul(h.x),i.mul(h.y),kx(0,h.z)))}),JE=iy(({roughness:e,mipInt:t,envMap:r,N_immutable:i,GGX_SAMPLES:n,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=gy(i).toVar(),A=gy(0).toVar(),u=Ay(0).toVar();return ay(e.lessThan(.001),()=>{A.assign($E(r,l,t,s,a,o))}).Else(()=>{const i=cv(Tx(l.z).lessThan(.999),gy(0,0,1),gy(1,0,0)),h=mx(Wx(i,l)).toVar(),c=Wx(l,h).toVar();gS({start:hy(0),end:n},({i:i})=>{const d=ZE(i,n),p=KE(d,gy(0,0,1),e),f=mx(h.mul(p.x).add(c.mul(p.y)).add(l.mul(p.z))),m=mx(f.mul(jx(l,f).mul(2)).sub(l)),g=kx(jx(l,m),0);ay(g.greaterThan(0),()=>{const e=$E(r,m,t,s,a,o);A.addAssign(e.mul(g)),u.addAssign(g)})}),ay(u.greaterThan(0),()=>{A.assign(A.div(u))})}),vy(A,1)}),eC=[.125,.215,.35,.446,.526,.582],tC=20,rC=new gm(-1,1,1,-1,0,1),iC=new cm(90,1),nC=new jd;let sC=null,aC=0,oC=0;const lC=new Vc,AC=new WeakMap,uC=[3,1,5,0,4,2],hC=WE(b_(),y_("faceIndex")).normalize(),cC=gy(hC.x,hC.y,hC.z);class dC{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=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=lC,renderTarget:o=null}=n;if(this._setSize(s),!1===this._hasInitialized){wc('PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.');const s=o||this._allocateTarget();return n.renderTarget=s,this.fromSceneAsync(e,t,r,i,n),s}sC=this._renderer.getRenderTarget(),aC=this._renderer.getActiveCubeFace(),oC=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 Mc('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,i,n)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){wc('PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" 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 Mc('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){wc("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 Mc('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=gC(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=yC(),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===Ou||e.mapping===ku?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._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=eC[a-e+4-1]:0===a&&(o=0),r.push(o);const l=1/(s-2),A=-l,u=1+l,h=[A,A,u,A,u,u,A,A,u,u,A,u],c=6,d=6,p=3,f=2,m=1,g=new Float32Array(p*d*c),y=new Float32Array(f*d*c),b=new Float32Array(m*d*c);for(let e=0;e2?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=uC[e];g.set(i,p*d*n),y.set(h,f*d*n);const s=[n,n,n,n,n,n];b.set(s,m*d*n)}const x=new Wp;x.setAttribute("position",new Cp(g,p)),x.setAttribute("uv",new Cp(y,f)),x.setAttribute("faceIndex",new Cp(b,m)),i.push(new bf(x,null)),n>4&&n--}return{lodMeshes:i,sizeLods:t,sigmas:r}}(t)),this._blurMaterial=function(e,t,r){const i=I_(new Array(tC).fill(0)),n=mb(new Vc(0,1,0)),s=mb(0),a=Ay(tC),o=mb(0),l=mb(1),A=E_(),u=mb(0),h=Ay(1/t),c=Ay(1/r),d=Ay(e),p={n:a,latitudinal:o,weights:i,poleAxis:n,outputDirection:cC,dTheta:s,samples:l,envMap:A,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d},f=mC("blur");return f.fragmentNode=XE({...p,latitudinal:o.equal(1)}),AC.set(f,p),f}(t,e.width,e.height),this._ggxMaterial=function(e,t,r){const i=E_(),n=mb(0),s=mb(0),a=Ay(1/t),o=Ay(1/r),l=Ay(e),A={envMap:i,roughness:n,mipInt:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:l},u=mC("ggx");return u.fragmentNode=JE({...A,N_immutable:cC,GGX_SAMPLES:hy(512)}),AC.set(u,A),u}(t,e.width,e.height)}}async _compileMaterial(e){const t=new bf(new Wp,e);await this._renderer.compile(t,rC)}_sceneToCubeUV(e,t,r,i,n){const s=iC;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(nC),l.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new bf(new Uf,new of({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,h=u.material;let c=!1;const d=e.background;d?d.isColor&&(h.color.copy(d),e.background=null,c=!0):(h.color.copy(nC),c=!0),l.setRenderTarget(i),l.clear(),c&&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;fC(i,r*A,t>2?A:0,A,A),l.render(e,s)}l.autoClear=A,e.background=d}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===Ou||e.mapping===ku;i?null===this._cubemapMaterial&&(this._cubemapMaterial=gC(e)):null===this._equirectMaterial&&(this._equirectMaterial=yC(e));const n=i?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=e;const s=this._lodMeshes[0];s.material=n;const a=this._cubeSize;fC(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(s,rC)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let t=1;th-4?r-h+4:0),p=4*(this._cubeSize-c);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=u,o.mipInt.value=h-t,fC(n,d,p,3*c,2*c),i.setRenderTarget(n),i.render(a,rC),n.texture.frame=(n.texture.frame||0)+1,o.envMap.value=n.texture,o.roughness.value=0,o.mipInt.value=h-r,fC(e,d,p,3*c,2*c),i.setRenderTarget(e),i.render(a,rC)}_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&&Tc("blur direction must be either latitudinal or longitudinal!");const A=this._lodMeshes[i];A.material=l;const u=AC.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):tC;p>tC&&wc(`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;eg-4?i-g+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(A,rC)}}function pC(e,t){const r=new od(e,t,{magFilter:Hu,minFilter:Hu,generateMipmaps:!1,type:rh,format:Ah,colorSpace:Jh});return r.texture.mapping=306,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function fC(e,t,r,i,n){e.viewport.set(t,r,i,n),e.scissor.set(t,r,i,n)}function mC(e){const t=new lN;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function gC(e){const t=mC("cubemap");return t.fragmentNode=_T(e,cC),t}function yC(e){const t=mC("equirect");return t.fragmentNode=E_(e,fN(cC),0),t}const bC=new WeakMap;function xC(e,t,r){const i=function(e){let t=bC.get(e);void 0===t&&(t=new WeakMap,bC.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;i0}(t))return null;n=r.fromEquirectangular(e,n)}n.pmremVersion=e.pmremVersion,i.set(e,n)}return n.texture}class vC extends og{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 sd;i.isRenderTargetTexture=!0,this._texture=E_(i),this._width=mb(0),this._height=mb(0),this._maxMip=mb(0),this.updateBeforeType=Ym.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:xC(i,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new dC(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=pT.mul(gy(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),HE(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const _C=Kg(vC).setParameterLength(1,3),wC=new WeakMap;class TC extends TS{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 i=r.isTextureNode?r.value:t[r.property],n=this._getPMREMNodeCache(e.renderer);let s=n.get(i);void 0===s&&(s=_C(i),n.set(i,s)),r=s}const i=!0===t.useAnisotropy||t.anisotropy>0?eM:rT,n=r.context(MC(qy,i)).mul(dT),s=r.context(SC(iT)).mul(Math.PI).mul(dT),a=e_(n),o=e_(s);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const l=e.context.lightingModel.clearcoatRadiance;if(l){const e=r.context(MC(ky,nT)).mul(dT),t=e_(e);l.addAssign(t)}}_getPMREMNodeCache(e){let t=wC.get(e);return void 0===t&&(t=new WeakMap,wC.set(e,t)),t}}const MC=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=Hw.negate().reflect(t),r=Xx(e).mix(r,t).normalize(),r=r.transformDirection(dw)),r),getTextureLevel:()=>e}},SC=e=>({getUV:()=>e,getTextureLevel:()=>Ay(1)}),NC=new Wf;class EC extends lN{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(NC),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new TC(t):null}setupLightingModel(){return new CE}setupSpecular(){const e=Jx(gy(.04),Dy.rgb,Ly);Xy.assign(gy(.04)),Yy.assign(e),Zy.assign(1)}setupVariants(){const e=this.metalnessNode?Ay(this.metalnessNode):_M;Ly.assign(e);let t=this.roughnessNode?Ay(this.roughnessNode):vM;t=ON({roughness:t}),qy.assign(t),this.setupSpecular(),Iy.assign(Dy.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const CC=new Hf;class RC extends EC{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(CC),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?Ay(this.iorNode):qM;ib.assign(e),Xy.assign(Ox($x(ib.sub(1).div(ib.add(1))).mul(yM),gy(1)).mul(gM)),Yy.assign(Jx(Xy,Dy.rgb,Ly)),Zy.assign(Jx(gM,1,Ly))}setupLightingModel(){return new CE(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Ay(this.clearcoatNode):TM,t=this.clearcoatRoughnessNode?Ay(this.clearcoatRoughnessNode):MM;Oy.assign(e),ky.assign(ON({roughness:t}))}if(this.useSheen){const e=this.sheenNode?gy(this.sheenNode):EM,t=this.sheenRoughnessNode?Ay(this.sheenRoughnessNode):CM;Uy.assign(e),Vy.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Ay(this.iridescenceNode):BM,t=this.iridescenceIORNode?Ay(this.iridescenceIORNode):PM,r=this.iridescenceThicknessNode?Ay(this.iridescenceThicknessNode):DM;zy.assign(e),Gy.assign(t),jy.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?dy(this.anisotropyNode):RM).toVar();Hy.assign(e.length()),ay(Hy.equal(0),()=>{e.assign(dy(1,0))}).Else(()=>{e.divAssign(dy(Hy)),Hy.assign(Hy.saturate())}),Wy.assign(Hy.pow2().mix(qy.pow2(),1)),$y.assign(KT[0].mul(e.x).add(KT[1].mul(e.y))),Qy.assign(KT[1].mul(e.x).sub(KT[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Ay(this.transmissionNode):IM,t=this.thicknessNode?Ay(this.thicknessNode):FM,r=this.attenuationDistanceNode?Ay(this.attenuationDistanceNode):LM,i=this.attenuationColorNode?gy(this.attenuationColorNode):OM;if(nb.assign(e),sb.assign(t),ab.assign(r),ob.assign(i),this.useDispersion){const e=this.dispersionNode?Ay(this.dispersionNode):WM;lb.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?gy(this.clearcoatNormalNode):SM}setup(e){e.context.setupClearcoatNormal=()=>Sv(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.iorNode=e.iorNode,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 BC=iy(({normal:e,lightDirection:t,builder:r})=>{const i=e.dot(t),n=dy(i.mul(.5).add(.5),0);if(r.material.gradientMap){const e=ET("gradientMap","texture").context({getUV:()=>n});return gy(e.r)}{const e=n.fwidth().mul(.5);return Jx(gy(.7),gy(1),iv(Ay(.7).sub(e.x),Ay(.7).add(e.x),n.x))}});class PC extends TN{direct({lightDirection:e,lightColor:t,reflectedLight:r},i){const n=BC({normal:Zw,lightDirection:e,builder:i}).mul(t);r.directDiffuse.addAssign(n.mul(CN({diffuseColor:Dy.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(CN({diffuseColor:Dy}))),i.indirectDiffuse.mulAssign(t)}}const DC=new Qf;class IC extends lN{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(DC),this.setValues(e)}setupLightingModel(){return new PC}}const FC=iy(()=>{const e=gy(Hw.z,0,Hw.x.negate()).normalize(),t=Hw.cross(e);return dy(e.dot(rT),t.dot(rT)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),qC=new Zf;class LC extends lN{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(qC),this.setValues(e)}setupVariants(e){const t=FC;let r;r=e.material.matcap?ET("matcap","texture").context({getUV:()=>t}):gy(Jx(.2,.8,t.y)),Dy.rgb.mulAssign(r.rgb)}}class OC extends og{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 My(e,i,i.negate(),e).mul(r)}{const e=t,i=Ny(vy(1,0,0,0),vy(0,bx(e.x),yx(e.x).negate(),0),vy(0,yx(e.x),bx(e.x),0),vy(0,0,0,1)),n=Ny(vy(bx(e.y),0,yx(e.y),0),vy(0,1,0,0),vy(yx(e.y).negate(),0,bx(e.y),0),vy(0,0,0,1)),s=Ny(vy(bx(e.z),yx(e.z).negate(),0,0),vy(yx(e.z),bx(e.z),0,0),vy(0,0,1,0),vy(0,0,0,1));return i.mul(n).mul(s).mul(vy(r,1)).xyz}}}const kC=Kg(OC).setParameterLength(2),UC=new Zp;class VC extends lN{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(UC),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:i,rotationNode:n,scaleNode:s,sizeAttenuation:a}=this,o=Fw.mul(gy(i||0));let l=dy(Ew[0].xyz.length(),Ew[1].xyz.length());null!==s&&(l=l.mul(dy(s))),r.isPerspectiveCamera&&!1===a&&(l=l.mul(o.z.negate()));let A=Uw.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>new Lv(e,t,r))("center","vec2",t);A=A.sub(e.sub(.5))}A=A.mul(l);const u=Ay(n||NM),h=kC(A,u);return vy(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 zC=new Ff,GC=new kc;class jC extends VC{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(zC),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Fw.mul(gy(e||Vw)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:i,scaleNode:n,sizeNode:s,sizeAttenuation:a}=this;let o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let l=null!==s?dy(s):jM;l=l.mul(k_),r.isPerspectiveCamera&&!0===a&&(l=l.mul(WC.div(Ww.z.negate()))),n&&n.isNode&&(l=l.mul(dy(n)));let A=Uw.xy;if(i&&i.isNode){const e=Ay(i);A=kC(A,e)}return A=A.mul(l),A=A.div(j_.div(2)),A=A.mul(o.w),o=o.add(vy(A,0,0)),o}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const WC=mb(1).onFrameUpdate(function({renderer:e}){const t=e.getSize(GC);this.value=.5*t.y});class HC extends TN{constructor(){super(),this.shadowNode=Ay(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Dy.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Dy.rgb)}}const $C=new jf;class QC extends lN{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues($C),this.setValues(e)}setupLightingModel(){return new HC}}By("vec3"),By("vec3"),By("vec3");class XC{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,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,this.renderer._inspector.begin(),null!==this._animationLoop&&this._animationLoop(t,r),this.renderer._inspector.finish()};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 YC{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return void 0===r&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{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)}getIndirectOffset(){return this._geometries.getIndirectOffset(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.id),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;e1||Array.isArray(e.morphTargetInfluences))&&(i+=e.uuid+","),i+=this.context.id+",",i+=e.receiveShadow+",",qm(i)}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=Om(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Om(e,1)),e=Om(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const JC=[];class eR{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);JC[0]=e,JC[1]=t,JC[2]=s,JC[3]=n;let A=l.get(JC);return void 0===A?(A=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,i,n,s,a,o),l.set(JC,A)):(A.camera=i,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)),JC[0]=null,JC[1]=null,JC[2]=null,JC[3]=null,A}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new YC)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,i,n,s,a,o,l,A,u){const h=this.getChainMap(u),c=new KC(e,t,r,i,n,s,a,o,l,A);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.deleteForRender(c),this.nodes.delete(c),h.delete(c.getChainArray())},c}}class tR{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 rR=1,iR=2,nR=3,sR=4,aR=16;class oR extends tR{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===rR?this.backend.createAttribute(e):t===iR?this.backend.createIndexAttribute(e):t===nR?this.backend.createStorageAttribute(e):t===sR&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version=65535?Bp:Rp)(t,1);return n.version=lR(e),n.__id=AR(e),n}class hR extends tR{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}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),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,nR):this.updateAttribute(e,rR);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,iR);const i=e.geometry.indirect;null!==i&&this.updateAttribute(i,sR)}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}getIndirectOffset(e){return e.geometry.indirectOffset}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=uR(t),e.set(t,r)):r.version===lR(t)&&r.__id===AR(t)||(this.attributes.delete(r),r=uR(t),e.set(t,r)),i=r}return i}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class cR{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):Tc("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 dR{constructor(e){this.cacheKey=e,this.usedTimes=0}}class pR extends dR{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class fR extends dR{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let mR=0;class gR{constructor(e,t,r,i=null,n=null){this.id=mR++,this.code=e,this.stage=t,this.name=r,this.transforms=i,this.attributes=n,this.usedTimes=0}}class yR extends tR{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 gR(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 gR(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 gR(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 fR(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 pR(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 bR extends tR{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))}deleteForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t)this.backend.deleteBindGroupData(e),this.delete(e)}deleteForRender(e){const t=e.getBindings();for(const e of t)this.backend.deleteBindGroupData(e),this.delete(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.isSampler)this.textures.updateSampler(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?sR:nR;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(!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){const e=t.attribute,n=e.isIndirectStorageBufferAttribute?sR:nR,s=r.get(t);this.attributes.update(e,n),s.attribute!==e&&(s.attribute=e,i=!0)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampledTexture){const o=t.update(),l=t.texture,A=this.textures.get(l);o&&(this.textures.updateTexture(l),t.generation!==A.generation&&(t.generation=A.generation,i=!0),A.bindGroups.add(e));if(void 0!==r.get(l).externalTexture||A.isDefaultTexture?n=!1:(s=10*s+l.id,a+=l.version),!0===l.isStorageTexture&&!0===l.mipmapsAutoUpdate){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)}}else if(t.isSampler){if(t.update()){const e=this.textures.updateSampler(t.texture);t.samplerKey!==e&&(t.samplerKey=e,i=!0)}}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}}!0===i&&this.backend.updateBindings(e,t,n?s:0,a)}}function xR(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 vR(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 _R(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&2===e.side&&!1===e.forceSinglePass}class wR{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||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(_R(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||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(_R(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||xR),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||vR),this.transparent.length>1&&this.transparent.sort(t||vR)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>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 Of,A.format=e.stencilBuffer?hh:uh,A.type=e.stencilBuffer?sh:eh,A.image.width=o,A.image.height=l,A.image.depth=a.depth,A.renderTarget=e,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{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}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.destroyTexture(e),e.isFramebufferTexture){const t=this.renderer.getRenderTarget();e.type=t?t.texture.type:Xu}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,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,i||!0===e.isStorageTexture||!0===e.isExternalTexture)n.createTexture(e,t),r.generation=e.version;else if(e.version>0){const i=e.image;if(void 0===i)wc("Renderer: Texture marked for update but image is undefined.");else if(!1===i.complete)wc("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);const s=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;t.needsMipmaps&&0===e.mipmaps.length&&!s&&n.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else n.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;!0!==r.initialized&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.memory.textures++,e.isVideoTexture&&!0===Xc.enabled&&Xc.getTransfer(e.colorSpace)!==tc&&wc("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=RR){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):"undefined"!=typeof VideoFrame&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(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.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1,i}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyRenderTarget(e){if(!0===this.has(e)){const t=this.get(e),r=t.textures,i=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e=2)for(let r=0;r{if(this._currentNode=t,!t.isVarNode||!t.isIntent(e)||!0===t.isAssign(e))if("setup"===i)t.build(e);else if("analyze"===i)t.build(e,this);else if("generate"===i){const r=e.getDataFromNode(t,"any").stages,i=r&&r[e.shaderStage];if(t.isVarNode&&i&&1===i.length&&i[0]&&i[0].isStackNode)return;t.build(e,"void")}},s=[...this.nodes];for(const e of s)n(e);this._currentNode=null;const a=this.nodes.filter(e=>-1===s.indexOf(e));for(const e of a)n(e);let o;return o=this.hasOutput(e)?this.outputNode.build(e,...t):super.build(e,...t),ny(r),e.removeActiveStack(this),o}}const FR=Kg(IR).setParameterLength(0,1);class qR extends ng{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=1,r=0;for(const i of this.membersLayout){const n=i.type,s=jm(n),a=Wm(n)/e;t=Math.max(t,a);const o=r%t%a;0!==o&&(r+=a-o),r+=s}return Math.ceil(r/t)*t}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.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class LR extends ng{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){const e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){const t=e.getVarFromNode(this),r=t.type,i=e.getPropertyName(t);return e.addLineFlowCode(`${i} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}class OR extends ng{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(){return"OutputType"}generate(e){const t=e.getDataFromNode(this);if(void 0===t.membersLayout){const r=this.members,i=[];for(let t=0;tnew HR(e,"uint","float"),XR={};class YR extends Zb{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){"int"===r?t.assign($R(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return hy;case"int":return uy;case"uvec2":return fy;case"uvec3":return by;case"uvec4":return wy;case"ivec2":return py;case"ivec3":return yy;case"ivec4":return _y}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return iy(([e])=>{const i=hy(0);this._resolveElementType(e,i,t);const n=Ay(i.bitAnd(Nx(i))),s=QR(n).shiftRight(23).sub(127);return r(s)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return iy(([e])=>{ay(e.equal(hy(0)),()=>hy(32));const i=hy(0),n=hy(0);return this._resolveElementType(e,i,t),ay(i.shiftRight(16).equal(0),()=>{n.addAssign(16),i.shiftLeftAssign(16)}),ay(i.shiftRight(24).equal(0),()=>{n.addAssign(8),i.shiftLeftAssign(8)}),ay(i.shiftRight(28).equal(0),()=>{n.addAssign(4),i.shiftLeftAssign(4)}),ay(i.shiftRight(30).equal(0),()=>{n.addAssign(2),i.shiftLeftAssign(2)}),ay(i.shiftRight(31).equal(0),()=>{n.addAssign(1)}),r(n)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return iy(([e])=>{const i=hy(0);this._resolveElementType(e,i,t),i.assign(i.sub(i.shiftRight(hy(1)).bitAnd(hy(1431655765)))),i.assign(i.bitAnd(hy(858993459)).add(i.shiftRight(hy(2)).bitAnd(hy(858993459))));const n=i.add(i.shiftRight(hy(4))).bitAnd(hy(252645135)).mul(hy(16843009)).shiftRight(hy(24));return r(n)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,i){const n=this._returnDataNode(t),s=iy(([e])=>{if(1===r)return n(i(e));{const t=n(0),s=["x","y","z","w"];for(let n=0;nu(r))()}}YR.COUNT_TRAILING_ZEROS="countTrailingZeros",YR.COUNT_LEADING_ZEROS="countLeadingZeros",YR.COUNT_ONE_BITS="countOneBits";const ZR=ey(YR,YR.COUNT_TRAILING_ZEROS).setParameterLength(1),KR=ey(YR,YR.COUNT_LEADING_ZEROS).setParameterLength(1),JR=ey(YR,YR.COUNT_ONE_BITS).setParameterLength(1),eB=iy(([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)}),tB=(e,t)=>Hx(Nb(4,e.mul(Sb(1,e))),t);class rB extends og{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}getNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const iB=ey(rB,"snorm").setParameterLength(1),nB=ey(rB,"unorm").setParameterLength(1),sB=ey(rB,"float16").setParameterLength(1);class aB extends og{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}getNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const oB=ey(aB,"snorm").setParameterLength(1),lB=ey(aB,"unorm").setParameterLength(1),AB=ey(aB,"float16").setParameterLength(1),uB=iy(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),hB=iy(([e])=>gy(uB(e.z.add(uB(e.y.mul(1)))),uB(e.z.add(uB(e.x.mul(1)))),uB(e.y.add(uB(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),cB=iy(([e,t,r])=>{const i=gy(e).toVar(),n=Ay(1.4).toVar(),s=Ay(0).toVar(),a=gy(i).toVar();return gS({start:Ay(0),end:Ay(3),type:"float",condition:"<="},()=>{const e=gy(hB(a.mul(2))).toVar();i.addAssign(e.add(r.mul(Ay(.1).mul(t)))),a.mulAssign(1.8),n.mulAssign(1.5),i.mulAssign(1.2);const o=Ay(uB(i.z.add(uB(i.x.add(uB(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 dB extends ng{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}getNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let r=this._candidateFn;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;rn&&(i=r,n=s)}}this._candidateFn=r=i}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const pB=Kg(dB),fB=e=>(...t)=>pB(e,...t),mB=mb(0).setGroup(db).onRenderUpdate(e=>e.time),gB=mb(0).setGroup(db).onRenderUpdate(e=>e.deltaTime),yB=mb(0,"uint").setGroup(db).onRenderUpdate(e=>e.frameId);const bB=iy(([e,t,r=dy(.5)])=>kC(e.sub(r),t).add(r)),xB=iy(([e,t,r=dy(.5)])=>{const i=e.sub(r),n=i.dot(i),s=n.mul(n).mul(t);return e.add(i.mul(s))}),vB=iy(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let i;null!==e?(i=Ew.toVar(),i[3][0]=e.x,i[3][1]=e.y,i[3][2]=e.z):i=Ew;const n=dw.mul(i);return Wg(t)&&(n[0][0]=Ew[0].length(),n[0][1]=0,n[0][2]=0),Wg(r)&&(n[1][0]=0,n[1][1]=Ew[1].length(),n[1][2]=0),n[2][0]=0,n[2][1]=0,n[2][2]=1,hw.mul(n).mul(Vw)}),_B=iy(([e=null])=>{const t=$S();return $S(LS(e)).sub(t).lessThan(0).select(U_,e)}),wB=iy(([e,t=b_(),r=Ay(0)])=>{const i=e.x,n=e.y,s=r.mod(i.mul(n)).floor(),a=s.mod(i),o=n.sub(s.add(1).div(i).ceil()),l=e.reciprocal(),A=dy(a,o);return t.add(A).mul(l)}),TB=iy(([e,t=null,r=null,i=Ay(1),n=Vw,s=Kw])=>{let a=s.abs().normalize();a=a.div(a.dot(gy(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=E_(u,o).mul(a.x),p=E_(h,l).mul(a.y),f=E_(c,A).mul(a.z);return Mb(d,p,f)}),MB=new Sf,SB=new Vc,NB=new Vc,EB=new Vc,CB=new Ad,RB=new Vc(0,0,-1),BB=new ad,PB=new Vc,DB=new Vc,IB=new ad,FB=new kc,qB=new od,LB=U_.flipX();qB.depthTexture=new Of(1,1);let OB=!1;class kB extends S_{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||qB.texture,LB),this._reflectorBaseNode=e.reflector||new UB(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=new kB({defaultTexture:qB.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.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class UB extends ng{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new qd,resolutionScale:i=1,generateMipmaps:n=!1,bounces:s=!0,depth:a=!1,samples:o=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=i,void 0!==t.resolution&&(Mc('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=n,this.bounces=s,this.depth=a,this.samples=o,this.updateBeforeType=s?Ym.RENDER:Ym.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolutionScale;t.getDrawingBufferSize(FB),e.setSize(Math.round(FB.width*r),Math.round(FB.height*r))}setup(e){return this._updateResolution(qB,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 od(0,0,{type:rh,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=1008,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new Of),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&OB)return!1;OB=!0;const{scene:t,camera:r,renderer:i,material:n}=e,{target:s}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);i.getDrawingBufferSize(FB),this._updateResolution(o,i),NB.setFromMatrixPosition(s.matrixWorld),EB.setFromMatrixPosition(r.matrixWorld),CB.extractRotation(s.matrixWorld),SB.set(0,0,1),SB.applyMatrix4(CB),PB.subVectors(NB,EB);let l=!1;if(!0===PB.dot(SB)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(OB=!1);l=!0}PB.reflect(SB).negate(),PB.add(NB),CB.extractRotation(r.matrixWorld),RB.set(0,0,-1),RB.applyMatrix4(CB),RB.add(EB),DB.subVectors(NB,RB),DB.reflect(SB).negate(),DB.add(NB),a.coordinateSystem=r.coordinateSystem,a.position.copy(PB),a.up.set(0,1,0),a.up.applyMatrix4(CB),a.up.reflect(SB),a.lookAt(DB),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),MB.setFromNormalAndCoplanarPoint(SB,NB),MB.applyMatrix4(a.matrixWorldInverse),BB.set(MB.normal.x,MB.normal.y,MB.normal.z,MB.constant);const A=a.projectionMatrix;IB.x=(Math.sign(BB.x)+A.elements[8])/A.elements[0],IB.y=(Math.sign(BB.y)+A.elements[9])/A.elements[5],IB.z=-1,IB.w=(1+A.elements[10])/A.elements[14],BB.multiplyScalar(1/BB.dot(IB));A.elements[2]=BB.x,A.elements[6]=BB.y,A.elements[10]=i.coordinateSystem===pc?BB.z-0:BB.z+1-0,A.elements[14]=BB.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;const d=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",l?(i.clear(),this.hasOutput=!1):(i.render(t,a),this.hasOutput=!0),t.name=d,i.setMRT(h),i.setRenderTarget(u),i.autoClear=c,n.visible=!0,OB=!1,this.forceUpdate=!1}get resolution(){return Mc('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){Mc('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const VB=new gm(-1,1,1,-1,0,1);class zB extends Wp{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Dp([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Dp(t,2))}}const GB=new zB;class jB extends bf{constructor(e=null){super(GB,e),this.camera=VB,this.isQuadMesh=!0}async renderAsync(e){Mc('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,VB)}render(e){e.render(this,VB)}}const WB=new kc;class HB extends S_{static get type(){return"RTTNode"}constructor(e,t=null,r=null,i={type:rh}){const n=new od(t,r,i);super(n.texture,b_()),this.isRTTNode=!0,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 jB(new lN),this.updateBeforeType=Ym.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(WB),i=Math.floor(r.width*t),n=Math.floor(r.height*t);i===this.renderTarget.width&&n===this.renderTarget.height||(this.renderTarget.setSize(i,n),this.textureNeedsUpdate=!0)}let t="RTT";this.node.name&&(t=this.node.name+" [ "+t+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=t;const r=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(r)}clone(){const e=new S_(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const $B=(e,...t)=>new HB(Qg(e),...t),QB=iy(([e,t,r],i)=>{let n;i.renderer.coordinateSystem===pc?(e=dy(e.x,e.y.oneMinus()).mul(2).sub(1),n=vy(gy(e,t),1)):n=vy(gy(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const s=vy(r.mul(n));return s.xyz.div(s.w)}),XB=iy(([e,t])=>{const r=t.mul(vy(e,1)),i=r.xy.div(r.w).mul(.5).add(.5).toVar();return dy(i.x,i.y.oneMinus())}),YB=iy(([e,t,r])=>{const i=v_(C_(t)),n=py(e.mul(i)).toVar(),s=C_(t,n).toVar(),a=C_(t,n.sub(py(2,0))).toVar(),o=C_(t,n.sub(py(1,0))).toVar(),l=C_(t,n.add(py(1,0))).toVar(),A=C_(t,n.add(py(2,0))).toVar(),u=C_(t,n.add(py(0,2))).toVar(),h=C_(t,n.add(py(0,1))).toVar(),c=C_(t,n.sub(py(0,1))).toVar(),d=C_(t,n.sub(py(0,2))).toVar(),p=Tx(Sb(Ay(2).mul(o).sub(a),s)).toVar(),f=Tx(Sb(Ay(2).mul(l).sub(A),s)).toVar(),m=Tx(Sb(Ay(2).mul(h).sub(u),s)).toVar(),g=Tx(Sb(Ay(2).mul(c).sub(d),s)).toVar(),y=QB(e,s,r).toVar(),b=p.lessThan(f).select(y.sub(QB(e.sub(dy(Ay(1).div(i.x),0)),o,r)),y.negate().add(QB(e.add(dy(Ay(1).div(i.x),0)),l,r))),x=m.lessThan(g).select(y.sub(QB(e.add(dy(0,Ay(1).div(i.y))),h,r)),y.negate().add(QB(e.sub(dy(0,Ay(1).div(i.y))),c,r)));return mx(Wx(b,x))}),ZB=iy(([e])=>gx(Ay(52.9829189).mul(gx(jx(e,dy(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),KB=iy(([e,t,r])=>{const i=Ay(2.399963229728653),n=cx(Ay(e).add(.5).div(Ay(t))),s=Ay(e).mul(i).add(r);return dy(bx(s),yx(s)).mul(n)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class JB extends ng{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(b_())}sample(e){return this.callback(e)}}class eP extends ng{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===eP.OBJECT?this.updateType=Ym.OBJECT:e===eP.MATERIAL?this.updateType=Ym.RENDER:e===eP.BEFORE_OBJECT?this.updateBeforeType=Ym.OBJECT:e===eP.BEFORE_MATERIAL&&(this.updateBeforeType=Ym.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}eP.OBJECT="object",eP.MATERIAL="material",eP.BEFORE_OBJECT="beforeObject",eP.BEFORE_MATERIAL="beforeMaterial";const tP=(e,t)=>new eP(e,t).toStack();class rP extends _f{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class iP extends Cp{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class nP extends ng{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const sP=Jg(nP),aP=new bd,oP=new Ad,lP=mb(0).setGroup(db).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),AP=mb(1).setGroup(db).onRenderUpdate(({scene:e})=>e.backgroundIntensity),uP=mb(new Ad).setGroup(db).onRenderUpdate(({scene:e})=>{const t=e.background;return null!==t&&t.isTexture&&300!==t.mapping?(aP.copy(e.backgroundRotation),aP.x*=-1,aP.y*=-1,aP.z*=-1,oP.makeRotationFromEuler(aP)):oP.identity(),oP});class hP extends S_{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=Zm.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}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}generateSnippet(e,t,r,i,n,s,a,o,l){const A=this.value;return e.generateStorageTextureLoad(A,t,r,i,s,l)}toReadWrite(){return this.setAccess(Zm.READ_WRITE)}toReadOnly(){return this.setAccess(Zm.READ_ONLY)}toWriteOnly(){return this.setAccess(Zm.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,!0===this.value.is3DTexture?"uvec3":"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.mipLevel=this.mipLevel,e.access=this.access,e}}const cP=Kg(hP).setParameterLength(1,3),dP=iy(({texture:e,uv:t})=>{const r=1e-4,i=gy().toVar();return ay(t.x.lessThan(r),()=>{i.assign(gy(1,0,0))}).ElseIf(t.y.lessThan(r),()=>{i.assign(gy(0,1,0))}).ElseIf(t.z.lessThan(r),()=>{i.assign(gy(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{i.assign(gy(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{i.assign(gy(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{i.assign(gy(0,0,-1))}).Else(()=>{const r=.01,n=e.sample(t.add(gy(-.01,0,0))).r.sub(e.sample(t.add(gy(r,0,0))).r),s=e.sample(t.add(gy(0,-.01,0))).r.sub(e.sample(t.add(gy(0,r,0))).r),a=e.sample(t.add(gy(0,0,-.01))).r.sub(e.sample(t.add(gy(0,0,r))).r);i.assign(gy(n,s,a))}),i.normalize()});class pP extends S_{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return gy(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return dP({texture:this,uv:e})}}const fP=Kg(pP).setParameterLength(1,3);class mP extends TT{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 gP=new WeakMap;class yP extends og{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Ym.OBJECT,this.updateAfterType=Ym.OBJECT,this.previousModelWorldMatrix=mb(new Ad),this.previousProjectionMatrix=mb(new Ad).setGroup(db),this.previousCameraViewMatrix=mb(new Ad)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const i=xP(r);this.previousModelWorldMatrix.value.copy(i);const n=bP(t);n.frameId!==e&&(n.frameId=e,void 0===n.previousProjectionMatrix?(n.previousProjectionMatrix=new Ad,n.previousCameraViewMatrix=new Ad,n.currentProjectionMatrix=new Ad,n.currentCameraViewMatrix=new Ad,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}){xP(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?hw:mb(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Fw).mul(Vw),i=this.previousProjectionMatrix.mul(t).mul(zw),n=r.xy.div(r.w),s=i.xy.div(i.w);return Sb(n,s)}}function bP(e){let t=gP.get(e);return void 0===t&&(t={},gP.set(e,t)),t}function xP(e,t=0){const r=bP(e);let i=r[t];return void 0===i&&(r[t]=i=new Ad,r[t].copy(e.matrixWorld)),i}const vP=Jg(yP),_P=iy(([e])=>SP(e.rgb)),wP=iy(([e,t=Ay(1)])=>t.mix(SP(e.rgb),e.rgb)),TP=iy(([e,t=Ay(1)])=>{const r=Mb(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 Jx(e.rgb,i,n)}),MP=iy(([e,t=Ay(1)])=>{const r=gy(.57735,.57735,.57735),i=t.cos();return gy(e.rgb.mul(i).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(jx(r,e.rgb).mul(i.oneMinus())))))}),SP=(e,t=gy(Xc.getLuminanceCoefficients(new Vc)))=>jx(e,t),NP=iy(([e,t=gy(1),r=gy(0),i=gy(1),n=Ay(1),s=gy(Xc.getLuminanceCoefficients(new Vc,Jh))])=>{const a=e.rgb.dot(gy(s)),o=kx(e.rgb.mul(t).add(r),0).toVar(),l=o.pow(i).toVar();return ay(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),ay(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),ay(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(n))),vy(o.rgb,e.a)}),EP=iy(([e,t])=>e.mul(t).floor().div(t));let CP=null;class RP extends RS{static get type(){return"ViewportSharedTextureNode"}constructor(e=U_,t=null){null===CP&&(CP=new qf),super(e,t,CP)}getTextureForReference(){return CP}updateReference(){return this}}const BP=Kg(RP).setParameterLength(0,2),PP=new kc;class DP extends S_{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){return e.getNodeProperties(this).passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class IP extends DP{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}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.offsetNode=this.offsetNode,e}}class FP extends og{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 Of;n.isRenderTargetTexture=!0,n.name="depth";const s=new od(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:rh,...i});s.texture.name="output",s.depthTexture=n,this.renderTarget=s,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:s.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=mb(0),this._cameraFar=mb(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=Ym.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return wc("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return wc("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}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=new IP(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=new IP(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=GS(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=kS(n,r,i)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),this.scope===FP.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),PP.set(s.width,s.height)):(i=this.camera,n=t.getPixelRatio(),t.getSize(PP)),this._pixelRatio=n,this.setSize(PP.width,PP.height);const a=t.getRenderTarget(),o=t.getMRT(),l=t.autoClear,A=t.transparent,u=t.opaque,h=i.layers.mask,c=t.contextNode,d=r.overrideMaterial;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);null!==this.overrideMaterial&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,null!==this.contextNode&&(null!==this._contextNodeCache&&this._contextNodeCache.version===this.version||(this._contextNodeCache={version:this.version,context:pv({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const p=r.name;r.name=this.name?this.name:r.name,t.render(r,i),r.name=p,r.overrideMaterial=d,t.setRenderTarget(a),t.setMRT(o),t.autoClear=l,t.transparent=A,t.opaque=u,t.contextNode=c,i.layers.mask=h}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._pixelRatio*this._resolutionScale),i=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(r,i),null!==this._scissor&&this.renderTarget.scissor.copy(this._scissor),null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,r,i){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new ad),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,r,i){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new ad),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}FP.COLOR="color",FP.DEPTH="depth";class qP extends FP{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,i,n){super(FP.COLOR,e,t),this.colorNode=r,this.thicknessNode=i,this.alphaNode=n,this._materialCache=new WeakMap,this.name="Outline Pass"}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 lN;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=1;const t=Kw.negate(),r=hw.mul(Fw),i=Ay(1),n=r.mul(vy(Vw,1)),s=r.mul(vy(Vw.add(t),1)),a=mx(n.sub(s));return e.vertexNode=n.add(a.mul(this.thicknessNode).mul(n.w).mul(i)),e.colorNode=vy(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 LP=iy(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),OP=iy(([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"}]}),kP=iy(([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"}]}),UP=iy(([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)}),VP=iy(([e,t])=>{const r=Sy(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=Sy(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=UP(e),(e=i.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),zP=Sy(gy(1.6605,-.1246,-.0182),gy(-.5876,1.1329,-.1006),gy(-.0728,-.0083,1.1187)),GP=Sy(gy(.6274,.0691,.0164),gy(.3293,.9195,.088),gy(.0433,.0113,.8956)),jP=iy(([e])=>{const t=gy(e).toVar(),r=gy(t.mul(t)).toVar(),i=gy(r.mul(r)).toVar();return Ay(15.5).mul(i.mul(r)).sub(Nb(40.14,i.mul(t))).add(Nb(31.96,i).sub(Nb(6.868,r.mul(t))).add(Nb(.4298,r).add(Nb(.1191,t).sub(.00232))))}),WP=iy(([e,t])=>{const r=gy(e).toVar(),i=Sy(gy(.856627153315983,.137318972929847,.11189821299995),gy(.0951212405381588,.761241990602591,.0767994186031903),gy(.0482516061458583,.101439036467562,.811302368396859)),n=Sy(gy(1.1271005818144368,-.1413297634984383,-.14132976349843826),gy(-.11060664309660323,1.157823702216272,-.11060664309660294),gy(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=Ay(-12.47393),a=Ay(4.026069);return r.mulAssign(t),r.assign(GP.mul(r)),r.assign(i.mul(r)),r.assign(kx(r,1e-10)),r.assign(hx(r)),r.assign(r.sub(s).div(a.sub(s))),r.assign(ev(r,0,1)),r.assign(jP(r)),r.assign(n.mul(r)),r.assign(Hx(kx(gy(0),r),gy(2.2))),r.assign(zP.mul(r)),r.assign(ev(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),HP=iy(([e,t])=>{const r=Ay(.76),i=Ay(.15);e=e.mul(t);const n=Ox(e.r,Ox(e.g,e.b)),s=cv(n.lessThan(.08),n.sub(Nb(6.25,n.mul(n))),.04);e.subAssign(s);const a=kx(e.r,kx(e.g,e.b));ay(a.lessThan(r),()=>e);const o=Sb(1,r),l=Sb(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(l.div(a));const A=Sb(1,Eb(1,i.mul(a.sub(l)).add(1)));return Jx(e,gy(l),A)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class $P extends ng{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 QP=Kg($P).setParameterLength(1,3);class XP extends $P{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}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 YP=(e,t=[],r="")=>{for(let e=0;ei.call(...e);return n.functionNode=i,n};function ZP(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Ww.z).negate()}const KP=iy(([e,t],r)=>{const i=ZP(r);return iv(e,t,i)}),JP=iy(([e],t)=>{const r=ZP(t);return e.mul(e,r,r).negate().exp().oneMinus()}),eD=iy(([e,t],r)=>{const i=ZP(r),n=t.sub(Gw.y).max(0).toConst().mul(i).toConst();return e.mul(e,n,n).negate().exp().oneMinus()}),tD=iy(([e,t])=>vy(t.toFloat().mix(Jy.rgb,e.toVec3()),Jy.a));let rD=null,iD=null;class nD extends ng{static get type(){return"RangeNode"}constructor(e=Ay(),t=Ay()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),i=e.getTypeLength(Hm(t.value)),n=e.getTypeLength(Hm(r.value));return i>n?i:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(e=>{!0===e.isConstNode&&(t=e)}),null===t)throw new T_('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),s=i.value,a=n.value,o=e.getTypeLength(Hm(s)),l=e.getTypeLength(Hm(a));rD=rD||new ad,iD=iD||new ad,rD.setScalar(0),iD.setScalar(0),1===o?rD.setScalar(s):s.isColor?rD.set(s.r,s.g,s.b,1):rD.set(s.x,s.y,s.z||0,s.w||0),1===l?iD.setScalar(a):a.isColor?iD.set(a.r,a.g,a.b,1):iD.set(a.x,a.y,a.z||0,a.w||0);const A=4,u=A*t.count,h=new Float32Array(u);for(let e=0;enew aD(e,t),lD=oD("numWorkgroups","uvec3"),AD=oD("workgroupId","uvec3"),uD=oD("globalId","uvec3"),hD=oD("localId","uvec3"),cD=oD("subgroupSize","uint");const dD=Kg(class extends ng{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 pD extends sg{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 fD extends ng{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return wc('TSL: "label()" has been deprecated. Use "setName()" instead.',new Im),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new pD(this,e)}generate(e){const t=""!==this.name?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class mD extends ng{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(!(!!r&&(1===r.length&&!0===r[0].isStackNode)))return void 0===t.constNode&&(t.constNode=l_(A,n).toConst()),t.constNode.build(e);e.addLineFlowCode(A,this)}}mD.ATOMIC_LOAD="atomicLoad",mD.ATOMIC_STORE="atomicStore",mD.ATOMIC_ADD="atomicAdd",mD.ATOMIC_SUB="atomicSub",mD.ATOMIC_MAX="atomicMax",mD.ATOMIC_MIN="atomicMin",mD.ATOMIC_AND="atomicAnd",mD.ATOMIC_OR="atomicOr",mD.ATOMIC_XOR="atomicXor";const gD=Kg(mD),yD=(e,t,r)=>gD(e,t,r).toStack();class bD extends og{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}getNodeType(e){const t=this.method;return t===bD.SUBGROUP_ELECT?"bool":t===bD.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,i=this.getNodeType(e),n=this.getInputType(e),s=this.aNode,a=this.bNode,o=[];if(r===bD.SUBGROUP_BROADCAST||r===bD.SUBGROUP_SHUFFLE||r===bD.QUAD_BROADCAST){const t=a.getNodeType(e);o.push(s.build(e,i),a.build(e,"float"===t?"int":i))}else r===bD.SUBGROUP_SHUFFLE_XOR||r===bD.SUBGROUP_SHUFFLE_DOWN||r===bD.SUBGROUP_SHUFFLE_UP?o.push(s.build(e,i),a.build(e,"uint")):(null!==s&&o.push(s.build(e,n)),null!==a&&o.push(a.build(e,n)));const l=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(r,i)}${l}`,i,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}bD.SUBGROUP_ELECT="subgroupElect",bD.SUBGROUP_BALLOT="subgroupBallot",bD.SUBGROUP_ADD="subgroupAdd",bD.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",bD.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",bD.SUBGROUP_MUL="subgroupMul",bD.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",bD.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",bD.SUBGROUP_AND="subgroupAnd",bD.SUBGROUP_OR="subgroupOr",bD.SUBGROUP_XOR="subgroupXor",bD.SUBGROUP_MIN="subgroupMin",bD.SUBGROUP_MAX="subgroupMax",bD.SUBGROUP_ALL="subgroupAll",bD.SUBGROUP_ANY="subgroupAny",bD.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",bD.QUAD_SWAP_X="quadSwapX",bD.QUAD_SWAP_Y="quadSwapY",bD.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",bD.SUBGROUP_BROADCAST="subgroupBroadcast",bD.SUBGROUP_SHUFFLE="subgroupShuffle",bD.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",bD.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",bD.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",bD.QUAD_BROADCAST="quadBroadcast";const xD=ey(bD,bD.SUBGROUP_ELECT).setParameterLength(0),vD=ey(bD,bD.SUBGROUP_BALLOT).setParameterLength(1),_D=ey(bD,bD.SUBGROUP_ADD).setParameterLength(1),wD=ey(bD,bD.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),TD=ey(bD,bD.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),MD=ey(bD,bD.SUBGROUP_MUL).setParameterLength(1),SD=ey(bD,bD.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),ND=ey(bD,bD.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),ED=ey(bD,bD.SUBGROUP_AND).setParameterLength(1),CD=ey(bD,bD.SUBGROUP_OR).setParameterLength(1),RD=ey(bD,bD.SUBGROUP_XOR).setParameterLength(1),BD=ey(bD,bD.SUBGROUP_MIN).setParameterLength(1),PD=ey(bD,bD.SUBGROUP_MAX).setParameterLength(1),DD=ey(bD,bD.SUBGROUP_ALL).setParameterLength(0),ID=ey(bD,bD.SUBGROUP_ANY).setParameterLength(0),FD=ey(bD,bD.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),qD=ey(bD,bD.QUAD_SWAP_X).setParameterLength(1),LD=ey(bD,bD.QUAD_SWAP_Y).setParameterLength(1),OD=ey(bD,bD.QUAD_SWAP_DIAGONAL).setParameterLength(1),kD=ey(bD,bD.SUBGROUP_BROADCAST).setParameterLength(2),UD=ey(bD,bD.SUBGROUP_SHUFFLE).setParameterLength(2),VD=ey(bD,bD.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),zD=ey(bD,bD.SUBGROUP_SHUFFLE_UP).setParameterLength(2),GD=ey(bD,bD.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),jD=ey(bD,bD.QUAD_BROADCAST).setParameterLength(1);let WD;function HD(e){WD=WD||new WeakMap;let t=WD.get(e);return void 0===t&&WD.set(e,t={}),t}function $D(e){const t=HD(e);return t.shadowMatrix||(t.shadowMatrix=mb("mat4").setGroup(db).onRenderUpdate(t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function QD(e,t=Gw){const r=$D(e).mul(t);return r.xyz.div(r.w)}function XD(e){const t=HD(e);return t.position||(t.position=mb(new Vc).setGroup(db).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function YD(e){const t=HD(e);return t.targetPosition||(t.targetPosition=mb(new Vc).setGroup(db).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function ZD(e){const t=HD(e);return t.viewPosition||(t.viewPosition=mb(new Vc).setGroup(db).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new Vc,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}const KD=e=>dw.transformDirection(XD(e).sub(YD(e))),JD=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},eI=new WeakMap,tI=[];class rI extends ng{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=By("vec3","totalDiffuse"),this.totalSpecularNode=By("vec3","totalSpecular"),this.outgoingLightNode=By("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort((e,t)=>e.id-t.id))(this._lights),n=e.renderer.library;for(const e of i)if(e.isNode)t.push(Qg(e));else{let i=null;if(null!==r&&(i=JD(e.id,r)),null===i){const r=n.getLightNodeClass(e.constructor);if(null===r){wc(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let i=null;eI.has(e)?i=eI.get(e):(i=new r(e),eI.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=gy(null!==A?A.mix(p,l):l)),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 iI extends ng{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Ym.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){nI.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Gw)}}const nI=By("vec3","shadowPositionWorld");function sI(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 jd),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 aI=new WeakMap,oI=iy(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=E_(e,t.xy).setName("t_basic");return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)}),lI=iy(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{const n=(t,r)=>{let n=E_(e,t);return e.isArrayTexture&&(n=n.depth(i)),n.compare(r)},s=MT("mapSize","vec2",r).setGroup(db),a=MT("radius","float",r).setGroup(db),o=dy(1).div(s),l=a.mul(o.x),A=ZB(z_.xy).mul(6.28318530718);return Mb(n(t.xy.add(KB(0,5,A).mul(l)),t.z),n(t.xy.add(KB(1,5,A).mul(l)),t.z),n(t.xy.add(KB(2,5,A).mul(l)),t.z),n(t.xy.add(KB(3,5,A).mul(l)),t.z),n(t.xy.add(KB(4,5,A).mul(l)),t.z)).mul(.2)}),AI=iy(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{const n=(t,r)=>{let n=E_(e,t);return e.isArrayTexture&&(n=n.depth(i)),n.compare(r)},s=MT("mapSize","vec2",r).setGroup(db),a=dy(1).div(s),o=a.x,l=a.y,A=t.xy,u=gx(A.mul(s).add(.5));return A.subAssign(u.mul(a)),Mb(n(A,t.z),n(A.add(dy(o,0)),t.z),n(A.add(dy(0,l)),t.z),n(A.add(a),t.z),Jx(n(A.add(dy(o.negate(),0)),t.z),n(A.add(dy(o.mul(2),0)),t.z),u.x),Jx(n(A.add(dy(o.negate(),l)),t.z),n(A.add(dy(o.mul(2),l)),t.z),u.x),Jx(n(A.add(dy(0,l.negate())),t.z),n(A.add(dy(0,l.mul(2))),t.z),u.y),Jx(n(A.add(dy(o,l.negate())),t.z),n(A.add(dy(o,l.mul(2))),t.z),u.y),Jx(Jx(n(A.add(dy(o.negate(),l.negate())),t.z),n(A.add(dy(o.mul(2),l.negate())),t.z),u.x),Jx(n(A.add(dy(o.negate(),l.mul(2))),t.z),n(A.add(dy(o.mul(2),l.mul(2))),t.z),u.x),u.y)).mul(1/9)}),uI=iy(({depthTexture:e,shadowCoord:t,depthLayer:r},i)=>{let n=E_(e).sample(t.xy);e.isArrayTexture&&(n=n.depth(r)),n=n.rg;const s=n.x,a=kx(1e-7,n.y.mul(n.y)),o=i.renderer.reversedDepthBuffer?Ux(s,t.z):Ux(t.z,s),l=Ay(1).toVar();return ay(o.notEqual(1),()=>{const e=t.z.sub(s);let r=a.div(a.add(e.mul(e)));r=ev(Sb(r,.3).div(.65)),l.assign(kx(o,r))}),l}),hI=e=>{let t=aI.get(e);return void 0===t&&(t=new lN,t.colorNode=vy(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=0,t.fog=!1,aI.set(e,t)),t},cI=e=>{const t=aI.get(e);void 0!==t&&(t.dispose(),aI.delete(e))},dI=new YC,pI=[],fI=(e,t,r,i)=>{pI[0]=e,pI[1]=t;let n=dI.get(pI);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&&(Qm(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,dI.set(pI,n)),pI[0]=null,pI[1]=null,n},mI=iy(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:n})=>{const s=Ay(0).toVar("meanVertical"),a=Ay(0).toVar("squareMeanVertical"),o=e.lessThanEqual(Ay(1)).select(Ay(0),Ay(2).div(e.sub(1))),l=e.lessThanEqual(Ay(1)).select(Ay(0),Ay(-1));gS({start:uy(0),end:uy(e),type:"int",condition:"<"},({i:e})=>{const A=l.add(Ay(e).mul(o));let u=i.sample(Mb(z_.xy,dy(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=cx(a.sub(s.mul(s)).max(0));return dy(s,A)}),gI=iy(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:n})=>{const s=Ay(0).toVar("meanHorizontal"),a=Ay(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(Ay(1)).select(Ay(0),Ay(2).div(e.sub(1))),l=e.lessThanEqual(Ay(1)).select(Ay(0),Ay(-1));gS({start:uy(0),end:uy(e),type:"int",condition:"<"},({i:e})=>{const A=l.add(Ay(e).mul(o));let u=i.sample(Mb(z_.xy,dy(A,0).mul(t)).div(r));i.value.isArrayTexture&&(u=u.depth(n)),s.addAssign(u.x),a.addAssign(Mb(u.y.mul(u.y),u.x.mul(u.x)))}),s.divAssign(e),a.divAssign(e);const A=cx(a.sub(s.mul(s)).max(0));return dy(s,A)}),yI=[oI,lI,AI,uI];let bI;const xI=new jB;class vI extends iI{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._currentShadowType=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,Ay(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:i}=e,n=r.biasNode||MT("bias","float",r).setGroup(db);let s,a=t;if(r.camera.isOrthographicCamera||!0!==i.logarithmicDepthBuffer)a=a.xyz.div(a.w),s=a.z;else{const e=a.w;a=a.xy.div(e);const t=MT("near","float",r.camera).setGroup(db),i=MT("far","float",r.camera).setGroup(db);s=jS(e.negate(),t,i)}return a=gy(a.x,a.y.oneMinus(),i.reversedDepthBuffer?s.sub(n):s.add(n)),a}getShadowFilterFn(e){return yI[e]}setupRenderTarget(e,t){const r=new Of(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?Ac:ac;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,camera:r}=e,{light:i,shadow:n}=this,{depthTexture:s,shadowMap:a}=this.setupRenderTarget(n,e),o=t.shadowMap.type,l=t.hasCompatibility(gc);if(1!==o&&2!==o||!l?(s.minFilter=Gu,s.magFilter=Gu):(s.minFilter=Hu,s.magFilter=Hu),n.camera.coordinateSystem=r.coordinateSystem,n.camera.updateProjectionMatrix(),3===o&&!0!==n.isPointLightShadow){s.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:ph,type:rh,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:ph,type:rh,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:ph,type:rh,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:ph,type:rh,depthBuffer:!1}));let t=E_(s);s.isArrayTexture&&(t=t.depth(this.depthLayer));let r=E_(this.vsmShadowMapVertical.texture);s.isArrayTexture&&(r=r.depth(this.depthLayer));const i=MT("blurSamples","float",n).setGroup(db),o=MT("radius","float",n).setGroup(db),l=MT("mapSize","vec2",n).setGroup(db);let A=this.vsmMaterialVertical||(this.vsmMaterialVertical=new lN);A.fragmentNode=mI({samples:i,radius:o,size:l,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),A.name="VSMVertical",A=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new lN),A.fragmentNode=gI({samples:i,radius:o,size:l,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),A.name="VSMHorizontal"}const A=MT("intensity","float",n).setGroup(db),u=MT("normalBias","float",n).setGroup(db),h=$D(i).mul(nI.add(iT.mul(u))),c=this.setupShadowCoord(e,h),d=n.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===d)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const p=3===o&&!0!==n.isPointLightShadow?this.vsmShadowMapHorizontal.texture:s,f=this.setupShadowFilter(e,{filterFn:d,shadowTexture:a.texture,depthTexture:p,shadowCoord:c,shadow:n,depthLayer:this.depthLayer});let m,g;!0===t.shadowMap.transmitted&&(a.texture.isCubeTexture?m=_T(a.texture,c.xyz):(m=E_(a.texture,c),s.isArrayTexture&&(m=m.depth(this.depthLayer)))),g=m?Jx(1,f.rgb.mix(m,1),A.mul(m.a)).toVar():Jx(1,f,A).toVar(),this.shadowMap=a,this.shadow.map=a;const y=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return m&&g.toInspector(`${y} / Color`,()=>this.shadowMap.texture.isCubeTexture?_T(this.shadowMap.texture):E_(this.shadowMap.texture)),g.toInspector(`${y} / Depth`,()=>this.shadowMap.texture.isCubeTexture?_T(this.shadowMap.texture).r.oneMinus():C_(this.shadowMap.depthTexture,b_().mul(v_(E_(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(!1!==e.renderer.shadowMap.enabled)return iy(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),null===r&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}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);const a=s.name;s.name=`Shadow Map [ ${i.name||"ID: "+i.id} ]`,n.render(s,t.camera),s.name=a}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");bI=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=sI(e,r)),r}(n,s,bI),s.overrideMaterial=hI(r),n.setRenderObjectFunction(fI(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,bI)}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),xI.material=this.vsmMaterialVertical,xI.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),xI.material=this.vsmMaterialHorizontal,xI.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,cI(this.light),this.shadowMap&&(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)}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 _I=(e,t)=>new vI(e,t),wI=new jd,TI=new Ad,MI=new Vc,SI=new Vc,NI=[new Vc(1,0,0),new Vc(-1,0,0),new Vc(0,-1,0),new Vc(0,1,0),new Vc(0,0,1),new Vc(0,0,-1)],EI=[new Vc(0,-1,0),new Vc(0,-1,0),new Vc(0,0,-1),new Vc(0,0,1),new Vc(0,-1,0),new Vc(0,-1,0)],CI=[new Vc(1,0,0),new Vc(-1,0,0),new Vc(0,1,0),new Vc(0,-1,0),new Vc(0,0,1),new Vc(0,0,-1)],RI=[new Vc(0,-1,0),new Vc(0,-1,0),new Vc(0,0,1),new Vc(0,0,-1),new Vc(0,-1,0),new Vc(0,-1,0)],BI=iy(({depthTexture:e,bd3D:t,dp:r})=>_T(e,t).compare(r)),PI=iy(({depthTexture:e,bd3D:t,dp:r,shadow:i})=>{const n=MT("radius","float",i).setGroup(db),s=MT("mapSize","vec2",i).setGroup(db),a=n.div(s.x),o=Tx(t),l=mx(Wx(t,o.x.greaterThan(o.z).select(gy(0,1,0),gy(1,0,0)))),A=Wx(t,l),u=ZB(z_.xy).mul(6.28318530718),h=KB(0,5,u),c=KB(1,5,u),d=KB(2,5,u),p=KB(3,5,u),f=KB(4,5,u);return _T(e,t.add(l.mul(h.x).add(A.mul(h.y)).mul(a))).compare(r).add(_T(e,t.add(l.mul(c.x).add(A.mul(c.y)).mul(a))).compare(r)).add(_T(e,t.add(l.mul(d.x).add(A.mul(d.y)).mul(a))).compare(r)).add(_T(e,t.add(l.mul(p.x).add(A.mul(p.y)).mul(a))).compare(r)).add(_T(e,t.add(l.mul(f.x).add(A.mul(f.y)).mul(a))).compare(r)).mul(.2)}),DI=iy(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:i},n)=>{const s=r.xyz.toConst(),a=s.abs().toConst(),o=a.x.max(a.y).max(a.z),l=mb("float").setGroup(db).onRenderUpdate(()=>i.camera.near),A=mb("float").setGroup(db).onRenderUpdate(()=>i.camera.far),u=MT("bias","float",i).setGroup(db),h=Ay(1).toVar();return ay(o.sub(A).lessThanEqual(0).and(o.sub(l).greaterThanEqual(0)),()=>{let r;n.renderer.reversedDepthBuffer?(r=zS(o.negate(),l,A),r.subAssign(u)):(r=VS(o.negate(),l,A),r.addAssign(u));const a=s.normalize();h.assign(e({depthTexture:t,bd3D:a,dp:r,shadow:i}))}),h});class II extends vI{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return 0===e?BI:PI}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:i,shadow:n}){return DI({filterFn:t,depthTexture:r,shadowCoord:i,shadow:n})}setupRenderTarget(e,t){const r=new kf(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?Ac:ac;const i=t.createCubeRenderTarget(e.mapSize.width);return i.texture.name="PointShadowMap",i.depthTexture=r,{shadowMap:i,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:i}=this,{renderer:n,scene:s}=e,a=t.camera,o=t.matrix,l=n.coordinateSystem===pc,A=l?NI:CI,u=l?EI:RI;r.setSize(t.mapSize.width,t.mapSize.width);const h=n.autoClear,c=n.getClearColor(wI),d=n.getClearAlpha();n.autoClear=!1,n.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){n.setRenderTarget(r,e),n.clear();const l=i.distance||a.far;l!==a.far&&(a.far=l,a.updateProjectionMatrix()),MI.setFromMatrixPosition(i.matrixWorld),a.position.copy(MI),SI.copy(a.position),SI.add(A[e]),a.up.copy(u[e]),a.lookAt(SI),a.updateMatrixWorld(),o.makeTranslation(-MI.x,-MI.y,-MI.z),TI.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(TI,a.coordinateSystem,a.reversedDepth);const h=s.name;s.name=`Point Light Shadow [ ${i.name||"ID: "+i.id} ] - Face ${e+1}`,n.render(s,a),s.name=h}n.autoClear=h,n.setClearColor(c,d)}}const FI=(e,t)=>new II(e,t);class qI extends TS{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new jd,this.colorNode=e&&e.colorNode||mb(this.color).setGroup(db),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Ym.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return ZD(this.light).sub(e.context.positionView||Ww)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return _I(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?Qg(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),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 LI=iy(({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)}),OI=({color:e,lightVector:t,cutoffDistance:r,decayExponent:i})=>{const n=t.normalize(),s=t.length(),a=LI({lightDistance:s,cutoffDistance:r,decayExponent:i});return{lightDirection:n,lightColor:e.mul(a)}};class kI extends qI{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=mb(0).setGroup(db),this.decayExponentNode=mb(2).setGroup(db)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return FI(this.light)}setupDirect(e){return OI({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const UI=iy(([e=b_()])=>{const t=e.mul(2),r=t.x.floor(),i=t.y.floor();return r.add(i).mod(2).sign()}),VI=iy(([e=b_()],{renderer:t,material:r})=>{const i=Kx(e.mul(2).sub(1));let n;if(r.alphaToCoverage&&t.currentSamples>0){const e=Ay(i.fwidth()).toVar();n=iv(e.oneMinus(),e.add(1),i).oneMinus()}else n=cv(i.greaterThan(1),0,1);return n}),zI=iy(([e,t,r])=>{const i=Ay(r).toVar(),n=Ay(t).toVar(),s=cy(e).toVar();return cv(s,n,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),GI=iy(([e,t])=>{const r=cy(t).toVar(),i=Ay(e).toVar();return cv(r,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),jI=iy(([e])=>{const t=Ay(e).toVar();return uy(px(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),WI=iy(([e,t])=>{const r=Ay(e).toVar();return t.assign(jI(r)),r.sub(Ay(t))}),HI=fB([iy(([e,t,r,i,n,s])=>{const a=Ay(s).toVar(),o=Ay(n).toVar(),l=Ay(i).toVar(),A=Ay(r).toVar(),u=Ay(t).toVar(),h=Ay(e).toVar(),c=Ay(Sb(1,o)).toVar();return Sb(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"}]}),iy(([e,t,r,i,n,s])=>{const a=Ay(s).toVar(),o=Ay(n).toVar(),l=gy(i).toVar(),A=gy(r).toVar(),u=gy(t).toVar(),h=gy(e).toVar(),c=Ay(Sb(1,o)).toVar();return Sb(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"}]})]),$I=fB([iy(([e,t,r,i,n,s,a,o,l,A,u])=>{const h=Ay(u).toVar(),c=Ay(A).toVar(),d=Ay(l).toVar(),p=Ay(o).toVar(),f=Ay(a).toVar(),m=Ay(s).toVar(),g=Ay(n).toVar(),y=Ay(i).toVar(),b=Ay(r).toVar(),x=Ay(t).toVar(),v=Ay(e).toVar(),_=Ay(Sb(1,d)).toVar(),w=Ay(Sb(1,c)).toVar();return Ay(Sb(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"}]}),iy(([e,t,r,i,n,s,a,o,l,A,u])=>{const h=Ay(u).toVar(),c=Ay(A).toVar(),d=Ay(l).toVar(),p=gy(o).toVar(),f=gy(a).toVar(),m=gy(s).toVar(),g=gy(n).toVar(),y=gy(i).toVar(),b=gy(r).toVar(),x=gy(t).toVar(),v=gy(e).toVar(),_=Ay(Sb(1,d)).toVar(),w=Ay(Sb(1,c)).toVar();return Ay(Sb(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"}]})]),QI=iy(([e,t,r])=>{const i=Ay(r).toVar(),n=Ay(t).toVar(),s=hy(e).toVar(),a=hy(s.bitAnd(hy(7))).toVar(),o=Ay(zI(a.lessThan(hy(4)),n,i)).toVar(),l=Ay(Nb(2,zI(a.lessThan(hy(4)),i,n))).toVar();return GI(o,cy(a.bitAnd(hy(1)))).add(GI(l,cy(a.bitAnd(hy(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),XI=iy(([e,t,r,i])=>{const n=Ay(i).toVar(),s=Ay(r).toVar(),a=Ay(t).toVar(),o=hy(e).toVar(),l=hy(o.bitAnd(hy(15))).toVar(),A=Ay(zI(l.lessThan(hy(8)),a,s)).toVar(),u=Ay(zI(l.lessThan(hy(4)),s,zI(l.equal(hy(12)).or(l.equal(hy(14))),a,n))).toVar();return GI(A,cy(l.bitAnd(hy(1)))).add(GI(u,cy(l.bitAnd(hy(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"}]}),YI=fB([QI,XI]),ZI=iy(([e,t,r])=>{const i=Ay(r).toVar(),n=Ay(t).toVar(),s=by(e).toVar();return gy(YI(s.x,n,i),YI(s.y,n,i),YI(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"}]}),KI=iy(([e,t,r,i])=>{const n=Ay(i).toVar(),s=Ay(r).toVar(),a=Ay(t).toVar(),o=by(e).toVar();return gy(YI(o.x,a,s,n),YI(o.y,a,s,n),YI(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"}]}),JI=fB([ZI,KI]),eF=iy(([e])=>{const t=Ay(e).toVar();return Nb(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),tF=iy(([e])=>{const t=Ay(e).toVar();return Nb(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),rF=fB([eF,iy(([e])=>{const t=gy(e).toVar();return Nb(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),iF=fB([tF,iy(([e])=>{const t=gy(e).toVar();return Nb(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),nF=iy(([e,t])=>{const r=uy(t).toVar(),i=hy(e).toVar();return i.shiftLeft(r).bitOr(i.shiftRight(uy(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),sF=iy(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(nF(r,uy(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(nF(e,uy(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(nF(t,uy(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(nF(r,uy(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(nF(e,uy(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(nF(t,uy(4))),t.addAssign(e)}),aF=iy(([e,t,r])=>{const i=hy(r).toVar(),n=hy(t).toVar(),s=hy(e).toVar();return i.bitXorAssign(n),i.subAssign(nF(n,uy(14))),s.bitXorAssign(i),s.subAssign(nF(i,uy(11))),n.bitXorAssign(s),n.subAssign(nF(s,uy(25))),i.bitXorAssign(n),i.subAssign(nF(n,uy(16))),s.bitXorAssign(i),s.subAssign(nF(i,uy(4))),n.bitXorAssign(s),n.subAssign(nF(s,uy(14))),i.bitXorAssign(n),i.subAssign(nF(n,uy(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),oF=iy(([e])=>{const t=hy(e).toVar();return Ay(t).div(Ay(hy(uy(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),lF=iy(([e])=>{const t=Ay(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"}]}),AF=fB([iy(([e])=>{const t=uy(e).toVar(),r=hy(hy(1)).toVar(),i=hy(hy(uy(3735928559)).add(r.shiftLeft(hy(2))).add(hy(13))).toVar();return aF(i.add(hy(t)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),iy(([e,t])=>{const r=uy(t).toVar(),i=uy(e).toVar(),n=hy(hy(2)).toVar(),s=hy().toVar(),a=hy().toVar(),o=hy().toVar();return s.assign(a.assign(o.assign(hy(uy(3735928559)).add(n.shiftLeft(hy(2))).add(hy(13))))),s.addAssign(hy(i)),a.addAssign(hy(r)),aF(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),iy(([e,t,r])=>{const i=uy(r).toVar(),n=uy(t).toVar(),s=uy(e).toVar(),a=hy(hy(3)).toVar(),o=hy().toVar(),l=hy().toVar(),A=hy().toVar();return o.assign(l.assign(A.assign(hy(uy(3735928559)).add(a.shiftLeft(hy(2))).add(hy(13))))),o.addAssign(hy(s)),l.addAssign(hy(n)),A.addAssign(hy(i)),aF(o,l,A)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),iy(([e,t,r,i])=>{const n=uy(i).toVar(),s=uy(r).toVar(),a=uy(t).toVar(),o=uy(e).toVar(),l=hy(hy(4)).toVar(),A=hy().toVar(),u=hy().toVar(),h=hy().toVar();return A.assign(u.assign(h.assign(hy(uy(3735928559)).add(l.shiftLeft(hy(2))).add(hy(13))))),A.addAssign(hy(o)),u.addAssign(hy(a)),h.addAssign(hy(s)),sF(A,u,h),A.addAssign(hy(n)),aF(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"}]}),iy(([e,t,r,i,n])=>{const s=uy(n).toVar(),a=uy(i).toVar(),o=uy(r).toVar(),l=uy(t).toVar(),A=uy(e).toVar(),u=hy(hy(5)).toVar(),h=hy().toVar(),c=hy().toVar(),d=hy().toVar();return h.assign(c.assign(d.assign(hy(uy(3735928559)).add(u.shiftLeft(hy(2))).add(hy(13))))),h.addAssign(hy(A)),c.addAssign(hy(l)),d.addAssign(hy(o)),sF(h,c,d),h.addAssign(hy(a)),c.addAssign(hy(s)),aF(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"}]})]),uF=fB([iy(([e,t])=>{const r=uy(t).toVar(),i=uy(e).toVar(),n=hy(AF(i,r)).toVar(),s=by().toVar();return s.x.assign(n.bitAnd(uy(255))),s.y.assign(n.shiftRight(uy(8)).bitAnd(uy(255))),s.z.assign(n.shiftRight(uy(16)).bitAnd(uy(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),iy(([e,t,r])=>{const i=uy(r).toVar(),n=uy(t).toVar(),s=uy(e).toVar(),a=hy(AF(s,n,i)).toVar(),o=by().toVar();return o.x.assign(a.bitAnd(uy(255))),o.y.assign(a.shiftRight(uy(8)).bitAnd(uy(255))),o.z.assign(a.shiftRight(uy(16)).bitAnd(uy(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),hF=iy(([e])=>{const t=dy(e).toVar(),r=uy().toVar(),i=uy().toVar(),n=Ay(WI(t.x,r)).toVar(),s=Ay(WI(t.y,i)).toVar(),a=Ay(lF(n)).toVar(),o=Ay(lF(s)).toVar(),l=Ay(HI(YI(AF(r,i),n,s),YI(AF(r.add(uy(1)),i),n.sub(1),s),YI(AF(r,i.add(uy(1))),n,s.sub(1)),YI(AF(r.add(uy(1)),i.add(uy(1))),n.sub(1),s.sub(1)),a,o)).toVar();return rF(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),cF=iy(([e])=>{const t=gy(e).toVar(),r=uy().toVar(),i=uy().toVar(),n=uy().toVar(),s=Ay(WI(t.x,r)).toVar(),a=Ay(WI(t.y,i)).toVar(),o=Ay(WI(t.z,n)).toVar(),l=Ay(lF(s)).toVar(),A=Ay(lF(a)).toVar(),u=Ay(lF(o)).toVar(),h=Ay($I(YI(AF(r,i,n),s,a,o),YI(AF(r.add(uy(1)),i,n),s.sub(1),a,o),YI(AF(r,i.add(uy(1)),n),s,a.sub(1),o),YI(AF(r.add(uy(1)),i.add(uy(1)),n),s.sub(1),a.sub(1),o),YI(AF(r,i,n.add(uy(1))),s,a,o.sub(1)),YI(AF(r.add(uy(1)),i,n.add(uy(1))),s.sub(1),a,o.sub(1)),YI(AF(r,i.add(uy(1)),n.add(uy(1))),s,a.sub(1),o.sub(1)),YI(AF(r.add(uy(1)),i.add(uy(1)),n.add(uy(1))),s.sub(1),a.sub(1),o.sub(1)),l,A,u)).toVar();return iF(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),dF=fB([hF,cF]),pF=iy(([e])=>{const t=dy(e).toVar(),r=uy().toVar(),i=uy().toVar(),n=Ay(WI(t.x,r)).toVar(),s=Ay(WI(t.y,i)).toVar(),a=Ay(lF(n)).toVar(),o=Ay(lF(s)).toVar(),l=gy(HI(JI(uF(r,i),n,s),JI(uF(r.add(uy(1)),i),n.sub(1),s),JI(uF(r,i.add(uy(1))),n,s.sub(1)),JI(uF(r.add(uy(1)),i.add(uy(1))),n.sub(1),s.sub(1)),a,o)).toVar();return rF(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),fF=iy(([e])=>{const t=gy(e).toVar(),r=uy().toVar(),i=uy().toVar(),n=uy().toVar(),s=Ay(WI(t.x,r)).toVar(),a=Ay(WI(t.y,i)).toVar(),o=Ay(WI(t.z,n)).toVar(),l=Ay(lF(s)).toVar(),A=Ay(lF(a)).toVar(),u=Ay(lF(o)).toVar(),h=gy($I(JI(uF(r,i,n),s,a,o),JI(uF(r.add(uy(1)),i,n),s.sub(1),a,o),JI(uF(r,i.add(uy(1)),n),s,a.sub(1),o),JI(uF(r.add(uy(1)),i.add(uy(1)),n),s.sub(1),a.sub(1),o),JI(uF(r,i,n.add(uy(1))),s,a,o.sub(1)),JI(uF(r.add(uy(1)),i,n.add(uy(1))),s.sub(1),a,o.sub(1)),JI(uF(r,i.add(uy(1)),n.add(uy(1))),s,a.sub(1),o.sub(1)),JI(uF(r.add(uy(1)),i.add(uy(1)),n.add(uy(1))),s.sub(1),a.sub(1),o.sub(1)),l,A,u)).toVar();return iF(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),mF=fB([pF,fF]),gF=fB([iy(([e])=>{const t=Ay(e).toVar(),r=uy(jI(t)).toVar();return oF(AF(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),iy(([e])=>{const t=dy(e).toVar(),r=uy(jI(t.x)).toVar(),i=uy(jI(t.y)).toVar();return oF(AF(r,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),iy(([e])=>{const t=gy(e).toVar(),r=uy(jI(t.x)).toVar(),i=uy(jI(t.y)).toVar(),n=uy(jI(t.z)).toVar();return oF(AF(r,i,n))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),iy(([e])=>{const t=vy(e).toVar(),r=uy(jI(t.x)).toVar(),i=uy(jI(t.y)).toVar(),n=uy(jI(t.z)).toVar(),s=uy(jI(t.w)).toVar();return oF(AF(r,i,n,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),yF=fB([iy(([e])=>{const t=Ay(e).toVar(),r=uy(jI(t)).toVar();return gy(oF(AF(r,uy(0))),oF(AF(r,uy(1))),oF(AF(r,uy(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),iy(([e])=>{const t=dy(e).toVar(),r=uy(jI(t.x)).toVar(),i=uy(jI(t.y)).toVar();return gy(oF(AF(r,i,uy(0))),oF(AF(r,i,uy(1))),oF(AF(r,i,uy(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),iy(([e])=>{const t=gy(e).toVar(),r=uy(jI(t.x)).toVar(),i=uy(jI(t.y)).toVar(),n=uy(jI(t.z)).toVar();return gy(oF(AF(r,i,n,uy(0))),oF(AF(r,i,n,uy(1))),oF(AF(r,i,n,uy(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),iy(([e])=>{const t=vy(e).toVar(),r=uy(jI(t.x)).toVar(),i=uy(jI(t.y)).toVar(),n=uy(jI(t.z)).toVar(),s=uy(jI(t.w)).toVar();return gy(oF(AF(r,i,n,s,uy(0))),oF(AF(r,i,n,s,uy(1))),oF(AF(r,i,n,s,uy(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),bF=iy(([e,t,r,i])=>{const n=Ay(i).toVar(),s=Ay(r).toVar(),a=uy(t).toVar(),o=gy(e).toVar(),l=Ay(0).toVar(),A=Ay(1).toVar();return gS(a,()=>{l.addAssign(A.mul(dF(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"}]}),xF=iy(([e,t,r,i])=>{const n=Ay(i).toVar(),s=Ay(r).toVar(),a=uy(t).toVar(),o=gy(e).toVar(),l=gy(0).toVar(),A=Ay(1).toVar();return gS(a,()=>{l.addAssign(A.mul(mF(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"}]}),vF=iy(([e,t,r,i])=>{const n=Ay(i).toVar(),s=Ay(r).toVar(),a=uy(t).toVar(),o=gy(e).toVar();return dy(bF(o,a,s,n),bF(o.add(gy(uy(19),uy(193),uy(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"}]}),_F=iy(([e,t,r,i])=>{const n=Ay(i).toVar(),s=Ay(r).toVar(),a=uy(t).toVar(),o=gy(e).toVar(),l=gy(xF(o,a,s,n)).toVar(),A=Ay(bF(o.add(gy(uy(19),uy(193),uy(17))),a,s,n)).toVar();return vy(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"}]}),wF=iy(([e,t,r,i,n,s,a])=>{const o=uy(a).toVar(),l=Ay(s).toVar(),A=uy(n).toVar(),u=uy(i).toVar(),h=uy(r).toVar(),c=uy(t).toVar(),d=dy(e).toVar(),p=gy(yF(dy(c.add(u),h.add(A)))).toVar(),f=dy(p.x,p.y).toVar();f.subAssign(.5),f.mulAssign(l),f.addAssign(.5);const m=dy(dy(Ay(c),Ay(h)).add(f)).toVar(),g=dy(m.sub(d)).toVar();return ay(o.equal(uy(2)),()=>Tx(g.x).add(Tx(g.y))),ay(o.equal(uy(3)),()=>kx(Tx(g.x),Tx(g.y))),jx(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"}]}),TF=iy(([e,t,r,i,n,s,a,o,l])=>{const A=uy(l).toVar(),u=Ay(o).toVar(),h=uy(a).toVar(),c=uy(s).toVar(),d=uy(n).toVar(),p=uy(i).toVar(),f=uy(r).toVar(),m=uy(t).toVar(),g=gy(e).toVar(),y=gy(yF(gy(m.add(d),f.add(c),p.add(h)))).toVar();y.subAssign(.5),y.mulAssign(u),y.addAssign(.5);const b=gy(gy(Ay(m),Ay(f),Ay(p)).add(y)).toVar(),x=gy(b.sub(g)).toVar();return ay(A.equal(uy(2)),()=>Tx(x.x).add(Tx(x.y)).add(Tx(x.z))),ay(A.equal(uy(3)),()=>kx(Tx(x.x),Tx(x.y),Tx(x.z))),jx(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"}]}),MF=fB([wF,TF]),SF=iy(([e,t,r])=>{const i=uy(r).toVar(),n=Ay(t).toVar(),s=dy(e).toVar(),a=uy().toVar(),o=uy().toVar(),l=dy(WI(s.x,a),WI(s.y,o)).toVar(),A=Ay(1e6).toVar();return gS({start:-1,end:uy(1),name:"x",condition:"<="},({x:e})=>{gS({start:-1,end:uy(1),name:"y",condition:"<="},({y:t})=>{const r=Ay(MF(l,e,t,a,o,n,i)).toVar();A.assign(Ox(A,r))})}),ay(i.equal(uy(0)),()=>{A.assign(cx(A))}),A}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),NF=iy(([e,t,r])=>{const i=uy(r).toVar(),n=Ay(t).toVar(),s=dy(e).toVar(),a=uy().toVar(),o=uy().toVar(),l=dy(WI(s.x,a),WI(s.y,o)).toVar(),A=dy(1e6,1e6).toVar();return gS({start:-1,end:uy(1),name:"x",condition:"<="},({x:e})=>{gS({start:-1,end:uy(1),name:"y",condition:"<="},({y:t})=>{const r=Ay(MF(l,e,t,a,o,n,i)).toVar();ay(r.lessThan(A.x),()=>{A.y.assign(A.x),A.x.assign(r)}).ElseIf(r.lessThan(A.y),()=>{A.y.assign(r)})})}),ay(i.equal(uy(0)),()=>{A.assign(cx(A))}),A}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),EF=iy(([e,t,r])=>{const i=uy(r).toVar(),n=Ay(t).toVar(),s=dy(e).toVar(),a=uy().toVar(),o=uy().toVar(),l=dy(WI(s.x,a),WI(s.y,o)).toVar(),A=gy(1e6,1e6,1e6).toVar();return gS({start:-1,end:uy(1),name:"x",condition:"<="},({x:e})=>{gS({start:-1,end:uy(1),name:"y",condition:"<="},({y:t})=>{const r=Ay(MF(l,e,t,a,o,n,i)).toVar();ay(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)})})}),ay(i.equal(uy(0)),()=>{A.assign(cx(A))}),A}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),CF=iy(([e,t,r])=>{const i=uy(r).toVar(),n=Ay(t).toVar(),s=gy(e).toVar(),a=uy().toVar(),o=uy().toVar(),l=uy().toVar(),A=gy(WI(s.x,a),WI(s.y,o),WI(s.z,l)).toVar(),u=Ay(1e6).toVar();return gS({start:-1,end:uy(1),name:"x",condition:"<="},({x:e})=>{gS({start:-1,end:uy(1),name:"y",condition:"<="},({y:t})=>{gS({start:-1,end:uy(1),name:"z",condition:"<="},({z:r})=>{const s=Ay(MF(A,e,t,r,a,o,l,n,i)).toVar();u.assign(Ox(u,s))})})}),ay(i.equal(uy(0)),()=>{u.assign(cx(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),RF=fB([SF,CF]),BF=iy(([e,t,r])=>{const i=uy(r).toVar(),n=Ay(t).toVar(),s=gy(e).toVar(),a=uy().toVar(),o=uy().toVar(),l=uy().toVar(),A=gy(WI(s.x,a),WI(s.y,o),WI(s.z,l)).toVar(),u=dy(1e6,1e6).toVar();return gS({start:-1,end:uy(1),name:"x",condition:"<="},({x:e})=>{gS({start:-1,end:uy(1),name:"y",condition:"<="},({y:t})=>{gS({start:-1,end:uy(1),name:"z",condition:"<="},({z:r})=>{const s=Ay(MF(A,e,t,r,a,o,l,n,i)).toVar();ay(s.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(s)}).ElseIf(s.lessThan(u.y),()=>{u.y.assign(s)})})})}),ay(i.equal(uy(0)),()=>{u.assign(cx(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),PF=fB([NF,BF]),DF=iy(([e,t,r])=>{const i=uy(r).toVar(),n=Ay(t).toVar(),s=gy(e).toVar(),a=uy().toVar(),o=uy().toVar(),l=uy().toVar(),A=gy(WI(s.x,a),WI(s.y,o),WI(s.z,l)).toVar(),u=gy(1e6,1e6,1e6).toVar();return gS({start:-1,end:uy(1),name:"x",condition:"<="},({x:e})=>{gS({start:-1,end:uy(1),name:"y",condition:"<="},({y:t})=>{gS({start:-1,end:uy(1),name:"z",condition:"<="},({z:r})=>{const s=Ay(MF(A,e,t,r,a,o,l,n,i)).toVar();ay(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)})})})}),ay(i.equal(uy(0)),()=>{u.assign(cx(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),IF=fB([EF,DF]),FF=iy(([e,t,r,i,n,s,a,o,l,A,u])=>{const h=uy(e).toVar(),c=dy(t).toVar(),d=dy(r).toVar(),p=dy(i).toVar(),f=Ay(n).toVar(),m=Ay(s).toVar(),g=Ay(a).toVar(),y=cy(o).toVar(),b=uy(l).toVar(),x=Ay(A).toVar(),v=Ay(u).toVar(),_=c.mul(d).add(p),w=Ay(0).toVar();return ay(h.equal(uy(0)),()=>{w.assign(mF(_))}),ay(h.equal(uy(1)),()=>{w.assign(yF(_))}),ay(h.equal(uy(2)),()=>{w.assign(IF(_,f,uy(0)))}),ay(h.equal(uy(3)),()=>{w.assign(xF(gy(_,0),b,x,v))}),w.assign(w.mul(g.sub(m)).add(m)),ay(y,()=>{w.assign(ev(w,m,g))}),w}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),qF=iy(([e,t,r,i,n,s,a,o,l,A,u])=>{const h=uy(e).toVar(),c=gy(t).toVar(),d=gy(r).toVar(),p=gy(i).toVar(),f=Ay(n).toVar(),m=Ay(s).toVar(),g=Ay(a).toVar(),y=cy(o).toVar(),b=uy(l).toVar(),x=Ay(A).toVar(),v=Ay(u).toVar(),_=c.mul(d).add(p),w=Ay(0).toVar();return ay(h.equal(uy(0)),()=>{w.assign(mF(_))}),ay(h.equal(uy(1)),()=>{w.assign(yF(_))}),ay(h.equal(uy(2)),()=>{w.assign(IF(_,f,uy(0)))}),ay(h.equal(uy(3)),()=>{w.assign(xF(_,b,x,v))}),w.assign(w.mul(g.sub(m)).add(m)),ay(y,()=>{w.assign(ev(w,m,g))}),w}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),LF=iy(([e])=>{const t=e.y,r=e.z,i=gy().toVar();return ay(t.lessThan(1e-4),()=>{i.assign(gy(r,r,r))}).Else(()=>{let n=e.x;n=n.sub(px(n)).mul(6).toVar();const s=uy(Dx(n)),a=n.sub(Ay(s)),o=r.mul(t.oneMinus()),l=r.mul(t.mul(a).oneMinus()),A=r.mul(t.mul(a.oneMinus()).oneMinus());ay(s.equal(uy(0)),()=>{i.assign(gy(r,A,o))}).ElseIf(s.equal(uy(1)),()=>{i.assign(gy(l,r,o))}).ElseIf(s.equal(uy(2)),()=>{i.assign(gy(o,r,A))}).ElseIf(s.equal(uy(3)),()=>{i.assign(gy(o,l,r))}).ElseIf(s.equal(uy(4)),()=>{i.assign(gy(A,o,r))}).Else(()=>{i.assign(gy(r,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),OF=iy(([e])=>{const t=gy(e).toVar(),r=Ay(t.x).toVar(),i=Ay(t.y).toVar(),n=Ay(t.z).toVar(),s=Ay(Ox(r,Ox(i,n))).toVar(),a=Ay(kx(r,kx(i,n))).toVar(),o=Ay(a.sub(s)).toVar(),l=Ay().toVar(),A=Ay().toVar(),u=Ay().toVar();return u.assign(a),ay(a.greaterThan(0),()=>{A.assign(o.div(a))}).Else(()=>{A.assign(0)}),ay(A.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{ay(r.greaterThanEqual(a),()=>{l.assign(i.sub(n).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(Mb(2,n.sub(r).div(o)))}).Else(()=>{l.assign(Mb(4,r.sub(i).div(o)))}),l.mulAssign(1/6),ay(l.lessThan(0),()=>{l.addAssign(1)})}),gy(l,A,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),kF=iy(([e])=>{const t=gy(e).toVar(),r=xy(Db(t,gy(.04045))).toVar(),i=gy(t.div(12.92)).toVar(),n=gy(Hx(kx(t.add(gy(.055)),gy(0)).div(1.055),gy(2.4))).toVar();return Jx(i,n,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),UF=(e,t)=>{e=Ay(e),t=Ay(t);const r=dy(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return iv(e.sub(r),e.add(r),t)},VF=(e,t,r,i)=>Jx(e,t,r[i].clamp()),zF=(e,t,r,i,n)=>Jx(e,t,UF(r,i[n])),GF=iy(([e,t,r])=>{const i=mx(e).toVar(),n=Sb(Ay(.5).mul(t.sub(r)),Gw).div(i).toVar(),s=Sb(Ay(-.5).mul(t.sub(r)),Gw).div(i).toVar(),a=gy().toVar();a.x=i.x.greaterThan(Ay(0)).select(n.x,s.x),a.y=i.y.greaterThan(Ay(0)).select(n.y,s.y),a.z=i.z.greaterThan(Ay(0)).select(n.z,s.z);const o=Ox(a.x,a.y,a.z).toVar();return Gw.add(i.mul(o)).toVar().sub(r)}),jF=iy(([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(Nb(r,r).sub(Nb(i,i)))),s});var WF=Object.freeze({__proto__:null,BRDF_GGX:jN,BRDF_Lambert:CN,BasicPointShadowFilter:BI,BasicShadowFilter:oI,Break:yS,Const:wv,Continue:()=>l_("continue").toStack(),DFGLUT:$N,D_GGX:VN,Discard:A_,EPSILON:Kb,F_Schlick:EN,Fn:iy,HALF_PI:ix,INFINITY:Jb,If:ay,Loop:gS,NodeAccess:Zm,NodeShaderStage:Xm,NodeType:{BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},NodeUpdateType:Ym,OnBeforeMaterialUpdate:e=>tP(eP.BEFORE_MATERIAL,e),OnBeforeObjectUpdate:e=>tP(eP.BEFORE_OBJECT,e),OnMaterialUpdate:e=>tP(eP.MATERIAL,e),OnObjectUpdate:e=>tP(eP.OBJECT,e),PCFShadowFilter:lI,PCFSoftShadowFilter:AI,PI:ex,PI2:tx,PointShadowFilter:PI,Return:()=>l_("return").toStack(),Schlick_to_F0:YN,ShaderNode:$g,Stack:oy,Switch:(...e)=>gg.Switch(...e),TBNViewMatrix:KT,TWO_PI:rx,VSMShadowFilter:uI,V_GGX_SmithCorrelated:kN,Var:_v,VarIntent:Tv,abs:Tx,acesFilmicToneMapping:VP,acos:_x,add:Mb,addMethodChaining:bg,addNodeElement:function(e){wc("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:WP,all:nx,alphaT:Wy,and:qb,anisotropy:Hy,anisotropyB:Qy,anisotropyT:$y,any:sx,append:e=>(wc("TSL: append() has been renamed to Stack().",new Im),oy(e)),array:yb,arrayBuffer:e=>new fg(e,"ArrayBuffer"),asin:vx,assign:xb,atan:wx,atomicAdd:(e,t)=>yD(mD.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>yD(mD.ATOMIC_AND,e,t),atomicFunc:yD,atomicLoad:e=>yD(mD.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>yD(mD.ATOMIC_MAX,e,t),atomicMin:(e,t)=>yD(mD.ATOMIC_MIN,e,t),atomicOr:(e,t)=>yD(mD.ATOMIC_OR,e,t),atomicStore:(e,t)=>yD(mD.ATOMIC_STORE,e,t),atomicSub:(e,t)=>yD(mD.ATOMIC_SUB,e,t),atomicXor:(e,t)=>yD(mD.ATOMIC_XOR,e,t),attenuationColor:ob,attenuationDistance:ab,attribute:y_,attributeArray:(e,t="float")=>{let r,i;!0===t.isStruct?(r=t.layout.getLength(),i=zm("float")):(r=Gm(t),i=zm(t));const n=new iP(e,r,i);return JM(n,t,e)},backgroundBlurriness:lP,backgroundIntensity:AP,backgroundRotation:uP,batch:cS,bentNormalView:eM,billboarding:vB,bitAnd:Ub,bitNot:Vb,bitOr:zb,bitXor:Gb,bitangentGeometry:QT,bitangentLocal:XT,bitangentView:YT,bitangentWorld:ZT,bitcast:$R,blendBurn:tN,blendColor:sN,blendDodge:rN,blendOverlay:nN,blendScreen:iN,blur:XE,bool:cy,buffer:B_,bufferAttribute:$v,builtin:F_,builtinAOContext:yv,builtinShadowContext:gv,bumpMap:lM,bvec2:my,bvec3:xy,bvec4:Ty,bypass:i_,cache:t_,call:_b,cameraFar:uw,cameraIndex:lw,cameraNear:Aw,cameraNormalMatrix:fw,cameraPosition:mw,cameraProjectionMatrix:hw,cameraProjectionMatrixInverse:cw,cameraViewMatrix:dw,cameraViewport:gw,cameraWorldMatrix:pw,cbrt:Zx,cdl:NP,ceil:fx,checker:UI,cineonToneMapping:kP,clamp:ev,clearcoat:Oy,clearcoatNormalView:nT,clearcoatRoughness:ky,clipSpace:kw,code:QP,color:ly,colorSpaceToWorking:Fv,colorToDirection:e=>Qg(e).mul(2).sub(1),compute:Kv,computeKernel:Zv,computeSkinning:(e,t=null)=>{const r=new pS(e);return r.positionNode=JM(new _f(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(rS).toVar(),r.skinIndexNode=JM(new _f(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(rS).toVar(),r.skinWeightNode=JM(new _f(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(rS).toVar(),r.bindMatrixNode=mb(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=mb(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=B_(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Qg(r)},context:pv,convert:Cy,convertColorSpace:(e,t,r)=>new Dv(Qg(e),t,r),convertToTexture:(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():$B(e,...t),cos:bx,countLeadingZeros:KR,countOneBits:JR,countTrailingZeros:ZR,cross:Wx,cubeTexture:_T,cubeTextureBase:vT,dFdx:Cx,dFdy:Rx,dashSize:eb,debug:d_,decrement:Xb,decrementBefore:$b,defaultBuildStages:Jm,defaultShaderStages:Km,defined:Wg,degrees:ox,deltaTime:gB,densityFogFactor:JP,depth:HS,depthPass:(e,t,r)=>new FP(FP.DEPTH,e,t,r),determinant:qx,difference:Gx,diffuseColor:Dy,diffuseContribution:Iy,directPointLight:OI,directionToColor:tM,directionToFaceDirection:Yw,dispersion:lb,disposeShadowMaterial:cI,distance:zx,div:Eb,dot:jx,drawIndex:aS,dynamicBufferAttribute:(e,t=null,r=0,i=0)=>Hv(e,t,r,i,cc),element:Ey,emissive:Fy,equal:Rb,equirectUV:fN,exp:lx,exp2:Ax,exponentialHeightFogFactor:eD,expression:l_,faceDirection:Xw,faceForward:nv,faceforward:Av,float:Ay,floatBitsToInt:e=>new HR(e,"int","float"),floatBitsToUint:QR,floor:px,fog:tD,fract:gx,frameGroup:cb,frameId:yB,frontFacing:Qw,fwidth:Ix,gain:(e,t)=>e.lessThan(.5)?tB(e.mul(2),t).div(2):Sb(1,tB(Nb(Sb(1,e),2),t).div(2)),gapSize:tb,getConstNodeType:Hg,getCurrentStack:sy,getDirection:WE,getDistanceAttenuation:LI,getGeometryRoughness:LN,getNormalFromDepth:YB,getParallaxCorrectNormal:GF,getRoughness:ON,getScreenPosition:XB,getShIrradianceAt:jF,getShadowMaterial:hI,getShadowRenderObjectFunction:fI,getTextureIndex:GR,getViewPosition:QB,ggxConvolution:JE,globalId:uD,glsl:(e,t)=>QP(e,t,"glsl"),glslFn:(e,t)=>YP(e,t,"glsl"),grayscale:_P,greaterThan:Db,greaterThanEqual:Fb,hash:eB,highpModelNormalViewMatrix:Ow,highpModelViewMatrix:Lw,hue:MP,increment:Qb,incrementBefore:Hb,inspector:m_,instance:lS,instanceIndex:rS,instancedArray:(e,t="float")=>{let r,i;!0===t.isStruct?(r=t.layout.getLength(),i=zm("float")):(r=Gm(t),i=zm(t));const n=new rP(e,r,i);return JM(n,t,n.count)},instancedBufferAttribute:Qv,instancedDynamicBufferAttribute:Xv,instancedMesh:uS,int:uy,intBitsToFloat:e=>new HR(e,"float","int"),interleavedGradientNoise:ZB,inverse:Lx,inverseSqrt:dx,inversesqrt:uv,invocationLocalIndex:sS,invocationSubgroupIndex:nS,ior:ib,iridescence:zy,iridescenceIOR:Gy,iridescenceThickness:jy,isolate:e_,ivec2:py,ivec3:yy,ivec4:_y,js:(e,t)=>QP(e,t,"js"),label:bv,length:Sx,lengthSq:Kx,lessThan:Pb,lessThanEqual:Ib,lightPosition:XD,lightProjectionUV:QD,lightShadowMatrix:$D,lightTargetDirection:KD,lightTargetPosition:YD,lightViewPosition:ZD,lightingContext:NS,lights:(e=[])=>(new rI).setLights(e),linearDepth:$S,linearToneMapping:LP,localId:hD,log:ux,log2:hx,logarithmicDepthToViewZ:(e,t,r)=>{const i=e.mul(ux(r.div(t)));return Ay(Math.E).pow(i).mul(t).negate()},luminance:SP,mat2:My,mat3:Sy,mat4:Ny,matcapUV:FC,materialAO:$M,materialAlphaTest:hM,materialAnisotropy:RM,materialAnisotropyVector:QM,materialAttenuationColor:OM,materialAttenuationDistance:LM,materialClearcoat:TM,materialClearcoatNormal:SM,materialClearcoatRoughness:MM,materialColor:cM,materialDispersion:WM,materialEmissive:pM,materialEnvIntensity:dT,materialEnvRotation:pT,materialIOR:qM,materialIridescence:BM,materialIridescenceIOR:PM,materialIridescenceThickness:DM,materialLightMap:HM,materialLineDashOffset:GM,materialLineDashSize:UM,materialLineGapSize:VM,materialLineScale:kM,materialLineWidth:zM,materialMetalness:_M,materialNormal:wM,materialOpacity:fM,materialPointSize:jM,materialReference:ET,materialReflectivity:xM,materialRefractionRatio:cT,materialRotation:NM,materialRoughness:vM,materialSheen:EM,materialSheenRoughness:CM,materialShininess:dM,materialSpecular:mM,materialSpecularColor:yM,materialSpecularIntensity:gM,materialSpecularStrength:bM,materialThickness:FM,materialTransmission:IM,max:kx,maxMipLevel:w_,mediumpModelViewMatrix:qw,metalness:Ly,min:Ox,mix:Jx,mixElement:av,mod:Cb,modInt:Yb,modelDirection:Nw,modelNormalMatrix:Dw,modelPosition:Cw,modelRadius:Pw,modelScale:Rw,modelViewMatrix:Fw,modelViewPosition:Bw,modelViewProjection:XM,modelWorldMatrix:Ew,modelWorldMatrixInverse:Iw,morphReference:wS,mrt:WR,mul:Nb,mx_aastep:UF,mx_add:(e,t=Ay(0))=>Mb(e,t),mx_atan2:(e=Ay(0),t=Ay(1))=>wx(e,t),mx_cell_noise_float:(e=b_())=>gF(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>Ay(e).sub(r).mul(t).add(r),mx_divide:(e,t=Ay(1))=>Eb(e,t),mx_fractal_noise_float:(e=b_(),t=3,r=2,i=.5,n=1)=>bF(e,uy(t),r,i).mul(n),mx_fractal_noise_vec2:(e=b_(),t=3,r=2,i=.5,n=1)=>vF(e,uy(t),r,i).mul(n),mx_fractal_noise_vec3:(e=b_(),t=3,r=2,i=.5,n=1)=>xF(e,uy(t),r,i).mul(n),mx_fractal_noise_vec4:(e=b_(),t=3,r=2,i=.5,n=1)=>_F(e,uy(t),r,i).mul(n),mx_frame:()=>yB,mx_heighttonormal:(e,t)=>(e=gy(e),t=Ay(t),lM(e,t)),mx_hsvtorgb:LF,mx_ifequal:(e,t,r,i)=>e.equal(t).mix(r,i),mx_ifgreater:(e,t,r,i)=>e.greaterThan(t).mix(r,i),mx_ifgreatereq:(e,t,r,i)=>e.greaterThanEqual(t).mix(r,i),mx_invert:(e,t=Ay(1))=>Sb(t,e),mx_modulo:(e,t=Ay(1))=>Cb(e,t),mx_multiply:(e,t=Ay(1))=>Nb(e,t),mx_noise_float:(e=b_(),t=1,r=0)=>dF(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=b_(),t=1,r=0)=>mF(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=b_(),t=1,r=0)=>{e=e.convert("vec2|vec3");return vy(mF(e),dF(e.add(dy(19,73)))).mul(t).add(r)},mx_place2d:(e,t=dy(.5,.5),r=dy(1,1),i=Ay(0),n=dy(0,0))=>{let s=e;if(t&&(s=s.sub(t)),r&&(s=s.mul(r)),i){const e=i.mul(Math.PI/180),t=e.cos(),r=e.sin();s=dy(s.x.mul(t).sub(s.y.mul(r)),s.x.mul(r).add(s.y.mul(t)))}return t&&(s=s.add(t)),n&&(s=s.add(n)),s},mx_power:(e,t=Ay(1))=>Hx(e,t),mx_ramp4:(e,t,r,i,n=b_())=>{const s=n.x.clamp(),a=n.y.clamp(),o=Jx(e,t,s),l=Jx(r,i,s);return Jx(o,l,a)},mx_ramplr:(e,t,r=b_())=>VF(e,t,r,"x"),mx_ramptb:(e,t,r=b_())=>VF(e,t,r,"y"),mx_rgbtohsv:OF,mx_rotate2d:(e,t)=>{e=dy(e);const r=(t=Ay(t)).mul(Math.PI/180);return kC(e,r)},mx_rotate3d:(e,t,r)=>{e=gy(e),t=Ay(t),r=gy(r);const i=t.mul(Math.PI/180),n=r.normalize(),s=i.cos(),a=i.sin(),o=Ay(1).sub(s);return e.mul(s).add(n.cross(e).mul(a)).add(n.mul(n.dot(e)).mul(o))},mx_safepower:(e,t=1)=>(e=Ay(e)).abs().pow(t).mul(e.sign()),mx_separate:(e,t=null)=>{if("string"==typeof t){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},i=t.replace(/^out/,"").toLowerCase();if(void 0!==r[i])return e.element(r[i])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==r[t])return e.element(r[t])}return e},mx_splitlr:(e,t,r,i=b_())=>zF(e,t,r,i,"x"),mx_splittb:(e,t,r,i=b_())=>zF(e,t,r,i,"y"),mx_srgb_texture_to_lin_rec709:kF,mx_subtract:(e,t=Ay(0))=>Sb(e,t),mx_timer:()=>mB,mx_transform_uv:(e=1,t=0,r=b_())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=b_(),r=dy(1,1),i=dy(0,0),n=1,s=0,a=1,o=!1,l=1,A=2,u=.5)=>FF(e,t.convert("vec2|vec3"),r,i,n,s,a,o,l,A,u),mx_unifiednoise3d:(e,t=b_(),r=dy(1,1),i=dy(0,0),n=1,s=0,a=1,o=!1,l=1,A=2,u=.5)=>qF(e,t.convert("vec2|vec3"),r,i,n,s,a,o,l,A,u),mx_worley_noise_float:(e=b_(),t=1)=>RF(e.convert("vec2|vec3"),t,uy(1)),mx_worley_noise_vec2:(e=b_(),t=1)=>PF(e.convert("vec2|vec3"),t,uy(1)),mx_worley_noise_vec3:(e=b_(),t=1)=>IF(e.convert("vec2|vec3"),t,uy(1)),negate:Nx,neutralToneMapping:HP,nodeArray:Zg,nodeImmutable:Jg,nodeObject:Qg,nodeObjectIntent:Xg,nodeObjects:Yg,nodeProxy:Kg,nodeProxyIntent:ey,normalFlat:Jw,normalGeometry:Zw,normalLocal:Kw,normalMap:nM,normalView:rT,normalViewGeometry:eT,normalWorld:iT,normalWorldGeometry:tT,normalize:mx,not:Ob,notEqual:Bb,numWorkgroups:lD,objectDirection:xw,objectGroup:pb,objectPosition:_w,objectRadius:Mw,objectScale:ww,objectViewPosition:Tw,objectWorldMatrix:vw,oneMinus:Ex,or:Lb,orthographicDepthToViewZ:US,oscSawtooth:(e=mB)=>e.fract(),oscSine:(e=mB)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=mB)=>e.fract().round(),oscTriangle:(e=mB)=>e.add(.5).fract().mul(2).sub(1).abs(),output:Jy,outputStruct:kR,overloadingFn:fB,packHalf2x16:sB,packSnorm2x16:iB,packUnorm2x16:nB,parabola:tB,parallaxDirection:JT,parallaxUV:(e,t)=>e.sub(JT.mul(t)),parameter:(e,t)=>new DR(e,t),pass:(e,t,r)=>new FP(FP.COLOR,e,t,r),passTexture:(e,t)=>new DP(e,t),pcurve:(e,t,r)=>Hx(Eb(Hx(e,t),Mb(Hx(e,t),Hx(Sb(1,e),r))),1/t),perspectiveDepthToViewZ:GS,pmremTexture:_C,pointShadow:FI,pointUV:sP,pointWidth:rb,positionGeometry:Uw,positionLocal:Vw,positionPrevious:zw,positionView:Ww,positionViewDirection:Hw,positionWorld:Gw,positionWorldDirection:jw,posterize:EP,pow:Hx,pow2:$x,pow3:Qx,pow4:Xx,premultiplyAlpha:aN,property:By,quadBroadcast:jD,quadSwapDiagonal:OD,quadSwapX:qD,quadSwapY:LD,radians:ax,rand:sv,range:sD,rangeFogFactor:KP,reciprocal:Px,reference:MT,referenceBuffer:ST,reflect:Vx,reflectVector:gT,reflectView:fT,reflector:e=>new kB(e),refract:rv,refractVector:yT,refractView:mT,reinhardToneMapping:OP,remap:s_,remapClamp:a_,renderGroup:db,renderOutput:h_,rendererReference:kv,replaceDefaultUV:function(e,t=null){return pv(t,{getUV:"function"==typeof e?e:()=>e})},rotate:kC,rotateUV:bB,roughness:qy,round:Bx,rtt:$B,sRGBTransferEOTF:Rv,sRGBTransferOETF:Bv,sample:(e,t=null)=>new JB(e,Qg(t)),sampler:e=>(!0===e.isNode?e:E_(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:E_(e)).convert("samplerComparison"),saturate:tv,saturation:wP,screenCoordinate:z_,screenDPR:k_,screenSize:V_,screenUV:U_,select:cv,setCurrentStack:ny,setName:mv,shaderStages:eg,shadow:_I,shadowPositionWorld:nI,shapeCircle:VI,sharedUniformGroup:hb,sheen:Uy,sheenRoughness:Vy,shiftLeft:jb,shiftRight:Wb,shininess:Ky,sign:Mx,sin:yx,sinc:(e,t)=>yx(ex.mul(t.mul(e).sub(1))).div(ex.mul(t.mul(e).sub(1))),skinning:fS,smoothstep:iv,smoothstepElement:ov,specularColor:Xy,specularColorBlended:Yy,specularF90:Zy,spherizeUV:xB,split:(e,t)=>new ug(Qg(e),t),spritesheetUV:wB,sqrt:cx,stack:FR,step:Ux,stepElement:lv,storage:JM,storageBarrier:()=>dD("storage").toStack(),storageTexture:cP,string:(e="")=>new fg(e,"string"),struct:(e,t=null)=>{const r=new qR(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;efP(e,t).level(r),texture3DLoad:(...e)=>fP(...e).setSampler(!1),textureBarrier:()=>dD("texture").toStack(),textureBicubic:fE,textureBicubicLevel:pE,textureCubeUV:HE,textureLevel:(e,t,r)=>E_(e,t).level(r),textureLoad:C_,textureSize:v_,textureStore:(e,t,r)=>{let i;return!0===e.isStorageTextureNode?(i=e.clone(),i.uvNode=t,i.storeNode=r):i=cP(e,t,r),null!==r&&i.toStack(),i},thickness:sb,time:mB,toneMapping:Vv,toneMappingExposure:zv,toonOutlinePass:(e,t,r=new jd(0,0,0),i=.003,n=1)=>new qP(e,t,Qg(r),Qg(i),Qg(n)),transformDirection:Yx,transformNormal:sT,transformNormalToView:aT,transformedClearcoatNormalView:AT,transformedNormalView:oT,transformedNormalWorld:lT,transmission:nb,transpose:Fx,triNoise3D:cB,triplanarTexture:(...e)=>TB(...e),triplanarTextures:TB,trunc:Dx,uint:hy,uintBitsToFloat:e=>new HR(e,"float","uint"),uniform:mb,uniformArray:I_,uniformCubeTexture:(e=bT)=>vT(e),uniformFlow:fv,uniformGroup:ub,uniformTexture:(e=M_)=>E_(e),unpackHalf2x16:AB,unpackNormal:rM,unpackSnorm2x16:oB,unpackUnorm2x16:lB,unpremultiplyAlpha:oN,userData:(e,t,r)=>new mP(e,t,r),uv:b_,uvec2:fy,uvec3:by,uvec4:wy,varying:Ev,varyingProperty:Py,vec2:dy,vec3:gy,vec4:vy,vectorComponents:tg,velocity:vP,vertexColor:eN,vertexIndex:tS,vertexStage:Cv,vibrance:TP,viewZToLogarithmicDepth:jS,viewZToOrthographicDepth:kS,viewZToPerspectiveDepth:VS,viewZToReversedOrthographicDepth:(e,t,r)=>e.add(r).div(r.sub(t)),viewZToReversedPerspectiveDepth:zS,viewport:G_,viewportCoordinate:W_,viewportDepthTexture:LS,viewportLinearDepth:QS,viewportMipTexture:PS,viewportOpaqueMipTexture:IS,viewportResolution:$_,viewportSafeUV:_B,viewportSharedTexture:BP,viewportSize:j_,viewportTexture:BS,viewportUV:H_,vogelDiskSample:KB,wgsl:(e,t)=>QP(e,t,"wgsl"),wgslFn:(e,t)=>YP(e,t,"wgsl"),workgroupArray:(e,t)=>new fD("Workgroup",e,t),workgroupBarrier:()=>dD("workgroup").toStack(),workgroupId:AD,workingToColorSpace:Iv,xor:kb});const HF=new PR;class $F extends tR{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(HF),HF.a=i._clearColor.a;else if(!0===n.isColor)n.getRGB(HF),HF.a=1,s=!0;else if(!0===n.isNode){const o=this.get(e),l=n;HF.copy(i._clearColor);let A=o.backgroundMesh;if(void 0===A){const h=vy(l).mul(AP).context({getUV:()=>uP.mul(tT),getTextureLevel:()=>lP}),c=hw.element(3).element(3).equal(1),d=Eb(1,hw.element(1).element(1)).mul(3),p=c.select(Vw.mul(d),Vw),f=Fw.mul(vy(p,0));let m=hw.mul(vy(f.xyz,1));m=m.setZ(m.w);const g=new lN;function y(){n.removeEventListener("dispose",y),A.material.dispose(),A.geometry.dispose()}g.name="Background.material",g.side=1,g.depthTest=!1,g.depthWrite=!1,g.allowOverride=!1,g.fog=!1,g.lights=!1,g.vertexNode=m,g.colorNode=h,o.backgroundMeshNode=h,o.backgroundMesh=A=new bf(new Gf(1,32,32),g),A.frustumCulled=!1,A.name="Background.mesh",n.addEventListener("dispose",y)}const u=l.getCacheKey();o.backgroundCacheKey!==u&&(o.backgroundMeshNode.node=vy(l).mul(AP),o.backgroundMeshNode.needsUpdate=!0,A.material.needsUpdate=!0,o.backgroundCacheKey=u),t.unshift(A,A.geometry,A.material,0,0,null,null)}else Tc("Renderer: Unsupported background configuration.",n);const a=i.xr.getEnvironmentBlendMode();if("additive"===a?HF.set(0,0,0,1):"alpha-blend"===a&&HF.set(0,0,0,0),!0===i.autoClear||!0===s){const b=r.clearColorValue;b.r=HF.r,b.g=HF.g,b.b=HF.b,b.a=HF.a,!0!==i.backend.isWebGLBackend&&!0!==i.alpha||(b.r*=b.a,b.g*=b.a,b.b*=b.a),r.depthClearValue=i.getClearDepth(),r.stencilClearValue=i.getClearStencil(),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 QF=0;class XF{constructor(e="",t=[],r=0){this.name=e,this.bindings=t,this.index=r,this.id=QF++}}class YF{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 XF(t.name,[],t.index);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class ZF{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class KF{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}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 JF{constructor(e,t,r=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=i}}class eq extends JF{constructor(e,t,r=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=i}}class tq{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let rq=0;class iq{constructor(e=null){this.id=rq++,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 nq{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class sq{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class aq extends sq{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class oq extends sq{constructor(e,t=new kc){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class lq extends sq{constructor(e,t=new Vc){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Aq extends sq{constructor(e,t=new ad){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class uq extends sq{constructor(e,t=new jd){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class hq extends sq{constructor(e,t=new Em){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class cq extends sq{constructor(e,t=new jc){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class dq extends sq{constructor(e,t=new Ad){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class pq extends aq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class fq extends oq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class mq extends lq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class gq extends Aq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class yq extends uq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class bq extends hq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class xq extends cq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class vq extends dq{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let _q=0;const wq=new WeakMap,Tq=new WeakMap,Mq=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Sq=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class Nq{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.types={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=FR(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new iq,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:_q++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}isOpaque(){const e=this.material;return!1===e.transparent&&1===e.blending&&!1===e.alphaToCoverage}createRenderTarget(e,t,r){return new od(e,t,r)}createCubeRenderTarget(e,t){return new mN(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let i,n=r.shared;if(n)for(let e=1;ee.nodeUniform.node.id-t.nodeUniform.node.id);for(const t of e.uniforms)r+=t.nodeUniform.node.id}else r+=e.nodeUniform.id;const n=this.renderer._currentRenderContext||this.renderer;let s=wq.get(n);void 0===s&&(s=new Map,wq.set(n,s));const a=qm(r);i=s.get(a),void 0===i&&(i=new XF(e,t,this.bindingsIndexes[e].group),s.set(a,i))}else i=new XF(e,t,this.bindingsIndexes[e].group);return i}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 eg)for(const i in r[e]){const n=r[e][i],s=t[i]||(t[i]=[]);for(const e of n)!1===s.includes(e)&&s.push(e)}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=0?`${Math.round(t)}u`:"0u";if("bool"===e)return t?"true":"false";if("color"===e)return`${this.getType("vec3")}( ${Sq(t.r)}, ${Sq(t.g)}, ${Sq(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 ZF(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===Ju)return"int";if(t===eh)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=Vm(e);const i="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),i+r}getTypeFromArray(e){return Mq.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 Pp||!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")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]!==e)throw new Error("NodeBuilder: Invalid active stack removal.");this.activeStacks.pop()}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=FR(this.stack);const e=sy();return this.stacks.push(e),ny(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){this.getDataFromNode(t).stack=e}return this.stack=e.parent,ny(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,"vertex");let i=r.bufferAttribute;if(void 0===i){const n=this.uniforms.index++;i=new ZF("nodeAttribute"+n,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}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 a=this.structs.index++;null===r&&(r="StructType"+a),s=new nq(r,t),this.structs[i].push(s),this.types[i][r]=e,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 KF(i||"nodeUniform"+a,t,e),this.uniforms[r].push(s),this.registerDeclaration(s),n.uniform=s}return s}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=e.getArrayCount(this);o=new JF(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 eq(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,wc(`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 tq("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 XP,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 DR(e.type,e.name);e.layout=null;const i=e.call(r),n=this.flowStagesNode(i,t.type);return e.layout=t,n}flowBuildStage(e,t,r=null){const i=this.getBuildStage();this.setBuildStage(t);const n=e.build(this,r);return this.setBuildStage(i),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 iq,this.stack=FR();for(const r of Jm)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(){wc("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(){wc("Abstract function.")}getVaryings(){wc("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(){wc("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(){wc("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&&(Tc(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new lN),e.build(this)}else this.addFlow("compute",e);for(const e of Jm){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of eg){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}getSharedDataFromNode(e){let t=Tq.get(e);return void 0===t&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let i=r.cache;if(void 0===i){if("float"===t||"int"===t||"uint"===t)i=new pq(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)i=new fq(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)i=new mq(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)i=new gq(e);else if("color"===t)i=new yq(e);else if("mat2"===t)i=new bq(e);else if("mat3"===t)i=new xq(e);else{if("mat4"!==t)throw new Error(`Uniform "${t}" not implemented.`);i=new vq(e)}r.cache=i}return i}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${cu} - Node System\n`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||!0===Qm(this.object).useVelocity}}class Eq{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={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Ym.FRAME){const t=this._getMaps(this.updateBeforeMap,r);if(t.frameId!==this.frameId){const r=t.frameId;t.frameId=this.frameId,!1===e.updateBefore(this)&&(t.frameId=r)}}else if(t===Ym.RENDER){const t=this._getMaps(this.updateBeforeMap,r);if(t.renderId!==this.renderId){const r=t.renderId;t.renderId=this.renderId,!1===e.updateBefore(this)&&(t.renderId=r)}}else t===Ym.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Ym.FRAME){const t=this._getMaps(this.updateAfterMap,r);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===Ym.RENDER){const t=this._getMaps(this.updateAfterMap,r);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===Ym.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Ym.FRAME){const t=this._getMaps(this.updateMap,r);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===Ym.RENDER){const t=this._getMaps(this.updateMap,r);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===Ym.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 Cq{constructor(e,t,r=null,i="",n=!1){this.type=e,this.name=t,this.count=r,this.qualifier=i,this.isConst=n}}Cq.isNodeFunctionInput=!0;class Rq extends qI{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class Bq extends qI{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:KD(this.light),lightColor:e}}}class Pq extends qI{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=XD(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=mb(new jd).setGroup(db)}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=iT.dot(i).mul(.5).add(.5),s=Jx(r,t,n);e.context.irradiance.addAssign(s)}}class Dq extends qI{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=mb(0).setGroup(db),this.penumbraCosNode=mb(0).setGroup(db),this.cutoffDistanceNode=mb(0).setGroup(db),this.decayExponentNode=mb(0).setGroup(db),this.colorNode=mb(this.color).setGroup(db)}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 iv(r,i,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=QD(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(KD(n)),l=this.getSpotAttenuation(e,o),A=s.length(),u=LI({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=E_(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 Iq extends Dq{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=E_(r,dy(e,0),0).r}else i=super.getSpotAttenuation(t);return i}}class Fq extends qI{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new Vc);this.lightProbe=I_(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=jF(iT,this.lightProbe);e.context.irradiance.addAssign(t)}}const qq=iy(([e,t])=>{const r=e.abs().sub(t);return Sx(kx(r,0)).add(Ox(kx(r.x,r.y),0))});class Lq extends Dq{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=Ay(0),r=this.penumbraCosNode,i=$D(this.light).mul(e.context.positionWorld||Gw);return ay(i.w.greaterThan(0),()=>{const e=i.xyz.div(i.w),n=qq(e.xy.sub(dy(.5)),dy(.5)),s=Eb(-1,Sb(1,_x(r)).sub(1));t.assign(tv(n.mul(-2).mul(s)))}),t}}const Oq=new Ad,kq=new Ad;let Uq=null;class Vq extends qI{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=mb(new Vc).setGroup(db),this.halfWidth=mb(new Vc).setGroup(db),this.updateType=Ym.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;kq.identity(),Oq.copy(t.matrixWorld),Oq.premultiply(r),kq.extractRotation(Oq),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(kq),this.halfHeight.value.applyMatrix4(kq)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=E_(Uq.LTC_FLOAT_1),r=E_(Uq.LTC_FLOAT_2)):(t=E_(Uq.LTC_HALF_1),r=E_(Uq.LTC_HALF_2));const{colorNode:i,light:n}=this;return{lightColor:i,lightPosition:ZD(n),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){Uq=e}}class zq{parseFunction(){wc("Abstract function.")}}class Gq{constructor(e,t,r="",i=""){this.type=e,this.inputs=t,this.name=r,this.precision=i}getCode(){wc("Abstract function.")}}Gq.isNodeFunction=!0;const jq=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Wq=/[a-z_0-9]+/gi,Hq="#pragma main";class $q extends Gq{constructor(e){const{type:t,inputs:r,name:i,precision:n,inputsCode:s,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Hq),r=-1!==t?e.slice(t+12):e,i=r.match(jq);if(null!==i&&5===i.length){const n=i[4],s=[];let a=null;for(;null!==(a=Wq.exec(n));)s.push(a);const o=[];let l=0;for(;l{const r=this.backend.createNodeBuilder(e.object,this.renderer);return r.scene=e.scene,r.material=t,r.camera=e.camera,r.context.material=t,r.lightsNode=e.lightsNode,r.environmentNode=this.getEnvironmentNode(e.scene),r.fogNode=this.getFogNode(e.scene),r.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&r.enableMultiview(),r};let s=t(e.material);try{s.build()}catch(e){s=t(new lN),s.build();let r=e.stackTrace;!r&&e.stack&&(r=new Im(e.stack)),Tc("TSL: "+e,r)}r=this._createNodeBuilderState(s),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 YF(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){Yq[0]=e,Yq[1]=t;const r=this.renderer.info.calls,i=this.callHashCache.get(Yq)||{};if(i.callId!==r){const n=this.getEnvironmentNode(e),s=this.getFogNode(e);t&&Zq.push(t.getCacheKey(!0)),n&&Zq.push(n.getCacheKey()),s&&Zq.push(s.getCacheKey()),Zq.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Zq.push(this.renderer.shadowMap.enabled?1:0),Zq.push(this.renderer.shadowMap.type),i.callId=r,i.cacheKey=Lm(Zq),this.callHashCache.set(Yq,i),Zq.length=0}return Yq[0]=null,Yq[1]=null,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 _C(r);{let e;return e=!0===r.isCubeTexture?_T(r):E_(r),vN(e)}}if(!0===r.isTexture)return E_(r,U_.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&Tc("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=MT("color","color",r).setGroup(db),t=MT("density","float",r).setGroup(db);return tD(e,JP(t))}if(r.isFog){const e=MT("color","color",r).setGroup(db),t=MT("near","float",r).setGroup(db),i=MT("far","float",r).setGroup(db);return tD(e,KP(t,i))}Tc("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?_T(r):!0===r.isTexture?E_(r):void Tc("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 Xq.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),i=e.isArrayTexture?fP(e,gy(U_,F_("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):E_(e,U_).renderOutput(t.toneMapping,t.currentColorSpace);return Xq.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 Eq,this.nodeBuilderCache=new Map,this.cacheLib={}}}const Jq=new Sf;class eL{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new jc,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;n0,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 lL(n.framebufferWidth,n.framebufferHeight,{format:Ah,type:Xu,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),n.layers.mask=6|e.layers.mask,s.layers.mask=-5&n.layers.mask,a.layers.mask=-3&n.layers.mask;const o=e.parent,l=n.cameras;cL(n,o);for(let e=0;e=0&&(r[s]=null,t[s].disconnect(n))}for(let i=0;i=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 mL(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 gL(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{await this.compileAsync(e,t);const i=this._renderLists.get(e,t),n=this._renderContexts.get(this._renderTarget,this._mrt),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(){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 Kq(this,r),this._animation=new XC(this,this._nodes,this.info),this._attributes=new oR(r),this._background=new $F(this,this._nodes),this._geometries=new hR(this._attributes,this.info),this._textures=new BR(this,r,this.info),this._pipelines=new yR(r,this._nodes),this._bindings=new bR(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new eR(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new MR(this.lighting),this._bundles=new iL,this._renderContexts=new CR(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}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._handleObjectFunction,l=this._compilationPromises,A=!0===e.isScene?e:bL;null===r&&(r=e);const u=this._renderTarget,h=this._renderContexts.get(u,this._mrt),c=this._activeMipmapLevel,d=[];this._currentRenderContext=h,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=d,i.renderId++,i.update(),h.depth=this.depth,h.stencil=this.stencil,h.clippingContext||(h.clippingContext=new eL),h.clippingContext.updateGlobal(A,t),A.onBeforeRender(this,e,t,u);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,h.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)}),p.finish(),null!==u){this._textures.updateRenderTarget(u,c);const e=this._textures.get(u);h.textures=e.textures,h.depthTexture=e.depthTexture}else h.textures=null,h.depthTexture=null;r!==e?this._background.update(r,p,h):this._background.update(A,p,h);const f=p.opaque,m=p.transparent,g=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&f.length>0&&this._renderObjects(f,t,A,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,g,t,A,y),i.renderId=n,this._currentRenderContext=s,this._currentRenderObjectFunction=a,this._handleObjectFunction=o,this._compilationPromises=l,await Promise.all(d)}async renderAsync(e,t){Mc('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){Tc("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;!0===e?(t.modelViewMatrix=Lw,t.modelNormalViewMatrix=Ow):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===Lw&&e.modelNormalViewMatrix===Ow}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Mc('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),Tc(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>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=x,p.viewportValue.maxDepth=v,p.viewport=!1===p.viewportValue.equals(vL),p.scissorValue.copy(y).multiplyScalar(b).floor(),p.scissor=m._scissorTest&&!1===p.scissorValue.equals(vL),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new eL),p.clippingContext.updateGlobal(A,t),A.onBeforeRender(this,e,t,d);const _=t.isArrayCamera?wL:_L;t.isArrayCamera||(TL.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(TL,t.coordinateSystem,t.reversedDepth));const w=this._renderLists.get(e,t);if(w.begin(),this._projectObject(e,t,0,w,p.clippingContext),w.finish(),!0===this.sortObjects&&w.sort(this._opaqueSort,this._transparentSort),null!==d){this._textures.updateRenderTarget(d,c);const e=this._textures.get(d);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=d,p.depth=d.depthBuffer,p.stencil=d.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=xL.width,p.height=xL.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=h,p.activeMipmapLevel=c,p.occlusionQueryCount=w.occlusionQueryCount,p.scissorValue.max(ML.set(0,0,0,0)),p.scissorValue.x+p.scissorValue.width>p.width&&(p.scissorValue.width=Math.max(p.width-p.scissorValue.x,0)),p.scissorValue.y+p.scissorValue.height>p.height&&(p.scissorValue.height=Math.max(p.height-p.scissorValue.y,0)),this._background.update(A,w,p),p.camera=t,this.backend.beginRender(p);const{bundles:T,lightsNode:M,transparentDoublePass:S,transparent:N,opaque:E}=w;return T.length>0&&this._renderBundles(T,A,M),!0===this.opaque&&E.length>0&&this._renderObjects(E,t,A,M),!0===this.transparent&&N.length>0&&this._renderTransparents(N,S,t,A,M),this.backend.finishRender(p),n.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=l,this._callDepth--,null!==i&&(this.setRenderTarget(u,h,c),this._renderOutput(d)),A.onAfterRender(this,e,t,d),this.inspector.finishRender(this.backend.getTimestampUID(p)),p}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._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)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,i){this._canvasTarget.setScissor(e,t,r,i)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,i,n=0,s=1){this._canvasTarget.setViewport(e,t,r,i,n,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!0===this.reversedDepthBuffer?1-this._clearDepth: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)throw new Error('Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.');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.get(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;const t=this.backend.getClearColor();n.clearColorValue.r=t.r,n.clearColorValue.g=t.g,n.clearColorValue.b=t.b,n.clearColorValue.a=t.a,n.clearDepthValue=this.getClearDepth(),n.clearStencilValue=this.getClearStencil(),n.activeCubeFace=this.getActiveCubeFace(),n.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,n),null!==i&&null===this._renderTarget&&this._renderOutput(i)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){Mc('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){Mc('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){Mc('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){Mc('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=0!==this.currentToneMapping,t=this.currentColorSpace!==Xc.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Xc.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){!0===this._initialized&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.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}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_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,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return wc("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,i=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const n=this.backend,s=this._pipelines,a=this._bindings,o=this._nodes,l=Array.isArray(e)?e:[e];if(void 0===l[0]||!0!==l[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");n.beginCompute(e);for(const r of l){if(!1===s.has(r)){const e=()=>{r.removeEventListener("dispose",e),s.delete(r),a.deleteForCompute(r),o.delete(r)};r.addEventListener("dispose",e);const t=r.onInitFunction;null!==t&&t.call(r,{renderer:this})}o.updateForCompute(r),a.updateForCompute(r);const i=a.getForCompute(r),l=s.getForCompute(r,i);n.compute(e,r,i,l,t)}n.finishCompute(e),r.renderId=i,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return Mc('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(!1===this._initialized)throw new Error('Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){Mc('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(!1===this._initialized)throw new Error('Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(!1===this._initialized)throw new Error('Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=ML.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void Tc("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=ML.copy(t).floor()}else t=ML.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),this._inspector.copyFramebufferToTexture(e)}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),this._inspector.copyTextureToTexture(e,t)}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?wL:_L;if(!e.frustumCulled||s.intersectsSprite(e,t)){!0===this.sortObjects&&ML.setFromMatrixPosition(e.matrixWorld).applyMatrix4(TL);const{geometry:t,material:s}=e;s.visible&&i.push(e,t,s,r,ML.z,null,n)}}else if(e.isLineLoop)Tc("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?wL:_L;if(!e.frustumCulled||s.intersectsObject(e,t)){const{geometry:t,material:s}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),ML.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(TL)),Array.isArray(s)){const a=t.groups;for(let o=0,l=a.length;o0){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(t.not().discard(),e))(l)}}e.depthNode&&e.depthNode.isNode&&(A=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),r={version:t,colorNode:l,depthNode:A,positionNode:o},this._cacheShadowNodes.set(e,r)}return r}renderObject(e,t,r,i,n,s,a,o=null,l=null){let A,u,h,c,d=!1;if(e.onBeforeRender(this,t,r,i,n,s),!0===n.allowOverride&&null!==t.overrideMaterial){const e=t.overrideMaterial;if(d=!0,A=e.isNodeMaterial?e.colorNode:null,u=e.isNodeMaterial?e.depthNode:null,h=e.isNodeMaterial?e.positionNode:null,c=t.overrideMaterial.side,n.positionNode&&n.positionNode.isNode&&(e.positionNode=n.positionNode),e.alphaTest=n.alphaTest,e.alphaMap=n.alphaMap,e.transparent=n.transparent||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode,e.isShadowPassMaterial){const{colorNode:t,depthNode:r,positionNode:i}=this._getShadowNodes(n);3===this.shadowMap.type?e.side=null!==n.shadowSide?n.shadowSide:n.side:e.side=null!==n.shadowSide?n.shadowSide:SL[n.side],null!==t&&(e.colorNode=t),null!==r&&(e.depthNode=r),null!==i&&(e.positionNode=i)}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),d&&(t.overrideMaterial.colorNode=A,t.overrideMaterial.depthNode=u,t.overrideMaterial.positionNode=h,t.overrideMaterial.side=c),e.onAfterRender(this,t,r,i,n,s)}hasCompatibility(e){return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,i,n,s,a,o){const l=this._objects.get(e,t,r,i,n,this._currentRenderContext,a,o);if(l.drawRange=e.geometry.drawRange,l.group=s,null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup}const A=this._nodes.needsRefresh(l);A&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),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)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class EL{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}let CL=class extends EL{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return(e=this._buffer.byteLength)+(aR-e%aR)%aR;var e}get buffer(){return this._buffer}update(){return!0}};class RL extends CL{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let BL=0;class PL extends RL{constructor(e,t){super("UniformBuffer_"+BL++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get buffer(){return this.nodeUniform.value}}class DL extends RL{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map}addUniformUpdateRange(e){const t=e.index;if(!0!==this._updateRangeCache.has(t)){const r=this.updateRanges,i={start:e.offset,count:e.itemSize};r.push(i),this._updateRangeCache.set(t,i)}}clearUpdateRanges(){this._updateRangeCache.clear(),super.clearUpdateRanges()}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{this.generation=null,this.version=-1},this.texture=t,this.version=t?t.version:-1,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture&&this._texture.removeEventListener("dispose",this._onTextureDispose),this._texture=e,this.generation=null,this.version=-1,this._texture&&this._texture.addEventListener("dispose",this._onTextureDispose))}get texture(){return this._texture}update(){const{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}clone(){const e=super.clone();return e._texture=null,e._onTextureDispose=()=>{e.generation=null,e.version=-1},e.texture=this.texture,e}}let LL=0;class OL extends qL{constructor(e,t){super(e,t),this.id=LL++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class kL extends OL{constructor(e,t,r,i=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r,this.access=i}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class UL extends kL{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledCubeTexture=!0}}class VL extends kL{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledTexture3D=!0}}const zL={bitcast_int_uint:new $P("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new $P("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }")},GL={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},jL={low:"lowp",medium:"mediump",high:"highp"},WL={swizzleAssign:!0,storageBuffer:!1},HL={perspective:"smooth",linear:"noperspective"},$L={centroid:"centroid"},QL="\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 highp sampler2DShadow;\nprecision highp sampler2DArrayShadow;\nprecision highp samplerCubeShadow;\n";class XL extends Nq{constructor(e,t){super(e,t,new Qq),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==Zh}_include(e){const t=zL[e];return t.build(this),this.addInclude(t),t}getMethod(e){return void 0!==zL[e]&&this._include(e),GL[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`${e} ? ${t} : ${r}`}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?dh:ch;2===i?s=n?fh:ph:3===i?s=n?1032:lh:4===i&&(s=n?mh:Ah);const a={Float32Array:th,Uint8Array:Xu,Uint16Array:Ku,Uint32Array:eh,Int8Array:Yu,Int16Array:Zu,Int32Array:Ju,Uint8ClampedArray:Xu},o=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/i))));let l=Math.ceil(r/i/o);o*l*i0?n:"";t=`${r.name} {\n\t${i} ${e.name}[${s}];\n};\n`}else{const t=e.groupNode.name;if(void 0===i[t]){const e=this.uniformGroups[t];if(void 0!==e){const r=[];for(const t of e.uniforms){const e=t.getType(),i=this.getVectorType(e),n=t.nodeUniform.node.precision;let s=`${i} ${t.name};`;null!==n&&(s=jL[n]+" "+s),r.push("\t"+s)}i[t]=r}}n=!0}if(!n){const i=e.node.precision;null!==i&&(t=jL[i]+" "+t),t="uniform "+t,r.push(t)}}let n="";for(const e in i){const t=i[e];n+=this._getGLSLUniformStruct(e,t.join("\n"))+"\n"}return n+=r.join("\n"),n}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ju){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+=`${HL[i.interpolationType]||i.interpolationType} ${$L[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+=`${HL[e.interpolationType]||e.interpolationType} ${$L[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`}getSubgroupSize(){Tc("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){Tc("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){Tc("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}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=WL[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)}WL[e]=t}return t}isFlipY(){return!0}getUniformBufferLimit(){const e=this.renderer.backend.gl;return e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE)}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;r0&&(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 kL(n.name,n.node,i),l.push(a);else if("cubeTexture"===t||"cubeDepthTexture"===t)a=new UL(n.name,n.node,i),l.push(a);else if("texture3D"===t)a=new VL(n.name,n.node,i),l.push(a);else if("buffer"===t){n.name=`buffer${e.id}`;const t=this.getSharedDataFromNode(e);let r=t.buffer;void 0===r&&(e.name=`NodeBuffer_${e.id}`,r=new PL(e,i),r.name=e.name,t.buffer=r),l.push(r),a=r}else{let e=this.uniformGroups[o];void 0===e?(e=new FL(o,i),this.uniformGroups[o]=e,l.push(e)):-1===l.indexOf(e)&&l.push(e),a=this.getNodeUniform(n,t);const r=a.name,s=e.uniforms.some(e=>e.name===r);s||e.addUniform(a)}s.uniformGPU=a}return n}}let YL=null,ZL=null;class KL{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[mc]:null,[fc]: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(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let i;i=!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls,t.timestampUID=i+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?fc:mc;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void Mc("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return YL=YL||new kc,this.renderer.getDrawingBufferSize(YL)}setScissorTest(){}getClearColor(){const e=this.renderer;return ZL=ZL||new PR,e.getClearColor(ZL),ZL.getRGB(ZL),ZL}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:function(){const e=bc("canvas");return e.style.display="block",e}(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${cu} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}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)}deleteBindGroupData(){}dispose(){}}let JL,eO,tO=0;class rO{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 iO{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===Ju,id:tO++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(i,t,n,s);u=new rO(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;e0?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{!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 aO,oO,lO,AO=!1;class uO{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===AO&&(this._init(),AO=!0)}_init(){const e=this.gl;aO={[Uu]:e.REPEAT,[Vu]:e.CLAMP_TO_EDGE,[zu]:e.MIRRORED_REPEAT},oO={[Gu]:e.NEAREST,[ju]:e.NEAREST_MIPMAP_NEAREST,[Wu]:e.NEAREST_MIPMAP_LINEAR,[Hu]:e.LINEAR,[$u]:e.LINEAR_MIPMAP_NEAREST,[Qu]:e.LINEAR_MIPMAP_LINEAR},lO={[ic]:e.NEVER,[uc]:e.ALWAYS,[nc]:e.LESS,[ac]:e.LEQUAL,[sc]:e.EQUAL,[Ac]:e.GEQUAL,[oc]:e.GREATER,[lc]: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];wc("WebGLBackend: 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?ec:Xc.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===tc?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),r===s.UNSIGNED_INT_10F_11F_11F_REV&&(o=s.R11F_G11F_B10F)}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?ec:Xc.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===tc?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=Xc.getPrimaries(Xc.workingColorSpace),a=t.colorSpace===Zh?null:Xc.getPrimaries(t.colorSpace),o=t.colorSpace===Zh||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,aO[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,aO[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,aO[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,oO[t.magFilter]);const l=void 0!==t.mipmaps&&t.mipmaps.length>0,A=t.minFilter===Hu&&l?Qu:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,oO[A]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lO[t.compareFunction])),!0===i.has("EXT_texture_filter_anisotropic")){if(t.magFilter===Gu)return;if(t.minFilter!==Wu&&t.minFilter!==Qu)return;if(t.type===th&&!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})}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;t0){const t=Cm(i.width,i.height,e.format,e.type);for(const n of e.layerUpdates){const e=i.data.subarray(n*t/i.data.BYTES_PER_ELEMENT,(n+1)*t/i.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,n,i.width,i.height,1,o,l,e)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,i.width,i.height,i.depth,o,l,i.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 s=e.mipmaps;if(s.length>0)for(let e=0,t=s.length;e0,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();a.state.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),a.state.bindFramebuffer(o.READ_FRAMEBUFFER,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}dispose(){const{gl:e}=this;null!==this._srcFramebuffer&&e.deleteFramebuffer(this._srcFramebuffer),null!==this._dstFramebuffer&&e.deleteFramebuffer(this._dstFramebuffer)}}function hO(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 cO{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 dO{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 pO={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",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fO{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;ithis.maxQueries)return Mc(`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,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);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){Tc("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);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){Tc("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=new Map;for(const[t,r]of this.queryOffsets){if("ended"===this.queryStates.get(r)){const i=this.queries[r];e.set(t,this.resolveQuery(i))}}if(0===e.size)return this.lastValue;const t={},r=[];for(const[i,n]of e){const e=i.match(/^(.*):f(\d+)$/),s=parseInt(e[2]);!1===r.includes(s)&&r.push(s),void 0===t[s]&&(t[s]=0);const a=await n;this.timestamps.set(i,a),t[s]+=a}const i=t[r[r.length-1]];return this.lastValue=i,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,i}catch(e){return Tc("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){Tc("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}}}class yO extends KL{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.currentSamples>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 cO(this),this.capabilities=new dO(this),this.attributeUtils=new iO(this),this.textureUtils=new uO(this),this.bufferRenderer=new fO(this),this.state=new nO(this),this.utils=new sO(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.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),!0===t.reversedDepthBuffer&&this.extensions.has("EXT_clip_control")&&this.state.setReversedDepth(!0)}get coordinateSystem(){return dc}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}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&&wc("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new gO(this.gl,e,2048));const r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}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();t.viewport(0,0,e,r)}if(e.scissor)this.updateScissor(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.scissor(0,0,e,r)}this.initTimestampQuery(mc,this.getTimestampUID(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{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(Mc("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):Mc("WebGLBackend: 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{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":" "} ${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");Tc("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&&wc("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;epO[t]===e),r=this.extensions;for(let e=0;e1,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=ER(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,n=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,n)}else{s.framebuffers[b]=x;for(let r=0;r0&&!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;r0&&!1===this._useMultisampledExtension(i)){const s=n.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;i.resolveDepthBuffer&&(i.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),i.stencilBuffer&&i.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const o=n.msaaFrameBuffer,l=n.msaaRenderbuffers,A=e.textures,u=A.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,s),u)for(let e=0;e0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){null!==this.textureUtils&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const bO="point-list",xO="line-list",vO="line-strip",_O="triangle-list",wO="undefined"!=typeof self&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},TO="never",MO="less",SO="equal",NO="less-equal",EO="greater",CO="not-equal",RO="greater-equal",BO="always",PO="store",DO="load",IO="clear",FO="ccw",qO="cw",LO="none",OO="back",kO="uint16",UO="uint32",VO="r8unorm",zO="r8snorm",GO="r8uint",jO="r8sint",WO="r16uint",HO="r16sint",$O="r16float",QO="rg8unorm",XO="rg8snorm",YO="rg8uint",ZO="rg8sint",KO="r32uint",JO="r32sint",ek="r32float",tk="rg16uint",rk="rg16sint",ik="rg16float",nk="rgba8unorm",sk="rgba8unorm-srgb",ak="rgba8snorm",ok="rgba8uint",lk="rgba8sint",Ak="bgra8unorm",uk="bgra8unorm-srgb",hk="rgb9e5ufloat",ck="rgb10a2unorm",dk="rg11b10ufloat",pk="rg32uint",fk="rg32sint",mk="rg32float",gk="rgba16uint",yk="rgba16sint",bk="rgba16float",xk="rgba32uint",vk="rgba32sint",_k="rgba32float",wk="depth16unorm",Tk="depth24plus",Mk="depth24plus-stencil8",Sk="depth32float",Nk="depth32float-stencil8",Ek="bc1-rgba-unorm",Ck="bc1-rgba-unorm-srgb",Rk="bc2-rgba-unorm",Bk="bc2-rgba-unorm-srgb",Pk="bc3-rgba-unorm",Dk="bc3-rgba-unorm-srgb",Ik="bc4-r-unorm",Fk="bc4-r-snorm",qk="bc5-rg-unorm",Lk="bc5-rg-snorm",Ok="bc6h-rgb-ufloat",kk="bc6h-rgb-float",Uk="bc7-rgba-unorm",Vk="bc7-rgba-unorm-srgb",zk="etc2-rgb8unorm",Gk="etc2-rgb8unorm-srgb",jk="etc2-rgb8a1unorm",Wk="etc2-rgb8a1unorm-srgb",Hk="etc2-rgba8unorm",$k="etc2-rgba8unorm-srgb",Qk="eac-r11unorm",Xk="eac-r11snorm",Yk="eac-rg11unorm",Zk="eac-rg11snorm",Kk="astc-4x4-unorm",Jk="astc-4x4-unorm-srgb",eU="astc-5x4-unorm",tU="astc-5x4-unorm-srgb",rU="astc-5x5-unorm",iU="astc-5x5-unorm-srgb",nU="astc-6x5-unorm",sU="astc-6x5-unorm-srgb",aU="astc-6x6-unorm",oU="astc-6x6-unorm-srgb",lU="astc-8x5-unorm",AU="astc-8x5-unorm-srgb",uU="astc-8x6-unorm",hU="astc-8x6-unorm-srgb",cU="astc-8x8-unorm",dU="astc-8x8-unorm-srgb",pU="astc-10x5-unorm",fU="astc-10x5-unorm-srgb",mU="astc-10x6-unorm",gU="astc-10x6-unorm-srgb",yU="astc-10x8-unorm",bU="astc-10x8-unorm-srgb",xU="astc-10x10-unorm",vU="astc-10x10-unorm-srgb",_U="astc-12x10-unorm",wU="astc-12x10-unorm-srgb",TU="astc-12x12-unorm",MU="astc-12x12-unorm-srgb",SU="clamp-to-edge",NU="repeat",EU="mirror-repeat",CU="linear",RU="nearest",BU="zero",PU="one",DU="src",IU="one-minus-src",FU="src-alpha",qU="one-minus-src-alpha",LU="dst",OU="one-minus-dst",kU="dst-alpha",UU="one-minus-dst-alpha",VU="src-alpha-saturated",zU="constant",GU="one-minus-constant",jU="add",WU="subtract",HU="reverse-subtract",$U="min",QU="max",XU=0,YU=15,ZU="keep",KU="zero",JU="replace",eV="invert",tV="increment-clamp",rV="decrement-clamp",iV="increment-wrap",nV="decrement-wrap",sV="storage",aV="read-only-storage",oV="write-only",lV="read-only",AV="read-write",uV="non-filtering",hV="comparison",cV="float",dV="unfilterable-float",pV="depth",fV="sint",mV="uint",gV="2d",yV="3d",bV="2d",xV="2d-array",vV="cube",_V="3d",wV="all",TV="vertex",MV="instance",SV={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"},NV={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class EV extends qL{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class CV extends CL{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let RV=0;class BV extends CV{constructor(e,t){super("StorageBuffer_"+RV++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Zm.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}class PV extends tR{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:CU}),this.flipYSampler=e.createSampler({minFilter:RU}),this.flipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),this.noFlipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM}),this.transferPipelines={},this.mipmapShaderModule=e.createShaderModule({label:"mipmap",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4f,\n\t@location( 0 ) vTex : vec2f,\n\t@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,\n};\n\n@group( 0 ) @binding ( 2 )\nvar flipY: u32;\n\n@vertex\nfn mainVS(\n\t\t@builtin( vertex_index ) vertexIndex : u32,\n\t\t@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array(\n\t\tvec2f( -1, -1 ),\n\t\tvec2f( -1, 3 ),\n\t\tvec2f( 3, -1 ),\n\t);\n\n\tlet p = pos[ vertexIndex ];\n\tlet mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );\n\tVarys.vTex = p * mult + vec2f( 0.5 );\n\tVarys.Position = vec4f( p, 0, 1 );\n\tVarys.vBaseArrayLayer = instanceIndex;\n\n\treturn Varys;\n\n}\n\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img2d : texture_2d;\n\n@fragment\nfn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2d, imgSampler, Varys.vTex );\n\n}\n\n@group( 0 ) @binding( 1 )\nvar img2dArray : texture_2d_array;\n\n@fragment\nfn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );\n\n}\n\nconst faceMat = array(\n mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x\n mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x\n mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y\n mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y\n mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z\n mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z\n);\n\n@group( 0 ) @binding( 1 )\nvar imgCube : texture_cube;\n\n@fragment\nfn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );\n\n}\n"})}getTransferPipeline(e,t){const r=`${e}-${t=t||"2d-array"}`;let i=this.transferPipelines[r];return void 0===i&&(i=this.device.createRenderPipeline({label:`mipmap-${e}-${t}`,vertex:{module:this.mipmapShaderModule},fragment:{module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},layout:"auto"}),this.transferPipelines[r]=i),i}flipY(e,t,r=0){const i=t.format,{width:n,height:s}=t.size,a=this.device.createTexture({size:{width:n,height:s},format:i,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),o=this.getTransferPipeline(i,e.textureBindingViewDimension),l=this.getTransferPipeline(i,a.textureBindingViewDimension),A=this.device.createCommandEncoder({}),u=(e,t,r,i,n,s)=>{const a=e.getBindGroupLayout(0),o=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t.createView({dimension:t.textureBindingViewDimension||"2d-array",baseMipLevel:0,mipLevelCount:1})},{binding:2,resource:{buffer:s?this.flipUniformBuffer:this.noFlipUniformBuffer}}]}),l=A.beginRenderPass({colorAttachments:[{view:i.createView({dimension:"2d",baseMipLevel:0,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1}),loadOp:IO,storeOp:PO}]});l.setPipeline(e),l.setBindGroup(0,o),l.draw(3,1,0,r),l.end()};u(o,e,r,a,0,!1),u(l,a,0,e,r,!0),this.device.queue.submit([A.finish()]),a.destroy()}generateMipmaps(e,t=null){const r=this.get(e),i=r.layers||this._mipmapCreateBundles(e),n=t||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(n,i),null===t&&this.device.queue.submit([n.finish()]),r.layers=i}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),i=r.getBindGroupLayout(0),n=[];for(let s=1;s0)for(let t=0,s=i.length;t0)for(let t=0,s=i.length;t0?e.width:r.size.width,A=a>0?e.height:r.size.height;try{o.queue.copyExternalImageToTexture({source:e,flipY:n},{texture:t,mipLevel:a,origin:{x:0,y:0,z:i},premultipliedAlpha:s},{width:l,height:A,depthOrArrayLayers:1})}catch(e){}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new PV(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,i,n,s=0,a=0){const o=this.backend.device,l=e.data,A=this._getBytesPerTexel(r.format),u=e.width*A;o.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:i}},l,{offset:e.width*e.height*A*s,bytesPerRow:u},{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]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,OV=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,kV={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"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 UV extends Gq{constructor(e){const{type:t,inputs:r,name:i,inputsCode:n,blockCode:s,outputType:a}=(e=>{const t=(e=e.trim()).match(LV);if(null!==t&&4===t.length){const r=t[2],i=[];let n=null;for(;null!==(n=OV.exec(r));)i.push({name:n[1],type:n[2]});const s=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class VV extends zq{parseFunction(e){return new UV(e)}}const zV={[Zm.READ_ONLY]:"read",[Zm.WRITE_ONLY]:"write",[Zm.READ_WRITE]:"read_write"},GV={[Uu]:"repeat",[Vu]:"clamp",[zu]:"mirror"},jV={vertex:wO.VERTEX,fragment:wO.FRAGMENT,compute:wO.COMPUTE},WV={instance:!0,swizzleAssign:!1,storageBuffer:!0},HV={"^^":"tsl_xor"},$V={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},QV={},XV={tsl_xor:new $P("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new $P("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new $P("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new $P("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new $P("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new $P("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new $P("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new $P("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new $P("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new $P("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new $P("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 $P("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new $P("\nfn tsl_biquadraticTexture( map : texture_2d, 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"),biquadraticTextureArray:new $P("\nfn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, 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, layer, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},YV={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",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let ZV="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(ZV+="diagnostic( off, derivative_uniformity );\n");class KV extends Nq{constructor(e,t){super(e,t,new VV),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,r,i,n,s=this.shaderStage){return"fragment"===s?i?n?`textureSample( ${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:n?`textureSample( ${t}, ${t}_sampler, ${r}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",i)}generateTextureSampleLevel(e,t,r,i,n,s){return!1===this.isUnfilterable(e)?n?s?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${i}, ${s} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${i} )`:s?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s,i,n):this.generateTextureLod(e,t,r,n,s,i)}generateWrapFunction(e){const t=`tsl_coord_${GV[e.wrapS]}S_${GV[e.wrapT]}_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}T`;let r=QV[t];if(void 0===r){const i=[],n=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let s=`fn ${t}( coord : ${n} ) -> ${n} {\n\n\treturn ${n}(\n`;const a=(e,t)=>{e===Uu?(i.push(XV.repeatWrapping_float),s+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===Vu?(i.push(XV.clampWrapping_float),s+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===zu?(i.push(XV.mirrorWrapping_float),s+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(s+=`\t\tcoord.${t}`,wc(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),s+=",\n",a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(s+=",\n",a(e.wrapR,"z")),s+="\n\t);\n\n}\n",QV[t]=r=new $P(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.is3DTexture||e.isData3DTexture?"vec3":"vec2",s=l||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,n=new xv(new o_(`textureDimensions( ${s} )`,a)),i.dimensionsSnippet[r]=n,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(i.arrayLayerCount=new xv(new o_(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new xv(new o_("6u","u32")))}return n.build(this)}generateFilteredTexture(e,t,r,i,n="0u",s){const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,n);return i&&(r=`${r} + vec2(${i}) / ${o}`),s?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${r} ), ${o}, u32( ${s} ), u32( ${n} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${r} ), ${o}, u32( ${n} ) )`)}generateTextureLod(e,t,r,i,n,s="0u"){if(!0===e.isCubeTexture){n&&(r=`${r} + vec3(${n})`);return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${e.isDepthTexture?"u32":"f32"}( ${s} ) )`}const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,s),l=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";n&&(r=`${r} + ${l}(${n}) / ${l}( ${o} )`);return r=`${l}( clamp( floor( ${a}( ${r} ) * ${l}( ${o} ) ), ${`${l}( 0 )`}, ${`${l}( ${o} - ${"vec3"===l?"vec3( 1, 1, 1 )":"vec2( 1, 1 )"} )`} ) )`,this.generateTextureLoad(e,t,r,s,i,null)}generateStorageTextureLoad(e,t,r,i,n,s){let a;return s&&(r=`${r} + ${s}`),a=n?`textureLoad( ${t}, ${r}, ${n} )`:`textureLoad( ${t}, ${r} )`,a}generateTextureLoad(e,t,r,i,n,s){let a;return null===i&&(i="0u"),s&&(r=`${r} + ${s}`),n?a=`textureLoad( ${t}, ${r}, ${n}, u32( ${i} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}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&&this.renderer.hasCompatibility(gc)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===th||!1===this.isSampleCompare(e)&&e.minFilter===Gu&&e.magFilter===Gu||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,i,n,s=this.shaderStage){let a=null;return a=this.isUnfilterable(e)?this.generateTextureLod(e,t,r,i,n,"0",s):this._generateTextureSample(e,t,r,i,n,s),a}generateTextureGrad(e,t,r,i,n,s,a=this.shaderStage){if("fragment"===a)return n?s?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${n}, ${i[0]}, ${i[1]}, ${s} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${n}, ${i[0]}, ${i[1]} )`:s?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i[0]}, ${i[1]}, ${s} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i[0]}, ${i[1]} )`;Tc(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,i,n,s,a=this.shaderStage){if("fragment"===a)return!0===e.isDepthTexture&&!0===e.isArrayTexture?s?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${i} )`:s?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i} )`;Tc(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,r,i,n,s){return!1===this.isUnfilterable(e)?n?s?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${i}, ${s} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${i} )`:s?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s,i,n):this.generateTextureLod(e,t,r,n,s,i)}generateTextureBias(e,t,r,i,n,s,a=this.shaderStage){if("fragment"===a)return n?s?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${n}, ${i}, ${s} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${n}, ${i} )`:s?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i} )`;Tc(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} 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||"cubeDepthTexture"===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=HV[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?(wc("WebGPURenderer: Atomic operations are only supported in compute shaders."),Zm.READ_WRITE):Zm.READ_ONLY:e.access}getStorageAccess(e,t){return zV[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||"cubeDepthTexture"===t||"storageTexture"===t||"texture3D"===t){let i=null;const s=this.getNodeAccess(e,r);"texture"===t||"storageTexture"===t?i=!0===e.value.is3DTexture?new VL(n.name,n.node,o,s):new kL(n.name,n.node,o,s):"cubeTexture"===t||"cubeDepthTexture"===t?i=new UL(n.name,n.node,o,s):"texture3D"===t&&(i=new VL(n.name,n.node,o,s)),i.store=!0===e.isStorageTextureNode,i.mipLevel=i.store?e.mipLevel:0,i.setVisibility(jV[r]);if(!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===i.store){const e=new EV(`${n.name}_sampler`,n.node,o);e.setVisibility(jV[r]),A.push(e,i),a=[e,i]}else A.push(i),a=[i]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const s=this.getSharedDataFromNode(e);let l=s.buffer;if(void 0===l){l=new("buffer"===t?PL:BV)(e,o),s.buffer=l}l.setVisibility(l.getVisibility()|jV[r]),A.push(l),a=l,n.name=i||"NodeBuffer_"+n.id}else{let e=this.uniformGroups[l];void 0===e&&(e=new FL(l,o),e.setVisibility(wO.VERTEX|wO.FRAGMENT|wO.COMPUTE),this.uniformGroups[l]=e),-1===A.indexOf(e)&&A.push(e),a=this.getNodeUniform(n,t);const r=a.name,i=e.uniforms.some(e=>e.name===r);i||e.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")+".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`,"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","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","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"),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","builtinClipSpace","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,i=this.vars[e];for(let n=0;nr.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||"cubeDepthTexture"===n.type||"storageTexture"===n.type||"texture3D"===n.type){const t=n.node.value;let i;(!0===t.isCubeTexture||!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&&!0===t.isDepthTexture)i="texture_depth_cube";else if(!0===t.isCubeTexture)i="texture_cube";else if(!0===t.isDepthTexture)i=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${s}_2d`:`texture_depth${s}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===n.node.isStorageTextureNode){const r=qV(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";else if(!0===t.is3DTexture||!0===t.isData3DTexture)i="texture_3d";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=n.groupNode.name;if(void 0===s[e]){const t=this.uniformGroups[e];if(void 0!==t){const r=[];for(const e of t.uniforms){const t=e.getType(),i=this.getType(this.getVectorType(t));r.push(`\t${e.name} : ${i}`)}let i=this.uniformGroupsBindings[e];void 0===i&&(i={index:a.binding++,id:a.group},this.uniformGroupsBindings[e]=i),s[e]={index:i.index,id:i.id,snippets:r}}}}}for(const e in s){const t=s[e];n.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}return[...r,...i,...n].join("\n")}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.builtinClipSpace = ${n.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",i+=`return ${n.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",i+=`output.color = ${n.result};\n\n\treturn output;`}}r.flow=i}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return $V[e]||e}isAvailable(e){let t=WV[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),WV[e]=t),t}getUniformBufferLimit(){return this.renderer.backend.device.limits.maxUniformBufferBindingSize}_getWGSLMethod(e){return void 0!==XV[e]&&this._include(e),YV[e]}_include(e){const t=XV[e];return t.build(this),this.addInclude(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 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${ZV}\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){const[r,i,n]=t;return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar 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( ${r}, ${i}, ${n} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x\n\t\t+ globalId.y * ( ${r} * numWorkgroups.x )\n\t\t+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${i} * numWorkgroups.y );\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 JV{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?Mk:Tk),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.currentSamples}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}getCurrentColorFormats(e){return null!==e.textures?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?bO:e.isLineSegments||e.isMesh&&!0===t.wireframe?xO:e.isLine?vO:e.isMesh?_O:void 0}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Xu)return Ak;if(e===rh)return bk;throw new Error("Unsupported output buffer type.")}}const ez=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&&ez.set(Float16Array,["float16"]);const tz=new Map([[Pp,["float16"]]]),rz=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class iz{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;e0&&(void 0===s.groups&&(s.groups=[],s.versions=[]),s.versions[r]===i&&(o=s.groups[r])),void 0===o&&(o=this.createBindGroup(e,a),r>0&&(s.groups[r]=o,s.versions[r]=i)),s.group=o}updateBinding(e){const t=this.backend,r=t.device,i=e.buffer,n=t.get(e).buffer,s=e.updateRanges;if(0===s.length)r.queue.writeBuffer(n,0,i,0);else{const e=yc(i),t=e?1:i.BYTES_PER_ELEMENT;for(let a=0,o=s.length;a1&&(n+=`-${e.texture.depthOrArrayLayers}`),n+=`-${r}-${i}`,a=e[n],void 0===a){const s=wV;let o;o=t.isSampledCubeTexture?vV:t.isSampledTexture3D?_V:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?xV:bV,a=e[n]=e.texture.createView({aspect:s,dimension:o,mipLevelCount:r,baseMipLevel:i})}}s.push({binding:n,resource:a})}else if(t.isSampler){const e=r.get(t.texture);s.push({binding:n,resource:e.sampler})}n++}return i.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:s})}_createLayoutEntries(e){const t=[];let r=0;for(const i of e.bindings){const e=this.backend,n={binding:r,visibility:i.visibility};if(i.isUniformBuffer||i.isStorageBuffer){const e={};i.isStorageBuffer&&(i.visibility&wO.COMPUTE&&(i.access===Zm.READ_WRITE||i.access===Zm.WRITE_ONLY)?e.type=sV:e.type=aV),n.buffer=e}else if(i.isSampledTexture&&i.store){const e={};e.format=this.backend.get(i.texture).texture.format;const t=i.access;e.access=t===Zm.READ_WRITE?AV:t===Zm.WRITE_ONLY?oV:lV,i.texture.isArrayTexture?e.viewDimension=xV:i.texture.is3DTexture&&(e.viewDimension=_V),n.storageTexture=e}else if(i.isSampledTexture){const t={},{primarySamples:r}=e.utils.getTextureSampleData(i.texture);if(r>1&&(t.multisampled=!0,i.texture.isDepthTexture||(t.sampleType=dV)),i.texture.isDepthTexture)e.compatibilityMode&&null===i.texture.compareFunction?t.sampleType=dV:t.sampleType=pV;else if(i.texture.isDataTexture||i.texture.isDataArrayTexture||i.texture.isData3DTexture){const e=i.texture.type;e===Ju?t.sampleType=fV:e===eh?t.sampleType=mV:e===th&&(this.backend.hasFeature("float32-filterable")?t.sampleType=cV:t.sampleType=dV)}i.isSampledCubeTexture?t.viewDimension=vV:i.texture.isArrayTexture||i.texture.isDataArrayTexture||i.texture.isCompressedArrayTexture?t.viewDimension=xV:i.isSampledTexture3D&&(t.viewDimension=_V),n.texture=t}else if(i.isSampler){const t={};i.texture.isDepthTexture&&(null!==i.texture.compareFunction&&e.hasCompatibility(gc)?t.type=hV:t.type=uV),n.sampler=t}else Tc(`WebGPUBindingUtils: Unsupported binding "${i}".`);t.push(n),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,0===r.layout.usedTimes&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class az{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),{layoutGPU:r}=e.layout;c.push(r)}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,r=e.context.mrt;for(let e=0;e1},layout:A.createPipelineLayout({bindGroupLayouts:c})},M={},S=e.context.depth,N=e.context.stencil;if(!0!==S&&!0!==N||(!0===S&&(M.format=_,M.depthWriteEnabled=i.depthWrite,M.depthCompare=v),!0===N&&(M.stencilFront=f,M.stencilBack=f,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),A.pushErrorScope("validation"),null===t)h.pipeline=A.createRenderPipeline(T),A.popErrorScope().then(e=>{null!==e&&(h.error=!0,Tc(e.message))});else{const e=new Promise(async e=>{try{h.pipeline=await A.createRenderPipelineAsync(T)}catch(e){}const t=await A.popErrorScope();null!==t&&(h.error=!0,Tc(t.message)),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.getCurrentColorFormats(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),{layoutGPU:i}=t.layout;a.push(i)}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:jU},r={srcFactor:n,dstFactor:s,operation:jU}};if(e.premultipliedAlpha)switch(i){case 1:n(PU,qU,PU,qU);break;case 2:n(PU,PU,PU,PU);break;case 3:n(BU,IU,BU,PU);break;case 4:n(LU,qU,BU,PU)}else switch(i){case 1:n(FU,qU,PU,qU);break;case 2:n(FU,PU,PU,PU);break;case 3:Tc(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case 4:Tc(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};Tc("WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case bu:t=BU;break;case 201:t=PU;break;case 202:t=DU;break;case 203:t=IU;break;case wu:t=FU;break;case Tu:t=qU;break;case 208:t=LU;break;case 209:t=OU;break;case 206:t=kU;break;case 207:t=UU;break;case 210:t=VU;break;case 211:t=zU;break;case 212:t=GU;break;default:Tc("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case 512:t=TO;break;case 519:t=BO;break;case 513:t=MO;break;case 515:t=NO;break;case 514:t=SO;break;case 518:t=RO;break;case 516:t=EO;break;case 517:t=CO;break;default:Tc("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case rc:t=ZU;break;case 0:t=KU;break;case 7681:t=JU;break;case 5386:t=eV;break;case 7682:t=tV;break;case 7683:t=rV;break;case 34055:t=iV;break;case 34056:t=nV;break;default:Tc("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case mu:t=jU;break;case 101:t=WU;break;case 102:t=HU;break;case 103:t=$U;break;case 104:t=QU;break;default:Tc("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const i={},n=this.backend.utils;i.topology=n.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?kO:UO);let s=1===r.side;return e.isMesh&&e.matrixWorld.determinant()<0&&(s=!s),i.frontFace=!0===s?qO:FO,i.cullMode=2===r.side?LO:OO,i}_getColorWriteMask(e){return!0===e.colorWrite?YU:XU}_getDepthCompare(e){let t;if(!1===e.depthTest)t=BO;else{const r=this.backend.parameters.reversedDepthBuffer?Sc[e.depthFunc]:e.depthFunc;switch(r){case 0:t=TO;break;case 1:t=BO;break;case 2:t=MO;break;case 3:t=NO;break;case 4:t=SO;break;case 5:t=RO;break;case 6:t=EO;break;case 7:t=CO;break;default:Tc("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class oz extends mO{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 Mc(`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,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)),a={},o=[];for(const[t,r]of e){const e=t.match(/^(.*):f(\d+)$/),i=parseInt(e[2]);!1===o.includes(i)&&o.push(i),void 0===a[i]&&(a[i]=0);const n=s[r],l=s[r+1],A=Number(l-n)/1e6;this.timestamps.set(t,A),a[i]+=A}const l=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=o,l}catch(e){return Tc("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){Tc("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){Tc("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 lz extends KL{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new JV(this),this.attributeUtils=new iz(this),this.bindingUtils=new sz(this),this.pipelineUtils=new az(this),this.textureUtils=new FV(this),this.occludedResolveCache=new Map;const t="undefined"==typeof navigator||!1===/Android/.test(navigator.userAgent);this._compatibility={[gc]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:"compatibility"},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(SV),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;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(t=>{if("destroyed"===t.reason)return;const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}),this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(SV.TimestampQuery),this.updateSize()}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(void 0===r){const i=this.parameters;r=!0===e.isDefaultCanvasTarget&&void 0!==i.context?i.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${cu} webgpu`);const n=i.alpha?"premultiplied":"opaque",s=i.outputType===rh?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:n,toneMapping:{mode:s}}),t.context=r}return r}get coordinateSystem(){return pc}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),i=e.currentSamples;let n=r.descriptor;if(void 0===n||r.samples!==i){n={colorAttachments:[{view:null}]},!0!==e.depth&&!0!==e.stencil||(n.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView()});const t=n.colorAttachments[0];i>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,r.descriptor=n,r.samples=i}const s=n.colorAttachments[0];return i>0?s.resolveTarget=this.context.getCurrentTexture().createView():s.view=this.context.getCurrentTexture().createView(),n}_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;void 0!==n&&i.width===r.width&&i.height===r.height&&i.samples===r.samples||(n={},i.descriptors=n);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;i1)if(!0===A){const t=e.camera.cameras;for(let e=0;e0&&(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:DO}),this.initTimestampQuery(mc,this.getTimestampUID(e),s),s.occlusionQuerySet=n;const a=s.depthStencilAttachment;if(null!==e.textures){const t=s.colorAttachments;for(let r=0;r0&&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;e0){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;eo&&(n[0]=Math.min(a,o),n[1]=Math.ceil(a/o)),s.dispatchSize=n}n=s.dispatchSize}a.dispatchWorkgroups(n[0],n[1]||1,n[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:r,material:i,context:n,pipeline:s}=e,a=e.getBindings(),o=this.get(n),l=this.get(s),A=l.pipeline;if(!0===l.error)return;const u=e.getIndex(),h=null!==u,c=e.getDrawParameters();if(null===c)return;const d=(t,r)=>{this.pipelineUtils.setPipeline(t,A),r.pipeline=A;const s=r.bindingGroups;for(let e=0,r=a.length;e{if(d(n,s),!0===r.isBatchedMesh){const e=r._multiDrawStarts,s=r._multiDrawCounts,a=r._multiDrawCount,o=r._multiDrawInstances;null!==o&&Mc("WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");let l=!0===h?u.array.BYTES_PER_ELEMENT:1;i.wireframe&&(l=r.geometry.attributes.position.count>65535?4:2);for(let i=0;i1?0:i;!0===h?n.drawIndexed(s[i],a,e[i]/l,0,A):n.draw(s[i],a,e[i],A),t.update(r,s[i],a)}}else if(!0===h){const{vertexCount:i,instanceCount:s,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const t=this.get(o).buffer,r=e.getIndirectOffset(),i=Array.isArray(r)?r:[r];for(let e=0;e0){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(wc("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new yO(e)));super(new t(e),e),this.library=new hz,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}WF.BRDF_GGX,WF.BRDF_Lambert,WF.BasicPointShadowFilter,WF.BasicShadowFilter,WF.Break,WF.Const,WF.Continue,WF.DFGLUT,WF.D_GGX,WF.Discard,WF.EPSILON,WF.F_Schlick;const dz=WF.Fn;WF.INFINITY;const pz=WF.If,fz=WF.Loop;WF.NodeAccess,WF.NodeShaderStage,WF.NodeType,WF.NodeUpdateType,WF.PCFShadowFilter,WF.PCFSoftShadowFilter,WF.PI,WF.PI2,WF.TWO_PI,WF.HALF_PI,WF.PointShadowFilter,WF.Return,WF.Schlick_to_F0,WF.ShaderNode,WF.Stack,WF.Switch,WF.TBNViewMatrix,WF.VSMShadowFilter,WF.V_GGX_SmithCorrelated,WF.Var,WF.VarIntent,WF.abs,WF.acesFilmicToneMapping,WF.acos,WF.add,WF.addMethodChaining,WF.addNodeElement,WF.agxToneMapping,WF.all,WF.alphaT,WF.and,WF.anisotropy,WF.anisotropyB,WF.anisotropyT,WF.any,WF.append,WF.array,WF.arrayBuffer;const mz=WF.asin;WF.assign,WF.atan,WF.atomicAdd,WF.atomicAnd,WF.atomicFunc,WF.atomicLoad,WF.atomicMax,WF.atomicMin,WF.atomicOr,WF.atomicStore,WF.atomicSub,WF.atomicXor,WF.attenuationColor,WF.attenuationDistance,WF.attribute,WF.attributeArray,WF.backgroundBlurriness,WF.backgroundIntensity,WF.backgroundRotation,WF.batch,WF.bentNormalView,WF.billboarding,WF.bitAnd,WF.bitNot,WF.bitOr,WF.bitXor,WF.bitangentGeometry,WF.bitangentLocal,WF.bitangentView,WF.bitangentWorld,WF.bitcast,WF.blendBurn,WF.blendColor,WF.blendDodge,WF.blendOverlay,WF.blendScreen,WF.blur,WF.bool,WF.buffer,WF.bufferAttribute,WF.bumpMap,WF.builtin,WF.builtinAOContext,WF.builtinShadowContext,WF.bvec2,WF.bvec3,WF.bvec4,WF.bypass,WF.cache,WF.call,WF.cameraFar,WF.cameraIndex,WF.cameraNear,WF.cameraNormalMatrix,WF.cameraPosition,WF.cameraProjectionMatrix,WF.cameraProjectionMatrixInverse,WF.cameraViewMatrix,WF.cameraViewport,WF.cameraWorldMatrix,WF.cbrt,WF.cdl,WF.ceil,WF.checker,WF.cineonToneMapping,WF.clamp,WF.clearcoat,WF.clearcoatNormalView,WF.clearcoatRoughness,WF.clipSpace,WF.code,WF.color,WF.colorSpaceToWorking,WF.colorToDirection,WF.compute,WF.computeKernel,WF.computeSkinning,WF.context,WF.convert,WF.convertColorSpace,WF.convertToTexture,WF.countLeadingZeros,WF.countOneBits,WF.countTrailingZeros;const gz=WF.cos;WF.cross,WF.cubeTexture,WF.cubeTextureBase,WF.dFdx,WF.dFdy,WF.dashSize,WF.debug,WF.decrement,WF.decrementBefore,WF.defaultBuildStages,WF.defaultShaderStages,WF.defined,WF.degrees,WF.deltaTime,WF.densityFog,WF.densityFogFactor,WF.depth,WF.depthPass,WF.determinant,WF.difference,WF.diffuseColor,WF.directPointLight,WF.directionToColor,WF.directionToFaceDirection,WF.dispersion,WF.distance,WF.div,WF.dot,WF.drawIndex,WF.dynamicBufferAttribute,WF.element,WF.emissive,WF.equal,WF.equirectUV;const yz=WF.exp;WF.exp2,WF.exponentialHeightFogFactor,WF.expression,WF.faceDirection,WF.faceForward,WF.faceforward;const bz=WF.float;WF.floatBitsToInt,WF.floatBitsToUint,WF.floor,WF.fog,WF.fract,WF.frameGroup,WF.frameId,WF.frontFacing,WF.fwidth,WF.gain,WF.gapSize,WF.getConstNodeType,WF.getCurrentStack,WF.getDirection,WF.getDistanceAttenuation,WF.getGeometryRoughness,WF.getNormalFromDepth,WF.interleavedGradientNoise,WF.vogelDiskSample,WF.getParallaxCorrectNormal,WF.getRoughness,WF.getScreenPosition,WF.getShIrradianceAt,WF.getShadowMaterial,WF.getShadowRenderObjectFunction,WF.getTextureIndex,WF.getViewPosition,WF.globalId,WF.glsl,WF.glslFn,WF.grayscale,WF.greaterThan,WF.greaterThanEqual,WF.hash,WF.highpModelNormalViewMatrix,WF.highpModelViewMatrix,WF.hue,WF.increment,WF.incrementBefore,WF.instance;const xz=WF.instanceIndex;WF.instancedArray,WF.instancedBufferAttribute,WF.instancedDynamicBufferAttribute,WF.instancedMesh,WF.int,WF.intBitsToFloat,WF.inverse,WF.inverseSqrt,WF.inversesqrt,WF.invocationLocalIndex,WF.invocationSubgroupIndex,WF.ior,WF.iridescence,WF.iridescenceIOR,WF.iridescenceThickness,WF.ivec2,WF.ivec3,WF.ivec4,WF.js,WF.label,WF.length,WF.lengthSq,WF.lessThan,WF.lessThanEqual,WF.lightPosition,WF.lightProjectionUV,WF.lightShadowMatrix,WF.lightTargetDirection,WF.lightTargetPosition,WF.lightViewPosition,WF.lightingContext,WF.lights,WF.linearDepth,WF.linearToneMapping,WF.localId,WF.log,WF.log2,WF.logarithmicDepthToViewZ,WF.luminance,WF.mat2,WF.mat3,WF.mat4,WF.matcapUV,WF.materialAO,WF.materialAlphaTest,WF.materialAnisotropy,WF.materialAnisotropyVector,WF.materialAttenuationColor,WF.materialAttenuationDistance,WF.materialClearcoat,WF.materialClearcoatNormal,WF.materialClearcoatRoughness,WF.materialColor,WF.materialDispersion,WF.materialEmissive,WF.materialEnvIntensity,WF.materialEnvRotation,WF.materialIOR,WF.materialIridescence,WF.materialIridescenceIOR,WF.materialIridescenceThickness,WF.materialLightMap,WF.materialLineDashOffset,WF.materialLineDashSize,WF.materialLineGapSize,WF.materialLineScale,WF.materialLineWidth,WF.materialMetalness,WF.materialNormal,WF.materialOpacity,WF.materialPointSize,WF.materialReference,WF.materialReflectivity,WF.materialRefractionRatio,WF.materialRotation,WF.materialRoughness,WF.materialSheen,WF.materialSheenRoughness,WF.materialShininess,WF.materialSpecular,WF.materialSpecularColor,WF.materialSpecularIntensity,WF.materialSpecularStrength,WF.materialThickness,WF.materialTransmission,WF.max,WF.maxMipLevel,WF.mediumpModelViewMatrix,WF.metalness,WF.min,WF.mix,WF.mixElement,WF.mod,WF.modInt,WF.modelDirection,WF.modelNormalMatrix,WF.modelPosition,WF.modelRadius,WF.modelScale,WF.modelViewMatrix,WF.modelViewPosition,WF.modelViewProjection,WF.modelWorldMatrix,WF.modelWorldMatrixInverse,WF.morphReference,WF.mrt,WF.mul,WF.mx_aastep,WF.mx_add,WF.mx_atan2,WF.mx_cell_noise_float,WF.mx_contrast,WF.mx_divide,WF.mx_fractal_noise_float,WF.mx_fractal_noise_vec2,WF.mx_fractal_noise_vec3,WF.mx_fractal_noise_vec4,WF.mx_frame,WF.mx_heighttonormal,WF.mx_hsvtorgb,WF.mx_ifequal,WF.mx_ifgreater,WF.mx_ifgreatereq,WF.mx_invert,WF.mx_modulo,WF.mx_multiply,WF.mx_noise_float,WF.mx_noise_vec3,WF.mx_noise_vec4,WF.mx_place2d,WF.mx_power,WF.mx_ramp4,WF.mx_ramplr,WF.mx_ramptb,WF.mx_rgbtohsv,WF.mx_rotate2d,WF.mx_rotate3d,WF.mx_safepower,WF.mx_separate,WF.mx_splitlr,WF.mx_splittb,WF.mx_srgb_texture_to_lin_rec709,WF.mx_subtract,WF.mx_timer,WF.mx_transform_uv,WF.mx_unifiednoise2d,WF.mx_unifiednoise3d,WF.mx_worley_noise_float,WF.mx_worley_noise_vec2,WF.mx_worley_noise_vec3;const vz=WF.negate;WF.neutralToneMapping,WF.nodeArray,WF.nodeImmutable,WF.nodeObject,WF.nodeObjectIntent,WF.nodeObjects,WF.nodeProxy,WF.nodeProxyIntent,WF.normalFlat,WF.normalGeometry,WF.normalLocal,WF.normalMap,WF.normalView,WF.normalViewGeometry,WF.normalWorld,WF.normalWorldGeometry,WF.normalize,WF.not,WF.notEqual,WF.numWorkgroups,WF.objectDirection,WF.objectGroup,WF.objectPosition,WF.objectRadius,WF.objectScale,WF.objectViewPosition,WF.objectWorldMatrix,WF.OnBeforeObjectUpdate,WF.OnBeforeMaterialUpdate,WF.OnObjectUpdate,WF.OnMaterialUpdate,WF.oneMinus,WF.or,WF.orthographicDepthToViewZ,WF.oscSawtooth,WF.oscSine,WF.oscSquare,WF.oscTriangle,WF.output,WF.outputStruct,WF.overloadingFn,WF.packHalf2x16,WF.packSnorm2x16,WF.packUnorm2x16,WF.parabola,WF.parallaxDirection,WF.parallaxUV,WF.parameter,WF.pass,WF.passTexture,WF.pcurve,WF.perspectiveDepthToViewZ,WF.pmremTexture,WF.pointShadow,WF.pointUV,WF.pointWidth,WF.positionGeometry,WF.positionLocal,WF.positionPrevious,WF.positionView,WF.positionViewDirection,WF.positionWorld,WF.positionWorldDirection,WF.posterize,WF.pow,WF.pow2,WF.pow3,WF.pow4,WF.premultiplyAlpha,WF.property,WF.radians,WF.rand,WF.range,WF.rangeFog,WF.rangeFogFactor,WF.reciprocal,WF.reference,WF.referenceBuffer,WF.reflect,WF.reflectVector,WF.reflectView,WF.reflector,WF.refract,WF.refractVector,WF.refractView,WF.reinhardToneMapping,WF.remap,WF.remapClamp,WF.renderGroup,WF.renderOutput,WF.rendererReference,WF.replaceDefaultUV,WF.rotate,WF.rotateUV,WF.roughness,WF.round,WF.rtt,WF.sRGBTransferEOTF,WF.sRGBTransferOETF,WF.sample,WF.sampler,WF.samplerComparison,WF.saturate,WF.saturation,WF.screen,WF.screenCoordinate,WF.screenDPR,WF.screenSize,WF.screenUV,WF.select,WF.setCurrentStack,WF.setName,WF.shaderStages,WF.shadow,WF.shadowPositionWorld,WF.shapeCircle,WF.sharedUniformGroup,WF.sheen,WF.sheenRoughness,WF.shiftLeft,WF.shiftRight,WF.shininess,WF.sign;const _z=WF.sin;WF.sinc,WF.skinning,WF.smoothstep,WF.smoothstepElement,WF.specularColor,WF.specularF90,WF.spherizeUV,WF.split,WF.spritesheetUV;const wz=WF.sqrt;WF.stack,WF.step,WF.stepElement;const Tz=WF.storage;WF.storageBarrier,WF.storageTexture,WF.string,WF.struct,WF.sub,WF.subgroupAdd,WF.subgroupAll,WF.subgroupAnd,WF.subgroupAny,WF.subgroupBallot,WF.subgroupBroadcast,WF.subgroupBroadcastFirst,WF.subBuild,WF.subgroupElect,WF.subgroupExclusiveAdd,WF.subgroupExclusiveMul,WF.subgroupInclusiveAdd,WF.subgroupInclusiveMul,WF.subgroupIndex,WF.subgroupMax,WF.subgroupMin,WF.subgroupMul,WF.subgroupOr,WF.subgroupShuffle,WF.subgroupShuffleDown,WF.subgroupShuffleUp,WF.subgroupShuffleXor,WF.subgroupSize,WF.subgroupXor,WF.tan,WF.tangentGeometry,WF.tangentLocal,WF.tangentView,WF.tangentWorld,WF.texture,WF.texture3D,WF.textureBarrier,WF.textureBicubic,WF.textureBicubicLevel,WF.textureCubeUV,WF.textureLoad,WF.textureSize,WF.textureLevel,WF.textureStore,WF.thickness,WF.time,WF.toneMapping,WF.toneMappingExposure,WF.toonOutlinePass,WF.transformDirection,WF.transformNormal,WF.transformNormalToView,WF.transformedClearcoatNormalView,WF.transformedNormalView,WF.transformedNormalWorld,WF.transmission,WF.transpose,WF.triNoise3D,WF.triplanarTexture,WF.triplanarTextures,WF.trunc,WF.uint,WF.uintBitsToFloat;const Mz=WF.uniform;WF.uniformArray,WF.uniformCubeTexture,WF.uniformGroup,WF.uniformFlow,WF.uniformTexture,WF.unpackHalf2x16,WF.unpackSnorm2x16,WF.unpackUnorm2x16,WF.unpremultiplyAlpha,WF.userData,WF.uv,WF.uvec2,WF.uvec3,WF.uvec4,WF.varying,WF.varyingProperty,WF.vec2,WF.vec3,WF.vec4,WF.vectorComponents,WF.velocity,WF.vertexColor,WF.vertexIndex,WF.vertexStage,WF.vibrance,WF.viewZToLogarithmicDepth,WF.viewZToOrthographicDepth,WF.viewZToPerspectiveDepth,WF.viewZToReversedOrthographicDepth,WF.viewZToReversedPerspectiveDepth,WF.viewport,WF.viewportCoordinate,WF.viewportDepthTexture,WF.viewportLinearDepth,WF.viewportMipTexture,WF.viewportOpaqueMipTexture,WF.viewportResolution,WF.viewportSafeUV,WF.viewportSharedTexture,WF.viewportSize,WF.viewportTexture,WF.viewportUV,WF.wgsl,WF.wgslFn,WF.workgroupArray,WF.workgroupBarrier,WF.workgroupId,WF.workingToColorSpace,WF.xor;var Sz=function(e){return e*e},Nz=function(e){return e*Math.PI/180};var Ez=Math.sqrt(2*Math.PI);var Cz=function(e){var t=v(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 Sz(Math.sin(e/2))},s=Nz(e[1]),a=Nz(t[1]),o=Nz(e[0]),l=Nz(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(-Sz(r/i)/2)/(i*Ez)*t}))},Rz=function(){var e,t=(e=y().m(function e(t){var r,i,n,s,a,o,l,A,u,h,c,d,p,f,m,g,b,x,v,_,w,T,M,S,N,E,C,R,B,P,D,I,F,q,L,O,k,U,V,z,G,j,W=arguments;return y().w(function(e){for(;;)switch(e.n){case 0:if(i=W.length>1&&void 0!==W[1]?W[1]:[],s=(n=W.length>2&&void 0!==W[2]?W[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 Cz(e,i,{lngAccessor:a,latAccessor:l,weightAccessor:u,bandwidth:h})}));case 1:return c=dz,d=pz,p=Mz,m=bz,g=xz,b=fz,x=wz,v=_z,_=gz,w=mz,T=yz,M=vz,S=(f=Tz)(new rP(new Float32Array(t.flat().map(Nz)),2),"vec2",t.length),N=f(new rP(new Float32Array(i.map(function(e){return[Nz(a(e)),Nz(l(e)),u(e)]}).flat()),3),"vec3",i.length),E=new rP(t.length,1),C=f(E,"float",t.length),R=m(Math.PI),B=x(R.mul(2)),P=function(e){return e.mul(e)},D=function(e){return P(v(e.div(2)))},I=function(e,t){var r=m(e[1]),i=m(t[1]),n=m(e[0]),s=m(t[0]);return m(2).mul(w(x(D(i.sub(r)).add(_(r).mul(_(i)).mul(D(s.sub(n)))))))},F=function(e,t){return T(M(P(e.div(t)).div(2))).div(t.mul(B))},q=p(Nz(h)),L=p(Nz(4*h)),O=p(i.length),k=c(function(){var e=S.element(g),t=C.element(g);t.assign(0),b(O,function(r){var i=r.i,n=N.element(i),s=n.z;d(s,function(){var r=I(n.xy,e.xy);d(r&&r.lessThan(L),function(){t.addAssign(F(r,q).mul(s))})})})}),U=k().compute(t.length),V=new cz,e.n=2,V.computeAsync(U);case 2:return z=Array,G=Float32Array,e.n=3,V.getArrayBufferAsync(E);case 3:return j=e.v,e.a(2,z.from.call(z,new G(j)))}},e)}),function(){var t=this,r=arguments;return new Promise(function(n,s){var a=e.apply(t,r);function o(e){i(a,n,s,o,l,"next",e)}function l(e){i(a,n,s,o,l,"throw",e)}o(void 0)})});return function(e){return t.apply(this,arguments)}}(),Bz=window.THREE?window.THREE:{Mesh:e.Mesh,MeshLambertMaterial:e.MeshLambertMaterial,SphereGeometry:e.SphereGeometry},Pz=function(e){var t=ot(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()},Dz=ee({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 Pz}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;he(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new Jo(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var e=new Bz.Mesh(new Bz.SphereGeometry(de),cl(new Bz.MeshLambertMaterial({vertexColors:!0,transparent:!0}),hl));return e.__globeObjType="heatmap",e})},update:function(e){var t=Wa(e.heatmapPoints),r=Wa(e.heatmapPointLat),i=Wa(e.heatmapPointLng),n=Wa(e.heatmapPointWeight),s=Wa(e.heatmapBandwidth),a=Wa(e.heatmapColorFn),o=Wa(e.heatmapColorSaturation),l=Wa(e.heatmapBaseAltitude),A=Wa(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=fe(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 Bz.SphereGeometry(de,b,b/2));var x=function(e){for(var t=e.itemSize,r=[],i=0;i=r)&&(t=r);return t}(i.map(Math.abs))||1e-15,o=ur([0,a/s],r);u.geometry.setAttribute("color",Po(i.map(function(e){return o(Math.abs(e))}),4));var l=Ar([0,a],[de*(1+f),de*(1+(n||f))]);u.geometry.setAttribute("r",Po(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 oe(s).to(n,e.heatmapsTransitionDuration).easing(te.Quadratic.InOut).onUpdate(i).onComplete(function(){e.tweenGroup.remove(this)}).start()))})}).digest(e.heatmapsData)}}),Iz=window.THREE?window.THREE:{DoubleSide:e.DoubleSide,Group:e.Group,LineBasicMaterial:e.LineBasicMaterial,LineSegments:e.LineSegments,Mesh:e.Mesh,MeshBasicMaterial:e.MeshBasicMaterial},Fz=ee({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;he(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new Jo(e,{objBindAttr:"__threeObjPolygon"}).id(function(e){return e.id}).onCreateObj(function(){var e=new Iz.Group;return e.__defaultSideMaterial=cl(new Iz.MeshBasicMaterial({side:Iz.DoubleSide,depthWrite:!0}),ul),e.__defaultCapMaterial=new Iz.MeshBasicMaterial({side:Iz.DoubleSide,depthWrite:!0}),e.add(new Iz.Mesh(void 0,[e.__defaultSideMaterial,e.__defaultCapMaterial])),e.add(new Iz.LineSegments(void 0,new Iz.LineBasicMaterial)),e.__globeObjType="polygon",e})},update:function(e){var t=Wa(e.polygonGeoJsonGeometry),r=Wa(e.polygonAltitude),i=Wa(e.polygonCapCurvatureResolution),n=Wa(e.polygonCapColor),s=Wa(e.polygonCapMaterial),a=Wa(e.polygonSideColor),o=Wa(e.polygonSideMaterial),l=Wa(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(g({id:"".concat(c,"_0"),coords:h.coordinates},u)):"MultiPolygon"===h.type?A.push.apply(A,w(h.coordinates.map(function(e,t){return g({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=v(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=v(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 SA(i,0,de,!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 Ia({type:"Polygon",coordinates:i},de,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=v(e,2),r=t[0],i=t[1];if(r&&!(i<0)){var n=c.material[i],s=Co(r);n.color.set(Eo(r)),n.transparent=s<1,n.opacity=s}}),p){var b=d.material,x=Co(l);b.color.set(Eo(l)),b.transparent=x<1,b.opacity=x}var _={alt:A},w=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.uSurfaceRadius.value=de/(r+1)})},T=t.__currentTargetD||Object.assign({},_,{alt:-.001});Object.keys(_).some(function(e){return T[e]!==_[e]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||T.alt===_.alt?w(_):e.tweenGroup.add(new oe(T).to(_,e.polygonsTransitionDuration).easing(te.Quadratic.InOut).onUpdate(w).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(A)}});var qz=window.THREE?window.THREE:{BufferGeometry:e.BufferGeometry,DoubleSide:e.DoubleSide,Mesh:e.Mesh,MeshLambertMaterial:e.MeshLambertMaterial,Vector3:e.Vector3},Lz=Object.assign({},ja),Oz=Lz.BufferGeometryUtils||Lz,kz=ee({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;he(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new Jo(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var e=new qz.Mesh(void 0,new qz.MeshLambertMaterial({side:qz.DoubleSide}));return e.__globeObjType="hexPolygon",e})},update:function(t){var r=Wa(t.hexPolygonGeoJsonGeometry),i=Wa(t.hexPolygonColor),n=Wa(t.hexPolygonAltitude),s=Wa(t.hexPolygonResolution),a=Wa(t.hexPolygonMargin),o=Wa(t.hexPolygonUseDots),l=Wa(t.hexPolygonCurvatureResolution),A=Wa(t.hexPolygonDotResolution);t.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=Co(b);u.material.color.set(Eo(b)),u.material.transparent=x<1,u.material.opacity=x;var _={alt:p,margin:f,curvatureResolution:g},w={geoJson:c,h3Res:d},T=u.__currentTargetD||Object.assign({},_,{alt:-.001}),M=u.__currentMemD||w;if(Object.keys(_).some(function(e){return T[e]!==_[e]})||Object.keys(w).some(function(e){return M[e]!==w[e]})){u.__currentMemD=w;var S=[];"Polygon"===c.type?au(c.coordinates,d,!0).forEach(function(e){return S.push(e)}):"MultiPolygon"===c.type?c.coordinates.forEach(function(e){return au(e,d,!0).forEach(function(e){return S.push(e)})}):console.warn("Unsupported GeoJson geometry type: ".concat(c.type,". Skipping geometry..."));var N=S.map(function(e){var t=nu(e),r=su(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(t){var r=u.__currentTargetD=t,i=r.alt,n=r.margin,s=r.curvatureResolution;u.geometry&&u.geometry.dispose(),u.geometry=N.length?(Oz.mergeGeometries||Oz.mergeBufferGeometries)(N.map(function(t){var r=v(t.hexCenter,2),a=r[0],o=r[1];if(m){var l=fe(a,o,i),A=fe(t.hexGeoJson[0][1],t.hexGeoJson[0][0],i),u=.85*(1-n)*new qz.Vector3(l.x,l.y,l.z).distanceTo(new qz.Vector3(A.x,A.y,A.z)),h=new e.CircleGeometry(u,y);return h.rotateX(ge(-a)),h.rotateY(ge(o)),h.translate(l.x,l.y,l.z),h}var c=0===n?t.hexGeoJson:t.hexGeoJson.map(function(e){var t=v(e,2),r=t[0],i=t[1];return[[r,o],[i,a]].map(function(e){var t=v(e,2);return function(e,t,r){return e-(e-t)*r}(t[0],t[1],n)})});return new SA([c],de,de*(1+i),!1,!0,!1,s)})):new qz.BufferGeometry};!t.hexPolygonsTransitionDuration||t.hexPolygonsTransitionDuration<0?E(_):t.tweenGroup.add(new oe(T).to(_,t.hexPolygonsTransitionDuration).easing(te.Quadratic.InOut).onUpdate(E).onComplete(function(){t.tweenGroup.remove(this)}).start())}}).digest(t.hexPolygonsData)}});const Uz=new e.Box3,Vz=new e.Vector3;class zz extends e.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 e.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 e.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(t){let r;t instanceof Float32Array?r=t:Array.isArray(t)&&(r=new Float32Array(t));const i=new e.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceStart",new e.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceEnd",new e.InterleavedBufferAttribute(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let r;t instanceof Float32Array?r=t:Array.isArray(t)&&(r=new Float32Array(t));const i=new e.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceColorStart",new e.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceColorEnd",new e.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(t){return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new e.Box3);const t=this.attributes.instanceStart,r=this.attributes.instanceEnd;void 0!==t&&void 0!==r&&(this.boundingBox.setFromBufferAttribute(t),Uz.setFromBufferAttribute(r),this.boundingBox.union(Uz))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new e.Sphere),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(void 0!==t&&void 0!==r){const e=this.boundingSphere.center;this.boundingBox.getCenter(e);let i=0;for(let n=0,s=t.count;n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \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 \n\t\t\t#include \n\t\t\t#include \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 \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \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 \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 \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"};class Gz extends e.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:e.UniformsUtils.clone(e.ShaderLib.line.uniforms),vertexShader:e.ShaderLib.line.vertexShader,fragmentShader:e.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}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.worldUnits&&(this.needsUpdate=!0),!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 jz=new e.Vector4,Wz=new e.Vector3,Hz=new e.Vector3,$z=new e.Vector4,Qz=new e.Vector4,Xz=new e.Vector4,Yz=new e.Vector3,Zz=new e.Matrix4,Kz=new e.Line3,Jz=new e.Vector3,eG=new e.Box3,tG=new e.Sphere,rG=new e.Vector4;let iG,nG;function sG(e,t,r){return rG.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),rG.multiplyScalar(1/rG.w),rG.x=nG/r.width,rG.y=nG/r.height,rG.applyMatrix4(e.projectionMatrixInverse),rG.multiplyScalar(1/rG.w),Math.abs(Math.max(rG.x,rG.y))}class aG extends e.Mesh{constructor(e=new zz,t=new Gz({color:16777215*Math.random()})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,r=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*r.count);for(let e=0,t=0,s=r.count;eh&&Qz.z>h)continue;if($z.z>h){const e=$z.z-Qz.z,t=($z.z-h)/e;$z.lerp(Qz,t)}else if(Qz.z>h){const e=Qz.z-$z.z,t=(Qz.z-h)/e;Qz.lerp($z,t)}$z.applyMatrix4(n),Qz.applyMatrix4(n),$z.multiplyScalar(1/$z.w),Qz.multiplyScalar(1/Qz.w),$z.x*=s.x/2,$z.y*=s.y/2,Qz.x*=s.x/2,Qz.y*=s.y/2,Kz.start.copy($z),Kz.start.z=0,Kz.end.copy(Qz),Kz.end.z=0;const o=Kz.closestPointToPointParameter(Yz,!0);Kz.at(o,Jz);const u=e.MathUtils.lerp($z.z,Qz.z,o),c=u>=-1&&u<=1,d=Yz.distanceTo(Jz)<.5*nG;if(c&&d){Kz.start.fromBufferAttribute(l,r),Kz.end.fromBufferAttribute(A,r),Kz.start.applyMatrix4(a),Kz.end.applyMatrix4(a);const n=new e.Vector3,s=new e.Vector3;iG.distanceSqToSegment(Kz.start,Kz.end,s,n),i.push({point:s,pointOnLine:n,distance:iG.origin.distanceTo(s),object:t,face:null,faceIndex:r,uv:null,uv1:null})}}}(this,n,r))}}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(jz),this.material.uniforms.resolution.value.set(jz.z,jz.w))}}class oG extends zz{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,r=new Float32Array(2*t);for(let i=0;i2&&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?Ar().domain(e.map(function(t,r){return r/(e.length-1)})).range(e):e;r=function(e){return Ro(a(e),n,!0)}}else{var o=Ro(e,n,!0);r=function(){return o}}for(var l=[],A=0,u=s;A1&&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]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;u0?1e3/_:0,f){b.material.resolution=e.rendererSize;var T=o(d),M=l(d),S=A(d);b.material.dashed=M>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=T,b.material.gapSize=M,b.material.dashOffset=-S);var N=a(d);if(N instanceof Array){var E=h(a(d),x.length-1,1,!1);b.geometry.setColors(E.array),b.material.vertexColors=!0}else{var C=N,R=Co(C);b.material.color=new hG.Color(Eo(C)),b.material.transparent=R<1,b.material.opacity=R,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 B=h(a(d),x.length),P=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;n0&&void 0!==arguments[0]?arguments[0]:1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;s(this,t),(e=n(this,t)).type="CircleLineGeometry",e.parameters={radius:r,segmentCount:i};for(var a=[],o=0;o<=i;o++){var l=(o/i-.25)*Math.PI*2;a.push({x:Math.cos(l)*r,y:Math.sin(l)*r,z:0})}return e.setFromPoints(a),e}return p(t,e),u(t)}((window.THREE?window.THREE:{BufferGeometry:e.BufferGeometry}).BufferGeometry),xG=window.THREE?window.THREE:{Color:e.Color,Group:e.Group,Line:e.Line,LineBasicMaterial:e.LineBasicMaterial,Vector3:e.Vector3},vG=ll.default||ll,_G=ee({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;he(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new Jo(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var e=new xG.Group;return e.__globeObjType="ring",e}),t.ticker=new vG,t.ticker.onTick.add(function(e){if(t.ringsData.length){var r=Wa(t.ringColor),i=Wa(t.ringAltitude),n=Wa(t.ringMaxRadius),s=Wa(t.ringPropagationSpeed),a=Wa(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(e){return v(e,2)[1]}).forEach(function(o){var l,A,u=v(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 xG.Line(new bG(1,t.ringResolution),new xG.LineBasicMaterial),m=r(h),g=m instanceof Array||m instanceof Function;g?m instanceof Array?(p=Ar().domain(m.map(function(e,t){return t/(m.length-1)})).range(m),f.material.transparent=m.some(function(e){return Co(e)<1})):(p=m,f.material.transparent=!0):(f.material.color=new xG.Color(Eo(m)),l=f.material,A=Co(m),l.opacity=A,l.transparent=A<1,l.depthWrite=A>=1);var y=de*(1+i(h)),b=n(h),x=b*Math.PI/180,_=s(h),w=_<=0,T=function(e){var t=e.t,r=(w?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 xG.Color(Eo(i)),f.material.transparent&&(f.material.opacity=Co(i))}};if(0===_)T({t:0}),c.add(f);else{var M=1e3*Math.abs(b/_);t.tweenGroup.add(new oe({t:0}).to({t:1},M).onUpdate(T).onStart(function(){return c.add(f)}).onComplete(function(){t.tweenGroup.remove(this),c.remove(f),ue(f)}).start())}}})}})},update:function(e){var t=Wa(e.ringLat),r=Wa(e.ringLng),i=Wa(e.ringAltitude),n=e.scene.localToWorld(new xG.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(e,s){var a=t(s),o=r(s),l=i(s);Object.assign(e.position,fe(a,o,l)),e.lookAt(n)}).digest(e.ringsData)}});class wG extends e.ExtrudeGeometry{constructor(e,t={}){const r=t.font;if(void 0===r)super();else{const i=r.generateShapes(e,t.size,t.direction);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 TG(t,r,i,n,s){const a=s.glyphs[t]||s.glyphs["?"];if(!a)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+s.familyName+".");const o=new e.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":{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},SG=g(g({},window.THREE?window.THREE:{BoxGeometry:e.BoxGeometry,CircleGeometry:e.CircleGeometry,DoubleSide:e.DoubleSide,Group:e.Group,Mesh:e.Mesh,MeshLambertMaterial:e.MeshLambertMaterial,TextGeometry:wG,Vector3:e.Vector3}),{},{Font:class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,r="ltr"){const i=[],n=function(e,t,r,i){const n=Array.from(e),s=t/r.resolution,a=(r.boundingBox.yMax-r.boundingBox.yMin+r.underlineThickness)*s,o=[];let l=0,A=0;"rtl"!=i&&"tb"!=i||n.reverse();for(let e=0;e1?t-1:0),i=1;i1?t-1:0),i=1;i2&&void 0!==arguments[2]&&arguments[2],r=function(r){function i(){var r;s(this,i);for(var a=arguments.length,o=new Array(a),l=0;l1&&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}(dj,(window.THREE?window.THREE:{Group:e.Group}).Group,!0);return pj});