// Version 2.39.2 globe.gl - https://github.com/vasturiano/globe.gl !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Globe=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n>8&255]+bt[e>>16&255]+bt[e>>24&255]+"-"+bt[255&t]+bt[t>>8&255]+"-"+bt[t>>16&15|64]+bt[t>>24&255]+"-"+bt[63&n|128]+bt[n>>8&255]+"-"+bt[n>>16&255]+bt[n>>24&255]+bt[255&r]+bt[r>>8&255]+bt[r>>16&255]+bt[r>>24&255]).toLowerCase()}function Et(e,t,n){return Math.max(t,Math.min(n,e))}function Ct(e,t){return(e%t+t)%t}function Rt(e,t,n){return(1-n)*e+n*t}function Nt(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 Pt(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 Dt={DEG2RAD:wt,RAD2DEG:Tt,generateUUID:Mt,clamp:Et,euclideanModulo:Ct,mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:Rt,damp:function(e,t,n,r){return Rt(e,t,1-Math.exp(-n*r))},pingpong:function(e,t=1){return t-Math.abs(Ct(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-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&&(St=e);let t=St+=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*wt},radToDeg:function(e){return e*Tt},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,n,r,i){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),u=s((t+r)/2),c=a((t+r)/2),A=s((t-r)/2),h=a((t-r)/2),d=s((r-t)/2),p=a((r-t)/2);switch(i){case"XYX":e.set(o*c,l*A,l*h,o*u);break;case"YZY":e.set(l*h,o*c,l*A,o*u);break;case"ZXZ":e.set(l*A,l*h,o*c,o*u);break;case"XZX":e.set(o*c,l*p,l*d,o*u);break;case"YXY":e.set(l*d,o*c,l*p,o*u);break;case"ZYZ":e.set(l*p,l*d,o*c,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:Pt,denormalize:Nt};class Lt{constructor(e=0,t=0){Lt.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,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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=Et(this.x,e.x,t.x),this.y=Et(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Et(this.x,e,t),this.y=Et(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Et(n,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 n=this.dot(e)/t;return Math.acos(Et(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,s=this.y-e.y;return this.x=i*n-s*r+e.x,this.y=i*r+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class It{constructor(e,t,n,r,i,s,a,o,l){It.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,r,i,s,a,o,l)}set(e,t,n,r,i,s,a,o,l){const u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=i,u[5]=o,u[6]=n,u[7]=s,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,r=t.elements,i=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],u=n[4],c=n[7],A=n[2],h=n[5],d=n[8],p=r[0],f=r[3],m=r[6],g=r[1],_=r[4],v=r[7],y=r[2],x=r[5],b=r[8];return i[0]=s*p+a*g+o*y,i[3]=s*f+a*_+o*x,i[6]=s*m+a*v+o*b,i[1]=l*p+u*g+c*y,i[4]=l*f+u*_+c*x,i[7]=l*m+u*v+c*b,i[2]=A*p+h*g+d*y,i[5]=A*f+h*_+d*x,i[8]=A*m+h*v+d*b,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],n=e[1],r=e[2],i=e[3],s=e[4],a=e[5],o=e[6],l=e[7],u=e[8];return t*s*u-t*a*l-n*i*u+n*a*o+r*i*l-r*s*o}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],a=e[5],o=e[6],l=e[7],u=e[8],c=u*s-a*l,A=a*o-u*i,h=l*i-s*o,d=t*c+n*A+r*h;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const p=1/d;return e[0]=c*p,e[1]=(r*l-u*n)*p,e[2]=(a*n-r*s)*p,e[3]=A*p,e[4]=(u*t-r*o)*p,e[5]=(r*i-a*t)*p,e[6]=h*p,e[7]=(n*o-l*t)*p,e[8]=(s*t-n*i)*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,n,r,i,s,a){const o=Math.cos(i),l=Math.sin(i);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-r*l,r*o,-r*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Ut.makeScale(e,t)),this}rotate(e){return this.premultiply(Ut.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ut.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Ut=new It;function Bt(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Ot(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Ft(){const e=Ot("canvas");return e.style.display="block",e}const kt={};function qt(e){e in kt||(kt[e]=!0,console.warn(e))}const Gt=(new It).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),zt=(new It).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Vt(){const e={enabled:!0,workingColorSpace:it,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n?(this.spaces[t].transfer===at&&(e.r=jt(e.r),e.g=jt(e.g),e.b=jt(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===at&&(e.r=Wt(e.r),e.g=Wt(e.g),e.b=Wt(e.b)),e):e},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===nt?st:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[it]:{primaries:t,whitePoint:r,transfer:st,toXYZ:Gt,fromXYZ:zt,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:rt},outputColorSpaceConfig:{drawingBufferColorSpace:rt}},[rt]:{primaries:t,whitePoint:r,transfer:at,toXYZ:Gt,fromXYZ:zt,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:rt}}}),e}const Ht=Vt();function jt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Wt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let Xt;class Qt{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Xt&&(Xt=Ot("canvas")),Xt.width=e.width,Xt.height=e.height;const n=Xt.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Xt}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=Ot("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}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 j:e.x=e.x-Math.floor(e.x);break;case W:e.x=e.x<0?0:1;break;case X: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 j:e.y=e.y-Math.floor(e.y);break;case W:e.y=e.y<0?0:1;break;case X: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++}}Jt.DEFAULT_IMAGE=null,Jt.DEFAULT_MAPPING=300,Jt.DEFAULT_ANISOTROPY=1;class en{constructor(e=0,t=0,n=0,r=1){en.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}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,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,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,n=this.y,r=this.z,i=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r+s[12]*i,this.y=s[1]*t+s[5]*n+s[9]*r+s[13]*i,this.z=s[2]*t+s[6]*n+s[10]*r+s[14]*i,this.w=s[3]*t+s[7]*n+s[11]*r+s[15]*i,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,n,r,i;const s=.01,a=.1,o=e.elements,l=o[0],u=o[4],c=o[8],A=o[1],h=o[5],d=o[9],p=o[2],f=o[6],m=o[10];if(Math.abs(u-A)o&&e>g?eg?o=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const i=Math.sqrt(r),s=Math.atan2(i,t*n);e=Math.sin(e*s)/i,a=Math.sin(a*s)/i}const i=a*n;if(o=o*e+A*i,l=l*e+h*i,u=u*e+d*i,c=c*e+p*i,e===1-a){const e=1/Math.sqrt(o*o+l*l+u*u+c*c);o*=e,l*=e,u*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,r,i,s){const a=n[r],o=n[r+1],l=n[r+2],u=n[r+3],c=i[s],A=i[s+1],h=i[s+2],d=i[s+3];return e[t]=a*d+u*c+o*h-l*A,e[t+1]=o*d+u*A+l*c-a*h,e[t+2]=l*d+u*h+a*A-o*c,e[t+3]=u*d-a*c-o*A-l*h,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,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,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 n=e._x,r=e._y,i=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),u=a(r/2),c=a(i/2),A=o(n/2),h=o(r/2),d=o(i/2);switch(s){case"XYZ":this._x=A*u*c+l*h*d,this._y=l*h*c-A*u*d,this._z=l*u*d+A*h*c,this._w=l*u*c-A*h*d;break;case"YXZ":this._x=A*u*c+l*h*d,this._y=l*h*c-A*u*d,this._z=l*u*d-A*h*c,this._w=l*u*c+A*h*d;break;case"ZXY":this._x=A*u*c-l*h*d,this._y=l*h*c+A*u*d,this._z=l*u*d+A*h*c,this._w=l*u*c-A*h*d;break;case"ZYX":this._x=A*u*c-l*h*d,this._y=l*h*c+A*u*d,this._z=l*u*d-A*h*c,this._w=l*u*c+A*h*d;break;case"YZX":this._x=A*u*c+l*h*d,this._y=l*h*c+A*u*d,this._z=l*u*d-A*h*c,this._w=l*u*c-A*h*d;break;case"XZY":this._x=A*u*c-l*h*d,this._y=l*h*c-A*u*d,this._z=l*u*d+A*h*c,this._w=l*u*c+A*h*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],s=t[1],a=t[5],o=t[9],l=t[2],u=t[6],c=t[10],A=n+a+c;if(A>0){const e=.5/Math.sqrt(A+1);this._w=.25/e,this._x=(u-o)*e,this._y=(i-l)*e,this._z=(s-r)*e}else if(n>a&&n>c){const e=2*Math.sqrt(1+n-a-c);this._w=(u-o)/e,this._x=.25*e,this._y=(r+s)/e,this._z=(i+l)/e}else if(a>c){const e=2*Math.sqrt(1+a-n-c);this._w=(i-l)/e,this._x=(r+s)/e,this._y=.25*e,this._z=(o+u)/e}else{const e=2*Math.sqrt(1+c-n-a);this._w=(s-r)/e,this._x=(i+l)/e,this._y=(o+u)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Et(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),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 n=e._x,r=e._y,i=e._z,s=e._w,a=t._x,o=t._y,l=t._z,u=t._w;return this._x=n*u+s*a+r*l-i*o,this._y=r*u+s*o+i*a-n*l,this._z=i*u+s*l+n*o-r*a,this._w=s*u-n*a-r*o-i*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,i=this._z,s=this._w;let a=s*e._w+n*e._x+r*e._y+i*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=n,this._y=r,this._z=i,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}const l=Math.sqrt(o),u=Math.atan2(l,a),c=Math.sin((1-t)*u)/l,A=Math.sin(t*u)/l;return this._w=s*c+this._w*A,this._x=n*c+this._x*A,this._y=r*c+this._y*A,this._z=i*c+this._z*A,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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 on{constructor(e=0,t=0,n=0){on.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,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(un.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(un.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,s=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*s,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*s,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,s=e.y,a=e.z,o=e.w,l=2*(s*r-a*n),u=2*(a*t-i*r),c=2*(i*n-s*t);return this.x=t+o*l+s*c-a*u,this.y=n+o*u+a*l-i*c,this.z=r+o*c+i*u-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,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,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=Et(this.x,e.x,t.x),this.y=Et(this.y,e.y,t.y),this.z=Et(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Et(this.x,e,t),this.y=Et(this.y,e,t),this.z=Et(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Et(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,s=t.x,a=t.y,o=t.z;return this.x=r*o-i*a,this.y=i*s-n*o,this.z=n*a-r*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ln.copy(this).projectOnVector(e),this.sub(ln)}reflect(e){return this.sub(ln.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 n=this.dot(e)/t;return Math.acos(Et(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ln=new on,un=new an;class cn{constructor(e=new on(1/0,1/0,1/0),t=new on(-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,n=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,hn),hn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yn),xn.subVectors(this.max,yn),pn.subVectors(e.a,yn),fn.subVectors(e.b,yn),mn.subVectors(e.c,yn),gn.subVectors(fn,pn),_n.subVectors(mn,fn),vn.subVectors(pn,mn);let t=[0,-gn.z,gn.y,0,-_n.z,_n.y,0,-vn.z,vn.y,gn.z,0,-gn.x,_n.z,0,-_n.x,vn.z,0,-vn.x,-gn.y,gn.x,0,-_n.y,_n.x,0,-vn.y,vn.x,0];return!!wn(t,pn,fn,mn,xn)&&(t=[1,0,0,0,1,0,0,0,1],!!wn(t,pn,fn,mn,xn)&&(bn.crossVectors(gn,_n),t=[bn.x,bn.y,bn.z],wn(t,pn,fn,mn,xn)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(hn).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()||(An[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),An[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),An[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),An[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),An[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),An[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),An[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),An[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(An)),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)}}const An=[new on,new on,new on,new on,new on,new on,new on,new on],hn=new on,dn=new cn,pn=new on,fn=new on,mn=new on,gn=new on,_n=new on,vn=new on,yn=new on,xn=new on,bn=new on,Sn=new on;function wn(e,t,n,r,i){for(let s=0,a=e.length-3;s<=a;s+=3){Sn.fromArray(e,s);const a=i.x*Math.abs(Sn.x)+i.y*Math.abs(Sn.y)+i.z*Math.abs(Sn.z),o=t.dot(Sn),l=n.dot(Sn),u=r.dot(Sn);if(Math.max(-Math.max(o,l,u),Math.min(o,l,u))>a)return!1}return!0}const Tn=new cn,Mn=new on,En=new on;class Cn{constructor(e=new on,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):Tn.setFromPoints(e).getCenter(n);let r=0;for(let t=0,i=e.length;tthis.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;Mn.subVectors(e,this.center);const t=Mn.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(Mn,n/e),this.radius+=n}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):(En.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mn.copy(e.center).add(En)),this.expandByPoint(Mn.copy(e.center).sub(En))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Rn=new on,Nn=new on,Pn=new on,Dn=new on,Ln=new on,In=new on,Un=new on;class Bn{constructor(e=new on,t=new on(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,Rn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Rn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Rn.copy(this.origin).addScaledVector(this.direction,t),Rn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Nn.copy(e).add(t).multiplyScalar(.5),Pn.copy(t).sub(e).normalize(),Dn.copy(this.origin).sub(Nn);const i=.5*e.distanceTo(t),s=-this.direction.dot(Pn),a=Dn.dot(this.direction),o=-Dn.dot(Pn),l=Dn.lengthSq(),u=Math.abs(1-s*s);let c,A,h,d;if(u>0)if(c=s*o-a,A=s*a-o,d=i*u,c>=0)if(A>=-d)if(A<=d){const e=1/u;c*=e,A*=e,h=c*(c+s*A+2*a)+A*(s*c+A+2*o)+l}else A=i,c=Math.max(0,-(s*A+a)),h=-c*c+A*(A+2*o)+l;else A=-i,c=Math.max(0,-(s*A+a)),h=-c*c+A*(A+2*o)+l;else A<=-d?(c=Math.max(0,-(-s*i+a)),A=c>0?-i:Math.min(Math.max(-i,-o),i),h=-c*c+A*(A+2*o)+l):A<=d?(c=0,A=Math.min(Math.max(-i,-o),i),h=A*(A+2*o)+l):(c=Math.max(0,-(s*i+a)),A=c>0?i:Math.min(Math.max(-i,-o),i),h=-c*c+A*(A+2*o)+l);else A=s>0?-i:i,c=Math.max(0,-(s*A+a)),h=-c*c+A*(A+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,c),r&&r.copy(Nn).addScaledVector(Pn,A),h}intersectSphere(e,t){Rn.subVectors(e.center,this.origin);const n=Rn.dot(this.direction),r=Rn.dot(Rn)-n*n,i=e.radius*e.radius;if(r>i)return null;const s=Math.sqrt(i-r),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return 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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,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 n,r,i,s,a,o;const l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,A=this.origin;return l>=0?(n=(e.min.x-A.x)*l,r=(e.max.x-A.x)*l):(n=(e.max.x-A.x)*l,r=(e.min.x-A.x)*l),u>=0?(i=(e.min.y-A.y)*u,s=(e.max.y-A.y)*u):(i=(e.max.y-A.y)*u,s=(e.min.y-A.y)*u),n>s||i>r?null:((i>n||isNaN(n))&&(n=i),(s=0?(a=(e.min.z-A.z)*c,o=(e.max.z-A.z)*c):(a=(e.max.z-A.z)*c,o=(e.min.z-A.z)*c),n>o||a>r?null:((a>n||n!=n)&&(n=a),(o=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,Rn)}intersectTriangle(e,t,n,r,i){Ln.subVectors(t,e),In.subVectors(n,e),Un.crossVectors(Ln,In);let s,a=this.direction.dot(Un);if(a>0){if(r)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Dn.subVectors(this.origin,e);const o=s*this.direction.dot(In.crossVectors(Dn,In));if(o<0)return null;const l=s*this.direction.dot(Ln.cross(Dn));if(l<0)return null;if(o+l>a)return null;const u=-s*Dn.dot(Un);return u<0?null:this.at(u/a,i)}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 On{constructor(e,t,n,r,i,s,a,o,l,u,c,A,h,d,p,f){On.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,r,i,s,a,o,l,u,c,A,h,d,p,f)}set(e,t,n,r,i,s,a,o,l,u,c,A,h,d,p,f){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=r,m[1]=i,m[5]=s,m[9]=a,m[13]=o,m[2]=l,m[6]=u,m[10]=c,m[14]=A,m[3]=h,m[7]=d,m[11]=p,m[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new On).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/Fn.setFromMatrixColumn(e,0).length(),i=1/Fn.setFromMatrixColumn(e,1).length(),s=1/Fn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(r),l=Math.sin(r),u=Math.cos(i),c=Math.sin(i);if("XYZ"===e.order){const e=s*u,n=s*c,r=a*u,i=a*c;t[0]=o*u,t[4]=-o*c,t[8]=l,t[1]=n+r*l,t[5]=e-i*l,t[9]=-a*o,t[2]=i-e*l,t[6]=r+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*u,n=o*c,r=l*u,i=l*c;t[0]=e+i*a,t[4]=r*a-n,t[8]=s*l,t[1]=s*c,t[5]=s*u,t[9]=-a,t[2]=n*a-r,t[6]=i+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*u,n=o*c,r=l*u,i=l*c;t[0]=e-i*a,t[4]=-s*c,t[8]=r+n*a,t[1]=n+r*a,t[5]=s*u,t[9]=i-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*u,n=s*c,r=a*u,i=a*c;t[0]=o*u,t[4]=r*l-n,t[8]=e*l+i,t[1]=o*c,t[5]=i*l+e,t[9]=n*l-r,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,r=a*o,i=a*l;t[0]=o*u,t[4]=i-e*c,t[8]=r*c+n,t[1]=c,t[5]=s*u,t[9]=-a*u,t[2]=-l*u,t[6]=n*c+r,t[10]=e-i*c}else if("XZY"===e.order){const e=s*o,n=s*l,r=a*o,i=a*l;t[0]=o*u,t[4]=-c,t[8]=l*u,t[1]=e*c+i,t[5]=s*u,t[9]=n*c-r,t[2]=r*c-n,t[6]=a*u,t[10]=i*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(qn,e,Gn)}lookAt(e,t,n){const r=this.elements;return Hn.subVectors(e,t),0===Hn.lengthSq()&&(Hn.z=1),Hn.normalize(),zn.crossVectors(n,Hn),0===zn.lengthSq()&&(1===Math.abs(n.z)?Hn.x+=1e-4:Hn.z+=1e-4,Hn.normalize(),zn.crossVectors(n,Hn)),zn.normalize(),Vn.crossVectors(Hn,zn),r[0]=zn.x,r[4]=Vn.x,r[8]=Hn.x,r[1]=zn.y,r[5]=Vn.y,r[9]=Hn.y,r[2]=zn.z,r[6]=Vn.z,r[10]=Hn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],u=n[1],c=n[5],A=n[9],h=n[13],d=n[2],p=n[6],f=n[10],m=n[14],g=n[3],_=n[7],v=n[11],y=n[15],x=r[0],b=r[4],S=r[8],w=r[12],T=r[1],M=r[5],E=r[9],C=r[13],R=r[2],N=r[6],P=r[10],D=r[14],L=r[3],I=r[7],U=r[11],B=r[15];return i[0]=s*x+a*T+o*R+l*L,i[4]=s*b+a*M+o*N+l*I,i[8]=s*S+a*E+o*P+l*U,i[12]=s*w+a*C+o*D+l*B,i[1]=u*x+c*T+A*R+h*L,i[5]=u*b+c*M+A*N+h*I,i[9]=u*S+c*E+A*P+h*U,i[13]=u*w+c*C+A*D+h*B,i[2]=d*x+p*T+f*R+m*L,i[6]=d*b+p*M+f*N+m*I,i[10]=d*S+p*E+f*P+m*U,i[14]=d*w+p*C+f*D+m*B,i[3]=g*x+_*T+v*R+y*L,i[7]=g*b+_*M+v*N+y*I,i[11]=g*S+_*E+v*P+y*U,i[15]=g*w+_*C+v*D+y*B,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],s=e[1],a=e[5],o=e[9],l=e[13],u=e[2],c=e[6],A=e[10],h=e[14];return e[3]*(+i*o*c-r*l*c-i*a*A+n*l*A+r*a*h-n*o*h)+e[7]*(+t*o*h-t*l*A+i*s*A-r*s*h+r*l*u-i*o*u)+e[11]*(+t*l*c-t*a*h-i*s*c+n*s*h+i*a*u-n*l*u)+e[15]*(-r*a*u-t*o*c+t*a*A+r*s*c-n*s*A+n*o*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],a=e[5],o=e[6],l=e[7],u=e[8],c=e[9],A=e[10],h=e[11],d=e[12],p=e[13],f=e[14],m=e[15],g=c*f*l-p*A*l+p*o*h-a*f*h-c*o*m+a*A*m,_=d*A*l-u*f*l-d*o*h+s*f*h+u*o*m-s*A*m,v=u*p*l-d*c*l+d*a*h-s*p*h-u*a*m+s*c*m,y=d*c*o-u*p*o-d*a*A+s*p*A+u*a*f-s*c*f,x=t*g+n*_+r*v+i*y;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/x;return e[0]=g*b,e[1]=(p*A*i-c*f*i-p*r*h+n*f*h+c*r*m-n*A*m)*b,e[2]=(a*f*i-p*o*i+p*r*l-n*f*l-a*r*m+n*o*m)*b,e[3]=(c*o*i-a*A*i-c*r*l+n*A*l+a*r*h-n*o*h)*b,e[4]=_*b,e[5]=(u*f*i-d*A*i+d*r*h-t*f*h-u*r*m+t*A*m)*b,e[6]=(d*o*i-s*f*i-d*r*l+t*f*l+s*r*m-t*o*m)*b,e[7]=(s*A*i-u*o*i+u*r*l-t*A*l-s*r*h+t*o*h)*b,e[8]=v*b,e[9]=(d*c*i-u*p*i-d*n*h+t*p*h+u*n*m-t*c*m)*b,e[10]=(s*p*i-d*a*i+d*n*l-t*p*l-s*n*m+t*a*m)*b,e[11]=(u*a*i-s*c*i-u*n*l+t*c*l+s*n*h-t*a*h)*b,e[12]=y*b,e[13]=(u*p*r-d*c*r+d*n*A-t*p*A-u*n*f+t*c*f)*b,e[14]=(d*a*r-s*p*r-d*n*o+t*p*o+s*n*f-t*a*f)*b,e[15]=(s*c*r-u*a*r+u*n*o-t*c*o-s*n*A+t*a*A)*b,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),i=1-n,s=e.x,a=e.y,o=e.z,l=i*s,u=i*a;return this.set(l*s+n,l*a-r*o,l*o+r*a,0,l*a+r*o,u*a+n,u*o-r*s,0,l*o-r*a,u*o+r*s,i*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,s){return this.set(1,n,i,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,s=t._y,a=t._z,o=t._w,l=i+i,u=s+s,c=a+a,A=i*l,h=i*u,d=i*c,p=s*u,f=s*c,m=a*c,g=o*l,_=o*u,v=o*c,y=n.x,x=n.y,b=n.z;return r[0]=(1-(p+m))*y,r[1]=(h+v)*y,r[2]=(d-_)*y,r[3]=0,r[4]=(h-v)*x,r[5]=(1-(A+m))*x,r[6]=(f+g)*x,r[7]=0,r[8]=(d+_)*b,r[9]=(f-g)*b,r[10]=(1-(A+p))*b,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=Fn.set(r[0],r[1],r[2]).length();const s=Fn.set(r[4],r[5],r[6]).length(),a=Fn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],kn.copy(this);const o=1/i,l=1/s,u=1/a;return kn.elements[0]*=o,kn.elements[1]*=o,kn.elements[2]*=o,kn.elements[4]*=l,kn.elements[5]*=l,kn.elements[6]*=l,kn.elements[8]*=u,kn.elements[9]*=u,kn.elements[10]*=u,t.setFromRotationMatrix(kn),n.x=i,n.y=s,n.z=a,this}makePerspective(e,t,n,r,i,s,a=2e3){const o=this.elements,l=2*i/(t-e),u=2*i/(n-r),c=(t+e)/(t-e),A=(n+r)/(n-r);let h,d;if(a===vt)h=-(s+i)/(s-i),d=-2*s*i/(s-i);else{if(a!==yt)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);h=-s/(s-i),d=-s*i/(s-i)}return o[0]=l,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=u,o[9]=A,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,r,i,s,a=2e3){const o=this.elements,l=1/(t-e),u=1/(n-r),c=1/(s-i),A=(t+e)*l,h=(n+r)*u;let d,p;if(a===vt)d=(s+i)*c,p=-2*c;else{if(a!==yt)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);d=i*c,p=-1*c}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-A,o[1]=0,o[5]=2*u,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=p,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Fn=new on,kn=new On,qn=new on(0,0,0),Gn=new on(1,1,1),zn=new on,Vn=new on,Hn=new on,jn=new On,Wn=new an;class Xn{constructor(e=0,t=0,n=0,r=Xn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,i=r[0],s=r[4],a=r[8],o=r[1],l=r[5],u=r[9],c=r[2],A=r[6],h=r[10];switch(t){case"XYZ":this._y=Math.asin(Et(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,h),this._z=Math.atan2(-s,i)):(this._x=Math.atan2(A,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Et(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,h),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin(Et(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(-c,h),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,i));break;case"ZYX":this._y=Math.asin(-Et(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(A,h),this._z=Math.atan2(o,i)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Et(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(a,h));break;case"XZY":this._z=Math.asin(-Et(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(A,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-u,h),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return jn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(jn,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Wn.setFromEuler(this),this.setFromQuaternion(Wn,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Xn.DEFAULT_ORDER="XYZ";class Qn{constructor(){this.mask=1}set(e){this.mask=1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),null!==this._colorsTexture&&(r.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),null!==this.boundingBox&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),u.length>0&&(n.animations=u),c.length>0&&(n.nodes=c)}return n.object=r,n;function s(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Ar.subVectors(r,t),hr.subVectors(n,t),dr.subVectors(e,t);const s=Ar.dot(Ar),a=Ar.dot(hr),o=Ar.dot(dr),l=hr.dot(hr),u=hr.dot(dr),c=s*l-a*a;if(0===c)return i.set(0,0,0),null;const A=1/c,h=(l*o-a*u)*A,d=(s*u-a*o)*A;return i.set(1-h-d,d,h)}static containsPoint(e,t,n,r){return null!==this.getBarycoord(e,t,n,r,pr)&&(pr.x>=0&&pr.y>=0&&pr.x+pr.y<=1)}static getInterpolation(e,t,n,r,i,s,a,o){return null===this.getBarycoord(e,t,n,r,pr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(i,pr.x),o.addScaledVector(s,pr.y),o.addScaledVector(a,pr.z),o)}static getInterpolatedAttribute(e,t,n,r,i,s){return xr.setScalar(0),br.setScalar(0),Sr.setScalar(0),xr.fromBufferAttribute(e,t),br.fromBufferAttribute(e,n),Sr.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(xr,i.x),s.addScaledVector(br,i.y),s.addScaledVector(Sr,i.z),s}static isFrontFacing(e,t,n,r){return Ar.subVectors(n,t),hr.subVectors(e,t),Ar.cross(hr).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 Ar.subVectors(this.c,this.b),hr.subVectors(this.a,this.b),.5*Ar.cross(hr).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return wr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return wr.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,i){return wr.getInterpolation(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return wr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return wr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,i=this.c;let s,a;fr.subVectors(r,n),mr.subVectors(i,n),_r.subVectors(e,n);const o=fr.dot(_r),l=mr.dot(_r);if(o<=0&&l<=0)return t.copy(n);vr.subVectors(e,r);const u=fr.dot(vr),c=mr.dot(vr);if(u>=0&&c<=u)return t.copy(r);const A=o*c-u*l;if(A<=0&&o>=0&&u<=0)return s=o/(o-u),t.copy(n).addScaledVector(fr,s);yr.subVectors(e,i);const h=fr.dot(yr),d=mr.dot(yr);if(d>=0&&h<=d)return t.copy(i);const p=h*l-o*d;if(p<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(n).addScaledVector(mr,a);const f=u*d-h*c;if(f<=0&&c-u>=0&&h-d>=0)return gr.subVectors(i,r),a=(c-u)/(c-u+(h-d)),t.copy(r).addScaledVector(gr,a);const m=1/(f+p+A);return s=p*m,a=A*m,t.copy(n).addScaledVector(fr,s).addScaledVector(mr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Tr={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},Mr={h:0,s:0,l:0},Er={h:0,s:0,l:0};function Cr(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}let Rr=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=rt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Ht.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Ht.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ht.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Ht.workingColorSpace){if(e=Ct(e,1),t=Et(t,0,1),n=Et(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Cr(i,r,e+1/3),this.g=Cr(i,r,e),this.b=Cr(i,r,e-1/3)}return Ht.toWorkingColorSpace(this,r),this}setStyle(e,t=rt){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const s=r[1],a=r[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=r[1],i=n.length;if(3===i)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===i)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=rt){const n=Tr[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=jt(e.r),this.g=jt(e.g),this.b=jt(e.b),this}copyLinearToSRGB(e){return this.r=Wt(e.r),this.g=Wt(e.g),this.b=Wt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=rt){return Ht.fromWorkingColorSpace(Nr.copy(this),e),65536*Math.round(Et(255*Nr.r,0,255))+256*Math.round(Et(255*Nr.g,0,255))+Math.round(Et(255*Nr.b,0,255))}getHexString(e=rt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ht.workingColorSpace){Ht.fromWorkingColorSpace(Nr.copy(this),t);const n=Nr.r,r=Nr.g,i=Nr.b,s=Math.max(n,r,i),a=Math.min(n,r,i);let o,l;const u=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=u<=.5?e/(s+a):e/(2-s-a),s){case n:o=(r-i)/e+(r0!=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 n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==x&&(n.blendSrc=this.blendSrc),this.blendDst!==b&&(n.blendDst=this.blendDst),this.blendEquation!==p&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ot&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ot&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ot&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}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 n=null;if(null!==t){const e=t.length;n=new Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Lr extends Dr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Rr(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 Xn,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 Ir=Ur();function Ur(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(r[e]=0,r[256|e]=32768,i[e]=24,i[256|e]=24):t<-14?(r[e]=1024>>-t-14,r[256|e]=1024>>-t-14|32768,i[e]=-t-1,i[256|e]=-t-1):t<=15?(r[e]=t+15<<10,r[256|e]=t+15<<10|32768,i[e]=13,i[256|e]=13):t<128?(r[e]=31744,r[256|e]=64512,i[e]=24,i[256|e]=24):(r[e]=31744,r[256|e]=64512,i[e]=13,i[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,n=0;for(;!(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,s[e]=t|n}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:n,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function Br(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Et(e,-65504,65504),Ir.floatView[0]=e;const t=Ir.uint32View[0],n=t>>23&511;return Ir.baseTable[n]+((8388607&t)>>Ir.shiftTable[n])}function Or(e){const t=e>>10;return Ir.uint32View[0]=Ir.mantissaTable[Ir.offsetTable[t]+(1023&e)]+Ir.exponentTable[t],Ir.floatView[0]}const Fr=new on,kr=new Lt;class qr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=mt,this.updateRanges=[],this.gpuType=ae,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;rt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new cn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new on(-1/0,-1/0,-1/0),new on(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);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 n=this.attributes;for(const t in n){const r=n[t];e.data.attributes[t]=r.toJSON(e.data)}const r={};let i=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],s=[];for(let t=0,r=n.length;t0&&(r[t]=s,i=!0)}i&&(e.data.morphAttributes=r,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={center:a.center.toArray(),radius:a.radius}),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 n=e.index;null!==n&&this.setIndex(n.clone(t));const r=e.attributes;for(const e in r){const n=r[e];this.setAttribute(e,n.clone(t))}const i=e.morphAttributes;for(const e in i){const n=[],r=i[e];for(let e=0,i=r.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}Jr.copy(i).invert(),ei.copy(e.ray).applyMatrix4(Jr),null!==n.boundingBox&&!1===ei.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,ei)}}_computeIntersections(e,t,n){let r;const i=this.geometry,s=this.material,a=i.index,o=i.attributes.position,l=i.attributes.uv,u=i.attributes.uv1,c=i.attributes.normal,A=i.groups,h=i.drawRange;if(null!==a)if(Array.isArray(s))for(let i=0,o=A.length;in.far?null:{distance:u,point:ui.clone(),object:e}}(e,t,n,r,ri,ii,si,li);if(c){const e=new on;wr.getBarycoord(li,ri,ii,si,e),i&&(c.uv=wr.getInterpolatedAttribute(i,o,l,u,e,new Lt)),s&&(c.uv1=wr.getInterpolatedAttribute(s,o,l,u,e,new Lt)),a&&(c.normal=wr.getInterpolatedAttribute(a,o,l,u,e,new on),c.normal.dot(r.direction)>0&&c.normal.multiplyScalar(-1));const t={a:o,b:l,c:u,normal:new on,materialIndex:0};wr.getNormal(ri,ii,si,t.normal),c.face=t,c.barycoord=e}return c}class hi extends Zr{constructor(e=1,t=1,n=1,r=1,i=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:s};const a=this;r=Math.floor(r),i=Math.floor(i),s=Math.floor(s);const o=[],l=[],u=[],c=[];let A=0,h=0;function d(e,t,n,r,i,s,d,p,f,m,g){const _=s/f,v=d/m,y=s/2,x=d/2,b=p/2,S=f+1,w=m+1;let T=0,M=0;const E=new on;for(let s=0;s0?1:-1,u.push(E.x,E.y,E.z),c.push(o/f),c.push(1-s/m),T+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class _i extends cr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new On,this.projectionMatrix=new On,this.projectionMatrixInverse=new On,this.coordinateSystem=vt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const vi=new on,yi=new Lt,xi=new Lt;class bi extends _i{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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*Tt*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*wt*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Tt*Math.atan(Math.tan(.5*wt*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,n){vi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(vi.x,vi.y).multiplyScalar(-e/vi.z),vi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(vi.x,vi.y).multiplyScalar(-e/vi.z)}getViewSize(e,t){return this.getViewBounds(e,yi,xi),t.subVectors(xi,yi)}setViewOffset(e,t,n,r,i,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=n,this.view.offsetY=r,this.view.width=i,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*wt*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;i+=s.offsetX*r/e,t-=s.offsetY*n/a,r*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(i+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Si=-90;class wi extends cr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new bi(Si,1,e,t);r.layers=this.layers,this.add(r);const i=new bi(Si,1,e,t);i.layers=this.layers,this.add(i);const s=new bi(Si,1,e,t);s.layers=this.layers,this.add(s);const a=new bi(Si,1,e,t);a.layers=this.layers,this.add(a);const o=new bi(Si,1,e,t);o.layers=this.layers,this.add(o);const l=new bi(Si,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,i,s,a,o]=t;for(const e of t)this.remove(e);if(e===vt)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.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!==yt)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.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:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,s,a,o,l,u]=this.children,c=e.getRenderTarget(),A=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;const p=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,i),e.setRenderTarget(n,1,r),e.render(t,s),e.setRenderTarget(n,2,r),e.render(t,a),e.setRenderTarget(n,3,r),e.render(t,o),e.setRenderTarget(n,4,r),e.render(t,l),n.texture.generateMipmaps=p,e.setRenderTarget(n,5,r),e.render(t,u),e.setRenderTarget(c,A,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Ti extends Jt{constructor(e,t,n,r,i,s,a,o,l,u){super(e=void 0!==e?e:[],t=void 0!==t?t:q,n,r,i,s,a,o,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Mi extends nn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Ti(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:K}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},r=new hi(5,5,5),i=new gi({name:"CubemapFromEquirect",uniforms:di(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;const s=new ci(r,i),a=t.minFilter;t.minFilter===J&&(t.minFilter=K);return new wi(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,n,r){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}}class Ei extends cr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Xn,this.environmentIntensity=1,this.environmentRotation=new Xn,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Ci{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=mt,this.updateRanges=[],this.version=0,this.uuid=Mt()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||Bi.getNormalMatrix(e),r=this.coplanarPoint(Ii).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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 Fi=new Cn,ki=new on;class qi{constructor(e=new Oi,t=new Oi,n=new Oi,r=new Oi,i=new Oi,s=new Oi){this.planes=[e,t,n,r,i,s]}set(e,t,n,r,i,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,r=e.elements,i=r[0],s=r[1],a=r[2],o=r[3],l=r[4],u=r[5],c=r[6],A=r[7],h=r[8],d=r[9],p=r[10],f=r[11],m=r[12],g=r[13],_=r[14],v=r[15];if(n[0].setComponents(o-i,A-l,f-h,v-m).normalize(),n[1].setComponents(o+i,A+l,f+h,v+m).normalize(),n[2].setComponents(o+s,A+u,f+d,v+g).normalize(),n[3].setComponents(o-s,A-u,f-d,v-g).normalize(),n[4].setComponents(o-a,A-c,f-p,v-_).normalize(),t===vt)n[5].setComponents(o+a,A+c,f+p,v+_).normalize();else{if(t!==yt)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,c,p,_).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Fi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Fi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Fi)}intersectsSprite(e){return Fi.center.set(0,0,0),Fi.radius=.7071067811865476,Fi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Fi)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,ki.y=r.normal.y>0?e.max.y:e.min.y,ki.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ki)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}class Gi extends Dr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Rr(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const zi=new on,Vi=new on,Hi=new On,ji=new Bn,Wi=new Cn,Xi=new on,Qi=new on;class Yi extends cr{constructor(e=new Zr,t=new Gi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,r=t.count;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;Xi.applyMatrix4(e.matrixWorld);const o=t.ray.origin.distanceTo(Xi);return ot.far?void 0:{distance:o,point:Qi.clone().applyMatrix4(e.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:e}}const Ki=new on,Zi=new on;class Ji extends Yi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,r=t.count;ei.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}let as=class extends cr{constructor(){super(),this.isGroup=!0,this.type="Group"}};class os extends Jt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Q,this.minFilter=Q,this.generateMipmaps=!1,this.needsUpdate=!0}}class ls extends Jt{constructor(e,t,n,r,i,s,a,o,l,u=1026){if(u!==ge&&u!==_e)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&u===ge&&(n=se),void 0===n&&u===_e&&(n=ce),super(null,r,i,s,a,o,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:Q,this.minFilter=void 0!==o?o:Q,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class us{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),i=0;t.push(0);for(let s=1;s<=e;s++)n=this.getPoint(s/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const i=n.length;let s;s=t||e*n[i-1];let a,o=0,l=i-1;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),a=n[r]-s,a<0)o=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(r=l,n[r]===s)return r/(i-1);const u=n[r];return(r+(s-u)/(n[r+1]-u))/(i-1)}getTangent(e,t){const n=1e-4;let r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);const s=this.getPoint(r),a=this.getPoint(i),o=t||(s.isVector2?new Lt:new on);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new on,r=[],i=[],s=[],a=new on,o=new On;for(let t=0;t<=e;t++){const n=t/e;r[t]=this.getTangentAt(n,new on)}i[0]=new on,s[0]=new on;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),c=Math.abs(r[0].y),A=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),A<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],a),s[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(r[t-1],r[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Et(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(Et(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(a.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(o.makeRotationAxis(r[n],t*n)),s[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class cs extends us{constructor(e=0,t=0,n=1,r=1,i=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t=new Lt){const n=t,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const s=Math.abs(i)r;)i-=r;ir.length-2?r.length-1:s+1],c=r[s>r.length-3?r.length-1:s+2];return n.set(ms(a,o.x,l.x,u.x,c.x),ms(a,o.y,l.y,u.y,c.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===u&&l===i-1&&(l=i-2,u=1),this.closed||l>0?a=r[(l-1)%i]:(hs.subVectors(r[0],r[1]).add(r[0]),a=hs);const c=r[l%i],A=r[(l+1)%i];if(this.closed||l+2=n){const e=r[i]-n,s=this.curves[i],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class Cs extends Zr{constructor(e=1,t=32,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const i=[],s=[],a=[],o=[],l=new on,u=new Lt;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let i=0,c=3;i<=t;i++,c+=3){const A=n+i/t*r;l.x=e*Math.cos(A),l.y=e*Math.sin(A),s.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(s[c]/e+1)/2,u.y=(s[c+1]/e+1)/2,o.push(u.x,u.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute("position",new Hr(s,3)),this.setAttribute("normal",new Hr(a,3)),this.setAttribute("uv",new Hr(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cs(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Rs extends Zr{constructor(e=1,t=1,n=1,r=32,i=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o};const l=this;r=Math.floor(r),i=Math.floor(i);const u=[],c=[],A=[],h=[];let d=0;const p=[],f=n/2;let m=0;function g(n){const i=d,s=new Lt,p=new on;let g=0;const _=!0===n?e:t,v=!0===n?1:-1;for(let e=1;e<=r;e++)c.push(0,f*v,0),A.push(0,v,0),h.push(.5,.5),d++;const y=d;for(let e=0;e<=r;e++){const t=e/r*o+a,n=Math.cos(t),i=Math.sin(t);p.x=_*i,p.y=f*v,p.z=_*n,c.push(p.x,p.y,p.z),A.push(0,v,0),s.x=.5*n+.5,s.y=.5*i*v+.5,h.push(s.x,s.y),d++}for(let e=0;e0||0!==r)&&(u.push(s,a,l),_+=3),(t>0||r!==i-1)&&(u.push(a,o,l),_+=3)}l.addGroup(m,_,0),m+=_}(),!1===s&&(e>0&&g(!0),t>0&&g(!1)),this.setIndex(u),this.setAttribute("position",new Hr(c,3)),this.setAttribute("normal",new Hr(A,3)),this.setAttribute("uv",new Hr(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rs(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ns extends Es{constructor(e){super(e),this.uuid=Mt(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n80*n){o=u=e[0],l=c=e[1];for(let t=n;tu&&(u=A),h>c&&(c=h);d=Math.max(u-o,c-l),d=0!==d?32767/d:0}return Is(s,a,n,o,l,d,0),a};function Ds(e,t,n,r,i){let s,a;if(i===function(e,t,n,r){let i=0;for(let s=t,a=n-r;s0)for(s=t;s=t;s-=r)a=Js(s,e[s],e[s+1],a);return a&&Xs(a,a.next)&&(ea(a),a=a.next),a}function Ls(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!Xs(r,r.next)&&0!==Ws(r.prev,r,r.next))r=r.next;else{if(ea(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function Is(e,t,n,r,i,s,a){if(!e)return;!a&&s&&function(e,t,n,r){let i=e;do{0===i.z&&(i.z=zs(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n,r,i,s,a,o,l,u=1;do{for(n=e,e=null,s=null,a=0;n;){for(a++,r=n,o=0,t=0;t0||l>0&&r;)0!==o&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,o--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;n=r}s.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,s);let o,l,u=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,s?Bs(e,r,i,s):Us(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),ea(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?Is(e=Os(Ls(e),t,n),t,n,r,i,s,2):2===a&&Fs(e,t,n,r,i,s):Is(Ls(e),t,n,r,i,s,1);break}}function Us(e){const t=e.prev,n=e,r=e.next;if(Ws(t,n,r)>=0)return!1;const i=t.x,s=n.x,a=r.x,o=t.y,l=n.y,u=r.y,c=is?i>a?i:a:s>a?s:a,d=o>l?o>u?o:u:l>u?l:u;let p=r.next;for(;p!==t;){if(p.x>=c&&p.x<=h&&p.y>=A&&p.y<=d&&Hs(i,o,s,l,a,u,p.x,p.y)&&Ws(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Bs(e,t,n,r){const i=e.prev,s=e,a=e.next;if(Ws(i,s,a)>=0)return!1;const o=i.x,l=s.x,u=a.x,c=i.y,A=s.y,h=a.y,d=ol?o>u?o:u:l>u?l:u,m=c>A?c>h?c:h:A>h?A:h,g=zs(d,p,t,n,r),_=zs(f,m,t,n,r);let v=e.prevZ,y=e.nextZ;for(;v&&v.z>=g&&y&&y.z<=_;){if(v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==i&&v!==a&&Hs(o,c,l,A,u,h,v.x,v.y)&&Ws(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==i&&y!==a&&Hs(o,c,l,A,u,h,y.x,y.y)&&Ws(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;v&&v.z>=g;){if(v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==i&&v!==a&&Hs(o,c,l,A,u,h,v.x,v.y)&&Ws(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;y&&y.z<=_;){if(y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==i&&y!==a&&Hs(o,c,l,A,u,h,y.x,y.y)&&Ws(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Os(e,t,n){let r=e;do{const i=r.prev,s=r.next.next;!Xs(i,s)&&Qs(i,r,r.next,s)&&Ks(i,s)&&Ks(s,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(s.i/n|0),ea(r),ea(r.next),r=e=s),r=r.next}while(r!==e);return Ls(r)}function Fs(e,t,n,r,i,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&js(a,e)){let o=Zs(a,e);return a=Ls(a,a.next),o=Ls(o,o.next),Is(a,t,n,r,i,s,0),void Is(o,t,n,r,i,s,0)}e=e.next}a=a.next}while(a!==e)}function ks(e,t){return e.x-t.x}function qs(e,t){const n=function(e,t){let n,r=t,i=-1/0;const s=e.x,a=e.y;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){const e=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=s&&e>i&&(i=e,n=r.x=r.x&&r.x>=l&&s!==r.x&&Hs(an.x||r.x===n.x&&Gs(n,r)))&&(n=r,A=c)),r=r.next}while(r!==o);return n}(e,t);if(!n)return t;const r=Zs(n,e);return Ls(r,r.next),Ls(n,n.next)}function Gs(e,t){return Ws(e.prev,e,t.prev)<0&&Ws(t.next,e,e.next)<0}function zs(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Vs(e){let t=e,n=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(r-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(i-a)*(r-o)}function js(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Qs(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Ks(e,t)&&Ks(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Ws(e.prev,e,t.prev)||Ws(e,t.prev,t))||Xs(e,t)&&Ws(e.prev,e,e.next)>0&&Ws(t.prev,t,t.next)>0)}function Ws(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Xs(e,t){return e.x===t.x&&e.y===t.y}function Qs(e,t,n,r){const i=$s(Ws(e,t,n)),s=$s(Ws(e,t,r)),a=$s(Ws(n,r,e)),o=$s(Ws(n,r,t));return i!==s&&a!==o||(!(0!==i||!Ys(e,n,t))||(!(0!==s||!Ys(e,r,t))||(!(0!==a||!Ys(n,e,r))||!(0!==o||!Ys(n,t,r)))))}function Ys(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function $s(e){return e>0?1:e<0?-1:0}function Ks(e,t){return Ws(e.prev,e,e.next)<0?Ws(e,t,e.next)>=0&&Ws(e,e.prev,t)>=0:Ws(e,t,e.prev)<0||Ws(e,e.next,t)<0}function Zs(e,t){const n=new ta(e.i,e.x,e.y),r=new ta(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function Js(e,t,n,r){const i=new ta(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function ea(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 ta(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class na{static area(e){const t=e.length;let n=0;for(let r=t-1,i=0;i2&&e[t-1].equals(e[0])&&e.pop()}function ia(e,t){for(let n=0;nNumber.EPSILON){const A=Math.sqrt(c),h=Math.sqrt(l*l+u*u),d=t.x-o/A,p=t.y+a/A,f=((n.x-u/h-d)*u-(n.y+l/h-p)*l)/(a*u-o*l);r=d+a*f-e.x,i=p+o*f-e.y;const m=r*r+i*i;if(m<=2)return new Lt(r,i);s=Math.sqrt(m/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(u)&&(e=!0),e?(r=-o,i=a,s=Math.sqrt(c)):(r=a,i=o,s=Math.sqrt(c/2))}return new Lt(r/s,i/s)}const P=[];for(let e=0,t=M.length,n=t-1,r=e+1;e=0;e--){const t=e/d,n=c*Math.cos(t*Math.PI/2),r=A*Math.sin(t*Math.PI/2)+h;for(let e=0,t=M.length;e=0;){const r=n;let i=n-1;i<0&&(i=e.length-1);for(let e=0,n=o+2*d;e0)&&h.push(t,i,l),(e!==n-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 fa extends Dr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Rr(16777215),this.specular=new Rr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ma extends Dr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Rr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lt(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 ga extends Dr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lt(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 _a extends Dr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Rr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class va extends Dr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class ya extends Dr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class xa extends Dr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Rr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ba extends Gi{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}}const Sa={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class wa{constructor(e,t,n){const r=this;let i,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===s&&void 0!==r.onStart&&r.onStart(e,a,o),s=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,o),a===o&&(s=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;tNumber.EPSILON){if(l<0&&(n=t[s],o=-o,a=t[i],l=-l),e.ya.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return r}const n=na.isClockWise,r=this.subPaths;if(0===r.length)return[];let i,s,a;const o=[];if(1===r.length)return s=r[0],a=new Ns,a.curves=s.curves,o.push(a),o;let l=!n(r[0].getPoints());l=e?!l:l;const u=[],c=[];let A,h,d=[],p=0;c[p]=void 0,d[p]=[];for(let t=0,a=r.length;t1){let e=!1,n=0;for(let e=0,t=c.length;e0&&!1===e&&(d=u)}for(let e=0,t=c.length;ee.start-t.start));let t=0;for(let e=1;e 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},ho={common:{diffuse:{value:new Rr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new It},alphaMap:{value:null},alphaMapTransform:{value:new It},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new It}},envmap:{envMap:{value:null},envMapRotation:{value:new It},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new It}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new It}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new It},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new It},normalScale:{value:new Lt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new It},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new It}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new It}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new It}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Rr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Rr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new It},alphaTest:{value:0},uvTransform:{value:new It}},sprite:{diffuse:{value:new Rr(16777215)},opacity:{value:1},center:{value:new Lt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new It},alphaMap:{value:null},alphaMapTransform:{value:new It},alphaTest:{value:0}}},po={basic:{uniforms:pi([ho.common,ho.specularmap,ho.envmap,ho.aomap,ho.lightmap,ho.fog]),vertexShader:Ao.meshbasic_vert,fragmentShader:Ao.meshbasic_frag},lambert:{uniforms:pi([ho.common,ho.specularmap,ho.envmap,ho.aomap,ho.lightmap,ho.emissivemap,ho.bumpmap,ho.normalmap,ho.displacementmap,ho.fog,ho.lights,{emissive:{value:new Rr(0)}}]),vertexShader:Ao.meshlambert_vert,fragmentShader:Ao.meshlambert_frag},phong:{uniforms:pi([ho.common,ho.specularmap,ho.envmap,ho.aomap,ho.lightmap,ho.emissivemap,ho.bumpmap,ho.normalmap,ho.displacementmap,ho.fog,ho.lights,{emissive:{value:new Rr(0)},specular:{value:new Rr(1118481)},shininess:{value:30}}]),vertexShader:Ao.meshphong_vert,fragmentShader:Ao.meshphong_frag},standard:{uniforms:pi([ho.common,ho.envmap,ho.aomap,ho.lightmap,ho.emissivemap,ho.bumpmap,ho.normalmap,ho.displacementmap,ho.roughnessmap,ho.metalnessmap,ho.fog,ho.lights,{emissive:{value:new Rr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ao.meshphysical_vert,fragmentShader:Ao.meshphysical_frag},toon:{uniforms:pi([ho.common,ho.aomap,ho.lightmap,ho.emissivemap,ho.bumpmap,ho.normalmap,ho.displacementmap,ho.gradientmap,ho.fog,ho.lights,{emissive:{value:new Rr(0)}}]),vertexShader:Ao.meshtoon_vert,fragmentShader:Ao.meshtoon_frag},matcap:{uniforms:pi([ho.common,ho.bumpmap,ho.normalmap,ho.displacementmap,ho.fog,{matcap:{value:null}}]),vertexShader:Ao.meshmatcap_vert,fragmentShader:Ao.meshmatcap_frag},points:{uniforms:pi([ho.points,ho.fog]),vertexShader:Ao.points_vert,fragmentShader:Ao.points_frag},dashed:{uniforms:pi([ho.common,ho.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ao.linedashed_vert,fragmentShader:Ao.linedashed_frag},depth:{uniforms:pi([ho.common,ho.displacementmap]),vertexShader:Ao.depth_vert,fragmentShader:Ao.depth_frag},normal:{uniforms:pi([ho.common,ho.bumpmap,ho.normalmap,ho.displacementmap,{opacity:{value:1}}]),vertexShader:Ao.meshnormal_vert,fragmentShader:Ao.meshnormal_frag},sprite:{uniforms:pi([ho.sprite,ho.fog]),vertexShader:Ao.sprite_vert,fragmentShader:Ao.sprite_frag},background:{uniforms:{uvTransform:{value:new It},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ao.background_vert,fragmentShader:Ao.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new It}},vertexShader:Ao.backgroundCube_vert,fragmentShader:Ao.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ao.cube_vert,fragmentShader:Ao.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ao.equirect_vert,fragmentShader:Ao.equirect_frag},distanceRGBA:{uniforms:pi([ho.common,ho.displacementmap,{referencePosition:{value:new on},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ao.distanceRGBA_vert,fragmentShader:Ao.distanceRGBA_frag},shadow:{uniforms:pi([ho.lights,ho.fog,{color:{value:new Rr(0)},opacity:{value:1}}]),vertexShader:Ao.shadow_vert,fragmentShader:Ao.shadow_frag}};po.physical={uniforms:pi([po.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new It},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new It},clearcoatNormalScale:{value:new Lt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new It},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new It},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new It},sheen:{value:0},sheenColor:{value:new Rr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new It},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new It},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new It},transmissionSamplerSize:{value:new Lt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new It},attenuationDistance:{value:0},attenuationColor:{value:new Rr(0)},specularColor:{value:new Rr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new It},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new It},anisotropyVector:{value:new Lt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new It}}]),vertexShader:Ao.meshphysical_vert,fragmentShader:Ao.meshphysical_frag};const fo={r:0,b:0,g:0},mo=new Xn,go=new On;function _o(e,t,n,r,i,s,a){const o=new Rr(0);let l,u,c=!0===s?0:1,A=null,h=0,d=null;function p(e){let r=!0===e.isScene?e.background:null;if(r&&r.isTexture){r=(e.backgroundBlurriness>0?n:t).get(r)}return r}function f(t,n){t.getRGB(fo,fi(e)),r.buffers.color.setClear(fo.r,fo.g,fo.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),c=t,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,f(o,c)},render:function(t){let n=!1;const i=p(t);null===i?f(o,c):i&&i.isColor&&(f(i,1),n=!0);const s=e.xr.getEnvironmentBlendMode();"additive"===s?r.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&r.buffers.color.setClear(0,0,0,0,a),(e.autoClear||n)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const r=p(n);r&&(r.isCubeTexture||r.mapping===H)?(void 0===u&&(u=new ci(new hi(1,1,1),new gi({name:"BackgroundCubeMaterial",uniforms:di(po.backgroundCube.uniforms),vertexShader:po.backgroundCube.vertexShader,fragmentShader:po.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),mo.copy(n.backgroundRotation),mo.x*=-1,mo.y*=-1,mo.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(mo.y*=-1,mo.z*=-1),u.material.uniforms.envMap.value=r,u.material.uniforms.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,u.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(go.makeRotationFromEuler(mo)),u.material.toneMapped=Ht.getTransfer(r.colorSpace)!==at,A===r&&h===r.version&&d===e.toneMapping||(u.material.needsUpdate=!0,A=r,h=r.version,d=e.toneMapping),u.layers.enableAll(),t.unshift(u,u.geometry,u.material,0,0,null)):r&&r.isTexture&&(void 0===l&&(l=new ci(new oa(2,2),new gi({name:"BackgroundMaterial",uniforms:di(po.background.uniforms),vertexShader:po.background.vertexShader,fragmentShader:po.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=r,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=Ht.getTransfer(r.colorSpace)!==at,!0===r.matrixAutoUpdate&&r.updateMatrix(),l.material.uniforms.uvTransform.value.copy(r.matrix),A===r&&h===r.version&&d===e.toneMapping||(l.material.needsUpdate=!0,A=r,h=r.version,d=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==u&&(u.geometry.dispose(),u.material.dispose()),void 0!==l&&(l.geometry.dispose(),l.material.dispose())}}}function vo(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=u(null);let s=i,a=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function u(e){const t=[],r=[],i=[];for(let e=0;e=0){const n=i[t];let r=a[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===n)return!0;if(n.attribute!==r)return!0;if(r&&n.data!==r.data)return!0;o++}}return s.attributesNum!==o||s.index!==r}(n,f,l,m),g&&function(e,t,n,r){const i={},a=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){let n=a[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,o++}}s.attributes=i,s.attributesNum=o,s.index=r}(n,f,l,m),null!==m&&t.update(m,e.ELEMENT_ARRAY_BUFFER),(g||a)&&(a=!1,function(n,r,i,s){c();const a=s.attributes,o=i.getAttributes(),l=r.defaultAttributeValues;for(const r in o){const i=o[r];if(i.location>=0){let o=a[r];if(void 0===o&&("instanceMatrix"===r&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===r&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const r=o.normalized,a=o.itemSize,l=t.get(o);if(void 0===l)continue;const u=l.buffer,c=l.type,d=l.bytesPerElement,f=c===e.INT||c===e.UNSIGNED_INT||o.gpuType===ie;if(o.isInterleavedBufferAttribute){const t=o.data,l=t.stride,m=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,u=!0===n.reverseDepthBuffer&&t.has("EXT_clip_control"),c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),A=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:s,textureFormatReadable:function(t){return t===pe||r.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const i=n===oe&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==ee&&r.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==ae&&!i)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:u,maxTextures:c,maxVertexTextures:A,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:A>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function bo(e){const t=this;let n=null,r=0,i=!1,s=!1;const a=new Oi,o=new It,l={value:null,needsUpdate:!1};function u(e,n,r,i){const s=null!==e?e.length:0;let u=null;if(0!==s){if(u=l.value,!0!==i||null===u){const t=r+4*s,i=n.matrixWorldInverse;o.getNormalMatrix(i),(null===u||u.length0);t.numPlanes=r,t.numIntersection=0}();else{const e=s?0:r,t=4*e;let i=p.clippingState||null;l.value=i,i=u(A,o,t,c);for(let e=0;e!==t;++e)i[e]=n[e];p.clippingState=i,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function So(e){let t=new WeakMap;function n(e,t){return t===z?e.mapping=q:t===V&&(e.mapping=G),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const s=i.mapping;if(s===z||s===V){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const s=i.image;if(s&&s.height>0){const a=new Mi(s.height);return a.fromEquirectangularTexture(e,i),t.set(i,a),i.addEventListener("dispose",r),n(a.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}const wo=[.125,.215,.35,.446,.526,.582],To=20,Mo=new za,Eo=new Rr;let Co=null,Ro=0,No=0,Po=!1;const Do=(1+Math.sqrt(5))/2,Lo=1/Do,Io=[new on(-Do,Lo,0),new on(Do,Lo,0),new on(-Lo,0,Do),new on(Lo,0,Do),new on(0,Do,-Lo),new on(0,Do,Lo),new on(-1,1,-1),new on(1,1,-1),new on(-1,1,1),new on(1,1,1)];let Uo=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){Co=this._renderer.getRenderTarget(),Ro=this._renderer.getActiveCubeFace(),No=this._renderer.getActiveMipmapLevel(),Po=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=ko(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Fo(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=wo[a-e+4-1]:0===a&&(o=0),r.push(o);const l=1/(s-2),u=-l,c=1+l,A=[u,u,c,u,c,c,u,u,c,c,u,c],h=6,d=6,p=3,f=2,m=1,g=new Float32Array(p*d*h),_=new Float32Array(f*d*h),v=new Float32Array(m*d*h);for(let e=0;e2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];g.set(r,p*d*e),_.set(A,f*d*e);const i=[e,e,e,e,e,e];v.set(i,m*d*e)}const y=new Zr;y.setAttribute("position",new qr(g,p)),y.setAttribute("uv",new qr(_,f)),y.setAttribute("faceIndex",new qr(v,m)),t.push(y),i>4&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(To),i=new on(0,1,0),s=new gi({name:"SphericalGaussianBlur",defines:{n:To,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:qo(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(r,e,t)}return r}_compileMaterial(e){const t=new ci(this._lodPlanes[0],e);this._renderer.compile(t,Mo)}_sceneToCubeUV(e,t,n,r){const i=new bi(90,1,t,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,u=o.toneMapping;o.getClearColor(Eo),o.toneMapping=0,o.autoClear=!1;const c=new Lr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),A=new ci(new hi,c);let h=!1;const d=e.background;d?d.isColor&&(c.color.copy(d),e.background=null,h=!0):(c.color.copy(Eo),h=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,s[t],0),i.lookAt(a[t],0,0)):1===n?(i.up.set(0,0,s[t]),i.lookAt(0,a[t],0)):(i.up.set(0,s[t],0),i.lookAt(0,0,a[t]));const l=this._cubeSize;Oo(r,n*l,t>2?l:0,l,l),o.setRenderTarget(r),h&&o.render(A,i),o.render(e,i)}A.geometry.dispose(),A.material.dispose(),o.toneMapping=u,o.autoClear=l,e.background=d}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===q||e.mapping===G;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=ko()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Fo());const i=r?this._cubemapMaterial:this._equirectMaterial,s=new ci(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const a=this._cubeSize;Oo(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Mo)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let t=1;tTo&&console.warn(`sigmaRadians, ${i}, 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?r-g+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(u,Mo)}};function Bo(e,t,n){const r=new nn(e,t,n);return r.texture.mapping=H,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Oo(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Fo(){return new gi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:qo(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function ko(){return new gi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:qo(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function qo(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Go(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const s=i.mapping,a=s===z||s===V,o=s===q||s===G;if(a||o){let s=t.get(i);const l=void 0!==s?s.texture.pmremVersion:0;if(i.isRenderTargetTexture&&i.pmremVersion!==l)return null===n&&(n=new Uo(e)),s=a?n.fromEquirectangular(i,s):n.fromCubemap(i,s),s.texture.pmremVersion=i.pmremVersion,t.set(i,s),s.texture;if(void 0!==s)return s.texture;{const l=i.image;return a&&l&&l.height>0||o&&l&&function(e){let t=0;const n=6;for(let r=0;rt.maxTextureSize&&(y=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);const x=new Float32Array(v*y*4*c),b=new rn(x,v,y,c);b.type=ae,b.needsUpdate=!0;const S=4*_;for(let T=0;T0)return e;const i=t*n;let s=Jo[i];if(void 0===s&&(s=new Float32Array(i),Jo[i]=s),0!==t){r.toArray(s,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(s,i)}return s}function sl(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n":" "} ${i}: ${n[e]}`)}return r.join("\n")}(e.getShaderSource(t),r)}return i}function ru(e,t){const n=function(e){Ht._getMatrix(tu,Ht.workingColorSpace,e);const t=`mat3( ${tu.elements.map((e=>e.toFixed(4)))} )`;switch(Ht.getTransfer(e)){case st:return[t,"LinearTransferOETF"];case at:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function iu(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const su=new on;function au(){Ht.getLuminanceCoefficients(su);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${su.x.toFixed(4)}, ${su.y.toFixed(4)}, ${su.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function ou(e){return""!==e}function lu(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function uu(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const cu=/^[ \t]*#include +<([\w\d./]+)>/gm;function Au(e){return e.replace(cu,du)}const hu=new Map;function du(e,t){let n=Ao[t];if(void 0===n){const e=hu.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Ao[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return Au(n)}const pu=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function fu(e){return e.replace(pu,mu)}function mu(e,t,n,r){let i="";for(let e=parseInt(t);e0&&(m+="\n"),g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p].filter(ou).join("\n"),g.length>0&&(g+="\n")):(m=[gu(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ou).join("\n"),g=[gu(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+c:"",n.envMap?"#define "+A:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Ao.tonemapping_pars_fragment:"",0!==n.toneMapping?iu("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ao.colorspace_pars_fragment,ru("linearToOutputTexel",n.outputColorSpace),au(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ou).join("\n")),a=Au(a),a=lu(a,n),a=uu(a,n),o=Au(o),o=lu(o,n),o=uu(o,n),a=fu(a),o=fu(o),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",m=[d,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+m,g=["#define varying in",n.glslVersion===_t?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===_t?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+g);const v=_+m+a,y=_+g+o,x=Jl(i,i.VERTEX_SHADER,v),b=Jl(i,i.FRAGMENT_SHADER,y);function S(t){if(e.debug.checkShaderErrors){const n=i.getProgramInfoLog(f).trim(),r=i.getShaderInfoLog(x).trim(),s=i.getShaderInfoLog(b).trim();let a=!0,o=!0;if(!1===i.getProgramParameter(f,i.LINK_STATUS))if(a=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(i,f,x,b);else{const e=nu(i,x,"vertex"),r=nu(i,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(f,i.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+n+"\n"+e+"\n"+r)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==r&&""!==s||(o=!1);o&&(t.diagnostics={runnable:a,programLog:n,vertexShader:{log:r,prefix:m},fragmentShader:{log:s,prefix:g}})}i.deleteShader(x),i.deleteShader(b),w=new Zl(i,f),T=function(e,t){const n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i0,Q=s.clearcoat>0,Y=s.dispersion>0,$=s.iridescence>0,K=s.sheen>0,Z=s.transmission>0,J=X&&!!s.anisotropyMap,ee=Q&&!!s.clearcoatMap,te=Q&&!!s.clearcoatNormalMap,ne=Q&&!!s.clearcoatRoughnessMap,re=$&&!!s.iridescenceMap,ie=$&&!!s.iridescenceThicknessMap,se=K&&!!s.sheenColorMap,ae=K&&!!s.sheenRoughnessMap,oe=!!s.specularMap,le=!!s.specularColorMap,ue=!!s.specularIntensityMap,ce=Z&&!!s.transmissionMap,Ae=Z&&!!s.thicknessMap,he=!!s.gradientMap,de=!!s.alphaMap,pe=s.alphaTest>0,fe=!!s.alphaHash,me=!!s.extensions;let ge=0;s.toneMapped&&(null!==P&&!0!==P.isXRRenderTarget||(ge=e.toneMapping));const _e={shaderID:S,shaderType:s.type,shaderName:s.name,vertexShader:M,fragmentShader:E,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:d,batching:I,batchingColor:I&&null!==g._colorsTexture,instancing:L,instancingColor:L&&null!==g.instanceColor,instancingMorph:L&&null!==g.morphTexture,supportsVertexTextures:h,outputColorSpace:null===P?e.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:it,alphaToCoverage:!!s.alphaToCoverage,map:U,matcap:B,envMap:O,envMapMode:O&&x.mapping,envMapCubeUVHeight:b,aoMap:F,lightMap:k,bumpMap:q,normalMap:G,displacementMap:h&&z,emissiveMap:V,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:j,roughnessMap:W,anisotropy:X,anisotropyMap:J,clearcoat:Q,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,dispersion:Y,iridescence:$,iridescenceMap:re,iridescenceThicknessMap:ie,sheen:K,sheenColorMap:se,sheenRoughnessMap:ae,specularMap:oe,specularColorMap:le,specularIntensityMap:ue,transmission:Z,transmissionMap:ce,thicknessMap:Ae,gradientMap:he,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:de,alphaTest:pe,alphaHash:fe,combine:s.combine,mapUv:U&&f(s.map.channel),aoMapUv:F&&f(s.aoMap.channel),lightMapUv:k&&f(s.lightMap.channel),bumpMapUv:q&&f(s.bumpMap.channel),normalMapUv:G&&f(s.normalMap.channel),displacementMapUv:z&&f(s.displacementMap.channel),emissiveMapUv:V&&f(s.emissiveMap.channel),metalnessMapUv:j&&f(s.metalnessMap.channel),roughnessMapUv:W&&f(s.roughnessMap.channel),anisotropyMapUv:J&&f(s.anisotropyMap.channel),clearcoatMapUv:ee&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:te&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:re&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:se&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:ae&&f(s.sheenRoughnessMap.channel),specularMapUv:oe&&f(s.specularMap.channel),specularColorMapUv:le&&f(s.specularColorMap.channel),specularIntensityMapUv:ue&&f(s.specularIntensityMap.channel),transmissionMapUv:ce&&f(s.transmissionMap.channel),thicknessMapUv:Ae&&f(s.thicknessMap.channel),alphaMapUv:de&&f(s.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(G||X),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!v.attributes.color&&4===v.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!v.attributes.uv&&(U||de),fog:!!_,useFog:!0===s.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:A,reverseDepthBuffer:D,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==v.morphAttributes.position,morphNormals:void 0!==v.morphAttributes.normal,morphColors:void 0!==v.morphAttributes.color,morphTargetsCount:T,morphTextureStride:N,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:ge,decodeVideoTexture:U&&!0===s.map.isVideoTexture&&Ht.getTransfer(s.map.colorSpace)===at,decodeVideoTextureEmissive:V&&!0===s.emissiveMap.isVideoTexture&&Ht.getTransfer(s.emissiveMap.colorSpace)===at,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:me&&!0===s.extensions.clipCullDistance&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&!0===s.extensions.multiDraw||I)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return _e.vertexUv1s=u.has(1),_e.vertexUv2s=u.has(2),_e.vertexUv3s=u.has(3),u.clear(),_e},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.supportsVertexTextures&&o.enable(0);t.instancing&&o.enable(1);t.instancingColor&&o.enable(2);t.instancingMorph&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);t.alphaHash&&o.enable(18);t.batching&&o.enable(19);t.dispersion&&o.enable(20);t.batchingColor&&o.enable(21);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.reverseDepthBuffer&&o.enable(4);t.skinning&&o.enable(5);t.morphTargets&&o.enable(6);t.morphNormals&&o.enable(7);t.morphColors&&o.enable(8);t.premultipliedAlpha&&o.enable(9);t.shadowMapEnabled&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);t.decodeVideoTexture&&o.enable(19);t.decodeVideoTextureEmissive&&o.enable(20);t.alphaToCoverage&&o.enable(21);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=p[e.type];let n;if(t){const e=po[t];n=mi.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,t=c.length;e0?r.push(c):!0===a.transparent?i.push(c):n.push(c)},unshift:function(e,t,a,o,l,u){const c=s(e,t,a,o,l,u);a.transmission>0?r.unshift(c):!0===a.transparent?i.unshift(c):n.unshift(c)},finish:function(){for(let n=t,r=e.length;n1&&n.sort(e||wu),r.length>1&&r.sort(t||Tu),i.length>1&&i.sort(t||Tu)}}}function Eu(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new Mu,e.set(t,[i])):n>=r.length?(i=new Mu,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Cu(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new on,color:new Rr};break;case"SpotLight":n={position:new on,direction:new on,color:new Rr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new on,color:new Rr,distance:0,decay:0};break;case"HemisphereLight":n={direction:new on,skyColor:new Rr,groundColor:new Rr};break;case"RectAreaLight":n={color:new Rr,position:new on,halfWidth:new on,halfHeight:new on}}return e[t.id]=n,n}}}let Ru=0;function Nu(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Pu(e){const t=new Cu,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lt,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new on);const i=new on,s=new On,a=new On;return{setup:function(i){let s=0,a=0,o=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0;i.sort(Nu);for(let e=0,v=i.length;e0&&(!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=ho.LTC_FLOAT_1,r.rectAreaLTC2=ho.LTC_FLOAT_2):(r.rectAreaLTC1=ho.LTC_HALF_1,r.rectAreaLTC2=ho.LTC_HALF_2)),r.ambient[0]=s,r.ambient[1]=a,r.ambient[2]=o;const v=r.hash;v.directionalLength===l&&v.pointLength===u&&v.spotLength===c&&v.rectAreaLength===A&&v.hemiLength===h&&v.numDirectionalShadows===d&&v.numPointShadows===p&&v.numSpotShadows===f&&v.numSpotMaps===m&&v.numLightProbes===_||(r.directional.length=l,r.spot.length=c,r.rectArea.length=A,r.point.length=u,r.hemi.length=h,r.directionalShadow.length=d,r.directionalShadowMap.length=d,r.pointShadow.length=p,r.pointShadowMap.length=p,r.spotShadow.length=f,r.spotShadowMap.length=f,r.directionalShadowMatrix.length=d,r.pointShadowMatrix.length=p,r.spotLightMatrix.length=f+m-g,r.spotLightMap.length=m,r.numSpotLightShadowsWithMaps=g,r.numLightProbes=_,v.directionalLength=l,v.pointLength=u,v.spotLength=c,v.rectAreaLength=A,v.hemiLength=h,v.numDirectionalShadows=d,v.numPointShadows=p,v.numSpotShadows=f,v.numSpotMaps=m,v.numLightProbes=_,r.version=Ru++)},setupView:function(e,t){let n=0,o=0,l=0,u=0,c=0;const A=t.matrixWorldInverse;for(let t=0,h=e.length;t=i.length?(s=new Du(e),i.push(s)):s=i[r],s},dispose:function(){t=new WeakMap}}}function Iu(e,t,n){let r=new qi;const i=new Lt,s=new Lt,a=new en,o=new va({depthPacking:3201}),l=new ya,u={},c=n.maxTextureSize,p={[A]:1,[h]:0,[d]:2},f=new gi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lt},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const g=new Zr;g.setAttribute("position",new qr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new ci(g,f),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let y=this.type;function x(n,r){const s=t.update(_);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,m.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,m.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new nn(i.x,i.y)),f.uniforms.shadow_pass.value=n.map.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,s,f,_,null),m.uniforms.shadow_pass.value=n.mapPass.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,s,m,_,null)}function b(t,n,r,i){let s=null;const a=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===r.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let r=u[e];void 0===r&&(r={},u[e]=r);let i=r[t];void 0===i&&(i=s.clone(),r[t]=i,n.addEventListener("dispose",w)),s=i}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=3===i?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:p[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===r.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=r}return s}function S(n,i,s,a,o){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const r=t.update(n),l=n.material;if(Array.isArray(l)){const t=r.groups;for(let u=0,c=t.length;uc||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/f.x),i.x=s.x*f.x,A.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/f.y),i.y=s.y*f.y,A.mapSize.y=s.y)),null===A.map||!0===d||!0===p){const e=3!==this.type?{minFilter:Q,magFilter:Q}:{};null!==A.map&&A.map.dispose(),A.map=new nn(i.x,i.y,e),A.map.texture.name=u.name+".shadowMap",A.camera.updateProjectionMatrix()}e.setRenderTarget(A.map),e.clear();const m=A.getViewportCount();for(let e=0;e=1):-1!==Y.indexOf("OpenGL ES")&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),X=Q>=2);let $=null,K={};const Z=e.getParameter(e.SCISSOR_BOX),J=e.getParameter(e.VIEWPORT),ee=(new en).fromArray(Z),te=(new en).fromArray(J);function ne(t,n,r,i){const s=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let a=0;an||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(r*i.width),s=Math.floor(r*i.height);void 0===A&&(A=p(n,s));const a=t?p(n,s):A;a.width=n,a.height=s;return a.getContext("2d").drawImage(e,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+i.width+"x"+i.height+") to ("+n+"x"+s+")."),a}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+i.width+"x"+i.height+")."),e}return e}function m(e){return e.generateMipmaps}function g(t){e.generateMipmap(t)}function _(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function v(n,r,i,s,a=!1){if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=r;if(r===e.RED&&(i===e.FLOAT&&(o=e.R32F),i===e.HALF_FLOAT&&(o=e.R16F),i===e.UNSIGNED_BYTE&&(o=e.R8)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(o=e.R8UI),i===e.UNSIGNED_SHORT&&(o=e.R16UI),i===e.UNSIGNED_INT&&(o=e.R32UI),i===e.BYTE&&(o=e.R8I),i===e.SHORT&&(o=e.R16I),i===e.INT&&(o=e.R32I)),r===e.RG&&(i===e.FLOAT&&(o=e.RG32F),i===e.HALF_FLOAT&&(o=e.RG16F),i===e.UNSIGNED_BYTE&&(o=e.RG8)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(o=e.RG8UI),i===e.UNSIGNED_SHORT&&(o=e.RG16UI),i===e.UNSIGNED_INT&&(o=e.RG32UI),i===e.BYTE&&(o=e.RG8I),i===e.SHORT&&(o=e.RG16I),i===e.INT&&(o=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(o=e.RGB8UI),i===e.UNSIGNED_SHORT&&(o=e.RGB16UI),i===e.UNSIGNED_INT&&(o=e.RGB32UI),i===e.BYTE&&(o=e.RGB8I),i===e.SHORT&&(o=e.RGB16I),i===e.INT&&(o=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),i===e.UNSIGNED_INT&&(o=e.RGBA32UI),i===e.BYTE&&(o=e.RGBA8I),i===e.SHORT&&(o=e.RGBA16I),i===e.INT&&(o=e.RGBA32I)),r===e.RGB&&i===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.RGBA){const t=a?st:Ht.getTransfer(s);i===e.FLOAT&&(o=e.RGBA32F),i===e.HALF_FLOAT&&(o=e.RGBA16F),i===e.UNSIGNED_BYTE&&(o=t===at?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return o!==e.R16F&&o!==e.R32F&&o!==e.RG16F&&o!==e.RG32F&&o!==e.RGBA16F&&o!==e.RGBA32F||t.get("EXT_color_buffer_float"),o}function y(t,n){let r;return t?null===n||n===se||n===ce?r=e.DEPTH24_STENCIL8:n===ae?r=e.DEPTH32F_STENCIL8:n===re&&(r=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===se||n===ce?r=e.DEPTH_COMPONENT24:n===ae?r=e.DEPTH_COMPONENT32F:n===re&&(r=e.DEPTH_COMPONENT16),r}function x(e,t){return!0===m(e)||e.isFramebufferTexture&&e.minFilter!==Q&&e.minFilter!==K?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function b(e){const t=e.target;t.removeEventListener("dispose",b),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=h.get(n);if(i){const r=i[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&w(e),0===Object.keys(i).length&&h.delete(n)}r.remove(e)}(t),t.isVideoTexture&&c.delete(t)}function S(t){const n=t.target;n.removeEventListener("dispose",S),function(t){const n=r.get(t);t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r0&&s.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void D(s,t,i);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+i)}const E={[j]:e.REPEAT,[W]:e.CLAMP_TO_EDGE,[X]:e.MIRRORED_REPEAT},C={[Q]:e.NEAREST,[Y]:e.NEAREST_MIPMAP_NEAREST,[$]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[Z]:e.LINEAR_MIPMAP_NEAREST,[J]:e.LINEAR_MIPMAP_LINEAR},R={[lt]:e.NEVER,[ft]:e.ALWAYS,[ut]:e.LESS,[At]:e.LEQUAL,[ct]:e.EQUAL,[pt]:e.GEQUAL,[ht]:e.GREATER,[dt]:e.NOTEQUAL};function N(n,s){if(s.type!==ae||!1!==t.has("OES_texture_float_linear")||s.magFilter!==K&&s.magFilter!==Z&&s.magFilter!==$&&s.magFilter!==J&&s.minFilter!==K&&s.minFilter!==Z&&s.minFilter!==$&&s.minFilter!==J||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,E[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,E[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,E[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,C[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(s.magFilter===Q)return;if(s.minFilter!==$&&s.minFilter!==J)return;if(s.type===ae&&!1===t.has("OES_texture_float_linear"))return;if(s.anisotropy>1||r.get(s).__currentAnisotropy){const a=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,i.getMaxAnisotropy())),r.get(s).__currentAnisotropy=s.anisotropy}}}function P(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",b));const i=n.source;let s=h.get(i);void 0===s&&(s={},h.set(i,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,r=!0),s[o].usedTimes++;const i=s[t.__cacheKey];void 0!==i&&(s[t.__cacheKey].usedTimes--,0===i.usedTimes&&w(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return r}function D(t,a,o){let l=e.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=e.TEXTURE_3D);const u=P(t,a),c=a.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const A=r.get(c);if(c.version!==A.__version||!0===u){n.activeTexture(e.TEXTURE0+o);const t=Ht.getPrimaries(Ht.workingColorSpace),r=a.colorSpace===nt?null:Ht.getPrimaries(a.colorSpace),h=a.colorSpace===nt||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);let d=f(a.image,!1,i.maxTextureSize);d=q(a,d);const p=s.convert(a.format,a.colorSpace),_=s.convert(a.type);let b,S=v(a.internalFormat,p,_,a.colorSpace,a.isVideoTexture);N(l,a);const w=a.mipmaps,T=!0!==a.isVideoTexture,M=void 0===A.__version||!0===u,E=c.dataReady,C=x(a,d);if(a.isDepthTexture)S=y(a.format===_e,a.type),M&&(T?n.texStorage2D(e.TEXTURE_2D,1,S,d.width,d.height):n.texImage2D(e.TEXTURE_2D,0,S,d.width,d.height,0,p,_,null));else if(a.isDataTexture)if(w.length>0){T&&M&&n.texStorage2D(e.TEXTURE_2D,C,S,w[0].width,w[0].height);for(let t=0,r=w.length;t0){const r=lo(b.width,b.height,a.format,a.type);for(const i of a.layerUpdates){const s=b.data.subarray(i*r/b.data.BYTES_PER_ELEMENT,(i+1)*r/b.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,i,b.width,b.height,1,p,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,b.width,b.height,d.depth,p,b.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,S,b.width,b.height,d.depth,0,b.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?E&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,b.width,b.height,d.depth,p,_,b.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,S,b.width,b.height,d.depth,0,p,_,b.data)}else{T&&M&&n.texStorage2D(e.TEXTURE_2D,C,S,w[0].width,w[0].height);for(let t=0,r=w.length;t0){const t=lo(d.width,d.height,a.format,a.type);for(const r of a.layerUpdates){const i=d.data.subarray(r*t/d.data.BYTES_PER_ELEMENT,(r+1)*t/d.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,d.width,d.height,1,p,_,i)}a.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,d.width,d.height,d.depth,p,_,d.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,S,d.width,d.height,d.depth,0,p,_,d.data);else if(a.isData3DTexture)T?(M&&n.texStorage3D(e.TEXTURE_3D,C,S,d.width,d.height,d.depth),E&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,d.width,d.height,d.depth,p,_,d.data)):n.texImage3D(e.TEXTURE_3D,0,S,d.width,d.height,d.depth,0,p,_,d.data);else if(a.isFramebufferTexture){if(M)if(T)n.texStorage2D(e.TEXTURE_2D,C,S,d.width,d.height);else{let t=d.width,r=d.height;for(let i=0;i>=1,r>>=1}}else if(w.length>0){if(T&&M){const t=G(w[0]);n.texStorage2D(e.TEXTURE_2D,C,S,t.width,t.height)}for(let t=0,r=w.length;t>c),r=Math.max(1,i.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,c,d,t,r,i.depth,0,A,h,null):n.texImage2D(u,c,d,t,r,0,A,h,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),k(i)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,f.__webglTexture,0,F(i)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,u,f.__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function I(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){const i=n.depthTexture,s=i&&i.isDepthTexture?i.type:null,a=y(n.stencilBuffer,s),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=F(n);k(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,u,a,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,u,a,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,a,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=r.get(i.depthTexture);s.__renderTarget=i,s.__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),M(i.depthTexture,0);const a=s.__webglTexture,l=F(i);if(i.depthTexture.format===ge)k(i)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0);else{if(i.depthTexture.format!==_e)throw new Error("Unknown depthTexture format");k(i)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0)}}(i.__webglFramebuffer,t)}else if(s){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),void 0===i.__webglDepthbuffer[r])i.__webglDepthbuffer[r]=e.createRenderbuffer(),I(i.__webglDepthbuffer[r],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,s=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,s)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),void 0===i.__webglDepthbuffer)i.__webglDepthbuffer=e.createRenderbuffer(),I(i.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}n.bindFramebuffer(e.FRAMEBUFFER,null)}const B=[],O=[];function F(e){return Math.min(i.maxSamples,e.samples)}function k(e){const n=r.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function q(e,t){const n=e.colorSpace,r=e.format,i=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==it&&n!==nt&&(Ht.getTransfer(n)===at?r===pe&&i===ee||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),t}function G(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(u.width=e.naturalWidth||e.width,u.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(u.width=e.displayWidth,u.height=e.displayHeight):(u.width=e.width,u.height=e.height),u}this.allocateTextureUnit=function(){const e=T;return e>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+i.maxTextures),T+=1,e},this.resetTextureUnits=function(){T=0},this.setTexture2D=M,this.setTexture2DArray=function(t,i){const s=r.get(t);t.version>0&&s.__version!==t.version?D(s,t,i):n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+i)},this.setTexture3D=function(t,i){const s=r.get(t);t.version>0&&s.__version!==t.version?D(s,t,i):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+i)},this.setTextureCube=function(t,a){const o=r.get(t);t.version>0&&o.__version!==t.version?function(t,a,o){if(6!==a.image.length)return;const l=P(t,a),u=a.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const c=r.get(u);if(u.version!==c.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=Ht.getPrimaries(Ht.workingColorSpace),r=a.colorSpace===nt?null:Ht.getPrimaries(a.colorSpace),A=a.colorSpace===nt||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,A);const h=a.isCompressedTexture||a.image[0].isCompressedTexture,d=a.image[0]&&a.image[0].isDataTexture,p=[];for(let e=0;e<6;e++)p[e]=h||d?d?a.image[e].image:a.image[e]:f(a.image[e],!0,i.maxCubemapSize),p[e]=q(a,p[e]);const _=p[0],y=s.convert(a.format,a.colorSpace),b=s.convert(a.type),S=v(a.internalFormat,y,b,a.colorSpace),w=!0!==a.isVideoTexture,T=void 0===c.__version||!0===l,M=u.dataReady;let E,C=x(a,_);if(N(e.TEXTURE_CUBE_MAP,a),h){w&&T&&n.texStorage2D(e.TEXTURE_CUBE_MAP,C,S,_.width,_.height);for(let t=0;t<6;t++){E=p[t].mipmaps;for(let r=0;r0&&C++;const t=G(p[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,C,S,t.width,t.height)}for(let t=0;t<6;t++)if(d){w?M&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,p[t].width,p[t].height,y,b,p[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,S,p[t].width,p[t].height,0,y,b,p[t].data);for(let r=0;r1;if(A||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=i.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let t=0;t0&&!1===k(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0)if(!1===k(t)){const i=t.textures,s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const u=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=r.get(t),A=i.length>1;if(A)for(let t=0;to+u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-u&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==i&&(r=i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(ku)))}return null!==a&&(a.visible=null!==r),null!==o&&(o.visible=null!==i),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new as;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Gu{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(null===this.texture){const r=new Jt;e.properties.get(r).__webglTexture=t.texture,t.depthNear===n.depthNear&&t.depthFar===n.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new gi({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ci(new oa(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zu extends xt{constructor(e,t){super();const n=this;let r=null,i=1,s=null,a="local-floor",o=1,l=null,u=null,c=null,A=null,h=null,d=null;const p=new Gu,f=t.getContextAttributes();let m=null,g=null;const _=[],v=[],y=new Lt;let x=null;const b=new bi;b.viewport=new en;const S=new bi;S.viewport=new en;const w=[b,S],T=new $a;let M=null,E=null;function C(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=_[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){r.removeEventListener("select",C),r.removeEventListener("selectstart",C),r.removeEventListener("selectend",C),r.removeEventListener("squeeze",C),r.removeEventListener("squeezestart",C),r.removeEventListener("squeezeend",C),r.removeEventListener("end",R),r.removeEventListener("inputsourceschange",N);for(let e=0;e<_.length;e++){const t=v[e];null!==t&&(v[e]=null,_[e].disconnect(t))}M=null,E=null,p.reset(),e.setRenderTarget(m),h=null,A=null,c=null,r=null,g=null,U.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(y.width,y.height,!1),n.dispatchEvent({type:"sessionend"})}function N(e){for(let t=0;t=0&&(v[r]=null,_[r].disconnect(n))}for(let t=0;t=v.length){v.push(n),r=e;break}if(null===v[e]){v[e]=n,r=e;break}}if(-1===r)break}const i=_[r];i&&i.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return void 0===t&&(t=new qu,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new qu,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new qu,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==A?A:h},this.getBinding=function(){return c},this.getFrame=function(){return d},this.getSession=function(){return r},this.setSession=async function(u){if(r=u,null!==r){m=e.getRenderTarget(),r.addEventListener("select",C),r.addEventListener("selectstart",C),r.addEventListener("selectend",C),r.addEventListener("squeeze",C),r.addEventListener("squeezestart",C),r.addEventListener("squeezeend",C),r.addEventListener("end",R),r.addEventListener("inputsourceschange",N),!0!==f.xrCompatible&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(y);if(void 0!==r.enabledFeatures&&r.enabledFeatures.includes("layers")){let n=null,s=null,a=null;f.depth&&(a=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?_e:ge,s=f.stencil?ce:se);const o={colorFormat:t.RGBA8,depthFormat:a,scaleFactor:i};c=new XRWebGLBinding(r,t),A=c.createProjectionLayer(o),r.updateRenderState({layers:[A]}),e.setPixelRatio(1),e.setSize(A.textureWidth,A.textureHeight,!1),g=new nn(A.textureWidth,A.textureHeight,{format:pe,type:ee,depthTexture:new ls(A.textureWidth,A.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:!1===A.ignoreDepthValues})}else{const n={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:i};h=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),g=new nn(h.framebufferWidth,h.framebufferHeight,{format:pe,type:ee,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await r.requestReferenceSpace(a),U.setContext(r),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};const P=new on,D=new on;function L(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;let t=e.near,n=e.far;null!==p.texture&&(p.depthNear>0&&(t=p.depthNear),p.depthFar>0&&(n=p.depthFar)),T.near=S.near=b.near=t,T.far=S.far=b.far=n,M===T.near&&E===T.far||(r.updateRenderState({depthNear:T.near,depthFar:T.far}),M=T.near,E=T.far),b.layers.mask=2|e.layers.mask,S.layers.mask=4|e.layers.mask,T.layers.mask=b.layers.mask|S.layers.mask;const i=e.parent,s=T.cameras;L(T,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);const i=t.get(r),s=i.envMap,a=i.envMapRotation;s&&(e.envMap.value=s,Vu.copy(a),Vu.x*=-1,Vu.y*=-1,Vu.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(Vu.y*=-1,Vu.z*=-1),e.envMapRotation.value.setFromMatrix4(Hu.makeRotationFromEuler(Vu)),e.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,fi(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,i,s,a,o){i.isMeshBasicMaterial||i.isMeshLambertMaterial?r(e,i):i.isMeshToonMaterial?(r(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(r(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(r(e,i),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,i),i.isMeshPhysicalMaterial&&function(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,i,o)):i.isMeshMatcapMaterial?(r(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?r(e,i):i.isMeshDistanceMaterial?(r(e,i),function(e,n){const r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,i)):i.isMeshNormalMaterial?r(e,i):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*i,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i,s,a):i.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function Wu(e,t,n,r){let i={},s={},a=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,r){const i=e.value,s=t+"_"+n;if(void 0===r[s])return r[s]="number"==typeof i||"boolean"==typeof i?i:i.clone(),!0;{const e=r[s];if("number"==typeof i||"boolean"==typeof i){if(e!==i)return r[s]=i,!0}else if(!1===e.equals(i))return e.copy(i),!0}return!1}function u(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function c(t){const n=t.target;n.removeEventListener("dispose",c);const r=a.indexOf(n.__bindingPointIndex);a.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete s[n.id]}return{bind:function(e,t){const n=t.program;r.uniformBlockBinding(e,n)},update:function(n,A){let h=i[n.id];void 0===h&&(!function(e){const t=e.uniforms;let n=0;const r=16;for(let e=0,i=t.length;e0&&(n+=r-i);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e=t||n<0||A&&e-u>=s}function f(){var e=nc();if(p(e))return m(e);o=setTimeout(f,function(e){var n=t-(e-l);return A?yc(n,s-(e-u)):n}(e))}function m(e){return o=void 0,h&&r?d(e):(r=i=void 0,a)}function g(){var e=nc(),n=p(e);if(r=arguments,i=this,l=e,n){if(void 0===o)return function(e){return u=e,o=setTimeout(f,t),c?d(e):a}(l);if(A)return clearTimeout(o),o=setTimeout(f,t),d(l)}return void 0===o&&(o=setTimeout(f,t)),a}return t=_c(t)||0,Zu(n)&&(c=!!n.leading,s=(A="maxWait"in n)?vc(_c(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h),g.cancel=function(){void 0!==o&&clearTimeout(o),u=0,r=l=i=o=void 0},g.flush=function(){return void 0===o?a:m(nc())},g}function bc(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1e4?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}}}}),Cc=function(){return performance.now()},Rc=function(){function e(){for(var e=[],t=0;t0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(e[n],e[n-1],n-r):s(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){for(var n=0,r=e.length-1,i=Math.pow,s=Nc.Utils.Bernstein,a=0;a<=r;a++)n+=i(1-t,r-a)*i(t,a)*e[a]*s(r,a);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),s=Nc.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),s(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(s(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(s(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):s(e[i?i-1:0],e[i],e[n1;r--)n*=r;return e[t]=n,n}}(),CatmullRom:function(e,t,n,r,i){var s=.5*(n-e),a=.5*(r-t),o=i*i;return(2*t-2*n+s+a)*(i*o)+(-3*t+3*n-2*s-a)*o+s*i+t}}},Pc=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),Dc=new Rc,Lc=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=Ec.Linear.None,this._interpolationFunction=Nc.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Pc.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=Dc,Dc.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=Cc()),void 0===t&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var n in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];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 r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}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,n,r,i){for(var s in n){var a=e[s],o=Array.isArray(a),l=o?"array":typeof a,u=!o&&Array.isArray(n[s]);if("undefined"!==l&&"function"!==l){if(u){if(0===(m=n[s]).length)continue;for(var c=[a],A=0,h=m.length;Al)return 1;var e=Math.trunc(a/o),t=a-e*o,n=Math.min(t/s._duration,1);return 0===n&&a===s._duration?1:n}(),c=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,c),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),0===this._duration||a>=this._duration){if(this._repeat>0){var A=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(i in isFinite(this._repeat)&&(this._repeat-=A),this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[i]||(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*A,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var h=0,d=this._chainedTweens.length;h=(a=(v+b)/2))?v=a:b=a,(d=n>=(o=(y+S)/2))?y=o:S=o,(p=r>=(l=(x+w)/2))?x=l:w=l,s=g,!(g=g[f=p<<2|d<<1|h]))return s[f]=_,e;if(u=+e._x.call(null,g.data),c=+e._y.call(null,g.data),A=+e._z.call(null,g.data),t===u&&n===c&&r===A)return _.next=g,s?s[f]=_:e._root=_,e;do{s=s?s[f]=new Array(8):e._root=new Array(8),(h=t>=(a=(v+b)/2))?v=a:b=a,(d=n>=(o=(y+S)/2))?y=o:S=o,(p=r>=(l=(x+w)/2))?x=l:w=l}while((f=p<<2|d<<1|h)==(m=(A>=l)<<2|(c>=o)<<1|u>=a));return s[m]=g,s[f]=_,e}function Bc(e,t,n,r,i,s,a){this.node=e,this.x0=t,this.y0=n,this.z0=r,this.x1=i,this.y1=s,this.z1=a}Ic.getAll.bind(Ic),Ic.removeAll.bind(Ic),Ic.add.bind(Ic),Ic.remove.bind(Ic),Ic.update.bind(Ic);const Oc=(e,t,n,r,i,s)=>Math.sqrt((e-r)**2+(t-i)**2+(n-s)**2);function Fc(e){return e[0]}function kc(e){return e[1]}function qc(e){return e[2]}function Gc(e,t,n,r){var i=new zc(null==t?Fc:t,null==n?kc:n,null==r?qc:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==e?i:i.addAll(e)}function zc(e,t,n,r,i,s,a,o,l){this._x=e,this._y=t,this._z=n,this._x0=r,this._y0=i,this._z0=s,this._x1=a,this._y1=o,this._z1=l,this._root=void 0}function Vc(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Hc=Gc.prototype=zc.prototype;function jc(e,t){return null==e||null==t?NaN:et?1:e>=t?0:NaN}function Wc(e,t){return null==e||null==t?NaN:te?1:t>=e?0:NaN}function Xc(e){let t,n,r;function i(e,r,i=0,s=e.length){if(i>>1;n(e[t],r)<0?i=t+1:s=t}while(ijc(e(t),n),r=(t,n)=>e(t)-n):(t=e===jc||e===Wc?e:Qc,n=e,r=e),{left:i,center:function(e,t,n=0,s=e.length){const a=i(e,t,n,s-1);return a>n&&r(e[a-1],t)>-r(e[a],t)?a-1:a},right:function(e,r,i=0,s=e.length){if(i>>1;n(e[t],r)<=0?i=t+1:s=t}while(il&&(l=h),du&&(u=d),pc&&(c=p));if(s>l||a>u||o>c)return this;this.cover(s,a,o).cover(l,u,c);for(let s=0;se||e>=a||i>t||t>=o||s>n||n>=l;)switch(c=(nm||(a=A.y0)>g||(o=A.z0)>_||(l=A.x1)=S)<<2|(t>=b)<<1|e>=x)&&(A=v[v.length-1],v[v.length-1]=v[v.length-1-h],v[v.length-1-h]=A)}else{var w=e-+this._x.call(null,y.data),T=t-+this._y.call(null,y.data),M=n-+this._z.call(null,y.data),E=w*w+T*T+M*M;if(E{if(!A.length)do{const s=A.data;Oc(e,t,n,this._x(s),this._y(s),this._z(s))<=r&&i.push(s)}while(A=A.next);return h>l||d>u||p>c||f=(l=(g+y)/2))?g=l:y=l,(h=a>=(u=(_+x)/2))?_=u:x=u,(d=o>=(c=(v+b)/2))?v=c:b=c,t=m,!(m=m[p=d<<2|h<<1|A]))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])&&(n=t,f=p)}for(;m.data!==e;)if(r=m,!(m=m.next))return this;return(i=m.next)&&delete m.next,r?(i?r.next=i:delete r.next,this):t?(i?t[p]=i: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&&(n?n[f]=m:this._root=m),this):(this._root=i,this)},Hc.removeAll=function(e){for(var t=0,n=e.length;t=t&&(n=r=t):(n>t&&(n=t),r=s&&(n=r=s):(n>s&&(n=s),r0){for(s=e[--i];i>0&&(t=s,n=e[--i],s=t+n,r=n-(s-t),!r););i>0&&(r<0&&e[i-1]<0||r>0&&e[i-1]>0)&&(n=2*r,t=s+n,n==t-s&&(s=t))}return s}}const Zc=Math.sqrt(50),Jc=Math.sqrt(10),eA=Math.sqrt(2);function tA(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=Zc?10:s>=Jc?5:s>=eA?2:1;let o,l,u;return i<0?(u=Math.pow(10,-i)/a,o=Math.round(e*u),l=Math.round(t*u),o/ut&&--l,u=-u):(u=Math.pow(10,i)*a,o=Math.round(e/u),l=Math.round(t/u),o*ut&&--l),l>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?MA(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?MA(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=fA.exec(e))?new CA(t[1],t[2],t[3],1):(t=mA.exec(e))?new CA(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=gA.exec(e))?MA(t[1],t[2],t[3],t[4]):(t=_A.exec(e))?MA(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=vA.exec(e))?IA(t[1],t[2]/100,t[3]/100,1):(t=yA.exec(e))?IA(t[1],t[2]/100,t[3]/100,t[4]):xA.hasOwnProperty(e)?TA(xA[e]):"transparent"===e?new CA(NaN,NaN,NaN,0):null}function TA(e){return new CA(e>>16&255,e>>8&255,255&e,1)}function MA(e,t,n,r){return r<=0&&(e=t=n=NaN),new CA(e,t,n,r)}function EA(e,t,n,r){return 1===arguments.length?function(e){return e instanceof lA||(e=wA(e)),e?new CA((e=e.rgb()).r,e.g,e.b,e.opacity):new CA}(e):new CA(e,t,n,null==r?1:r)}function CA(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function RA(){return`#${LA(this.r)}${LA(this.g)}${LA(this.b)}`}function NA(){const e=PA(this.opacity);return`${1===e?"rgb(":"rgba("}${DA(this.r)}, ${DA(this.g)}, ${DA(this.b)}${1===e?")":`, ${e})`}`}function PA(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function DA(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function LA(e){return((e=DA(e))<16?"0":"")+e.toString(16)}function IA(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new BA(e,t,n,r)}function UA(e){if(e instanceof BA)return new BA(e.h,e.s,e.l,e.opacity);if(e instanceof lA||(e=wA(e)),!e)return new BA;if(e instanceof BA)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(a=t===s?(n-r)/o+6*(n0&&l<1?0:a,new BA(a,o,l,e.opacity)}function BA(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function OA(e){return(e=(e||0)%360)<0?e+360:e}function FA(e){return Math.max(0,Math.min(1,e||0))}function kA(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}aA(lA,wA,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bA,formatHex:bA,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return UA(this).formatHsl()},formatRgb:SA,toString:SA}),aA(CA,EA,oA(lA,{brighter(e){return e=null==e?cA:Math.pow(cA,e),new CA(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?uA:Math.pow(uA,e),new CA(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new CA(DA(this.r),DA(this.g),DA(this.b),PA(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:RA,formatHex:RA,formatHex8:function(){return`#${LA(this.r)}${LA(this.g)}${LA(this.b)}${LA(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:NA,toString:NA})),aA(BA,(function(e,t,n,r){return 1===arguments.length?UA(e):new BA(e,t,n,null==r?1:r)}),oA(lA,{brighter(e){return e=null==e?cA:Math.pow(cA,e),new BA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?uA:Math.pow(uA,e),new BA(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,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new CA(kA(e>=240?e-240:e+120,i,r),kA(e,i,r),kA(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new BA(OA(this.h),FA(this.s),FA(this.l),PA(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=PA(this.opacity);return`${1===e?"hsl(":"hsla("}${OA(this.h)}, ${100*FA(this.s)}%, ${100*FA(this.l)}%${1===e?")":`, ${e})`}`}}));var qA=e=>()=>e;function GA(e){return 1==(e=+e)?zA:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):qA(isNaN(t)?n:t)}}function zA(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):qA(isNaN(e)?t:e)}var VA=function e(t){var n=GA(t);function r(e,t){var r=n((e=EA(e)).r,(t=EA(t)).r),i=n(e.g,t.g),s=n(e.b,t.b),a=zA(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=s(t),e.opacity=a(t),e+""}}return r.gamma=e,r}(1);function HA(e,t){t||(t=[]);var n,r=e?Math.min(t.length,e.length):0,i=t.slice();return function(s){for(n=0;ns&&(i=t.slice(s,i),o[a]?o[a]+=i:o[++a]=i),(n=n[0])===(r=r[0])?o[a]?o[a]+=r:o[++a]=r:(o[++a]=null,l.push({i:a,x:YA(n,r)})),s=ZA.lastIndex;return st&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}(a[0],a[e-1])),r=e>2?oh:ah,i=s=null,A}function A(t){return null==t||isNaN(t=+t)?n:(i||(i=r(a.map(e),o,l)))(e(u(t)))}return A.invert=function(n){return u(t((s||(s=r(o,a.map(e),YA)))(n)))},A.domain=function(e){return arguments.length?(a=Array.from(e,nh),c()):a.slice()},A.range=function(e){return arguments.length?(o=Array.from(e),c()):o.slice()},A.rangeRound=function(e){return o=Array.from(e),l=th,c()},A.clamp=function(e){return arguments.length?(u=!!e||ih,c()):u!==ih},A.interpolate=function(e){return arguments.length?(l=e,c()):l},A.unknown=function(e){return arguments.length?(n=e,A):n},function(n,r){return e=n,t=r,c()}}function uh(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function ch(e){return(e=uh(Math.abs(e)))?e[1]:NaN}var Ah,hh=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function dh(e){if(!(t=hh.exec(e)))throw new Error("invalid format: "+e);var t;return new ph({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 ph(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 fh(e,t){var n=uh(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}dh.prototype=ph.prototype,ph.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 mh={"%":(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)=>fh(100*e,t),r:fh,s:function(e,t){var n=uh(e,t);if(!n)return e+"";var r=n[0],i=n[1],s=i-(Ah=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+uh(e,Math.max(0,t+s-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function gh(e){return e}var _h,vh,yh,xh=Array.prototype.map,bh=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Sh(e){var t,n,r=void 0===e.grouping||void 0===e.thousands?gh:(t=xh.call(e.grouping,Number),n=e.thousands+"",function(e,r){for(var i=e.length,s=[],a=0,o=t[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(e.substring(i-=o,i+o)),!((l+=o+1)>r));)o=t[a=(a+1)%t.length];return s.reverse().join(n)}),i=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?gh:function(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}(xh.call(e.numerals,String)),l=void 0===e.percent?"%":e.percent+"",u=void 0===e.minus?"−":e.minus+"",c=void 0===e.nan?"NaN":e.nan+"";function A(e){var t=(e=dh(e)).fill,n=e.align,A=e.sign,h=e.symbol,d=e.zero,p=e.width,f=e.comma,m=e.precision,g=e.trim,_=e.type;"n"===_?(f=!0,_="g"):mh[_]||(void 0===m&&(m=12),g=!0,_="g"),(d||"0"===t&&"="===n)&&(d=!0,t="0",n="=");var v="$"===h?i:"#"===h&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",y="$"===h?s:/[%p]/.test(_)?l:"",x=mh[_],b=/[defgprs%]/.test(_);function S(e){var i,s,l,h=v,S=y;if("c"===_)S=x(e)+S,e="";else{var w=(e=+e)<0||1/e<0;if(e=isNaN(e)?c:x(Math.abs(e),m),g&&(e=function(e){e:for(var t,n=e.length,r=1,i=-1;r0&&(i=0)}return i>0?e.slice(0,i)+e.slice(t+1):e}(e)),w&&0==+e&&"+"!==A&&(w=!1),h=(w?"("===A?A:u:"-"===A||"("===A?"":A)+h,S=("s"===_?bh[8+Ah/3]:"")+S+(w&&"("===A?")":""),b)for(i=-1,s=e.length;++i(l=e.charCodeAt(i))||l>57){S=(46===l?a+e.slice(i+1):e.slice(i))+S,e=e.slice(0,i);break}}f&&!d&&(e=r(e,1/0));var T=h.length+e.length+S.length,M=T>1)+h+e+S+M.slice(T);break;default:e=M+h+e+S}return o(e)}return m=void 0===m?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),S.toString=function(){return e+""},S}return{format:A,formatPrefix:function(e,t){var n=A(((e=dh(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor(ch(t)/3))),i=Math.pow(10,-r),s=bh[8+r/3];return function(e){return n(i*e)+s}}}}function wh(e,t,n,r){var i,s=function(e,t,n){n=+n;const r=(t=+t)<(e=+e),i=r?nA(t,e,n):nA(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}(e,t,n);switch((r=dh(null==r?",f":r)).type){case"s":var a=Math.max(Math.abs(e),Math.abs(t));return null!=r.precision||isNaN(i=function(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(ch(t)/3)))-ch(Math.abs(e)))}(s,a))||(r.precision=i),yh(r,a);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,ch(t)-ch(e))+1}(s,Math.max(Math.abs(e),Math.abs(t))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(e){return Math.max(0,-ch(Math.abs(e)))}(s))||(r.precision=i-2*("%"===r.type))}return vh(r)}function Th(e){var t=e.domain;return e.ticks=function(e){var n=t();return function(e,t,n){if(!((n=+n)>0))return[];if((e=+e)==(t=+t))return[e];const r=t=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let e=0;e0;){if((i=nA(l,u,n))===r)return s[a]=l,s[o]=u,t(s);if(i>0)l=Math.floor(l/i)*i,u=Math.ceil(u/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,u=Math.floor(u*i)/i}r=i}return e},e}function Mh(){var e=lh()(ih,ih);return e.copy=function(){return t=e,Mh().domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());var t},sA.apply(e,arguments),Th(e)}function Eh(){var e,t=0,n=1,r=1,i=[.5],s=[0,1];function a(t){return null!=t&&t<=t?s[Yc(i,t,0,r)]:e}function o(){var e=-1;for(i=new Array(r);++e=r?[i[r-1],n]:[i[a-1],i[a]]},a.unknown=function(t){return arguments.length?(e=t,a):a},a.thresholds=function(){return i.slice()},a.copy=function(){return Eh().domain([t,n]).range(s).unknown(e)},sA.apply(Th(a),arguments)}_h=Sh({thousands:",",grouping:[3],currency:["$",""]}),vh=_h.format,yh=_h.formatPrefix;var Ch=1e-6,Rh=1e-12,Nh=Math.PI,Ph=Nh/2,Dh=Nh/4,Lh=2*Nh,Ih=180/Nh,Uh=Nh/180,Bh=Math.abs,Oh=Math.atan,Fh=Math.atan2,kh=Math.cos,qh=Math.ceil,Gh=Math.exp,zh=Math.hypot,Vh=Math.log,Hh=Math.sin,jh=Math.sign||function(e){return e>0?1:e<0?-1:0},Wh=Math.sqrt,Xh=Math.tan;function Qh(e){return e>1?Ph:e<-1?-Ph:Math.asin(e)}function Yh(e){return(e=Hh(e/2))*e}function $h(){}function Kh(e,t){e&&Jh.hasOwnProperty(e.type)&&Jh[e.type](e,t)}var Zh={Feature:function(e,t){Kh(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r=0?1:-1,i=r*n,s=kh(t=(t*=Uh)/2+Dh),a=Hh(t),o=od*a,l=ad*s+o*kh(i),u=o*r*Hh(i);vd.add(Fh(u,l)),sd=e,ad=s,od=a}function Md(e){return[Fh(e[1],e[0]),Qh(e[2])]}function Ed(e){var t=e[0],n=e[1],r=kh(n);return[r*kh(t),r*Hh(t),Hh(n)]}function Cd(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Rd(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 Nd(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function Pd(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Dd(e){var t=Wh(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var Ld,Id,Ud,Bd,Od,Fd,kd,qd,Gd,zd,Vd,Hd,jd,Wd,Xd,Qd,Yd={point:$d,lineStart:Zd,lineEnd:Jd,polygonStart:function(){Yd.point=ep,Yd.lineStart=tp,Yd.lineEnd=np,md=new Kc,xd.polygonStart()},polygonEnd:function(){xd.polygonEnd(),Yd.point=$d,Yd.lineStart=Zd,Yd.lineEnd=Jd,vd<0?(ld=-(cd=180),ud=-(Ad=90)):md>Ch?Ad=90:md<-1e-6&&(ud=-90),_d[0]=ld,_d[1]=cd},sphere:function(){ld=-(cd=180),ud=-(Ad=90)}};function $d(e,t){gd.push(_d=[ld=e,cd=e]),tAd&&(Ad=t)}function Kd(e,t){var n=Ed([e*Uh,t*Uh]);if(fd){var r=Rd(fd,n),i=Rd([r[1],-r[0],0],r);Dd(i),i=Md(i);var s,a=e-hd,o=a>0?1:-1,l=i[0]*Ih*o,u=Bh(a)>180;u^(o*hdAd&&(Ad=s):u^(o*hd<(l=(l+360)%360-180)&&lAd&&(Ad=t)),u?erp(ld,cd)&&(cd=e):rp(e,cd)>rp(ld,cd)&&(ld=e):cd>=ld?(ecd&&(cd=e)):e>hd?rp(ld,e)>rp(ld,cd)&&(cd=e):rp(e,cd)>rp(ld,cd)&&(ld=e)}else gd.push(_d=[ld=e,cd=e]);tAd&&(Ad=t),fd=n,hd=e}function Zd(){Yd.point=Kd}function Jd(){_d[0]=ld,_d[1]=cd,Yd.point=$d,fd=null}function ep(e,t){if(fd){var n=e-hd;md.add(Bh(n)>180?n+(n>0?360:-360):n)}else dd=e,pd=t;xd.point(e,t),Kd(e,t)}function tp(){xd.lineStart()}function np(){ep(dd,pd),xd.lineEnd(),Bh(md)>Ch&&(ld=-(cd=180)),_d[0]=ld,_d[1]=cd,fd=null}function rp(e,t){return(t-=e)<0?t+360:t}function ip(e,t){return e[0]-t[0]}function sp(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:trp(r[0],r[1])&&(r[1]=i[1]),rp(i[0],r[1])>rp(r[0],r[1])&&(r[0]=i[0])):s.push(r=i);for(a=-1/0,t=0,r=s[n=s.length-1];t<=n;r=i,++t)i=s[t],(o=rp(r[1],i[0]))>a&&(a=o,ld=i[0],cd=r[1])}return gd=_d=null,ld===1/0||ud===1/0?[[NaN,NaN],[NaN,NaN]]:[[ld,ud],[cd,Ad]]}var op={sphere:$h,point:lp,lineStart:cp,lineEnd:dp,polygonStart:function(){op.lineStart=pp,op.lineEnd=fp},polygonEnd:function(){op.lineStart=cp,op.lineEnd=dp}};function lp(e,t){e*=Uh;var n=kh(t*=Uh);up(n*kh(e),n*Hh(e),Hh(t))}function up(e,t,n){++Ld,Ud+=(e-Ud)/Ld,Bd+=(t-Bd)/Ld,Od+=(n-Od)/Ld}function cp(){op.point=Ap}function Ap(e,t){e*=Uh;var n=kh(t*=Uh);Wd=n*kh(e),Xd=n*Hh(e),Qd=Hh(t),op.point=hp,up(Wd,Xd,Qd)}function hp(e,t){e*=Uh;var n=kh(t*=Uh),r=n*kh(e),i=n*Hh(e),s=Hh(t),a=Fh(Wh((a=Xd*s-Qd*i)*a+(a=Qd*r-Wd*s)*a+(a=Wd*i-Xd*r)*a),Wd*r+Xd*i+Qd*s);Id+=a,Fd+=a*(Wd+(Wd=r)),kd+=a*(Xd+(Xd=i)),qd+=a*(Qd+(Qd=s)),up(Wd,Xd,Qd)}function dp(){op.point=lp}function pp(){op.point=mp}function fp(){gp(Hd,jd),op.point=lp}function mp(e,t){Hd=e,jd=t,e*=Uh,t*=Uh,op.point=gp;var n=kh(t);Wd=n*kh(e),Xd=n*Hh(e),Qd=Hh(t),up(Wd,Xd,Qd)}function gp(e,t){e*=Uh;var n=kh(t*=Uh),r=n*kh(e),i=n*Hh(e),s=Hh(t),a=Xd*s-Qd*i,o=Qd*r-Wd*s,l=Wd*i-Xd*r,u=zh(a,o,l),c=Qh(u),A=u&&-c/u;Gd.add(A*a),zd.add(A*o),Vd.add(A*l),Id+=c,Fd+=c*(Wd+(Wd=r)),kd+=c*(Xd+(Xd=i)),qd+=c*(Qd+(Qd=s)),up(Wd,Xd,Qd)}function _p(e){Ld=Id=Ud=Bd=Od=Fd=kd=qd=0,Gd=new Kc,zd=new Kc,Vd=new Kc,nd(e,op);var t=+Gd,n=+zd,r=+Vd,i=zh(t,n,r);return iNh&&(e-=Math.round(e/Lh)*Lh),[e,t]}function xp(e,t,n){return(e%=Lh)?t||n?vp(Sp(e),wp(t,n)):Sp(e):t||n?wp(t,n):yp}function bp(e){return function(t,n){return Bh(t+=e)>Nh&&(t-=Math.round(t/Lh)*Lh),[t,n]}}function Sp(e){var t=bp(e);return t.invert=bp(-e),t}function wp(e,t){var n=kh(e),r=Hh(e),i=kh(t),s=Hh(t);function a(e,t){var a=kh(t),o=kh(e)*a,l=Hh(e)*a,u=Hh(t),c=u*n+o*r;return[Fh(l*i-c*s,o*n-u*r),Qh(c*i+l*s)]}return a.invert=function(e,t){var a=kh(t),o=kh(e)*a,l=Hh(e)*a,u=Hh(t),c=u*i-l*s;return[Fh(l*i+u*s,o*n+c*r),Qh(c*n-o*r)]},a}function Tp(e,t){(t=Ed(t))[0]-=e,Dd(t);var n=function(e){return e>1?0:e<-1?Nh:Math.acos(e)}(-t[1]);return((-t[2]<0?-n:n)+Lh-Ch)%Lh}function Mp(){var e,t=[];return{point:function(t,n,r){e.push([t,n,r])},lineStart:function(){t.push(e=[])},lineEnd:$h,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var n=t;return t=[],e=null,n}}}function Ep(e,t){return Bh(e[0]-t[0])=0;--s)i.point((c=u[s])[0],c[1]);else r(h.x,h.p.x,-1,i);h=h.p}u=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function Np(e){if(t=e.length){for(var t,n,r=0,i=e[0];++r=0?1:-1,M=T*w,E=M>Nh,C=m*b;if(l.add(Fh(C*T*Hh(M),g*S+C*kh(M))),a+=E?w+T*Lh:w,E^p>=n^y>=n){var R=Rd(Ed(d),Ed(v));Dd(R);var N=Rd(s,R);Dd(N);var P=(E^w>=0?-1:1)*Qh(N[2]);(r>P||r===P&&(R[0]||R[1]))&&(o+=E^w>=0?1:-1)}}return(a<-1e-6||a0){for(A||(i.polygonStart(),A=!0),i.lineStart(),e=0;e1&&2&l&&h.push(h.pop().concat(h.shift())),a.push(h.filter(Ip))}return h}}function Ip(e){return e.length>1}function Up(e,t){return((e=e.x)[0]<0?e[1]-Ph-Ch:Ph-e[1])-((t=t.x)[0]<0?t[1]-Ph-Ch:Ph-t[1])}yp.invert=yp;var Bp=Lp((function(){return!0}),(function(e){var t,n=NaN,r=NaN,i=NaN;return{lineStart:function(){e.lineStart(),t=1},point:function(s,a){var o=s>0?Nh:-Nh,l=Bh(s-n);Bh(l-Nh)0?Ph:-Ph),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(o,r),e.point(s,r),t=0):i!==o&&l>=Nh&&(Bh(n-i)Ch?Oh((Hh(t)*(s=kh(r))*Hh(n)-Hh(r)*(i=kh(t))*Hh(e))/(i*s*a)):(t+r)/2}(n,r,s,a),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(o,r),t=0),e.point(n=s,r=a),i=o},lineEnd:function(){e.lineEnd(),n=r=NaN},clean:function(){return 2-t}}}),(function(e,t,n,r){var i;if(null==e)i=n*Ph,r.point(-Nh,i),r.point(0,i),r.point(Nh,i),r.point(Nh,0),r.point(Nh,-i),r.point(0,-i),r.point(-Nh,-i),r.point(-Nh,0),r.point(-Nh,i);else if(Bh(e[0]-t[0])>Ch){var s=e[0]0,i=Bh(t)>Ch;function s(e,n){return kh(e)*kh(n)>t}function a(e,n,r){var i=[1,0,0],s=Rd(Ed(e),Ed(n)),a=Cd(s,s),o=s[0],l=a-o*o;if(!l)return!r&&e;var u=t*a/l,c=-t*o/l,A=Rd(i,s),h=Pd(i,u);Nd(h,Pd(s,c));var d=A,p=Cd(h,d),f=Cd(d,d),m=p*p-f*(Cd(h,h)-1);if(!(m<0)){var g=Wh(m),_=Pd(d,(-p-g)/f);if(Nd(_,h),_=Md(_),!r)return _;var v,y=e[0],x=n[0],b=e[1],S=n[1];x0^_[1]<(Bh(_[0]-y)Nh^(y<=_[0]&&_[0]<=x)){var M=Pd(d,(-p+g)/f);return Nd(M,h),[_,Md(M)]}}}function o(t,n){var i=r?e:Nh-e,s=0;return t<-i?s|=1:t>i&&(s|=2),n<-i?s|=4:n>i&&(s|=8),s}return Lp(s,(function(e){var t,n,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(A,h){var d,p=[A,h],f=s(A,h),m=r?f?0:o(A,h):f?o(A+(A<0?Nh:-Nh),h):0;if(!t&&(u=l=f)&&e.lineStart(),f!==l&&(!(d=a(t,p))||Ep(t,d)||Ep(p,d))&&(p[2]=1),f!==l)c=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(i&&t&&r^f){var g;m&n||!(g=a(p,t,!0))||(c=0,r?(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&&Ep(t,p)||e.point(p[0],p[1]),t=p,l=f,n=m},lineEnd:function(){l&&e.lineEnd(),t=null},clean:function(){return c|(u&&l)<<1}}}),(function(t,r,i,s){!function(e,t,n,r,i,s){if(n){var a=kh(t),o=Hh(t),l=r*n;null==i?(i=t+r*Lh,s=t-l/2):(i=Tp(a,i),s=Tp(a,s),(r>0?is)&&(i+=r*Lh));for(var u,c=i;r>0?c>s:c0)do{u.point(0===c||3===c?e:n,c>1?r:t)}while((c=(c+o+4)%4)!==A);else u.point(s[0],s[1])}function a(r,i){return Bh(r[0]-e)0?0:3:Bh(r[0]-n)0?2:1:Bh(r[1]-t)0?1:0:i>0?3:2}function o(e,t){return l(e.x,t.x)}function l(e,t){var n=a(e,1),r=a(t,1);return n!==r?n-r:0===n?t[1]-e[1]:1===n?e[0]-t[0]:2===n?e[1]-t[1]:t[0]-e[0]}return function(a){var l,u,c,A,h,d,p,f,m,g,_,v=a,y=Mp(),x={point:b,lineStart:function(){x.point=S,u&&u.push(c=[]);g=!0,m=!1,p=f=NaN},lineEnd:function(){l&&(S(A,h),d&&m&&y.rejoin(),l.push(y.result()));x.point=b,m&&v.lineEnd()},polygonStart:function(){v=y,l=[],u=[],_=!0},polygonEnd:function(){var t=function(){for(var t=0,n=0,i=u.length;nr&&(h-s)*(r-a)>(d-a)*(e-s)&&++t:d<=r&&(h-s)*(r-a)<(d-a)*(e-s)&&--t;return t}(),n=_&&t,i=(l=rA(l)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),s(null,null,1,a),a.lineEnd()),i&&Rp(l,o,t,s,a),a.polygonEnd());v=a,l=u=c=null}};function b(e,t){i(e,t)&&v.point(e,t)}function S(s,a){var o=i(s,a);if(u&&c.push([s,a]),g)A=s,h=a,d=o,g=!1,o&&(v.lineStart(),v.point(s,a));else if(o&&m)v.point(s,a);else{var l=[p=Math.max(Vp,Math.min(zp,p)),f=Math.max(Vp,Math.min(zp,f))],y=[s=Math.max(Vp,Math.min(zp,s)),a=Math.max(Vp,Math.min(zp,a))];!function(e,t,n,r,i,s){var a,o=e[0],l=e[1],u=0,c=1,A=t[0]-o,h=t[1]-l;if(a=n-o,A||!(a>0)){if(a/=A,A<0){if(a0){if(a>c)return;a>u&&(u=a)}if(a=i-o,A||!(a<0)){if(a/=A,A<0){if(a>c)return;a>u&&(u=a)}else if(A>0){if(a0)){if(a/=h,h<0){if(a0){if(a>c)return;a>u&&(u=a)}if(a=s-l,h||!(a<0)){if(a/=h,h<0){if(a>c)return;a>u&&(u=a)}else if(h>0){if(a0&&(e[0]=o+u*A,e[1]=l+u*h),c<1&&(t[0]=o+c*A,t[1]=l+c*h),!0}}}}}(l,y,e,t,n,r)?o&&(v.lineStart(),v.point(s,a),_=!1):(m||(v.lineStart(),v.point(l[0],l[1])),v.point(y[0],y[1]),o||v.lineEnd(),_=!1)}p=s,f=a,m=o}return x}}var jp={sphere:$h,point:$h,lineStart:function(){jp.point=Xp,jp.lineEnd=Wp},lineEnd:$h,polygonStart:$h,polygonEnd:$h};function Wp(){jp.point=jp.lineEnd=$h}function Xp(e,t){kp=e*=Uh,qp=Hh(t*=Uh),Gp=kh(t),jp.point=Qp}function Qp(e,t){e*=Uh;var n=Hh(t*=Uh),r=kh(t),i=Bh(e-kp),s=kh(i),a=r*Hh(i),o=Gp*n-qp*r*s,l=qp*n+Gp*r*s;Fp.add(Fh(Wh(a*a+o*o),l)),kp=e,qp=n,Gp=r}var Yp=[null,null],$p={type:"LineString",coordinates:Yp};function Kp(e,t){return Yp[0]=e,Yp[1]=t,function(e){return Fp=new Kc,nd(e,jp),+Fp}($p)}var Zp={Feature:function(e,t){return ef(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r0&&(i=Kp(e[s],e[s-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))Ch})).map(l)).concat(iA(qh(s/d)*d,i,d).filter((function(e){return Bh(e%f)>Ch})).map(u))}return g.lines=function(){return _().map((function(e){return{type:"LineString",coordinates:e}}))},g.outline=function(){return{type:"Polygon",coordinates:[c(r).concat(A(a).slice(1),c(n).reverse().slice(1),A(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?(r=+e[0][0],n=+e[1][0],o=+e[0][1],a=+e[1][1],r>n&&(e=r,r=n,n=e),o>a&&(e=o,o=a,a=e),g.precision(m)):[[r,o],[n,a]]},g.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],s=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),s>i&&(n=s,s=i,i=n),g.precision(m)):[[t,s],[e,i]]},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?(h=+e[0],d=+e[1],g):[h,d]},g.precision=function(h){return arguments.length?(m=+h,l=of(s,i,90),u=lf(t,e,m),c=of(o,a,90),A=lf(r,n,m),g):m},g.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}()()}function cf(e,t){var n=e[0]*Uh,r=e[1]*Uh,i=t[0]*Uh,s=t[1]*Uh,a=kh(r),o=Hh(r),l=kh(s),u=Hh(s),c=a*kh(n),A=a*Hh(n),h=l*kh(i),d=l*Hh(i),p=2*Qh(Wh(Yh(s-r)+a*l*Yh(i-n))),f=Hh(p),m=p?function(e){var t=Hh(e*=p)/f,n=Hh(p-e)/f,r=n*c+t*h,i=n*A+t*d,s=n*o+t*u;return[Fh(i,r)*Ih,Fh(s,Wh(r*r+i*i))*Ih]}:function(){return[n*Ih,r*Ih]};return m.distance=p,m}var Af=e=>e,hf=1/0,df=hf,pf=-hf,ff=pf,mf={point:function(e,t){epf&&(pf=e);tff&&(ff=t)},lineStart:$h,lineEnd:$h,polygonStart:$h,polygonEnd:$h,result:function(){var e=[[hf,df],[pf,ff]];return pf=ff=-(df=hf=1/0),e}};function gf(e){return function(t){var n=new _f;for(var r in e)n[r]=e[r];return n.stream=t,n}}function _f(){}function vf(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),null!=r&&e.clipExtent(null),nd(n,e.stream(mf)),t(mf.result()),null!=r&&e.clipExtent(r),e}function yf(e,t,n){return vf(e,(function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],s=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),a=+t[0][0]+(r-s*(n[1][0]+n[0][0]))/2,o=+t[0][1]+(i-s*(n[1][1]+n[0][1]))/2;e.scale(150*s).translate([a,o])}),n)}_f.prototype={constructor:_f,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 xf=kh(30*Uh);function bf(e,t){return+t?function(e,t){function n(r,i,s,a,o,l,u,c,A,h,d,p,f,m){var g=u-r,_=c-i,v=g*g+_*_;if(v>4*t&&f--){var y=a+h,x=o+d,b=l+p,S=Wh(y*y+x*x+b*b),w=Qh(b/=S),T=Bh(Bh(b)-1)t||Bh((g*R+_*N)/v-.5)>.3||a*h+o*d+l*p2?e[2]%360*Uh:0,R()):[m*Ih,g*Ih,_*Ih]},E.angle=function(e){return arguments.length?(v=e%360*Uh,R()):v*Ih},E.reflectX=function(e){return arguments.length?(y=e?-1:1,R()):y<0},E.reflectY=function(e){return arguments.length?(x=e?-1:1,R()):x<0},E.precision=function(e){return arguments.length?(a=bf(o,M=e*e),N()):Wh(M)},E.fitExtent=function(e,t){return yf(E,e,t)},E.fitSize=function(e,t){return function(e,t,n){return yf(e,[[0,0],t],n)}(E,e,t)},E.fitWidth=function(e,t){return function(e,t,n){return vf(e,(function(n){var r=+t,i=r/(n[1][0]-n[0][0]),s=(r-i*(n[1][0]+n[0][0]))/2,a=-i*n[0][1];e.scale(150*i).translate([s,a])}),n)}(E,e,t)},E.fitHeight=function(e,t){return function(e,t,n){return vf(e,(function(n){var r=+t,i=r/(n[1][1]-n[0][1]),s=-i*n[0][0],a=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([s,a])}),n)}(E,e,t)},function(){return t=e.apply(this,arguments),E.invert=t.invert&&C,R()}}((function(){return e}))()}function Mf(e,t){return[e,Vh(Xh((Ph+t)/2))]}function Ef(e,t){var n=kh(t),r=1+kh(e)*n;return[n*Hh(e)/r,Hh(t)/r]}function Cf(){return Tf(Ef).scale(250).clipAngle(142)}function Rf(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=[],o=Math.pow(2,e),l=360/o,u=180/o,c=void 0===i?o-1:i,A=void 0===s?o-1:s,h=n,d=Math.min(o-1,c);h<=d;h++)for(var p=r,f=Math.min(o-1,A);p<=f;p++){var m=p,g=u;if(t)m=0===p?p:Zf(p/o)*o,g=180*((p+1===o?p+1:Zf((p+1)/o)*o)-m)/o;var _=(h+.5)*l-180,v=90-(180*m/o+g/2),y=g;a.push({x:h,y:p,lng:_,lat:v,latLen:y})}return a},tm=new WeakMap,nm=new WeakMap,rm=new WeakMap,im=new WeakMap,sm=new WeakMap,am=new WeakMap,om=new WeakMap,lm=new WeakMap,um=new WeakSet,cm=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.tileUrl,s=r.minLevel,a=void 0===s?0:s,o=r.maxLevel,l=void 0===o?17:o,u=r.mercatorProjection,c=void 0===u||u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){Df(e,t),t.add(e)}(n=Pf(this,t),um),If(n,tm,void 0),If(n,nm,void 0),If(n,rm,void 0),If(n,im,void 0),If(n,sm,{}),If(n,am,void 0),If(n,om,void 0),If(n,lm,void 0),Of(n,"minLevel",void 0),Of(n,"maxLevel",void 0),Of(n,"thresholds",zf(new Array(30)).map((function(e,t){return 8/Math.pow(2,t)}))),Of(n,"curvatureResolution",5),Of(n,"tileMargin",0),Of(n,"clearTiles",(function(){Object.values(Lf(sm,n)).forEach((function(e){e.forEach((function(e){e.obj&&(n.remove(e.obj),Xf(e.obj),delete e.obj)}))})),Uf(sm,n,{})})),Uf(tm,n,e),n.tileUrl=i,Uf(nm,n,c),n.minLevel=a,n.maxLevel=l,n.level=0,n.add(Uf(lm,n,new ci(new la(.99*Lf(tm,n),180,90),new Lr({color:0})))),Lf(lm,n).visible=!1,Lf(lm,n).material.polygonOffset=!0,Lf(lm,n).material.polygonOffsetUnits=3,Lf(lm,n).material.polygonOffsetFactor=1,n}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.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),qf(e,t)}(t,e),Bf(t,[{key:"tileUrl",get:function(){return Lf(rm,this)},set:function(e){Uf(rm,this,e),this.updatePov(Lf(om,this))}},{key:"level",get:function(){return Lf(im,this)},set:function(e){var t=this;Lf(sm,this)[e]||Nf(um,this,Am).call(this,e);var n=Lf(im,this);if(Uf(im,this,e),e!==n&&void 0!==n){if(Lf(lm,this).visible=e>0,Lf(sm,this)[e].forEach((function(e){return e.obj&&(e.obj.material.depthWrite=!0)})),ne)for(var r=e+1;r<=n;r++)Lf(sm,this)[r]&&Lf(sm,this)[r].forEach((function(e){e.obj&&(t.remove(e.obj),Xf(e.obj),delete e.obj)}));Nf(um,this,hm).call(this)}}},{key:"updatePov",value:function(e){var t,n=this;if(e&&e instanceof _i&&(Uf(om,this,e),Uf(am,this,(function(r){if(!r.hullPnts){var i=360/Math.pow(2,n.level),s=r.lng,a=r.lat,o=r.latLen,l=s-i/2,u=s+i/2,c=a-o/2,A=a+o/2;r.hullPnts=[[a,s],[c,l],[A,l],[c,u],[A,u]].map((function(e){var t=Gf(e,2);return Qf(t[0],t[1],Lf(tm,n))})).map((function(e){var t=e.x,n=e.y,r=e.z;return new on(t,n,r)}))}return t||(t=new qi,e.updateMatrix(),e.updateMatrixWorld(),t.setFromProjectionMatrix((new On).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse))),r.hullPnts.some((function(e){return t.containsPoint(e.clone().applyMatrix4(n.matrixWorld))}))})),this.tileUrl)){var r=(e.position.clone().distanceTo(this.getWorldPosition(new on))-Lf(tm,this))/Lf(tm,this),i=this.thresholds.findIndex((function(e){return e&&e<=r}));this.level=Math.min(this.maxLevel,Math.max(this.minLevel,i<0?this.thresholds.length:i)),Nf(um,this,hm).call(this)}}}])}(as);function Am(e){var t=this;if(e>7)Lf(sm,this)[e]=[];else{var n=Lf(sm,this)[e]=em(e,Lf(nm,this));n.forEach((function(e){return e.centroid=Qf(e.lat,e.lng,Lf(tm,t))})),n.octree=Gc().x((function(e){return e.centroid.x})).y((function(e){return e.centroid.y})).z((function(e){return e.centroid.z})).addAll(n)}}function hm(){var e=this;if(this.tileUrl&&void 0!==this.level&&Lf(sm,this).hasOwnProperty(this.level)&&(Lf(am,this)||!(this.level>6))){var t=Lf(sm,this)[this.level];if(Lf(om,this)){var n=this.worldToLocal(Lf(om,this).position.clone());if(t.octree){var r,i=this.worldToLocal(Lf(om,this).position.clone()),s=3*(i.length()-Lf(tm,this));t=(r=t.octree).findAllWithinRadius.apply(r,zf(i).concat([s]))}else{var a=function(e){var t=e.x,n=e.y,r=e.z,i=Math.sqrt(t*t+n*n+r*r),s=Math.acos(n/i),a=Math.atan2(r,t);return{lat:90-180*s/Math.PI,lng:90-180*a/Math.PI-(a<-Math.PI/2?360:0),r:i}}(n),o=90*(a.r/Lf(tm,this)-1),l=o/Math.cos(Yf(a.lat)),u=[a.lng-l,a.lng+l],c=[a.lat+o,a.lat-o],A=Gf(Jf(this.level,Lf(nm,this),u[0],c[0]),2),h=A[0],d=A[1],p=Gf(Jf(this.level,Lf(nm,this),u[1],c[1]),2),f=p[0],m=p[1];!t.record&&(t.record={});var g=t.record;if(g.hasOwnProperty("".concat(Math.round((h+f)/2),"_").concat(Math.round((d+m)/2)))){for(var _=[],v=h;v<=f;v++)for(var y=d;y<=m;y++){var x="".concat(v,"_").concat(y);g.hasOwnProperty(x)||(g[x]=em(this.level,Lf(nm,this),v,y,v,y)[0],t.push(g[x])),_.push(g[x])}t=_}else t=em(this.level,Lf(nm,this),h,d,f,m).map((function(e){var n="".concat(e.x,"_").concat(e.y);return g.hasOwnProperty(n)?g[n]:(g[n]=e,t.push(e),e)}))}}t.filter((function(e){return!e.obj})).filter(Lf(am,this)||function(){return!0}).forEach((function(t){var n=t.x,r=t.y,i=t.lng,s=t.lat,a=t.latLen,o=360/Math.pow(2,e.level);if(!t.obj){var l=o*(1-e.tileMargin),u=a*(1-e.tileMargin),c=Yf(i),A=Yf(-s),h=new ci(new la(Lf(tm,e),Math.ceil(l/e.curvatureResolution),Math.ceil(u/e.curvatureResolution),Yf(90-l/2)+c,Yf(l),Yf(90-u/2)+A,Yf(u)),new _a);if(Lf(nm,e)){var d=Gf([s+a/2,s-a/2].map((function(e){return.5-e/180})),2),p=d[0],f=d[1];!function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=Mh().domain([1,0]).range([t,n]).clamp(!0),i=Mh().domain([Kf(t),Kf(n)]).range([1,0]).clamp(!0),s=function(e){return i(Kf(r(e)))},a=e.array,o=0,l=a.length;o80*n){o=1/0,l=1/0;let t=-1/0,r=-1/0;for(let s=n;st&&(t=n),i>r&&(r=i)}u=Math.max(t-o,r-l),u=0!==u?32767/u:0}return mm(s,a,n,o,l,u,0),a}function pm(e,t,n,r,i){let s;if(i===function(e,t,n,r){let i=0;for(let s=t,a=n-r;s0)for(let i=t;i=t;i-=r)s=Bm(i/r|0,e[i],e[i+1],s);return s&&Nm(s,s.next)&&(Om(s),s=s.next),s}function fm(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!Nm(r,r.next)&&0!==Rm(r.prev,r,r.next))r=r.next;else{if(Om(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function mm(e,t,n,r,i,s,a){if(!e)return;!a&&s&&function(e,t,n,r){let i=e;do{0===i.z&&(i.z=wm(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n=1;do{let r,i=e;e=null;let s=null;for(t=0;i;){t++;let a=i,o=0;for(let e=0;e0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(r=i,i=i.nextZ,o--):(r=a,a=a.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;i=a}s.nextZ=null,n*=2}while(t>1)}(i)}(e,r,i,s);let o=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(s?_m(e,r,i,s):gm(e))t.push(l.i,e.i,u.i),Om(e),e=u.next,o=u.next;else if((e=u)===o){a?1===a?mm(e=vm(fm(e),t),t,n,r,i,s,2):2===a&&ym(e,t,n,r,i,s):mm(fm(e),t,n,r,i,s,1);break}}}function gm(e){const t=e.prev,n=e,r=e.next;if(Rm(t,n,r)>=0)return!1;const i=t.x,s=n.x,a=r.x,o=t.y,l=n.y,u=r.y,c=Math.min(i,s,a),A=Math.min(o,l,u),h=Math.max(i,s,a),d=Math.max(o,l,u);let p=r.next;for(;p!==t;){if(p.x>=c&&p.x<=h&&p.y>=A&&p.y<=d&&Em(i,o,s,l,a,u,p.x,p.y)&&Rm(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function _m(e,t,n,r){const i=e.prev,s=e,a=e.next;if(Rm(i,s,a)>=0)return!1;const o=i.x,l=s.x,u=a.x,c=i.y,A=s.y,h=a.y,d=Math.min(o,l,u),p=Math.min(c,A,h),f=Math.max(o,l,u),m=Math.max(c,A,h),g=wm(d,p,t,n,r),_=wm(f,m,t,n,r);let v=e.prevZ,y=e.nextZ;for(;v&&v.z>=g&&y&&y.z<=_;){if(v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==i&&v!==a&&Em(o,c,l,A,u,h,v.x,v.y)&&Rm(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==i&&y!==a&&Em(o,c,l,A,u,h,y.x,y.y)&&Rm(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;v&&v.z>=g;){if(v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==i&&v!==a&&Em(o,c,l,A,u,h,v.x,v.y)&&Rm(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;y&&y.z<=_;){if(y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==i&&y!==a&&Em(o,c,l,A,u,h,y.x,y.y)&&Rm(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function vm(e,t){let n=e;do{const r=n.prev,i=n.next.next;!Nm(r,i)&&Pm(r,n,n.next,i)&&Im(r,i)&&Im(i,r)&&(t.push(r.i,n.i,i.i),Om(n),Om(n.next),n=e=i),n=n.next}while(n!==e);return fm(n)}function ym(e,t,n,r,i,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Cm(a,e)){let o=Um(a,e);return a=fm(a,a.next),o=fm(o,o.next),mm(a,t,n,r,i,s,0),void mm(o,t,n,r,i,s,0)}e=e.next}a=a.next}while(a!==e)}function xm(e,t){let n=e.x-t.x;if(0===n&&(n=e.y-t.y,0===n)){n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return n}function bm(e,t){const n=function(e,t){let n=t;const r=e.x,i=e.y;let s,a=-1/0;if(Nm(e,n))return n;do{if(Nm(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,s=n.x=n.x&&n.x>=l&&r!==n.x&&Mm(is.x||n.x===s.x&&Sm(s,n)))&&(s=n,c=t)}n=n.next}while(n!==o);return s}(e,t);if(!n)return t;const r=Um(n,e);return fm(r,r.next),fm(n,n.next)}function Sm(e,t){return Rm(e.prev,e,t.prev)<0&&Rm(t.next,e,e.next)<0}function wm(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Tm(e){let t=e,n=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(r-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(i-a)*(r-o)}function Em(e,t,n,r,i,s,a,o){return!(e===a&&t===o)&&Mm(e,t,n,r,i,s,a,o)}function Cm(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Pm(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Im(e,t)&&Im(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Rm(e.prev,e,t.prev)||Rm(e,t.prev,t))||Nm(e,t)&&Rm(e.prev,e,e.next)>0&&Rm(t.prev,t,t.next)>0)}function Rm(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Nm(e,t){return e.x===t.x&&e.y===t.y}function Pm(e,t,n,r){const i=Lm(Rm(e,t,n)),s=Lm(Rm(e,t,r)),a=Lm(Rm(n,r,e)),o=Lm(Rm(n,r,t));return i!==s&&a!==o||(!(0!==i||!Dm(e,n,t))||(!(0!==s||!Dm(e,r,t))||(!(0!==a||!Dm(n,e,r))||!(0!==o||!Dm(n,t,r)))))}function Dm(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Lm(e){return e>0?1:e<0?-1:0}function Im(e,t){return Rm(e.prev,e,e.next)<0?Rm(e,t,e.next)>=0&&Rm(e,e.prev,t)>=0:Rm(e,t,e.prev)<0||Rm(e,e.next,t)<0}function Um(e,t){const n=Fm(e.i,e.x,e.y),r=Fm(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function Bm(e,t,n,r){const i=Fm(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Om(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 Fm(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(e){const t=[],n=[],r=e[0][0].length;let i=0,s=0;for(const a of e){for(const e of a)for(let n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&void 0!==arguments[1]?arguments[1]:1,t=[],n=null;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((function(r){if(n){var i=180*Kp(r,n)/Math.PI;if(i>e)for(var s=cf(n,r),a=n.length>2||r.length>2?YA(n[2]||0,r[2]||0):null,o=a?function(e){return[].concat(Wm(s(e)),[a(e)])}:s,l=1/Math.ceil(i/e),u=l;u<1;)t.push(o(u)),u+=l}t.push(n=r)})),t},Ym="undefined"!=typeof window&&window.THREE?window.THREE:{BufferGeometry:Zr,Float32BufferAttribute:Hr},$m=(new Ym.BufferGeometry).setAttribute?"setAttribute":"addAttribute",Km=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=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),(n=Gm(this,t)).type="GeoJsonGeometry",n.parameters={geoJson:e,radius:r,resolution:i};var s=({Point:u,MultiPoint:function(e,t){var n={vertices:[],indices:[]};return e.map((function(e){return u(e,t)})).forEach((function(e){var t=jm(e,1)[0];Zm(n,t)})),[n]},LineString:c,MultiLineString:function(e,t){var n={vertices:[],indices:[]};return e.map((function(e){return c(e,t)})).forEach((function(e){var t=jm(e,1)[0];Zm(n,t)})),[n]},Polygon:A,MultiPolygon:function(e,t){var n={vertices:[],indices:[]},r={vertices:[],indices:[]};e.map((function(e){return A(e,t)})).forEach((function(e){var t=jm(e,2),i=t[0],s=t[1];Zm(n,i),s&&Zm(r,s)}));var i=[n];return r.vertices.length&&i.push(r),i}}[e.type]||function(){return[]})(e.coordinates,r),a=[],o=[],l=0;function u(e,t){return[{vertices:eg(e[1],e[0],t+(e[2]||0)),indices:[]}]}function c(e,t){for(var n=km([Qm(e,i).map((function(e){var n=jm(e,3),r=n[0],i=n[1],s=n[2];return eg(i,r,t+(void 0===s?0:s))}))]).vertices,r=Math.round(n.length/3),s=[],a=1;a=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}(t);try{for(r.s();!(n=r.n()).done;){var i=n.value;e.push(i)}}catch(e){r.e(e)}finally{r.f()}}function eg(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}function tg(e){let t,n,r,i=-1,s=0;for(let a=0;a=2&&a.setY(t,e.getY(t)),r>=3&&a.setZ(t,e.getZ(t)),r>=4&&a.setW(t,e.getW(t));return a}var rg=Object.freeze({__proto__:null,computeMikkTSpaceTangents:function(e,t,n=!0){if(!t||!t.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!e.hasAttribute("position")||!e.hasAttribute("normal")||!e.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function r(e){if(e.normalized||e.isInterleavedBufferAttribute){const t=new Float32Array(e.count*e.itemSize);for(let n=0,r=0;n2&&(t[r++]=e.getZ(n));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}const i=e.index?e.toNonIndexed():e,s=t.generateTangents(r(i.attributes.position),r(i.attributes.normal),r(i.attributes.uv));if(n)for(let e=3;ee.materialIndex!==t.materialIndex?e.materialIndex-t.materialIndex:e.start-t.start)),null===e.getIndex()){const t=e.getAttribute("position"),n=[];for(let e=0;e{const r=new e.array.constructor(e.count*e.itemSize);u[n][t]=new e.constructor(r,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;tn&&l.add(t)}l.normalize(),p.setXYZ(t+e,l.x,l.y,l.z)}}return c.setAttribute("normal",p),c},toTrianglesDrawMode:function(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(e=Cg(e,360),t=Cg(t,100),n=Cg(n,100),0===t)r=i=s=n;else{var o=n<.5?n*(1+t):n+t-n*t,l=2*n-o;r=a(l,o,e+1/3),i=a(l,o,e),s=a(l,o,e-1/3)}return{r:255*r,g:255*i,b:255*s}}(e.h,r,s),a=!0,o="hsl"),e.hasOwnProperty("a")&&(n=e.a));return n=Eg(n),{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:n}}(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.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=n.ok}function ug(e,t,n){e=Cg(e,255),t=Cg(t,255),n=Cg(n,255);var r,i,s=Math.max(e,t,n),a=Math.min(e,t,n),o=(s+a)/2;if(s==a)r=i=0;else{var l=s-a;switch(i=o>.5?l/(2-s-a):l/(s+a),s){case e:r=(t-n)/l+(t>1)+720)%360;--t;)r.h=(r.h+i)%360,s.push(lg(r));return s}function wg(e,t){t=t||6;for(var n=lg(e).toHsv(),r=n.h,i=n.s,s=n.v,a=[],o=1/t;t--;)a.push(lg({h:r,s:i,v:s})),s=(s+o)%1;return a}lg.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,n,r=this.toRgb();return e=r.r/255,t=r.g/255,n=r.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*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},setAlpha:function(e){return this._a=Eg(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=cg(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=cg(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=ug(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=ug(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return Ag(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,t,n,r,i){var s=[Pg(Math.round(e).toString(16)),Pg(Math.round(t).toString(16)),Pg(Math.round(n).toString(16)),Pg(Lg(r))];if(i&&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*Cg(this._r,255))+"%",g:Math.round(100*Cg(this._g,255))+"%",b:Math.round(100*Cg(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*Cg(this._r,255))+"%, "+Math.round(100*Cg(this._g,255))+"%, "+Math.round(100*Cg(this._b,255))+"%)":"rgba("+Math.round(100*Cg(this._r,255))+"%, "+Math.round(100*Cg(this._g,255))+"%, "+Math.round(100*Cg(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(Mg[Ag(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+hg(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var i=lg(e);n="#"+hg(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(n=this.toRgbString()),"prgb"===e&&(n=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(n=this.toHexString()),"hex3"===e&&(n=this.toHexString(!0)),"hex4"===e&&(n=this.toHex8String(!0)),"hex8"===e&&(n=this.toHex8String()),"name"===e&&(n=this.toName()),"hsl"===e&&(n=this.toHslString()),"hsv"===e&&(n=this.toHsvString()),n||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return lg(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(mg,arguments)},brighten:function(){return this._applyModification(gg,arguments)},darken:function(){return this._applyModification(_g,arguments)},desaturate:function(){return this._applyModification(dg,arguments)},saturate:function(){return this._applyModification(pg,arguments)},greyscale:function(){return this._applyModification(fg,arguments)},spin:function(){return this._applyModification(vg,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(Sg,arguments)},complement:function(){return this._applyCombination(yg,arguments)},monochromatic:function(){return this._applyCombination(wg,arguments)},splitcomplement:function(){return this._applyCombination(bg,arguments)},triad:function(){return this._applyCombination(xg,[3])},tetrad:function(){return this._applyCombination(xg,[4])}},lg.fromRatio=function(e,t){if("object"==sg(e)){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]="a"===r?e[r]:Dg(e[r]));e=n}return lg(e,t)},lg.equals=function(e,t){return!(!e||!t)&&lg(e).toRgbString()==lg(t).toRgbString()},lg.random=function(){return lg.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},lg.mix=function(e,t,n){n=0===n?0:n||50;var r=lg(e).toRgb(),i=lg(t).toRgb(),s=n/100;return lg({r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(i.a-r.a)*s+r.a})}, // =4.5;break;case"AAlarge":i=s>=3;break;case"AAAsmall":i=s>=7}return i},lg.mostReadable=function(e,t,n){var r,i,s,a,o=null,l=0;i=(n=n||{}).includeFallbackColors,s=n.level,a=n.size;for(var u=0;ul&&(l=r,o=lg(t[u]));return lg.isReadable(e,o,{level:s,size:a})||!i?o:(n.includeFallbackColors=!1,lg.mostReadable(e,["#fff","#000"],n))};var Tg=lg.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"},Mg=lg.hexNames=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}(Tg);function Eg(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function Cg(e,t){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var n=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function Rg(e){return Math.min(1,Math.max(0,e))}function Ng(e){return parseInt(e,16)}function Pg(e){return 1==e.length?"0"+e:""+e}function Dg(e){return e<=1&&(e=100*e+"%"),e}function Lg(e){return Math.round(255*parseFloat(e)).toString(16)}function Ig(e){return Ng(e)/255}var Ug,Bg,Og,Fg=(Bg="[\\s|\\(]+("+(Ug="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+Ug+")[,|\\s]+("+Ug+")\\s*\\)?",Og="[\\s|\\(]+("+Ug+")[,|\\s]+("+Ug+")[,|\\s]+("+Ug+")[,|\\s]+("+Ug+")\\s*\\)?",{CSS_UNIT:new RegExp(Ug),rgb:new RegExp("rgb"+Bg),rgba:new RegExp("rgba"+Og),hsl:new RegExp("hsl"+Bg),hsla:new RegExp("hsla"+Og),hsv:new RegExp("hsv"+Bg),hsva:new RegExp("hsva"+Og),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 kg(e){return!!Fg.CSS_UNIT.exec(e)}function qg(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=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=i},function(e,t,n){!function(t,n){e.exports=n()}(0,(function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){var n=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;tu==c>-u?(s=u,u=t[++A]):(s=c,c=r[++h]);let d=0;if(Au==c>-u?(a=u+s,o=s-(a-u),u=t[++A]):(a=c+s,o=s-(a-c),c=r[++h]),s=a,0!==o&&(i[d++]=o);Au==c>-u?(a=s+u,l=a-s,o=s-(a-l)+(u-l),u=t[++A]):(a=s+c,l=a-s,o=s-(a-l)+(c-l),c=r[++h]),s=a,0!==o&&(i[d++]=o);for(;A=33306690738754716e-32*u?l:-function(e,t,n,r,i,s,a){let o,l,u,c,A,h,d,p,f,m,g,_,v,y,x,b,S,w;const T=e-i,M=n-i,E=t-s,C=r-s;y=T*C,h=l_*T,d=h-(h-T),p=T-d,h=l_*C,f=h-(h-C),m=C-f,x=p*m-(y-d*f-p*f-d*m),b=E*M,h=l_*E,d=h-(h-E),p=E-d,h=l_*M,f=h-(h-M),m=M-f,S=p*m-(b-d*f-p*f-d*m),g=x-S,A=x-g,A_[0]=x-(g+A)+(A-S),_=y+g,A=_-y,v=y-(_-A)+(g-A),g=v-b,A=v-g,A_[1]=v-(g+A)+(A-b),w=_+g,A=w-_,A_[2]=_-(w-A)+(g-A),A_[3]=w;let R=function(e,t){let n=t[0];for(let r=1;r=N||-R>=N)return R;if(A=e-T,o=e-(T+A)+(A-i),A=n-M,u=n-(M+A)+(A-i),A=t-E,l=t-(E+A)+(A-s),A=r-C,c=r-(C+A)+(A-s),0===o&&0===l&&0===u&&0===c)return R;if(N=11093356479670487e-47*a+33306690738754706e-32*Math.abs(R),R+=T*c+C*o-(E*u+M*l),R>=N||-R>=N)return R;y=o*C,h=l_*o,d=h-(h-o),p=o-d,h=l_*C,f=h-(h-C),m=C-f,x=p*m-(y-d*f-p*f-d*m),b=l*M,h=l_*l,d=h-(h-l),p=l-d,h=l_*M,f=h-(h-M),m=M-f,S=p*m-(b-d*f-p*f-d*m),g=x-S,A=x-g,f_[0]=x-(g+A)+(A-S),_=y+g,A=_-y,v=y-(_-A)+(g-A),g=v-b,A=v-g,f_[1]=v-(g+A)+(A-b),w=_+g,A=w-_,f_[2]=_-(w-A)+(g-A),f_[3]=w;const P=u_(4,A_,4,f_,h_);y=T*c,h=l_*T,d=h-(h-T),p=T-d,h=l_*c,f=h-(h-c),m=c-f,x=p*m-(y-d*f-p*f-d*m),b=E*u,h=l_*E,d=h-(h-E),p=E-d,h=l_*u,f=h-(h-u),m=u-f,S=p*m-(b-d*f-p*f-d*m),g=x-S,A=x-g,f_[0]=x-(g+A)+(A-S),_=y+g,A=_-y,v=y-(_-A)+(g-A),g=v-b,A=v-g,f_[1]=v-(g+A)+(A-b),w=_+g,A=w-_,f_[2]=_-(w-A)+(g-A),f_[3]=w;const D=u_(P,h_,4,f_,d_);y=o*c,h=l_*o,d=h-(h-o),p=o-d,h=l_*c,f=h-(h-c),m=c-f,x=p*m-(y-d*f-p*f-d*m),b=l*u,h=l_*l,d=h-(h-l),p=l-d,h=l_*u,f=h-(h-u),m=u-f,S=p*m-(b-d*f-p*f-d*m),g=x-S,A=x-g,f_[0]=x-(g+A)+(A-S),_=y+g,A=_-y,v=y-(_-A)+(g-A),g=v-b,A=v-g,f_[1]=v-(g+A)+(A-b),w=_+g,A=w-_,f_[2]=_-(w-A)+(g-A),f_[3]=w;const L=u_(D,d_,4,f_,p_);return p_[L-1]}(e,t,n,r,i,s,u)}const g_=Math.pow(2,-52),__=new Uint32Array(512);class v_{static from(e,t=T_,n=M_){const r=e.length,i=new Float64Array(2*r);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 n=Math.max(2*t-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),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:n,_hullTri:r,_hullHash:i}=this,s=e.length>>1;let a=1/0,o=1/0,l=-1/0,u=-1/0;for(let t=0;tl&&(l=n),r>u&&(u=r),this._ids[t]=t}const c=(a+l)/2,A=(o+u)/2;let h,d,p;for(let t=0,n=1/0;t0&&(d=t,n=r)}let g=e[2*d],_=e[2*d+1],v=1/0;for(let t=0;tr&&(t[n++]=i,r=s)}return this.hull=t.subarray(0,n),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(m_(f,m,g,_,y,x)<0){const e=d,t=g,n=_;d=p,g=y,_=x,p=e,y=t,x=n}const b=function(e,t,n,r,i,s){const a=n-e,o=r-t,l=i-e,u=s-t,c=a*a+o*o,A=l*l+u*u,h=.5/(a*u-o*l),d=e+(u*c-o*A)*h,p=t+(a*A-l*c)*h;return{x:d,y:p}}(f,m,g,_,y,x);this._cx=b.x,this._cy=b.y;for(let t=0;t0&&Math.abs(u-s)<=g_&&Math.abs(c-a)<=g_)continue;if(s=u,a=c,l===h||l===d||l===p)continue;let A=0;for(let e=0,t=this._hashKey(u,c);e=0;)if(m=f,m===A){m=-1;break}if(-1===m)continue;let g=this._addTriangle(m,l,n[m],-1,-1,r[m]);r[l]=this._legalize(g+2),r[m]=g,S++;let _=n[m];for(;f=n[_],m_(u,c,e[2*_],e[2*_+1],e[2*f],e[2*f+1])<0;)g=this._addTriangle(_,l,f,r[l],-1,r[_]),r[l]=this._legalize(g+2),n[_]=_,S--,_=f;if(m===A)for(;f=t[m],m_(u,c,e[2*f],e[2*f+1],e[2*m],e[2*m+1])<0;)g=this._addTriangle(f,l,m,-1,r[m],r[f]),this._legalize(g+2),r[f]=g,n[m]=m,S--,m=f;this._hullStart=t[l]=m,n[m]=t[_]=l,n[l]=_,i[this._hashKey(u,c)]=l,i[this._hashKey(e[2*m],e[2*m+1])]=m}this.hull=new Uint32Array(S);for(let e=0,t=this._hullStart;e0?3-n:1+n)/4}(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:n,coords:r}=this;let i=0,s=0;for(;;){const a=n[e],o=e-e%3;if(s=o+(e+2)%3,-1===a){if(0===i)break;e=__[--i];continue}const l=a-a%3,u=o+(e+1)%3,c=l+(a+2)%3,A=t[s],h=t[e],d=t[u],p=t[c];if(x_(r[2*A],r[2*A+1],r[2*h],r[2*h+1],r[2*d],r[2*d+1],r[2*p],r[2*p+1])){t[e]=p,t[a]=A;const r=n[c];if(-1===r){let t=this._hullStart;do{if(this._hullTri[t]===c){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(a,n[s]),this._link(s,c);const o=l+(a+1)%3;i<__.length&&(__[i++]=o)}else{if(0===i)break;e=__[--i]}}return s}_link(e,t){this._halfedges[e]=t,-1!==t&&(this._halfedges[t]=e)}_addTriangle(e,t,n,r,i,s){const a=this.trianglesLen;return this._triangles[a]=e,this._triangles[a+1]=t,this._triangles[a+2]=n,this._link(a,r),this._link(a+1,i),this._link(a+2,s),this.trianglesLen+=3,a}}function y_(e,t,n,r){const i=e-n,s=t-r;return i*i+s*s}function x_(e,t,n,r,i,s,a,o){const l=e-a,u=t-o,c=n-a,A=r-o,h=i-a,d=s-o,p=c*c+A*A,f=h*h+d*d;return l*(A*f-p*d)-u*(c*f-p*h)+(l*l+u*u)*(c*d-A*h)<0}function b_(e,t,n,r,i,s){const a=n-e,o=r-t,l=i-e,u=s-t,c=a*a+o*o,A=l*l+u*u,h=.5/(a*u-o*l),d=(u*c-o*A)*h,p=(a*A-l*c)*h;return d*d+p*p}function S_(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){const r=e[i],s=t[r];let a=i-1;for(;a>=n&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=r}else{let i=n+1,s=r;w_(e,n+r>>1,i),t[e[n]]>t[e[r]]&&w_(e,n,r),t[e[i]]>t[e[r]]&&w_(e,i,r),t[e[n]]>t[e[i]]&&w_(e,n,i);const a=e[i],o=t[a];for(;;){do{i++}while(t[e[i]]o);if(s=s-n?(S_(e,t,i,r),S_(e,t,n,s-1)):(S_(e,t,n,s-1),S_(e,t,i,r))}}function w_(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function T_(e){return e[0]}function M_(e){return e[1]}function E_(e,t){var n,r,i,s,a,o,l,u,c,A=0,h=e[0],d=e[1],p=t.length;for(n=0;n=0||s<=0&&o>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(0===(i=m_(s,o,a,l,0,0)))return 0;(i>0&&l>0&&a<=0||i<0&&l<=0&&a>0)&&A++}u=c,a=l,s=o}}return A%2!=0}var C_=function(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const r=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),i="Feature"===(s=t).type?s.geometry:s;var s;const a=i.type,o=t.bbox;let l=i.coordinates;if(o&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(r,o))return!1;"Polygon"===a&&(l=[l]);let u=!1;for(var c=0;cR_||Math.abs(this._y1-i)>R_)&&(this._+="L"+r+","+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class P_{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 D_{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t)&&(i=+i)>=(n=+n)))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=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let i,s;const a=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r,o,l=0,u=0,c=n.length;l1;)i-=2;for(let e=2;e0){if(t>=this.ymax)return null;(i=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(i=(this.xmax-e)/n)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:n}=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,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]));const e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],s[r[0]]=1,2===r.length&&(s[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new D_(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:s,collinear:a}=this;if(a){const t=a.indexOf(e);return t>0&&(yield a[t-1]),void(t=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){const{inedges:r,hull:i,_hullIndex:s,halfedges:a,triangles:o,points:l}=this;if(-1===r[e]||!l.length)return(e+1)%(l.length>>1);let u=e,c=I_(t-l[2*e],2)+I_(n-l[2*e+1],2);const A=r[e];let h=A;do{let r=o[h];const A=I_(t-l[2*r],2)+I_(n-l[2*r+1],2);if(A0?1:e<0?-1:0},Y_=Math.sqrt;function $_(e){return e>1?q_:e<-1?-q_:Math.asin(e)}function K_(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Z_(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 J_(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function ev(e){var t=Y_(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function tv(e){return[V_(e[1],e[0])*G_,$_(j_(-1,W_(1,e[2])))*G_]}function nv(e){const t=e[0]*z_,n=e[1]*z_,r=H_(n);return[r*H_(t),r*X_(t),X_(n)]}function rv(e){return e=e.map((e=>nv(e))),K_(e[0],Z_(e[2],e[1]))}function iv(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]*Uh:0),t.invert=function(t){return(t=e.invert(t[0]*Uh,t[1]*Uh))[0]*=Ih,t[1]*=Ih,t},t}(e[t]),r=Cf().translate([0,0]).scale(1).rotate(n.invert([180,0]));e=e.map(r);const i=[];let s=1;for(let t=0,n=e.length;t1e32?i.push(t):n>s&&(s=n)}const a=1e6*Y_(s);i.forEach((t=>e[t]=[a,0])),e.push([0,a]),e.push([-a,0]),e.push([0,-a]);const o=F_.from(e);o.projection=r;const{triangles:l,halfedges:u,inedges:c}=o;for(let n=0,r=u.length;ne.length-3-1&&(l[n]=t);return o}(e),n=function(e){const{triangles:t}=e;if(!t)return[];const n=[];for(let e=0,r=t.length/3;e{if(e[0]!==e[1]&&!(rv(e.map((e=>t[e])))<0))for(let t,r=0;r<3;r++)t=(r+1)%3,n.add($c([e[r],e[t]]).join("-"))})),Array.from(n,(e=>e.split("-").map(Number))))}(n,e),i=function(e,t){const n=[];e.forEach((e=>{for(let t=0;t<3;t++){const r=e[t],i=e[(t+1)%3];n[r]=n[r]||[],n[r].push(i)}})),0===e.length&&(2===t?(n[0]=[1],n[1]=[0]):1===t&&(n[0]=[]));return n}(n,e.length),s=function(e,t){function n(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return n*n+r*r+i*i}return function(r,i,s){void 0===s&&(s=0);let a,o,l=s;const u=nv([r,i]);do{a=s,s=null,o=n(u,nv(t[a])),e[a].forEach((e=>{let r=n(u,nv(t[e]));if(r{const n=e.map((e=>t[e])).map(nv);return tv(ev(J_(J_(Z_(n[1],n[0]),Z_(n[2],n[1])),Z_(n[0],n[2]))))}))}(n,e),{polygons:o,centers:l}=function(e,t,n){const r=[],i=e.slice();if(0===t.length){if(n.length<2)return{polygons:r,centers:i};if(2===n.length){const e=nv(n[0]),t=nv(n[1]),s=ev(J_(e,t)),o=ev(Z_(e,t)),l=Z_(s,o),u=[s,Z_(s,l),Z_(Z_(s,l),l),Z_(Z_(Z_(s,l),l),l)].map(tv).map(a);return r.push(u),r.push(u.slice().reverse()),{polygons:r,centers:i}}}t.forEach(((e,t)=>{for(let n=0;n<3;n++){const i=e[n],s=e[(n+1)%3],a=e[(n+2)%3];r[i]=r[i]||[],r[i].push([s,a,t,[i,s,a]])}}));const s=r.map((e=>{const t=[e[0][2]];let r=e[0][1];for(let n=1;n2)return t;if(2==t.length){const r=sv(n[e[0][3][0]],n[e[0][3][1]],i[t[0]]),s=sv(n[e[0][3][2]],n[e[0][3][0]],i[t[0]]),o=a(r),l=a(s);return[t[0],l,t[1],o]}}));function a(e){let n=-1;return i.slice(t.length,1/0).forEach(((r,i)=>{r[0]===e[0]&&r[1]===e[1]&&(n=i+t.length)})),n<0&&(n=i.length,i.push(e)),n}return{polygons:s,centers:i}}(a,n,e),u=function(e){const t=[];return e.forEach((e=>{if(!e)return;let n=e[e.length-1];for(let r of e)r>n&&t.push([n,r]),n=r})),t}(o),c=function(e,t){const n=new Set,r=[];e.map((e=>{if(!(rv(e.map((e=>t[e>t.length?0:e])))>1e-12))for(let t=0;t<3;t++){let r=[e[t],e[(t+1)%3]],i=`${r[0]}-${r[1]}`;n.has(i)?n.delete(i):n.add(`${r[1]}-${r[0]}`)}}));const i=new Map;let s;if(n.forEach((e=>{e=e.split("-").map(Number),i.set(e[0],e[1]),s=e[0]})),void 0===s)return r;let a=s;do{r.push(a);let e=i.get(a);i.set(a,-1),a=e}while(a>-1&&a!==s);return r}(n,e),A=function(e,t){return function(n){const r=new Map,i=new Map;return e.forEach(((e,t)=>{const s=e.join("-");r.set(s,n[t]),i.set(s,!0)})),t.forEach((e=>{let t=0,n=-1;for(let i=0;i<3;i++){let s=$c([e[i],e[(i+1)%3]]).join("-");r.get(s)>t&&(t=r.get(s),n=s)}i.set(n,!1)})),e.map((e=>i.get(e.join("-"))))}}(r,n);return{delaunay:t,edges:r,triangles:n,centers:l,neighbors:i,polygons:o,mesh:u,hull:c,urquhart:A,find:s}}function sv(e,t,n){e=nv(e),t=nv(t),n=nv(n);const r=Q_(K_(Z_(t,e),n));return tv(ev(J_(e,t)).map((e=>r*e)))}function av(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&void 0!==arguments[1]?arguments[1]:{}).resolution,n=void 0===t?1/0:t,r=function(e,t){return e.map((function(e){var n,r=[];return e.forEach((function(e){if(n){var i=180*Kp(e,n)/Math.PI;if(i>t)for(var s=cf(n,e),a=1/Math.ceil(i/t),o=a;o<1;)r.push(s(o)),o+=a}r.push(n=e)})),r}))}(e,n),i=rA(r),s=function(e,t){var n={type:"Polygon",coordinates:e},r=ap(n),i=Av(r,2),s=Av(i[0],2),a=s[0],o=s[1],l=Av(i[1],2),u=l[0],c=l[1];if(Math.min(Math.abs(u-a),Math.abs(c-o))u||c>=89||o<=-89;return function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minLng,r=t.maxLng,i=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},u=function(e){return Math.acos(2*e/a-1)/Math.PI*180-90},c=function(e){return a*(Math.cos((e+90)*Math.PI/180)+1)/2},A=[void 0!==s?Math.ceil(c(s)):0,void 0!==i?Math.floor(c(i)):a-1],h=void 0===n&&void 0===r?function(){return!0}:void 0===n?function(e){return e<=r}:void 0===r?function(e){return e>=n}:r>=n?function(e){return e>=n&&e<=r}:function(e){return e>=n||e<=r},d=[],p=A[0];p<=A[1];p++){var f=l(p);h(f)&&d.push([f,u(p)])}return d}(t,{minLng:a,maxLng:u,minLat:o,maxLat:c}).filter((function(e){return fv(e,n,A)}))}(e,n),a=[].concat(hv(i),hv(s)),o={type:"Polygon",coordinates:e},l=Av(ap(o),2),u=Av(l[0],2),c=u[0],A=u[1],h=Av(l[1],2),d=h[0],p=h[1],f=c>d||p>=89||A<=-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=iv(t.points)}return t};return t._vx=function(e){return"object"==typeof e&&"type"in e?_p(e)[0]:0 in e?e[0]:void 0},t._vy=function(e){return"object"==typeof e&&"type"in e?_p(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 n={type:"FeatureCollection",features:[]};return 0===t.valid.length||(t.delaunay.polygons.forEach(((e,r)=>n.features.push({type:"Feature",geometry:e?{type:"Polygon",coordinates:[[...e,e[0]].map((e=>t.delaunay.centers[e]))]}:null,properties:{site:t.valid[r],sitecoordinates:t.points[r],neighbours:t.delaunay.neighbors[r]}}))),1===t.valid.length&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:t.valid[0],sitecoordinates:t.points[0],neighbours:[]}})),n},t.triangles=function(e){return void 0!==e&&t(e),!!t.delaunay&&{type:"FeatureCollection",features:t.delaunay.triangles.map(((e,n)=>(e=e.map((e=>t.points[e])),e.center=t.delaunay.centers[n],e))).filter((e=>rv(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 n=t.delaunay.edges.map((e=>Kp(t.points[e[0]],t.points[e[1]]))),r=t.delaunay.urquhart(n);return{type:"FeatureCollection",features:t.delaunay.edges.map(((e,i)=>({type:"Feature",properties:{source:t.valid[e[0]],target:t.valid[e[1]],length:n[i],urquhart:!!r[i]},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:n,polygons:r}=t.delaunay,i=[];for(const e of r)if(e)for(let t=e.length,r=e[t-1],s=e[0],a=0;ar&&i.push([n[r],n[s]]);return{type:"MultiLineString",coordinates:i}},t._found=void 0,t.find=function(e,n,r){if(t._found=t.delaunay.find(e,n,t._found),!r||Kp([e,n],t.points[t._found])r[e])),r[n[0]]]]}},t(e)}(a).triangles(),_=new Map(a.map((function(e,t){var n=Av(e,2),r=n[0],i=n[1];return["".concat(r,"-").concat(i),t]})));g.features.forEach((function(e){var t,n=e.geometry.coordinates[0].slice(0,3).reverse(),r=[];if(n.forEach((function(e){var t=Av(e,2),n=t[0],i=t[1],s="".concat(n,"-").concat(i);_.has(s)&&r.push(_.get(s))})),3===r.length){if(r.some((function(e){return e=t&&(++n,r+=t);else{let i=-1;for(let s of e)null!=(s=t(s,++i,e))&&(s=+s)>=s&&(++n,r+=s)}if(n)return r/n}(r,(function(t){return t[e]}))}));if(!fv(s,o,f))return 1}(t=m).push.apply(t,hv(n))},x=0,b=v.triangles.length;x2&&void 0!==arguments[2]&&arguments[2]?function(e,t){return(e&&Zp.hasOwnProperty(e.type)?Zp[e.type]:ef)(e,t)}(t,e):C_(e,t)}var mv=window.THREE?window.THREE:{BufferGeometry:Zr,Float32BufferAttribute:Hr},gv=(new mv.BufferGeometry).setAttribute?"setAttribute":"addAttribute",_v=function(e){function t(e,n,r,i,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=ov(this,t)).type="ConicPolygonGeometry",l.parameters={polygonGeoJson:e,bottomHeight:n,topHeight:r,closedBottom:i,closedTop:s,includeSides:a,curvatureResolution:o},n=n||0,r=r||1,i=void 0===i||i,s=void 0===s||s,a=void 0===a||a;var u=pv(e,{resolution:o=o||5}),c=u.contour,A=u.triangles,h=rA(A.uvs),d=[],p=[],f=[],m=0,g=function(e){var t=Math.round(d.length/3),n=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(n,f.length-n,m++)};function _(e,t){var n="function"==typeof t?t:function(){return t},r=e.map((function(e){return e.map((function(e){var t=Av(e,2),r=t[0],i=t[1];return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}(i,r,n(r,i))}))}));return km(r)}function v(e){return{indices:!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?A.indices:A.indices.slice().reverse(),vertices:_([A.points],e).vertices,uvs:h}}return a&&g(function(){for(var e=_(c,n),t=e.vertices,i=e.holes,s=_(c,r).vertices,a=rA([s,t]),o=Math.round(s.length/3),l=new Set(i),u=0,A=[],h=0;h=0;m--)for(var g=0;ge.length)&&(t=e.length);for(var n=0,r=Array(t);n0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=(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 r=e,s=t;return i.forEach((function(e,t){var a,o=e.keyAccessor;if(e.isProp){var l=s,u=l[o],c=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r1&&void 0!==arguments[1]?arguments[1]:1;r===i.length?Object.keys(t).forEach((function(e){return t[e]=n(t[e])})):Object.values(t).forEach((function(t){return e(t,r+1)}))}(s);var a=s;return r&&(a=[],function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];n.length===i.length?a.push({keys:n,vals:t}):Object.entries(t).forEach((function(t){var r=yv(t,2),i=r[0],s=r[1];return e(s,[].concat(xv(n),[i]))}))}(s),t instanceof Array&&0===t.length&&1===a.length&&(a[0].keys=[])),a},Tv=function(e){var t,n=void 0!==(e=e||{})?e:{},r={};for(t in n)n.hasOwnProperty(t)&&(r[t]=n[t]);var i,s,a,o,l;i="object"==typeof window,s="function"==typeof importScripts,o="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,a=o&&!i&&!s,l=!i&&!a&&!s;var u,c,A,h,d,p="";a?(p=__dirname+"/",u=function(e,t){var n;return(n=re(e))||(h||(h=require("fs")),d||(d=require("path")),e=d.normalize(e),n=h.readFileSync(e)),t?n:n.toString()},A=function(e){var t=u(e,!0);return t.buffer||(t=new Uint8Array(t)),v(t.buffer),t},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),n.inspect=function(){return"[Emscripten Module object]"}):l?("undefined"!=typeof read&&(u=function(e){var t=re(e);return t?te(t):read(e)}),A=function(e){var t;return(t=re(e))?t:"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(v("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)):(i||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):"",u=function(e){try{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText}catch(t){var n=re(e);if(n)return te(n);throw t}},s&&(A=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 n=re(e);if(n)return n;throw t}}),c=function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)t(r.response);else{var i=re(e);i?t(i.buffer):n()}},r.onerror=n,r.send(null)});var f=n.print||console.log.bind(console),m=n.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(n[t]=r[t]);r=null,n.arguments&&n.arguments,n.thisProgram&&n.thisProgram;var g=0;var _=!1;function v(e,t){e||ge("Assertion failed: "+t)}function y(e){var t=n["_"+e];return v(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function x(e,t,n,r,i){var s={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);(function(e,t,n){(function(e,t,n,r){if(!(r>0))return 0;for(var i=n,s=n+r-1,a=0;a=55296&&o<=57343)o=65536+((1023&o)<<10)|1023&e.charCodeAt(++a);if(o<=127){if(n>=s)break;t[n++]=o}else if(o<=2047){if(n+1>=s)break;t[n++]=192|o>>6,t[n++]=128|63&o}else if(o<=65535){if(n+2>=s)break;t[n++]=224|o>>12,t[n++]=128|o>>6&63,t[n++]=128|63&o}else{if(n+3>=s)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63,t[n++]=128|o>>6&63,t[n++]=128|63&o}}t[n]=0})(e,w,t,n)})(e,t=le(n),n)}return t},array:function(e){var t=le(e.length);return function(e,t){S.set(e,t)}(e,t),t}};var a=y(e),o=[],l=0;if(r)for(var u=0;u=r);)++i;if(i-t>16&&e.subarray&&R)return R.decode(e.subarray(t,i));for(var s="";t>10,56320|1023&u)}}else s+=String.fromCharCode((31&a)<<6|o)}else s+=String.fromCharCode(a)}return s}(w,e,t):""}function P(e,t){return e%t>0&&(e+=t-e%t),e}function D(e){b=e,n.HEAP8=S=new Int8Array(e),n.HEAP16=T=new Int16Array(e),n.HEAP32=M=new Int32Array(e),n.HEAPU8=w=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=E=new Float32Array(e),n.HEAPF64=C=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var L=n.TOTAL_MEMORY||33554432;function I(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var r=t.func;"number"==typeof r?void 0===t.arg?n.dynCall_v(r):n.dynCall_vi(r,t.arg):r(void 0===t.arg?null:t.arg)}else t()}}L=(b=n.buffer?n.buffer:new ArrayBuffer(L)).byteLength,D(b),M[6032]=5267040;var U=[],B=[],O=[],F=[];var k=Math.abs,q=Math.ceil,G=Math.floor,z=Math.min,V=0,H=null;n.preloadedImages={},n.preloadedAudios={};var j,W,X=null,Q="data:application/octet-stream;base64,";function Y(e){return String.prototype.startsWith?e.startsWith(Q):0===e.indexOf(Q)}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//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP7KBdLHZTpFAqKYk69AqekDbeGY41MdjQD8AZzHK501A1vcrrjubNkD5LnquvBYhQCbiRRD71QlAqt72EbOH8z8Eu+jL1YbdP4uaox/xUcY/abedg1XfsD+BsUdzJ4KZP5wE9YFySIM/rW1kAKMpbT+rZFthVRhWPy4PKlXIs0A/qMZLlwDnMEHByqEF0I0ZQQYSFD8lUQNBPpY+dFs07UAH8BZImBPWQN9RY0I0sMBA2T7kLfc6qUByFYvfhBKTQMq+0Mis1XxA0XQbeQXMZUBJJ5aEGXpQQP7/SY0a6ThAaMD92b/UIkAs8s8yqXoMQNIegOvCk/U/aOi7NZJP4D8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAAGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjb29yZGlqay5jAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAbGF0TG5nVG9DZWxsAGNlbGxUb0NoaWxkUG9zAHZhbGlkYXRlQ2hpbGRQb3MAbGF0TG5nLmMAY2VsbEFyZWFSYWRzMgBwb2x5Z29uLT5uZXh0ID09IE5VTEwAbGlua2VkR2VvLmMAYWRkTmV3TGlua2VkUG9seWdvbgBuZXh0ICE9IE5VTEwAbG9vcCAhPSBOVUxMAGFkZE5ld0xpbmtlZExvb3AAcG9seWdvbi0+Zmlyc3QgPT0gTlVMTABhZGRMaW5rZWRMb29wAGNvb3JkICE9IE5VTEwAYWRkTGlua2VkQ29vcmQAbG9vcC0+Zmlyc3QgPT0gTlVMTABpbm5lckxvb3BzICE9IE5VTEwAbm9ybWFsaXplTXVsdGlQb2x5Z29uAGJib3hlcyAhPSBOVUxMAGNhbmRpZGF0ZXMgIT0gTlVMTABmaW5kUG9seWdvbkZvckhvbGUAY2FuZGlkYXRlQkJveGVzICE9IE5VTEwAcmV2RGlyICE9IElOVkFMSURfRElHSVQAbG9jYWxpai5jAGNlbGxUb0xvY2FsSWprAGJhc2VDZWxsICE9IG9yaWdpbkJhc2VDZWxsACEob3JpZ2luT25QZW50ICYmIGluZGV4T25QZW50KQBiYXNlQ2VsbCA9PSBvcmlnaW5CYXNlQ2VsbABiYXNlQ2VsbCAhPSBJTlZBTElEX0JBU0VfQ0VMTABsb2NhbElqa1RvQ2VsbAAhX2lzQmFzZUNlbGxQZW50YWdvbihiYXNlQ2VsbCkAYmFzZUNlbGxSb3RhdGlvbnMgPj0gMABncmlkUGF0aENlbGxzADAAdmVydGV4LmMAY2VsbFRvVmVydGV4AGdyYXBoLT5idWNrZXRzICE9IE5VTEwAdmVydGV4R3JhcGguYwBpbml0VmVydGV4R3JhcGgAbm9kZSAhPSBOVUxMAGFkZFZlcnRleE5vZGU=";function $(e){return e}function K(e){return e.replace(/\b__Z[\w\d_]+/g,(function(e){return e===e?e:e+" ["+e+"]"}))}function Z(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(t){e=t}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function J(){return S.length}function ee(e){try{var t=new ArrayBuffer(e);if(t.byteLength!=e)return;return new Int8Array(t).set(S),se(t),D(t),1}catch(e){}}function te(e){for(var t=[],n=0;n255&&(r&=255),t.push(String.fromCharCode(r))}return t.join("")}var ne="function"==typeof atob?atob:function(e){var t,n,r,i,s,a,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=o.indexOf(e.charAt(u++))<<2|(i=o.indexOf(e.charAt(u++)))>>4,n=(15&i)<<4|(s=o.indexOf(e.charAt(u++)))>>2,r=(3&s)<<6|(a=o.indexOf(e.charAt(u++))),l+=String.fromCharCode(t),64!==s&&(l+=String.fromCharCode(n)),64!==a&&(l+=String.fromCharCode(r))}while(u=0){if((0|n)>13780509){if(0|(o=0|tt(15,l)))break;l=0|i[(u=l)>>2],u=0|i[u+4>>2]}else c=0|Ot(0|n,0|(o=((0|n)<0)<<31>>31),3,0),u=0|T(),o=0|Dt(0|n,0|o,1,0),o=0|Dt(0|(o=0|Ot(0|c,0|u,0|o,0|T())),0|T(),1,0),u=0|T(),i[l>>2]=o,i[l+4>>2]=u,l=o;if(Xt(0|r,0,l<<3),0|s){Xt(0|s,0,l<<2),o=0|B(e,t,n,r,s,l,u,0);break}(o=0|Pt(l,4))?(c=0|B(e,t,n,r,o,l,u,0),Nt(o),o=c):o=13}else o=2}while(0);return D=a,0|(c=o)}function U(e,t,n,r,s){e|=0,t|=0,n|=0,r|=0,s|=0;var a,o,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0;if(o=D,D=D+16|0,m=o+8|0,i[(f=a=o)>>2]=e,i[f+4>>2]=t,(0|n)<0)return D=o,0|(m=2);if(i[(l=r)>>2]=e,i[l+4>>2]=t,(l=!!(0|s))&&(i[s>>2]=0),0|Oe(e,t))return D=o,0|(m=9);i[m>>2]=0;e:do{if((0|n)>=1)if(l)for(d=1,h=0,p=0,f=1,l=e;;){if(!(h|p)){if(0|(l=0|O(l,t,4,m,a)))break e;if(0|Oe(l=0|i[(t=a)>>2],t=0|i[t+4>>2])){l=9;break e}}if(0|(l=0|O(l,t,0|i[22384+(p<<2)>>2],m,a)))break e;if(l=0|i[(t=a)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=l,i[e+4>>2]=t,i[s+(d<<2)>>2]=f,u=(0|(e=h+1|0))==(0|f),A=6==(0|(c=p+1|0)),0|Oe(l,t)){l=9;break e}if((0|(f=f+(A&u&1)|0))>(0|n)){l=0;break}d=d+1|0,h=u?0:e,p=u?A?0:c:p}else for(d=1,h=0,p=0,f=1,l=e;;){if(!(h|p)){if(0|(l=0|O(l,t,4,m,a)))break e;if(0|Oe(l=0|i[(t=a)>>2],t=0|i[t+4>>2])){l=9;break e}}if(0|(l=0|O(l,t,0|i[22384+(p<<2)>>2],m,a)))break e;if(l=0|i[(t=a)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=l,i[e+4>>2]=t,u=(0|(e=h+1|0))==(0|f),A=6==(0|(c=p+1|0)),0|Oe(l,t)){l=9;break e}if((0|(f=f+(A&u&1)|0))>(0|n)){l=0;break}d=d+1|0,h=u?0:e,p=u?A?0:c:p}else l=0}while(0);return D=o,0|(m=l)}function B(e,t,n,r,s,a,o,l){n|=0,r|=0,s|=0,l|=0;var u,c,A,h=0,d=0,p=0,f=0,m=0,g=0,_=0;if(A=D,D=D+16|0,u=A+8|0,c=A,h=0|kt(0|(e|=0),0|(t|=0),0|(a|=0),0|(o|=0)),p=0|T(),!(!(0|(_=0|i[(g=f=r+(h<<3)|0)>>2]))&!(0|(g=0|i[g+4>>2]))|(d=(0|_)==(0|e)&(0|g)==(0|t))))do{h=0|Ft(0|(h=0|Dt(0|h,0|p,1,0)),0|T(),0|a,0|o),p=0|T(),d=(0|(g=0|i[(_=f=r+(h<<3)|0)>>2]))==(0|e)&(0|(_=0|i[_+4>>2]))==(0|t)}while(!(!(0|g)&!(0|_)|d));if(h=s+(h<<2)|0,d&&(0|i[h>>2])<=(0|l))return D=A,0|(_=0);if(i[(_=f)>>2]=e,i[_+4>>2]=t,i[h>>2]=l,(0|l)>=(0|n))return D=A,0|(_=0);switch(d=l+1|0,i[u>>2]=0,0|(h=0|O(e,t,2,u,c))){case 9:m=9;break;case 0:(h=0|B(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,a,o,d))||(m=9)}e:do{if(9==(0|m)){switch(i[u>>2]=0,0|(h=0|O(e,t,3,u,c))){case 9:break;case 0:if(0|(h=0|B(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,a,o,d)))break e;break;default:break e}switch(i[u>>2]=0,0|(h=0|O(e,t,1,u,c))){case 9:break;case 0:if(0|(h=0|B(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,a,o,d)))break e;break;default:break e}switch(i[u>>2]=0,0|(h=0|O(e,t,5,u,c))){case 9:break;case 0:if(0|(h=0|B(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,a,o,d)))break e;break;default:break e}switch(i[u>>2]=0,0|(h=0|O(e,t,4,u,c))){case 9:break;case 0:if(0|(h=0|B(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,a,o,d)))break e;break;default:break e}switch(i[u>>2]=0,0|(h=0|O(e,t,6,u,c))){case 9:break;case 0:if(0|(h=0|B(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,a,o,d)))break e;break;default:break e}return D=A,0|(_=0)}}while(0);return D=A,0|(_=h)}function O(e,t,n,r,s){e|=0,t|=0,s|=0;var a,o,l=0,u=0,c=0,A=0,h=0,d=0,p=0;if((n|=0)>>>0>6)return 0|(s=1);if(h=(0|i[(r|=0)>>2])%6|0,i[r>>2]=h,(0|h)>0){l=0;do{n=0|pe(n),l=l+1|0}while((0|l)<(0|i[r>>2]))}if(h=0|Gt(0|e,0|t,45),T(),(o=127&h)>>>0>121)return 0|(s=5);a=0|Fe(e,t),l=0|Gt(0|e,0|t,52),T(),l&=15;e:do{if(l){for(;;){if(c=0|Gt(0|e,0|t,0|(u=3*(15-l|0)|0)),T(),7==(0|(c&=7))){t=5;break}if(p=!(0|Ve(l)),l=l+-1|0,d=0|zt(7,0,0|u),t&=~T(),e=0|zt(0|i[(p?432:16)+(28*c|0)+(n<<2)>>2],0,0|u)|e&~d,t|=u=0|T(),!(n=0|i[(p?640:224)+(28*c|0)+(n<<2)>>2])){n=0;break e}if(!l){A=8;break e}}return 0|t}A=8}while(0);8==(0|A)&&(e|=0|zt(0|(p=0|i[848+(28*o|0)+(n<<2)>>2]),0,45),t=T()|-1040385&t,n=0|i[4272+(28*o|0)+(n<<2)>>2],127&~p||(p=0|zt(0|i[848+(28*o|0)+20>>2],0,45),t=T()|-1040385&t,n=0|i[4272+(28*o|0)+20>>2],e=0|qe(p|e,t),t=0|T(),i[r>>2]=1+(0|i[r>>2]))),c=0|Gt(0|e,0|t,45),T(),c&=127;e:do{if(0|q(c)){t:do{if(1==(0|Fe(e,t))){if((0|o)!=(0|c)){if(0|H(c,0|i[7696+(28*o|0)>>2])){e=0|ze(e,t),u=1,t=0|T();break}M(23313,22416,436,22424)}switch(0|a){case 3:e=0|qe(e,t),t=0|T(),i[r>>2]=1+(0|i[r>>2]),u=0;break t;case 5:e=0|ze(e,t),t=0|T(),i[r>>2]=5+(0|i[r>>2]),u=0;break t;case 0:return 0|(p=9);default:return 0|(p=1)}}else u=0}while(0);if((0|n)>0){l=0;do{e=0|ke(e,t),t=0|T(),l=l+1|0}while((0|l)!=(0|n))}if((0|o)!=(0|c)){if(!(0|G(c))){if(!!(0|u)|5!=(0|Fe(e,t)))break;i[r>>2]=1+(0|i[r>>2]);break}switch(127&h){case 8:case 118:break e}3!=(0|Fe(e,t))&&(i[r>>2]=1+(0|i[r>>2]))}}else if((0|n)>0){l=0;do{e=0|qe(e,t),t=0|T(),l=l+1|0}while((0|l)!=(0|n))}}while(0);return i[r>>2]=((0|i[r>>2])+n|0)%6|0,i[(p=s)>>2]=e,i[p+4>>2]=t,0|(p=0)}function F(e,t,n,r){n|=0,r|=0;var s,a,o,l=0,u=0;for(o=D,D=D+16|0,s=o,a=o+8|0,l=(l=!(0|Oe(e|=0,t|=0)))?1:2;;){if(i[a>>2]=0,!(0|O(e,t,l,a,s))&((0|i[(u=s)>>2])==(0|n)?(0|i[u+4>>2])==(0|r):0)){e=4;break}if((l=l+1|0)>>>0>=7){l=7,e=4;break}}return 4==(0|e)?(D=o,0|l):0}function k(e,t,n,r,a,o,l){t|=0,n|=0,r|=0,a|=0,o|=0,l|=0;var u,c,A,h,d,p,f,m,g,_,v=0,y=0,x=0,b=0,S=0,w=0,M=0,E=0,C=0,R=0,N=0,P=0,L=0,I=0,U=0,B=0,O=0,F=0,k=0;if(_=D,D=D+64|0,f=_+48|0,m=_+32|0,g=_+24|0,u=_+8|0,c=_,(0|(y=0|i[(e|=0)>>2]))<=0)return D=_,0|(U=0);for(A=e+4|0,h=f+8|0,d=m+8|0,p=u+8|0,v=0,L=0;;){P=(x=0|i[A>>2])+(L<<4)|0,i[f>>2]=i[P>>2],i[f+4>>2]=i[P+4>>2],i[f+8>>2]=i[P+8>>2],i[f+12>>2]=i[P+12>>2],(0|L)==(y+-1|0)?(i[m>>2]=i[x>>2],i[m+4>>2]=i[x+4>>2],i[m+8>>2]=i[x+8>>2],i[m+12>>2]=i[x+12>>2]):(P=x+(L+1<<4)|0,i[m>>2]=i[P>>2],i[m+4>>2]=i[P+4>>2],i[m+8>>2]=i[P+8>>2],i[m+12>>2]=i[P+12>>2]),y=0|$(f,m,r,g);e:do{if(y)x=0,v=y;else if(y=0|i[(x=g)>>2],(0|(x=0|i[x+4>>2]))>0|!(0|x)&y>>>0>0){N=0,P=0;t:for(;;){if(k=+s[f>>3],F=+((R=0|Lt(0|y,0|x,0|N,0|P))>>>0)+4294967296*+(0|T()),B=+(y>>>0)+4294967296*+(0|x),O=+(N>>>0)+4294967296*+(0|P),s[u>>3]=k*F/B+ +s[m>>3]*O/B,s[p>>3]=+s[h>>3]*F/B+ +s[d>>3]*O/B,0|(y=0|He(u,r,c))){v=y;break}w=0|kt(0|(C=0|i[(R=c)>>2]),0|(R=0|i[R+4>>2]),0|t,0|n),b=0|T(),x=0|i[(S=y=l+(w<<3)|0)>>2],S=0|i[S+4>>2];n:do{if(!(0|x)&!(0|S))I=y,U=16;else for(M=0,E=0;;){if((0|M)>(0|n)|(0|M)==(0|n)&E>>>0>t>>>0){v=1;break t}if((0|x)==(0|C)&(0|S)==(0|R))break n;if(w=0|Ft(0|(y=0|Dt(0|w,0|b,1,0)),0|T(),0|t,0|n),b=0|T(),E=0|Dt(0|E,0|M,1,0),M=0|T(),!(0|(x=0|i[(S=y=l+(w<<3)|0)>>2]))&!(0|(S=0|i[S+4>>2]))){I=y,U=16;break}}}while(0);if(16!=(0|U)||(U=0,!(0|C)&!(0|R))||(i[(E=I)>>2]=C,i[E+4>>2]=R,E=o+(i[a>>2]<<3)|0,i[E>>2]=C,i[E+4>>2]=R,E=0|Dt(0|i[(E=a)>>2],0|i[E+4>>2],1,0),C=0|T(),i[(R=a)>>2]=E,i[R+4>>2]=C),N=0|Dt(0|N,0|P,1,0),P=0|T(),y=0|i[(x=g)>>2],!((0|(x=0|i[x+4>>2]))>(0|P)|(0|x)==(0|P)&y>>>0>N>>>0)){x=1;break e}}x=0}else x=1}while(0);if(L=L+1|0,!x){U=21;break}if((0|L)>=(0|(y=0|i[e>>2]))){v=0,U=21;break}}return 21==(0|U)?(D=_,0|v):0}function q(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|i[7696+(28*e|0)+16>>2])}function G(e){return 4==(0|(e|=0))|117==(0|e)}function z(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)>>2]}function V(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)+4>>2]}function H(e,t){return t|=0,(0|i[7696+(28*(e|=0)|0)+20>>2])==(0|t)?0|(t=1):0|(t=(0|i[7696+(28*e|0)+24>>2])==(0|t))}function j(e,t){return 0|i[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function W(e,t){return t|=0,(0|i[848+(28*(e|=0)|0)>>2])==(0|t)?0|(t=0):(0|i[848+(28*e|0)+4>>2])==(0|t)?0|(t=1):(0|i[848+(28*e|0)+8>>2])==(0|t)?0|(t=2):(0|i[848+(28*e|0)+12>>2])==(0|t)?0|(t=3):(0|i[848+(28*e|0)+16>>2])==(0|t)?0|(t=4):(0|i[848+(28*e|0)+20>>2])==(0|t)?0|(t=5):0|((0|i[848+(28*e|0)+24>>2])==(0|t)?6:7)}function X(e){return+s[(e|=0)+16>>3]<+s[e+24>>3]|0}function Q(e,t){e|=0;var n,r,i=0;return(i=+s[(t|=0)>>3])>=+s[e+8>>3]&&i<=+s[e>>3]?(n=+s[e+16>>3],i=+s[e+24>>3],t=(r=+s[t+8>>3])>=i,e=r<=n&1,n>2]=0,f=f+4|0}while((0|f)<(0|m));return 0|(t=0|Ye(t,g))?(D=d,0|(b=t)):(Xe(g=0|i[(m=g)>>2],m=0|i[m+4>>2],h),Qe(g,m,_),A=+et(h,_+8|0),s[h>>3]=+s[e>>3],s[(m=h+8|0)>>3]=+s[e+16>>3],s[_>>3]=+s[e+8>>3],s[(g=_+8|0)>>3]=+s[e+24>>3],o=+et(h,_),S=+s[m>>3]-+s[g>>3],c=+u(+S),p=+s[h>>3]-+s[_>>3],r=+u(+p),!(0==S|0==p)&&(S=+Vt(+c,+r),S=+v(+o*o/+Ht(+S/+Ht(+c,+r),3)/(A*(2.59807621135*A)*.8)),s[a>>3]=S,y=~~S>>>0,b=+u(S)>=1?S>0?~~+x(+l(S/4294967296),4294967295)>>>0:~~+v((S-+(~~S>>>0))/4294967296)>>>0:0,2146435072&~i[a+4>>2])?(_=!(0|y)&!(0|b),i[(t=n)>>2]=_?1:y,i[t+4>>2]=_?0:b,t=0):t=1,D=d,0|(b=t))}function $(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o,c,A,h,d=0,p=0,f=0;h=D,D=D+288|0,c=h+264|0,A=h+96|0,o=(d=p=h)+96|0;do{i[d>>2]=0,d=d+4|0}while((0|d)<(0|o));return 0|(n=0|Ye(n,p))?(D=h,0|(r=n)):(Xe(d=0|i[(n=p)>>2],n=0|i[n+4>>2],c),Qe(d,n,A),f=+et(c,A+8|0),f=+v(+ +et(e,t)/(2*f)),s[a>>3]=f,n=~~f>>>0,d=+u(f)>=1?f>0?~~+x(+l(f/4294967296),4294967295)>>>0:~~+v((f-+(~~f>>>0))/4294967296)>>>0:0,2146435072&~i[a+4>>2]?(p=!(0|n)&!(0|d),i[r>>2]=p?1:n,i[r+4>>2]=p?0:d,D=h,0|(r=0)):(D=h,0|(r=1)))}function K(e,t,n,r){t|=0,n|=0,r|=0,i[(e|=0)>>2]=t,i[e+4>>2]=n,i[e+8>>2]=r}function Z(e,t){e|=0;var n,r,a,o,l=0,c=0,A=0,h=0,d=0,p=0,f=0;i[(o=(t|=0)+8|0)>>2]=0,r=+s[e>>3],h=+u(+r),a=+s[e+8>>3],h+=.5*(d=+u(+a)/.8660254037844386),h-=+(0|(l=~~h)),d-=+(0|(e=~~d));do{if(h<.5){if(h<.3333333333333333){if(i[t>>2]=l,d<.5*(h+1)){i[t+4>>2]=e;break}e=e+1|0,i[t+4>>2]=e;break}if(e=(1&!(d<(f=1-h)))+e|0,i[t+4>>2]=e,f<=d&d<2*h){l=l+1|0,i[t>>2]=l;break}i[t>>2]=l;break}if(!(h<.6666666666666666)){if(l=l+1|0,i[t>>2]=l,d<.5*h){i[t+4>>2]=e;break}e=e+1|0,i[t+4>>2]=e;break}if(d<1-h){if(i[t+4>>2]=e,2*h-1>2]=l;break}}else e=e+1|0,i[t+4>>2]=e;l=l+1|0,i[t>>2]=l}while(0);do{if(r<0){if(1&e){l=~~(+(0|l)-(2*(+((p=0|Lt(0|l,((0|l)<0)<<31>>31,0|(p=(e+1|0)/2|0),((0|p)<0)<<31>>31))>>>0)+4294967296*+(0|T()))+1)),i[t>>2]=l;break}l=~~(+(0|l)-2*(+((p=0|Lt(0|l,((0|l)<0)<<31>>31,0|(p=(0|e)/2|0),((0|p)<0)<<31>>31))>>>0)+4294967296*+(0|T()))),i[t>>2]=l;break}}while(0);p=t+4|0,a<0&&(l=l-((1|e<<1)/2|0)|0,i[t>>2]=l,e=0-e|0,i[p>>2]=e),c=e-l|0,(0|l)<0?(A=0-l|0,i[p>>2]=c,i[o>>2]=A,i[t>>2]=0,e=c,l=0):A=0,(0|e)<0&&(l=l-e|0,i[t>>2]=l,A=A-e|0,i[o>>2]=A,i[p>>2]=0,e=0),n=l-A|0,c=e-A|0,(0|A)<0&&(i[t>>2]=n,i[p>>2]=c,i[o>>2]=0,e=c,l=n,A=0),(0|(c=(0|A)<(0|(c=(0|e)<(0|l)?e:l))?A:c))<=0||(i[t>>2]=l-c,i[p>>2]=e-c,i[o>>2]=A-c)}function J(e){var t,n=0,r=0,s=0,a=0,o=0;n=0|i[(e|=0)>>2],r=0|i[(t=e+4|0)>>2],(0|n)<0&&(r=r-n|0,i[t>>2]=r,i[(o=e+8|0)>>2]=(0|i[o>>2])-n,i[e>>2]=0,n=0),(0|r)<0?(n=n-r|0,i[e>>2]=n,a=(0|i[(o=e+8|0)>>2])-r|0,i[o>>2]=a,i[t>>2]=0,r=0):(o=a=e+8|0,a=0|i[a>>2]),(0|a)<0&&(n=n-a|0,i[e>>2]=n,r=r-a|0,i[t>>2]=r,i[o>>2]=0,a=0),(0|(s=(0|a)<(0|(s=(0|r)<(0|n)?r:n))?a:s))<=0||(i[e>>2]=n-s,i[t>>2]=r-s,i[o>>2]=a-s)}function ee(e,t){t|=0;var n,r;r=0|i[(e|=0)+8>>2],n=+((0|i[e+4>>2])-r|0),s[t>>3]=+((0|i[e>>2])-r|0)-.5*n,s[t+8>>3]=.8660254037844386*n}function te(e,t,n){e|=0,t|=0,i[(n|=0)>>2]=(0|i[t>>2])+(0|i[e>>2]),i[n+4>>2]=(0|i[t+4>>2])+(0|i[e+4>>2]),i[n+8>>2]=(0|i[t+8>>2])+(0|i[e+8>>2])}function ne(e,t,n){e|=0,t|=0,i[(n|=0)>>2]=(0|i[e>>2])-(0|i[t>>2]),i[n+4>>2]=(0|i[e+4>>2])-(0|i[t+4>>2]),i[n+8>>2]=(0|i[e+8>>2])-(0|i[t+8>>2])}function re(e,t){t|=0;var n,r=0;r=0|y(0|i[(e|=0)>>2],t),i[e>>2]=r,n=0|y(0|i[(r=e+4|0)>>2],t),i[r>>2]=n,t=0|y(0|i[(e=e+8|0)>>2],t),i[e>>2]=t}function ie(e){var t,n,r=0,s=0,a=0,o=0,l=0;l=(0|(n=0|i[(e|=0)>>2]))<0,e=(e=(s=(0|(o=((t=(0|(a=(0|i[e+4>>2])-(l?n:0)|0))<0)?0-a|0:0)+((0|i[e+8>>2])-(l?n:0))|0))<0)?0:o)-((a=(0|(s=(0|e)<(0|(s=(0|(r=(t?0:a)-(s?o:0)|0))<(0|(o=(l?0:n)-(t?a:0)-(s?o:0)|0))?r:o))?e:s))>0)?s:0)|0,r=r-(a?s:0)|0;e:do{switch(o-(a?s:0)|0){case 0:switch(0|r){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|r){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 se(e){var t,n=0,r=0,s=0,a=0,o=0,l=0;a=0|i[(t=(e|=0)+8|0)>>2],o=(0|i[e>>2])-a|0,a=(0|i[(l=e+4|0)>>2])-a|0;do{if(o>>>0>715827881|a>>>0>715827881){if(r=(0|o)>0){if((2147483647-o|0)<(0|o))return 0|(l=1);if((2147483647-(o<<1)|0)<(0|o))return 0|(l=1)}else{if((-2147483648-o|0)>(0|o))return 0|(l=1);if((-2147483648-(o<<1)|0)>(0|o))return 0|(l=1)}if(n=3*o|0,(0|a)>0){if((2147483647-a|0)<(0|a))return 0|(l=1)}else if((-2147483648-a|0)>(0|a))return 0|(l=1);if(s=a<<1,(0|o)>-1){if((-2147483648|n)>=(0|a))return 0|(l=1)}else if((-2147483648^n)<(0|a))return 0|(l=1);if(r){if(!((2147483647-o|0)<(0|s))){r=s;break}return 0|(n=1)}if(!((-2147483648-o|0)>(0|s))){r=s;break}return 0|(n=1)}r=a<<1,n=3*o|0}while(0);s=0|Ct(+(n-a|0)/7),i[e>>2]=s,a=0|Ct(+(r+o|0)/7),i[l>>2]=a,i[t>>2]=0,n=(r=(0|a)<(0|s))?s:a,r=r?a:s;do{if((0|r)<0){if((0|n)>0){if((-2147483648|n)<(0|r)&-2147483648!=(0|r)&(2147483647-n|0)>=(0|r))break;M(23313,22444,355,22455)}if(-2147483648==(0|r)|(-2147483648-n|0)>(0|r)&&M(23313,22444,355,22455),(0|n)>-1){if((-2147483648|n)<(0|r))break;M(23313,22444,355,22455)}else{if((-2147483648^n)>=(0|r))break;M(23313,22444,355,22455)}}}while(0);return n=a-s|0,(0|s)<0?(r=0-s|0,i[l>>2]=n,i[t>>2]=r,i[e>>2]=0,s=0):(n=a,r=0),(0|n)<0&&(s=s-n|0,i[e>>2]=s,r=r-n|0,i[t>>2]=r,i[l>>2]=0,n=0),o=s-r|0,a=n-r|0,(0|r)<0?(i[e>>2]=o,i[l>>2]=a,i[t>>2]=0,n=a,a=o,r=0):a=s,(0|(s=(0|r)<(0|(s=(0|n)<(0|a)?n:a))?r:s))<=0||(i[e>>2]=a-s,i[l>>2]=n-s,i[t>>2]=r-s),0|(l=0)}function ae(e){var t,n=0,r=0,s=0,a=0,o=0,l=0;a=0|i[(t=(e|=0)+8|0)>>2],o=(0|i[e>>2])-a|0,a=(0|i[(l=e+4|0)>>2])-a|0;do{if(o>>>0>715827881|a>>>0>715827881){if(r=(0|o)>0){if((2147483647-o|0)<(0|o))return 0|(l=1)}else if((-2147483648-o|0)>(0|o))return 0|(l=1);if(n=o<<1,(0|a)>0){if((2147483647-a|0)<(0|a))return 0|(l=1);if((2147483647-(a<<1)|0)<(0|a))return 0|(l=1)}else{if((-2147483648-a|0)>(0|a))return 0|(l=1);if((-2147483648-(a<<1)|0)>(0|a))return 0|(l=1)}if(s=3*a|0,r){if((2147483647-n|0)<(0|a))return 0|(l=1)}else if((-2147483648-n|0)>(0|a))return 0|(l=1);if((0|a)>-1){if((-2147483648|s)<(0|o)){r=s;break}return 0|(n=1)}if(!((-2147483648^s)<(0|o))){r=s;break}return 0|(n=1)}r=3*a|0,n=o<<1}while(0);s=0|Ct(+(n+a|0)/7),i[e>>2]=s,a=0|Ct(+(r-o|0)/7),i[l>>2]=a,i[t>>2]=0,n=(r=(0|a)<(0|s))?s:a,r=r?a:s;do{if((0|r)<0){if((0|n)>0){if((-2147483648|n)<(0|r)&-2147483648!=(0|r)&(2147483647-n|0)>=(0|r))break;M(23313,22444,404,22469)}if(-2147483648==(0|r)|(-2147483648-n|0)>(0|r)&&M(23313,22444,404,22469),(0|n)>-1){if((-2147483648|n)<(0|r))break;M(23313,22444,404,22469)}else{if((-2147483648^n)>=(0|r))break;M(23313,22444,404,22469)}}}while(0);return n=a-s|0,(0|s)<0?(r=0-s|0,i[l>>2]=n,i[t>>2]=r,i[e>>2]=0,s=0):(n=a,r=0),(0|n)<0&&(s=s-n|0,i[e>>2]=s,r=r-n|0,i[t>>2]=r,i[l>>2]=0,n=0),o=s-r|0,a=n-r|0,(0|r)<0?(i[e>>2]=o,i[l>>2]=a,i[t>>2]=0,n=a,a=o,r=0):a=s,(0|(s=(0|r)<(0|(s=(0|n)<(0|a)?n:a))?r:s))<=0||(i[e>>2]=a-s,i[l>>2]=n-s,i[t>>2]=r-s),0|(l=0)}function oe(e){var t,n,r=0,s=0,a=0,o=0,l=0;s=0|i[(t=(e|=0)+8|0)>>2],a=0|Ct(+((3*(r=(0|i[e>>2])-s|0)|0)-(s=(0|i[(n=e+4|0)>>2])-s|0)|0)/7),i[e>>2]=a,r=0|Ct(+((s<<1)+r|0)/7),i[n>>2]=r,i[t>>2]=0,s=r-a|0,(0|a)<0?(l=0-a|0,i[n>>2]=s,i[t>>2]=l,i[e>>2]=0,r=s,a=0,s=l):s=0,(0|r)<0&&(a=a-r|0,i[e>>2]=a,s=s-r|0,i[t>>2]=s,i[n>>2]=0,r=0),l=a-s|0,o=r-s|0,(0|s)<0?(i[e>>2]=l,i[n>>2]=o,i[t>>2]=0,r=o,o=l,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|r)<(0|o)?r:o))?s:a))<=0||(i[e>>2]=o-a,i[n>>2]=r-a,i[t>>2]=s-a)}function le(e){var t,n,r=0,s=0,a=0,o=0,l=0;s=0|i[(t=(e|=0)+8|0)>>2],a=0|Ct(+(((r=(0|i[e>>2])-s|0)<<1)+(s=(0|i[(n=e+4|0)>>2])-s|0)|0)/7),i[e>>2]=a,r=0|Ct(+((3*s|0)-r|0)/7),i[n>>2]=r,i[t>>2]=0,s=r-a|0,(0|a)<0?(l=0-a|0,i[n>>2]=s,i[t>>2]=l,i[e>>2]=0,r=s,a=0,s=l):s=0,(0|r)<0&&(a=a-r|0,i[e>>2]=a,s=s-r|0,i[t>>2]=s,i[n>>2]=0,r=0),l=a-s|0,o=r-s|0,(0|s)<0?(i[e>>2]=l,i[n>>2]=o,i[t>>2]=0,r=o,o=l,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|r)<(0|o)?r:o))?s:a))<=0||(i[e>>2]=o-a,i[n>>2]=r-a,i[t>>2]=s-a)}function ue(e){var t,n,r,s=0,a=0,o=0,l=0;s=0|i[(e|=0)>>2],a=0|i[(n=e+4|0)>>2],o=0|i[(r=e+8|0)>>2],l=a+(3*s|0)|0,i[e>>2]=l,a=o+(3*a|0)|0,i[n>>2]=a,s=(3*o|0)+s|0,i[r>>2]=s,o=a-l|0,(0|l)<0?(s=s-l|0,i[n>>2]=o,i[r>>2]=s,i[e>>2]=0,a=o,o=0):o=l,(0|a)<0&&(o=o-a|0,i[e>>2]=o,s=s-a|0,i[r>>2]=s,i[n>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=l,i[r>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(i[e>>2]=o-a,i[n>>2]=l-a,i[r>>2]=s-a)}function ce(e){var t,n,r,s=0,a=0,o=0,l=0;l=0|i[(e|=0)>>2],o=(3*(s=0|i[(n=e+4|0)>>2])|0)+l|0,l=(a=0|i[(r=e+8|0)>>2])+(3*l|0)|0,i[e>>2]=l,i[n>>2]=o,s=(3*a|0)+s|0,i[r>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,i[n>>2]=a,i[r>>2]=s,i[e>>2]=0,l=0):a=o,(0|a)<0&&(l=l-a|0,i[e>>2]=l,s=s-a|0,i[r>>2]=s,i[n>>2]=0,a=0),t=l-s|0,o=a-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=o,i[r>>2]=0,l=t,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|o)<(0|l)?o:l))?s:a))<=0||(i[e>>2]=l-a,i[n>>2]=o-a,i[r>>2]=s-a)}function Ae(e,t){e|=0;var n,r,s,a=0,o=0,l=0;((t|=0)+-1|0)>>>0>=6||(l=(0|i[15440+(12*t|0)>>2])+(0|i[e>>2])|0,i[e>>2]=l,s=e+4|0,o=(0|i[15440+(12*t|0)+4>>2])+(0|i[s>>2])|0,i[s>>2]=o,r=e+8|0,t=(0|i[15440+(12*t|0)+8>>2])+(0|i[r>>2])|0,i[r>>2]=t,a=o-l|0,(0|l)<0?(t=t-l|0,i[s>>2]=a,i[r>>2]=t,i[e>>2]=0,o=0):(a=o,o=l),(0|a)<0&&(o=o-a|0,i[e>>2]=o,t=t-a|0,i[r>>2]=t,i[s>>2]=0,a=0),n=o-t|0,l=a-t|0,(0|t)<0?(i[e>>2]=n,i[s>>2]=l,i[r>>2]=0,o=n,t=0):l=a,(0|(a=(0|t)<(0|(a=(0|l)<(0|o)?l:o))?t:a))<=0||(i[e>>2]=o-a,i[s>>2]=l-a,i[r>>2]=t-a))}function he(e){var t,n,r,s=0,a=0,o=0,l=0;l=0|i[(e|=0)>>2],o=(s=0|i[(n=e+4|0)>>2])+l|0,l=(a=0|i[(r=e+8|0)>>2])+l|0,i[e>>2]=l,i[n>>2]=o,s=a+s|0,i[r>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,i[n>>2]=a,i[r>>2]=s,i[e>>2]=0,o=0):(a=o,o=l),(0|a)<0&&(o=o-a|0,i[e>>2]=o,s=s-a|0,i[r>>2]=s,i[n>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=l,i[r>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(i[e>>2]=o-a,i[n>>2]=l-a,i[r>>2]=s-a)}function de(e){var t,n,r,s=0,a=0,o=0,l=0;s=0|i[(e|=0)>>2],o=0|i[(n=e+4|0)>>2],a=0|i[(r=e+8|0)>>2],l=o+s|0,i[e>>2]=l,o=a+o|0,i[n>>2]=o,s=a+s|0,i[r>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,i[n>>2]=a,i[r>>2]=s,i[e>>2]=0,o=0):(a=o,o=l),(0|a)<0&&(o=o-a|0,i[e>>2]=o,s=s-a|0,i[r>>2]=s,i[n>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=l,i[r>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(i[e>>2]=o-a,i[n>>2]=l-a,i[r>>2]=s-a)}function pe(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 fe(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 me(e){var t,n,r,s=0,a=0,o=0,l=0;s=0|i[(e|=0)>>2],a=0|i[(n=e+4|0)>>2],o=0|i[(r=e+8|0)>>2],l=a+(s<<1)|0,i[e>>2]=l,a=o+(a<<1)|0,i[n>>2]=a,s=(o<<1)+s|0,i[r>>2]=s,o=a-l|0,(0|l)<0?(s=s-l|0,i[n>>2]=o,i[r>>2]=s,i[e>>2]=0,a=o,o=0):o=l,(0|a)<0&&(o=o-a|0,i[e>>2]=o,s=s-a|0,i[r>>2]=s,i[n>>2]=0,a=0),t=o-s|0,l=a-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=l,i[r>>2]=0,o=t,s=0):l=a,(0|(a=(0|s)<(0|(a=(0|l)<(0|o)?l:o))?s:a))<=0||(i[e>>2]=o-a,i[n>>2]=l-a,i[r>>2]=s-a)}function ge(e){var t,n,r,s=0,a=0,o=0,l=0;l=0|i[(e|=0)>>2],o=((s=0|i[(n=e+4|0)>>2])<<1)+l|0,l=(a=0|i[(r=e+8|0)>>2])+(l<<1)|0,i[e>>2]=l,i[n>>2]=o,s=(a<<1)+s|0,i[r>>2]=s,a=o-l|0,(0|l)<0?(s=s-l|0,i[n>>2]=a,i[r>>2]=s,i[e>>2]=0,l=0):a=o,(0|a)<0&&(l=l-a|0,i[e>>2]=l,s=s-a|0,i[r>>2]=s,i[n>>2]=0,a=0),t=l-s|0,o=a-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=o,i[r>>2]=0,l=t,s=0):o=a,(0|(a=(0|s)<(0|(a=(0|o)<(0|l)?o:l))?s:a))<=0||(i[e>>2]=l-a,i[n>>2]=o-a,i[r>>2]=s-a)}function _e(e,t){t|=0;var n,r,s,a=0,o=0,l=0;return s=(0|(r=(0|i[(e|=0)>>2])-(0|i[t>>2])|0))<0,n=(0|(o=(0|i[e+4>>2])-(0|i[t+4>>2])-(s?r:0)|0))<0,t=(t=(e=(0|(l=(s?0-r|0:0)+(0|i[e+8>>2])-(0|i[t+8>>2])+(n?0-o|0:0)|0))<0)?0:l)-((o=(0|(e=(0|t)<(0|(e=(0|(a=(n?0:o)-(e?l:0)|0))<(0|(l=(s?0:r)-(n?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 ve(e,t){t|=0;var n;n=0|i[(e|=0)+8>>2],i[t>>2]=(0|i[e>>2])-n,i[t+4>>2]=(0|i[e+4>>2])-n}function ye(e,t){t|=0;var n,r,s,a=0,o=0,l=0;o=0|i[(e|=0)>>2],i[t>>2]=o,l=0|i[e+4>>2],i[(r=t+4|0)>>2]=l,i[(s=t+8|0)>>2]=0,e=(a=(0|l)<(0|o))?o:l,a=a?l:o;do{if((0|a)<0){if((0|e)>0){if((-2147483648|e)<(0|a)&-2147483648!=(0|a)&(2147483647-e|0)>=(0|a))break;return 0|(e=1)}if(-2147483648==(0|a)|(-2147483648-e|0)>(0|a))return 0|(t=1);if((0|e)>-1){if((-2147483648|e)<(0|a))break;return 0|(e=1)}if(!((-2147483648^e)<(0|a)))break;return 0|(e=1)}}while(0);return e=l-o|0,(0|o)<0?(a=0-o|0,i[r>>2]=e,i[s>>2]=a,i[t>>2]=0,o=0):(e=l,a=0),(0|e)<0&&(o=o-e|0,i[t>>2]=o,a=a-e|0,i[s>>2]=a,i[r>>2]=0,e=0),n=o-a|0,l=e-a|0,(0|a)<0?(i[t>>2]=n,i[r>>2]=l,i[s>>2]=0,e=l,l=n,a=0):l=o,(0|(o=(0|a)<(0|(o=(0|e)<(0|l)?e:l))?a:o))<=0||(i[t>>2]=l-o,i[r>>2]=e-o,i[s>>2]=a-o),0|(t=0)}function xe(e){var t,n,r,s;n=(s=0|i[(t=(e|=0)+8|0)>>2])-(0|i[e>>2])|0,i[e>>2]=n,e=(0|i[(r=e+4|0)>>2])-s|0,i[r>>2]=e,i[t>>2]=0-(e+n)}function be(e){var t,n,r=0,s=0,a=0,o=0,l=0;r=0-(s=0|i[(e|=0)>>2])|0,i[e>>2]=r,i[(t=e+8|0)>>2]=0,o=(a=0|i[(n=e+4|0)>>2])+s|0,(0|s)>0?(i[n>>2]=o,i[t>>2]=s,i[e>>2]=0,r=0,a=o):s=0,(0|a)<0?(l=r-a|0,i[e>>2]=l,s=s-a|0,i[t>>2]=s,i[n>>2]=0,o=l-s|0,r=0-s|0,(0|s)<0?(i[e>>2]=o,i[n>>2]=r,i[t>>2]=0,a=r,s=0):(a=0,o=l)):o=r,(0|(r=(0|s)<(0|(r=(0|a)<(0|o)?a:o))?s:r))<=0||(i[e>>2]=o-r,i[n>>2]=a-r,i[t>>2]=s-r)}function Se(e,t,n){n|=0;var r,s,a=0,o=0;return s=D,D=D+16|0,r=s,o=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(a=0|Gt(0|(e|=0),0|t,56),T(),a=0|function(e,t,n){e|=0,t|=0,n|=0;var r=0,s=0,a=0;if(a=D,D=D+16|0,s=a,r=0|Oe(e,t),(n+-1|0)>>>0>5)return D=a,0|(s=-1);if(r=!!(0|r),1==(0|n)&r)return D=a,0|(s=-1);do{if(!(0|vt(e,t,s))){if(r){r=(5+(0|i[21936+(n<<2)>>2])-(0|i[s>>2])|0)%5|0;break}r=(6+(0|i[21968+(n<<2)>>2])-(0|i[s>>2])|0)%6|0;break}r=-1}while(0);return s=r,D=a,0|s}(e,o,7&a),-1==(0|a)?(i[n>>2]=0,D=s,0|(o=6)):(0|We(e,o,r)&&M(23313,22484,282,22499),t=0|Gt(0|e,0|t,52),T(),t&=15,0|Oe(e,o)?Ee(r,t,a,2,n):Pe(r,t,a,2,n),D=s,0|(o=0))):(D=s,0|(o=6))}function we(e,t,n,r){t|=0,r|=0;var a,o=0,l=0,u=0,c=0;if(a=D,D=D+16|0,function(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;o=D,D=D+32|0,a=o,function(e,t){e|=0,t|=0;var n=0,r=0,i=0;n=+s[e>>3],r=+h(+n),n=+d(+n),s[t+16>>3]=n,n=+s[e+8>>3],i=r*+h(+n),s[t>>3]=i,n=r*+d(+n),s[t+8>>3]=n}(e,a),i[t>>2]=0,s[n>>3]=5,r=+_t(16400,a),r<+s[n>>3]&&(i[t>>2]=0,s[n>>3]=r);r=+_t(16424,a),r<+s[n>>3]&&(i[t>>2]=1,s[n>>3]=r);r=+_t(16448,a),r<+s[n>>3]&&(i[t>>2]=2,s[n>>3]=r);r=+_t(16472,a),r<+s[n>>3]&&(i[t>>2]=3,s[n>>3]=r);r=+_t(16496,a),r<+s[n>>3]&&(i[t>>2]=4,s[n>>3]=r);r=+_t(16520,a),r<+s[n>>3]&&(i[t>>2]=5,s[n>>3]=r);r=+_t(16544,a),r<+s[n>>3]&&(i[t>>2]=6,s[n>>3]=r);r=+_t(16568,a),r<+s[n>>3]&&(i[t>>2]=7,s[n>>3]=r);r=+_t(16592,a),r<+s[n>>3]&&(i[t>>2]=8,s[n>>3]=r);r=+_t(16616,a),r<+s[n>>3]&&(i[t>>2]=9,s[n>>3]=r);r=+_t(16640,a),r<+s[n>>3]&&(i[t>>2]=10,s[n>>3]=r);r=+_t(16664,a),r<+s[n>>3]&&(i[t>>2]=11,s[n>>3]=r);r=+_t(16688,a),r<+s[n>>3]&&(i[t>>2]=12,s[n>>3]=r);r=+_t(16712,a),r<+s[n>>3]&&(i[t>>2]=13,s[n>>3]=r);r=+_t(16736,a),r<+s[n>>3]&&(i[t>>2]=14,s[n>>3]=r);r=+_t(16760,a),r<+s[n>>3]&&(i[t>>2]=15,s[n>>3]=r);r=+_t(16784,a),r<+s[n>>3]&&(i[t>>2]=16,s[n>>3]=r);r=+_t(16808,a),r<+s[n>>3]&&(i[t>>2]=17,s[n>>3]=r);r=+_t(16832,a),r<+s[n>>3]&&(i[t>>2]=18,s[n>>3]=r);if(r=+_t(16856,a),!(r<+s[n>>3]))return void(D=o);i[t>>2]=19,s[n>>3]=r,D=o}(e|=0,n|=0,c=a),(l=+f(+(1-.5*+s[c>>3])))<1e-16)return i[r>>2]=0,i[r+4>>2]=0,i[r+8>>2]=0,i[r+12>>2]=0,void(D=a);if(c=0|i[n>>2],o=+Ze((o=+s[15920+(24*c|0)>>3])-+Ze(+function(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0;return a=+s[t>>3],r=+h(+a),i=+s[t+8>>3]-+s[e+8>>3],o=r*+d(+i),n=+s[e>>3],+ +_(+o,+(+d(+a)*+h(+n)-+h(+i)*(r*+d(+n))))}(15600+(c<<4)|0,e))),u=0|Ve(t)?+Ze(o+-.3334731722518321):o,o=+p(+l)/.381966011250105,(0|t)>0){e=0;do{o*=2.6457513110645907,e=e+1|0}while((0|e)!=(0|t))}l=+h(+u)*o,s[r>>3]=l,u=+d(+u)*o,s[r+8>>3]=u,D=a}function Te(e,t,n,r,a){t|=0,n|=0,r|=0,a|=0;var o=0,l=0;if(o=+function(e){e|=0;var t=0,n=0;return n=+s[e>>3],t=+s[e+8>>3],+ +c(+(n*n+t*t))}(e|=0),o<1e-16)return t=15600+(t<<4)|0,i[a>>2]=i[t>>2],i[a+4>>2]=i[t+4>>2],i[a+8>>2]=i[t+8>>2],void(i[a+12>>2]=i[t+12>>2]);if(l=+_(+ +s[e+8>>3],+ +s[e>>3]),(0|n)>0){e=0;do{o/=2.6457513110645907,e=e+1|0}while((0|e)!=(0|n))}r?(o/=3,n=!(0|Ve(n)),o=+g(.381966011250105*(n?o:o/2.6457513110645907))):(o=+g(.381966011250105*o),0|Ve(n)&&(l=+Ze(l+.3334731722518321))),function(e,t,n,r){e|=0,t=+t,n=+n,r|=0;var a=0,o=0,l=0,c=0;if(n<1e-16)return i[r>>2]=i[e>>2],i[r+4>>2]=i[e+4>>2],i[r+8>>2]=i[e+8>>2],void(i[r+12>>2]=i[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=+u(+(o+-3.141592653589793))<1e-16,t=+s[e>>3],a){t-=n,s[r>>3]=t,a=r;break}if(l=+h(+n),n=+d(+n),t=l*+d(+t)+ +h(+o)*(n*+h(+t)),t=+m(+((t=t>1?1:t)<-1?-1:t)),s[r>>3]=t,+u(+(t+-1.5707963267948966))<1e-16)return s[r>>3]=1.5707963267948966,void(s[r+8>>3]=0);if(+u(+(t+1.5707963267948966))<1e-16)return s[r>>3]=-1.5707963267948966,void(s[r+8>>3]=0);if(c=+h(+t),o=n*+d(+o)/c,n=+s[e>>3],t=(l-+d(+t)*+d(+n))/+h(+n)/c,l=o>1?1:o,t=t>1?1:t,(t=+s[e+8>>3]+ +_(+(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[r+8>>3]=t)}t=+s[e>>3]+n,s[r>>3]=t,a=r}while(0);if(+u(+(t+-1.5707963267948966))<1e-16)return s[a>>3]=1.5707963267948966,void(s[r+8>>3]=0);if(+u(+(t+1.5707963267948966))<1e-16)return s[a>>3]=-1.5707963267948966,void(s[r+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[r+8>>3]=t}(15600+(t<<4)|0,+Ze(+s[15920+(24*t|0)>>3]-l),o,a)}function Me(e,t,n){t|=0,n|=0;var r,s;r=D,D=D+16|0,ee((e|=0)+4|0,s=r),Te(s,0|i[e>>2],t,0,n),D=r}function Ee(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,l,u,c,A,h,d,p,f,m,g,_,v,y,x,b,S,w,T,E,C,R,N=0,P=0,L=0,I=0,U=0,B=0;if(R=D,D=D+272|0,I=R+240|0,T=R,E=R+224|0,C=R+208|0,g=R+176|0,_=R+160|0,v=R+192|0,y=R+144|0,x=R+128|0,b=R+112|0,S=R+96|0,w=R+80|0,i[(N=R+256|0)>>2]=t,i[I>>2]=i[e>>2],i[I+4>>2]=i[e+4>>2],i[I+8>>2]=i[e+8>>2],i[I+12>>2]=i[e+12>>2],Ce(I,N,T),i[a>>2]=0,(0|(I=r+n+(5==(0|r)&1)|0))<=(0|n))D=R;else{l=E+4|0,u=g+4|0,c=n+5|0,A=16880+((o=0|i[N>>2])<<2)|0,h=16960+(o<<2)|0,d=x+8|0,p=b+8|0,f=S+8|0,m=C+4|0,L=n;e:for(;;){P=T+((0|L)%5<<4)|0,i[C>>2]=i[P>>2],i[C+4>>2]=i[P+4>>2],i[C+8>>2]=i[P+8>>2],i[C+12>>2]=i[P+12>>2];do{}while(2==(0|Re(C,o,0,1)));if((0|L)>(0|n)&!!(0|Ve(t))){if(i[g>>2]=i[C>>2],i[g+4>>2]=i[C+4>>2],i[g+8>>2]=i[C+8>>2],i[g+12>>2]=i[C+12>>2],ee(l,_),r=0|i[g>>2],N=0|i[17040+(80*r|0)+(i[E>>2]<<2)>>2],i[g>>2]=i[18640+(80*r|0)+(20*N|0)>>2],(0|(P=0|i[18640+(80*r|0)+(20*N|0)+16>>2]))>0){e=0;do{he(u),e=e+1|0}while((0|e)<(0|P))}switch(P=18640+(80*r|0)+(20*N|0)+4|0,i[v>>2]=i[P>>2],i[v+4>>2]=i[P+4>>2],i[v+8>>2]=i[P+8>>2],re(v,3*(0|i[A>>2])|0),te(u,v,u),J(u),ee(u,y),U=+(0|i[h>>2]),s[x>>3]=3*U,s[d>>3]=0,B=-1.5*U,s[b>>3]=B,s[p>>3]=2.598076211353316*U,s[S>>3]=B,s[f>>3]=-2.598076211353316*U,0|i[17040+(80*(0|i[g>>2])|0)+(i[C>>2]<<2)>>2]){case 1:e=b,r=x;break;case 3:e=S,r=b;break;case 2:e=x,r=S;break;default:e=12;break e}mt(_,y,r,e,w),Te(w,0|i[g>>2],o,1,a+8+(i[a>>2]<<4)|0),i[a>>2]=1+(0|i[a>>2])}if((0|L)<(0|c)&&(ee(m,g),Te(g,0|i[C>>2],o,1,a+8+(i[a>>2]<<4)|0),i[a>>2]=1+(0|i[a>>2])),i[E>>2]=i[C>>2],i[E+4>>2]=i[C+4>>2],i[E+8>>2]=i[C+8>>2],i[E+12>>2]=i[C+12>>2],(0|(L=L+1|0))>=(0|I)){e=3;break}}3!=(0|e)?12==(0|e)&&M(22522,22569,571,22579):D=R}}function Ce(e,t,n){e|=0,t|=0,n|=0;var r,s=0,a=0,o=0,l=0,u=0;r=D,D=D+128|0,a=r,l=20240,u=(o=s=r+64|0)+60|0;do{i[o>>2]=i[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|u));l=20304,u=(o=a)+60|0;do{i[o>>2]=i[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|u));s=(u=!(0|Ve(0|i[t>>2])))?s:a,me(a=e+4|0),ge(a),0|Ve(0|i[t>>2])&&(ce(a),i[t>>2]=1+(0|i[t>>2])),i[n>>2]=i[e>>2],te(a,s,t=n+4|0),J(t),i[n+16>>2]=i[e>>2],te(a,s+12|0,t=n+20|0),J(t),i[n+32>>2]=i[e>>2],te(a,s+24|0,t=n+36|0),J(t),i[n+48>>2]=i[e>>2],te(a,s+36|0,t=n+52|0),J(t),i[n+64>>2]=i[e>>2],te(a,s+48|0,n=n+68|0),J(n),D=r}function Re(e,t,n,r){n|=0,r|=0;var s,a,o,l,u,c,A=0,h=0,d=0,p=0,f=0;if(c=D,D=D+32|0,u=c+12|0,a=c,f=(e|=0)+4|0,p=0|i[16960+((t|=0)<<2)>>2],p=(l=!!(0|r))?3*p|0:p,A=0|i[f>>2],s=0|i[(o=e+8|0)>>2],l){if((0|(A=s+A+(r=0|i[(h=e+12|0)>>2])|0))==(0|p))return D=c,0|(f=1);d=h}else A=s+A+(r=0|i[(d=e+12|0)>>2])|0;if((0|A)<=(0|p))return D=c,0|(f=0);do{if((0|r)>0){if(r=0|i[e>>2],(0|s)>0){h=18640+(80*r|0)+60|0,r=e;break}r=18640+(80*r|0)+40|0,n?(K(u,p,0,0),ne(f,u,a),de(a),te(a,u,f),h=r,r=e):(h=r,r=e)}else h=18640+(80*(0|i[e>>2])|0)+20|0,r=e}while(0);if(i[r>>2]=i[h>>2],(0|i[(A=h+16|0)>>2])>0){r=0;do{he(f),r=r+1|0}while((0|r)<(0|i[A>>2]))}return e=h+4|0,i[u>>2]=i[e>>2],i[u+4>>2]=i[e+4>>2],i[u+8>>2]=i[e+8>>2],t=0|i[16880+(t<<2)>>2],re(u,l?3*t|0:t),te(f,u,f),J(f),r=l&&((0|i[o>>2])+(0|i[f>>2])+(0|i[d>>2])|0)==(0|p)?1:2,D=c,0|(f=r)}function Ne(e,t){e|=0,t|=0;var n=0;do{n=0|Re(e,t,0,1)}while(2==(0|n));return 0|n}function Pe(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o,l,u,c,A,h,d,p,f,m,g,_,v,y,x,b,S,w,T=0,E=0,C=0,R=0,N=0;if(w=D,D=D+240|0,y=w+208|0,x=w,b=w+192|0,S=w+176|0,f=w+160|0,m=w+144|0,g=w+128|0,_=w+112|0,v=w+96|0,i[(T=w+224|0)>>2]=t,i[y>>2]=i[e>>2],i[y+4>>2]=i[e+4>>2],i[y+8>>2]=i[e+8>>2],i[y+12>>2]=i[e+12>>2],De(y,T,x),i[a>>2]=0,(0|(p=r+n+(6==(0|r)&1)|0))<=(0|n))D=w;else{l=n+6|0,u=16960+((o=0|i[T>>2])<<2)|0,c=m+8|0,A=g+8|0,h=_+8|0,d=b+4|0,E=0,C=n,r=-1;e:for(;;){if(e=x+((T=(0|C)%6|0)<<4)|0,i[b>>2]=i[e>>2],i[b+4>>2]=i[e+4>>2],i[b+8>>2]=i[e+8>>2],i[b+12>>2]=i[e+12>>2],e=E,E=0|Re(b,o,0,1),(0|C)>(0|n)&!!(0|Ve(t))&&(1!=(0|e)&&(0|i[b>>2])!=(0|r))){switch(ee(x+((T+5|0)%6<<4)+4|0,S),ee(x+(T<<4)+4|0,f),R=+(0|i[u>>2]),s[m>>3]=3*R,s[c>>3]=0,N=-1.5*R,s[g>>3]=N,s[A>>3]=2.598076211353316*R,s[_>>3]=N,s[h>>3]=-2.598076211353316*R,T=0|i[y>>2],0|i[17040+(80*T|0)+(((0|r)==(0|T)?i[b>>2]:r)<<2)>>2]){case 1:e=g,r=m;break;case 3:e=_,r=g;break;case 2:e=m,r=_;break;default:e=8;break e}mt(S,f,r,e,v),0|gt(S,v)||0|gt(f,v)||(Te(v,0|i[y>>2],o,1,a+8+(i[a>>2]<<4)|0),i[a>>2]=1+(0|i[a>>2]))}if((0|C)<(0|l)&&(ee(d,S),Te(S,0|i[b>>2],o,1,a+8+(i[a>>2]<<4)|0),i[a>>2]=1+(0|i[a>>2])),(0|(C=C+1|0))>=(0|p)){e=3;break}r=0|i[b>>2]}3!=(0|e)?8==(0|e)&&M(22606,22569,736,22651):D=w}}function De(e,t,n){e|=0,t|=0,n|=0;var r,s=0,a=0,o=0,l=0,u=0;r=D,D=D+160|0,a=r,l=20368,u=(o=s=r+80|0)+72|0;do{i[o>>2]=i[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|u));l=20448,u=(o=a)+72|0;do{i[o>>2]=i[l>>2],o=o+4|0,l=l+4|0}while((0|o)<(0|u));s=(u=!(0|Ve(0|i[t>>2])))?s:a,me(a=e+4|0),ge(a),0|Ve(0|i[t>>2])&&(ce(a),i[t>>2]=1+(0|i[t>>2])),i[n>>2]=i[e>>2],te(a,s,t=n+4|0),J(t),i[n+16>>2]=i[e>>2],te(a,s+12|0,t=n+20|0),J(t),i[n+32>>2]=i[e>>2],te(a,s+24|0,t=n+36|0),J(t),i[n+48>>2]=i[e>>2],te(a,s+36|0,t=n+52|0),J(t),i[n+64>>2]=i[e>>2],te(a,s+48|0,t=n+68|0),J(t),i[n+80>>2]=i[e>>2],te(a,s+60|0,n=n+84|0),J(n),D=r}function Le(e,t){return t=0|Gt(0|(e|=0),0|(t|=0),45),T(),127&t}function Ie(e,t){var n=0,r=0,i=0,s=0,a=0,o=0;if(!(!0&134217728==(-16777216&(t|=0))))return 0|(t=0);if(a=0|Gt(0|(e|=0),0|t,45),T(),(a&=127)>>>0>121)return 0|(t=0);n=0|Gt(0|e,0|t,52),T(),n&=15;do{if(0|n){for(i=1,r=0;;){if(s=0|Gt(0|e,0|t,3*(15-i|0)|0),T(),!!(0|(s&=7))&(1^r)){if(1==(0|s)&!!(0|q(a))){o=0,r=13;break}r=1}if(7==(0|s)){o=0,r=13;break}if(!(i>>>0>>0)){r=9;break}i=i+1|0}if(9==(0|r)){if(15!=(0|n))break;return 0|(o=1)}if(13==(0|r))return 0|o}}while(0);for(;;){if(o=0|Gt(0|e,0|t,3*(14-n|0)|0),T(),!(!0&!(7&~o))){o=0,r=13;break}if(!(n>>>0<14)){o=1,r=13;break}n=n+1|0}return 13==(0|r)?0|o:0}function Ue(e,t,n,r){n|=0,r|=0;var s=0,a=0;if(a=0|Gt(0|(e|=0),0|(t|=0),52),T(),n>>>0>15)return 0|(r=4);if((0|(a&=15))<(0|n))return 0|(r=12);if((0|a)==(0|n))return i[r>>2]=e,i[r+4>>2]=t,0|(r=0);if(s=0|zt(0|n,0,52),s|=e,e=T()|-15728641&t,(0|a)>(0|n))do{t=0|zt(7,0,3*(14-n|0)|0),n=n+1|0,s|=t,e=T()|e}while((0|n)<(0|a));return i[r>>2]=s,i[r+4>>2]=e,0|(r=0)}function Be(e,t,n,r){n|=0,r|=0;var s=0,a=0,o=0;if(a=0|Gt(0|(e|=0),0|(t|=0),52),T(),!((0|n)<16&(0|(a&=15))<=(0|n)))return 0|(r=4);s=n-a|0,n=0|Gt(0|e,0|t,45),T();e:do{if(0|q(127&n)){t:do{if(0|a){for(n=1;!((o=0|zt(7,0,3*(15-n|0)|0))&e)&!(T()&t);){if(!(n>>>0>>0))break t;n=n+1|0}n=0|At(7,0,s,((0|s)<0)<<31>>31),s=0|T();break e}}while(0);n=0|Dt(0|(n=0|Ot(0|(n=0|At(7,0,s,((0|s)<0)<<31>>31)),0|T(),5,0)),0|T(),-5,-1),n=0|Dt(0|(n=0|Bt(0|n,0|T(),6,0)),0|T(),1,0),s=0|T()}else n=0|At(7,0,s,((0|s)<0)<<31>>31),s=0|T()}while(0);return i[(o=r)>>2]=n,i[o+4>>2]=s,0|(o=0)}function Oe(e,t){var n=0,r=0,i=0;if(i=0|Gt(0|(e|=0),0|(t|=0),45),T(),!(0|q(127&i)))return 0|(i=0);i=0|Gt(0|e,0|t,52),T(),i&=15;e:do{if(i)for(r=1;;){if(n=0|Gt(0|e,0|t,3*(15-r|0)|0),T(),0|(n&=7))break e;if(!(r>>>0>>0)){n=0;break}r=r+1|0}else n=0}while(0);return 0|(i=1&!(0|n))}function Fe(e,t){var n=0,r=0,i=0;if(i=0|Gt(0|(e|=0),0|(t|=0),52),T(),!(i&=15))return 0|(i=0);for(r=1;;){if(n=0|Gt(0|e,0|t,3*(15-r|0)|0),T(),0|(n&=7)){r=5;break}if(!(r>>>0>>0)){n=0,r=5;break}r=r+1|0}return 5==(0|r)?0|n:0}function ke(e,t){var n=0,r=0,i=0,s=0,a=0,o=0,l=0;if(l=0|Gt(0|(e|=0),0|(t|=0),52),T(),!(l&=15))return l=e,w(0|(o=t)),0|l;for(o=1,n=0;;){r=0|zt(7,0,0|(s=3*(15-o|0)|0)),i=0|T(),a=0|Gt(0|e,0|t,0|s),T(),e=(s=0|zt(0|pe(7&a),0,0|s))|e&~r,t=(a=0|T())|t&~i;e:do{if(!n)if(!(s&r)&!(a&i))n=0;else if(r=0|Gt(0|e,0|t,52),T(),r&=15){n=1;t:for(;;){switch(a=0|Gt(0|e,0|t,3*(15-n|0)|0),T(),7&a){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0>>0)){n=1;break e}n=n+1|0}for(n=1;;){if(i=0|Gt(0|e,0|t,0|(a=3*(15-n|0)|0)),T(),s=0|zt(7,0,0|a),t&=~T(),e=e&~s|(a=0|zt(0|pe(7&i),0,0|a)),t|=T(),!(n>>>0>>0)){n=1;break}n=n+1|0}}else n=1}while(0);if(!(o>>>0>>0))break;o=o+1|0}return w(0|t),0|e}function qe(e,t){var n=0,r=0,i=0,s=0,a=0;if(r=0|Gt(0|(e|=0),0|(t|=0),52),T(),!(r&=15))return r=e,w(0|(n=t)),0|r;for(n=1;a=0|Gt(0|e,0|t,0|(s=3*(15-n|0)|0)),T(),i=0|zt(7,0,0|s),t&=~T(),e=(s=0|zt(0|pe(7&a),0,0|s))|e&~i,t=T()|t,n>>>0>>0;)n=n+1|0;return w(0|t),0|e}function Ge(e,t){var n=0,r=0,i=0,s=0,a=0,o=0,l=0;if(l=0|Gt(0|(e|=0),0|(t|=0),52),T(),!(l&=15))return l=e,w(0|(o=t)),0|l;for(o=1,n=0;;){r=0|zt(7,0,0|(s=3*(15-o|0)|0)),i=0|T(),a=0|Gt(0|e,0|t,0|s),T(),e=(s=0|zt(0|fe(7&a),0,0|s))|e&~r,t=(a=0|T())|t&~i;e:do{if(!n)if(!(s&r)&!(a&i))n=0;else if(r=0|Gt(0|e,0|t,52),T(),r&=15){n=1;t:for(;;){switch(a=0|Gt(0|e,0|t,3*(15-n|0)|0),T(),7&a){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0>>0)){n=1;break e}n=n+1|0}for(n=1;;){if(s=0|zt(7,0,0|(i=3*(15-n|0)|0)),a=t&~T(),t=0|Gt(0|e,0|t,0|i),T(),e=e&~s|(t=0|zt(0|fe(7&t),0,0|i)),t=a|T(),!(n>>>0>>0)){n=1;break}n=n+1|0}}else n=1}while(0);if(!(o>>>0>>0))break;o=o+1|0}return w(0|t),0|e}function ze(e,t){var n=0,r=0,i=0,s=0,a=0;if(r=0|Gt(0|(e|=0),0|(t|=0),52),T(),!(r&=15))return r=e,w(0|(n=t)),0|r;for(n=1;s=0|zt(7,0,0|(a=3*(15-n|0)|0)),i=t&~T(),t=0|Gt(0|e,0|t,0|a),T(),e=(t=0|zt(0|fe(7&t),0,0|a))|e&~s,t=T()|i,n>>>0>>0;)n=n+1|0;return w(0|t),0|e}function Ve(e){return(0|(e|=0))%2|0}function He(e,t,n){n|=0;var r,s=0;return r=D,D=D+16|0,s=r,(t|=0)>>>0>15?(D=r,0|(s=4)):2146435072&~i[(e|=0)+4>>2]&&2146435072&~i[e+8+4>>2]?(function(e,t,n){var r,i;r=D,D=D+16|0,we(e|=0,t|=0,n|=0,i=r),Z(i,n+4|0),D=r}(e,t,s),t=0|function(e,t){e|=0;var n,r=0,s=0,a=0,o=0,l=0,u=0,c=0,A=0;if(n=D,D=D+64|0,u=n+40|0,s=n+24|0,a=n+12|0,o=n,zt(0|(t|=0),0,52),r=134225919|T(),!t)return(0|i[e+4>>2])>2||(0|i[e+8>>2])>2||(0|i[e+12>>2])>2?(u=0,w(0|(l=0)),D=n,0|u):(zt(0|z(e),0,45),l=T()|r,u=-1,w(0|l),D=n,0|u);if(i[u>>2]=i[e>>2],i[u+4>>2]=i[e+4>>2],i[u+8>>2]=i[e+8>>2],i[u+12>>2]=i[e+12>>2],l=u+4|0,(0|t)>0)for(e=-1;i[s>>2]=i[l>>2],i[s+4>>2]=i[l+4>>2],i[s+8>>2]=i[l+8>>2],1&t?(oe(l),i[a>>2]=i[l>>2],i[a+4>>2]=i[l+4>>2],i[a+8>>2]=i[l+8>>2],ue(a)):(le(l),i[a>>2]=i[l>>2],i[a+4>>2]=i[l+4>>2],i[a+8>>2]=i[l+8>>2],ce(a)),ne(s,a,o),J(o),c=0|zt(7,0,0|(A=3*(15-t|0)|0)),r&=~T(),e=(A=0|zt(0|ie(o),0,0|A))|e&~c,r=T()|r,(0|t)>1;)t=t+-1|0;else e=-1;e:do{if((0|i[l>>2])<=2&&(0|i[u+8>>2])<=2&&(0|i[u+12>>2])<=2){if(t=0|zt(0|(s=0|z(u)),0,45),t|=e,e=T()|-1040385&r,o=0|V(u),!(0|q(s))){if((0|o)<=0)break;for(a=0;;){if(s=0|Gt(0|t,0|e,52),T(),s&=15)for(r=1;u=0|Gt(0|t,0|e,0|(A=3*(15-r|0)|0)),T(),c=0|zt(7,0,0|A),e&=~T(),t=t&~c|(A=0|zt(0|pe(7&u),0,0|A)),e|=T(),r>>>0>>0;)r=r+1|0;if((0|(a=a+1|0))==(0|o))break e}}a=0|Gt(0|t,0|e,52),T(),a&=15;t:do{if(a){r=1;n:for(;;){switch(A=0|Gt(0|t,0|e,3*(15-r|0)|0),T(),7&A){case 1:break n;case 0:break;default:break t}if(!(r>>>0>>0))break t;r=r+1|0}if(0|H(s,0|i[u>>2]))for(r=1;c=0|zt(7,0,0|(u=3*(15-r|0)|0)),A=e&~T(),e=0|Gt(0|t,0|e,0|u),T(),t=t&~c|(e=0|zt(0|fe(7&e),0,0|u)),e=A|T(),r>>>0>>0;)r=r+1|0;else for(r=1;u=0|Gt(0|t,0|e,0|(A=3*(15-r|0)|0)),T(),c=0|zt(7,0,0|A),e&=~T(),t=t&~c|(A=0|zt(0|pe(7&u),0,0|A)),e|=T(),r>>>0>>0;)r=r+1|0}}while(0);if((0|o)>0){r=0;do{t=0|ke(t,e),e=0|T(),r=r+1|0}while((0|r)!=(0|o))}}else t=0,e=0}while(0);return A=t,w(0|(c=e)),D=n,0|A}(s,t),s=0|T(),i[n>>2]=t,i[n+4>>2]=s,!(0|t)&!(0|s)&&M(23313,22674,786,22697),D=r,0|(s=0)):(D=r,0|(s=3))}function je(e,t,n){var r,s=0,a=0,o=0;if(r=(n|=0)+4|0,a=0|Gt(0|(e|=0),0|(t|=0),52),T(),a&=15,o=0|Gt(0|e,0|t,45),T(),s=!(0|a),0|q(127&o)){if(s)return 0|(o=1);s=1}else{if(s)return 0|(o=0);s=0|i[r>>2]||0|i[n+8>>2]?1:1&!!(0|i[n+12>>2])}for(n=1;1&n?ue(r):ce(r),o=0|Gt(0|e,0|t,3*(15-n|0)|0),T(),Ae(r,7&o),n>>>0>>0;)n=n+1|0;return 0|s}function We(e,t,n){n|=0;var r,s,a=0,o=0,l=0,u=0,c=0,A=0;if(s=D,D=D+16|0,r=s,A=0|Gt(0|(e|=0),0|(t|=0),45),T(),(A&=127)>>>0>121)return i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,i[n+12>>2]=0,D=s,0|(A=5);e:do{if(0|q(A)&&(l=0|Gt(0|e,0|t,52),T(),0|(l&=15))){a=1;t:for(;;){switch(c=0|Gt(0|e,0|t,3*(15-a|0)|0),T(),7&c){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;u=0|zt(7,0,0|(t=3*(15-o|0)|0)),c=a&~T(),a=0|Gt(0|e,0|a,0|t),T(),e=e&~u|(a=0|zt(0|fe(7&a),0,0|t)),a=c|T(),o>>>0>>0;)o=o+1|0}else a=t}while(0);if(c=7696+(28*A|0)|0,i[n>>2]=i[c>>2],i[n+4>>2]=i[c+4>>2],i[n+8>>2]=i[c+8>>2],i[n+12>>2]=i[c+12>>2],!(0|je(e,a,n)))return D=s,0|(A=0);if(u=n+4|0,i[r>>2]=i[u>>2],i[r+4>>2]=i[u+4>>2],i[r+8>>2]=i[u+8>>2],l=0|Gt(0|e,0|a,52),T(),c=15&l,1&l?(ce(u),l=c+1|0):l=c,0|q(A)){e:do{if(c)for(t=1;;){if(o=0|Gt(0|e,0|a,3*(15-t|0)|0),T(),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|Re(n,l,a,0)){if(0|q(A))do{}while(0|Re(n,l,0,0));(0|l)!=(0|c)&&le(u)}else(0|l)!=(0|c)&&(i[u>>2]=i[r>>2],i[u+4>>2]=i[r+4>>2],i[u+8>>2]=i[r+8>>2]);return D=s,0|(A=0)}function Xe(e,t,n){n|=0;var r,i,s=0;return i=D,D=D+16|0,0|(s=0|We(e|=0,t|=0,r=i))?(D=i,0|s):(s=0|Gt(0|e,0|t,52),T(),Me(r,15&s,n),D=i,0|(s=0))}function Qe(e,t,n){n|=0;var r,i=0,s=0,a=0;if(r=D,D=D+16|0,0|(i=0|We(e|=0,t|=0,a=r)))return D=r,0|(a=i);i=0|Gt(0|e,0|t,45),T(),i=!(0|q(127&i)),s=0|Gt(0|e,0|t,52),T(),s&=15;e:do{if(!i){if(0|s)for(i=1;;){if(!(!((0|zt(7,0,3*(15-i|0)|0))&e)&!(T()&t)))break e;if(!(i>>>0>>0))break;i=i+1|0}return Ee(a,s,0,5,n),D=r,0|0}}while(0);return Pe(a,s,0,6,n),D=r,0|0}function Ye(e,t){t|=0;var n=0,r=0,s=0,a=0,o=0,l=0,u=0;if((e|=0)>>>0>15)return 0|(l=4);if(zt(0|e,0,52),l=134225919|T(),!e){n=0,r=0;do{0|q(r)&&(zt(0|r,0,45),o=l|T(),i[(e=t+(n<<3)|0)>>2]=-1,i[e+4>>2]=o,n=n+1|0),r=r+1|0}while(122!=(0|r));return 0|(n=0)}n=0,o=0;do{if(0|q(o)){for(zt(0|o,0,45),r=1,s=-1,a=l|T();s&=~(u=0|zt(7,0,3*(15-r|0)|0)),a&=~T(),(0|r)!=(0|e);)r=r+1|0;i[(u=t+(n<<3)|0)>>2]=s,i[u+4>>2]=a,n=n+1|0}o=o+1|0}while(122!=(0|o));return 0|(n=0)}function $e(e,t,n,r){e|=0,r|=0;var s=0,a=0;s=0|Gt(0|(t|=0),0|(n|=0),52),T(),!(0|t)&!(0|n)|(0|r)>15|(0|(s&=15))>(0|r)?(r=-1,s=-1,t=0,n=0):(a=0|function(e,t,n,r){return e|=0,t|=0,(0|(r|=0))<(0|(n|=0))?(r=e,w(0|(n=t)),0|r):(n=0|zt(-1,-1,3+(3*(r-n|0)|0)|0),r=0|zt(0|~n,0|~T(),3*(15-r|0)|0),n=~T()&t,r=~r&e,w(0|n),0|r)}(t,n,s+1|0,r),n=-15728641&T(),t=0|zt(0|r,0,52),r=(a=!(0|Oe(t|=a,n|=T())))?-1:r),i[(a=e)>>2]=t,i[a+4>>2]=n,i[e+8>>2]=s,i[e+12>>2]=r}function Ke(e){var t,n=0,r=0,s=0,a=0,o=0,l=0,u=0,c=0;if(!(!(0|(n=0|i[(r=e|=0)>>2]))&!(0|(r=0|i[r+4>>2]))||(s=0|Gt(0|n,0|r,52),T(),n=0|Dt(0|(u=0|zt(1,0,3*(15^(s&=15))|0)),0|T(),0|n,0|r),r=0|T(),i[(u=e)>>2]=n,i[u+4>>2]=r,(0|s)<(0|(l=0|i[(u=e+8|0)>>2]))))){for(t=e+12|0,o=s;;){if((0|o)==(0|l)){s=5;break}if(c=(0|o)==(0|i[t>>2]),s=0|Gt(0|n,0|r,0|(a=3*(15-o|0)|0)),T(),c&1==(0|(s&=7))&!0){s=7;break}if(!(7==(0|s)&!0)){s=10;break}if(n=0|Dt(0|n,0|r,0|(c=0|zt(1,0,0|a)),0|T()),r=0|T(),i[(c=e)>>2]=n,i[c+4>>2]=r,!((0|o)>(0|l))){s=10;break}o=o+-1|0}if(5==(0|s))return i[(c=e)>>2]=0,i[c+4>>2]=0,i[u>>2]=-1,void(i[t>>2]=-1);if(7==(0|s))return l=0|Dt(0|n,0|r,0|(l=0|zt(1,0,0|a)),0|T()),u=0|T(),i[(c=e)>>2]=l,i[c+4>>2]=u,void(i[t>>2]=o+-1)}}function Ze(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function Je(e,t){return t|=0,+u(+(+s[(e|=0)>>3]-+s[t>>3]))<17453292519943298e-27?0|(t=+u(+(+s[e+8>>3]-+s[t+8>>3]))<17453292519943298e-27):0|(t=0)}function et(e,t){e|=0;var n,r,i,a=0;return r=+s[(t|=0)>>3],n=+s[e>>3],a=(i=+d(.5*(r-n)))*i+(a=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+h(+r)*+h(+n)*a),2*+_(+ +c(+a),+ +c(+(1-a)))*6371.007180918475}function tt(e,t){t|=0;var n=0;return(e|=0)>>>0>15?0|(t=4):(n=0|Ot(0|(n=0|At(7,0,e,((0|e)<0)<<31>>31)),0|T(),120,0),e=0|T(),i[t>>2]=2|n,i[t+4>>2]=e,0|(t=0))}function nt(e,t,n){e|=0,n|=0;var r,i,a,o,l=0,u=0,A=0,f=0,m=0,v=0;return v=+s[(t|=0)>>3],a=+s[e>>3],m=+d(.5*(v-a)),A=+s[t+8>>3],i=+s[e+8>>3],f=+d(.5*(A-i)),r=+h(+a),o=+h(+v),f=2*+_(+ +c(+(f=m*m+f*(o*r*f))),+ +c(+(1-f))),m=+s[n>>3],v=+d(.5*(m-v)),l=+s[n+8>>3],A=+d(.5*(l-A)),u=+h(+m),A=2*+_(+ +c(+(A=v*v+A*(o*u*A))),+ +c(+(1-A))),m=+d(.5*(a-m)),l=+d(.5*(i-l)),l=2*+_(+ +c(+(l=m*m+l*(r*u*l))),+ +c(+(1-l))),4*+g(+ +c(+ +p(.5*(u=.5*(f+A+l)))*+p(.5*(u-f))*+p(.5*(u-A))*+p(.5*(u-l))))}function rt(e,t,n){n|=0;var r,a,o,l=0,u=0;if(o=D,D=D+192|0,a=o,0|(u=0|Xe(e|=0,t|=0,r=o+168|0)))return D=o,0|(n=u);if(0|Qe(e,t,a)&&M(23313,22742,386,22751),(0|(t=0|i[a>>2]))>0){if(l=+nt(a+8|0,a+8+((1!=(0|t)&1)<<4)|0,r)+0,1!=(0|t)){e=1;do{l+=+nt(a+8+((u=e)<<4)|0,a+8+((0|(e=e+1|0))%(0|t)<<4)|0,r)}while((0|e)<(0|t))}}else l=0;return s[n>>3]=l,D=o,0|(n=0)}function it(e){e|=0;var t,n,r=0;return(t=0|Pt(1,12))||M(22832,22787,49,22845),0|(r=0|i[(n=e+4|0)>>2])?(i[(r=r+8|0)>>2]=t,i[n>>2]=t,0|t):(0|i[e>>2]&&M(22862,22787,61,22885),i[(r=e)>>2]=t,i[n>>2]=t,0|t)}function st(e,t){e|=0,t|=0;var n,r;return(r=0|Rt(24))||M(22899,22787,78,22913),i[r>>2]=i[t>>2],i[r+4>>2]=i[t+4>>2],i[r+8>>2]=i[t+8>>2],i[r+12>>2]=i[t+12>>2],i[r+16>>2]=0,0|(n=0|i[(t=e+4|0)>>2])?(i[n+16>>2]=r,i[t>>2]=r,0|r):(0|i[e>>2]&&M(22928,22787,82,22913),i[e>>2]=r,i[t>>2]=r,0|r)}function at(e){var t=0,n=0,r=0,s=0;if(e|=0)for(r=1;;){if(0|(t=0|i[e>>2]))do{if(0|(n=0|i[t>>2]))do{s=n,n=0|i[n+16>>2],Nt(s)}while(0|n);s=t,t=0|i[t+8>>2],Nt(s)}while(0|t);if(t=e,e=0|i[e+8>>2],r||Nt(t),!e)break;r=0}}function ot(e){var t,n,r=0,a=0,o=0,l=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0,x=0,b=0,S=0,w=0,T=0,E=0,C=0,R=0,N=0,P=0,D=0,L=0,I=0,U=0,B=0;if(0|i[(l=(e|=0)+8|0)>>2])return 0|(B=1);if(!(o=0|i[e>>2]))return 0|(B=0);r=o,a=0;do{a=a+1|0,r=0|i[r+8>>2]}while(0|r);if(a>>>0<2)return 0|(B=0);(n=0|Rt(a<<2))||M(22948,22787,317,22967),(t=0|Rt(a<<5))||M(22989,22787,321,22967),i[e>>2]=0,i[(C=e+4|0)>>2]=0,i[l>>2]=0,a=0,I=0,E=0,m=0;e:for(;;){if(f=0|i[o>>2]){c=0,A=f;do{if(d=+s[A+8>>3],r=A,A=0|i[A+16>>2],h=+s[(l=(p=!(0|A))?f:A)+8>>3],+u(+(d-h))>3.141592653589793){B=14;break}c+=(h-d)*(+s[r>>3]+ +s[l>>3])}while(!p);if(14==(0|B)){B=0,c=0,r=f;do{T=+s[r+8>>3],D=0|i[(L=r+16|0)>>2],w=+s[(D=0|D?D:f)+8>>3],c+=(+s[r>>3]+ +s[D>>3])*((w<0?w+6.283185307179586:w)-(T<0?T+6.283185307179586:T)),r=0|i[(0|r?L:o)>>2]}while(0|r)}c>0?(i[n+(I<<2)>>2]=o,I=I+1|0,l=E,r=m):B=19}else B=19;if(19==(0|B)){B=0;do{if(!a){if(m){l=C,A=m+8|0,r=o,a=e;break}if(0|i[e>>2]){B=27;break e}l=C,A=e,r=o,a=e;break}if(0|i[(r=a+8|0)>>2]){B=21;break e}if(!(a=0|Pt(1,12))){B=23;break e}i[r>>2]=a,l=a+4|0,A=a,r=m}while(0);if(i[A>>2]=o,i[l>>2]=o,A=t+(E<<5)|0,p=0|i[o>>2]){for(s[(f=t+(E<<5)+8|0)>>3]=17976931348623157e292,s[(m=t+(E<<5)+24|0)>>3]=17976931348623157e292,s[A>>3]=-17976931348623157e292,s[(g=t+(E<<5)+16|0)>>3]=-17976931348623157e292,b=17976931348623157e292,S=-17976931348623157e292,l=0,_=p,d=17976931348623157e292,y=17976931348623157e292,x=-17976931348623157e292,h=-17976931348623157e292;c=+s[_>>3],T=+s[_+8>>3],_=0|i[_+16>>2],w=+s[((v=!(0|_))?p:_)+8>>3],c>3]=c,d=c),T>3]=T,y=T),c>x?s[A>>3]=c:c=x,T>h&&(s[g>>3]=T,h=T),b=T>0&TS?T:S,l|=+u(+(T-w))>3.141592653589793,!v;)x=c;l&&(s[g>>3]=S,s[m>>3]=b)}else i[A>>2]=0,i[A+4>>2]=0,i[A+8>>2]=0,i[A+12>>2]=0,i[A+16>>2]=0,i[A+20>>2]=0,i[A+24>>2]=0,i[A+28>>2]=0;l=E+1|0}if(o=0|i[(L=o+8|0)>>2],i[L>>2]=0,!o){B=45;break}E=l,m=r}if(21==(0|B))M(22765,22787,35,22799);else if(23==(0|B))M(22819,22787,37,22799);else if(27==(0|B))M(22862,22787,61,22885);else if(45==(0|B)){e:do{if((0|I)>0){for(L=!(0|l),P=l<<2,D=!(0|e),N=0,r=0;;){if(R=0|i[n+(N<<2)>>2],L)B=73;else{if(!(E=0|Rt(P))){B=50;break}if(!(C=0|Rt(P))){B=52;break}t:do{if(D)a=0;else{for(l=0,a=0,A=e;o=t+(l<<5)|0,0|lt(0|i[A>>2],o,0|i[R>>2])?(i[E+(a<<2)>>2]=A,i[C+(a<<2)>>2]=o,v=a+1|0):v=a,A=0|i[A+8>>2];)l=l+1|0,a=v;if((0|v)>0)if(o=0|i[E>>2],1==(0|v))a=o;else for(g=0,_=-1,a=o,m=o;;){for(p=0|i[m>>2],o=0,A=0;f=(0|(l=0|i[i[E+(A<<2)>>2]>>2]))==(0|p)?o:o+(1<(l,0|i[C+(A<<2)>>2],0|i[p>>2]))|0,(0|(A=A+1|0))!=(0|v);)o=f;if(a=(l=(0|f)>(0|_))?m:a,(0|(o=g+1|0))==(0|v))break t;g=o,_=l?f:_,m=0|i[E+(o<<2)>>2]}else a=0}}while(0);if(Nt(E),Nt(C),a){if(o=0|i[(l=a+4|0)>>2])a=o+8|0;else if(0|i[a>>2]){B=70;break}i[a>>2]=R,i[l>>2]=R}else B=73}if(73==(0|B)){if(B=0,0|(r=0|i[R>>2]))do{C=r,r=0|i[r+16>>2],Nt(C)}while(0|r);Nt(R),r=1}if((0|(N=N+1|0))>=(0|I)){U=r;break e}}50==(0|B)?M(23004,22787,249,23023):52==(0|B)?M(23042,22787,252,23023):70==(0|B)&&M(22862,22787,61,22885)}else U=0}while(0);return Nt(n),Nt(t),0|(B=U)}return 0}function lt(e,t,n){e|=0;var r=0,a=0,o=0,l=0,u=0,c=0,A=0,h=0;if(!(0|Q(t|=0,n|=0)))return 0|(e=0);if(t=0|X(t),r=+s[n>>3],a=t&(a=+s[n+8>>3])<0?a+6.283185307179586:a,!(e=0|i[e>>2]))return 0|(e=0);if(t){t=0,A=a,n=e;e:for(;;){for(;l=+s[n>>3],a=+s[n+8>>3],h=0|i[(n=n+16|0)>>2],o=+s[(h=0|h?h:e)>>3],u=+s[h+8>>3],l>o?(c=l,l=u):(c=o,o=l,l=a,a=u),(r=r==o|r==c?r+2220446049250313e-31:r)c;)if(!(n=0|i[n>>2])){n=22;break e}if(((c=(u=l<0?l+6.283185307179586:l)+(r-o)/(c-o)*((l=a<0?a+6.283185307179586:a)-u))<0?c+6.283185307179586:c)>(A=u==A|l==A?A+-2220446049250313e-31:A)&&(t^=1),!(n=0|i[n>>2])){n=22;break}}if(22==(0|n))return 0|t}else{t=0,A=a,n=e;e:for(;;){for(;l=+s[n>>3],a=+s[n+8>>3],h=0|i[(n=n+16|0)>>2],o=+s[(h=0|h?h:e)>>3],u=+s[h+8>>3],l>o?(c=l,l=u):(c=o,o=l,l=a,a=u),(r=r==o|r==c?r+2220446049250313e-31:r)c;)if(!(n=0|i[n>>2])){n=22;break e}if(l+(r-o)/(c-o)*(a-l)>(A=l==A|a==A?A+-2220446049250313e-31:A)&&(t^=1),!(n=0|i[n>>2])){n=22;break}}if(22==(0|n))return 0|t}return 0}function ut(e,t,n,s,a){n|=0,s|=0,a|=0;var o,l,u,c,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0;if(c=D,D=D+32|0,y=c+16|0,u=c,A=0|Gt(0|(e|=0),0|(t|=0),52),T(),A&=15,g=0|Gt(0|n,0|s,52),T(),(0|A)!=(15&g))return D=c,0|(y=12);if(f=0|Gt(0|e,0|t,45),T(),f&=127,m=0|Gt(0|n,0|s,45),T(),f>>>0>121|(m&=127)>>>0>121)return D=c,0|(y=5);if(g=(0|f)!=(0|m)){if(7==(0|(d=0|W(f,m))))return D=c,0|(y=1);7==(0|(p=0|W(m,f)))?M(23066,23090,161,23100):(_=d,h=p)}else _=0,h=0;o=0|q(f),l=0|q(m),i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0;do{if(_){if(d=(0|(m=0|i[4272+(28*f|0)+(_<<2)>>2]))>0,l)if(d){f=0,p=n,d=s;do{p=0|Ge(p,d),d=0|T(),1==(0|(h=0|fe(h)))&&(h=0|fe(1)),f=f+1|0}while((0|f)!=(0|m));m=h,f=p,p=d}else m=h,f=n,p=s;else if(d){f=0,p=n,d=s;do{p=0|ze(p,d),d=0|T(),h=0|fe(h),f=f+1|0}while((0|f)!=(0|m));m=h,f=p,p=d}else m=h,f=n,p=s;if(je(f,p,y),g||M(23115,23090,191,23100),(d=!!(0|o))&(h=!!(0|l))&&M(23142,23090,192,23100),d){if(7==(0|(h=0|Fe(e,t)))){A=5;break}if(0|r[21872+(7*h|0)+_|0]){A=1;break}f=p=0|i[21040+(28*h|0)+(_<<2)>>2]}else if(h){if(7==(0|(h=0|Fe(f,p)))){A=5;break}if(0|r[21872+(7*h|0)+m|0]){A=1;break}f=0,p=0|i[21040+(28*m|0)+(h<<2)>>2]}else f=0,p=0;if((f|p)<0)A=5;else{if((0|p)>0){d=y+4|0,h=0;do{de(d),h=h+1|0}while((0|h)!=(0|p))}if(i[u>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,Ae(u,_),0|A)for(;0|Ve(A)?ue(u):ce(u),(0|A)>1;)A=A+-1|0;if((0|f)>0){A=0;do{de(u),A=A+1|0}while((0|A)!=(0|f))}te(v=y+4|0,u,v),J(v),v=51}}else if(je(n,s,y),!!(0|o)&!!(0|l))if((0|m)!=(0|f)&&M(23173,23090,261,23100),7==(0|(h=0|Fe(e,t)))|7==(0|(A=0|Fe(n,s))))A=5;else if(0|r[21872+(7*h|0)+A|0])A=1;else if((0|(h=0|i[21040+(28*h|0)+(A<<2)>>2]))>0){d=y+4|0,A=0;do{de(d),A=A+1|0}while((0|A)!=(0|h));v=51}else v=51;else v=51}while(0);return 51==(0|v)&&(A=y+4|0,i[a>>2]=i[A>>2],i[a+4>>2]=i[A+4>>2],i[a+8>>2]=i[A+8>>2],A=0),D=c,0|(y=A)}function ct(e,t,n,r){n|=0,r|=0;var s,a,o,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0;if(o=D,D=D+48|0,s=o+36|0,c=o+24|0,A=o+12|0,h=o,l=0|Gt(0|(e|=0),0|(t|=0),52),T(),l&=15,p=0|Gt(0|e,0|t,45),T(),(p&=127)>>>0>121)return D=o,0|(r=5);if(a=0|q(p),zt(0|l,0,52),g=134225919|T(),i[(u=r)>>2]=-1,i[u+4>>2]=g,!l)return 7==(0|(l=0|ie(n)))||127==(0|(l=0|j(p,l)))?(D=o,0|(g=1)):(f=0|zt(0|l,0,45),m=0|T(),m=-1040385&i[(p=r)+4>>2]|m,i[(g=r)>>2]=i[p>>2]|f,i[g+4>>2]=m,D=o,0|(g=0));for(i[s>>2]=i[n>>2],i[s+4>>2]=i[n+4>>2],i[s+8>>2]=i[n+8>>2],n=l;;){if(u=n,n=n+-1|0,i[c>>2]=i[s>>2],i[c+4>>2]=i[s+4>>2],i[c+8>>2]=i[s+8>>2],0|Ve(u)){if(0|(l=0|se(s))){n=13;break}i[A>>2]=i[s>>2],i[A+4>>2]=i[s+4>>2],i[A+8>>2]=i[s+8>>2],ue(A)}else{if(0|(l=0|ae(s))){n=13;break}i[A>>2]=i[s>>2],i[A+4>>2]=i[s+4>>2],i[A+8>>2]=i[s+8>>2],ce(A)}if(ne(c,A,h),J(h),v=0|i[(l=r)>>2],l=0|i[l+4>>2],_=0|zt(7,0,0|(y=3*(15-u|0)|0)),l&=~T(),y=0|zt(0|ie(h),0,0|y),l=T()|l,i[(g=r)>>2]=y|v&~_,i[g+4>>2]=l,(0|u)<=1){n=14;break}}e:do{if(13!=(0|n)&&14==(0|n))if((0|i[s>>2])<=1&&(0|i[s+4>>2])<=1&&(0|i[s+8>>2])<=1){h=127==(0|(l=0|j(p,n=0|ie(s))))?0:0|q(l);t:do{if(n){if(a){if(7==(0|(l=0|Fe(e,t)))){l=5;break e}if((0|(u=0|i[21248+(28*l|0)+(n<<2)>>2]))>0){l=n,n=0;do{l=0|pe(l),n=n+1|0}while((0|n)!=(0|u))}else l=n;if(1==(0|l)){l=9;break e}127==(0|(n=0|j(p,l)))&&M(23200,23090,411,23230),0|q(n)?M(23245,23090,412,23230):(m=n,f=u,d=l)}else m=l,f=0,d=n;if((0|(A=0|i[4272+(28*p|0)+(d<<2)>>2]))<=-1&&M(23276,23090,419,23230),!h){if((0|f)<0){l=5;break e}if(0|f){l=0,n=0|i[(u=r)>>2],u=0|i[u+4>>2];do{n=0|qe(n,u),u=0|T(),i[(y=r)>>2]=n,i[y+4>>2]=u,l=l+1|0}while((0|l)<(0|f))}if((0|A)<=0){l=m,n=58;break}for(l=0,n=0|i[(u=r)>>2],u=0|i[u+4>>2];;)if(n=0|qe(n,u),u=0|T(),i[(y=r)>>2]=n,i[y+4>>2]=u,(0|(l=l+1|0))==(0|A)){l=m,n=58;break t}}if(7==(0|(c=0|W(m,p)))&&M(23066,23090,428,23230),n=0|i[(l=r)>>2],l=0|i[l+4>>2],(0|A)>0){u=0;do{n=0|qe(n,l),l=0|T(),i[(y=r)>>2]=n,i[y+4>>2]=l,u=u+1|0}while((0|u)!=(0|A))}if(7==(0|(l=0|Fe(n,l)))&&M(23313,23090,440,23230),n=0|G(m),(0|(n=0|i[(n?21664:21456)+(28*c|0)+(l<<2)>>2]))<0&&M(23313,23090,454,23230),n){l=0,u=0|i[(c=r)>>2],c=0|i[c+4>>2];do{u=0|ke(u,c),c=0|T(),i[(y=r)>>2]=u,i[y+4>>2]=c,l=l+1|0}while((0|l)<(0|n));l=m,n=58}else l=m,n=58}else if(!!(0|a)&!!(0|h)){if(7==(0|(n=0|Fe(e,t)))|7==(0|(u=0|Fe(0|i[(u=r)>>2],0|i[u+4>>2])))){l=5;break e}if((0|(u=0|i[21248+(28*n|0)+(u<<2)>>2]))<0){l=5;break e}if(u){n=0,c=0|i[(A=r)>>2],A=0|i[A+4>>2];do{c=0|qe(c,A),A=0|T(),i[(y=r)>>2]=c,i[y+4>>2]=A,n=n+1|0}while((0|n)<(0|u));n=58}else n=59}else n=58}while(0);if(58==(0|n)&&h&&(n=59),59==(0|n)&&1==(0|Fe(0|i[(y=r)>>2],0|i[y+4>>2]))){l=9;break}_=0|i[(y=r)>>2],y=-1040385&i[y+4>>2],v=0|zt(0|l,0,45),y|=T(),i[(l=r)>>2]=_|v,i[l+4>>2]=y,l=0}else l=1}while(0);return D=o,0|(y=l)}function At(e,t,n,r){e|=0,t|=0;var i=0,s=0,a=0;if(!(0|(n|=0))&!(0|(r|=0)))return s=1,w(0|(i=0)),0|s;s=e,i=t,e=1,t=0;do{e=0|Ot(0|((a=!0&!(1&n))?1:s),0|(a?0:i),0|e,0|t),t=0|T(),n=0|qt(0|n,0|r,1),r=0|T(),s=0|Ot(0|s,0|i,0|s,0|i),i=0|T()}while(!(!(0|n)&!(0|r)));return w(0|t),0|e}function ht(e,t,n){e|=0;var r,a=0,o=0,l=0,u=0,c=0,A=0,h=0,d=0,p=0;if(!(0|Q(t|=0,n|=0)))return 0|(p=0);if(t=0|X(t),a=+s[n>>3],o=t&(o=+s[n+8>>3])<0?o+6.283185307179586:o,(0|(p=0|i[e>>2]))<=0)return 0|(p=0);if(r=0|i[e+4>>2],t){t=0,d=o,n=-1,e=0;e:for(;;){for(h=e;u=+s[r+(h<<4)>>3],o=+s[r+(h<<4)+8>>3],l=+s[r+((e=(n+2|0)%(0|p)|0)<<4)>>3],c=+s[r+(e<<4)+8>>3],u>l?(A=u,u=c):(A=l,l=u,u=o,o=c),(a=a==l|a==A?a+2220446049250313e-31:a)A;){if((0|(n=h+1|0))>=(0|p)){n=22;break e}e=h,h=n,n=e}if(((A=(c=u<0?u+6.283185307179586:u)+(a-l)/(A-l)*((u=o<0?o+6.283185307179586:o)-c))<0?A+6.283185307179586:A)>(d=c==d|u==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=h+1|0))>=(0|p)){n=22;break}n=h}if(22==(0|n))return 0|t}else{t=0,d=o,n=-1,e=0;e:for(;;){for(h=e;u=+s[r+(h<<4)>>3],o=+s[r+(h<<4)+8>>3],l=+s[r+((e=(n+2|0)%(0|p)|0)<<4)>>3],c=+s[r+(e<<4)+8>>3],u>l?(A=u,u=c):(A=l,l=u,u=o,o=c),(a=a==l|a==A?a+2220446049250313e-31:a)A;){if((0|(n=h+1|0))>=(0|p)){n=22;break e}e=h,h=n,n=e}if(u+(a-l)/(A-l)*(o-u)>(d=u==d|o==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=h+1|0))>=(0|p)){n=22;break}n=h}if(22==(0|n))return 0|t}return 0}function dt(e,t){t|=0;var n,r,a,o,l,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0,x=0;if(!(r=0|i[(e|=0)>>2]))return i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,void(i[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|r)<=0)){for(n=0|i[e+4>>2],g=17976931348623157e292,_=-17976931348623157e292,v=0,e=-1,d=17976931348623157e292,p=17976931348623157e292,m=-17976931348623157e292,A=-17976931348623157e292,y=0;c=+s[n+(y<<4)>>3],f=+s[n+(y<<4)+8>>3],h=+s[n+(((0|(e=e+2|0))==(0|r)?0:e)<<4)+8>>3],c>3]=c,d=c),f>3]=f,p=f),c>m?s[t>>3]=c:c=m,f>A&&(s[l>>3]=f,A=f),g=f>0&f_?f:_,v|=+u(+(f-h))>3.141592653589793,(0|(e=y+1|0))!=(0|r);)x=y,m=c,y=e,e=x;v&&(s[l>>3]=_,s[o>>3]=g)}}function pt(e,t){t|=0;var n,r=0,a=0,o=0,l=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0,x=0,b=0,S=0,w=0,T=0,M=0;if(_=0|i[(e|=0)>>2]){if(s[(v=t+8|0)>>3]=17976931348623157e292,s[(y=t+24|0)>>3]=17976931348623157e292,s[t>>3]=-17976931348623157e292,s[(x=t+16|0)>>3]=-17976931348623157e292,(0|_)>0){for(o=0|i[e+4>>2],m=17976931348623157e292,g=-17976931348623157e292,a=0,r=-1,h=17976931348623157e292,d=17976931348623157e292,f=-17976931348623157e292,c=-17976931348623157e292,b=0;l=+s[o+(b<<4)>>3],p=+s[o+(b<<4)+8>>3],A=+s[o+(((0|(T=r+2|0))==(0|_)?0:T)<<4)+8>>3],l>3]=l,h=l),p>3]=p,d=p),l>f?s[t>>3]=l:l=f,p>c&&(s[x>>3]=p,c=p),m=p>0&pg?p:g,a|=+u(+(p-A))>3.141592653589793,(0|(r=b+1|0))!=(0|_);)T=b,f=l,b=r,r=T;a&&(s[x>>3]=g,s[y>>3]=m)}}else i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;if(!((0|(r=0|i[(T=e+8|0)>>2]))<=0)){n=e+12|0,w=0;do{if(o=0|i[n>>2],a=w,y=t+((w=w+1|0)<<5)|0,x=0|i[o+(a<<3)>>2]){if(s[(b=t+(w<<5)+8|0)>>3]=17976931348623157e292,s[(e=t+(w<<5)+24|0)>>3]=17976931348623157e292,s[y>>3]=-17976931348623157e292,s[(S=t+(w<<5)+16|0)>>3]=-17976931348623157e292,(0|x)>0){for(_=0|i[o+(a<<3)+4>>2],m=17976931348623157e292,g=-17976931348623157e292,o=0,a=-1,v=0,h=17976931348623157e292,d=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292;l=+s[_+(v<<4)>>3],f=+s[_+(v<<4)+8>>3],A=+s[_+(((0|(a=a+2|0))==(0|x)?0:a)<<4)+8>>3],l>3]=l,h=l),f>3]=f,d=f),l>p?s[y>>3]=l:l=p,f>c&&(s[S>>3]=f,c=f),m=f>0&fg?f:g,o|=+u(+(f-A))>3.141592653589793,(0|(a=v+1|0))!=(0|x);)M=v,v=a,p=l,a=M;o&&(s[S>>3]=g,s[e>>3]=m)}}else i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0,i[y+16>>2]=0,i[y+20>>2]=0,i[y+24>>2]=0,i[y+28>>2]=0,r=0|i[T>>2]}while((0|w)<(0|r))}}function ft(e,t,n){var r=0,s=0,a=0;if(!(0|ht(e|=0,t|=0,n|=0)))return 0|(s=0);if((0|i[(s=e+8|0)>>2])<=0)return 0|(s=1);for(r=e+12|0,e=0;;){if(a=e,e=e+1|0,0|ht((0|i[r>>2])+(a<<3)|0,t+(e<<5)|0,n)){e=0,r=6;break}if((0|e)>=(0|i[s>>2])){e=1,r=6;break}}return 6==(0|r)?0|e:0}function mt(e,t,n,r,i){t|=0,n|=0,r|=0,i|=0;var a,o,l,u,c,A,h,d=0;u=+s[(e|=0)>>3],l=+s[t>>3]-u,o=+s[e+8>>3],a=+s[t+8>>3]-o,A=+s[n>>3],d=((d=+s[r>>3]-A)*(o-(h=+s[n+8>>3]))-(u-A)*(c=+s[r+8>>3]-h))/(l*c-a*d),s[i>>3]=u+l*d,s[i+8>>3]=o+a*d}function gt(e,t){return t|=0,+u(+(+s[(e|=0)>>3]-+s[t>>3]))<1.1920928955078125e-7?0|(t=+u(+(+s[e+8>>3]-+s[t+8>>3]))<1.1920928955078125e-7):0|(t=0)}function _t(e,t){t|=0;var n,r,i;return+((i=+s[(e|=0)>>3]-+s[t>>3])*i+(r=+s[e+8>>3]-+s[t+8>>3])*r+(n=+s[e+16>>3]-+s[t+16>>3])*n)}function vt(e,t,n){n|=0;var r,s,a,o,l=0,u=0,c=0;if(o=D,D=D+32|0,c=o,0|(l=0|We(e|=0,t|=0,s=o+16|0)))return D=o,0|(n=l);r=0|Le(e,t),a=0|Fe(e,t),function(e,t){e=7696+(28*(e|=0)|0)|0,i[(t|=0)>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2]}(r,c),l=0|function(e,t){e|=0;var n=0,r=0;if((t|=0)>>>0>20)return-1;do{if((0|i[11120+(216*t|0)>>2])!=(0|e))if((0|i[11120+(216*t|0)+8>>2])!=(0|e))if((0|i[11120+(216*t|0)+16>>2])!=(0|e))if((0|i[11120+(216*t|0)+24>>2])!=(0|e))if((0|i[11120+(216*t|0)+32>>2])!=(0|e))if((0|i[11120+(216*t|0)+40>>2])!=(0|e))if((0|i[11120+(216*t|0)+48>>2])!=(0|e))if((0|i[11120+(216*t|0)+56>>2])!=(0|e))if((0|i[11120+(216*t|0)+64>>2])!=(0|e))if((0|i[11120+(216*t|0)+72>>2])!=(0|e))if((0|i[11120+(216*t|0)+80>>2])!=(0|e))if((0|i[11120+(216*t|0)+88>>2])!=(0|e))if((0|i[11120+(216*t|0)+96>>2])!=(0|e))if((0|i[11120+(216*t|0)+104>>2])!=(0|e))if((0|i[11120+(216*t|0)+112>>2])!=(0|e))if((0|i[11120+(216*t|0)+120>>2])!=(0|e))if((0|i[11120+(216*t|0)+128>>2])!=(0|e)){if((0|i[11120+(216*t|0)+136>>2])!=(0|e)){if((0|i[11120+(216*t|0)+144>>2])==(0|e)){e=0,n=2,r=0;break}if((0|i[11120+(216*t|0)+152>>2])==(0|e)){e=0,n=2,r=1;break}if((0|i[11120+(216*t|0)+160>>2])==(0|e)){e=0,n=2,r=2;break}if((0|i[11120+(216*t|0)+168>>2])==(0|e)){e=1,n=2,r=0;break}if((0|i[11120+(216*t|0)+176>>2])==(0|e)){e=1,n=2,r=1;break}if((0|i[11120+(216*t|0)+184>>2])==(0|e)){e=1,n=2,r=2;break}if((0|i[11120+(216*t|0)+192>>2])==(0|e)){e=2,n=2,r=0;break}if((0|i[11120+(216*t|0)+200>>2])==(0|e)){e=2,n=2,r=1;break}if((0|i[11120+(216*t|0)+208>>2])==(0|e)){e=2,n=2,r=2;break}return-1}e=2,n=1,r=2}else e=2,n=1,r=1;else e=2,n=1,r=0;else e=1,n=1,r=2;else e=1,n=1,r=1;else e=1,n=1,r=0;else e=0,n=1,r=2;else e=0,n=1,r=1;else e=0,n=1,r=0;else e=2,n=0,r=2;else e=2,n=0,r=1;else e=2,n=0,r=0;else e=1,n=0,r=2;else e=1,n=0,r=1;else e=1,n=0,r=0;else e=0,n=0,r=2;else e=0,n=0,r=1;else e=0,n=0,r=0}while(0);return 0|i[11120+(216*t|0)+(72*n|0)+(24*e|0)+(r<<3)+4>>2]}(r,0|i[s>>2]);e:do{if(0|q(r)){switch(0|r){case 4:e=0;break;case 14:e=1;break;case 24:e=2;break;case 38:e=3;break;case 49:e=4;break;case 58:e=5;break;case 63:e=6;break;case 72:e=7;break;case 83:e=8;break;case 97:e=9;break;case 107:e=10;break;case 117:e=11;break;default:l=1;break e}if(u=0|i[22e3+(24*e|0)+8>>2],t=0|i[22e3+(24*e|0)+16>>2],(0|(e=0|i[s>>2]))!=(0|i[c>>2])&&(c=0|G(r))|(0|(e=0|i[s>>2]))==(0|t)&&(l=(l+1|0)%6|0),3==(0|a)&(0|e)==(0|t)){l=(l+5|0)%6|0,u=22;break}5==(0|a)&(0|e)==(0|u)?(l=(l+1|0)%6|0,u=22):u=22}else u=22}while(0);return 22==(0|u)&&(i[n>>2]=l,l=0),D=o,0|(n=l)}function yt(e,t,n,r){n|=0,r|=0;var s,a,o,l,u,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0;if(u=D,D=D+32|0,y=u+24|0,l=u+20|0,o=u+8|0,a=u+16|0,s=u,p=(p=!(0|Oe(e|=0,t|=0)))?6:5,m=0|Gt(0|e,0|t,52),T(),p>>>0<=n>>>0)return D=u,0|(r=2);!(g=!(0|(m&=15)))&&!((_=0|zt(7,0,3*(15^m)|0))&e)&!(T()&t)?c=n:A=4;e:do{if(4==(0|A)){if((0|((c=!!(0|Oe(e,t)))?4:5))<(0|n))return D=u,0|(r=1);if(0|vt(e,t,y))return D=u,0|(r=1);if(A=(0|i[y>>2])+n|0,7==(0|(_=0|i[(c=c?22288+((0|A)%5<<2)|0:22320+((0|A)%6<<2)|0)>>2])))return D=u,0|(r=1);i[l>>2]=0,c=0|O(e,t,_,l,o);do{if(!c){if(f=0|i[(d=o)>>2],A=(h=(d=0|i[d+4>>2])>>>0>>0|(0|d)==(0|t)&f>>>0>>0)?f:e,h=h?d:t,!g&&!(f&(g=0|zt(7,0,3*(15^m)|0)))&!(d&T()))c=n;else{if(d=(n+-1+p|0)%(0|p)|0,c=0|Oe(e,t),(0|d)<0&&M(23313,23315,245,23324),(0|((p=!!(0|c))?4:5))<(0|d)&&M(23313,23315,245,23324),0|vt(e,t,y)&&M(23313,23315,245,23324),c=(0|i[y>>2])+d|0,7==(0|(d=0|i[(c=p?22288+((0|c)%5<<2)|0:22320+((0|c)%6<<2)|0)>>2]))&&M(23313,23315,245,23324),i[a>>2]=0,0|(c=0|O(e,t,d,a,s)))break;p=0|i[(f=s)>>2],f=0|i[f+4>>2];do{if(f>>>0>>0|(0|f)==(0|h)&p>>>0>>0){if(A=0|Oe(p,f)?0|F(p,f,e,t):0|i[22384+(((0|i[a>>2])+(0|i[22352+(d<<2)>>2])|0)%6<<2)>>2],c=0|Oe(p,f),(A+-1|0)>>>0>5){c=-1,A=p,h=f;break}if(1==(0|A)&(c=!!(0|c))){c=-1,A=p,h=f;break}do{if(!(0|vt(p,f,y))){if(c){c=(5+(0|i[21936+(A<<2)>>2])-(0|i[y>>2])|0)%5|0;break}c=(6+(0|i[21968+(A<<2)>>2])-(0|i[y>>2])|0)%6|0;break}c=-1}while(0);A=p,h=f}else c=n}while(0);f=0|i[(d=o)>>2],d=0|i[d+4>>2]}if((0|A)==(0|f)&(0|h)==(0|d)){if(e=(p=!!(0|Oe(f,d)))?0|F(f,d,e,t):0|i[22384+(((0|i[l>>2])+(0|i[22352+(_<<2)>>2])|0)%6<<2)>>2],c=0|Oe(f,d),(e+-1|0)>>>0<=5&&!(1==(0|e)&(v=!!(0|c))))do{if(!(0|vt(f,d,y))){if(v){c=(5+(0|i[21936+(e<<2)>>2])-(0|i[y>>2])|0)%5|0;break}c=(6+(0|i[21968+(e<<2)>>2])-(0|i[y>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|p&5==(0|c)?0:c}t=h,e=A;break e}}while(0);return D=u,0|(r=c)}}while(0);return v=0|zt(0|c,0,56),y=T()|-2130706433&t|536870912,i[r>>2]=v|e,i[r+4>>2]=y,D=u,0|(r=0)}function xt(e,t,n){e|=0,n|=0;var r=0;(0|(t|=0))>0?(r=0|Pt(t,4),i[e>>2]=r,r||M(23337,23360,40,23374)):i[e>>2]=0,i[e+4>>2]=t,i[e+8>>2]=0,i[e+12>>2]=n}function bt(e){var t,n,r,a=0,o=0,l=0,c=0;t=(e|=0)+4|0,n=e+12|0,r=e+8|0;e:for(;;){for(o=0|i[t>>2],a=0;;){if((0|a)>=(0|o))break e;if(l=0|i[e>>2],c=0|i[l+(a<<2)>>2])break;a=a+1|0}a=l+(~~(+u(+ +A(10,+ +(15-(0|i[n>>2])|0))*(+s[c>>3]+ +s[c+8>>3]))%+(0|o))>>>0<<2)|0,o=0|i[a>>2];t:do{if(0|o){if(l=c+32|0,(0|o)==(0|c))i[a>>2]=i[l>>2];else{if(!(a=0|i[(o=o+32|0)>>2]))break;for(;(0|a)!=(0|c);)if(!(a=0|i[(o=a+32|0)>>2]))break t;i[o>>2]=i[l>>2]}Nt(c),i[r>>2]=(0|i[r>>2])-1}}while(0)}Nt(0|i[e>>2])}function St(e){var t,n=0,r=0;for(t=0|i[(e|=0)+4>>2],r=0;;){if((0|r)>=(0|t)){n=0,r=4;break}if(n=0|i[(0|i[e>>2])+(r<<2)>>2]){r=4;break}r=r+1|0}return 4==(0|r)?0|n:0}function wt(e,t){t|=0;var n=0,r=0,a=0,o=0;if(n=~~(+u(+ +A(10,+ +(15-(0|i[(e|=0)+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,n=(0|i[e>>2])+(n<<2)|0,!(r=0|i[n>>2]))return 0|(o=1);o=t+32|0;do{if((0|r)!=(0|t)){if(!(n=0|i[r+32>>2]))return 0|(o=1);for(a=n;;){if((0|a)==(0|t)){a=8;break}if(!(n=0|i[a+32>>2])){n=1,a=10;break}r=a,a=n}if(8==(0|a)){i[r+32>>2]=i[o>>2];break}if(10==(0|a))return 0|n}else i[n>>2]=i[o>>2]}while(0);return Nt(t),i[(o=e+8|0)>>2]=(0|i[o>>2])-1,0|(o=0)}function Tt(e,t,n){e|=0,t|=0,n|=0;var r,a=0,o=0,l=0;(r=0|Rt(40))||M(23390,23360,98,23403),i[r>>2]=i[t>>2],i[r+4>>2]=i[t+4>>2],i[r+8>>2]=i[t+8>>2],i[r+12>>2]=i[t+12>>2],i[(o=r+16|0)>>2]=i[n>>2],i[o+4>>2]=i[n+4>>2],i[o+8>>2]=i[n+8>>2],i[o+12>>2]=i[n+12>>2],i[r+32>>2]=0,o=~~(+u(+ +A(10,+ +(15-(0|i[e+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,o=(0|i[e>>2])+(o<<2)|0,a=0|i[o>>2];do{if(a){for(;!(0|Je(a,t)&&0|Je(a+16|0,n));)if(o=0|i[a+32>>2],!(0|i[(a=0|o?o:a)+32>>2])){l=10;break}if(10==(0|l)){i[a+32>>2]=r;break}return Nt(r),0|(l=a)}i[o>>2]=r}while(0);return i[(l=e+8|0)>>2]=1+(0|i[l>>2]),0|(l=r)}function Mt(e,t,n){t|=0,n|=0;var r=0,a=0;if(a=~~(+u(+ +A(10,+ +(15-(0|i[(e|=0)+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,!(a=0|i[(0|i[e>>2])+(a<<2)>>2]))return 0|(n=0);if(!n){for(e=a;;){if(0|Je(e,t)){r=10;break}if(!(e=0|i[e+32>>2])){e=0,r=10;break}}if(10==(0|r))return 0|e}for(e=a;;){if(0|Je(e,t)&&0|Je(e+16|0,n)){r=10;break}if(!(e=0|i[e+32>>2])){e=0,r=10;break}}return 10==(0|r)?0|e:0}function Et(e,t){t|=0;var n=0;if(n=~~(+u(+ +A(10,+ +(15-(0|i[(e|=0)+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,!(e=0|i[(0|i[e>>2])+(n<<2)>>2]))return 0|(n=0);for(;;){if(0|Je(e,t)){t=5;break}if(!(e=0|i[e+32>>2])){e=0,t=5;break}}return 5==(0|t)?0|e:0}function Ct(e){return 0|+function(e){return+ +Qt(+(e=+e))}(e=+e)}function Rt(e){e|=0;var t,n=0,r=0,s=0,a=0,o=0,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0,x=0,b=0;t=D,D=D+16|0,p=t;do{if(e>>>0<245){if(e=(A=e>>>0<11?16:e+11&-8)>>>3,3&(r=(d=0|i[5857])>>>e))return s=0|i[(r=(e=23468+((n=(1&r^1)+e|0)<<1<<2)|0)+8|0)>>2],(0|(o=0|i[(a=s+8|0)>>2]))==(0|e)?i[5857]=d&~(1<>2]=e,i[r>>2]=o),b=n<<3,i[s+4>>2]=3|b,i[(b=s+b+4|0)>>2]=1|i[b>>2],D=t,0|(b=a);if(A>>>0>(h=0|i[5859])>>>0){if(0|r)return n=((n=r<>>=u=n>>>12&16)>>>5&8)|u|(o=(n>>>=r)>>>2&4)|(e=(n>>>=o)>>>1&2)|(s=(n>>>=e)>>>1&1))+(n>>>s)|0)<<1<<2)|0)+8|0)>>2],(0|(r=0|i[(u=o+8|0)>>2]))==(0|n)?(e=d&~(1<>2]=n,i[e>>2]=r,e=d),l=(b=s<<3)-A|0,i[o+4>>2]=3|A,i[(a=o+A|0)+4>>2]=1|l,i[o+b>>2]=l,0|h&&(s=0|i[5862],r=23468+((n=h>>>3)<<1<<2)|0,e&(n=1<>2]:(i[5857]=e|n,n=r,e=r+8|0),i[e>>2]=s,i[n+12>>2]=s,i[s+8>>2]=n,i[s+12>>2]=r),i[5859]=l,i[5862]=a,D=t,0|(b=u);if(o=0|i[5858]){for(r=(o&0-o)-1|0,r=c=0|i[23732+(((s=(r>>>=a=r>>>12&16)>>>5&8)|a|(l=(r>>>=s)>>>2&4)|(u=(r>>>=l)>>>1&2)|(c=(r>>>=u)>>>1&1))+(r>>>c)<<2)>>2],u=c,c=(-8&i[c+4>>2])-A|0;(e=0|i[r+16>>2])||(e=0|i[r+20>>2]);)r=e,u=(a=(l=(-8&i[e+4>>2])-A|0)>>>0>>0)?e:u,c=a?l:c;if((l=u+A|0)>>>0>u>>>0){a=0|i[u+24>>2],n=0|i[u+12>>2];do{if((0|n)==(0|u)){if(!(n=0|i[(e=u+20|0)>>2])&&!(n=0|i[(e=u+16|0)>>2])){r=0;break}for(;;)if(r=0|i[(s=n+20|0)>>2])n=r,e=s;else{if(!(r=0|i[(s=n+16|0)>>2]))break;n=r,e=s}i[e>>2]=0,r=n}else r=0|i[u+8>>2],i[r+12>>2]=n,i[n+8>>2]=r,r=n}while(0);do{if(0|a){if(n=0|i[u+28>>2],(0|u)==(0|i[(e=23732+(n<<2)|0)>>2])){if(i[e>>2]=r,!r){i[5858]=o&~(1<>2])==(0|u)?b:a+20)>>2]=r,!r)break;i[r+24>>2]=a,0|(n=0|i[u+16>>2])&&(i[r+16>>2]=n,i[n+24>>2]=r),0|(n=0|i[u+20>>2])&&(i[r+20>>2]=n,i[n+24>>2]=r)}}while(0);return c>>>0<16?(b=c+A|0,i[u+4>>2]=3|b,i[(b=u+b+4|0)>>2]=1|i[b>>2]):(i[u+4>>2]=3|A,i[l+4>>2]=1|c,i[l+c>>2]=c,0|h&&(s=0|i[5862],r=23468+((n=h>>>3)<<1<<2)|0,(n=1<>2]:(i[5857]=n|d,n=r,e=r+8|0),i[e>>2]=s,i[n+12>>2]=s,i[s+8>>2]=n,i[s+12>>2]=r),i[5859]=c,i[5862]=l),D=t,0|(b=u+8|0)}d=A}else d=A}else d=A}else if(e>>>0<=4294967231)if(A=-8&(e=e+11|0),s=0|i[5858]){a=0-A|0,c=(e>>>=8)?A>>>0>16777215?31:A>>>((c=14-((u=((g=e<<(d=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|d|(c=((g<<=u)+245760|0)>>>16&2))+(g<>>15)|0)+7|0)&1|c<<1:0,r=0|i[23732+(c<<2)>>2];e:do{if(r)for(e=0,u=A<<(31==(0|c)?0:25-(c>>>1)),o=0;;){if((l=(-8&i[r+4>>2])-A|0)>>>0>>0){if(!l){e=r,a=0,g=65;break e}e=r,a=l}if(o=!(0|(g=0|i[r+20>>2]))|(0|g)==(0|(r=0|i[r+16+(u>>>31<<2)>>2]))?o:g,!r){r=o,g=61;break}u<<=1}else r=0,e=0,g=61}while(0);if(61==(0|g)){if(!(0|r)&!(0|e)){if(!(e=((e=2<>>=l=d>>>12&16)>>>5&8)|l|(u=(d>>>=o)>>>2&4)|(c=(d>>>=u)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?g=65:(u=e,l=a)}if(65==(0|g))for(o=r;;){if(a=(r=(d=(-8&i[o+4>>2])-A|0)>>>0>>0)?d:a,e=r?o:e,(r=0|i[o+16>>2])||(r=0|i[o+20>>2]),!r){u=e,l=a;break}o=r}if(0|u&&l>>>0<((0|i[5859])-A|0)>>>0&&(h=u+A|0)>>>0>u>>>0){o=0|i[u+24>>2],n=0|i[u+12>>2];do{if((0|n)==(0|u)){if(!(n=0|i[(e=u+20|0)>>2])&&!(n=0|i[(e=u+16|0)>>2])){n=0;break}for(;;)if(r=0|i[(a=n+20|0)>>2])n=r,e=a;else{if(!(r=0|i[(a=n+16|0)>>2]))break;n=r,e=a}i[e>>2]=0}else b=0|i[u+8>>2],i[b+12>>2]=n,i[n+8>>2]=b}while(0);do{if(o){if(e=0|i[u+28>>2],(0|u)==(0|i[(r=23732+(e<<2)|0)>>2])){if(i[r>>2]=n,!n){s&=~(1<>2])==(0|u)?b:o+20)>>2]=n,!n)break;i[n+24>>2]=o,0|(e=0|i[u+16>>2])&&(i[n+16>>2]=e,i[e+24>>2]=n),(e=0|i[u+20>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);e:do{if(l>>>0<16)b=l+A|0,i[u+4>>2]=3|b,i[(b=u+b+4|0)>>2]=1|i[b>>2];else{if(i[u+4>>2]=3|A,i[h+4>>2]=1|l,i[h+l>>2]=l,n=l>>>3,l>>>0<256){r=23468+(n<<1<<2)|0,(e=0|i[5857])&(n=1<>2]:(i[5857]=e|n,n=r,e=r+8|0),i[e>>2]=h,i[n+12>>2]=h,i[h+8>>2]=n,i[h+12>>2]=r;break}if(n=23732+((r=(n=l>>>8)?l>>>0>16777215?31:l>>>((r=14-((y=((b=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(r=((b<<=y)+245760|0)>>>16&2))+(b<>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[h+28>>2]=r,i[(e=h+16|0)+4>>2]=0,i[e>>2]=0,!(s&(e=1<>2]=h,i[h+24>>2]=n,i[h+12>>2]=h,i[h+8>>2]=h;break}n=0|i[n>>2];t:do{if((-8&i[n+4>>2])!=(0|l)){for(s=l<<(31==(0|r)?0:25-(r>>>1));e=0|i[(r=n+16+(s>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|l)){n=e;break t}s<<=1,n=e}i[r>>2]=h,i[h+24>>2]=n,i[h+12>>2]=h,i[h+8>>2]=h;break e}}while(0);b=0|i[(x=n+8|0)>>2],i[b+12>>2]=h,i[x>>2]=h,i[h+8>>2]=b,i[h+12>>2]=n,i[h+24>>2]=0}}while(0);return D=t,0|(b=u+8|0)}d=A}else d=A;else d=-1}while(0);if((r=0|i[5859])>>>0>=d>>>0)return n=r-d|0,e=0|i[5862],n>>>0>15?(b=e+d|0,i[5862]=b,i[5859]=n,i[b+4>>2]=1|n,i[e+r>>2]=n,i[e+4>>2]=3|d):(i[5859]=0,i[5862]=0,i[e+4>>2]=3|r,i[(b=e+r+4|0)>>2]=1|i[b>>2]),D=t,0|(b=e+8|0);if((l=0|i[5860])>>>0>d>>>0)return y=l-d|0,i[5860]=y,x=(b=0|i[5863])+d|0,i[5863]=x,i[x+4>>2]=1|y,i[b+4>>2]=3|d,D=t,0|(b=b+8|0);if(0|i[5975]?e=0|i[5977]:(i[5977]=4096,i[5976]=4096,i[5978]=-1,i[5979]=-1,i[5980]=0,i[5968]=0,i[5975]=-16&p^1431655768,e=4096),u=d+48|0,(A=(o=e+(c=d+47|0)|0)&(a=0-e|0))>>>0<=d>>>0)return D=t,0|(b=0);if(0|(e=0|i[5967])&&(p=(h=0|i[5965])+A|0)>>>0<=h>>>0|p>>>0>e>>>0)return D=t,0|(b=0);e:do{if(4&i[5968])n=0,g=143;else{r=0|i[5863];t:do{if(r){for(s=23876;!((p=0|i[s>>2])>>>0<=r>>>0&&(p+(0|i[s+4>>2])|0)>>>0>r>>>0);){if(!(e=0|i[s+8>>2])){g=128;break t}s=e}if((n=o-l&a)>>>0<2147483647)if((0|(e=0|Yt(0|n)))==((0|i[s>>2])+(0|i[s+4>>2])|0)){if(-1!=(0|e)){l=n,o=e,g=145;break e}}else s=e,g=136;else n=0}else g=128}while(0);do{if(128==(0|g))if(-1!=(0|(r=0|Yt(0)))&&(n=r,m=(n=((m=(f=0|i[5976])+-1|0)&n?(m+n&0-f)-n|0:0)+A|0)+(f=0|i[5965])|0,n>>>0>d>>>0&n>>>0<2147483647)){if(0|(p=0|i[5967])&&m>>>0<=f>>>0|m>>>0>p>>>0){n=0;break}if((0|(e=0|Yt(0|n)))==(0|r)){l=n,o=r,g=145;break e}s=e,g=136}else n=0}while(0);do{if(136==(0|g)){if(r=0-n|0,!(u>>>0>n>>>0&n>>>0<2147483647&-1!=(0|s))){if(-1==(0|s)){n=0;break}l=n,o=s,g=145;break e}if((e=c-n+(e=0|i[5977])&0-e)>>>0>=2147483647){l=n,o=s,g=145;break e}if(-1==(0|Yt(0|e))){Yt(0|r),n=0;break}l=e+n|0,o=s,g=145;break e}}while(0);i[5968]=4|i[5968],g=143}}while(0);if(143==(0|g)&&A>>>0<2147483647&&!(-1==(0|(y=0|Yt(0|A)))|1^(v=(_=(m=0|Yt(0))-y|0)>>>0>(d+40|0)>>>0)|y>>>0>>0&-1!=(0|y)&-1!=(0|m)^1)&&(l=v?_:n,o=y,g=145),145==(0|g)){n=(0|i[5965])+l|0,i[5965]=n,n>>>0>(0|i[5966])>>>0&&(i[5966]=n),c=0|i[5863];e:do{if(c){for(n=23876;;){if((0|o)==((e=0|i[n>>2])+(r=0|i[n+4>>2])|0)){g=154;break}if(!(s=0|i[n+8>>2]))break;n=s}if(!(154!=(0|g)||(x=n+4|0,8&i[n+12>>2]))&&o>>>0>c>>>0&e>>>0<=c>>>0){i[x>>2]=r+l,x=c+(y=7&(y=c+8|0)?0-y&7:0)|0,y=(b=(0|i[5860])+l|0)-y|0,i[5863]=x,i[5860]=y,i[x+4>>2]=1|y,i[c+b+4>>2]=40,i[5864]=i[5979];break}for(o>>>0<(0|i[5861])>>>0&&(i[5861]=o),r=o+l|0,n=23876;;){if((0|i[n>>2])==(0|r)){g=162;break}if(!(e=0|i[n+8>>2]))break;n=e}if(162==(0|g)&&!(8&i[n+12>>2])){i[n>>2]=o,i[(h=n+4|0)>>2]=(0|i[h>>2])+l,A=(h=o+(7&(h=o+8|0)?0-h&7:0)|0)+d|0,u=(n=r+(7&(n=r+8|0)?0-n&7:0)|0)-h-d|0,i[h+4>>2]=3|d;t:do{if((0|c)==(0|n))b=(0|i[5860])+u|0,i[5860]=b,i[5863]=A,i[A+4>>2]=1|b;else{if((0|i[5862])==(0|n)){b=(0|i[5859])+u|0,i[5859]=b,i[5862]=A,i[A+4>>2]=1|b,i[A+b>>2]=b;break}if(1==(3&(e=0|i[n+4>>2]))){l=-8&e,s=e>>>3;n:do{if(e>>>0<256){if(e=0|i[n+8>>2],(0|(r=0|i[n+12>>2]))==(0|e)){i[5857]=i[5857]&~(1<>2]=r,i[r+8>>2]=e;break}o=0|i[n+24>>2],e=0|i[n+12>>2];do{if((0|e)==(0|n)){if(e=0|i[(s=(r=n+16|0)+4|0)>>2])r=s;else if(!(e=0|i[r>>2])){e=0;break}for(;;)if(s=0|i[(a=e+20|0)>>2])e=s,r=a;else{if(!(s=0|i[(a=e+16|0)>>2]))break;e=s,r=a}i[r>>2]=0}else b=0|i[n+8>>2],i[b+12>>2]=e,i[e+8>>2]=b}while(0);if(!o)break;s=23732+((r=0|i[n+28>>2])<<2)|0;do{if((0|i[s>>2])==(0|n)){if(i[s>>2]=e,0|e)break;i[5858]=i[5858]&~(1<>2])==(0|n)?b:o+20)>>2]=e,!e)break n}while(0);if(i[e+24>>2]=o,0|(s=0|i[(r=n+16|0)>>2])&&(i[e+16>>2]=s,i[s+24>>2]=e),!(r=0|i[r+4>>2]))break;i[e+20>>2]=r,i[r+24>>2]=e}while(0);n=n+l|0,a=l+u|0}else a=u;if(i[(n=n+4|0)>>2]=-2&i[n>>2],i[A+4>>2]=1|a,i[A+a>>2]=a,n=a>>>3,a>>>0<256){r=23468+(n<<1<<2)|0,(e=0|i[5857])&(n=1<>2]:(i[5857]=e|n,n=r,e=r+8|0),i[e>>2]=A,i[n+12>>2]=A,i[A+8>>2]=n,i[A+12>>2]=r;break}n=a>>>8;do{if(n){if(a>>>0>16777215){s=31;break}s=a>>>((s=14-((y=((b=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(s=((b<<=y)+245760|0)>>>16&2))+(b<>>15)|0)+7|0)&1|s<<1}else s=0}while(0);if(n=23732+(s<<2)|0,i[A+28>>2]=s,i[(e=A+16|0)+4>>2]=0,i[e>>2]=0,!((e=0|i[5858])&(r=1<>2]=A,i[A+24>>2]=n,i[A+12>>2]=A,i[A+8>>2]=A;break}n=0|i[n>>2];n:do{if((-8&i[n+4>>2])!=(0|a)){for(s=a<<(31==(0|s)?0:25-(s>>>1));e=0|i[(r=n+16+(s>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|a)){n=e;break n}s<<=1,n=e}i[r>>2]=A,i[A+24>>2]=n,i[A+12>>2]=A,i[A+8>>2]=A;break t}}while(0);b=0|i[(x=n+8|0)>>2],i[b+12>>2]=A,i[x>>2]=A,i[A+8>>2]=b,i[A+12>>2]=n,i[A+24>>2]=0}}while(0);return D=t,0|(b=h+8|0)}for(n=23876;!((e=0|i[n>>2])>>>0<=c>>>0&&(b=e+(0|i[n+4>>2])|0)>>>0>c>>>0);)n=0|i[n+8>>2];n=(e=(e=(a=b+-47|0)+(7&(e=a+8|0)?0-e&7:0)|0)>>>0<(a=c+16|0)>>>0?c:e)+8|0,x=o+(y=7&(y=o+8|0)?0-y&7:0)|0,y=(r=l+-40|0)-y|0,i[5863]=x,i[5860]=y,i[x+4>>2]=1|y,i[o+r+4>>2]=40,i[5864]=i[5979],i[(r=e+4|0)>>2]=27,i[n>>2]=i[5969],i[n+4>>2]=i[5970],i[n+8>>2]=i[5971],i[n+12>>2]=i[5972],i[5969]=o,i[5970]=l,i[5972]=0,i[5971]=n,n=e+24|0;do{x=n,i[(n=n+4|0)>>2]=7}while((x+8|0)>>>0>>0);if((0|e)!=(0|c)){if(o=e-c|0,i[r>>2]=-2&i[r>>2],i[c+4>>2]=1|o,i[e>>2]=o,n=o>>>3,o>>>0<256){r=23468+(n<<1<<2)|0,(e=0|i[5857])&(n=1<>2]:(i[5857]=e|n,n=r,e=r+8|0),i[e>>2]=c,i[n+12>>2]=c,i[c+8>>2]=n,i[c+12>>2]=r;break}if(r=23732+((s=(n=o>>>8)?o>>>0>16777215?31:o>>>((s=14-((y=((b=n<<(x=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|x|(s=((b<<=y)+245760|0)>>>16&2))+(b<>>15)|0)+7|0)&1|s<<1:0)<<2)|0,i[c+28>>2]=s,i[c+20>>2]=0,i[a>>2]=0,!((n=0|i[5858])&(e=1<>2]=c,i[c+24>>2]=r,i[c+12>>2]=c,i[c+8>>2]=c;break}n=0|i[r>>2];t:do{if((-8&i[n+4>>2])!=(0|o)){for(s=o<<(31==(0|s)?0:25-(s>>>1));e=0|i[(r=n+16+(s>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|o)){n=e;break t}s<<=1,n=e}i[r>>2]=c,i[c+24>>2]=n,i[c+12>>2]=c,i[c+8>>2]=c;break e}}while(0);b=0|i[(x=n+8|0)>>2],i[b+12>>2]=c,i[x>>2]=c,i[c+8>>2]=b,i[c+12>>2]=n,i[c+24>>2]=0}}else!(0|(b=0|i[5861]))|o>>>0>>0&&(i[5861]=o),i[5969]=o,i[5970]=l,i[5972]=0,i[5866]=i[5975],i[5865]=-1,i[5870]=23468,i[5869]=23468,i[5872]=23476,i[5871]=23476,i[5874]=23484,i[5873]=23484,i[5876]=23492,i[5875]=23492,i[5878]=23500,i[5877]=23500,i[5880]=23508,i[5879]=23508,i[5882]=23516,i[5881]=23516,i[5884]=23524,i[5883]=23524,i[5886]=23532,i[5885]=23532,i[5888]=23540,i[5887]=23540,i[5890]=23548,i[5889]=23548,i[5892]=23556,i[5891]=23556,i[5894]=23564,i[5893]=23564,i[5896]=23572,i[5895]=23572,i[5898]=23580,i[5897]=23580,i[5900]=23588,i[5899]=23588,i[5902]=23596,i[5901]=23596,i[5904]=23604,i[5903]=23604,i[5906]=23612,i[5905]=23612,i[5908]=23620,i[5907]=23620,i[5910]=23628,i[5909]=23628,i[5912]=23636,i[5911]=23636,i[5914]=23644,i[5913]=23644,i[5916]=23652,i[5915]=23652,i[5918]=23660,i[5917]=23660,i[5920]=23668,i[5919]=23668,i[5922]=23676,i[5921]=23676,i[5924]=23684,i[5923]=23684,i[5926]=23692,i[5925]=23692,i[5928]=23700,i[5927]=23700,i[5930]=23708,i[5929]=23708,i[5932]=23716,i[5931]=23716,x=o+(y=7&(y=o+8|0)?0-y&7:0)|0,y=(b=l+-40|0)-y|0,i[5863]=x,i[5860]=y,i[x+4>>2]=1|y,i[o+b+4>>2]=40,i[5864]=i[5979]}while(0);if((n=0|i[5860])>>>0>d>>>0)return y=n-d|0,i[5860]=y,x=(b=0|i[5863])+d|0,i[5863]=x,i[x+4>>2]=1|y,i[b+4>>2]=3|d,D=t,0|(b=b+8|0)}return i[(b=23424)>>2]=12,D=t,0|(b=0)}function Nt(e){var t=0,n=0,r=0,s=0,a=0,o=0,l=0,u=0;if(e|=0){n=e+-8|0,s=0|i[5861],u=n+(t=-8&(e=0|i[e+-4>>2]))|0;do{if(1&e)l=n,o=n;else{if(r=0|i[n>>2],!(3&e))return;if(a=r+t|0,(o=n+(0-r)|0)>>>0>>0)return;if((0|i[5862])==(0|o)){if(3&~(t=0|i[(e=u+4|0)>>2])){l=o,t=a;break}return i[5859]=a,i[e>>2]=-2&t,i[o+4>>2]=1|a,void(i[o+a>>2]=a)}if(n=r>>>3,r>>>0<256){if(e=0|i[o+8>>2],(0|(t=0|i[o+12>>2]))==(0|e)){i[5857]=i[5857]&~(1<>2]=t,i[t+8>>2]=e,l=o,t=a;break}s=0|i[o+24>>2],e=0|i[o+12>>2];do{if((0|e)==(0|o)){if(e=0|i[(n=(t=o+16|0)+4|0)>>2])t=n;else if(!(e=0|i[t>>2])){e=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0}else l=0|i[o+8>>2],i[l+12>>2]=e,i[e+8>>2]=l}while(0);if(s){if(t=0|i[o+28>>2],(0|i[(n=23732+(t<<2)|0)>>2])==(0|o)){if(i[n>>2]=e,!e){i[5858]=i[5858]&~(1<>2])==(0|o)?l:s+20)>>2]=e,!e){l=o,t=a;break}i[e+24>>2]=s,0|(n=0|i[(t=o+16|0)>>2])&&(i[e+16>>2]=n,i[n+24>>2]=e),(t=0|i[t+4>>2])?(i[e+20>>2]=t,i[t+24>>2]=e,l=o,t=a):(l=o,t=a)}else l=o,t=a}}while(0);if(!(o>>>0>=u>>>0)&&1&(r=0|i[(e=u+4|0)>>2])){if(2&r)i[e>>2]=-2&r,i[l+4>>2]=1|t,i[o+t>>2]=t,s=t;else{if((0|i[5863])==(0|u)){if(u=(0|i[5860])+t|0,i[5860]=u,i[5863]=l,i[l+4>>2]=1|u,(0|l)!=(0|i[5862]))return;return i[5862]=0,void(i[5859]=0)}if((0|i[5862])==(0|u))return u=(0|i[5859])+t|0,i[5859]=u,i[5862]=o,i[l+4>>2]=1|u,void(i[o+u>>2]=u);s=(-8&r)+t|0,n=r>>>3;do{if(r>>>0<256){if(t=0|i[u+8>>2],(0|(e=0|i[u+12>>2]))==(0|t)){i[5857]=i[5857]&~(1<>2]=e,i[e+8>>2]=t;break}a=0|i[u+24>>2],e=0|i[u+12>>2];do{if((0|e)==(0|u)){if(e=0|i[(n=(t=u+16|0)+4|0)>>2])t=n;else if(!(e=0|i[t>>2])){n=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0,n=e}else n=0|i[u+8>>2],i[n+12>>2]=e,i[e+8>>2]=n,n=e}while(0);if(0|a){if(e=0|i[u+28>>2],(0|i[(t=23732+(e<<2)|0)>>2])==(0|u)){if(i[t>>2]=n,!n){i[5858]=i[5858]&~(1<>2])==(0|u)?r:a+20)>>2]=n,!n)break;i[n+24>>2]=a,0|(t=0|i[(e=u+16|0)>>2])&&(i[n+16>>2]=t,i[t+24>>2]=n),0|(e=0|i[e+4>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);if(i[l+4>>2]=1|s,i[o+s>>2]=s,(0|l)==(0|i[5862]))return void(i[5859]=s)}if(e=s>>>3,s>>>0<256)return n=23468+(e<<1<<2)|0,(t=0|i[5857])&(e=1<>2]:(i[5857]=t|e,e=n,t=n+8|0),i[t>>2]=l,i[e+12>>2]=l,i[l+8>>2]=e,void(i[l+12>>2]=n);e=23732+((r=(e=s>>>8)?s>>>0>16777215?31:s>>>((r=14-((a=((u=e<<(o=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|o|(r=((u<<=a)+245760|0)>>>16&2))+(u<>>15)|0)+7|0)&1|r<<1:0)<<2)|0,i[l+28>>2]=r,i[l+20>>2]=0,i[l+16>>2]=0,t=0|i[5858],n=1<>2];t:do{if((-8&i[e+4>>2])!=(0|s)){for(r=s<<(31==(0|r)?0:25-(r>>>1));t=0|i[(n=e+16+(r>>>31<<2)|0)>>2];){if((-8&i[t+4>>2])==(0|s)){e=t;break t}r<<=1,e=t}i[n>>2]=l,i[l+24>>2]=e,i[l+12>>2]=l,i[l+8>>2]=l;break e}}while(0);u=0|i[(o=e+8|0)>>2],i[u+12>>2]=l,i[o>>2]=l,i[l+8>>2]=u,i[l+12>>2]=e,i[l+24>>2]=0}else i[5858]=t|n,i[e>>2]=l,i[l+24>>2]=e,i[l+12>>2]=l,i[l+8>>2]=l}while(0);if(u=(0|i[5865])-1|0,i[5865]=u,!(0|u)){for(e=23884;e=0|i[e>>2];)e=e+8|0;i[5865]=-1}}}}function Pt(e,t){t|=0;var n=0;return(e|=0)?(n=0|y(t,e),(t|e)>>>0>65535&&(n=((n>>>0)/(e>>>0)|0)==(0|t)?n:-1)):n=0,(e=0|Rt(n))&&3&i[e+-4>>2]?(Xt(0|e,0,0|n),0|e):0|e}function Dt(e,t,n,r){return 0|(w((t|=0)+(r|=0)+((n=(e|=0)+(n|=0)>>>0)>>>0>>0|0)>>>0|0),n)}function Lt(e,t,n,r){return 0|(w(0|(r=(t|=0)-(r|=0)-((n|=0)>>>0>(e|=0)>>>0|0)>>>0)),e-n>>>0)}function It(e){return 0|((e|=0)?31-(0|S(e^e-1)):32)}function Ut(e,t,n,r,s){s|=0;var a=0,o=0,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0;if(A=e|=0,o=n|=0,l=d=r|=0,!(c=u=t|=0))return a=!!(0|s),l?a?(i[s>>2]=0|e,i[s+4>>2]=0,s=0,0|(w(0|(d=0)),s)):(s=0,0|(w(0|(d=0)),s)):(a&&(i[s>>2]=(A>>>0)%(o>>>0),i[s+4>>2]=0),s=(A>>>0)/(o>>>0)>>>0,0|(w(0|(d=0)),s));a=!(0|l);do{if(o){if(!a){if((a=(0|S(0|l))-(0|S(0|c))|0)>>>0<=31){o=h=a+1|0,e=A>>>(h>>>0)&(t=a-31>>31)|c<<(l=31-a|0),t&=c>>>(h>>>0),a=0,l=A<>2]=0|e,i[s+4>>2]=0|u,s=0,0|(w(0|(d=0)),s)):(s=0,0|(w(0|(d=0)),s))}if((a=o-1|0)&o){o=l=33+(0|S(0|o))-(0|S(0|c))|0,e=(h=32-l|0)-1>>31&c>>>((p=l-32|0)>>>0)|(c<>>(l>>>0))&(t=p>>31),t&=c>>>(l>>>0),a=A<<(f=64-l|0)&(u=h>>31),l=(c<>>(p>>>0))&u|A<>31;break}return 0|s&&(i[s>>2]=a&A,i[s+4>>2]=0),1==(0|o)?(f=0|e,0|(w(0|(p=0|u)),f)):(p=c>>>((f=0|It(0|o))>>>0)|0,f=c<<32-f|A>>>(f>>>0),0|(w(0|p),f))}if(a)return 0|s&&(i[s>>2]=(c>>>0)%(o>>>0),i[s+4>>2]=0),f=(c>>>0)/(o>>>0)>>>0,0|(w(0|(p=0)),f);if(!A)return 0|s&&(i[s>>2]=0,i[s+4>>2]=(c>>>0)%(l>>>0)),f=(c>>>0)/(l>>>0)>>>0,0|(w(0|(p=0)),f);if(!((a=l-1|0)&l))return 0|s&&(i[s>>2]=0|e,i[s+4>>2]=a&c),p=0,f=c>>>((0|It(0|l))>>>0),0|(w(0|p),f);if((a=(0|S(0|l))-(0|S(0|c))|0)>>>0<=30){o=t=a+1|0,e=c<<(l=31-a|0)|A>>>(t>>>0),t=c>>>(t>>>0),a=0,l=A<>2]=0|e,i[s+4>>2]=0|u,f=0,0|(w(0|(p=0)),f)):(f=0,0|(w(0|(p=0)),f))}while(0);if(o){c=0|Dt(0|(h=0|n),0|(A=0|d),-1,-1),n=0|T(),u=l,l=0;do{r=u,u=a>>>31|u<<1,a=l|a<<1,Lt(0|c,0|n,0|(r=e<<1|r>>>31),0|(d=e>>>31|t<<1)),l=1&(p=(f=0|T())>>31|((0|f)<0?-1:0)<<1),e=0|Lt(0|r,0|d,p&h,(((0|f)<0?-1:0)>>31|((0|f)<0?-1:0)<<1)&A),t=0|T(),o=o-1|0}while(0|o);c=u,u=0}else c=l,u=0,l=0;return o=0,0|s&&(i[s>>2]=e,i[s+4>>2]=t),f=a<<1&-2|l,0|(w(0|(p=(0|a)>>>31|(c|o)<<1|u)),f)}function Bt(e,t,n,r){n|=0;var i,s,a,o,l;return s=(r|=0)>>31|((0|r)<0?-1:0)<<1,i=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,a=0|Lt((l=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0),(o=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t,0|l,0|o),e=s^l,t=i^o,0|Lt(Ut(a,0|T(),0|Lt(s^n,i^r,0|s,0|i),0|T(),0)^e,T()^t,0|e,0|t)}function Ot(e,t,n,r){t|=0,r|=0;var i,s;return n=0|function(e,t){var n,r,i,s=0;return e=((n=0|y(s=65535&(t|=0),i=65535&(e|=0)))>>>16)+(0|y(s,r=e>>>16))|0,t=0|y(s=t>>>16,i),0|(w((e>>>16)+(0|y(s,r))+(((65535&e)+t|0)>>>16)|0),e+t<<16|65535&n)}(i=e|=0,s=n|=0),e=0|T(),0|(w((0|y(t,s))+(0|y(r,i))+e|0),n)}function Ft(e,t,n,r){n|=0;var s,a,o,l,u,c;return s=D,D=D+16|0,l=0|s,c=(r|=0)>>31|((0|r)<0?-1:0)<<1,u=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,Ut(e=0|Lt((o=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0),(a=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t,0|o,0|a),t=0|T(),0|Lt(c^n,u^r,0|c,0|u),0|T(),l),r=0|Lt(i[l>>2]^o,i[l+4>>2]^a,0|o,0|a),n=0|T(),D=s,0|(w(0|n),r)}function kt(e,t,n,r){var s,a;return a=D,D=D+16|0,Ut(e|=0,t|=0,n|=0,r|=0,s=0|a),D=a,0|(w(0|i[s+4>>2]),i[s>>2])}function qt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(w(t>>n),e>>>n|(t&(1<>n-32)}function Gt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(w(t>>>n|0),e>>>n|(t&(1<>>n-32|0)}function zt(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(w(t<>>32-n),e<=0?+l(e+.5):+v(e-.5)}function Wt(e,t,n){e|=0,t|=0;var s,a,o=0;if((0|(n|=0))>=8192)return R(0|e,0|t,0|n),0|e;if(a=0|e,s=e+n|0,(3&e)==(3&t)){for(;3&e;){if(!n)return 0|a;r[e|0]=0|r[t|0],e=e+1|0,t=t+1|0,n=n-1|0}for(o=(n=-4&s)-64|0;(0|e)<=(0|o);)i[e>>2]=i[t>>2],i[e+4>>2]=i[t+4>>2],i[e+8>>2]=i[t+8>>2],i[e+12>>2]=i[t+12>>2],i[e+16>>2]=i[t+16>>2],i[e+20>>2]=i[t+20>>2],i[e+24>>2]=i[t+24>>2],i[e+28>>2]=i[t+28>>2],i[e+32>>2]=i[t+32>>2],i[e+36>>2]=i[t+36>>2],i[e+40>>2]=i[t+40>>2],i[e+44>>2]=i[t+44>>2],i[e+48>>2]=i[t+48>>2],i[e+52>>2]=i[t+52>>2],i[e+56>>2]=i[t+56>>2],i[e+60>>2]=i[t+60>>2],e=e+64|0,t=t+64|0;for(;(0|e)<(0|n);)i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}else for(n=s-4|0;(0|e)<(0|n);)r[e|0]=0|r[t|0],r[e+1|0]=0|r[t+1|0],r[e+2|0]=0|r[t+2|0],r[e+3|0]=0|r[t+3|0],e=e+4|0,t=t+4|0;for(;(0|e)<(0|s);)r[e|0]=0|r[t|0],e=e+1|0,t=t+1|0;return 0|a}function Xt(e,t,n){t|=0;var s,a=0,o=0,l=0;if(s=(e|=0)+(n|=0)|0,t&=255,(0|n)>=67){for(;3&e;)r[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);)i[e>>2]=l,i[e+4>>2]=l,i[e+8>>2]=l,i[e+12>>2]=l,i[e+16>>2]=l,i[e+20>>2]=l,i[e+24>>2]=l,i[e+28>>2]=l,i[e+32>>2]=l,i[e+36>>2]=l,i[e+40>>2]=l,i[e+44>>2]=l,i[e+48>>2]=l,i[e+52>>2]=l,i[e+56>>2]=l,i[e+60>>2]=l,e=e+64|0;for(;(0|e)<(0|a);)i[e>>2]=l,e=e+4|0}for(;(0|e)<(0|s);)r[e|0]=t,e=e+1|0;return s-n|0}function Qt(e){return(e=+e)>=0?+l(e+.5):+v(e-.5)}function Yt(e){e|=0;var t,n,r;return r=0|C(),(0|e)>0&(0|(t=(n=0|i[o>>2])+e|0))<(0|n)|(0|t)<0?(P(0|t),E(12),-1):(0|t)>(0|r)&&!(0|N(0|t))?(E(12),-1):(i[o>>2]=t,0|n)}return{___divdi3:Bt,___muldi3:Ot,___remdi3:Ft,___uremdi3:kt,_areNeighborCells:function(e,t,n,r,s){s|=0;var a,o,l,u=0,c=0,A=0,h=0;if(l=D,D=D+64|0,o=l,a=l+56|0,!(!0&134217728==(2013265920&(t|=0))&!0&134217728==(2013265920&(r|=0))))return D=l,0|(s=5);if((0|(e|=0))==(0|(n|=0))&(0|t)==(0|r))return i[s>>2]=0,D=l,0|(s=0);if(c=0|Gt(0|e,0|t,52),T(),c&=15,h=0|Gt(0|n,0|r,52),T(),(0|c)!=(15&h))return D=l,0|(s=12);if(u=c+-1|0,c>>>0>1){Ue(e,t,u,o),Ue(n,r,u,a),A=0|i[(h=o)>>2],h=0|i[h+4>>2];e:do{if((0|A)==(0|i[a>>2])&&(0|h)==(0|i[a+4>>2])){u=0|Gt(0|e,0|t,0|(c=3*(15^c)|0)),T(),u&=7,c=0|Gt(0|n,0|r,0|c),T(),c&=7;do{if(!(0|u)|!(0|c))i[s>>2]=1,u=0;else if(7==(0|u))u=5;else{if(1==(0|u)|1==(0|c)&&0|Oe(A,h)){u=5;break}if((0|i[15536+(u<<2)>>2])!=(0|c)&&(0|i[15568+(u<<2)>>2])!=(0|c))break e;i[s>>2]=1,u=0}}while(0);return D=l,0|(s=u)}}while(0)}c=(u=o)+56|0;do{i[u>>2]=0,u=u+4|0}while((0|u)<(0|c));return L(e,t,1,o),u=(0|i[(t=o)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=o+8|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=o+16|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=o+24|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=o+32|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=o+40|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)?1:1&((0|i[(u=o+48|0)>>2])==(0|n)?(0|i[u+4>>2])==(0|r):0),i[s>>2]=u,D=l,0|(s=0)},_bitshift64Ashr:qt,_bitshift64Lshr:Gt,_bitshift64Shl:zt,_calloc:Pt,_cellAreaKm2:function(e,t,n){return 0|(e=0|rt(e|=0,t|=0,n|=0))||(s[n>>3]=6371.007180918475*+s[n>>3]*6371.007180918475),0|e},_cellAreaM2:function(e,t,n){return 0|(e=0|rt(e|=0,t|=0,n|=0))||(s[n>>3]=6371.007180918475*+s[n>>3]*6371.007180918475*1e3*1e3),0|e},_cellAreaRads2:rt,_cellToBoundary:Qe,_cellToCenterChild:function(e,t,n,r){n|=0,r|=0;var s=0;return s=0|Gt(0|(e|=0),0|(t|=0),52),T(),(0|n)<16&(0|(s&=15))<=(0|n)?((0|s)<(0|n)&&(s=0|zt(-1,-1,3+(3*(n+-1-s|0)|0)|0),s=0|zt(0|~s,0|~T(),3*(15-n|0)|0),t=~T()&t,e&=~s),s=0|zt(0|n,0,52),n=-15728641&t|T(),i[r>>2]=e|s,i[r+4>>2]=n,0|(r=0)):0|(r=4)},_cellToChildPos:function(e,t,n,r){n|=0,r|=0;var s,a=0,o=0,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0;if(s=D,D=D+16|0,_=s,v=0|Gt(0|(e|=0),0|(t|=0),52),T(),v&=15,n>>>0>15)return D=s,0|(v=4);if((0|v)<(0|n))return D=s,0|(v=12);if((0|v)!=(0|n))if(o=0|zt(0|n,0,52),o|=e,u=T()|-15728641&t,(0|v)>(0|n)){c=n;do{g=0|zt(7,0,3*(14-c|0)|0),c=c+1|0,o|=g,u=T()|u}while((0|c)<(0|v));g=o}else g=o;else g=e,u=t;m=0|Gt(0|g,0|u,45),T();e:do{if(0|q(127&m)){if(c=0|Gt(0|g,0|u,52),T(),0|(c&=15))for(o=1;;){if(!(!((m=0|zt(7,0,3*(15-o|0)|0))&g)&!(T()&u))){A=33;break e}if(!(o>>>0>>0))break;o=o+1|0}if(i[(m=r)>>2]=0,i[m+4>>2]=0,(0|v)>(0|n)){for(m=-15728641&t,f=v;;){if(p=f,(f=f+-1|0)>>>0>15|(0|v)<(0|f)){A=19;break}if((0|v)!=(0|f))if(o=0|zt(0|f,0,52),o|=e,c=T()|m,(0|v)<(0|p))d=o;else{A=f;do{d=0|zt(7,0,3*(14-A|0)|0),A=A+1|0,o|=d,c=T()|c}while((0|A)<(0|v));d=o}else d=e,c=t;if(h=0|Gt(0|d,0|c,45),T(),0|q(127&h)){h=0|Gt(0|d,0|c,52),T(),h&=15;t:do{if(h)for(A=1;;){if(o=0|Gt(0|d,0|c,3*(15-A|0)|0),T(),0|(o&=7))break t;if(!(A>>>0>>0)){o=0;break}A=A+1|0}else o=0}while(0);o=1&!(0|o)}else o=0;if(c=0|Gt(0|e,0|t,3*(15-p|0)|0),T(),7==(0|(c&=7))){a=5,A=42;break}if(1==(0|c)&(o=!!(0|o))){a=5,A=42;break}if(0|(d=c+((!!(0|c)&o)<<31>>31)|0)&&(A=0|At(7,0,A=v-p|0,((0|A)<0)<<31>>31),h=0|T(),o?(o=0|Dt(0|(o=0|Ot(0|A,0|h,5,0)),0|T(),-5,-1),o=0|Dt(0|(o=0|Bt(0|o,0|T(),6,0)),0|T(),1,0),c=0|T()):(o=A,c=h),p=0|Dt(0|o,0|c,0|(p=0|Ot(0|A,0|h,0|(p=d+-1|0),((0|p)<0)<<31>>31)),0|T()),h=0|Dt(0|p,0|(d=0|T()),0|i[(h=r)>>2],0|i[h+4>>2]),d=0|T(),i[(p=r)>>2]=h,i[p+4>>2]=d),(0|f)<=(0|n)){A=37;break}}if(19==(0|A))M(23313,22674,1099,22710);else{if(37==(0|A)){a=0|i[(l=r)+4>>2],l=0|i[l>>2];break}if(42==(0|A))return D=s,0|a}}else a=0,l=0}else A=33}while(0);e:do{if(33==(0|A)){if(i[(m=r)>>2]=0,i[m+4>>2]=0,(0|v)>(0|n)){for(o=v;;){if(a=0|Gt(0|e,0|t,3*(15-o|0)|0),T(),7==(0|(a&=7))){a=5;break}if(a=0|Ot(0|(l=0|At(7,0,l=v-o|0,((0|l)<0)<<31>>31)),0|T(),0|a,0),l=0|T(),l=0|Dt(0|i[(m=r)>>2],0|i[m+4>>2],0|a,0|l),a=0|T(),i[(m=r)>>2]=l,i[m+4>>2]=a,(0|(o=o+-1|0))<=(0|n))break e}return D=s,0|a}a=0,l=0}}while(0);return 0|Be(g,u,v,_)&&M(23313,22674,1063,22725),((0|a)>-1|-1==(0|a)&l>>>0>4294967295)&((0|(_=0|i[(v=_)+4>>2]))>(0|a)|((0|_)==(0|a)?(0|i[v>>2])>>>0>l>>>0:0))?(D=s,0|(v=0)):(M(23313,22674,1139,22710),0)},_cellToChildren:function(e,t,n,r){r|=0;var s,a,o=0,l=0;if(a=D,D=D+16|0,$e(s=a,e|=0,t|=0,n|=0),!(0|(e=0|i[(t=s)>>2]))&!(0|(t=0|i[t+4>>2])))return D=a,0;o=0,n=0;do{i[(l=r+(o<<3)|0)>>2]=e,i[l+4>>2]=t,o=0|Dt(0|o,0|n,1,0),n=0|T(),Ke(s),e=0|i[(l=s)>>2],t=0|i[l+4>>2]}while(!(!(0|e)&!(0|t)));return D=a,0},_cellToChildrenSize:Be,_cellToLatLng:Xe,_cellToLocalIj:function(e,t,n,r,i,s){var a,o;return e|=0,t|=0,n|=0,r|=0,s|=0,o=D,D=D+16|0,a=o,(i|=0)?e=15:(e=0|ut(e,t,n,r,a))||(ve(a,s),e=0),D=o,0|e},_cellToParent:Ue,_cellToVertex:yt,_cellToVertexes:function(e,t,n){n|=0;var r,s=0,a=0;return a=!(0|Oe(e|=0,t|=0)),r=!(0|(s=0|yt(e,t,0,n))),a?r?0|(s=0|yt(e,t,1,n+8|0))||0|(s=0|yt(e,t,2,n+16|0))||0|(s=0|yt(e,t,3,n+24|0))||(s=0|yt(e,t,4,n+32|0))?0|(a=s):0|yt(e,t,5,n+40|0):0|(a=s):r?0|(s=0|yt(e,t,1,n+8|0))||0|(s=0|yt(e,t,2,n+16|0))||0|(s=0|yt(e,t,3,n+24|0))||0|(s=0|yt(e,t,4,n+32|0))?0|(a=s):(i[(a=n+40|0)>>2]=0,i[a+4>>2]=0,0|(a=0)):0|(a=s)},_cellsToDirectedEdge:function(e,t,n,r,s){return s|=0,7==(0|(n=0|F(e|=0,t|=0,n|=0,r|=0)))?0|(s=11):(r=0|zt(0|n,0,56),t=-2130706433&t|T()|268435456,i[s>>2]=e|r,i[s+4>>2]=t,0|(s=0))},_cellsToLinkedMultiPolygon:function(e,t,n){n|=0;var r,s,a,o=0;if(a=D,D=D+32|0,r=a,e=0|function(e,t,n){e|=0,n|=0;var r,s,a=0,o=0,l=0,u=0,c=0,A=0;if(s=D,D=D+176|0,r=s,(0|(t|=0))<1)return xt(n,0,0),D=s,0;for(c=0|Gt(0|i[(c=e)>>2],0|i[c+4>>2],52),T(),xt(n,(0|t)>6?t:6,15&c),c=0;!(0|(a=0|Qe(0|i[(a=e+(c<<3)|0)>>2],0|i[a+4>>2],r)));){if((0|(a=0|i[r>>2]))>0){u=0;do{l=r+8+(u<<4)|0,(o=0|Mt(n,a=r+8+((0|(u=u+1|0))%(0|a)<<4)|0,l))?wt(n,o):Tt(n,l,a),a=0|i[r>>2]}while((0|u)<(0|a))}if((0|(c=c+1|0))>=(0|t)){a=0,A=13;break}}return 13==(0|A)?(D=s,0|a):(bt(n),D=s,0|(A=a))}(e|=0,t|=0,s=a+16|0),0|e)return D=a,0|(n=e);if(i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,0|(e=0|St(s)))do{t=0|it(n);do{st(t,e),o=e+16|0,i[r>>2]=i[o>>2],i[r+4>>2]=i[o+4>>2],i[r+8>>2]=i[o+8>>2],i[r+12>>2]=i[o+12>>2],wt(s,e),e=0|Et(s,r)}while(0|e);e=0|St(s)}while(0|e);return bt(s),(e=0|ot(n))?(at(n),D=a,0|(o=e)):(D=a,0|(o=0))},_childPosToCell:function(e,t,n,r,s,a){e|=0,t|=0,a|=0;var o,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0;if(o=D,D=D+16|0,l=o,(s|=0)>>>0>15)return D=o,0|(a=4);if(u=0|Gt(0|(n|=0),0|(r|=0),52),T(),(0|(u&=15))>(0|s))return D=o,0|(a=12);if(0|Be(n,r,s,l)&&M(23313,22674,1063,22725),!(((0|t)>-1|-1==(0|t)&e>>>0>4294967295)&((0|(A=0|i[(h=l)+4>>2]))>(0|t)|((0|A)==(0|t)?(0|i[h>>2])>>>0>e>>>0:0))))return D=o,0|(a=2);h=s-u|0,s=0|zt(0|s,0,52),c=T()|-15728641&r,i[(A=a)>>2]=s|n,i[A+4>>2]=c,A=0|Gt(0|n,0|r,45),T();e:do{if(0|q(127&A)){if(0|u)for(l=1;;){if(!(!((A=0|zt(7,0,3*(15-l|0)|0))&n)&!(T()&r)))break e;if(!(l>>>0>>0))break;l=l+1|0}if((0|h)<1)return D=o,0|(a=0);for(A=15^u,r=-1,c=1,l=1;;){u=0|At(7,0,u=h-c|0,((0|u)<0)<<31>>31),n=0|T();do{if(l){if(l=0|Bt(0|(l=0|Dt(0|(l=0|Ot(0|u,0|n,5,0)),0|T(),-5,-1)),0|T(),6,0),(0|t)>(0|(s=0|T()))|(0|t)==(0|s)&e>>>0>l>>>0){t=0|Lt(0|(t=0|Dt(0|e,0|t,-1,-1)),0|T(),0|l,0|s),l=0|T(),f=0|i[(d=a)>>2],d=0|i[d+4>>2],p=0|zt(7,0,0|(m=3*(A+r|0)|0)),d&=~T(),m=0|zt(0|(s=0|Dt(0|(r=0|Bt(0|t,0|l,0|u,0|n)),0|(e=0|T()),2,0)),0|T(),0|m),d=T()|d,i[(s=a)>>2]=m|f&~p,i[s+4>>2]=d,e=0|Lt(0|t,0|l,0|(e=0|Ot(0|r,0|e,0|u,0|n)),0|T()),l=0,t=0|T();break}p=0|i[(m=a)>>2],m=0|i[m+4>>2],f=0|zt(7,0,3*(A+r|0)|0),m&=~T(),i[(l=a)>>2]=p&~f,i[l+4>>2]=m,l=1;break}s=0|i[(p=a)>>2],p=0|i[p+4>>2],d=0|zt(7,0,0|(r=3*(A+r|0)|0)),p&=~T(),r=0|zt(0|(m=0|Bt(0|e,0|t,0|u,0|n)),0|(l=0|T()),0|r),p=T()|p,i[(f=a)>>2]=r|s&~d,i[f+4>>2]=p,e=0|Lt(0|e,0|t,0|(l=0|Ot(0|m,0|l,0|u,0|n)),0|T()),l=0,t=0|T()}while(0);if(!((0|h)>(0|c))){t=0;break}r=~c,c=c+1|0}return D=o,0|t}}while(0);if((0|h)<1)return D=o,0|(m=0);for(s=15^u,l=1;;){if(f=0|At(7,0,f=h-l|0,((0|f)<0)<<31>>31),m=0|T(),n=0|i[(c=a)>>2],c=0|i[c+4>>2],r=0|zt(7,0,0|(u=3*(s-l|0)|0)),c&=~T(),u=0|zt(0|(d=0|Bt(0|e,0|t,0|f,0|m)),0|(p=0|T()),0|u),c=T()|c,i[(A=a)>>2]=u|n&~r,i[A+4>>2]=c,e=0|Lt(0|e,0|t,0|(m=0|Ot(0|d,0|p,0|f,0|m)),0|T()),t=0|T(),(0|h)<=(0|l)){t=0;break}l=l+1|0}return D=o,0|t},_compactCells:function(e,t,n,r){t|=0;var s,a=0,o=0,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0,x=0,b=0,S=0,w=0,E=0;if(!(0|(n|=0))&!(0|(r|=0)))return 0|(w=0);if(o=0|i[(a=e|=0)>>2],!0&!(15728640&(a=0|i[a+4>>2]))){if(!((0|r)>0|!(0|r)&n>>>0>0))return 0|(w=0);if(i[(w=t)>>2]=o,i[w+4>>2]=a,1==(0|n)&!(0|r))return 0|(w=0);a=1;do{S=0|i[(b=e+(a<<3)|0)+4>>2],i[(w=t+(a<<3)|0)>>2]=i[b>>2],i[w+4>>2]=S,a=a+1|0}while(0<(0|r)|!(0|r)&a>>>0>>0);return 0|(a=0)}if(!(S=0|Rt(s=n<<3)))return 0|(w=13);if(Wt(0|S,0|e,0|s),!(b=0|Pt(n,8)))return Nt(S),0|(w=13);e:do{if(0|n){t:for(;;){y=0|Gt(0|(v=0|i[(a=S)>>2]),0|(a=0|i[a+4>>2]),52),T(),x=(y&=15)+-1|0,_=(0|n)>0;n:do{if(!!(0|y)&_){if(f=((0|n)<0)<<31>>31,m=0|zt(0|x,0,52),g=0|T(),x>>>0>15){if(!(!(0|v)&!(0|a))){w=17;break t}for(o=0;;){if((0|(o=o+1|0))>=(0|n))break n;if(!(!(0|(g=0|i[(r=S+(o<<3)|0)>>2]))&!(0|(r=0|i[r+4>>2])))){a=r,w=17;break t}}}for(o=0,e=v,r=a;;){if(!(!(0|e)&!(0|r))){if(!(!0&!(117440512&r))){w=22;break t}if(u=0|Gt(0|e,0|r,52),T(),(0|(u&=15))<(0|x)){a=12,w=28;break t}if((0|u)!=(0|x)&&(e|=m,r=-15728641&r|g,u>>>0>=y>>>0)){l=x;do{p=0|zt(7,0,3*(14-l|0)|0),l=l+1|0,e|=p,r=T()|r}while(l>>>0>>0)}if(l=0|kt(0|e,0|r,0|n,0|f),T(),!(0|(c=0|i[(u=A=b+(l<<3)|0)>>2]))&!(0|(u=0|i[u+4>>2])))l=A;else for(p=0;;){if((0|p)>(0|n)){w=32;break t}if((0|c)==(0|e)&(-117440513&u)==(0|r)){h=0|Gt(0|c,0|u,56),T(),d=(h&=7)+1|0,E=0|Gt(0|c,0|u,45),T();r:do{if(0|q(127&E)){if(c=0|Gt(0|c,0|u,52),T(),!(c&=15)){u=6;break}for(u=1;;){if(!(!((E=0|zt(7,0,3*(15-u|0)|0))&e)&!(T()&r))){u=7;break r}if(!(u>>>0>>0)){u=6;break}u=u+1|0}}else u=7}while(0);if((h+2|0)>>>0>u>>>0){w=42;break t}E=0|zt(0|d,0,56),r=T()|-117440513&r,i[(d=A)>>2]=0,i[d+4>>2]=0,e|=E}else l=(l+1|0)%(0|n)|0;if(!(0|(c=0|i[(u=A=b+(l<<3)|0)>>2]))&!(0|(u=0|i[u+4>>2]))){l=A;break}p=p+1|0}i[(E=l)>>2]=e,i[E+4>>2]=r}if((0|(o=o+1|0))>=(0|n))break n;e=0|i[(r=S+(o<<3)|0)>>2],r=0|i[r+4>>2]}}}while(0);if((n+5|0)>>>0<11){w=85;break}if(!(g=0|Pt((0|n)/6|0,8))){w=49;break}n:do{if(_){p=0,d=0;do{if(!(!(0|(o=0|i[(r=u=b+(p<<3)|0)>>2]))&!(0|(r=0|i[r+4>>2])))){c=0|Gt(0|o,0|r,56),T(),e=(c&=7)+1|0,A=-117440513&r,E=0|Gt(0|o,0|r,45),T();r:do{if(0|q(127&E)){if(h=0|Gt(0|o,0|r,52),T(),0|(h&=15))for(l=1;;){if(!(!(o&(E=0|zt(7,0,3*(15-l|0)|0)))&!(A&T())))break r;if(!(l>>>0>>0))break;l=l+1|0}o|=r=0|zt(0|e,0,56),r=T()|A,i[(e=u)>>2]=o,i[e+4>>2]=r,e=c+2|0}}while(0);7==(0|e)&&(i[(E=g+(d<<3)|0)>>2]=o,i[E+4>>2]=-117440513&r,d=d+1|0)}p=p+1|0}while((0|p)!=(0|n));if(_){if(p=((0|n)<0)<<31>>31,f=0|zt(0|x,0,52),m=0|T(),x>>>0>15){if(!(!(0|v)&!(0|a))){a=4,w=84;break t}for(a=0;;){if((0|(a=a+1|0))>=(0|n)){o=0,a=d;break n}if(!(!(0|i[(E=S+(a<<3)|0)>>2])&!(0|i[E+4>>2]))){a=4,w=84;break t}}}for(h=0,o=0,A=v;;){do{if(!(!(0|A)&!(0|a))){if(u=0|Gt(0|A,0|a,52),T(),(0|(u&=15))<(0|x)){a=12,w=84;break t}do{if((0|u)==(0|x))r=A,u=a;else{if(r=A|f,e=-15728641&a|m,u>>>0>>0){u=e;break}l=x;do{E=0|zt(7,0,3*(14-l|0)|0),l=l+1|0,r|=E,e=T()|e}while(l>>>0>>0);u=e}}while(0);for(l=0|kt(0|r,0|u,0|n,0|p),T(),e=0;;){if((0|e)>(0|n)){w=77;break t}if((-117440513&(c=0|i[(E=b+(l<<3)|0)+4>>2]))==(0|u)&&(0|i[E>>2])==(0|r)){w=79;break}if((0|i[(E=b+((l=(l+1|0)%(0|n)|0)<<3)|0)>>2])==(0|r)&&(0|i[E+4>>2])==(0|u))break;e=e+1|0}if(79==(0|w)&&(w=0,!0&100663296==(117440512&c)))break;i[(E=t+(o<<3)|0)>>2]=A,i[E+4>>2]=a,o=o+1|0}}while(0);if((0|(a=h+1|0))>=(0|n)){a=d;break n}h=a,A=0|i[(E=S+(a<<3)|0)>>2],a=0|i[E+4>>2]}}else o=0,a=d}else o=0,a=0}while(0);if(Xt(0|b,0,0|s),Wt(0|S,0|g,a<<3),Nt(g),!a)break e;t=t+(o<<3)|0,n=a}if(17==(0|w))!0&!(117440512&a)?(a=4,w=28):w=22;else if(32==(0|w))M(23313,22674,362,22684);else{if(42==(0|w))return Nt(S),Nt(b),0|(E=10);if(49==(0|w))return Nt(S),Nt(b),0|(E=13);if(77==(0|w))M(23313,22674,462,22684);else{if(84==(0|w))return Nt(g),Nt(S),Nt(b),0|(E=a);if(85==(0|w)){Wt(0|t,0|S,n<<3);break}}}if(22==(0|w))return Nt(S),Nt(b),0|(E=5);if(28==(0|w))return Nt(S),Nt(b),0|(E=a)}}while(0);return Nt(S),Nt(b),0|(E=0)},_destroyLinkedMultiPolygon:at,_directedEdgeToBoundary:Se,_directedEdgeToCells:function(e,t,n){e|=0;var r,s,a,o=0;return r=D,D=D+16|0,o=r,!0&268435456==(2013265920&(t|=0))?(s=-2130706433&t|134217728,i[(a=n|=0)>>2]=e,i[a+4>>2]=s,i[o>>2]=0,t=0|Gt(0|e,0|t,56),T(),o=0|O(e,s,7&t,o,n+8|0),D=r,0|o):(D=r,0|(o=6))},_edgeLengthKm:function(e,t,n){n|=0;var r,a=0,o=0,l=0,u=0,A=0,p=0,f=0;if(r=D,D=D+176|0,0|(e=0|Se(e|=0,t|=0,u=r)))return u=e,l=+s[n>>3],l*=6371.007180918475,s[n>>3]=l,D=r,0|u;if(s[n>>3]=0,(0|(e=0|i[u>>2]))<=1)return u=0,l=0,l*=6371.007180918475,s[n>>3]=l,D=r,0|u;t=e+-1|0,e=0,a=+s[u+8>>3],o=+s[u+16>>3],l=0;do{p=a,a=+s[u+8+((e=e+1|0)<<4)>>3],f=+d(.5*(a-p)),A=o,o=+s[u+8+(e<<4)+8>>3],A=f*f+(A=+d(.5*(o-A)))*(+h(+p)*+h(+a)*A),l+=2*+_(+ +c(+A),+ +c(+(1-A)))}while((0|e)!=(0|t));return s[n>>3]=l,u=0,f=l,f*=6371.007180918475,s[n>>3]=f,D=r,0|u},_edgeLengthM:function(e,t,n){n|=0;var r,a=0,o=0,l=0,u=0,A=0,p=0,f=0;if(r=D,D=D+176|0,0|(e=0|Se(e|=0,t|=0,u=r)))return u=e,l=+s[n>>3],l*=6371.007180918475,l*=1e3,s[n>>3]=l,D=r,0|u;if(s[n>>3]=0,(0|(e=0|i[u>>2]))<=1)return u=0,l=0,l*=6371.007180918475,l*=1e3,s[n>>3]=l,D=r,0|u;t=e+-1|0,e=0,a=+s[u+8>>3],o=+s[u+16>>3],l=0;do{p=a,a=+s[u+8+((e=e+1|0)<<4)>>3],f=+d(.5*(a-p)),A=o,o=+s[u+8+(e<<4)+8>>3],A=f*f+(A=+d(.5*(o-A)))*(+h(+p)*+h(+a)*A),l+=2*+_(+ +c(+A),+ +c(+(1-A)))}while((0|e)!=(0|t));return s[n>>3]=l,u=0,f=l,f*=6371.007180918475,f*=1e3,s[n>>3]=f,D=r,0|u},_edgeLengthRads:function(e,t,n){n|=0;var r,a=0,o=0,l=0,u=0,A=0,p=0,f=0;if(r=D,D=D+176|0,0|(e=0|Se(e|=0,t|=0,u=r)))return D=r,0|(u=e);if(s[n>>3]=0,(0|(e=0|i[u>>2]))<=1)return D=r,0|(u=0);t=e+-1|0,e=0,a=+s[u+8>>3],o=+s[u+16>>3],l=0;do{p=a,a=+s[u+8+((e=e+1|0)<<4)>>3],f=+d(.5*(a-p)),A=o,o=+s[u+8+(e<<4)+8>>3],A=f*f+(A=+d(.5*(o-A)))*(+h(+a)*+h(+p)*A),l+=2*+_(+ +c(+A),+ +c(+(1-A)))}while((0|e)<(0|t));return s[n>>3]=l,D=r,0|(u=0)},_emscripten_replace_memory:function(e){return r=new Int8Array(e),i=new Int32Array(e),s=new Float64Array(e),n=e,!0},_free:Nt,_getBaseCellNumber:Le,_getDirectedEdgeDestination:function(e,t,n){e|=0,t|=0,n|=0;var r,s,a=0;return r=D,D=D+16|0,i[(a=r)>>2]=0,!0&268435456==(2013265920&t)?(s=0|Gt(0|e,0|t,56),T(),a=0|O(e,-2130706433&t|134217728,7&s,a,n),D=r,0|a):(D=r,0|(a=6))},_getDirectedEdgeOrigin:function(e,t,n){return e|=0,n|=0,!0&268435456==(2013265920&(t|=0))?(i[n>>2]=e,i[n+4>>2]=-2130706433&t|134217728,0|(n=0)):0|(n=6)},_getHexagonAreaAvgKm2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20528+(e<<3)>>3],0|(t=0))},_getHexagonAreaAvgM2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20656+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgKm:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20784+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgM:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20912+(e<<3)>>3],0|(t=0))},_getIcosahedronFaces:function e(t,n,r){r|=0;var s,a=0,o=0,l=0,u=0,c=0,A=0,h=0,d=0;s=D,D=D+128|0,h=s+112|0,l=s+96|0,d=s,o=0|Gt(0|(t|=0),0|(n|=0),52),T(),c=15&o,i[h>>2]=c,u=0|Gt(0|t,0|n,45),T(),u&=127;e:do{if(0|q(u)){if(0|c)for(a=1;;){if(!(!((A=0|zt(7,0,3*(15-a|0)|0))&t)&!(T()&n))){o=0;break e}if(!(a>>>0>>0))break;a=a+1|0}if(!(1&o))return A=0|zt(c+1|0,0,52),d=T()|-15728641&n,d=0|e((A|t)&~(h=0|zt(7,0,3*(14-c|0)|0)),d&~T(),r),D=s,0|d;o=1}else o=0}while(0);if(!(a=0|We(t,n,l))){o?(Ce(l,h,d),A=5):(De(l,h,d),A=6);e:do{if(0|q(u))if(c)for(a=1;;){if(!(!((u=0|zt(7,0,3*(15-a|0)|0))&t)&!(T()&n))){t=2;break e}if(!(a>>>0>>0)){t=5;break}a=a+1|0}else t=5;else t=2}while(0);Xt(0|r,-1,t<<2);e:do{if(o)for(l=0;;){if(Ne(u=d+(l<<4)|0,0|i[h>>2]),u=0|i[u>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|u))a=r;else{o=0;do{if((o=o+1|0)>>>0>=t>>>0){a=1;break e}c=0|i[(a=r+(o<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|u)))}if(i[a>>2]=u,(l=l+1|0)>>>0>=A>>>0){a=0;break}}else for(l=0;;){if(Re(u=d+(l<<4)|0,0|i[h>>2],0,1),u=0|i[u>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|u))a=r;else{o=0;do{if((o=o+1|0)>>>0>=t>>>0){a=1;break e}c=0|i[(a=r+(o<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|u)))}if(i[a>>2]=u,(l=l+1|0)>>>0>=A>>>0){a=0;break}}}while(0)}return D=s,0|(d=a)},_getNumCells:tt,_getPentagons:Ye,_getRes0Cells:function(e){e|=0;var t=0,n=0,r=0;t=0;do{zt(0|t,0,45),r=134225919|T(),i[(n=e+(t<<3)|0)>>2]=-1,i[n+4>>2]=r,t=t+1|0}while(122!=(0|t));return 0},_getResolution:function(e,t){return t=0|Gt(0|(e|=0),0|(t|=0),52),T(),15&t},_greatCircleDistanceKm:et,_greatCircleDistanceM:function(e,t){e|=0;var n,r,i,a=0;return r=+s[(t|=0)>>3],n=+s[e>>3],a=(i=+d(.5*(r-n)))*i+(a=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+h(+r)*+h(+n)*a),2*+_(+ +c(+a),+ +c(+(1-a)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(e,t){e|=0;var n,r,i,a=0;return r=+s[(t|=0)>>3],n=+s[e>>3],a=(i=+d(.5*(r-n)))*i+(a=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+h(+r)*+h(+n)*a),2*+_(+ +c(+a),+ +c(+(1-a)))},_gridDisk:L,_gridDiskDistances:I,_gridDistance:function(e,t,n,r,s){n|=0,r|=0,s|=0;var a,o,l=0,u=0;return o=D,D=D+32|0,u=o,0|(a=0|ut(e|=0,t|=0,e,t,l=o+12|0))?(D=o,0|(u=a)):0|(e=0|ut(e,t,n,r,u))?(D=o,0|(u=e)):(l=0|_e(l,u),i[(u=s)>>2]=l,i[u+4>>2]=((0|l)<0)<<31>>31,D=o,0|(u=0))},_gridPathCells:function(e,t,n,r,s){n|=0,r|=0,s|=0;var a,o=0,l=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0,x=0,b=0,S=0,w=0,E=0,C=0;if(a=D,D=D+48|0,c=a+12|0,E=a,!(o=0|ut(e|=0,t|=0,e,t,l=a+24|0))&&!(o=0|ut(e,t,n,r,c))){w=((0|(S=0|_e(l,c)))<0)<<31>>31,i[l>>2]=0,i[l+4>>2]=0,i[l+8>>2]=0,i[c>>2]=0,i[c+4>>2]=0,i[c+8>>2]=0,0|ut(e,t,e,t,l)&&M(23313,23090,691,23299),0|ut(e,t,n,r,c)&&M(23313,23090,696,23299),xe(l),xe(c),S?(g=+(0|S),b=l,r=p=0|i[l>>2],o=f=0|i[(y=l+4|0)>>2],n=m=0|i[(x=l+8|0)>>2],_=+((0|i[c>>2])-p|0)/g,v=+((0|i[c+4>>2])-f|0)/g,g=+((0|i[c+8>>2])-m|0)/g):(y=o=l+4|0,x=n=l+8|0,b=l,r=0|i[l>>2],o=0|i[o>>2],n=0|i[n>>2],_=0,v=0,g=0),i[E>>2]=r,i[(m=E+4|0)>>2]=o,i[(f=E+8|0)>>2]=n;e:do{if((0|S)<0)o=0;else for(d=0,p=0,o=r;;){C=_*(h=+(p>>>0)+4294967296*+(0|d))+ +(0|o),A=v*h+ +(0|i[y>>2]),h=g*h+ +(0|i[x>>2]),n=~~+jt(+C),l=~~+jt(+A),o=~~+jt(+h),C=+u(+(+(0|n)-C)),A=+u(+(+(0|l)-A)),h=+u(+(+(0|o)-h));do{if(!(C>A&C>h)){if(c=0-n|0,A>h){r=c-o|0;break}r=l,o=c-l|0;break}n=0-(l+o)|0,r=l}while(0);if(i[E>>2]=n,i[m>>2]=r,i[f>>2]=o,be(E),0|(o=0|ct(e,t,E,s+(p<<3)|0)))break e;if(!((0|d)<(0|w)|(0|d)==(0|w)&p>>>0>>0)){o=0;break e}o=0|Dt(0|p,0|d,1,0),d=c=0|T(),p=o,o=0|i[b>>2]}}while(0);return D=a,0|(E=o)}return D=a,0|(E=o)},_gridPathCellsSize:function(e,t,n,r,s){n|=0,r|=0,s|=0;var a,o=0,l=0,u=0;return a=D,D=D+32|0,u=a,(o=0|ut(e|=0,t|=0,e,t,l=a+12|0))||(o=0|ut(e,t,n,r,u))?(D=a,0|(u=o)):(r=0|Dt(0|(r=0|_e(l,u)),((0|r)<0)<<31>>31,1,0),l=0|T(),i[(u=s)>>2]=r,i[u+4>>2]=l,D=a,0|(u=0))},_gridRingUnsafe:function(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var s,a,o=0,l=0,u=0,c=0,A=0,h=0,d=0,p=0,f=0;if(a=D,D=D+16|0,f=a+8|0,i[(p=s=a)>>2]=e,i[p+4>>2]=t,!n)return i[(f=r)>>2]=e,i[f+4>>2]=t,D=a,0|(f=0);i[f>>2]=0;e:do{if(0|Oe(e,t))e=9;else{if(l=(0|n)>0){o=0,p=e;do{if(0|(e=0|O(p,t,4,f,s)))break e;if(o=o+1|0,0|Oe(p=0|i[(t=s)>>2],t=0|i[t+4>>2])){e=9;break e}}while((0|o)<(0|n));if(i[(d=r)>>2]=p,i[d+4>>2]=t,d=n+-1|0,l){h=0,e=1;do{if(o=22384+(h<<2)|0,5==(0|h))for(u=0|i[o>>2],l=0,o=e;;){if(0|(e=0|O(0|i[(e=s)>>2],0|i[e+4>>2],u,f,s)))break e;if((0|l)!=(0|d)){if(c=0|i[(A=s)>>2],A=0|i[A+4>>2],i[(e=r+(o<<3)|0)>>2]=c,i[e+4>>2]=A,0|Oe(c,A)){e=9;break e}e=o+1|0}else e=o;if((0|(l=l+1|0))>=(0|n))break;o=e}else for(u=s,A=0|i[o>>2],c=0,o=e,l=0|i[u>>2],u=0|i[u+4>>2];;){if(0|(e=0|O(l,u,A,f,s)))break e;if(l=0|i[(u=s)>>2],u=0|i[u+4>>2],i[(e=r+(o<<3)|0)>>2]=l,i[e+4>>2]=u,e=o+1|0,0|Oe(l,u)){e=9;break e}if((0|(c=c+1|0))>=(0|n))break;o=e}h=h+1|0}while(h>>>0<6);u=p,o=0|i[(e=s)>>2],l=t,e=0|i[e+4>>2]}else u=p,o=p,l=t,e=t}else i[(u=r)>>2]=e,i[u+4>>2]=t,u=e,o=e,l=t,e=t;e=(0|u)==(0|o)&(0|l)==(0|e)?0:9}}while(0);return D=a,0|(f=e)},_i64Add:Dt,_i64Subtract:Lt,_isPentagon:Oe,_isResClassIII:function(e,t){return t=0|Gt(0|(e|=0),0|(t|=0),52),T(),1&t},_isValidCell:Ie,_isValidDirectedEdge:function(e,t){var n=0;switch(n=0|Gt(0|(e|=0),0|(t|=0),56),T(),7&n){case 0:case 7:return 0|(n=0)}return n=-2130706433&t|134217728,!0&268435456==(2013265920&t)?!0&16777216==(117440512&t)&!!(0|Oe(e,n))?0|(n=0):0|(n=0|Ie(e,n)):0|(n=0)},_isValidVertex:function(e,t){e|=0;var n,r,s=0,a=0;return r=D,D=D+16|0,n=r,!0&536870912==(2013265920&(t|=0))&&0|Ie(e,s=-2130706433&t|134217728)?(a=0|Gt(0|e,0|t,56),T(),s=(a=!(0|yt(e,s,7&a,n)))&((0|i[(s=n)>>2])==(0|e)?(0|i[s+4>>2])==(0|t):0)&1,D=r,0|s):(D=r,0|(s=0))},_latLngToCell:He,_llvm_maxnum_f64:Vt,_llvm_minnum_f64:Ht,_llvm_round_f64:jt,_localIjToCell:function(e,t,n,r,i){var s,a;return e|=0,t|=0,n|=0,i|=0,a=D,D=D+16|0,s=a,(r|=0)?n=15:(n=0|ye(n,s))||(n=0|ct(e,t,s,i)),D=a,0|n},_malloc:Rt,_maxFaceCount:function(e,t,n){n|=0;var r=0,s=0;if(s=0|Gt(0|(e|=0),0|(t|=0),45),T(),!(0|q(127&s)))return s=2,i[n>>2]=s,0;if(s=0|Gt(0|e,0|t,52),T(),!(s&=15))return s=5,i[n>>2]=s,0;for(r=1;;){if(!(!((0|zt(7,0,3*(15-r|0)|0))&e)&!(T()&t))){r=2,e=6;break}if(!(r>>>0>>0)){r=5,e=6;break}r=r+1|0}return 6==(0|e)?(i[n>>2]=r,0):0},_maxGridDiskSize:function(e,t){t|=0;var n=0,r=0,s=0;return(0|(e|=0))<0?0|(t=2):(0|e)>13780509?0|(t=0|tt(15,t)):(s=0|Ot(0|e,0|(n=((0|e)<0)<<31>>31),3,0),r=0|T(),n=0|Dt(0|e,0|n,1,0),n=0|Dt(0|(n=0|Ot(0|s,0|r,0|n,0|T())),0|T(),1,0),e=0|T(),i[t>>2]=n,i[t+4>>2]=e,0|(t=0))},_maxPolygonToCellsSize:function(e,t,n,r){t|=0,r|=0;var s,a=0,o=0,l=0,u=0,c=0;if(s=D,D=D+48|0,a=s+16|0,o=s+8|0,l=s,0|(n|=0))return D=s,0|(l=15);if(u=0|i[(c=e|=0)+4>>2],i[(n=o)>>2]=i[c>>2],i[n+4>>2]=u,dt(o,a),!(t=0|Y(a,t,l))){if(n=0|i[o>>2],(0|(o=0|i[e+8>>2]))>0){a=0|i[e+12>>2],t=0;do{n=(0|i[a+(t<<3)>>2])+n|0,t=t+1|0}while((0|t)<(0|o))}a=0|i[(t=l)>>2],(0|(t=0|i[t+4>>2]))<(0|(o=((0|n)<0)<<31>>31))|(0|t)==(0|o)&a>>>0>>0?(i[(t=l)>>2]=n,i[t+4>>2]=o,t=o):n=a,u=0|Dt(0|n,0|t,12,0),c=0|T(),i[(t=l)>>2]=u,i[t+4>>2]=c,i[(t=r)>>2]=u,i[t+4>>2]=c,t=0}return D=s,0|(c=t)},_memcpy:Wt,_memset:Xt,_originToDirectedEdges:function(e,t,n){n|=0;var r,s=0;return r=!(0|Oe(e|=0,t|=0)),t&=-2130706433,i[(s=n)>>2]=r?e:0,i[s+4>>2]=r?285212672|t:0,i[(s=n+8|0)>>2]=e,i[s+4>>2]=301989888|t,i[(s=n+16|0)>>2]=e,i[s+4>>2]=318767104|t,i[(s=n+24|0)>>2]=e,i[s+4>>2]=335544320|t,i[(s=n+32|0)>>2]=e,i[s+4>>2]=352321536|t,i[(n=n+40|0)>>2]=e,i[n+4>>2]=369098752|t,0},_pentagonCount:function(){return 12},_polygonToCells:function(e,t,n,r){t|=0,r|=0;var s,a,o,l,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0,y=0,x=0,b=0,S=0,w=0,M=0,E=0,C=0,R=0,N=0,P=0,L=0,I=0,O=0,F=0,q=0;if(l=D,D=D+112|0,s=l+80|0,d=l+72|0,a=l,o=l+56|0,0|(n|=0))return D=l,0|(q=15);if(!(q=0|Rt(32+(i[(p=(e|=0)+8|0)>>2]<<5)|0)))return D=l,0|(q=13);if(pt(e,q),F=0|i[(O=e)+4>>2],i[(n=d)>>2]=i[O>>2],i[n+4>>2]=F,dt(d,s),n=0|Y(s,t,a))O=0,F=0;else{if(n=0|i[d>>2],(0|(c=0|i[p>>2]))>0){A=0|i[e+12>>2],u=0;do{n=(0|i[A+(u<<3)>>2])+n|0,u=u+1|0}while((0|u)!=(0|c));u=n}else u=n;c=0|i[(n=a)>>2],(0|(n=0|i[n+4>>2]))<(0|(A=((0|u)<0)<<31>>31))|(0|n)==(0|A)&c>>>0>>0?(i[(n=a)>>2]=u,i[n+4>>2]=A,n=A):u=c,O=0|Dt(0|u,0|n,12,0),F=0|T(),i[(n=a)>>2]=O,i[n+4>>2]=F,n=0}if(0|n)return Nt(q),D=l,0|(q=n);if(!(u=0|Pt(O,8)))return Nt(q),D=l,0|(q=13);if(!(h=0|Pt(O,8)))return Nt(q),Nt(u),D=l,0|(q=13);i[(L=s)>>2]=0,i[L+4>>2]=0,I=0|i[(L=e)+4>>2],i[(n=d)>>2]=i[L>>2],i[n+4>>2]=I,n=0|k(d,O,F,t,s,u,h);e:do{if(n)Nt(u),Nt(h),Nt(q);else{t:do{if((0|i[p>>2])>0){for(A=e+12|0,c=0;n=0|k((0|i[A>>2])+(c<<3)|0,O,F,t,s,u,h),c=c+1|0,!(0|n);)if((0|c)>=(0|i[p>>2]))break t;Nt(u),Nt(h),Nt(q);break e}}while(0);(0|F)>0|!(0|F)&O>>>0>0&&Xt(0|h,0,O<<3),L=0|i[(I=s)+4>>2];t:do{if((0|L)>0|!(0|L)&(0|i[I>>2])>>>0>0){R=u,N=h,P=u,L=h,I=u,n=u,M=u,E=h,C=h,u=h;n:for(;;){for(x=0,b=0,S=0,w=0,c=0,A=0;;){d=(h=a)+56|0;do{i[h>>2]=0,h=h+4|0}while((0|h)<(0|d));if(0|U(p=0|i[(t=R+(x<<3)|0)>>2],t=0|i[t+4>>2],1,a,0)){d=(h=a)+56|0;do{i[h>>2]=0,h=h+4|0}while((0|h)<(0|d));0|(h=0|Pt(7,4))&&(B(p,t,1,a,h,7,0,0),Nt(h))}for(y=0;;){_=0|i[(v=a+(y<<3)|0)>>2],v=0|i[v+4>>2];r:do{if(!(0|_)&!(0|v))h=c,d=A;else{if(f=0|kt(0|_,0|v,0|O,0|F),p=0|T(),!(!(0|(d=0|i[(t=h=r+(f<<3)|0)>>2]))&!(0|(t=0|i[t+4>>2])))){m=0,g=0;do{if((0|m)>(0|F)|(0|m)==(0|F)&g>>>0>O>>>0)break n;if((0|d)==(0|_)&(0|t)==(0|v)){h=c,d=A;break r}f=0|Ft(0|(h=0|Dt(0|f,0|p,1,0)),0|T(),0|O,0|F),p=0|T(),g=0|Dt(0|g,0|m,1,0),m=0|T(),d=0|i[(t=h=r+(f<<3)|0)>>2],t=0|i[t+4>>2]}while(!(!(0|d)&!(0|t)))}!(0|_)&!(0|v)?(h=c,d=A):(Xe(_,v,o),0|ft(e,q,o)&&(g=0|Dt(0|c,0|A,1,0),A=0|T(),i[(m=h)>>2]=_,i[m+4>>2]=v,i[(c=N+(c<<3)|0)>>2]=_,i[c+4>>2]=v,c=g),h=c,d=A)}}while(0);if((y=y+1|0)>>>0>=7)break;c=h,A=d}if(x=0|Dt(0|x,0|b,1,0),b=0|T(),S=0|Dt(0|S,0|w,1,0),w=0|T(),c=0|i[(A=s)>>2],!((0|w)<(0|(A=0|i[A+4>>2]))|(0|w)==(0|A)&S>>>0>>0))break;c=h,A=d}if((0|A)>0|!(0|A)&c>>>0>0){c=0,A=0;do{i[(w=R+(c<<3)|0)>>2]=0,i[w+4>>2]=0,c=0|Dt(0|c,0|A,1,0),A=0|T(),S=0|i[(w=s)+4>>2]}while((0|A)<(0|S)|((0|A)==(0|S)?c>>>0<(0|i[w>>2])>>>0:0))}if(i[(w=s)>>2]=h,i[w+4>>2]=d,!((0|d)>0|!(0|d)&h>>>0>0))break t;y=u,x=C,b=I,S=E,w=N,u=M,C=n,E=P,M=y,n=x,I=L,L=b,P=S,N=R,R=w}Nt(P),Nt(L),Nt(q),n=1;break e}n=h}while(0);Nt(q),Nt(u),Nt(n),n=0}}while(0);return D=l,0|(q=n)},_readInt64AsDoubleFromPointer:function(e){return+(+((0|i[(e|=0)>>2])>>>0)+4294967296*+(0|i[e+4>>2]))},_res0CellCount:function(){return 122},_round:Qt,_sbrk:Yt,_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,n,r,s,a,o){e|=0,r|=0,s|=0,a|=0;var l,u=0,c=0,A=0,h=0,d=0,p=0,f=0,m=0;if(l=D,D=D+16|0,m=l,!((0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0))return D=l,0|(m=0);if((0|(o|=0))>=16)return D=l,0|(m=12);p=0,f=0,d=0,u=0;e:for(;;){if(h=0|Gt(0|(c=0|i[(A=e+(p<<3)|0)>>2]),0|(A=0|i[A+4>>2]),52),T(),(15&h)>(0|o)){u=12,c=11;break}if($e(m,c,A,o),!(0|(A=0|i[(h=m)>>2]))&!(0|(h=0|i[h+4>>2])))c=d;else{c=d;do{if(!((0|u)<(0|a)|(0|u)==(0|a)&c>>>0>>0)){c=10;break e}i[(d=r+(c<<3)|0)>>2]=A,i[d+4>>2]=h,c=0|Dt(0|c,0|u,1,0),u=0|T(),Ke(m),A=0|i[(d=m)>>2],h=0|i[d+4>>2]}while(!(!(0|A)&!(0|h)))}if(p=0|Dt(0|p,0|f,1,0),!((0|(f=0|T()))<(0|n)|(0|f)==(0|n)&p>>>0>>0)){u=0,c=11;break}d=c}return 10==(0|c)?(D=l,0|(m=14)):11==(0|c)?(D=l,0|u):0},_uncompactCellsSize:function(e,t,n,r,s){e|=0,t|=0,n|=0,r|=0,s|=0;var a,o,l=0,u=0,c=0,A=0,h=0,d=0;o=D,D=D+16|0,a=o;e:do{if((0|n)>0|!(0|n)&t>>>0>0){for(h=0,u=0,l=0,d=0;;){if(!(!(0|(c=0|i[(A=e+(h<<3)|0)>>2]))&!(0|(A=0|i[A+4>>2]))||(A=!(0|Be(c,A,r,a)),u=0|Dt(0|i[(c=a)>>2],0|i[c+4>>2],0|u,0|l),l=0|T(),A))){l=12;break}if(h=0|Dt(0|h,0|d,1,0),!((0|(d=0|T()))<(0|n)|(0|d)==(0|n)&h>>>0>>0))break e}return D=o,0|l}u=0,l=0}while(0);return i[s>>2]=u,i[s+4>>2]=l,D=o,0|(s=0)},_vertexToLatLng:function(e,t,n){n|=0;var r,s,a,o,l=0,u=0;return o=D,D=D+192|0,s=o,a=o+168|0,l=0|Gt(0|(e|=0),0|(t|=0),56),T(),l&=7,0|(r=0|We(e,u=-2130706433&t|134217728,a))?(D=o,0|(u=r)):(t=0|Gt(0|e,0|t,52),T(),t&=15,0|Oe(e,u)?Ee(a,t,l,1,s):Pe(a,t,l,1,s),u=s+8|0,i[n>>2]=i[u>>2],i[n+4>>2]=i[u+4>>2],i[n+8>>2]=i[u+8>>2],i[n+12>>2]=i[u+12>>2],D=o,0|(u=0))},establishStackSpace:function(e,t){D=e|=0},stackAlloc:function(e){var t;return t=D,D=(D=D+(e|=0)|0)+15&-16,0|t},stackRestore:function(e){D=e|=0},stackSave:function(){return 0|D}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{a:ge,b:function(e){g=e},c:function(){return g},d:function(e,t,n,r){ge("Assertion failed: "+N(e)+", at: "+[t?N(t):"unknown filename",n,r?N(r):"unknown function"])},e:function(e){return n.___errno_location&&(M[n.___errno_location()>>2]=e),e},f:J,g:function(e,t,n){w.set(w.subarray(t,t+n),e)},h:function(e){var t=J(),n=16777216,r=2130706432;if(e>r)return!1;for(var i=Math.max(t,16777216);i>1]=t;break;case"i32":M[e>>2]=t;break;case"i64":W=[t>>>0,(j=t,+k(j)>=1?j>0?(0|z(+G(j/4294967296),4294967295))>>>0:~~+q((j-+(~~j>>>0))/4294967296)>>>0:0)],M[e>>2]=W[0],M[e+4>>2]=W[1];break;case"float":E[e>>2]=t;break;case"double":C[e>>3]=t;break;default:ge("invalid type for setValue: "+n)}},n.getValue=function(e,t,n){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return S[e|0];case"i16":return T[e>>1];case"i32":case"i64":return M[e>>2];case"float":return E[e>>2];case"double":return C[e>>3];default:ge("invalid type for getValue: "+t)}return null},X)if(Y(X)||(ae=X,X=n.locateFile?n.locateFile(ae,p):p+ae),a||l){var Ae=A(X);w.set(Ae,8)}else{V++,n.monitorRunDependencies&&n.monitorRunDependencies(V);var he=function(e){e.byteLength&&(e=new Uint8Array(e)),w.set(e,8),n.memoryInitializerRequest&&delete n.memoryInitializerRequest.response,function(){if(V--,n.monitorRunDependencies&&n.monitorRunDependencies(V),0==V&&H){var e=H;H=null,e()}}()},de=function(){c(X,he,(function(){throw"could not load memory initializer "+X}))},pe=re(X);if(pe)he(pe.buffer);else if(n.memoryInitializerRequest){var fe=function(){var e=n.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var r=re(n.memoryInitializerRequestURL);if(!r)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+e.status+", retrying "+X),void de();t=r.buffer}he(t)};n.memoryInitializerRequest.response?setTimeout(fe,0):n.memoryInitializerRequest.addEventListener("load",fe)}else de()}function me(e){function t(){oe||(oe=!0,_||(I(B),I(O),n.onRuntimeInitialized&&n.onRuntimeInitialized(),function(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)e=n.postRun.shift(),F.unshift(e);var e;I(F)}()))}V>0||(!function(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)e=n.preRun.shift(),U.unshift(e);var e;I(U)}(),V>0||(n.setStatus?(n.setStatus("Running..."),setTimeout((function(){setTimeout((function(){n.setStatus("")}),1),t()}),1)):t()))}function ge(e){throw n.onAbort&&n.onAbort(e),f(e+=""),m(e),_=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}if(H=function e(){oe||me(),oe||(H=e)},n.run=me,n.abort=ge,n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return me(),e}("object"==typeof Tv?Tv:{}),Mv="number",Ev={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"},Cv={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function Rv(e,t,n){var r=n&&"value"in n,i=new Error((e[t]||"Unknown error")+" (code: "+t+(r?", value: "+n.value:"")+")");return i.code=t,i}function Nv(e,t){return Rv(Ev,e,2===arguments.length?{value:t}:{})}function Pv(e,t){return Rv(Cv,e,2===arguments.length?{value:t}:{})}function Dv(e){if(0!==e)throw Nv(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 Lv={};[["sizeOfH3Index",Mv],["sizeOfLatLng",Mv],["sizeOfCellBoundary",Mv],["sizeOfGeoLoop",Mv],["sizeOfGeoPolygon",Mv],["sizeOfLinkedGeoPolygon",Mv],["sizeOfCoordIJ",Mv],["readInt64AsDoubleFromPointer",Mv],["isValidCell",Mv,[Mv,Mv]],["latLngToCell",Mv,[Mv,Mv,Mv,Mv]],["cellToLatLng",Mv,[Mv,Mv,Mv]],["cellToBoundary",Mv,[Mv,Mv,Mv]],["maxGridDiskSize",Mv,[Mv,Mv]],["gridDisk",Mv,[Mv,Mv,Mv,Mv]],["gridDiskDistances",Mv,[Mv,Mv,Mv,Mv,Mv]],["gridRingUnsafe",Mv,[Mv,Mv,Mv,Mv]],["maxPolygonToCellsSize",Mv,[Mv,Mv,Mv,Mv]],["polygonToCells",Mv,[Mv,Mv,Mv,Mv]],["cellsToLinkedMultiPolygon",Mv,[Mv,Mv,Mv]],["destroyLinkedMultiPolygon",null,[Mv]],["compactCells",Mv,[Mv,Mv,Mv,Mv]],["uncompactCells",Mv,[Mv,Mv,Mv,Mv,Mv,Mv]],["uncompactCellsSize",Mv,[Mv,Mv,Mv,Mv,Mv]],["isPentagon",Mv,[Mv,Mv]],["isResClassIII",Mv,[Mv,Mv]],["getBaseCellNumber",Mv,[Mv,Mv]],["getResolution",Mv,[Mv,Mv]],["maxFaceCount",Mv,[Mv,Mv,Mv]],["getIcosahedronFaces",Mv,[Mv,Mv,Mv]],["cellToParent",Mv,[Mv,Mv,Mv,Mv]],["cellToChildren",Mv,[Mv,Mv,Mv,Mv]],["cellToCenterChild",Mv,[Mv,Mv,Mv,Mv]],["cellToChildrenSize",Mv,[Mv,Mv,Mv,Mv]],["cellToChildPos",Mv,[Mv,Mv,Mv,Mv]],["childPosToCell",Mv,[Mv,Mv,Mv,Mv,Mv,Mv]],["areNeighborCells",Mv,[Mv,Mv,Mv,Mv,Mv]],["cellsToDirectedEdge",Mv,[Mv,Mv,Mv,Mv,Mv]],["getDirectedEdgeOrigin",Mv,[Mv,Mv,Mv]],["getDirectedEdgeDestination",Mv,[Mv,Mv,Mv]],["isValidDirectedEdge",Mv,[Mv,Mv]],["directedEdgeToCells",Mv,[Mv,Mv,Mv]],["originToDirectedEdges",Mv,[Mv,Mv,Mv]],["directedEdgeToBoundary",Mv,[Mv,Mv,Mv]],["gridDistance",Mv,[Mv,Mv,Mv,Mv,Mv]],["gridPathCells",Mv,[Mv,Mv,Mv,Mv,Mv]],["gridPathCellsSize",Mv,[Mv,Mv,Mv,Mv,Mv]],["cellToLocalIj",Mv,[Mv,Mv,Mv,Mv,Mv,Mv]],["localIjToCell",Mv,[Mv,Mv,Mv,Mv,Mv]],["getHexagonAreaAvgM2",Mv,[Mv,Mv]],["getHexagonAreaAvgKm2",Mv,[Mv,Mv]],["getHexagonEdgeLengthAvgM",Mv,[Mv,Mv]],["getHexagonEdgeLengthAvgKm",Mv,[Mv,Mv]],["greatCircleDistanceM",Mv,[Mv,Mv]],["greatCircleDistanceKm",Mv,[Mv,Mv]],["greatCircleDistanceRads",Mv,[Mv,Mv]],["cellAreaM2",Mv,[Mv,Mv,Mv]],["cellAreaKm2",Mv,[Mv,Mv,Mv]],["cellAreaRads2",Mv,[Mv,Mv,Mv]],["edgeLengthM",Mv,[Mv,Mv,Mv]],["edgeLengthKm",Mv,[Mv,Mv,Mv]],["edgeLengthRads",Mv,[Mv,Mv,Mv]],["getNumCells",Mv,[Mv,Mv]],["getRes0Cells",Mv,[Mv]],["res0CellCount",Mv],["getPentagons",Mv,[Mv,Mv]],["pentagonCount",Mv],["cellToVertex",Mv,[Mv,Mv,Mv,Mv]],["cellToVertexes",Mv,[Mv,Mv,Mv]],["vertexToLatLng",Mv,[Mv,Mv,Mv]],["isValidVertex",Mv,[Mv,Mv]]].forEach((function(e){Lv[e[0]]=Tv.cwrap.apply(Tv,e)}));var Iv=16,Uv=Lv.sizeOfH3Index(),Bv=Lv.sizeOfLatLng(),Ov=Lv.sizeOfCellBoundary(),Fv=Lv.sizeOfGeoPolygon(),kv=Lv.sizeOfGeoLoop();Lv.sizeOfLinkedGeoPolygon(),Lv.sizeOfCoordIJ();var qv=Math.pow(2,32)-1;var Gv,zv,Vv,Hv,jv,Wv,Xv,Qv,Yv=/[^0-9a-fA-F]/;function $v(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||Yv.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),Iv);return[parseInt(e.substring(e.length-8),Iv),t]}function Kv(e){if(e>=0)return e.toString(Iv);var t=Zv(8,(e&=2147483647).toString(Iv));return t=(parseInt(t[0],Iv)+8).toString(Iv)+t.substring(1)}function Zv(e,t){for(var n=e-t.length,r="",i=0;i15||Math.floor(e)!==e)throw Nv(4,e)}(t),n=Boolean(n),0===e.length||0===e[0].length)return[];var r,i=function(e,t){var n,r=e.length-1,i=Tv._calloc(Fv),s=0+kv,a=s+4;if(Jv(e[0],i+0,t),r>0){n=Tv._calloc(r,kv);for(var o=0;oqv)throw Pv(1001,e);return e}((r=s,Lv.readInt64AsDoubleFromPointer(r))),o=Tv._calloc(a,Uv);try{return Dv(Lv.polygonToCells(i,t,0,o)),function(e,t){for(var n=[],r=0;r0){for(var i=Tv.getValue(e+n,"i32"),s=0;s=4&&n<16){this.subdivide();for(var r=0;ro.x&&(l+=1),s>o.y&&(l+=2),a>o.z&&(l+=4);var u=function(e,t){return 0===t?e.q0:1===t?e.q1:2===t?e.q2:3===t?e.q3:4===t?e.q4:5===t?e.q5:6===t?e.q6:7===t?e.q7:void 0}(this,l);u.insert(e,t,n+1)}},t.prototype.query=function(e,t,n,r){if(n(this.bounds)){var i=this.items,s="function"==typeof r;if(i)for(var a=0;ar.x+s&&(i-=u(e-(r.x+s))),tr.y+s&&(i-=u(t-(r.y+s))),nr.z+s&&(i-=u(n-(r.z+s))),i>0}function A(r,i,s){return u(r-e)+u(i-t)+u(s-n)o&&(o=A),hl&&(l=h),du&&(u=d)}var p=Math.max(Math.max(o-i,l-s),u-a),f=(p+=2)/2,m=new e((i-=1)+f,(s-=1)+f,(a-=1)+f,f);return new t(m)}},Xv}(),cy=r_(uy);const Ay=new cn,hy=new on;class dy extends Ya{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 Hr([-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 Hr([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new Ja(t,6,1);return this.setAttribute("instanceStart",new Ni(n,3,0)),this.setAttribute("instanceEnd",new Ni(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new Ja(t,6,1);return this.setAttribute("instanceColorStart",new Ni(n,3,0)),this.setAttribute("instanceColorEnd",new Ni(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new ca(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new cn);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),Ay.setFromBufferAttribute(t),this.boundingBox.union(Ay))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Cn),null===this.boundingBox&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,s=e.count;i\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\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\tfloat alpha = opacity;\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\tvec4 diffuseColor = vec4( diffuse, alpha );\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 py extends gi{constructor(e){super({type:"LineMaterial",uniforms:mi.clone(po.line.uniforms),vertexShader:po.line.vertexShader,fragmentShader:po.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const fy=new en,my=new on,gy=new on,_y=new en,vy=new en,yy=new en,xy=new on,by=new On,Sy=new class{constructor(e=new on,t=new on){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){io.subVectors(e,this.start),so.subVectors(this.end,this.start);const n=so.dot(so);let r=so.dot(io)/n;return t&&(r=Et(r,0,1)),r}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},wy=new on,Ty=new cn,My=new Cn,Ey=new en;let Cy,Ry;function Ny(e,t,n){return Ey.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),Ey.multiplyScalar(1/Ey.w),Ey.x=Ry/n.width,Ey.y=Ry/n.height,Ey.applyMatrix4(e.projectionMatrixInverse),Ey.multiplyScalar(1/Ey.w),Math.abs(Math.max(Ey.x,Ey.y))}class Py extends ci{constructor(e=new dy,t=new py({color:16777215*Math.random()})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,s=t.count;ec&&vy.z>c)continue;if(_y.z>c){const e=_y.z-vy.z,t=(_y.z-c)/e;_y.lerp(vy,t)}else if(vy.z>c){const e=vy.z-_y.z,t=(vy.z-c)/e;vy.lerp(_y,t)}_y.applyMatrix4(r),vy.applyMatrix4(r),_y.multiplyScalar(1/_y.w),vy.multiplyScalar(1/vy.w),_y.x*=i.x/2,_y.y*=i.y/2,vy.x*=i.x/2,vy.y*=i.y/2,Sy.start.copy(_y),Sy.start.z=0,Sy.end.copy(vy),Sy.end.z=0;const a=Sy.closestPointToPointParameter(xy,!0);Sy.at(a,wy);const u=Dt.lerp(_y.z,vy.z,a),A=u>=-1&&u<=1,h=xy.distanceTo(wy)<.5*Ry;if(A&&h){Sy.start.fromBufferAttribute(o,t),Sy.end.fromBufferAttribute(l,t),Sy.start.applyMatrix4(s),Sy.end.applyMatrix4(s);const r=new on,i=new on;Cy.distanceSqToSegment(Sy.start,Sy.end,i,r),n.push({point:i,pointOnLine:r,distance:Cy.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}(this,r,t))}}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(fy),this.material.uniforms.resolution.value.set(fy.z,fy.w))}}class Dy extends dy{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let r=0;re.length)&&(t=e.length);for(var n=0,r=Array(t);n1?i-1:0),a=1;a2&&void 0!==arguments[2]?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180,s=ux*(1+n),a=Math.sin(r);return{x:s*a*Math.cos(i),y:s*Math.cos(r),z:s*a*Math.sin(i)}}function hx(e){var t=e.x,n=e.y,r=e.z,i=Math.sqrt(t*t+n*n+r*r),s=Math.acos(n/i),a=Math.atan2(r,t);return{lat:90-180*s/Math.PI,lng:90-180*a/Math.PI-(a<-Math.PI/2?360:0),altitude:i/ux-1}}function dx(e){return e*Math.PI/180}var px=window.THREE?window.THREE:{BackSide:1,BufferAttribute:qr,Color:Rr,Mesh:ci,ShaderMaterial:gi};var fx=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.color,s=void 0===i?"gold":i,a=r.size,o=void 0===a?2:a,l=r.coefficient,u=void 0===l?.5:l,c=r.power,A=void 0===c?1:c,h=r.hollowRadius,d=void 0===h?0:h,p=r.backside,f=void 0===p||p;qy(this,t),n=Fy(this,t);var m=function(e,t){for(var n=e.clone(),r=new Float32Array(3*e.attributes.position.count),i=0,s=r.length;i1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=1,s=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(s){var a=ex(s.slice(1),4),o=a[0],l=a[1],u=a[2],c=a[3];t=new Rr("rgb(".concat(+o,",").concat(+l,",").concat(+u,")")),i=Math.min(+c,1)}else t=new Rr(e);r&&t.convertLinearToSRGB();var A=t.toArray();return n?[].concat(nx(A),[i]):A};var xx=window.THREE?window.THREE:{BufferAttribute:qr};function bx(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float32Array;if(1===t)return new xx.BufferAttribute(new n(e),t);for(var r=new xx.BufferAttribute(new n(e.length*t),t),i=0,s=e.length;i1&&void 0!==arguments[1]?arguments[1]:{},i=r.dataBindAttr,s=void 0===i?"__data":i,a=r.objBindAttr,o=void 0===a?"__threeObj":a,l=r.removeDelay,u=void 0===l?0:l;return qy(this,t),Wy(n=Fy(this,t),"scene",void 0),zy(n,Sx,void 0),zy(n,wx,void 0),zy(n,Tx,void 0),n.scene=e,Vy(Sx,n,s),Vy(wx,n,o),Vy(Tx,n,u),n.onRemoveObj((function(){})),n}return Yy(t,e),jy(t,[{key:"onCreateObj",value:function(e){var n=this;return tx(t,"onCreateObj",this)([function(t){var r=e(t);return t[Gy(wx,n)]=r,r[Gy(Sx,n)]=t,n.scene.add(r),r}]),this}},{key:"onRemoveObj",value:function(e){var n=this;return tx(t,"onRemoveObj",this)([function(r,i){var s=tx(t,"getData",n)([r]);e(r,i);var a=function(){n.scene.remove(r),ox(r),delete s[Gy(wx,n)]};Gy(Tx,n)?setTimeout(a,Gy(Tx,n)):a()}]),this}}])}(n_),Ex=window.THREE?window.THREE:{BufferGeometry:Zr,Color:Rr,CylinderGeometry:Rs,Matrix4:On,Mesh:ci,MeshLambertMaterial:_a,Object3D:cr,Vector3:on},Cx=Object.assign({},rg),Rx=Cx.BufferGeometryUtils||Cx,Nx=Mc({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,n){var r=n.tweenGroup;ox(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Mx(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=ig(e.pointLat),r=ig(e.pointLng),i=ig(e.pointAltitude),s=ig(e.pointRadius),a=ig(e.pointColor),o=new Ex.CylinderGeometry(1,1,1,e.pointResolution);o.applyMatrix4((new Ex.Matrix4).makeRotationX(Math.PI/2)),o.applyMatrix4((new Ex.Matrix4).makeTranslation(0,0,-.5));var l=2*Math.PI*ux/360,u={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&ox(e.scene),e.dataMapper.scene=e.pointsMerge?new Ex.Object3D:e.scene,e.dataMapper.onCreateObj((function(){var e=new Ex.Mesh(o);return e.__globeObjType="point",e})).onUpdateObj((function(t,o){var c=function(n){var r=t.__currentTargetD=n,i=r.r,s=r.alt,a=r.lat,o=r.lng;Object.assign(t.position,Ax(a,o));var u=e.pointsMerge?new Ex.Vector3(0,0,0):e.scene.localToWorld(new Ex.Vector3(0,0,0));t.lookAt(u),t.scale.x=t.scale.y=Math.min(30,i)*l,t.scale.z=Math.max(s*ux,.1)},A={alt:+i(o),r:+s(o),lat:+n(o),lng:+r(o)},h=t.__currentTargetD||Object.assign({},A,{alt:-.001});Object.keys(A).some((function(e){return h[e]!==A[e]}))&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?c(A):e.tweenGroup.add(new Lc(h).to(A,e.pointsTransitionDuration).easing(Ec.Quadratic.InOut).onUpdate(c).start()));if(!e.pointsMerge){var d=a(o),p=d?vx(d):0,f=!!p;t.visible=f,f&&(u.hasOwnProperty(d)||(u[d]=new Ex.MeshLambertMaterial({color:_x(d),transparent:p<1,opacity:p})),t.material=u[d])}})).digest(e.pointsData),e.pointsMerge){var c=e.pointsData.length?(Rx.mergeGeometries||Rx.mergeBufferGeometries)(e.pointsData.map((function(t){var n=e.dataMapper.getObj(t),r=n.geometry.clone();n.updateMatrix(),r.applyMatrix4(n.matrix);var i=yx(a(t));return r.setAttribute("color",bx(Array(r.getAttribute("position").count).fill(i),4)),r}))):new Ex.BufferGeometry,A=new Ex.Mesh(c,new Ex.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));A.__globeObjType="points",A.__data=e.pointsData,e.dataMapper.clear(),ox(e.scene),e.scene.add(A)}}}),Px=function(e){return e.uniforms.surfaceRadius={type:"float",value:0},e.vertexShader=("attribute float surfaceRadius;\nvarying float vSurfaceRadius;\nvarying vec3 vPos;\n"+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join("\n")),e.fragmentShader=("uniform float surfaceRadius;\nvarying float vSurfaceRadius;\nvarying vec3 vPos;\n"+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(surfaceRadius, vSurfaceRadius)) discard;"].join("\n")),e},Dx=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},Lx=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},Ix=["stroke"],Ux=window.THREE?window.THREE:{BufferGeometry:Zr,CubicBezierCurve3:ys,Curve:us,Group:as,Line:Yi,Mesh:ci,NormalBlending:1,QuadraticBezierCurve3:Ss,ShaderMaterial:gi,TubeGeometry:ua,Vector3:on},Bx=o_.default||o_,Ox=Mc({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},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 Bx,sharedMaterial:new Ux.ShaderMaterial(Zy(Zy({},{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:"\n uniform float dashTranslate; \n\n attribute vec4 color;\n varying vec4 vColor;\n \n attribute float relDistance;\n varying float vRelDistance;\n\n void main() {\n // pass through colors and distances\n vColor = color;\n vRelDistance = relDistance + dashTranslate;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float dashOffset; \n uniform float dashSize;\n uniform float gapSize; \n \n varying vec4 vColor;\n varying float vRelDistance;\n \n void main() {\n // ignore pixels in the gap\n if (vRelDistance < dashOffset) discard;\n if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;\n \n // set px color: [r, g, b, a], interpolated between vertices \n gl_FragColor = vColor; \n }\n "}),{},{transparent:!0,blending:Ux.NormalBlending}))}},init:function(e,t){ox(e),t.scene=e,t.dataMapper=new Mx(e,{objBindAttr:"__threeObjArc"}).onCreateObj((function(){var e=new Ux.Group;return e.__globeObjType="arc",e})),t.ticker.onTick.add((function(e,n){t.dataMapper.entries().map((function(e){return ex(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],r=t.__dashAnimateStep*n,i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r}))}))},update:function(e){var t=ig(e.arcStartLat),n=ig(e.arcStartLng),r=ig(e.arcEndLat),i=ig(e.arcEndLng),s=ig(e.arcAltitude),a=ig(e.arcAltitudeAutoScale),o=ig(e.arcStroke),l=ig(e.arcColor),u=ig(e.arcDashLength),c=ig(e.arcDashGap),A=ig(e.arcDashInitialGap),h=ig(e.arcDashAnimateTime);e.dataMapper.onUpdateObj((function(d,p){var f=o(p),m=null!=f;if(!d.children.length||m!==("Mesh"===d.children[0].type)){ox(d);var g=m?new Ux.Mesh:new Ux.Line(new Ux.BufferGeometry);g.material=e.sharedMaterial.clone(),d.add(g)}var _=d.children[0];Object.assign(_.material.uniforms,{dashSize:{value:u(p)},gapSize:{value:c(p)},dashOffset:{value:A(p)}});var v=h(p);_.__dashAnimateStep=v>0?1e3/v:0;var y=function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=t+1;if(e instanceof Array||e instanceof Function){var s=e instanceof Array?Mh().domain(e.map((function(t,n){return n/(e.length-1)}))).range(e):e;n=function(e){return yx(s(e),!0,!0)}}else{var a=yx(e,!0,!0);n=function(){return a}}for(var o=[],l=0,u=i;l1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[],i=0,s=e+1;i170&&(e[0]+=n>t?360:-360)})),t.__globeObjType="hexbin",t})).onUpdateObj((function(t,n){var r=Math.max(0,Math.min(1,+l(n))),i=ex(t.__hexCenter,2),u=i[0],c=i[1],h=0===r?t.__hexGeoJson:t.__hexGeoJson.map((function(e){var t=ex(e,2),n=t[0],i=t[1];return[[n,c],[i,u]].map((function(e){var t=ex(e,2);return function(e,t,n){return e-(e-t)*n}(t[0],t[1],r)}))})),d=e.hexTopCurvatureResolution;t.geometry&&t.geometry.dispose(),t.geometry=new _v([h],0,ux,!1,!0,!0,d);var p={alt:+s(n)},f=function(e){var n=(t.__currentTargetD=e).alt;t.scale.x=t.scale.y=t.scale.z=1+n;var r=ux/(n+1);t.geometry.setAttribute("surfaceRadius",bx(Array(t.geometry.getAttribute("position").count).fill(r),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 Lc(m).to(p,e.hexTransitionDuration).easing(Ec.Quadratic.InOut).onUpdate(f).start()));if(!e.hexBinMerge){var g=o(n),_=a(n);[g,_].forEach((function(e){if(!A.hasOwnProperty(e)){var t=vx(e);A[e]=Lx(new Fx.MeshLambertMaterial({color:_x(e),transparent:t<1,opacity:t,side:Fx.DoubleSide}),Px)}})),t.material=[g,_].map((function(e){return A[e]}))}})).digest(c),e.hexBinMerge){var h=c.length?(qx.mergeGeometries||qx.mergeBufferGeometries)(c.map((function(t){var n=e.dataMapper.getObj(t),r=n.geometry.toNonIndexed();n.updateMatrix(),r.applyMatrix4(n.matrix);var i=yx(a(t)),s=yx(o(t)),l=r.getAttribute("position").count,u=r.groups[0].count;return r.setAttribute("color",bx(nx(new Array(l)).map((function(e,t){return t>=u?i:s})),4)),r}))):new Fx.BufferGeometry,d=new Fx.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:Fx.DoubleSide});d.onBeforeCompile=function(e){d.userData.shader=Px(e)};var p=new Fx.Mesh(h,d);p.__globeObjType="hexBinPoints",p.__data=c,e.dataMapper.clear(),ox(e.scene),e.scene.add(p)}}}),zx=function(e){return e*e};var Vx=Math.sqrt(2*Math.PI);var Hx=function(e){var t=ex(e,2),n=t[0],r=t[1],i=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,u=void 0===l?function(e){return e[1]}:l,c=s.weightAccessor,A=void 0===c?function(){return 1}:c,h=s.bandwidth,d=[n,r],p=h*Math.PI/180;return function(e){let t=0;for(let n of e)(n=+n)&&(t+=n);return t}(i.map((function(e){var t=A(e);if(!t)return 0;var n=function(e,t){var n=Math.sqrt,r=Math.cos,i=function(e){return e*Math.PI/180},s=function(e){return zx(Math.sin(e/2))},a=i(e[1]),o=i(t[1]),l=i(e[0]),u=i(t[0]);return 2*Math.asin(n(s(o-a)+r(a)*r(o)*s(u-l)))}(d,[o(e),u(e)]);return function(e,t){return Math.exp(-zx(e/t)/2)/(t*Vx)}(n,p)*t})))},jx=window.THREE?window.THREE:{Mesh:ci,MeshLambertMaterial:_a,SphereGeometry:la},Wx=new WeakSet,Xx=new WeakMap,Qx=new WeakMap,Yx=new WeakMap,$x=function(){return jy((function e(t,n){qy(this,e),function(e,t){ky(e,t),t.add(e)}(this,Wx),zy(this,Xx,void 0),zy(this,Qx,void 0),zy(this,Yx,void 0),Vy(Xx,this,t),Vy(Qx,this,cy()),Gy(Qx,this).init(t.map((function(e){return[e.x,e.y,e.z]})).flat()),Vy(Yx,this,Oy(Wx,this,Kx).call(this,Ax(0,0),Ax(0,Math.min(180,n))))}),[{key:"getNearPoints",value:function(e,t,n){var r=this;return Gy(Qx,this).intersectSphere(e,t,n,Gy(Yx,this)).map((function(e){return Gy(Xx,r)[e/3]}))}}])}();function Kx(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)+Math.pow(e.z-t.z,2))}var Zx=function(e){var t=wA(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()},Jx=Mc({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 Zx}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;ox(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Mx(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj((function(){var e=new jx.Mesh(new jx.SphereGeometry(ux),Lx(new jx.MeshLambertMaterial({vertexColors:!0,transparent:!0}),Dx));return e.__globeObjType="heatmap",e}))},update:function(e){var t=ig(e.heatmapPoints),n=ig(e.heatmapPointLat),r=ig(e.heatmapPointLng),i=ig(e.heatmapPointWeight),s=ig(e.heatmapBandwidth),a=ig(e.heatmapColorFn),o=ig(e.heatmapColorSaturation),l=ig(e.heatmapBaseAltitude),u=ig(e.heatmapTopAltitude);e.dataMapper.onUpdateObj((function(c,A){var h=s(A),d=a(A),p=o(A),f=l(A),m=u(A),g=t(A).map((function(e){var t=n(e),s=r(e),a=Ax(t,s);return{x:a.x,y:a.y,z:a.z,lat:t,lng:s,weight:i(e)}})),_=Math.max(.1,h/3.5),v=Math.ceil(360/(_||-1));c.geometry.parameters.widthSegments!==v&&(c.geometry.dispose(),c.geometry=new jx.SphereGeometry(ux,v,v/2));var y=function(e){for(var t=e.itemSize,n=[],r=0;r=n)&&(t=n);return t}(n.map(Math.abs))||1e-15,a=Eh([0,s/i],w);c.geometry.setAttribute("color",bx(n.map((function(e){return a(Math.abs(e))})),4));var o=Mh([0,s],[ux*(1+f),ux*(1+(r||f))]);c.geometry.setAttribute("r",bx(n.map(o)))},M={kdeVals:S,topAlt:m,saturation:p},E=c.__currentTargetD||Object.assign({},M,{kdeVals:S.map((function(){return 0})),topAlt:m?f:m,saturation:.5});E.kdeVals.length!==S.length&&(E.kdeVals=S.slice()),Object.keys(M).some((function(e){return E[e]!==M[e]}))&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?T(M):e.tweenGroup.add(new Lc(E).to(M,e.heatmapsTransitionDuration).easing(Ec.Quadratic.InOut).onUpdate(T).start()))})).digest(e.heatmapsData)}}),eb=window.THREE?window.THREE:{DoubleSide:2,Group:as,LineBasicMaterial:Gi,LineSegments:Ji,Mesh:ci,MeshBasicMaterial:Lr},tb=Mc({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,n){var r=n.tweenGroup;ox(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Mx(e,{objBindAttr:"__threeObjPolygon"}).id((function(e){return e.id})).onCreateObj((function(){var e=new eb.Group;return e.__defaultSideMaterial=Lx(new eb.MeshBasicMaterial({side:eb.DoubleSide,depthWrite:!0}),Px),e.__defaultCapMaterial=new eb.MeshBasicMaterial({side:eb.DoubleSide,depthWrite:!0}),e.add(new eb.Mesh(void 0,[e.__defaultSideMaterial,e.__defaultCapMaterial])),e.add(new eb.LineSegments(void 0,new eb.LineBasicMaterial)),e.__globeObjType="polygon",e}))},update:function(e){var t=ig(e.polygonGeoJsonGeometry),n=ig(e.polygonAltitude),r=ig(e.polygonCapCurvatureResolution),i=ig(e.polygonCapColor),s=ig(e.polygonCapMaterial),a=ig(e.polygonSideColor),o=ig(e.polygonSideMaterial),l=ig(e.polygonStrokeColor),u=[];e.polygonsData.forEach((function(e){var c={data:e,capColor:i(e),capMaterial:s(e),sideColor:a(e),sideMaterial:o(e),strokeColor:l(e),altitude:+n(e),capCurvatureResolution:+r(e)},A=t(e),h=e.__id||"".concat(Math.round(1e9*Math.random()));e.__id=h,"Polygon"===A.type?u.push(Zy({id:"".concat(h,"_0"),coords:A.coordinates},c)):"MultiPolygon"===A.type?u.push.apply(u,nx(A.coordinates.map((function(e,t){return Zy({id:"".concat(h,"_").concat(t),coords:e},c)})))):console.warn("Unsupported GeoJson geometry type: ".concat(A.type,". Skipping geometry..."))})),e.dataMapper.onUpdateObj((function(t,n){var r=n.coords,i=n.capColor,s=n.capMaterial,a=n.sideColor,o=n.sideMaterial,l=n.strokeColor,u=n.altitude,c=n.capCurvatureResolution,A=ex(t.children,2),h=A[0],d=A[1],p=!!l;if(d.visible=p,function(e,t){var n=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 r=ex(t,2),i=r[0],s=r[1];return e.hasOwnProperty(i)&&n(i)(e[i],s)}))}(h.geometry.parameters||{},{polygonGeoJson:r,curvatureResolution:c})||(h.geometry&&h.geometry.dispose(),h.geometry=new _v(r,0,ux,!1,!0,!0,c)),!p||d.geometry.parameters&&d.geometry.parameters.geoJson.coordinates===r&&d.geometry.parameters.resolution===c||(d.geometry&&d.geometry.dispose(),d.geometry=new Km({type:"Polygon",coordinates:r},ux,c)),h.material[0]=o||t.__defaultSideMaterial,h.material[1]=s||t.__defaultCapMaterial,[!o&&a,!s&&i].forEach((function(e,t){if(e){var n=h.material[t],r=vx(e);n.color.set(_x(e)),n.transparent=r<1,n.opacity=r}})),p){var f=d.material,m=vx(l);f.color.set(_x(l)),f.transparent=m<1,f.opacity=m}var g={alt:u},_=function(e){var n=(t.__currentTargetD=e).alt;h.scale.x=h.scale.y=h.scale.z=1+n,p&&(d.scale.x=d.scale.y=d.scale.z=1+n+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 n=e.onBeforeCompile;e.onBeforeCompile=function(e){n(e),t(e.uniforms)}}}(t.__defaultSideMaterial,(function(e){return e.surfaceRadius.value=ux/(n+1)}))},v=t.__currentTargetD||Object.assign({},g,{alt:-.001});Object.keys(g).some((function(e){return v[e]!==g[e]}))&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||v.alt===g.alt?_(g):e.tweenGroup.add(new Lc(v).to(g,e.polygonsTransitionDuration).easing(Ec.Quadratic.InOut).onUpdate(_).start()))})).digest(u)}});var nb=window.THREE?window.THREE:{BufferGeometry:Zr,CircleGeometry:Cs,DoubleSide:2,Mesh:ci,MeshLambertMaterial:_a,Vector3:on},rb=Object.assign({},rg),ib=rb.BufferGeometryUtils||rb,sb=Mc({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,n){var r=n.tweenGroup;ox(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Mx(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj((function(){var e=new nb.Mesh(void 0,new nb.MeshLambertMaterial({side:nb.DoubleSide}));return e.__globeObjType="hexPolygon",e}))},update:function(e){var t=ig(e.hexPolygonGeoJsonGeometry),n=ig(e.hexPolygonColor),r=ig(e.hexPolygonAltitude),i=ig(e.hexPolygonResolution),s=ig(e.hexPolygonMargin),a=ig(e.hexPolygonUseDots),o=ig(e.hexPolygonCurvatureResolution),l=ig(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj((function(u,c){var A=t(c),h=i(c),d=r(c),p=Math.max(0,Math.min(1,+s(c))),f=a(c),m=o(c),g=l(c),_=n(c),v=vx(_);u.material.color.set(_x(_)),u.material.transparent=v<1,u.material.opacity=v;var y={alt:d,margin:p,curvatureResolution:m},x={geoJson:A,h3Res:h},b=u.__currentTargetD||Object.assign({},y,{alt:-.001}),S=u.__currentMemD||x;if(Object.keys(y).some((function(e){return b[e]!==y[e]}))||Object.keys(x).some((function(e){return S[e]!==x[e]}))){u.__currentMemD=x;var w=[];"Polygon"===A.type?ay(A.coordinates,h,!0).forEach((function(e){return w.push(e)})):"MultiPolygon"===A.type?A.coordinates.forEach((function(e){return ay(e,h,!0).forEach((function(e){return w.push(e)}))})):console.warn("Unsupported GeoJson geometry type: ".concat(A.type,". Skipping geometry..."));var T=w.map((function(e){var t=iy(e),n=sy(e).reverse(),r=t[1];return n.forEach((function(e){var t=e[0];Math.abs(r-t)>170&&(e[0]+=r>t?360:-360)})),{h3Idx:e,hexCenter:t,hexGeoJson:n}})),M=function(e){var t=u.__currentTargetD=e,n=t.alt,r=t.margin,i=t.curvatureResolution;u.geometry&&u.geometry.dispose(),u.geometry=T.length?(ib.mergeGeometries||ib.mergeBufferGeometries)(T.map((function(e){var t=ex(e.hexCenter,2),s=t[0],a=t[1];if(f){var o=Ax(s,a,n),l=Ax(e.hexGeoJson[0][1],e.hexGeoJson[0][0],n),u=.85*(1-r)*new nb.Vector3(o.x,o.y,o.z).distanceTo(new nb.Vector3(l.x,l.y,l.z)),c=new Cs(u,g);return c.rotateX(dx(-s)),c.rotateY(dx(a)),c.translate(o.x,o.y,o.z),c}var A=0===r?e.hexGeoJson:e.hexGeoJson.map((function(e){var t=ex(e,2),n=t[0],i=t[1];return[[n,a],[i,s]].map((function(e){var t=ex(e,2);return function(e,t,n){return e-(e-t)*n}(t[0],t[1],r)}))}));return new _v([A],ux,ux*(1+n),!1,!0,!1,i)}))):new nb.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?M(y):e.tweenGroup.add(new Lc(b).to(y,e.hexPolygonsTransitionDuration).easing(Ec.Quadratic.InOut).onUpdate(M).start())}})).digest(e.hexPolygonsData)}}),ab=window.THREE?window.THREE:{Vector3:on};function ob(e,t){var n=Math.max(e.length,t.length),r=WA.apply(void 0,nx([e,t].map((function(e){return e.map((function(e){return[e.x,e.y,e.z]}))})).map((function(e){return function(e,t){var n=e[e.length-1];return[].concat(nx(e),nx(Array(t-e.length).fill(n)))}(e,n)}))));return function(n){return 0===n?e:1===n?t:r(n).map((function(e){var t=ex(e,3),n=t[0],r=t[1],i=t[2];return new ab.Vector3(n,r,i)}))}}var lb=window.THREE?window.THREE:{BufferGeometry:Zr,Color:Rr,Group:as,Line:Yi,NormalBlending:1,ShaderMaterial:gi,Vector3:on},ub=o_.default||o_,cb=Mc({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.pause()},resumeAnimation:function(e){var t;null===(t=e.ticker)||void 0===t||t.resume()},_destructor:function(e){var t;null===(t=e.ticker)||void 0===t||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new ub,sharedMaterial:new lb.ShaderMaterial(Zy(Zy({},{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:"\n uniform float dashTranslate; \n\n attribute vec4 color;\n varying vec4 vColor;\n \n attribute float relDistance;\n varying float vRelDistance;\n\n void main() {\n // pass through colors and distances\n vColor = color;\n vRelDistance = relDistance + dashTranslate;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float dashOffset; \n uniform float dashSize;\n uniform float gapSize; \n \n varying vec4 vColor;\n varying float vRelDistance;\n \n void main() {\n // ignore pixels in the gap\n if (vRelDistance < dashOffset) discard;\n if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;\n \n // set px color: [r, g, b, a], interpolated between vertices \n gl_FragColor = vColor; \n }\n "}),{},{transparent:!0,blending:lb.NormalBlending}))}},init:function(e,t){ox(e),t.scene=e,t.dataMapper=new Mx(e,{objBindAttr:"__threeObjPath"}).onCreateObj((function(){var e=new lb.Group;return e.__globeObjType="path",e})),t.ticker.onTick.add((function(e,n){t.dataMapper.entries().map((function(e){return ex(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],r=t.__dashAnimateStep*n;if("Line"===t.type){var i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r}else if("Line2"===t.type){for(var s=t.material.dashOffset-r,a=t.material.dashSize+t.material.gapSize;s<=-a;)s+=a;t.material.dashOffset=s}}))}))},update:function(e){var t=ig(e.pathPoints),n=ig(e.pathPointLat),r=ig(e.pathPointLng),i=ig(e.pathPointAlt),s=ig(e.pathStroke),a=ig(e.pathColor),o=ig(e.pathDashLength),l=ig(e.pathDashGap),u=ig(e.pathDashInitialGap),c=ig(e.pathDashAnimateTime);function A(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=t+1;if(e instanceof Array||e instanceof Function){var a=e instanceof Array?Mh().domain(e.map((function(t,n){return n/(e.length-1)}))).range(e):e;n=function(e){return yx(a(e),i,!0)}}else{var o=yx(e,i,!0);n=function(){return o}}for(var l=[],u=0,c=s;u1&&void 0!==arguments[1]?arguments[1]:1,t=[],n=null;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((function(r){if(n){for(;Math.abs(n[1]-r[1])>180;)n[1]+=360*(n[1]e)for(var a=Math.floor(i/e),o=s(n[0],r[0],a),l=s(n[1],r[1],a),u=s(n[2],r[2],a),c=0,A=o.length;c0?1e3/x:0,f){v.material.resolution=e.rendererSize;var b=o(d),S=l(d),w=u(d);v.material.dashed=S>0,v.material.dashed?v.material.defines.USE_DASH="":delete v.material.defines.USE_DASH,v.material.dashed&&(v.material.dashScale=1/(_=0,y.forEach((function(e){g&&(_+=g.distanceTo(e)),g=e})),_),v.material.dashSize=b,v.material.gapSize=S,v.material.dashOffset=-w);var T=a(d);if(T instanceof Array){var M=A(a(d),y.length-1,1,!1);v.geometry.setColors(M.array),v.material.vertexColors=!0}else{var E=T,C=vx(E);v.material.color=new lb.Color(_x(E)),v.material.transparent=C<1,v.material.opacity=C,v.material.vertexColors=!1}v.material.needsUpdate=!0}else{Object.assign(v.material.uniforms,{dashSize:{value:o(d)},gapSize:{value:l(d)},dashOffset:{value:u(d)}});var R=A(a(d),y.length),N=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[],i=0,s=e+1;i0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;qy(this,t),(e=Fy(this,t)).type="CircleLineGeometry",e.parameters={radius:n,segmentCount:r};for(var i=[],s=0;s<=r;s++){var a=(s/r-.25)*Math.PI*2;i.push({x:Math.cos(a)*n,y:Math.sin(a)*n,z:0})}return e.setFromPoints(i),e}return Yy(t,e),jy(t)}((window.THREE?window.THREE:{BufferGeometry:Zr}).BufferGeometry),gb=window.THREE?window.THREE:{Color:Rr,Group:as,Line:Yi,LineBasicMaterial:Gi,Vector3:on},_b=o_.default||o_,vb=Mc({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,n){var r=n.tweenGroup;ox(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Mx(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj((function(){var e=new gb.Group;return e.__globeObjType="ring",e})),t.ticker=new _b,t.ticker.onTick.add((function(e){if(t.ringsData.length){var n=ig(t.ringColor),r=ig(t.ringAltitude),i=ig(t.ringMaxRadius),s=ig(t.ringPropagationSpeed),a=ig(t.ringRepeatPeriod);t.dataMapper.entries().filter((function(e){return ex(e,2)[1]})).forEach((function(o){var l,u,c=ex(o,2),A=c[0],h=c[1];if((h.__nextRingTime||0)<=e){var d=a(A)/1e3;h.__nextRingTime=e+(d<=0?1/0:d);var p,f=new gb.Line(new mb(1,t.ringResolution),new gb.LineBasicMaterial),m=n(A),g=m instanceof Array||m instanceof Function;g?m instanceof Array?(p=Mh().domain(m.map((function(e,t){return t/(m.length-1)}))).range(m),f.material.transparent=m.some((function(e){return vx(e)<1}))):(p=m,f.material.transparent=!0):(f.material.color=new gb.Color(_x(m)),l=f.material,u=vx(m),l.opacity=u,l.transparent=u<1,l.depthWrite=u>=1);var _=ux*(1+r(A)),v=i(A),y=v*Math.PI/180,x=s(A),b=x<=0,S=function(e){var t=e.t,n=(b?1-t:t)*y;if(f.scale.x=f.scale.y=_*Math.sin(n),f.position.z=_*(1-Math.cos(n)),g){var r=p(t);f.material.color=new gb.Color(_x(r)),f.material.transparent&&(f.material.opacity=vx(r))}};if(0===x)S({t:0}),h.add(f);else{var w=1e3*Math.abs(v/x);t.tweenGroup.add(new Lc({t:0}).to({t:1},w).onUpdate(S).onStart((function(){return h.add(f)})).onComplete((function(){h.remove(f),ax(f)})).start())}}}))}}))},update:function(e){var t=ig(e.ringLat),n=ig(e.ringLng),r=ig(e.ringAltitude),i=e.scene.localToWorld(new gb.Vector3(0,0,0));e.dataMapper.onUpdateObj((function(e,s){var a=t(s),o=n(s),l=r(s);Object.assign(e.position,Ax(a,o,l)),e.lookAt(i)})).digest(e.ringsData)}}),yb={glyphs:{0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},"ο":{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},"Τ":{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},"Π":{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},"ΐ":{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},"Κ":{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},"ƒ":{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},"ό":{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},"ώ":{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},"ÿ":{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},"µ":{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},"Ι":{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},"Ύ":{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},"Ν":{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},"ς":{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},"Ψ":{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},"ι":{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},"Ά":{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},"ε":{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},"Δ":{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},"ρ":{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},"Η":{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},"Α":{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},"ν":{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},"β":{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},"Μ":{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},"Ό":{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"Ή":{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},"γ":{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},"α":{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},"Χ":{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},"Ξ":{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},"Ϋ":{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},"Ί":{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},"Β":{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},"υ":{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},"χ":{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},"ί":{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},"Ζ":{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},"δ":{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},"έ":{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},"ω":{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"ϋ":{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},"Ω":{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},"ύ":{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},"ή":{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},"Θ":{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},"Ε":{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},"σ":{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},"ζ":{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},"θ":{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},"Ο":{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},"Γ":{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},"Έ":{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"Ώ":{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},"Ϊ":{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},"Ρ":{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},"ª":{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},"Φ":{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},"Σ":{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},"λ":{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},"τ":{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},"ξ":{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},"Λ":{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},"ΰ":{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},"Υ":{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},"μ":{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},"φ":{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},"ϊ":{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},"π":{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},"ά":{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},"κ":{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},"ψ":{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},"η":{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},cssFontWeight:"normal",ascender:1189,underlinePosition:-100,cssFontStyle:"normal",boundingBox:{yMin:-334,xMin:-111,yMax:1189,xMax:1672},resolution:1e3,original_font_information:{postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:'Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r\n\r\nThe above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r\n\r\nThe Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r\n\r\nThis License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r\n\r\nThe Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r\n\r\nTHE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.',manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},descender:-334,familyName:"Helvetiker",lineHeight:1522,underlineThickness:50},xb=Zy(Zy({},window.THREE?window.THREE:{BoxGeometry:hi,CircleGeometry:Cs,DoubleSide:2,Group:as,Mesh:ci,MeshLambertMaterial:_a,TextGeometry:Iy,Vector3:on}),{},{Font:class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],r=function(e,t,n){const r=Array.from(e),i=t/n.resolution,s=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,a=[];let o=0,l=0;for(let e=0;e1?t-1:0),r=1;r1?t-1:0),r=1;r2&&void 0!==arguments[2]&&arguments[2],n=function(n){function r(){var n;qy(this,r);for(var i=arguments.length,s=new Array(i),a=0;a1&&void 0!==arguments[1]?arguments[1]:Object);return Object.keys(e()).forEach((function(e){return n.prototype[e]=function(){var t,n=(t=this.__kapsuleInstance)[e].apply(t,arguments);return n===this.__kapsuleInstance?this:n}})),n}(oS,(window.THREE?window.THREE:{Group:as}).Group,!0);const uS=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class cS{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=uS,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.nodes.modelViewMatrix||null!==e.renderer.nodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];null!=r&&("object"==typeof r&&void 0!==r.clone?!0===r.isTexture?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const s=i.material;for(const e in s){const t=s[e],r=n[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 s[e]=r,!1}if(s.transmission>0){const{width:t,height:n}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==n)return i.bufferWidth=t,i.bufferHeight=n,!1}const a=i.geometry,o=r.attributes,l=a.attributes,u=Object.keys(l),c=Object.keys(o);if(u.length!==c.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of u){const t=l[e],n=o[e];if(void 0===n)return delete l[e],!1;if(t.version!==n.version)return t.version=n.version,!1}const A=r.index,h=a.indexVersion,d=A?A.version:null;if(h!==d)return a.indexVersion=d,!1;if(a.drawRange.start!==r.drawRange.start||a.drawRange.count!==r.drawRange.count)return a.drawRange.start=r.drawRange.start,a.drawRange.count=r.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let n=0;n>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const hS=e=>AS(e),dS=(...e)=>AS(e);function pS(e,t=!1){const n=[];!0===e.isNode&&(n.push(e.id),e=e.getSelf());for(const{property:r,childNode:i}of fS(e))n.push(n,AS(r.slice(0,-4)),i.getCacheKey(t));return AS(n)}function*fS(e,t=!1){for(const n in e){if(!0===n.startsWith("_"))continue;const r=e[n];if(!0===Array.isArray(r))for(let e=0;ee.charCodeAt(0))).buffer):null;var r}function yS(e){let t=gS.get(e);return void 0===t&&(t={},gS.set(e,t)),t}const xS="vertex",bS="none",SS="frame",wS="render",TS="object",MS="readOnly",ES="writeOnly",CS="readWrite",RS=["setup","analyze","generate"],NS=["fragment","vertex","compute"],PS=["x","y","z","w"];let DS=0;class LS extends xt{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=bS,this.updateBeforeType=bS,this.updateAfterType=bS,this.uuid=Dt.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:DS++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,SS)}onRenderUpdate(e){return this.onUpdate(e,wS)}onObjectUpdate(e){return this.onUpdate(e,TS)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of fS(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=dS(pS(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const e of this.getChildren())t["node"+n++]=e;return t.outputNode||null}analyze(e){if(1===e.increaseUsage(this)){const t=e.getNodeProperties(this);for(const n of Object.values(t))n&&!0===n.isNode&&n.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&!0===n.isNode)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null;const i=e.getBuildStage();if("setup"===i){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0;const n=this.setup(e),r=n&&!0===n.isNode;for(const n of Object.values(t))n&&!0===n.isNode&&n.build(e);r&&n.build(e),t.outputNode=n}}else if("analyze"===i)this.analyze(e);else if("generate"===i){if(1===this.generate.length){const n=this.getNodeType(e),i=e.getDataFromNode(this);r=i.snippet,void 0===r?(r=this.generate(e)||"",i.snippet=r):void 0!==i.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,n,t)}else r=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return fS(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:i,childNode:s}of t)void 0!==i?(void 0===n[r]&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=s.toJSON(e.meta).uuid):n[r]=s.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if("object"==typeof e.inputNodes[n]){const r={};for(const i in e.inputNodes[n]){const s=e.inputNodes[n][i];r[i]=t[s]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=void 0===e||"string"==typeof e;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function s(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(void 0===i&&(i={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},!0!==r&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),r){const t=s(e.textures),n=s(e.images),r=s(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}}class IS extends LS{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){return`${this.node.build(e)}[ ${this.indexNode.build(e,"uint")} ]`}}class US extends LS{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))null!==n&&e.getTypeLength(t)!==e.getTypeLength(r)||(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}}class BS extends LS{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 n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(void 0!==r.propertyName)return e.format(r.propertyName,n,t);if("void"!==n&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,n),s=e.getVarFromNode(this,null,n),a=e.getPropertyName(s);return e.addLineFlowCode(`${a} = ${i}`,this),r.snippet=i,r.propertyName=a,e.format(r.propertyName,n,t)}}return super.build(e,t)}}class OS extends BS{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,n)=>t+e.getTypeLength(n.getNodeType(e))),0))}generate(e,t){const n=this.getNodeType(e),r=this.nodes,i=e.getComponentType(n),s=[];for(const t of r){let n=t.build(e);const r=e.getComponentType(t.getNodeType(e));r!==i&&(n=e.format(n,r,i)),s.push(n)}const a=`${e.getType(n)}( ${s.join(", ")} )`;return e.format(a,n,t)}}const FS=PS.join("");class kS extends LS{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(PS.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let i=null;if(r>1){let s=null;this.getVectorLength()>=r&&(s=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=n.build(e,s);i=this.components.length===r&&this.components===FS.slice(0,this.components.length)?e.format(a,s,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class qS extends BS{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),s=e.getComponentType(r.getNodeType(e)),a=e.getTypeFromLength(n.length,s),o=r.build(e,a),l=t.build(e,i),u=e.getTypeLength(i),c=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),QS=e=>XS(e).split("").sort().join(""),YS={setup(e,t){const n=t.shift();return e(vw(n),...t)},get(e,t,n){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(HS.assign(n,...e),n);if(jS.has(t)){const r=jS.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&jS.has(t.slice(0,t.length-6))){const r=jS.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=XS(t),_w(new kS(n,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=QS(t.slice(3).toLowerCase()),n=>_w(new qS(e,t,n));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=QS(t.slice(4).toLowerCase()),()=>_w(new GS(_w(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),_w(new kS(e,t));if(!0===/^\d+$/.test(t))return _w(new IS(n,new VS(Number(t),"uint")))}return Reflect.get(e,t,n)},set:(e,t,n,r)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,n,r):(r[t].assign(n),!0)},$S=new WeakMap,KS=new WeakMap,ZS=function(e,t=null){for(const n in e)e[n]=_w(e[n],t);return e},JS=function(e,t=null){const n=e.length;for(let r=0;r_w(null!==r?Object.assign(e,r):e);return null===t?(...t)=>i(new e(...yw(t))):null!==n?(n=_w(n),(...r)=>i(new e(t,...yw(r),n))):(...n)=>i(new e(t,...yw(n)))},tw=function(e,...t){return _w(new e(...yw(t)))};class nw extends LS{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let i=null;if(t.layout){let r=KS.get(e.constructor);void 0===r&&(r=new WeakMap,KS.set(e.constructor,r));let s=r.get(t);void 0===s&&(s=_w(e.buildFunctionNode(t)),r.set(t,s)),null!==e.currentFunctionNode&&e.currentFunctionNode.includes.push(s),i=_w(s.call(n))}else{const r=t.jsFunc,s=null!==n?r(n,e):r(e);i=_w(s)}return t.once&&(r.onceOutput=i),i}getOutputNode(e){const t=e.getNodeProperties(this);return null===t.outputNode&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class rw extends LS{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return vw(e),_w(new nw(this,e))}setup(){return this.call()}}const iw=[!1,!0],sw=[0,1,2,3],aw=[-1,-2],ow=[.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],lw=new Map;for(const e of iw)lw.set(e,new VS(e));const uw=new Map;for(const e of sw)uw.set(e,new VS(e,"uint"));const cw=new Map([...uw].map((e=>new VS(e.value,"int"))));for(const e of aw)cw.set(e,new VS(e,"int"));const Aw=new Map([...cw].map((e=>new VS(e.value))));for(const e of ow)Aw.set(e,new VS(e));for(const e of ow)Aw.set(-e,new VS(-e));const hw={bool:lw,uint:uw,ints:cw,float:Aw},dw=new Map([...lw,...Aw]),pw=(e,t)=>dw.has(e)?dw.get(e):!0===e.isNode?e:new VS(e,t),fw=function(e,t=null){return(...n)=>{if((0===n.length||!["bool","float","int","uint"].includes(e)&&n.every((e=>"object"!=typeof e)))&&(n=[vS(e,...n)]),1===n.length&&null!==t&&t.has(n[0]))return _w(t.get(n[0]));if(1===n.length){const t=pw(n[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?_w(t):_w(new US(t,e))}const r=n.map((e=>pw(e)));return _w(new OS(r,e))}},mw=e=>"object"==typeof e&&null!==e?e.value:e;function gw(e,t){return new Proxy(new rw(e,t),YS)}const _w=(e,t=null)=>function(e,t=null){const n=_S(e);if("node"===n){let t=$S.get(e);return void 0===t&&(t=new Proxy(e,YS),$S.set(e,t),$S.set(t,t)),t}return null===t&&("float"===n||"boolean"===n)||n&&"shader"!==n&&"string"!==n?_w(pw(e,t)):"shader"===n?Sw(e):e}(e,t),vw=(e,t=null)=>new ZS(e,t),yw=(e,t=null)=>new JS(e,t),xw=(...e)=>new ew(...e),bw=(...e)=>new tw(...e),Sw=(e,t)=>{const n=new gw(e,t),r=(...e)=>{let t;return vw(e),t=e[0]&&e[0].isNode?[...e]:e[0],n.call(t)};return r.shaderNode=n,r.setLayout=e=>(n.setLayout(e),r),r.once=()=>(n.once=!0,r),r};WS("toGlobal",(e=>(e.global=!0,e)));const ww=e=>{HS=e},Tw=()=>HS,Mw=(...e)=>HS.If(...e);WS("append",(function(e){return HS&&HS.add(e),e}));const Ew=new fw("color"),Cw=new fw("float",hw.float),Rw=new fw("int",hw.ints),Nw=new fw("uint",hw.uint),Pw=new fw("bool",hw.bool),Dw=new fw("vec2"),Lw=new fw("ivec2"),Iw=new fw("uvec2"),Uw=new fw("bvec2"),Bw=new fw("vec3"),Ow=new fw("ivec3"),Fw=new fw("uvec3"),kw=new fw("bvec3"),qw=new fw("vec4"),Gw=new fw("ivec4"),zw=new fw("uvec4"),Vw=new fw("bvec4"),Hw=new fw("mat2"),jw=new fw("mat3"),Ww=new fw("mat4");WS("toColor",Ew),WS("toFloat",Cw),WS("toInt",Rw),WS("toUint",Nw),WS("toBool",Pw),WS("toVec2",Dw),WS("toIVec2",Lw),WS("toUVec2",Iw),WS("toBVec2",Uw),WS("toVec3",Bw),WS("toIVec3",Ow),WS("toUVec3",Fw),WS("toBVec3",kw),WS("toVec4",qw),WS("toIVec4",Gw),WS("toUVec4",zw),WS("toBVec4",Vw),WS("toMat2",Hw),WS("toMat3",jw),WS("toMat4",Ww);WS("element",xw(IS)),WS("convert",((e,t)=>_w(new US(_w(e),t))));class Xw extends LS{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,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 Qw=e=>new Xw(e),Yw=(e,t=0)=>new Xw(e,!0,t),$w=Yw("frame"),Kw=Yw("render"),Zw=Qw("object");class Jw extends zS{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Zw}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate((t=>{const r=e(t,n);void 0!==r&&(this.value=r)}),t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let i=e.getNodeFromHash(r);void 0===i&&(e.setHashNode(this,r),i=this);const s=i.getInputType(e),a=e.getUniformFromNode(i,s,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,n,t)}}const eT=(e,t)=>{const n=(e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null)(t||e),r=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return _w(new Jw(r,n))};class tT extends LS{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}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 nT=(e,t)=>_w(new tT(e,t,!0)),rT=bw(tT,"vec4","DiffuseColor"),iT=bw(tT,"vec3","EmissiveColor"),sT=bw(tT,"float","Roughness"),aT=bw(tT,"float","Metalness"),oT=bw(tT,"float","Clearcoat"),lT=bw(tT,"float","ClearcoatRoughness"),uT=bw(tT,"vec3","Sheen"),cT=bw(tT,"float","SheenRoughness"),AT=bw(tT,"float","Iridescence"),hT=bw(tT,"float","IridescenceIOR"),dT=bw(tT,"float","IridescenceThickness"),pT=bw(tT,"float","AlphaT"),fT=bw(tT,"float","Anisotropy"),mT=bw(tT,"vec3","AnisotropyT"),gT=bw(tT,"vec3","AnisotropyB"),_T=bw(tT,"color","SpecularColor"),vT=bw(tT,"float","SpecularF90"),yT=bw(tT,"float","Shininess"),xT=bw(tT,"vec4","Output"),bT=bw(tT,"float","dashSize"),ST=bw(tT,"float","gapSize"),wT=bw(tT,"float","IOR"),TT=bw(tT,"float","Transmission"),MT=bw(tT,"float","Thickness"),ET=bw(tT,"float","AttenuationDistance"),CT=bw(tT,"color","AttenuationColor"),RT=bw(tT,"float","Dispersion");class NT extends BS{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}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 n=e.getTypeLength(t.node.getNodeType(e));return PS.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:r}=this,i=this.needsSplitAssign(e),s=n.getNodeType(e),a=n.context({assign:!0}).build(e),o=r.build(e,s),l=r.getNodeType(e),u=e.getDataFromNode(this);let c;if(!0===u.initialized)"void"!==t&&(c=a);else if(i){const r=e.getVarFromNode(this,null,s),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${o}`,this);const l=n.node.context({assign:!0}).build(e);for(let t=0;t{const r=n.type;let i;return i="pointer"===r?"&"+t.build(e):t.build(e,r),i};if(Array.isArray(i))for(let e=0;e(t=t.length>1||t[0]&&!0===t[0].isNode?yw(t):vw(t[0]),_w(new PT(_w(e),t)))));class DT extends BS{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let i=new DT(e,t,n);for(let t=0;t>"===n||"<<"===n)return e.getIntegerType(s);if("!"===n||"=="===n||"&&"===n||"||"===n||"^^"===n)return"bool";if("<"===n||">"===n||"<="===n||">="===n){const n=t?e.getTypeLength(t):Math.max(e.getTypeLength(s),e.getTypeLength(a));return n>1?`bvec${n}`:"bool"}return"float"===s&&e.isMatrix(a)?a:e.isMatrix(s)&&e.isVector(a)?e.getVectorFromMatrix(s):e.isVector(s)&&e.isMatrix(a)?e.getVectorFromMatrix(a):e.getTypeLength(a)>e.getTypeLength(s)?a:s}generate(e,t){const n=this.op,r=this.aNode,i=this.bNode,s=this.getNodeType(e,t);let a=null,o=null;"void"!==s?(a=r.getNodeType(e),o=void 0!==i?i.getNodeType(e):null,"<"===n||">"===n||"<="===n||">="===n||"=="===n?e.isVector(a)?o=a:a!==o&&(a=o="float"):">>"===n||"<<"===n?(a=s,o=e.changeComponentType(o,"uint")):e.isMatrix(a)&&e.isVector(o)?o=e.getVectorFromMatrix(a):a=e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):o=s):a=o=s;const l=r.build(e,a),u=void 0!==i?i.build(e,o):null,c=e.getTypeLength(t),A=e.getFunctionOperator(n);return"void"!==t?"<"===n&&c>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${l}, ${u} )`,s,t):e.format(`( ${l} < ${u} )`,s,t):"<="===n&&c>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${l}, ${u} )`,s,t):e.format(`( ${l} <= ${u} )`,s,t):">"===n&&c>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${l}, ${u} )`,s,t):e.format(`( ${l} > ${u} )`,s,t):">="===n&&c>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${l}, ${u} )`,s,t):e.format(`( ${l} >= ${u} )`,s,t):"!"===n||"~"===n?e.format(`(${n}${l})`,a,t):A?e.format(`${A}( ${l}, ${u} )`,s,t):e.format(`( ${l} ${n} ${u} )`,s,t):"void"!==a?A?e.format(`${A}( ${l}, ${u} )`,s,t):e.format(`${l} ${n} ${u}`,s,t):void 0}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const LT=xw(DT,"+"),IT=xw(DT,"-"),UT=xw(DT,"*"),BT=xw(DT,"/"),OT=xw(DT,"%"),FT=xw(DT,"=="),kT=xw(DT,"!="),qT=xw(DT,"<"),GT=xw(DT,">"),zT=xw(DT,"<="),VT=xw(DT,">="),HT=xw(DT,"&&"),jT=xw(DT,"||"),WT=xw(DT,"!"),XT=xw(DT,"^^"),QT=xw(DT,"&"),YT=xw(DT,"~"),$T=xw(DT,"|"),KT=xw(DT,"^"),ZT=xw(DT,"<<"),JT=xw(DT,">>");WS("add",LT),WS("sub",IT),WS("mul",UT),WS("div",BT),WS("modInt",OT),WS("equal",FT),WS("notEqual",kT),WS("lessThan",qT),WS("greaterThan",GT),WS("lessThanEqual",zT),WS("greaterThanEqual",VT),WS("and",HT),WS("or",jT),WS("not",WT),WS("xor",XT),WS("bitAnd",QT),WS("bitNot",YT),WS("bitOr",$T),WS("bitXor",KT),WS("shiftLeft",ZT),WS("shiftRight",JT);WS("remainder",((...e)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),OT(...e))));class eM extends BS{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),s=e.isMatrix(n)?0:e.getTypeLength(n),a=e.isMatrix(r)?0:e.getTypeLength(r);return i>s&&i>a?t:s>a?n:a>i?r:t}getNodeType(e){const t=this.method;return t===eM.LENGTH||t===eM.DISTANCE||t===eM.DOT?"float":t===eM.CROSS?"vec3":t===eM.ALL?"bool":t===eM.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===eM.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let n=this.method;const r=this.getNodeType(e),i=this.getInputType(e),s=this.aNode,a=this.bNode,o=this.cNode,l=e.renderer.coordinateSystem;if(n===eM.TRANSFORM_DIRECTION){let n=s,r=a;e.isMatrix(n.getNodeType(e))?r=qw(Bw(r),0):n=qw(Bw(n),0);const i=UT(n,r).xyz;return fM(i).build(e,t)}if(n===eM.NEGATE)return e.format("( - "+s.build(e,i)+" )",r,t);if(n===eM.ONE_MINUS)return IT(1,s).build(e,t);if(n===eM.RECIPROCAL)return BT(1,s).build(e,t);if(n===eM.DIFFERENCE)return SM(IT(s,a)).build(e,t);{const u=[];return n===eM.CROSS||n===eM.MOD?u.push(s.build(e,r),a.build(e,r)):l===vt&&n===eM.STEP?u.push(s.build(e,1===e.getTypeLength(s.getNodeType(e))?"float":i),a.build(e,i)):l===vt&&(n===eM.MIN||n===eM.MAX)||n===eM.MOD?u.push(s.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)):n===eM.REFRACT?u.push(s.build(e,i),a.build(e,i),o.build(e,"float")):n===eM.MIX?u.push(s.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(l===yt&&n===eM.ATAN&&null!==a&&(n="atan2"),u.push(s.build(e,i)),null!==a&&u.push(a.build(e,i)),null!==o&&u.push(o.build(e,i))),e.format(`${e.getMethod(n,r)}( ${u.join(", ")} )`,r,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}eM.ALL="all",eM.ANY="any",eM.RADIANS="radians",eM.DEGREES="degrees",eM.EXP="exp",eM.EXP2="exp2",eM.LOG="log",eM.LOG2="log2",eM.SQRT="sqrt",eM.INVERSE_SQRT="inversesqrt",eM.FLOOR="floor",eM.CEIL="ceil",eM.NORMALIZE="normalize",eM.FRACT="fract",eM.SIN="sin",eM.COS="cos",eM.TAN="tan",eM.ASIN="asin",eM.ACOS="acos",eM.ATAN="atan",eM.ABS="abs",eM.SIGN="sign",eM.LENGTH="length",eM.NEGATE="negate",eM.ONE_MINUS="oneMinus",eM.DFDX="dFdx",eM.DFDY="dFdy",eM.ROUND="round",eM.RECIPROCAL="reciprocal",eM.TRUNC="trunc",eM.FWIDTH="fwidth",eM.TRANSPOSE="transpose",eM.BITCAST="bitcast",eM.EQUALS="equals",eM.MIN="min",eM.MAX="max",eM.MOD="mod",eM.STEP="step",eM.REFLECT="reflect",eM.DISTANCE="distance",eM.DIFFERENCE="difference",eM.DOT="dot",eM.CROSS="cross",eM.POW="pow",eM.TRANSFORM_DIRECTION="transformDirection",eM.MIX="mix",eM.CLAMP="clamp",eM.REFRACT="refract",eM.SMOOTHSTEP="smoothstep",eM.FACEFORWARD="faceforward";const tM=Cw(1e-6),nM=Cw(Math.PI),rM=xw(eM,eM.ALL),iM=xw(eM,eM.ANY),sM=xw(eM,eM.RADIANS),aM=xw(eM,eM.DEGREES),oM=xw(eM,eM.EXP),lM=xw(eM,eM.EXP2),uM=xw(eM,eM.LOG),cM=xw(eM,eM.LOG2),AM=xw(eM,eM.SQRT),hM=xw(eM,eM.INVERSE_SQRT),dM=xw(eM,eM.FLOOR),pM=xw(eM,eM.CEIL),fM=xw(eM,eM.NORMALIZE),mM=xw(eM,eM.FRACT),gM=xw(eM,eM.SIN),_M=xw(eM,eM.COS),vM=xw(eM,eM.TAN),yM=xw(eM,eM.ASIN),xM=xw(eM,eM.ACOS),bM=xw(eM,eM.ATAN),SM=xw(eM,eM.ABS),wM=xw(eM,eM.SIGN),TM=xw(eM,eM.LENGTH),MM=xw(eM,eM.NEGATE),EM=xw(eM,eM.ONE_MINUS),CM=xw(eM,eM.DFDX),RM=xw(eM,eM.DFDY),NM=xw(eM,eM.ROUND),PM=xw(eM,eM.RECIPROCAL),DM=xw(eM,eM.TRUNC),LM=xw(eM,eM.FWIDTH),IM=xw(eM,eM.TRANSPOSE);eM.BITCAST;const UM=xw(eM,eM.EQUALS),BM=xw(eM,eM.MIN),OM=xw(eM,eM.MAX),FM=xw(eM,eM.MOD),kM=xw(eM,eM.STEP),qM=xw(eM,eM.REFLECT),GM=xw(eM,eM.DISTANCE),zM=xw(eM,eM.DIFFERENCE),VM=xw(eM,eM.DOT),HM=xw(eM,eM.CROSS),jM=xw(eM,eM.POW),WM=xw(eM,eM.POW,2),XM=xw(eM,eM.POW,3),QM=xw(eM,eM.POW,4),YM=xw(eM,eM.TRANSFORM_DIRECTION),$M=xw(eM,eM.MIX),KM=(e,t=0,n=1)=>_w(new eM(eM.CLAMP,_w(e),_w(t),_w(n))),ZM=xw(eM,eM.REFRACT),JM=xw(eM,eM.SMOOTHSTEP),eE=xw(eM,eM.FACEFORWARD),tE=Sw((([e])=>{const t=VM(e.xy,Dw(12.9898,78.233)),n=FM(t,nM);return mM(gM(n).mul(43758.5453))}));WS("all",rM),WS("any",iM),WS("equals",UM),WS("radians",sM),WS("degrees",aM),WS("exp",oM),WS("exp2",lM),WS("log",uM),WS("log2",cM),WS("sqrt",AM),WS("inverseSqrt",hM),WS("floor",dM),WS("ceil",pM),WS("normalize",fM),WS("fract",mM),WS("sin",gM),WS("cos",_M),WS("tan",vM),WS("asin",yM),WS("acos",xM),WS("atan",bM),WS("abs",SM),WS("sign",wM),WS("length",TM),WS("lengthSq",(e=>VM(e,e))),WS("negate",MM),WS("oneMinus",EM),WS("dFdx",CM),WS("dFdy",RM),WS("round",NM),WS("reciprocal",PM),WS("trunc",DM),WS("fwidth",LM),WS("atan2",((e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),bM(e,t)))),WS("min",BM),WS("max",OM),WS("mod",FM),WS("step",kM),WS("reflect",qM),WS("distance",GM),WS("dot",VM),WS("cross",HM),WS("pow",jM),WS("pow2",WM),WS("pow3",XM),WS("pow4",QM),WS("transformDirection",YM),WS("mix",((e,t,n)=>$M(t,n,e))),WS("clamp",KM),WS("refract",ZM),WS("smoothstep",((e,t,n)=>JM(t,n,e))),WS("faceForward",eE),WS("difference",zM),WS("saturate",(e=>KM(e))),WS("cbrt",(e=>UT(wM(e),jM(SM(e),1/3)))),WS("transpose",IM),WS("rand",tE);class nE extends LS{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(null!==n){const t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,null!==r&&(e.getDataFromNode(r).parentNodeBlock=i);const s=e.getNodeProperties(this);s.condNode=t,s.ifNode=n.context({nodeBlock:n}),s.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(void 0!==r.nodeProperty)return r.nodeProperty;const{condNode:i,ifNode:s,elseNode:a}=e.getNodeProperties(this),o="void"!==t,l=o?((e,t)=>_w(new tT(e,t)))(n).build(e):"";r.nodeProperty=l;const u=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let c=s.build(e,n);if(c&&(c=o?l+" = "+c+";":"return "+c+";"),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,n);t&&(t=o?l+" = "+t+";":"return "+t+";"),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,n,t)}}const rE=xw(nE);WS("select",rE);WS("cond",((...e)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),rE(...e))));class iE extends LS{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const sE=xw(iE);WS("context",sE),WS("label",((e,t)=>sE(e,{label:t})));class aE extends LS{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),i=e.getPropertyName(r),s=t.build(e,r.type);return e.addLineFlowCode(`${i} = ${s}`,this),i}}const oE=xw(aE);WS("toVar",((...e)=>oE(...e).append()));WS("temp",(e=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),oE(e))));class lE extends LS{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(void 0===n){const r=this.name,i=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,i),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation="fragment"===e.shaderStage),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r="fragment"===e.shaderStage&&!0===t.reassignPosition&&e.context.needsPositionReassign;if(void 0===t.propertyName||r){const i=this.getNodeType(e),s=e.getPropertyName(n,xS);e.flowNodeFromShaderStage(xS,this.node,i,s),t.propertyName=s,r?t.reassignPosition=!1:void 0===t.reassignPosition&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const uE=xw(lE);WS("varying",uE),WS("vertexStage",(e=>uE(e)));const cE=Sw((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045);return $M(t,n,r)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),AE=Sw((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308);return $M(t,n,r)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),hE="WorkingColorSpace",dE="OutputColorSpace";class pE extends BS{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===hE?Ht.workingColorSpace:t===dE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let i=t;return!1!==Ht.enabled&&n!==r&&n&&r?(Ht.getTransfer(n)===at&&(i=qw(cE(i.rgb),i.a)),Ht.getPrimaries(n)!==Ht.getPrimaries(r)&&(i=qw(jw(Ht._getMatrix(new It,n,r)).mul(i.rgb),i.a)),Ht.getTransfer(r)===at&&(i=qw(AE(i.rgb),i.a)),i):i}}const fE=(e,t)=>_w(new pE(_w(e),t,hE));WS("toOutputColorSpace",(e=>_w(new pE(_w(e),hE,dE)))),WS("toWorkingColorSpace",(e=>_w(new pE(_w(e),dE,hE)))),WS("workingToColorSpace",((e,t)=>_w(new pE(_w(e),hE,t)))),WS("colorSpaceToWorking",fE);let mE=class extends IS{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),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class gE extends LS{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=TS}setGroup(e){return this.group=e,this}element(e){return _w(new mE(this,_w(e)))}setNodeType(e){const t=eT(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let e=1;e_w(new _E(e,t,n));class yE extends BS{static get type(){return"ToneMappingNode"}constructor(e,t=xE,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return dS(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(0===n)return t;let r=null;const i=e.renderer.library.getToneMappingFunction(n);return null!==i?r=qw(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const xE=vE("toneMappingExposure","float");WS("toneMapping",((e,t,n)=>((e,t,n)=>_w(new yE(e,_w(t),_w(n))))(t,n,e)));class bE extends zS{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=mt,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,s=this.bufferOffset,a=!0===n.isInterleavedBuffer?n:new Ci(n,i),o=new Ni(a,r,s);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=r,i=r;else{i=uE(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const SE=(e,t=null,n=0,r=0)=>_w(new bE(e,t,n,r)),wE=(e,t=null,n=0,r=0)=>SE(e,t,n,r).setInstanced(!0),TE=(e,t=null,n=0,r=0)=>((e,t=null,n=0,r=0)=>SE(e,t,n,r).setUsage(gt))(e,t,n,r).setInstanced(!0);WS("toAttribute",(e=>SE(e.value)));class ME extends LS{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=TS,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let e=1;e_w(new ME(_w(e),t,n))));class EE extends LS{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const i=this.node.build(e,...t);return e.setCache(n),i}}const CE=(e,t)=>_w(new EE(_w(e),t));WS("cache",CE);class RE extends LS{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)}}WS("bypass",xw(RE));class NE extends LS{static get type(){return"RemapNode"}constructor(e,t,n,r=Cw(0),i=Cw(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:s}=this;let a=e.sub(t).div(n.sub(t));return!0===s&&(a=a.clamp()),a.mul(i.sub(r)).add(r)}}const PE=xw(NE,null,null,{doClamp:!1}),DE=xw(NE);WS("remap",PE),WS("remapClamp",DE);class LE extends LS{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if("void"!==n)return e.format(`( ${r} )`,n,t);e.addLineFlowCode(r,this)}}const IE=xw(LE);WS("discard",(e=>(e?rE(e,IE("discard")):IE("discard")).append()));class UE extends BS{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||0,r=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||nt;return 0!==n&&(t=t.toneMapping(n)),r!==nt&&r!==Ht.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}WS("renderOutput",((e,t=null,n=null)=>_w(new UE(_w(e),t,n))));class BE extends LS{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 n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),s=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(s.name,i,n);return uE(this).build(e,n)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}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 OE=(e,t)=>_w(new BE(e,t)),FE=(e=0)=>OE("uv"+(e>0?e:""),"vec2");class kE extends LS{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const qE=xw(kE);class GE extends Jw{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=SS}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&void 0!==n.width){const{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}const zE=xw(GE);class VE extends Jw{static get type(){return"TextureNode"}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=bS,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===se?"uvec4":this.value.type===ie?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return FE(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=eT(this.value.matrix)),this._matrixUniform.mul(Bw(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?wS:bS,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&!0===n.flipY||!0===n.isRenderTargetTexture||!0===n.isFramebufferTexture||!0===n.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(Rw(qE(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||!0!==n.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;null!==r&&!0!==e.context.forceUVContext||!e.context.getUV||(r=e.context.getUV(this)),r||(r=this.getDefaultUV()),!0===this.updateMatrix&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,n,r,i,s,a,o){const l=this.value;let u;return u=r?e.generateTextureLevel(l,t,n,r,s):i?e.generateTextureBias(l,t,n,i,s):o?e.generateTextureGrad(l,t,n,o,s):a?e.generateTextureCompare(l,t,n,a,s):!1===this.sampler?e.generateTextureLoad(l,t,n,s):e.generateTexture(l,t,n,s),u}generate(e,t){const n=this.value,r=e.getNodeProperties(this),i=super.generate(e,"property");if("sampler"===t)return i+"_sampler";if(e.isReference(t))return i;{const s=e.getDataFromNode(this);let a=s.propertyName;if(void 0===a){const{uvNode:t,levelNode:n,biasNode:o,compareNode:l,depthNode:u,gradNode:c}=r,A=this.generateUV(e,t),h=n?n.build(e,"float"):null,d=o?o.build(e,"float"):null,p=u?u.build(e,"int"):null,f=l?l.build(e,"float"):null,m=c?[c[0].build(e,"vec2"),c[1].build(e,"vec2")]:null,g=e.getVarFromNode(this);a=e.getPropertyName(g);const _=this.generateSnippet(e,i,A,h,d,p,f,m);e.addLineFlowCode(`${a} = ${_}`,this),s.snippet=_,s.propertyName=a}let o=a;const l=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(o=fE(IE(o,l),n.colorSpace).setup(e).build(e,l)),e.format(o,l,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=_w(e),t.referenceNode=this.getSelf(),_w(t)}blur(e){const t=this.clone();return t.biasNode=_w(e).mul(zE(t)),t.referenceNode=this.getSelf(),_w(t)}level(e){const t=this.clone();return t.levelNode=_w(e),t.referenceNode=this.getSelf(),_w(t)}size(e){return qE(this,e)}bias(e){const t=this.clone();return t.biasNode=_w(e),t.referenceNode=this.getSelf(),_w(t)}compare(e){const t=this.clone();return t.compareNode=_w(e),t.referenceNode=this.getSelf(),_w(t)}grad(e,t){const n=this.clone();return n.gradNode=[_w(e),_w(t)],n.referenceNode=this.getSelf(),_w(n)}depth(e){const t=this.clone();return t.depthNode=_w(e),t.referenceNode=this.getSelf(),_w(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const HE=xw(VE),jE=(...e)=>HE(...e).setSampler(!1),WE=eT("float").label("cameraNear").setGroup(Kw).onRenderUpdate((({camera:e})=>e.near)),XE=eT("float").label("cameraFar").setGroup(Kw).onRenderUpdate((({camera:e})=>e.far)),QE=eT("mat4").label("cameraProjectionMatrix").setGroup(Kw).onRenderUpdate((({camera:e})=>e.projectionMatrix)),YE=eT("mat4").label("cameraViewMatrix").setGroup(Kw).onRenderUpdate((({camera:e})=>e.matrixWorldInverse)),$E=eT(new on).label("cameraPosition").setGroup(Kw).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)));class KE extends LS{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=TS,this._uniformNode=new Jw(null)}getNodeType(){const e=this.scope;return e===KE.WORLD_MATRIX?"mat4":e===KE.POSITION||e===KE.VIEW_POSITION||e===KE.DIRECTION||e===KE.SCALE?"vec3":void 0}update(e){const t=this.object3d,n=this._uniformNode,r=this.scope;if(r===KE.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===KE.POSITION)n.value=n.value||new on,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===KE.SCALE)n.value=n.value||new on,n.value.setFromMatrixScale(t.matrixWorld);else if(r===KE.DIRECTION)n.value=n.value||new on,t.getWorldDirection(n.value);else if(r===KE.VIEW_POSITION){const r=e.camera;n.value=n.value||new on,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(r.matrixWorldInverse)}}generate(e){const t=this.scope;return t===KE.WORLD_MATRIX?this._uniformNode.nodeType="mat4":t!==KE.POSITION&&t!==KE.VIEW_POSITION&&t!==KE.DIRECTION&&t!==KE.SCALE||(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}KE.WORLD_MATRIX="worldMatrix",KE.POSITION="position",KE.SCALE="scale",KE.VIEW_POSITION="viewPosition",KE.DIRECTION="direction",KE.DIRECTION,KE.WORLD_MATRIX;const ZE=xw(KE,KE.POSITION);KE.SCALE,KE.VIEW_POSITION;class JE extends KE{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const eC=bw(JE,JE.WORLD_MATRIX),tC=eT(new It).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),nC=Sw((e=>e.renderer.nodes.modelViewMatrix||rC)).once()().toVar("modelViewMatrix"),rC=YE.mul(eC),iC=OE("position","vec3"),sC=iC.varying("positionLocal"),aC=iC.varying("positionPrevious"),oC=eC.mul(sC).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),lC=sC.transformDirection(eC).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),uC=Sw((e=>e.context.setupPositionView()),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),cC=uC.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class AC extends LS{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===vt&&1===n.side?"false":e.getFrontFacing()}}const hC=Cw(bw(AC)).mul(2).sub(1),dC=OE("normal","vec3"),pC=Sw((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Bw(0,1,0)):dC),"vec3").once()().toVar("normalLocal"),fC=uC.dFdx().cross(uC.dFdy()).normalize().toVar("normalFlat"),mC=Sw((e=>{let t;return t=!0===e.material.flatShading?fC:uE(bC(pC),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),gC=uE(mC.transformDirection(YE),"v_normalWorld").normalize().toVar("normalWorld"),_C=Sw((e=>e.context.setupNormal()),"vec3").once()().mul(hC).toVar("transformedNormalView"),vC=_C.transformDirection(YE).toVar("transformedNormalWorld"),yC=Sw((e=>e.context.setupClearcoatNormal()),"vec3").once()().mul(hC).toVar("transformedClearcoatNormalView"),xC=Sw((([e,t=eC])=>{const n=jw(t),r=e.div(Bw(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz})),bC=Sw((([e],t)=>{const n=t.renderer.nodes.modelNormalViewMatrix;if(null!==n)return n.transformDirection(e);const r=tC.mul(e);return YE.transformDirection(r)})),SC=eT(0).onReference((({material:e})=>e)).onRenderUpdate((({material:e})=>e.refractionRatio)),wC=cC.negate().reflect(_C),TC=cC.negate().refract(_C,SC),MC=wC.transformDirection(YE).toVar("reflectVector"),EC=TC.transformDirection(YE).toVar("reflectVector");class CC extends VE{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===q?MC:e.mapping===G?EC:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Bw(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem!==yt&&n.isRenderTargetTexture?t:Bw(t.x.negate(),t.yz)}generateUV(e,t){return t.build(e,"vec3")}}const RC=xw(CC);class NC extends Jw{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const PC=(e,t,n)=>_w(new NC(e,t,n));class DC extends IS{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class LC extends NC{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?_S(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=wS,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,n=this.elementType;if("float"===n||"int"===n||"uint"===n)for(let n=0;n_w(new LC(e,t));class UC extends IS{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),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class BC extends LS{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=TS}element(e){return _w(new UC(this,_w(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?PC(null,e,this.count):Array.isArray(this.getValueFromReference())?IC(null,e):"texture"===e?HE(null):"cubeTexture"===e?RC(null):eT(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let e=1;e_w(new BC(e,t,n)),FC=(e,t,n,r)=>_w(new BC(e,t,r,n));class kC extends BC{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const qC=(e,t,n=null)=>_w(new kC(e,t,n)),GC=Sw((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),OE("tangent","vec4"))))(),zC=GC.xyz.toVar("tangentLocal"),VC=nC.mul(qw(zC,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView");var HC;const jC=jw(VC,uE((HC=mC.cross(VC),HC.mul(GC.w).xyz),"v_bitangentView").normalize().toVar("bitangentView"),mC),WC=(()=>{let e=gT.cross(cC);return e=e.cross(gT).normalize(),e=$M(e,_C,fT.mul(sT.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),XC=Sw((e=>{const{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,s=t.dFdx(),a=t.dFdy(),o=i.dFdx(),l=i.dFdy(),u=n,c=a.cross(u),A=u.cross(s),h=c.mul(o.x).add(A.mul(l.x)),d=c.mul(o.y).add(A.mul(l.y)),p=h.dot(h).max(d.dot(d)),f=hC.mul(p.inverseSqrt());return LT(h.mul(r.x,f),d.mul(r.y,f),u.mul(r.z)).normalize()}));class QC extends BS{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=0}setup(e){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);null!==n&&(r=Bw(r.xy.mul(n),r.z));let i=null;if(1===t)i=bC(r);else if(0===t){i=!0===e.hasGeometryAttribute("tangent")?jC.mul(r).normalize():XC({eye_pos:uC,surf_norm:mC,mapN:r,uv:FE()})}return i}}const YC=xw(QC),$C=Sw((({textureNode:e,bumpScale:t})=>{const n=t=>e.cache().context({getUV:e=>t(e.uvNode||FE()),forceUVContext:!0}),r=Cw(n((e=>e)));return Dw(Cw(n((e=>e.add(e.dFdx())))).sub(r),Cw(n((e=>e.add(e.dFdy())))).sub(r)).mul(t)})),KC=Sw((e=>{const{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),s=n,a=t.dFdy().normalize().cross(s),o=s.cross(i),l=i.dot(a).mul(hC),u=l.sign().mul(r.x.mul(a).add(r.y.mul(o)));return l.abs().mul(n).sub(u).normalize()}));class ZC extends BS{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=$C({textureNode:this.textureNode,bumpScale:e});return KC({surf_pos:uC,surf_norm:mC,dHdxy:t})}}const JC=xw(ZC),eR=new Map;class tR extends LS{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=eR.get(e);return void 0===n&&(n=qC(e,t),eR.set(e,n)),n}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,n=this.scope;let r=null;if(n===tR.COLOR){const e=void 0!==t.color?this.getColor(n):Bw();r=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(n===tR.OPACITY){const e=this.getFloat(n);r=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(n===tR.SPECULAR_STRENGTH)r=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Cw(1);else if(n===tR.SPECULAR_INTENSITY){const e=this.getFloat(n);r=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(n).a):e}else if(n===tR.SPECULAR_COLOR){const e=this.getColor(n);r=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(n).rgb):e}else if(n===tR.ROUGHNESS){const e=this.getFloat(n);r=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(n).g):e}else if(n===tR.METALNESS){const e=this.getFloat(n);r=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(n).b):e}else if(n===tR.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(n).mul(e);r=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(n)):i}else if(n===tR.NORMAL)t.normalMap?(r=YC(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):r=t.bumpMap?JC(this.getTexture("bump").r,this.getFloat("bumpScale")):mC;else if(n===tR.CLEARCOAT){const e=this.getFloat(n);r=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(n).r):e}else if(n===tR.CLEARCOAT_ROUGHNESS){const e=this.getFloat(n);r=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(n).r):e}else if(n===tR.CLEARCOAT_NORMAL)r=t.clearcoatNormalMap?YC(this.getTexture(n),this.getCache(n+"Scale","vec2")):mC;else if(n===tR.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));r=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(n===tR.SHEEN_ROUGHNESS){const e=this.getFloat(n);r=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(n).a):e,r=r.clamp(.07,1)}else if(n===tR.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(n);r=Hw(OR.x,OR.y,OR.y.negate(),OR.x).mul(e.rg.mul(2).sub(Dw(1)).normalize().mul(e.b))}else r=OR;else if(n===tR.IRIDESCENCE_THICKNESS){const e=OC("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=OC("0","float",t.iridescenceThicknessRange);r=e.sub(i).mul(this.getTexture(n).g).add(i)}else r=e}else if(n===tR.TRANSMISSION){const e=this.getFloat(n);r=t.transmissionMap?e.mul(this.getTexture(n).r):e}else if(n===tR.THICKNESS){const e=this.getFloat(n);r=t.thicknessMap?e.mul(this.getTexture(n).g):e}else if(n===tR.IOR)r=this.getFloat(n);else if(n===tR.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===tR.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const t=this.getNodeType(e);r=this.getCache(n,t)}return r}}tR.ALPHA_TEST="alphaTest",tR.COLOR="color",tR.OPACITY="opacity",tR.SHININESS="shininess",tR.SPECULAR="specular",tR.SPECULAR_STRENGTH="specularStrength",tR.SPECULAR_INTENSITY="specularIntensity",tR.SPECULAR_COLOR="specularColor",tR.REFLECTIVITY="reflectivity",tR.ROUGHNESS="roughness",tR.METALNESS="metalness",tR.NORMAL="normal",tR.CLEARCOAT="clearcoat",tR.CLEARCOAT_ROUGHNESS="clearcoatRoughness",tR.CLEARCOAT_NORMAL="clearcoatNormal",tR.EMISSIVE="emissive",tR.ROTATION="rotation",tR.SHEEN="sheen",tR.SHEEN_ROUGHNESS="sheenRoughness",tR.ANISOTROPY="anisotropy",tR.IRIDESCENCE="iridescence",tR.IRIDESCENCE_IOR="iridescenceIOR",tR.IRIDESCENCE_THICKNESS="iridescenceThickness",tR.IOR="ior",tR.TRANSMISSION="transmission",tR.THICKNESS="thickness",tR.ATTENUATION_DISTANCE="attenuationDistance",tR.ATTENUATION_COLOR="attenuationColor",tR.LINE_SCALE="scale",tR.LINE_DASH_SIZE="dashSize",tR.LINE_GAP_SIZE="gapSize",tR.LINE_WIDTH="linewidth",tR.LINE_DASH_OFFSET="dashOffset",tR.POINT_WIDTH="pointWidth",tR.DISPERSION="dispersion",tR.LIGHT_MAP="light",tR.AO="ao";const nR=bw(tR,tR.ALPHA_TEST),rR=bw(tR,tR.COLOR),iR=bw(tR,tR.SHININESS),sR=bw(tR,tR.EMISSIVE),aR=bw(tR,tR.OPACITY),oR=bw(tR,tR.SPECULAR),lR=bw(tR,tR.SPECULAR_INTENSITY),uR=bw(tR,tR.SPECULAR_COLOR),cR=bw(tR,tR.SPECULAR_STRENGTH),AR=bw(tR,tR.REFLECTIVITY),hR=bw(tR,tR.ROUGHNESS),dR=bw(tR,tR.METALNESS),pR=bw(tR,tR.NORMAL).context({getUV:null}),fR=bw(tR,tR.CLEARCOAT),mR=bw(tR,tR.CLEARCOAT_ROUGHNESS),gR=bw(tR,tR.CLEARCOAT_NORMAL).context({getUV:null}),_R=bw(tR,tR.ROTATION),vR=bw(tR,tR.SHEEN),yR=bw(tR,tR.SHEEN_ROUGHNESS),xR=bw(tR,tR.ANISOTROPY),bR=bw(tR,tR.IRIDESCENCE),SR=bw(tR,tR.IRIDESCENCE_IOR),wR=bw(tR,tR.IRIDESCENCE_THICKNESS),TR=bw(tR,tR.TRANSMISSION),MR=bw(tR,tR.THICKNESS),ER=bw(tR,tR.IOR),CR=bw(tR,tR.ATTENUATION_DISTANCE),RR=bw(tR,tR.ATTENUATION_COLOR),NR=bw(tR,tR.LINE_SCALE),PR=bw(tR,tR.LINE_DASH_SIZE),DR=bw(tR,tR.LINE_GAP_SIZE);tR.LINE_WIDTH;const LR=bw(tR,tR.LINE_DASH_OFFSET);tR.POINT_WIDTH;const IR=bw(tR,tR.DISPERSION),UR=bw(tR,tR.LIGHT_MAP),BR=bw(tR,tR.AO),OR=eT(new Lt).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))})),FR=Sw((e=>e.context.setupModelViewProjection()),"vec4").once()().varying("v_modelViewProjection");class kR extends LS{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r,i;if(n===kR.VERTEX)r=e.getVertexIndex();else if(n===kR.INSTANCE)r=e.getInstanceIndex();else if(n===kR.DRAW)r=e.getDrawIndex();else if(n===kR.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===kR.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else{if(n!==kR.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+n);r=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=r;else{i=uE(this).build(e,t)}return i}}kR.VERTEX="vertex",kR.INSTANCE="instance",kR.SUBGROUP="subgroup",kR.INVOCATION_LOCAL="invocationLocal",kR.INVOCATION_SUBGROUP="invocationSubgroup",kR.DRAW="draw";const qR=bw(kR,kR.VERTEX),GR=bw(kR,kR.INSTANCE);kR.SUBGROUP,kR.INVOCATION_SUBGROUP,kR.INVOCATION_LOCAL;const zR=bw(kR,kR.DRAW);class VR extends LS{static get type(){return"InstanceNode"}constructor(e,t,n){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=SS,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:n,instanceColor:r}=this;let{instanceMatrixNode:i,instanceColorNode:s}=this;if(null===i){if(t<=1e3)i=PC(n.array,"mat4",Math.max(t,1)).element(GR);else{const e=new Ja(n.array,16,1);this.buffer=e;const t=n.usage===gt?TE:wE,r=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=Ww(...r)}this.instanceMatrixNode=i}if(r&&null===s){const e=new Li(r.array,3),t=r.usage===gt?TE:wE;this.bufferColor=e,s=Bw(t(e,"vec3",3,0)),this.instanceColorNode=s}const a=i.mul(sC).xyz;if(sC.assign(a),e.hasGeometryAttribute("normal")){const e=xC(pC,i);pC.assign(e)}null!==this.instanceColorNode&&nT("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==gt&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==gt&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}class HR extends VR{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const jR=xw(HR);class WR extends LS{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=GR:this.batchingIdNode=zR);const t=Sw((([e])=>{const t=qE(jE(this.batchMesh._indirectTexture),0),n=Rw(e).modInt(Rw(t)),r=Rw(e).div(Rw(t));return jE(this.batchMesh._indirectTexture,Lw(n,r)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),n=t(Rw(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=qE(jE(r),0),s=Cw(n).mul(4).toInt().toVar(),a=s.modInt(i),o=s.div(Rw(i)),l=Ww(jE(r,Lw(a,o)),jE(r,Lw(a.add(1),o)),jE(r,Lw(a.add(2),o)),jE(r,Lw(a.add(3),o))),u=this.batchMesh._colorsTexture;if(null!==u){const e=Sw((([e])=>{const t=qE(jE(u),0).x,n=e,r=n.modInt(t),i=n.div(t);return jE(u,Lw(r,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(n);nT("vec3","vBatchColor").assign(t)}const c=jw(l);sC.assign(l.mul(sC));const A=pC.div(Bw(c[0].dot(c[0]),c[1].dot(c[1]),c[2].dot(c[2]))),h=c.mul(A).xyz;pC.assign(h),e.hasGeometryAttribute("tangent")&&zC.mulAssign(c)}}const XR=xw(WR),QR=new WeakMap;class YR extends LS{static get type(){return"SkinningNode"}constructor(e,t=!1){let n,r,i;super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=TS,this.skinIndexNode=OE("skinIndex","uvec4"),this.skinWeightNode=OE("skinWeight","vec4"),t?(n=OC("bindMatrix","mat4"),r=OC("bindMatrixInverse","mat4"),i=FC("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=eT(e.bindMatrix,"mat4"),r=eT(e.bindMatrixInverse,"mat4"),i=PC(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=i,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=sC){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:s}=this,a=e.element(n.x),o=e.element(n.y),l=e.element(n.z),u=e.element(n.w),c=i.mul(t),A=LT(a.mul(r.x).mul(c),o.mul(r.y).mul(c),l.mul(r.z).mul(c),u.mul(r.w).mul(c));return s.mul(A).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=pC){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:s}=this,a=e.element(n.x),o=e.element(n.y),l=e.element(n.z),u=e.element(n.w);let c=LT(r.x.mul(a),r.y.mul(o),r.z.mul(l),r.w.mul(u));return c=s.mul(c).mul(i),c.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=FC("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,aC)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===yS(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&aC.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(sC.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();pC.assign(t),e.hasGeometryAttribute("tangent")&&zC.assign(t)}}generate(e,t){if("void"!==t)return sC.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;QR.get(t)!==e.frameId&&(QR.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}class $R extends LS{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const n={};for(let e=0,t=this.params.length-1;eNumber(s)?">=":"<"));const c={start:i,end:s,condition:l},A=c.start,h=c.end;let d="",p="",f="";u||(u="int"===o||"uint"===o?l.includes("<")?"++":"--":l.includes("<")?"+= 1.":"-= 1."),d+=e.getVar(o,a)+" = "+A,p+=a+" "+l+" "+h,f+=a+" "+u;const m=`for ( ${d}; ${p}; ${f} )`;e.addFlowCode((0===t?"\n":"")+e.tab+m+" {\n\n").addFlowTab()}const i=r.build(e,"void"),s=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,n=this.params.length-1;t_w(new $R(yw(e,"int"))).append(),ZR=new WeakMap,JR=new en,eN=Sw((({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:s})=>{const a=Rw(qR).mul(n).add(s),o=a.div(r),l=a.sub(o.mul(r));return jE(e,Lw(l,o)).depth(i).mul(t)}));class tN extends LS{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=eT(1),this.updateType=TS}setup(e){const{geometry:t}=e,n=void 0!==t.morphAttributes.position,r=t.hasAttribute("normal")&&void 0!==t.morphAttributes.normal,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,s=void 0!==i?i.length:0,{texture:a,stride:o,size:l}=function(e){const t=void 0!==e.morphAttributes.position,n=void 0!==e.morphAttributes.normal,r=void 0!==e.morphAttributes.color,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,s=void 0!==i?i.length:0;let a=ZR.get(e);if(void 0===a||a.count!==s){void 0!==a&&a.texture.dispose();const o=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],u=e.morphAttributes.color||[];let c=0;!0===t&&(c=1),!0===n&&(c=2),!0===r&&(c=3);let A=e.attributes.position.count*c,h=1;const d=4096;A>d&&(h=Math.ceil(A/d),A=d);const p=new Float32Array(A*h*4*s),f=new rn(p,A,h,s);f.type=ae,f.needsUpdate=!0;const m=4*c;for(let _=0;_{const t=Cw(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(jE(this.mesh.morphTexture,Lw(Rw(e).add(1),Rw(GR))).r):t.assign(OC("morphTargetInfluences","float").element(e).toVar()),!0===n&&sC.addAssign(eN({bufferMap:a,influence:t,stride:o,width:u,depth:e,offset:Rw(0)})),!0===r&&pC.addAssign(eN({bufferMap:a,influence:t,stride:o,width:u,depth:e,offset:Rw(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 nN=xw(tN);class rN extends LS{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class iN extends rN{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class sN extends iE{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n={directDiffuse:Bw().toVar("directDiffuse"),directSpecular:Bw().toVar("directSpecular"),indirectDiffuse:Bw().toVar("indirectDiffuse"),indirectSpecular:Bw().toVar("indirectSpecular")};return{radiance:Bw().toVar("radiance"),irradiance:Bw().toVar("irradiance"),iblIrradiance:Bw().toVar("iblIrradiance"),ambientOcclusion:Cw(1).toVar("ambientOcclusion"),reflectedLight:n,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 aN=xw(sN);class oN extends rN{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let lN,uN;class cN extends LS{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===cN.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=bS;return this.scope!==cN.SIZE&&this.scope!==cN.VIEWPORT||(e=wS),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===cN.VIEWPORT?null!==t?uN.copy(t.viewport):(e.getViewport(uN),uN.multiplyScalar(e.getPixelRatio())):null!==t?(lN.width=t.width,lN.height=t.height):e.getDrawingBufferSize(lN)}setup(){const e=this.scope;let t=null;return t=e===cN.SIZE?eT(lN||(lN=new Lt)):e===cN.VIEWPORT?eT(uN||(uN=new en)):Dw(dN.div(hN)),t}generate(e){if(this.scope===cN.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(hN).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}cN.COORDINATE="coordinate",cN.VIEWPORT="viewport",cN.SIZE="size",cN.UV="uv";const AN=bw(cN,cN.UV),hN=bw(cN,cN.SIZE),dN=bw(cN,cN.COORDINATE),pN=bw(cN,cN.VIEWPORT);pN.zw,pN.xy;const fN=new Lt;class mN extends VE{static get type(){return"ViewportTextureNode"}constructor(e=AN,t=null,n=null){null===n&&((n=new os).minFilter=J),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=SS}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(fN);const n=this.value;n.image.width===fN.width&&n.image.height===fN.height||(n.image.width=fN.width,n.image.height=fN.height,n.needsUpdate=!0);const r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const gN=xw(mN,null,null,{generateMipmaps:!0});let _N=null;class vN extends mN{static get type(){return"ViewportDepthTextureNode"}constructor(e=AN,t=null){null===_N&&(_N=new ls),super(e,t,_N)}}const yN=xw(vN);class xN extends LS{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===xN.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===xN.DEPTH_BASE)null!==n&&(r=MN().assign(n));else if(t===xN.DEPTH)r=e.isPerspectiveCamera?SN(uC.z,WE,XE):bN(uC.z,WE,XE);else if(t===xN.LINEAR_DEPTH)if(null!==n)if(e.isPerspectiveCamera){const e=wN(n,WE,XE);r=bN(e,WE,XE)}else r=n;else r=bN(uC.z,WE,XE);return r}}xN.DEPTH_BASE="depthBase",xN.DEPTH="depth",xN.LINEAR_DEPTH="linearDepth";const bN=(e,t,n)=>e.add(t).div(t.sub(n)),SN=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),wN=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),TN=(e,t,n)=>{t=t.max(1e-6).toVar();const r=cM(e.negate().div(t)),i=cM(n.div(t));return r.div(i)},MN=xw(xN,xN.DEPTH_BASE),EN=bw(xN,xN.DEPTH);xN.LINEAR_DEPTH;yN(),EN.assign=e=>MN(e);const CN=xw(class extends LS{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}});class RN extends LS{static get type(){return"ClippingNode"}constructor(e=RN.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===RN.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===RN.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return Sw((()=>{const n=Cw().toVar("distanceToPlane"),r=Cw().toVar("distanceToGradient"),i=Cw(1).toVar("clipOpacity"),s=t.length;if(!1===this.hardwareClipping&&s>0){const e=IC(t);KR(s,(({i:t})=>{const s=e.element(t);n.assign(uC.dot(s.xyz).negate().add(s.w)),r.assign(n.fwidth().div(2)),i.mulAssign(JM(r.negate(),r,n))}))}const a=e.length;if(a>0){const t=IC(e),s=Cw(1).toVar("intersectionClipOpacity");KR(a,(({i:e})=>{const i=t.element(e);n.assign(uC.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),s.mulAssign(JM(r.negate(),r,n).oneMinus())})),i.mulAssign(s.oneMinus())}rT.a.mulAssign(i),rT.a.equal(0).discard()}))()}setupDefault(e,t){return Sw((()=>{const n=t.length;if(!1===this.hardwareClipping&&n>0){const e=IC(t);KR(n,(({i:t})=>{const n=e.element(t);uC.dot(n.xyz).greaterThan(n.w).discard()}))}const r=e.length;if(r>0){const t=IC(e),n=Pw(!0).toVar("clipped");KR(r,(({i:e})=>{const r=t.element(e);n.assign(uC.dot(r.xyz).greaterThan(r.w).and(n))})),n.discard()}}))()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Sw((()=>{const r=IC(e),i=CN(t.getClipDistance());KR(n,(({i:e})=>{const t=r.element(e),n=uC.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)}))}))()}}RN.ALPHA_TO_COVERAGE="alphaToCoverage",RN.DEFAULT="default",RN.HARDWARE="hardware";const NN=Sw((([e])=>mM(UT(1e4,gM(UT(17,e.x).add(UT(.1,e.y)))).mul(LT(.1,SM(gM(UT(13,e.y).add(e.x)))))))),PN=Sw((([e])=>NN(Dw(NN(e.xy),e.z)))),DN=Sw((([e])=>{const t=OM(TM(CM(e.xyz)),TM(RM(e.xyz))),n=Cw(1).div(Cw(.05).mul(t)).toVar("pixScale"),r=Dw(lM(dM(cM(n))),lM(pM(cM(n)))),i=Dw(PN(dM(r.x.mul(e.xyz))),PN(dM(r.y.mul(e.xyz)))),s=mM(cM(n)),a=LT(UT(s.oneMinus(),i.x),UT(s,i.y)),o=BM(s,s.oneMinus()),l=Bw(a.mul(a).div(UT(2,o).mul(IT(1,o))),a.sub(UT(.5,o)).div(IT(1,o)),IT(1,IT(1,a).mul(IT(1,a)).div(UT(2,o).mul(IT(1,o))))),u=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return KM(u,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class LN extends Dr{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.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+pS(this)}build(e){this.setup(e)}setupObserver(e){return new cS(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=this.vertexNode||this.setupVertex(e);let i;e.stack.outputNode=r,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const s=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==n?!0===n.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const r=this.setupLighting(e);null!==s&&e.stack.add(s);const a=qw(r,rT.a).max(0);if(i=this.setupOutput(e,a),xT.assign(i),null!==this.outputNode&&(i=this.outputNode),null!==n){const e=t.getMRT(),n=this.mrtNode;null!==e?(i=e,null!==n&&(i=e.merge(n))):null!==n&&(i=n)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=qw(t)),i=this.setupOutput(e,t)}e.stack.outputNode=i,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?r=_w(new RN(RN.ALPHA_TO_COVERAGE)):e.stack.add(_w(new RN))}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(_w(new RN(RN.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(null===r){const e=t.getMRT();e&&e.has("depth")?r=e.get("depth"):!0===t.logarithmicDepthBuffer&&(r=n.isPerspectiveCamera?TN(uC.z,WE,XE):bN(uC.z,WE,XE))}null!==r&&EN.assign(r).append()}setupPositionView(){return nC.mul(sC).xyz}setupModelViewProjection(){return QE.mul(uC)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),FR}setupPosition(e){const{object:t,geometry:n}=e;var r;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&nN(t).append(),!0===t.isSkinnedMesh&&(r=t,_w(new YR(r,!0))).append(),this.displacementMap){const e=qC("displacementMap","texture"),t=qC("displacementScale","float"),n=qC("displacementBias","float");sC.addAssign(pC.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&XR(t).append(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&jR(t).append(),null!==this.positionNode&&sC.assign(this.positionNode.context({isPositionNodeInput:!0})),sC}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?qw(this.colorNode):rR;if(!0===this.vertexColors&&t.hasAttribute("color")&&(n=qw(n.xyz.mul(OE("color","vec3")),n.a)),e.instanceColor){n=nT("vec3","vInstanceColor").mul(n)}if(e.isBatchedMesh&&e._colorsTexture){n=nT("vec3","vBatchColor").mul(n)}rT.assign(n);const r=this.opacityNode?Cw(this.opacityNode):aR;if(rT.a.assign(rT.a.mul(r)),null!==this.alphaTestNode||this.alphaTest>0){const e=null!==this.alphaTestNode?Cw(this.alphaTestNode):nR;rT.a.lessThanEqual(e).discard()}!0===this.alphaHash&&rT.a.lessThan(DN(sC)).discard(),!1===this.transparent&&1===this.blending&&!1===this.alphaToCoverage&&rT.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?Bw(0):rT.rgb}setupNormal(){return this.normalNode?Bw(this.normalNode):pR}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?qC("envMap","cubeTexture"):qC("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new oN(UR)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:BR;t.push(new iN(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=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);a=aN(s,t,n,r)}else null!==n&&(a=Bw(null!==r?$M(a,n,r):n));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(iT.assign(Bw(i||sR)),a=a.add(iT)),a}setupOutput(e,t){if(!0===this.fog){const n=e.fogNode;n&&(xT.assign(t),t=qw(n))}return t}setDefaultValues(e){for(const t in e){const n=e[t];void 0===this[t]&&(this[t]=n,n&&n.clone&&(this[t]=n.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 n=Dr.prototype.toJSON.call(this,e),r=fS(this);n.inputNodes={};for(const{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(t){const t=i(e.textures),r=i(e.images),s=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),s.length>0&&(n.nodes=s)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const IN=new Gi;class UN extends LN{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(IN),this.setValues(e)}}const BN=new ba;class ON extends LN{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(BN),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Cw(this.offsetNode):LR,t=this.dashScaleNode?Cw(this.dashScaleNode):NR,n=this.dashSizeNode?Cw(this.dashSizeNode):PR,r=this.gapSizeNode?Cw(this.gapSizeNode):DR;bT.assign(n),ST.assign(r);const i=uE(OE("lineDistance").mul(t));(e?i.add(e):i).mod(bT.add(ST)).greaterThan(bT).discard()}}const FN=new ga;class kN extends LN{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(FN),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Cw(this.opacityNode):aR;rT.assign(qw(_w(_C).mul(.5).add(.5),e))}}class qN extends BS{static get type(){return"EquirectUVNode"}constructor(e=lC){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Dw(t,n)}}const GN=xw(qN);class zN extends Mi{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=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 i=new hi(5,5,5),s=GN(lC),a=new LN;a.colorNode=HE(t,s,0),a.side=1,a.blending=0;const o=new ci(i,a),l=new Ei;l.add(o),t.minFilter===J&&(t.minFilter=K);const u=new wi(1,10,this),c=e.getMRT();return e.setMRT(null),u.update(e,l),e.setMRT(c),t.minFilter=n,t.currentGenerateMipmaps=r,o.geometry.dispose(),o.material.dispose(),this}}const VN=new WeakMap;class HN extends BS{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=RC();const t=new Ti;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=wS}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){const n=e.mapping;if(n===z||n===V){if(VN.has(e)){const t=VN.get(e);WN(t,e.mapping),this._cubeTexture=t}else{const n=e.image;if(function(e){return null!=e&&e.height>0}(n)){const r=new zN(n.height);r.fromEquirectangularTexture(t,e),WN(r.texture,e.mapping),this._cubeTexture=r.texture,VN.set(e,r.texture),e.addEventListener("dispose",jN)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function jN(e){const t=e.target;t.removeEventListener("dispose",jN);const n=VN.get(t);void 0!==n&&(VN.delete(t),n.dispose())}function WN(e,t){t===z?e.mapping=q:t===V&&(e.mapping=G)}const XN=xw(HN);class QN extends rN{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=XN(this.envNode)}}class YN extends rN{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Cw(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class $N{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class KN extends $N{constructor(){super()}indirect(e,t,n){const r=e.ambientOcclusion,i=e.reflectedLight,s=n.context.irradianceLightMap;i.indirectDiffuse.assign(qw(0)),s?i.indirectDiffuse.addAssign(s):i.indirectDiffuse.addAssign(qw(1,1,1,0)),i.indirectDiffuse.mulAssign(r),i.indirectDiffuse.mulAssign(rT.rgb)}finish(e,t,n){const r=n.material,i=e.outgoingLight,s=n.context.environment;if(s)switch(r.combine){case 0:i.rgb.assign($M(i.rgb,i.rgb.mul(s.rgb),cR.mul(AR)));break;case 1:i.rgb.assign($M(i.rgb,s.rgb,cR.mul(AR)));break;case 2:i.rgb.addAssign(s.rgb.mul(cR.mul(AR)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine)}}}const ZN=new Lr;class JN extends LN{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ZN),this.setValues(e)}setupNormal(){return mC}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new QN(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new YN(UR)),t}setupOutgoingLight(){return rT.rgb}setupLightingModel(){return new KN}}const eP=Sw((({f0:e,f90:t,dotVH:n})=>{const r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))})),tP=Sw((e=>e.diffuseColor.mul(1/Math.PI))),nP=Sw((({dotNH:e})=>yT.mul(Cw(.5)).add(1).mul(Cw(1/Math.PI)).mul(e.pow(yT)))),rP=Sw((({lightDirection:e})=>{const t=e.add(cC).normalize(),n=_C.dot(t).clamp(),r=cC.dot(t).clamp(),i=eP({f0:_T,f90:1,dotVH:r}),s=Cw(.25),a=nP({dotNH:n});return i.mul(s).mul(a)}));class iP extends KN{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const r=_C.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(tP({diffuseColor:rT.rgb}))),!0===this.specular&&n.directSpecular.addAssign(r.mul(rP({lightDirection:e})).mul(cR))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(tP({diffuseColor:rT}))),n.indirectDiffuse.mulAssign(e)}}const sP=new _a;class aP extends LN{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(sP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new QN(t):null}setupLightingModel(){return new iP(!1)}}const oP=new fa;class lP extends LN{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(oP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new QN(t):null}setupLightingModel(){return new iP}setupVariants(){const e=(this.shininessNode?Cw(this.shininessNode):iR).max(1e-4);yT.assign(e);const t=this.specularNode||oR;_T.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const uP=Sw((e=>{if(!1===e.geometry.hasAttribute("normal"))return Cw(0);const t=mC.dFdx().abs().max(mC.dFdy().abs());return t.x.max(t.y).max(t.z)})),cP=Sw((e=>{const{roughness:t}=e,n=uP();let r=t.max(.0525);return r=r.add(n),r=r.min(1),r})),AP=Sw((({alpha:e,dotNL:t,dotNV:n})=>{const r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),s=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return BT(.5,i.add(s).max(tM))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),hP=Sw((({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(Bw(e.mul(n),t.mul(r),a).length()),u=a.mul(Bw(e.mul(i),t.mul(s),o).length());return BT(.5,l.add(u)).saturate()})).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),dP=Sw((({alpha:e,dotNH:t})=>{const n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),pP=Cw(1/Math.PI),fP=Sw((({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{const s=e.mul(t),a=Bw(t.mul(r),e.mul(i),s.mul(n)),o=a.dot(a),l=s.div(o);return pP.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"}]}),mP=Sw((e=>{const{lightDirection:t,f0:n,f90:r,roughness:i,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,l=e.normalView||_C,u=i.pow2(),c=t.add(cC).normalize(),A=l.dot(t).clamp(),h=l.dot(cC).clamp(),d=l.dot(c).clamp(),p=cC.dot(c).clamp();let f,m,g=eP({f0:n,f90:r,dotVH:p});if(mw(a)&&(g=AT.mix(g,s)),mw(o)){const e=mT.dot(t),n=mT.dot(cC),r=mT.dot(c),i=gT.dot(t),s=gT.dot(cC),a=gT.dot(c);f=hP({alphaT:pT,alphaB:u,dotTV:n,dotBV:s,dotTL:e,dotBL:i,dotNV:h,dotNL:A}),m=fP({alphaT:pT,alphaB:u,dotNH:d,dotTH:r,dotBH:a})}else f=AP({alpha:u,dotNL:A,dotNV:h}),m=dP({alpha:u,dotNH:d});return g.mul(f).mul(m)})),gP=Sw((({roughness:e,dotNV:t})=>{const n=qw(-1,-.0275,-.572,.022),r=qw(1,.0425,1.04,-.04),i=e.mul(n).add(r),s=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Dw(-1.04,1.04).mul(s).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),_P=Sw((e=>{const{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,s=gP({dotNV:t,roughness:i});return n.mul(s.x).add(r.mul(s.y))})),vP=Sw((({f:e,f90:t,dotVH:n})=>{const r=n.oneMinus().saturate(),i=r.mul(r),s=r.mul(i,i).clamp(0,.9999);return e.sub(Bw(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"}]}),yP=Sw((({roughness:e,dotNH:t})=>{const n=e.pow2(),r=Cw(1).div(n),i=t.pow2().oneMinus().max(.0078125);return Cw(2).add(r).mul(i.pow(r.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),xP=Sw((({dotNV:e,dotNL:t})=>Cw(1).div(Cw(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),bP=Sw((({lightDirection:e})=>{const t=e.add(cC).normalize(),n=_C.dot(e).clamp(),r=_C.dot(cC).clamp(),i=_C.dot(t).clamp(),s=yP({roughness:cT,dotNH:i}),a=xP({dotNV:r,dotNL:n});return uT.mul(s).mul(a)})),SP=Sw((({N:e,V:t,roughness:n})=>{const r=e.dot(t).saturate(),i=Dw(n,r.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),wP=Sw((({f:e})=>{const t=e.length();return OM(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),TP=Sw((({v1:e,v2:t})=>{const n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),s=r.add(4.1616724).mul(r).add(3.417594).toVar(),a=i.div(s),o=n.greaterThan(0).select(a,OM(n.mul(n).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"}]}),MP=Sw((({N:e,V:t,P:n,mInv:r,p0:i,p1:s,p2:a,p3:o})=>{const l=s.sub(i).toVar(),u=o.sub(i).toVar(),c=l.cross(u),A=Bw().toVar();return Mw(c.dot(n.sub(i)).greaterThanEqual(0),(()=>{const l=t.sub(e.mul(t.dot(e))).normalize(),u=e.cross(l).negate(),c=r.mul(jw(l,u,e).transpose()).toVar(),h=c.mul(i.sub(n)).normalize().toVar(),d=c.mul(s.sub(n)).normalize().toVar(),p=c.mul(a.sub(n)).normalize().toVar(),f=c.mul(o.sub(n)).normalize().toVar(),m=Bw(0).toVar();m.addAssign(TP({v1:h,v2:d})),m.addAssign(TP({v1:d,v2:p})),m.addAssign(TP({v1:p,v2:f})),m.addAssign(TP({v1:f,v2:h})),A.assign(Bw(wP({f:m})))})),A})).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"}]}),EP=1/6,CP=e=>UT(EP,UT(e,UT(e,e.negate().add(3)).sub(3)).add(1)),RP=e=>UT(EP,UT(e,UT(e,UT(3,e).sub(6))).add(4)),NP=e=>UT(EP,UT(e,UT(e,UT(-3,e).add(3)).add(3)).add(1)),PP=e=>UT(EP,jM(e,3)),DP=e=>CP(e).add(RP(e)),LP=e=>NP(e).add(PP(e)),IP=e=>LT(-1,RP(e).div(CP(e).add(RP(e)))),UP=e=>LT(1,PP(e).div(NP(e).add(PP(e)))),BP=(e,t,n)=>{const r=e.uvNode,i=UT(r,t.zw).add(.5),s=dM(i),a=mM(i),o=DP(a.x),l=LP(a.x),u=IP(a.x),c=UP(a.x),A=IP(a.y),h=UP(a.y),d=Dw(s.x.add(u),s.y.add(A)).sub(.5).mul(t.xy),p=Dw(s.x.add(c),s.y.add(A)).sub(.5).mul(t.xy),f=Dw(s.x.add(u),s.y.add(h)).sub(.5).mul(t.xy),m=Dw(s.x.add(c),s.y.add(h)).sub(.5).mul(t.xy),g=DP(a.y).mul(LT(o.mul(e.sample(d).level(n)),l.mul(e.sample(p).level(n)))),_=LP(a.y).mul(LT(o.mul(e.sample(f).level(n)),l.mul(e.sample(m).level(n))));return g.add(_)},OP=Sw((([e,t=Cw(3)])=>{const n=Dw(e.size(Rw(t))),r=Dw(e.size(Rw(t.add(1)))),i=BT(1,n),s=BT(1,r),a=BP(e,qw(i,n),dM(t)),o=BP(e,qw(s,r),pM(t));return mM(t).mix(a,o)})),FP=Sw((([e,t,n,r,i])=>{const s=Bw(ZM(t.negate(),fM(e),BT(1,r))),a=Bw(TM(i[0].xyz),TM(i[1].xyz),TM(i[2].xyz));return fM(s).mul(n.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"}]}),kP=Sw((([e,t])=>e.mul(KM(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),qP=gN(),GP=gN(),zP=Sw((([e,t,n],{material:r})=>{const i=(1===r.side?qP:GP).sample(e),s=cM(hN.x).mul(kP(t,n));return OP(i,s)})),VP=Sw((([e,t,n])=>(Mw(n.notEqual(0),(()=>{const r=uM(t).negate().div(n);return oM(r.negate().mul(e))})),Bw(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),HP=Sw((([e,t,n,r,i,s,a,o,l,u,c,A,h,d,p])=>{let f,m;if(p){f=qw().toVar(),m=Bw().toVar();const i=c.sub(1).mul(p.mul(.025)),s=Bw(c.sub(i),c,c.add(i));KR({start:0,end:3},(({i:i})=>{const c=s.element(i),p=FP(e,t,A,c,o),g=a.add(p),_=u.mul(l.mul(qw(g,1))),v=Dw(_.xy.div(_.w)).toVar();v.addAssign(1),v.divAssign(2),v.assign(Dw(v.x,v.y.oneMinus()));const y=zP(v,n,c);f.element(i).assign(y.element(i)),f.a.addAssign(y.a),m.element(i).assign(r.element(i).mul(VP(TM(p),h,d).element(i)))})),f.a.divAssign(3)}else{const i=FP(e,t,A,c,o),s=a.add(i),p=u.mul(l.mul(qw(s,1))),g=Dw(p.xy.div(p.w)).toVar();g.addAssign(1),g.divAssign(2),g.assign(Dw(g.x,g.y.oneMinus())),f=zP(g,n,c),m=r.mul(VP(TM(i),h,d))}const g=m.rgb.mul(f.rgb),_=e.dot(t).clamp(),v=Bw(_P({dotNV:_,specularColor:i,specularF90:s,roughness:n})),y=m.r.add(m.g,m.b).div(3);return qw(v.oneMinus().mul(g),f.a.oneMinus().mul(y).oneMinus())})),jP=jw(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),WP=(e,t)=>e.sub(t).div(e.add(t)).pow2(),XP=Sw((({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{const s=$M(e,t,JM(0,.03,r)),a=e.div(s).pow2().mul(n.pow2().oneMinus()).oneMinus();Mw(a.lessThan(0),(()=>Bw(1)));const o=a.sqrt(),l=WP(s,e),u=eP({f0:l,f90:1,dotVH:n}),c=u.oneMinus(),A=s.lessThan(e).select(Math.PI,0),h=Cw(Math.PI).sub(A),d=(e=>{const t=e.sqrt();return Bw(1).add(t).div(Bw(1).sub(t))})(i.clamp(0,.9999)),p=WP(d,s.toVec3()),f=eP({f0:p,f90:1,dotVH:o}),m=Bw(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(r,o,2),_=Bw(h).add(m),v=u.mul(f).clamp(1e-5,.9999),y=v.sqrt(),x=c.pow2().mul(f).div(Bw(1).sub(v)),b=u.add(x).toVar(),S=x.sub(c).toVar();return KR({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{S.mulAssign(y);const t=((e,t)=>{const n=e.mul(2*Math.PI*1e-9),r=Bw(54856e-17,44201e-17,52481e-17),i=Bw(1681e3,1795300,2208400),s=Bw(43278e5,93046e5,66121e5),a=Cw(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp());let o=r.mul(s.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(s).exp());return o=Bw(o.x.add(a),o.y,o.z).div(1.0685e-7),jP.mul(o)})(Cw(e).mul(g),Cw(e).mul(_)).mul(2);b.addAssign(S.mul(t))})),b.max(Bw(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"}]}),QP=Sw((({normal:e,viewDir:t,roughness:n})=>{const r=e.dot(t).saturate(),i=n.pow2(),s=rE(n.lessThan(.25),Cw(-339.2).mul(i).add(Cw(161.4).mul(n)).sub(25.9),Cw(-8.48).mul(i).add(Cw(14.3).mul(n)).sub(9.95)),a=rE(n.lessThan(.25),Cw(44).mul(i).sub(Cw(23.7).mul(n)).add(3.26),Cw(1.97).mul(i).sub(Cw(3.27).mul(n)).add(.72));return rE(n.lessThan(.25),0,Cw(.1).mul(n).sub(.025)).add(s.mul(r).add(a).exp()).mul(1/Math.PI).saturate()})),YP=Bw(.04),$P=Cw(1);class KP extends $N{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,s=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,this.dispersion=s,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=Bw().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Bw().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Bw().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=Bw().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Bw().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=_C.dot(cC).clamp();this.iridescenceFresnel=XP({outsideIOR:Cw(1),eta2:hT,cosTheta1:e,thinFilmThickness:dT,baseF0:_T}),this.iridescenceF0=vP({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=oC,n=$E.sub(oC).normalize(),r=vC;e.backdrop=HP(r,n,sT,rT,_T,vT,t,eC,YE,QE,wT,MT,CT,ET,this.dispersion?RT:null),e.backdropAlpha=TT,rT.a.mulAssign($M(1,e.backdrop.a,TT))}}computeMultiscattering(e,t,n){const r=_C.dot(cC).clamp(),i=gP({roughness:sT,dotNV:r}),s=(this.iridescenceF0?AT.mix(_T,this.iridescenceF0):_T).mul(i.x).add(n.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=_T.add(_T.oneMinus().mul(.047619)),l=s.mul(o).div(a.mul(o).oneMinus());e.addAssign(s),t.addAssign(l.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const r=_C.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(r.mul(bP({lightDirection:e}))),!0===this.clearcoat){const n=yC.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(n.mul(mP({lightDirection:e,f0:YP,f90:$P,roughness:lT,normalView:yC})))}n.directDiffuse.addAssign(r.mul(tP({diffuseColor:rT.rgb}))),n.directSpecular.addAssign(r.mul(mP({lightDirection:e,f0:_T,f90:1,roughness:sT,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:s,ltc_2:a}){const o=t.add(n).sub(r),l=t.sub(n).sub(r),u=t.sub(n).add(r),c=t.add(n).add(r),A=_C,h=cC,d=uC.toVar(),p=SP({N:A,V:h,roughness:sT}),f=s.sample(p).toVar(),m=a.sample(p).toVar(),g=jw(Bw(f.x,0,f.y),Bw(0,1,0),Bw(f.z,0,f.w)).toVar(),_=_T.mul(m.x).add(_T.oneMinus().mul(m.y)).toVar();i.directSpecular.addAssign(e.mul(_).mul(MP({N:A,V:h,P:d,mInv:g,p0:o,p1:l,p2:u,p3:c}))),i.directDiffuse.addAssign(e.mul(rT).mul(MP({N:A,V:h,P:d,mInv:jw(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:u,p3:c})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(tP({diffuseColor:rT})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(t.mul(uT,QP({normal:_C,viewDir:cC,roughness:cT}))),!0===this.clearcoat){const e=yC.dot(cC).clamp(),t=_P({dotNV:e,specularColor:YP,specularF90:$P,roughness:lT});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const r=Bw().toVar("singleScattering"),i=Bw().toVar("multiScattering"),s=t.mul(1/Math.PI);this.computeMultiscattering(r,i,vT);const a=r.add(i),o=rT.mul(a.r.max(a.g).max(a.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(i.mul(s)),n.indirectDiffuse.addAssign(o.mul(s))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const n=_C.dot(cC).clamp().add(e),r=sT.mul(-16).oneMinus().negate().exp2(),i=e.sub(n.pow(r).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(e),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(i)}finish(e){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=yC.dot(cC).clamp(),n=eP({dotVH:e,f0:YP,f90:$P}),r=t.mul(oT.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(oT));t.assign(r)}if(!0===this.sheen){const e=uT.r.max(uT.g).max(uT.b).mul(.157).oneMinus(),n=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(n)}}}const ZP=Cw(1),JP=Cw(-2),eD=Cw(.8),tD=Cw(-1),nD=Cw(.4),rD=Cw(2),iD=Cw(.305),sD=Cw(3),aD=Cw(.21),oD=Cw(4),lD=Cw(4),uD=Cw(16),cD=Sw((([e])=>{const t=Bw(SM(e)).toVar(),n=Cw(-1).toVar();return Mw(t.x.greaterThan(t.z),(()=>{Mw(t.x.greaterThan(t.y),(()=>{n.assign(rE(e.x.greaterThan(0),0,3))})).Else((()=>{n.assign(rE(e.y.greaterThan(0),1,4))}))})).Else((()=>{Mw(t.z.greaterThan(t.y),(()=>{n.assign(rE(e.z.greaterThan(0),2,5))})).Else((()=>{n.assign(rE(e.y.greaterThan(0),1,4))}))})),n})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),AD=Sw((([e,t])=>{const n=Dw().toVar();return Mw(t.equal(0),(()=>{n.assign(Dw(e.z,e.y).div(SM(e.x)))})).ElseIf(t.equal(1),(()=>{n.assign(Dw(e.x.negate(),e.z.negate()).div(SM(e.y)))})).ElseIf(t.equal(2),(()=>{n.assign(Dw(e.x.negate(),e.y).div(SM(e.z)))})).ElseIf(t.equal(3),(()=>{n.assign(Dw(e.z.negate(),e.y).div(SM(e.x)))})).ElseIf(t.equal(4),(()=>{n.assign(Dw(e.x.negate(),e.z).div(SM(e.y)))})).Else((()=>{n.assign(Dw(e.x,e.y).div(SM(e.z)))})),UT(.5,n.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),hD=Sw((([e])=>{const t=Cw(0).toVar();return Mw(e.greaterThanEqual(eD),(()=>{t.assign(ZP.sub(e).mul(tD.sub(JP)).div(ZP.sub(eD)).add(JP))})).ElseIf(e.greaterThanEqual(nD),(()=>{t.assign(eD.sub(e).mul(rD.sub(tD)).div(eD.sub(nD)).add(tD))})).ElseIf(e.greaterThanEqual(iD),(()=>{t.assign(nD.sub(e).mul(sD.sub(rD)).div(nD.sub(iD)).add(rD))})).ElseIf(e.greaterThanEqual(aD),(()=>{t.assign(iD.sub(e).mul(oD.sub(sD)).div(iD.sub(aD)).add(sD))})).Else((()=>{t.assign(Cw(-2).mul(cM(UT(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),dD=Sw((([e,t])=>{const n=e.toVar();n.assign(UT(2,n).sub(1));const r=Bw(n,1).toVar();return Mw(t.equal(0),(()=>{r.assign(r.zyx)})).ElseIf(t.equal(1),(()=>{r.assign(r.xzy),r.xz.mulAssign(-1)})).ElseIf(t.equal(2),(()=>{r.x.mulAssign(-1)})).ElseIf(t.equal(3),(()=>{r.assign(r.zyx),r.xz.mulAssign(-1)})).ElseIf(t.equal(4),(()=>{r.assign(r.xzy),r.xy.mulAssign(-1)})).ElseIf(t.equal(5),(()=>{r.z.mulAssign(-1)})),r})).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),pD=Sw((([e,t,n,r,i,s])=>{const a=Cw(n),o=Bw(t),l=KM(hD(a),JP,s),u=mM(l),c=dM(l),A=Bw(fD(e,o,c,r,i,s)).toVar();return Mw(u.notEqual(0),(()=>{const t=Bw(fD(e,o,c.add(1),r,i,s)).toVar();A.assign($M(A,t,u))})),A})),fD=Sw((([e,t,n,r,i,s])=>{const a=Cw(n).toVar(),o=Bw(t),l=Cw(cD(o)).toVar(),u=Cw(OM(lD.sub(a),0)).toVar();a.assign(OM(a,lD));const c=Cw(lM(a)).toVar(),A=Dw(AD(o,l).mul(c.sub(2)).add(1)).toVar();return Mw(l.greaterThan(2),(()=>{A.y.addAssign(c),l.subAssign(3)})),A.x.addAssign(l.mul(c)),A.x.addAssign(u.mul(UT(3,uD))),A.y.addAssign(UT(4,lM(s).sub(c))),A.x.mulAssign(r),A.y.mulAssign(i),e.sample(A).grad(Dw(),Dw())})),mD=Sw((({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=_M(r),u=n.mul(l).add(i.cross(n).mul(gM(r))).add(i.mul(i.dot(n).mul(l.oneMinus())));return fD(e,u,t,s,a,o)})),gD=Sw((({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:s,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:A})=>{const h=Bw(rE(t,n,HM(n,r))).toVar();Mw(rM(h.equals(Bw(0))),(()=>{h.assign(Bw(r.z,0,r.x.negate()))})),h.assign(fM(h));const d=Bw().toVar();return d.addAssign(i.element(Rw(0)).mul(mD({theta:0,axis:h,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:A}))),KR({start:Rw(1),end:e},(({i:e})=>{Mw(e.greaterThanEqual(s),(()=>{IE("break").append()}));const t=Cw(a.mul(Cw(e))).toVar();d.addAssign(i.element(e).mul(mD({theta:t.mul(-1),axis:h,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:A}))),d.addAssign(i.element(e).mul(mD({theta:t,axis:h,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:A})))})),qw(d,1)}));let _D=null;const vD=new WeakMap;function yD(e){let t=vD.get(e);if((void 0!==t?t.pmremVersion:-1)!==e.pmremVersion){const n=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const n=6;for(let r=0;r0}(n))return null;t=_D.fromEquirectangular(e,t)}t.pmremVersion=e.pmremVersion,vD.set(e,t)}return t.texture}class xD extends BS{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new Jt;r.isRenderTargetTexture=!0,this._texture=HE(r),this._width=eT(0),this._height=eT(0),this._maxMip=eT(0),this.updateBeforeType=wS}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,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,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(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(e=!0===n.isPMREMTexture?n:yD(n),null!==e&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){null===_D&&(_D=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===vt&&!0!==n.isPMREMTexture&&!0===n.isRenderTargetTexture&&(t=Bw(t.x.negate(),t.yz)),t=Bw(t.x,t.y.negate(),t.z);let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),pD(this._texture,t,r,this._width,this._height,this._maxMip)}}const bD=xw(xD),SD=new WeakMap;class wD extends rN{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const e=n.isTextureNode?n.value:t[n.property];let r=SD.get(e);void 0===r&&(r=bD(e),SD.set(e,r)),n=r}const r=t.envMap?OC("envMapIntensity","float",e.material):OC("environmentIntensity","float",e.scene),i=!0===t.useAnisotropy||t.anisotropy>0?WC:_C,s=n.context(TD(sT,i)).mul(r),a=n.context(MD(vC)).mul(Math.PI).mul(r),o=CE(s),l=CE(a);e.context.radiance.addAssign(o),e.context.iblIrradiance.addAssign(l);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=n.context(TD(lT,yC)).mul(r),t=CE(e);u.addAssign(t)}}}const TD=(e,t)=>{let n=null;return{getUV:()=>(null===n&&(n=cC.negate().reflect(t),n=e.mul(e).mix(n,t).normalize(),n=n.transformDirection(YE)),n),getTextureLevel:()=>e}},MD=e=>({getUV:()=>e,getTextureLevel:()=>Cw(1)}),ED=new da;class CD 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(ED),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new wD(t):null}setupLightingModel(){return new KP}setupSpecular(){const e=$M(Bw(.04),rT.rgb,aT);_T.assign(e),vT.assign(1)}setupVariants(){const e=this.metalnessNode?Cw(this.metalnessNode):dR;aT.assign(e);let t=this.roughnessNode?Cw(this.roughnessNode):hR;t=cP({roughness:t}),sT.assign(t),this.setupSpecular(),rT.assign(qw(rT.rgb.mul(e.oneMinus()),rT.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const RD=new pa;class ND extends CD{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(RD),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?Cw(this.iorNode):ER;wT.assign(e),_T.assign($M(BM(WM(wT.sub(1).div(wT.add(1))).mul(uR),Bw(1)).mul(lR),rT.rgb,aT)),vT.assign($M(lR,1,aT))}setupLightingModel(){return new KP(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Cw(this.clearcoatNode):fR,t=this.clearcoatRoughnessNode?Cw(this.clearcoatRoughnessNode):mR;oT.assign(e),lT.assign(cP({roughness:t}))}if(this.useSheen){const e=this.sheenNode?Bw(this.sheenNode):vR,t=this.sheenRoughnessNode?Cw(this.sheenRoughnessNode):yR;uT.assign(e),cT.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Cw(this.iridescenceNode):bR,t=this.iridescenceIORNode?Cw(this.iridescenceIORNode):SR,n=this.iridescenceThicknessNode?Cw(this.iridescenceThicknessNode):wR;AT.assign(e),hT.assign(t),dT.assign(n)}if(this.useAnisotropy){const e=(this.anisotropyNode?Dw(this.anisotropyNode):xR).toVar();fT.assign(e.length()),Mw(fT.equal(0),(()=>{e.assign(Dw(1,0))})).Else((()=>{e.divAssign(Dw(fT)),fT.assign(fT.saturate())})),pT.assign(fT.pow2().mix(sT.pow2(),1)),mT.assign(jC[0].mul(e.x).add(jC[1].mul(e.y))),gT.assign(jC[1].mul(e.x).sub(jC[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Cw(this.transmissionNode):TR,t=this.thicknessNode?Cw(this.thicknessNode):MR,n=this.attenuationDistanceNode?Cw(this.attenuationDistanceNode):CR,r=this.attenuationColorNode?Bw(this.attenuationColorNode):RR;if(TT.assign(e),MT.assign(t),ET.assign(n),CT.assign(r),this.useDispersion){const e=this.dispersionNode?Cw(this.dispersionNode):IR;RT.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Bw(this.clearcoatNormalNode):gR}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const PD=Sw((({normal:e,lightDirection:t,builder:n})=>{const r=e.dot(t),i=Dw(r.mul(.5).add(.5),0);if(n.material.gradientMap){const e=qC("gradientMap","texture").context({getUV:()=>i});return Bw(e.r)}{const e=i.fwidth().mul(.5);return $M(Bw(.7),Bw(1),JM(Cw(.7).sub(e.x),Cw(.7).add(e.x),i.x))}}));class DD extends $N{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,i){const s=PD({normal:dC,lightDirection:e,builder:i}).mul(t);n.directDiffuse.addAssign(s.mul(tP({diffuseColor:rT.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(tP({diffuseColor:rT}))),n.indirectDiffuse.mulAssign(e)}}const LD=new ma;class ID extends LN{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(LD),this.setValues(e)}setupLightingModel(){return new DD}}class UD extends BS{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=Bw(cC.z,0,cC.x.negate()).normalize(),t=cC.cross(e);return Dw(e.dot(_C),t.dot(_C)).mul(.495).add(.5)}}const BD=bw(UD),OD=new xa;class FD extends LN{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(OD),this.setValues(e)}setupVariants(e){const t=BD;let n;n=e.material.matcap?qC("matcap","texture").context({getUV:()=>t}):Bw($M(.2,.8,t.y)),rT.rgb.mulAssign(n.rgb)}}const kD=new es;class qD extends LN{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(kD),this.setValues(e)}}class GD extends BS{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:n}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),r=t.sin();return Hw(e,r,r.negate(),e).mul(n)}{const e=t,r=Ww(qw(1,0,0,0),qw(0,_M(e.x),gM(e.x).negate(),0),qw(0,gM(e.x),_M(e.x),0),qw(0,0,0,1)),i=Ww(qw(_M(e.y),0,gM(e.y),0),qw(0,1,0,0),qw(gM(e.y).negate(),0,_M(e.y),0),qw(0,0,0,1)),s=Ww(qw(_M(e.z),gM(e.z).negate(),0,0),qw(gM(e.z),_M(e.z),0,0),qw(0,0,1,0),qw(0,0,0,1));return r.mul(i).mul(s).mul(qw(n,1)).xyz}}}const zD=xw(GD),VD=new Pi;class HD 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.setDefaultValues(VD),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:i,rotationNode:s,scaleNode:a}=this,o=nC.mul(Bw(i||0));let l=Dw(eC[0].xyz.length(),eC[1].xyz.length());if(null!==a&&(l=l.mul(a)),!1===r)if(n.isPerspectiveCamera)l=l.mul(o.z.negate());else{const e=Cw(2).div(QE.element(1).element(1));l=l.mul(e.mul(2))}let u=iC.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,n)=>_w(new gE(e,t,n)))("center","vec2",t);u=u.sub(e.sub(.5))}u=u.mul(l);const c=Cw(s||_R),A=zD(u,c);return qw(o.xy.add(A),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)}}class jD extends $N{constructor(){super(),this.shadowNode=Cw(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){rT.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(rT.rgb)}}const WD=new ha;class XD extends LN{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(WD),this.setValues(e)}setupLightingModel(){return new jD}}Sw((({texture:e,uv:t})=>{const n=1e-4,r=Bw().toVar();return Mw(t.x.lessThan(n),(()=>{r.assign(Bw(1,0,0))})).ElseIf(t.y.lessThan(n),(()=>{r.assign(Bw(0,1,0))})).ElseIf(t.z.lessThan(n),(()=>{r.assign(Bw(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{r.assign(Bw(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{r.assign(Bw(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{r.assign(Bw(0,0,-1))})).Else((()=>{const n=.01,i=e.sample(t.add(Bw(-.01,0,0))).r.sub(e.sample(t.add(Bw(n,0,0))).r),s=e.sample(t.add(Bw(0,-.01,0))).r.sub(e.sample(t.add(Bw(0,n,0))).r),a=e.sample(t.add(Bw(0,0,-.01))).r.sub(e.sample(t.add(Bw(0,0,n))).r);r.assign(Bw(i,s,a))})),r.normalize()}));class QD{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class YD{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}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().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;n.push(e);const s=e.isInterleavedBufferAttribute?e.data:e;r.add(s)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:i}=this,s=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a,l=n.isInstancedBufferGeometry?n.instanceCount:e.count>1?e.count:1;if(0===l)return null;if(s.instanceCount=l,!0===e.isBatchedMesh)return s;let u=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(u=2);let c=i.start*u,A=(i.start+i.count)*u;null!==r&&(c=Math.max(c,r.start*u),A=Math.min(A,(r.start+r.count)*u));const h=n.attributes.position;let d=1/0;o?d=a.count:null!=h&&(d=h.count),c=Math.max(c,0),A=Math.min(A,d);const p=A-c;return p<0||p===1/0?null:(s.vertexCount=p,s.firstVertex=c,s)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const e of function(e){const t=Object.keys(e);let n=Object.getPrototypeOf(e);for(;n;){const e=Object.getOwnPropertyDescriptors(n);for(const n in e)if(void 0!==e[n]){const r=e[n];r&&"function"==typeof r.get&&t.push(n)}n=Object.getPrototypeOf(n)}return t}(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;const r=t[e];let i;if(null!==r){const e=typeof r;"number"===e?i=0!==r?"1":"0":"object"===e?(i="{",r.isTexture&&(i+=r.mapping),i+="}"):i=String(r)}else i=String(r);n+=i+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(n+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",null!==e._colorsTexture&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",AS(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const ZD=[];class JD{constructor(e,t,n,r,i,s){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=s,this.chainMaps={}}get(e,t,n,r,i,s,a,o){const l=this.getChainMap(o);ZD[0]=e,ZD[1]=t,ZD[2]=s,ZD[3]=i;let u=l.get(ZD);return void 0===u?(u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,s,a,o),l.set(ZD,u)):(u.updateClipping(a),u.needsGeometryUpdate&&u.setGeometry(e.geometry),(u.version!==t.version||u.needsUpdate)&&(u.initialCacheKey!==u.getCacheKey()?(u.dispose(),u=this.get(e,t,n,r,i,s,a,o)):u.version=t.version)),u}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new YD)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,s,a,o,l,u,c){const A=this.getChainMap(c),h=new KD(e,t,n,r,i,s,a,o,l,u);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),A.delete(h.getChainArray())},h}}class eL{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 tL=1,nL=2,rL=3,iL=4,sL=16;class aL extends eL{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return void 0!==t&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(void 0===n.version)t===tL?this.backend.createAttribute(e):t===nL?this.backend.createIndexAttribute(e):t===rL?this.backend.createStorageAttribute(e):t===iL&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(n.version=0;--t)if(e[t]>=65535)return!0;return!1}(t)?zr:Gr)(t,1);return i.version=oL(e),i}class uL extends eL{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const n=()=>{this.info.memory.geometries--;const r=t.index,i=e.getAttributes();null!==r&&this.attributes.delete(r);for(const e of i)this.attributes.delete(e);const s=this.wireframes.get(t);void 0!==s&&this.attributes.delete(s),t.removeEventListener("dispose",n)};t.addEventListener("dispose",n)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,rL):this.updateAttribute(e,tL);const n=this.getIndex(e);null!==n&&this.updateAttribute(n,nL);const r=e.geometry.indirect;null!==r&&this.updateAttribute(r,iL)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(!0===n.wireframe){const e=this.wireframes;let n=e.get(t);void 0===n?(n=lL(t),e.set(t,n)):n.version!==oL(t)&&(this.attributes.delete(n),n=lL(t),e.set(t,n)),r=n}return r}}class cL{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,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){0===this[e].timestampCalls&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,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 AL{constructor(e){this.cacheKey=e,this.usedTimes=0}}class hL extends AL{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class dL extends AL{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let pL=0;class fL{constructor(e,t,n,r=null,i=null){this.id=pL++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}}class mL extends eL{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:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const s=this.nodes.getForCompute(e);let a=this.programs.compute.get(s.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new fL(s.computeShader,"compute",e.name,s.transforms,s.nodeAttributes),this.programs.compute.set(s.computeShader,a),n.createProgram(a));const o=this._getComputeCacheKey(e,a);let l=this.caches.get(o);void 0===l&&(i&&0===i.usedTimes&&this._releasePipeline(i),l=this._getComputePipeline(e,a,o,t)),l.usedTimes++,a.usedTimes++,r.version=e.version,r.pipeline=l}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const s=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(s.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new fL(s.vertexShader,"vertex",a),this.programs.vertex.set(s.vertexShader,o),n.createProgram(o));let l=this.programs.fragment.get(s.fragmentShader);void 0===l&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),l=new fL(s.fragmentShader,"fragment",a),this.programs.fragment.set(s.fragmentShader,l),n.createProgram(l));const u=this._getRenderCacheKey(e,o,l);let c=this.caches.get(u);void 0===c?(i&&0===i.usedTimes&&this._releasePipeline(i),c=this._getRenderPipeline(e,o,l,u,t)):e.pipeline=c,c.usedTimes++,o.usedTimes++,l.usedTimes++,r.pipeline=c}return r.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,n,r){n=n||this._getComputeCacheKey(e,t);let i=this.caches.get(n);return void 0===i&&(i=new dL(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r=r||this._getRenderCacheKey(e,t,n);let s=this.caches.get(r);return void 0===s&&(s=new hL(r,t,n),this.caches.set(r,s),e.pipeline=s,this.backend.createRenderPipeline(e,i)),s}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].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 gL extends eL{constructor(e,t,n,r,i,s){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=s,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const n=this.get(e);void 0===n.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const n=this.get(e);void 0===n.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,n=e.isIndirectStorageBufferAttribute?iL:rL;this.attributes.update(e,n)}}_update(e,t){const{backend:n}=this;let r=!1,i=!0,s=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isUniformBuffer){t.update()&&n.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(r=!0);const o=t.update(),l=t.texture;o&&this.textures.updateTexture(l);const u=n.get(l);if(void 0!==u.externalTexture||e.isDefaultTexture?i=!1:(s=10*s+l.id,a+=l.version),!0===n.isWebGPUBackend&&void 0===u.texture&&void 0===u.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,l,t.textureNode.value,r),this.textures.updateTexture(l),r=!0),!0===l.isStorageTexture){const e=this.get(l);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(l)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(l),e.needsMipmap=!1)}}}!0===r&&this.backend.updateBindings(e,t,i?s:0,a)}}function _L(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function vL(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 yL(e){return(e.transmission>0||e.transmissionNode)&&2===e.side&&!1===e.forceSinglePass}class xL{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,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,n,r,i,s,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:s,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=n,o.groupOrder=r,o.renderOrder=e.renderOrder,o.z=i,o.group=s,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,n,r,i,s,a){const o=this.getNextRenderItem(e,t,n,r,i,s,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===n.transparent||n.transmission>0?(yL(n)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,n,r,i,s,a){const o=this.getNextRenderItem(e,t,n,r,i,s,a);!0===n.transparent||n.transmission>0?(yL(n)&&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||_L),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||vL),this.transparent.length>1&&this.transparent.sort(t||vL)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,l=a.height>>t;let u=e.depthTexture||i[t];const c=!0===e.depthBuffer||!0===e.stencilBuffer;let A=!1;void 0===u&&c&&(u=new ls,u.format=e.stencilBuffer?_e:ge,u.type=e.stencilBuffer?ce:se,u.image.width=o,u.image.height=l,i[t]=u),n.width===a.width&&a.height===n.height||(A=!0,u&&(u.needsUpdate=!0,u.image.width=o,u.image.height=l)),n.width=a.width,n.height=a.height,n.textures=s,n.depthTexture=u||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(A=!0,u&&(u.needsUpdate=!0),n.sampleCount=r);const h={sampleCount:r};for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const r=e.image;if(void 0===r)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===r.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const n=[];for(const t of e.images)n.push(t);t.images=n}else t.image=r;void 0!==n.isDefaultTexture&&!0!==n.isDefaultTexture||(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version}if(!0!==n.initialized){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",t)}n.version=e.version}getSize(e,t=EL){let n=e.images?e.images[0]:e.image;return n?(void 0!==n.image&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return r=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return this.isEnvironmentTexture(e)||!0===e.isCompressedTexture||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===z||t===V||t===q||t===G}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class RL extends Rr{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class NL extends tT{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class PL extends LS{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new gw(t);return this._currentCond=rE(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new gw(t),r=rE(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new gw(e),this}build(e,...t){const n=Tw();ww(this);for(const t of this.nodes)t.build(e,"void");return ww(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const DL=xw(PL);new Oi,new on,new on,new on,new On,new on(0,0,-1),new en,new on,new on,new en,new Lt;const LL=new tn;AN.flipX(),LL.depthTexture=new ls(1,1);const IL=new za(-1,1,1,-1,0,1);class UL extends Zr{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Hr([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Hr(t,2))}}const BL=new UL;class OL extends ci{constructor(e=null){super(BL,e),this.camera=IL,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,IL)}render(e){e.render(this,IL)}}const FL=new Xn,kL=new On;class qL extends LS{static get type(){return"SceneNode"}constructor(e=qL.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=null!==this.scene?this.scene:e.scene;let r;return t===qL.BACKGROUND_BLURRINESS?r=OC("backgroundBlurriness","float",n):t===qL.BACKGROUND_INTENSITY?r=OC("backgroundIntensity","float",n):t===qL.BACKGROUND_ROTATION?r=eT("mat4").label("backgroundRotation").setGroup(Kw).onRenderUpdate((()=>{const e=n.background;return null!==e&&e.isTexture&&300!==e.mapping?(FL.copy(n.backgroundRotation),FL.x*=-1,FL.y*=-1,FL.z*=-1,kL.makeRotationFromEuler(FL)):kL.identity(),kL})):console.error("THREE.SceneNode: Unknown scope:",t),r}}qL.BACKGROUND_BLURRINESS="backgroundBlurriness",qL.BACKGROUND_INTENSITY="backgroundIntensity",qL.BACKGROUND_ROTATION="backgroundRotation";const GL=bw(qL,qL.BACKGROUND_BLURRINESS),zL=bw(qL,qL.BACKGROUND_INTENSITY),VL=bw(qL,qL.BACKGROUND_ROTATION),HL=new Lt;class jL extends VE{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class WL extends jL{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class XL extends BS{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const i=new ls;i.isRenderTargetTexture=!0,i.name="depth";const s=new tn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:oe,...r});s.texture.name="output",s.depthTexture=i,this.renderTarget=s,this._textures={output:s.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=eT(0),this._cameraFar=eT(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=SS}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}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 n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=_w(new WL(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=_w(new WL(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=wN(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=bN(i,n,r)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.scope===XL.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();const i=t.getSize(HL);this.setSize(i.width,i.height);const s=t.getRenderTarget(),a=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(s),t.setMRT(a)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}XL.COLOR="color",XL.DEPTH="depth";const QL=Sw((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),YL=Sw((([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"}]}),$L=Sw((([e,t])=>{const n=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),KL=Sw((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)})),ZL=Sw((([e,t])=>{const n=jw(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=jw(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=KL(e),(e=r.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),JL=jw(Bw(1.6605,-.1246,-.0182),Bw(-.5876,1.1329,-.1006),Bw(-.0728,-.0083,1.1187)),eI=jw(Bw(.6274,.0691,.0164),Bw(.3293,.9195,.088),Bw(.0433,.0113,.8956)),tI=Sw((([e])=>{const t=Bw(e).toVar(),n=Bw(t.mul(t)).toVar(),r=Bw(n.mul(n)).toVar();return Cw(15.5).mul(r.mul(n)).sub(UT(40.14,r.mul(t))).add(UT(31.96,r).sub(UT(6.868,n.mul(t))).add(UT(.4298,n).add(UT(.1191,t).sub(.00232))))})),nI=Sw((([e,t])=>{const n=Bw(e).toVar(),r=jw(Bw(.856627153315983,.137318972929847,.11189821299995),Bw(.0951212405381588,.761241990602591,.0767994186031903),Bw(.0482516061458583,.101439036467562,.811302368396859)),i=jw(Bw(1.1271005818144368,-.1413297634984383,-.14132976349843826),Bw(-.11060664309660323,1.157823702216272,-.11060664309660294),Bw(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=Cw(-12.47393),a=Cw(4.026069);return n.mulAssign(t),n.assign(eI.mul(n)),n.assign(r.mul(n)),n.assign(OM(n,1e-10)),n.assign(cM(n)),n.assign(n.sub(s).div(a.sub(s))),n.assign(KM(n,0,1)),n.assign(tI(n)),n.assign(i.mul(n)),n.assign(jM(OM(Bw(0),n),Bw(2.2))),n.assign(JL.mul(n)),n.assign(KM(n,0,1)),n})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),rI=Sw((([e,t])=>{const n=Cw(.76),r=Cw(.15);e=e.mul(t);const i=BM(e.r,BM(e.g,e.b)),s=rE(i.lessThan(.08),i.sub(UT(6.25,i.mul(i))),.04);e.subAssign(s);const a=OM(e.r,OM(e.g,e.b));Mw(a.lessThan(n),(()=>e));const o=IT(1,n),l=IT(1,o.mul(o).div(a.add(o.sub(n))));e.mulAssign(l.div(a));const u=IT(1,BT(1,r.mul(a.sub(l)).add(1)));return $M(e,Bw(l),u)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class iI extends LS{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=n}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const n of t)n.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.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}}class sI extends iI{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return void 0===n&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,i=n.type,s=e.getCodeFromNode(this,i);""!==r&&(s.name=r);const a=e.getPropertyName(s),o=this.getNodeFunction(e).getCode(a);return s.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}function aI(e){let t;const n=e.context.getViewZ;return void 0!==n&&(t=n(this)),(t||uC.z).negate()}const oI=Sw((([e,t],n)=>{const r=aI(n);return JM(e,t,r)})),lI=Sw((([e],t)=>{const n=aI(t);return e.mul(e,n,n).negate().exp().oneMinus()})),uI=Sw((([e,t])=>qw(t.toFloat().mix(xT.rgb,e.toVec3()),xT.a)));xw(class extends LS{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;!0===n.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class cI extends BS{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),i=this.pointerNode,s=this.valueNode,a=[];a.push(`&${i.build(e,r)}`),a.push(s.build(e,r));const o=`${e.getMethod(t,n)}( ${a.join(", ")} )`;if(null!==this.storeNode){const t=this.storeNode.build(e,r);e.addLineFlowCode(`${t} = ${o}`,this)}else e.addLineFlowCode(o,this)}}let AI;function hI(e){AI=AI||new WeakMap;let t=AI.get(e);return void 0===t&&AI.set(e,t={}),t}function dI(e){const t=hI(e);return t.shadowMatrix||(t.shadowMatrix=eT("mat4").setGroup(Kw).onRenderUpdate((()=>(!0!==e.castShadow&&e.shadow.updateMatrices(e),e.shadow.matrix))))}function pI(e){const t=hI(e);return t.position||(t.position=eT(new on).setGroup(Kw).onRenderUpdate(((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))))}function fI(e){const t=hI(e);return t.viewPosition||(t.viewPosition=eT(new on).setGroup(Kw).onRenderUpdate((({camera:t},n)=>{n.value=n.value||new on,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})))}cI.ATOMIC_LOAD="atomicLoad",cI.ATOMIC_STORE="atomicStore",cI.ATOMIC_ADD="atomicAdd",cI.ATOMIC_SUB="atomicSub",cI.ATOMIC_MAX="atomicMax",cI.ATOMIC_MIN="atomicMin",cI.ATOMIC_AND="atomicAnd",cI.ATOMIC_OR="atomicOr",cI.ATOMIC_XOR="atomicXor",xw(cI);const mI=e=>YE.transformDirection(pI(e).sub(function(e){const t=hI(e);return t.targetPosition||(t.targetPosition=eT(new on).setGroup(Kw).onRenderUpdate(((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))))}(e))),gI=(e,t)=>{for(const n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},_I=new WeakMap;class vI extends LS{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Bw().toVar("totalDiffuse"),this.totalSpecularNode=Bw().toVar("totalSpecular"),this.outgoingLightNode=Bw().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;ne.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of r)if(e.isNode)t.push(_w(e));else{let r=null;if(null!==n&&(r=gI(e.id,n)),null===r){const n=i.getLightNodeClass(e.constructor);if(null===n){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;_I.has(e)?r=_I.get(e):(r=_w(new n(e)),_I.set(e,r)),t.push(r)}}this._lightNodes=t}setupLights(e,t){for(const n of t)n.build(e)}setup(e){null===this._lightNodes&&this.setupLightsNode(e);const t=e.context,n=t.lightingModel;let r=this.outgoingLightNode;if(n){const{_lightNodes:i,totalDiffuseNode:s,totalSpecularNode:a}=this;t.outgoingLight=r;const o=e.addStack();e.getDataFromNode(this).nodes=o.nodes,n.start(t,o,e),this.setupLights(e,i),n.indirect(t,o,e);const{backdrop:l,backdropAlpha:u}=t,{directDiffuse:c,directSpecular:A,indirectDiffuse:h,indirectSpecular:d}=t.reflectedLight;let p=c.add(h);null!==l&&(p=Bw(null!==u?u.mix(p,l):l),t.material.transparent=!0),s.assign(p),a.assign(A.add(d)),r.assign(s.add(a)),n.finish(t,o,e),r=r.bypass(e.removeStack())}return 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 yI extends LS{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=wS,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){xI.assign(e.shadowPositionNode||oC)}dispose(){this.updateBeforeType=bS}}const xI=Bw().toVar("shadowPositionWorld");function bI(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 Rr),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 SI=new WeakMap,wI=Sw((([e,t,n])=>{let r=oC.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r})),TI=e=>{let t=SI.get(e);if(void 0===t){const n=e.isPointLight?(e=>{const t=e.shadow.camera,n=OC("near","float",t).setGroup(Kw),r=OC("far","float",t).setGroup(Kw),i=ZE(e);return wI(i,n,r)})(e):null;t=new LN,t.colorNode=qw(0,0,0,1),t.depthNode=n,t.isShadowNodeMaterial=!0,t.name="ShadowMaterial",t.fog=!1,SI.set(e,t)}return t},MI=Sw((({depthTexture:e,shadowCoord:t})=>HE(e,t.xy).compare(t.z))),EI=Sw((({depthTexture:e,shadowCoord:t,shadow:n})=>{const r=(t,n)=>HE(e,t).compare(n),i=OC("mapSize","vec2",n).setGroup(Kw),s=OC("radius","float",n).setGroup(Kw),a=Dw(1).div(i),o=a.x.negate().mul(s),l=a.y.negate().mul(s),u=a.x.mul(s),c=a.y.mul(s),A=o.div(2),h=l.div(2),d=u.div(2),p=c.div(2);return LT(r(t.xy.add(Dw(o,l)),t.z),r(t.xy.add(Dw(0,l)),t.z),r(t.xy.add(Dw(u,l)),t.z),r(t.xy.add(Dw(A,h)),t.z),r(t.xy.add(Dw(0,h)),t.z),r(t.xy.add(Dw(d,h)),t.z),r(t.xy.add(Dw(o,0)),t.z),r(t.xy.add(Dw(A,0)),t.z),r(t.xy,t.z),r(t.xy.add(Dw(d,0)),t.z),r(t.xy.add(Dw(u,0)),t.z),r(t.xy.add(Dw(A,p)),t.z),r(t.xy.add(Dw(0,p)),t.z),r(t.xy.add(Dw(d,p)),t.z),r(t.xy.add(Dw(o,c)),t.z),r(t.xy.add(Dw(0,c)),t.z),r(t.xy.add(Dw(u,c)),t.z)).mul(1/17)})),CI=Sw((({depthTexture:e,shadowCoord:t,shadow:n})=>{const r=(t,n)=>HE(e,t).compare(n),i=OC("mapSize","vec2",n).setGroup(Kw),s=Dw(1).div(i),a=s.x,o=s.y,l=t.xy,u=mM(l.mul(i).add(.5));return l.subAssign(u.mul(s)),LT(r(l,t.z),r(l.add(Dw(a,0)),t.z),r(l.add(Dw(0,o)),t.z),r(l.add(s),t.z),$M(r(l.add(Dw(a.negate(),0)),t.z),r(l.add(Dw(a.mul(2),0)),t.z),u.x),$M(r(l.add(Dw(a.negate(),o)),t.z),r(l.add(Dw(a.mul(2),o)),t.z),u.x),$M(r(l.add(Dw(0,o.negate())),t.z),r(l.add(Dw(0,o.mul(2))),t.z),u.y),$M(r(l.add(Dw(a,o.negate())),t.z),r(l.add(Dw(a,o.mul(2))),t.z),u.y),$M($M(r(l.add(Dw(a.negate(),o.negate())),t.z),r(l.add(Dw(a.mul(2),o.negate())),t.z),u.x),$M(r(l.add(Dw(a.negate(),o.mul(2))),t.z),r(l.add(Dw(a.mul(2),o.mul(2))),t.z),u.x),u.y)).mul(1/9)})),RI=Sw((({depthTexture:e,shadowCoord:t})=>{const n=Cw(1).toVar(),r=HE(e).sample(t.xy).rg,i=kM(t.z,r.x);return Mw(i.notEqual(Cw(1)),(()=>{const e=t.z.sub(r.x),s=OM(0,r.y.mul(r.y));let a=s.div(s.add(e.mul(e)));a=KM(IT(a,.3).div(.95-.3)),n.assign(KM(OM(i,a)))})),n})),NI=Sw((({samples:e,radius:t,size:n,shadowPass:r})=>{const i=Cw(0).toVar(),s=Cw(0).toVar(),a=e.lessThanEqual(Cw(1)).select(Cw(0),Cw(2).div(e.sub(1))),o=e.lessThanEqual(Cw(1)).select(Cw(0),Cw(-1));KR({start:Rw(0),end:Rw(e),type:"int",condition:"<"},(({i:e})=>{const l=o.add(Cw(e).mul(a)),u=r.sample(LT(dN.xy,Dw(0,l).mul(t)).div(n)).x;i.addAssign(u),s.addAssign(u.mul(u))})),i.divAssign(e),s.divAssign(e);const l=AM(s.sub(i.mul(i)));return Dw(i,l)})),PI=Sw((({samples:e,radius:t,size:n,shadowPass:r})=>{const i=Cw(0).toVar(),s=Cw(0).toVar(),a=e.lessThanEqual(Cw(1)).select(Cw(0),Cw(2).div(e.sub(1))),o=e.lessThanEqual(Cw(1)).select(Cw(0),Cw(-1));KR({start:Rw(0),end:Rw(e),type:"int",condition:"<"},(({i:e})=>{const l=o.add(Cw(e).mul(a)),u=r.sample(LT(dN.xy,Dw(l,0).mul(t)).div(n));i.addAssign(u.x),s.addAssign(LT(u.y.mul(u.y),u.x.mul(u.x)))})),i.divAssign(e),s.divAssign(e);const l=AM(s.sub(i.mul(i)));return Dw(i,l)})),DI=[MI,EI,CI,RI];let LI;const II=new OL;class UI extends yI{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.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i}){const s=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),a=t({depthTexture:n,shadowCoord:r,shadow:i});return s.select(a,Cw(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,i=OC("bias","float",n).setGroup(Kw);let s,a=t;if(n.camera.isOrthographicCamera||!0!==r.logarithmicDepthBuffer)a=a.xyz.div(a.w),s=a.z,r.coordinateSystem===yt&&(s=s.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=OC("near","float",n.camera).setGroup(Kw),r=OC("far","float",n.camera).setGroup(Kw);s=TN(e.negate(),t,r)}return a=Bw(a.x,a.y.oneMinus(),s.add(i)),a}getShadowFilterFn(e){return DI[e]}setupShadow(e){const{renderer:t}=e,{light:n,shadow:r}=this,i=t.shadowMap.type,s=new ls(r.mapSize.width,r.mapSize.height);s.compareFunction=ut;const a=e.createRenderTarget(r.mapSize.width,r.mapSize.height);if(a.depthTexture=s,r.camera.updateProjectionMatrix(),3===i){s.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:xe,type:oe}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:xe,type:oe});const t=HE(s),n=HE(this.vsmShadowMapVertical.texture),i=OC("blurSamples","float",r).setGroup(Kw),a=OC("radius","float",r).setGroup(Kw),o=OC("mapSize","vec2",r).setGroup(Kw);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new LN);l.fragmentNode=NI({samples:i,radius:a,size:o,shadowPass:t}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new LN),l.fragmentNode=PI({samples:i,radius:a,size:o,shadowPass:n}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=OC("intensity","float",r).setGroup(Kw),l=OC("normalBias","float",r).setGroup(Kw),u=dI(n).mul(xI.add(vC.mul(l))),c=this.setupShadowCoord(e,u),A=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===A)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=3===i?this.vsmShadowMapHorizontal.texture:s,d=this.setupShadowFilter(e,{filterFn:A,shadowTexture:a.texture,depthTexture:h,shadowCoord:c,shadow:r}),p=HE(a.texture,c),f=$M(1,d.rgb.mix(p,1),o.mul(p.a)).toVar();return this.shadowMap=a,this.shadow.map=a,f}setup(e){if(!1!==e.renderer.shadowMap.enabled)return Sw((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:s}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height),i.render(s,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:s,camera:a}=e,o=i.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l,r.camera.layers.mask=a.layers.mask;const u=i.getRenderObjectFunction(),c=i.getMRT(),A=!!c&&c.has("velocity");LI=function(e,t,n){return n=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,n=bI(e,n)),n}(i,s,LI),s.overrideMaterial=TI(n),i.setRenderObjectFunction(((e,t,n,s,l,u,...c)=>{(!0===e.castShadow||e.receiveShadow&&3===o)&&(A&&(yS(e).useVelocity=!0),e.onBeforeShadow(i,e,a,r.camera,s,t.overrideMaterial,u),i.renderObject(e,t,n,s,l,u,...c),e.onAfterShadow(i,e,a,r.camera,s,t.overrideMaterial,u))})),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),!0!==n.isPointLight&&3===o&&this.vsmPass(i),function(e,t,n){!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,n),function(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}(t,n)}(i,s,LI)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),II.material=this.vsmMaterialVertical,II.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),II.material=this.vsmMaterialHorizontal,II.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}class BI extends rN{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Rr,this.colorNode=e&&e.colorNode||eT(this.color).setGroup(Kw),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=SS}customCacheKey(){return dS(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return((e,t)=>_w(new UI(e,t)))(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let n=this.shadowColorNode;if(null===n){const t=this.light.shadow.shadowNode;let r;r=void 0!==t?_w(t):this.setupShadowNode(e),this.shadowNode=r,this.shadowColorNode=n=this.colorNode.mul(r),this.baseColorNode=this.colorNode}this.colorNode=n}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)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const OI=Sw((e=>{const{lightDistance:t,cutoffDistance:n,decayExponent:r}=e,i=t.pow(r).max(.01).reciprocal();return n.greaterThan(0).select(i.mul(t.div(n).pow4().oneMinus().clamp().pow2()),i)})),FI=new Rr,kI=Sw((([e,t])=>{const n=e.toVar(),r=SM(n),i=BT(1,OM(r.x,OM(r.y,r.z)));r.mulAssign(i),n.mulAssign(i.mul(t.mul(2).oneMinus()));const s=Dw(n.xy).toVar(),a=t.mul(1.5).oneMinus();return Mw(r.z.greaterThanEqual(a),(()=>{Mw(n.z.greaterThan(0),(()=>{s.x.assign(IT(4,n.x))}))})).ElseIf(r.x.greaterThanEqual(a),(()=>{const e=wM(n.x);s.x.assign(n.z.mul(e).add(e.mul(2)))})).ElseIf(r.y.greaterThanEqual(a),(()=>{const e=wM(n.y);s.x.assign(n.x.add(e.mul(2)).add(2)),s.y.assign(n.z.mul(e).sub(2))})),Dw(.125,.25).mul(s).add(Dw(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),qI=Sw((({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>HE(e,kI(t,r.y)).compare(n))),GI=Sw((({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{const s=OC("radius","float",i).setGroup(Kw),a=Dw(-1,1).mul(s).mul(r.y);return HE(e,kI(t.add(a.xyy),r.y)).compare(n).add(HE(e,kI(t.add(a.yyy),r.y)).compare(n)).add(HE(e,kI(t.add(a.xyx),r.y)).compare(n)).add(HE(e,kI(t.add(a.yyx),r.y)).compare(n)).add(HE(e,kI(t,r.y)).compare(n)).add(HE(e,kI(t.add(a.xxy),r.y)).compare(n)).add(HE(e,kI(t.add(a.yxy),r.y)).compare(n)).add(HE(e,kI(t.add(a.xxx),r.y)).compare(n)).add(HE(e,kI(t.add(a.yxx),r.y)).compare(n)).mul(1/9)})),zI=Sw((({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r})=>{const i=n.xyz.toVar(),s=i.length(),a=eT("float").setGroup(Kw).onRenderUpdate((()=>r.camera.near)),o=eT("float").setGroup(Kw).onRenderUpdate((()=>r.camera.far)),l=OC("bias","float",r).setGroup(Kw),u=eT(r.mapSize).setGroup(Kw),c=Cw(1).toVar();return Mw(s.sub(o).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),(()=>{const n=s.sub(a).div(o.sub(a)).toVar();n.addAssign(l);const A=i.normalize(),h=Dw(1).div(u.mul(Dw(4,2)));c.assign(e({depthTexture:t,bd3D:A,dp:n,texelSize:h,shadow:r}))})),c})),VI=new en,HI=new Lt,jI=new Lt;class WI extends UI{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return 0===e?qI:GI}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:s}){return zI({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:s})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:s}=e,a=t.getFrameExtents();jI.copy(t.mapSize),jI.multiply(a),n.setSize(jI.width,jI.height),HI.copy(t.mapSize);const o=i.autoClear,l=i.getClearColor(FI),u=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const c=t.getViewportCount();for(let e=0;e{const s=i.context.lightingModel,a=t.sub(uC),o=a.normalize(),l=a.length(),u=OI({lightDistance:l,cutoffDistance:n,decayExponent:r}),c=e.mul(u),A=i.context.reflectedLight;s.direct({lightDirection:o,lightColor:c,reflectedLight:A},i.stack,i)}));class QI extends BI{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=eT(0).setGroup(Kw),this.decayExponentNode=eT(2).setGroup(Kw)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return((e,t)=>_w(new WI(e,t)))(this.light)}setup(e){super.setup(e),XI({color:this.colorNode,lightViewPosition:fI(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const YI=Sw((([e,t])=>{const n=e.x,r=e.y,i=e.z;let s=t.element(0).mul(.886227);return s=s.add(t.element(1).mul(1.023328).mul(r)),s=s.add(t.element(2).mul(1.023328).mul(i)),s=s.add(t.element(3).mul(1.023328).mul(n)),s=s.add(t.element(4).mul(.858086).mul(n).mul(r)),s=s.add(t.element(5).mul(.858086).mul(r).mul(i)),s=s.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),s=s.add(t.element(7).mul(.858086).mul(n).mul(i)),s=s.add(t.element(8).mul(.429043).mul(UT(n,n).sub(UT(r,r)))),s})),$I=new RL;class KI extends eL{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let s=!1;if(null===i)r._clearColor.getRGB($I,it),$I.a=r._clearColor.a;else if(!0===i.isColor)i.getRGB($I,it),$I.a=1,s=!0;else if(!0===i.isNode){const n=this.get(e),s=i;$I.copy(r._clearColor);let a=n.backgroundMesh;if(void 0===a){const e=sE(qw(s).mul(zL),{getUV:()=>VL.mul(gC),getTextureLevel:()=>GL});let t=FR;t=t.setZ(t.w);const r=new LN;r.name="Background.material",r.side=1,r.depthTest=!1,r.depthWrite=!1,r.fog=!1,r.lights=!1,r.vertexNode=t,r.colorNode=e,n.backgroundMeshNode=e,n.backgroundMesh=a=new ci(new la(1,32,32),r),a.frustumCulled=!1,a.name="Background.mesh",a.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)}}const o=s.getCacheKey();n.backgroundCacheKey!==o&&(n.backgroundMeshNode.node=qw(s).mul(zL),n.backgroundMeshNode.needsUpdate=!0,a.material.needsUpdate=!0,n.backgroundCacheKey=o),t.unshift(a,a.geometry,a.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);if(!0===r.autoClear||!0===s){const e=n.clearColorValue;e.r=$I.r,e.g=$I.g,e.b=$I.b,e.a=$I.a,!0!==r.backend.isWebGLBackend&&!0!==r.alpha||(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=!0===r.autoClearColor,n.clearDepth=!0===r.autoClearDepth,n.clearStencil=!0===r.autoClearStencil}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let ZI=0;class JI{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=ZI++}}class eU{constructor(e,t,n,r,i,s,a,o,l,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=u,this.nodeAttributes=r,this.bindings=i,this.updateNodes=s,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.monitor=l,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const n=new JI(t.name,[],t.index,t);e.push(n);for(const e of t.bindings)n.bindings.push(e.clone())}else e.push(t)}return e}}class tU{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class nU{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class rU{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class iU extends rU{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class sU{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let aU=0;class oU{constructor(e=null){this.id=aU++,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 lU extends LS{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class uU{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class cU extends uU{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class AU extends uU{constructor(e,t=new Lt){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class hU extends uU{constructor(e,t=new on){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class dU extends uU{constructor(e,t=new en){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class pU extends uU{constructor(e,t=new Rr){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class fU extends uU{constructor(e,t=new It){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class mU extends uU{constructor(e,t=new On){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class gU extends cU{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class _U extends AU{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class vU extends hU{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class yU extends dU{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class xU extends pU{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class bU extends fU{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class SU extends mU{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const wU=[.125,.215,.35,.446,.526,.582],TU=20,MU=new za(-1,1,1,-1,0,1),EU=new bi(90,1),CU=new Rr;let RU=null,NU=0,PU=0;const DU=(1+Math.sqrt(5))/2,LU=1/DU,IU=[new on(-DU,LU,0),new on(DU,LU,0),new on(-LU,0,DU),new on(LU,0,DU),new on(0,DU,-LU),new on(0,DU,LU),new on(-1,1,-1),new on(1,1,-1),new on(-1,1,1),new on(1,1,1)],UU=[3,1,5,0,4,2],BU=dD(FE(),OE("faceIndex")).normalize(),OU=Bw(BU.x,BU.y,BU.z);class FU{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i=null){if(this._setSize(256),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const s=i||this._allocateTargets();return this.fromSceneAsync(e,t,n,r,s),s}RU=this._renderer.getRenderTarget(),NU=this._renderer.getActiveCubeFace(),PU=this._renderer.getActiveMipmapLevel();const s=i||this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}async fromSceneAsync(e,t=0,n=.1,r=100,i=null){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=zU(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=VU(),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===q||e.mapping===G?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?l=wU[o-e+4-1]:0===o&&(l=0),r.push(l);const u=1/(a-2),c=-u,A=1+u,h=[c,c,A,c,A,A,c,c,A,A,c,A],d=6,p=6,f=3,m=2,g=1,_=new Float32Array(f*p*d),v=new Float32Array(m*p*d),y=new Float32Array(g*p*d);for(let e=0;e2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=UU[e];_.set(r,f*p*i),v.set(h,m*p*i);const s=[i,i,i,i,i,i];y.set(s,g*p*i)}const x=new Zr;x.setAttribute("position",new qr(_,f)),x.setAttribute("uv",new qr(v,m)),x.setAttribute("faceIndex",new qr(y,g)),t.push(x),i.push(new ci(x,null)),s>4&&s--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}(r)),this._blurMaterial=function(e,t,n){const r=IC(new Array(TU).fill(0)),i=eT(new on(0,1,0)),s=eT(0),a=Cw(TU),o=eT(0),l=eT(1),u=HE(null),c=eT(0),A=Cw(1/t),h=Cw(1/n),d=Cw(e),p={n:a,latitudinal:o,weights:r,poleAxis:i,outputDirection:OU,dTheta:s,samples:l,envMap:u,mipInt:c,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:d},f=GU("blur");return f.uniforms=p,f.fragmentNode=gD({...p,latitudinal:o.equal(1)}),f}(r,e,t)}return r}async _compileMaterial(e){const t=new ci(this._lodPlanes[0],e);await this._renderer.compile(t,MU)}_sceneToCubeUV(e,t,n,r){const i=EU;i.near=t,i.far=n;const s=[1,1,1,1,-1,1],a=[1,-1,1,-1,1,-1],o=this._renderer,l=o.autoClear;o.getClearColor(CU),o.autoClear=!1;let u=this._backgroundBox;if(null===u){const e=new Lr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1});u=new ci(new hi,e)}let c=!1;const A=e.background;A?A.isColor&&(u.material.color.copy(A),e.background=null,c=!0):(u.material.color.copy(CU),c=!0),o.setRenderTarget(r),o.clear(),c&&o.render(u,i);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,s[t],0),i.lookAt(a[t],0,0)):1===n?(i.up.set(0,0,s[t]),i.lookAt(0,a[t],0)):(i.up.set(0,s[t],0),i.lookAt(0,0,a[t]));const l=this._cubeSize;qU(r,n*l,t>2?l:0,l,l),o.render(e,i)}o.autoClear=l,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===q||e.mapping===G;r?null===this._cubemapMaterial&&(this._cubemapMaterial=zU(e)):null===this._equirectMaterial&&(this._equirectMaterial=VU(e));const i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const s=this._lodMeshes[0];s.material=i;const a=this._cubeSize;qU(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,MU)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let t=1;tTU&&console.warn(`sigmaRadians, ${i}, 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?r-g+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(u,MU)}}function kU(e,t,n){const r=new tn(e,t,n);return r.texture.mapping=H,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function qU(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function GU(e){const t=new LN;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function zU(e){const t=GU("cubemap");return t.fragmentNode=RC(e,OU),t}function VU(e){const t=GU("equirect");return t.fragmentNode=HE(e,GN(OU),0),t}const HU=new WeakMap,jU=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),WU=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class XU{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=DL(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new oU,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=HU.get(this.renderer);return void 0===e&&(e=new YD,HU.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new tn(e,t,n)}createCubeRenderTarget(e,t){return new zN(e,t)}createPMREMGenerator(){return new FU(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let i,s=!0;for(const e of t)r.push(e),s=s&&!0!==e.groupNode.shared;return s?(i=n.get(r),void 0===i&&(i=new JI(e,r,this.bindingsIndexes[e].group,r),n.set(r,i))):i=new JI(e,r,this.bindingsIndexes[e].group,r),i}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return void 0===r&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(null===e){const t={},n=this.bindings;for(const e of NS)for(const r in n[e]){const i=n[e][r];(t[r]||(t[r]=[])).push(...i)}e=[];for(const n in t){const r=t[n],i=this._getBindGroup(n,r);e.push(i)}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")}( ${WU(t.r)}, ${WU(t.g)}, ${WU(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(2===n)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(3===n)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(4===n)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(", ")} )`;if(n>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 n=this.attributes;for(const t of n)if(t.name===e)return t;const r=new tU(e,t);return n.push(r),r}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||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ie)return"int";if(t===se)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;const n=function(e){return mS.get(e)}(e);return("float"===t?"":t[0])+n}getTypeFromArray(e){return jU.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,i=e.normalized;let s;return e instanceof Vr||!0===i||(s=this.getTypeFromArray(n)),this.getTypeFromLength(r,s)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return null!==n?Number(n[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=DL(this.stack),this.stacks.push(Tw()||this.stack),ww(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,ww(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){let r=(n=null===n?e.isGlobal(this)?this.globalCache:this.cache:n).getData(e);return void 0===r&&(r={},n.setData(e,r)),void 0===r[t]&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let r=n.bufferAttribute;if(void 0===r){const i=this.uniforms.index++;r=new tU("nodeAttribute"+i,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e,n);let i=r.structType;if(void 0===i){const e=this.structs.index++;i=new lU("StructType"+e,t),this.structs[n].push(i),r.structType=i}return i}getUniformFromNode(e,t,n=this.shaderStage,r=null){const i=this.getDataFromNode(e,n,this.globalCache);let s=i.uniform;if(void 0===s){const a=this.uniforms.index++;s=new nU(r||"nodeUniform"+a,t,e),this.uniforms[n].push(s),i.uniform=s}return s}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){const i=this.getDataFromNode(e,r);let s=i.variable;if(void 0===s){const e=this.vars[r]||(this.vars[r]=[]);null===t&&(t="nodeVar"+e.length),s=new rU(t,n),e.push(s),i.variable=s}return s}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let i=r.varying;if(void 0===i){const e=this.varyings,s=e.length;null===t&&(t="nodeVarying"+s),i=new iU(t,n),e.push(i),r.varying=i}return i}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let i=r.code;if(void 0===i){const e=this.codes[n]||(this.codes[n]=[]),s=e.length;i=new sU("nodeCode"+s,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let i=!0,s=t;for(;s;){if(!0===r.get(s)){i=!1;break}s=this.getDataFromNode(s).parentNodeBlock}if(i)for(const e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),i=r.flowCodes||(r.flowCodes=[]),s=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);i.push(t),s.set(n,!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),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new sI,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[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)n[e.name]=new NL(e.type,e.name);e.layout=null;const r=e.call(n),i=this.flowStagesNode(r,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,i=this.cache,s=this.buildStage,a=this.stack,o={code:""};this.flow=o,this.vars={},this.cache=new oU,this.stack=DL();for(const n of RS)this.setBuildStage(n),o.result=e.build(this,t);return o.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=i,this.stack=a,this.setBuildStage(s),o}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const i=this.shaderStage;this.setShaderStage(e);const s=this.flowChildNode(t,n);return null!==r&&(s.code+=`${this.tab+r} = ${s.result};\n`),this.flowCode[e]=this.flowCode[e]+s.code,this.setShaderStage(i),s}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(void 0!==n)for(const e of n)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(void 0!==t)for(const e of t)n+=e.code+"\n";return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(null!==t){let e=n.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new LN),e.build(this)}else this.addFlow("compute",e);for(const e of RS){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of NS){this.setShaderStage(t);const n=this.flowNodes[t];for(const t of n)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new gU(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new _U(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new vU(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new yU(e);if("color"===t)return new xU(e);if("mat3"===t)return new bU(e);if("mat4"===t)return new SU(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if((t=this.getVectorType(t))===(n=this.getVectorType(n))||null===n||this.isReference(n))return e;const r=this.getTypeLength(t),i=this.getTypeLength(n);return 16===r&&9===i?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:9===r&&4===i?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||i>4||0===i?e:r===i?`${this.getType(n)}( ${e} )`:r>i?this.format(`${e}.${"xyz".slice(0,i)}`,this.getTypeFromLength(i,this.getComponentType(t)),n):4===i&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===r?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===r&&i>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${s} - Node System\n`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class QU{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 n=e.get(t);return void 0===n&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===SS){const{frameMap:t}=this._getMaps(this.updateBeforeMap,n);t.get(n)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(n,this.frameId)}else if(t===wS){const{renderMap:t}=this._getMaps(this.updateBeforeMap,n);t.get(n)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(n,this.renderId)}else t===TS&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===SS){const{frameMap:t}=this._getMaps(this.updateAfterMap,n);t.get(n)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(n,this.frameId)}else if(t===wS){const{renderMap:t}=this._getMaps(this.updateAfterMap,n);t.get(n)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(n,this.renderId)}else t===TS&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===SS){const{frameMap:t}=this._getMaps(this.updateMap,n);t.get(n)!==this.frameId&&!1!==e.update(this)&&t.set(n,this.frameId)}else if(t===wS){const{renderMap:t}=this._getMaps(this.updateMap,n);t.get(n)!==this.renderId&&!1!==e.update(this)&&t.set(n,this.renderId)}else t===TS&&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 YU{constructor(e,t,n=null,r="",i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}}YU.isNodeFunctionInput=!0;class $U extends BI{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=mI(this.light),i=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:i},e.stack,e)}}const KU=new On,ZU=new On;let JU=null;class eB extends BI{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=eT(new on).setGroup(Kw),this.halfWidth=eT(new on).setGroup(Kw),this.updateType=wS}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;ZU.identity(),KU.copy(t.matrixWorld),KU.premultiply(n),ZU.extractRotation(KU),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(ZU),this.halfHeight.value.applyMatrix4(ZU)}setup(e){let t,n;super.setup(e),e.isAvailable("float32Filterable")?(t=HE(JU.LTC_FLOAT_1),n=HE(JU.LTC_FLOAT_2)):(t=HE(JU.LTC_HALF_1),n=HE(JU.LTC_HALF_2));const{colorNode:r,light:i}=this,s=e.context.lightingModel,a=fI(i),o=e.context.reflectedLight;s.directRectArea({lightColor:r,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:o,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){JU=e}}class tB extends BI{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=eT(0).setGroup(Kw),this.penumbraCosNode=eT(0).setGroup(Kw),this.cutoffDistanceNode=eT(0).setGroup(Kw),this.decayExponentNode=eT(0).setGroup(Kw)}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){const{coneCosNode:t,penumbraCosNode:n}=this;return JM(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:i,light:s}=this,a=fI(s).sub(uC),o=a.normalize(),l=o.dot(mI(s)),u=this.getSpotAttenuation(l),c=a.length(),A=OI({lightDistance:c,cutoffDistance:r,decayExponent:i});let h=n.mul(u).mul(A);if(s.map){const e=function(e){const t=hI(e);if(void 0===t.projectionUV){const n=dI(e).mul(oC);t.projectionUV=n.xyz.div(n.w)}return t.projectionUV}(s),t=HE(s.map,e.xy).onRenderUpdate((()=>s.map));h=e.mul(2).sub(1).abs().lessThan(1).all().select(h.mul(t),h)}const d=e.context.reflectedLight;t.direct({lightDirection:o,lightColor:h,reflectedLight:d},e.stack,e)}}class nB extends tB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&!0===t.isTexture){const r=e.acos().mul(1/Math.PI);n=HE(t,Dw(r,0),0).r}else n=super.getSpotAttenuation(e);return n}}class rB extends BI{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class iB extends BI{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=pI(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=eT(new Rr).setGroup(Kw)}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:n,lightDirectionNode:r}=this,i=mC.dot(r).mul(.5).add(.5),s=$M(n,t,i);e.context.irradiance.addAssign(s)}}class sB extends BI{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new on);this.lightProbe=IC(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=YI(gC,this.lightProbe);e.context.irradiance.addAssign(t)}}class aB{parseFunction(){console.warn("Abstract function.")}}class oB{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}oB.isNodeFunction=!0;const lB=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,uB=/[a-z_0-9]+/gi,cB="#pragma main";class AB extends oB{constructor(e){const{type:t,inputs:n,name:r,precision:i,inputsCode:s,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(cB),n=-1!==t?e.slice(t+12):e,r=n.match(lB);if(null!==r&&5===r.length){const i=r[4],s=[];let a=null;for(;null!==(a=uB.exec(i));)s.push(a);const o=[];let l=0;for(;l0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==n||r){const i=this.getCacheNode("background",n,(()=>{if(!0===n.isCubeTexture||n.mapping===z||n.mapping===V||n.mapping===H){if(e.backgroundBlurriness>0||n.mapping===H)return bD(n);{let e;return e=!0===n.isCubeTexture?RC(n):HE(n),XN(e)}}if(!0===n.isTexture)return HE(n,AN.flipY()).setUpdateMatrix(!0);!0!==n.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",n)}),r);t.backgroundNode=i,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let s=i.get(t);return(void 0===s||r)&&(s=n(),i.set(t,s)),s}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const e=this.getCacheNode("fog",n,(()=>{if(n.isFogExp2){const e=OC("color","color",n).setGroup(Kw),t=OC("density","float",n).setGroup(Kw);return uI(e,lI(t))}if(n.isFog){const e=OC("color","color",n).setGroup(Kw),t=OC("near","float",n).setGroup(Kw),r=OC("far","float",n).setGroup(Kw);return uI(e,oI(t,r))}console.error("THREE.Renderer: Unsupported fog configuration.",n)}));t.fogNode=e,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const e=this.getCacheNode("environment",n,(()=>!0===n.isCubeTexture?RC(n):!0===n.isTexture?HE(n):void console.error("Nodes: Unsupported environment configuration.",n)));t.environmentNode=e,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,i=null){const s=this.nodeFrame;return s.renderer=e,s.scene=t,s.object=n,s.camera=r,s.material=i,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}hasOutputChange(e){return dB.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=HE(e,AN).renderOutput(t.toneMapping,t.currentColorSpace);return dB.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const e of n.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const e of n.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new QU,this.nodeBuilderCache=new Map,this.cacheLib={}}}const fB=new Oi;class mB{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new It,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,n){const r=e.length;for(let i=0;i{await this.compileAsync(e,t);const r=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),s=e.overrideMaterial||n.material,a=this._objects.get(n,s,e,t,r.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:l}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:l}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){return void t(e)}}this._nodes=new pB(this,n),this._animation=new QD(this._nodes,this.info),this._attributes=new aL(n),this._background=new KI(this,this._nodes),this._geometries=new uL(this._attributes,this.info),this._textures=new CL(this,n,this.info),this._pipelines=new mL(n,this._nodes),this._bindings=new gL(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new JD(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new bL(this.lighting),this._bundles=new _B,this._renderContexts=new ML,this._animation.start(),this._initialized=!0,e()}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const r=this._nodes.nodeFrame,i=r.renderId,s=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,l=!0===e.isScene?e:bB;null===n&&(n=e);const u=this._renderTarget,c=this._renderContexts.get(n,t,u),A=this._activeMipmapLevel,h=[];this._currentRenderContext=c,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,r.renderId++,r.update(),c.depth=this.depth,c.stencil=this.stencil,c.clippingContext||(c.clippingContext=new mB),c.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,u);const d=this._renderLists.get(e,t);if(d.begin(),this._projectObject(e,t,0,d,c.clippingContext),n!==e&&n.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&d.pushLight(e)})),d.finish(),null!==u){this._textures.updateRenderTarget(u,A);const e=this._textures.get(u);c.textures=e.textures,c.depthTexture=e.depthTexture}else c.textures=null,c.depthTexture=null;this._background.update(l,d,c);const p=d.opaque,f=d.transparent,m=d.transparentDoublePass,g=d.lightsNode;!0===this.opaque&&p.length>0&&this._renderObjects(p,t,l,g),!0===this.transparent&&f.length>0&&this._renderTransparents(f,m,t,l,g),r.renderId=i,this._currentRenderContext=s,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init();const n=this._renderScene(e,t);await this.backend.resolveTimestampAsync(n,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:i,renderList:s}=e,a=this._currentRenderContext,o=this._bundles.get(r,i),l=this.backend.get(o);void 0===l.renderContexts&&(l.renderContexts=new Set);const u=r.version!==l.version,c=!1===l.renderContexts.has(a)||u;if(l.renderContexts.add(a),c){this.backend.beginBundle(a),(void 0===l.renderObjects||u)&&(l.renderObjects=[]),this._currentRenderBundle=o;const e=s.opaque;!0===this.opaque&&e.length>0&&this._renderObjects(e,i,t,n),this._currentRenderBundle=null,this.backend.finishBundle(a,o),l.version=r.version}else{const{renderObjects:e}=l;for(let t=0,n=e.length;t>=A,d.viewportValue.height>>=A,d.viewportValue.minDepth=_,d.viewportValue.maxDepth=v,d.viewport=!1===d.viewportValue.equals(wB),d.scissorValue.copy(m).multiplyScalar(g).floor(),d.scissor=this._scissorTest&&!1===d.scissorValue.equals(wB),d.scissorValue.width>>=A,d.scissorValue.height>>=A,d.clippingContext||(d.clippingContext=new mB),d.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,h),MB.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),TB.setFromProjectionMatrix(MB,p);const y=this._renderLists.get(e,t);if(y.begin(),this._projectObject(e,t,0,y,d.clippingContext),y.finish(),!0===this.sortObjects&&y.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,A);const e=this._textures.get(h);d.textures=e.textures,d.depthTexture=e.depthTexture,d.width=e.width,d.height=e.height,d.renderTarget=h,d.depth=h.depthBuffer,d.stencil=h.stencilBuffer}else d.textures=null,d.depthTexture=null,d.width=this.domElement.width,d.height=this.domElement.height,d.depth=this.depth,d.stencil=this.stencil;d.width>>=A,d.height>>=A,d.activeCubeFace=c,d.activeMipmapLevel=A,d.occlusionQueryCount=y.occlusionQueryCount,this._background.update(l,y,d),this.backend.beginRender(d);const{bundles:x,lightsNode:b,transparentDoublePass:S,transparent:w,opaque:T}=y;if(x.length>0&&this._renderBundles(x,l,b),!0===this.opaque&&T.length>0&&this._renderObjects(T,t,l,b),!0===this.transparent&&w.length>0&&this._renderTransparents(w,S,t,l,b),this.backend.finishRender(d),i.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==r){this.setRenderTarget(u,c,A);const e=this._quad;this._nodes.hasOutputChange(h.texture)&&(e.material.fragmentNode=this._nodes.getOutputNode(h.texture),e.material.needsUpdate=!0),this._renderScene(e,e.camera,!1)}return l.onAfterRender(this,e,t,h),d}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,n=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===n&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,i=0,s=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,n,r),a.minDepth=i,a.maxDepth=s}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const r=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==r){this._textures.updateRenderTarget(r);const e=this._textures.get(r);i=this._renderContexts.get(null,null,r),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=r,i.depth=r.depthBuffer,i.stencil=r.stencilBuffer}if(this.backend.clear(e,t,n,i),null!==r&&null===this._renderTarget){const e=this._quad;this._nodes.hasOutputChange(r.texture)&&(e.material.fragmentNode=this._nodes.getOutputNode(r.texture),e.material.needsUpdate=!0),this._renderScene(e,e.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){!1===this._initialized&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return null!==this._renderTarget?0:this.toneMapping}get currentColorSpace(){return null!==this._renderTarget?it:this.outputColorSpace}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this.isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,n=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const r=this.backend,i=this._pipelines,s=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");r.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),s.delete(t),a.delete(t)};t.addEventListener("dispose",e);const n=t.onInitFunction;null!==n&&n.call(t,{renderer:this})}a.updateForCompute(t),s.updateForCompute(t);const n=s.getForCompute(t),o=i.getForCompute(t,n);r.compute(e,t,n,o)}r.finishCompute(e),t.renderId=n}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=EB.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=EB.copy(t).floor()}else t=EB.set(0,0,e.image.width,e.image.height);let n,r=this._currentRenderContext;null!==r?n=r.renderTarget:(n=this._renderTarget||this._getFrameBufferTarget(),null!==n&&(this._textures.updateRenderTarget(n),r=this._textures.get(n))),this._textures.updateTexture(e,{renderTarget:n}),this.backend.copyFramebufferToTexture(e,r,t)}copyTextureToTexture(e,t,n=null,r=null,i=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,i)}async readRenderTargetPixelsAsync(e,t,n,r,i,s=0,a=0){return this.backend.copyTextureToBuffer(e.textures[s],t,n,r,i,a)}_projectObject(e,t,n,r,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||TB.intersectsSprite(e)){!0===this.sortObjects&&EB.setFromMatrixPosition(e.matrixWorld).applyMatrix4(MB);const{geometry:t,material:s}=e;s.visible&&r.push(e,t,s,n,EB.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||TB.intersectsObject(e))){const{geometry:t,material:s}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),EB.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(MB)),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,n,r,i,"backSide");for(const{material:e}of t)e.side=0;this._renderObjects(e,n,r,i);for(const{material:e}of t)e.side=2}else this._renderObjects(e,n,r,i)}_renderObjects(e,t,n,r,i=null){for(let s=0,a=e.length;s0,e.isShadowNodeMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(A=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(c=e.colorNode,e.colorNode=i.castShadowNode)),i=e}!0===i.transparent&&2===i.side&&!1===i.forceSinglePass?(i.side=1,this._handleObjectFunction(e,i,t,n,a,s,o,"backSide"),i.side=0,this._handleObjectFunction(e,i,t,n,a,s,o,l),i.side=2):this._handleObjectFunction(e,i,t,n,a,s,o,l),void 0!==u&&(t.overrideMaterial.positionNode=u),void 0!==A&&(t.overrideMaterial.depthNode=A),void 0!==c&&(t.overrideMaterial.colorNode=c),e.onAfterRender(this,t,n,r,i,s)}_renderObjectDirect(e,t,n,r,i,s,a,o){const l=this._objects.get(e,t,n,r,i,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=s;const u=this._nodes.needsRefresh(l);if(u&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(l,this.info),u&&this._nodes.updateAfter(l)}_createObjectPipeline(e,t,n,r,i,s,a,o){const l=this._objects.get(e,t,n,r,i,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=s,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}get compile(){return this.compileAsync}}class RB{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}let NB=class extends RB{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(sL-e%sL)%sL;var e}get buffer(){return this._buffer}update(){return!0}};class PB extends NB{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let DB=0;class LB extends PB{constructor(e,t){super("UniformBuffer_"+DB++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class IB extends PB{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=0;for(let t=0,n=this.uniforms.length;t0?r:"";t=`${e.name} {\n\t${n} ${i.name}[${s}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,s=!0}const a=i.node.precision;if(null!==a&&(t=VB[a]+" "+t),s){t="\t"+t;const e=i.groupNode.name;(r[e]||(r[e]=[])).push(t)}else t="uniform "+t,n.push(t)}let i="";for(const t in r){const n=r[t];i+=this._getGLSLUniformStruct(e+"_"+t,n.join("\n"))+"\n"}return i+=n.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==ie){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;!1==(r instanceof Uint32Array||r instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let n=0;for(const r of e)t+=`layout( location = ${n++} ) in ${r.type} ${r.name};\n`}return t}getStructMembers(e){const t=[],n=e.getMemberTypes();for(let e=0;ee*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);!1===r.has(e)&&r.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 n=this.extensions[e];if(void 0!==n)for(const{name:e,behavior:r}of n.values())t.push(`#extension ${e} : ${r}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=HB[e];if(void 0===t){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance"}if(void 0!==n){const e=this.renderer.backend.extensions;e.has(n)&&(e.get(n),t=!0)}HB[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n0&&(n+="\n"),n+=`\t// flow -> ${s}\n\t`),n+=`${r.code}\n\t`,e===i&&"compute"!==t&&(n+="// result\n\t","vertex"===t?(n+="gl_Position = ",n+=`${r.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${r.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=n}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const i=super.getUniformFromNode(e,t,n,r),s=this.getDataFromNode(e,n,this.globalCache);let a=s.uniformGPU;if(void 0===a){const r=e.groupNode,o=r.name,l=this.getBindGroupArray(o,n);if("texture"===t)a=new kB(i.name,i.node,r),l.push(a);else if("cubeTexture"===t)a=new qB(i.name,i.node,r),l.push(a);else if("texture3D"===t)a=new GB(i.name,i.node,r),l.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new LB(e,r);t.name=e.name,l.push(t),a=t}else{const e=this.uniformGroups[n]||(this.uniformGroups[n]={});let s=e[o];void 0===s&&(s=new BB(n+"_"+o,r),e[o]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}s.uniformGPU=a}return i}}let XB=null,QB=null;class YB{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return XB=XB||new Lt,this.renderer.getDrawingBufferSize(XB)}setScissorTest(){}getClearColor(){const e=this.renderer;return QB=QB||new RL,e.getClearColor(QB),QB.getRGB(QB,this.renderer.currentColorSpace),QB}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:Ft(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${s} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let $B=0;class KB{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 ZB{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,i=e.array,s=e.usage||r.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=n.get(a);let l,u=o.bufferGPU;if(void 0===u&&(u=this._createBuffer(r,t,i,s),o.bufferGPU=u,o.bufferType=t,o.version=a.version),i instanceof Float32Array)l=r.FLOAT;else if(i instanceof Uint16Array)l=e.isFloat16BufferAttribute?r.HALF_FLOAT:r.UNSIGNED_SHORT;else if(i instanceof Int16Array)l=r.SHORT;else if(i instanceof Uint32Array)l=r.UNSIGNED_INT;else if(i instanceof Int32Array)l=r.INT;else if(i instanceof Int8Array)l=r.BYTE;else if(i instanceof Uint8Array)l=r.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);l=r.UNSIGNED_BYTE}let c={bufferGPU:u,bufferType:t,type:l,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===r.INT||l===r.UNSIGNED_INT||e.gpuType===ie,id:$B++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(r,t,i,s);c=new KB(c,e)}n.set(e,c)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,i=e.isInterleavedBufferAttribute?e.data:e,s=t.get(i),a=s.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(a,s.bufferGPU),0===o.length)n.bufferSubData(a,0,r);else{for(let e=0,t=o.length;e1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){const e=12288;for(let t=0;t<8;t++)t{!function i(){const s=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(s===e.WAIT_FAILED)return e.deleteSync(t),void r();s!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),n()):requestAnimationFrame(i)}()}))}}let iO,sO,aO,oO=!1;class lO{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===oO&&(this._init(this.gl),oO=!0)}_init(e){iO={[j]:e.REPEAT,[W]:e.CLAMP_TO_EDGE,[X]:e.MIRRORED_REPEAT},sO={[Q]:e.NEAREST,[Y]:e.NEAREST_MIPMAP_NEAREST,[$]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[Z]:e.LINEAR_MIPMAP_NEAREST,[J]:e.LINEAR_MIPMAP_LINEAR},aO={[lt]:e.NEVER,[ft]:e.ALWAYS,[ut]:e.LESS,[At]:e.LEQUAL,[ct]:e.EQUAL,[pt]:e.GEQUAL,[ht]:e.GREATER,[dt]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===Q||e===Y||e===$?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let n;return n=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,i=!1){const{gl:s,extensions:a}=this;if(null!==e){if(void 0!==s[e])return s[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;return t===s.RED&&(n===s.FLOAT&&(o=s.R32F),n===s.HALF_FLOAT&&(o=s.R16F),n===s.UNSIGNED_BYTE&&(o=s.R8),n===s.UNSIGNED_SHORT&&(o=s.R16),n===s.UNSIGNED_INT&&(o=s.R32UI),n===s.BYTE&&(o=s.R8I),n===s.SHORT&&(o=s.R16I),n===s.INT&&(o=s.R32I)),t===s.RED_INTEGER&&(n===s.UNSIGNED_BYTE&&(o=s.R8UI),n===s.UNSIGNED_SHORT&&(o=s.R16UI),n===s.UNSIGNED_INT&&(o=s.R32UI),n===s.BYTE&&(o=s.R8I),n===s.SHORT&&(o=s.R16I),n===s.INT&&(o=s.R32I)),t===s.RG&&(n===s.FLOAT&&(o=s.RG32F),n===s.HALF_FLOAT&&(o=s.RG16F),n===s.UNSIGNED_BYTE&&(o=s.RG8),n===s.UNSIGNED_SHORT&&(o=s.RG16),n===s.UNSIGNED_INT&&(o=s.RG32UI),n===s.BYTE&&(o=s.RG8I),n===s.SHORT&&(o=s.RG16I),n===s.INT&&(o=s.RG32I)),t===s.RG_INTEGER&&(n===s.UNSIGNED_BYTE&&(o=s.RG8UI),n===s.UNSIGNED_SHORT&&(o=s.RG16UI),n===s.UNSIGNED_INT&&(o=s.RG32UI),n===s.BYTE&&(o=s.RG8I),n===s.SHORT&&(o=s.RG16I),n===s.INT&&(o=s.RG32I)),t===s.RGB&&(n===s.FLOAT&&(o=s.RGB32F),n===s.HALF_FLOAT&&(o=s.RGB16F),n===s.UNSIGNED_BYTE&&(o=s.RGB8),n===s.UNSIGNED_SHORT&&(o=s.RGB16),n===s.UNSIGNED_INT&&(o=s.RGB32UI),n===s.BYTE&&(o=s.RGB8I),n===s.SHORT&&(o=s.RGB16I),n===s.INT&&(o=s.RGB32I),n===s.UNSIGNED_BYTE&&(o=r===rt&&!1===i?s.SRGB8:s.RGB8),n===s.UNSIGNED_SHORT_5_6_5&&(o=s.RGB565),n===s.UNSIGNED_SHORT_5_5_5_1&&(o=s.RGB5_A1),n===s.UNSIGNED_SHORT_4_4_4_4&&(o=s.RGB4),n===s.UNSIGNED_INT_5_9_9_9_REV&&(o=s.RGB9_E5)),t===s.RGB_INTEGER&&(n===s.UNSIGNED_BYTE&&(o=s.RGB8UI),n===s.UNSIGNED_SHORT&&(o=s.RGB16UI),n===s.UNSIGNED_INT&&(o=s.RGB32UI),n===s.BYTE&&(o=s.RGB8I),n===s.SHORT&&(o=s.RGB16I),n===s.INT&&(o=s.RGB32I)),t===s.RGBA&&(n===s.FLOAT&&(o=s.RGBA32F),n===s.HALF_FLOAT&&(o=s.RGBA16F),n===s.UNSIGNED_BYTE&&(o=s.RGBA8),n===s.UNSIGNED_SHORT&&(o=s.RGBA16),n===s.UNSIGNED_INT&&(o=s.RGBA32UI),n===s.BYTE&&(o=s.RGBA8I),n===s.SHORT&&(o=s.RGBA16I),n===s.INT&&(o=s.RGBA32I),n===s.UNSIGNED_BYTE&&(o=r===rt&&!1===i?s.SRGB8_ALPHA8:s.RGBA8),n===s.UNSIGNED_SHORT_4_4_4_4&&(o=s.RGBA4),n===s.UNSIGNED_SHORT_5_5_5_1&&(o=s.RGB5_A1)),t===s.RGBA_INTEGER&&(n===s.UNSIGNED_BYTE&&(o=s.RGBA8UI),n===s.UNSIGNED_SHORT&&(o=s.RGBA16UI),n===s.UNSIGNED_INT&&(o=s.RGBA32UI),n===s.BYTE&&(o=s.RGBA8I),n===s.SHORT&&(o=s.RGBA16I),n===s.INT&&(o=s.RGBA32I)),t===s.DEPTH_COMPONENT&&(n===s.UNSIGNED_INT&&(o=s.DEPTH24_STENCIL8),n===s.FLOAT&&(o=s.DEPTH_COMPONENT32F)),t===s.DEPTH_STENCIL&&n===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:n,extensions:r,backend:i}=this;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),n.texParameteri(e,n.TEXTURE_WRAP_S,iO[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,iO[t.wrapT]),e!==n.TEXTURE_3D&&e!==n.TEXTURE_2D_ARRAY||n.texParameteri(e,n.TEXTURE_WRAP_R,iO[t.wrapR]),n.texParameteri(e,n.TEXTURE_MAG_FILTER,sO[t.magFilter]);const s=void 0!==t.mipmaps&&t.mipmaps.length>0,a=t.minFilter===K&&s?J:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,sO[a]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,aO[t.compareFunction])),!0===r.has("EXT_texture_filter_anisotropic")){if(t.magFilter===Q)return;if(t.minFilter!==$&&t.minFilter!==J)return;if(t.type===ae&&!1===r.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const s=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,i=this.getGLTextureType(e);let s=r[i];void 0===s&&(s=t.createTexture(),n.state.bindTexture(i,s),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),r[i]=s),n.set(e,{textureGPU:s,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:i,width:s,height:a,depth:o}=t,l=r.utils.convert(e.format,e.colorSpace),u=r.utils.convert(e.type),c=this.getInternalFormat(e.internalFormat,l,u,e.colorSpace,e.isVideoTexture),A=n.createTexture(),h=this.getGLTextureType(e);r.state.bindTexture(h,A),this.setTextureParameters(h,e),e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,i,c,s,a,o):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,i,c,s,a,o):e.isVideoTexture||n.texStorage2D(h,i,c,s,a),r.set(e,{textureGPU:A,glTextureType:h,glFormat:l,glType:u,glInternalFormat:c})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:i,glTextureType:s,glFormat:a,glType:o}=r.get(t),{width:l,height:u}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(s,i),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(s,0,0,0,l,u,a,o,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:i}=t,{textureGPU:s,glTextureType:a,glFormat:o,glType:l,glInternalFormat:u}=this.backend.get(e);if(e.isRenderTargetTexture||void 0===s)return;const c=e=>e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||e instanceof OffscreenCanvas?e:e.data;if(this.backend.state.bindTexture(a,s),this.setTextureParameters(a,e),e.isCompressedTexture){const r=e.mipmaps,i=t.image;for(let t=0;t0,A=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(c){const n=0!==a||0!==o;let c,h;if(!0===e.isDepthTexture?(c=r.DEPTH_BUFFER_BIT,h=r.DEPTH_ATTACHMENT,t.stencil&&(c|=r.STENCIL_BUFFER_BIT)):(c=r.COLOR_BUFFER_BIT,h=r.COLOR_ATTACHMENT0),n){const e=this.backend.get(t.renderTarget),n=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(r.DRAW_FRAMEBUFFER,n),i.bindFramebuffer(r.READ_FRAMEBUFFER,h);const d=A-o-u;r.blitFramebuffer(a,d,a+l,d+u,a,d,a+l,d+u,c,r.NEAREST),i.bindFramebuffer(r.READ_FRAMEBUFFER,n),i.bindTexture(r.TEXTURE_2D,s),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,a,d,l,u),i.unbindTexture()}else{const e=r.createFramebuffer();i.bindFramebuffer(r.DRAW_FRAMEBUFFER,e),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,h,r.TEXTURE_2D,s,0),r.blitFramebuffer(0,0,l,u,0,0,l,u,c,r.NEAREST),r.deleteFramebuffer(e)}}else i.bindTexture(r.TEXTURE_2D,s),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,a,A-u-o,l,u),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:n}=this,r=t.renderTarget,{samples:i,depthTexture:s,depthBuffer:a,stencilBuffer:o,width:l,height:u}=r;if(n.bindRenderbuffer(n.RENDERBUFFER,e),a&&!o){let t=n.DEPTH_COMPONENT24;i>0?(s&&s.isDepthTexture&&s.type===n.FLOAT&&(t=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,i,t,l,u)):n.renderbufferStorage(n.RENDERBUFFER,t,l,u),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else a&&o&&(i>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,i,n.DEPTH24_STENCIL8,l,u):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,l,u),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,i,s){const{backend:a,gl:o}=this,{textureGPU:l,glFormat:u,glType:c}=this.backend.get(e),A=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,A);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+s:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,l,0);const d=this._getTypedArrayType(c),p=r*i*this._getBytesPerTexel(c,u),f=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,f),o.bufferData(o.PIXEL_PACK_BUFFER,p,o.STREAM_READ),o.readPixels(t,n,r,i,u,c,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const m=new d(p/d.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,f),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,m),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(A),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:n}=this;let r=0;return e===n.UNSIGNED_BYTE&&(r=1),e!==n.UNSIGNED_SHORT_4_4_4_4&&e!==n.UNSIGNED_SHORT_5_5_5_1&&e!==n.UNSIGNED_SHORT_5_6_5&&e!==n.UNSIGNED_SHORT&&e!==n.HALF_FLOAT||(r=2),e!==n.UNSIGNED_INT&&e!==n.FLOAT||(r=4),t===n.RGBA?4*r:t===n.RGB?3*r:t===n.ALPHA?r:void 0}}class uO{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 cO{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 n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const AO={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class hO{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:n,mode:r,object:i,type:s,info:a,index:o}=this;0!==o?n.drawElements(r,t,s,e):n.drawArrays(r,e,t),a.update(i,t,r,1)}renderInstances(e,t,n){const{gl:r,mode:i,type:s,index:a,object:o,info:l}=this;0!==n&&(0!==a?r.drawElementsInstanced(i,t,s,e,n):r.drawArraysInstanced(i,e,t,n),l.update(o,t,i,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:i,object:s,info:a}=this;if(0===n)return;const o=r.get("WEBGL_multi_draw");if(null===o)for(let r=0;r0)){const e=t.queryQueue.shift();this.initTimestampQuery(e)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const n=this.get(e);n.gpuQueries||(n.gpuQueries=[]);for(let e=0;e0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),i=r.previousContext,s=e.occlusionQueryCount;s>0&&(s>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0){const i=r.framebuffers[e.getCacheKey()],s=t.COLOR_BUFFER_BIT,a=r.msaaFrameBuffer,o=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,a),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let n=0;n{let a=0;for(let t=0;t0&&e.add(r[t]),n[t]=null,i.deleteQuery(s),a++))}a1?m.renderInstances(v,g,_):m.render(v,g),o.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,i,s){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,s)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new WB(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,i="fragment"===n?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(i,r),t.compileShader(i),this.set(e,{shaderGPU:i})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:i,vertexProgram:s}=r,a=n.createProgram(),o=this.get(i).shaderGPU,l=this.get(s).shaderGPU;if(n.attachShader(a,o),n.attachShader(a,l),n.linkProgram(a),this.set(r,{programGPU:a,fragmentShader:o,vertexShader:l}),null!==t&&this.parallel){const i=new Promise((t=>{const i=this.parallel,s=()=>{n.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),t()):requestAnimationFrame(s)};s()}));t.push(i)}else this._completeCompile(e,r)}_handleSource(e,t){const n=e.split("\n"),r=[],i=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let e=i;e":" "} ${i}: ${n[e]}`)}return r.join("\n")}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&""===i)return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const r=parseInt(s[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),r)}return i}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,i=r.getProgramInfoLog(e).trim();if(!1===r.getProgramParameter(e,r.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(r,e,n,t);else{const s=this._getShaderErrors(r,n,"vertex"),a=this._getShaderErrors(r,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+s+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:n,gl:r}=this,i=this.get(t),{programGPU:s,fragmentShader:a,vertexShader:o}=i;!1===r.getProgramParameter(s,r.LINK_STATUS)&&this._logProgramError(s,a,o),n.useProgram(s);const l=e.getBindings();this._setupBindings(l,s),this.set(t,{programGPU:s})}createComputePipeline(e,t){const{state:n,gl:r}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:s}=e,a=r.createProgram(),o=this.get(i).shaderGPU,l=this.get(s).shaderGPU,u=s.transforms,c=[],A=[];for(let e=0;eAO[t]===e)),n=this.extensions;for(let e=0;e0){if(void 0===h){const r=[];h=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,h);const i=[],u=e.textures;for(let n=0;n,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:_O,stripIndexFormat:UO},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:_O,stripIndexFormat:UO},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:i,height:s}=t.size,a=this.getTransferPipeline(r),o=this.getFlipYPipeline(r),l=this.device.createTexture({size:{width:i,height:s,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),u=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:CF,baseArrayLayer:n}),c=l.createView({baseMipLevel:0,mipLevelCount:1,dimension:CF,baseArrayLayer:0}),A=this.device.createCommandEncoder({}),h=(e,t,n)=>{const r=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),s=A.beginRenderPass({colorAttachments:[{view:n,loadOp:RO,storeOp:EO,clearValue:[0,0,0,0]}]});s.setPipeline(e),s.setBindGroup(0,i),s.draw(4,1,0,0),s.end()};h(a,u,c),h(o,c,u),this.device.queue.submit([A.finish()]),l.destroy()}generateMipmaps(e,t,n=0){const r=this.get(e);void 0===r.useCount&&(r.useCount=0,r.layers=[]);const i=r.layers[n]||this._mipmapCreateBundles(e,t,n),s=this.device.createCommandEncoder({});this._mipmapRunBundles(s,i),this.device.queue.submit([s.finish()]),0!==r.useCount&&(r.layers[n]=i),r.useCount++}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),i=r.getBindGroupLayout(0);let s=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:CF,baseArrayLayer:n});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,XF=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,QF={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_multisampled_2d:"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 YF extends oB{constructor(e){const{type:t,inputs:n,name:r,inputsCode:i,blockCode:s,outputType:a}=(e=>{const t=(e=e.trim()).match(WF);if(null!==t&&4===t.length){const n=t[2],r=[];let i=null;for(;null!==(i=XF.exec(n));)r.push({name:i[1],type:i[2]});const s=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class $F extends aB{parseFunction(e){return new YF(e)}}const KF="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},ZF={[MS]:"read",[ES]:"write",[CS]:"read_write"},JF={[j]:"repeat",[W]:"clamp",[X]:"mirror"},ek={vertex:KF?KF.VERTEX:1,fragment:KF?KF.FRAGMENT:2,compute:KF?KF.COMPUTE:4},tk={instance:!0,swizzleAssign:!1,storageBuffer:!0},nk={"^^":"tsl_xor"},rk={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"},ik={},sk={tsl_xor:new iI("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new iI("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new iI("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new iI("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new iI("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new iI("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new iI("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new iI("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 iI("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 iI("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new iI("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 iI("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new iI("\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")},ak={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"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(sk.pow_float=new iI("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),sk.pow_vec2=new iI("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[sk.pow_float]),sk.pow_vec3=new iI("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[sk.pow_float]),sk.pow_vec4=new iI("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[sk.pow_float]),ak.pow_float="tsl_pow_float",ak.pow_vec2="tsl_pow_vec2",ak.pow_vec3="tsl_pow_vec3",ak.pow_vec4="tsl_pow_vec4");let ok="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(ok+="diagnostic( off, derivative_uniformity );\n");class lk extends XU{constructor(e,t){super(e,t,new $F),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==nt}_generateTextureSample(e,t,n,r,i=this.shaderStage){return"fragment"===i?r?`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n):this.generateTextureLod(e,t,n,r,"0")}_generateVideoSample(e,t,n=this.shaderStage){if("fragment"===n)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${n} shader.`)}_generateTextureSampleLevel(e,t,n,r,i,s=this.shaderStage){return"fragment"!==s&&"compute"!==s||!1!==this.isUnfilterable(e)?this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r):this.generateTextureLod(e,t,n,i,r):`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`}generateWrapFunction(e){const t=`tsl_coord_${JF[e.wrapS]}S_${JF[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=ik[t];if(void 0===n){const r=[],i=e.isData3DTexture?"vec3f":"vec2f";let s=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===j?(r.push(sk.repeatWrapping_float),s+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===W?(r.push(sk.clampWrapping_float),s+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===X?(r.push(sk.mirrorWrapping_float),s+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(s+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),s+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(s+=",\n",a(e.wrapR,"z")),s+="\n\t);\n\n}\n",ik[t]=n=new iI(s,r)}return n.build(this),t}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===r.dimensionsSnippet&&(r.dimensionsSnippet={});let i=r.dimensionsSnippet[n];if(void 0===r.dimensionsSnippet[n]){let s,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),l=o>1;a=e.isData3DTexture?"vec3":"vec2",s=l||e.isVideoTexture||e.isStorageTexture?t:`${t}${n?`, u32( ${n} )`:""}`,i=new aE(new LE(`textureDimensions( ${s} )`,a)),r.dimensionsSnippet[n]=i,(e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new aE(new LE(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new aE(new LE("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,n,r="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${n} ), ${this.generateTextureDimension(e,t,r)}, u32( ${r} ) )`}generateTextureLod(e,t,n,r,i="0u"){const s=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",l=`${o}(${s}(${n}) * ${o}(${a}))`;return this.generateTextureLoad(e,t,l,r,i)}generateTextureLoad(e,t,n,r,i="0u"){return!0===e.isVideoTexture||!0===e.isStorageTexture?`textureLoad( ${t}, ${n} )`:r?`textureLoad( ${t}, ${n}, ${r}, u32( ${i} ) )`:`textureLoad( ${t}, ${n}, u32( ${i} ) )`}generateTextureStore(e,t,n,r){return`textureStore( ${t}, ${n}, ${r} )`}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===ae||!1===this.isSampleCompare(e)&&e.minFilter===Q&&e.magFilter===Q||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,i=this.shaderStage){let s=null;return s=!0===e.isVideoTexture?this._generateVideoSample(t,n,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,n,r,"0",i):this._generateTextureSample(e,t,n,r,i),s}generateTextureGrad(e,t,n,r,i,s=this.shaderStage){if("fragment"===s)return`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${s} shader.`)}generateTextureCompare(e,t,n,r,i,s=this.shaderStage){if("fragment"===s)return`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${s} shader.`)}generateTextureLevel(e,t,n,r,i,s=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,n,s):this._generateTextureSampleLevel(e,t,n,r,i,s),a}generateTextureBias(e,t,n,r,i,s=this.shaderStage){if("fragment"===s)return`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${s} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,n=e.type;return"texture"===n||"cubeTexture"===n||"storageTexture"===n||"texture3D"===n?t:"buffer"===n||"storageBuffer"===n||"indirectStorageBuffer"===n?`NodeBuffer_${e.id}.${t}`:e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=nk[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?MS:e.access}getStorageAccess(e,t){return ZF[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const i=super.getUniformFromNode(e,t,n,r),s=this.getDataFromNode(e,n,this.globalCache);if(void 0===s.uniformGPU){let r;const a=e.groupNode,o=a.name,l=this.getBindGroupArray(o,n);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const o=this.getNodeAccess(e,n);if("texture"===t||"storageTexture"===t?s=new kB(i.name,i.node,a,o):"cubeTexture"===t?s=new qB(i.name,i.node,a,o):"texture3D"===t&&(s=new GB(i.name,i.node,a,o)),s.store=!0===e.isStorageTextureNode,s.setVisibility(ek[n]),"fragment"!==n&&"compute"!==n||!1!==this.isUnfilterable(e.value)||!1!==s.store)l.push(s),r=[s];else{const e=new OF(`${i.name}_sampler`,i.node,a);e.setVisibility(ek[n]),l.push(e,s),r=[e,s]}}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const i=new("buffer"===t?LB:qF)(e,a);i.setVisibility(ek[n]),l.push(i),r=i}else{const e=this.uniformGroups[n]||(this.uniformGroups[n]={});let s=e[o];void 0===s&&(s=new BB(o,a),s.setVisibility(ek[n]),e[o]=s,l.push(s)),r=this.getNodeUniform(i,t),s.addUniform(r)}s.uniformGPU=r}return i}getBuiltin(e,t,n,r=this.shaderStage){const i=this.builtins[r]||(this.builtins[r]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:n}),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,n=this.flowShaderNode(e),r=[];for(const e of t.inputs)r.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} {\n${n.vars}\n${n.code}\n`;return n.result&&(i+=`\treturn ${n.result};\n`),i+="\n}\n",i}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=[],n=this.directives[e];if(void 0!==n)for(const e of n)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=[],n=this.builtins[e];if(void 0!==n)for(const{name:e,property:r,type:i}of n.values())t.push(`@builtin( ${e} ) ${r} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,n,r){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:n,bufferType:r,bufferCount:i}of this.scopedArrays.values()){const s=this.getType(r);t.push(`var<${n}> ${e}: array< ${s}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","id","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 n=this.getAttributesArray();for(let e=0,r=n.length;e`)}const r=this.getBuiltins("output");return r&&t.push("\t"+r),t.join(",\n")}getStructs(e){const t=[],n=this.structs[e];for(let e=0,r=n.length;e output : ${i};\n\n`)}return t.join("\n\n")}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],n=this.vars[e];if(void 0!==n)for(const e of n)t.push(`\t${this.getVar(e.type,e.name)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const n=this.varyings,r=this.vars[e];for(let i=0;i1&&(s="_multisampled"),!0===t.isCubeTexture)r="texture_cube";else if(!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)r="texture_2d_array";else if(!0===t.isDepthTexture)r=`texture_depth${s}_2d`;else if(!0===t.isVideoTexture)r="texture_external";else if(!0===t.isData3DTexture)r="texture_3d";else if(!0===i.node.isStorageTextureNode){r=`texture_storage_2d<${jF(t)}, ${this.getStorageAccess(i.node,e)}>`}else{r=`texture${s}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}n.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${r};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,n=this.getType(t.bufferType),s=t.bufferCount,o=s>0&&"buffer"===i.type?", "+s:"",l=t.isAtomic?`atomic<${n}>`:`${n}`,u=`\t${i.name} : array< ${l}${o} >\n`,c=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";r.push(this._getWGSLStructBinding("NodeBuffer_"+t.id,u,c,a.binding++,a.group))}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(s[t]||(s[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in s){const t=s[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=n.join("\n");return a+=r.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r="// code\n\n";r+=this.flowCode[t];const i=this.flowNodes[t],s=i[i.length-1],a=s.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),l=e.name;if(l&&(r.length>0&&(r+="\n"),r+=`\t// flow -> ${l}\n\t`),r+=`${i.code}\n\t`,e===s&&"compute"!==t)if(r+="// result\n\n\t","vertex"===t)r+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)n.returnType=a.nodeType,r+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",e),n.structs+="\nvar output : OutputStruct;\n\n",r+=`output.color = ${i.result};\n\n\treturn output;`}}n.flow=r}null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let n;return null!==t&&(n=this._getWGSLMethod(e+"_"+t)),void 0===n&&(n=this._getWGSLMethod(e)),n||e}getType(e){return rk[e]||e}isAvailable(e){let t=tk[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),tk[e]=t),t}_getWGSLMethod(e){return void 0!==sk[e]&&this._include(e),ak[e]}_include(e){const t=sk[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// 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${ok}\n\n// uniforms\n${e.uniforms}\n\n// structs\n${e.structs}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,n,r=0,i=0){const s=e+"Struct";return`${this._getWGSLStruct(s,t)}\n@binding( ${r} ) @group( ${i} )\nvar<${n}> ${e} : ${s};`}}class uk{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=BO.Depth24PlusStencil8:e.depth&&(t=BO.Depth24Plus),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,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?pO:e.isLineSegments||e.isMesh&&!0===t.wireframe?fO:e.isLine?mO:e.isMesh?gO:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?BO.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const ck=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),Ak=new Map([[Vr,["float16"]]]),hk=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class dk{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,i=r.get(n);let s=i.buffer;if(void 0===s){const a=r.device;let o=n.array;if(!1===e.normalized&&(o.constructor===Int16Array||o.constructor===Uint16Array)){const e=new Uint32Array(o.length);for(let t=0;t1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=bF)),n.texture.isDepthTexture)r.sampleType=SF;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){const e=n.texture.type;e===ie?r.sampleType=wF:e===se?r.sampleType=TF:e===ae&&(this.backend.hasFeature("float32-filterable")?r.sampleType=xF:r.sampleType=bF)}n.isSampledCubeTexture?r.viewDimension=NF:n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=RF:n.isSampledTexture3D&&(r.viewDimension=PF),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:i,bindGroupLayoutCache:s}=this,a=i.get(e);let o,l=s.get(e.bindingsReference);void 0===l&&(l=this.createBindingsLayout(e),s.set(e.bindingsReference,l)),n>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[n]===r&&(o=a.groups[n])),void 0===o&&(o=this.createBindGroup(e,l),n>0&&(a.groups[n]=o,a.versions[n]=r)),a.group=o,a.layout=l}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroup(e,t){const n=this.backend,r=n.device;let i=0;const s=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=n.get(t);if(void 0===e.buffer){const n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=r.createBuffer({label:"bindingBuffer_"+t.name,size:n,usage:i});e.buffer=s}s.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=n.get(t);if(void 0===e.buffer){const r=t.attribute;e.buffer=n.get(r).buffer}s.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=n.get(t.texture);s.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=n.get(t.texture);let a;if(void 0!==e.externalTexture)a=r.importExternalTexture({source:e.externalTexture});else{const n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(a=e[r],void 0===a){const i=DF;let s;s=t.isSampledCubeTexture?NF:t.isSampledTexture3D?PF:t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?RF:CF,a=e[r]=e.texture.createView({aspect:i,dimension:s,mipLevelCount:n})}}s.push({binding:i,resource:a})}i++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:s})}}class fk{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:i,pipeline:s}=e,{vertexProgram:a,fragmentProgram:o}=s,l=this.backend,u=l.device,c=l.utils,A=l.get(s),h=[];for(const t of e.getBindings()){const e=l.get(t);h.push(e.layout)}const d=l.attributeUtils.createShaderVertexBuffers(e);let p;!0===r.transparent&&0!==r.blending&&(p=this._getBlending(r));let f={};!0===r.stencilWrite&&(f={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const m=this._getColorWriteMask(r),g=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:u.createPipelineLayout({bindGroupLayouts:h})},T={},M=e.context.depth,E=e.context.stencil;if(!0!==M&&!0!==E||(!0===M&&(T.format=b,T.depthWriteEnabled=r.depthWrite,T.depthCompare=x),!0===E&&(T.stencilFront=f,T.stencilBack={},T.stencilReadMask=r.stencilFuncMask,T.stencilWriteMask=r.stencilWriteMask),w.depthStencil=T),null===t)A.pipeline=u.createRenderPipeline(w);else{const e=new Promise((e=>{u.createRenderPipelineAsync(w).then((t=>{A.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e){const t=this.backend,{utils:n,device:r}=t,i=n.getCurrentDepthStencilFormat(e),s={label:"renderBundleEncoder",colorFormats:[n.getCurrentColorFormat(e)],depthStencilFormat:i,sampleCount:this._getSampleCount(e)};return r.createRenderBundleEncoder(s)}createComputePipeline(e,t){const n=this.backend,r=n.device,i=n.get(e.computeProgram).module,s=n.get(e),a=[];for(const e of t){const t=n.get(e);a.push(t.layout)}s.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,n;const r=e.blending,i=e.blendSrc,s=e.blendDst,a=e.blendEquation;if(5===r){const r=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:s,l=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(a)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(l)}}else{const i=(e,r,i,s)=>{t={srcFactor:e,dstFactor:r,operation:tF},n={srcFactor:i,dstFactor:s,operation:tF}};if(e.premultipliedAlpha)switch(r){case 1:i(VO,XO,VO,XO);break;case 2:i(VO,VO,VO,VO);break;case 3:i(zO,jO,zO,VO);break;case 4:i(zO,HO,zO,WO)}else switch(r){case 1:i(WO,XO,VO,XO);break;case 2:i(WO,VO,WO,VO);break;case 3:i(zO,jO,zO,VO);break;case 4:i(zO,HO,zO,HO)}}if(void 0!==t&&void 0!==n)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case 200:t=zO;break;case 201:t=VO;break;case 202:t=HO;break;case 203:t=jO;break;case x:t=WO;break;case b:t=XO;break;case 208:t=QO;break;case 209:t=YO;break;case 206:t=$O;break;case 207:t=KO;break;case 210:t=ZO;break;case 211:t=JO;break;case 212:t=eF;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case 512:t=vO;break;case 519:t=MO;break;case 513:t=yO;break;case 515:t=bO;break;case 514:t=xO;break;case 518:t=TO;break;case 516:t=SO;break;case 517:t=wO;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case ot:t=lF;break;case 0:t=uF;break;case 7681:t=cF;break;case 5386:t=AF;break;case 7682:t=hF;break;case 7683:t=dF;break;case 34055:t=pF;break;case 34056:t=fF;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case p:t=tF;break;case 101:t=nF;break;case 102:t=rF;break;case 103:t=iF;break;case 104:t=sF;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?IO:UO),n.side){case 0:r.frontFace=NO,r.cullMode=LO;break;case 1:r.frontFace=NO,r.cullMode=DO;break;case 2:r.frontFace=NO,r.cullMode=PO;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",n.side)}return r}_getColorWriteMask(e){return!0===e.colorWrite?oF:aF}_getDepthCompare(e){let t;if(!1===e.depthTest)t=MO;else{const n=e.depthFunc;switch(n){case 0:t=vO;break;case 1:t=MO;break;case 2:t=yO;break;case 3:t=bO;break;case 4:t=xO;break;case 5:t=TO;break;case 6:t=SO;break;case 7:t=wO;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class mk extends YB{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.trackTimestamp=!0===e.trackTimestamp,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new uk(this),this.attributeUtils=new dk(this),this.bindingUtils=new pk(this),this.pipelineUtils=new fk(this),this.textureUtils=new HF(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(void 0===t.device){const e={powerPreference:t.powerPreference},r="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===r)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(UF),s=[];for(const e of i)r.features.has(e)&&s.push(e);const a={requiredFeatures:s,requiredLimits:t.requiredLimits};n=await r.requestDevice(a)}else n=t.device;n.lost.then((t=>{const n={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)}));const r=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(UF.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return yt}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let i=r.descriptors;if(void 0===i||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==n.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples||r.loadOp!==t.loadOp){i={},r.descriptors=i;const e=()=>{n.removeEventListener("dispose",e),this.delete(n)};n.addEventListener("dispose",e)}const s=e.getCacheKey();let a=i[s];if(void 0===a){const o=e.textures,l=[];let u;for(let r=0;r0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null),s=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:CO}),this.initTimestampQuery(e,s),s.occlusionQuerySet=i;const a=s.depthStencilAttachment;if(null!==e.textures){const t=s.colorAttachments;for(let n=0;n0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),n>0){const r=8*n;let i=this.occludedResolveCache.get(r);void 0===i&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));const s=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,s,0,r),t.occlusionQueryBuffer=s,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(l.x=Math.min(t.dispatchCount,a),l.y=Math.ceil(t.dispatchCount/a)):l.x=t.dispatchCount,i.dispatchWorkgroups(l.x,l.y,l.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:n,context:r,pipeline:i}=e,s=e.getBindings(),a=this.get(r),o=this.get(i).pipeline,l=a.currentSets,u=a.currentPass,c=e.getDrawParameters();if(null===c)return;l.pipeline!==o&&(u.setPipeline(o),l.pipeline=o);const A=l.bindingGroups;for(let e=0,t=s.length;e1?0:n;!0===d?u.drawIndexed(t[n],r,e[n]/h.array.BYTES_PER_ELEMENT,0,s):u.draw(t[n],r,e[n],s)}}else if(!0===d){const{vertexCount:r,instanceCount:i,firstVertex:s}=c,a=e.getIndirect();if(null!==a){const e=this.get(a).buffer;u.drawIndexedIndirect(e,0)}else u.drawIndexed(r,i,s,0,0);t.update(n,r,i)}else{const{vertexCount:r,instanceCount:i,firstVertex:s}=c,a=e.getIndirect();if(null!==a){const e=this.get(a).buffer;u.drawIndirect(e,0)}else u.draw(r,i,s,0);t.update(n,r,i)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,i=this.utils,s=i.getSampleCountRenderContext(e.context),a=i.getCurrentColorSpace(e.context),o=i.getCurrentColorFormat(e.context),l=i.getCurrentDepthStencilFormat(e.context),u=i.getPrimitiveTopology(n,r);let c=!1;return t.material===r&&t.materialVersion===r.version&&t.transparent===r.transparent&&t.blending===r.blending&&t.premultipliedAlpha===r.premultipliedAlpha&&t.blendSrc===r.blendSrc&&t.blendDst===r.blendDst&&t.blendEquation===r.blendEquation&&t.blendSrcAlpha===r.blendSrcAlpha&&t.blendDstAlpha===r.blendDstAlpha&&t.blendEquationAlpha===r.blendEquationAlpha&&t.colorWrite===r.colorWrite&&t.depthWrite===r.depthWrite&&t.depthTest===r.depthTest&&t.depthFunc===r.depthFunc&&t.stencilWrite===r.stencilWrite&&t.stencilFunc===r.stencilFunc&&t.stencilFail===r.stencilFail&&t.stencilZFail===r.stencilZFail&&t.stencilZPass===r.stencilZPass&&t.stencilFuncMask===r.stencilFuncMask&&t.stencilWriteMask===r.stencilWriteMask&&t.side===r.side&&t.alphaToCoverage===r.alphaToCoverage&&t.sampleCount===s&&t.colorSpace===a&&t.colorFormat===o&&t.depthStencilFormat===l&&t.primitiveTopology===u&&t.clippingContextCacheKey===e.clippingContextCacheKey||(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=s,t.colorSpace=a,t.colorFormat=o,t.depthStencilFormat=l,t.primitiveTopology=u,t.clippingContextCacheKey=e.clippingContextCacheKey,c=!0),c}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,i,s){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,s)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const n=this.get(e);if(!n.timeStampQuerySet){const r=e.isComputeNode?"compute":"render",i=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${r}_${e.id}`}),s={querySet:i,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1};Object.assign(t,{timestampWrites:s}),n.timeStampQuerySet=i}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const n=this.get(e),r=2*BigInt64Array.BYTES_PER_ELEMENT;void 0===n.currentTimestampQueryBuffers&&(n.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:i,resultBuffer:s}=n.currentTimestampQueryBuffers;t.resolveQuerySet(n.timeStampQuerySet,0,2,i,0),"unmapped"===s.mapState&&t.copyBufferToBuffer(i,0,s,0,r)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const n=this.get(e);if(void 0===n.currentTimestampQueryBuffers)return;const{resultBuffer:r}=n.currentTimestampQueryBuffers;"unmapped"===r.mapState&&r.mapAsync(GPUMapMode.READ).then((()=>{const e=new BigUint64Array(r.getMappedRange()),n=Number(e[1]-e[0])/1e6;this.renderer.info.updateTimestamp(t,n),r.unmap()}))}createNodeBuilder(e,t){return new lk(e,t)}createProgram(e){this.get(e).module={module:this.device.createShaderModule({code:e.code,label:e.stage+(""!==e.name?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),r=n.currentPass.finish();this.get(t).bundleGPU=r,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0){let s=0,a=0,o=0,l=0,u=0,c=0,A=e.image.width,h=e.image.height;null!==n&&(l=n.x,u=n.y,c=n.z||0,A=n.width,h=n.height),null!==r&&(s=r.x,a=r.y,o=r.z||0);const d=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),p=this.get(e).texture,f=this.get(t).texture;d.copyTextureToTexture({texture:p,mipLevel:i,origin:{x:l,y:u,z:c}},{texture:f,mipLevel:i,origin:{x:s,y:a,z:o}},[A,h,1]),this.device.queue.submit([d.finish()])}copyFramebufferToTexture(e,t,n){const r=this.get(t);let i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();const s=this.get(e).texture;if(i.format!==s.format)return void console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",i.format,s.format);let a;if(r.currentPass?(r.currentPass.end(),a=r.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),a.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:s},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),r.currentPass){const{descriptor:e}=r;for(let t=0;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new dO(e)));super(new t(e),e),this.library=new _k,this.isWebGPURenderer=!0}}const yk={type:"change"},xk={type:"start"},bk={type:"end"},Sk=1e-6,wk=-1,Tk=0,Mk=1,Ek=2,Ck=3,Rk=4,Nk=new Lt,Pk=new Lt,Dk=new on,Lk=new on,Ik=new on,Uk=new an,Bk=new on,Ok=new on,Fk=new on,kk=new on;class qk extends oo{constructor(e,t=null){super(e,t),this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:a.ROTATE,MIDDLE:a.DOLLY,RIGHT:a.PAN},this.state=wk,this.keyState=wk,this.target=new on,this._lastPosition=new on,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new on,this._movePrev=new Lt,this._moveCurr=new Lt,this._lastAxis=new on,this._zoomStart=new Lt,this._zoomEnd=new Lt,this._panStart=new Lt,this._panEnd=new Lt,this._pointers=[],this._pointerPositions={},this._onPointerMove=zk.bind(this),this._onPointerDown=Gk.bind(this),this._onPointerUp=Vk.bind(this),this._onPointerCancel=Hk.bind(this),this._onContextMenu=Kk.bind(this),this._onMouseWheel=$k.bind(this),this._onKeyDown=Wk.bind(this),this._onKeyUp=jk.bind(this),this._onTouchStart=Zk.bind(this),this._onTouchMove=Jk.bind(this),this._onTouchEnd=eq.bind(this),this._onMouseDown=Xk.bind(this),this._onMouseMove=Qk.bind(this),this._onMouseUp=Yk.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,null!==t&&(this.connect(),this.handleResize()),this.update()}connect(){window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}handleResize(){const e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>Sk&&(this.dispatchEvent(yk),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>Sk||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(yk),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=wk,this.keyState=wk,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(yk),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Pk.copy(this._panEnd).sub(this._panStart),Pk.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Pk.x*=e,Pk.y*=t}Pk.multiplyScalar(this._eye.length()*this.panSpeed),Lk.copy(this._eye).cross(this.object.up).setLength(Pk.x),Lk.add(Dk.copy(this.object.up).setLength(Pk.y)),this.object.position.add(Lk),this.target.add(Lk),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Pk.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){kk.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=kk.length();e?(this._eye.copy(this.object.position).sub(this.target),Bk.copy(this._eye).normalize(),Ok.copy(this.object.up).normalize(),Fk.crossVectors(Ok,Bk).normalize(),Ok.setLength(this._moveCurr.y-this._movePrev.y),Fk.setLength(this._moveCurr.x-this._movePrev.x),kk.copy(Ok.add(Fk)),Ik.crossVectors(kk,this._eye).normalize(),e*=this.rotateSpeed,Uk.setFromAxisAngle(Ik,e),this._eye.applyQuaternion(Uk),this.object.up.applyQuaternion(Uk),this._lastAxis.copy(Ik),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),Uk.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(Uk),this.object.up.applyQuaternion(Uk)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Rk?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Dt.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,1!==e&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Dt.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Nk.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Nk}_getMouseOnCircle(e,t){return Nk.set((e-.5*this.screen.width-this.screen.left)/(.5*this.screen.width),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Nk}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=lq),r<-Math.PI?r+=lq:r>Math.PI&&(r-=lq),this._spherical.theta=n<=r?Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(oq.setFromSpherical(this._spherical),oq.applyQuaternion(this._quatInverse),t.copy(this.target).add(oq),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){const t=oq.length();e=this._clampDistance(t*this._scale);const n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){const t=new on(this._mouse.x,this._mouse.y,0);t.unproject(this.object);const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;const r=new on(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=oq.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==e&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(iq.origin.copy(this.object.position),iq.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(iq.direction))gq||8*(1-this._lastQuaternion.dot(this.object.quaternion))>gq||this._lastTargetPosition.distanceToSquared(this.target)>gq)&&(this.dispatchEvent(tq),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(e){return null!==e?lq/60*this.autoRotateSpeed*e:lq/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(.01*e);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){oq.setFromMatrixColumn(t,0),oq.multiplyScalar(-e),this._panOffset.add(oq)}_panUp(e,t){!0===this.screenSpacePanning?oq.setFromMatrixColumn(t,1):(oq.setFromMatrixColumn(t,0),oq.crossVectors(this.object.up,oq)),oq.multiplyScalar(e),this._panOffset.add(oq)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;oq.copy(r).sub(this.target);let i=oq.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,s=n.width,a=n.height;this._mouse.x=r/s*2-1,this._mouse.y=-i/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(lq*this._rotateDelta.x/t.clientHeight),this._rotateUp(lq*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(lq*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-lq*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(lq*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-lq*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(1===this._pointers.length)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(1===this._pointers.length)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(1==this._pointers.length)this._rotateEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(lq*this._rotateDelta.x/t.clientHeight),this._rotateUp(lq*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(1===this._pointers.length)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=.5*(e.pageX+t.x),a=.5*(e.pageY+t.y);this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tDq||8*(1-this._lastQuaternion.dot(t.quaternion))>Dq)&&(this.dispatchEvent(Pq),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function Uq(e){if(!e.altKey&&!1!==this.enabled){switch(e.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1}this._updateMovementVector(),this._updateRotationVector()}}function Bq(e){if(!1!==this.enabled){switch(e.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0}this._updateMovementVector(),this._updateRotationVector()}}function Oq(e){if(!1!==this.enabled)if(this.dragToLook)this._status++;else{switch(e.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1}this._updateMovementVector()}}function Fq(e){if(!1!==this.enabled&&(!this.dragToLook||this._status>0)){const t=this._getContainerDimensions(),n=t.size[0]/2,r=t.size[1]/2;this._moveState.yawLeft=-(e.pageX-t.offset[0]-n)/n,this._moveState.pitchDown=(e.pageY-t.offset[1]-r)/r,this._updateRotationVector()}}function kq(e){if(!1!==this.enabled){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(e.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0}this._updateMovementVector()}this._updateRotationVector()}}function qq(){!1!==this.enabled&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Gq(e){!1!==this.enabled&&e.preventDefault()}const zq={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"};class Vq{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Hq=new za(-1,1,1,-1,0,1);const jq=new class extends Zr{constructor(){super(),this.setAttribute("position",new Hr([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Hr([0,2,0,0,2,0],2))}};class Wq{constructor(e){this._mesh=new ci(jq,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Hq)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Xq extends Vq{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof gi?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=mi.clone(e.uniforms),this.material=new gi({name:void 0!==e.name?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Wq(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class Qq extends Vq{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),i=e.state;let s,a;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0),this.inverse?(s=0,a=1):(s=1,a=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,s,4294967295),i.buffers.stencil.setClear(a),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}}class Yq extends Vq{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class $q{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),void 0===t){const n=e.getSize(new Lt);this._width=n.width,this._height=n.height,(t=new nn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:oe})).texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Xq(zq),this.copyPass.material.blending=0,this.clock=new Ka}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);-1!==t&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t1?r-1:0),s=1;s=0&&i<1?(o=s,l=a):i>=1&&i<2?(o=a,l=s):i>=2&&i<3?(l=s,u=a):i>=3&&i<4?(l=a,u=s):i>=4&&i<5?(o=a,u=s):i>=5&&i<6&&(o=s,u=a);var c=n-s/2;return r(o+c,l+c,u+c)}var uG={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",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:"ff00ff",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:"639",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"};var cG=/^#[a-fA-F0-9]{6}$/,AG=/^#[a-fA-F0-9]{8}$/,hG=/^#[a-fA-F0-9]{3}$/,dG=/^#[a-fA-F0-9]{4}$/,pG=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,fG=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,mG=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,gG=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function _G(e){if("string"!=typeof e)throw new sG(3);var t=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return uG[t]?"#"+uG[t]:e}(e);if(t.match(cG))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(AG)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(hG))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(dG)){var r=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:r}}var i=pG.exec(t);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10)};var s=fG.exec(t.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var a=mG.exec(t);if(a){var o="rgb("+lG(parseInt(""+a[1],10),parseInt(""+a[2],10)/100,parseInt(""+a[3],10)/100)+")",l=pG.exec(o);if(!l)throw new sG(4,t,o);return{red:parseInt(""+l[1],10),green:parseInt(""+l[2],10),blue:parseInt(""+l[3],10)}}var u=gG.exec(t.substring(0,50));if(u){var c="rgb("+lG(parseInt(""+u[1],10),parseInt(""+u[2],10)/100,parseInt(""+u[3],10)/100)+")",A=pG.exec(c);if(!A)throw new sG(4,t,c);return{red:parseInt(""+A[1],10),green:parseInt(""+A[2],10),blue:parseInt(""+A[3],10),alpha:parseFloat(""+u[4])>1?parseFloat(""+u[4])/100:parseFloat(""+u[4])}}throw new sG(5)}function vG(e){return function(e){var t,n=e.red/255,r=e.green/255,i=e.blue/255,s=Math.max(n,r,i),a=Math.min(n,r,i),o=(s+a)/2;if(s===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:o,alpha:e.alpha}:{hue:0,saturation:0,lightness:o};var l=s-a,u=o>.5?l/(2-s-a):l/(s+a);switch(s){case n:t=(r-i)/l+(r=1?TG(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new sG(7)}function EG(e){if("object"!=typeof e)throw new sG(8);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha}(e))return MG(e);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return TG(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha}(e))return function(e,t,n,r){if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?wG(e.hue,e.saturation,e.lightness):"rgba("+lG(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new sG(2)}(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return function(e,t,n){if("object"==typeof e&&void 0===t&&void 0===n)return wG(e.hue,e.saturation,e.lightness);throw new sG(1)}(e);throw new sG(8)}function CG(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):CG(e,t,r)}}function RG(e){return CG(e,e.length,[])}function NG(e,t,n){return Math.max(e,Math.min(t,n))}RG((function(e,t){if("transparent"===t)return t;var n=vG(t);return EG(Zq({},n,{hue:n.hue+parseFloat(e)}))})),RG((function(e,t){if("transparent"===t)return t;var n=vG(t);return EG(Zq({},n,{lightness:NG(0,1,n.lightness-parseFloat(e))}))})),RG((function(e,t){if("transparent"===t)return t;var n=vG(t);return EG(Zq({},n,{saturation:NG(0,1,n.saturation-parseFloat(e))}))})),RG((function(e,t){if("transparent"===t)return t;var n=vG(t);return EG(Zq({},n,{lightness:NG(0,1,n.lightness+parseFloat(e))}))}));var PG=RG((function(e,t,n){if("transparent"===t)return n;if("transparent"===n)return t;if(0===e)return n;var r=_G(t),i=Zq({},r,{alpha:"number"==typeof r.alpha?r.alpha:1}),s=_G(n),a=Zq({},s,{alpha:"number"==typeof s.alpha?s.alpha:1}),o=i.alpha-a.alpha,l=2*parseFloat(e)-1,u=((l*o==-1?l:l+o)/(1+l*o)+1)/2,c=1-u;return MG({red:Math.floor(i.red*u+a.red*c),green:Math.floor(i.green*u+a.green*c),blue:Math.floor(i.blue*u+a.blue*c),alpha:i.alpha*parseFloat(e)+a.alpha*(1-parseFloat(e))})})),DG=PG;var LG=RG((function(e,t){if("transparent"===t)return t;var n=_G(t);return MG(Zq({},n,{alpha:NG(0,1,(100*("number"==typeof n.alpha?n.alpha:1)+100*parseFloat(e))/100)}))})),IG=LG;RG((function(e,t){if("transparent"===t)return t;var n=vG(t);return EG(Zq({},n,{saturation:NG(0,1,n.saturation+parseFloat(e))}))})),RG((function(e,t){return"transparent"===t?t:EG(Zq({},vG(t),{hue:parseFloat(e)}))})),RG((function(e,t){return"transparent"===t?t:EG(Zq({},vG(t),{lightness:parseFloat(e)}))})),RG((function(e,t){return"transparent"===t?t:EG(Zq({},vG(t),{saturation:parseFloat(e)}))})),RG((function(e,t){return"transparent"===t?t:DG(parseFloat(e),"rgb(0, 0, 0)",t)})),RG((function(e,t){return"transparent"===t?t:DG(parseFloat(e),"rgb(255, 255, 255)",t)})),RG((function(e,t){if("transparent"===t)return t;var n=_G(t);return MG(Zq({},n,{alpha:NG(0,1,+(100*("number"==typeof n.alpha?n.alpha:1)-100*parseFloat(e)).toFixed(2)/100)}))}));var UG="http://www.w3.org/1999/xhtml",BG={svg:"http://www.w3.org/2000/svg",xhtml:UG,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function OG(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),BG.hasOwnProperty(t)?{space:BG[t],local:e}:e}function FG(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===UG&&t.documentElement.namespaceURI===UG?t.createElement(e):t.createElementNS(n,e)}}function kG(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qG(e){var t=OG(e);return(t.local?kG:FG)(t)}function GG(){}function zG(e){return null==e?GG:function(){return this.querySelector(e)}}function VG(){return[]}function HG(e){return function(){return function(e){return null==e?[]:Array.isArray(e)?e:Array.from(e)}(e.apply(this,arguments))}}function jG(e){return function(t){return t.matches(e)}}var WG=Array.prototype.find;function XG(){return this.firstElementChild}var QG=Array.prototype.filter;function YG(){return Array.from(this.children)}function $G(e){return new Array(e.length)}function KG(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function ZG(e,t,n,r,i,s){for(var a,o=0,l=t.length,u=s.length;ot?1:e>=t?0:NaN}function rz(e){return function(){this.removeAttribute(e)}}function iz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sz(e,t){return function(){this.setAttribute(e,t)}}function az(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function oz(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function lz(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function uz(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function cz(e){return function(){this.style.removeProperty(e)}}function Az(e,t,n){return function(){this.style.setProperty(e,t,n)}}function hz(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function dz(e){return function(){delete this[e]}}function pz(e,t){return function(){this[e]=t}}function fz(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function mz(e){return e.trim().split(/^|\s+/)}function gz(e){return e.classList||new _z(e)}function _z(e){this._node=e,this._names=mz(e.getAttribute("class")||"")}function vz(e,t){for(var n=gz(e),r=-1,i=t.length;++r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var Gz=[null];function zz(e,t){this._groups=e,this._parents=t}zz.prototype={constructor:zz,select:function(e){"function"!=typeof e&&(e=zG(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=y&&(y=v+1);!(_=m[y])&&++y=0;)(r=i[s])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=nz);for(var n=this._groups,r=n.length,i=new Array(r),s=0;s1?this.each((null==t?cz:"function"==typeof t?hz:Az)(e,t,null==n?"":n)):function(e,t){return e.style.getPropertyValue(t)||uz(e).getComputedStyle(e,null).getPropertyValue(t)}(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?dz:"function"==typeof t?fz:pz)(e,t)):this.node()[e]},classed:function(e,t){var n=mz(e+"");if(arguments.length<2){for(var r=gz(this.node()),i=-1,s=n.length;++i=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=s.length;if(!(arguments.length<2)){for(o=t?Oz:Bz,r=0;rt&&Xz.sort($z));dV.__r=0}function pV(e,t,n,r,i,s,a,o,l,u,c){var A,h,d,p,f,m,g=r&&r.__k||nV,_=t.length;for(l=fV(n,t,g,l,_),A=0;A<_;A++)null!=(d=n.__k[A])&&(h=-1===d.__i?tV:g[d.__i]||tV,d.__i=A,m=xV(e,d,h,i,s,a,o,l,u,c),p=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&wV(h.ref,null,d),c.push(d.ref,d.__c||p,d)),null==f&&null!=p&&(f=p),4&d.__u||h.__k===d.__k?l=mV(d,l,e):"function"==typeof d.type&&void 0!==m?l=m:p&&(l=p.nextSibling),d.__u&=-7);return n.__e=f,l}function fV(e,t,n,r,i){var s,a,o,l,u,c=n.length,A=c,h=0;for(e.__k=new Array(i),s=0;s0?oV(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,o=null,-1!==(u=a.__i=gV(a,n,l,A))&&(A--,(o=n[u])&&(o.__u|=2)),null==o||null===o.__v?(-1==u&&h--,"function"!=typeof a.type&&(a.__u|=4)):u!=l&&(u==l-1?h--:u==l+1?h++:(u>l?h--:h++,a.__u|=4))):e.__k[s]=null;if(A)for(s=0;s(null==l||2&l.__u?0:1))for(i=n-1,s=n+1;i>=0||s=0){if((l=t[i])&&!(2&l.__u)&&a==l.key&&o===l.type)return i;i--}if(s2&&(a.children=arguments.length>3?Vz.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===a[s]&&(a[s]=e.defaultProps[s]);return oV(e,a,r,i,null)}(lV,null,[e]),r||tV,tV,t.namespaceURI,r?null:t.firstChild?Vz.call(t.childNodes):null,i,r?r.__e:t.firstChild,false,s),bV(i,e,s)}function CV(e,t,n){var r,i,s,a,o=sV({},e.props);for(s in e.type&&e.type.defaultProps&&(a=e.type.defaultProps),t)"key"==s?r=t[s]:"ref"==s?i=t[s]:o[s]=void 0===t[s]&&void 0!==a?a[s]:t[s];return arguments.length>2&&(o.children=arguments.length>3?Vz.call(arguments,2):n),oV(e.type,o,r||e.key,i||e.ref,null)}function RV(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n2&&void 0!==arguments[2]?arguments[2]:{}).style,r=void 0===n?{}:n,i=function(e){return"string"==typeof e?new zz([[document.querySelector(e)]],[document.documentElement]):new zz([[e]],Gz)}(!!e&&"object"===LV(e)&&!!e.node&&"function"==typeof e.node?e.node():e);"static"===i.style("position")&&i.style("position","relative"),t.tooltipEl=i.append("div").attr("class","float-tooltip-kap"),Object.entries(r).forEach((function(e){var n=DV(e,2),r=n[0],i=n[1];return t.tooltipEl.style(r,i)})),t.tooltipEl.style("left","-10000px").style("display","none");var s="tooltip-".concat(Math.round(1e12*Math.random()));t.mouseInside=!1,i.on("mousemove.".concat(s),(function(e){t.mouseInside=!0;var n=function(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}(e),r=i.node(),s=r.offsetWidth,a=r.offsetHeight,o=[null===t.offsetX||void 0===t.offsetX?"-".concat(n[0]/s*100,"%"):"number"==typeof t.offsetX?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,null===t.offsetY||void 0===t.offsetY?a>130&&a-n[1]<100?"calc(-100% - 6px)":"21px":"number"==typeof t.offsetY?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",n[0]+"px").style("top",n[1]+"px").style("transform","translate(".concat(o.join(","),")")),t.content&&t.tooltipEl.style("display","inline")})),i.on("mouseover.".concat(s),(function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")})),i.on("mouseout.".concat(s),(function(){t.mouseInside=!1,t.tooltipEl.style("display","none")}))},update:function(e){var t,n;e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append((function(){return e.content}))):"string"==typeof e.content?e.tooltipEl.html(e.content):!function(e){return Wz(CV(e))}(e.content)?(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):(e.tooltipEl.text(""),t=e.content,delete(n=e.tooltipEl.node()).__k,EV(IV(t),n)):e.tooltipEl.text("")}});function BV(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n0),A=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,d=!!n.morphAttributes.color;let p=0;r.toneMapped&&(null!==w&&!0!==w.isXRRenderTarget||(p=y.toneMapping));const f=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,m=void 0!==f?f.length:0,_=ne.get(r),v=g.state.lights;if(!0===G&&(!0===z||e!==M)){const t=e===M&&r.id===T;ve.setState(r,e,t)}let x=!1;r.version===_.__version?_.needsLights&&_.lightsStateVersion!==v.state.version||_.outputColorSpace!==o||i.isBatchedMesh&&!1===_.batching?x=!0:i.isBatchedMesh||!0!==_.batching?i.isBatchedMesh&&!0===_.batchingColor&&null===i.colorTexture||i.isBatchedMesh&&!1===_.batchingColor&&null!==i.colorTexture||i.isInstancedMesh&&!1===_.instancing?x=!0:i.isInstancedMesh||!0!==_.instancing?i.isSkinnedMesh&&!1===_.skinning?x=!0:i.isSkinnedMesh||!0!==_.skinning?i.isInstancedMesh&&!0===_.instancingColor&&null===i.instanceColor||i.isInstancedMesh&&!1===_.instancingColor&&null!==i.instanceColor||i.isInstancedMesh&&!0===_.instancingMorph&&null===i.morphTexture||i.isInstancedMesh&&!1===_.instancingMorph&&null!==i.morphTexture||_.envMap!==l||!0===r.fog&&_.fog!==s?x=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===ve.numPlanes&&_.numIntersection===ve.numIntersection?(_.vertexAlphas!==u||_.vertexTangents!==c||_.morphTargets!==A||_.morphNormals!==h||_.morphColors!==d||_.toneMapping!==p||_.morphTargetsCount!==m)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,_.__version=r.version);let b=_.currentProgram;!0===x&&(b=Ye(r,t,i));let S=!1,E=!1,C=!1;const R=b.getUniforms(),N=_.uniforms;Z.useProgram(b.program)&&(S=!0,E=!0,C=!0);r.id!==T&&(T=r.id,E=!0);if(S||M!==e){Z.buffers.depth.getReversed()?(V.copy(e.projectionMatrix),function(e){const t=e.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}(V),function(e){const t=e.elements;-1===t[11]?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=1-t[14])}(V),R.setValue(Pe,"projectionMatrix",V)):R.setValue(Pe,"projectionMatrix",e.projectionMatrix),R.setValue(Pe,"viewMatrix",e.matrixWorldInverse);const t=R.map.cameraPosition;void 0!==t&&t.setValue(Pe,j.setFromMatrixPosition(e.matrixWorld)),K.logarithmicDepthBuffer&&R.setValue(Pe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&R.setValue(Pe,"isOrthographic",!0===e.isOrthographicCamera),M!==e&&(M=e,E=!0,C=!0)}if(i.isSkinnedMesh){R.setOptional(Pe,i,"bindMatrix"),R.setOptional(Pe,i,"bindMatrixInverse");const e=i.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),R.setValue(Pe,"boneTexture",e.boneTexture,ie))}i.isBatchedMesh&&(R.setOptional(Pe,i,"batchingTexture"),R.setValue(Pe,"batchingTexture",i._matricesTexture,ie),R.setOptional(Pe,i,"batchingIdTexture"),R.setValue(Pe,"batchingIdTexture",i._indirectTexture,ie),R.setOptional(Pe,i,"batchingColorTexture"),null!==i._colorsTexture&&R.setValue(Pe,"batchingColorTexture",i._colorsTexture,ie));const P=n.morphAttributes;void 0===P.position&&void 0===P.normal&&void 0===P.color||Te.update(i,n,b);(E||_.receiveShadow!==i.receiveShadow)&&(_.receiveShadow=i.receiveShadow,R.setValue(Pe,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(N.envMap.value=l,N.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);r.isMeshStandardMaterial&&null===r.envMap&&null!==t.environment&&(N.envMapIntensity.value=t.environmentIntensity);E&&(R.setValue(Pe,"toneMappingExposure",y.toneMappingExposure),_.needsLights&&(U=C,(D=N).ambientLightColor.needsUpdate=U,D.lightProbe.needsUpdate=U,D.directionalLights.needsUpdate=U,D.directionalLightShadows.needsUpdate=U,D.pointLights.needsUpdate=U,D.pointLightShadows.needsUpdate=U,D.spotLights.needsUpdate=U,D.spotLightShadows.needsUpdate=U,D.rectAreaLights.needsUpdate=U,D.hemisphereLights.needsUpdate=U),s&&!0===r.fog&&me.refreshFogUniforms(N,s),me.refreshMaterialUniforms(N,r,I,L,g.state.transmissionRenderTarget[e.id]),Zl.upload(Pe,$e(_),N,ie));var D,U;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(Zl.upload(Pe,$e(_),N,ie),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&R.setValue(Pe,"center",i.center);if(R.setValue(Pe,"modelViewMatrix",i.modelViewMatrix),R.setValue(Pe,"normalMatrix",i.normalMatrix),R.setValue(Pe,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t{function n(){r.forEach((function(e){ne.get(e).currentProgram.isReady()&&r.delete(e)})),0!==r.size?setTimeout(n,10):t(e)}null!==$.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let qe=null;function Ge(){Ve.stop()}function ze(){Ve.start()}const Ve=new uo;function He(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)g.pushLight(e),e.castShadow&&g.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||q.intersectsSprite(e)){r&&W.setFromMatrixPosition(e.matrixWorld).applyMatrix4(H);const t=pe.update(e),i=e.material;i.visible&&m.push(e,t,i,n,W.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||q.intersectsObject(e))){const t=pe.update(e),i=e.material;if(r&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),W.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),W.copy(t.boundingSphere.center)),W.applyMatrix4(e.matrixWorld).applyMatrix4(H)),Array.isArray(i)){const r=t.groups;for(let s=0,a=r.length;s0&&Xe(i,t,n),s.length>0&&Xe(s,t,n),a.length>0&&Xe(a,t,n),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function We(e,t,n,r){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[r.id]&&(g.state.transmissionRenderTarget[r.id]=new nn(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?oe:ee,minFilter:J,samples:4,stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ht.workingColorSpace}));const s=g.state.transmissionRenderTarget[r.id],a=r.viewport||E;s.setSize(a.z*y.transmissionResolutionScale,a.w*y.transmissionResolutionScale);const o=y.getRenderTarget();y.setRenderTarget(s),y.getClearColor(N),P=y.getClearAlpha(),P<1&&y.setClearColor(16777215,.5),y.clear(),Q&&we.render(n);const l=y.toneMapping;y.toneMapping=0;const u=r.viewport;if(void 0!==r.viewport&&(r.viewport=void 0),g.setupLightsView(r),!0===G&&ve.setGlobalState(y.clippingPlanes,r),Xe(e,n,r),ie.updateMultisampleRenderTarget(s),ie.updateRenderTargetMipmap(s),!1===$.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let i=0,s=t.length;i0)for(let t=0,s=n.length;t0&&We(r,i,e,t),Q&&we.render(e),je(m,e,t);null!==w&&0===S&&(ie.updateMultisampleRenderTarget(w),ie.updateRenderTargetMipmap(w)),!0===e.isScene&&e.onAfterRender(y,e,t),Re.resetDefaultState(),T=-1,M=null,v.pop(),v.length>0?(g=v[v.length-1],!0===G&&ve.setGlobalState(y.clippingPlanes,g.state.camera)):g=null,_.pop(),m=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(e,t,n){ne.get(e.texture).__webglTexture=t,ne.get(e.depthTexture).__webglTexture=n;const r=ne.get(e);r.__hasExternalTextures=!0,r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===$.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(e,t){const n=ne.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const Ze=Pe.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){w=e,b=t,S=n;let r=!0,i=null,s=!1,a=!1;if(e){const o=ne.get(e);if(void 0!==o.__useDefaultFramebuffer)Z.bindFramebuffer(Pe.FRAMEBUFFER,null),r=!1;else if(void 0===o.__webglFramebuffer)ie.setupRenderTarget(e);else if(o.__hasExternalTextures)ie.rebindTextures(e,ne.get(e.texture).__webglTexture,ne.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&ne.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ie.setupDepthRenderbuffer(e)}}const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const u=ne.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(u[t])?u[t][n]:u[t],s=!0):i=e.samples>0&&!1===ie.useMultisampledRTT(e)?ne.get(e).__webglMultisampledFramebuffer:Array.isArray(u)?u[n]:u,E.copy(e.viewport),C.copy(e.scissor),R=e.scissorTest}else E.copy(O).multiplyScalar(I).floor(),C.copy(F).multiplyScalar(I).floor(),R=k;0!==n&&(i=Ze);if(Z.bindFramebuffer(Pe.FRAMEBUFFER,i)&&r&&Z.drawBuffers(e,i),Z.viewport(E),Z.scissor(C),Z.setScissorTest(R),s){const r=ne.get(e.texture);Pe.framebufferTexture2D(Pe.FRAMEBUFFER,Pe.COLOR_ATTACHMENT0,Pe.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){const r=ne.get(e.texture),i=t;Pe.framebufferTextureLayer(Pe.FRAMEBUFFER,Pe.COLOR_ATTACHMENT0,r.__webglTexture,n,i)}else if(null!==e&&0!==n){const t=ne.get(e.texture);Pe.framebufferTexture2D(Pe.FRAMEBUFFER,Pe.COLOR_ATTACHMENT0,Pe.TEXTURE_2D,t.__webglTexture,n)}T=-1},this.readRenderTargetPixels=function(e,t,n,r,i,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){Z.bindFramebuffer(Pe.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(!K.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!K.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&Pe.readPixels(t,n,r,i,Ce.convert(o),Ce.convert(l),s)}finally{const e=null!==w?ne.get(w).__webglFramebuffer:null;Z.bindFramebuffer(Pe.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,s,a){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=e.texture,l=a.format,u=a.type;if(!K.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!K.textureTypeReadable(u))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){Z.bindFramebuffer(Pe.FRAMEBUFFER,o);const e=Pe.createBuffer();Pe.bindBuffer(Pe.PIXEL_PACK_BUFFER,e),Pe.bufferData(Pe.PIXEL_PACK_BUFFER,s.byteLength,Pe.STREAM_READ),Pe.readPixels(t,n,r,i,Ce.convert(l),Ce.convert(u),0);const a=null!==w?ne.get(w).__webglFramebuffer:null;Z.bindFramebuffer(Pe.FRAMEBUFFER,a);const c=Pe.fenceSync(Pe.SYNC_GPU_COMMANDS_COMPLETE,0);return Pe.flush(),await function(e,t,n){return new Promise((function(r,i){setTimeout((function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}),n)}))}(Pe,c,4),Pe.bindBuffer(Pe.PIXEL_PACK_BUFFER,e),Pe.getBufferSubData(Pe.PIXEL_PACK_BUFFER,0,s),Pe.deleteBuffer(e),Pe.deleteSync(c),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){!0!==e.isTexture&&(qt("WebGLRenderer: copyFramebufferToTexture function signature has changed."),t=arguments[0]||null,e=arguments[1]);const r=Math.pow(2,-n),i=Math.floor(e.image.width*r),s=Math.floor(e.image.height*r),a=null!==t?t.x:0,o=null!==t?t.y:0;ie.setTexture2D(e,0),Pe.copyTexSubImage2D(Pe.TEXTURE_2D,n,0,0,a,o,i,s),Z.unbindTexture()};const Je=Pe.createFramebuffer(),et=Pe.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,s=null){let a,o,l,u,c,A,h,d,p;!0!==e.isTexture&&(qt("WebGLRenderer: copyTextureToTexture function signature has changed."),r=arguments[0]||null,e=arguments[1],t=arguments[2],s=arguments[3]||0,n=null),null===s&&(0!==i?(qt("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=i,i=0):s=0);const f=e.isCompressedTexture?e.mipmaps[s]:e.image;if(null!==n)a=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,u=n.min.x,c=n.min.y,A=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-i);a=Math.floor(f.width*t),o=Math.floor(f.height*t),l=e.isDataArrayTexture?f.depth:e.isData3DTexture?Math.floor(f.depth*t):1,u=0,c=0,A=0}null!==r?(h=r.x,d=r.y,p=r.z):(h=0,d=0,p=0);const m=Ce.convert(t.format),g=Ce.convert(t.type);let _;t.isData3DTexture?(ie.setTexture3D(t,0),_=Pe.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ie.setTexture2DArray(t,0),_=Pe.TEXTURE_2D_ARRAY):(ie.setTexture2D(t,0),_=Pe.TEXTURE_2D),Pe.pixelStorei(Pe.UNPACK_FLIP_Y_WEBGL,t.flipY),Pe.pixelStorei(Pe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),Pe.pixelStorei(Pe.UNPACK_ALIGNMENT,t.unpackAlignment);const v=Pe.getParameter(Pe.UNPACK_ROW_LENGTH),y=Pe.getParameter(Pe.UNPACK_IMAGE_HEIGHT),x=Pe.getParameter(Pe.UNPACK_SKIP_PIXELS),b=Pe.getParameter(Pe.UNPACK_SKIP_ROWS),S=Pe.getParameter(Pe.UNPACK_SKIP_IMAGES);Pe.pixelStorei(Pe.UNPACK_ROW_LENGTH,f.width),Pe.pixelStorei(Pe.UNPACK_IMAGE_HEIGHT,f.height),Pe.pixelStorei(Pe.UNPACK_SKIP_PIXELS,u),Pe.pixelStorei(Pe.UNPACK_SKIP_ROWS,c),Pe.pixelStorei(Pe.UNPACK_SKIP_IMAGES,A);const w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=ne.get(e),r=ne.get(t),f=ne.get(n.__renderTarget),m=ne.get(r.__renderTarget);Z.bindFramebuffer(Pe.READ_FRAMEBUFFER,f.__webglFramebuffer),Z.bindFramebuffer(Pe.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,r=arguments.length,i=new Array(r>3?r-3:0),s=3;s2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,i=e.camera;if(t){var s=new GV.Vector3(0,0,0),a=2*Math.max.apply(Math,kV(Object.entries(t).map((function(e){var t=FV(e,2),n=t[0],r=t[1];return Math.max.apply(Math,kV(r.map((function(e){return Math.abs(s[n]-e)}))))})))),o=(1-2*r/e.height)*i.fov,l=a/Math.atan(o*Math.PI/180),u=l/i.aspect,c=Math.max(l,u);if(c>0){var A=s.clone().sub(i.position).normalize().multiplyScalar(-c);this.cameraPosition(A,s,n)}}return this},getBbox:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return!0},n=new GV.Box3(new GV.Vector3(0,0,0),new GV.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach((function(e){return n.expandByObject(e)})),Object.assign.apply(Object,kV(["x","y","z"].map((function(e){return OV({},e,[n.min[e],n.max[e]])}))))):null},getScreenCoords:function(e,t,n,r){var i=new GV.Vector3(t,n,r);return i.project(this.camera()),{x:(i.x+1)*e.width/2,y:-(i.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=new GV.Vector2(t/e.width*2-1,-n/e.height*2+1),s=new GV.Raycaster;return s.setFromCamera(i,e.camera),Object.assign({},s.ray.at(r,new GV.Vector3))},intersectingObjects:function(e,t,n){var r=new GV.Vector2(t/e.width*2-1,-n/e.height*2+1),i=new GV.Raycaster;return i.params.Line.threshold=e.lineHoverPrecision,i.params.Points.threshold=e.pointsHoverPrecision,i.setFromCamera(r,e.camera),i.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new GV.Scene,camera:new GV.PerspectiveCamera,clock:new GV.Clock,tweenGroup:new Rc}},init:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.controlType,i=void 0===r?"trackball":r,s=n.useWebGPU,a=void 0!==s&&s,o=n.rendererConfig,l=void 0===o?{}:o,u=n.extraRenderers,c=void 0===u?[]:u,A=n.waitForLoadComplete,h=void 0===A||A;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[i]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new UV(t.container),t.pointerPos=new GV.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach((function(e){return t.container.addEventListener(e,(function(n){if("pointerdown"===e&&(t.isPointerPressed=!0),!t.isPointerDragging&&"pointermove"===n.type&&(n.pressure>0||t.isPointerPressed)&&("touch"!==n.pointerType||void 0===n.movementX||[n.movementX,n.movementY].some((function(e){return Math.abs(e)>1})))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var r=(i=t.container,s=i.getBoundingClientRect(),a=window.pageXOffset||document.documentElement.scrollLeft,o=window.pageYOffset||document.documentElement.scrollTop,{top:s.top+o,left:s.left+a});t.pointerPos.x=n.pageX-r.left,t.pointerPos.y=n.pageY-r.top}var i,s,a,o}),{passive:!0})})),t.container.addEventListener("pointerup",(function(e){t.isPointerPressed=!1,t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag)||requestAnimationFrame((function(){0===e.button&&t.onClick(t.hoverObj||null,e,t.intersection),2===e.button&&t.onRightClick&&t.onRightClick(t.hoverObj||null,e,t.intersection)}))}),{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",(function(e){t.onRightClick&&e.preventDefault()})),t.renderer=new(a?vk:GV.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},l)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=c,t.extraRenderers.forEach((function(e){e.domElement.style.position="absolute",e.domElement.style.top="0px",e.domElement.style.pointerEvents="none",t.container.appendChild(e.domElement)})),t.postProcessingComposer=new $q(t.renderer),t.postProcessingComposer.addPass(new Kq(t.scene,t.camera)),t.controls=new{trackball:qk,orbit:_q,fly:Iq}[i](t.camera,t.renderer.domElement),"fly"===i&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),"trackball"!==i&&"orbit"!==i||(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",(function(){t.controlsEngaged=!0})),t.controls.addEventListener("change",(function(){t.controlsEngaged&&(t.controlsDragging=!0)})),t.controls.addEventListener("end",(function(){t.controlsEngaged=!1,t.controlsDragging=!1}))),[t.renderer,t.postProcessingComposer].concat(kV(t.extraRenderers)).forEach((function(e){return e.setSize(t.width,t.height)})),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new GV.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!h,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))&&(e.container.style.width="".concat(e.width,"px"),e.container.style.height="".concat(e.height,"px"),[e.renderer,e.postProcessingComposer].concat(kV(e.extraRenderers)).forEach((function(t){return t.setSize(e.width,e.height)})),e.camera.aspect=e.width/e.height,e.camera.updateProjectionMatrix()),t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=2.5*e.skyRadius,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new GV.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var n=_G(e.backgroundColor).alpha;void 0===n&&(n=1),e.renderer.setClearColor(new GV.Color(IG(1,e.backgroundColor)),n)}function r(){e.loadComplete=e.scene.visible=!0}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?(new GV.TextureLoader).load(e.backgroundImageUrl,(function(t){t.colorSpace=GV.SRGBColorSpace,e.skysphere.material=new GV.MeshBasicMaterial({map:t,side:GV.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&r()})):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&r())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach((function(t){return e.scene.remove(t)})),e.lights.forEach((function(t){return e.scene.add(t)}))),t.hasOwnProperty("objects")&&((t.objects||[]).forEach((function(t){return e.scene.remove(t)})),e.objects.forEach((function(t){return e.scene.add(t)})))}});function VV(e,t){var n=new t;return n._destructor&&n._destructor(),{linkProp:function(t){return{default:n[t](),onChange:function(n,r){r[e][t](n)},triggerUpdate:!1}},linkMethod:function(t){return function(n){for(var r=n[e],i=arguments.length,s=new Array(i>1?i-1:0),a=1;a=-1&&Xu.z<=1&&!0===e.layers.test(r.layers),u=e.element;u.style.display=!0===l?"":"none",!0===l&&(e.onBeforeRender(t,n,r),u.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(Xu.x*i+i)+"px,"+(-Xu.y*s+s)+"px)",u.parentNode!==o&&o.appendChild(u),e.onAfterRender(t,n,r));const A={distanceToCameraSquared:c(r,e)};a.objects.set(e,A)}for(let t=0,i=e.children.length;t1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=e.globe.toGeoCoords(e.renderObjs.cameraPosition());if(void 0===t.lat&&void 0===t.lng&&void 0===t.altitude)return r;var i=Object.assign({},r,t);if(["lat","lng","altitude"].forEach((function(e){return i[e]=+i[e]})),n){for(;r.lng-i.lng>180;)r.lng-=360;for(;r.lng-i.lng<-180;)r.lng+=360;e.tweenGroup.add(new Lc(r).to(i,n).easing(Ec.Cubic.InOut).onUpdate(s).start())}else s(i);return this;function s(t){var n=t.lat,r=t.lng,i=t.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(n,r,i)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i