@mapxus/mapxus-visual 1.8.1 → 1.9.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/mapxus-visual.css +1070 -0
- package/dist/mapxus-visual.d.ts +6919 -0
- package/dist/mapxus-visual.js +11 -0
- package/dist/mapxus-visual.js.map +1 -0
- package/dist/mapxus-visual.module.d.ts +6919 -0
- package/dist/mapxus-visual.module.js +91327 -0
- package/dist/mapxus-visual.module.js.map +1 -0
- package/dist/mapxus-visual.unminified.js +91353 -0
- package/dist/mapxus-visual.unminified.js.map +1 -0
- package/package.json +45 -8
- package/LICENSE +0 -11
- package/index.css +0 -2
- package/index.d.ts +0 -163
- package/index.js +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MapxusVisual={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}let i;function r(){return void 0===i&&(i=function(){const e={alpha:!1,antialias:!1,depth:!0,failIfMajorPerformanceCaveat:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,stencil:!0},t=document.createElement("canvas"),i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);if(!i)return!1;const r=["OES_standard_derivatives"],n=i.getSupportedExtensions();for(const e of r)if(-1===n.indexOf(e))return!1;return!0}()),i}function n(){return"undefined"!=typeof window&&"undefined"!=typeof document&&!!(Array.prototype&&Array.prototype.filter&&Array.prototype.indexOf&&Array.prototype.map)&&!(!Function.prototype||!Function.prototype.bind)&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&&!(!Object.keys||!Object.assign)}var o;e.EdgeDirection=void 0,(o=e.EdgeDirection||(e.EdgeDirection={}))[o.Next=0]="Next",o[o.Prev=1]="Prev",o[o.StepLeft=2]="StepLeft",o[o.StepRight=3]="StepRight",o[o.StepForward=4]="StepForward",o[o.StepBackward=5]="StepBackward",o[o.TurnLeft=6]="TurnLeft",o[o.TurnRight=7]="TurnRight",o[o.TurnU=8]="TurnU",o[o.Pano=9]="Pano",o[o.Similar=10]="Similar";class s{constructor(){this.panoMinDistance=.1,this.panoMaxDistance=20,this.panoPreferredDistance=5,this.panoMaxItems=4,this.panoMaxStepTurnChange=Math.PI/8,this.rotationMaxDistance=this.turnMaxRigDistance,this.rotationMaxDirectionChange=Math.PI/6,this.rotationMaxVerticalDirectionChange=Math.PI/8,this.similarMaxDirectionChange=Math.PI/8,this.similarMaxDistance=12,this.similarMinTimeDifference=432e5,this.stepMaxDistance=20,this.stepMaxDirectionChange=Math.PI/6,this.stepMaxDrift=Math.PI/6,this.stepPreferredDistance=4,this.turnMaxDistance=15,this.turnMaxDirectionChange=2*Math.PI/9,this.turnMaxRigDistance=.65,this.turnMinRigDirectionChange=Math.PI/6}get maxDistance(){return Math.max(this.panoMaxDistance,this.similarMaxDistance,this.stepMaxDistance,this.turnMaxDistance)}}class a{constructor(){this.steps={},this.turns={},this.panos={},this.steps[e.EdgeDirection.StepForward]={direction:e.EdgeDirection.StepForward,motionChange:0,useFallback:!0},this.steps[e.EdgeDirection.StepBackward]={direction:e.EdgeDirection.StepBackward,motionChange:Math.PI,useFallback:!0},this.steps[e.EdgeDirection.StepLeft]={direction:e.EdgeDirection.StepLeft,motionChange:Math.PI/2,useFallback:!1},this.steps[e.EdgeDirection.StepRight]={direction:e.EdgeDirection.StepRight,motionChange:-Math.PI/2,useFallback:!1},this.turns[e.EdgeDirection.TurnLeft]={direction:e.EdgeDirection.TurnLeft,directionChange:Math.PI/2,motionChange:Math.PI/4},this.turns[e.EdgeDirection.TurnRight]={direction:e.EdgeDirection.TurnRight,directionChange:-Math.PI/2,motionChange:-Math.PI/4},this.turns[e.EdgeDirection.TurnU]={direction:e.EdgeDirection.TurnU,directionChange:Math.PI,motionChange:null},this.panos[e.EdgeDirection.StepForward]={direction:e.EdgeDirection.StepForward,directionChange:0,next:e.EdgeDirection.StepLeft,prev:e.EdgeDirection.StepRight},this.panos[e.EdgeDirection.StepBackward]={direction:e.EdgeDirection.StepBackward,directionChange:Math.PI,next:e.EdgeDirection.StepRight,prev:e.EdgeDirection.StepLeft},this.panos[e.EdgeDirection.StepLeft]={direction:e.EdgeDirection.StepLeft,directionChange:Math.PI/2,next:e.EdgeDirection.StepBackward,prev:e.EdgeDirection.StepForward},this.panos[e.EdgeDirection.StepRight]={direction:e.EdgeDirection.StepRight,directionChange:-Math.PI/2,next:e.EdgeDirection.StepForward,prev:e.EdgeDirection.StepBackward}}}class c{constructor(){this.panoPreferredDistance=2,this.panoMotion=2,this.panoSequencePenalty=1,this.panoMergeCCPenalty=4,this.stepPreferredDistance=4,this.stepMotion=3,this.stepRotation=4,this.stepSequencePenalty=2,this.stepMergeCCPenalty=6,this.similarDistance=2,this.similarRotation=3,this.turnDistance=4,this.turnMotion=2,this.turnSequencePenalty=1,this.turnMergeCCPenalty=4}}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");const t=Object(e);for(let e=1;e<arguments.length;e++){const i=arguments[e];if(null!=i)for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])}return t});const h=100,u=306,l=1e3,p=1001,d=1002,f=1003,m=1004,g=1005,v=1006,_=1008,y=1009,b=1012,x=1014,w=1015,A=1016,S=1020,M=1022,E=1023,T=1026,C=1027,I=2300,N=2301,P=2302,R=2400,O=2401,D=2402,L=2500,k=3e3,B=3001,F=3007,j=3002,z=7680,$=35044,V=35048;function U(){}Object.assign(U.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)},removeEventListener:function(e,t){if(void 0!==this._listeners){var i=this._listeners[e];if(void 0!==i){var r=i.indexOf(t);-1!==r&&i.splice(r,1)}}},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var i=t.slice(0),r=0,n=i.length;r<n;r++)i[r].call(this,e)}}}});for(var G=[],H=0;H<256;H++)G[H]=(H<16?"0":"")+H.toString(16);var q,W={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(G[255&e]+G[e>>8&255]+G[e>>16&255]+G[e>>24&255]+"-"+G[255&t]+G[t>>8&255]+"-"+G[t>>16&15|64]+G[t>>24&255]+"-"+G[63&i|128]+G[i>>8&255]+"-"+G[i>>16&255]+G[i>>24&255]+G[255&r]+G[r>>8&255]+G[r>>16&255]+G[r>>24&255]).toUpperCase()},clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-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())},degToRad:function(e){return e*W.DEG2RAD},radToDeg:function(e){return e*W.RAD2DEG},isPowerOfTwo:function(e){return 0==(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,i,r,n){var o=Math.cos,s=Math.sin,a=o(i/2),c=s(i/2),h=o((t+r)/2),u=s((t+r)/2),l=o((t-r)/2),p=s((t-r)/2),d=o((r-t)/2),f=s((r-t)/2);switch(n){case"XYX":e.set(a*u,c*l,c*p,a*h);break;case"YZY":e.set(c*p,a*u,c*l,a*h);break;case"ZXZ":e.set(c*l,c*p,a*u,a*h);break;case"XZX":e.set(a*u,c*f,c*d,a*h);break;case"YXY":e.set(c*d,a*u,c*f,a*h);break;case"ZYZ":e.set(c*f,c*d,a*u,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}};function Q(e,t){this.x=e||0,this.y=t||0}function Y(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(Q.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(Q.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(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:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){return Math.atan2(-this.y,-this.x)+Math.PI},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,o=this.y-e.y;return this.x=n*i-o*r+e.x,this.y=n*r+o*i+e.y,this},random:function(){return this.x=Math.random(),this.y=Math.random(),this}}),Object.assign(Y.prototype,{isMatrix3:!0,set:function(e,t,i,r,n,o,s,a,c){var h=this.elements;return h[0]=e,h[1]=r,h[2]=s,h[3]=t,h[4]=n,h[5]=a,h[6]=i,h[7]=o,h[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this},extractBasis:function(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this},setFromMatrix4:function(e){var 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:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements,n=this.elements,o=i[0],s=i[3],a=i[6],c=i[1],h=i[4],u=i[7],l=i[2],p=i[5],d=i[8],f=r[0],m=r[3],g=r[6],v=r[1],_=r[4],y=r[7],b=r[2],x=r[5],w=r[8];return n[0]=o*f+s*v+a*b,n[3]=o*m+s*_+a*x,n[6]=o*g+s*y+a*w,n[1]=c*f+h*v+u*b,n[4]=c*m+h*_+u*x,n[7]=c*g+h*y+u*w,n[2]=l*f+p*v+d*b,n[5]=l*m+p*_+d*x,n[8]=l*g+p*y+d*w,this},multiplyScalar:function(e){var 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:function(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],c=e[7],h=e[8];return t*o*h-t*s*c-i*n*h+i*s*a+r*n*c-r*o*a},getInverse:function(e,t){void 0!==t&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");var i=e.elements,r=this.elements,n=i[0],o=i[1],s=i[2],a=i[3],c=i[4],h=i[5],u=i[6],l=i[7],p=i[8],d=p*c-h*l,f=h*u-p*a,m=l*a-c*u,g=n*d+o*f+s*m;if(0===g)return this.set(0,0,0,0,0,0,0,0,0);var v=1/g;return r[0]=d*v,r[1]=(s*l-p*o)*v,r[2]=(h*o-s*c)*v,r[3]=f*v,r[4]=(p*n-s*u)*v,r[5]=(s*a-h*n)*v,r[6]=m*v,r[7]=(o*u-l*n)*v,r[8]=(c*n-o*a)*v,this},transpose:function(){var e,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:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var 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:function(e,t,i,r,n,o,s){var a=Math.cos(n),c=Math.sin(n);this.set(i*a,i*c,-i*(a*o+c*s)+o+e,-r*c,r*a,-r*(-c*o+a*s)+s+t,0,0,1)},scale:function(e,t){var i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this},rotate:function(e){var t=Math.cos(e),i=Math.sin(e),r=this.elements,n=r[0],o=r[3],s=r[6],a=r[1],c=r[4],h=r[7];return r[0]=t*n+i*a,r[3]=t*o+i*c,r[6]=t*s+i*h,r[1]=-i*n+t*a,r[4]=-i*o+t*c,r[7]=-i*s+t*h,this},translate:function(e,t){var i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this},equals:function(e){for(var t=this.elements,i=e.elements,r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var i=0;i<9;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}});var X={getDataURL:function(e){var t;if("undefined"==typeof HTMLCanvasElement)return e.src;if(e instanceof HTMLCanvasElement)t=e;else{void 0===q&&(q=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),q.width=e.width,q.height=e.height;var i=q.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=q}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},Z=0;function K(e,t,i,r,n,o,s,a,c,h){Object.defineProperty(this,"id",{value:Z++}),this.uuid=W.generateUUID(),this.name="",this.image=void 0!==e?e:K.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:K.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:p,this.wrapT=void 0!==r?r:p,this.magFilter=void 0!==n?n:v,this.minFilter=void 0!==o?o:_,this.anisotropy=void 0!==c?c:1,this.format=void 0!==s?s:E,this.internalFormat=null,this.type=void 0!==a?a:y,this.offset=new Q(0,0),this.repeat=new Q(1,1),this.center=new Q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Y,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:k,this.version=0,this.onUpdate=null}function J(e,t,i,r){this.x=e||0,this.y=t||0,this.z=i||0,this.w=void 0!==r?r:1}function ee(e,t,i){this.width=e,this.height=t,this.scissor=new J(0,0,e,t),this.scissorTest=!1,this.viewport=new J(0,0,e,t),i=i||{},this.texture=new K(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:v,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function te(e,t,i){ee.call(this,e,t,i),this.samples=4}function ie(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1}K.DEFAULT_IMAGE=void 0,K.DEFAULT_MAPPING=300,K.prototype=Object.assign(Object.create(U.prototype),{constructor:K,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=W.generateUUID()),!t&&void 0===e.images[r.uuid]){var n;if(Array.isArray(r)){n=[];for(var o=0,s=r.length;o<s;o++)n.push(X.getDataURL(r[o]))}else n=X.getDataURL(r);e.images[r.uuid]={uuid:r.uuid,url:n}}i.image=r.uuid}return t||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case l:e.x=e.x-Math.floor(e.x);break;case p:e.x=e.x<0?0:1;break;case d: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 l:e.y=e.y-Math.floor(e.y);break;case p:e.y=e.y<0?0:1;break;case d: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}}),Object.defineProperty(K.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.defineProperties(J.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign(J.prototype,{isVector4:!0,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(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:function(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:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(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:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(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:function(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:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(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},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*n,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*n,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*n,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var 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:function(e){var t,i,r,n,o=.01,s=.1,a=e.elements,c=a[0],h=a[4],u=a[8],l=a[1],p=a[5],d=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(h-l)<o&&Math.abs(u-f)<o&&Math.abs(d-m)<o){if(Math.abs(h+l)<s&&Math.abs(u+f)<s&&Math.abs(d+m)<s&&Math.abs(c+p+g-3)<s)return this.set(1,0,0,0),this;t=Math.PI;var v=(c+1)/2,_=(p+1)/2,y=(g+1)/2,b=(h+l)/4,x=(u+f)/4,w=(d+m)/4;return v>_&&v>y?v<o?(i=0,r=.707106781,n=.707106781):(r=b/(i=Math.sqrt(v)),n=x/i):_>y?_<o?(i=.707106781,r=0,n=.707106781):(i=b/(r=Math.sqrt(_)),n=w/r):y<o?(i=.707106781,r=.707106781,n=0):(i=x/(n=Math.sqrt(y)),r=w/n),this.set(i,r,n,t),this}var A=Math.sqrt((m-d)*(m-d)+(u-f)*(u-f)+(l-h)*(l-h));return Math.abs(A)<.001&&(A=1),this.x=(m-d)/A,this.y=(u-f)/A,this.z=(l-h)/A,this.w=Math.acos((c+p+g-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this},random:function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}),ee.prototype=Object.assign(Object.create(U.prototype),{constructor:ee,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.texture.image.width=e,this.texture.image.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),te.prototype=Object.assign(Object.create(ee.prototype),{constructor:te,isWebGLMultisampleRenderTarget:!0,copy:function(e){return ee.prototype.copy.call(this,e),this.samples=e.samples,this}}),Object.assign(ie,{slerp:function(e,t,i,r){return i.copy(e).slerp(t,r)},slerpFlat:function(e,t,i,r,n,o,s){var a=i[r+0],c=i[r+1],h=i[r+2],u=i[r+3],l=n[o+0],p=n[o+1],d=n[o+2],f=n[o+3];if(u!==f||a!==l||c!==p||h!==d){var m=1-s,g=a*l+c*p+h*d+u*f,v=g>=0?1:-1,_=1-g*g;if(_>Number.EPSILON){var y=Math.sqrt(_),b=Math.atan2(y,g*v);m=Math.sin(m*b)/y,s=Math.sin(s*b)/y}var x=s*v;if(a=a*m+l*x,c=c*m+p*x,h=h*m+d*x,u=u*m+f*x,m===1-s){var w=1/Math.sqrt(a*a+c*c+h*h+u*u);a*=w,c*=w,h*=w,u*=w}}e[t]=a,e[t+1]=c,e[t+2]=h,e[t+3]=u},multiplyQuaternionsFlat:function(e,t,i,r,n,o){var s=i[r],a=i[r+1],c=i[r+2],h=i[r+3],u=n[o],l=n[o+1],p=n[o+2],d=n[o+3];return e[t]=s*d+h*u+a*p-c*l,e[t+1]=a*d+h*l+c*u-s*p,e[t+2]=c*d+h*p+s*l-a*u,e[t+3]=h*d-s*u-a*l-c*p,e}}),Object.defineProperties(ie.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(ie.prototype,{isQuaternion:!0,set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=e._x,r=e._y,n=e._z,o=e.order,s=Math.cos,a=Math.sin,c=s(i/2),h=s(r/2),u=s(n/2),l=a(i/2),p=a(r/2),d=a(n/2);switch(o){case"XYZ":this._x=l*h*u+c*p*d,this._y=c*p*u-l*h*d,this._z=c*h*d+l*p*u,this._w=c*h*u-l*p*d;break;case"YXZ":this._x=l*h*u+c*p*d,this._y=c*p*u-l*h*d,this._z=c*h*d-l*p*u,this._w=c*h*u+l*p*d;break;case"ZXY":this._x=l*h*u-c*p*d,this._y=c*p*u+l*h*d,this._z=c*h*d+l*p*u,this._w=c*h*u-l*p*d;break;case"ZYX":this._x=l*h*u-c*p*d,this._y=c*p*u+l*h*d,this._z=c*h*d-l*p*u,this._w=c*h*u+l*p*d;break;case"YZX":this._x=l*h*u+c*p*d,this._y=c*p*u+l*h*d,this._z=c*h*d-l*p*u,this._w=c*h*u-l*p*d;break;case"XZY":this._x=l*h*u-c*p*d,this._y=c*p*u-l*h*d,this._z=c*h*d+l*p*u,this._w=c*h*u+l*p*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var t,i=e.elements,r=i[0],n=i[4],o=i[8],s=i[1],a=i[5],c=i[9],h=i[2],u=i[6],l=i[10],p=r+a+l;return p>0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(u-c)*t,this._y=(o-h)*t,this._z=(s-n)*t):r>a&&r>l?(t=2*Math.sqrt(1+r-a-l),this._w=(u-c)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(o+h)/t):a>l?(t=2*Math.sqrt(1+a-r-l),this._w=(o-h)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(c+u)/t):(t=2*Math.sqrt(1+l-r-a),this._w=(s-n)/t,this._x=(o+h)/t,this._y=(c+u)/t,this._z=.25*t),this._onChangeCallback(),this},setFromUnitVectors:function(e,t){var i=e.dot(t)+1;return i<1e-6?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(W.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var i=this.angleTo(e);if(0===i)return this;var r=Math.min(1,t/i);return this.slerp(e,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var 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:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z,o=e._w,s=t._x,a=t._y,c=t._z,h=t._w;return this._x=i*h+o*s+r*c-n*a,this._y=r*h+o*a+n*s-i*c,this._z=n*h+o*c+i*a-r*s,this._w=o*h-i*s-r*a-n*c,this._onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,o=this._w,s=o*e._w+i*e._x+r*e._y+n*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=o,this._x=i,this._y=r,this._z=n,this;var a=1-s*s;if(a<=Number.EPSILON){var c=1-t;return this._w=c*o+t*this._w,this._x=c*i+t*this._x,this._y=c*r+t*this._y,this._z=c*n+t*this._z,this.normalize(),this._onChangeCallback(),this}var h=Math.sqrt(a),u=Math.atan2(h,s),l=Math.sin((1-t)*u)/h,p=Math.sin(t*u)/h;return this._w=o*l+this._w*p,this._x=i*l+this._x*p,this._y=r*l+this._y*p,this._z=n*l+this._z*p,this._onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},fromBufferAttribute:function(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var re=new oe,ne=new ie;function oe(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}Object.assign(oe.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(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:function(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:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(ne.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(ne.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements,o=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,o=e.y,s=e.z,a=e.w,c=a*t+o*r-s*i,h=a*i+s*t-n*r,u=a*r+n*i-o*t,l=-n*t-o*i-s*r;return this.x=c*a+l*-n+h*-s-u*-o,this.y=h*a+l*-o+u*-n-c*-s,this.z=u*a+l*-s+c*-o-h*-n,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(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:function(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:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(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:function(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,o=t.x,s=t.y,a=t.z;return this.x=r*a-n*s,this.y=n*o-i*a,this.z=i*s-r*o,this},projectOnVector:function(e){var t=e.lengthSq();if(0===t)return this.set(0,0,0);var i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)},projectOnPlane:function(e){return re.copy(this).projectOnVector(e),this.sub(re)},reflect:function(e){return this.sub(re.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;var i=this.dot(e)/t;return Math.acos(W.clamp(i,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,i){var r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},setFromMatrix3Column:function(e,t){return this.fromArray(e.elements,3*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this},random:function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}});var se=new oe,ae=new de,ce=new oe(0,0,0),he=new oe(1,1,1),ue=new oe,le=new oe,pe=new oe;function de(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(de.prototype,{isMatrix4:!0,set:function(e,t,i,r,n,o,s,a,c,h,u,l,p,d,f,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=n,g[5]=o,g[9]=s,g[13]=a,g[2]=c,g[6]=h,g[10]=u,g[14]=l,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new de).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:function(e){var t=this.elements,i=e.elements,r=1/se.setFromMatrixColumn(e,0).length(),n=1/se.setFromMatrixColumn(e,1).length(),o=1/se.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,i=e.x,r=e.y,n=e.z,o=Math.cos(i),s=Math.sin(i),a=Math.cos(r),c=Math.sin(r),h=Math.cos(n),u=Math.sin(n);if("XYZ"===e.order){var l=o*h,p=o*u,d=s*h,f=s*u;t[0]=a*h,t[4]=-a*u,t[8]=c,t[1]=p+d*c,t[5]=l-f*c,t[9]=-s*a,t[2]=f-l*c,t[6]=d+p*c,t[10]=o*a}else if("YXZ"===e.order){var m=a*h,g=a*u,v=c*h,_=c*u;t[0]=m+_*s,t[4]=v*s-g,t[8]=o*c,t[1]=o*u,t[5]=o*h,t[9]=-s,t[2]=g*s-v,t[6]=_+m*s,t[10]=o*a}else if("ZXY"===e.order){m=a*h,g=a*u,v=c*h,_=c*u;t[0]=m-_*s,t[4]=-o*u,t[8]=v+g*s,t[1]=g+v*s,t[5]=o*h,t[9]=_-m*s,t[2]=-o*c,t[6]=s,t[10]=o*a}else if("ZYX"===e.order){l=o*h,p=o*u,d=s*h,f=s*u;t[0]=a*h,t[4]=d*c-p,t[8]=l*c+f,t[1]=a*u,t[5]=f*c+l,t[9]=p*c-d,t[2]=-c,t[6]=s*a,t[10]=o*a}else if("YZX"===e.order){var y=o*a,b=o*c,x=s*a,w=s*c;t[0]=a*h,t[4]=w-y*u,t[8]=x*u+b,t[1]=u,t[5]=o*h,t[9]=-s*h,t[2]=-c*h,t[6]=b*u+x,t[10]=y-w*u}else if("XZY"===e.order){y=o*a,b=o*c,x=s*a,w=s*c;t[0]=a*h,t[4]=-u,t[8]=c*h,t[1]=y*u+w,t[5]=o*h,t[9]=b*u-x,t[2]=x*u-b,t[6]=s*h,t[10]=w*u+y}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(ce,e,he)},lookAt:function(e,t,i){var r=this.elements;return pe.subVectors(e,t),0===pe.lengthSq()&&(pe.z=1),pe.normalize(),ue.crossVectors(i,pe),0===ue.lengthSq()&&(1===Math.abs(i.z)?pe.x+=1e-4:pe.z+=1e-4,pe.normalize(),ue.crossVectors(i,pe)),ue.normalize(),le.crossVectors(pe,ue),r[0]=ue.x,r[4]=le.x,r[8]=pe.x,r[1]=ue.y,r[5]=le.y,r[9]=pe.y,r[2]=ue.z,r[6]=le.z,r[10]=pe.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements,n=this.elements,o=i[0],s=i[4],a=i[8],c=i[12],h=i[1],u=i[5],l=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],v=i[3],_=i[7],y=i[11],b=i[15],x=r[0],w=r[4],A=r[8],S=r[12],M=r[1],E=r[5],T=r[9],C=r[13],I=r[2],N=r[6],P=r[10],R=r[14],O=r[3],D=r[7],L=r[11],k=r[15];return n[0]=o*x+s*M+a*I+c*O,n[4]=o*w+s*E+a*N+c*D,n[8]=o*A+s*T+a*P+c*L,n[12]=o*S+s*C+a*R+c*k,n[1]=h*x+u*M+l*I+p*O,n[5]=h*w+u*E+l*N+p*D,n[9]=h*A+u*T+l*P+p*L,n[13]=h*S+u*C+l*R+p*k,n[2]=d*x+f*M+m*I+g*O,n[6]=d*w+f*E+m*N+g*D,n[10]=d*A+f*T+m*P+g*L,n[14]=d*S+f*C+m*R+g*k,n[3]=v*x+_*M+y*I+b*O,n[7]=v*w+_*E+y*N+b*D,n[11]=v*A+_*T+y*P+b*L,n[15]=v*S+_*C+y*R+b*k,this},multiplyScalar:function(e){var 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:function(){var e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],o=e[1],s=e[5],a=e[9],c=e[13],h=e[2],u=e[6],l=e[10],p=e[14];return e[3]*(+n*a*u-r*c*u-n*s*l+i*c*l+r*s*p-i*a*p)+e[7]*(+t*a*p-t*c*l+n*o*l-r*o*p+r*c*h-n*a*h)+e[11]*(+t*c*u-t*s*p-n*o*u+i*o*p+n*s*h-i*c*h)+e[15]*(-r*s*h-t*a*u+t*s*l+r*o*u-i*o*l+i*a*h)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},setPosition:function(e,t,i){var 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]=i),this},getInverse:function(e,t){void 0!==t&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");var i=this.elements,r=e.elements,n=r[0],o=r[1],s=r[2],a=r[3],c=r[4],h=r[5],u=r[6],l=r[7],p=r[8],d=r[9],f=r[10],m=r[11],g=r[12],v=r[13],_=r[14],y=r[15],b=d*_*l-v*f*l+v*u*m-h*_*m-d*u*y+h*f*y,x=g*f*l-p*_*l-g*u*m+c*_*m+p*u*y-c*f*y,w=p*v*l-g*d*l+g*h*m-c*v*m-p*h*y+c*d*y,A=g*d*u-p*v*u-g*h*f+c*v*f+p*h*_-c*d*_,S=n*b+o*x+s*w+a*A;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var M=1/S;return i[0]=b*M,i[1]=(v*f*a-d*_*a-v*s*m+o*_*m+d*s*y-o*f*y)*M,i[2]=(h*_*a-v*u*a+v*s*l-o*_*l-h*s*y+o*u*y)*M,i[3]=(d*u*a-h*f*a-d*s*l+o*f*l+h*s*m-o*u*m)*M,i[4]=x*M,i[5]=(p*_*a-g*f*a+g*s*m-n*_*m-p*s*y+n*f*y)*M,i[6]=(g*u*a-c*_*a-g*s*l+n*_*l+c*s*y-n*u*y)*M,i[7]=(c*f*a-p*u*a+p*s*l-n*f*l-c*s*m+n*u*m)*M,i[8]=w*M,i[9]=(g*d*a-p*v*a-g*o*m+n*v*m+p*o*y-n*d*y)*M,i[10]=(c*v*a-g*h*a+g*o*l-n*v*l-c*o*y+n*h*y)*M,i[11]=(p*h*a-c*d*a-p*o*l+n*d*l+c*o*m-n*h*m)*M,i[12]=A*M,i[13]=(p*v*s-g*d*s+g*o*f-n*v*f-p*o*_+n*d*_)*M,i[14]=(g*h*s-c*v*s-g*o*u+n*v*u+c*o*_-n*h*_)*M,i[15]=(c*d*s-p*h*s+p*o*u-n*d*u-c*o*f+n*h*f)*M,this},scale:function(e){var t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=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,i,r))},makeTranslation:function(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=1-i,o=e.x,s=e.y,a=e.z,c=n*o,h=n*s;return this.set(c*o+i,c*s-r*a,c*a+r*s,0,c*s+r*a,h*s+i,h*a-r*o,0,c*a-r*s,h*a+r*o,n*a*a+i,0,0,0,0,1),this},makeScale:function(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(e,t,i){return this.set(1,t,i,0,e,1,i,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,i){var r=this.elements,n=t._x,o=t._y,s=t._z,a=t._w,c=n+n,h=o+o,u=s+s,l=n*c,p=n*h,d=n*u,f=o*h,m=o*u,g=s*u,v=a*c,_=a*h,y=a*u,b=i.x,x=i.y,w=i.z;return r[0]=(1-(f+g))*b,r[1]=(p+y)*b,r[2]=(d-_)*b,r[3]=0,r[4]=(p-y)*x,r[5]=(1-(l+g))*x,r[6]=(m+v)*x,r[7]=0,r[8]=(d+_)*w,r[9]=(m-v)*w,r[10]=(1-(l+f))*w,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this},decompose:function(e,t,i){var r=this.elements,n=se.set(r[0],r[1],r[2]).length(),o=se.set(r[4],r[5],r[6]).length(),s=se.set(r[8],r[9],r[10]).length();this.determinant()<0&&(n=-n),e.x=r[12],e.y=r[13],e.z=r[14],ae.copy(this);var a=1/n,c=1/o,h=1/s;return ae.elements[0]*=a,ae.elements[1]*=a,ae.elements[2]*=a,ae.elements[4]*=c,ae.elements[5]*=c,ae.elements[6]*=c,ae.elements[8]*=h,ae.elements[9]*=h,ae.elements[10]*=h,t.setFromRotationMatrix(ae),i.x=n,i.y=o,i.z=s,this},makePerspective:function(e,t,i,r,n,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var s=this.elements,a=2*n/(t-e),c=2*n/(i-r),h=(t+e)/(t-e),u=(i+r)/(i-r),l=-(o+n)/(o-n),p=-2*o*n/(o-n);return s[0]=a,s[4]=0,s[8]=h,s[12]=0,s[1]=0,s[5]=c,s[9]=u,s[13]=0,s[2]=0,s[6]=0,s[10]=l,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this},makeOrthographic:function(e,t,i,r,n,o){var s=this.elements,a=1/(t-e),c=1/(i-r),h=1/(o-n),u=(t+e)*a,l=(i+r)*c,p=(o+n)*h;return s[0]=2*a,s[4]=0,s[8]=0,s[12]=-u,s[1]=0,s[5]=2*c,s[9]=0,s[13]=-l,s[2]=0,s[6]=0,s[10]=-2*h,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this},equals:function(e){for(var t=this.elements,i=e.elements,r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}});var fe=new de,me=new ie;function ge(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._order=r||ge.DefaultOrder}function ve(){this.mask=1}ge.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ge.DefaultOrder="XYZ",Object.defineProperties(ge.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this._onChangeCallback()}}}),Object.assign(ge.prototype,{isEuler:!0,set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){var r=W.clamp,n=e.elements,o=n[0],s=n[4],a=n[8],c=n[1],h=n[5],u=n[9],l=n[2],p=n[6],d=n[10];switch(t=t||this._order){case"XYZ":this._y=Math.asin(r(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-s,o)):(this._x=Math.atan2(p,h),this._z=0);break;case"YXZ":this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-l,o),this._z=0);break;case"ZXY":this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(c,o));break;case"ZYX":this._y=Math.asin(-r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-l,o)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-r(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(p,h),this._y=Math.atan2(a,o)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!1!==i&&this._onChangeCallback(),this},setFromQuaternion:function(e,t,i){return fe.makeRotationFromQuaternion(e),this.setFromRotationMatrix(fe,t,i)},setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(e){return me.setFromEuler(this),this.setFromQuaternion(me,e)},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(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:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new oe(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}}),Object.assign(ve.prototype,{set:function(e){this.mask=1<<e|0},enable:function(e){this.mask|=1<<e|0},enableAll:function(){this.mask=-1},toggle:function(e){this.mask^=1<<e|0},disable:function(e){this.mask&=~(1<<e|0)},disableAll:function(){this.mask=0},test:function(e){return 0!=(this.mask&e.mask)}});let _e=0;const ye=new oe,be=new ie,xe=new de,we=new oe,Ae=new oe,Se=new oe,Me=new ie,Ee=new oe(1,0,0),Te=new oe(0,1,0),Ce=new oe(0,0,1),Ie={type:"added"},Ne={type:"removed"};function Pe(){Object.defineProperty(this,"id",{value:_e++}),this.uuid=W.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pe.DefaultUp.clone();var e=new oe,t=new ge,i=new ie,r=new oe(1,1,1);t._onChange((function(){i.setFromEuler(t,!1)})),i._onChange((function(){t.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new de},normalMatrix:{value:new Y}}),this.matrix=new de,this.matrixWorld=new de,this.matrixAutoUpdate=Pe.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new ve,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function Re(){Pe.call(this),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Pe.DefaultUp=new oe(0,1,0),Pe.DefaultMatrixAutoUpdate=!0,Pe.prototype=Object.assign(Object.create(U.prototype),{constructor:Pe,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(e,t){return be.setFromAxisAngle(e,t),this.quaternion.multiply(be),this},rotateOnWorldAxis:function(e,t){return be.setFromAxisAngle(e,t),this.quaternion.premultiply(be),this},rotateX:function(e){return this.rotateOnAxis(Ee,e)},rotateY:function(e){return this.rotateOnAxis(Te,e)},rotateZ:function(e){return this.rotateOnAxis(Ce,e)},translateOnAxis:function(e,t){return ye.copy(e).applyQuaternion(this.quaternion),this.position.add(ye.multiplyScalar(t)),this},translateX:function(e){return this.translateOnAxis(Ee,e)},translateY:function(e){return this.translateOnAxis(Te,e)},translateZ:function(e){return this.translateOnAxis(Ce,e)},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(xe.getInverse(this.matrixWorld))},lookAt:function(e,t,i){e.isVector3?we.copy(e):we.set(e,t,i);var r=this.parent;this.updateWorldMatrix(!0,!1),Ae.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xe.lookAt(Ae,we,this.up):xe.lookAt(we,Ae,this.up),this.quaternion.setFromRotationMatrix(xe),r&&(xe.extractRotation(r.matrixWorld),be.setFromRotationMatrix(xe),this.quaternion.premultiply(be.inverse()))},add:function(e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Ie)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)},remove:function(e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}var i=this.children.indexOf(e);return-1!==i&&(e.parent=null,this.children.splice(i,1),e.dispatchEvent(Ne)),this},attach:function(e){return this.updateWorldMatrix(!0,!1),xe.getInverse(this.matrixWorld),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),xe.multiply(e.parent.matrixWorld)),e.applyMatrix4(xe),e.updateWorldMatrix(!1,!1),this.add(e),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(var i=0,r=this.children.length;i<r;i++){var n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}},getWorldPosition:function(e){return void 0===e&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),e=new oe),this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(e){return void 0===e&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),e=new ie),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Ae,e,Se),e},getWorldScale:function(e){return void 0===e&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),e=new oe),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Ae,Me,e),e},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),e=new oe),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(e){e(this);for(var t=this.children,i=0,r=t.length;i<r;i++)t[i].traverse(e)},traverseVisible:function(e){if(!1!==this.visible){e(this);for(var t=this.children,i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}},traverseAncestors:function(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=this.children,i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)},updateWorldMatrix:function(e,t){var i=this.parent;if(!0===e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t)for(var r=this.children,n=0,o=r.length;n<o;n++)r[n].updateWorldMatrix(!1,!0)},toJSON:function(e){var t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var r={};function n(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){r.geometry=n(e.geometries,this.geometry);var o=this.geometry.parameters;if(void 0!==o&&void 0!==o.shapes){var s=o.shapes;if(Array.isArray(s))for(var a=0,c=s.length;a<c;a++){var h=s[a];n(e.shapes,h)}else n(e.shapes,s)}}if(void 0!==this.material)if(Array.isArray(this.material)){var u=[];for(a=0,c=this.material.length;a<c;a++)u.push(n(e.materials,this.material[a]));r.material=u}else r.material=n(e.materials,this.material);if(this.children.length>0){r.children=[];for(a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(t){var l=m(e.geometries),p=m(e.materials),d=m(e.textures),f=m(e.images);s=m(e.shapes);l.length>0&&(i.geometries=l),p.length>0&&(i.materials=p),d.length>0&&(i.textures=d),f.length>0&&(i.images=f),s.length>0&&(i.shapes=s)}return i.object=r,i;function m(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),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.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.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var i=0;i<e.children.length;i++){var r=e.children[i];this.add(r.clone())}return this}}),Re.prototype=Object.assign(Object.create(Pe.prototype),{constructor:Re,isScene:!0,copy:function(e,t){return Pe.prototype.copy.call(this,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()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},toJSON:function(e){var t=Pe.prototype.toJSON.call(this,e);return null!==this.background&&(t.object.background=this.background.toJSON(e)),null!==this.environment&&(t.object.environment=this.environment.toJSON(e)),null!==this.fog&&(t.object.fog=this.fog.toJSON()),t},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Oe=[new oe,new oe,new oe,new oe,new oe,new oe,new oe,new oe],De=new oe,Le=new qe,ke=new oe,Be=new oe,Fe=new oe,je=new oe,ze=new oe,$e=new oe,Ve=new oe,Ue=new oe,Ge=new oe,He=new oe;function qe(e,t){this.min=void 0!==e?e:new oe(1/0,1/0,1/0),this.max=void 0!==t?t:new oe(-1/0,-1/0,-1/0)}function We(e,t,i,r,n){var o,s;for(o=0,s=e.length-3;o<=s;o+=3){He.fromArray(e,o);var a=n.x*Math.abs(He.x)+n.y*Math.abs(He.y)+n.z*Math.abs(He.z),c=t.dot(He),h=i.dot(He),u=r.dot(He);if(Math.max(-Math.max(c,h,u),Math.min(c,h,u))>a)return!1}return!0}Object.assign(qe.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,s=-1/0,a=0,c=e.length;a<c;a+=3){var h=e[a],u=e[a+1],l=e[a+2];h<t&&(t=h),u<i&&(i=u),l<r&&(r=l),h>n&&(n=h),u>o&&(o=u),l>s&&(s=l)}return this.min.set(t,i,r),this.max.set(n,o,s),this},setFromBufferAttribute:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,s=-1/0,a=0,c=e.count;a<c;a++){var h=e.getX(a),u=e.getY(a),l=e.getZ(a);h<t&&(t=h),u<i&&(i=u),l<r&&(r=l),h>n&&(n=h),u>o&&(o=u),l>s&&(s=l)}return this.min.set(t,i,r),this.max.set(n,o,s),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(e,t){var i=De.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this},setFromObject:function(e){return this.makeEmpty(),this.expandByObject(e)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(e){return void 0===e&&(console.warn("THREE.Box3: .getCenter() target is now required"),e=new oe),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("THREE.Box3: .getSize() target is now required"),e=new oe),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},expandByObject:function(e){e.updateWorldMatrix(!1,!1);var t=e.geometry;void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),Le.copy(t.boundingBox),Le.applyMatrix4(e.matrixWorld),this.union(Le));for(var i=e.children,r=0,n=i.length;r<n;r++)this.expandByObject(i[r]);return this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)},containsBox:function(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:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new oe),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:function(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:function(e){return this.clampPoint(e.center,De),De.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Ve),Ue.subVectors(this.max,Ve),ke.subVectors(e.a,Ve),Be.subVectors(e.b,Ve),Fe.subVectors(e.c,Ve),je.subVectors(Be,ke),ze.subVectors(Fe,Be),$e.subVectors(ke,Fe);var t=[0,-je.z,je.y,0,-ze.z,ze.y,0,-$e.z,$e.y,je.z,0,-je.x,ze.z,0,-ze.x,$e.z,0,-$e.x,-je.y,je.x,0,-ze.y,ze.x,0,-$e.y,$e.x,0];return!!We(t,ke,Be,Fe,Ue)&&(!!We(t=[1,0,0,0,1,0,0,0,1],ke,Be,Fe,Ue)&&(Ge.crossVectors(je,ze),We(t=[Ge.x,Ge.y,Ge.z],ke,Be,Fe,Ue)))},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new oe),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return De.copy(e).clamp(this.min,this.max).sub(e).length()},getBoundingSphere:function(e){return void 0===e&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(De).length(),e},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){return this.isEmpty()||(Oe[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Oe[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Oe[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Oe[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Oe[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Oe[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Oe[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Oe[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Oe)),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var Qe=new qe;function Ye(e,t){this.center=void 0!==e?e:new oe,this.radius=void 0!==t?t:-1}Object.assign(Ye.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var i=this.center;void 0!==t?i.copy(t):Qe.setFromPoints(e).getCenter(i);for(var r=0,n=0,o=e.length;n<o;n++)r=Math.max(r,i.distanceToSquared(e[n]));return this.radius=Math.sqrt(r),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},isEmpty:function(){return this.radius<0},makeEmpty:function(){return this.center.set(0,0,0),this.radius=-1,this},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius},clampPoint:function(e,t){var i=this.center.distanceToSquared(e);return void 0===t&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),t=new oe),t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new qe),this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}});var Xe=new oe,Ze=new oe,Ke=new oe,Je=new oe,et=new oe,tt=new oe,it=new oe;function rt(e,t){this.origin=void 0!==e?e:new oe,this.direction=void 0!==t?t:new oe(0,0,-1)}Object.assign(rt.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new oe),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,Xe)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new oe),t.subVectors(e,this.origin);var i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=Xe.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Xe.copy(this.direction).multiplyScalar(t).add(this.origin),Xe.distanceToSquared(e))},distanceSqToSegment:function(e,t,i,r){Ze.copy(e).add(t).multiplyScalar(.5),Ke.copy(t).sub(e).normalize(),Je.copy(this.origin).sub(Ze);var n,o,s,a,c=.5*e.distanceTo(t),h=-this.direction.dot(Ke),u=Je.dot(this.direction),l=-Je.dot(Ke),p=Je.lengthSq(),d=Math.abs(1-h*h);if(d>0)if(o=h*u-l,a=c*d,(n=h*l-u)>=0)if(o>=-a)if(o<=a){var f=1/d;s=(n*=f)*(n+h*(o*=f)+2*u)+o*(h*n+o+2*l)+p}else o=c,s=-(n=Math.max(0,-(h*o+u)))*n+o*(o+2*l)+p;else o=-c,s=-(n=Math.max(0,-(h*o+u)))*n+o*(o+2*l)+p;else o<=-a?s=-(n=Math.max(0,-(-h*c+u)))*n+(o=n>0?-c:Math.min(Math.max(-c,-l),c))*(o+2*l)+p:o<=a?(n=0,s=(o=Math.min(Math.max(-c,-l),c))*(o+2*l)+p):s=-(n=Math.max(0,-(h*c+u)))*n+(o=n>0?c:Math.min(Math.max(-c,-l),c))*(o+2*l)+p;else o=h>0?-c:c,s=-(n=Math.max(0,-(h*o+u)))*n+o*(o+2*l)+p;return i&&i.copy(this.direction).multiplyScalar(n).add(this.origin),r&&r.copy(Ke).multiplyScalar(o).add(Ze),s},intersectSphere:function(e,t){Xe.subVectors(e.center,this.origin);var i=Xe.dot(this.direction),r=Xe.dot(Xe)-i*i,n=e.radius*e.radius;if(r>n)return null;var o=Math.sqrt(n-r),s=i-o,a=i+o;return s<0&&a<0?null:s<0?this.at(a,t):this.at(s,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var i,r,n,o,s,a,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,l=this.origin;return c>=0?(i=(e.min.x-l.x)*c,r=(e.max.x-l.x)*c):(i=(e.max.x-l.x)*c,r=(e.min.x-l.x)*c),h>=0?(n=(e.min.y-l.y)*h,o=(e.max.y-l.y)*h):(n=(e.max.y-l.y)*h,o=(e.min.y-l.y)*h),i>o||n>r?null:((n>i||i!=i)&&(i=n),(o<r||r!=r)&&(r=o),u>=0?(s=(e.min.z-l.z)*u,a=(e.max.z-l.z)*u):(s=(e.max.z-l.z)*u,a=(e.min.z-l.z)*u),i>a||s>r?null:((s>i||i!=i)&&(i=s),(a<r||r!=r)&&(r=a),r<0?null:this.at(i>=0?i:r,t)))},intersectsBox:function(e){return null!==this.intersectBox(e,Xe)},intersectTriangle:function(e,t,i,r,n){et.subVectors(t,e),tt.subVectors(i,e),it.crossVectors(et,tt);var o,s=this.direction.dot(it);if(s>0){if(r)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}Je.subVectors(this.origin,e);var a=o*this.direction.dot(tt.crossVectors(Je,tt));if(a<0)return null;var c=o*this.direction.dot(et.cross(Je));if(c<0)return null;if(a+c>s)return null;var h=-o*Je.dot(it);return h<0?null:this.at(h/s,n)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});var nt=new oe,ot=new oe,st=new Y;function at(e,t){this.normal=void 0!==e?e:new oe(1,0,0),this.constant=void 0!==t?t:0}Object.assign(at.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,i){var r=nt.subVectors(i,t).cross(ot.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new oe),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){void 0===t&&(console.warn("THREE.Plane: .intersectLine() target is now required"),t=new oe);var i=e.delta(nt),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;var n=-(e.start.dot(this.normal)+this.constant)/r;return n<0||n>1?void 0:t.copy(i).multiplyScalar(n).add(e.start)},intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new oe),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){var i=t||st.getNormalMatrix(e),r=this.coplanarPoint(nt).applyMatrix4(e),n=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(n),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});var ct=new oe,ht=new oe,ut=new oe,lt=new oe,pt=new oe,dt=new oe,ft=new oe,mt=new oe,gt=new oe,vt=new oe;function _t(e,t,i){this.a=void 0!==e?e:new oe,this.b=void 0!==t?t:new oe,this.c=void 0!==i?i:new oe}Object.assign(_t,{getNormal:function(e,t,i,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new oe),r.subVectors(i,t),ct.subVectors(e,t),r.cross(ct);var n=r.lengthSq();return n>0?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)},getBarycoord:function(e,t,i,r,n){ct.subVectors(r,t),ht.subVectors(i,t),ut.subVectors(e,t);var o=ct.dot(ct),s=ct.dot(ht),a=ct.dot(ut),c=ht.dot(ht),h=ht.dot(ut),u=o*c-s*s;if(void 0===n&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),n=new oe),0===u)return n.set(-2,-1,-1);var l=1/u,p=(c*a-s*h)*l,d=(o*h-s*a)*l;return n.set(1-p-d,d,p)},containsPoint:function(e,t,i,r){return _t.getBarycoord(e,t,i,r,lt),lt.x>=0&<.y>=0&<.x+lt.y<=1},getUV:function(e,t,i,r,n,o,s,a){return this.getBarycoord(e,t,i,r,lt),a.set(0,0),a.addScaledVector(n,lt.x),a.addScaledVector(o,lt.y),a.addScaledVector(s,lt.z),a},isFrontFacing:function(e,t,i,r){return ct.subVectors(i,t),ht.subVectors(e,t),ct.cross(ht).dot(r)<0}}),Object.assign(_t.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){return ct.subVectors(this.c,this.b),ht.subVectors(this.a,this.b),.5*ct.cross(ht).length()},getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new oe),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return _t.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new at),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return _t.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,i,r,n){return _t.getUV(e,this.a,this.b,this.c,t,i,r,n)},containsPoint:function(e){return _t.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return _t.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new oe);var i,r,n=this.a,o=this.b,s=this.c;pt.subVectors(o,n),dt.subVectors(s,n),mt.subVectors(e,n);var a=pt.dot(mt),c=dt.dot(mt);if(a<=0&&c<=0)return t.copy(n);gt.subVectors(e,o);var h=pt.dot(gt),u=dt.dot(gt);if(h>=0&&u<=h)return t.copy(o);var l=a*u-h*c;if(l<=0&&a>=0&&h<=0)return i=a/(a-h),t.copy(n).addScaledVector(pt,i);vt.subVectors(e,s);var p=pt.dot(vt),d=dt.dot(vt);if(d>=0&&p<=d)return t.copy(s);var f=p*c-a*d;if(f<=0&&c>=0&&d<=0)return r=c/(c-d),t.copy(n).addScaledVector(dt,r);var m=h*d-p*u;if(m<=0&&u-h>=0&&p-d>=0)return ft.subVectors(s,o),r=(u-h)/(u-h+(p-d)),t.copy(o).addScaledVector(ft,r);var g=1/(m+f+l);return i=f*g,r=l*g,t.copy(n).addScaledVector(pt,i).addScaledVector(dt,r)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var yt={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},bt={h:0,s:0,l:0},xt={h:0,s:0,l:0};function wt(e,t,i){return void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}function At(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}function St(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Mt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function Et(e,t,i,r,n,o){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new oe,this.vertexNormals=Array.isArray(r)?r:[],this.color=n&&n.isColor?n:new wt,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=void 0!==o?o:0}Object.assign(wt.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(e,t,i){if(e=W.euclideanModulo(e,1),t=W.clamp(t,0,1),i=W.clamp(i,0,1),0===t)this.r=this.g=this.b=i;else{var r=i<=.5?i*(1+t):i+t-i*t,n=2*i-r;this.r=At(n,r,e+1/3),this.g=At(n,r,e),this.b=At(n,r,e-1/3)}return this},setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var s=parseFloat(r[1])/360,a=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(s,a,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var h=i[1],u=h.length;if(3===u)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var t=yt[e];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=St(e.r),this.g=St(e.g),this.b=St(e.b),this},copyLinearToSRGB:function(e){return this.r=Mt(e.r),this.g=Mt(e.g),this.b=Mt(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,i,r=this.r,n=this.g,o=this.b,s=Math.max(r,n,o),a=Math.min(r,n,o),c=(a+s)/2;if(a===s)t=0,i=0;else{var h=s-a;switch(i=c<=.5?h/(s+a):h/(2-s-a),s){case r:t=(n-o)/h+(n<o?6:0);break;case n:t=(o-r)/h+2;break;case o:t=(r-n)/h+4}t/=6}return e.h=t,e.s=i,e.l=c,e},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(e,t,i){return this.getHSL(bt),bt.h+=e,bt.s+=t,bt.l+=i,this.setHSL(bt.h,bt.s,bt.l),this},add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},sub:function(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},lerpHSL:function(e,t){this.getHSL(bt),e.getHSL(xt);var i=W.lerp(bt.h,xt.h,t),r=W.lerp(bt.s,xt.s,t),n=W.lerp(bt.l,xt.l,t);return this.setHSL(i,r,n),this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e},toJSON:function(){return this.getHex()}}),wt.NAMES=yt,Object.assign(Et.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}});var Tt=0;function Ct(){Object.defineProperty(this,"id",{value:Tt++}),this.uuid=W.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=h,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=z,this.stencilZFail=z,this.stencilZPass=z,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}function It(e){Ct.call(this),this.type="MeshBasicMaterial",this.color=new wt(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.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(e)}Ct.prototype=Object.assign(Object.create(U.prototype),{constructor:Ct,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(void 0!==e)for(var t in e){var i=e[t];if(void 0!==i)if("shading"!==t){var r=this[t];void 0!==r?r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}else console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;else console.warn("THREE.Material: '"+t+"' parameter is undefined.")}},toJSON:function(e){var t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,void 0!==this.combine&&(i.combine=this.combine),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.morphNormals&&(i.morphNormals=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){var n=r(e.textures),o=r(e.images);n.length>0&&(i.textures=n),o.length>0&&(i.images=o)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,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.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;var t=e.clippingPlanes,i=null;if(null!==t){var r=t.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,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.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Ct.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),It.prototype=Object.create(Ct.prototype),It.prototype.constructor=It,It.prototype.isMeshBasicMaterial=!0,It.prototype.copy=function(e){return Ct.prototype.copy.call(this,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.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.skinning=e.skinning,this.morphTargets=e.morphTargets,this};var Nt=new oe;function Pt(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===i,this.usage=$,this.updateRange={offset:0,count:-1},this.version=0}function Rt(e,t,i){Pt.call(this,new Int8Array(e),t,i)}function Ot(e,t,i){Pt.call(this,new Uint8Array(e),t,i)}function Dt(e,t,i){Pt.call(this,new Uint8ClampedArray(e),t,i)}function Lt(e,t,i){Pt.call(this,new Int16Array(e),t,i)}function kt(e,t,i){Pt.call(this,new Uint16Array(e),t,i)}function Bt(e,t,i){Pt.call(this,new Int32Array(e),t,i)}function Ft(e,t,i){Pt.call(this,new Uint32Array(e),t,i)}function jt(e,t,i){Pt.call(this,new Float32Array(e),t,i)}function zt(e,t,i){Pt.call(this,new Float64Array(e),t,i)}function $t(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Vt(e){if(0===e.length)return-1/0;let t=e[0];for(let i=1,r=e.length;i<r;++i)e[i]>t&&(t=e[i]);return t}Object.defineProperty(Pt.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(Pt.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(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},copyAt:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(var r=0,n=this.itemSize;r<n;r++)this.array[e+r]=t.array[i+r];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;r<n;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),o=new wt),t[i++]=o.r,t[i++]=o.g,t[i++]=o.b}return this},copyVector2sArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;r<n;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),o=new Q),t[i++]=o.x,t[i++]=o.y}return this},copyVector3sArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;r<n;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),o=new oe),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z}return this},copyVector4sArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;r<n;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),o=new J),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z,t[i++]=o.w}return this},applyMatrix3:function(e){for(var t=0,i=this.count;t<i;t++)Nt.x=this.getX(t),Nt.y=this.getY(t),Nt.z=this.getZ(t),Nt.applyMatrix3(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this},applyMatrix4:function(e){for(var t=0,i=this.count;t<i;t++)Nt.x=this.getX(t),Nt.y=this.getY(t),Nt.z=this.getZ(t),Nt.applyMatrix4(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this},applyNormalMatrix:function(e){for(var t=0,i=this.count;t<i;t++)Nt.x=this.getX(t),Nt.y=this.getY(t),Nt.z=this.getZ(t),Nt.applyNormalMatrix(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this},transformDirection:function(e){for(var t=0,i=this.count;t<i;t++)Nt.x=this.getX(t),Nt.y=this.getY(t),Nt.z=this.getZ(t),Nt.transformDirection(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),Rt.prototype=Object.create(Pt.prototype),Rt.prototype.constructor=Rt,Ot.prototype=Object.create(Pt.prototype),Ot.prototype.constructor=Ot,Dt.prototype=Object.create(Pt.prototype),Dt.prototype.constructor=Dt,Lt.prototype=Object.create(Pt.prototype),Lt.prototype.constructor=Lt,kt.prototype=Object.create(Pt.prototype),kt.prototype.constructor=kt,Bt.prototype=Object.create(Pt.prototype),Bt.prototype.constructor=Bt,Ft.prototype=Object.create(Pt.prototype),Ft.prototype.constructor=Ft,jt.prototype=Object.create(Pt.prototype),jt.prototype.constructor=jt,zt.prototype=Object.create(Pt.prototype),zt.prototype.constructor=zt,Object.assign($t.prototype,{computeGroups:function(e){for(var t,i=[],r=void 0,n=e.faces,o=0;o<n.length;o++){var s=n[o];s.materialIndex!==r&&(r=s.materialIndex,void 0!==t&&(t.count=3*o-t.start,i.push(t)),t={start:3*o,materialIndex:r})}void 0!==t&&(t.count=3*o-t.start,i.push(t)),this.groups=i},fromGeometry:function(e){var t,i=e.faces,r=e.vertices,n=e.faceVertexUvs,o=n[0]&&n[0].length>0,s=n[1]&&n[1].length>0,a=e.morphTargets,c=a.length;if(c>0){t=[];for(var h=0;h<c;h++)t[h]={name:a[h].name,data:[]};this.morphTargets.position=t}var u,l=e.morphNormals,p=l.length;if(p>0){u=[];for(h=0;h<p;h++)u[h]={name:l[h].name,data:[]};this.morphTargets.normal=u}var d=e.skinIndices,f=e.skinWeights,m=d.length===r.length,g=f.length===r.length;r.length>0&&0===i.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(h=0;h<i.length;h++){var v=i[h];this.vertices.push(r[v.a],r[v.b],r[v.c]);var _=v.vertexNormals;if(3===_.length)this.normals.push(_[0],_[1],_[2]);else{var y=v.normal;this.normals.push(y,y,y)}var b,x=v.vertexColors;if(3===x.length)this.colors.push(x[0],x[1],x[2]);else{var w=v.color;this.colors.push(w,w,w)}if(!0===o)void 0!==(b=n[0][h])?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",h),this.uvs.push(new Q,new Q,new Q));if(!0===s)void 0!==(b=n[1][h])?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",h),this.uvs2.push(new Q,new Q,new Q));for(var A=0;A<c;A++){var S=a[A].vertices;t[A].data.push(S[v.a],S[v.b],S[v.c])}for(A=0;A<p;A++){var M=l[A].vertexNormals[h];u[A].data.push(M.a,M.b,M.c)}m&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this}});var Ut=1,Gt=new de,Ht=new Pe,qt=new oe,Wt=new qe,Qt=new qe,Yt=new oe;function Xt(){Object.defineProperty(this,"id",{value:Ut+=2}),this.uuid=W.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}Xt.prototype=Object.assign(Object.create(U.prototype),{constructor:Xt,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(Vt(e)>65535?Ft:kt)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){var t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);var i=this.attributes.normal;if(void 0!==i){var r=(new Y).getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}var n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return Gt.makeRotationX(e),this.applyMatrix4(Gt),this},rotateY:function(e){return Gt.makeRotationY(e),this.applyMatrix4(Gt),this},rotateZ:function(e){return Gt.makeRotationZ(e),this.applyMatrix4(Gt),this},translate:function(e,t,i){return Gt.makeTranslation(e,t,i),this.applyMatrix4(Gt),this},scale:function(e,t,i){return Gt.makeScale(e,t,i),this.applyMatrix4(Gt),this},lookAt:function(e){return Ht.lookAt(e),Ht.updateMatrix(),this.applyMatrix4(Ht.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(qt).negate(),this.translate(qt.x,qt.y,qt.z),this},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var i=new jt(3*t.vertices.length,3),r=new jt(3*t.colors.length,3);if(this.setAttribute("position",i.copyVector3sArray(t.vertices)),this.setAttribute("color",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var n=new jt(t.lineDistances.length,1);this.setAttribute("lineDistance",n.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],i=0,r=e.length;i<r;i++){var n=e[i];t.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new jt(t,3)),this},updateFromObject:function(e){var t,i=e.geometry;if(e.isMesh){var r=i.__directGeometry;if(!0===i.elementsNeedUpdate&&(r=void 0,i.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(i);r.verticesNeedUpdate=i.verticesNeedUpdate,r.normalsNeedUpdate=i.normalsNeedUpdate,r.colorsNeedUpdate=i.colorsNeedUpdate,r.uvsNeedUpdate=i.uvsNeedUpdate,r.groupsNeedUpdate=i.groupsNeedUpdate,i.verticesNeedUpdate=!1,i.normalsNeedUpdate=!1,i.colorsNeedUpdate=!1,i.uvsNeedUpdate=!1,i.groupsNeedUpdate=!1,i=r}return!0===i.verticesNeedUpdate&&(void 0!==(t=this.attributes.position)&&(t.copyVector3sArray(i.vertices),t.needsUpdate=!0),i.verticesNeedUpdate=!1),!0===i.normalsNeedUpdate&&(void 0!==(t=this.attributes.normal)&&(t.copyVector3sArray(i.normals),t.needsUpdate=!0),i.normalsNeedUpdate=!1),!0===i.colorsNeedUpdate&&(void 0!==(t=this.attributes.color)&&(t.copyColorsArray(i.colors),t.needsUpdate=!0),i.colorsNeedUpdate=!1),i.uvsNeedUpdate&&(void 0!==(t=this.attributes.uv)&&(t.copyVector2sArray(i.uvs),t.needsUpdate=!0),i.uvsNeedUpdate=!1),i.lineDistancesNeedUpdate&&(void 0!==(t=this.attributes.lineDistance)&&(t.copyArray(i.lineDistances),t.needsUpdate=!0),i.lineDistancesNeedUpdate=!1),i.groupsNeedUpdate&&(i.computeGroups(e.geometry),this.groups=i.groups,i.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new $t).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(3*e.vertices.length);if(this.setAttribute("position",new Pt(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){var i=new Float32Array(3*e.normals.length);this.setAttribute("normal",new Pt(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.setAttribute("color",new Pt(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var n=new Float32Array(2*e.uvs.length);this.setAttribute("uv",new Pt(n,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.setAttribute("uv2",new Pt(o,2).copyVector2sArray(e.uvs2))}for(var s in this.groups=e.groups,e.morphTargets){for(var a=[],c=e.morphTargets[s],h=0,u=c.length;h<u;h++){var l=c[h],p=new jt(3*l.data.length,3);p.name=l.name,a.push(p.copyVector3sArray(l.data))}this.morphAttributes[s]=a}if(e.skinIndices.length>0){var d=new jt(4*e.skinIndices.length,4);this.setAttribute("skinIndex",d.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new jt(4*e.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new qe);var e=this.attributes.position,t=this.morphAttributes.position;if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(var i=0,r=t.length;i<r;i++){var n=t[i];Wt.setFromBufferAttribute(n),this.morphTargetsRelative?(Yt.addVectors(this.boundingBox.min,Wt.min),this.boundingBox.expandByPoint(Yt),Yt.addVectors(this.boundingBox.max,Wt.max),this.boundingBox.expandByPoint(Yt)):(this.boundingBox.expandByPoint(Wt.min),this.boundingBox.expandByPoint(Wt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Ye);var e=this.attributes.position,t=this.morphAttributes.position;if(e){var i=this.boundingSphere.center;if(Wt.setFromBufferAttribute(e),t)for(var r=0,n=t.length;r<n;r++){var o=t[r];Qt.setFromBufferAttribute(o),this.morphTargetsRelative?(Yt.addVectors(Wt.min,Qt.min),Wt.expandByPoint(Yt),Yt.addVectors(Wt.max,Qt.max),Wt.expandByPoint(Yt)):(Wt.expandByPoint(Qt.min),Wt.expandByPoint(Qt.max))}Wt.getCenter(i);var s=0;for(r=0,n=e.count;r<n;r++)Yt.fromBufferAttribute(e,r),s=Math.max(s,i.distanceToSquared(Yt));if(t)for(r=0,n=t.length;r<n;r++){o=t[r];for(var a=this.morphTargetsRelative,c=0,h=o.count;c<h;c++)Yt.fromBufferAttribute(o,c),a&&(qt.fromBufferAttribute(e,c),Yt.add(qt)),s=Math.max(s,i.distanceToSquared(Yt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,t=this.attributes;if(t.position){var i=t.position.array;if(void 0===t.normal)this.setAttribute("normal",new Pt(new Float32Array(i.length),3));else for(var r=t.normal.array,n=0,o=r.length;n<o;n++)r[n]=0;var s,a,c,h=t.normal.array,u=new oe,l=new oe,p=new oe,d=new oe,f=new oe;if(e){var m=e.array;for(n=0,o=e.count;n<o;n+=3)s=3*m[n+0],a=3*m[n+1],c=3*m[n+2],u.fromArray(i,s),l.fromArray(i,a),p.fromArray(i,c),d.subVectors(p,l),f.subVectors(u,l),d.cross(f),h[s]+=d.x,h[s+1]+=d.y,h[s+2]+=d.z,h[a]+=d.x,h[a+1]+=d.y,h[a+2]+=d.z,h[c]+=d.x,h[c+1]+=d.y,h[c+2]+=d.z}else for(n=0,o=i.length;n<o;n+=9)u.fromArray(i,n),l.fromArray(i,n+3),p.fromArray(i,n+6),d.subVectors(p,l),f.subVectors(u,l),d.cross(f),h[n]=d.x,h[n+1]=d.y,h[n+2]=d.z,h[n+3]=d.x,h[n+4]=d.y,h[n+5]=d.z,h[n+6]=d.x,h[n+7]=d.y,h[n+8]=d.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},merge:function(e,t){if(e&&e.isBufferGeometry){void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var i=this.attributes;for(var r in i)if(void 0!==e.attributes[r])for(var n=i[r].array,o=e.attributes[r],s=o.array,a=o.itemSize*t,c=Math.min(s.length,n.length-a),h=0,u=a;h<c;h++,u++)n[u]=s[h];return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e)},normalizeNormals:function(){for(var e=this.attributes.normal,t=0,i=e.count;t<i;t++)Yt.x=e.getX(t),Yt.y=e.getY(t),Yt.z=e.getZ(t),Yt.normalize(),e.setXYZ(t,Yt.x,Yt.y,Yt.z)},toNonIndexed:function(){function e(e,t){for(var i=e.array,r=e.itemSize,n=e.normalized,o=new i.constructor(t.length*r),s=0,a=0,c=0,h=t.length;c<h;c++){s=t[c]*r;for(var u=0;u<r;u++)o[a++]=i[s++]}return new Pt(o,r,n)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new Xt,i=this.index.array,r=this.attributes;for(var n in r){var o=e(r[n],i);t.setAttribute(n,o)}var s=this.morphAttributes;for(n in s){for(var a=[],c=s[n],h=0,u=c.length;h<u;h++){o=e(c[h],i);a.push(o)}t.morphAttributes[n]=a}t.morphTargetsRelative=this.morphTargetsRelative;for(var l=this.groups,p=(h=0,l.length);h<p;h++){var d=l[h];t.addGroup(d.start,d.count,d.materialIndex)}return t},toJSON:function(){var e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};var r=this.index;null!==r&&(e.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var n=this.attributes;for(var i in n){var o=(p=n[i]).toJSON();""!==p.name&&(o.name=p.name),e.data.attributes[i]=o}var s={},a=!1;for(var i in this.morphAttributes){for(var c=this.morphAttributes[i],h=[],u=0,l=c.length;u<l;u++){var p;o=(p=c[u]).toJSON();""!==p.name&&(o.name=p.name),h.push(o)}h.length>0&&(s[i]=h,a=!0)}a&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);var d=this.groups;d.length>0&&(e.data.groups=JSON.parse(JSON.stringify(d)));var f=this.boundingSphere;return null!==f&&(e.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),e},clone:function(){return(new Xt).copy(this)},copy:function(e){var t,i,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var n=e.index;null!==n&&this.setIndex(n.clone());var o=e.attributes;for(t in o){var s=o[t];this.setAttribute(t,s.clone())}var a=e.morphAttributes;for(t in a){var c=[],h=a[t];for(i=0,r=h.length;i<r;i++)c.push(h[i].clone());this.morphAttributes[t]=c}this.morphTargetsRelative=e.morphTargetsRelative;var u=e.groups;for(i=0,r=u.length;i<r;i++){var l=u[i];this.addGroup(l.start,l.count,l.materialIndex)}var p=e.boundingBox;null!==p&&(this.boundingBox=p.clone());var d=e.boundingSphere;return null!==d&&(this.boundingSphere=d.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Zt=new de,Kt=new rt,Jt=new Ye,ei=new oe,ti=new oe,ii=new oe,ri=new oe,ni=new oe,oi=new oe,si=new oe,ai=new oe,ci=new oe,hi=new Q,ui=new Q,li=new Q,pi=new oe,di=new oe;function fi(e,t){Pe.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new Xt,this.material=void 0!==t?t:new It,this.updateMorphTargets()}function mi(e,t,i,r,n,o,s,a){if(null===(1===t.side?r.intersectTriangle(s,o,n,!0,a):r.intersectTriangle(n,o,s,2!==t.side,a)))return null;di.copy(a),di.applyMatrix4(e.matrixWorld);var c=i.ray.origin.distanceTo(di);return c<i.near||c>i.far?null:{distance:c,point:di.clone(),object:e}}function gi(e,t,i,r,n,o,s,a,c,h,u,l){ei.fromBufferAttribute(n,h),ti.fromBufferAttribute(n,u),ii.fromBufferAttribute(n,l);var p=e.morphTargetInfluences;if(t.morphTargets&&o&&p){si.set(0,0,0),ai.set(0,0,0),ci.set(0,0,0);for(var d=0,f=o.length;d<f;d++){var m=p[d],g=o[d];0!==m&&(ri.fromBufferAttribute(g,h),ni.fromBufferAttribute(g,u),oi.fromBufferAttribute(g,l),s?(si.addScaledVector(ri,m),ai.addScaledVector(ni,m),ci.addScaledVector(oi,m)):(si.addScaledVector(ri.sub(ei),m),ai.addScaledVector(ni.sub(ti),m),ci.addScaledVector(oi.sub(ii),m)))}ei.add(si),ti.add(ai),ii.add(ci)}e.isSkinnedMesh&&(e.boneTransform(h,ei),e.boneTransform(u,ti),e.boneTransform(l,ii));var v=mi(e,t,i,r,ei,ti,ii,pi);if(v){a&&(hi.fromBufferAttribute(a,h),ui.fromBufferAttribute(a,u),li.fromBufferAttribute(a,l),v.uv=_t.getUV(pi,ei,ti,ii,hi,ui,li,new Q)),c&&(hi.fromBufferAttribute(c,h),ui.fromBufferAttribute(c,u),li.fromBufferAttribute(c,l),v.uv2=_t.getUV(pi,ei,ti,ii,hi,ui,li,new Q));var _=new Et(h,u,l);_t.getNormal(ei,ti,ii,_.normal),v.face=_}return v}fi.prototype=Object.assign(Object.create(Pe.prototype),{constructor:fi,isMesh:!0,copy:function(e){return Pe.prototype.copy.call(this,e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e,t,i,r=this.geometry;if(r.isBufferGeometry){var n=r.morphAttributes,o=Object.keys(n);if(o.length>0){var s=n[o[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;e<t;e++)i=s[e].name||String(e),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}else{var a=r.morphTargets;void 0!==a&&a.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){var i,r=this.geometry,n=this.material,o=this.matrixWorld;if(void 0!==n&&(null===r.boundingSphere&&r.computeBoundingSphere(),Jt.copy(r.boundingSphere),Jt.applyMatrix4(o),!1!==e.ray.intersectsSphere(Jt)&&(Zt.getInverse(o),Kt.copy(e.ray).applyMatrix4(Zt),null===r.boundingBox||!1!==Kt.intersectsBox(r.boundingBox))))if(r.isBufferGeometry){var s,a,c,h,u,l,p,d,f,m=r.index,g=r.attributes.position,v=r.morphAttributes.position,_=r.morphTargetsRelative,y=r.attributes.uv,b=r.attributes.uv2,x=r.groups,w=r.drawRange;if(null!==m)if(Array.isArray(n))for(h=0,l=x.length;h<l;h++)for(f=n[(d=x[h]).materialIndex],u=Math.max(d.start,w.start),p=Math.min(d.start+d.count,w.start+w.count);u<p;u+=3)s=m.getX(u),a=m.getX(u+1),c=m.getX(u+2),(i=gi(this,f,e,Kt,g,v,_,y,b,s,a,c))&&(i.faceIndex=Math.floor(u/3),i.face.materialIndex=d.materialIndex,t.push(i));else for(h=Math.max(0,w.start),l=Math.min(m.count,w.start+w.count);h<l;h+=3)s=m.getX(h),a=m.getX(h+1),c=m.getX(h+2),(i=gi(this,n,e,Kt,g,v,_,y,b,s,a,c))&&(i.faceIndex=Math.floor(h/3),t.push(i));else if(void 0!==g)if(Array.isArray(n))for(h=0,l=x.length;h<l;h++)for(f=n[(d=x[h]).materialIndex],u=Math.max(d.start,w.start),p=Math.min(d.start+d.count,w.start+w.count);u<p;u+=3)(i=gi(this,f,e,Kt,g,v,_,y,b,s=u,a=u+1,c=u+2))&&(i.faceIndex=Math.floor(u/3),i.face.materialIndex=d.materialIndex,t.push(i));else for(h=Math.max(0,w.start),l=Math.min(g.count,w.start+w.count);h<l;h+=3)(i=gi(this,n,e,Kt,g,v,_,y,b,s=h,a=h+1,c=h+2))&&(i.faceIndex=Math.floor(h/3),t.push(i))}else if(r.isGeometry){var A,S,M,E,T=Array.isArray(n),C=r.vertices,I=r.faces,N=r.faceVertexUvs[0];N.length>0&&(E=N);for(var P=0,R=I.length;P<R;P++){var O=I[P],D=T?n[O.materialIndex]:n;if(void 0!==D&&(A=C[O.a],S=C[O.b],M=C[O.c],i=mi(this,D,e,Kt,A,S,M,pi))){if(E&&E[P]){var L=E[P];hi.copy(L[0]),ui.copy(L[1]),li.copy(L[2]),i.uv=_t.getUV(pi,A,S,M,hi,ui,li,new Q)}i.face=O,i.faceIndex=P,t.push(i)}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var vi=0,_i=new de,yi=new Pe,bi=new oe;function xi(){Object.defineProperty(this,"id",{value:vi+=2}),this.uuid=W.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}xi.prototype=Object.assign(Object.create(U.prototype),{constructor:xi,isGeometry:!0,applyMatrix4:function(e){for(var t=(new Y).getNormalMatrix(e),i=0,r=this.vertices.length;i<r;i++){this.vertices[i].applyMatrix4(e)}for(i=0,r=this.faces.length;i<r;i++){var n=this.faces[i];n.normal.applyMatrix3(t).normalize();for(var o=0,s=n.vertexNormals.length;o<s;o++)n.vertexNormals[o].applyMatrix3(t).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return _i.makeRotationX(e),this.applyMatrix4(_i),this},rotateY:function(e){return _i.makeRotationY(e),this.applyMatrix4(_i),this},rotateZ:function(e){return _i.makeRotationZ(e),this.applyMatrix4(_i),this},translate:function(e,t,i){return _i.makeTranslation(e,t,i),this.applyMatrix4(_i),this},scale:function(e,t,i){return _i.makeScale(e,t,i),this.applyMatrix4(_i),this},lookAt:function(e){return yi.lookAt(e),yi.updateMatrix(),this.applyMatrix4(yi.matrix),this},fromBufferGeometry:function(e){var t=this,i=null!==e.index?e.index.array:void 0,r=e.attributes;if(void 0===r.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var n=r.position.array,o=void 0!==r.normal?r.normal.array:void 0,s=void 0!==r.color?r.color.array:void 0,a=void 0!==r.uv?r.uv.array:void 0,c=void 0!==r.uv2?r.uv2.array:void 0;void 0!==c&&(this.faceVertexUvs[1]=[]);for(var h=0;h<n.length;h+=3)t.vertices.push((new oe).fromArray(n,h)),void 0!==s&&t.colors.push((new wt).fromArray(s,h));function u(e,i,r,n){var h=void 0===s?[]:[t.colors[e].clone(),t.colors[i].clone(),t.colors[r].clone()],u=new Et(e,i,r,void 0===o?[]:[(new oe).fromArray(o,3*e),(new oe).fromArray(o,3*i),(new oe).fromArray(o,3*r)],h,n);t.faces.push(u),void 0!==a&&t.faceVertexUvs[0].push([(new Q).fromArray(a,2*e),(new Q).fromArray(a,2*i),(new Q).fromArray(a,2*r)]),void 0!==c&&t.faceVertexUvs[1].push([(new Q).fromArray(c,2*e),(new Q).fromArray(c,2*i),(new Q).fromArray(c,2*r)])}var l=e.groups;if(l.length>0)for(h=0;h<l.length;h++)for(var p=l[h],d=p.start,f=d,m=d+p.count;f<m;f+=3)void 0!==i?u(i[f],i[f+1],i[f+2],p.materialIndex):u(f,f+1,f+2,p.materialIndex);else if(void 0!==i)for(h=0;h<i.length;h+=3)u(i[h],i[h+1],i[h+2]);else for(h=0;h<n.length/3;h+=3)u(h,h+1,h+2);return this.computeFaceNormals(),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(bi).negate(),this.translate(bi.x,bi.y,bi.z),this},normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,t=this.boundingSphere.radius,i=0===t?1:1/t,r=new de;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this},computeFaceNormals:function(){for(var e=new oe,t=new oe,i=0,r=this.faces.length;i<r;i++){var n=this.faces[i],o=this.vertices[n.a],s=this.vertices[n.b],a=this.vertices[n.c];e.subVectors(a,s),t.subVectors(o,s),e.cross(t),e.normalize(),n.normal.copy(e)}},computeVertexNormals:function(e){var t,i,r,n,o,s;for(void 0===e&&(e=!0),s=new Array(this.vertices.length),t=0,i=this.vertices.length;t<i;t++)s[t]=new oe;if(e){var a,c,h,u=new oe,l=new oe;for(r=0,n=this.faces.length;r<n;r++)o=this.faces[r],a=this.vertices[o.a],c=this.vertices[o.b],h=this.vertices[o.c],u.subVectors(h,c),l.subVectors(a,c),u.cross(l),s[o.a].add(u),s[o.b].add(u),s[o.c].add(u)}else for(this.computeFaceNormals(),r=0,n=this.faces.length;r<n;r++)s[(o=this.faces[r]).a].add(o.normal),s[o.b].add(o.normal),s[o.c].add(o.normal);for(t=0,i=this.vertices.length;t<i;t++)s[t].normalize();for(r=0,n=this.faces.length;r<n;r++){var p=(o=this.faces[r]).vertexNormals;3===p.length?(p[0].copy(s[o.a]),p[1].copy(s[o.b]),p[2].copy(s[o.c])):(p[0]=s[o.a].clone(),p[1]=s[o.b].clone(),p[2]=s[o.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,i;for(this.computeFaceNormals(),e=0,t=this.faces.length;e<t;e++){var r=(i=this.faces[e]).vertexNormals;3===r.length?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,r,n;for(i=0,r=this.faces.length;i<r;i++)for((n=this.faces[i]).__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),e=0,t=n.vertexNormals.length;e<t;e++)n.__originalVertexNormals[e]?n.__originalVertexNormals[e].copy(n.vertexNormals[e]):n.__originalVertexNormals[e]=n.vertexNormals[e].clone();var o=new xi;for(o.faces=this.faces,e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];var s=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(i=0,r=this.faces.length;i<r;i++)c=new oe,h={a:new oe,b:new oe,c:new oe},s.push(c),a.push(h)}var c,h,u=this.morphNormals[e];for(o.vertices=this.morphTargets[e].vertices,o.computeFaceNormals(),o.computeVertexNormals(),i=0,r=this.faces.length;i<r;i++)n=this.faces[i],c=u.faceNormals[i],h=u.vertexNormals[i],c.copy(n.normal),h.a.copy(n.vertexNormals[0]),h.b.copy(n.vertexNormals[1]),h.c.copy(n.vertexNormals[2])}for(i=0,r=this.faces.length;i<r;i++)(n=this.faces[i]).normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new qe),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Ye),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,i){if(e&&e.isGeometry){var r,n=this.vertices.length,o=this.vertices,s=e.vertices,a=this.faces,c=e.faces,h=this.colors,u=e.colors;void 0===i&&(i=0),void 0!==t&&(r=(new Y).getNormalMatrix(t));for(var l=0,p=s.length;l<p;l++){var d=s[l].clone();void 0!==t&&d.applyMatrix4(t),o.push(d)}for(l=0,p=u.length;l<p;l++)h.push(u[l].clone());for(l=0,p=c.length;l<p;l++){var f,m,g,v=c[l],_=v.vertexNormals,y=v.vertexColors;(f=new Et(v.a+n,v.b+n,v.c+n)).normal.copy(v.normal),void 0!==r&&f.normal.applyMatrix3(r).normalize();for(var b=0,x=_.length;b<x;b++)m=_[b].clone(),void 0!==r&&m.applyMatrix3(r).normalize(),f.vertexNormals.push(m);f.color.copy(v.color);for(b=0,x=y.length;b<x;b++)g=y[b],f.vertexColors.push(g.clone());f.materialIndex=v.materialIndex+i,a.push(f)}for(l=0,p=e.faceVertexUvs.length;l<p;l++){var w=e.faceVertexUvs[l];void 0===this.faceVertexUvs[l]&&(this.faceVertexUvs[l]=[]);for(b=0,x=w.length;b<x;b++){for(var A=w[b],S=[],M=0,E=A.length;M<E;M++)S.push(A[M].clone());this.faceVertexUvs[l].push(S)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e)},mergeMesh:function(e){e&&e.isMesh?(e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e)},mergeVertices:function(){var e,t,i,r,n,o,s,a,c={},h=[],u=[],l=Math.pow(10,4);for(i=0,r=this.vertices.length;i<r;i++)e=this.vertices[i],void 0===c[t=Math.round(e.x*l)+"_"+Math.round(e.y*l)+"_"+Math.round(e.z*l)]?(c[t]=i,h.push(this.vertices[i]),u[i]=h.length-1):u[i]=u[c[t]];var p=[];for(i=0,r=this.faces.length;i<r;i++){(n=this.faces[i]).a=u[n.a],n.b=u[n.b],n.c=u[n.c],o=[n.a,n.b,n.c];for(var d=0;d<3;d++)if(o[d]===o[(d+1)%3]){p.push(i);break}}for(i=p.length-1;i>=0;i--){var f=p[i];for(this.faces.splice(f,1),s=0,a=this.faceVertexUvs.length;s<a;s++)this.faceVertexUvs[s].splice(f,1)}var m=this.vertices.length-h.length;return this.vertices=h,m},setFromPoints:function(e){this.vertices=[];for(var t=0,i=e.length;t<i;t++){var r=e[t];this.vertices.push(new oe(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){for(var e=this.faces,t=e.length,i=0;i<t;i++)e[i]._id=i;e.sort((function(e,t){return e.materialIndex-t.materialIndex}));var r,n,o=this.faceVertexUvs[0],s=this.faceVertexUvs[1];o&&o.length===t&&(r=[]),s&&s.length===t&&(n=[]);for(i=0;i<t;i++){var a=e[i]._id;r&&r.push(o[a]),n&&n.push(s[a])}r&&(this.faceVertexUvs[0]=r),n&&(this.faceVertexUvs[1]=n)},toJSON:function(){var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),void 0!==this.parameters){var t=this.parameters;for(var i in t)void 0!==t[i]&&(e[i]=t[i]);return e}for(var r=[],n=0;n<this.vertices.length;n++){var o=this.vertices[n];r.push(o.x,o.y,o.z)}var s=[],a=[],c={},h=[],u={},l=[],p={};for(n=0;n<this.faces.length;n++){var d=this.faces[n],f=void 0!==this.faceVertexUvs[0][n],m=d.normal.length()>0,g=d.vertexNormals.length>0,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,_=d.vertexColors.length>0,y=0;if(y=A(y,0,0),y=A(y,1,!0),y=A(y,2,!1),y=A(y,3,f),y=A(y,4,m),y=A(y,5,g),y=A(y,6,v),y=A(y,7,_),s.push(y),s.push(d.a,d.b,d.c),s.push(d.materialIndex),f){var b=this.faceVertexUvs[0][n];s.push(E(b[0]),E(b[1]),E(b[2]))}if(m&&s.push(S(d.normal)),g){var x=d.vertexNormals;s.push(S(x[0]),S(x[1]),S(x[2]))}if(v&&s.push(M(d.color)),_){var w=d.vertexColors;s.push(M(w[0]),M(w[1]),M(w[2]))}}function A(e,t,i){return i?e|1<<t:e&~(1<<t)}function S(e){var t=e.x.toString()+e.y.toString()+e.z.toString();return void 0!==c[t]||(c[t]=a.length/3,a.push(e.x,e.y,e.z)),c[t]}function M(e){var t=e.r.toString()+e.g.toString()+e.b.toString();return void 0!==u[t]||(u[t]=h.length,h.push(e.getHex())),u[t]}function E(e){var t=e.x.toString()+e.y.toString();return void 0!==p[t]||(p[t]=l.length/2,l.push(e.x,e.y)),p[t]}return e.data={},e.data.vertices=r,e.data.normals=a,h.length>0&&(e.data.colors=h),l.length>0&&(e.data.uvs=[l]),e.data.faces=s,e},clone:function(){return(new xi).copy(this)},copy:function(e){var t,i,r,n,o,s;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var a=e.vertices;for(t=0,i=a.length;t<i;t++)this.vertices.push(a[t].clone());var c=e.colors;for(t=0,i=c.length;t<i;t++)this.colors.push(c[t].clone());var h=e.faces;for(t=0,i=h.length;t<i;t++)this.faces.push(h[t].clone());for(t=0,i=e.faceVertexUvs.length;t<i;t++){var u=e.faceVertexUvs[t];for(void 0===this.faceVertexUvs[t]&&(this.faceVertexUvs[t]=[]),r=0,n=u.length;r<n;r++){var l=u[r],p=[];for(o=0,s=l.length;o<s;o++){var d=l[o];p.push(d.clone())}this.faceVertexUvs[t].push(p)}}var f=e.morphTargets;for(t=0,i=f.length;t<i;t++){var m={};if(m.name=f[t].name,void 0!==f[t].vertices)for(m.vertices=[],r=0,n=f[t].vertices.length;r<n;r++)m.vertices.push(f[t].vertices[r].clone());if(void 0!==f[t].normals)for(m.normals=[],r=0,n=f[t].normals.length;r<n;r++)m.normals.push(f[t].normals[r].clone());this.morphTargets.push(m)}var g=e.morphNormals;for(t=0,i=g.length;t<i;t++){var v={};if(void 0!==g[t].vertexNormals)for(v.vertexNormals=[],r=0,n=g[t].vertexNormals.length;r<n;r++){var _=g[t].vertexNormals[r],y={};y.a=_.a.clone(),y.b=_.b.clone(),y.c=_.c.clone(),v.vertexNormals.push(y)}if(void 0!==g[t].faceNormals)for(v.faceNormals=[],r=0,n=g[t].faceNormals.length;r<n;r++)v.faceNormals.push(g[t].faceNormals[r].clone());this.morphNormals.push(v)}var b=e.skinWeights;for(t=0,i=b.length;t<i;t++)this.skinWeights.push(b[t].clone());var x=e.skinIndices;for(t=0,i=x.length;t<i;t++)this.skinIndices.push(x[t].clone());var w=e.lineDistances;for(t=0,i=w.length;t<i;t++)this.lineDistances.push(w[t]);var A=e.boundingBox;null!==A&&(this.boundingBox=A.clone());var S=e.boundingSphere;return null!==S&&(this.boundingSphere=S.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});class wi extends Xt{constructor(e,t,i,r,n,o){super(),this.type="BoxBufferGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:o};const s=this;e=e||1,t=t||1,i=i||1,r=Math.floor(r)||1,n=Math.floor(n)||1,o=Math.floor(o)||1;const a=[],c=[],h=[],u=[];let l=0,p=0;function d(e,t,i,r,n,o,d,f,m,g,v){const _=o/m,y=d/g,b=o/2,x=d/2,w=f/2,A=m+1,S=g+1;let M=0,E=0;const T=new oe;for(let o=0;o<S;o++){const s=o*y-x;for(let a=0;a<A;a++){const l=a*_-b;T[e]=l*r,T[t]=s*n,T[i]=w,c.push(T.x,T.y,T.z),T[e]=0,T[t]=0,T[i]=f>0?1:-1,h.push(T.x,T.y,T.z),u.push(a/m),u.push(1-o/g),M+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const i=l+t+A*e,r=l+t+A*(e+1),n=l+(t+1)+A*(e+1),o=l+(t+1)+A*e;a.push(i,r,o),a.push(r,n,o),E+=6}s.addGroup(p,E,v),p+=E,l+=M}d("z","y","x",-1,-1,i,t,e,o,n,0),d("z","y","x",1,-1,i,t,-e,o,n,1),d("x","z","y",1,1,e,i,t,r,o,2),d("x","z","y",1,-1,e,i,-t,r,o,3),d("x","y","z",1,-1,e,t,i,r,n,4),d("x","y","z",-1,-1,e,t,-i,r,n,5),this.setIndex(a),this.setAttribute("position",new jt(c,3)),this.setAttribute("normal",new jt(h,3)),this.setAttribute("uv",new jt(u,2))}}function Ai(e){var t={};for(var i in e)for(var r in t[i]={},e[i]){var n=e[i][r];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture)?t[i][r]=n.clone():Array.isArray(n)?t[i][r]=n.slice():t[i][r]=n}return t}function Si(e){for(var t={},i=0;i<e.length;i++){var r=Ai(e[i]);for(var n in r)t[n]=r[n]}return t}var Mi={clone:Ai,merge:Si};function Ei(e){Ct.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}function Ti(){Pe.call(this),this.type="Camera",this.matrixWorldInverse=new de,this.projectionMatrix=new de,this.projectionMatrixInverse=new de}function Ci(e,t,i,r){Ti.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Ei.prototype=Object.create(Ct.prototype),Ei.prototype.constructor=Ei,Ei.prototype.isShaderMaterial=!0,Ei.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ai(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=Object.assign({},e.extensions),this},Ei.prototype.toJSON=function(e){var t=Ct.prototype.toJSON.call(this,e);for(var i in t.uniforms={},this.uniforms){var r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var n={};for(var o in this.extensions)!0===this.extensions[o]&&(n[o]=!0);return Object.keys(n).length>0&&(t.extensions=n),t},Ti.prototype=Object.assign(Object.create(Pe.prototype),{constructor:Ti,isCamera:!0,copy:function(e,t){return Pe.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new oe),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){Pe.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,t){Pe.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),Ci.prototype=Object.assign(Object.create(Ti.prototype),{constructor:Ci,isPerspectiveCamera:!0,copy:function(e,t){return Ti.prototype.copy.call(this,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:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*W.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*W.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*W.RAD2DEG*Math.atan(Math.tan(.5*W.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,i,r,n,o){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=i,this.view.offsetY=r,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(.5*W.DEG2RAD*this.fov)/this.zoom,i=2*t,r=this.aspect*i,n=-.5*r,o=this.view;if(null!==this.view&&this.view.enabled){var s=o.fullWidth,a=o.fullHeight;n+=o.offsetX*r/s,t-=o.offsetY*i/a,r*=o.width/s,i*=o.height/a}var c=this.filmOffset;0!==c&&(n+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,t,t-i,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=Pe.prototype.toJSON.call(this,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}});var Ii=90;function Ni(e,t,i){if(Pe.call(this),this.type="CubeCamera",!0===i.isWebGLCubeRenderTarget){this.renderTarget=i;var r=new Ci(Ii,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new oe(1,0,0)),this.add(r);var n=new Ci(Ii,1,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new oe(-1,0,0)),this.add(n);var o=new Ci(Ii,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new oe(0,1,0)),this.add(o);var s=new Ci(Ii,1,e,t);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new oe(0,-1,0)),this.add(s);var a=new Ci(Ii,1,e,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new oe(0,0,1)),this.add(a);var c=new Ci(Ii,1,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new oe(0,0,-1)),this.add(c),this.update=function(e,t){null===this.parent&&this.updateMatrixWorld();var h=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;var l=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,n),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,s),e.setRenderTarget(i,4),e.render(t,a),i.texture.generateMipmaps=l,e.setRenderTarget(i,5),e.render(t,c),e.setRenderTarget(u),e.xr.enabled=h},this.clear=function(e,t,r,n){for(var o=e.getRenderTarget(),s=0;s<6;s++)e.setRenderTarget(i,s),e.clear(t,r,n);e.setRenderTarget(o)}}else console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.")}function Pi(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),ee.call(this,e,e,t)}function Ri(e,t,i,r,n,o,s,a,c,h,u,l){K.call(this,null,o,s,a,c,h,r,n,u,l),this.image={data:e||null,width:t||1,height:i||1},this.magFilter=void 0!==c?c:f,this.minFilter=void 0!==h?h:f,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Ni.prototype=Object.create(Pe.prototype),Ni.prototype.constructor=Ni,Pi.prototype=Object.create(ee.prototype),Pi.prototype.constructor=Pi,Pi.prototype.isWebGLCubeRenderTarget=!0,Pi.prototype.fromEquirectangularTexture=function(e,t){this.texture.type=t.type,this.texture.format=t.format,this.texture.encoding=t.encoding;var i=new Re,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include <begin_vertex>","\t#include <project_vertex>","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#include <common>","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV = equirectUv( direction );","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},n=new Ei({type:"CubemapFromEquirect",uniforms:Ai(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:1,blending:0});n.uniforms.tEquirect.value=t;var o=new fi(new wi(5,5,5),n);return i.add(o),new Ni(1,10,this).update(e,i),o.geometry.dispose(),o.material.dispose(),this},Ri.prototype=Object.create(K.prototype),Ri.prototype.constructor=Ri,Ri.prototype.isDataTexture=!0;var Oi=new Ye,Di=new oe;function Li(e,t,i,r,n,o){this.planes=[void 0!==e?e:new at,void 0!==t?t:new at,void 0!==i?i:new at,void 0!==r?r:new at,void 0!==n?n:new at,void 0!==o?o:new at]}Object.assign(Li.prototype,{set:function(e,t,i,r,n,o){var s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(r),s[4].copy(n),s[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromProjectionMatrix:function(e){var t=this.planes,i=e.elements,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],c=i[5],h=i[6],u=i[7],l=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],v=i[14],_=i[15];return t[0].setComponents(s-r,u-a,f-l,_-m).normalize(),t[1].setComponents(s+r,u+a,f+l,_+m).normalize(),t[2].setComponents(s+n,u+c,f+p,_+g).normalize(),t[3].setComponents(s-n,u-c,f-p,_-g).normalize(),t[4].setComponents(s-o,u-h,f-d,_-v).normalize(),t[5].setComponents(s+o,u+h,f+d,_+v).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Oi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Oi)},intersectsSprite:function(e){return Oi.center.set(0,0,0),Oi.radius=.7071067811865476,Oi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Oi)},intersectsSphere:function(e){for(var t=this.planes,i=e.center,r=-e.radius,n=0;n<6;n++){if(t[n].distanceToPoint(i)<r)return!1}return!0},intersectsBox:function(e){for(var t=this.planes,i=0;i<6;i++){var r=t[i];if(Di.x=r.normal.x>0?e.max.x:e.min.x,Di.y=r.normal.y>0?e.max.y:e.min.y,Di.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Di)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}});var ki={common:{diffuse:{value:new wt(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Y},uv2Transform:{value:new Y},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Q(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new wt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new wt(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Y}},sprite:{diffuse:{value:new wt(15658734)},opacity:{value:1},center:{value:new Q(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Y}}};function Bi(){var e=null,t=!1,i=null;function r(n,o){!1!==t&&(i(n,o),e.requestAnimationFrame(r))}return{start:function(){!0!==t&&null!==i&&(e.requestAnimationFrame(r),t=!0)},stop:function(){t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function Fi(e,t){var i=t.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);var i=r.get(t);i&&(e.deleteBuffer(i.buffer),r.delete(t))},update:function(t,n){t.isInterleavedBufferAttribute&&(t=t.data);var o=r.get(t);void 0===o?r.set(t,function(t,i){var r=t.array,n=t.usage,o=e.createBuffer();e.bindBuffer(i,o),e.bufferData(i,r,n),t.onUploadCallback();var s=5126;return r instanceof Float32Array?s=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?s=5123:r instanceof Int16Array?s=5122:r instanceof Uint32Array?s=5125:r instanceof Int32Array?s=5124:r instanceof Int8Array?s=5120:r instanceof Uint8Array&&(s=5121),{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(t,n)):o.version<t.version&&(!function(t,r,n){var o=r.array,s=r.updateRange;e.bindBuffer(n,t),-1===s.count?e.bufferSubData(n,0,o):(i?e.bufferSubData(n,s.offset*o.BYTES_PER_ELEMENT,o,s.offset,s.count):e.bufferSubData(n,s.offset*o.BYTES_PER_ELEMENT,o.subarray(s.offset,s.offset+s.count)),s.count=-1)}(o.buffer,t,n),o.version=t.version)}}}function ji(e,t,i,r){xi.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r},this.fromBufferGeometry(new zi(e,t,i,r)),this.mergeVertices()}function zi(e,t,i,r){Xt.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};var n,o,s=(e=e||1)/2,a=(t=t||1)/2,c=Math.floor(i)||1,h=Math.floor(r)||1,u=c+1,l=h+1,p=e/c,d=t/h,f=[],m=[],g=[],v=[];for(o=0;o<l;o++){var _=o*d-a;for(n=0;n<u;n++){var y=n*p-s;m.push(y,-_,0),g.push(0,0,1),v.push(n/c),v.push(1-o/h)}}for(o=0;o<h;o++)for(n=0;n<c;n++){var b=n+u*o,x=n+u*(o+1),w=n+1+u*(o+1),A=n+1+u*o;f.push(b,x,A),f.push(x,w,A)}this.setIndex(f),this.setAttribute("position",new jt(m,3)),this.setAttribute("normal",new jt(g,3)),this.setAttribute("uv",new jt(v,2))}ji.prototype=Object.create(xi.prototype),ji.prototype.constructor=ji,zi.prototype=Object.create(Xt.prototype),zi.prototype.constructor=zi;var $i={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\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\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\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#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_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}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * 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}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\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:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\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; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\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 max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\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}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\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}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return 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}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x); } else if (face == 1.0) {\n uv = vec2(-direction.x, -direction.z) / abs(direction.y); } else if (face == 2.0) {\n uv = vec2(-direction.x, direction.y) / abs(direction.z); } else if (face == 3.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x); } else if (face == 4.0) {\n uv = vec2(-direction.x, direction.z) / abs(direction.y); } else {\n uv = vec2(direction.x, direction.y) / abs(direction.z); }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 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, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( 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 LinearTosRGB( 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}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec2 sampleUV = equirectUv( reflectVec );\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\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 int maxMipLevel;\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 )\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 )\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:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV = equirectUv( reflectVec );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\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\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\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 fogDepth;\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 texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\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 GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\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\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\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\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.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\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\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\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.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\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\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\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.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 GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",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;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\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.specularRoughness;\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * 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:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\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\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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\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\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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, geometry, 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\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\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 ], geometry );\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, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\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\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\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, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).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 * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",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.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( 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( 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 linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - 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_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, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#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#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ 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#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 shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\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 shadow;\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 shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#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#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ 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#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\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.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.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ 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.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\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\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, vUv );\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;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( 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 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",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}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\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#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#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\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#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\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#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\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#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\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#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\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#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\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},Vi={basic:{uniforms:Si([ki.common,ki.specularmap,ki.envmap,ki.aomap,ki.lightmap,ki.fog]),vertexShader:$i.meshbasic_vert,fragmentShader:$i.meshbasic_frag},lambert:{uniforms:Si([ki.common,ki.specularmap,ki.envmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.fog,ki.lights,{emissive:{value:new wt(0)}}]),vertexShader:$i.meshlambert_vert,fragmentShader:$i.meshlambert_frag},phong:{uniforms:Si([ki.common,ki.specularmap,ki.envmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.fog,ki.lights,{emissive:{value:new wt(0)},specular:{value:new wt(1118481)},shininess:{value:30}}]),vertexShader:$i.meshphong_vert,fragmentShader:$i.meshphong_frag},standard:{uniforms:Si([ki.common,ki.envmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.roughnessmap,ki.metalnessmap,ki.fog,ki.lights,{emissive:{value:new wt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$i.meshphysical_vert,fragmentShader:$i.meshphysical_frag},toon:{uniforms:Si([ki.common,ki.specularmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.gradientmap,ki.fog,ki.lights,{emissive:{value:new wt(0)},specular:{value:new wt(1118481)},shininess:{value:30}}]),vertexShader:$i.meshtoon_vert,fragmentShader:$i.meshtoon_frag},matcap:{uniforms:Si([ki.common,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.fog,{matcap:{value:null}}]),vertexShader:$i.meshmatcap_vert,fragmentShader:$i.meshmatcap_frag},points:{uniforms:Si([ki.points,ki.fog]),vertexShader:$i.points_vert,fragmentShader:$i.points_frag},dashed:{uniforms:Si([ki.common,ki.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$i.linedashed_vert,fragmentShader:$i.linedashed_frag},depth:{uniforms:Si([ki.common,ki.displacementmap]),vertexShader:$i.depth_vert,fragmentShader:$i.depth_frag},normal:{uniforms:Si([ki.common,ki.bumpmap,ki.normalmap,ki.displacementmap,{opacity:{value:1}}]),vertexShader:$i.normal_vert,fragmentShader:$i.normal_frag},sprite:{uniforms:Si([ki.sprite,ki.fog]),vertexShader:$i.sprite_vert,fragmentShader:$i.sprite_frag},background:{uniforms:{uvTransform:{value:new Y},t2D:{value:null}},vertexShader:$i.background_vert,fragmentShader:$i.background_frag},cube:{uniforms:Si([ki.envmap,{opacity:{value:1}}]),vertexShader:$i.cube_vert,fragmentShader:$i.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$i.equirect_vert,fragmentShader:$i.equirect_frag},distanceRGBA:{uniforms:Si([ki.common,ki.displacementmap,{referencePosition:{value:new oe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$i.distanceRGBA_vert,fragmentShader:$i.distanceRGBA_frag},shadow:{uniforms:Si([ki.lights,ki.fog,{color:{value:new wt(0)},opacity:{value:1}}]),vertexShader:$i.shadow_vert,fragmentShader:$i.shadow_frag}};function Ui(e,t,i,r){var n,o,s=new wt(0),a=0,c=null,h=0,l=null;function p(e,i){t.buffers.color.setClear(e.r,e.g,e.b,i,r)}return{getClearColor:function(){return s},setClearColor:function(e,t){s.set(e),p(s,a=void 0!==t?t:1)},getClearAlpha:function(){return a},setClearAlpha:function(e){p(s,a=e)},render:function(t,r,d,f){var m=r.background,g=e.xr,v=g.getSession&&g.getSession();if(v&&"additive"===v.environmentBlendMode&&(m=null),null===m?p(s,a):m&&m.isColor&&(p(m,1),f=!0),(e.autoClear||f)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.isWebGLCubeRenderTarget||m.mapping===u)){void 0===o&&((o=new fi(new wi(1,1,1),new Ei({type:"BackgroundCubeMaterial",uniforms:Ai(Vi.cube.uniforms),vertexShader:Vi.cube.vertexShader,fragmentShader:Vi.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),o.geometry.deleteAttribute("uv"),o.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(o.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(o));var _=m.isWebGLCubeRenderTarget?m.texture:m;o.material.uniforms.envMap.value=_,o.material.uniforms.flipEnvMap.value=_.isCubeTexture?-1:1,c===m&&h===_.version&&l===e.toneMapping||(o.material.needsUpdate=!0,c=m,h=_.version,l=e.toneMapping),t.unshift(o,o.geometry,o.material,0,0,null)}else m&&m.isTexture&&(void 0===n&&((n=new fi(new zi(2,2),new Ei({type:"BackgroundMaterial",uniforms:Ai(Vi.background.uniforms),vertexShader:Vi.background.vertexShader,fragmentShader:Vi.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(n.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(n)),n.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),n.material.uniforms.uvTransform.value.copy(m.matrix),c===m&&h===m.version&&l===e.toneMapping||(n.material.needsUpdate=!0,c=m,h=m.version,l=e.toneMapping),t.unshift(n,n.geometry,n.material,0,0,null))}}}function Gi(e,t,i,r){var n,o=r.isWebGL2;this.setMode=function(e){n=e},this.render=function(t,r){e.drawArrays(n,t,r),i.update(r,n)},this.renderInstances=function(r,s,a,c){if(0!==c){var h,u;if(o)h=e,u="drawArraysInstanced";else if(u="drawArraysInstancedANGLE",null===(h=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[u](n,s,a,c),i.update(a,n,c)}}}function Hi(e,t,i){var r;function n(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext,s=void 0!==i.precision?i.precision:"highp",a=n(s);a!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",a,"instead."),s=a);var c=!0===i.logarithmicDepthBuffer,h=e.getParameter(34930),u=e.getParameter(35660),l=e.getParameter(3379),p=e.getParameter(34076),d=e.getParameter(34921),f=e.getParameter(36347),m=e.getParameter(36348),g=e.getParameter(36349),v=u>0,_=o||!!t.get("OES_texture_float");return{isWebGL2:o,getMaxAnisotropy:function(){if(void 0!==r)return r;var i=t.get("EXT_texture_filter_anisotropic");return r=null!==i?e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:s,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:l,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:_,floatVertexTextures:v&&_,maxSamples:o?e.getParameter(36183):0}}function qi(){var e=this,t=null,i=0,r=!1,n=!1,o=new at,s=new Y,a={value:null,needsUpdate:!1};function c(){a.value!==t&&(a.value=t,a.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(t,i,r,n){var c=null!==t?t.length:0,h=null;if(0!==c){if(h=a.value,!0!==n||null===h){var u=r+4*c,l=i.matrixWorldInverse;s.getNormalMatrix(l),(null===h||h.length<u)&&(h=new Float32Array(u));for(var p=0,d=r;p!==c;++p,d+=4)o.copy(t[p]).applyMatrix4(l,s),o.normal.toArray(h,d),h[d+3]=o.constant}a.value=h,a.needsUpdate=!0}return e.numPlanes=c,e.numIntersection=0,h}this.uniform=a,this.numPlanes=0,this.numIntersection=0,this.init=function(e,n,o){var s=0!==e.length||n||0!==i||r;return r=n,t=h(e,o,0),i=e.length,s},this.beginShadows=function(){n=!0,h(null)},this.endShadows=function(){n=!1,c()},this.setState=function(e,o,s,u,l,p){if(!r||null===e||0===e.length||n&&!s)n?h(null):c();else{var d=n?0:i,f=4*d,m=l.clippingState||null;a.value=m,m=h(e,u,f,p);for(var g=0;g!==f;++g)m[g]=t[g];l.clippingState=m,this.numIntersection=o?this.numPlanes:0,this.numPlanes+=d}}}function Wi(e){var t={};return{get:function(i){if(void 0!==t[i])return t[i];var r;switch(i){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(i)}return null===r&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),t[i]=r,r}}}function Qi(e,t,i){var r=new WeakMap,n=new WeakMap;function o(e){var s=e.target,a=r.get(s);for(var c in null!==a.index&&t.remove(a.index),a.attributes)t.remove(a.attributes[c]);s.removeEventListener("dispose",o),r.delete(s);var h=n.get(a);h&&(t.remove(h),n.delete(a)),i.memory.geometries--}function s(e){var i=[],r=e.index,o=e.attributes.position,s=0;if(null!==r){var a=r.array;s=r.version;for(var c=0,h=a.length;c<h;c+=3){var u=a[c+0],l=a[c+1],p=a[c+2];i.push(u,l,l,p,p,u)}}else{a=o.array;s=o.version;for(c=0,h=a.length/3-1;c<h;c+=3){u=c+0,l=c+1,p=c+2;i.push(u,l,l,p,p,u)}}var d=new(Vt(i)>65535?Ft:kt)(i,1);d.version=s,t.update(d,34963);var f=n.get(e);f&&t.remove(f),n.set(e,d)}return{get:function(e,t){var n=r.get(t);return n||(t.addEventListener("dispose",o),t.isBufferGeometry?n=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new Xt).setFromObject(e)),n=t._bufferGeometry),r.set(t,n),i.memory.geometries++,n)},update:function(e){var i=e.index,r=e.attributes;for(var n in null!==i&&t.update(i,34963),r)t.update(r[n],34962);var o=e.morphAttributes;for(var n in o)for(var s=o[n],a=0,c=s.length;a<c;a++)t.update(s[a],34962)},getWireframeAttribute:function(e){var t=n.get(e);if(t){var i=e.index;null!==i&&t.version<i.version&&s(e)}else s(e);return n.get(e)}}}function Yi(e,t,i,r){var n,o,s,a=r.isWebGL2;this.setMode=function(e){n=e},this.setIndex=function(e){o=e.type,s=e.bytesPerElement},this.render=function(t,r){e.drawElements(n,r,o,t*s),i.update(r,n)},this.renderInstances=function(r,c,h,u){if(0!==u){var l,p;if(a)l=e,p="drawElementsInstanced";else if(p="drawElementsInstancedANGLE",null===(l=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[p](n,h,o,c*s,u),i.update(h,n,u)}}}function Xi(e){var t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(e,i,r){switch(r=r||1,t.calls++,i){case 4:t.triangles+=r*(e/3);break;case 1:t.lines+=r*(e/2);break;case 3:t.lines+=r*(e-1);break;case 2:t.lines+=r*e;break;case 0:t.points+=r*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Zi(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Ki(e){var t={},i=new Float32Array(8);return{update:function(r,n,o,s){var a=r.morphTargetInfluences,c=void 0===a?0:a.length,h=t[n.id];if(void 0===h){h=[];for(var u=0;u<c;u++)h[u]=[u,0];t[n.id]=h}var l=o.morphTargets&&n.morphAttributes.position,p=o.morphNormals&&n.morphAttributes.normal;for(u=0;u<c;u++){0!==(f=h[u])[1]&&(l&&n.deleteAttribute("morphTarget"+u),p&&n.deleteAttribute("morphNormal"+u))}for(u=0;u<c;u++){(f=h[u])[0]=u,f[1]=a[u]}h.sort(Zi);var d=0;for(u=0;u<8;u++){var f;if(f=h[u]){var m=f[0],g=f[1];if(g){l&&n.setAttribute("morphTarget"+u,l[m]),p&&n.setAttribute("morphNormal"+u,p[m]),i[u]=g,d+=g;continue}}i[u]=0}var v=n.morphTargetsRelative?1:1-d;s.getUniforms().setValue(e,"morphTargetBaseInfluence",v),s.getUniforms().setValue(e,"morphTargetInfluences",i)}}}function Ji(e,t,i,r){var n=new WeakMap;return{update:function(e){var o=r.render.frame,s=e.geometry,a=t.get(e,s);return n.get(a)!==o&&(s.isGeometry&&a.updateFromObject(e),t.update(a),n.set(a,o)),e.isInstancedMesh&&i.update(e.instanceMatrix,34962),a},dispose:function(){n=new WeakMap}}}function er(e,t,i,r,n,o,s,a,c,h){e=void 0!==e?e:[],t=void 0!==t?t:301,s=void 0!==s?s:M,K.call(this,e,t,i,r,n,o,s,a,c,h),this.flipY=!1}function tr(e,t,i,r){K.call(this,null),this.image={data:e||null,width:t||1,height:i||1,depth:r||1},this.magFilter=f,this.minFilter=f,this.wrapR=p,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function ir(e,t,i,r){K.call(this,null),this.image={data:e||null,width:t||1,height:i||1,depth:r||1},this.magFilter=f,this.minFilter=f,this.wrapR=p,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Vi.physical={uniforms:Si([Vi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Q(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new wt(0)},transparency:{value:0}}]),vertexShader:$i.meshphysical_vert,fragmentShader:$i.meshphysical_frag},er.prototype=Object.create(K.prototype),er.prototype.constructor=er,er.prototype.isCubeTexture=!0,Object.defineProperty(er.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),tr.prototype=Object.create(K.prototype),tr.prototype.constructor=tr,tr.prototype.isDataTexture2DArray=!0,ir.prototype=Object.create(K.prototype),ir.prototype.constructor=ir,ir.prototype.isDataTexture3D=!0;var rr=new K,nr=new tr,or=new ir,sr=new er,ar=[],cr=[],hr=new Float32Array(16),ur=new Float32Array(9),lr=new Float32Array(4);function pr(e,t,i){var r=e[0];if(r<=0||r>0)return e;var n=t*i,o=ar[n];if(void 0===o&&(o=new Float32Array(n),ar[n]=o),0!==t){r.toArray(o,0);for(var s=1,a=0;s!==t;++s)a+=i,e[s].toArray(o,a)}return o}function dr(e,t){if(e.length!==t.length)return!1;for(var i=0,r=e.length;i<r;i++)if(e[i]!==t[i])return!1;return!0}function fr(e,t){for(var i=0,r=t.length;i<r;i++)e[i]=t[i]}function mr(e,t){var i=cr[t];void 0===i&&(i=new Int32Array(t),cr[t]=i);for(var r=0;r!==t;++r)i[r]=e.allocateTextureUnit();return i}function gr(e,t){var i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function vr(e,t){var i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(dr(i,t))return;e.uniform2fv(this.addr,t),fr(i,t)}}function _r(e,t){var i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(void 0!==t.r)i[0]===t.r&&i[1]===t.g&&i[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(dr(i,t))return;e.uniform3fv(this.addr,t),fr(i,t)}}function yr(e,t){var i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(dr(i,t))return;e.uniform4fv(this.addr,t),fr(i,t)}}function br(e,t){var i=this.cache,r=t.elements;if(void 0===r){if(dr(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),fr(i,t)}else{if(dr(i,r))return;lr.set(r),e.uniformMatrix2fv(this.addr,!1,lr),fr(i,r)}}function xr(e,t){var i=this.cache,r=t.elements;if(void 0===r){if(dr(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),fr(i,t)}else{if(dr(i,r))return;ur.set(r),e.uniformMatrix3fv(this.addr,!1,ur),fr(i,r)}}function wr(e,t){var i=this.cache,r=t.elements;if(void 0===r){if(dr(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),fr(i,t)}else{if(dr(i,r))return;hr.set(r),e.uniformMatrix4fv(this.addr,!1,hr),fr(i,r)}}function Ar(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.safeSetTexture2D(t||rr,n)}function Sr(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.setTexture2DArray(t||nr,n)}function Mr(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.setTexture3D(t||or,n)}function Er(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.safeSetTextureCube(t||sr,n)}function Tr(e,t){var i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function Cr(e,t){var i=this.cache;dr(i,t)||(e.uniform2iv(this.addr,t),fr(i,t))}function Ir(e,t){var i=this.cache;dr(i,t)||(e.uniform3iv(this.addr,t),fr(i,t))}function Nr(e,t){var i=this.cache;dr(i,t)||(e.uniform4iv(this.addr,t),fr(i,t))}function Pr(e,t){var i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function Rr(e,t){e.uniform1fv(this.addr,t)}function Or(e,t){e.uniform1iv(this.addr,t)}function Dr(e,t){e.uniform2iv(this.addr,t)}function Lr(e,t){e.uniform3iv(this.addr,t)}function kr(e,t){e.uniform4iv(this.addr,t)}function Br(e,t){var i=pr(t,this.size,2);e.uniform2fv(this.addr,i)}function Fr(e,t){var i=pr(t,this.size,3);e.uniform3fv(this.addr,i)}function jr(e,t){var i=pr(t,this.size,4);e.uniform4fv(this.addr,i)}function zr(e,t){var i=pr(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function $r(e,t){var i=pr(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function Vr(e,t){var i=pr(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function Ur(e,t,i){var r=t.length,n=mr(i,r);e.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.safeSetTexture2D(t[o]||rr,n[o])}function Gr(e,t,i){var r=t.length,n=mr(i,r);e.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.safeSetTextureCube(t[o]||sr,n[o])}function Hr(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=function(e){switch(e){case 5126:return gr;case 35664:return vr;case 35665:return _r;case 35666:return yr;case 35674:return br;case 35675:return xr;case 35676:return wr;case 5124:case 35670:return Tr;case 35667:case 35671:return Cr;case 35668:case 35672:return Ir;case 35669:case 35673:return Nr;case 5125:return Pr;case 35678:case 36198:case 36298:case 36306:case 35682:return Ar;case 35679:case 36299:case 36307:return Mr;case 35680:case 36300:case 36308:case 36293:return Er;case 36289:case 36303:case 36311:case 36292:return Sr}}(t.type)}function qr(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Rr;case 35664:return Br;case 35665:return Fr;case 35666:return jr;case 35674:return zr;case 35675:return $r;case 35676:return Vr;case 5124:case 35670:return Or;case 35667:case 35671:return Dr;case 35668:case 35672:return Lr;case 35669:case 35673:return kr;case 35678:case 36198:case 36298:case 36306:case 35682:return Ur;case 35680:case 36300:case 36308:case 36293:return Gr}}(t.type)}function Wr(e){this.id=e,this.seq=[],this.map={}}qr.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),fr(t,e)},Wr.prototype.setValue=function(e,t,i){for(var r=this.seq,n=0,o=r.length;n!==o;++n){var s=r[n];s.setValue(e,t[s.id],i)}};var Qr=/([\w\d_]+)(\])?(\[|\.)?/g;function Yr(e,t){e.seq.push(t),e.map[t.id]=t}function Xr(e,t,i){var r=e.name,n=r.length;for(Qr.lastIndex=0;;){var o=Qr.exec(r),s=Qr.lastIndex,a=o[1],c="]"===o[2],h=o[3];if(c&&(a|=0),void 0===h||"["===h&&s+2===n){Yr(i,void 0===h?new Hr(a,e,t):new qr(a,e,t));break}var u=i.map[a];void 0===u&&Yr(i,u=new Wr(a)),i=u}}function Zr(e,t){this.seq=[],this.map={};for(var i=e.getProgramParameter(t,35718),r=0;r<i;++r){var n=e.getActiveUniform(t,r);Xr(n,e.getUniformLocation(t,n.name),this)}}function Kr(e,t,i){var r=e.createShader(t);return e.shaderSource(r,i),e.compileShader(r),r}Zr.prototype.setValue=function(e,t,i,r){var n=this.map[t];void 0!==n&&n.setValue(e,i,r)},Zr.prototype.setOptional=function(e,t,i){var r=t[i];void 0!==r&&this.setValue(e,i,r)},Zr.upload=function(e,t,i,r){for(var n=0,o=t.length;n!==o;++n){var s=t[n],a=i[s.id];!1!==a.needsUpdate&&s.setValue(e,a.value,r)}},Zr.seqWithValue=function(e,t){for(var i=[],r=0,n=e.length;r!==n;++r){var o=e[r];o.id in t&&i.push(o)}return i};var Jr=0;function en(e){switch(e){case k:return["Linear","( value )"];case B:return["sRGB","( value )"];case j:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case F:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:throw new Error("unsupported encoding: "+e)}}function tn(e,t,i){var r=e.getShaderParameter(t,35713),n=e.getShaderInfoLog(t).trim();return r&&""===n?"":"THREE.WebGLShader: gl.getShaderInfoLog() "+i+"\n"+n+function(e){for(var t=e.split("\n"),i=0;i<t.length;i++)t[i]=i+1+": "+t[i];return t.join("\n")}(e.getShaderSource(t))}function rn(e,t){var i=en(t);return"vec4 "+e+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function nn(e,t){var i;switch(t){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="Uncharted2";break;case 4:i="OptimizedCineon";break;case 5:i="ACESFilmic";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function on(e){return""!==e}function sn(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).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/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function an(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var cn=/^[ \t]*#include +<([\w\d./]+)>/gm;function hn(e){return e.replace(cn,un)}function un(e,t){var i=$i[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return hn(i)}var ln=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,pn=/#pragma unroll_loop_start[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g;function dn(e){return e.replace(pn,mn).replace(ln,fn)}function fn(e,t,i,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),mn(e,t,i,r)}function mn(e,t,i,r){for(var n="",o=parseInt(t);o<parseInt(i);o++)n+=r.replace(/\[ i \]/g,"[ "+o+" ]").replace(/UNROLLED_LOOP_INDEX/g,o);return n}function gn(e){var t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function vn(e,t,i){var r,n,o,s,a,c=e.getContext(),h=i.defines,l=i.vertexShader,p=i.fragmentShader,d=function(e){var t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(i),f=function(e){var t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case 301:case 302:t="ENVMAP_TYPE_CUBE";break;case u:case 307:t="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:t="ENVMAP_TYPE_EQUIREC";break;case 305:t="ENVMAP_TYPE_SPHERE"}return t}(i),m=function(e){var t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case 302:case 304:t="ENVMAP_MODE_REFRACTION"}return t}(i),g=function(e){var t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(i),v=e.gammaFactor>0?e.gammaFactor:1,_=i.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(on).join("\n")}(i),y=function(e){var t=[];for(var i in e){var r=e[i];!1!==r&&t.push("#define "+i+" "+r)}return t.join("\n")}(h),b=c.createProgram();if(i.isRawShaderMaterial?((r=[y].filter(on).join("\n")).length>0&&(r+="\n"),(n=[_,y].filter(on).join("\n")).length>0&&(n+="\n")):(r=[gn(i),"#define SHADER_NAME "+i.shaderName,y,i.instancing?"#define USE_INSTANCING":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+v,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+m:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+d:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(on).join("\n"),n=[_,gn(i),"#define SHADER_NAME "+i.shaderName,y,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+v,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+f:"",i.envMap?"#define "+m:"",i.envMap?"#define "+g:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+d:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?$i.tonemapping_pars_fragment:"",0!==i.toneMapping?nn("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.outputEncoding||i.mapEncoding||i.matcapEncoding||i.envMapEncoding||i.emissiveMapEncoding||i.lightMapEncoding?$i.encodings_pars_fragment:"",i.mapEncoding?rn("mapTexelToLinear",i.mapEncoding):"",i.matcapEncoding?rn("matcapTexelToLinear",i.matcapEncoding):"",i.envMapEncoding?rn("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?rn("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMapEncoding?rn("lightMapTexelToLinear",i.lightMapEncoding):"",i.outputEncoding?(o="linearToOutputTexel",s=i.outputEncoding,a=en(s),"vec4 "+o+"( vec4 value ) { return LinearTo"+a[0]+a[1]+"; }"):"",i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(on).join("\n")),l=an(l=sn(l=hn(l),i),i),p=an(p=sn(p=hn(p),i),i),l=dn(l),p=dn(p),i.isWebGL2&&!i.isRawShaderMaterial){var x=!1,w=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==l.match(w)&&null!==p.match(w)&&(x=!0,l=l.replace(w,""),p=p.replace(w,"")),r=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+r,n=["#version 300 es\n","#define varying in",x?"":"out highp vec4 pc_fragColor;",x?"":"#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"+n}var A,S,M=n+p,E=Kr(c,35633,r+l),T=Kr(c,35632,M);if(c.attachShader(b,E),c.attachShader(b,T),void 0!==i.index0AttributeName?c.bindAttribLocation(b,0,i.index0AttributeName):!0===i.morphTargets&&c.bindAttribLocation(b,0,"position"),c.linkProgram(b),e.debug.checkShaderErrors){var C=c.getProgramInfoLog(b).trim(),I=c.getShaderInfoLog(E).trim(),N=c.getShaderInfoLog(T).trim(),P=!0,R=!0;if(!1===c.getProgramParameter(b,35714)){P=!1;var O=tn(c,E,"vertex"),D=tn(c,T,"fragment");console.error("THREE.WebGLProgram: shader error: ",c.getError(),"35715",c.getProgramParameter(b,35715),"gl.getProgramInfoLog",C,O,D)}else""!==C?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",C):""!==I&&""!==N||(R=!1);R&&(this.diagnostics={runnable:P,programLog:C,vertexShader:{log:I,prefix:r},fragmentShader:{log:N,prefix:n}})}return c.deleteShader(E),c.deleteShader(T),this.getUniforms=function(){return void 0===A&&(A=new Zr(c,b)),A},this.getAttributes=function(){return void 0===S&&(S=function(e,t){for(var i={},r=e.getProgramParameter(t,35721),n=0;n<r;n++){var o=e.getActiveAttrib(t,n).name;i[o]=e.getAttribLocation(t,o)}return i}(c,b)),S},this.destroy=function(){c.deleteProgram(b),this.program=void 0},this.name=i.shaderName,this.id=Jr++,this.cacheKey=t,this.usedTimes=1,this.program=b,this.vertexShader=E,this.fragmentShader=T,this}function _n(e,t,i){var r=[],n=i.isWebGL2,o=i.logarithmicDepthBuffer,s=i.floatVertexTextures,a=i.precision,c=i.maxVertexUniforms,h=i.vertexTextures,l={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},p=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen"];function d(e){var t;return e?e.isTexture?t=e.encoding:e.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),t=e.texture.encoding):t=k,t}this.getParameters=function(r,p,f,m,g,v,_){var y=m.fog,b=r.isMeshStandardMaterial?m.environment:null,x=r.envMap||b,w=l[r.type],A=_.isSkinnedMesh?function(e){var t=e.skeleton.bones;if(s)return 1024;var i=c,r=Math.floor((i-20)/4),n=Math.min(r,t.length);return n<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+n+"."),0):n}(_):0;null!==r.precision&&(a=i.getMaxPrecision(r.precision))!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",a,"instead.");var S=function(e,t){var i;if(t){var r=Vi[t];i={name:e.type,uniforms:Mi.clone(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader}}else i={name:e.type,uniforms:e.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader};return i}(r,w);r.onBeforeCompile(S,e);var M=e.getRenderTarget();return{isWebGL2:n,shaderID:w,shaderName:S.name,uniforms:S.uniforms,vertexShader:S.vertexShader,fragmentShader:S.fragmentShader,defines:r.defines,isRawShaderMaterial:r.isRawShaderMaterial,isShaderMaterial:r.isShaderMaterial,precision:a,instancing:!0===_.isInstancedMesh,supportsVertexTextures:h,outputEncoding:null!==M?d(M.texture):e.outputEncoding,map:!!r.map,mapEncoding:d(r.map),matcap:!!r.matcap,matcapEncoding:d(r.matcap),envMap:!!x,envMapMode:x&&x.mapping,envMapEncoding:d(x),envMapCubeUV:!!x&&(x.mapping===u||307===x.mapping),lightMap:!!r.lightMap,lightMapEncoding:d(r.lightMap),aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,emissiveMapEncoding:d(r.emissiveMap),bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:1===r.normalMapType,tangentSpaceNormalMap:0===r.normalMapType,clearcoatMap:!!r.clearcoatMap,clearcoatRoughnessMap:!!r.clearcoatRoughnessMap,clearcoatNormalMap:!!r.clearcoatNormalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,alphaMap:!!r.alphaMap,gradientMap:!!r.gradientMap,sheen:!!r.sheen,combine:r.combine,vertexTangents:r.normalMap&&r.vertexTangents,vertexColors:r.vertexColors,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.displacementMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||!r.displacementMap),fog:!!y,useFog:r.fog,fogExp2:y&&y.isFogExp2,flatShading:r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:o,skinning:r.skinning&&A>0,maxBones:A,useVertexTexture:s,morphTargets:r.morphTargets,morphNormals:r.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:p.directional.length,numPointLights:p.point.length,numSpotLights:p.spot.length,numRectAreaLights:p.rectArea.length,numHemiLights:p.hemi.length,numDirLightShadows:p.directionalShadowMap.length,numPointLightShadows:p.pointShadowMap.length,numSpotLightShadows:p.spotShadowMap.length,numClippingPlanes:g,numClipIntersection:v,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&f.length>0,shadowMapType:e.shadowMap.type,toneMapping:r.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:2===r.side,flipSided:1===r.side,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:n||null!==t.get("EXT_frag_depth"),rendererExtensionDrawBuffers:n||null!==t.get("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:n||null!==t.get("EXT_shader_texture_lod"),onBeforeCompile:r.onBeforeCompile}},this.getProgramCacheKey=function(t){var i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var r in t.defines)i.push(r),i.push(t.defines[r]);if(void 0===t.isRawShaderMaterial){for(var n=0;n<p.length;n++)i.push(t[p[n]]);i.push(e.outputEncoding),i.push(e.gammaFactor)}return i.push(t.onBeforeCompile.toString()),i.join()},this.acquireProgram=function(t,i){for(var n,o=0,s=r.length;o<s;o++){var a=r[o];if(a.cacheKey===i){++(n=a).usedTimes;break}}return void 0===n&&(n=new vn(e,i,t),r.push(n)),n},this.releaseProgram=function(e){if(0==--e.usedTimes){var t=r.indexOf(e);r[t]=r[r.length-1],r.pop(),e.destroy()}},this.programs=r}function yn(){var e=new WeakMap;return{get:function(t){var i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,r){e.get(t)[i]=r},dispose:function(){e=new WeakMap}}}function bn(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id: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 xn(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 wn(){var e=[],t=0,i=[],r=[],n={id:-1};function o(i,r,o,s,a,c){var h=e[t];return void 0===h?(h={id:i.id,object:i,geometry:r,material:o,program:o.program||n,groupOrder:s,renderOrder:i.renderOrder,z:a,group:c},e[t]=h):(h.id=i.id,h.object=i,h.geometry=r,h.material=o,h.program=o.program||n,h.groupOrder=s,h.renderOrder=i.renderOrder,h.z=a,h.group=c),t++,h}return{opaque:i,transparent:r,init:function(){t=0,i.length=0,r.length=0},push:function(e,t,n,s,a,c){var h=o(e,t,n,s,a,c);(!0===n.transparent?r:i).push(h)},unshift:function(e,t,n,s,a,c){var h=o(e,t,n,s,a,c);(!0===n.transparent?r:i).unshift(h)},finish:function(){for(var i=t,r=e.length;i<r;i++){var n=e[i];if(null===n.id)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.program=null,n.group=null}},sort:function(e,t){i.length>1&&i.sort(e||bn),r.length>1&&r.sort(t||xn)}}}function An(){var e=new WeakMap;function t(i){var r=i.target;r.removeEventListener("dispose",t),e.delete(r)}return{get:function(i,r){var n,o=e.get(i);return void 0===o?(n=new wn,e.set(i,new WeakMap),e.get(i).set(r,n),i.addEventListener("dispose",t)):void 0===(n=o.get(r))&&(n=new wn,o.set(r,n)),n},dispose:function(){e=new WeakMap}}}function Sn(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new oe,color:new wt};break;case"SpotLight":i={position:new oe,direction:new oe,color:new wt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new oe,color:new wt,distance:0,decay:0};break;case"HemisphereLight":i={direction:new oe,skyColor:new wt,groundColor:new wt};break;case"RectAreaLight":i={color:new wt,position:new oe,halfWidth:new oe,halfHeight:new oe}}return e[t.id]=i,i}}}var Mn=0;function En(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Tn(){for(var e,t=new Sn,i=(e={},{get:function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowRadius:1,shadowMapSize:new Q};break;case"PointLight":i={shadowBias:0,shadowRadius:1,shadowMapSize:new Q,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=0;n<9;n++)r.probe.push(new oe);var o=new oe,s=new de,a=new de;return{setup:function(e,n,c){for(var h=0,u=0,l=0,p=0;p<9;p++)r.probe[p].set(0,0,0);var d=0,f=0,m=0,g=0,v=0,_=0,y=0,b=0,x=c.matrixWorldInverse;e.sort(En),p=0;for(var w=e.length;p<w;p++){var A=e[p],S=A.color,M=A.intensity,E=A.distance,T=A.shadow&&A.shadow.map?A.shadow.map.texture:null;if(A.isAmbientLight)h+=S.r*M,u+=S.g*M,l+=S.b*M;else if(A.isLightProbe)for(var C=0;C<9;C++)r.probe[C].addScaledVector(A.sh.coefficients[C],M);else if(A.isDirectionalLight){if((P=t.get(A)).color.copy(A.color).multiplyScalar(A.intensity),P.direction.setFromMatrixPosition(A.matrixWorld),o.setFromMatrixPosition(A.target.matrixWorld),P.direction.sub(o),P.direction.transformDirection(x),A.castShadow){var I=A.shadow;(N=i.get(A)).shadowBias=I.bias,N.shadowRadius=I.radius,N.shadowMapSize=I.mapSize,r.directionalShadow[d]=N,r.directionalShadowMap[d]=T,r.directionalShadowMatrix[d]=A.shadow.matrix,_++}r.directional[d]=P,d++}else if(A.isSpotLight){if((P=t.get(A)).position.setFromMatrixPosition(A.matrixWorld),P.position.applyMatrix4(x),P.color.copy(S).multiplyScalar(M),P.distance=E,P.direction.setFromMatrixPosition(A.matrixWorld),o.setFromMatrixPosition(A.target.matrixWorld),P.direction.sub(o),P.direction.transformDirection(x),P.coneCos=Math.cos(A.angle),P.penumbraCos=Math.cos(A.angle*(1-A.penumbra)),P.decay=A.decay,A.castShadow){I=A.shadow;(N=i.get(A)).shadowBias=I.bias,N.shadowRadius=I.radius,N.shadowMapSize=I.mapSize,r.spotShadow[m]=N,r.spotShadowMap[m]=T,r.spotShadowMatrix[m]=A.shadow.matrix,b++}r.spot[m]=P,m++}else if(A.isRectAreaLight){(P=t.get(A)).color.copy(S).multiplyScalar(M),P.position.setFromMatrixPosition(A.matrixWorld),P.position.applyMatrix4(x),a.identity(),s.copy(A.matrixWorld),s.premultiply(x),a.extractRotation(s),P.halfWidth.set(.5*A.width,0,0),P.halfHeight.set(0,.5*A.height,0),P.halfWidth.applyMatrix4(a),P.halfHeight.applyMatrix4(a),r.rectArea[g]=P,g++}else if(A.isPointLight){if((P=t.get(A)).position.setFromMatrixPosition(A.matrixWorld),P.position.applyMatrix4(x),P.color.copy(A.color).multiplyScalar(A.intensity),P.distance=A.distance,P.decay=A.decay,A.castShadow){var N;I=A.shadow;(N=i.get(A)).shadowBias=I.bias,N.shadowRadius=I.radius,N.shadowMapSize=I.mapSize,N.shadowCameraNear=I.camera.near,N.shadowCameraFar=I.camera.far,r.pointShadow[f]=N,r.pointShadowMap[f]=T,r.pointShadowMatrix[f]=A.shadow.matrix,y++}r.point[f]=P,f++}else if(A.isHemisphereLight){var P;(P=t.get(A)).direction.setFromMatrixPosition(A.matrixWorld),P.direction.transformDirection(x),P.direction.normalize(),P.skyColor.copy(A.color).multiplyScalar(M),P.groundColor.copy(A.groundColor).multiplyScalar(M),r.hemi[v]=P,v++}}r.ambient[0]=h,r.ambient[1]=u,r.ambient[2]=l;var R=r.hash;R.directionalLength===d&&R.pointLength===f&&R.spotLength===m&&R.rectAreaLength===g&&R.hemiLength===v&&R.numDirectionalShadows===_&&R.numPointShadows===y&&R.numSpotShadows===b||(r.directional.length=d,r.spot.length=m,r.rectArea.length=g,r.point.length=f,r.hemi.length=v,r.directionalShadow.length=_,r.directionalShadowMap.length=_,r.pointShadow.length=y,r.pointShadowMap.length=y,r.spotShadow.length=b,r.spotShadowMap.length=b,r.directionalShadowMatrix.length=_,r.pointShadowMatrix.length=y,r.spotShadowMatrix.length=b,R.directionalLength=d,R.pointLength=f,R.spotLength=m,R.rectAreaLength=g,R.hemiLength=v,R.numDirectionalShadows=_,R.numPointShadows=y,R.numSpotShadows=b,r.version=Mn++)},state:r}}function Cn(){var e=new Tn,t=[],i=[];return{init:function(){t.length=0,i.length=0},state:{lightsArray:t,shadowsArray:i,lights:e},setupLights:function(r){e.setup(t,i,r)},pushLight:function(e){t.push(e)},pushShadow:function(e){i.push(e)}}}function In(){var e=new WeakMap;function t(i){var r=i.target;r.removeEventListener("dispose",t),e.delete(r)}return{get:function(i,r){var n;return!1===e.has(i)?(n=new Cn,e.set(i,new WeakMap),e.get(i).set(r,n),i.addEventListener("dispose",t)):!1===e.get(i).has(r)?(n=new Cn,e.get(i).set(r,n)):n=e.get(i).get(r),n},dispose:function(){e=new WeakMap}}}function Nn(e){Ct.call(this),this.type="MeshDepthMaterial",this.depthPacking=3200,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}function Pn(e){Ct.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new oe,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}Nn.prototype=Object.create(Ct.prototype),Nn.prototype.constructor=Nn,Nn.prototype.isMeshDepthMaterial=!0,Nn.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,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},Pn.prototype=Object.create(Ct.prototype),Pn.prototype.constructor=Pn,Pn.prototype.isMeshDistanceMaterial=!0,Pn.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this};function Rn(e,t,i){var r=new Li,n=new Q,o=new Q,s=new J,a=[],c=[],h={},u={0:1,1:0,2:2},l=new Ei({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Q},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 <packing>\nvoid main() {\n float mean = 0.0;\n float squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n #ifdef HORIZONAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=l.clone();p.defines.HORIZONAL_PASS=1;var d=new Xt;d.setAttribute("position",new Pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var m=new fi(d,l),g=this;function _(i,r){var n=t.update(m);l.uniforms.shadow_pass.value=i.map.texture,l.uniforms.resolution.value=i.mapSize,l.uniforms.radius.value=i.radius,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(r,null,n,l,m,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(r,null,n,p,m,null)}function y(e,t,i){var r=e<<0|t<<1|i<<2,n=a[r];return void 0===n&&(n=new Nn({depthPacking:3201,morphTargets:e,skinning:t}),a[r]=n),n}function b(e,t,i){var r=e<<0|t<<1|i<<2,n=c[r];return void 0===n&&(n=new Pn({morphTargets:e,skinning:t}),c[r]=n),n}function x(t,i,r,n,o,s,a){var c=null,l=y,p=t.customDepthMaterial;if(!0===n.isPointLight&&(l=b,p=t.customDistanceMaterial),void 0===p){var d=!1;!0===r.morphTargets&&(d=i.morphAttributes&&i.morphAttributes.position&&i.morphAttributes.position.length>0);var f=!1;!0===t.isSkinnedMesh&&(!0===r.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t)),c=l(d,f,!0===t.isInstancedMesh)}else c=p;if(e.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var m=c.uuid,g=r.uuid,v=h[m];void 0===v&&(v={},h[m]=v);var _=v[g];void 0===_&&(_=c.clone(),v[g]=_),c=_}return c.visible=r.visible,c.wireframe=r.wireframe,c.side=3===a?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:u[r.side],c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,!0===n.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(n.matrixWorld),c.nearDistance=o,c.farDistance=s),c}function w(i,n,o,s,a){if(!1!==i.visible){if(i.layers.test(n.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||r.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,i.matrixWorld);var c=t.update(i),h=i.material;if(Array.isArray(h))for(var u=c.groups,l=0,p=u.length;l<p;l++){var d=u[l],f=h[d.materialIndex];if(f&&f.visible){var m=x(i,c,f,s,o.near,o.far,a);e.renderBufferDirect(o,null,c,m,i,d)}}else if(h.visible){m=x(i,c,h,s,o.near,o.far,a);e.renderBufferDirect(o,null,c,m,i,null)}}for(var g=i.children,v=0,_=g.length;v<_;v++)w(g[v],n,o,s,a)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(t,a,c){if(!1!==g.enabled&&(!1!==g.autoUpdate||!1!==g.needsUpdate)&&0!==t.length){var h=e.getRenderTarget(),u=e.getActiveCubeFace(),l=e.getActiveMipmapLevel(),p=e.state;p.setBlending(0),p.buffers.color.setClear(1,1,1,1),p.buffers.depth.setTest(!0),p.setScissorTest(!1);for(var d=0,m=t.length;d<m;d++){var y=t[d],b=y.shadow;if(void 0!==b){n.copy(b.mapSize);var x=b.getFrameExtents();if(n.multiply(x),o.copy(b.mapSize),(n.x>i||n.y>i)&&(n.x>i&&(o.x=Math.floor(i/x.x),n.x=o.x*x.x,b.mapSize.x=o.x),n.y>i&&(o.y=Math.floor(i/x.y),n.y=o.y*x.y,b.mapSize.y=o.y)),null===b.map&&!b.isPointLightShadow&&3===this.type){var A={minFilter:v,magFilter:v,format:E};b.map=new ee(n.x,n.y,A),b.map.texture.name=y.name+".shadowMap",b.mapPass=new ee(n.x,n.y,A),b.camera.updateProjectionMatrix()}if(null===b.map){A={minFilter:f,magFilter:f,format:E};b.map=new ee(n.x,n.y,A),b.map.texture.name=y.name+".shadowMap",b.camera.updateProjectionMatrix()}e.setRenderTarget(b.map),e.clear();for(var S=b.getViewportCount(),M=0;M<S;M++){var T=b.getViewport(M);s.set(o.x*T.x,o.y*T.y,o.x*T.z,o.y*T.w),p.viewport(s),b.updateMatrices(y,M),r=b.getFrustum(),w(a,c,b.camera,y,this.type)}b.isPointLightShadow||3!==this.type||_(b,c)}else console.warn("THREE.WebGLShadowMap:",y,"has no shadow.")}g.needsUpdate=!1,e.setRenderTarget(h,u,l)}}}function On(e,t,i){var r=i.isWebGL2;var n=new function(){var t=!1,i=new J,r=null,n=new J(0,0,0,0);return{setMask:function(i){r===i||t||(e.colorMask(i,i,i,i),r=i)},setLocked:function(e){t=e},setClear:function(t,r,o,s,a){!0===a&&(t*=s,r*=s,o*=s),i.set(t,r,o,s),!1===n.equals(i)&&(e.clearColor(t,r,o,s),n.copy(i))},reset:function(){t=!1,r=null,n.set(-1,0,0,0)}}},o=new function(){var t=!1,i=null,r=null,n=null;return{setTest:function(e){e?j(2929):z(2929)},setMask:function(r){i===r||t||(e.depthMask(r),i=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case 0:e.depthFunc(512);break;case 1:e.depthFunc(519);break;case 2:e.depthFunc(513);break;case 3:default:e.depthFunc(515);break;case 4:e.depthFunc(514);break;case 5:e.depthFunc(518);break;case 6:e.depthFunc(516);break;case 7:e.depthFunc(517)}else e.depthFunc(515);r=t}},setLocked:function(e){t=e},setClear:function(t){n!==t&&(e.clearDepth(t),n=t)},reset:function(){t=!1,i=null,r=null,n=null}}},s=new function(){var t=!1,i=null,r=null,n=null,o=null,s=null,a=null,c=null,h=null;return{setTest:function(e){t||(e?j(2960):z(2960))},setMask:function(r){i===r||t||(e.stencilMask(r),i=r)},setFunc:function(t,i,s){r===t&&n===i&&o===s||(e.stencilFunc(t,i,s),r=t,n=i,o=s)},setOp:function(t,i,r){s===t&&a===i&&c===r||(e.stencilOp(t,i,r),s=t,a=i,c=r)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,i=null,r=null,n=null,o=null,s=null,a=null,c=null,h=null}}},a=e.getParameter(34921),c=new Uint8Array(a),u=new Uint8Array(a),l=new Uint8Array(a),p={},d=null,f=null,m=null,g=null,v=null,_=null,y=null,b=null,x=null,w=!1,A=null,S=null,M=null,E=null,T=null,C=e.getParameter(35661),I=!1,N=0,P=e.getParameter(7938);-1!==P.indexOf("WebGL")?(N=parseFloat(/^WebGL\ ([0-9])/.exec(P)[1]),I=N>=1):-1!==P.indexOf("OpenGL ES")&&(N=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(P)[1]),I=N>=2);var R=null,O={},D=new J,L=new J;function k(t,i,r){var n=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(var s=0;s<r;s++)e.texImage2D(i+s,0,6408,1,1,0,6408,5121,n);return o}var B={};function F(i,n){(c[i]=1,0===u[i]&&(e.enableVertexAttribArray(i),u[i]=1),l[i]!==n)&&((r?e:t.get("ANGLE_instanced_arrays"))[r?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,n),l[i]=n)}function j(t){!0!==p[t]&&(e.enable(t),p[t]=!0)}function z(t){!1!==p[t]&&(e.disable(t),p[t]=!1)}B[3553]=k(3553,3553,1),B[34067]=k(34067,34069,6),n.setClear(0,0,0,1),o.setClear(1),s.setClear(0),j(2929),o.setFunc(3),H(!1),q(1),j(2884),G(0);var $={[h]:32774,101:32778,102:32779};if(r)$[103]=32775,$[104]=32776;else{var V=t.get("EXT_blend_minmax");null!==V&&($[103]=V.MIN_EXT,$[104]=V.MAX_EXT)}var U={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function G(t,i,r,n,o,s,a,c){if(0!==t){if(f||(j(3042),f=!0),5===t)o=o||i,s=s||r,a=a||n,i===g&&o===y||(e.blendEquationSeparate($[i],$[o]),g=i,y=o),r===v&&n===_&&s===b&&a===x||(e.blendFuncSeparate(U[r],U[n],U[s],U[a]),v=r,_=n,b=s,x=a),m=t,w=null;else if(t!==m||c!==w){if(g===h&&y===h||(e.blendEquation(32774),g=h,y=h),c)switch(t){case 1:e.blendFuncSeparate(1,771,1,771);break;case 2:e.blendFunc(1,1);break;case 3:e.blendFuncSeparate(0,0,769,771);break;case 4:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(770,771,1,771);break;case 2:e.blendFunc(770,1);break;case 3:e.blendFunc(0,769);break;case 4:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}v=null,_=null,b=null,x=null,m=t,w=c}}else f&&(z(3042),f=!1)}function H(t){A!==t&&(t?e.frontFace(2304):e.frontFace(2305),A=t)}function q(t){0!==t?(j(2884),t!==S&&(1===t?e.cullFace(1029):2===t?e.cullFace(1028):e.cullFace(1032))):z(2884),S=t}function W(t,i,r){t?(j(32823),E===i&&T===r||(e.polygonOffset(i,r),E=i,T=r)):z(32823)}function Q(t){void 0===t&&(t=33984+C-1),R!==t&&(e.activeTexture(t),R=t)}return{buffers:{color:n,depth:o,stencil:s},initAttributes:function(){for(var e=0,t=c.length;e<t;e++)c[e]=0},enableAttribute:function(e){F(e,0)},enableAttributeAndDivisor:F,disableUnusedAttributes:function(){for(var t=0,i=u.length;t!==i;++t)u[t]!==c[t]&&(e.disableVertexAttribArray(t),u[t]=0)},vertexAttribPointer:function(t,i,n,o,s,a){!0!==r||5124!==n&&5125!==n?e.vertexAttribPointer(t,i,n,o,s,a):e.vertexAttribIPointer(t,i,n,o,s,a)},enable:j,disable:z,useProgram:function(t){return d!==t&&(e.useProgram(t),d=t,!0)},setBlending:G,setMaterial:function(e,t){2===e.side?z(2884):j(2884);var i=1===e.side;t&&(i=!i),H(i),1===e.blending&&!1===e.transparent?G(0):G(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),o.setFunc(e.depthFunc),o.setTest(e.depthTest),o.setMask(e.depthWrite),n.setMask(e.colorWrite);var r=e.stencilWrite;s.setTest(r),r&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),W(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)},setFlipSided:H,setCullFace:q,setLineWidth:function(t){t!==M&&(I&&e.lineWidth(t),M=t)},setPolygonOffset:W,setScissorTest:function(e){e?j(3089):z(3089)},activeTexture:Q,bindTexture:function(t,i){null===R&&Q();var r=O[R];void 0===r&&(r={type:void 0,texture:void 0},O[R]=r),r.type===t&&r.texture===i||(e.bindTexture(t,i||B[t]),r.type=t,r.texture=i)},unbindTexture:function(){var t=O[R];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===D.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),D.copy(t))},viewport:function(t){!1===L.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),L.copy(t))},reset:function(){for(var t=0;t<u.length;t++)1===u[t]&&(e.disableVertexAttribArray(t),u[t]=0);p={},R=null,O={},d=null,m=null,A=null,S=null,n.reset(),o.reset(),s.reset()}}}function Dn(e,t,i,r,n,o,s){var a,c=n.isWebGL2,h=n.maxTextures,u=n.maxCubemapSize,y=n.maxTextureSize,I=n.maxSamples,N=new WeakMap,P=!1;try{P="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function R(e,t){return P?new OffscreenCanvas(e,t):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function O(e,t,i,r){var n=1;if((e.width>r||e.height>r)&&(n=r/Math.max(e.width,e.height)),n<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var o=t?W.floorPowerOfTwo:Math.floor,s=o(n*e.width),c=o(n*e.height);void 0===a&&(a=R(s,c));var h=i?R(s,c):a;return h.width=s,h.height=c,h.getContext("2d").drawImage(e,0,0,s,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+c+")."),h}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function D(e){return W.isPowerOfTwo(e.width)&&W.isPowerOfTwo(e.height)}function L(e,t){return e.generateMipmaps&&t&&e.minFilter!==f&&e.minFilter!==v}function k(t,i,n,o){e.generateMipmap(t),r.get(i).__maxMipLevel=Math.log(Math.max(n,o))*Math.LOG2E}function B(i,r,n){if(!1===c)return r;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}var o=r;return 6403===r&&(5126===n&&(o=33326),5131===n&&(o=33325),5121===n&&(o=33321)),6407===r&&(5126===n&&(o=34837),5131===n&&(o=34843),5121===n&&(o=32849)),6408===r&&(5126===n&&(o=34836),5131===n&&(o=34842),5121===n&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||t.get("EXT_color_buffer_float"),o}function F(e){return e===f||e===m||e===g?9728:9729}function j(t){var i=t.target;i.removeEventListener("dispose",j),function(t){var i=r.get(t);if(void 0===i.__webglInit)return;e.deleteTexture(i.__webglTexture),r.remove(t)}(i),i.isVideoTexture&&N.delete(i),s.memory.textures--}function z(t){var i=t.target;i.removeEventListener("dispose",z),function(t){var i=r.get(t),n=r.get(t.texture);if(!t)return;void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(var o=0;o<6;o++)e.deleteFramebuffer(i.__webglFramebuffer[o]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[o]);else e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&e.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer);r.remove(t.texture),r.remove(t)}(i),s.memory.textures--}var $=0;function V(e,t){var n=r.get(e);if(e.isVideoTexture&&function(e){var t=s.render.frame;N.get(e)!==t&&(N.set(e,t),e.update())}(e),e.version>0&&n.__version!==e.version){var o=e.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==o.complete)return void X(n,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+t),i.bindTexture(3553,n.__webglTexture)}function U(t,n){if(6===t.image.length){var s=r.get(t);if(t.version>0&&s.__version!==t.version){Y(s,t),i.activeTexture(33984+n),i.bindTexture(34067,s.__webglTexture),e.pixelStorei(37440,t.flipY);for(var a=t&&(t.isCompressedTexture||t.image[0].isCompressedTexture),h=t.image[0]&&t.image[0].isDataTexture,l=[],p=0;p<6;p++)l[p]=a||h?h?t.image[p].image:t.image[p]:O(t.image[p],!1,!0,u);var d,f=l[0],m=D(f)||c,g=o.convert(t.format),v=o.convert(t.type),_=B(t.internalFormat,g,v);if(Q(34067,t,m),a){for(p=0;p<6;p++){d=l[p].mipmaps;for(var y=0;y<d.length;y++){var b=d[y];t.format!==E&&t.format!==M?null!==g?i.compressedTexImage2D(34069+p,y,_,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+p,y,_,b.width,b.height,0,g,v,b.data)}}s.__maxMipLevel=d.length-1}else{d=t.mipmaps;for(p=0;p<6;p++)if(h){i.texImage2D(34069+p,0,_,l[p].width,l[p].height,0,g,v,l[p].data);for(y=0;y<d.length;y++){var x=(b=d[y]).image[p].image;i.texImage2D(34069+p,y+1,_,x.width,x.height,0,g,v,x.data)}}else{i.texImage2D(34069+p,0,_,g,v,l[p]);for(y=0;y<d.length;y++){b=d[y];i.texImage2D(34069+p,y+1,_,g,v,b.image[p])}}s.__maxMipLevel=d.length}L(t,m)&&k(34067,t,f.width,f.height),s.__version=t.version,t.onUpdate&&t.onUpdate(t)}else i.activeTexture(33984+n),i.bindTexture(34067,s.__webglTexture)}}function G(e,t){i.activeTexture(33984+t),i.bindTexture(34067,r.get(e).__webglTexture)}var H={[l]:10497,[p]:33071,[d]:33648},q={[f]:9728,[m]:9984,[g]:9986,[v]:9729,1007:9985,[_]:9987};function Q(i,o,s){s?(e.texParameteri(i,10242,H[o.wrapS]),e.texParameteri(i,10243,H[o.wrapT]),32879!==i&&35866!==i||e.texParameteri(i,32882,H[o.wrapR]),e.texParameteri(i,10240,q[o.magFilter]),e.texParameteri(i,10241,q[o.minFilter])):(e.texParameteri(i,10242,33071),e.texParameteri(i,10243,33071),32879!==i&&35866!==i||e.texParameteri(i,32882,33071),o.wrapS===p&&o.wrapT===p||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,10240,F(o.magFilter)),e.texParameteri(i,10241,F(o.minFilter)),o.minFilter!==f&&o.minFilter!==v&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));var a=t.get("EXT_texture_filter_anisotropic");if(a){if(o.type===w&&null===t.get("OES_texture_float_linear"))return;if(o.type===A&&null===(c||t.get("OES_texture_half_float_linear")))return;(o.anisotropy>1||r.get(o).__currentAnisotropy)&&(e.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,n.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function Y(t,i){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",j),t.__webglTexture=e.createTexture(),s.memory.textures++)}function X(t,r,n){var s=3553;r.isDataTexture2DArray&&(s=35866),r.isDataTexture3D&&(s=32879),Y(t,r),i.activeTexture(33984+n),i.bindTexture(s,t.__webglTexture),e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment);var a=function(e){return!c&&(e.wrapS!==p||e.wrapT!==p||e.minFilter!==f&&e.minFilter!==v)}(r)&&!1===D(r.image),h=O(r.image,a,!1,y),u=D(h)||c,l=o.convert(r.format),d=o.convert(r.type),m=B(r.internalFormat,l,d);Q(s,r,u);var g,_=r.mipmaps;if(r.isDepthTexture)m=6402,c?m=r.type===w?36012:r.type===x?33190:r.type===S?35056:33189:r.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===T&&6402===m&&r.type!==b&&r.type!==x&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=b,d=o.convert(r.type)),r.format===C&&6402===m&&(m=34041,r.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=S,d=o.convert(r.type))),i.texImage2D(3553,0,m,h.width,h.height,0,l,d,null);else if(r.isDataTexture)if(_.length>0&&u){for(var A=0,I=_.length;A<I;A++)g=_[A],i.texImage2D(3553,A,m,g.width,g.height,0,l,d,g.data);r.generateMipmaps=!1,t.__maxMipLevel=_.length-1}else i.texImage2D(3553,0,m,h.width,h.height,0,l,d,h.data),t.__maxMipLevel=0;else if(r.isCompressedTexture){for(A=0,I=_.length;A<I;A++)g=_[A],r.format!==E&&r.format!==M?null!==l?i.compressedTexImage2D(3553,A,m,g.width,g.height,0,g.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,A,m,g.width,g.height,0,l,d,g.data);t.__maxMipLevel=_.length-1}else if(r.isDataTexture2DArray)i.texImage3D(35866,0,m,h.width,h.height,h.depth,0,l,d,h.data),t.__maxMipLevel=0;else if(r.isDataTexture3D)i.texImage3D(32879,0,m,h.width,h.height,h.depth,0,l,d,h.data),t.__maxMipLevel=0;else if(_.length>0&&u){for(A=0,I=_.length;A<I;A++)g=_[A],i.texImage2D(3553,A,m,l,d,g);r.generateMipmaps=!1,t.__maxMipLevel=_.length-1}else i.texImage2D(3553,0,m,l,d,h),t.__maxMipLevel=0;L(r,u)&&k(s,r,h.width,h.height),t.__version=r.version,r.onUpdate&&r.onUpdate(r)}function Z(t,n,s,a){var c=o.convert(n.texture.format),h=o.convert(n.texture.type),u=B(n.texture.internalFormat,c,h);i.texImage2D(a,0,u,n.width,n.height,0,c,h,null),e.bindFramebuffer(36160,t),e.framebufferTexture2D(36160,s,a,r.get(n.texture).__webglTexture,0),e.bindFramebuffer(36160,null)}function K(t,i,r){if(e.bindRenderbuffer(36161,t),i.depthBuffer&&!i.stencilBuffer){var n=33189;if(r){var s=i.depthTexture;s&&s.isDepthTexture&&(s.type===w?n=36012:s.type===x&&(n=33190));var a=ee(i);e.renderbufferStorageMultisample(36161,a,n,i.width,i.height)}else e.renderbufferStorage(36161,n,i.width,i.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(i.depthBuffer&&i.stencilBuffer){if(r){a=ee(i);e.renderbufferStorageMultisample(36161,a,35056,i.width,i.height)}else e.renderbufferStorage(36161,34041,i.width,i.height);e.framebufferRenderbuffer(36160,33306,36161,t)}else{var c=o.convert(i.texture.format),h=o.convert(i.texture.type);n=B(i.texture.internalFormat,c,h);if(r){a=ee(i);e.renderbufferStorageMultisample(36161,a,n,i.width,i.height)}else e.renderbufferStorage(36161,n,i.width,i.height)}e.bindRenderbuffer(36161,null)}function J(t){var i=r.get(t),n=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(n)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(e.bindFramebuffer(36160,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__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),V(i.depthTexture,0);var n=r.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===T)e.framebufferTexture2D(36160,36096,3553,n,0);else{if(i.depthTexture.format!==C)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,n,0)}}(i.__webglFramebuffer,t)}else if(n){i.__webglDepthbuffer=[];for(var o=0;o<6;o++)e.bindFramebuffer(36160,i.__webglFramebuffer[o]),i.__webglDepthbuffer[o]=e.createRenderbuffer(),K(i.__webglDepthbuffer[o],t,!1)}else e.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),K(i.__webglDepthbuffer,t,!1);e.bindFramebuffer(36160,null)}function ee(e){return c&&e.isWebGLMultisampleRenderTarget?Math.min(I,e.samples):0}var te=!1,ie=!1;this.allocateTextureUnit=function(){var e=$;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),$+=1,e},this.resetTextureUnits=function(){$=0},this.setTexture2D=V,this.setTexture2DArray=function(e,t){var n=r.get(e);e.version>0&&n.__version!==e.version?X(n,e,t):(i.activeTexture(33984+t),i.bindTexture(35866,n.__webglTexture))},this.setTexture3D=function(e,t){var n=r.get(e);e.version>0&&n.__version!==e.version?X(n,e,t):(i.activeTexture(33984+t),i.bindTexture(32879,n.__webglTexture))},this.setTextureCube=U,this.setTextureCubeDynamic=G,this.setupRenderTarget=function(t){var n=r.get(t),a=r.get(t.texture);t.addEventListener("dispose",z),a.__webglTexture=e.createTexture(),s.memory.textures++;var h=!0===t.isWebGLCubeRenderTarget,u=!0===t.isWebGLMultisampleRenderTarget,l=D(t)||c;if(!c||t.texture.format!==M||t.texture.type!==w&&t.texture.type!==A||(t.texture.format=E,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){n.__webglFramebuffer=[];for(var p=0;p<6;p++)n.__webglFramebuffer[p]=e.createFramebuffer()}else if(n.__webglFramebuffer=e.createFramebuffer(),u)if(c){n.__webglMultisampledFramebuffer=e.createFramebuffer(),n.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,n.__webglColorRenderbuffer);var d=o.convert(t.texture.format),f=o.convert(t.texture.type),m=B(t.texture.internalFormat,d,f),g=ee(t);e.renderbufferStorageMultisample(36161,g,m,t.width,t.height),e.bindFramebuffer(36160,n.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,n.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(n.__webglDepthRenderbuffer=e.createRenderbuffer(),K(n.__webglDepthRenderbuffer,t,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(h){i.bindTexture(34067,a.__webglTexture),Q(34067,t.texture,l);for(p=0;p<6;p++)Z(n.__webglFramebuffer[p],t,36064,34069+p);L(t.texture,l)&&k(34067,t.texture,t.width,t.height),i.bindTexture(34067,null)}else i.bindTexture(3553,a.__webglTexture),Q(3553,t.texture,l),Z(n.__webglFramebuffer,t,36064,3553),L(t.texture,l)&&k(3553,t.texture,t.width,t.height),i.bindTexture(3553,null);t.depthBuffer&&J(t)},this.updateRenderTargetMipmap=function(e){var t=e.texture;if(L(t,D(e)||c)){var n=e.isWebGLCubeRenderTarget?34067:3553,o=r.get(t).__webglTexture;i.bindTexture(n,o),k(n,t,e.width,e.height),i.bindTexture(n,null)}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(c){var i=r.get(t);e.bindFramebuffer(36008,i.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,i.__webglFramebuffer);var n=t.width,o=t.height,s=16384;t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024),e.blitFramebuffer(0,0,n,o,0,0,n,o,s,9728),e.bindFramebuffer(36160,i.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===te&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),te=!0),e=e.texture),V(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===ie&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ie=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?U(e,t):G(e,t)}}function Ln(e,t,i){var r=i.isWebGL2;return{convert:function(e){var i;if(e===y)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120;if(1011===e)return 5122;if(e===b)return 5123;if(1013===e)return 5124;if(e===x)return 5125;if(e===w)return 5126;if(e===A)return r?5131:null!==(i=t.get("OES_texture_half_float"))?i.HALF_FLOAT_OES:null;if(1021===e)return 6406;if(e===M)return 6407;if(e===E)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(e===T)return 6402;if(e===C)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032===e)return 36248;if(1033===e)return 36249;if(33776===e||33777===e||33778===e||33779===e){if(null===(i=t.get("WEBGL_compressed_texture_s3tc")))return null;if(33776===e)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===e)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===e)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===e)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===e||35841===e||35842===e||35843===e){if(null===(i=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(35840===e)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===e)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===e)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===e)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e)return null!==(i=t.get("WEBGL_compressed_texture_etc1"))?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((37492===e||37496===e)&&null!==(i=t.get("WEBGL_compressed_texture_etc"))){if(37492===e)return i.COMPRESSED_RGB8_ETC2;if(37496===e)return i.COMPRESSED_RGBA8_ETC2_EAC}return 37808===e||37809===e||37810===e||37811===e||37812===e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e?null!==(i=t.get("WEBGL_compressed_texture_astc"))?e:null:36492===e?null!==(i=t.get("EXT_texture_compression_bptc"))?e:null:e===S?r?34042:null!==(i=t.get("WEBGL_depth_texture"))?i.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}function kn(e){Ci.call(this),this.cameras=e||[]}function Bn(){Pe.call(this),this.type="Group"}function Fn(){this._targetRay=null,this._grip=null}function jn(e,t){var i=this,r=null,n=1,o=null,s="local-floor",a=null,c=[],h=new Map,u=new Ci;u.layers.enable(1),u.viewport=new J;var l=new Ci;l.layers.enable(2),l.viewport=new J;var p=[u,l],d=new kn;d.layers.enable(1),d.layers.enable(2);var f=null,m=null;function g(e){var t=h.get(e.inputSource);t&&t.dispatchEvent({type:e.type})}function v(){h.forEach((function(e,t){e.disconnect(t)})),h.clear(),e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),S.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function _(e){o=e,S.setContext(r),S.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}function y(e){for(var t=r.inputSources,i=0;i<c.length;i++)h.set(t[i],c[i]);for(i=0;i<e.removed.length;i++){var n=e.removed[i];(o=h.get(n))&&(o.dispatchEvent({type:"disconnected",data:n}),h.delete(n))}for(i=0;i<e.added.length;i++){var o;n=e.added[i];(o=h.get(n))&&o.dispatchEvent({type:"connected",data:n})}}this.enabled=!1,this.isPresenting=!1,this.getController=function(e){var t=c[e];return void 0===t&&(t=new Fn,c[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){var t=c[e];return void 0===t&&(t=new Fn,c[e]=t),t.getGripSpace()},this.setFramebufferScaleFactor=function(e){n=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getSession=function(){return r},this.setSession=function(e){if(null!==(r=e)){r.addEventListener("select",g),r.addEventListener("selectstart",g),r.addEventListener("selectend",g),r.addEventListener("squeeze",g),r.addEventListener("squeezestart",g),r.addEventListener("squeezeend",g),r.addEventListener("end",v);var i=t.getContextAttributes();!0!==i.xrCompatible&&t.makeXRCompatible();var o={antialias:i.antialias,alpha:i.alpha,depth:i.depth,stencil:i.stencil,framebufferScaleFactor:n},a=new XRWebGLLayer(r,t,o);r.updateRenderState({baseLayer:a}),r.requestReferenceSpace(s).then(_),r.addEventListener("inputsourceschange",y)}};var b=new oe,x=new oe;function w(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.getInverse(e.matrixWorld)}this.getCamera=function(e){d.near=l.near=u.near=e.near,d.far=l.far=u.far=e.far,f===d.near&&m===d.far||(r.updateRenderState({depthNear:d.near,depthFar:d.far}),f=d.near,m=d.far);var t=e.parent,i=d.cameras;w(d,t);for(var n=0;n<i.length;n++)w(i[n],t);e.matrixWorld.copy(d.matrixWorld);for(var o=e.children,s=(n=0,o.length);n<s;n++)o[n].updateMatrixWorld(!0);return 2===i.length?function(e,t,i){b.setFromMatrixPosition(t.matrixWorld),x.setFromMatrixPosition(i.matrixWorld);var r=b.distanceTo(x),n=t.projectionMatrix.elements,o=i.projectionMatrix.elements,s=n[14]/(n[10]-1),a=n[14]/(n[10]+1),c=(n[9]+1)/n[5],h=(n[9]-1)/n[5],u=(n[8]-1)/n[0],l=(o[8]+1)/o[0],p=s*u,d=s*l,f=r/(-u+l),m=f*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.getInverse(e.matrixWorld);var g=s+f,v=a+f,_=p-m,y=d+(r-m),w=c*a/v*g,A=h*a/v*g;e.projectionMatrix.makePerspective(_,y,w,A,g,v)}(d,u,l):d.projectionMatrix.copy(u.projectionMatrix),d};var A=null;var S=new Bi;S.setAnimationLoop((function(t,i){if(null!==(a=i.getViewerPose(o))){var n=a.views,s=r.renderState.baseLayer;e.setFramebuffer(s.framebuffer);var h=!1;n.length!==d.cameras.length&&(d.cameras.length=0,h=!0);for(var u=0;u<n.length;u++){var l=n[u],f=s.getViewport(l),m=p[u];m.matrix.fromArray(l.transform.matrix),m.projectionMatrix.fromArray(l.projectionMatrix),m.viewport.set(f.x,f.y,f.width,f.height),0===u&&d.matrix.copy(m.matrix),!0===h&&d.cameras.push(m)}}var g=r.inputSources;for(u=0;u<c.length;u++){var v=c[u],_=g[u];v.update(_,i,o)}A&&A(t,i)})),this.setAnimationLoop=function(e){A=e},this.dispose=function(){}}function zn(e){function t(t,i,r){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map),i.alphaMap&&(t.alphaMap.value=i.alphaMap),i.specularMap&&(t.specularMap.value=i.specularMap);var n,o,s=i.envMap||r;s&&(t.envMap.value=s,t.flipEnvMap.value=s.isCubeTexture?-1:1,t.reflectivity.value=i.reflectivity,t.refractionRatio.value=i.refractionRatio,t.maxMipLevel.value=e.get(s).__maxMipLevel),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity),i.map?n=i.map:i.specularMap?n=i.specularMap:i.displacementMap?n=i.displacementMap:i.normalMap?n=i.normalMap:i.bumpMap?n=i.bumpMap:i.roughnessMap?n=i.roughnessMap:i.metalnessMap?n=i.metalnessMap:i.alphaMap?n=i.alphaMap:i.emissiveMap&&(n=i.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix)),i.aoMap?o=i.aoMap:i.lightMap&&(o=i.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),t.uv2Transform.value.copy(o.matrix))}function i(e,t,i){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),(t.envMap||i)&&(e.envMapIntensity.value=t.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,r,n,o,s){r.isMeshBasicMaterial?t(e,r):r.isMeshLambertMaterial?(t(e,r),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(e,r)):r.isMeshToonMaterial?(t(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.gradientMap&&(e.gradientMap.value=t.gradientMap);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,r)):r.isMeshPhongMaterial?(t(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,r)):r.isMeshStandardMaterial?(t(e,r,n),r.isMeshPhysicalMaterial?function(e,t,r){i(e,t,r),e.reflectivity.value=t.reflectivity,e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.sheen&&e.sheen.value.copy(t.sheen);t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap);t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap);t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate());e.transparency.value=t.transparency}(e,r,n):i(e,r,n)):r.isMeshMatcapMaterial?(t(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,r)):r.isMeshDepthMaterial?(t(e,r),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,r)):r.isMeshDistanceMaterial?(t(e,r),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,r)):r.isMeshNormalMaterial?(t(e,r),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,r)):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(e,r,o,s):r.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);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var i;t.map?i=t.map:t.alphaMap&&(i=t.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function $n(e){var t=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),i=void 0!==e.context?e.context:null,r=void 0!==e.alpha&&e.alpha,n=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,s=void 0!==e.antialias&&e.antialias,a=void 0===e.premultipliedAlpha||e.premultipliedAlpha,c=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,h=void 0!==e.powerPreference?e.powerPreference:"default",u=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat,l=null,p=null;this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=k,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var d,f,m,g,v,_,b,x,S,M,T,C,I,N,P,R,O,D,L,B=this,F=!1,j=null,z=0,$=0,V=null,U=null,G=-1,H={geometry:null,program:null,wireframe:!1},q=null,Y=null,X=new J,Z=new J,K=null,ee=t.width,te=t.height,ie=1,re=null,ne=null,se=new J(0,0,ee,te),ae=new J(0,0,ee,te),ce=!1,he=new Li,ue=new qi,le=!1,pe=!1,fe=new de,me=new oe;function ge(){return null===V?ie:1}try{var ve={alpha:r,depth:n,stencil:o,antialias:s,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if(t.addEventListener("webglcontextlost",xe,!1),t.addEventListener("webglcontextrestored",we,!1),null===(d=i||t.getContext("webgl",ve)||t.getContext("experimental-webgl",ve)))throw null!==t.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===d.getShaderPrecisionFormat&&(d.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function _e(){f=new Wi(d),!1===(m=new Hi(d,f,e)).isWebGL2&&(f.get("WEBGL_depth_texture"),f.get("OES_texture_float"),f.get("OES_texture_half_float"),f.get("OES_texture_half_float_linear"),f.get("OES_standard_derivatives"),f.get("OES_element_index_uint"),f.get("ANGLE_instanced_arrays")),f.get("OES_texture_float_linear"),L=new Ln(d,f,m),(g=new On(d,f,m)).scissor(Z.copy(ae).multiplyScalar(ie).floor()),g.viewport(X.copy(se).multiplyScalar(ie).floor()),v=new Xi,_=new yn,b=new Dn(d,f,g,_,m,L,v),x=new Fi(d,m),S=new Qi(d,x,v),M=new Ji(d,S,x,v),R=new Ki(d),T=new _n(B,f,m),C=new zn(_),I=new An,N=new In,P=new Ui(B,g,M,a),O=new Gi(d,f,v,m),D=new Yi(d,f,v,m),v.programs=T.programs,B.capabilities=m,B.extensions=f,B.properties=_,B.renderLists=I,B.state=g,B.info=v}_e();var ye=new jn(B,d);this.xr=ye;var be=new Rn(B,M,m.maxTextureSize);function xe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),F=!0}function we(){console.log("THREE.WebGLRenderer: Context Restored."),F=!1,_e()}function Ae(e){var t=e.target;t.removeEventListener("dispose",Ae),function(e){Se(e),_.remove(e)}(t)}function Se(e){var t=_.get(e).program;e.program=void 0,void 0!==t&&T.releaseProgram(t)}this.shadowMap=be,this.getContext=function(){return d},this.getContextAttributes=function(){return d.getContextAttributes()},this.forceContextLoss=function(){var e=f.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=f.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(e){void 0!==e&&(ie=e,this.setSize(ee,te,!1))},this.getSize=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),e=new Q),e.set(ee,te)},this.setSize=function(e,i,r){ye.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(ee=e,te=i,t.width=Math.floor(e*ie),t.height=Math.floor(i*ie),!1!==r&&(t.style.width=e+"px",t.style.height=i+"px"),this.setViewport(0,0,e,i))},this.getDrawingBufferSize=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),e=new Q),e.set(ee*ie,te*ie).floor()},this.setDrawingBufferSize=function(e,i,r){ee=e,te=i,ie=r,t.width=Math.floor(e*r),t.height=Math.floor(i*r),this.setViewport(0,0,e,i)},this.getCurrentViewport=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),e=new J),e.copy(X)},this.getViewport=function(e){return e.copy(se)},this.setViewport=function(e,t,i,r){e.isVector4?se.set(e.x,e.y,e.z,e.w):se.set(e,t,i,r),g.viewport(X.copy(se).multiplyScalar(ie).floor())},this.getScissor=function(e){return e.copy(ae)},this.setScissor=function(e,t,i,r){e.isVector4?ae.set(e.x,e.y,e.z,e.w):ae.set(e,t,i,r),g.scissor(Z.copy(ae).multiplyScalar(ie).floor())},this.getScissorTest=function(){return ce},this.setScissorTest=function(e){g.setScissorTest(ce=e)},this.setOpaqueSort=function(e){re=e},this.setTransparentSort=function(e){ne=e},this.getClearColor=function(){return P.getClearColor()},this.setClearColor=function(){P.setClearColor.apply(P,arguments)},this.getClearAlpha=function(){return P.getClearAlpha()},this.setClearAlpha=function(){P.setClearAlpha.apply(P,arguments)},this.clear=function(e,t,i){var r=0;(void 0===e||e)&&(r|=16384),(void 0===t||t)&&(r|=256),(void 0===i||i)&&(r|=1024),d.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",xe,!1),t.removeEventListener("webglcontextrestored",we,!1),I.dispose(),N.dispose(),_.dispose(),M.dispose(),ye.dispose(),Te.stop()},this.renderBufferImmediate=function(e,t){g.initAttributes();var i=_.get(e);e.hasPositions&&!i.position&&(i.position=d.createBuffer()),e.hasNormals&&!i.normal&&(i.normal=d.createBuffer()),e.hasUvs&&!i.uv&&(i.uv=d.createBuffer()),e.hasColors&&!i.color&&(i.color=d.createBuffer());var r=t.getAttributes();e.hasPositions&&(d.bindBuffer(34962,i.position),d.bufferData(34962,e.positionArray,35048),g.enableAttribute(r.position),d.vertexAttribPointer(r.position,3,5126,!1,0,0)),e.hasNormals&&(d.bindBuffer(34962,i.normal),d.bufferData(34962,e.normalArray,35048),g.enableAttribute(r.normal),d.vertexAttribPointer(r.normal,3,5126,!1,0,0)),e.hasUvs&&(d.bindBuffer(34962,i.uv),d.bufferData(34962,e.uvArray,35048),g.enableAttribute(r.uv),d.vertexAttribPointer(r.uv,2,5126,!1,0,0)),e.hasColors&&(d.bindBuffer(34962,i.color),d.bufferData(34962,e.colorArray,35048),g.enableAttribute(r.color),d.vertexAttribPointer(r.color,3,5126,!1,0,0)),g.disableUnusedAttributes(),d.drawArrays(4,0,e.count),e.count=0};var Me=new Re;this.renderBufferDirect=function(e,t,i,r,n,o){null===t&&(t=Me);var s=n.isMesh&&n.matrixWorld.determinant()<0,a=Oe(e,t,r,n);g.setMaterial(r,s);var c=!1;H.geometry===i.id&&H.program===a.id&&H.wireframe===(!0===r.wireframe)||(H.geometry=i.id,H.program=a.id,H.wireframe=!0===r.wireframe,c=!0),(r.morphTargets||r.morphNormals)&&(R.update(n,i,r,a),c=!0),!0===n.isInstancedMesh&&(c=!0);var h=i.index,u=i.attributes.position;if(null===h){if(void 0===u||0===u.count)return}else if(0===h.count)return;var l,p=1;!0===r.wireframe&&(h=S.getWireframeAttribute(i),p=2);var v=O;null!==h&&(l=x.get(h),(v=D).setIndex(l)),c&&(!function(e,t,i,r){if(!1===m.isWebGL2&&(e.isInstancedMesh||t.isInstancedBufferGeometry)&&null===f.get("ANGLE_instanced_arrays"))return;g.initAttributes();var n=t.attributes,o=r.getAttributes(),s=i.defaultAttributeValues;for(var a in o){var c=o[a];if(c>=0){var h=n[a];if(void 0!==h){var u=h.normalized,l=h.itemSize;if(void 0===(A=x.get(h)))continue;var p=A.buffer,v=A.type,_=A.bytesPerElement;if(h.isInterleavedBufferAttribute){var y=h.data,b=y.stride,w=h.offset;y&&y.isInstancedInterleavedBuffer?(g.enableAttributeAndDivisor(c,y.meshPerAttribute),void 0===t._maxInstanceCount&&(t._maxInstanceCount=y.meshPerAttribute*y.count)):g.enableAttribute(c),d.bindBuffer(34962,p),g.vertexAttribPointer(c,l,v,u,b*_,w*_)}else h.isInstancedBufferAttribute?(g.enableAttributeAndDivisor(c,h.meshPerAttribute),void 0===t._maxInstanceCount&&(t._maxInstanceCount=h.meshPerAttribute*h.count)):g.enableAttribute(c),d.bindBuffer(34962,p),g.vertexAttribPointer(c,l,v,u,0,0)}else if("instanceMatrix"===a){var A;if(void 0===(A=x.get(e.instanceMatrix)))continue;p=A.buffer,v=A.type;g.enableAttributeAndDivisor(c+0,1),g.enableAttributeAndDivisor(c+1,1),g.enableAttributeAndDivisor(c+2,1),g.enableAttributeAndDivisor(c+3,1),d.bindBuffer(34962,p),d.vertexAttribPointer(c+0,4,v,!1,64,0),d.vertexAttribPointer(c+1,4,v,!1,64,16),d.vertexAttribPointer(c+2,4,v,!1,64,32),d.vertexAttribPointer(c+3,4,v,!1,64,48)}else if(void 0!==s){var S=s[a];if(void 0!==S)switch(S.length){case 2:d.vertexAttrib2fv(c,S);break;case 3:d.vertexAttrib3fv(c,S);break;case 4:d.vertexAttrib4fv(c,S);break;default:d.vertexAttrib1fv(c,S)}}}}g.disableUnusedAttributes()}(n,i,r,a),null!==h&&d.bindBuffer(34963,l.buffer));var _=null!==h?h.count:u.count,y=i.drawRange.start*p,b=i.drawRange.count*p,w=null!==o?o.start*p:0,A=null!==o?o.count*p:1/0,M=Math.max(y,w),E=Math.min(_,y+b,w+A)-1,T=Math.max(0,E-M+1);if(0!==T){if(n.isMesh)!0===r.wireframe?(g.setLineWidth(r.wireframeLinewidth*ge()),v.setMode(1)):v.setMode(4);else if(n.isLine){var C=r.linewidth;void 0===C&&(C=1),g.setLineWidth(C*ge()),n.isLineSegments?v.setMode(1):n.isLineLoop?v.setMode(2):v.setMode(3)}else n.isPoints?v.setMode(0):n.isSprite&&v.setMode(4);if(n.isInstancedMesh)v.renderInstances(i,M,T,n.count);else if(i.isInstancedBufferGeometry){var I=Math.min(i.instanceCount,i._maxInstanceCount);v.renderInstances(i,M,T,I)}else v.render(M,T)}},this.compile=function(e,t){(p=N.get(e,t)).init(),e.traverse((function(e){e.isLight&&(p.pushLight(e),e.castShadow&&p.pushShadow(e))})),p.setupLights(t);const i={};e.traverse((function(t){let r=t.material;if(r)if(Array.isArray(r))for(let n=0;n<r.length;n++){let o=r[n];o.uuid in i==!1&&(Pe(o,e,t),i[o.uuid]=!0)}else r.uuid in i==!1&&(Pe(r,e,t),i[r.uuid]=!0)}))};var Ee=null;var Te=new Bi;function Ce(e,t,i,r){if(!1!==e.visible){if(e.layers.test(t.layers))if(e.isGroup)i=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)p.pushLight(e),e.castShadow&&p.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||he.intersectsSprite(e)){r&&me.setFromMatrixPosition(e.matrixWorld).applyMatrix4(fe);var n=M.update(e);(o=e.material).visible&&l.push(e,n,o,i,me.z,null)}}else if(e.isImmediateRenderObject)r&&me.setFromMatrixPosition(e.matrixWorld).applyMatrix4(fe),l.push(e,null,e.material,i,me.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==v.render.frame&&(e.skeleton.update(),e.skeleton.frame=v.render.frame),!e.frustumCulled||he.intersectsObject(e))){r&&me.setFromMatrixPosition(e.matrixWorld).applyMatrix4(fe);n=M.update(e);var o=e.material;if(Array.isArray(o))for(var s=n.groups,a=0,c=s.length;a<c;a++){var h=s[a],u=o[h.materialIndex];u&&u.visible&&l.push(e,n,u,i,me.z,h)}else o.visible&&l.push(e,n,o,i,me.z,null)}var d=e.children;for(a=0,c=d.length;a<c;a++)Ce(d[a],t,i,r)}}function Ie(e,t,i,r){for(var n=0,o=e.length;n<o;n++){var s=e[n],a=s.object,c=s.geometry,h=void 0===r?s.material:r,u=s.group;if(i.isArrayCamera){Y=i;for(var l=i.cameras,d=0,f=l.length;d<f;d++){var m=l[d];a.layers.test(m.layers)&&(g.viewport(X.copy(m.viewport)),p.setupLights(m),Ne(a,t,m,c,h,u))}}else Y=null,Ne(a,t,i,c,h,u)}}function Ne(e,t,i,r,n,o){if(e.onBeforeRender(B,t,i,r,n,o),p=N.get(t,Y||i),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject){var s=Oe(i,t,n,e);g.setMaterial(n),H.geometry=null,H.program=null,H.wireframe=!1,function(e,t){e.render((function(e){B.renderBufferImmediate(e,t)}))}(e,s)}else B.renderBufferDirect(i,t,r,n,e,o);e.onAfterRender(B,t,i,r,n,o),p=N.get(t,Y||i)}function Pe(e,t,i){var r=_.get(e),n=p.state.lights,o=p.state.shadowsArray,s=n.state.version,a=T.getParameters(e,n.state,o,t,ue.numPlanes,ue.numIntersection,i),c=T.getProgramCacheKey(a),h=r.program,u=!0;if(void 0===h)e.addEventListener("dispose",Ae);else if(h.cacheKey!==c)Se(e);else if(r.lightsStateVersion!==s)r.lightsStateVersion=s,u=!1;else{if(void 0!==a.shaderID)return;u=!1}u&&(h=T.acquireProgram(a,c),r.program=h,r.uniforms=a.uniforms,r.outputEncoding=a.outputEncoding,e.program=h);var l=h.getAttributes();if(e.morphTargets){e.numSupportedMorphTargets=0;for(var d=0;d<B.maxMorphTargets;d++)l["morphTarget"+d]>=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(d=0;d<B.maxMorphNormals;d++)l["morphNormal"+d]>=0&&e.numSupportedMorphNormals++}var f=r.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(r.numClippingPlanes=ue.numPlanes,r.numIntersection=ue.numIntersection,f.clippingPlanes=ue.uniform),r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=s,r.needsLights&&(f.ambientLightColor.value=n.state.ambient,f.lightProbe.value=n.state.probe,f.directionalLights.value=n.state.directional,f.directionalLightShadows.value=n.state.directionalShadow,f.spotLights.value=n.state.spot,f.spotLightShadows.value=n.state.spotShadow,f.rectAreaLights.value=n.state.rectArea,f.pointLights.value=n.state.point,f.pointLightShadows.value=n.state.pointShadow,f.hemisphereLights.value=n.state.hemi,f.directionalShadowMap.value=n.state.directionalShadowMap,f.directionalShadowMatrix.value=n.state.directionalShadowMatrix,f.spotShadowMap.value=n.state.spotShadowMap,f.spotShadowMatrix.value=n.state.spotShadowMatrix,f.pointShadowMap.value=n.state.pointShadowMap,f.pointShadowMatrix.value=n.state.pointShadowMatrix);var m=r.program.getUniforms(),g=Zr.seqWithValue(m.seq,f);r.uniformsList=g}function Oe(e,t,i,r){b.resetTextureUnits();var n=t.fog,o=i.isMeshStandardMaterial?t.environment:null,s=null===V?B.outputEncoding:V.texture.encoding,a=_.get(i),c=p.state.lights;if(le&&(pe||e!==q)){var h=e===q&&i.id===G;ue.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,e,a,h)}i.version===a.__version?void 0===a.program||i.fog&&a.fog!==n||a.environment!==o||a.needsLights&&a.lightsStateVersion!==c.state.version?Pe(i,t,r):void 0===a.numClippingPlanes||a.numClippingPlanes===ue.numPlanes&&a.numIntersection===ue.numIntersection?a.outputEncoding!==s&&Pe(i,t,r):Pe(i,t,r):(Pe(i,t,r),a.__version=i.version);var u,l,f=!1,v=!1,y=!1,x=a.program,A=x.getUniforms(),S=a.uniforms;if(g.useProgram(x.program)&&(f=!0,v=!0,y=!0),i.id!==G&&(G=i.id,v=!0),f||q!==e){if(A.setValue(d,"projectionMatrix",e.projectionMatrix),m.logarithmicDepthBuffer&&A.setValue(d,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),q!==e&&(q=e,v=!0,y=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){var M=A.map.cameraPosition;void 0!==M&&M.setValue(d,me.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&A.setValue(d,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&A.setValue(d,"viewMatrix",e.matrixWorldInverse)}if(i.skinning){A.setOptional(d,r,"bindMatrix"),A.setOptional(d,r,"bindMatrixInverse");var T=r.skeleton;if(T){var I=T.bones;if(m.floatVertexTextures){if(void 0===T.boneTexture){var N=Math.sqrt(4*I.length);N=W.ceilPowerOfTwo(N),N=Math.max(N,4);var P=new Float32Array(N*N*4);P.set(T.boneMatrices);var R=new Ri(P,N,N,E,w);T.boneMatrices=P,T.boneTexture=R,T.boneTextureSize=N}A.setValue(d,"boneTexture",T.boneTexture,b),A.setValue(d,"boneTextureSize",T.boneTextureSize)}else A.setOptional(d,T,"boneMatrices")}}return(v||a.receiveShadow!==r.receiveShadow)&&(a.receiveShadow=r.receiveShadow,A.setValue(d,"receiveShadow",r.receiveShadow)),v&&(A.setValue(d,"toneMappingExposure",B.toneMappingExposure),A.setValue(d,"toneMappingWhitePoint",B.toneMappingWhitePoint),a.needsLights&&(l=y,(u=S).ambientLightColor.needsUpdate=l,u.lightProbe.needsUpdate=l,u.directionalLights.needsUpdate=l,u.directionalLightShadows.needsUpdate=l,u.pointLights.needsUpdate=l,u.pointLightShadows.needsUpdate=l,u.spotLights.needsUpdate=l,u.spotLightShadows.needsUpdate=l,u.rectAreaLights.needsUpdate=l,u.hemisphereLights.needsUpdate=l),n&&i.fog&&C.refreshFogUniforms(S,n),C.refreshMaterialUniforms(S,i,o,ie,te),void 0!==S.ltc_1&&(S.ltc_1.value=ki.LTC_1),void 0!==S.ltc_2&&(S.ltc_2.value=ki.LTC_2),Zr.upload(d,a.uniformsList,S,b)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Zr.upload(d,a.uniformsList,S,b),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&A.setValue(d,"center",r.center),A.setValue(d,"modelViewMatrix",r.modelViewMatrix),A.setValue(d,"normalMatrix",r.normalMatrix),A.setValue(d,"modelMatrix",r.matrixWorld),x}Te.setAnimationLoop((function(e){ye.isPresenting||Ee&&Ee(e)})),"undefined"!=typeof window&&Te.setContext(window),this.setAnimationLoop=function(e){Ee=e,ye.setAnimationLoop(e),Te.start()},this.render=function(e,t){var i,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),i=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),t&&t.isCamera){if(!F){H.geometry=null,H.program=null,H.wireframe=!1,G=-1,q=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),ye.enabled&&ye.isPresenting&&(t=ye.getCamera(t)),e.onBeforeRender(B,e,t,i||V),(p=N.get(e,t)).init(),fe.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),he.setFromProjectionMatrix(fe),pe=this.localClippingEnabled,le=ue.init(this.clippingPlanes,pe,t),(l=I.get(e,t)).init(),Ce(e,t,0,B.sortObjects),l.finish(),!0===B.sortObjects&&l.sort(re,ne),le&&ue.beginShadows();var n=p.state.shadowsArray;be.render(n,e,t),p.setupLights(t),le&&ue.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==i&&this.setRenderTarget(i),P.render(l,e,t,r);var o=l.opaque,s=l.transparent;if(e.overrideMaterial){var a=e.overrideMaterial;o.length&&Ie(o,e,t,a),s.length&&Ie(s,e,t,a)}else o.length&&Ie(o,e,t),s.length&&Ie(s,e,t);e.onAfterRender(B,e,t),null!==V&&(b.updateRenderTargetMipmap(V),b.updateMultisampleRenderTarget(V)),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1),l=null,p=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(e){j!==e&&null===V&&d.bindFramebuffer(36160,e),j=e},this.getActiveCubeFace=function(){return z},this.getActiveMipmapLevel=function(){return $},this.getRenderTarget=function(){return V},this.setRenderTarget=function(e,t,i){V=e,z=t,$=i,e&&void 0===_.get(e).__webglFramebuffer&&b.setupRenderTarget(e);var r=j,n=!1;if(e){var o=_.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=o[t||0],n=!0):r=e.isWebGLMultisampleRenderTarget?_.get(e).__webglMultisampledFramebuffer:o,X.copy(e.viewport),Z.copy(e.scissor),K=e.scissorTest}else X.copy(se).multiplyScalar(ie).floor(),Z.copy(ae).multiplyScalar(ie).floor(),K=ce;if(U!==r&&(d.bindFramebuffer(36160,r),U=r),g.viewport(X),g.scissor(Z),g.setScissorTest(K),n){var s=_.get(e.texture);d.framebufferTexture2D(36160,36064,34069+(t||0),s.__webglTexture,i||0)}},this.readRenderTargetPixels=function(e,t,i,r,n,o,s){if(e&&e.isWebGLRenderTarget){var a=_.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(a=a[s]),a){var c=!1;a!==U&&(d.bindFramebuffer(36160,a),c=!0);try{var h=e.texture,u=h.format,l=h.type;if(u!==E&&L.convert(u)!==d.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(l===y||L.convert(l)===d.getParameter(35738)||l===w&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||l===A&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===d.checkFramebufferStatus(36160)?t>=0&&t<=e.width-r&&i>=0&&i<=e.height-n&&d.readPixels(t,i,r,n,L.convert(u),L.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&d.bindFramebuffer(36160,U)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,i){void 0===i&&(i=0);var r=Math.pow(2,-i),n=Math.floor(t.image.width*r),o=Math.floor(t.image.height*r),s=L.convert(t.format);b.setTexture2D(t,0),d.copyTexImage2D(3553,i,s,e.x,e.y,n,o,0),g.unbindTexture()},this.copyTextureToTexture=function(e,t,i,r){void 0===r&&(r=0);var n=t.image.width,o=t.image.height,s=L.convert(i.format),a=L.convert(i.type);b.setTexture2D(i,0),t.isDataTexture?d.texSubImage2D(3553,r,e.x,e.y,n,o,s,a,t.image.data):t.isCompressedTexture?d.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):d.texSubImage2D(3553,r,e.x,e.y,s,a,t.image),0===r&&i.generateMipmaps&&d.generateMipmap(3553),g.unbindTexture()},this.initTexture=function(e){b.setTexture2D(e,0),g.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Vn(e,t){this.name="",this.color=new wt(e),this.density=void 0!==t?t:25e-5}function Un(e,t,i){this.name="",this.color=new wt(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3}function Gn(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=$,this.updateRange={offset:0,count:-1},this.version=0}kn.prototype=Object.assign(Object.create(Ci.prototype),{constructor:kn,isArrayCamera:!0}),Bn.prototype=Object.assign(Object.create(Pe.prototype),{constructor:Bn,isGroup:!0}),Object.assign(Fn.prototype,{constructor:Fn,getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new Bn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new Bn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),this},update:function(e,t,i){var r=null,n=null,o=this._targetRay,s=this._grip;return e&&(null!==o&&null!==(r=t.getPose(e.targetRaySpace,i))&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale)),null!==s&&e.gripSpace&&null!==(n=t.getPose(e.gripSpace,i))&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale))),null!==o&&(o.visible=null!==r),null!==s&&(s.visible=null!==n),this}}),Object.assign(jn.prototype,U.prototype),Object.assign(Vn.prototype,{isFogExp2:!0,clone:function(){return new Vn(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(Un.prototype,{isFog:!0,clone:function(){return new Un(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Gn.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(Gn.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,i){e*=this.stride,i*=t.stride;for(var r=0,n=this.stride;r<n;r++)this.array[e+r]=t.array[i+r];return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(e){return this.onUploadCallback=e,this}});var Hn,qn=new oe;function Wn(e,t,i,r){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=!0===r}function Qn(e){Ct.call(this),this.type="SpriteMaterial",this.color=new wt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}Object.defineProperties(Wn.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(Wn.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(e){for(var t=0,i=this.data.count;t<i;t++)qn.x=this.getX(t),qn.y=this.getY(t),qn.z=this.getZ(t),qn.applyMatrix4(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this},clone:function(){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");for(var e=[],t=0;t<this.count;t++)for(var i=t*this.data.stride+this.offset,r=0;r<this.itemSize;r++)e.push(this.data.array[i+r]);return new Pt(new this.array.constructor(e),this.itemSize,this.normalized)},toJSON:function(){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");for(var e=[],t=0;t<this.count;t++)for(var i=t*this.data.stride+this.offset,r=0;r<this.itemSize;r++)e.push(this.data.array[i+r]);return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}}),Qn.prototype=Object.create(Ct.prototype),Qn.prototype.constructor=Qn,Qn.prototype.isSpriteMaterial=!0,Qn.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this};var Yn=new oe,Xn=new oe,Zn=new oe,Kn=new Q,Jn=new Q,eo=new de,to=new oe,io=new oe,ro=new oe,no=new Q,oo=new Q,so=new Q;function ao(e){if(Pe.call(this),this.type="Sprite",void 0===Hn){Hn=new Xt;var t=new Gn(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Hn.setIndex([0,1,2,0,2,3]),Hn.setAttribute("position",new Wn(t,3,0,!1)),Hn.setAttribute("uv",new Wn(t,2,3,!1))}this.geometry=Hn,this.material=void 0!==e?e:new Qn,this.center=new Q(.5,.5)}function co(e,t,i,r,n,o){Kn.subVectors(e,i).addScalar(.5).multiply(r),void 0!==n?(Jn.x=o*Kn.x-n*Kn.y,Jn.y=n*Kn.x+o*Kn.y):Jn.copy(Kn),e.copy(t),e.x+=Jn.x,e.y+=Jn.y,e.applyMatrix4(eo)}ao.prototype=Object.assign(Object.create(Pe.prototype),{constructor:ao,isSprite:!0,raycast:function(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Xn.setFromMatrixScale(this.matrixWorld),eo.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Zn.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Xn.multiplyScalar(-Zn.z);var i,r,n=this.material.rotation;0!==n&&(r=Math.cos(n),i=Math.sin(n));var o=this.center;co(to.set(-.5,-.5,0),Zn,o,Xn,i,r),co(io.set(.5,-.5,0),Zn,o,Xn,i,r),co(ro.set(.5,.5,0),Zn,o,Xn,i,r),no.set(0,0),oo.set(1,0),so.set(1,1);var s=e.ray.intersectTriangle(to,io,ro,!1,Yn);if(null!==s||(co(io.set(-.5,.5,0),Zn,o,Xn,i,r),oo.set(0,1),null!==(s=e.ray.intersectTriangle(to,ro,io,!1,Yn)))){var a=e.ray.origin.distanceTo(Yn);a<e.near||a>e.far||t.push({distance:a,point:Yn.clone(),uv:_t.getUV(Yn,to,io,ro,no,oo,so,new Q),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return Pe.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var ho,uo,lo,po,fo,mo=new oe,go=new oe;function vo(){Pe.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function _o(e,t){e&&e.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),fi.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new de,this.bindMatrixInverse=new de}vo.prototype=Object.assign(Object.create(Pe.prototype),{constructor:vo,isLOD:!0,copy:function(e){Pe.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,r=t.length;i<r;i++){var n=t[i];this.addLevel(n.object.clone(),n.distance)}return this.autoUpdate=e.autoUpdate,this},addLevel:function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var i=this.levels,r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,object:e}),this.add(e),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(e){var t=this.levels;if(t.length>0){for(var i=1,r=t.length;i<r&&!(e<t[i].distance);i++);return t[i-1].object}return null},raycast:function(e,t){if(this.levels.length>0){mo.setFromMatrixPosition(this.matrixWorld);var i=e.ray.origin.distanceTo(mo);this.getObjectForDistance(i).raycast(e,t)}},update:function(e){var t=this.levels;if(t.length>1){mo.setFromMatrixPosition(e.matrixWorld),go.setFromMatrixPosition(this.matrixWorld);var i=mo.distanceTo(go)/e.zoom;t[0].object.visible=!0;for(var r=1,n=t.length;r<n&&i>=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;r<n;r++)t[r].object.visible=!1}},toJSON:function(e){var t=Pe.prototype.toJSON.call(this,e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];for(var i=this.levels,r=0,n=i.length;r<n;r++){var o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance})}return t}}),_o.prototype=Object.assign(Object.create(fi.prototype),{constructor:_o,isSkinnedMesh:!0,bind:function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var e=new J,t=this.geometry.attributes.skinWeight,i=0,r=t.count;i<r;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);var n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}},updateMatrixWorld:function(e){fi.prototype.updateMatrixWorld.call(this,e),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)},boneTransform:(ho=new oe,uo=new J,lo=new J,po=new oe,fo=new de,function(e,t){var i=this.skeleton,r=this.geometry;uo.fromBufferAttribute(r.attributes.skinIndex,e),lo.fromBufferAttribute(r.attributes.skinWeight,e),ho.fromBufferAttribute(r.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(var n=0;n<4;n++){var o=lo.getComponent(n);if(0!==o){var s=uo.getComponent(n);fo.multiplyMatrices(i.bones[s].matrixWorld,i.boneInverses[s]),t.addScaledVector(po.copy(ho).applyMatrix4(fo),o)}}return t.applyMatrix4(this.bindMatrixInverse)})});var yo=new de,bo=new de;function xo(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),this.frame=-1,void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new de)}}function wo(){Pe.call(this),this.type="Bone"}Object.assign(xo.prototype,{calculateInverses:function(){this.boneInverses=[];for(var e=0,t=this.bones.length;e<t;e++){var i=new de;this.bones[e]&&i.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(i)}},pose:function(){var e,t,i;for(t=0,i=this.bones.length;t<i;t++)(e=this.bones[t])&&e.matrixWorld.getInverse(this.boneInverses[t]);for(t=0,i=this.bones.length;t<i;t++)(e=this.bones[t])&&(e.parent&&e.parent.isBone?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},update:function(){for(var e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture,n=0,o=e.length;n<o;n++){var s=e[n]?e[n].matrixWorld:bo;yo.multiplyMatrices(s,t[n]),yo.toArray(i,16*n)}void 0!==r&&(r.needsUpdate=!0)},clone:function(){return new xo(this.bones,this.boneInverses)},getBoneByName:function(e){for(var t=0,i=this.bones.length;t<i;t++){var r=this.bones[t];if(r.name===e)return r}},dispose:function(){this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=void 0)}}),wo.prototype=Object.assign(Object.create(Pe.prototype),{constructor:wo,isBone:!0});var Ao=new de,So=new de,Mo=[],Eo=new fi;function To(e,t,i){fi.call(this,e,t),this.instanceMatrix=new Pt(new Float32Array(16*i),16),this.count=i,this.frustumCulled=!1}function Co(e){Ct.call(this),this.type="LineBasicMaterial",this.color=new wt(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(e)}To.prototype=Object.assign(Object.create(fi.prototype),{constructor:To,isInstancedMesh:!0,getMatrixAt:function(e,t){t.fromArray(this.instanceMatrix.array,16*e)},raycast:function(e,t){var i=this.matrixWorld,r=this.count;if(Eo.geometry=this.geometry,Eo.material=this.material,void 0!==Eo.material)for(var n=0;n<r;n++){this.getMatrixAt(n,Ao),So.multiplyMatrices(i,Ao),Eo.matrixWorld=So,Eo.raycast(e,Mo);for(var o=0,s=Mo.length;o<s;o++){var a=Mo[o];a.instanceId=n,a.object=this,t.push(a)}Mo.length=0}},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,16*e)},updateMorphTargets:function(){}}),Co.prototype=Object.create(Ct.prototype),Co.prototype.constructor=Co,Co.prototype.isLineBasicMaterial=!0,Co.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.morphTargets=e.morphTargets,this};var Io=new oe,No=new oe,Po=new de,Ro=new rt,Oo=new Ye;function Do(e,t,i){1===i&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),Pe.call(this),this.type="Line",this.geometry=void 0!==e?e:new Xt,this.material=void 0!==t?t:new Co,this.updateMorphTargets()}Do.prototype=Object.assign(Object.create(Pe.prototype),{constructor:Do,isLine:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,i=[0],r=1,n=t.count;r<n;r++)Io.fromBufferAttribute(t,r-1),No.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Io.distanceTo(No);e.setAttribute("lineDistance",new jt(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry){var o=e.vertices;(i=e.lineDistances)[0]=0;for(r=1,n=o.length;r<n;r++)i[r]=i[r-1],i[r]+=o[r-1].distanceTo(o[r])}return this},raycast:function(e,t){var i=this.geometry,r=this.matrixWorld,n=e.params.Line.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Oo.copy(i.boundingSphere),Oo.applyMatrix4(r),Oo.radius+=n,!1!==e.ray.intersectsSphere(Oo)){Po.getInverse(r),Ro.copy(e.ray).applyMatrix4(Po);var o=n/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,a=new oe,c=new oe,h=new oe,u=new oe,l=this&&this.isLineSegments?2:1;if(i.isBufferGeometry){var p=i.index,d=i.attributes.position.array;if(null!==p)for(var f=p.array,m=0,g=f.length-1;m<g;m+=l){var v=f[m],_=f[m+1];if(a.fromArray(d,3*v),c.fromArray(d,3*_),!(Ro.distanceSqToSegment(a,c,u,h)>s))u.applyMatrix4(this.matrixWorld),(x=e.ray.origin.distanceTo(u))<e.near||x>e.far||t.push({distance:x,point:h.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,g=d.length/3-1;m<g;m+=l){if(a.fromArray(d,3*m),c.fromArray(d,3*m+3),!(Ro.distanceSqToSegment(a,c,u,h)>s))u.applyMatrix4(this.matrixWorld),(x=e.ray.origin.distanceTo(u))<e.near||x>e.far||t.push({distance:x,point:h.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(i.isGeometry){var y=i.vertices,b=y.length;for(m=0;m<b-1;m+=l){var x;if(!(Ro.distanceSqToSegment(y[m],y[m+1],u,h)>s))u.applyMatrix4(this.matrixWorld),(x=e.ray.origin.distanceTo(u))<e.near||x>e.far||t.push({distance:x,point:h.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},updateMorphTargets:function(){var e,t,i,r=this.geometry;if(r.isBufferGeometry){var n=r.morphAttributes,o=Object.keys(n);if(o.length>0){var s=n[o[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;e<t;e++)i=s[e].name||String(e),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}else{var a=r.morphTargets;void 0!==a&&a.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Lo=new oe,ko=new oe;function Bo(e,t){Do.call(this,e,t),this.type="LineSegments"}function Fo(e,t){Do.call(this,e,t),this.type="LineLoop"}function jo(e){Ct.call(this),this.type="PointsMaterial",this.color=new wt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}Bo.prototype=Object.assign(Object.create(Do.prototype),{constructor:Bo,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,i=[],r=0,n=t.count;r<n;r+=2)Lo.fromBufferAttribute(t,r),ko.fromBufferAttribute(t,r+1),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+Lo.distanceTo(ko);e.setAttribute("lineDistance",new jt(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry){var o=e.vertices;for(i=e.lineDistances,r=0,n=o.length;r<n;r+=2)Lo.copy(o[r]),ko.copy(o[r+1]),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+Lo.distanceTo(ko)}return this}}),Fo.prototype=Object.assign(Object.create(Do.prototype),{constructor:Fo,isLineLoop:!0}),jo.prototype=Object.create(Ct.prototype),jo.prototype.constructor=jo,jo.prototype.isPointsMaterial=!0,jo.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this};var zo=new de,$o=new rt,Vo=new Ye,Uo=new oe;function Go(e,t){Pe.call(this),this.type="Points",this.geometry=void 0!==e?e:new Xt,this.material=void 0!==t?t:new jo,this.updateMorphTargets()}function Ho(e,t,i,r,n,o,s){var a=$o.distanceSqToPoint(e);if(a<i){var c=new oe;$o.closestPointToPoint(e,c),c.applyMatrix4(r);var h=n.ray.origin.distanceTo(c);if(h<n.near||h>n.far)return;o.push({distance:h,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,object:s})}}function qo(e,t,i,r,n,o,s,a,c){K.call(this,e,t,i,r,n,o,s,a,c),this.format=void 0!==s?s:M,this.minFilter=void 0!==o?o:v,this.magFilter=void 0!==n?n:v,this.generateMipmaps=!1}function Wo(e,t,i,r,n,o,s,a,c,h,u,l){K.call(this,null,o,s,a,c,h,r,n,u,l),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Qo(e,t,i,r,n,o,s,a,c){K.call(this,e,t,i,r,n,o,s,a,c),this.needsUpdate=!0}function Yo(e,t,i,r,n,o,s,a,c,h){if((h=void 0!==h?h:T)!==T&&h!==C)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===T&&(i=b),void 0===i&&h===C&&(i=S),K.call(this,null,r,n,o,s,a,h,i,c),this.image={width:e,height:t},this.magFilter=void 0!==s?s:f,this.minFilter=void 0!==a?a:f,this.flipY=!1,this.generateMipmaps=!1}function Xo(e){Xt.call(this),this.type="WireframeGeometry";var t,i,r,n,o,s,a,c,h,u,l=[],p=[0,0],d={},f=["a","b","c"];if(e&&e.isGeometry){var m=e.faces;for(t=0,r=m.length;t<r;t++){var g=m[t];for(i=0;i<3;i++)a=g[f[i]],c=g[f[(i+1)%3]],p[0]=Math.min(a,c),p[1]=Math.max(a,c),void 0===d[h=p[0]+","+p[1]]&&(d[h]={index1:p[0],index2:p[1]})}for(h in d)s=d[h],u=e.vertices[s.index1],l.push(u.x,u.y,u.z),u=e.vertices[s.index2],l.push(u.x,u.y,u.z)}else if(e&&e.isBufferGeometry){var v,_,y,b,x,w,A;if(u=new oe,null!==e.index){for(v=e.attributes.position,_=e.index,0===(y=e.groups).length&&(y=[{start:0,count:_.count,materialIndex:0}]),n=0,o=y.length;n<o;++n)for(t=x=(b=y[n]).start,r=x+b.count;t<r;t+=3)for(i=0;i<3;i++)a=_.getX(t+i),c=_.getX(t+(i+1)%3),p[0]=Math.min(a,c),p[1]=Math.max(a,c),void 0===d[h=p[0]+","+p[1]]&&(d[h]={index1:p[0],index2:p[1]});for(h in d)s=d[h],u.fromBufferAttribute(v,s.index1),l.push(u.x,u.y,u.z),u.fromBufferAttribute(v,s.index2),l.push(u.x,u.y,u.z)}else for(t=0,r=(v=e.attributes.position).count/3;t<r;t++)for(i=0;i<3;i++)w=3*t+i,u.fromBufferAttribute(v,w),l.push(u.x,u.y,u.z),A=3*t+(i+1)%3,u.fromBufferAttribute(v,A),l.push(u.x,u.y,u.z)}this.setAttribute("position",new jt(l,3))}function Zo(e,t,i){xi.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i},this.fromBufferGeometry(new Ko(e,t,i)),this.mergeVertices()}function Ko(e,t,i){Xt.call(this),this.type="ParametricBufferGeometry",this.parameters={func:e,slices:t,stacks:i};var r,n,o=[],s=[],a=[],c=[],h=1e-5,u=new oe,l=new oe,p=new oe,d=new oe,f=new oe;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var m=t+1;for(r=0;r<=i;r++){var g=r/i;for(n=0;n<=t;n++){var v=n/t;e(v,g,l),s.push(l.x,l.y,l.z),v-h>=0?(e(v-h,g,p),d.subVectors(l,p)):(e(v+h,g,p),d.subVectors(p,l)),g-h>=0?(e(v,g-h,p),f.subVectors(l,p)):(e(v,g+h,p),f.subVectors(p,l)),u.crossVectors(d,f).normalize(),a.push(u.x,u.y,u.z),c.push(v,g)}}for(r=0;r<i;r++)for(n=0;n<t;n++){var _=r*m+n,y=r*m+n+1,b=(r+1)*m+n+1,x=(r+1)*m+n;o.push(_,y,x),o.push(y,b,x)}this.setIndex(o),this.setAttribute("position",new jt(s,3)),this.setAttribute("normal",new jt(a,3)),this.setAttribute("uv",new jt(c,2))}function Jo(e,t,i,r){xi.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r},this.fromBufferGeometry(new es(e,t,i,r)),this.mergeVertices()}function es(e,t,i,r){Xt.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r},i=i||1;var n=[],o=[];function s(e,t,i,r){var n,o,s=Math.pow(2,r),c=[];for(n=0;n<=s;n++){c[n]=[];var h=e.clone().lerp(i,n/s),u=t.clone().lerp(i,n/s),l=s-n;for(o=0;o<=l;o++)c[n][o]=0===o&&n===s?h:h.clone().lerp(u,o/l)}for(n=0;n<s;n++)for(o=0;o<2*(s-n)-1;o++){var p=Math.floor(o/2);o%2==0?(a(c[n][p+1]),a(c[n+1][p]),a(c[n][p])):(a(c[n][p+1]),a(c[n+1][p+1]),a(c[n+1][p]))}}function a(e){n.push(e.x,e.y,e.z)}function c(t,i){var r=3*t;i.x=e[r+0],i.y=e[r+1],i.z=e[r+2]}function h(e,t,i,r){r<0&&1===e.x&&(o[t]=e.x-1),0===i.x&&0===i.z&&(o[t]=r/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}function l(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}!function(e){for(var i=new oe,r=new oe,n=new oe,o=0;o<t.length;o+=3)c(t[o+0],i),c(t[o+1],r),c(t[o+2],n),s(i,r,n,e)}(r=r||0),function(e){for(var t=new oe,i=0;i<n.length;i+=3)t.x=n[i+0],t.y=n[i+1],t.z=n[i+2],t.normalize().multiplyScalar(e),n[i+0]=t.x,n[i+1]=t.y,n[i+2]=t.z}(i),function(){for(var e=new oe,t=0;t<n.length;t+=3){e.x=n[t+0],e.y=n[t+1],e.z=n[t+2];var i=u(e)/2/Math.PI+.5,r=l(e)/Math.PI+.5;o.push(i,1-r)}(function(){for(var e=new oe,t=new oe,i=new oe,r=new oe,s=new Q,a=new Q,c=new Q,l=0,p=0;l<n.length;l+=9,p+=6){e.set(n[l+0],n[l+1],n[l+2]),t.set(n[l+3],n[l+4],n[l+5]),i.set(n[l+6],n[l+7],n[l+8]),s.set(o[p+0],o[p+1]),a.set(o[p+2],o[p+3]),c.set(o[p+4],o[p+5]),r.copy(e).add(t).add(i).divideScalar(3);var d=u(r);h(s,p+0,e,d),h(a,p+2,t,d),h(c,p+4,i,d)}})(),function(){for(var e=0;e<o.length;e+=6){var t=o[e+0],i=o[e+2],r=o[e+4],n=Math.max(t,i,r),s=Math.min(t,i,r);n>.9&&s<.1&&(t<.2&&(o[e+0]+=1),i<.2&&(o[e+2]+=1),r<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new jt(n,3)),this.setAttribute("normal",new jt(n.slice(),3)),this.setAttribute("uv",new jt(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function ts(e,t){xi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new is(e,t)),this.mergeVertices()}function is(e,t){es.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function rs(e,t){xi.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new ns(e,t)),this.mergeVertices()}function ns(e,t){es.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function os(e,t){xi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new ss(e,t)),this.mergeVertices()}function ss(e,t){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];es.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function as(e,t){xi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new cs(e,t)),this.mergeVertices()}function cs(e,t){var i=(1+Math.sqrt(5))/2,r=1/i,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r];es.call(this,n,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function hs(e,t,i,r,n,o){xi.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var s=new us(e,t,i,r,n);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals,this.fromBufferGeometry(s),this.mergeVertices()}function us(e,t,i,r,n){Xt.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},t=t||64,i=i||1,r=r||8,n=n||!1;var o=e.computeFrenetFrames(t,n);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var s,a,c=new oe,h=new oe,u=new Q,l=new oe,p=[],d=[],f=[],m=[];function g(n){l=e.getPointAt(n/t,l);var s=o.normals[n],u=o.binormals[n];for(a=0;a<=r;a++){var f=a/r*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);h.x=g*s.x+m*u.x,h.y=g*s.y+m*u.y,h.z=g*s.z+m*u.z,h.normalize(),d.push(h.x,h.y,h.z),c.x=l.x+i*h.x,c.y=l.y+i*h.y,c.z=l.z+i*h.z,p.push(c.x,c.y,c.z)}}!function(){for(s=0;s<t;s++)g(s);g(!1===n?t:0),function(){for(s=0;s<=t;s++)for(a=0;a<=r;a++)u.x=s/t,u.y=a/r,f.push(u.x,u.y)}(),function(){for(a=1;a<=t;a++)for(s=1;s<=r;s++){var e=(r+1)*(a-1)+(s-1),i=(r+1)*a+(s-1),n=(r+1)*a+s,o=(r+1)*(a-1)+s;m.push(e,i,o),m.push(i,n,o)}}()}(),this.setIndex(m),this.setAttribute("position",new jt(p,3)),this.setAttribute("normal",new jt(d,3)),this.setAttribute("uv",new jt(f,2))}function ls(e,t,i,r,n,o,s){xi.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:n,q:o},void 0!==s&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new ps(e,t,i,r,n,o)),this.mergeVertices()}function ps(e,t,i,r,n,o){Xt.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:n,q:o},e=e||1,t=t||.4,i=Math.floor(i)||64,r=Math.floor(r)||8,n=n||2,o=o||3;var s,a,c=[],h=[],u=[],l=[],p=new oe,d=new oe,f=new oe,m=new oe,g=new oe,v=new oe,_=new oe;for(s=0;s<=i;++s){var y=s/i*n*Math.PI*2;for(T(y,n,o,e,f),T(y+.01,n,o,e,m),v.subVectors(m,f),_.addVectors(m,f),g.crossVectors(v,_),_.crossVectors(g,v),g.normalize(),_.normalize(),a=0;a<=r;++a){var b=a/r*Math.PI*2,x=-t*Math.cos(b),w=t*Math.sin(b);p.x=f.x+(x*_.x+w*g.x),p.y=f.y+(x*_.y+w*g.y),p.z=f.z+(x*_.z+w*g.z),h.push(p.x,p.y,p.z),d.subVectors(p,f).normalize(),u.push(d.x,d.y,d.z),l.push(s/i),l.push(a/r)}}for(a=1;a<=i;a++)for(s=1;s<=r;s++){var A=(r+1)*(a-1)+(s-1),S=(r+1)*a+(s-1),M=(r+1)*a+s,E=(r+1)*(a-1)+s;c.push(A,S,E),c.push(S,M,E)}function T(e,t,i,r,n){var o=Math.cos(e),s=Math.sin(e),a=i/t*e,c=Math.cos(a);n.x=r*(2+c)*.5*o,n.y=r*(2+c)*s*.5,n.z=r*Math.sin(a)*.5}this.setIndex(c),this.setAttribute("position",new jt(h,3)),this.setAttribute("normal",new jt(u,3)),this.setAttribute("uv",new jt(l,2))}function ds(e,t,i,r,n){xi.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:n},this.fromBufferGeometry(new fs(e,t,i,r,n)),this.mergeVertices()}function fs(e,t,i,r,n){Xt.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:n},e=e||1,t=t||.4,i=Math.floor(i)||8,r=Math.floor(r)||6,n=n||2*Math.PI;var o,s,a=[],c=[],h=[],u=[],l=new oe,p=new oe,d=new oe;for(o=0;o<=i;o++)for(s=0;s<=r;s++){var f=s/r*n,m=o/i*Math.PI*2;p.x=(e+t*Math.cos(m))*Math.cos(f),p.y=(e+t*Math.cos(m))*Math.sin(f),p.z=t*Math.sin(m),c.push(p.x,p.y,p.z),l.x=e*Math.cos(f),l.y=e*Math.sin(f),d.subVectors(p,l).normalize(),h.push(d.x,d.y,d.z),u.push(s/r),u.push(o/i)}for(o=1;o<=i;o++)for(s=1;s<=r;s++){var g=(r+1)*o+s-1,v=(r+1)*(o-1)+s-1,_=(r+1)*(o-1)+s,y=(r+1)*o+s;a.push(g,v,y),a.push(v,_,y)}this.setIndex(a),this.setAttribute("position",new jt(c,3)),this.setAttribute("normal",new jt(h,3)),this.setAttribute("uv",new jt(u,2))}Go.prototype=Object.assign(Object.create(Pe.prototype),{constructor:Go,isPoints:!0,raycast:function(e,t){var i=this.geometry,r=this.matrixWorld,n=e.params.Points.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Vo.copy(i.boundingSphere),Vo.applyMatrix4(r),Vo.radius+=n,!1!==e.ray.intersectsSphere(Vo)){zo.getInverse(r),$o.copy(e.ray).applyMatrix4(zo);var o=n/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o;if(i.isBufferGeometry){var a=i.index,c=i.attributes.position.array;if(null!==a)for(var h=a.array,u=0,l=h.length;u<l;u++){var p=h[u];Uo.fromArray(c,3*p),Ho(Uo,p,s,r,e,t,this)}else{u=0;for(var d=c.length/3;u<d;u++)Uo.fromArray(c,3*u),Ho(Uo,u,s,r,e,t,this)}}else{var f=i.vertices;for(u=0,d=f.length;u<d;u++)Ho(f[u],u,s,r,e,t,this)}}},updateMorphTargets:function(){var e,t,i,r=this.geometry;if(r.isBufferGeometry){var n=r.morphAttributes,o=Object.keys(n);if(o.length>0){var s=n[o[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;e<t;e++)i=s[e].name||String(e),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}else{var a=r.morphTargets;void 0!==a&&a.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),qo.prototype=Object.assign(Object.create(K.prototype),{constructor:qo,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),Wo.prototype=Object.create(K.prototype),Wo.prototype.constructor=Wo,Wo.prototype.isCompressedTexture=!0,Qo.prototype=Object.create(K.prototype),Qo.prototype.constructor=Qo,Qo.prototype.isCanvasTexture=!0,Yo.prototype=Object.create(K.prototype),Yo.prototype.constructor=Yo,Yo.prototype.isDepthTexture=!0,Xo.prototype=Object.create(Xt.prototype),Xo.prototype.constructor=Xo,Zo.prototype=Object.create(xi.prototype),Zo.prototype.constructor=Zo,Ko.prototype=Object.create(Xt.prototype),Ko.prototype.constructor=Ko,Jo.prototype=Object.create(xi.prototype),Jo.prototype.constructor=Jo,es.prototype=Object.create(Xt.prototype),es.prototype.constructor=es,ts.prototype=Object.create(xi.prototype),ts.prototype.constructor=ts,is.prototype=Object.create(es.prototype),is.prototype.constructor=is,rs.prototype=Object.create(xi.prototype),rs.prototype.constructor=rs,ns.prototype=Object.create(es.prototype),ns.prototype.constructor=ns,os.prototype=Object.create(xi.prototype),os.prototype.constructor=os,ss.prototype=Object.create(es.prototype),ss.prototype.constructor=ss,as.prototype=Object.create(xi.prototype),as.prototype.constructor=as,cs.prototype=Object.create(es.prototype),cs.prototype.constructor=cs,hs.prototype=Object.create(xi.prototype),hs.prototype.constructor=hs,us.prototype=Object.create(Xt.prototype),us.prototype.constructor=us,us.prototype.toJSON=function(){var e=Xt.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},ls.prototype=Object.create(xi.prototype),ls.prototype.constructor=ls,ps.prototype=Object.create(Xt.prototype),ps.prototype.constructor=ps,ds.prototype=Object.create(xi.prototype),ds.prototype.constructor=ds,fs.prototype=Object.create(Xt.prototype),fs.prototype.constructor=fs;var ms=function(e,t,i){i=i||2;var r,n,o,s,a,c,h,u=t&&t.length,l=u?t[0]*i:e.length,p=gs(e,0,l,i,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(e,t,i,r){var n,o,s,a=[];for(n=0,o=t.length;n<o;n++)(s=gs(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1))===s.next&&(s.steiner=!0),a.push(Ts(s));for(a.sort(As),n=0;n<a.length;n++)Ss(a[n],i),i=vs(i,i.next);return i}(e,t,p,i)),e.length>80*i){r=o=e[0],n=s=e[1];for(var f=i;f<l;f+=i)(a=e[f])<r&&(r=a),(c=e[f+1])<n&&(n=c),a>o&&(o=a),c>s&&(s=c);h=0!==(h=Math.max(o-r,s-n))?1/h:0}return _s(p,d,i,r,n,h),d};function gs(e,t,i,r,n){var o,s;if(n===function(e,t,i,r){for(var n=0,o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}(e,t,i,r)>0)for(o=t;o<i;o+=r)s=Bs(o,e[o],e[o+1],s);else for(o=i-r;o>=t;o-=r)s=Bs(o,e[o],e[o+1],s);return s&&Ps(s,s.next)&&(Fs(s),s=s.next),s}function vs(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!Ps(r,r.next)&&0!==Ns(r.prev,r,r.next))r=r.next;else{if(Fs(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function _s(e,t,i,r,n,o,s){if(e){!s&&o&&function(e,t,i,r){var n=e;do{null===n.z&&(n.z=Es(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,s,a,c,h=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t<h&&(a++,r=r.nextZ);t++);for(c=h;a>0||c>0&&r;)0!==a&&(0===c||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,c--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,h*=2}while(s>1)}(n)}(e,r,n,o);for(var a,c,h=e;e.prev!==e.next;)if(a=e.prev,c=e.next,o?bs(e,r,n,o):ys(e))t.push(a.i/i),t.push(e.i/i),t.push(c.i/i),Fs(e),e=c.next,h=c.next;else if((e=c)===h){s?1===s?_s(e=xs(vs(e),t,i),t,i,r,n,o,2):2===s&&ws(e,t,i,r,n,o):_s(vs(e),t,i,r,n,o,1);break}}}function ys(e){var t=e.prev,i=e,r=e.next;if(Ns(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(Cs(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&Ns(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function bs(e,t,i,r){var n=e.prev,o=e,s=e.next;if(Ns(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,c=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,h=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,u=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,l=Es(a,c,t,i,r),p=Es(h,u,t,i,r),d=e.prevZ,f=e.nextZ;d&&d.z>=l&&f&&f.z<=p;){if(d!==e.prev&&d!==e.next&&Cs(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ns(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==e.prev&&f!==e.next&&Cs(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ns(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=l;){if(d!==e.prev&&d!==e.next&&Cs(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ns(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==e.prev&&f!==e.next&&Cs(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ns(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function xs(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!Ps(n,o)&&Rs(n,r,r.next,o)&&Ls(n,o)&&Ls(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),Fs(r),Fs(r.next),r=e=o),r=r.next}while(r!==e);return vs(r)}function ws(e,t,i,r,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Is(s,a)){var c=ks(s,a);return s=vs(s,s.next),c=vs(c,c.next),_s(s,t,i,r,n,o),void _s(c,t,i,r,n,o)}a=a.next}s=s.next}while(s!==e)}function As(e,t){return e.x-t.x}function Ss(e,t){if(t=function(e,t){var i,r=t,n=e.x,o=e.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!i)return null;if(n===s)return i;var c,h=i,u=i.x,l=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=u&&n!==r.x&&Cs(o<l?n:s,o,u,l,o<l?s:n,o,r.x,r.y)&&(c=Math.abs(o-r.y)/(n-r.x),Ls(r,e)&&(c<p||c===p&&(r.x>i.x||r.x===i.x&&Ms(i,r)))&&(i=r,p=c)),r=r.next}while(r!==h);return i}(e,t),t){var i=ks(t,e);vs(t,t.next),vs(i,i.next)}}function Ms(e,t){return Ns(e.prev,e,t.prev)<0&&Ns(t.next,e,e.next)<0}function Es(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ts(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Cs(e,t,i,r,n,o,s,a){return(n-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function Is(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Rs(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Ls(e,t)&&Ls(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(Ns(e.prev,e,t.prev)||Ns(e,t.prev,t))||Ps(e,t)&&Ns(e.prev,e,e.next)>0&&Ns(t.prev,t,t.next)>0)}function Ns(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Ps(e,t){return e.x===t.x&&e.y===t.y}function Rs(e,t,i,r){var n=Ds(Ns(e,t,i)),o=Ds(Ns(e,t,r)),s=Ds(Ns(i,r,e)),a=Ds(Ns(i,r,t));return n!==o&&s!==a||(!(0!==n||!Os(e,i,t))||(!(0!==o||!Os(e,r,t))||(!(0!==s||!Os(i,e,r))||!(0!==a||!Os(i,t,r)))))}function Os(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Ds(e){return e>0?1:e<0?-1:0}function Ls(e,t){return Ns(e.prev,e,e.next)<0?Ns(e,t,e.next)>=0&&Ns(e,e.prev,t)>=0:Ns(e,t,e.prev)<0||Ns(e,e.next,t)<0}function ks(e,t){var i=new js(e.i,e.x,e.y),r=new js(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Bs(e,t,i,r){var n=new js(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Fs(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 js(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var zs={area:function(e){for(var t=e.length,i=0,r=t-1,n=0;n<t;r=n++)i+=e[r].x*e[n].y-e[n].x*e[r].y;return.5*i},isClockWise:function(e){return zs.area(e)<0},triangulateShape:function(e,t){var i=[],r=[],n=[];$s(e),Vs(i,e);var o=e.length;t.forEach($s);for(var s=0;s<t.length;s++)r.push(o),o+=t[s].length,Vs(i,t[s]);var a=ms(i,r);for(s=0;s<a.length;s+=3)n.push(a.slice(s,s+3));return n}};function $s(e){var t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Vs(e,t){for(var i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}function Us(e,t){xi.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},this.fromBufferGeometry(new Gs(e,t)),this.mergeVertices()}function Gs(e,t){Xt.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];for(var i=this,r=[],n=[],o=0,s=e.length;o<s;o++){a(e[o])}function a(e){var o=[],s=void 0!==t.curveSegments?t.curveSegments:12,a=void 0!==t.steps?t.steps:1,c=void 0!==t.depth?t.depth:100,h=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:6,l=void 0!==t.bevelSize?t.bevelSize:u-2,p=void 0!==t.bevelOffset?t.bevelOffset:0,d=void 0!==t.bevelSegments?t.bevelSegments:3,f=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:Hs;void 0!==t.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),c=t.amount);var g,v,_,y,b,x,w,A,S=!1;f&&(g=f.getSpacedPoints(a),S=!0,h=!1,v=f.computeFrenetFrames(a,!1),_=new oe,y=new oe,b=new oe),h||(d=0,u=0,l=0,p=0);var M=e.extractPoints(s),E=M.shape,T=M.holes;if(!zs.isClockWise(E))for(E=E.reverse(),w=0,A=T.length;w<A;w++)x=T[w],zs.isClockWise(x)&&(T[w]=x.reverse());var C=zs.triangulateShape(E,T),I=E;for(w=0,A=T.length;w<A;w++)x=T[w],E=E.concat(x);function N(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(i).add(e)}var P,R,O,D,L,k,B=E.length,F=C.length;function j(e,t,i){var r,n,o,s=e.x-t.x,a=e.y-t.y,c=i.x-e.x,h=i.y-e.y,u=s*s+a*a,l=s*h-a*c;if(Math.abs(l)>Number.EPSILON){var p=Math.sqrt(u),d=Math.sqrt(c*c+h*h),f=t.x-a/p,m=t.y+s/p,g=((i.x-h/d-f)*h-(i.y+c/d-m)*c)/(s*h-a*c),v=(r=f+s*g-e.x)*r+(n=m+a*g-e.y)*n;if(v<=2)return new Q(r,n);o=Math.sqrt(v/2)}else{var _=!1;s>Number.EPSILON?c>Number.EPSILON&&(_=!0):s<-Number.EPSILON?c<-Number.EPSILON&&(_=!0):Math.sign(a)===Math.sign(h)&&(_=!0),_?(r=-a,n=s,o=Math.sqrt(u)):(r=s,n=a,o=Math.sqrt(u/2))}return new Q(r/o,n/o)}for(var z=[],$=0,V=I.length,U=V-1,G=$+1;$<V;$++,U++,G++)U===V&&(U=0),G===V&&(G=0),z[$]=j(I[$],I[U],I[G]);var H,q,W=[],Y=z.concat();for(w=0,A=T.length;w<A;w++){for(x=T[w],H=[],$=0,U=(V=x.length)-1,G=$+1;$<V;$++,U++,G++)U===V&&(U=0),G===V&&(G=0),H[$]=j(x[$],x[U],x[G]);W.push(H),Y=Y.concat(H)}for(P=0;P<d;P++){for(O=P/d,D=u*Math.cos(O*Math.PI/2),R=l*Math.sin(O*Math.PI/2)+p,$=0,V=I.length;$<V;$++)Z((L=N(I[$],z[$],R)).x,L.y,-D);for(w=0,A=T.length;w<A;w++)for(x=T[w],H=W[w],$=0,V=x.length;$<V;$++)Z((L=N(x[$],H[$],R)).x,L.y,-D)}for(R=l+p,$=0;$<B;$++)L=h?N(E[$],Y[$],R):E[$],S?(y.copy(v.normals[0]).multiplyScalar(L.x),_.copy(v.binormals[0]).multiplyScalar(L.y),b.copy(g[0]).add(y).add(_),Z(b.x,b.y,b.z)):Z(L.x,L.y,0);for(q=1;q<=a;q++)for($=0;$<B;$++)L=h?N(E[$],Y[$],R):E[$],S?(y.copy(v.normals[q]).multiplyScalar(L.x),_.copy(v.binormals[q]).multiplyScalar(L.y),b.copy(g[q]).add(y).add(_),Z(b.x,b.y,b.z)):Z(L.x,L.y,c/a*q);for(P=d-1;P>=0;P--){for(O=P/d,D=u*Math.cos(O*Math.PI/2),R=l*Math.sin(O*Math.PI/2)+p,$=0,V=I.length;$<V;$++)Z((L=N(I[$],z[$],R)).x,L.y,c+D);for(w=0,A=T.length;w<A;w++)for(x=T[w],H=W[w],$=0,V=x.length;$<V;$++)L=N(x[$],H[$],R),S?Z(L.x,L.y+g[a-1].y,g[a-1].x+D):Z(L.x,L.y,c+D)}function X(e,t){var i,r;for($=e.length;--$>=0;){i=$,(r=$-1)<0&&(r=e.length-1);var n=0,o=a+2*d;for(n=0;n<o;n++){var s=B*n,c=B*(n+1);J(t+i+s,t+r+s,t+r+c,t+i+c)}}}function Z(e,t,i){o.push(e),o.push(t),o.push(i)}function K(e,t,n){ee(e),ee(t),ee(n);var o=r.length/3,s=m.generateTopUV(i,r,o-3,o-2,o-1);te(s[0]),te(s[1]),te(s[2])}function J(e,t,n,o){ee(e),ee(t),ee(o),ee(t),ee(n),ee(o);var s=r.length/3,a=m.generateSideWallUV(i,r,s-6,s-3,s-2,s-1);te(a[0]),te(a[1]),te(a[3]),te(a[1]),te(a[2]),te(a[3])}function ee(e){r.push(o[3*e+0]),r.push(o[3*e+1]),r.push(o[3*e+2])}function te(e){n.push(e.x),n.push(e.y)}!function(){var e=r.length/3;if(h){var t=0,n=B*t;for($=0;$<F;$++)K((k=C[$])[2]+n,k[1]+n,k[0]+n);for(n=B*(t=a+2*d),$=0;$<F;$++)K((k=C[$])[0]+n,k[1]+n,k[2]+n)}else{for($=0;$<F;$++)K((k=C[$])[2],k[1],k[0]);for($=0;$<F;$++)K((k=C[$])[0]+B*a,k[1]+B*a,k[2]+B*a)}i.addGroup(e,r.length/3-e,0)}(),function(){var e=r.length/3,t=0;for(X(I,t),t+=I.length,w=0,A=T.length;w<A;w++)X(x=T[w],t),t+=x.length;i.addGroup(e,r.length/3-e,1)}()}this.setAttribute("position",new jt(r,3)),this.setAttribute("uv",new jt(n,2)),this.computeVertexNormals()}Us.prototype=Object.create(xi.prototype),Us.prototype.constructor=Us,Us.prototype.toJSON=function(){var e=xi.prototype.toJSON.call(this);return qs(this.parameters.shapes,this.parameters.options,e)},Gs.prototype=Object.create(Xt.prototype),Gs.prototype.constructor=Gs,Gs.prototype.toJSON=function(){var e=Xt.prototype.toJSON.call(this);return qs(this.parameters.shapes,this.parameters.options,e)};var Hs={generateTopUV:function(e,t,i,r,n){var o=t[3*i],s=t[3*i+1],a=t[3*r],c=t[3*r+1],h=t[3*n],u=t[3*n+1];return[new Q(o,s),new Q(a,c),new Q(h,u)]},generateSideWallUV:function(e,t,i,r,n,o){var s=t[3*i],a=t[3*i+1],c=t[3*i+2],h=t[3*r],u=t[3*r+1],l=t[3*r+2],p=t[3*n],d=t[3*n+1],f=t[3*n+2],m=t[3*o],g=t[3*o+1],v=t[3*o+2];return Math.abs(a-u)<.01?[new Q(s,1-c),new Q(h,1-l),new Q(p,1-f),new Q(m,1-v)]:[new Q(a,1-c),new Q(u,1-l),new Q(d,1-f),new Q(g,1-v)]}};function qs(e,t,i){if(i.shapes=[],Array.isArray(e))for(var r=0,n=e.length;r<n;r++){var o=e[r];i.shapes.push(o.uuid)}else i.shapes.push(e.uuid);return void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON()),i}function Ws(e,t){xi.call(this),this.type="TextGeometry",this.parameters={text:e,parameters:t},this.fromBufferGeometry(new Qs(e,t)),this.mergeVertices()}function Qs(e,t){var i=(t=t||{}).font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new xi;var r=i.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),Gs.call(this,r,t),this.type="TextBufferGeometry"}function Ys(e,t,i,r,n,o,s){xi.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new Xs(e,t,i,r,n,o,s)),this.mergeVertices()}function Xs(e,t,i,r,n,o,s){Xt.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:s},e=e||1,t=Math.max(3,Math.floor(t)||8),i=Math.max(2,Math.floor(i)||6),r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI,o=void 0!==o?o:0,s=void 0!==s?s:Math.PI;var a,c,h=Math.min(o+s,Math.PI),u=0,l=[],p=new oe,d=new oe,f=[],m=[],g=[],v=[];for(c=0;c<=i;c++){var _=[],y=c/i,b=0;for(0==c&&0==o?b=.5/t:c==i&&h==Math.PI&&(b=-.5/t),a=0;a<=t;a++){var x=a/t;p.x=-e*Math.cos(r+x*n)*Math.sin(o+y*s),p.y=e*Math.cos(o+y*s),p.z=e*Math.sin(r+x*n)*Math.sin(o+y*s),m.push(p.x,p.y,p.z),d.copy(p).normalize(),g.push(d.x,d.y,d.z),v.push(x+b,1-y),_.push(u++)}l.push(_)}for(c=0;c<i;c++)for(a=0;a<t;a++){var w=l[c][a+1],A=l[c][a],S=l[c+1][a],M=l[c+1][a+1];(0!==c||o>0)&&f.push(w,A,M),(c!==i-1||h<Math.PI)&&f.push(A,S,M)}this.setIndex(f),this.setAttribute("position",new jt(m,3)),this.setAttribute("normal",new jt(g,3)),this.setAttribute("uv",new jt(v,2))}function Zs(e,t,i,r,n,o){xi.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},this.fromBufferGeometry(new Ks(e,t,i,r,n,o)),this.mergeVertices()}function Ks(e,t,i,r,n,o){Xt.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},e=e||.5,t=t||1,n=void 0!==n?n:0,o=void 0!==o?o:2*Math.PI,i=void 0!==i?Math.max(3,i):8;var s,a,c,h=[],u=[],l=[],p=[],d=e,f=(t-e)/(r=void 0!==r?Math.max(1,r):1),m=new oe,g=new Q;for(a=0;a<=r;a++){for(c=0;c<=i;c++)s=n+c/i*o,m.x=d*Math.cos(s),m.y=d*Math.sin(s),u.push(m.x,m.y,m.z),l.push(0,0,1),g.x=(m.x/t+1)/2,g.y=(m.y/t+1)/2,p.push(g.x,g.y);d+=f}for(a=0;a<r;a++){var v=a*(i+1);for(c=0;c<i;c++){var _=s=c+v,y=s+i+1,b=s+i+2,x=s+1;h.push(_,y,x),h.push(y,b,x)}}this.setIndex(h),this.setAttribute("position",new jt(u,3)),this.setAttribute("normal",new jt(l,3)),this.setAttribute("uv",new jt(p,2))}function Js(e,t,i,r){xi.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},this.fromBufferGeometry(new ea(e,t,i,r)),this.mergeVertices()}function ea(e,t,i,r){Xt.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t)||12,i=i||0,r=r||2*Math.PI,r=W.clamp(r,0,2*Math.PI);var n,o,s,a=[],c=[],h=[],u=1/t,l=new oe,p=new Q;for(o=0;o<=t;o++){var d=i+o*u*r,f=Math.sin(d),m=Math.cos(d);for(s=0;s<=e.length-1;s++)l.x=e[s].x*f,l.y=e[s].y,l.z=e[s].x*m,c.push(l.x,l.y,l.z),p.x=o/t,p.y=s/(e.length-1),h.push(p.x,p.y)}for(o=0;o<t;o++)for(s=0;s<e.length-1;s++){var g=n=s+o*e.length,v=n+e.length,_=n+e.length+1,y=n+1;a.push(g,v,y),a.push(v,_,y)}if(this.setIndex(a),this.setAttribute("position",new jt(c,3)),this.setAttribute("uv",new jt(h,2)),this.computeVertexNormals(),r===2*Math.PI){var b=this.attributes.normal.array,x=new oe,w=new oe,A=new oe;for(n=t*e.length*3,o=0,s=0;o<e.length;o++,s+=3)x.x=b[s+0],x.y=b[s+1],x.z=b[s+2],w.x=b[n+s+0],w.y=b[n+s+1],w.z=b[n+s+2],A.addVectors(x,w).normalize(),b[s+0]=b[n+s+0]=A.x,b[s+1]=b[n+s+1]=A.y,b[s+2]=b[n+s+2]=A.z}}function ta(e,t){xi.call(this),this.type="ShapeGeometry","object"==typeof t&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),t=t.curveSegments),this.parameters={shapes:e,curveSegments:t},this.fromBufferGeometry(new ia(e,t)),this.mergeVertices()}function ia(e,t){Xt.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:t},t=t||12;var i=[],r=[],n=[],o=[],s=0,a=0;if(!1===Array.isArray(e))h(e);else for(var c=0;c<e.length;c++)h(e[c]),this.addGroup(s,a,c),s+=a,a=0;function h(e){var s,c,h,u=r.length/3,l=e.extractPoints(t),p=l.shape,d=l.holes;for(!1===zs.isClockWise(p)&&(p=p.reverse()),s=0,c=d.length;s<c;s++)h=d[s],!0===zs.isClockWise(h)&&(d[s]=h.reverse());var f=zs.triangulateShape(p,d);for(s=0,c=d.length;s<c;s++)h=d[s],p=p.concat(h);for(s=0,c=p.length;s<c;s++){var m=p[s];r.push(m.x,m.y,0),n.push(0,0,1),o.push(m.x,m.y)}for(s=0,c=f.length;s<c;s++){var g=f[s],v=g[0]+u,_=g[1]+u,y=g[2]+u;i.push(v,_,y),a+=3}}this.setIndex(i),this.setAttribute("position",new jt(r,3)),this.setAttribute("normal",new jt(n,3)),this.setAttribute("uv",new jt(o,2))}function ra(e,t){if(t.shapes=[],Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var n=e[i];t.shapes.push(n.uuid)}else t.shapes.push(e.uuid);return t}function na(e,t){Xt.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1;var i,r,n,o,s=[],a=Math.cos(W.DEG2RAD*t),c=[0,0],h={},u=["a","b","c"];e.isBufferGeometry?(o=new xi).fromBufferGeometry(e):o=e.clone(),o.mergeVertices(),o.computeFaceNormals();for(var l=o.vertices,p=o.faces,d=0,f=p.length;d<f;d++)for(var m=p[d],g=0;g<3;g++)i=m[u[g]],r=m[u[(g+1)%3]],c[0]=Math.min(i,r),c[1]=Math.max(i,r),void 0===h[n=c[0]+","+c[1]]?h[n]={index1:c[0],index2:c[1],face1:d,face2:void 0}:h[n].face2=d;for(n in h){var v=h[n];if(void 0===v.face2||p[v.face1].normal.dot(p[v.face2].normal)<=a){var _=l[v.index1];s.push(_.x,_.y,_.z),_=l[v.index2],s.push(_.x,_.y,_.z)}}this.setAttribute("position",new jt(s,3))}function oa(e,t,i,r,n,o,s,a){xi.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:s,thetaLength:a},this.fromBufferGeometry(new sa(e,t,i,r,n,o,s,a)),this.mergeVertices()}function sa(e,t,i,r,n,o,s,a){Xt.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:s,thetaLength:a};var c=this;e=void 0!==e?e:1,t=void 0!==t?t:1,i=i||1,r=Math.floor(r)||8,n=Math.floor(n)||1,o=void 0!==o&&o,s=void 0!==s?s:0,a=void 0!==a?a:2*Math.PI;var h=[],u=[],l=[],p=[],d=0,f=[],m=i/2,g=0;function v(i){var n,o,f,v=new Q,_=new oe,y=0,b=!0===i?e:t,x=!0===i?1:-1;for(o=d,n=1;n<=r;n++)u.push(0,m*x,0),l.push(0,x,0),p.push(.5,.5),d++;for(f=d,n=0;n<=r;n++){var w=n/r*a+s,A=Math.cos(w),S=Math.sin(w);_.x=b*S,_.y=m*x,_.z=b*A,u.push(_.x,_.y,_.z),l.push(0,x,0),v.x=.5*A+.5,v.y=.5*S*x+.5,p.push(v.x,v.y),d++}for(n=0;n<r;n++){var M=o+n,E=f+n;!0===i?h.push(E,E+1,M):h.push(E+1,E,M),y+=3}c.addGroup(g,y,!0===i?1:2),g+=y}!function(){var o,v,_=new oe,y=new oe,b=0,x=(t-e)/i;for(v=0;v<=n;v++){var w=[],A=v/n,S=A*(t-e)+e;for(o=0;o<=r;o++){var M=o/r,E=M*a+s,T=Math.sin(E),C=Math.cos(E);y.x=S*T,y.y=-A*i+m,y.z=S*C,u.push(y.x,y.y,y.z),_.set(T,x,C).normalize(),l.push(_.x,_.y,_.z),p.push(M,1-A),w.push(d++)}f.push(w)}for(o=0;o<r;o++)for(v=0;v<n;v++){var I=f[v][o],N=f[v+1][o],P=f[v+1][o+1],R=f[v][o+1];h.push(I,N,R),h.push(N,P,R),b+=6}c.addGroup(g,b,0),g+=b}(),!1===o&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new jt(u,3)),this.setAttribute("normal",new jt(l,3)),this.setAttribute("uv",new jt(p,2))}function aa(e,t,i,r,n,o,s){oa.call(this,0,e,t,i,r,n,o,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:s}}function ca(e,t,i,r,n,o,s){sa.call(this,0,e,t,i,r,n,o,s),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:s}}function ha(e,t,i,r){xi.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new ua(e,t,i,r)),this.mergeVertices()}function ua(e,t,i,r){Xt.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},e=e||1,t=void 0!==t?Math.max(3,t):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var n,o,s=[],a=[],c=[],h=[],u=new oe,l=new Q;for(a.push(0,0,0),c.push(0,0,1),h.push(.5,.5),o=0,n=3;o<=t;o++,n+=3){var p=i+o/t*r;u.x=e*Math.cos(p),u.y=e*Math.sin(p),a.push(u.x,u.y,u.z),c.push(0,0,1),l.x=(a[n]/e+1)/2,l.y=(a[n+1]/e+1)/2,h.push(l.x,l.y)}for(n=1;n<=t;n++)s.push(n,n+1,0);this.setIndex(s),this.setAttribute("position",new jt(a,3)),this.setAttribute("normal",new jt(c,3)),this.setAttribute("uv",new jt(h,2))}Ws.prototype=Object.create(xi.prototype),Ws.prototype.constructor=Ws,Qs.prototype=Object.create(Gs.prototype),Qs.prototype.constructor=Qs,Ys.prototype=Object.create(xi.prototype),Ys.prototype.constructor=Ys,Xs.prototype=Object.create(Xt.prototype),Xs.prototype.constructor=Xs,Zs.prototype=Object.create(xi.prototype),Zs.prototype.constructor=Zs,Ks.prototype=Object.create(Xt.prototype),Ks.prototype.constructor=Ks,Js.prototype=Object.create(xi.prototype),Js.prototype.constructor=Js,ea.prototype=Object.create(Xt.prototype),ea.prototype.constructor=ea,ta.prototype=Object.create(xi.prototype),ta.prototype.constructor=ta,ta.prototype.toJSON=function(){var e=xi.prototype.toJSON.call(this);return ra(this.parameters.shapes,e)},ia.prototype=Object.create(Xt.prototype),ia.prototype.constructor=ia,ia.prototype.toJSON=function(){var e=Xt.prototype.toJSON.call(this);return ra(this.parameters.shapes,e)},na.prototype=Object.create(Xt.prototype),na.prototype.constructor=na,oa.prototype=Object.create(xi.prototype),oa.prototype.constructor=oa,sa.prototype=Object.create(Xt.prototype),sa.prototype.constructor=sa,aa.prototype=Object.create(oa.prototype),aa.prototype.constructor=aa,ca.prototype=Object.create(sa.prototype),ca.prototype.constructor=ca,ha.prototype=Object.create(xi.prototype),ha.prototype.constructor=ha,ua.prototype=Object.create(Xt.prototype),ua.prototype.constructor=ua;var la=Object.freeze({__proto__:null,WireframeGeometry:Xo,ParametricGeometry:Zo,ParametricBufferGeometry:Ko,TetrahedronGeometry:ts,TetrahedronBufferGeometry:is,OctahedronGeometry:rs,OctahedronBufferGeometry:ns,IcosahedronGeometry:os,IcosahedronBufferGeometry:ss,DodecahedronGeometry:as,DodecahedronBufferGeometry:cs,PolyhedronGeometry:Jo,PolyhedronBufferGeometry:es,TubeGeometry:hs,TubeBufferGeometry:us,TorusKnotGeometry:ls,TorusKnotBufferGeometry:ps,TorusGeometry:ds,TorusBufferGeometry:fs,TextGeometry:Ws,TextBufferGeometry:Qs,SphereGeometry:Ys,SphereBufferGeometry:Xs,RingGeometry:Zs,RingBufferGeometry:Ks,PlaneGeometry:ji,PlaneBufferGeometry:zi,LatheGeometry:Js,LatheBufferGeometry:ea,ShapeGeometry:ta,ShapeBufferGeometry:ia,ExtrudeGeometry:Us,ExtrudeBufferGeometry:Gs,EdgesGeometry:na,ConeGeometry:aa,ConeBufferGeometry:ca,CylinderGeometry:oa,CylinderBufferGeometry:sa,CircleGeometry:ha,CircleBufferGeometry:ua,BoxGeometry:class extends xi{constructor(e,t,i,r,n,o){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:o},this.fromBufferGeometry(new wi(e,t,i,r,n,o)),this.mergeVertices()}},BoxBufferGeometry:wi});function pa(e){Ct.call(this),this.type="ShadowMaterial",this.color=new wt(0),this.transparent=!0,this.setValues(e)}function da(e){Ei.call(this,e),this.type="RawShaderMaterial"}function fa(e){Ct.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new wt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(e)}function ma(e){fa.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Q(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,this.sheen=null,this.transparency=0,this.setValues(e)}function ga(e){Ct.call(this),this.type="MeshPhongMaterial",this.color=new wt(16777215),this.specular=new wt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function va(e){Ct.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new wt(16777215),this.specular=new wt(1118481),this.shininess=30,this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function _a(e){Ct.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function ya(e){Ct.call(this),this.type="MeshLambertMaterial",this.color=new wt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function ba(e){Ct.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new wt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function xa(e){Co.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}pa.prototype=Object.create(Ct.prototype),pa.prototype.constructor=pa,pa.prototype.isShadowMaterial=!0,pa.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.color.copy(e.color),this},da.prototype=Object.create(Ei.prototype),da.prototype.constructor=da,da.prototype.isRawShaderMaterial=!0,fa.prototype=Object.create(Ct.prototype),fa.prototype.constructor=fa,fa.prototype.isMeshStandardMaterial=!0,fa.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.vertexTangents=e.vertexTangents,this},ma.prototype=Object.create(fa.prototype),ma.prototype.constructor=ma,ma.prototype.isMeshPhysicalMaterial=!0,ma.prototype.copy=function(e){return fa.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},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.reflectivity=e.reflectivity,e.sheen?this.sheen=(this.sheen||new wt).copy(e.sheen):this.sheen=null,this.transparency=e.transparency,this},ga.prototype=Object.create(Ct.prototype),ga.prototype.constructor=ga,ga.prototype.isMeshPhongMaterial=!0,ga.prototype.copy=function(e){return Ct.prototype.copy.call(this,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.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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},va.prototype=Object.create(Ct.prototype),va.prototype.constructor=va,va.prototype.isMeshToonMaterial=!0,va.prototype.copy=function(e){return Ct.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},_a.prototype=Object.create(Ct.prototype),_a.prototype.constructor=_a,_a.prototype.isMeshNormalMaterial=!0,_a.prototype.copy=function(e){return Ct.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},ya.prototype=Object.create(Ct.prototype),ya.prototype.constructor=ya,ya.prototype.isMeshLambertMaterial=!0,ya.prototype.copy=function(e){return Ct.prototype.copy.call(this,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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},ba.prototype=Object.create(Ct.prototype),ba.prototype.constructor=ba,ba.prototype.isMeshMatcapMaterial=!0,ba.prototype.copy=function(e){return Ct.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},xa.prototype=Object.create(Co.prototype),xa.prototype.constructor=xa,xa.prototype.isLineDashedMaterial=!0,xa.prototype.copy=function(e){return Co.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var wa=Object.freeze({__proto__:null,ShadowMaterial:pa,SpriteMaterial:Qn,RawShaderMaterial:da,ShaderMaterial:Ei,PointsMaterial:jo,MeshPhysicalMaterial:ma,MeshStandardMaterial:fa,MeshPhongMaterial:ga,MeshToonMaterial:va,MeshNormalMaterial:_a,MeshLambertMaterial:ya,MeshDepthMaterial:Nn,MeshDistanceMaterial:Pn,MeshBasicMaterial:It,MeshMatcapMaterial:ba,LineDashedMaterial:xa,LineBasicMaterial:Co,Material:Ct}),Aa={arraySlice:function(e,t,i){return Aa.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){for(var t=e.length,i=new Array(t),r=0;r!==t;++r)i[r]=r;return i.sort((function(t,i){return e[t]-e[i]})),i},sortedArray:function(e,t,i){for(var r=e.length,n=new e.constructor(r),o=0,s=0;s!==r;++o)for(var a=i[o]*t,c=0;c!==t;++c)n[s++]=e[a+c];return n},flattenJSON:function(e,t,i,r){for(var n=1,o=e[0];void 0!==o&&void 0===o[r];)o=e[n++];if(void 0!==o){var s=o[r];if(void 0!==s)if(Array.isArray(s))do{void 0!==(s=o[r])&&(t.push(o.time),i.push.apply(i,s)),o=e[n++]}while(void 0!==o);else if(void 0!==s.toArray)do{void 0!==(s=o[r])&&(t.push(o.time),s.toArray(i,i.length)),o=e[n++]}while(void 0!==o);else do{void 0!==(s=o[r])&&(t.push(o.time),i.push(s)),o=e[n++]}while(void 0!==o)}},subclip:function(e,t,i,r,n){n=n||30;var o=e.clone();o.name=t;for(var s=[],a=0;a<o.tracks.length;++a){for(var c=o.tracks[a],h=c.getValueSize(),u=[],l=[],p=0;p<c.times.length;++p){var d=c.times[p]*n;if(!(d<i||d>=r)){u.push(c.times[p]);for(var f=0;f<h;++f)l.push(c.values[p*h+f])}}0!==u.length&&(c.times=Aa.convertArray(u,c.times.constructor),c.values=Aa.convertArray(l,c.values.constructor),s.push(c))}o.tracks=s;var m=1/0;for(a=0;a<o.tracks.length;++a)m>o.tracks[a].times[0]&&(m=o.tracks[a].times[0]);for(a=0;a<o.tracks.length;++a)o.tracks[a].shift(-1*m);return o.resetDuration(),o},makeClipAdditive:function(e,t,i,r){void 0===t&&(t=0),void 0===i&&(i=e),(void 0===r||r<=0)&&(r=30);for(var n=e.tracks.length,o=t/r,s=0;s<n;++s){var a=i.tracks[s],c=a.ValueTypeName;if("bool"!==c&&"string"!==c){var h=e.tracks.find((function(e){return e.name===a.name&&e.ValueTypeName===c}));if(void 0!==h){var u,l=a.getValueSize(),p=a.times.length-1;if(o<=a.times[0])u=Aa.arraySlice(a.values,0,a.valueSize);else if(o>=a.times[p]){var d=p*l;u=Aa.arraySlice(a.values,d)}else{var f=a.createInterpolant();f.evaluate(o),u=f.resultBuffer}if("quaternion"===c)new ie(u[0],u[1],u[2],u[3]).normalize().conjugate().toArray(u);for(var m=h.times.length,g=0;g<m;++g){var v=g*l;if("quaternion"===c)ie.multiplyQuaternionsFlat(h.values,v,u,0,h.values,v);else for(var _=0;_<l;++_)h.values[v+_]-=u[_]}}}}return e.blendMode=2501,e}};function Sa(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i}function Ma(e,t,i,r){Sa.call(this,e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Ea(e,t,i,r){Sa.call(this,e,t,i,r)}function Ta(e,t,i,r){Sa.call(this,e,t,i,r)}function Ca(e,t,i,r){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Aa.convertArray(t,this.TimeBufferType),this.values=Aa.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}function Ia(e,t,i){Ca.call(this,e,t,i)}function Na(e,t,i,r){Ca.call(this,e,t,i,r)}function Pa(e,t,i,r){Ca.call(this,e,t,i,r)}function Ra(e,t,i,r){Sa.call(this,e,t,i,r)}function Oa(e,t,i,r){Ca.call(this,e,t,i,r)}function Da(e,t,i,r){Ca.call(this,e,t,i,r)}function La(e,t,i,r){Ca.call(this,e,t,i,r)}function ka(e,t,i,r){this.name=e,this.tracks=i,this.duration=void 0!==t?t:-1,this.blendMode=void 0!==r?r:L,this.uuid=W.generateUUID(),this.duration<0&&this.resetDuration()}function Ba(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Pa;case"vector":case"vector2":case"vector3":case"vector4":return La;case"color":return Na;case"quaternion":return Oa;case"bool":case"boolean":return Ia;case"string":return Da}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){var i=[],r=[];Aa.flattenJSON(e.keys,i,r,"value"),e.times=i,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}Object.assign(Sa.prototype,{evaluate:function(e){var t=this.parameterPositions,i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{var o;i:{r:if(!(e<r)){for(var s=i+2;;){if(void 0===r){if(e<n)break r;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,n)}if(i===s)break;if(n=r,e<(r=t[++i]))break t}o=t.length;break i}if(e>=n)break e;var a=t[1];e<a&&(i=2,n=a);for(s=i-2;;){if(void 0===n)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(i===s)break;if(r=n,e>=(n=t[--i-1]))break t}o=i,i=0}for(;i<o;){var c=i+o>>>1;e<t[c]?o=c:i=c+1}if(r=t[i],void 0===(n=t[i-1]))return this._cachedIndex=0,this.beforeStart_(0,e,r);if(void 0===r)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,n,e)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,e,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){for(var t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=e*r,o=0;o!==r;++o)t[o]=i[n+o];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Sa.prototype,{beforeStart_:Sa.prototype.copySampleValue_,afterEnd_:Sa.prototype.copySampleValue_}),Ma.prototype=Object.assign(Object.create(Sa.prototype),{constructor:Ma,DefaultSettings_:{endingStart:R,endingEnd:R},intervalChanged_:function(e,t,i){var r=this.parameterPositions,n=e-2,o=e+1,s=r[n],a=r[o];if(void 0===s)switch(this.getSettings_().endingStart){case O:n=e,s=2*t-i;break;case D:s=t+r[n=r.length-2]-r[n+1];break;default:n=e,s=i}if(void 0===a)switch(this.getSettings_().endingEnd){case O:o=e,a=2*i-t;break;case D:o=1,a=i+r[1]-r[0];break;default:o=e-1,a=t}var c=.5*(i-t),h=this.valueSize;this._weightPrev=c/(t-s),this._weightNext=c/(a-i),this._offsetPrev=n*h,this._offsetNext=o*h},interpolate_:function(e,t,i,r){for(var n=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,c=a-s,h=this._offsetPrev,u=this._offsetNext,l=this._weightPrev,p=this._weightNext,d=(i-t)/(r-t),f=d*d,m=f*d,g=-l*m+2*l*f-l*d,v=(1+l)*m+(-1.5-2*l)*f+(-.5+l)*d+1,_=(-1-p)*m+(1.5+p)*f+.5*d,y=p*m-p*f,b=0;b!==s;++b)n[b]=g*o[h+b]+v*o[c+b]+_*o[a+b]+y*o[u+b];return n}}),Ea.prototype=Object.assign(Object.create(Sa.prototype),{constructor:Ea,interpolate_:function(e,t,i,r){for(var n=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,c=a-s,h=(i-t)/(r-t),u=1-h,l=0;l!==s;++l)n[l]=o[c+l]*u+o[a+l]*h;return n}}),Ta.prototype=Object.assign(Object.create(Sa.prototype),{constructor:Ta,interpolate_:function(e){return this.copySampleValue_(e-1)}}),Object.assign(Ca,{toJSON:function(e){var t,i=e.constructor;if(void 0!==i.toJSON)t=i.toJSON(e);else{t={name:e.name,times:Aa.convertArray(e.times,Array),values:Aa.convertArray(e.values,Array)};var r=e.getInterpolation();r!==e.DefaultInterpolation&&(t.interpolation=r)}return t.type=e.ValueTypeName,t}}),Object.assign(Ca.prototype,{constructor:Ca,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:N,InterpolantFactoryMethodDiscrete:function(e){return new Ta(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new Ea(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new Ma(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){var t;switch(e){case I:t=this.InterpolantFactoryMethodDiscrete;break;case N:t=this.InterpolantFactoryMethodLinear;break;case P:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return I;case this.InterpolantFactoryMethodLinear:return N;case this.InterpolantFactoryMethodSmooth:return P}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(0!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]+=e;return this},scale:function(e){if(1!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]*=e;return this},trim:function(e,t){for(var i=this.times,r=i.length,n=0,o=r-1;n!==r&&i[n]<e;)++n;for(;-1!==o&&i[o]>t;)--o;if(++o,0!==n||o!==r){n>=o&&(n=(o=Math.max(o,1))-1);var s=this.getValueSize();this.times=Aa.arraySlice(i,n,o),this.values=Aa.arraySlice(this.values,n*s,o*s)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var i=this.times,r=this.values,n=i.length;0===n&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var o=null,s=0;s!==n;s++){var a=i[s];if("number"==typeof a&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,s,a),e=!1;break}if(null!==o&&o>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,s,a,o),e=!1;break}o=a}if(void 0!==r&&Aa.isTypedArray(r)){s=0;for(var c=r.length;s!==c;++s){var h=r[s];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,s,h),e=!1;break}}}return e},optimize:function(){for(var e=Aa.arraySlice(this.times),t=Aa.arraySlice(this.values),i=this.getValueSize(),r=this.getInterpolation()===P,n=1,o=e.length-1,s=1;s<o;++s){var a=!1,c=e[s];if(c!==e[s+1]&&(1!==s||c!==c[0]))if(r)a=!0;else for(var h=s*i,u=h-i,l=h+i,p=0;p!==i;++p){var d=t[h+p];if(d!==t[u+p]||d!==t[l+p]){a=!0;break}}if(a){if(s!==n){e[n]=e[s];var f=s*i,m=n*i;for(p=0;p!==i;++p)t[m+p]=t[f+p]}++n}}if(o>0){e[n]=e[o];for(f=o*i,m=n*i,p=0;p!==i;++p)t[m+p]=t[f+p];++n}return n!==e.length?(this.times=Aa.arraySlice(e,0,n),this.values=Aa.arraySlice(t,0,n*i)):(this.times=e,this.values=t),this},clone:function(){var e=Aa.arraySlice(this.times,0),t=Aa.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}),Ia.prototype=Object.assign(Object.create(Ca.prototype),{constructor:Ia,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:I,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Na.prototype=Object.assign(Object.create(Ca.prototype),{constructor:Na,ValueTypeName:"color"}),Pa.prototype=Object.assign(Object.create(Ca.prototype),{constructor:Pa,ValueTypeName:"number"}),Ra.prototype=Object.assign(Object.create(Sa.prototype),{constructor:Ra,interpolate_:function(e,t,i,r){for(var n=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,c=(i-t)/(r-t),h=a+s;a!==h;a+=4)ie.slerpFlat(n,0,o,a-s,o,a,c);return n}}),Oa.prototype=Object.assign(Object.create(Ca.prototype),{constructor:Oa,ValueTypeName:"quaternion",DefaultInterpolation:N,InterpolantFactoryMethodLinear:function(e){return new Ra(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),Da.prototype=Object.assign(Object.create(Ca.prototype),{constructor:Da,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:I,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),La.prototype=Object.assign(Object.create(Ca.prototype),{constructor:La,ValueTypeName:"vector"}),Object.assign(ka,{parse:function(e){for(var t=[],i=e.tracks,r=1/(e.fps||1),n=0,o=i.length;n!==o;++n)t.push(Ba(i[n]).scale(r));return new ka(e.name,e.duration,t,e.blendMode)},toJSON:function(e){for(var t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode},n=0,o=i.length;n!==o;++n)t.push(Ca.toJSON(i[n]));return r},CreateFromMorphTargetSequence:function(e,t,i,r){for(var n=t.length,o=[],s=0;s<n;s++){var a=[],c=[];a.push((s+n-1)%n,s,(s+1)%n),c.push(0,1,0);var h=Aa.getKeyframeOrder(a);a=Aa.sortedArray(a,1,h),c=Aa.sortedArray(c,1,h),r||0!==a[0]||(a.push(n),c.push(c[0])),o.push(new Pa(".morphTargetInfluences["+t[s].name+"]",a,c).scale(1/i))}return new ka(e,-1,o)},findByName:function(e,t){var i=e;if(!Array.isArray(e)){var r=e;i=r.geometry&&r.geometry.animations||r.animations}for(var n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null},CreateClipsFromMorphTargetSequences:function(e,t,i){for(var r={},n=/^([\w-]*?)([\d]+)$/,o=0,s=e.length;o<s;o++){var a=e[o],c=a.name.match(n);if(c&&c.length>1){var h=r[l=c[1]];h||(r[l]=h=[]),h.push(a)}}var u=[];for(var l in r)u.push(ka.CreateFromMorphTargetSequence(l,r[l],t,i));return u},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(e,t,i,r,n){if(0!==i.length){var o=[],s=[];Aa.flattenJSON(i,o,s,r),0!==o.length&&n.push(new e(t,o,s))}},r=[],n=e.name||"default",o=e.length||-1,s=e.fps||30,a=e.blendMode,c=e.hierarchy||[],h=0;h<c.length;h++){var u=c[h].keys;if(u&&0!==u.length)if(u[0].morphTargets){for(var l={},p=0;p<u.length;p++)if(u[p].morphTargets)for(var d=0;d<u[p].morphTargets.length;d++)l[u[p].morphTargets[d]]=-1;for(var f in l){var m=[],g=[];for(d=0;d!==u[p].morphTargets.length;++d){var v=u[p];m.push(v.time),g.push(v.morphTarget===f?1:0)}r.push(new Pa(".morphTargetInfluence["+f+"]",m,g))}o=l.length*(s||1)}else{var _=".bones["+t[h].name+"]";i(La,_+".position",u,"pos",r),i(Oa,_+".quaternion",u,"rot",r),i(La,_+".scale",u,"scl",r)}}return 0===r.length?null:new ka(n,o,r,a)}}),Object.assign(ka.prototype,{resetDuration:function(){for(var e=0,t=0,i=this.tracks.length;t!==i;++t){var r=this.tracks[t];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this},trim:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},validate:function(){for(var e=!0,t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e},optimize:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this},clone:function(){for(var e=[],t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new ka(this.name,this.duration,e,this.blendMode)}});var Fa={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={}}};function ja(e,t,i){var r=this,n=!1,o=0,s=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){s++,!1===n&&void 0!==r.onStart&&r.onStart(e,o,s),n=!0},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,s),o===s&&(n=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return a?a(e):e},this.setURLModifier=function(e){return a=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){var t=c.indexOf(e);return-1!==t&&c.splice(t,2),this},this.getHandler=function(e){for(var t=0,i=c.length;t<i;t+=2){var r=c[t],n=c[t+1];if(r.global&&(r.lastIndex=0),r.test(e))return n}return null}}var za=new ja;function $a(e){this.manager=void 0!==e?e:za,this.crossOrigin="anonymous",this.path="",this.resourcePath="",this.requestHeader={}}Object.assign($a.prototype,{load:function(){},loadAsync:function(e,t){var i=this;return new Promise((function(r,n){i.load(e,r,t,n)}))},parse:function(){},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}});var Va={};function Ua(e){$a.call(this,e)}function Ga(e){$a.call(this,e)}function Ha(e){$a.call(this,e)}function qa(e){$a.call(this,e)}function Wa(e){$a.call(this,e)}function Qa(e){$a.call(this,e)}function Ya(e){$a.call(this,e)}function Xa(){this.type="Curve",this.arcLengthDivisions=200}function Za(e,t,i,r,n,o,s,a){Xa.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=i||1,this.yRadius=r||1,this.aStartAngle=n||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=s||!1,this.aRotation=a||0}function Ka(e,t,i,r,n,o){Za.call(this,e,t,i,i,r,n,o),this.type="ArcCurve"}function Ja(){var e=0,t=0,i=0,r=0;function n(n,o,s,a){e=n,t=s,i=-3*n+3*o-2*s-a,r=2*n-2*o+s+a}return{initCatmullRom:function(e,t,i,r,o){n(t,i,o*(i-e),o*(r-t))},initNonuniformCatmullRom:function(e,t,i,r,o,s,a){var c=(t-e)/o-(i-e)/(o+s)+(i-t)/s,h=(i-t)/s-(r-t)/(s+a)+(r-i)/a;n(t,i,c*=s,h*=s)},calc:function(n){var o=n*n;return e+t*n+i*o+r*(o*n)}}}Ua.prototype=Object.assign(Object.create($a.prototype),{constructor:Ua,load:function(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,o=Fa.get(e);if(void 0!==o)return n.manager.itemStart(e),setTimeout((function(){t&&t(o),n.manager.itemEnd(e)}),0),o;if(void 0===Va[e]){var s=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(s){var a=s[1],c=!!s[2],h=s[3];h=decodeURIComponent(h),c&&(h=atob(h));try{var u,l=(this.responseType||"").toLowerCase();switch(l){case"arraybuffer":case"blob":for(var p=new Uint8Array(h.length),d=0;d<h.length;d++)p[d]=h.charCodeAt(d);u="blob"===l?new Blob([p.buffer],{type:a}):p.buffer;break;case"document":var f=new DOMParser;u=f.parseFromString(h,a);break;case"json":u=JSON.parse(h);break;default:u=h}setTimeout((function(){t&&t(u),n.manager.itemEnd(e)}),0)}catch(t){setTimeout((function(){r&&r(t),n.manager.itemError(e),n.manager.itemEnd(e)}),0)}}else{Va[e]=[],Va[e].push({onLoad:t,onProgress:i,onError:r});var m=new XMLHttpRequest;for(var g in m.open("GET",e,!0),m.addEventListener("load",(function(t){var i=this.response,r=Va[e];if(delete Va[e],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Fa.add(e,i);for(var o=0,s=r.length;o<s;o++){(a=r[o]).onLoad&&a.onLoad(i)}n.manager.itemEnd(e)}else{for(o=0,s=r.length;o<s;o++){var a;(a=r[o]).onError&&a.onError(t)}n.manager.itemError(e),n.manager.itemEnd(e)}}),!1),m.addEventListener("progress",(function(t){for(var i=Va[e],r=0,n=i.length;r<n;r++){var o=i[r];o.onProgress&&o.onProgress(t)}}),!1),m.addEventListener("error",(function(t){var i=Va[e];delete Va[e];for(var r=0,o=i.length;r<o;r++){var s=i[r];s.onError&&s.onError(t)}n.manager.itemError(e),n.manager.itemEnd(e)}),!1),m.addEventListener("abort",(function(t){var i=Va[e];delete Va[e];for(var r=0,o=i.length;r<o;r++){var s=i[r];s.onError&&s.onError(t)}n.manager.itemError(e),n.manager.itemEnd(e)}),!1),void 0!==this.responseType&&(m.responseType=this.responseType),void 0!==this.withCredentials&&(m.withCredentials=this.withCredentials),m.overrideMimeType&&m.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)m.setRequestHeader(g,this.requestHeader[g]);m.send(null)}return n.manager.itemStart(e),m}Va[e].push({onLoad:t,onProgress:i,onError:r})},setResponseType:function(e){return this.responseType=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setMimeType:function(e){return this.mimeType=e,this}}),Ga.prototype=Object.assign(Object.create($a.prototype),{constructor:Ga,load:function(e,t,i,r){var n=this,o=new Ua(n.manager);o.setPath(n.path),o.load(e,(function(i){try{t(n.parse(JSON.parse(i)))}catch(t){r?r(t):console.error(t),n.manager.itemError(e)}}),i,r)},parse:function(e){for(var t=[],i=0;i<e.length;i++){var r=ka.parse(e[i]);t.push(r)}return t}}),Ha.prototype=Object.assign(Object.create($a.prototype),{constructor:Ha,load:function(e,t,i,r){var n=this,o=[],s=new Wo;s.image=o;var a=new Ua(this.manager);function c(c){a.load(e[c],(function(e){var i=n.parse(e,!0);o[c]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},6===(h+=1)&&(1===i.mipmapCount&&(s.minFilter=v),s.format=i.format,s.needsUpdate=!0,t&&t(s))}),i,r)}if(a.setPath(this.path),a.setResponseType("arraybuffer"),Array.isArray(e))for(var h=0,u=0,l=e.length;u<l;++u)c(u);else a.load(e,(function(e){var i=n.parse(e,!0);if(i.isCubemap)for(var r=i.mipmaps.length/i.mipmapCount,a=0;a<r;a++){o[a]={mipmaps:[]};for(var c=0;c<i.mipmapCount;c++)o[a].mipmaps.push(i.mipmaps[a*i.mipmapCount+c]),o[a].format=i.format,o[a].width=i.width,o[a].height=i.height}else s.image.width=i.width,s.image.height=i.height,s.mipmaps=i.mipmaps;1===i.mipmapCount&&(s.minFilter=v),s.format=i.format,s.needsUpdate=!0,t&&t(s)}),i,r);return s}}),qa.prototype=Object.assign(Object.create($a.prototype),{constructor:qa,load:function(e,t,i,r){var n=this,o=new Ri,s=new Ua(this.manager);return s.setResponseType("arraybuffer"),s.setPath(this.path),s.load(e,(function(e){var i=n.parse(e);i&&(void 0!==i.image?o.image=i.image:void 0!==i.data&&(o.image.width=i.width,o.image.height=i.height,o.image.data=i.data),o.wrapS=void 0!==i.wrapS?i.wrapS:p,o.wrapT=void 0!==i.wrapT?i.wrapT:p,o.magFilter=void 0!==i.magFilter?i.magFilter:v,o.minFilter=void 0!==i.minFilter?i.minFilter:v,o.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.format&&(o.format=i.format),void 0!==i.type&&(o.type=i.type),void 0!==i.mipmaps&&(o.mipmaps=i.mipmaps,o.minFilter=_),1===i.mipmapCount&&(o.minFilter=v),o.needsUpdate=!0,t&&t(o,i))}),i,r),o}}),Wa.prototype=Object.assign(Object.create($a.prototype),{constructor:Wa,load:function(e,t,i,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,o=Fa.get(e);if(void 0!==o)return n.manager.itemStart(e),setTimeout((function(){t&&t(o),n.manager.itemEnd(e)}),0),o;var s=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){s.removeEventListener("load",a,!1),s.removeEventListener("error",c,!1),Fa.add(e,this),t&&t(this),n.manager.itemEnd(e)}function c(t){s.removeEventListener("load",a,!1),s.removeEventListener("error",c,!1),r&&r(t),n.manager.itemError(e),n.manager.itemEnd(e)}return s.addEventListener("load",a,!1),s.addEventListener("error",c,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),n.manager.itemStart(e),s.src=e,s}}),Qa.prototype=Object.assign(Object.create($a.prototype),{constructor:Qa,load:function(e,t,i,r){var n=new er,o=new Wa(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);var s=0;function a(i){o.load(e[i],(function(e){n.images[i]=e,6===++s&&(n.needsUpdate=!0,t&&t(n))}),void 0,r)}for(var c=0;c<e.length;++c)a(c);return n}}),Ya.prototype=Object.assign(Object.create($a.prototype),{constructor:Ya,load:function(e,t,i,r){var n=new K,o=new Wa(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,(function(i){n.image=i;var r=e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/);n.format=r?M:E,n.needsUpdate=!0,void 0!==t&&t(n)}),i,r),n}}),Object.assign(Xa.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var i=this.getUtoTmapping(e);return this.getPoint(i,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,r=[],n=this.getPoint(0),o=0;for(r.push(0),i=1;i<=e;i++)o+=(t=this.getPoint(i/e)).distanceTo(n),r.push(o),n=t;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var i,r=this.getLengths(),n=0,o=r.length;i=t||e*r[o-1];for(var s,a=0,c=o-1;a<=c;)if((s=r[n=Math.floor(a+(c-a)/2)]-i)<0)a=n+1;else{if(!(s>0)){c=n;break}c=n-1}if(r[n=c]===i)return n/(o-1);var h=r[n];return(n+(i-h)/(r[n+1]-h))/(o-1)},getTangent:function(e,t){var i=1e-4,r=e-i,n=e+i;r<0&&(r=0),n>1&&(n=1);var o=this.getPoint(r),s=this.getPoint(n),a=t||(o.isVector2?new Q:new oe);return a.copy(s).sub(o).normalize(),a},getTangentAt:function(e,t){var i=this.getUtoTmapping(e);return this.getTangent(i,t)},computeFrenetFrames:function(e,t){var i,r,n,o=new oe,s=[],a=[],c=[],h=new oe,u=new de;for(i=0;i<=e;i++)r=i/e,s[i]=this.getTangentAt(r,new oe),s[i].normalize();a[0]=new oe,c[0]=new oe;var l=Number.MAX_VALUE,p=Math.abs(s[0].x),d=Math.abs(s[0].y),f=Math.abs(s[0].z);for(p<=l&&(l=p,o.set(1,0,0)),d<=l&&(l=d,o.set(0,1,0)),f<=l&&o.set(0,0,1),h.crossVectors(s[0],o).normalize(),a[0].crossVectors(s[0],h),c[0].crossVectors(s[0],a[0]),i=1;i<=e;i++)a[i]=a[i-1].clone(),c[i]=c[i-1].clone(),h.crossVectors(s[i-1],s[i]),h.length()>Number.EPSILON&&(h.normalize(),n=Math.acos(W.clamp(s[i-1].dot(s[i]),-1,1)),a[i].applyMatrix4(u.makeRotationAxis(h,n))),c[i].crossVectors(s[i],a[i]);if(!0===t)for(n=Math.acos(W.clamp(a[0].dot(a[e]),-1,1)),n/=e,s[0].dot(h.crossVectors(a[0],a[e]))>0&&(n=-n),i=1;i<=e;i++)a[i].applyMatrix4(u.makeRotationAxis(s[i],n*i)),c[i].crossVectors(s[i],a[i]);return{tangents:s,normals:a,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),Za.prototype=Object.create(Xa.prototype),Za.prototype.constructor=Za,Za.prototype.isEllipseCurve=!0,Za.prototype.getPoint=function(e,t){for(var i=t||new Q,r=2*Math.PI,n=this.aEndAngle-this.aStartAngle,o=Math.abs(n)<Number.EPSILON;n<0;)n+=r;for(;n>r;)n-=r;n<Number.EPSILON&&(n=o?0:r),!0!==this.aClockwise||o||(n===r?n=-r:n-=r);var s=this.aStartAngle+e*n,a=this.aX+this.xRadius*Math.cos(s),c=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){var h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),l=a-this.aX,p=c-this.aY;a=l*h-p*u+this.aX,c=l*u+p*h+this.aY}return i.set(a,c)},Za.prototype.copy=function(e){return Xa.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},Za.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},Za.prototype.fromJSON=function(e){return Xa.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},Ka.prototype=Object.create(Za.prototype),Ka.prototype.constructor=Ka,Ka.prototype.isArcCurve=!0;var ec=new oe,tc=new Ja,ic=new Ja,rc=new Ja;function nc(e,t,i,r){Xa.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=i||"centripetal",this.tension=r||.5}function oc(e,t,i,r,n){var o=.5*(r-t),s=.5*(n-i),a=e*e;return(2*i-2*r+o+s)*(e*a)+(-3*i+3*r-2*o-s)*a+o*e+i}function sc(e,t,i,r){return function(e,t){var i=1-e;return i*i*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,i)+function(e,t){return e*e*t}(e,r)}function ac(e,t,i,r,n){return function(e,t){var i=1-e;return i*i*i*t}(e,t)+function(e,t){var i=1-e;return 3*i*i*e*t}(e,i)+function(e,t){return 3*(1-e)*e*e*t}(e,r)+function(e,t){return e*e*e*t}(e,n)}function cc(e,t,i,r){Xa.call(this),this.type="CubicBezierCurve",this.v0=e||new Q,this.v1=t||new Q,this.v2=i||new Q,this.v3=r||new Q}function hc(e,t,i,r){Xa.call(this),this.type="CubicBezierCurve3",this.v0=e||new oe,this.v1=t||new oe,this.v2=i||new oe,this.v3=r||new oe}function uc(e,t){Xa.call(this),this.type="LineCurve",this.v1=e||new Q,this.v2=t||new Q}function lc(e,t){Xa.call(this),this.type="LineCurve3",this.v1=e||new oe,this.v2=t||new oe}function pc(e,t,i){Xa.call(this),this.type="QuadraticBezierCurve",this.v0=e||new Q,this.v1=t||new Q,this.v2=i||new Q}function dc(e,t,i){Xa.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new oe,this.v1=t||new oe,this.v2=i||new oe}function fc(e){Xa.call(this),this.type="SplineCurve",this.points=e||[]}nc.prototype=Object.create(Xa.prototype),nc.prototype.constructor=nc,nc.prototype.isCatmullRomCurve3=!0,nc.prototype.getPoint=function(e,t){var i,r,n,o,s=t||new oe,a=this.points,c=a.length,h=(c-(this.closed?0:1))*e,u=Math.floor(h),l=h-u;if(this.closed?u+=u>0?0:(Math.floor(Math.abs(u)/c)+1)*c:0===l&&u===c-1&&(u=c-2,l=1),this.closed||u>0?i=a[(u-1)%c]:(ec.subVectors(a[0],a[1]).add(a[0]),i=ec),r=a[u%c],n=a[(u+1)%c],this.closed||u+2<c?o=a[(u+2)%c]:(ec.subVectors(a[c-1],a[c-2]).add(a[c-1]),o=ec),"centripetal"===this.curveType||"chordal"===this.curveType){var p="chordal"===this.curveType?.5:.25,d=Math.pow(i.distanceToSquared(r),p),f=Math.pow(r.distanceToSquared(n),p),m=Math.pow(n.distanceToSquared(o),p);f<1e-4&&(f=1),d<1e-4&&(d=f),m<1e-4&&(m=f),tc.initNonuniformCatmullRom(i.x,r.x,n.x,o.x,d,f,m),ic.initNonuniformCatmullRom(i.y,r.y,n.y,o.y,d,f,m),rc.initNonuniformCatmullRom(i.z,r.z,n.z,o.z,d,f,m)}else"catmullrom"===this.curveType&&(tc.initCatmullRom(i.x,r.x,n.x,o.x,this.tension),ic.initCatmullRom(i.y,r.y,n.y,o.y,this.tension),rc.initCatmullRom(i.z,r.z,n.z,o.z,this.tension));return s.set(tc.calc(l),ic.calc(l),rc.calc(l)),s},nc.prototype.copy=function(e){Xa.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},nc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);e.points=[];for(var t=0,i=this.points.length;t<i;t++){var r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},nc.prototype.fromJSON=function(e){Xa.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var r=e.points[t];this.points.push((new oe).fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},cc.prototype=Object.create(Xa.prototype),cc.prototype.constructor=cc,cc.prototype.isCubicBezierCurve=!0,cc.prototype.getPoint=function(e,t){var i=t||new Q,r=this.v0,n=this.v1,o=this.v2,s=this.v3;return i.set(ac(e,r.x,n.x,o.x,s.x),ac(e,r.y,n.y,o.y,s.y)),i},cc.prototype.copy=function(e){return Xa.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},cc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},cc.prototype.fromJSON=function(e){return Xa.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},hc.prototype=Object.create(Xa.prototype),hc.prototype.constructor=hc,hc.prototype.isCubicBezierCurve3=!0,hc.prototype.getPoint=function(e,t){var i=t||new oe,r=this.v0,n=this.v1,o=this.v2,s=this.v3;return i.set(ac(e,r.x,n.x,o.x,s.x),ac(e,r.y,n.y,o.y,s.y),ac(e,r.z,n.z,o.z,s.z)),i},hc.prototype.copy=function(e){return Xa.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},hc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},hc.prototype.fromJSON=function(e){return Xa.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},uc.prototype=Object.create(Xa.prototype),uc.prototype.constructor=uc,uc.prototype.isLineCurve=!0,uc.prototype.getPoint=function(e,t){var i=t||new Q;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},uc.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},uc.prototype.getTangent=function(e,t){return(t||new Q).copy(this.v2).sub(this.v1).normalize()},uc.prototype.copy=function(e){return Xa.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},uc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},uc.prototype.fromJSON=function(e){return Xa.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},lc.prototype=Object.create(Xa.prototype),lc.prototype.constructor=lc,lc.prototype.isLineCurve3=!0,lc.prototype.getPoint=function(e,t){var i=t||new oe;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},lc.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},lc.prototype.copy=function(e){return Xa.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},lc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},lc.prototype.fromJSON=function(e){return Xa.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},pc.prototype=Object.create(Xa.prototype),pc.prototype.constructor=pc,pc.prototype.isQuadraticBezierCurve=!0,pc.prototype.getPoint=function(e,t){var i=t||new Q,r=this.v0,n=this.v1,o=this.v2;return i.set(sc(e,r.x,n.x,o.x),sc(e,r.y,n.y,o.y)),i},pc.prototype.copy=function(e){return Xa.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},pc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},pc.prototype.fromJSON=function(e){return Xa.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},dc.prototype=Object.create(Xa.prototype),dc.prototype.constructor=dc,dc.prototype.isQuadraticBezierCurve3=!0,dc.prototype.getPoint=function(e,t){var i=t||new oe,r=this.v0,n=this.v1,o=this.v2;return i.set(sc(e,r.x,n.x,o.x),sc(e,r.y,n.y,o.y),sc(e,r.z,n.z,o.z)),i},dc.prototype.copy=function(e){return Xa.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},dc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},dc.prototype.fromJSON=function(e){return Xa.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},fc.prototype=Object.create(Xa.prototype),fc.prototype.constructor=fc,fc.prototype.isSplineCurve=!0,fc.prototype.getPoint=function(e,t){var i=t||new Q,r=this.points,n=(r.length-1)*e,o=Math.floor(n),s=n-o,a=r[0===o?o:o-1],c=r[o],h=r[o>r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return i.set(oc(s,a.x,c.x,h.x,u.x),oc(s,a.y,c.y,h.y,u.y)),i},fc.prototype.copy=function(e){Xa.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var r=e.points[t];this.points.push(r.clone())}return this},fc.prototype.toJSON=function(){var e=Xa.prototype.toJSON.call(this);e.points=[];for(var t=0,i=this.points.length;t<i;t++){var r=this.points[t];e.points.push(r.toArray())}return e},fc.prototype.fromJSON=function(e){Xa.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var r=e.points[t];this.points.push((new Q).fromArray(r))}return this};var mc=Object.freeze({__proto__:null,ArcCurve:Ka,CatmullRomCurve3:nc,CubicBezierCurve:cc,CubicBezierCurve3:hc,EllipseCurve:Za,LineCurve:uc,LineCurve3:lc,QuadraticBezierCurve:pc,QuadraticBezierCurve3:dc,SplineCurve:fc});function gc(){Xa.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function vc(e){gc.call(this),this.type="Path",this.currentPoint=new Q,e&&this.setFromPoints(e)}function _c(e){vc.call(this,e),this.uuid=W.generateUUID(),this.type="Shape",this.holes=[]}function yc(e,t){Pe.call(this),this.type="Light",this.color=new wt(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function bc(e,t,i){yc.call(this,e,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(Pe.DefaultUp),this.updateMatrix(),this.groundColor=new wt(t)}function xc(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new Q(512,512),this.map=null,this.mapPass=null,this.matrix=new de,this._frustum=new Li,this._frameExtents=new Q(1,1),this._viewportCount=1,this._viewports=[new J(0,0,1,1)]}function wc(){xc.call(this,new Ci(50,1,.5,500))}function Ac(e,t,i,r,n,o){yc.call(this,e,t),this.type="SpotLight",this.position.copy(Pe.DefaultUp),this.updateMatrix(),this.target=new Pe,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new wc}function Sc(){xc.call(this,new Ci(90,1,.5,500)),this._frameExtents=new Q(4,2),this._viewportCount=6,this._viewports=[new J(2,1,1,1),new J(0,1,1,1),new J(3,1,1,1),new J(1,1,1,1),new J(3,0,1,1),new J(1,0,1,1)],this._cubeDirections=[new oe(1,0,0),new oe(-1,0,0),new oe(0,0,1),new oe(0,0,-1),new oe(0,1,0),new oe(0,-1,0)],this._cubeUps=[new oe(0,1,0),new oe(0,1,0),new oe(0,1,0),new oe(0,1,0),new oe(0,0,1),new oe(0,0,-1)]}function Mc(e,t,i,r){yc.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==i?i:0,this.decay=void 0!==r?r:1,this.shadow=new Sc}function Ec(e,t,i,r,n,o){Ti.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==e?e:-1,this.right=void 0!==t?t:1,this.top=void 0!==i?i:1,this.bottom=void 0!==r?r:-1,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function Tc(){xc.call(this,new Ec(-5,5,5,-5,.5,500))}function Cc(e,t){yc.call(this,e,t),this.type="DirectionalLight",this.position.copy(Pe.DefaultUp),this.updateMatrix(),this.target=new Pe,this.shadow=new Tc}function Ic(e,t){yc.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function Nc(e,t,i,r){yc.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==i?i:10,this.height=void 0!==r?r:10}function Pc(){this.coefficients=[];for(var e=0;e<9;e++)this.coefficients.push(new oe)}function Rc(e,t){yc.call(this,void 0,t),this.type="LightProbe",this.sh=void 0!==e?e:new Pc}function Oc(e){$a.call(this,e),this.textures={}}gc.prototype=Object.assign(Object.create(Xa.prototype),{constructor:gc,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new uc(t,e))},getPoint:function(e){for(var t=e*this.getLength(),i=this.getCurveLengths(),r=0;r<i.length;){if(i[r]>=t){var n=i[r]-t,o=this.curves[r],s=o.getLength(),a=0===s?0:1-n/s;return o.getPointAt(a)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e},getSpacedPoints:function(e){void 0===e&&(e=40);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t},getPoints:function(e){e=e||12;for(var t,i=[],r=0,n=this.curves;r<n.length;r++)for(var o=n[r],s=o&&o.isEllipseCurve?2*e:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,a=o.getPoints(s),c=0;c<a.length;c++){var h=a[c];t&&t.equals(h)||(i.push(h),t=h)}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},copy:function(e){Xa.prototype.copy.call(this,e),this.curves=[];for(var t=0,i=e.curves.length;t<i;t++){var r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this},toJSON:function(){var e=Xa.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(var t=0,i=this.curves.length;t<i;t++){var r=this.curves[t];e.curves.push(r.toJSON())}return e},fromJSON:function(e){Xa.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(var t=0,i=e.curves.length;t<i;t++){var r=e.curves[t];this.curves.push((new mc[r.type]).fromJSON(r))}return this}}),vc.prototype=Object.assign(Object.create(gc.prototype),{constructor:vc,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this},moveTo:function(e,t){return this.currentPoint.set(e,t),this},lineTo:function(e,t){var i=new uc(this.currentPoint.clone(),new Q(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this},quadraticCurveTo:function(e,t,i,r){var n=new pc(this.currentPoint.clone(),new Q(e,t),new Q(i,r));return this.curves.push(n),this.currentPoint.set(i,r),this},bezierCurveTo:function(e,t,i,r,n,o){var s=new cc(this.currentPoint.clone(),new Q(e,t),new Q(i,r),new Q(n,o));return this.curves.push(s),this.currentPoint.set(n,o),this},splineThru:function(e){var t=new fc([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this},arc:function(e,t,i,r,n,o){var s=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(e+s,t+a,i,r,n,o),this},absarc:function(e,t,i,r,n,o){return this.absellipse(e,t,i,i,r,n,o),this},ellipse:function(e,t,i,r,n,o,s,a){var c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,i,r,n,o,s,a),this},absellipse:function(e,t,i,r,n,o,s,a){var c=new Za(e,t,i,r,n,o,s,a);if(this.curves.length>0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(e){return gc.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=gc.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return gc.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),_c.prototype=Object.assign(Object.create(vc.prototype),{constructor:_c,getPointsHoles:function(e){for(var t=[],i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){vc.prototype.copy.call(this,e),this.holes=[];for(var t=0,i=e.holes.length;t<i;t++){var r=e.holes[t];this.holes.push(r.clone())}return this},toJSON:function(){var e=vc.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(var t=0,i=this.holes.length;t<i;t++){var r=this.holes[t];e.holes.push(r.toJSON())}return e},fromJSON:function(e){vc.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(var t=0,i=e.holes.length;t<i;t++){var r=e.holes[t];this.holes.push((new vc).fromJSON(r))}return this}}),yc.prototype=Object.assign(Object.create(Pe.prototype),{constructor:yc,isLight:!0,copy:function(e){return Pe.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=Pe.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),bc.prototype=Object.assign(Object.create(yc.prototype),{constructor:bc,isHemisphereLight:!0,copy:function(e){return yc.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(xc.prototype,{_projScreenMatrix:new de,_lightPositionWorld:new oe,_lookTarget:new oe,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){var t=this.camera,i=this.matrix,r=this._projScreenMatrix,n=this._lookTarget,o=this._lightPositionWorld;o.setFromMatrixPosition(e.matrixWorld),t.position.copy(o),n.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(n),t.updateMatrixWorld(),r.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),wc.prototype=Object.assign(Object.create(xc.prototype),{constructor:wc,isSpotLightShadow:!0,updateMatrices:function(e){var t=this.camera,i=2*W.RAD2DEG*e.angle,r=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;i===t.fov&&r===t.aspect&&n===t.far||(t.fov=i,t.aspect=r,t.far=n,t.updateProjectionMatrix()),xc.prototype.updateMatrices.call(this,e)}}),Ac.prototype=Object.assign(Object.create(yc.prototype),{constructor:Ac,isSpotLight:!0,copy:function(e){return yc.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Sc.prototype=Object.assign(Object.create(xc.prototype),{constructor:Sc,isPointLightShadow:!0,updateMatrices:function(e,t){void 0===t&&(t=0);var i=this.camera,r=this.matrix,n=this._lightPositionWorld,o=this._lookTarget,s=this._projScreenMatrix;n.setFromMatrixPosition(e.matrixWorld),i.position.copy(n),o.copy(i.position),o.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(o),i.updateMatrixWorld(),r.makeTranslation(-n.x,-n.y,-n.z),s.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(s)}}),Mc.prototype=Object.assign(Object.create(yc.prototype),{constructor:Mc,isPointLight:!0,copy:function(e){return yc.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),Ec.prototype=Object.assign(Object.create(Ti.prototype),{constructor:Ec,isOrthographicCamera:!0,copy:function(e,t){return Ti.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this},setViewOffset:function(e,t,i,r,n,o){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=i,this.view.offsetY=r,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,n=i-e,o=i+e,s=r+t,a=r-t;if(null!==this.view&&this.view.enabled){var c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o=(n+=c*this.view.offsetX)+c*this.view.width,a=(s-=h*this.view.offsetY)-h*this.view.height}this.projectionMatrix.makeOrthographic(n,o,s,a,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=Pe.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}),Tc.prototype=Object.assign(Object.create(xc.prototype),{constructor:Tc,isDirectionalLightShadow:!0,updateMatrices:function(e){xc.prototype.updateMatrices.call(this,e)}}),Cc.prototype=Object.assign(Object.create(yc.prototype),{constructor:Cc,isDirectionalLight:!0,copy:function(e){return yc.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Ic.prototype=Object.assign(Object.create(yc.prototype),{constructor:Ic,isAmbientLight:!0}),Nc.prototype=Object.assign(Object.create(yc.prototype),{constructor:Nc,isRectAreaLight:!0,copy:function(e){return yc.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){var t=yc.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}}),Object.assign(Pc.prototype,{isSphericalHarmonics3:!0,set:function(e){for(var t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this},zero:function(){for(var e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this},getAt:function(e,t){var i=e.x,r=e.y,n=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*n),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],i*r*1.092548),t.addScaledVector(o[5],r*n*1.092548),t.addScaledVector(o[6],.315392*(3*n*n-1)),t.addScaledVector(o[7],i*n*1.092548),t.addScaledVector(o[8],.546274*(i*i-r*r)),t},getIrradianceAt:function(e,t){var i=e.x,r=e.y,n=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],1.023328*r),t.addScaledVector(o[2],1.023328*n),t.addScaledVector(o[3],1.023328*i),t.addScaledVector(o[4],.858086*i*r),t.addScaledVector(o[5],.858086*r*n),t.addScaledVector(o[6],.743125*n*n-.247708),t.addScaledVector(o[7],.858086*i*n),t.addScaledVector(o[8],.429043*(i*i-r*r)),t},add:function(e){for(var t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this},addScaledSH:function(e,t){for(var i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this},scale:function(e){for(var t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this},lerp:function(e,t){for(var i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this},equals:function(e){for(var t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0},copy:function(e){return this.set(e.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(e,t){void 0===t&&(t=0);for(var i=this.coefficients,r=0;r<9;r++)i[r].fromArray(e,t+3*r);return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);for(var i=this.coefficients,r=0;r<9;r++)i[r].toArray(e,t+3*r);return e}}),Object.assign(Pc,{getBasisAt:function(e,t){var i=e.x,r=e.y,n=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*n,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*n,t[6]=.315392*(3*n*n-1),t[7]=1.092548*i*n,t[8]=.546274*(i*i-r*r)}}),Rc.prototype=Object.assign(Object.create(yc.prototype),{constructor:Rc,isLightProbe:!0,copy:function(e){return yc.prototype.copy.call(this,e),this.sh.copy(e.sh),this},fromJSON:function(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this},toJSON:function(e){var t=yc.prototype.toJSON.call(this,e);return t.object.sh=this.sh.toArray(),t}}),Oc.prototype=Object.assign(Object.create($a.prototype),{constructor:Oc,load:function(e,t,i,r){var n=this,o=new Ua(n.manager);o.setPath(n.path),o.load(e,(function(i){try{t(n.parse(JSON.parse(i)))}catch(t){r?r(t):console.error(t),n.manager.itemError(e)}}),i,r)},parse:function(e){var t=this.textures;function i(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}var r=new wa[e.type];if(void 0!==e.uuid&&(r.uuid=e.uuid),void 0!==e.name&&(r.name=e.name),void 0!==e.color&&r.color.setHex(e.color),void 0!==e.roughness&&(r.roughness=e.roughness),void 0!==e.metalness&&(r.metalness=e.metalness),void 0!==e.sheen&&(r.sheen=(new wt).setHex(e.sheen)),void 0!==e.emissive&&r.emissive.setHex(e.emissive),void 0!==e.specular&&r.specular.setHex(e.specular),void 0!==e.shininess&&(r.shininess=e.shininess),void 0!==e.clearcoat&&(r.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(r.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.fog&&(r.fog=e.fog),void 0!==e.flatShading&&(r.flatShading=e.flatShading),void 0!==e.blending&&(r.blending=e.blending),void 0!==e.combine&&(r.combine=e.combine),void 0!==e.side&&(r.side=e.side),void 0!==e.opacity&&(r.opacity=e.opacity),void 0!==e.transparent&&(r.transparent=e.transparent),void 0!==e.alphaTest&&(r.alphaTest=e.alphaTest),void 0!==e.depthTest&&(r.depthTest=e.depthTest),void 0!==e.depthWrite&&(r.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(r.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(r.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(r.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(r.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(r.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(r.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(r.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(r.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(r.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(r.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(r.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(r.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(r.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(r.rotation=e.rotation),1!==e.linewidth&&(r.linewidth=e.linewidth),void 0!==e.dashSize&&(r.dashSize=e.dashSize),void 0!==e.gapSize&&(r.gapSize=e.gapSize),void 0!==e.scale&&(r.scale=e.scale),void 0!==e.polygonOffset&&(r.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(r.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(r.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.skinning&&(r.skinning=e.skinning),void 0!==e.morphTargets&&(r.morphTargets=e.morphTargets),void 0!==e.morphNormals&&(r.morphNormals=e.morphNormals),void 0!==e.dithering&&(r.dithering=e.dithering),void 0!==e.vertexTangents&&(r.vertexTangents=e.vertexTangents),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.toneMapped&&(r.toneMapped=e.toneMapped),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),void 0!==e.uniforms)for(var n in e.uniforms){var o=e.uniforms[n];switch(r.uniforms[n]={},o.type){case"t":r.uniforms[n].value=i(o.value);break;case"c":r.uniforms[n].value=(new wt).setHex(o.value);break;case"v2":r.uniforms[n].value=(new Q).fromArray(o.value);break;case"v3":r.uniforms[n].value=(new oe).fromArray(o.value);break;case"v4":r.uniforms[n].value=(new J).fromArray(o.value);break;case"m3":r.uniforms[n].value=(new Y).fromArray(o.value);case"m4":r.uniforms[n].value=(new de).fromArray(o.value);break;default:r.uniforms[n].value=o.value}}if(void 0!==e.defines&&(r.defines=e.defines),void 0!==e.vertexShader&&(r.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(r.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(var s in e.extensions)r.extensions[s]=e.extensions[s];if(void 0!==e.shading&&(r.flatShading=1===e.shading),void 0!==e.size&&(r.size=e.size),void 0!==e.sizeAttenuation&&(r.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(r.map=i(e.map)),void 0!==e.matcap&&(r.matcap=i(e.matcap)),void 0!==e.alphaMap&&(r.alphaMap=i(e.alphaMap)),void 0!==e.bumpMap&&(r.bumpMap=i(e.bumpMap)),void 0!==e.bumpScale&&(r.bumpScale=e.bumpScale),void 0!==e.normalMap&&(r.normalMap=i(e.normalMap)),void 0!==e.normalMapType&&(r.normalMapType=e.normalMapType),void 0!==e.normalScale){var a=e.normalScale;!1===Array.isArray(a)&&(a=[a,a]),r.normalScale=(new Q).fromArray(a)}return void 0!==e.displacementMap&&(r.displacementMap=i(e.displacementMap)),void 0!==e.displacementScale&&(r.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(r.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(r.roughnessMap=i(e.roughnessMap)),void 0!==e.metalnessMap&&(r.metalnessMap=i(e.metalnessMap)),void 0!==e.emissiveMap&&(r.emissiveMap=i(e.emissiveMap)),void 0!==e.emissiveIntensity&&(r.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(r.specularMap=i(e.specularMap)),void 0!==e.envMap&&(r.envMap=i(e.envMap)),void 0!==e.envMapIntensity&&(r.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(r.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(r.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(r.lightMap=i(e.lightMap)),void 0!==e.lightMapIntensity&&(r.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(r.aoMap=i(e.aoMap)),void 0!==e.aoMapIntensity&&(r.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(r.gradientMap=i(e.gradientMap)),void 0!==e.clearcoatMap&&(r.clearcoatMap=i(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(r.clearcoatNormalScale=(new Q).fromArray(e.clearcoatNormalScale)),r},setTextures:function(e){return this.textures=e,this}});var Dc=function(e){var t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)};function Lc(){Xt.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function kc(e,t,i,r){"number"==typeof i&&(r=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),Pt.call(this,e,t,i),this.meshPerAttribute=r||1}function Bc(e){$a.call(this,e)}Lc.prototype=Object.assign(Object.create(Xt.prototype),{constructor:Lc,isInstancedBufferGeometry:!0,copy:function(e){return Xt.prototype.copy.call(this,e),this.instanceCount=e.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e=Xt.prototype.toJSON.call(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}),kc.prototype=Object.assign(Object.create(Pt.prototype),{constructor:kc,isInstancedBufferAttribute:!0,copy:function(e){return Pt.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},toJSON:function(){var e=Pt.prototype.toJSON.call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}),Bc.prototype=Object.assign(Object.create($a.prototype),{constructor:Bc,load:function(e,t,i,r){var n=this,o=new Ua(n.manager);o.setPath(n.path),o.load(e,(function(i){try{t(n.parse(JSON.parse(i)))}catch(t){r?r(t):console.error(t),n.manager.itemError(e)}}),i,r)},parse:function(e){var t=e.isInstancedBufferGeometry?new Lc:new Xt,i=e.data.index;if(void 0!==i){var r=new Fc[i.type](i.array);t.setIndex(new Pt(r,1))}var n=e.data.attributes;for(var o in n){var s=n[o],a=(r=new Fc[s.type](s.array),new(s.isInstancedBufferAttribute?kc:Pt)(r,s.itemSize,s.normalized));void 0!==s.name&&(a.name=s.name),t.setAttribute(o,a)}var c=e.data.morphAttributes;if(c)for(var o in c){for(var h=c[o],u=[],l=0,p=h.length;l<p;l++){s=h[l],a=new Pt(r=new Fc[s.type](s.array),s.itemSize,s.normalized);void 0!==s.name&&(a.name=s.name),u.push(a)}t.morphAttributes[o]=u}e.data.morphTargetsRelative&&(t.morphTargetsRelative=!0);var d=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==d){l=0;for(var f=d.length;l!==f;++l){var m=d[l];t.addGroup(m.start,m.count,m.materialIndex)}}var g=e.data.boundingSphere;if(void 0!==g){var v=new oe;void 0!==g.center&&v.fromArray(g.center),t.boundingSphere=new Ye(v,g.radius)}return e.name&&(t.name=e.name),e.userData&&(t.userData=e.userData),t}});var Fc={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function jc(e){$a.call(this,e)}jc.prototype=Object.assign(Object.create($a.prototype),{constructor:jc,load:function(e,t,i,r){var n=this,o=""===this.path?Dc(e):this.path;this.resourcePath=this.resourcePath||o;var s=new Ua(n.manager);s.setPath(this.path),s.load(e,(function(i){var o=null;try{o=JSON.parse(i)}catch(t){return void 0!==r&&r(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var s=o.metadata;void 0!==s&&void 0!==s.type&&"geometry"!==s.type.toLowerCase()?n.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e)}),i,r)},parse:function(e,t){var i=this.parseShape(e.shapes),r=this.parseGeometries(e.geometries,i),n=this.parseImages(e.images,(function(){void 0!==t&&t(a)})),o=this.parseTextures(e.textures,n),s=this.parseMaterials(e.materials,o),a=this.parseObject(e.object,r,s);return e.animations&&(a.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(a),a},parseShape:function(e){var t={};if(void 0!==e)for(var i=0,r=e.length;i<r;i++){var n=(new _c).fromJSON(e[i]);t[n.uuid]=n}return t},parseGeometries:function(e,t){var i={};if(void 0!==e)for(var r=new Bc,n=0,o=e.length;n<o;n++){var s,a=e[n];switch(a.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new la[a.type](a.width,a.height,a.widthSegments,a.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":s=new la[a.type](a.width,a.height,a.depth,a.widthSegments,a.heightSegments,a.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new la[a.type](a.radius,a.segments,a.thetaStart,a.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new la[a.type](a.radiusTop,a.radiusBottom,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":s=new la[a.type](a.radius,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new la[a.type](a.radius,a.widthSegments,a.heightSegments,a.phiStart,a.phiLength,a.thetaStart,a.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":s=new la[a.type](a.radius,a.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new la[a.type](a.innerRadius,a.outerRadius,a.thetaSegments,a.phiSegments,a.thetaStart,a.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new la[a.type](a.radius,a.tube,a.radialSegments,a.tubularSegments,a.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new la[a.type](a.radius,a.tube,a.tubularSegments,a.radialSegments,a.p,a.q);break;case"TubeGeometry":case"TubeBufferGeometry":s=new la[a.type]((new mc[a.path.type]).fromJSON(a.path),a.tubularSegments,a.radius,a.radialSegments,a.closed);break;case"LatheGeometry":case"LatheBufferGeometry":s=new la[a.type](a.points,a.segments,a.phiStart,a.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":s=new la[a.type](a.vertices,a.indices,a.radius,a.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":for(var c=[],h=0,u=a.shapes.length;h<u;h++){var l=t[a.shapes[h]];c.push(l)}s=new la[a.type](c,a.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":for(c=[],h=0,u=a.shapes.length;h<u;h++){l=t[a.shapes[h]];c.push(l)}var p=a.options.extrudePath;void 0!==p&&(a.options.extrudePath=(new mc[p.type]).fromJSON(p)),s=new la[a.type](c,a.options);break;case"BufferGeometry":case"InstancedBufferGeometry":s=r.parse(a);break;case"Geometry":console.error('THREE.ObjectLoader: Loading "Geometry" is not supported anymore.');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+a.type+'"');continue}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),!0===s.isBufferGeometry&&void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}return i},parseMaterials:function(e,t){var i={},r={};if(void 0!==e){var n=new Oc;n.setTextures(t);for(var o=0,s=e.length;o<s;o++){var a=e[o];if("MultiMaterial"===a.type){for(var c=[],h=0;h<a.materials.length;h++){var u=a.materials[h];void 0===i[u.uuid]&&(i[u.uuid]=n.parse(u)),c.push(i[u.uuid])}r[a.uuid]=c}else void 0===i[a.uuid]&&(i[a.uuid]=n.parse(a)),r[a.uuid]=i[a.uuid]}}return r},parseAnimations:function(e){for(var t=[],i=0;i<e.length;i++){var r=e[i],n=ka.parse(r);void 0!==r.uuid&&(n.uuid=r.uuid),t.push(n)}return t},parseImages:function(e,t){var i=this,r={};function n(e){return i.manager.itemStart(e),o.load(e,(function(){i.manager.itemEnd(e)}),void 0,(function(){i.manager.itemError(e),i.manager.itemEnd(e)}))}if(void 0!==e&&e.length>0){var o=new Wa(new ja(t));o.setCrossOrigin(this.crossOrigin);for(var s=0,a=e.length;s<a;s++){var c=e[s],h=c.url;if(Array.isArray(h)){r[c.uuid]=[];for(var u=0,l=h.length;u<l;u++){var p=h[u],d=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(p)?p:i.resourcePath+p;r[c.uuid].push(n(d))}}else{d=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c.url)?c.url:i.resourcePath+c.url;r[c.uuid]=n(d)}}}return r},parseTextures:function(e,t){function i(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var r={};if(void 0!==e)for(var n=0,o=e.length;n<o;n++){var s,a=e[n];void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===t[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image),(s=Array.isArray(t[a.image])?new er(t[a.image]):new K(t[a.image])).needsUpdate=!0,s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.mapping&&(s.mapping=i(a.mapping,$c)),void 0!==a.offset&&s.offset.fromArray(a.offset),void 0!==a.repeat&&s.repeat.fromArray(a.repeat),void 0!==a.center&&s.center.fromArray(a.center),void 0!==a.rotation&&(s.rotation=a.rotation),void 0!==a.wrap&&(s.wrapS=i(a.wrap[0],Vc),s.wrapT=i(a.wrap[1],Vc)),void 0!==a.format&&(s.format=a.format),void 0!==a.type&&(s.type=a.type),void 0!==a.encoding&&(s.encoding=a.encoding),void 0!==a.minFilter&&(s.minFilter=i(a.minFilter,Uc)),void 0!==a.magFilter&&(s.magFilter=i(a.magFilter,Uc)),void 0!==a.anisotropy&&(s.anisotropy=a.anisotropy),void 0!==a.flipY&&(s.flipY=a.flipY),void 0!==a.premultiplyAlpha&&(s.premultiplyAlpha=a.premultiplyAlpha),void 0!==a.unpackAlignment&&(s.unpackAlignment=a.unpackAlignment),r[a.uuid]=s}return r},parseObject:function(e,t,i){var r;function n(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function o(e){if(void 0!==e){if(Array.isArray(e)){for(var t=[],r=0,n=e.length;r<n;r++){var o=e[r];void 0===i[o]&&console.warn("THREE.ObjectLoader: Undefined material",o),t.push(i[o])}return t}return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),i[e]}}switch(e.type){case"Scene":r=new Re,void 0!==e.background&&Number.isInteger(e.background)&&(r.background=new wt(e.background)),void 0!==e.fog&&("Fog"===e.fog.type?r.fog=new Un(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(r.fog=new Vn(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":r=new Ci(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(r.focus=e.focus),void 0!==e.zoom&&(r.zoom=e.zoom),void 0!==e.filmGauge&&(r.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(r.filmOffset=e.filmOffset),void 0!==e.view&&(r.view=Object.assign({},e.view));break;case"OrthographicCamera":r=new Ec(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(r.zoom=e.zoom),void 0!==e.view&&(r.view=Object.assign({},e.view));break;case"AmbientLight":r=new Ic(e.color,e.intensity);break;case"DirectionalLight":r=new Cc(e.color,e.intensity);break;case"PointLight":r=new Mc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":r=new Nc(e.color,e.intensity,e.width,e.height);break;case"SpotLight":r=new Ac(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":r=new bc(e.color,e.groundColor,e.intensity);break;case"LightProbe":r=(new Rc).fromJSON(e);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":r=new fi(s=n(e.geometry),a=o(e.material));break;case"InstancedMesh":var s=n(e.geometry),a=o(e.material),c=e.count,h=e.instanceMatrix;(r=new To(s,a,c)).instanceMatrix=new Pt(new Float32Array(h.array),16);break;case"LOD":r=new vo;break;case"Line":r=new Do(n(e.geometry),o(e.material),e.mode);break;case"LineLoop":r=new Fo(n(e.geometry),o(e.material));break;case"LineSegments":r=new Bo(n(e.geometry),o(e.material));break;case"PointCloud":case"Points":r=new Go(n(e.geometry),o(e.material));break;case"Sprite":r=new ao(o(e.material));break;case"Group":r=new Bn;break;default:r=new Pe}if(r.uuid=e.uuid,void 0!==e.name&&(r.name=e.name),void 0!==e.matrix?(r.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(r.matrixAutoUpdate=e.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==e.position&&r.position.fromArray(e.position),void 0!==e.rotation&&r.rotation.fromArray(e.rotation),void 0!==e.quaternion&&r.quaternion.fromArray(e.quaternion),void 0!==e.scale&&r.scale.fromArray(e.scale)),void 0!==e.castShadow&&(r.castShadow=e.castShadow),void 0!==e.receiveShadow&&(r.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(r.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(r.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&r.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(r.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.frustumCulled&&(r.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(r.renderOrder=e.renderOrder),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.layers&&(r.layers.mask=e.layers),void 0!==e.children)for(var u=e.children,l=0;l<u.length;l++)r.add(this.parseObject(u[l],t,i));if("LOD"===e.type){void 0!==e.autoUpdate&&(r.autoUpdate=e.autoUpdate);for(var p=e.levels,d=0;d<p.length;d++){var f=p[d],m=r.getObjectByProperty("uuid",f.object);void 0!==m&&r.addLevel(m,f.distance)}}return r}});var zc,$c={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,SphericalReflectionMapping:305,CubeUVReflectionMapping:u,CubeUVRefractionMapping:307},Vc={RepeatWrapping:l,ClampToEdgeWrapping:p,MirroredRepeatWrapping:d},Uc={NearestFilter:f,NearestMipmapNearestFilter:m,NearestMipmapLinearFilter:g,LinearFilter:v,LinearMipmapNearestFilter:1007,LinearMipmapLinearFilter:_};function Gc(e){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),$a.call(this,e),this.options=void 0}function Hc(){this.type="ShapePath",this.color=new wt,this.subPaths=[],this.currentPath=null}function qc(e){this.type="Font",this.data=e}function Wc(e,t,i,r,n){var o=n.glyphs[e]||n.glyphs["?"];if(o){var s,a,c,h,u,l,p,d,f=new Hc;if(o.o)for(var m=o._cachedOutline||(o._cachedOutline=o.o.split(" ")),g=0,v=m.length;g<v;){switch(m[g++]){case"m":s=m[g++]*t+i,a=m[g++]*t+r,f.moveTo(s,a);break;case"l":s=m[g++]*t+i,a=m[g++]*t+r,f.lineTo(s,a);break;case"q":c=m[g++]*t+i,h=m[g++]*t+r,u=m[g++]*t+i,l=m[g++]*t+r,f.quadraticCurveTo(u,l,c,h);break;case"b":c=m[g++]*t+i,h=m[g++]*t+r,u=m[g++]*t+i,l=m[g++]*t+r,p=m[g++]*t+i,d=m[g++]*t+r,f.bezierCurveTo(u,l,p,d,c,h)}}return{offsetX:o.ha*t,path:f}}console.error('THREE.Font: character "'+e+'" does not exists in font family '+n.familyName+".")}function Qc(e){$a.call(this,e)}Gc.prototype=Object.assign(Object.create($a.prototype),{constructor:Gc,setOptions:function(e){return this.options=e,this},load:function(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,o=Fa.get(e);if(void 0!==o)return n.manager.itemStart(e),setTimeout((function(){t&&t(o),n.manager.itemEnd(e)}),0),o;fetch(e).then((function(e){return e.blob()})).then((function(e){return void 0===n.options?createImageBitmap(e):createImageBitmap(e,n.options)})).then((function(i){Fa.add(e,i),t&&t(i),n.manager.itemEnd(e)})).catch((function(t){r&&r(t),n.manager.itemError(e),n.manager.itemEnd(e)})),n.manager.itemStart(e)}}),Object.assign(Hc.prototype,{moveTo:function(e,t){return this.currentPath=new vc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this},lineTo:function(e,t){return this.currentPath.lineTo(e,t),this},quadraticCurveTo:function(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this},bezierCurveTo:function(e,t,i,r,n,o){return this.currentPath.bezierCurveTo(e,t,i,r,n,o),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,t){function i(e){for(var t=[],i=0,r=e.length;i<r;i++){var n=e[i],o=new _c;o.curves=n.curves,t.push(o)}return t}function r(e,t){for(var i=t.length,r=!1,n=i-1,o=0;o<i;n=o++){var s=t[n],a=t[o],c=a.x-s.x,h=a.y-s.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(s=t[o],c=-c,a=t[n],h=-h),e.y<s.y||e.y>a.y)continue;if(e.y===s.y){if(e.x===s.x)return!0}else{var u=h*(e.x-s.x)-c*(e.y-s.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(e.y!==s.y)continue;if(a.x<=e.x&&e.x<=s.x||s.x<=e.x&&e.x<=a.x)return!0}}return r}var n=zs.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return i(o);var s,a,c,h=[];if(1===o.length)return a=o[0],(c=new _c).curves=a.curves,h.push(c),h;var u=!n(o[0].getPoints());u=e?!u:u;var l,p,d=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,_=o.length;v<_;v++)s=n(l=(a=o[v]).getPoints()),(s=e?!s:s)?(!u&&f[g]&&g++,f[g]={s:new _c,p:l},f[g].s.curves=a.curves,u&&g++,m[g]=[]):m[g].push({h:a,p:l[0]});if(!f[0])return i(o);if(f.length>1){for(var y=!1,b=[],x=0,w=f.length;x<w;x++)d[x]=[];for(x=0,w=f.length;x<w;x++)for(var A=m[x],S=0;S<A.length;S++){for(var M=A[S],E=!0,T=0;T<f.length;T++)r(M.p,f[T].p)&&(x!==T&&b.push({froms:x,tos:T,hole:S}),E?(E=!1,d[T].push(M)):y=!0);E&&d[x].push(M)}b.length>0&&(y||(m=d))}v=0;for(var C=f.length;v<C;v++){c=f[v].s,h.push(c);for(var I=0,N=(p=m[v]).length;I<N;I++)c.holes.push(p[I].h)}return h}}),Object.assign(qc.prototype,{isFont:!0,generateShapes:function(e,t){void 0===t&&(t=100);for(var i=[],r=function(e,t,i){for(var r=Array.from?Array.from(e):String(e).split(""),n=t/i.resolution,o=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*n,s=[],a=0,c=0,h=0;h<r.length;h++){var u=r[h];if("\n"===u)a=0,c-=o;else{var l=Wc(u,n,a,c,i);a+=l.offsetX,s.push(l.path)}}return s}(e,t,this.data),n=0,o=r.length;n<o;n++)Array.prototype.push.apply(i,r[n].toShapes());return i}}),Qc.prototype=Object.assign(Object.create($a.prototype),{constructor:Qc,load:function(e,t,i,r){var n=this,o=new Ua(this.manager);o.setPath(this.path),o.load(e,(function(e){var i;try{i=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(e.substring(65,e.length-2))}var r=n.parse(i);t&&t(r)}),i,r)},parse:function(e){return new qc(e)}});var Yc=function(){return void 0===zc&&(zc=new(window.AudioContext||window.webkitAudioContext)),zc};function Xc(e){$a.call(this,e)}function Zc(e,t,i){Rc.call(this,void 0,i);var r=(new wt).set(e),n=(new wt).set(t),o=new oe(r.r,r.g,r.b),s=new oe(n.r,n.g,n.b),a=Math.sqrt(Math.PI),c=a*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(s).multiplyScalar(a),this.sh.coefficients[1].copy(o).sub(s).multiplyScalar(c)}function Kc(e,t){Rc.call(this,void 0,t);var i=(new wt).set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}Xc.prototype=Object.assign(Object.create($a.prototype),{constructor:Xc,load:function(e,t,i,r){var n=this,o=new Ua(n.manager);o.setResponseType("arraybuffer"),o.setPath(n.path),o.load(e,(function(i){try{var o=i.slice(0);Yc().decodeAudioData(o,(function(e){t(e)}))}catch(t){r?r(t):console.error(t),n.manager.itemError(e)}}),i,r)}}),Zc.prototype=Object.assign(Object.create(Rc.prototype),{constructor:Zc,isHemisphereLightProbe:!0,copy:function(e){return Rc.prototype.copy.call(this,e),this},toJSON:function(e){return Rc.prototype.toJSON.call(this,e)}}),Kc.prototype=Object.assign(Object.create(Rc.prototype),{constructor:Kc,isAmbientLightProbe:!0,copy:function(e){return Rc.prototype.copy.call(this,e),this},toJSON:function(e){return Rc.prototype.toJSON.call(this,e)}});var Jc=new de,eh=new de;function th(e){this.autoStart=void 0===e||e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}Object.assign(function(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ci,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ci,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}.prototype,{update:function(e){var t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;var i,r,n=e.projectionMatrix.clone(),o=t.eyeSep/2,s=o*t.near/t.focus,a=t.near*Math.tan(W.DEG2RAD*t.fov*.5)/t.zoom;eh.elements[12]=-o,Jc.elements[12]=o,i=-a*t.aspect+s,r=a*t.aspect+s,n.elements[0]=2*t.near/(r-i),n.elements[8]=(r+i)/(r-i),this.cameraL.projectionMatrix.copy(n),i=-a*t.aspect-s,r=a*t.aspect-s,n.elements[0]=2*t.near/(r-i),n.elements[8]=(r+i)/(r-i),this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(eh),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Jc)}}),Object.assign(th.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var t=("undefined"==typeof performance?Date:performance).now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}});var ih=new oe,rh=new ie,nh=new oe,oh=new oe;function sh(){Pe.call(this),this.type="AudioListener",this.context=Yc(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new th}function ah(e){Pe.call(this),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this._startedAt=0,this._progress=0,this.filters=[]}sh.prototype=Object.assign(Object.create(Pe.prototype),{constructor:sh,getInput:function(){return this.gain},removeFilter:function(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},getFilter:function(){return this.filter},setFilter:function(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this},updateMatrixWorld:function(e){Pe.prototype.updateMatrixWorld.call(this,e);var t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ih,rh,nh),oh.set(0,0,-1).applyQuaternion(rh),t.positionX){var r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(ih.x,r),t.positionY.linearRampToValueAtTime(ih.y,r),t.positionZ.linearRampToValueAtTime(ih.z,r),t.forwardX.linearRampToValueAtTime(oh.x,r),t.forwardY.linearRampToValueAtTime(oh.y,r),t.forwardZ.linearRampToValueAtTime(oh.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(ih.x,ih.y,ih.z),t.setOrientation(oh.x,oh.y,oh.z,i.x,i.y,i.z)}}),ah.prototype=Object.assign(Object.create(Pe.prototype),{constructor:ah,getOutput:function(){return this.gain},setNodeSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},setMediaElementSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this},setMediaStreamSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this},setBuffer:function(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(e){if(void 0===e&&(e=0),!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){this._startedAt=this.context.currentTime+e;var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")},pause:function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(e){return e||(e=[]),!0===this.isPlaying?(this.disconnect(),this.filters=e,this.connect()):this.filters=e,this},setDetune:function(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this},getDetune:function(){return this.detune},getFilter:function(){return this.getFilters()[0]},setFilter:function(e){return this.setFilters(e?[e]:[])},setPlaybackRate:function(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")},setLoopStart:function(e){return this.loopStart=e,this},setLoopEnd:function(e){return this.loopEnd=e,this},getVolume:function(){return this.gain.gain.value},setVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}});var ch=new oe,hh=new ie,uh=new oe,lh=new oe;function ph(e){ah.call(this,e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}function dh(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=void 0!==t?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}function fh(e,t,i){var r,n,o;switch(this.binding=e,this.valueSize=i,t){case"quaternion":r=this._slerp,n=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":r=this._select,n=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:r=this._lerp,n=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=n,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}ph.prototype=Object.assign(Object.create(ah.prototype),{constructor:ph,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(e){return this.panner.refDistance=e,this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(e){return this.panner.rolloffFactor=e,this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(e){return this.panner.distanceModel=e,this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(e){return this.panner.maxDistance=e,this},setDirectionalCone:function(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this},updateMatrixWorld:function(e){if(Pe.prototype.updateMatrixWorld.call(this,e),!0!==this.hasPlaybackControl||!1!==this.isPlaying){this.matrixWorld.decompose(ch,hh,uh),lh.set(0,0,1).applyQuaternion(hh);var t=this.panner;if(t.positionX){var i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(ch.x,i),t.positionY.linearRampToValueAtTime(ch.y,i),t.positionZ.linearRampToValueAtTime(ch.z,i),t.orientationX.linearRampToValueAtTime(lh.x,i),t.orientationY.linearRampToValueAtTime(lh.y,i),t.orientationZ.linearRampToValueAtTime(lh.z,i)}else t.setPosition(ch.x,ch.y,ch.z),t.setOrientation(lh.x,lh.y,lh.z)}}}),Object.assign(dh.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var e=0,t=this.getFrequencyData(),i=0;i<t.length;i++)e+=t[i];return e/t.length}}),Object.assign(fh.prototype,{accumulate:function(e,t){var i=this.buffer,r=this.valueSize,n=e*r+r,o=this.cumulativeWeight;if(0===o){for(var s=0;s!==r;++s)i[n+s]=i[s];o=t}else{var a=t/(o+=t);this._mixBufferRegion(i,n,0,a,r)}this.cumulativeWeight=o},accumulateAdditive:function(e){var t=this.buffer,i=this.valueSize,r=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e},apply:function(e){var t=this.valueSize,i=this.buffer,r=e*t+t,n=this.cumulativeWeight,o=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,n<1){var a=t*this._origIndex;this._mixBufferRegion(i,r,a,1-n,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(var c=t,h=t+t;c!==h;++c)if(i[c]!==i[c+t]){s.setValue(i,r);break}},saveOriginalState:function(){var e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(var n=i,o=r;n!==o;++n)t[n]=t[r+n%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)},_setAdditiveIdentityNumeric:function(){for(var e=this._addIndex*this.valueSize,t=e+this.valueSize,i=e;i<t;i++)this.buffer[i]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[4*this._addIndex+3]=1},_setAdditiveIdentityOther:function(){for(var e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize,i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]},_select:function(e,t,i,r,n){if(r>=.5)for(var o=0;o!==n;++o)e[t+o]=e[i+o]},_slerp:function(e,t,i,r){ie.slerpFlat(e,t,e,t,e,i,r)},_slerpAdditive:function(e,t,i,r,n){var o=this._workIndex*n;ie.multiplyQuaternionsFlat(e,o,e,t,e,i),ie.slerpFlat(e,t,e,t,e,o,r)},_lerp:function(e,t,i,r,n){for(var o=1-r,s=0;s!==n;++s){var a=t+s;e[a]=e[a]*o+e[i+s]*r}},_lerpAdditive:function(e,t,i,r,n){for(var o=0;o!==n;++o){var s=t+o;e[s]=e[s]+e[i+o]*r}}});var mh="\\[\\]\\.:\\/",gh=new RegExp("[\\[\\]\\.:\\/]","g"),vh="[^\\[\\]\\.:\\/]",_h="[^"+mh.replace("\\.","")+"]",yh=/((?:WC+[\/:])*)/.source.replace("WC",vh),bh=/(WCOD+)?/.source.replace("WCOD",_h),xh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vh),wh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vh),Ah=new RegExp("^"+yh+bh+xh+wh+"$"),Sh=["material","materials","bones"];function Mh(e,t,i){var r=i||Eh.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}function Eh(e,t,i){this.path=t,this.parsedPath=i||Eh.parseTrackName(t),this.node=Eh.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function Th(e,t,i,r){this._mixer=e,this._clip=t,this._localRoot=i||null,this.blendMode=r||t.blendMode;for(var n=t.tracks,o=n.length,s=new Array(o),a={endingStart:R,endingEnd:R},c=0;c!==o;++c){var h=n[c].createInterpolant(null);s[c]=h,h.settings=a}this._interpolantSettings=a,this._interpolants=s,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Ch(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Ih(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function Nh(e,t,i){Gn.call(this,e,t),this.meshPerAttribute=i||1}function Ph(e,t,i,r){this.ray=new rt(e,t),this.near=i||0,this.far=r||1/0,this.camera=null,this.layers=new ve,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Rh(e,t){return e.distance-t.distance}function Oh(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),!0===r)for(var n=e.children,o=0,s=n.length;o<s;o++)Oh(n[o],t,i,!0)}Object.assign(Mh.prototype,{getValue:function(e,t){this.bind();var i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(e,t)},setValue:function(e,t){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}),Object.assign(Eh,{Composite:Mh,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new Eh.Composite(e,t,i):new Eh(e,t,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(gh,"")},parseTrackName:function(e){var t=Ah.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){var n=i.nodeName.substring(r+1);-1!==Sh.indexOf(n)&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=n)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i},findNode:function(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){var r=function(e){for(var i=0;i<e.length;i++){var n=e[i];if(n.name===t||n.uuid===t)return n;var o=r(n.children);if(o)return o}return null},n=r(e.children);if(n)return n}return null}}),Object.assign(Eh.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,t){e[t]=this.node[this.propertyName]},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)e[t++]=i[r]},function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]},function(e,t){this.resolvedProperty.toArray(e,t)}],SetterByBindingTypeAndVersioning:[[function(e,t){this.targetObject[this.propertyName]=e[t]},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++]},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty.fromArray(e,t)},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){var e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,n=t.propertyIndex;if(e||(e=Eh.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){if(i){var o=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(var s=0;s<e.length;s++)if(e[s].name===o){o=s;break}break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==o){if(void 0===e[o])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[o]}}var a=e[r];if(void 0!==a){var c=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?c=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate);var h=this.BindingType.Direct;if(void 0!==n){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[n]&&(n=e.morphTargetDictionary[n])}h=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}else void 0!==a.fromArray&&void 0!==a.toArray?(h=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(h=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[h],this.setValue=this.SetterByBindingTypeAndVersioning[h][c]}else{var u=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",e)}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Eh.prototype,{_getValue_unbound:Eh.prototype.getValue,_setValue_unbound:Eh.prototype.setValue}),Object.assign(function(){this.uuid=W.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}.prototype,{isAnimationObjectGroup:!0,add:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._paths,o=this._parsedPaths,s=this._bindings,a=s.length,c=void 0,h=0,u=arguments.length;h!==u;++h){var l=arguments[h],p=l.uuid,d=r[p];if(void 0===d){d=t++,r[p]=d,e.push(l);for(var f=0,m=a;f!==m;++f)s[f].push(new Eh(l,n[f],o[f]))}else if(d<i){c=e[d];var g=--i,v=e[g];r[v.uuid]=d,e[d]=v,r[p]=g,e[g]=l;for(f=0,m=a;f!==m;++f){var _=s[f],y=_[g],b=_[d];_[d]=y,void 0===b&&(b=new Eh(l,n[f],o[f])),_[g]=b}}else e[d]!==c&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=i},remove:function(){for(var e=this._objects,t=this.nCachedObjects_,i=this._indicesByUUID,r=this._bindings,n=r.length,o=0,s=arguments.length;o!==s;++o){var a=arguments[o],c=a.uuid,h=i[c];if(void 0!==h&&h>=t){var u=t++,l=e[u];i[l.uuid]=h,e[h]=l,i[c]=u,e[u]=a;for(var p=0,d=n;p!==d;++p){var f=r[p],m=f[u],g=f[h];f[h]=m,f[u]=g}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,o=n.length,s=0,a=arguments.length;s!==a;++s){var c=arguments[s],h=c.uuid,u=r[h];if(void 0!==u)if(delete r[h],u<i){var l=--i,p=e[l],d=e[_=--t];r[p.uuid]=u,e[u]=p,r[d.uuid]=l,e[l]=d,e.pop();for(var f=0,m=o;f!==m;++f){var g=(y=n[f])[l],v=y[_];y[u]=g,y[l]=v,y.pop()}}else{var _;r[(d=e[_=--t]).uuid]=u,e[u]=d,e.pop();for(f=0,m=o;f!==m;++f){var y;(y=n[f])[u]=y[_],y.pop()}}}this.nCachedObjects_=i},subscribe_:function(e,t){var i=this._bindingsIndicesByPath,r=i[e],n=this._bindings;if(void 0!==r)return n[r];var o=this._paths,s=this._parsedPaths,a=this._objects,c=a.length,h=this.nCachedObjects_,u=new Array(c);r=n.length,i[e]=r,o.push(e),s.push(t),n.push(u);for(var l=h,p=a.length;l!==p;++l){var d=a[l];u[l]=new Eh(d,e,t)}return u},unsubscribe_:function(e){var t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){var r=this._paths,n=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s];t[e[s]]=i,o[i]=a,o.pop(),n[i]=n[s],n.pop(),r[i]=r[s],r.pop()}}}),Object.assign(Th.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(e){return this._startTime=e,this},setLoop:function(e,t){return this.loop=e,this.repetitions=t,this},setEffectiveWeight:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(e){return this._scheduleFading(e,0,1)},fadeOut:function(e){return this._scheduleFading(e,1,0)},crossFadeFrom:function(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){var r=this._clip.duration,n=e._clip.duration,o=n/r,s=r/n;e.warp(1,o,t),this.warp(s,1,t)}return this},crossFadeTo:function(e,t,i){return e.crossFadeFrom(this,t,i)},stopFading:function(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},setEffectiveTimeScale:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()},syncWith:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()},halt:function(e){return this.warp(this._effectiveTimeScale,0,e)},warp:function(e,t,i){var r=this._mixer,n=r.time,o=this._timeScaleInterpolant,s=this.timeScale;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);var a=o.parameterPositions,c=o.sampleValues;return a[0]=n,a[1]=n+i,c[0]=e/s,c[1]=t/s,this},stopWarping:function(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(e,t,i,r){if(this.enabled){var n=this._startTime;if(null!==n){var o=(e-n)*i;if(o<0||0===i)return;this._startTime=null,t=i*o}t*=this._updateTimeScale(e);var s=this._updateTime(t),a=this._updateWeight(e);if(a>0){var c=this._interpolants,h=this._propertyBindings;if(2501===this.blendMode)for(var u=0,l=c.length;u!==l;++u)c[u].evaluate(s),h[u].accumulateAdditive(a);else for(u=0,l=c.length;u!==l;++u)c[u].evaluate(s),h[u].accumulate(r,a)}}else this._updateWeight(e)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,i=this._clip.duration,r=this.loop,n=this._loopCount,o=2202===r;if(0===e)return-1===n?t:o&&1==(1&n)?i-t:t;if(2200===r){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=i)t=i;else{if(!(t<0)){this.time=t;break e}t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===n&&(e>=0?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),t>=i||t<0){var s=Math.floor(t/i);t-=i*s,n+=Math.abs(s);var a=this.repetitions-n;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){var c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=n,this.time=t,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:s})}}else this.time=t;if(o&&1==(1&n))return i-t}return t},_setEndings:function(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=O,r.endingEnd=O):(r.endingStart=e?this.zeroSlopeAtStart?O:R:D,r.endingEnd=t?this.zeroSlopeAtEnd?O:R:D)},_scheduleFading:function(e,t,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var s=o.parameterPositions,a=o.sampleValues;return s[0]=n,a[0]=t,s[1]=n+e,a[1]=i,this}}),Ch.prototype=Object.assign(Object.create(U.prototype),{constructor:Ch,_bindAction:function(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,o=e._propertyBindings,s=e._interpolants,a=i.uuid,c=this._bindingsByRootAndName,h=c[a];void 0===h&&(h={},c[a]=h);for(var u=0;u!==n;++u){var l=r[u],p=l.name,d=h[p];if(void 0!==d)o[u]=d;else{if(void 0!==(d=o[u])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,a,p));continue}var f=t&&t._propertyBindings[u].binding.parsedPath;++(d=new fh(Eh.create(i,p,f),l.ValueTypeName,l.getValueSize())).referenceCount,this._addInactiveBinding(d,a,p),o[u]=d}s[u].resultBuffer=d.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}for(var n=e._propertyBindings,o=0,s=n.length;o!==s;++o){var a=n[o];0==a.useCount++&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&t<this._nActiveActions},_addInactiveAction:function(e,t,i){var r=this._actions,n=this._actionsByClip,o=n[t];if(void 0===o)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=o;else{var s=o.knownActions;e._byClipCacheIndex=s.length,s.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e},_removeInactiveAction:function(e){var t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;var n=e._clip.uuid,o=this._actionsByClip,s=o[n],a=s.knownActions,c=a[a.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,a[h]=c,a.pop(),e._byClipCacheIndex=null,delete s.actionByRoot[(e._localRoot||this._root).uuid],0===a.length&&delete o[n],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0==--n.referenceCount&&this._removeInactiveBinding(n)}},_lendAction:function(e){var t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_takeBackAction:function(e){var t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_addInactiveBinding:function(e,t,i){var r=this._bindingsByRootAndName,n=r[t],o=this._bindings;void 0===n&&(n={},r[t]=n),n[i]=e,e._cacheIndex=o.length,o.push(e)},_removeInactiveBinding:function(e){var t=this._bindings,i=e.binding,r=i.rootNode.uuid,n=i.path,o=this._bindingsByRootAndName,s=o[r],a=t[t.length-1],c=e._cacheIndex;a._cacheIndex=c,t[c]=a,t.pop(),delete s[n],0===Object.keys(s).length&&delete o[r]},_lendBinding:function(e){var t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_takeBackBinding:function(e){var t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_lendControlInterpolant:function(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return void 0===i&&((i=new Ea(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=t,e[t]=i),i},_takeBackControlInterpolant:function(e){var t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,n=t[r];e.__cacheIndex=r,t[r]=e,n.__cacheIndex=i,t[i]=n},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t,i){var r=t||this._root,n=r.uuid,o="string"==typeof e?ka.findByName(r,e):e,s=null!==o?o.uuid:e,a=this._actionsByClip[s],c=null;if(void 0===i&&(i=null!==o?o.blendMode:L),void 0!==a){var h=a.actionByRoot[n];if(void 0!==h&&h.blendMode===i)return h;c=a.knownActions[0],null===o&&(o=c._clip)}if(null===o)return null;var u=new Th(this,o,t,i);return this._bindAction(u,c),this._addInactiveAction(u,s,n),u},existingAction:function(e,t){var i=t||this._root,r=i.uuid,n="string"==typeof e?ka.findByName(i,e):e,o=n?n.uuid:e,s=this._actionsByClip[o];return void 0!==s&&s.actionByRoot[r]||null},stopAllAction:function(){for(var e=this._actions,t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this},update:function(e){e*=this.timeScale;for(var t=this._actions,i=this._nActiveActions,r=this.time+=e,n=Math.sign(e),o=this._accuIndex^=1,s=0;s!==i;++s){t[s]._update(r,e,n,o)}var a=this._bindings,c=this._nActiveBindings;for(s=0;s!==c;++s)a[s].apply(o);return this},setTime:function(e){this.time=0;for(var t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)},getRoot:function(){return this._root},uncacheClip:function(e){var t=this._actions,i=e.uuid,r=this._actionsByClip,n=r[i];if(void 0!==n){for(var o=n.knownActions,s=0,a=o.length;s!==a;++s){var c=o[s];this._deactivateAction(c);var h=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}},uncacheRoot:function(e){var t=e.uuid,i=this._actionsByClip;for(var r in i){var n=i[r].actionByRoot[t];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}var o=this._bindingsByRootAndName[t];if(void 0!==o)for(var s in o){var a=o[s];a.restoreOriginalState(),this._removeInactiveBinding(a)}},uncacheAction:function(e,t){var i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}),Ih.prototype.clone=function(){return new Ih(void 0===this.value.clone?this.value:this.value.clone())},Nh.prototype=Object.assign(Object.create(Gn.prototype),{constructor:Nh,isInstancedInterleavedBuffer:!0,copy:function(e){return Gn.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}}),Object.assign(Ph.prototype,{set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(e,t,i){var r=i||[];return Oh(e,this,r,t),r.sort(Rh),r},intersectObjects:function(e,t,i){var r=i||[];if(!1===Array.isArray(e))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(var n=0,o=e.length;n<o;n++)Oh(e[n],this,r,t);return r.sort(Rh),r}}),Object.assign(function(e,t,i){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==i?i:0,this}.prototype,{set:function(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},makeSafe:function(){var e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(W.clamp(t/this.radius,-1,1))),this}}),Object.assign(function(e,t,i){return this.radius=void 0!==e?e:1,this.theta=void 0!==t?t:0,this.y=void 0!==i?i:0,this}.prototype,{set:function(e,t,i){return this.radius=e,this.theta=t,this.y=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}});var Dh=new Q;function Lh(e,t){this.min=void 0!==e?e:new Q(1/0,1/0),this.max=void 0!==t?t:new Q(-1/0,-1/0)}Object.assign(Lh.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(e,t){var i=Dh.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(e){return void 0===e&&(console.warn("THREE.Box2: .getCenter() target is now required"),e=new Q),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("THREE.Box2: .getSize() target is now required"),e=new Q),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)},containsBox:function(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},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new Q),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(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)},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new Q),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Dh.copy(e).clamp(this.min,this.max).sub(e).length()},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var kh=new oe,Bh=new oe;function Fh(e,t){this.start=void 0!==e?e:new oe,this.end=void 0!==t?t:new oe}function jh(e){Pe.call(this),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}Object.assign(Fh.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new oe),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new oe),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new oe),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){kh.subVectors(e,this.start),Bh.subVectors(this.end,this.start);var i=Bh.dot(Bh),r=Bh.dot(kh)/i;return t&&(r=W.clamp(r,0,1)),r},closestPointToPoint:function(e,t,i){var r=this.closestPointToPointParameter(e,t);return void 0===i&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new oe),this.delta(i).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),jh.prototype=Object.create(Pe.prototype),jh.prototype.constructor=jh,jh.prototype.isImmediateRenderObject=!0;var zh=new oe;function $h(e,t){Pe.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var i=new Xt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],n=0,o=1;n<32;n++,o++){var s=n/32*Math.PI*2,a=o/32*Math.PI*2;r.push(Math.cos(s),Math.sin(s),1,Math.cos(a),Math.sin(a),1)}i.setAttribute("position",new jt(r,3));var c=new Co({fog:!1,toneMapped:!1});this.cone=new Bo(i,c),this.add(this.cone),this.update()}$h.prototype=Object.create(Pe.prototype),$h.prototype.constructor=$h,$h.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},$h.prototype.update=function(){this.light.updateMatrixWorld();var e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),zh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(zh),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Vh=new oe,Uh=new de,Gh=new de;function Hh(e){var t=[];e&&e.isBone&&t.push(e);for(var i=0;i<e.children.length;i++)t.push.apply(t,Hh(e.children[i]));return t}function qh(e){for(var t=Hh(e),i=new Xt,r=[],n=[],o=new wt(0,0,1),s=new wt(0,1,0),a=0;a<t.length;a++){var c=t[a];c.parent&&c.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(o.r,o.g,o.b),n.push(s.r,s.g,s.b))}i.setAttribute("position",new jt(r,3)),i.setAttribute("color",new jt(n,3));var h=new Co({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});Bo.call(this,i,h),this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}function Wh(e,t,i){this.light=e,this.light.updateMatrixWorld(),this.color=i;var r=new Xs(t,4,2),n=new It({wireframe:!0,fog:!1,toneMapped:!1});fi.call(this,r,n),this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}qh.prototype=Object.create(Bo.prototype),qh.prototype.constructor=qh,qh.prototype.isSkeletonHelper=!0,qh.prototype.updateMatrixWorld=function(e){var t=this.bones,i=this.geometry,r=i.getAttribute("position");Gh.getInverse(this.root.matrixWorld);for(var n=0,o=0;n<t.length;n++){var s=t[n];s.parent&&s.parent.isBone&&(Uh.multiplyMatrices(Gh,s.matrixWorld),Vh.setFromMatrixPosition(Uh),r.setXYZ(o,Vh.x,Vh.y,Vh.z),Uh.multiplyMatrices(Gh,s.parent.matrixWorld),Vh.setFromMatrixPosition(Uh),r.setXYZ(o+1,Vh.x,Vh.y,Vh.z),o+=2)}i.getAttribute("position").needsUpdate=!0,Pe.prototype.updateMatrixWorld.call(this,e)},Wh.prototype=Object.create(fi.prototype),Wh.prototype.constructor=Wh,Wh.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},Wh.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)};var Qh=new oe,Yh=new wt,Xh=new wt;function Zh(e,t,i){Pe.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;var r=new ns(t);r.rotateY(.5*Math.PI),this.material=new It({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);var n=r.getAttribute("position"),o=new Float32Array(3*n.count);r.setAttribute("color",new Pt(o,3)),this.add(new fi(r,this.material)),this.update()}function Kh(e,t,i,r){e=e||10,t=t||10,i=new wt(void 0!==i?i:4473924),r=new wt(void 0!==r?r:8947848);for(var n=t/2,o=e/t,s=e/2,a=[],c=[],h=0,u=0,l=-s;h<=t;h++,l+=o){a.push(-s,0,l,s,0,l),a.push(l,0,-s,l,0,s);var p=h===n?i:r;p.toArray(c,u),u+=3,p.toArray(c,u),u+=3,p.toArray(c,u),u+=3,p.toArray(c,u),u+=3}var d=new Xt;d.setAttribute("position",new jt(a,3)),d.setAttribute("color",new jt(c,3));var f=new Co({vertexColors:!0,toneMapped:!1});Bo.call(this,d,f),this.type="GridHelper"}function Jh(e,t,i,r,n,o){e=e||10,t=t||16,i=i||8,r=r||64,n=new wt(void 0!==n?n:4473924),o=new wt(void 0!==o?o:8947848);var s,a,c,h,u,l,p,d=[],f=[];for(h=0;h<=t;h++)c=h/t*(2*Math.PI),s=Math.sin(c)*e,a=Math.cos(c)*e,d.push(0,0,0),d.push(s,0,a),p=1&h?n:o,f.push(p.r,p.g,p.b),f.push(p.r,p.g,p.b);for(h=0;h<=i;h++)for(p=1&h?n:o,l=e-e/i*h,u=0;u<r;u++)c=u/r*(2*Math.PI),s=Math.sin(c)*l,a=Math.cos(c)*l,d.push(s,0,a),f.push(p.r,p.g,p.b),c=(u+1)/r*(2*Math.PI),s=Math.sin(c)*l,a=Math.cos(c)*l,d.push(s,0,a),f.push(p.r,p.g,p.b);var m=new Xt;m.setAttribute("position",new jt(d,3)),m.setAttribute("color",new jt(f,3));var g=new Co({vertexColors:!0,toneMapped:!1});Bo.call(this,m,g),this.type="PolarGridHelper"}Zh.prototype=Object.create(Pe.prototype),Zh.prototype.constructor=Zh,Zh.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},Zh.prototype.update=function(){var e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var t=e.geometry.getAttribute("color");Yh.copy(this.light.color),Xh.copy(this.light.groundColor);for(var i=0,r=t.count;i<r;i++){var n=i<r/2?Yh:Xh;t.setXYZ(i,n.r,n.g,n.b)}t.needsUpdate=!0}e.lookAt(Qh.setFromMatrixPosition(this.light.matrixWorld).negate())},Kh.prototype=Object.assign(Object.create(Bo.prototype),{constructor:Kh,copy:function(e){return Bo.prototype.copy.call(this,e),this.geometry.copy(e.geometry),this.material.copy(e.material),this},clone:function(){return(new this.constructor).copy(this)}}),Jh.prototype=Object.create(Bo.prototype),Jh.prototype.constructor=Jh;var eu=new oe,tu=new oe,iu=new oe;function ru(e,t,i){Pe.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===t&&(t=1);var r=new Xt;r.setAttribute("position",new jt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));var n=new Co({fog:!1,toneMapped:!1});this.lightPlane=new Do(r,n),this.add(this.lightPlane),(r=new Xt).setAttribute("position",new jt([0,0,0,0,0,1],3)),this.targetLine=new Do(r,n),this.add(this.targetLine),this.update()}ru.prototype=Object.create(Pe.prototype),ru.prototype.constructor=ru,ru.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},ru.prototype.update=function(){eu.setFromMatrixPosition(this.light.matrixWorld),tu.setFromMatrixPosition(this.light.target.matrixWorld),iu.subVectors(tu,eu),this.lightPlane.lookAt(tu),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(tu),this.targetLine.scale.z=iu.length()};var nu=new oe,ou=new Ti;function su(e){var t=new Xt,i=new Co({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],n=[],o={},s=new wt(16755200),a=new wt(16711680),c=new wt(43775),h=new wt(16777215),u=new wt(3355443);function l(e,t,i){p(e,i),p(t,i)}function p(e,t){r.push(0,0,0),n.push(t.r,t.g,t.b),void 0===o[e]&&(o[e]=[]),o[e].push(r.length/3-1)}l("n1","n2",s),l("n2","n4",s),l("n4","n3",s),l("n3","n1",s),l("f1","f2",s),l("f2","f4",s),l("f4","f3",s),l("f3","f1",s),l("n1","f1",s),l("n2","f2",s),l("n3","f3",s),l("n4","f4",s),l("p","n1",a),l("p","n2",a),l("p","n3",a),l("p","n4",a),l("u1","u2",c),l("u2","u3",c),l("u3","u1",c),l("c","t",h),l("p","c",u),l("cn1","cn2",u),l("cn3","cn4",u),l("cf1","cf2",u),l("cf3","cf4",u),t.setAttribute("position",new jt(r,3)),t.setAttribute("color",new jt(n,3)),Bo.call(this,t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}function au(e,t,i,r,n,o,s){nu.set(n,o,s).unproject(r);var a=t[e];if(void 0!==a)for(var c=i.getAttribute("position"),h=0,u=a.length;h<u;h++)c.setXYZ(a[h],nu.x,nu.y,nu.z)}su.prototype=Object.create(Bo.prototype),su.prototype.constructor=su,su.prototype.update=function(){var e=this.geometry,t=this.pointMap;ou.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),au("c",t,e,ou,0,0,-1),au("t",t,e,ou,0,0,1),au("n1",t,e,ou,-1,-1,-1),au("n2",t,e,ou,1,-1,-1),au("n3",t,e,ou,-1,1,-1),au("n4",t,e,ou,1,1,-1),au("f1",t,e,ou,-1,-1,1),au("f2",t,e,ou,1,-1,1),au("f3",t,e,ou,-1,1,1),au("f4",t,e,ou,1,1,1),au("u1",t,e,ou,.7,1.1,-1),au("u2",t,e,ou,-.7,1.1,-1),au("u3",t,e,ou,0,2,-1),au("cf1",t,e,ou,-1,0,1),au("cf2",t,e,ou,1,0,1),au("cf3",t,e,ou,0,-1,1),au("cf4",t,e,ou,0,1,1),au("cn1",t,e,ou,-1,0,-1),au("cn2",t,e,ou,1,0,-1),au("cn3",t,e,ou,0,-1,-1),au("cn4",t,e,ou,0,1,-1),e.getAttribute("position").needsUpdate=!0};var cu=new qe;function hu(e,t){this.object=e,void 0===t&&(t=16776960);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),n=new Xt;n.setIndex(new Pt(i,1)),n.setAttribute("position",new Pt(r,3)),Bo.call(this,n,new Co({color:t,toneMapped:!1})),this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}function uu(e,t){this.type="Box3Helper",this.box=e,t=t||16776960;var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Xt;r.setIndex(new Pt(i,1)),r.setAttribute("position",new jt([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),Bo.call(this,r,new Co({color:t,toneMapped:!1})),this.type="Box3Helper",this.geometry.computeBoundingSphere()}function lu(e,t,i){this.plane=e,this.size=void 0===t?1:t;var r=void 0!==i?i:16776960,n=new Xt;n.setAttribute("position",new jt([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),n.computeBoundingSphere(),Do.call(this,n,new Co({color:r,toneMapped:!1})),this.type="PlaneHelper";var o=new Xt;o.setAttribute("position",new jt([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),o.computeBoundingSphere(),this.add(new fi(o,new It({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}hu.prototype=Object.create(Bo.prototype),hu.prototype.constructor=hu,hu.prototype.update=function(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&cu.setFromObject(this.object),!cu.isEmpty()){var t=cu.min,i=cu.max,r=this.geometry.attributes.position,n=r.array;n[0]=i.x,n[1]=i.y,n[2]=i.z,n[3]=t.x,n[4]=i.y,n[5]=i.z,n[6]=t.x,n[7]=t.y,n[8]=i.z,n[9]=i.x,n[10]=t.y,n[11]=i.z,n[12]=i.x,n[13]=i.y,n[14]=t.z,n[15]=t.x,n[16]=i.y,n[17]=t.z,n[18]=t.x,n[19]=t.y,n[20]=t.z,n[21]=i.x,n[22]=t.y,n[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}},hu.prototype.setFromObject=function(e){return this.object=e,this.update(),this},hu.prototype.copy=function(e){return Bo.prototype.copy.call(this,e),this.object=e.object,this},hu.prototype.clone=function(){return(new this.constructor).copy(this)},uu.prototype=Object.create(Bo.prototype),uu.prototype.constructor=uu,uu.prototype.updateMatrixWorld=function(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),Pe.prototype.updateMatrixWorld.call(this,e))},lu.prototype=Object.create(Do.prototype),lu.prototype.constructor=lu,lu.prototype.updateMatrixWorld=function(e){var t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?1:0,this.lookAt(this.plane.normal),Pe.prototype.updateMatrixWorld.call(this,e)};var pu,du,fu=new oe;function mu(e,t,i,r,n,o){Pe.call(this),this.type="ArrowHelper",void 0===e&&(e=new oe(0,0,1)),void 0===t&&(t=new oe(0,0,0)),void 0===i&&(i=1),void 0===r&&(r=16776960),void 0===n&&(n=.2*i),void 0===o&&(o=.2*n),void 0===pu&&((pu=new Xt).setAttribute("position",new jt([0,0,0,0,1,0],3)),(du=new sa(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new Do(pu,new Co({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new fi(du,new It({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,n,o)}function gu(e){var t=[0,0,0,e=e||1,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=new Xt;i.setAttribute("position",new jt(t,3)),i.setAttribute("color",new jt([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));var r=new Co({vertexColors:!0,toneMapped:!1});Bo.call(this,i,r),this.type="AxesHelper"}mu.prototype=Object.create(Pe.prototype),mu.prototype.constructor=mu,mu.prototype.setDirection=function(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{fu.set(e.z,0,-e.x).normalize();var t=Math.acos(e.y);this.quaternion.setFromAxisAngle(fu,t)}},mu.prototype.setLength=function(e,t,i){void 0===t&&(t=.2*e),void 0===i&&(i=.2*t),this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},mu.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},mu.prototype.copy=function(e){return Pe.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},mu.prototype.clone=function(){return(new this.constructor).copy(this)},gu.prototype=Object.create(Bo.prototype),gu.prototype.constructor=gu;var vu=Math.pow(2,8),_u=[.125,.215,.35,.446,.526,.582],yu=5+_u.length,bu=20,xu={[k]:0,[B]:1,[j]:2,3004:3,3005:4,3006:5,[F]:6},wu=new Ec,{_lodPlanes:Au,_sizeLods:Su,_sigmas:Mu}=function(){for(var e=[],t=[],i=[],r=8,n=0;n<yu;n++){var o=Math.pow(2,r);t.push(o);var s=1/o;n>4?s=_u[n-8+4-1]:0==n&&(s=0),i.push(s);for(var a=1/(o-1),c=-a/2,h=1+a/2,u=[c,c,h,c,h,h,c,c,h,h,c,h],l=new Float32Array(108),p=new Float32Array(72),d=new Float32Array(36),f=0;f<6;f++){var m=f%3*2/3-1,g=f>2?0:-1,v=[m,g,0,m+2/3,g,0,m+2/3,g+1,0,m,g,0,m+2/3,g+1,0,m,g+1,0];l.set(v,18*f),p.set(u,12*f);var _=[f,f,f,f,f,f];d.set(_,6*f)}var y=new Xt;y.setAttribute("position",new Pt(l,3)),y.setAttribute("uv",new Pt(p,2)),y.setAttribute("faceIndex",new Pt(d,1)),e.push(y),r>4&&r--}return{_lodPlanes:e,_sizeLods:t,_sigmas:i}}(),Eu=null,Tu=(1+Math.sqrt(5))/2,Cu=1/Tu,Iu=[new oe(1,1,1),new oe(-1,1,1),new oe(1,1,-1),new oe(-1,1,-1),new oe(0,Tu,Cu),new oe(0,Tu,-Cu),new oe(Cu,0,Tu),new oe(-Cu,0,Tu),new oe(Tu,Cu,0),new oe(-Tu,Cu,0)];function Nu(e){var t,i,r,n;this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=(t=bu,i=new Float32Array(t),r=new oe(0,1,0),(n=new da({defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r},inputEncoding:{value:xu[3e3]},outputEncoding:{value:xu[3e3]}},vertexShader:ku(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float mipInt;\nuniform vec3 poleAxis;\n\n${Bu()}\n\n#define ENVMAP_TYPE_CUBE_UV\n#include <cube_uv_reflection_fragment>\n\nvec3 getSample(float theta, vec3 axis) {\n\tfloat cosTheta = cos(theta);\n\t// Rodrigues' axis-angle rotation\n\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\treturn bilinearCubeUV(envMap, sampleDirection, mipInt);\n}\n\nvoid main() {\n\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\tif (all(equal(axis, vec3(0.0))))\n\t\taxis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n\taxis = normalize(axis);\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n\tfor (int i = 1; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfloat theta = dTheta * float(i);\n\t\tgl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n\t\tgl_FragColor.rgb += weights[i] * getSample(theta, axis);\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",n),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}function Pu(e){return void 0!==e&&e.type===y&&(e.encoding===k||e.encoding===B||e.encoding===F)}function Ru(e){var t=new ee(3*vu,3*vu,e);return t.texture.mapping=u,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Ou(e,t,i,r,n){e.viewport.set(t,i,r,n),e.scissor.set(t,i,r,n)}function Du(){var e=new da({uniforms:{envMap:{value:null},texelSize:{value:new Q(1,1)},inputEncoding:{value:xu[3e3]},outputEncoding:{value:xu[3e3]}},vertexShader:ku(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n${Bu()}\n\n#include <common>\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv = equirectUv( outputDirection );\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1});return e.type="EquirectangularToCubeUV",e}function Lu(){var e=new da({uniforms:{envMap:{value:null},inputEncoding:{value:xu[3e3]},outputEncoding:{value:xu[3e3]}},vertexShader:ku(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n\n${Bu()}\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function ku(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\n\n// RH coordinate system; PMREM face-indexing convention\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\t} else if (face == 2.0) {\n\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\t} else if (face == 5.0) {\n\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\t}\n\treturn direction;\n}\n\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t"}function Bu(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include <encodings_pars_fragment>\n\nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\n\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t"}function Fu(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),nc.call(this,e),this.type="catmullrom"}Nu.prototype={constructor:Nu,fromScene:function(e,t=0,i=.1,r=100){Eu=this._renderer.getRenderTarget();var n=this._allocateTargets();return this._sceneToCubeUV(e,i,r,n),t>0&&this._blur(n,0,0,t),this._applyPMREM(n),this._cleanup(n),n},fromEquirectangular:function(e){return e.magFilter=f,e.minFilter=f,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){Eu=this._renderer.getRenderTarget();var t=this._allocateTargets(e);return this._textureToCubeUV(e,t),this._applyPMREM(t),this._cleanup(t),t},compileCubemapShader:function(){null===this._cubemapShader&&(this._cubemapShader=Lu(),this._compileMaterial(this._cubemapShader))},compileEquirectangularShader:function(){null===this._equirectShader&&(this._equirectShader=Du(),this._compileMaterial(this._equirectShader))},dispose:function(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(var e=0;e<Au.length;e++)Au[e].dispose()},_cleanup:function(e){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(Eu),e.scissorTest=!1,e.setSize(e.width,e.height)},_allocateTargets:function(e){var t={magFilter:f,minFilter:f,generateMipmaps:!1,type:y,format:1023,encoding:Pu(e)?e.encoding:j,depthBuffer:!1,stencilBuffer:!1},i=Ru(t);return i.depthBuffer=!e,this._pingPongRenderTarget=Ru(t),i},_compileMaterial:function(e){var t=new fi(Au[0],e);this._renderer.compile(t,wu)},_sceneToCubeUV:function(e,t,i,r){var n=new Ci(90,1,t,i),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],a=this._renderer,c=a.outputEncoding,h=a.toneMapping,u=a.toneMappingExposure,l=a.getClearColor(),p=a.getClearAlpha();a.toneMapping=1,a.toneMappingExposure=1,a.outputEncoding=k;var d=e.background;if(d&&d.isColor){d.convertSRGBToLinear();var f=Math.max(d.r,d.g,d.b),m=Math.min(Math.max(Math.ceil(Math.log2(f)),-128),127);d=d.multiplyScalar(Math.pow(2,-m));var g=(m+128)/255;a.setClearColor(d,g),e.background=null}for(var v=0;v<6;v++){var _=v%3;0==_?(n.up.set(0,o[v],0),n.lookAt(s[v],0,0)):1==_?(n.up.set(0,0,o[v]),n.lookAt(0,s[v],0)):(n.up.set(0,o[v],0),n.lookAt(0,0,s[v])),Ou(r,_*vu,v>2?vu:0,vu,vu),a.setRenderTarget(r),a.render(e,n)}a.toneMapping=h,a.toneMappingExposure=u,a.outputEncoding=c,a.setClearColor(l,p)},_textureToCubeUV:function(e,t){var i=this._renderer;e.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=Lu()):null==this._equirectShader&&(this._equirectShader=Du());var r=e.isCubeTexture?this._cubemapShader:this._equirectShader,n=new fi(Au[0],r),o=r.uniforms;o.envMap.value=e,e.isCubeTexture||o.texelSize.value.set(1/e.image.width,1/e.image.height),o.inputEncoding.value=xu[e.encoding],o.outputEncoding.value=xu[t.texture.encoding],Ou(t,0,0,3*vu,2*vu),i.setRenderTarget(t),i.render(n,wu)},_applyPMREM:function(e){var t=this._renderer,i=t.autoClear;t.autoClear=!1;for(var r=1;r<yu;r++){var n=Math.sqrt(Mu[r]*Mu[r]-Mu[r-1]*Mu[r-1]),o=Iu[(r-1)%Iu.length];this._blur(e,r-1,r,n,o)}t.autoClear=i},_blur:function(e,t,i,r,n){var o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",n),this._halfBlur(o,e,i,i,r,"longitudinal",n)},_halfBlur:function(e,t,i,r,n,o,s){var a=this._renderer,c=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");var h=new fi(Au[r],c),u=c.uniforms,l=Su[i]-1,p=isFinite(n)?Math.PI/(2*l):2*Math.PI/39,d=n/p,f=isFinite(n)?1+Math.floor(3*d):bu;f>bu&&console.warn(`sigmaRadians, ${n}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);for(var m=[],g=0,v=0;v<bu;++v){var _=v/d,y=Math.exp(-_*_/2);m.push(y),0==v?g+=y:v<f&&(g+=2*y)}for(v=0;v<m.length;v++)m[v]=m[v]/g;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===o,s&&(u.poleAxis.value=s),u.dTheta.value=p,u.mipInt.value=8-i,u.inputEncoding.value=xu[e.texture.encoding],u.outputEncoding.value=xu[e.texture.encoding];var b=Su[r];Ou(t,_=3*Math.max(0,vu-2*b),(0===r?0:2*vu)+2*b*(r>4?r-8+4:0),3*b,2*b),a.setRenderTarget(t),a.render(h,wu)}},Xa.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Xa.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(gc.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new xi,i=0,r=e.length;i<r;i++){var n=e[i];t.vertices.push(new oe(n.x,n.y,n.z||0))}return t}}),Object.assign(vc.prototype,{fromPoints:function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),Object.create(nc.prototype),Object.create(nc.prototype),Fu.prototype=Object.create(nc.prototype),Object.assign(Fu.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),Kh.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},qh.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign($a.prototype,{extractUrlBase:function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Dc(e)}}),$a.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(jc.prototype,{setTexturePath:function(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}),Object.assign(Lh.prototype,{center:function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},size:function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(qe.prototype,{center:function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},size:function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(Ye.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}}),Li.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Fh.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Object.assign(W,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),W.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),W.ceilPowerOfTwo(e)}}),Object.assign(Y.prototype,{flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},multiplyVector3:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(de.prototype,{extractPosition:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new oe).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},crossVector:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(e,t,i,r,n,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,r,i,n,o)}}),at.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},ie.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Object.assign(rt.prototype,{isIntersectionBox:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}),Object.assign(_t.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},midpoint:function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},normal:function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},plane:function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)}}),Object.assign(_t,{barycoordFromPoint:function(e,t,i,r,n){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),_t.getBarycoord(e,t,i,r,n)},normal:function(e,t,i,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),_t.getNormal(e,t,i,r)}}),Object.assign(_c.prototype,{extractAllPoints:function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},extrude:function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Us(this,e)},makeGeometry:function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new ta(this,e)}}),Object.assign(Q.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(oe.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},applyProjection:function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},fromAttribute:function(e,t,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(J.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(xi.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.assign(Pe.prototype,{getChildByName:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(Pe.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(fi.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(fi.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(vo.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(xo.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),_o.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Xa.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),Ci.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(yc.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(Pt.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===V},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(V)}}}),Object.assign(Pt.prototype,{setDynamic:function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?V:$),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(Xt.prototype,{addIndex:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},addAttribute:function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new Pt(arguments[1],arguments[2])))},addDrawCall:function(e,t,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},applyMatrix:function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(Xt.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(Lc.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(e){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=e}}}),Object.defineProperties(Ph.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(e){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=e}}}),Object.defineProperties(Gn.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===V},set:function(e){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),Object.assign(Gn.prototype,{setDynamic:function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?V:$),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(Gs.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.defineProperties(Ih.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(Ct.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new wt}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(ga.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(Ei.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.assign($n.prototype,{clearTarget:function(e,t,i,r){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,i,r)},animate:function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties($n.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?B:k}}}),Object.defineProperties(Rn.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(ee.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Object.defineProperties(ah.prototype,{load:{value:function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var t=this;return(new Xc).load(e,(function(e){t.setBuffer(e)})),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),dh.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Ni.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},X.crossOrigin=void 0,X.loadTexture=function(e,t,i,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var n=new Ya;n.setCrossOrigin(this.crossOrigin);var o=n.load(e,i,void 0,r);return t&&(o.mapping=t),o},X.loadTextureCube=function(e,t,i,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var n=new Qa;n.setCrossOrigin(this.crossOrigin);var o=n.load(e,i,void 0,r);return t&&(o.mapping=t),o},X.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},X.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"117"}}));class ju extends Error{constructor(e){super(e),this.name="BeeviewError"}}class zu extends ju{constructor(e){super(null!=e?e:"The argument is not valid."),this.name="ArgumentBeeviewError"}}class $u extends ju{constructor(e){super(e),this.name="GraphBeeviewError"}}class Vu{constructor(e){null!=e?(this._position=(new oe).fromArray(e.unprojectSfM([0,0],0)),this._lookat=(new oe).fromArray(e.unprojectSfM([0,0],10)),this._up=e.upVector(),this._focal=this._getFocal(e)):(this._position=new oe(0,0,0),this._lookat=new oe(0,0,1),this._up=new oe(0,-1,0),this._focal=1)}get position(){return this._position}get lookat(){return this._lookat}get up(){return this._up}get focal(){return this._focal}set focal(e){this._focal=e}lerpCameras(e,t,i){this._position.subVectors(t.position,e.position).multiplyScalar(i).add(e.position),this._lookat.subVectors(t.lookat,e.lookat).multiplyScalar(i).add(e.lookat),this._up.subVectors(t.up,e.up).multiplyScalar(i).add(e.up),this._focal=(1-i)*e.focal+i*t.focal}copy(e){this._position.copy(e.position),this._lookat.copy(e.lookat),this._up.copy(e.up),this._focal=e.focal}clone(){let e=new Vu;return e.position.copy(this._position),e.lookat.copy(this._lookat),e.up.copy(this._up),e.focal=this._focal,e}diff(e){let t=this._position.distanceToSquared(e.position),i=this._lookat.distanceToSquared(e.lookat),r=this._up.distanceToSquared(e.up),n=100*Math.abs(this._focal-e.focal);return Math.max(t,i,r,n)}_getFocal(e){if(null==e.gpano)return e.focal;let t=Math.PI*e.gpano.CroppedAreaImageHeightPixels/e.gpano.FullPanoHeightPixels,i=.5/Math.tan(t/2);return Math.min(1/(2*(Math.sqrt(2)-1)),Math.max(.5,i))}}class Uu{constructor(){this._wgs84a=6378137,this._wgs84b=6356752.31424518}geodeticToEnu(e,t,i,r,n,o){let s=this.geodeticToEcef(e,t,i);return this.ecefToEnu(s[0],s[1],s[2],r,n,o)}enuToGeodetic(e,t,i,r,n,o){let s=this.enuToEcef(e,t,i,r,n,o);return this.ecefToGeodetic(s[0],s[1],s[2])}ecefToEnu(e,t,i,r,n,o){let s=this.geodeticToEcef(r,n,o),a=[e-s[0],t-s[1],i-s[2]];r=r*Math.PI/180,n=n*Math.PI/180;let c=Math.cos(r),h=Math.sin(r),u=Math.cos(n),l=Math.sin(n);return[-l*a[0]+u*a[1],-h*u*a[0]-h*l*a[1]+c*a[2],c*u*a[0]+c*l*a[1]+h*a[2]]}enuToEcef(e,t,i,r,n,o){let s=this.geodeticToEcef(r,n,o);r=r*Math.PI/180,n=n*Math.PI/180;let a=Math.cos(r),c=Math.sin(r),h=Math.cos(n),u=Math.sin(n);return[-u*e-c*h*t+a*h*i+s[0],h*e-c*u*t+a*u*i+s[1],a*t+c*i+s[2]]}geodeticToEcef(e,t,i){let r=this._wgs84a,n=this._wgs84b;e=e*Math.PI/180,t=t*Math.PI/180;let o=Math.cos(e),s=Math.sin(e),a=Math.cos(t),c=Math.sin(t),h=r*r,u=n*n,l=1/Math.sqrt(h*o*o+u*s*s),p=(h*l+i)*o;return[p*a,p*c,(u*l+i)*s]}ecefToGeodetic(e,t,i){let r=this._wgs84a,n=this._wgs84b,o=r*r,s=n*n,a=o-s,c=Math.sqrt(a/o),h=Math.sqrt(a/s),u=Math.sqrt(e*e+t*t),l=Math.atan2(i*r,u*n),p=Math.sin(l),d=Math.cos(l),f=Math.atan2(t,e),m=Math.atan2(i+h*h*n*p*p*p,u-c*c*r*d*d*d),g=Math.sin(m),v=u/Math.cos(m)-r/Math.sqrt(1-c*c*g*g);return[180*m/Math.PI,180*f/Math.PI,v]}}class Gu{constructor(){this._unprojectDepth=200}basicToCanvas(e,t,i,r,n){const o=r.unprojectBasic([e,t],this._unprojectDepth);return this.projectToCanvas(o,i,n)}basicToCanvasSafe(e,t,i,r,n){const o=r.unprojectBasic([e,t],this._unprojectDepth),s=this.worldToCamera(o,n);if(s[2]>0)return null;const[a,c]=this.cameraToViewport(s,n);return this.viewportToCanvas(a,c,i)}basicToViewport(e,t,i,r){const n=i.unprojectBasic([e,t],this._unprojectDepth);return this.projectToViewport(n,r)}cameraToViewport(e,t){const i=(new oe).fromArray(e).applyMatrix4(t.projectionMatrix);return[i.x,i.y]}canvasPosition(e,t){const i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}canvasToBasic(e,t,i,r,n){const o=this.unprojectFromCanvas(e,t,i,n).toArray();return r.projectBasic(o)}canvasToViewport(e,t,i){const[r,n]=this.containerToCanvas(i);return[2*e/r-1,1-2*t/n]}containerToCanvas(e){return[e.offsetWidth,e.offsetHeight]}getBasicDistances(e,t){const i=this.viewportToBasic(-1,1,e,t),r=this.viewportToBasic(1,1,e,t),n=this.viewportToBasic(1,-1,e,t),o=this.viewportToBasic(-1,-1,e,t);let s=0,a=0,c=0,h=0;return i[1]<0&&r[1]<0&&(s=i[1]>r[1]?-i[1]:-r[1]),r[0]>1&&n[0]>1&&(a=r[0]<n[0]?r[0]-1:n[0]-1),n[1]>1&&o[1]>1&&(c=n[1]<o[1]?n[1]-1:o[1]-1),o[0]<0&&i[0]<0&&(h=o[0]>i[0]?-o[0]:-i[0]),[s,a,c,h]}getPixelDistances(e,t,i){const r=this.viewportToBasic(-1,1,t,i),n=this.viewportToBasic(1,1,t,i),o=this.viewportToBasic(1,-1,t,i),s=this.viewportToBasic(-1,-1,t,i);let a=0,c=0,h=0,u=0;const[l,p]=this.containerToCanvas(e);if(r[1]<0&&n[1]<0){const o=r[1]>n[1]?r[0]:n[0],s=this.basicToCanvas(o,0,e,t,i);a=s[1]>0?s[1]:0}if(n[0]>1&&o[0]>1){const r=n[0]<o[0]?n[1]:o[1],s=this.basicToCanvas(1,r,e,t,i);c=s[0]<l?l-s[0]:0}if(o[1]>1&&s[1]>1){const r=o[1]<s[1]?o[0]:s[0],n=this.basicToCanvas(r,1,e,t,i);h=n[1]<p?p-n[1]:0}if(s[0]<0&&r[0]<0){const n=s[0]>r[0]?s[1]:r[1],o=this.basicToCanvas(0,n,e,t,i);u=o[0]>0?o[0]:0}return[a,c,h,u]}insideElement(e,t){const i=t.getBoundingClientRect(),r=i.left+t.clientLeft,n=r+t.clientWidth,o=i.top+t.clientTop,s=o+t.clientHeight;return e.clientX>r&&e.clientX<n&&e.clientY>o&&e.clientY<s}projectToCanvas(e,t,i){const r=this.projectToViewport(e,i);return this.viewportToCanvas(r[0],r[1],t)}projectToViewport(e,t){const i=new oe(e[0],e[1],e[2]).project(t);return[i.x,i.y]}unprojectFromCanvas(e,t,i,r){const n=this.canvasToViewport(e,t,i);return this.unprojectFromViewport(n[0],n[1],r)}unprojectFromViewport(e,t,i){return new oe(e,t,1).unproject(i)}viewportToBasic(e,t,i,r){const n=new oe(e,t,1).unproject(r).toArray();return i.projectBasic(n)}viewportToCanvas(e,t,i){const[r,n]=this.containerToCanvas(i);return[r*(e+1)/2,-n*(t-1)/2]}worldToCamera(e,t){return new oe(e[0],e[1],e[2]).applyMatrix4(t.matrixWorldInverse).toArray()}}class Hu{constructor(){this._epsilon=1e-9}azimuthalToBearing(e){return-e+Math.PI/2}degToRad(e){return Math.PI*e/180}radToDeg(e){return 180*e/Math.PI}rotationMatrix(e){let t=new oe(e[0],e[1],e[2]),i=t.length();return i>0&&t.normalize(),(new de).makeRotationAxis(t,i)}rotate(e,t){let i=new oe(e[0],e[1],e[2]),r=this.rotationMatrix(t);return i.applyMatrix4(r),i}opticalCenter(e,t){let i=[-e[0],-e[1],-e[2]],r=[-t[0],-t[1],-t[2]];return this.rotate(r,i)}viewingDirection(e){let t=[-e[0],-e[1],-e[2]];return this.rotate([0,0,1],t)}wrap(e,t,i){if(i<t)throw new Error("Invalid arguments: max must be larger than min.");let r=i-t;for(;e>i||e<t;)e>i?e-=r:e<t&&(e+=r);return e}wrapAngle(e){return this.wrap(e,-Math.PI,Math.PI)}clamp(e,t,i){return e<t?t:e>i?i:e}angleBetweenVector2(e,t,i,r){let n=Math.atan2(r,i)-Math.atan2(t,e);return this.wrapAngle(n)}angleDifference(e,t){let i=t-e;return this.wrapAngle(i)}relativeRotationAngle(e,t){let i=this.rotationMatrix([-e[0],-e[1],-e[2]]),r=this.rotationMatrix(t),n=i.multiply(r).elements;return Math.acos((n[0]+n[5]+n[10]-1)/2)}angleToPlane(e,t){let i=(new oe).fromArray(e),r=i.length();if(r<this._epsilon)return 0;let n=i.dot((new oe).fromArray(t));return Math.asin(n/r)}distanceFromLatLon(e,t,i,r){let n=this.degToRad(i-e),o=this.degToRad(r-t),s=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return 12742e3*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))}}class qu{constructor(e,t,i){this._orientation=this._getValue(e.orientation,1);let r=null!=t?t.width:4,n=null!=t?t.height:3,o=this._orientation<5;this._width=this._getValue(e.width,o?r:n),this._height=this._getValue(e.height,o?n:r),this._basicAspect=o?this._width/this._height:this._height/this._width,this._basicWidth=o?e.width:e.height,this._basicHeight=o?e.height:e.width,this._focal=this._getValue(e.focal,1),this._scale=this._getValue(e.scale,0),this._gpano=null!=e.gpano?e.gpano:null,this._rt=this._getRt(e.rotation,i)}get basicAspect(){return this._basicAspect}get basicHeight(){return this._basicHeight}get basicWidth(){return this._basicWidth}get focal(){return this._focal}get fullPano(){return null!=this._gpano&&0===this._gpano.CroppedAreaLeftPixels&&0===this._gpano.CroppedAreaTopPixels&&this._gpano.CroppedAreaImageWidthPixels===this._gpano.FullPanoWidthPixels&&this._gpano.CroppedAreaImageHeightPixels===this._gpano.FullPanoHeightPixels}get gpano(){return this._gpano}get height(){return this._height}get orientation(){return this._orientation}get rt(){return this._rt}get srt(){return this._srt}get scale(){return this._scale}get hasValidScale(){return this._scale>.01&&this._scale<50}get width(){return this._width}upVector(){let e=this._rt.elements;switch(this._orientation){case 1:default:return new oe(-e[1],-e[5],-e[9]);case 3:return new oe(e[1],e[5],e[9]);case 6:return new oe(-e[0],-e[4],-e[8]);case 8:return new oe(e[0],e[4],e[8])}}projectorMatrix(){let e=this._normalizedToTextureMatrix(),t=this._focal,i=(new de).set(t,0,0,0,0,t,0,0,0,0,0,0,0,0,1,0);return e.multiply(i),e.multiply(this._rt),e}projectBasic(e){let t=this.projectSfM(e);return this._sfmToBasic(t)}unprojectBasic(e,t){let i=this._basicToSfm(e);return this.unprojectSfM(i,t)}projectSfM(e){let t=new J(e[0],e[1],e[2],1);return t.applyMatrix4(this._rt),this._bearingToSfm([t.x,t.y,t.z])}unprojectSfM(e,t){let i=this._sfmToBearing(e),r=new J(t*i[0],t*i[1],t*i[2],1);return r.applyMatrix4((new de).getInverse(this._rt)),[r.x/r.w,r.y/r.w,r.z/r.w]}_sfmToBearing(e){if(this._fullPano()){let t=2*e[0]*Math.PI,i=2*-e[1]*Math.PI;return[Math.cos(i)*Math.sin(t),-Math.sin(i),Math.cos(i)*Math.cos(t)]}if(this._gpano){let t=Math.max(this.gpano.CroppedAreaImageWidthPixels,this.gpano.CroppedAreaImageHeightPixels),i=[e[0]*t+this.gpano.CroppedAreaImageWidthPixels/2+this.gpano.CroppedAreaLeftPixels,e[1]*t+this.gpano.CroppedAreaImageHeightPixels/2+this.gpano.CroppedAreaTopPixels],r=2*Math.PI*(i[0]/this.gpano.FullPanoWidthPixels-.5),n=-Math.PI*(i[1]/this.gpano.FullPanoHeightPixels-.5);return[Math.cos(n)*Math.sin(r),-Math.sin(n),Math.cos(n)*Math.cos(r)]}{let t=new oe(e[0],e[1],this._focal);return t.normalize(),[t.x,t.y,t.z]}}_bearingToSfm(e){if(this._fullPano()){let t=e[0],i=e[1],r=e[2],n=Math.atan2(t,r),o=Math.atan2(-i,Math.sqrt(t*t+r*r));return[n/(2*Math.PI),-o/(2*Math.PI)]}if(this._gpano){let t=e[0],i=e[1],r=e[2],n=Math.atan2(t,r),o=Math.atan2(-i,Math.sqrt(t*t+r*r)),s=[(n/(2*Math.PI)+.5)*this.gpano.FullPanoWidthPixels,(-o/Math.PI+.5)*this.gpano.FullPanoHeightPixels],a=Math.max(this.gpano.CroppedAreaImageWidthPixels,this.gpano.CroppedAreaImageHeightPixels);return[(s[0]-this.gpano.CroppedAreaLeftPixels-this.gpano.CroppedAreaImageWidthPixels/2)/a,(s[1]-this.gpano.CroppedAreaTopPixels-this.gpano.CroppedAreaImageHeightPixels/2)/a]}return e[2]>0?[e[0]*this._focal/e[2],e[1]*this._focal/e[2]]:[e[0]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,e[1]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY]}_basicToSfm(e){let t,i;switch(this._orientation){case 1:default:t=e[0],i=e[1];break;case 3:t=1-e[0],i=1-e[1];break;case 6:t=e[1],i=1-e[0];break;case 8:t=1-e[1],i=e[0]}let r=this._width,n=this._height,o=Math.max(r,n);return[t*r/o-r/o/2,i*n/o-n/o/2]}_sfmToBasic(e){let t,i,r=this._width,n=this._height,o=Math.max(r,n),s=(e[0]+r/o/2)/r*o,a=(e[1]+n/o/2)/n*o;switch(this._orientation){case 1:default:t=s,i=a;break;case 3:t=1-s,i=1-a;break;case 6:t=1-a,i=s;break;case 8:t=a,i=1-s}return[t,i]}_fullPano(){return null!=this.gpano&&0===this.gpano.CroppedAreaLeftPixels&&0===this.gpano.CroppedAreaTopPixels&&this.gpano.CroppedAreaImageWidthPixels===this.gpano.FullPanoWidthPixels&&this.gpano.CroppedAreaImageHeightPixels===this.gpano.FullPanoHeightPixels}_getValue(e,t){return null!=e&&e>0?e:t}_getRt(e,t){let i=new oe(e[0],e[1],e[2]),r=i.length();r>0&&i.normalize();let n=new de;return n.makeRotationAxis(i,r),n.setPosition(new oe(t[0],t[1],t[2])),n}_getSrt(e,t){let i=e.clone(),r=i.elements;return r[12]=t*r[12],r[13]=t*r[13],r[14]=t*r[14],i.scale(new oe(t,t,t)),i}_normalizedToTextureMatrix(){let e=Math.max(this._width,this._height),t=e/this._width,i=e/this._height;switch(this._orientation){case 1:default:return(new de).set(t,0,0,.5,0,-i,0,.5,0,0,1,0,0,0,0,1);case 3:return(new de).set(-t,0,0,.5,0,i,0,.5,0,0,1,0,0,0,0,1);case 6:return(new de).set(0,-i,0,.5,-t,0,0,.5,0,0,1,0,0,0,0,1);case 8:return(new de).set(0,i,0,.5,t,0,0,.5,0,0,1,0,0,0,0,1)}}}function Wu(e,t,i,r,n){Qu(e,t,i||0,r||e.length-1,n||Xu)}function Qu(e,t,i,r,n){for(;r>i;){if(r-i>600){var o=r-i+1,s=t-i+1,a=Math.log(o),c=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*c*(o-c)/o)*(s-o/2<0?-1:1);Qu(e,t,Math.max(i,Math.floor(t-s*c/o+h)),Math.min(r,Math.floor(t+(o-s)*c/o+h)),n)}var u=e[t],l=i,p=r;for(Yu(e,i,t),n(e[r],u)>0&&Yu(e,i,r);l<p;){for(Yu(e,l,p),l++,p--;n(e[l],u)<0;)l++;for(;n(e[p],u)>0;)p--}0===n(e[i],u)?Yu(e,i,p):Yu(e,++p,r),p<=t&&(i=p+1),t<=p&&(r=p-1)}}function Yu(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function Xu(e,t){return e<t?-1:e>t?1:0}function Zu(e,t,i){if(!i)return t.indexOf(e);for(let r=0;r<t.length;r++)if(i(e,t[r]))return r;return-1}function Ku(e,t){Ju(e,0,e.children.length,t,e)}function Ju(e,t,i,r,n){n||(n=cl(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let o=t;o<i;o++){const t=e.children[o];el(n,e.leaf?r(t):t)}return n}function el(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function tl(e,t){return e.minX-t.minX}function il(e,t){return e.minY-t.minY}function rl(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function nl(e){return e.maxX-e.minX+(e.maxY-e.minY)}function ol(e,t){const i=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),n=Math.min(e.maxX,t.maxX),o=Math.min(e.maxY,t.maxY);return Math.max(0,n-i)*Math.max(0,o-r)}function sl(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function al(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function cl(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function hl(e,t,i,r,n){const o=[t,i];for(;o.length;){if((i=o.pop())-(t=o.pop())<=r)continue;const s=t+Math.ceil((i-t)/r/2)*r;Wu(e,s,t,i,n),o.push(t,s,s,i)}}class ul extends class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!al(e,t))return i;const r=this.toBBox,n=[];for(;t;){for(let o=0;o<t.children.length;o++){const s=t.children[o],a=t.leaf?r(s):s;al(e,a)&&(t.leaf?i.push(s):sl(e,a)?this._all(s,i):n.push(s))}t=n.pop()}return i}collides(e){let t=this.data;if(!al(e,t))return!1;const i=[];for(;t;){for(let r=0;r<t.children.length;r++){const n=t.children[r],o=t.leaf?this.toBBox(n):n;if(al(e,o)){if(t.leaf||sl(e,o))return!0;i.push(n)}}t=i.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=cl([]),this}remove(e,t){if(!e)return this;let i=this.data;const r=this.toBBox(e),n=[],o=[];let s,a,c;for(;i||n.length;){if(i||(i=n.pop(),a=n[n.length-1],s=o.pop(),c=!0),i.leaf){const r=Zu(e,i.children,t);if(-1!==r)return i.children.splice(r,1),n.push(i),this._condense(n),this}c||i.leaf||!sl(i,r)?a?(s++,i=a.children[s],c=!1):i=null:(n.push(i),o.push(s),s=0,a=i,i=i.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,r){const n=i-t+1;let o,s=this._maxEntries;if(n<=s)return o=cl(e.slice(t,i+1)),Ku(o,this.toBBox),o;r||(r=Math.ceil(Math.log(n)/Math.log(s)),s=Math.ceil(n/Math.pow(s,r-1))),o=cl([]),o.leaf=!1,o.height=r;const a=Math.ceil(n/s),c=a*Math.ceil(Math.sqrt(s));hl(e,t,i,c,this.compareMinX);for(let n=t;n<=i;n+=c){const t=Math.min(n+c-1,i);hl(e,n,t,a,this.compareMinY);for(let i=n;i<=t;i+=a){const n=Math.min(i+a-1,t);o.children.push(this._build(e,i,n,r-1))}}return Ku(o,this.toBBox),o}_chooseSubtree(e,t,i,r){for(;r.push(t),!t.leaf&&r.length-1!==i;){let i,r=1/0,s=1/0;for(let a=0;a<t.children.length;a++){const c=t.children[a],h=rl(c),u=(n=e,o=c,(Math.max(o.maxX,n.maxX)-Math.min(o.minX,n.minX))*(Math.max(o.maxY,n.maxY)-Math.min(o.minY,n.minY))-h);u<s?(s=u,r=h<r?h:r,i=c):u===s&&h<r&&(r=h,i=c)}t=i||t.children[0]}var n,o;return t}_insert(e,t,i){const r=i?e:this.toBBox(e),n=[],o=this._chooseSubtree(r,this.data,t,n);for(o.children.push(e),el(o,r);t>=0&&n[t].children.length>this._maxEntries;)this._split(n,t),t--;this._adjustParentBBoxes(r,n,t)}_split(e,t){const i=e[t],r=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,r);const o=this._chooseSplitIndex(i,n,r),s=cl(i.children.splice(o,i.children.length-o));s.height=i.height,s.leaf=i.leaf,Ku(i,this.toBBox),Ku(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(i,s)}_splitRoot(e,t){this.data=cl([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Ku(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let r,n=1/0,o=1/0;for(let s=t;s<=i-t;s++){const t=Ju(e,0,s,this.toBBox),a=Ju(e,s,i,this.toBBox),c=ol(t,a),h=rl(t)+rl(a);c<n?(n=c,r=s,o=h<o?h:o):c===n&&h<o&&(o=h,r=s)}return r||i-t}_chooseSplitAxis(e,t,i){const r=e.leaf?this.compareMinX:tl,n=e.leaf?this.compareMinY:il;this._allDistMargin(e,t,i,r)<this._allDistMargin(e,t,i,n)&&e.children.sort(r)}_allDistMargin(e,t,i,r){e.children.sort(r);const n=this.toBBox,o=Ju(e,0,t,n),s=Ju(e,i-t,i,n);let a=nl(o)+nl(s);for(let r=t;r<i-t;r++){const t=e.children[r];el(o,e.leaf?n(t):t),a+=nl(o)}for(let r=i-t-1;r>=t;r--){const t=e.children[r];el(s,e.leaf?n(t):t),a+=nl(s)}return a}_adjustParentBBoxes(e,t,i){for(let r=i;r>=0;r--)el(t[r],e)}_condense(e){for(let t,i=e.length-1;i>=0;i--)0===e[i].children.length?i>0?(t=e[i-1].children,t.splice(t.indexOf(e[i]),1)):this.clear():Ku(e[i],this.toBBox)}}{compareMinX(e,t){return e.lat-t.lat}compareMinY(e,t){return e.lon-t.lon}toBBox(e){return{minX:e.lon,minY:e.lat,maxX:e.lon,maxY:e.lat}}}class ll{constructor(e,t,i){this._spatial=new Hu,this._geoCoords=new Uu,this._settings=null!=e?e:new s,this._directions=null!=t?t:new a,this._coefficients=null!=i?i:new c}getPotentialEdges(e,t,i){if(!e.full)throw new zu("Node has to be full.");if(!e.merged)return[];let r=this._spatial.viewingDirection(e.rotation),n=this._spatial.angleToPlane(r.toArray(),[0,0,1]),o=[];for(let s of t){if(!s.merged||s.key===e.key)continue;let t=this._geoCoords.geodeticToEnu(s.latLon.lat,s.latLon.lon,s.alt,e.latLon.lat,e.latLon.lon,e.alt),a=new oe(t[0],t[1],t[2]),c=a.length();if(c>this._settings.maxDistance&&i.indexOf(s.key)<0)continue;let h=this._spatial.angleBetweenVector2(r.x,r.y,a.x,a.y),u=this._spatial.angleToPlane(a.toArray(),[0,0,1]),l=this._spatial.viewingDirection(s.rotation),p=this._spatial.angleBetweenVector2(r.x,r.y,l.x,l.y),d=this._spatial.angleToPlane(l.toArray(),[0,0,1])-n,f=this._spatial.relativeRotationAngle(e.rotation,s.rotation),m=this._spatial.angleBetweenVector2(1,0,a.x,a.y),g=null!=s.sequenceKey&&null!=e.sequenceKey&&s.sequenceKey===e.sequenceKey,v=null==s.mergeCC&&null==e.mergeCC||s.mergeCC===e.mergeCC,_=s.userKey===e.userKey,y={capturedAt:s.capturedAt,croppedPano:s.pano&&!s.fullPano,directionChange:p,distance:c,fullPano:s.fullPano,key:s.key,motionChange:h,rotation:f,sameMergeCC:v,sameSequence:g,sameUser:_,sequenceKey:s.sequenceKey,verticalDirectionChange:d,verticalMotion:u,worldMotionAzimuth:m};o.push(y)}return o}computeSequenceEdges(t,i){if(!t.full)throw new zu("Node has to be full.");if(t.sequenceKey!==i.key)throw new zu("Node and sequence does not correspond.");let r=[],n=i.findNextKey(t.key);null!=n&&r.push({data:{direction:e.EdgeDirection.Next,worldMotionAzimuth:Number.NaN},from:t.key,to:n});let o=i.findPrevKey(t.key);return null!=o&&r.push({data:{direction:e.EdgeDirection.Prev,worldMotionAzimuth:Number.NaN},from:t.key,to:o}),r}computeSimilarEdges(t,i){if(!t.full)throw new zu("Node has to be full.");let r=t.fullPano,n={};for(let e of i)if(null!=e.sequenceKey&&!e.sameSequence&&e.sameMergeCC){if(r){if(!e.fullPano)continue}else if(!e.fullPano&&Math.abs(e.directionChange)>this._settings.similarMaxDirectionChange)continue;e.distance>this._settings.similarMaxDistance||e.sameUser&&Math.abs(e.capturedAt-t.capturedAt)<this._settings.similarMinTimeDifference||(null==n[e.sequenceKey]&&(n[e.sequenceKey]=[]),n[e.sequenceKey].push(e))}let o=[],s=t.fullPano?e=>e.distance:e=>this._coefficients.similarDistance*e.distance+this._coefficients.similarRotation*e.rotation;for(let e in n){if(!n.hasOwnProperty(e))continue;let t=Number.MAX_VALUE,i=null;for(let r of n[e]){let e=s(r);e<t&&(t=e,i=r)}null!=i&&o.push(i)}return o.map((i=>({data:{direction:e.EdgeDirection.Similar,worldMotionAzimuth:i.worldMotionAzimuth},from:t.key,to:i.key})))}computeStepEdges(e,t,i,r){if(!e.full)throw new zu("Node has to be full.");let n=[];if(e.pano)return n;for(let o in this._directions.steps){if(!this._directions.steps.hasOwnProperty(o))continue;let s=this._directions.steps[o],a=Number.MAX_VALUE,c=null,h=null;for(let e of t){if(e.croppedPano||e.fullPano)continue;if(Math.abs(e.directionChange)>this._settings.stepMaxDirectionChange)continue;let t=this._spatial.angleDifference(s.motionChange,e.motionChange),n=this._spatial.angleDifference(e.directionChange,t),o=Math.max(Math.abs(t),Math.abs(n));if(Math.abs(o)>this._settings.stepMaxDrift)continue;let u=e.key;if(!s.useFallback||u!==i&&u!==r||(h=e),e.distance>this._settings.stepMaxDistance)continue;t=Math.sqrt(t*t+e.verticalMotion*e.verticalMotion);let l=this._coefficients.stepPreferredDistance*Math.abs(e.distance-this._settings.stepPreferredDistance)/this._settings.stepMaxDistance+this._coefficients.stepMotion*t/this._settings.stepMaxDrift+this._coefficients.stepRotation*e.rotation/this._settings.stepMaxDirectionChange+this._coefficients.stepSequencePenalty*(e.sameSequence?0:1)+this._coefficients.stepMergeCCPenalty*(e.sameMergeCC?0:1);l<a&&(a=l,c=e)}c=null==c?h:c,null!=c&&n.push({data:{direction:s.direction,worldMotionAzimuth:c.worldMotionAzimuth},from:e.key,to:c.key})}return n}computeTurnEdges(t,i){if(!t.full)throw new zu("Node has to be full.");let r=[];if(t.pano)return r;for(let n in this._directions.turns){if(!this._directions.turns.hasOwnProperty(n))continue;let o=this._directions.turns[n],s=Number.MAX_VALUE,a=null;for(let t of i){if(t.croppedPano||t.fullPano)continue;if(t.distance>this._settings.turnMaxDistance)continue;let i,r=o.direction!==e.EdgeDirection.TurnU&&t.distance<this._settings.turnMaxRigDistance&&Math.abs(t.directionChange)>this._settings.turnMinRigDirectionChange,n=this._spatial.angleDifference(o.directionChange,t.directionChange);if(r&&t.directionChange*o.directionChange>0&&Math.abs(t.directionChange)<Math.abs(o.directionChange))i=-Math.PI/2+Math.abs(t.directionChange);else{if(Math.abs(n)>this._settings.turnMaxDirectionChange)continue;let e=o.motionChange?this._spatial.angleDifference(o.motionChange,t.motionChange):0;e=Math.sqrt(e*e+t.verticalMotion*t.verticalMotion),i=this._coefficients.turnDistance*t.distance/this._settings.turnMaxDistance+this._coefficients.turnMotion*e/Math.PI+this._coefficients.turnSequencePenalty*(t.sameSequence?0:1)+this._coefficients.turnMergeCCPenalty*(t.sameMergeCC?0:1)}i<s&&(s=i,a=t)}null!=a&&r.push({data:{direction:o.direction,worldMotionAzimuth:a.worldMotionAzimuth},from:t.key,to:a.key})}return r}computePerspectiveToPanoEdges(t,i){if(!t.full)throw new zu("Node has to be full.");if(t.pano)return[];let r=Number.MAX_VALUE,n=null;for(let e of i){if(!e.fullPano)continue;let t=this._coefficients.panoPreferredDistance*Math.abs(e.distance-this._settings.panoPreferredDistance)/this._settings.panoMaxDistance+this._coefficients.panoMotion*Math.abs(e.motionChange)/Math.PI+this._coefficients.panoMergeCCPenalty*(e.sameMergeCC?0:1);t<r&&(r=t,n=e)}return null==n?[]:[{data:{direction:e.EdgeDirection.Pano,worldMotionAzimuth:n.worldMotionAzimuth},from:t.key,to:n.key}]}computePanoEdges(t,i){if(!t.full)throw new zu("Node has to be full.");if(!t.fullPano)return[];let r=[],n=[],o=[];for(let e of i)if(!(e.distance>this._settings.panoMaxDistance))if(e.fullPano){if(e.distance<this._settings.panoMinDistance)continue;n.push(e)}else{if(e.croppedPano)continue;for(let t in this._directions.panos){if(!this._directions.panos.hasOwnProperty(t))continue;let i=this._directions.panos[t],r=this._spatial.angleDifference(e.directionChange,e.motionChange),n=this._spatial.angleDifference(i.directionChange,r);if(!(Math.abs(n)>this._settings.panoMaxStepTurnChange)){o.push([i.direction,e]);break}}}let s=Math.PI/this._settings.panoMaxItems,a=[],c=[];for(let i=0;i<this._settings.panoMaxItems;i++){let o=i/this._settings.panoMaxItems*2*Math.PI,h=Number.MAX_VALUE,u=null;for(let e of n){let t=this._spatial.angleDifference(o,e.motionChange);if(Math.abs(t)>s)continue;let i=Number.MAX_VALUE;for(let t of a){let r=Math.abs(this._spatial.angleDifference(t,e.motionChange));r<i&&(i=r)}if(i<=s)continue;let r=this._coefficients.panoPreferredDistance*Math.abs(e.distance-this._settings.panoPreferredDistance)/this._settings.panoMaxDistance+this._coefficients.panoMotion*Math.abs(t)/s+this._coefficients.panoSequencePenalty*(e.sameSequence?0:1)+this._coefficients.panoMergeCCPenalty*(e.sameMergeCC?0:1);r<h&&(h=r,u=e)}null!=u?(a.push(u.motionChange),r.push({data:{direction:e.EdgeDirection.Pano,worldMotionAzimuth:u.worldMotionAzimuth},from:t.key,to:u.key})):c.push(o)}let h={};h[e.EdgeDirection.Pano]=a,h[e.EdgeDirection.StepForward]=[],h[e.EdgeDirection.StepLeft]=[],h[e.EdgeDirection.StepBackward]=[],h[e.EdgeDirection.StepRight]=[];for(let i of c){let n=[];for(let a in this._directions.panos){if(!this._directions.panos.hasOwnProperty(a))continue;let c=this._directions.panos[a],u=h[e.EdgeDirection.Pano].concat(h[c.direction]).concat(h[c.prev]).concat(h[c.next]),l=Number.MAX_VALUE,p=null;for(let e of o){if(e[0]!==c.direction)continue;let t=this._spatial.angleDifference(i,e[1].motionChange);if(Math.abs(t)>s)continue;let r=Number.MAX_VALUE;for(let t of u){let i=Math.abs(this._spatial.angleDifference(t,e[1].motionChange));i<r&&(r=i)}if(r<=s)continue;let n=this._coefficients.panoPreferredDistance*Math.abs(e[1].distance-this._settings.panoPreferredDistance)/this._settings.panoMaxDistance+this._coefficients.panoMotion*Math.abs(t)/s+this._coefficients.panoMergeCCPenalty*(e[1].sameMergeCC?0:1);n<l&&(l=n,p=e)}null!=p&&(n.push(p),r.push({data:{direction:p[0],worldMotionAzimuth:p[1].worldMotionAzimuth},from:t.key,to:p[1].key}))}for(let e of n)h[e[0]].push(e[1].motionChange)}return r}}var pl="1.12.0",dl="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},fl=Array.prototype,ml=Object.prototype,gl="undefined"!=typeof Symbol?Symbol.prototype:null,vl=fl.push,_l=fl.slice,yl=ml.toString,bl=ml.hasOwnProperty,xl="undefined"!=typeof ArrayBuffer,wl="undefined"!=typeof DataView,Al=Array.isArray,Sl=Object.keys,Ml=Object.create,El=xl&&ArrayBuffer.isView,Tl=isNaN,Cl=isFinite,Il=!{toString:null}.propertyIsEnumerable("toString"),Nl=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],Pl=Math.pow(2,53)-1;function Rl(e,t){return t=null==t?e.length-1:+t,function(){for(var i=Math.max(arguments.length-t,0),r=Array(i),n=0;n<i;n++)r[n]=arguments[n+t];switch(t){case 0:return e.call(this,r);case 1:return e.call(this,arguments[0],r);case 2:return e.call(this,arguments[0],arguments[1],r)}var o=Array(t+1);for(n=0;n<t;n++)o[n]=arguments[n];return o[t]=r,e.apply(this,o)}}function Ol(e){var t=typeof e;return"function"===t||"object"===t&&!!e}function Dl(e){return void 0===e}function Ll(e){return!0===e||!1===e||"[object Boolean]"===yl.call(e)}function kl(e){var t="[object "+e+"]";return function(e){return yl.call(e)===t}}var Bl=kl("String"),Fl=kl("Number"),jl=kl("Date"),zl=kl("RegExp"),$l=kl("Error"),Vl=kl("Symbol"),Ul=kl("ArrayBuffer"),Gl=kl("Function"),Hl=dl.document&&dl.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof Hl&&(Gl=function(e){return"function"==typeof e||!1});var ql=Gl,Wl=kl("Object"),Ql=wl&&Wl(new DataView(new ArrayBuffer(8))),Yl="undefined"!=typeof Map&&Wl(new Map),Xl=kl("DataView");var Zl=Ql?function(e){return null!=e&&ql(e.getInt8)&&Ul(e.buffer)}:Xl,Kl=Al||kl("Array");function Jl(e,t){return null!=e&&bl.call(e,t)}var ep=kl("Arguments");!function(){ep(arguments)||(ep=function(e){return Jl(e,"callee")})}();var tp=ep;function ip(e){return Fl(e)&&Tl(e)}function rp(e){return function(){return e}}function np(e){return function(t){var i=e(t);return"number"==typeof i&&i>=0&&i<=Pl}}function op(e){return function(t){return null==t?void 0:t[e]}}var sp=op("byteLength"),ap=np(sp),cp=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var hp=xl?function(e){return El?El(e)&&!Zl(e):ap(e)&&cp.test(yl.call(e))}:rp(!1),up=op("length");function lp(e,t){t=function(e){for(var t={},i=e.length,r=0;r<i;++r)t[e[r]]=!0;return{contains:function(e){return t[e]},push:function(i){return t[i]=!0,e.push(i)}}}(t);var i=Nl.length,r=e.constructor,n=ql(r)&&r.prototype||ml,o="constructor";for(Jl(e,o)&&!t.contains(o)&&t.push(o);i--;)(o=Nl[i])in e&&e[o]!==n[o]&&!t.contains(o)&&t.push(o)}function pp(e){if(!Ol(e))return[];if(Sl)return Sl(e);var t=[];for(var i in e)Jl(e,i)&&t.push(i);return Il&&lp(e,t),t}function dp(e,t){var i=pp(t),r=i.length;if(null==e)return!r;for(var n=Object(e),o=0;o<r;o++){var s=i[o];if(t[s]!==n[s]||!(s in n))return!1}return!0}function fp(e){return e instanceof fp?e:this instanceof fp?void(this._wrapped=e):new fp(e)}function mp(e){return new Uint8Array(e.buffer||e,e.byteOffset||0,sp(e))}fp.VERSION=pl,fp.prototype.value=function(){return this._wrapped},fp.prototype.valueOf=fp.prototype.toJSON=fp.prototype.value,fp.prototype.toString=function(){return String(this._wrapped)};var gp="[object DataView]";function vp(e,t,i,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return!1;if(e!=e)return t!=t;var n=typeof e;return("function"===n||"object"===n||"object"==typeof t)&&_p(e,t,i,r)}function _p(e,t,i,r){e instanceof fp&&(e=e._wrapped),t instanceof fp&&(t=t._wrapped);var n=yl.call(e);if(n!==yl.call(t))return!1;if(Ql&&"[object Object]"==n&&Zl(e)){if(!Zl(t))return!1;n=gp}switch(n){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!=+e?+t!=+t:0==+e?1/+e==1/t:+e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object Symbol]":return gl.valueOf.call(e)===gl.valueOf.call(t);case"[object ArrayBuffer]":case gp:return _p(mp(e),mp(t),i,r)}var o="[object Array]"===n;if(!o&&hp(e)){if(sp(e)!==sp(t))return!1;if(e.buffer===t.buffer&&e.byteOffset===t.byteOffset)return!0;o=!0}if(!o){if("object"!=typeof e||"object"!=typeof t)return!1;var s=e.constructor,a=t.constructor;if(s!==a&&!(ql(s)&&s instanceof s&&ql(a)&&a instanceof a)&&"constructor"in e&&"constructor"in t)return!1}r=r||[];for(var c=(i=i||[]).length;c--;)if(i[c]===e)return r[c]===t;if(i.push(e),r.push(t),o){if((c=e.length)!==t.length)return!1;for(;c--;)if(!vp(e[c],t[c],i,r))return!1}else{var h,u=pp(e);if(c=u.length,pp(t).length!==c)return!1;for(;c--;)if(!Jl(t,h=u[c])||!vp(e[h],t[h],i,r))return!1}return i.pop(),r.pop(),!0}function yp(e,t){return vp(e,t)}function bp(e){if(!Ol(e))return[];var t=[];for(var i in e)t.push(i);return Il&&lp(e,t),t}function xp(e){var t=up(e);return function(i){if(null==i)return!1;var r=bp(i);if(up(r))return!1;for(var n=0;n<t;n++)if(!ql(i[e[n]]))return!1;return e!==Ep||!ql(i[wp])}}var wp="forEach",Ap=["clear","delete"],Sp=["get","has","set"],Mp=Ap.concat(wp,Sp),Ep=Ap.concat(Sp),Tp=["add"].concat(Ap,wp,"has"),Cp=Yl?xp(Mp):kl("Map"),Ip=Yl?xp(Ep):kl("WeakMap"),Np=Yl?xp(Tp):kl("Set"),Pp=kl("WeakSet");function Rp(e){for(var t=pp(e),i=t.length,r=Array(i),n=0;n<i;n++)r[n]=e[t[n]];return r}function Op(e){for(var t={},i=pp(e),r=0,n=i.length;r<n;r++)t[e[i[r]]]=i[r];return t}function Dp(e){var t=[];for(var i in e)ql(e[i])&&t.push(i);return t.sort()}function Lp(e,t){return function(i){var r=arguments.length;if(t&&(i=Object(i)),r<2||null==i)return i;for(var n=1;n<r;n++)for(var o=arguments[n],s=e(o),a=s.length,c=0;c<a;c++){var h=s[c];t&&void 0!==i[h]||(i[h]=o[h])}return i}}var kp=Lp(bp),Bp=Lp(pp),Fp=Lp(bp,!0);function jp(e){if(!Ol(e))return{};if(Ml)return Ml(e);var t=function(){};t.prototype=e;var i=new t;return t.prototype=null,i}function zp(e){return Ol(e)?Kl(e)?e.slice():kp({},e):e}function $p(e){return Kl(e)?e:[e]}function Vp(e){return fp.toPath(e)}function Up(e,t){for(var i=t.length,r=0;r<i;r++){if(null==e)return;e=e[t[r]]}return i?e:void 0}function Gp(e,t,i){var r=Up(e,Vp(t));return Dl(r)?i:r}function Hp(e){return e}function qp(e){return e=Bp({},e),function(t){return dp(t,e)}}function Wp(e){return e=Vp(e),function(t){return Up(t,e)}}function Qp(e,t,i){if(void 0===t)return e;switch(null==i?3:i){case 1:return function(i){return e.call(t,i)};case 3:return function(i,r,n){return e.call(t,i,r,n)};case 4:return function(i,r,n,o){return e.call(t,i,r,n,o)}}return function(){return e.apply(t,arguments)}}function Yp(e,t,i){return null==e?Hp:ql(e)?Qp(e,t,i):Ol(e)&&!Kl(e)?qp(e):Wp(e)}function Xp(e,t){return Yp(e,t,1/0)}function Zp(e,t,i){return fp.iteratee!==Xp?fp.iteratee(e,t):Yp(e,t,i)}function Kp(){}function Jp(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))}fp.toPath=$p,fp.iteratee=Xp;var ed=Date.now||function(){return(new Date).getTime()};function td(e){var t=function(t){return e[t]},i="(?:"+pp(e).join("|")+")",r=RegExp(i),n=RegExp(i,"g");return function(e){return e=null==e?"":""+e,r.test(e)?e.replace(n,t):e}}var id={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},rd=td(id),nd=td(Op(id)),od=fp.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},sd=/(.)^/,ad={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},cd=/\\|'|\r|\n|\u2028|\u2029/g;function hd(e){return"\\"+ad[e]}var ud=0;function ld(e,t,i,r,n){if(!(r instanceof t))return e.apply(i,n);var o=jp(e.prototype),s=e.apply(o,n);return Ol(s)?s:o}var pd=Rl((function(e,t){var i=pd.placeholder,r=function(){for(var n=0,o=t.length,s=Array(o),a=0;a<o;a++)s[a]=t[a]===i?arguments[n++]:t[a];for(;n<arguments.length;)s.push(arguments[n++]);return ld(e,r,this,this,s)};return r}));pd.placeholder=fp;var dd=Rl((function(e,t,i){if(!ql(e))throw new TypeError("Bind must be called on a function");var r=Rl((function(n){return ld(e,r,t,this,i.concat(n))}));return r})),fd=np(up);function md(e,t,i,r){if(r=r||[],t||0===t){if(t<=0)return r.concat(e)}else t=1/0;for(var n=r.length,o=0,s=up(e);o<s;o++){var a=e[o];if(fd(a)&&(Kl(a)||tp(a)))if(t>1)md(a,t-1,i,r),n=r.length;else for(var c=0,h=a.length;c<h;)r[n++]=a[c++];else i||(r[n++]=a)}return r}var gd=Rl((function(e,t){var i=(t=md(t,!1,!1)).length;if(i<1)throw new Error("bindAll must be passed function names");for(;i--;){var r=t[i];e[r]=dd(e[r],e)}return e}));var vd=Rl((function(e,t,i){return setTimeout((function(){return e.apply(null,i)}),t)})),_d=pd(vd,fp,1);function yd(e){return function(){return!e.apply(this,arguments)}}function bd(e,t){var i;return function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=null),i}}var xd=pd(bd,2);function wd(e,t,i){t=Zp(t,i);for(var r,n=pp(e),o=0,s=n.length;o<s;o++)if(t(e[r=n[o]],r,e))return r}function Ad(e){return function(t,i,r){i=Zp(i,r);for(var n=up(t),o=e>0?0:n-1;o>=0&&o<n;o+=e)if(i(t[o],o,t))return o;return-1}}var Sd=Ad(1),Md=Ad(-1);function Ed(e,t,i,r){for(var n=(i=Zp(i,r,1))(t),o=0,s=up(e);o<s;){var a=Math.floor((o+s)/2);i(e[a])<n?o=a+1:s=a}return o}function Td(e,t,i){return function(r,n,o){var s=0,a=up(r);if("number"==typeof o)e>0?s=o>=0?o:Math.max(o+a,s):a=o>=0?Math.min(o+1,a):o+a+1;else if(i&&o&&a)return r[o=i(r,n)]===n?o:-1;if(n!=n)return(o=t(_l.call(r,s,a),ip))>=0?o+s:-1;for(o=e>0?s:a-1;o>=0&&o<a;o+=e)if(r[o]===n)return o;return-1}}var Cd=Td(1,Sd,Ed),Id=Td(-1,Md);function Nd(e,t,i){var r=(fd(e)?Sd:wd)(e,t,i);if(void 0!==r&&-1!==r)return e[r]}function Pd(e,t,i){var r,n;if(t=Qp(t,i),fd(e))for(r=0,n=e.length;r<n;r++)t(e[r],r,e);else{var o=pp(e);for(r=0,n=o.length;r<n;r++)t(e[o[r]],o[r],e)}return e}function Rd(e,t,i){t=Zp(t,i);for(var r=!fd(e)&&pp(e),n=(r||e).length,o=Array(n),s=0;s<n;s++){var a=r?r[s]:s;o[s]=t(e[a],a,e)}return o}function Od(e){var t=function(t,i,r,n){var o=!fd(t)&&pp(t),s=(o||t).length,a=e>0?0:s-1;for(n||(r=t[o?o[a]:a],a+=e);a>=0&&a<s;a+=e){var c=o?o[a]:a;r=i(r,t[c],c,t)}return r};return function(e,i,r,n){var o=arguments.length>=3;return t(e,Qp(i,n,4),r,o)}}var Dd=Od(1),Ld=Od(-1);function kd(e,t,i){var r=[];return t=Zp(t,i),Pd(e,(function(e,i,n){t(e,i,n)&&r.push(e)})),r}function Bd(e,t,i){t=Zp(t,i);for(var r=!fd(e)&&pp(e),n=(r||e).length,o=0;o<n;o++){var s=r?r[o]:o;if(!t(e[s],s,e))return!1}return!0}function Fd(e,t,i){t=Zp(t,i);for(var r=!fd(e)&&pp(e),n=(r||e).length,o=0;o<n;o++){var s=r?r[o]:o;if(t(e[s],s,e))return!0}return!1}function jd(e,t,i,r){return fd(e)||(e=Rp(e)),("number"!=typeof i||r)&&(i=0),Cd(e,t,i)>=0}var zd=Rl((function(e,t,i){var r,n;return ql(t)?n=t:(t=Vp(t),r=t.slice(0,-1),t=t[t.length-1]),Rd(e,(function(e){var o=n;if(!o){if(r&&r.length&&(e=Up(e,r)),null==e)return;o=e[t]}return null==o?o:o.apply(e,i)}))}));function $d(e,t){return Rd(e,Wp(t))}function Vd(e,t,i){var r,n,o=-1/0,s=-1/0;if(null==t||"number"==typeof t&&"object"!=typeof e[0]&&null!=e)for(var a=0,c=(e=fd(e)?e:Rp(e)).length;a<c;a++)null!=(r=e[a])&&r>o&&(o=r);else t=Zp(t,i),Pd(e,(function(e,i,r){((n=t(e,i,r))>s||n===-1/0&&o===-1/0)&&(o=e,s=n)}));return o}function Ud(e,t,i){var r,n,o=1/0,s=1/0;if(null==t||"number"==typeof t&&"object"!=typeof e[0]&&null!=e)for(var a=0,c=(e=fd(e)?e:Rp(e)).length;a<c;a++)null!=(r=e[a])&&r<o&&(o=r);else t=Zp(t,i),Pd(e,(function(e,i,r){((n=t(e,i,r))<s||n===1/0&&o===1/0)&&(o=e,s=n)}));return o}function Gd(e,t,i){if(null==t||i)return fd(e)||(e=Rp(e)),e[Jp(e.length-1)];var r=fd(e)?zp(e):Rp(e),n=up(r);t=Math.max(Math.min(t,n),0);for(var o=n-1,s=0;s<t;s++){var a=Jp(s,o),c=r[s];r[s]=r[a],r[a]=c}return r.slice(0,t)}function Hd(e,t){return function(i,r,n){var o=t?[[],[]]:{};return r=Zp(r,n),Pd(i,(function(t,n){var s=r(t,n,i);e(o,t,s)})),o}}var qd=Hd((function(e,t,i){Jl(e,i)?e[i].push(t):e[i]=[t]})),Wd=Hd((function(e,t,i){e[i]=t})),Qd=Hd((function(e,t,i){Jl(e,i)?e[i]++:e[i]=1})),Yd=Hd((function(e,t,i){e[i?0:1].push(t)}),!0),Xd=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;function Zd(e,t,i){return t in i}var Kd=Rl((function(e,t){var i={},r=t[0];if(null==e)return i;ql(r)?(t.length>1&&(r=Qp(r,t[1])),t=bp(e)):(r=Zd,t=md(t,!1,!1),e=Object(e));for(var n=0,o=t.length;n<o;n++){var s=t[n],a=e[s];r(a,s,e)&&(i[s]=a)}return i})),Jd=Rl((function(e,t){var i,r=t[0];return ql(r)?(r=yd(r),t.length>1&&(i=t[1])):(t=Rd(md(t,!1,!1),String),r=function(e,i){return!jd(t,i)}),Kd(e,r,i)}));function ef(e,t,i){return _l.call(e,0,Math.max(0,e.length-(null==t||i?1:t)))}function tf(e,t,i){return null==e||e.length<1?null==t||i?void 0:[]:null==t||i?e[0]:ef(e,e.length-t)}function rf(e,t,i){return _l.call(e,null==t||i?1:t)}function nf(e,t,i){return null==e||e.length<1?null==t||i?void 0:[]:null==t||i?e[e.length-1]:rf(e,Math.max(0,e.length-t))}function of(e,t){return md(e,t,!1)}var sf=Rl((function(e,t){return t=md(t,!0,!0),kd(e,(function(e){return!jd(t,e)}))})),af=Rl((function(e,t){return sf(e,t)}));function cf(e,t,i,r){Ll(t)||(r=i,i=t,t=!1),null!=i&&(i=Zp(i,r));for(var n=[],o=[],s=0,a=up(e);s<a;s++){var c=e[s],h=i?i(c,s,e):c;t&&!i?(s&&o===h||n.push(c),o=h):i?jd(o,h)||(o.push(h),n.push(c)):jd(n,c)||n.push(c)}return n}var hf=Rl((function(e){return cf(md(e,!0,!0))}));function uf(e){for(var t=e&&Vd(e,up).length||0,i=Array(t),r=0;r<t;r++)i[r]=$d(e,r);return i}var lf=Rl(uf);function pf(e,t){return e._chain?fp(t).chain():t}function df(e){return Pd(Dp(e),(function(t){var i=fp[t]=e[t];fp.prototype[t]=function(){var e=[this._wrapped];return vl.apply(e,arguments),pf(this,i.apply(fp,e))}})),fp}Pd(["pop","push","reverse","shift","sort","splice","unshift"],(function(e){var t=fl[e];fp.prototype[e]=function(){var i=this._wrapped;return null!=i&&(t.apply(i,arguments),"shift"!==e&&"splice"!==e||0!==i.length||delete i[0]),pf(this,i)}})),Pd(["concat","join","slice"],(function(e){var t=fl[e];fp.prototype[e]=function(){var e=this._wrapped;return null!=e&&(e=t.apply(e,arguments)),pf(this,e)}}));var ff=Object.freeze({__proto__:null,VERSION:pl,restArguments:Rl,isObject:Ol,isNull:function(e){return null===e},isUndefined:Dl,isBoolean:Ll,isElement:function(e){return!(!e||1!==e.nodeType)},isString:Bl,isNumber:Fl,isDate:jl,isRegExp:zl,isError:$l,isSymbol:Vl,isArrayBuffer:Ul,isDataView:Zl,isArray:Kl,isFunction:ql,isArguments:tp,isFinite:function(e){return!Vl(e)&&Cl(e)&&!isNaN(parseFloat(e))},isNaN:ip,isTypedArray:hp,isEmpty:function(e){if(null==e)return!0;var t=up(e);return"number"==typeof t&&(Kl(e)||Bl(e)||tp(e))?0===t:0===up(pp(e))},isMatch:dp,isEqual:yp,isMap:Cp,isWeakMap:Ip,isSet:Np,isWeakSet:Pp,keys:pp,allKeys:bp,values:Rp,pairs:function(e){for(var t=pp(e),i=t.length,r=Array(i),n=0;n<i;n++)r[n]=[t[n],e[t[n]]];return r},invert:Op,functions:Dp,methods:Dp,extend:kp,extendOwn:Bp,assign:Bp,defaults:Fp,create:function(e,t){var i=jp(e);return t&&Bp(i,t),i},clone:zp,tap:function(e,t){return t(e),e},get:Gp,has:function(e,t){for(var i=(t=Vp(t)).length,r=0;r<i;r++){var n=t[r];if(!Jl(e,n))return!1;e=e[n]}return!!i},mapObject:function(e,t,i){t=Zp(t,i);for(var r=pp(e),n=r.length,o={},s=0;s<n;s++){var a=r[s];o[a]=t(e[a],a,e)}return o},identity:Hp,constant:rp,noop:Kp,toPath:$p,property:Wp,propertyOf:function(e){return null==e?Kp:function(t){return Gp(e,t)}},matcher:qp,matches:qp,times:function(e,t,i){var r=Array(Math.max(0,e));t=Qp(t,i,1);for(var n=0;n<e;n++)r[n]=t(n);return r},random:Jp,now:ed,escape:rd,unescape:nd,templateSettings:od,template:function(e,t,i){!t&&i&&(t=i),t=Fp({},t,fp.templateSettings);var r,n=RegExp([(t.escape||sd).source,(t.interpolate||sd).source,(t.evaluate||sd).source].join("|")+"|$","g"),o=0,s="__p+='";e.replace(n,(function(t,i,r,n,a){return s+=e.slice(o,a).replace(cd,hd),o=a+t.length,i?s+="'+\n((__t=("+i+"))==null?'':_.escape(__t))+\n'":r?s+="'+\n((__t=("+r+"))==null?'':__t)+\n'":n&&(s+="';\n"+n+"\n__p+='"),t})),s+="';\n",t.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";try{r=new Function(t.variable||"obj","_",s)}catch(e){throw e.source=s,e}var a=function(e){return r.call(this,e,fp)},c=t.variable||"obj";return a.source="function("+c+"){\n"+s+"}",a},result:function(e,t,i){var r=(t=Vp(t)).length;if(!r)return ql(i)?i.call(e):i;for(var n=0;n<r;n++){var o=null==e?void 0:e[t[n]];void 0===o&&(o=i,n=r),e=ql(o)?o.call(e):o}return e},uniqueId:function(e){var t=++ud+"";return e?e+t:t},chain:function(e){var t=fp(e);return t._chain=!0,t},iteratee:Xp,partial:pd,bind:dd,bindAll:gd,memoize:function(e,t){var i=function(r){var n=i.cache,o=""+(t?t.apply(this,arguments):r);return Jl(n,o)||(n[o]=e.apply(this,arguments)),n[o]};return i.cache={},i},delay:vd,defer:_d,throttle:function(e,t,i){var r,n,o,s,a=0;i||(i={});var c=function(){a=!1===i.leading?0:ed(),r=null,s=e.apply(n,o),r||(n=o=null)},h=function(){var h=ed();a||!1!==i.leading||(a=h);var u=t-(h-a);return n=this,o=arguments,u<=0||u>t?(r&&(clearTimeout(r),r=null),a=h,s=e.apply(n,o),r||(n=o=null)):r||!1===i.trailing||(r=setTimeout(c,u)),s};return h.cancel=function(){clearTimeout(r),a=0,r=n=o=null},h},debounce:function(e,t,i){var r,n,o=function(t,i){r=null,i&&(n=e.apply(t,i))},s=Rl((function(s){if(r&&clearTimeout(r),i){var a=!r;r=setTimeout(o,t),a&&(n=e.apply(this,s))}else r=vd(o,t,this,s);return n}));return s.cancel=function(){clearTimeout(r),r=null},s},wrap:function(e,t){return pd(t,e)},negate:yd,compose:function(){var e=arguments,t=e.length-1;return function(){for(var i=t,r=e[t].apply(this,arguments);i--;)r=e[i].call(this,r);return r}},after:function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},before:bd,once:xd,findKey:wd,findIndex:Sd,findLastIndex:Md,sortedIndex:Ed,indexOf:Cd,lastIndexOf:Id,find:Nd,detect:Nd,findWhere:function(e,t){return Nd(e,qp(t))},each:Pd,forEach:Pd,map:Rd,collect:Rd,reduce:Dd,foldl:Dd,inject:Dd,reduceRight:Ld,foldr:Ld,filter:kd,select:kd,reject:function(e,t,i){return kd(e,yd(Zp(t)),i)},every:Bd,all:Bd,some:Fd,any:Fd,contains:jd,includes:jd,include:jd,invoke:zd,pluck:$d,where:function(e,t){return kd(e,qp(t))},max:Vd,min:Ud,shuffle:function(e){return Gd(e,1/0)},sample:Gd,sortBy:function(e,t,i){var r=0;return t=Zp(t,i),$d(Rd(e,(function(e,i,n){return{value:e,index:r++,criteria:t(e,i,n)}})).sort((function(e,t){var i=e.criteria,r=t.criteria;if(i!==r){if(i>r||void 0===i)return 1;if(i<r||void 0===r)return-1}return e.index-t.index})),"value")},groupBy:qd,indexBy:Wd,countBy:Qd,partition:Yd,toArray:function(e){return e?Kl(e)?_l.call(e):Bl(e)?e.match(Xd):fd(e)?Rd(e,Hp):Rp(e):[]},size:function(e){return null==e?0:fd(e)?e.length:pp(e).length},pick:Kd,omit:Jd,first:tf,head:tf,take:tf,initial:ef,last:nf,rest:rf,tail:rf,drop:rf,compact:function(e){return kd(e,Boolean)},flatten:of,without:af,uniq:cf,unique:cf,union:hf,intersection:function(e){for(var t=[],i=arguments.length,r=0,n=up(e);r<n;r++){var o=e[r];if(!jd(t,o)){var s;for(s=1;s<i&&jd(arguments[s],o);s++);s===i&&t.push(o)}}return t},difference:sf,unzip:uf,transpose:uf,zip:lf,object:function(e,t){for(var i={},r=0,n=up(e);r<n;r++)t?i[e[r]]=t[r]:i[e[r][0]]=e[r][1];return i},range:function(e,t,i){null==t&&(t=e||0,e=0),i||(i=t<e?-1:1);for(var r=Math.max(Math.ceil((t-e)/i),0),n=Array(r),o=0;o<r;o++,e+=i)n[o]=e;return n},chunk:function(e,t){if(null==t||t<1)return[];for(var i=[],r=0,n=e.length;r<n;)i.push(_l.call(e,r,r+=t));return i},mixin:df,default:fp}),mf=df(ff);mf._=mf;var gf="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function vf(e){var t=e.default;if("function"==typeof t){var i=function(){return t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),i}var _f=Array.isArray,yf=Object.prototype.toString,bf=_f||function(e){return"[object Array]"===yf.call(e)};wf.NONE=0,wf.VTEXT=1,wf.VNODE=2,wf.WIDGET=3,wf.PROPS=4,wf.ORDER=5,wf.INSERT=6,wf.REMOVE=7,wf.THUNK=8;var xf=wf;function wf(e,t,i){this.type=Number(e),this.vNode=t,this.patch=i}wf.prototype.version="2",wf.prototype.type="VirtualPatch";var Af=function(e){return e&&"VirtualNode"===e.type&&"2"===e.version};var Sf=function(e){return e&&"VirtualText"===e.type&&"2"===e.version};var Mf=function(e){return e&&"Widget"===e.type};var Ef=function(e){return e&&"Thunk"===e.type};var Tf=Af,Cf=Sf,If=Mf,Nf=Ef,Pf=function(e,t){var i=e,r=t;Nf(t)&&(r=Rf(t,e));Nf(e)&&(i=Rf(e,null));return{a:i,b:r}};function Rf(e,t){var i=e.vnode;if(i||(i=e.vnode=e.render(t)),!(Tf(i)||Cf(i)||If(i)))throw new Error("thunk did not return a valid node");return i}var Of=function(e){return"object"==typeof e&&null!==e},Df=function(e){return e&&("function"==typeof e.hook&&!e.hasOwnProperty("hook")||"function"==typeof e.unhook&&!e.hasOwnProperty("unhook"))};var Lf=Of,kf=Df,Bf=function e(t,i){var r;for(var n in t){n in i||((r=r||{})[n]=void 0);var o=t[n],s=i[n];if(o!==s)if(Lf(o)&&Lf(s))if(Ff(s)!==Ff(o))(r=r||{})[n]=s;else if(kf(s))(r=r||{})[n]=s;else{var a=e(o,s);a&&((r=r||{})[n]=a)}else(r=r||{})[n]=s}for(var c in i)c in t||((r=r||{})[c]=i[c]);return r};function Ff(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}var jf=bf,zf=xf,$f=Af,Vf=Sf,Uf=Mf,Gf=Ef,Hf=Pf,qf=Bf;function Wf(e,t){var i={a:e};return Qf(e,t,i,0),i}function Qf(e,t,i,r){if(e!==t){var n=i[r],o=!1;if(Gf(e)||Gf(t))Zf(e,t,i,r);else if(null==t)Uf(e)||(Yf(e,i,r),n=i[r]),n=tm(n,new zf(zf.REMOVE,e,t));else if($f(t))if($f(e))if(e.tagName===t.tagName&&e.namespace===t.namespace&&e.key===t.key){var s=qf(e.properties,t.properties);s&&(n=tm(n,new zf(zf.PROPS,e,s))),n=function(e,t,i,r,n){for(var o=e.children,s=function(e,t){var i=em(t),r=i.keys,n=i.free;if(n.length===t.length)return{children:t,moves:null};var o=em(e),s=o.keys;if(o.free.length===e.length)return{children:t,moves:null};for(var a=[],c=0,h=n.length,u=0,l=0;l<e.length;l++){var p,d=e[l];d.key?r.hasOwnProperty(d.key)?(p=r[d.key],a.push(t[p])):(p=l-u++,a.push(null)):c<h?(p=n[c++],a.push(t[p])):(p=l-u++,a.push(null))}for(var f=c>=n.length?t.length:n[c],m=0;m<t.length;m++){var g=t[m];g.key?s.hasOwnProperty(g.key)||a.push(g):m>=f&&a.push(g)}for(var v,_=a.slice(),y=0,b=[],x=[],w=0;w<t.length;){var A=t[w];for(v=_[y];null===v&&_.length;)b.push(Jf(_,y,null)),v=_[y];v&&v.key===A.key?(y++,w++):A.key?(v&&v.key&&r[v.key]!==w+1?(b.push(Jf(_,y,v.key)),(v=_[y])&&v.key===A.key?y++:x.push({key:A.key,to:w})):x.push({key:A.key,to:w}),w++):v&&v.key&&b.push(Jf(_,y,v.key))}for(;y<_.length;)v=_[y],b.push(Jf(_,y,v&&v.key));if(b.length===u&&!x.length)return{children:a,moves:null};return{children:a,moves:{removes:b,inserts:x}}}(o,t.children),a=s.children,c=o.length,h=a.length,u=c>h?c:h,l=0;l<u;l++){var p=o[l],d=a[l];n+=1,p?Qf(p,d,i,n):d&&(r=tm(r,new zf(zf.INSERT,null,d))),$f(p)&&p.count&&(n+=p.count)}s.moves&&(r=tm(r,new zf(zf.ORDER,e,s.moves)));return r}(e,t,i,n,r)}else n=tm(n,new zf(zf.VNODE,e,t)),o=!0;else n=tm(n,new zf(zf.VNODE,e,t)),o=!0;else Vf(t)?Vf(e)?e.text!==t.text&&(n=tm(n,new zf(zf.VTEXT,e,t))):(n=tm(n,new zf(zf.VTEXT,e,t)),o=!0):Uf(t)&&(Uf(e)||(o=!0),n=tm(n,new zf(zf.WIDGET,e,t)));n&&(i[r]=n),o&&Yf(e,i,r)}}function Yf(e,t,i){Kf(e,t,i),Xf(e,t,i)}function Xf(e,t,i){if(Uf(e))"function"==typeof e.destroy&&(t[i]=tm(t[i],new zf(zf.REMOVE,e,null)));else if($f(e)&&(e.hasWidgets||e.hasThunks))for(var r=e.children,n=r.length,o=0;o<n;o++){var s=r[o];Xf(s,t,i+=1),$f(s)&&s.count&&(i+=s.count)}else Gf(e)&&Zf(e,null,t,i)}function Zf(e,t,i,r){var n=Hf(e,t),o=Wf(n.a,n.b);(function(e){for(var t in e)if("a"!==t)return!0;return!1})(o)&&(i[r]=new zf(zf.THUNK,null,o))}function Kf(e,t,i){if($f(e)){if(e.hooks&&(t[i]=tm(t[i],new zf(zf.PROPS,e,function(e){var t={};for(var i in e)t[i]=void 0;return t}(e.hooks)))),e.descendantHooks||e.hasThunks)for(var r=e.children,n=r.length,o=0;o<n;o++){var s=r[o];Kf(s,t,i+=1),$f(s)&&s.count&&(i+=s.count)}}else Gf(e)&&Zf(e,null,t,i)}function Jf(e,t,i){return e.splice(t,1),{from:t,key:i}}function em(e){for(var t={},i=[],r=e.length,n=0;n<r;n++){var o=e[n];o.key?t[o.key]=n:i.push(n)}return{keys:t,free:i}}function tm(e,t){return e?(jf(e)?e.push(t):e=[e,t],e):t}var im=Wf,rm=Array.prototype.slice,nm=function(e,t){"length"in e||(e=[e]);e=rm.call(e);for(;e.length;){var i=e.shift(),r=t(i);if(r)return r;i.childNodes&&i.childNodes.length&&(e=rm.call(i.childNodes).concat(e))}};var om=sm;function sm(e,t){if(!(this instanceof sm))return new sm(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}sm.prototype.nodeType=8,sm.prototype.nodeName="#comment",sm.prototype.toString=function(){return"[object Comment]"};var am=cm;function cm(e,t){if(!(this instanceof cm))return new cm(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}cm.prototype.type="DOMTextNode",cm.prototype.nodeType=3,cm.prototype.nodeName="#text",cm.prototype.toString=function(){return this.data},cm.prototype.replaceData=function(e,t,i){var r=this.data,n=r.substring(0,e),o=r.substring(e+t,r.length);this.data=n+i+o,this.length=this.data.length};var hm=function(e){var t=this,i=e.type;e.target||(e.target=t);t.listeners||(t.listeners={});var r=t.listeners[i];if(r)return r.forEach((function(i){e.currentTarget=t,"function"==typeof i?i(e):i.handleEvent(e)}));t.parentNode&&t.parentNode.dispatchEvent(e)};var um=function(e,t){var i=this;i.listeners||(i.listeners={});i.listeners[e]||(i.listeners[e]=[]);-1===i.listeners[e].indexOf(t)&&i.listeners[e].push(t)};var lm=function(e,t){var i=this;if(!i.listeners)return;if(!i.listeners[e])return;var r=i.listeners[e],n=r.indexOf(t);-1!==n&&r.splice(n,1)};var pm=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function dm(e){switch(e.nodeType){case 3:return gm(e.data);case 8:return"\x3c!--"+e.data+"--\x3e";default:return function(e){var t=[],i=e.tagName;"http://www.w3.org/1999/xhtml"===e.namespaceURI&&(i=i.toLowerCase());t.push("<"+i+function(e){var t=[];for(var i in e)fm(e,i)&&t.push({name:i,value:e[i]});for(var r in e._attributes)for(var n in e._attributes[r]){var o=e._attributes[r][n],s=(o.prefix?o.prefix+":":"")+n;t.push({name:s,value:o.value})}e.className&&t.push({name:"class",value:e.className});return t.length?mm(t):""}(e)+function(e){var t=e.dataset,i=[];for(var r in t)i.push({name:"data-"+r,value:t[r]});return i.length?mm(i):""}(e)),pm.indexOf(i)>-1?t.push(" />"):(t.push(">"),e.childNodes.length?t.push.apply(t,e.childNodes.map(dm)):e.textContent||e.innerText?t.push(gm(e.textContent||e.innerText)):e.innerHTML&&t.push(e.innerHTML),t.push("</"+i+">"));return t.join("")}(e)}}function fm(e,t){var i=typeof e[t];return"style"===t&&Object.keys(e.style).length>0||e.hasOwnProperty(t)&&("string"===i||"boolean"===i||"number"===i)&&"nodeName"!==t&&"className"!==t&&"tagName"!==t&&"textContent"!==t&&"innerText"!==t&&"namespaceURI"!==t&&"innerHTML"!==t}function mm(e){var t=[];return e.forEach((function(e){var i=e.name,r=e.value;"style"===i&&(r=function(e){if("string"==typeof e)return e;var t="";return Object.keys(e).forEach((function(i){var r=e[i];i=i.replace(/[A-Z]/g,(function(e){return"-"+e.toLowerCase()})),t+=i+":"+r+";"})),t}(r)),t.push(i+'="'+(gm(r).replace(/"/g,""")+'"'))})),t.length?" "+t.join(" "):""}function gm(e){var t="";return"string"==typeof e?t=e:e&&(t=e.toString()),t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var vm=nm,_m=hm,ym=um,bm=lm,xm=dm,wm="http://www.w3.org/1999/xhtml",Am=Sm;function Sm(e,t,i){if(!(this instanceof Sm))return new Sm(e);var r=void 0===i?wm:i||null;this.tagName=r===wm?String(e).toUpperCase():e,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=t||null,this.namespaceURI=r,this._attributes={},"INPUT"===this.tagName&&(this.type="text")}Sm.prototype.type="DOMElement",Sm.prototype.nodeType=1,Sm.prototype.appendChild=function(e){return e.parentNode&&e.parentNode.removeChild(e),this.childNodes.push(e),e.parentNode=this,e},Sm.prototype.replaceChild=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=this.childNodes.indexOf(t);return t.parentNode=null,this.childNodes[i]=e,e.parentNode=this,t},Sm.prototype.removeChild=function(e){var t=this.childNodes.indexOf(e);return this.childNodes.splice(t,1),e.parentNode=null,e},Sm.prototype.insertBefore=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=null==t?-1:this.childNodes.indexOf(t);return i>-1?this.childNodes.splice(i,0,e):this.childNodes.push(e),e.parentNode=this,e},Sm.prototype.setAttributeNS=function(e,t,i){var r=null,n=t,o=t.indexOf(":");(o>-1&&(r=t.substr(0,o),n=t.substr(o+1)),"INPUT"===this.tagName&&"type"===t)?this.type=i:(this._attributes[e]||(this._attributes[e]={}))[n]={value:i,prefix:r}},Sm.prototype.getAttributeNS=function(e,t){var i=this._attributes[e],r=i&&i[t]&&i[t].value;return"INPUT"===this.tagName&&"type"===t?this.type:"string"!=typeof r?null:r},Sm.prototype.removeAttributeNS=function(e,t){var i=this._attributes[e];i&&delete i[t]},Sm.prototype.hasAttributeNS=function(e,t){var i=this._attributes[e];return!!i&&t in i},Sm.prototype.setAttribute=function(e,t){return this.setAttributeNS(null,e,t)},Sm.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)},Sm.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)},Sm.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)},Sm.prototype.removeEventListener=bm,Sm.prototype.addEventListener=ym,Sm.prototype.dispatchEvent=_m,Sm.prototype.focus=function(){},Sm.prototype.toString=function(){return xm(this)},Sm.prototype.getElementsByClassName=function(e){var t=e.split(" "),i=[];return vm(this,(function(e){if(1===e.nodeType){var r=(e.className||"").split(" ");t.every((function(e){return-1!==r.indexOf(e)}))&&i.push(e)}})),i},Sm.prototype.getElementsByTagName=function(e){e=e.toLowerCase();var t=[];return vm(this.childNodes,(function(i){1!==i.nodeType||"*"!==e&&i.tagName.toLowerCase()!==e||t.push(i)})),t},Sm.prototype.contains=function(e){return vm(this,(function(t){return e===t}))||!1};var Mm=Am,Em=Tm;function Tm(e){if(!(this instanceof Tm))return new Tm;this.childNodes=[],this.parentNode=null,this.ownerDocument=e||null}Tm.prototype.type="DocumentFragment",Tm.prototype.nodeType=11,Tm.prototype.nodeName="#document-fragment",Tm.prototype.appendChild=Mm.prototype.appendChild,Tm.prototype.replaceChild=Mm.prototype.replaceChild,Tm.prototype.removeChild=Mm.prototype.removeChild,Tm.prototype.toString=function(){return this.childNodes.map((function(e){return String(e)})).join("")};var Cm=Im;function Im(e){}Im.prototype.initEvent=function(e,t,i){this.type=e,this.bubbles=t,this.cancelable=i},Im.prototype.preventDefault=function(){};var Nm=nm,Pm=om,Rm=am,Om=Am,Dm=Em,Lm=Cm,km=hm,Bm=um,Fm=lm,jm=zm;function zm(){if(!(this instanceof zm))return new zm;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var $m=zm.prototype;$m.createTextNode=function(e){return new Rm(e,this)},$m.createElementNS=function(e,t){var i=null===e?null:String(e);return new Om(t,this,i)},$m.createElement=function(e){return new Om(e,this)},$m.createDocumentFragment=function(){return new Dm(this)},$m.createEvent=function(e){return new Lm},$m.createComment=function(e){return new Pm(e,this)},$m.getElementById=function(e){return e=String(e),Nm(this.childNodes,(function(t){if(String(t.id)===e)return t}))||null},$m.getElementsByClassName=Om.prototype.getElementsByClassName,$m.getElementsByTagName=Om.prototype.getElementsByTagName,$m.contains=Om.prototype.contains,$m.removeEventListener=Fm,$m.addEventListener=Bm,$m.dispatchEvent=km;var Vm,Um=new jm,Gm=void 0!==gf?gf:"undefined"!=typeof window?window:{},Hm=Um;"undefined"!=typeof document?Vm=document:(Vm=Gm["__GLOBAL_DOCUMENT_CACHE@4"])||(Vm=Gm["__GLOBAL_DOCUMENT_CACHE@4"]=Hm);var qm=Of,Wm=Df,Qm=function(e,t,i){for(var r in t){var n=t[r];void 0===n?Ym(e,r,n,i):Wm(n)?(Ym(e,r,n,i),n.hook&&n.hook(e,r,i?i[r]:void 0)):qm(n)?Xm(e,t,i,r,n):e[r]=n}};function Ym(e,t,i,r){if(r){var n=r[t];if(Wm(n))n.unhook&&n.unhook(e,t,i);else if("attributes"===t)for(var o in n)e.removeAttribute(o);else if("style"===t)for(var s in n)e.style[s]="";else e[t]="string"==typeof n?"":null}}function Xm(e,t,i,r,n){var o=i?i[r]:void 0;if("attributes"!==r)if(o&&qm(o)&&Zm(o)!==Zm(n))e[r]=n;else{qm(e[r])||(e[r]={});var s="style"===r?"":void 0;for(var a in n){var c=n[a];e[r][a]=void 0===c?s:c}}else for(var h in n){var u=n[h];void 0===u?e.removeAttribute(h):e.setAttribute(h,u)}}function Zm(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}var Km=Vm,Jm=Qm,eg=Af,tg=Sf,ig=Mf,rg=Pf,ng=function e(t,i){var r=i&&i.document||Km,n=i?i.warn:null;if(t=rg(t).a,ig(t))return t.init();if(tg(t))return r.createTextNode(t.text);if(!eg(t))return n&&n("Item is not a valid virtual dom node",t),null;var o=null===t.namespace?r.createElement(t.tagName):r.createElementNS(t.namespace,t.tagName),s=t.properties;Jm(o,s);for(var a=t.children,c=0;c<a.length;c++){var h=e(a[c],i);h&&o.appendChild(h)}return o};var og={};function sg(e,t,i,r,n){if(r=r||{},e){ag(i,n,n)&&(r[n]=e);var o=t.children;if(o)for(var s=e.childNodes,a=0;a<t.children.length;a++){n+=1;var c=o[a]||og,h=n+(c.count||0);ag(i,n,h)&&sg(s[a],c,i,r,n),n=h}}return r}function ag(e,t,i){if(0===e.length)return!1;for(var r,n,o=0,s=e.length-1;o<=s;){if(n=e[r=(s+o)/2>>0],o===s)return n>=t&&n<=i;if(n<t)o=r+1;else{if(!(n>i))return!0;s=r-1}}return!1}function cg(e,t){return e>t?1:-1}var hg=Mf;var ug=Qm,lg=Mf,pg=xf,dg=function(e,t){if(hg(e)&&hg(t))return"name"in e&&"name"in t?e.id===t.id:e.init===t.init;return!1},fg=function(e,t,i){var r=e.type,n=e.vNode,o=e.patch;switch(r){case pg.REMOVE:return function(e,t){var i=e.parentNode;i&&i.removeChild(e);return mg(e,t),null}(t,n);case pg.INSERT:return function(e,t,i){var r=i.render(t,i);e&&e.appendChild(r);return e}(t,o,i);case pg.VTEXT:return function(e,t,i,r){var n;if(3===e.nodeType)e.replaceData(0,e.length,i.text),n=e;else{var o=e.parentNode;n=r.render(i,r),o&&n!==e&&o.replaceChild(n,e)}return n}(t,0,o,i);case pg.WIDGET:return function(e,t,i,r){var n,o=dg(t,i);n=o?i.update(t,e)||e:r.render(i,r);var s=e.parentNode;s&&n!==e&&s.replaceChild(n,e);o||mg(e,t);return n}(t,n,o,i);case pg.VNODE:return function(e,t,i,r){var n=e.parentNode,o=r.render(i,r);n&&o!==e&&n.replaceChild(o,e);return o}(t,0,o,i);case pg.ORDER:return function(e,t){for(var i,r,n,o=e.childNodes,s={},a=0;a<t.removes.length;a++)i=o[(r=t.removes[a]).from],r.key&&(s[r.key]=i),e.removeChild(i);for(var c=o.length,h=0;h<t.inserts.length;h++)i=s[(n=t.inserts[h]).key],e.insertBefore(i,n.to>=c++?null:o[n.to])}(t,o),t;case pg.PROPS:return ug(t,o,n.properties),t;case pg.THUNK:return function(e,t){e&&t&&e!==t&&e.parentNode&&e.parentNode.replaceChild(t,e);return t}(t,i.patch(t,o,i));default:return t}};function mg(e,t){"function"==typeof t.destroy&&lg(t)&&t.destroy(e)}var gg=Vm,vg=bf,_g=ng,yg=function(e,t,i,r){return i&&0!==i.length?(i.sort(cg),sg(e,t,i,r,0)):{}},bg=fg,xg=function e(t,i,r){return(r=r||{}).patch=r.patch&&r.patch!==e?r.patch:wg,r.render=r.render||_g,r.patch(t,i,r)};function wg(e,t,i){var r=function(e){var t=[];for(var i in e)"a"!==i&&t.push(Number(i));return t}(t);if(0===r.length)return e;var n=yg(e,t.a,r),o=e.ownerDocument;i.document||o===gg||(i.document=o);for(var s=0;s<r.length;s++){var a=r[s];e=Ag(e,n[a],t[a],i)}return e}function Ag(e,t,i,r){if(!t)return e;var n;if(vg(i))for(var o=0;o<i.length;o++)n=bg(i[o],t,r),t===e&&(e=n);else n=bg(i,t,r),t===e&&(e=n);return e}var Sg=xg,Mg=Af,Eg=Mf,Tg=Ef,Cg=Df,Ig=Rg,Ng={},Pg=[];function Rg(e,t,i,r,n){this.tagName=e,this.properties=t||Ng,this.children=i||Pg,this.key=null!=r?String(r):void 0,this.namespace="string"==typeof n?n:null;var o,s=i&&i.length||0,a=0,c=!1,h=!1,u=!1;for(var l in t)if(t.hasOwnProperty(l)){var p=t[l];Cg(p)&&p.unhook&&(o||(o={}),o[l]=p)}for(var d=0;d<s;d++){var f=i[d];Mg(f)?(a+=f.count||0,!c&&f.hasWidgets&&(c=!0),!h&&f.hasThunks&&(h=!0),u||!f.hooks&&!f.descendantHooks||(u=!0)):!c&&Eg(f)?"function"==typeof f.destroy&&(c=!0):!h&&Tg(f)&&(h=!0)}this.count=s+a,this.hasWidgets=c,this.hasThunks=h,this.hooks=o,this.descendantHooks=u}Rg.prototype.version="2",Rg.prototype.type="VirtualNode";var Og=Dg;function Dg(e){this.text=String(e)}Dg.prototype.version="2",Dg.prototype.type="VirtualText";
|
|
2
|
+
/*!
|
|
3
|
+
* Cross-Browser Split 1.1.1
|
|
4
|
+
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
|
|
5
|
+
* Available under the MIT License
|
|
6
|
+
* ECMAScript compliant, uniform cross-browser split method
|
|
7
|
+
*/
|
|
8
|
+
var Lg=function(e){var t,i=String.prototype.split,r=/()??/.exec("")[1]===e;return t=function(t,n,o){if("[object RegExp]"!==Object.prototype.toString.call(n))return i.call(t,n,o);var s,a,c,h,u=[],l=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.extended?"x":"")+(n.sticky?"y":""),p=0;n=new RegExp(n.source,l+"g");for(t+="",r||(s=new RegExp("^"+n.source+"$(?!\\s)",l)),o=o===e?-1>>>0:o>>>0;(a=n.exec(t))&&!((c=a.index+a[0].length)>p&&(u.push(t.slice(p,a.index)),!r&&a.length>1&&a[0].replace(s,(function(){for(var t=1;t<arguments.length-2;t++)arguments[t]===e&&(a[t]=e)})),a.length>1&&a.index<t.length&&Array.prototype.push.apply(u,a.slice(1)),h=a[0].length,p=c,u.length>=o));)n.lastIndex===a.index&&n.lastIndex++;return p===t.length?!h&&n.test("")||u.push(""):u.push(t.slice(p)),u.length>o?u.slice(0,o):u},t}(),kg=Lg,Bg=/([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/,Fg=/^\.|#/,jg=function(e,t){if(!e)return"DIV";var i,r,n,o,s=!t.hasOwnProperty("id"),a=kg(e,Bg),c=null;Fg.test(a[1])&&(c="DIV");for(o=0;o<a.length;o++)(r=a[o])&&(n=r.charAt(0),c?"."===n?(i=i||[]).push(r.substring(1,r.length)):"#"===n&&s&&(t.id=r.substring(1,r.length)):c=r);i&&(t.className&&i.push(t.className),t.className=i.join(" "));return t.namespace?c:c.toUpperCase()};var zg=$g;function $g(e){if(!(this instanceof $g))return new $g(e);this.value=e}$g.prototype.hook=function(e,t){e[t]!==this.value&&(e[t]=this.value)};var Vg="undefined"!=typeof window?window:void 0!==gf?gf:{};var Ug=function(e,t){if(e in Vg)return Vg[e];return Vg[e]=t,t},Gg=function(e,t,i){var r="__INDIVIDUAL_ONE_VERSION_"+e,n=Ug(r+"_ENFORCE_SINGLETON",t);if(n!==t)throw new Error("Can only have one copy of "+e+".\nYou already have version "+n+" installed.\nThis means you cannot install version "+t);return Ug(r,i)};Gg("ev-store","7");var Hg="__EV_STORE_KEY@7";var qg=function(e){var t=e[Hg];t||(t=e[Hg]={});return t},Wg=Qg;function Qg(e){if(!(this instanceof Qg))return new Qg(e);this.value=e}Qg.prototype.hook=function(e,t){qg(e)[t.substr(3)]=this.value},Qg.prototype.unhook=function(e,t){qg(e)[t.substr(3)]=void 0};var Yg=bf,Xg=Ig,Zg=Og,Kg=Af,Jg=Sf,ev=Mf,tv=Df,iv=Ef,rv=jg,nv=zg,ov=Wg,sv=function(e,t,i){var r,n,o,s,a=[];!i&&(c=t,"string"==typeof c||Yg(c)||cv(c))&&(i=t,n={});var c;r=rv(e,n=n||t||{}),n.hasOwnProperty("key")&&(o=n.key,n.key=void 0);n.hasOwnProperty("namespace")&&(s=n.namespace,n.namespace=void 0);"INPUT"!==r||s||!n.hasOwnProperty("value")||void 0===n.value||tv(n.value)||(n.value=nv(n.value));(function(e){for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];if(tv(i))continue;"ev-"===t.substr(0,3)&&(e[t]=ov(i))}})(n),null!=i&&av(i,a,r,n);return new Xg(r,n,a,o,s)};function av(e,t,i,r){if("string"==typeof e)t.push(new Zg(e));else if("number"==typeof e)t.push(new Zg(String(e)));else if(cv(e))t.push(e);else{if(!Yg(e)){if(null==e)return;throw o={foreignObject:e,parentVnode:{tagName:i,properties:r}},(s=new Error).type="virtual-hyperscript.unexpected.virtual-element",s.message="Unexpected virtual child passed to h().\nExpected a VNode / Vthunk / VWidget / string but:\ngot:\n"+hv(o.foreignObject)+".\nThe parent vnode is:\n"+hv(o.parentVnode),s.foreignObject=o.foreignObject,s.parentVnode=o.parentVnode,s}for(var n=0;n<e.length;n++)av(e[n],t,i,r)}var o,s}function cv(e){return Kg(e)||Jg(e)||ev(e)||iv(e)}function hv(e){try{return JSON.stringify(e,null," ")}catch(t){return String(e)}}var uv={diff:im,patch:Sg,h:sv,create:ng,VNode:Ig,VText:Og},lv=function(e,t){return lv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])},lv(e,t)};function pv(e,t){function i(){this.constructor=e}lv(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var dv=function(){return dv=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},dv.apply(this,arguments)};function fv(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function mv(e,t){var i,r,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(n=2&o[0]?r.return:o[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,o[1])).done)return n;switch(r=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{i=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function gv(){for(var e=0,t=0,i=arguments.length;t<i;t++)e+=arguments[t].length;var r=Array(e),n=0;for(t=0;t<i;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,n++)r[n]=o[s];return r}function vv(e){return"function"==typeof e}var _v=!1,yv={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){e&&(new Error).stack;_v=e},get useDeprecatedSynchronousErrorHandling(){return _v}};function bv(e){setTimeout((function(){throw e}))}var xv={closed:!0,next:function(e){},error:function(e){if(yv.useDeprecatedSynchronousErrorHandling)throw e;bv(e)},complete:function(){}},wv=Array.isArray||function(e){return e&&"number"==typeof e.length};function Av(e){return null!==e&&"object"==typeof e}function Sv(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}Sv.prototype=Object.create(Error.prototype);var Mv=Sv,Ev=function(){function e(e){this.closed=!1,this._parent=null,this._parents=null,this._subscriptions=null,e&&(this._unsubscribe=e)}return e.prototype.unsubscribe=function(){var e,t=!1;if(!this.closed){var i=this,r=i._parent,n=i._parents,o=i._unsubscribe,s=i._subscriptions;this.closed=!0,this._parent=null,this._parents=null,this._subscriptions=null;for(var a=-1,c=n?n.length:0;r;)r.remove(this),r=++a<c&&n[a]||null;if(vv(o))try{o.call(this)}catch(i){t=!0,e=i instanceof Mv?Tv(i.errors):[i]}if(wv(s))for(a=-1,c=s.length;++a<c;){var h=s[a];if(Av(h))try{h.unsubscribe()}catch(i){t=!0,e=e||[],i instanceof Mv?e=e.concat(Tv(i.errors)):e.push(i)}}if(t)throw new Mv(e)}},e.prototype.add=function(t){var i=t;switch(typeof t){case"function":i=new e(t);case"object":if(i===this||i.closed||"function"!=typeof i.unsubscribe)return i;if(this.closed)return i.unsubscribe(),i;if(!(i instanceof e)){var r=i;(i=new e)._subscriptions=[r]}break;default:if(!t)return e.EMPTY;throw new Error("unrecognized teardown "+t+" added to Subscription.")}if(i._addParent(this)){var n=this._subscriptions;n?n.push(i):this._subscriptions=[i]}return i},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var i=t.indexOf(e);-1!==i&&t.splice(i,1)}},e.prototype._addParent=function(e){var t=this._parent,i=this._parents;return t!==e&&(t?i?-1===i.indexOf(e)&&(i.push(e),!0):(this._parents=[e],!0):(this._parent=e,!0))},e.EMPTY=function(e){return e.closed=!0,e}(new e),e}();function Tv(e){return e.reduce((function(e,t){return e.concat(t instanceof Mv?t.errors:t)}),[])}var Cv="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),Iv=function(e){function t(i,r,n){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=xv;break;case 1:if(!i){o.destination=xv;break}if("object"==typeof i){i instanceof t?(o.syncErrorThrowable=i.syncErrorThrowable,o.destination=i,i.add(o)):(o.syncErrorThrowable=!0,o.destination=new Nv(o,i));break}default:o.syncErrorThrowable=!0,o.destination=new Nv(o,i,r,n)}return o}return pv(t,e),t.prototype[Cv]=function(){return this},t.create=function(e,i,r){var n=new t(e,i,r);return n.syncErrorThrowable=!1,n},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parent,t=this._parents;return this._parent=null,this._parents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parent=e,this._parents=t,this},t}(Ev),Nv=function(e){function t(t,i,r,n){var o,s=e.call(this)||this;s._parentSubscriber=t;var a=s;return vv(i)?o=i:i&&(o=i.next,r=i.error,n=i.complete,i!==xv&&(vv((a=Object.create(i)).unsubscribe)&&s.add(a.unsubscribe.bind(a)),a.unsubscribe=s.unsubscribe.bind(s))),s._context=a,s._next=o,s._error=r,s._complete=n,s}return pv(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;yv.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,i=yv.useDeprecatedSynchronousErrorHandling;if(this._error)i&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(t.syncErrorThrowable)i?(t.syncErrorValue=e,t.syncErrorThrown=!0):bv(e),this.unsubscribe();else{if(this.unsubscribe(),i)throw e;bv(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var i=function(){return e._complete.call(e._context)};yv.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,i),this.unsubscribe()):(this.__tryOrUnsub(i),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),yv.useDeprecatedSynchronousErrorHandling)throw e;bv(e)}},t.prototype.__tryOrSetError=function(e,t,i){if(!yv.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,i)}catch(t){return yv.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=t,e.syncErrorThrown=!0,!0):(bv(t),!0)}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(Iv);var Pv="function"==typeof Symbol&&Symbol.observable||"@@observable";function Rv(){}function Ov(e){return e?1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}:Rv}var Dv=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var i=new e;return i.source=this,i.operator=t,i},e.prototype.subscribe=function(e,t,i){var r=this.operator,n=function(e,t,i){if(e){if(e instanceof Iv)return e;if(e[Cv])return e[Cv]()}return e||t||i?new Iv(e,t,i):new Iv(xv)}(e,t,i);if(r?n.add(r.call(n,this.source)):n.add(this.source||yv.useDeprecatedSynchronousErrorHandling&&!n.syncErrorThrowable?this._subscribe(n):this._trySubscribe(n)),yv.useDeprecatedSynchronousErrorHandling&&n.syncErrorThrowable&&(n.syncErrorThrowable=!1,n.syncErrorThrown))throw n.syncErrorValue;return n},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){yv.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),!function(e){for(;e;){var t=e,i=t.closed,r=t.destination,n=t.isStopped;if(i||n)return!1;e=r&&r instanceof Iv?r:null}return!0}(e)?console.warn(t):e.error(t)}},e.prototype.forEach=function(e,t){var i=this;return new(t=Lv(t))((function(t,r){var n;n=i.subscribe((function(t){try{e(t)}catch(e){r(e),n&&n.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[Pv]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:Ov(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Lv(e))((function(e,i){var r;t.subscribe((function(e){return r=e}),(function(e){return i(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function Lv(e){if(e||(e=Promise),!e)throw new Error("no Promise impl found");return e}function kv(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}kv.prototype=Object.create(Error.prototype);var Bv=kv,Fv=function(e){function t(t,i){var r=e.call(this)||this;return r.subject=t,r.subscriber=i,r.closed=!1,r}return pv(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var i=t.indexOf(this.subscriber);-1!==i&&t.splice(i,1)}}},t}(Ev),jv=function(e){function t(t){var i=e.call(this,t)||this;return i.destination=t,i}return pv(t,e),t}(Iv),zv=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return pv(t,e),t.prototype[Cv]=function(){return new jv(this)},t.prototype.lift=function(e){var t=new $v(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new Bv;if(!this.isStopped)for(var t=this.observers,i=t.length,r=t.slice(),n=0;n<i;n++)r[n].next(e)},t.prototype.error=function(e){if(this.closed)throw new Bv;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,i=t.length,r=t.slice(),n=0;n<i;n++)r[n].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new Bv;this.isStopped=!0;for(var e=this.observers,t=e.length,i=e.slice(),r=0;r<t;r++)i[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(this.closed)throw new Bv;return e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){if(this.closed)throw new Bv;return this.hasError?(e.error(this.thrownError),Ev.EMPTY):this.isStopped?(e.complete(),Ev.EMPTY):(this.observers.push(e),new Fv(this,e))},t.prototype.asObservable=function(){var e=new Dv;return e.source=this,e},t.create=function(e,t){return new $v(e,t)},t}(Dv),$v=function(e){function t(t,i){var r=e.call(this)||this;return r.destination=t,r.source=i,r}return pv(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):Ev.EMPTY},t}(zv);function Vv(){return function(e){return e.lift(new Uv(e))}}var Uv=function(){function e(e){this.connectable=e}return e.prototype.call=function(e,t){var i=this.connectable;i._refCount++;var r=new Gv(e,i),n=t.subscribe(r);return r.closed||(r.connection=i.connect()),n},e}(),Gv=function(e){function t(t,i){var r=e.call(this,t)||this;return r.connectable=i,r}return pv(t,e),t.prototype._unsubscribe=function(){var e=this.connectable;if(e){this.connectable=null;var t=e._refCount;if(t<=0)this.connection=null;else if(e._refCount=t-1,t>1)this.connection=null;else{var i=this.connection,r=e._connection;this.connection=null,!r||i&&r!==i||r.unsubscribe()}}else this.connection=null},t}(Iv),Hv=function(e){function t(t,i){var r=e.call(this)||this;return r.source=t,r.subjectFactory=i,r._refCount=0,r._isComplete=!1,r}return pv(t,e),t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return e&&!e.isStopped||(this._subject=this.subjectFactory()),this._subject},t.prototype.connect=function(){var e=this._connection;return e||(this._isComplete=!1,(e=this._connection=new Ev).add(this.source.subscribe(new Wv(this.getSubject(),this))),e.closed?(this._connection=null,e=Ev.EMPTY):this._connection=e),e},t.prototype.refCount=function(){return Vv()(this)},t}(Dv).prototype,qv={operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:Hv._subscribe},_isComplete:{value:Hv._isComplete,writable:!0},getSubject:{value:Hv.getSubject},connect:{value:Hv.connect},refCount:{value:Hv.refCount}},Wv=function(e){function t(t,i){var r=e.call(this,t)||this;return r.connectable=i,r}return pv(t,e),t.prototype._error=function(t){this._unsubscribe(),e.prototype._error.call(this,t)},t.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){var e=this.connectable;if(e){this.connectable=null;var t=e._connection;e._refCount=0,e._subject=null,e._connection=null,t&&t.unsubscribe()}},t}(jv),Qv=function(e){function t(t){var i=e.call(this)||this;return i._value=t,i}return pv(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var i=e.prototype._subscribe.call(this,t);return i&&!i.closed&&t.next(this._value),i},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new Bv;return this._value},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(zv),Yv=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.scheduler=t,r.work=i,r.pending=!1,r}return pv(t,e),t.prototype.schedule=function(e,t){if(void 0===t&&(t=0),this.closed)return this;this.state=e;var i=this.id,r=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(r,i,t)),this.pending=!0,this.delay=t,this.id=this.id||this.requestAsyncId(r,this.id,t),this},t.prototype.requestAsyncId=function(e,t,i){return void 0===i&&(i=0),setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,t,i){if(void 0===i&&(i=0),null!==i&&this.delay===i&&!1===this.pending)return t;clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,t);if(i)return i;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var i=!1,r=void 0;try{this.work(e)}catch(e){i=!0,r=!!e&&e||new Error(e)}if(i)return this.unsubscribe(),r},t.prototype._unsubscribe=function(){var e=this.id,t=this.scheduler,i=t.actions,r=i.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&i.splice(r,1),null!=e&&(this.id=this.recycleAsyncId(t,e,null)),this.delay=null},t}(function(e){function t(t,i){return e.call(this)||this}return pv(t,e),t.prototype.schedule=function(e,t){return this},t}(Ev)),Xv=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.scheduler=t,r.work=i,r}return pv(t,e),t.prototype.schedule=function(t,i){return void 0===i&&(i=0),i>0?e.prototype.schedule.call(this,t,i):(this.delay=i,this.state=t,this.scheduler.flush(this),this)},t.prototype.execute=function(t,i){return i>0||this.closed?e.prototype.execute.call(this,t,i):this._execute(t,i)},t.prototype.requestAsyncId=function(t,i,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?e.prototype.requestAsyncId.call(this,t,i,r):t.flush(this)},t}(Yv),Zv=function(){function e(t,i){void 0===i&&(i=e.now),this.SchedulerAction=t,this.now=i}return e.prototype.schedule=function(e,t,i){return void 0===t&&(t=0),new this.SchedulerAction(this,e).schedule(i,t)},e.now=function(){return Date.now()},e}(),Kv=function(e){function t(i,r){void 0===r&&(r=Zv.now);var n=e.call(this,i,(function(){return t.delegate&&t.delegate!==n?t.delegate.now():r()}))||this;return n.actions=[],n.active=!1,n.scheduled=void 0,n}return pv(t,e),t.prototype.schedule=function(i,r,n){return void 0===r&&(r=0),t.delegate&&t.delegate!==this?t.delegate.schedule(i,r,n):e.prototype.schedule.call(this,i,r,n)},t.prototype.flush=function(e){var t=this.actions;if(this.active)t.push(e);else{var i;this.active=!0;do{if(i=e.execute(e.state,e.delay))break}while(e=t.shift());if(this.active=!1,i){for(;e=t.shift();)e.unsubscribe();throw i}}},t}(Zv),Jv=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return pv(t,e),t}(Kv),e_=new Jv(Xv),t_=new Dv((function(e){return e.complete()}));function i_(e){return e?function(e){return new Dv((function(t){return e.schedule((function(){return t.complete()}))}))}(e):t_}function r_(e){return e&&"function"==typeof e.schedule}var n_=function(e){return function(t){for(var i=0,r=e.length;i<r&&!t.closed;i++)t.next(e[i]);t.closed||t.complete()}};function o_(e,t){return new Dv(t?function(i){var r=new Ev,n=0;return r.add(t.schedule((function(){n!==e.length?(i.next(e[n++]),i.closed||r.add(this.schedule())):i.complete()}))),r}:n_(e))}function s_(e){var t=new Dv((function(t){t.next(e),t.complete()}));return t._isScalar=!0,t.value=e,t}function a_(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=e[e.length-1];switch(r_(i)?e.pop():i=void 0,e.length){case 0:return i_(i);case 1:return i?o_(e,i):s_(e[0]);default:return o_(e,i)}}function c_(e,t){return new Dv(t?function(i){return t.schedule(h_,0,{error:e,subscriber:i})}:function(t){return t.error(e)})}function h_(e){var t=e.error;e.subscriber.error(t)}var u_=function(){function e(e,t,i){this.kind=e,this.value=t,this.error=i,this.hasValue="N"===e}return e.prototype.observe=function(e){switch(this.kind){case"N":return e.next&&e.next(this.value);case"E":return e.error&&e.error(this.error);case"C":return e.complete&&e.complete()}},e.prototype.do=function(e,t,i){switch(this.kind){case"N":return e&&e(this.value);case"E":return t&&t(this.error);case"C":return i&&i()}},e.prototype.accept=function(e,t,i){return e&&"function"==typeof e.next?this.observe(e):this.do(e,t,i)},e.prototype.toObservable=function(){switch(this.kind){case"N":return a_(this.value);case"E":return c_(this.error);case"C":return i_()}throw new Error("unexpected notification kind value")},e.createNext=function(t){return void 0!==t?new e("N",t):e.undefinedValueNotification},e.createError=function(t){return new e("E",void 0,t)},e.createComplete=function(){return e.completeNotification},e.completeNotification=new e("C"),e.undefinedValueNotification=new e("N",void 0),e}(),l_=function(e){function t(t,i,r){void 0===r&&(r=0);var n=e.call(this,t)||this;return n.scheduler=i,n.delay=r,n}return pv(t,e),t.dispatch=function(e){var t=e.notification,i=e.destination;t.observe(i),this.unsubscribe()},t.prototype.scheduleMessage=function(e){this.destination.add(this.scheduler.schedule(t.dispatch,this.delay,new p_(e,this.destination)))},t.prototype._next=function(e){this.scheduleMessage(u_.createNext(e))},t.prototype._error=function(e){this.scheduleMessage(u_.createError(e)),this.unsubscribe()},t.prototype._complete=function(){this.scheduleMessage(u_.createComplete()),this.unsubscribe()},t}(Iv),p_=function(){return function(e,t){this.notification=e,this.destination=t}}(),d_=function(e){function t(t,i,r){void 0===t&&(t=Number.POSITIVE_INFINITY),void 0===i&&(i=Number.POSITIVE_INFINITY);var n=e.call(this)||this;return n.scheduler=r,n._events=[],n._infiniteTimeWindow=!1,n._bufferSize=t<1?1:t,n._windowTime=i<1?1:i,i===Number.POSITIVE_INFINITY?(n._infiniteTimeWindow=!0,n.next=n.nextInfiniteTimeWindow):n.next=n.nextTimeWindow,n}return pv(t,e),t.prototype.nextInfiniteTimeWindow=function(t){var i=this._events;i.push(t),i.length>this._bufferSize&&i.shift(),e.prototype.next.call(this,t)},t.prototype.nextTimeWindow=function(t){this._events.push(new f_(this._getNow(),t)),this._trimBufferThenGetEvents(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){var t,i=this._infiniteTimeWindow,r=i?this._events:this._trimBufferThenGetEvents(),n=this.scheduler,o=r.length;if(this.closed)throw new Bv;if(this.isStopped||this.hasError?t=Ev.EMPTY:(this.observers.push(e),t=new Fv(this,e)),n&&e.add(e=new l_(e,n)),i)for(var s=0;s<o&&!e.closed;s++)e.next(r[s]);else for(s=0;s<o&&!e.closed;s++)e.next(r[s].value);return this.hasError?e.error(this.thrownError):this.isStopped&&e.complete(),t},t.prototype._getNow=function(){return(this.scheduler||e_).now()},t.prototype._trimBufferThenGetEvents=function(){for(var e=this._getNow(),t=this._bufferSize,i=this._windowTime,r=this._events,n=r.length,o=0;o<n&&!(e-r[o].time<i);)o++;return n>t&&(o=Math.max(o,n-t)),o>0&&r.splice(0,o),r},t}(zv),f_=function(){return function(e,t){this.time=e,this.value=t}}(),m_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.value=null,t.hasNext=!1,t.hasCompleted=!1,t}return pv(t,e),t.prototype._subscribe=function(t){return this.hasError?(t.error(this.thrownError),Ev.EMPTY):this.hasCompleted&&this.hasNext?(t.next(this.value),t.complete(),Ev.EMPTY):e.prototype._subscribe.call(this,t)},t.prototype.next=function(e){this.hasCompleted||(this.value=e,this.hasNext=!0)},t.prototype.error=function(t){this.hasCompleted||e.prototype.error.call(this,t)},t.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&e.prototype.next.call(this,this.value),e.prototype.complete.call(this)},t}(zv),g_=new Kv(Yv);function v_(e){return e}function __(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}__.prototype=Object.create(Error.prototype);var y_=__;function b_(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}b_.prototype=Object.create(Error.prototype);var x_=b_;function w_(e,t){return function(i){if("function"!=typeof e)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return i.lift(new A_(e,t))}}var A_=function(){function e(e,t){this.project=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new S_(e,this.project,this.thisArg))},e}(),S_=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.project=i,n.count=0,n.thisArg=r||n,n}return pv(t,e),t.prototype._next=function(e){var t;try{t=this.project.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(Iv),M_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return pv(t,e),t.prototype.notifyNext=function(e,t,i,r,n){this.destination.next(t)},t.prototype.notifyError=function(e,t){this.destination.error(e)},t.prototype.notifyComplete=function(e){this.destination.complete()},t}(Iv),E_=function(e){function t(t,i,r){var n=e.call(this)||this;return n.parent=t,n.outerValue=i,n.outerIndex=r,n.index=0,n}return pv(t,e),t.prototype._next=function(e){this.parent.notifyNext(this.outerValue,e,this.outerIndex,this.index++,this)},t.prototype._error=function(e){this.parent.notifyError(e,this),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},t}(Iv),T_=function(e){return function(t){return e.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,bv),t}};function C_(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var I_=C_(),N_=function(e){return function(t){for(var i=e[I_]();;){var r=i.next();if(r.done){t.complete();break}if(t.next(r.value),t.closed)break}return"function"==typeof i.return&&t.add((function(){i.return&&i.return()})),t}},P_=function(e){return function(t){var i=e[Pv]();if("function"!=typeof i.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return i.subscribe(t)}},R_=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function O_(e){return!!e&&"function"!=typeof e.subscribe&&"function"==typeof e.then}var D_=function(e){if(e instanceof Dv)return function(t){return e._isScalar?(t.next(e.value),void t.complete()):e.subscribe(t)};if(e&&"function"==typeof e[Pv])return P_(e);if(R_(e))return n_(e);if(O_(e))return T_(e);if(e&&"function"==typeof e[I_])return N_(e);var t=Av(e)?"an invalid object":"'"+e+"'";throw new TypeError("You provided "+t+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")};function L_(e,t,i,r,n){if(void 0===n&&(n=new E_(e,i,r)),!n.closed)return D_(t)(n)}var k_={};function B_(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=null,r=null;return r_(e[e.length-1])&&(r=e.pop()),"function"==typeof e[e.length-1]&&(i=e.pop()),1===e.length&&wv(e[0])&&(e=e[0]),o_(e,r).lift(new F_(i))}var F_=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new j_(e,this.resultSelector))},e}(),j_=function(e){function t(t,i){var r=e.call(this,t)||this;return r.resultSelector=i,r.active=0,r.values=[],r.observables=[],r}return pv(t,e),t.prototype._next=function(e){this.values.push(k_),this.observables.push(e)},t.prototype._complete=function(){var e=this.observables,t=e.length;if(0===t)this.destination.complete();else{this.active=t,this.toRespond=t;for(var i=0;i<t;i++){var r=e[i];this.add(L_(this,r,r,i))}}},t.prototype.notifyComplete=function(e){0==(this.active-=1)&&this.destination.complete()},t.prototype.notifyNext=function(e,t,i,r,n){var o=this.values,s=o[i],a=this.toRespond?s===k_?--this.toRespond:this.toRespond:0;o[i]=t,0===a&&(this.resultSelector?this._tryResultSelector(o):this.destination.next(o.slice()))},t.prototype._tryResultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(M_);function z_(e,t){if(!t)return e instanceof Dv?e:new Dv(D_(e));if(null!=e){if(function(e){return e&&"function"==typeof e[Pv]}(e))return function(e,t){return new Dv(t?function(i){var r=new Ev;return r.add(t.schedule((function(){var n=e[Pv]();r.add(n.subscribe({next:function(e){r.add(t.schedule((function(){return i.next(e)})))},error:function(e){r.add(t.schedule((function(){return i.error(e)})))},complete:function(){r.add(t.schedule((function(){return i.complete()})))}}))}))),r}:P_(e))}(e,t);if(O_(e))return function(e,t){return new Dv(t?function(i){var r=new Ev;return r.add(t.schedule((function(){return e.then((function(e){r.add(t.schedule((function(){i.next(e),r.add(t.schedule((function(){return i.complete()})))})))}),(function(e){r.add(t.schedule((function(){return i.error(e)})))}))}))),r}:T_(e))}(e,t);if(R_(e))return o_(e,t);if(function(e){return e&&"function"==typeof e[I_]}(e)||"string"==typeof e)return function(e,t){if(!e)throw new Error("Iterable cannot be null");return new Dv(t?function(i){var r,n=new Ev;return n.add((function(){r&&"function"==typeof r.return&&r.return()})),n.add(t.schedule((function(){r=e[I_](),n.add(t.schedule((function(){if(!i.closed){var e,t;try{var n=r.next();e=n.value,t=n.done}catch(e){return void i.error(e)}t?i.complete():(i.next(e),this.schedule())}})))}))),n}:N_(e))}(e,t)}throw new TypeError((null!==e&&typeof e||e)+" is not observable")}function $_(e,t,i){return void 0===i&&(i=Number.POSITIVE_INFINITY),"function"==typeof t?function(r){return r.pipe($_((function(i,r){return z_(e(i,r)).pipe(w_((function(e,n){return t(i,e,r,n)})))}),i))}:("number"==typeof t&&(i=t),function(t){return t.lift(new V_(e,i))})}var V_=function(){function e(e,t){void 0===t&&(t=Number.POSITIVE_INFINITY),this.project=e,this.concurrent=t}return e.prototype.call=function(e,t){return t.subscribe(new U_(e,this.project,this.concurrent))},e}(),U_=function(e){function t(t,i,r){void 0===r&&(r=Number.POSITIVE_INFINITY);var n=e.call(this,t)||this;return n.project=i,n.concurrent=r,n.hasCompleted=!1,n.buffer=[],n.active=0,n.index=0,n}return pv(t,e),t.prototype._next=function(e){this.active<this.concurrent?this._tryNext(e):this.buffer.push(e)},t.prototype._tryNext=function(e){var t,i=this.index++;try{t=this.project(e,i)}catch(e){return void this.destination.error(e)}this.active++,this._innerSub(t,e,i)},t.prototype._innerSub=function(e,t,i){var r=new E_(this,void 0,void 0);this.destination.add(r),L_(this,e,t,i,r)},t.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e,t,i,r,n){this.destination.next(t)},t.prototype.notifyComplete=function(e){var t=this.buffer;this.remove(e),this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},t}(M_);function G_(e){return void 0===e&&(e=Number.POSITIVE_INFINITY),$_(v_,e)}function H_(){return G_(1)}function q_(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return H_()(a_.apply(void 0,e))}function W_(e,t,i,r){return vv(i)&&(r=i,i=void 0),r?W_(e,t,i).pipe(w_((function(e){return wv(e)?r.apply(void 0,e):r(e)}))):new Dv((function(r){Q_(e,t,(function(e){arguments.length>1?r.next(Array.prototype.slice.call(arguments)):r.next(e)}),r,i)}))}function Q_(e,t,i,r,n){var o;if(function(e){return e&&"function"==typeof e.addEventListener&&"function"==typeof e.removeEventListener}(e)){var s=e;e.addEventListener(t,i,n),o=function(){return s.removeEventListener(t,i,n)}}else if(function(e){return e&&"function"==typeof e.on&&"function"==typeof e.off}(e)){var a=e;e.on(t,i),o=function(){return a.off(t,i)}}else if(function(e){return e&&"function"==typeof e.addListener&&"function"==typeof e.removeListener}(e)){var c=e;e.addListener(t,i),o=function(){return c.removeListener(t,i)}}else{if(!e||!e.length)throw new TypeError("Invalid event target");for(var h=0,u=e.length;h<u;h++)Q_(e[h],t,i,r,n)}r.add(o)}function Y_(e){return!wv(e)&&e-parseFloat(e)+1>=0}function X_(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Number.POSITIVE_INFINITY,r=null,n=e[e.length-1];return r_(n)?(r=e.pop(),e.length>1&&"number"==typeof e[e.length-1]&&(i=e.pop())):"number"==typeof n&&(i=e.pop()),null===r&&1===e.length&&e[0]instanceof Dv?e[0]:G_(i)(o_(e,r))}function Z_(e){var t=e.index,i=e.period,r=e.subscriber;if(r.next(t),!r.closed){if(-1===i)return r.complete();e.index=t+1,this.schedule(e,i)}}function K_(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=e[e.length-1];return"function"==typeof i&&e.pop(),o_(e,void 0).lift(new ey(i))}var J_,ey=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new ty(e,this.resultSelector))},e}(),ty=function(e){function t(t,i,r){void 0===r&&(r=Object.create(null));var n=e.call(this,t)||this;return n.iterators=[],n.active=0,n.resultSelector="function"==typeof i?i:null,n.values=r,n}return pv(t,e),t.prototype._next=function(e){var t=this.iterators;wv(e)?t.push(new ry(e)):"function"==typeof e[I_]?t.push(new iy(e[I_]())):t.push(new ny(this.destination,this,e))},t.prototype._complete=function(){var e=this.iterators,t=e.length;if(this.unsubscribe(),0!==t){this.active=t;for(var i=0;i<t;i++){var r=e[i];if(r.stillUnsubscribed)this.destination.add(r.subscribe(r,i));else this.active--}}else this.destination.complete()},t.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},t.prototype.checkIterators=function(){for(var e=this.iterators,t=e.length,i=this.destination,r=0;r<t;r++){if("function"==typeof(s=e[r]).hasValue&&!s.hasValue())return}var n=!1,o=[];for(r=0;r<t;r++){var s,a=(s=e[r]).next();if(s.hasCompleted()&&(n=!0),a.done)return void i.complete();o.push(a.value)}this.resultSelector?this._tryresultSelector(o):i.next(o),n&&i.complete()},t.prototype._tryresultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(Iv),iy=function(){function e(e){this.iterator=e,this.nextResult=e.next()}return e.prototype.hasValue=function(){return!0},e.prototype.next=function(){var e=this.nextResult;return this.nextResult=this.iterator.next(),e},e.prototype.hasCompleted=function(){var e=this.nextResult;return e&&e.done},e}(),ry=function(){function e(e){this.array=e,this.index=0,this.length=0,this.length=e.length}return e.prototype[I_]=function(){return this},e.prototype.next=function(e){var t=this.index++,i=this.array;return t<this.length?{value:i[t],done:!1}:{value:null,done:!0}},e.prototype.hasValue=function(){return this.array.length>this.index},e.prototype.hasCompleted=function(){return this.array.length===this.index},e}(),ny=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.parent=i,n.observable=r,n.stillUnsubscribed=!0,n.buffer=[],n.isComplete=!1,n}return pv(t,e),t.prototype[I_]=function(){return this},t.prototype.next=function(){var e=this.buffer;return 0===e.length&&this.isComplete?{value:null,done:!0}:{value:e.shift(),done:!1}},t.prototype.hasValue=function(){return this.buffer.length>0},t.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},t.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},t.prototype.notifyNext=function(e,t,i,r,n){this.buffer.push(t),this.parent.checkIterators()},t.prototype.subscribe=function(e,t){return L_(this,this.observable,this,t)},t}(M_);function oy(e,t){return void 0===t&&(t=null),function(i){return i.lift(new sy(e,t))}}e.RenderMode=void 0,(J_=e.RenderMode||(e.RenderMode={}))[J_.Letterbox=0]="Letterbox",J_[J_.Fill=1]="Fill";var sy=function(){function e(e,t){this.bufferSize=e,this.startBufferEvery=t,this.subscriberClass=t&&e!==t?cy:ay}return e.prototype.call=function(e,t){return t.subscribe(new this.subscriberClass(e,this.bufferSize,this.startBufferEvery))},e}(),ay=function(e){function t(t,i){var r=e.call(this,t)||this;return r.bufferSize=i,r.buffer=[],r}return pv(t,e),t.prototype._next=function(e){var t=this.buffer;t.push(e),t.length==this.bufferSize&&(this.destination.next(t),this.buffer=[])},t.prototype._complete=function(){var t=this.buffer;t.length>0&&this.destination.next(t),e.prototype._complete.call(this)},t}(Iv),cy=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.bufferSize=i,n.startBufferEvery=r,n.buffers=[],n.count=0,n}return pv(t,e),t.prototype._next=function(e){var t=this,i=t.bufferSize,r=t.startBufferEvery,n=t.buffers,o=t.count;this.count++,o%r==0&&n.push([]);for(var s=n.length;s--;){var a=n[s];a.push(e),a.length===i&&(n.splice(s,1),this.destination.next(a))}},t.prototype._complete=function(){for(var t=this.buffers,i=this.destination;t.length>0;){var r=t.shift();r.length>0&&i.next(r)}e.prototype._complete.call(this)},t}(Iv);var hy=function(){function e(e){this.closingSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new uy(e,this.closingSelector))},e}(),uy=function(e){function t(t,i){var r=e.call(this,t)||this;return r.closingSelector=i,r.subscribing=!1,r.openBuffer(),r}return pv(t,e),t.prototype._next=function(e){this.buffer.push(e)},t.prototype._complete=function(){var t=this.buffer;t&&this.destination.next(t),e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){this.buffer=null,this.subscribing=!1},t.prototype.notifyNext=function(e,t,i,r,n){this.openBuffer()},t.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},t.prototype.openBuffer=function(){var e=this.closingSubscription;e&&(this.remove(e),e.unsubscribe());var t,i=this.buffer;this.buffer&&this.destination.next(i),this.buffer=[];try{t=(0,this.closingSelector)()}catch(e){return this.error(e)}e=new Ev,this.closingSubscription=e,this.add(e),this.subscribing=!0,e.add(L_(this,t)),this.subscribing=!1},t}(M_);function ly(e){return function(t){var i=new py(e),r=t.lift(i);return i.caught=r}}var py=function(){function e(e){this.selector=e}return e.prototype.call=function(e,t){return t.subscribe(new dy(e,this.selector,this.caught))},e}(),dy=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.selector=i,n.caught=r,n}return pv(t,e),t.prototype.error=function(t){if(!this.isStopped){var i=void 0;try{i=this.selector(t,this.caught)}catch(t){return void e.prototype.error.call(this,t)}this._unsubscribeAndRecycle();var r=new E_(this,void 0,void 0);this.add(r),L_(this,i,void 0,void 0,r)}},t}(M_);function fy(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=null;return"function"==typeof e[e.length-1]&&(i=e.pop()),1===e.length&&wv(e[0])&&(e=e[0].slice()),function(t){return t.lift.call(z_([t].concat(e)),new F_(i))}}function my(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(q_.apply(void 0,[t].concat(e)))}}function gy(e,t){return void 0===t&&(t=g_),function(i){return i.lift(new vy(e,t))}}var vy=function(){function e(e,t){this.dueTime=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new _y(e,this.dueTime,this.scheduler))},e}(),_y=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.dueTime=i,n.scheduler=r,n.debouncedSubscription=null,n.lastValue=null,n.hasValue=!1,n}return pv(t,e),t.prototype._next=function(e){this.clearDebounce(),this.lastValue=e,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(yy,this.dueTime,this))},t.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},t.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var e=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(e)}},t.prototype.clearDebounce=function(){var e=this.debouncedSubscription;null!==e&&(this.remove(e),e.unsubscribe(),this.debouncedSubscription=null)},t}(Iv);function yy(e){e.debouncedNext()}function by(e){return void 0===e&&(e=null),function(t){return t.lift(new xy(e))}}var xy=function(){function e(e){this.defaultValue=e}return e.prototype.call=function(e,t){return t.subscribe(new wy(e,this.defaultValue))},e}(),wy=function(e){function t(t,i){var r=e.call(this,t)||this;return r.defaultValue=i,r.isEmpty=!0,r}return pv(t,e),t.prototype._next=function(e){this.isEmpty=!1,this.destination.next(e)},t.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},t}(Iv);function Ay(e,t){void 0===t&&(t=g_);var i,r=(i=e)instanceof Date&&!isNaN(+i)?+e-t.now():Math.abs(e);return function(e){return e.lift(new Sy(r,t))}}var Sy=function(){function e(e,t){this.delay=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new My(e,this.delay,this.scheduler))},e}(),My=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.delay=i,n.scheduler=r,n.queue=[],n.active=!1,n.errored=!1,n}return pv(t,e),t.dispatch=function(e){for(var t=e.source,i=t.queue,r=e.scheduler,n=e.destination;i.length>0&&i[0].time-r.now()<=0;)i.shift().notification.observe(n);if(i.length>0){var o=Math.max(0,i[0].time-r.now());this.schedule(e,o)}else this.unsubscribe(),t.active=!1},t.prototype._schedule=function(e){this.active=!0,this.destination.add(e.schedule(t.dispatch,this.delay,{source:this,destination:this.destination,scheduler:e}))},t.prototype.scheduleNotification=function(e){if(!0!==this.errored){var t=this.scheduler,i=new Ey(t.now()+this.delay,e);this.queue.push(i),!1===this.active&&this._schedule(t)}},t.prototype._next=function(e){this.scheduleNotification(u_.createNext(e))},t.prototype._error=function(e){this.errored=!0,this.queue=[],this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.scheduleNotification(u_.createComplete()),this.unsubscribe()},t}(Iv),Ey=function(){return function(e,t){this.time=e,this.notification=t}}();var Ty=function(){function e(e,t){this.keySelector=e,this.flushes=t}return e.prototype.call=function(e,t){return t.subscribe(new Cy(e,this.keySelector,this.flushes))},e}(),Cy=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.keySelector=i,n.values=new Set,r&&n.add(L_(n,r)),n}return pv(t,e),t.prototype.notifyNext=function(e,t,i,r,n){this.values.clear()},t.prototype.notifyError=function(e,t){this._error(e)},t.prototype._next=function(e){this.keySelector?this._useKeySelector(e):this._finalizeNext(e,e)},t.prototype._useKeySelector=function(e){var t,i=this.destination;try{t=this.keySelector(e)}catch(e){return void i.error(e)}this._finalizeNext(t,e)},t.prototype._finalizeNext=function(e,t){var i=this.values;i.has(e)||(i.add(e),this.destination.next(t))},t}(M_);function Iy(e,t){return function(i){return i.lift(new Ny(e,t))}}var Ny=function(){function e(e,t){this.compare=e,this.keySelector=t}return e.prototype.call=function(e,t){return t.subscribe(new Py(e,this.compare,this.keySelector))},e}(),Py=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.keySelector=r,n.hasKey=!1,"function"==typeof i&&(n.compare=i),n}return pv(t,e),t.prototype.compare=function(e,t){return e===t},t.prototype._next=function(e){var t;try{var i=this.keySelector;t=i?i(e):e}catch(e){return this.destination.error(e)}var r=!1;if(this.hasKey)try{r=(0,this.compare)(this.key,t)}catch(e){return this.destination.error(e)}else this.hasKey=!0;r||(this.key=t,this.destination.next(e))},t}(Iv);function Ry(e,t){return function(i){return i.lift(new Oy(e,t))}}var Oy=function(){function e(e,t){this.predicate=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new Dy(e,this.predicate,this.thisArg))},e}(),Dy=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.predicate=i,n.thisArg=r,n.count=0,n}return pv(t,e),t.prototype._next=function(e){var t;try{t=this.predicate.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}t&&this.destination.next(e)},t}(Iv);function Ly(e,t,i){return function(r){return r.lift(new ky(e,t,i))}}var ky=function(){function e(e,t,i){this.nextOrObserver=e,this.error=t,this.complete=i}return e.prototype.call=function(e,t){return t.subscribe(new By(e,this.nextOrObserver,this.error,this.complete))},e}(),By=function(e){function t(t,i,r,n){var o=e.call(this,t)||this;return o._tapNext=Rv,o._tapError=Rv,o._tapComplete=Rv,o._tapError=r||Rv,o._tapComplete=n||Rv,vv(i)?(o._context=o,o._tapNext=i):i&&(o._context=i,o._tapNext=i.next||Rv,o._tapError=i.error||Rv,o._tapComplete=i.complete||Rv),o}return pv(t,e),t.prototype._next=function(e){try{this._tapNext.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.next(e)},t.prototype._error=function(e){try{this._tapError.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.error(e)},t.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(e){return void this.destination.error(e)}return this.destination.complete()},t}(Iv),Fy=function(e){return void 0===e&&(e=jy),Ly({hasValue:!1,next:function(){this.hasValue=!0},complete:function(){if(!this.hasValue)throw e()}})};function jy(){return new x_}function zy(e){return function(t){return 0===e?i_():t.lift(new $y(e))}}var $y=function(){function e(e){if(this.total=e,this.total<0)throw new y_}return e.prototype.call=function(e,t){return t.subscribe(new Vy(e,this.total))},e}(),Vy=function(e){function t(t,i){var r=e.call(this,t)||this;return r.total=i,r.count=0,r}return pv(t,e),t.prototype._next=function(e){var t=this.total,i=++this.count;i<=t&&(this.destination.next(e),i===t&&(this.destination.complete(),this.unsubscribe()))},t}(Iv);function Uy(e,t,i){return void 0===t&&(t=Number.POSITIVE_INFINITY),void 0===i&&(i=void 0),t=(t||0)<1?Number.POSITIVE_INFINITY:t,function(r){return r.lift(new Gy(e,t,i))}}var Gy=function(){function e(e,t,i){this.project=e,this.concurrent=t,this.scheduler=i}return e.prototype.call=function(e,t){return t.subscribe(new Hy(e,this.project,this.concurrent,this.scheduler))},e}(),Hy=function(e){function t(t,i,r,n){var o=e.call(this,t)||this;return o.project=i,o.concurrent=r,o.scheduler=n,o.index=0,o.active=0,o.hasCompleted=!1,r<Number.POSITIVE_INFINITY&&(o.buffer=[]),o}return pv(t,e),t.dispatch=function(e){var t=e.subscriber,i=e.result,r=e.value,n=e.index;t.subscribeToProjection(i,r,n)},t.prototype._next=function(e){var i=this.destination;if(i.closed)this._complete();else{var r=this.index++;if(this.active<this.concurrent){i.next(e);try{var n=(0,this.project)(e,r);if(this.scheduler){var o={subscriber:this,result:n,value:e,index:r};this.destination.add(this.scheduler.schedule(t.dispatch,0,o))}else this.subscribeToProjection(n,e,r)}catch(e){i.error(e)}}else this.buffer.push(e)}},t.prototype.subscribeToProjection=function(e,t,i){this.active++,this.destination.add(L_(this,e,t,i))},t.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e,t,i,r,n){this._next(t)},t.prototype.notifyComplete=function(e){var t=this.buffer;this.destination.remove(e),this.active--,t&&t.length>0&&this._next(t.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},t}(M_);function qy(e){return function(t){return t.lift(new Wy(e))}}var Wy=function(){function e(e){this.callback=e}return e.prototype.call=function(e,t){return t.subscribe(new Qy(e,this.callback))},e}(),Qy=function(e){function t(t,i){var r=e.call(this,t)||this;return r.add(new Ev(i)),r}return pv(t,e),t}(Iv);function Yy(e,t){var i=arguments.length>=2;return function(r){return r.pipe(e?Ry((function(t,i){return e(t,i,r)})):v_,zy(1),i?by(t):Fy((function(){return new x_})))}}function Xy(e){return function(t){return 0===e?i_():t.lift(new Zy(e))}}var Zy=function(){function e(e){if(this.total=e,this.total<0)throw new y_}return e.prototype.call=function(e,t){return t.subscribe(new Ky(e,this.total))},e}(),Ky=function(e){function t(t,i){var r=e.call(this,t)||this;return r.total=i,r.ring=new Array,r.count=0,r}return pv(t,e),t.prototype._next=function(e){var t=this.ring,i=this.total,r=this.count++;t.length<i?t.push(e):t[r%i]=e},t.prototype._complete=function(){var e=this.destination,t=this.count;if(t>0)for(var i=this.count>=this.total?this.total:this.count,r=this.ring,n=0;n<i;n++){var o=t++%i;e.next(r[o])}e.complete()},t}(Iv);function Jy(e,t){var i=arguments.length>=2;return function(r){return r.pipe(e?Ry((function(t,i){return e(t,i,r)})):v_,Xy(1),i?by(t):Fy((function(){return new x_})))}}function eb(e,t){var i=!1;return arguments.length>=2&&(i=!0),function(r){return r.lift(new tb(e,t,i))}}var tb=function(){function e(e,t,i){void 0===i&&(i=!1),this.accumulator=e,this.seed=t,this.hasSeed=i}return e.prototype.call=function(e,t){return t.subscribe(new ib(e,this.accumulator,this.seed,this.hasSeed))},e}(),ib=function(e){function t(t,i,r,n){var o=e.call(this,t)||this;return o.accumulator=i,o._seed=r,o.hasSeed=n,o.index=0,o}return pv(t,e),Object.defineProperty(t.prototype,"seed",{get:function(){return this._seed},set:function(e){this.hasSeed=!0,this._seed=e},enumerable:!0,configurable:!0}),t.prototype._next=function(e){if(this.hasSeed)return this._tryNext(e);this.seed=e,this.destination.next(e)},t.prototype._tryNext=function(e){var t,i=this.index++;try{t=this.accumulator(this.seed,e,i)}catch(e){this.destination.error(e)}this.seed=t,this.destination.next(t)},t}(Iv);function rb(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(X_.apply(void 0,[t].concat(e)))}}function nb(e,t){return function(i){var r;if(r="function"==typeof e?e:function(){return e},"function"==typeof t)return i.lift(new ob(r,t));var n=Object.create(i,qv);return n.source=i,n.subjectFactory=r,n}}var ob=function(){function e(e,t){this.subjectFactory=e,this.selector=t}return e.prototype.call=function(e,t){var i=this.selector,r=this.subjectFactory(),n=i(r).subscribe(e);return n.add(t.subscribe(r)),n},e}();function sb(){return function(e){return e.lift(new ab)}}var ab=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new cb(e))},e}(),cb=function(e){function t(t){var i=e.call(this,t)||this;return i.hasPrev=!1,i}return pv(t,e),t.prototype._next=function(e){this.hasPrev?this.destination.next([this.prev,e]):this.hasPrev=!0,this.prev=e},t}(Iv);function hb(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=e.length;if(0===i)throw new Error("list of properties cannot be empty.");return function(t){return w_(ub(e,i))(t)}}function ub(e,t){return function(i){for(var r=i,n=0;n<t;n++){var o=r[e[n]];if(void 0===o)return;r=o}return r}}function lb(e,t,i,r){i&&"function"!=typeof i&&(r=i);var n="function"==typeof i?i:void 0,o=new d_(e,t,r);return function(e){return nb((function(){return o}),n)(e)}}var pb=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){var i=new db(e),r=t.subscribe(i);return r.add(L_(i,this.notifier)),r},e}(),db=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.hasValue=!1,t}return pv(t,e),t.prototype._next=function(e){this.value=e,this.hasValue=!0},t.prototype.notifyNext=function(e,t,i,r,n){this.emitValue()},t.prototype.notifyComplete=function(){this.emitValue()},t.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},t}(M_);function fb(){return new zv}function mb(){return function(e){return Vv()(nb(fb)(e))}}function gb(e){return function(t){return t.lift(new vb(e))}}var vb=function(){function e(e){this.total=e}return e.prototype.call=function(e,t){return t.subscribe(new _b(e,this.total))},e}(),_b=function(e){function t(t,i){var r=e.call(this,t)||this;return r.total=i,r.count=0,r}return pv(t,e),t.prototype._next=function(e){++this.count>this.total&&this.destination.next(e)},t}(Iv);function yb(e){return function(t){return t.lift(new bb(e))}}var bb=function(){function e(e){this.predicate=e}return e.prototype.call=function(e,t){return t.subscribe(new xb(e,this.predicate))},e}(),xb=function(e){function t(t,i){var r=e.call(this,t)||this;return r.predicate=i,r.skipping=!0,r.index=0,r}return pv(t,e),t.prototype._next=function(e){var t=this.destination;this.skipping&&this.tryCallPredicate(e),this.skipping||t.next(e)},t.prototype.tryCallPredicate=function(e){try{var t=this.predicate(e,this.index++);this.skipping=Boolean(t)}catch(e){this.destination.error(e)}},t}(Iv);function wb(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var i=e[e.length-1];r_(i)?e.pop():i=null;var r=e.length;return q_(1!==r||i?r>0?o_(e,i):i_(i):s_(e[0]),t)}}function Ab(e,t){return"function"==typeof t?function(i){return i.pipe(Ab((function(i,r){return z_(e(i,r)).pipe(w_((function(e,n){return t(i,e,r,n)})))})))}:function(t){return t.lift(new Sb(e))}}var Sb=function(){function e(e){this.project=e}return e.prototype.call=function(e,t){return t.subscribe(new Mb(e,this.project))},e}(),Mb=function(e){function t(t,i){var r=e.call(this,t)||this;return r.project=i,r.index=0,r}return pv(t,e),t.prototype._next=function(e){var t,i=this.index++;try{t=this.project(e,i)}catch(e){return void this.destination.error(e)}this._innerSub(t,e,i)},t.prototype._innerSub=function(e,t,i){var r=this.innerSubscription;r&&r.unsubscribe();var n=new E_(this,void 0,void 0);this.destination.add(n),this.innerSubscription=L_(this,e,t,i,n)},t.prototype._complete=function(){var t=this.innerSubscription;t&&!t.closed||e.prototype._complete.call(this),this.unsubscribe()},t.prototype._unsubscribe=function(){this.innerSubscription=null},t.prototype.notifyComplete=function(t){this.destination.remove(t),this.innerSubscription=null,this.isStopped&&e.prototype._complete.call(this)},t.prototype.notifyNext=function(e,t,i,r,n){this.destination.next(t)},t}(M_);function Eb(e){return function(t){return t.lift(new Tb(e))}}var Tb=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){var i=new Cb(e),r=L_(i,this.notifier);return r&&!i.seenValue?(i.add(r),t.subscribe(i)):i},e}(),Cb=function(e){function t(t){var i=e.call(this,t)||this;return i.seenValue=!1,i}return pv(t,e),t.prototype.notifyNext=function(e,t,i,r,n){this.seenValue=!0,this.complete()},t.prototype.notifyComplete=function(){},t}(M_);var Ib=function(){function e(e,t){this.predicate=e,this.inclusive=t}return e.prototype.call=function(e,t){return t.subscribe(new Nb(e,this.predicate,this.inclusive))},e}(),Nb=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.predicate=i,n.inclusive=r,n.index=0,n}return pv(t,e),t.prototype._next=function(e){var t,i=this.destination;try{t=this.predicate(e,this.index++)}catch(e){return void i.error(e)}this.nextOrComplete(e,t)},t.prototype.nextOrComplete=function(e,t){var i=this.destination;Boolean(t)?i.next(e):(this.inclusive&&i.next(e),i.complete())},t}(Iv),Pb={leading:!0,trailing:!1};var Rb=function(){function e(e,t,i,r){this.duration=e,this.scheduler=t,this.leading=i,this.trailing=r}return e.prototype.call=function(e,t){return t.subscribe(new Ob(e,this.duration,this.scheduler,this.leading,this.trailing))},e}(),Ob=function(e){function t(t,i,r,n,o){var s=e.call(this,t)||this;return s.duration=i,s.scheduler=r,s.leading=n,s.trailing=o,s._hasTrailingValue=!1,s._trailingValue=null,s}return pv(t,e),t.prototype._next=function(e){this.throttled?this.trailing&&(this._trailingValue=e,this._hasTrailingValue=!0):(this.add(this.throttled=this.scheduler.schedule(Db,this.duration,{subscriber:this})),this.leading&&this.destination.next(e))},t.prototype._complete=function(){this._hasTrailingValue?(this.destination.next(this._trailingValue),this.destination.complete()):this.destination.complete()},t.prototype.clearThrottle=function(){var e=this.throttled;e&&(this.trailing&&this._hasTrailingValue&&(this.destination.next(this._trailingValue),this._trailingValue=null,this._hasTrailingValue=!1),e.unsubscribe(),this.remove(e),this.throttled=null)},t}(Iv);function Db(e){e.subscriber.clearThrottle()}function Lb(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var i;"function"==typeof e[e.length-1]&&(i=e.pop());var r=e;return t.lift(new zb(r,i))}}var kb,Bb,Fb,jb,zb=function(){function e(e,t){this.observables=e,this.project=t}return e.prototype.call=function(e,t){return t.subscribe(new $b(e,this.observables,this.project))},e}(),$b=function(e){function t(t,i,r){var n=e.call(this,t)||this;n.observables=i,n.project=r,n.toRespond=[];var o=i.length;n.values=new Array(o);for(var s=0;s<o;s++)n.toRespond.push(s);for(s=0;s<o;s++){var a=i[s];n.add(L_(n,a,a,s))}return n}return pv(t,e),t.prototype.notifyNext=function(e,t,i,r,n){this.values[i]=t;var o=this.toRespond;if(o.length>0){var s=o.indexOf(i);-1!==s&&o.splice(s,1)}},t.prototype.notifyComplete=function(){},t.prototype._next=function(e){if(0===this.toRespond.length){var t=[e].concat(this.values);this.project?this._tryProject(t):this.destination.next(t)}},t.prototype._tryProject=function(e){var t;try{t=this.project.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(M_);function Vb(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(K_.apply(void 0,[t].concat(e)))}}class Ub{constructor(t,i,r){this._adaptiveOperation$=new zv,this._render$=new zv,this._renderAdaptive$=new zv,this._renderService=i,this._currentFrame$=r;let n=uv.create(uv.h("div.domRenderer",[]));t.appendChild(n),this._offset$=this._adaptiveOperation$.pipe(eb(((e,t)=>t(e)),{elementHeight:t.offsetHeight,elementWidth:t.offsetWidth,imageAspect:0,renderMode:e.RenderMode.Fill}),Ry((e=>e.imageAspect>0&&e.elementWidth>0&&e.elementHeight>0)),w_((t=>{let i=t.elementWidth/t.elementHeight,r=t.imageAspect/i,n=0,o=0;return t.renderMode===e.RenderMode.Letterbox?t.imageAspect>i?n=t.elementHeight*(1-1/r)/2:o=t.elementWidth*(1-r)/2:t.imageAspect>i?o=-t.elementWidth*(r-1)/2:n=-t.elementHeight*(1/r-1)/2,{bottom:n,left:o,right:o,top:n}}))),this._currentFrame$.pipe(Ry((e=>null!=e.state.currentNode)),Iy(((e,t)=>e===t),(e=>e.state.currentNode.key)),w_((e=>e.state.currentTransform.basicAspect)),w_((e=>t=>(t.imageAspect=e,t)))).subscribe(this._adaptiveOperation$),this._renderAdaptive$.pipe(eb(((e,t)=>(null==t.vnode?delete e[t.name]:e[t.name]=t.vnode,e)),{}),fy(this._offset$),w_((e=>{let t=Rp(e[0]),i=e[1],r={style:{bottom:i.bottom+"px",left:i.left+"px","pointer-events":"none",position:"absolute",right:i.right+"px",top:i.top+"px"}};return{name:"adaptiveDomRenderer",vnode:uv.h("div.adaptiveDomRenderer",r,t)}}))).subscribe(this._render$),this._vNode$=this._render$.pipe(eb(((e,t)=>(null==t.vnode?delete e[t.name]:e[t.name]=t.vnode,e)),{}),w_((e=>{let t=Rp(e);return uv.h("div.domRenderer",t)}))),this._vPatch$=this._vNode$.pipe(eb(((e,t)=>(e.vpatch=uv.diff(e.vnode,t),e.vnode=t,e)),{vnode:uv.h("div.domRenderer",[]),vpatch:null}),hb("vpatch")),this._element$=this._vPatch$.pipe(eb(((e,t)=>uv.patch(e,t)),n),lb(1),Vv()),this._element$.subscribe((()=>{})),this._renderService.size$.pipe(w_((e=>t=>(t.elementWidth=e.width,t.elementHeight=e.height,t)))).subscribe(this._adaptiveOperation$),this._renderService.renderMode$.pipe(w_((e=>t=>(t.renderMode=e,t)))).subscribe(this._adaptiveOperation$)}get element$(){return this._element$}get render$(){return this._render$}get renderAdaptive$(){return this._renderAdaptive$}clear(e){this._renderAdaptive$.next({name:e,vnode:null}),this._render$.next({name:e,vnode:null})}}!function(e){e[e.Background=0]="Background",e[e.Foreground=1]="Foreground"}(kb||(kb={}));class Gb{constructor(e){this._document=e||document}get document(){return this._document}createElement(e,t,i){const r=this._document.createElement(e);return t&&(r.className=t),i&&i.appendChild(r),r}}class Hb{constructor(){this._events={}}on(e,t){this._events[e]=this._events[e]||[],this._events[e].push(t)}off(e,t){if(e)if(this._listens(e))delete this._events[e];else{let i=this._events[e].indexOf(t);i>=0&&this._events[e].splice(i,1),this._events[e].length&&delete this._events[e]}else this._events={}}fire(e,t){if(this._listens(e))for(let i of this._events[e])i.call(this,t)}_listens(e){return!(!this._events||!this._events[e])}}e.ImageSize=void 0,(Bb=e.ImageSize||(e.ImageSize={}))[Bb.Size320=320]="Size320",Bb[Bb.Size640=640]="Size640",Bb[Bb.Size1024=1024]="Size1024",Bb[Bb.Size2048=2048]="Size2048";class qb{static get baseImageSize(){return qb._baseImageSize}static get basePanoramaSize(){return qb._basePanoramaSize}static get maxImageSize(){return qb._maxImageSize}static setOptions(t){qb._baseImageSize=null!=t.baseImageSize?t.baseImageSize:e.ImageSize.Size640,qb._basePanoramaSize=null!=t.basePanoramaSize?t.basePanoramaSize:e.ImageSize.Size2048,qb._maxImageSize=null!=t.maxImageSize?t.maxImageSize:e.ImageSize.Size2048}}class Wb{static get domain(){return"beeview-cdn.mapxus.com/prod"}static get tileScheme(){return"https"}static get tileDomain(){return`${Wb.domain}/public/tiles`}static get thumbnailDomain(){return`${Wb.domain}/public/previews`}static get meshDomain(){return`${Wb.domain}/public/meshs`}static get origin(){return"visual.webgl"}static get authUrl(){return"https://map-api.mapxus.com/sc/api/v1/apikeys/auth"}static thumbnail(e,t=2048){return`${Wb.tileScheme}://${Wb.thumbnailDomain}/${e}/thumbnails/thumb-${t}.jpg`}static protoMesh(e){return`${Wb.tileScheme}://${Wb.meshDomain}/${e}`}static graphqlModel(){return"https://map-api.mapxus.com/vis/graphql"}}class Qb{constructor(e,t,i){this._renderFrame$=new zv,this._renderCameraOperation$=new zv,this._render$=new zv,this._clear$=new zv,this._renderOperation$=new zv,this._rendererOperation$=new zv,this._eraserOperation$=new zv,this._renderService=t,this._dom=i||new Gb,this._renderer$=this._rendererOperation$.pipe(eb(((e,t)=>t(e)),{needsRender:!1,renderer:null})),this._renderCollection$=this._renderOperation$.pipe(eb(((e,t)=>t(e)),{}),mb()),this._renderCamera$=this._renderCameraOperation$.pipe(eb(((e,t)=>t(e)),{frameId:-1,needsRender:!1,perspective:null})),this._eraser$=this._eraserOperation$.pipe(wb((e=>e)),eb(((e,t)=>t(e)),{needsRender:!1})),B_([this._renderer$,this._renderCollection$,this._renderCamera$,this._eraser$],((e,t,i,r)=>({camera:i,eraser:r,renderer:e,renders:Object.keys(t).map((e=>t[e]))}))).pipe(Ry((e=>{let t=e.renderer.needsRender||e.camera.needsRender||e.eraser.needsRender,i=e.camera.frameId;for(let r of e.renders){if(r.frameId!==i)return!1;t=t||r.needsRender}return t})),Iy(((e,t)=>e===t),(e=>e.eraser.needsRender?-1:e.camera.frameId))).subscribe((e=>{e.renderer.needsRender=!1,e.camera.needsRender=!1,e.eraser.needsRender=!1;let t=e.camera.perspective,i=[],r=[];for(let t of e.renders)t.stage===kb.Background?i.push(t.render):t.stage===kb.Foreground&&r.push(t.render);let n=e.renderer.renderer;n.clear();for(let e of i)e(t,n);n.clearDepth();for(let e of r)e(t,n)})),this._renderFrame$.pipe(w_((e=>t=>(t.frameId=e.frameId,t.perspective=e.perspective,!0===e.changed&&(t.needsRender=!0),t)))).subscribe(this._renderCameraOperation$),this._renderFrameSubscribe(),X_(this._render$.pipe(w_((e=>t=>(t[e.name]=e.render,t)))),this._clear$.pipe(w_((e=>t=>(delete t[e],t))))).subscribe(this._renderOperation$),this._webGLRenderer$=this._render$.pipe(Yy(),w_((i=>{const r=this._dom.createElement("canvas","Beeview-js-canvas");r.style.position="absolute",r.setAttribute("tabindex","0"),e.appendChild(r);const n=t.element,o=new $n({canvas:r});return o.setPixelRatio(window.devicePixelRatio),o.setSize(n.offsetWidth,n.offsetHeight),o.setClearColor(new wt(2105376),1),o.autoClear=!1,o})),lb(1),Vv()),this._webGLRenderer$.subscribe((()=>{}));let r=this._webGLRenderer$.pipe(Yy(),w_((e=>t=>(t.needsRender=!0,t.renderer=e,t)))),n=this._renderService.size$.pipe(w_((e=>t=>(null==t.renderer||(t.renderer.setSize(e.width,e.height),t.needsRender=!0),t))));X_(r,n,this._clear$.pipe(w_((e=>e=>(null==e.renderer||(e.needsRender=!0),e))))).subscribe(this._rendererOperation$);let o=this._renderCollection$.pipe(Ry((e=>0===Object.keys(e).length)),mb());o.subscribe((e=>{null!=this._renderFrameSubscription&&(this._renderFrameSubscription.unsubscribe(),this._renderFrameSubscription=null,this._renderFrameSubscribe())})),o.pipe(w_((e=>e=>(e.needsRender=!0,e)))).subscribe(this._eraserOperation$)}get render$(){return this._render$}get webGLRenderer$(){return this._webGLRenderer$}clear(e){this._clear$.next(e)}_renderFrameSubscribe(){this._render$.pipe(Yy(),w_((e=>e=>(e.needsRender=!0,e)))).subscribe((e=>{this._renderCameraOperation$.next(e)})),this._renderFrameSubscription=this._render$.pipe(Yy(),$_((e=>this._renderService.renderCameraFrame$))).subscribe(this._renderFrame$)}}class Yb{constructor(e,t,i){this.alpha=-1,this.zoom=0,this._frameId=-1,this._changed=!1,this._changedForFrame=-1,this.currentAspect=1,this.currentPano=!1,this.previousAspect=1,this.previousPano=!1,this.renderMode=i,this._spatial=new Hu,this._camera=new Vu;const r=this._getPerspectiveCameraAspect(e,t);this._perspective=new Ci(50,r,.4,1e4),this._perspective.matrixAutoUpdate=!1,this._rotation={phi:0,theta:0}}get camera(){return this._camera}get changed(){return this.frameId===this._changedForFrame}get frameId(){return this._frameId}set frameId(e){this._frameId=e,this._changed&&(this._changed=!1,this._changedForFrame=e)}get perspective(){return this._perspective}get rotation(){return this._rotation}getTilt(){return 90-this._spatial.radToDeg(this._rotation.theta)}updateAspect(e,t){const i=this._getPerspectiveCameraAspect(e,t);this._perspective.aspect=i,this._changed=!0}updateProjection(){let e=this._getAspect(this.currentAspect,this.currentPano,this.perspective.aspect),t=this._getAspect(this.previousAspect,this.previousPano,this.perspective.aspect),i=(1-this.alpha)*t+this.alpha*e,r=this._getVerticalFov(i,this._camera.focal,this.zoom);this._perspective.fov=r,this._perspective.updateProjectionMatrix(),this._changed=!0}updatePerspective(e){this._perspective.up.copy(e.up),this._perspective.position.copy(e.position),this._perspective.lookAt(e.lookat),this._perspective.updateMatrix(),this._perspective.updateMatrixWorld(!1),this._changed=!0}updateRotation(e){this._rotation=this._getRotation(e)}_getVerticalFov(e,t,i){return 2*Math.atan(.5/(Math.pow(2,i)*e*t))*180/Math.PI}_getAspect(t,i,r){if(i)return 1;let n=Math.max(1,1/t);return(this.renderMode===e.RenderMode.Letterbox?t>r:t<r)?n*r:n*t}_getPerspectiveCameraAspect(e,t){return 0===e?0:e/t}_getRotation(e){let t=e.lookat.clone().sub(e.position),i=e.up.clone(),r=t.clone().dot(i),n=t.clone().sub(i.clone().multiplyScalar(r));return{phi:Math.atan2(n.y,n.x),theta:Math.PI/2-this._spatial.angleToPlane(t.toArray(),[0,0,1])}}}class Xb{constructor(t,i,r){this._element=t,this._currentFrame$=i,this._spatial=new Hu,r=null!=r?r:e.RenderMode.Fill,this._panWithoutInertia$=new zv,this._pan$=new zv,this._resize$=new zv,this._renderCameraOperation$=new zv,this._size$=new Qv({height:this._element.offsetHeight,width:this._element.offsetWidth}),this._resize$.pipe(w_((()=>({height:this._element.offsetHeight,width:this._element.offsetWidth})))).subscribe(this._size$),this._renderMode$=new Qv(r),this._renderCameraHolder$=this._renderCameraOperation$.pipe(wb((e=>e)),eb(((e,t)=>t(e)),new Yb(this._element.offsetWidth,this._element.offsetHeight,r)),lb(1),Vv()),this._renderCameraFrame$=this._currentFrame$.pipe(Lb(this._renderCameraHolder$,((e,t)=>[e,t])),Ly((e=>{let t=e[0],i=e[1],r=t.state.camera;if(i.alpha!==t.state.alpha||i.zoom!==t.state.zoom||i.camera.diff(r)>1e-9){let e=t.state.currentTransform,n=null!=t.state.previousTransform?t.state.previousTransform:t.state.currentTransform,o=null!=t.state.previousNode?t.state.previousNode:t.state.currentNode;i.currentAspect=e.basicAspect,i.currentPano=t.state.currentNode.pano,i.previousAspect=n.basicAspect,i.previousPano=o.pano,i.alpha=t.state.alpha,i.zoom=t.state.zoom,i.camera.copy(r),i.updatePerspective(r),i.updateRotation(r),i.updateProjection()}i.frameId=t.id})),w_((e=>e[1])),lb(1),Vv()),this._renderCamera$=this._renderCameraFrame$.pipe(Ry((e=>e.changed)),lb(1),Vv()),this._bearing$=this._renderCamera$.pipe(w_((e=>{let t=this._spatial.radToDeg(this._spatial.azimuthalToBearing(e.rotation.phi));return this._spatial.wrap(t,0,360)})),lb(1),Vv()),this._size$.pipe(gb(1),w_((e=>t=>(t.updateAspect(e.width,e.height),t.updateProjection(),t)))).subscribe(this._renderCameraOperation$),this._renderMode$.pipe(gb(1),w_((e=>t=>(t.renderMode=e,t.updateProjection(),t)))).subscribe(this._renderCameraOperation$),this._bearing$.subscribe((()=>{})),this._renderCameraHolder$.subscribe((()=>{})),this._size$.subscribe((()=>{})),this._renderMode$.subscribe((()=>{})),this._renderCamera$.subscribe((()=>{})),this._renderCameraFrame$.subscribe((()=>{}))}get bearing$(){return this._bearing$}get panWithoutInertia$(){return this._panWithoutInertia$}get pan$(){return this._pan$}get element(){return this._element}get resize$(){return this._resize$}get size$(){return this._size$}get renderMode$(){return this._renderMode$}get renderCameraFrame$(){return this._renderCameraFrame$}get renderCamera$(){return this._renderCamera$}}e.Alignment=void 0,(Fb=e.Alignment||(e.Alignment={}))[Fb.Bottom=0]="Bottom",Fb[Fb.BottomLeft=1]="BottomLeft",Fb[Fb.BottomRight=2]="BottomRight",Fb[Fb.Center=3]="Center",Fb[Fb.Left=4]="Left",Fb[Fb.Right=5]="Right",Fb[Fb.Top=6]="Top",Fb[Fb.TopLeft=7]="TopLeft",Fb[Fb.TopRight=8]="TopRight";class Zb{constructor(e,t){this._graphService=e,this._stateService=t,this._started=!1}get started(){return this._started}start(){this._started||(this._uncacheSubscription=this._stateService.currentState$.pipe(Iy(void 0,(e=>e.state.currentNode.key)),w_((e=>e.state.trajectory.map((e=>e.key)))),oy(1,5),Ab((e=>{let t=e[0];return this._graphService.uncache$(t)}))).subscribe((()=>{})),this._started=!0)}stop(){this._started&&(this._uncacheSubscription.unsubscribe(),this._uncacheSubscription=null,this._started=!1)}}class Kb{constructor(e,t){this._components={};for(const i in Kb.registeredComponents){if(!Kb.registeredComponents.hasOwnProperty(i))continue;const r=Kb.registeredComponents[i];this._components[i]={active:!1,component:new r(i,e,t)}}this._coverComponent=new Kb.registeredCoverComponent("cover",e,t),this._coverComponent.activate(),this._coverActivated=!0}static register(e){void 0===Kb.registeredComponents[e.componentName]&&(Kb.registeredComponents[e.componentName]=e)}static registerCover(e){Kb.registeredCoverComponent=e}get coverActivated(){return this._coverActivated}activateCover(){if(!this._coverActivated){this._coverActivated=!0;for(let e of Rp(this._components))e.active&&e.component.deactivate()}}deactivateCover(){if(this._coverActivated){this._coverActivated=!1;for(let e of Rp(this._components))e.active&&e.component.activate()}}activate(e){this._checkName(e),this._components[e].active=!0,this._coverActivated||this.get(e).activate()}configure(e,t){this._checkName(e),this.get(e).configure(t)}deactivate(e){this._checkName(e),this._components[e].active=!1,this._coverActivated||this.get(e).deactivate()}resize(){for(let e of Rp(this._components))e.component.resize()}get(e){return this._components[e].component}getCover(){return this._coverComponent}_checkName(e){if(!(e in this._components))throw new zu(`Component does not exist: ${e}`)}}Kb.registeredComponents={},e.CoverState=void 0,(jb=e.CoverState||(e.CoverState={}))[jb.Hidden=0]="Hidden",jb[jb.Loading=1]="Loading",jb[jb.Visible=2]="Visible";class Jb{constructor(t,i,r,n,o,s){this._container=t,this._observer=r,this._navigator=i,this._options=null!=o?o:{},this._key=n,this._navigable=null==n,this._componentService=s||new Kb(this._container,this._navigator),this._coverComponent=this._componentService.getCover(),this._initializeComponents(),n?(this._initilizeCoverComponent(),this._subscribeCoverComponent()):this._navigator.movedToKey$.pipe(Yy((e=>null!=e))).subscribe((t=>{this._key=t,this._componentService.deactivateCover(),this._coverComponent.configure({key:this._key,state:e.CoverState.Hidden}),this._subscribeCoverComponent(),this._navigator.stateService.start(),this._observer.startEmit()}))}get navigable(){return this._navigable}get(e){return this._componentService.get(e)}activate(e){this._componentService.activate(e)}activateCover(){this._coverComponent.configure({state:e.CoverState.Visible})}deactivate(e){this._componentService.deactivate(e)}deactivateCover(){this._coverComponent.configure({state:e.CoverState.Loading})}resize(){this._componentService.resize()}_initializeComponents(){let e=this._options;this._uFalse(e.background,"background"),this._uFalse(e.debug,"debug"),this._uFalse(e.image,"image"),this._uFalse(e.navigation,"navigation"),this._uFalse(e.popup,"popup"),this._uFalse(e.route,"route"),this._uFalse(e.slider,"slider"),this._uFalse(e.tag,"tag"),this._uFalse(e.sequence,"sequence"),this._uFalse(e.direction,"direction"),this._uFalse(e.marker,"marker"),this._uTrue(e.cache,"cache"),this._uTrue(e.path,"path"),this._uTrue(e.bearing,"bearing"),this._uTrue(e.imagePlane,"imagePlane"),this._uTrue(e.keyboard,"keyboard"),this._uTrue(e.loading,"loading"),this._uTrue(e.mouse,"mouse")}_initilizeCoverComponent(){let e=this._options;this._coverComponent.configure({key:this._key}),void 0===e.cover||e.cover?this.activateCover():this.deactivateCover()}_setNavigable(e){this._navigable!==e&&(this._navigable=e,this._observer.navigable$.next(e))}_subscribeCoverComponent(){this._coverComponent.configuration$.subscribe((t=>{t.state===e.CoverState.Loading?this._navigator.stateService.currentKey$.pipe(Yy(),Ab((e=>{const i=null==e||e!==t.key;return i&&this._setNavigable(!1),i?this._navigator.moveToKey$(t.key):this._navigator.stateService.currentNode$.pipe(Yy())}))).subscribe((t=>{this._navigator.stateService.start(),this._observer.startEmit(),this._coverComponent.configure({state:e.CoverState.Hidden}),this._componentService.deactivateCover(),this._setNavigable(!0)}),(t=>{console.error("Failed to deactivate cover.",t),this._coverComponent.configure({state:e.CoverState.Visible})})):t.state===e.CoverState.Visible&&(this._observer.stopEmit(),this._navigator.stateService.stop(),this._componentService.activateCover(),this._setNavigable(null==t.key))}))}_uFalse(e,t){void 0!==e?"boolean"!=typeof e?(this._componentService.configure(t,e),this._componentService.activate(t)):e?this._componentService.activate(t):this._componentService.deactivate(t):this._componentService.deactivate(t)}_uTrue(e,t){void 0!==e?"boolean"!=typeof e?(this._componentService.configure(t,e),this._componentService.activate(t)):e?this._componentService.activate(t):this._componentService.deactivate(t):this._componentService.activate(t)}}class ex{constructor(e){this._keyDown$=W_(e,"keydown")}get keyDown$(){return this._keyDown$}}class tx{constructor(e,t,i,r,n){this._canvasContainer=t,this._domContainer=i,this._viewportCoords=null!=n?n:new Gu,this._activeSubject$=new Qv(!1),this._active$=this._activeSubject$.pipe(Iy(),nb(new d_(1)),Vv()),this._claimMouse$=new zv,this._claimWheel$=new zv,this._deferPixelClaims$=new zv,this._deferPixels$=this._deferPixelClaims$.pipe(eb(((e,t)=>(null==t.deferPixels?delete e[t.name]:e[t.name]=t.deferPixels,e)),{}),w_((e=>{let t=-1;for(const i in e){if(!e.hasOwnProperty(i))continue;const r=e[i];r>t&&(t=r)}return t})),wb(-1),nb(new d_(1)),Vv()),this._deferPixels$.subscribe((()=>{})),this._documentMouseMove$=W_(r,"mousemove"),this._documentMouseUp$=W_(r,"mouseup"),this._mouseDown$=W_(t,"mousedown"),this._mouseLeave$=W_(t,"mouseleave"),this._mouseMove$=W_(t,"mousemove"),this._mouseUp$=W_(t,"mouseup"),this._mouseOut$=W_(t,"mouseout"),this._mouseOver$=W_(t,"mouseover"),this._domMouseDown$=W_(i,"mousedown"),this._domMouseMove$=W_(i,"mousemove"),this._click$=W_(t,"click"),this._contextMenu$=W_(t,"contextmenu"),this._dblClick$=X_(W_(e,"click"),W_(t,"dblclick")).pipe(oy(3,1),Ry((e=>{const i=e[0],r=e[1],n=e[2];return"click"===i.type&&"click"===r.type&&"dblclick"===n.type&&i.target.parentNode===t&&r.target.parentNode===t})),w_((e=>e[2])),mb()),X_(this._domMouseDown$,this._domMouseMove$,this._dblClick$,this._contextMenu$).subscribe((e=>{e.preventDefault()})),this._mouseWheel$=X_(W_(t,"wheel"),W_(i,"wheel")).pipe(mb()),this._consistentContextMenu$=X_(this._mouseDown$,this._mouseMove$,this._mouseOut$,this._mouseUp$,this._contextMenu$).pipe(oy(3,1),Ry((e=>"mousedown"===e[0].type&&"contextmenu"===e[1].type&&"mouseup"===e[2].type)),w_((e=>e[1])),mb());const o=X_(W_(window,"blur"),this._documentMouseUp$.pipe(Ry((e=>0===e.button)))).pipe(mb()),s=this._createMouseDragInitiate$(this._mouseDown$,o,!0).pipe(mb());this._mouseDragStart$=this._createMouseDragStart$(s).pipe(mb()),this._mouseDrag$=this._createMouseDrag$(s,o).pipe(mb()),this._mouseDragEnd$=this._createMouseDragEnd$(this._mouseDragStart$,o).pipe(mb());const a=this._createMouseDragInitiate$(this._domMouseDown$,o,!1).pipe(mb());this._domMouseDragStart$=this._createMouseDragStart$(a).pipe(mb()),this._domMouseDrag$=this._createMouseDrag$(a,o).pipe(mb()),this._domMouseDragEnd$=this._createMouseDragEnd$(this._domMouseDragStart$,o).pipe(mb()),this._proximateClick$=this._mouseDown$.pipe(Ab((e=>this._click$.pipe(Eb(this._createDeferredMouseMove$(e,this._documentMouseMove$)),zy(1)))),nb(new zv),Vv()),this._staticClick$=this._mouseDown$.pipe(Ab((e=>this._click$.pipe(Eb(this._documentMouseMove$),zy(1)))),nb(new zv),Vv()),this._mouseDragStart$.subscribe(),this._mouseDrag$.subscribe(),this._mouseDragEnd$.subscribe(),this._domMouseDragStart$.subscribe(),this._domMouseDrag$.subscribe(),this._domMouseDragEnd$.subscribe(),this._staticClick$.subscribe(),this._mouseOwner$=this._createOwner$(this._claimMouse$).pipe(nb(new d_(1)),Vv()),this._wheelOwner$=this._createOwner$(this._claimWheel$).pipe(nb(new d_(1)),Vv()),this._mouseOwner$.subscribe((()=>{})),this._wheelOwner$.subscribe((()=>{}))}get active$(){return this._active$}get activate$(){return this._activeSubject$}get documentMouseMove$(){return this._documentMouseMove$}get documentMouseUp$(){return this._documentMouseUp$}get domMouseDragStart$(){return this._domMouseDragStart$}get domMouseDrag$(){return this._domMouseDrag$}get domMouseDragEnd$(){return this._domMouseDragEnd$}get domMouseDown$(){return this._domMouseDown$}get domMouseMove$(){return this._domMouseMove$}get mouseOwner$(){return this._mouseOwner$}get mouseDown$(){return this._mouseDown$}get mouseMove$(){return this._mouseMove$}get mouseLeave$(){return this._mouseLeave$}get mouseOut$(){return this._mouseOut$}get mouseOver$(){return this._mouseOver$}get mouseUp$(){return this._mouseUp$}get click$(){return this._click$}get dblClick$(){return this._dblClick$}get contextMenu$(){return this._consistentContextMenu$}get mouseWheel$(){return this._mouseWheel$}get mouseDragStart$(){return this._mouseDragStart$}get mouseDrag$(){return this._mouseDrag$}get mouseDragEnd$(){return this._mouseDragEnd$}get proximateClick$(){return this._proximateClick$}get staticClick$(){return this._staticClick$}claimMouse(e,t){this._claimMouse$.next({name:e,zindex:t})}unclaimMouse(e){this._claimMouse$.next({name:e,zindex:null})}deferPixels(e,t){this._deferPixelClaims$.next({name:e,deferPixels:t})}undeferPixels(e){this._deferPixelClaims$.next({name:e,deferPixels:null})}claimWheel(e,t){this._claimWheel$.next({name:e,zindex:t})}unclaimWheel(e){this._claimWheel$.next({name:e,zindex:null})}filtered$(e,t){return this._filtered(e,t,this._mouseOwner$)}filteredWheel$(e,t){return this._filtered(e,t,this._wheelOwner$)}_createDeferredMouseMove$(e,t){return t.pipe(w_((t=>{const i=t.clientX-e.clientX,r=t.clientY-e.clientY;return[t,Math.sqrt(i*i+r*r)]})),Lb(this._deferPixels$),Ry((([[e,t],i])=>t>i)),w_((([[e,t],i])=>e)))}_createMouseDrag$(e,t){return e.pipe(w_((([e,t])=>t)),Ab((e=>a_(e).pipe(my(this._documentMouseMove$),Eb(t)))))}_createMouseDragEnd$(e,t){return e.pipe(Ab((e=>t.pipe(Yy()))))}_createMouseDragStart$(e){return e.pipe(w_((([e,t])=>e)))}_createMouseDragInitiate$(e,t,i){return e.pipe(Ry((e=>0===e.button)),Ab((e=>B_(a_(e),i?this._createDeferredMouseMove$(e,this._documentMouseMove$):this._documentMouseMove$).pipe(Eb(t),zy(1)))))}_createOwner$(e){return e.pipe(eb(((e,t)=>(null==t.zindex?delete e[t.name]:e[t.name]=t.zindex,e)),{}),w_((e=>{let t=null,i=-1;for(const r in e)e.hasOwnProperty(r)&&e[r]>i&&(i=e[r],t=r);return t})),wb(null))}_filtered(e,t,i){return t.pipe(Lb(i),Ry((([t,i])=>i===e)),w_((([e,t])=>e)))}}class ix{constructor(e,t){this._canvasContainer=e,this._domContainer=t,this._activeSubject$=new Qv(!1),this._active$=this._activeSubject$.pipe(Iy(),nb(new d_(1)),Vv()),W_(t,"touchmove").subscribe((e=>{e.preventDefault()})),this._touchStart$=W_(e,"touchstart"),this._touchMove$=W_(e,"touchmove"),this._touchEnd$=W_(e,"touchend"),this._touchCancel$=W_(e,"touchcancel");const i=this._touchStart$.pipe(Ry((e=>1===e.touches.length&&1===e.targetTouches.length)),mb());var r;this._doubleTap$=i.pipe((r=()=>i.pipe(Yy(),Ab((e=>function(e,t,i){void 0===e&&(e=0);var r=-1;return Y_(t)?r=Number(t)<1?1:Number(t):r_(t)&&(i=t),r_(i)||(i=g_),new Dv((function(t){var n=Y_(e)?e:+e-i.now();return i.schedule(Z_,n,{index:0,period:r,subscriber:t})}))}(300).pipe(rb(i),zy(1))))),function(e){return e.lift(new hy(r))}),Ry((e=>2===e.length)),w_((e=>e[e.length-1])),mb()),this._doubleTap$.subscribe((e=>{e.preventDefault()})),this._singleTouchMove$=this._touchMove$.pipe(Ry((e=>1===e.touches.length&&1===e.targetTouches.length)),mb());let n=X_(this._touchStart$,this._touchEnd$,this._touchCancel$).pipe(Ry((e=>1===e.touches.length&&1===e.targetTouches.length))),o=X_(this._touchStart$,this._touchEnd$,this._touchCancel$).pipe(Ry((e=>e.touches.length>=1))),s=X_(this._touchEnd$,this._touchCancel$).pipe(Ry((e=>0===e.touches.length)));this._singleTouchDragStart$=n.pipe($_((e=>this._singleTouchMove$.pipe(Eb(X_(s,o)),zy(1))))),this._singleTouchDragEnd$=n.pipe($_((e=>X_(s,o).pipe(Yy())))),this._singleTouchDrag$=n.pipe(Ab((e=>this._singleTouchMove$.pipe(gb(1),Eb(X_(o,s))))));let a=X_(this._touchStart$,this._touchEnd$,this._touchCancel$);this._pinchStart$=a.pipe(Ry((e=>2===e.touches.length&&2===e.targetTouches.length))),this._pinchEnd$=a.pipe(Ry((e=>2!==e.touches.length||2!==e.targetTouches.length))),this._pinchOperation$=new zv,this._pinch$=this._pinchOperation$.pipe(eb(((e,t)=>t(e)),{changeX:0,changeY:0,clientX:0,clientY:0,distance:0,distanceChange:0,distanceX:0,distanceY:0,originalEvent:null,pageX:0,pageY:0,screenX:0,screenY:0,touch1:null,touch2:null})),this._touchMove$.pipe(Ry((e=>2===e.touches.length&&2===e.targetTouches.length)),w_((e=>t=>{let i=e.touches[0],r=e.touches[1],n=Math.min(i.clientX,r.clientX),o=Math.max(i.clientX,r.clientX),s=Math.min(i.clientY,r.clientY),a=n+(o-n)/2,c=s+(Math.max(i.clientY,r.clientY)-s)/2,h=a+i.pageX-i.clientX,u=c+i.pageY-i.clientY,l=a+i.screenX-i.clientX,p=c+i.screenY-i.clientY,d=Math.abs(i.clientX-r.clientX),f=Math.abs(i.clientY-r.clientY),m=Math.sqrt(d*d+f*f),g=m-t.distance;return{changeX:d-t.distanceX,changeY:f-t.distanceY,clientX:a,clientY:c,distance:m,distanceChange:g,distanceX:d,distanceY:f,originalEvent:e,pageX:h,pageY:u,screenX:l,screenY:p,touch1:i,touch2:r}}))).subscribe(this._pinchOperation$),this._pinchChange$=this._pinchStart$.pipe(Ab((e=>this._pinch$.pipe(gb(1),Eb(this._pinchEnd$)))))}get active$(){return this._active$}get activate$(){return this._activeSubject$}get doubleTap$(){return this._doubleTap$}get touchStart$(){return this._touchStart$}get touchMove$(){return this._touchMove$}get touchEnd$(){return this._touchEnd$}get touchCancel$(){return this._touchCancel$}get singleTouchDragStart$(){return this._singleTouchDragStart$}get singleTouchDrag$(){return this._singleTouchDrag$}get singleTouchDragEnd$(){return this._singleTouchDragEnd$}get pinch$(){return this._pinchChange$}get pinchStart$(){return this._pinchStart$}get pinchEnd$(){return this._pinchEnd$}}class rx{set json(e){this._json=e}set image(e){this._image=e,this._texture=new K(this._image),this._texture.minFilter=f}get loaded(){return!(!this._image||!this._json)}getGLSprite(e){if(!this.loaded)throw new Error("Sprites cannot be retrieved before the atlas is loaded.");let t=this._json[e];if(!t)return console.warn("Sprite with key"+e+"does not exist in sprite definition."),new Pe;let i=this._texture.clone();i.needsUpdate=!0;let r=this._image.width,n=this._image.height;return i.offset.x=t.x/r,i.offset.y=(n-t.y-t.height)/n,i.repeat.x=t.width/r,i.repeat.y=t.height/n,new ao(new Qn({map:i}))}getDOMSprite(t,i){if(!this.loaded)throw new Error("Sprites cannot be retrieved before the atlas is loaded.");null==i&&(i=e.Alignment.Center);let r=this._json[t];if(!r)return console.warn("Sprite with key"+t+"does not exist in sprite definition."),uv.h("div",{},[]);let n=r.y,o=r.x+r.width,s=r.y+r.height,a=r.x,c=-r.x,h=-r.y,u=this._image.height,l=this._image.width;switch(i){case e.Alignment.Bottom:case e.Alignment.Center:case e.Alignment.Top:c-=r.width/2;break;case e.Alignment.BottomLeft:case e.Alignment.Left:case e.Alignment.TopLeft:c-=r.width;case e.Alignment.BottomRight:case e.Alignment.Right:case e.Alignment.BottomRight:}switch(i){case e.Alignment.Center:case e.Alignment.Left:case e.Alignment.Right:h-=r.height/2;break;case e.Alignment.Top:case e.Alignment.TopLeft:case e.Alignment.TopRight:h-=r.height;case e.Alignment.Bottom:case e.Alignment.BottomLeft:case e.Alignment.BottomRight:}let p=1/r.pixelRatio;n*=p,o*=p,s*=p,a*=p,c*=p,h*=p,u*=p,l*=p;let d={src:this._image.src,style:{clip:`rect(${n}px, ${o}px, ${s}px, ${a}px)`,height:`${u}px`,left:`${c}px`,position:"absolute",top:`${h}px`,width:`${l}px`}};return uv.h("img",d,[])}}class nx{constructor(e){if(this._retina=window.devicePixelRatio>1,this._spriteAtlasOperation$=new zv,this._spriteAtlas$=this._spriteAtlasOperation$.pipe(wb((e=>e)),eb(((e,t)=>t(e)),new rx),nb(new d_(1)),Vv()),this._spriteAtlas$.subscribe((()=>{})),null==e)return;let t=this._retina?"@2x":"",i=new XMLHttpRequest;i.open("GET",e+t+".png",!0),i.custom&&i.custom.xhr&&(i=i.custom.xhr),i.responseType="arraybuffer",i.onload=()=>{let e=new Image;e.onload=()=>{this._spriteAtlasOperation$.next((t=>(t.image=e,t)))};let t=new Blob([i.response]);e.src=window.URL.createObjectURL(t)},i.onerror=i=>{console.error(new Error(`Failed to fetch sprite sheet (${e}${t}.png)`))},i.send();let r=new XMLHttpRequest;r.open("GET",e+t+".json",!0),r.custom&&r.custom.xhr&&(r=r.custom.xhr),r.responseType="text",r.onload=()=>{let e=JSON.parse(r.response);this._spriteAtlasOperation$.next((t=>(t.json=e,t)))},r.onerror=i=>{console.error(new Error(`Failed to fetch sheet (${e}${t}.json)`))},r.send()}get spriteAtlas$(){return this._spriteAtlas$}}class ox{constructor(e,t,i,r){if(this.id=e,this._dom=r||new Gb,this._container=this._dom.document.getElementById(e),!this._container)throw new Error(`Container '${e}' not found.`);this._container.classList.add("beeview-js"),this._canvasContainer=this._dom.createElement("div","beeview-js-interactive",this._container),this._domContainer=this._dom.createElement("div","beeview-js-dom",this._container),this.renderService=new Xb(this._container,t.currentState$,i.renderMode),this.glRenderer=new Qb(this._canvasContainer,this.renderService,this._dom),this.domRenderer=new Ub(this._domContainer,this.renderService,t.currentState$),this.keyboardService=new ex(this._canvasContainer),this.mouseService=new tx(this._container,this._canvasContainer,this._domContainer,document),this.touchService=new ix(this._canvasContainer,this._domContainer),this.spriteService=new nx(i.sprite)}get element(){return this._container}get canvasContainer(){return this._canvasContainer}}class sx{constructor(e,t){this._geoCoords=e||new Uu,this._viewportCoords=t||new Gu}basicToCanvas(e,t,i,r){return this._viewportCoords.basicToCanvas(e[0],e[1],t,r,i.perspective)}canvasToBasic(e,t,i,r){let n=this._viewportCoords.canvasToBasic(e[0],e[1],t,r,i.perspective);return(n[0]<0||n[0]>1||n[1]<0||n[1]>1)&&(n=null),n}eventToUnprojection(e,t,i,r,n){const o=this._viewportCoords.canvasPosition(e,t);return this.canvasToUnprojection(o,t,i,r,n)}canvasToUnprojection(e,t,i,r,n){const o=e[0],s=e[1],[a,c]=this._viewportCoords.canvasToViewport(o,s,t),h=new oe(a,c,1).unproject(i.perspective);let u=n.projectBasic(h.toArray());(u[0]<0||u[0]>1||u[1]<0||u[1]>1)&&(u=null);const l=h.clone().sub(i.camera.position).normalize(),p=-2/l.z;let d=null;if(p>0&&p<100&&u){const e=l.clone().multiplyScalar(p).add(i.camera.position),t=this._geoCoords.enuToGeodetic(e.x,e.y,e.z,r.lat,r.lon,r.alt).slice(0,2);d={lat:t[0],lon:t[1]}}return{basicPoint:u,latLon:d,pixelPoint:[o,s]}}cameraToLngLat(e,t){const i=e.camera.position,[r,n]=this._geoCoords.enuToGeodetic(i.x,i.y,i.z,t.lat,t.lon,t.alt);return{lat:r,lon:n}}}class ax{}ax.fov="fov",ax.position="position",ax.pov="pov",ax.bearingchanged="bearingchanged",ax.panwithoutinertiachanged="panwithoutinertiachanged",ax.panchanged="panchanged",ax.click="click",ax.contextmenu="contextmenu",ax.dblclick="dblclick",ax.loadingchanged="loadingchanged",ax.mousedown="mousedown",ax.mousemove="mousemove",ax.mouseout="mouseout",ax.mouseover="mouseover",ax.mouseup="mouseup",ax.moveend="moveend",ax.movestart="movestart",ax.navigablechanged="navigablechanged",ax.nodechanged="nodechanged",ax.sequenceedgeschanged="sequenceedgeschanged",ax.spatialedgeschanged="spatialedgeschanged";class cx{constructor(e,t,i){this._container=i,this._eventEmitter=e,this._navigator=t,this._projection=new sx,this._started=!1,this._navigable$=new zv,this._navigable$.subscribe((e=>{this._eventEmitter.fire(ax.navigablechanged,e)})),this._navigator.loadingService.loading$.subscribe((e=>{this._eventEmitter.fire(ax.loadingchanged,e)}))}get started(){return this._started}get navigable$(){return this._navigable$}get projection(){return this._projection}projectBasic$(e){return B_(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$).pipe(Yy(),w_((([t,i])=>{const r=this._projection.basicToCanvas(e,this._container.element,t,i);return[Math.round(r[0]),Math.round(r[1])]})))}startEmit(){if(this._started)return;this._started=!0,this._currentNodeSubscription=this._navigator.stateService.currentNodeExternal$.subscribe((e=>{this.setFilter(["==","floorId",e.floorId]),this._eventEmitter.fire(ax.nodechanged,e)})),this._sequenceEdgesSubscription=this._navigator.stateService.currentNodeExternal$.pipe(Ab((e=>e.sequenceEdges$))).subscribe((e=>{this._eventEmitter.fire(ax.sequenceedgeschanged,e)})),this._spatialEdgesSubscription=this._navigator.stateService.currentNodeExternal$.pipe(Ab((e=>e.spatialEdges$))).subscribe((e=>{this._eventEmitter.fire(ax.spatialedgeschanged,e)})),this._moveSubscription=B_(this._navigator.stateService.inMotion$,this._container.mouseService.active$,this._container.touchService.active$).pipe(w_((e=>e[0]||e[1]||e[2])),Iy()).subscribe((e=>{e?this._eventEmitter.fire(ax.movestart,null):this._eventEmitter.fire(ax.moveend,null)})),this._bearingSubscription=this._container.renderService.bearing$.pipe(function(e,t,i){return void 0===t&&(t=g_),void 0===i&&(i=Pb),function(r){return r.lift(new Rb(e,t,i.leading,i.trailing))}}(100),Iy(((e,t)=>Math.abs(t-e)<1))).subscribe((e=>{this._eventEmitter.fire(ax.bearingchanged,e)})),this._panToWithoutInertiaSubscription=this._container.renderService.panWithoutInertia$.subscribe((e=>{this._eventEmitter.fire(ax.panwithoutinertiachanged,e)})),this._panToSubscription=this._container.renderService.pan$.subscribe((e=>{this._eventEmitter.fire(ax.panchanged,e)}));const e=this._container.mouseService.active$.pipe(Ab((e=>e?i_():this._container.mouseService.mouseMove$)));this._viewerMouseEventSubscription=X_(this._mapMouseEvent$(ax.click,this._container.mouseService.staticClick$),this._mapMouseEvent$(ax.contextmenu,this._container.mouseService.contextMenu$),this._mapMouseEvent$(ax.dblclick,this._container.mouseService.dblClick$),this._mapMouseEvent$(ax.mousedown,this._container.mouseService.mouseDown$),this._mapMouseEvent$(ax.mousemove,e),this._mapMouseEvent$(ax.mouseout,this._container.mouseService.mouseOut$),this._mapMouseEvent$(ax.mouseover,this._container.mouseService.mouseOver$),this._mapMouseEvent$(ax.mouseup,this._container.mouseService.mouseUp$)).pipe(Lb(this._container.renderService.renderCamera$,this._navigator.stateService.reference$,this._navigator.stateService.currentTransform$),w_((([[e,t],i,r,n])=>{const o=this._projection.eventToUnprojection(t,this._container.element,i,r,n);return{basicPoint:o.basicPoint,latLon:o.latLon,originalEvent:t,pixelPoint:o.pixelPoint,target:this._eventEmitter,type:e}}))).subscribe((e=>{this._eventEmitter.fire(e.type,e)})),this._positionSubscription=this._container.renderService.renderCamera$.pipe(Iy((([e,t],[i,r])=>this._closeTo(e,i,.01)&&this._closeTo(t,r,.01)),(e=>e.camera.position.toArray()))).subscribe((()=>{this._eventEmitter.fire(ax.position,null)})),this._referenceSubscription=this._navigator.stateService.reference$.subscribe((()=>{this._eventEmitter.fire(ax.position,null)})),this._povSubscription=this._container.renderService.renderCamera$.pipe(Iy((([e,t],[i,r])=>this._closeTo(e,i,.001)&&this._closeTo(t,r,.001)),(e=>[e.rotation.phi,e.rotation.theta]))).subscribe((()=>{this._eventEmitter.fire(ax.pov,null)})),this._fovSubscription=this._container.renderService.renderCamera$.pipe(Iy(((e,t)=>this._closeTo(e,t,.01)),(e=>e.perspective.fov))).subscribe((()=>{this._eventEmitter.fire(ax.fov,null)}))}stopEmit(){this.started&&(this._started=!1,this._referenceSubscription.unsubscribe(),this._positionSubscription.unsubscribe(),this._povSubscription.unsubscribe(),this._fovSubscription.unsubscribe(),this._bearingSubscription.unsubscribe(),this._panToWithoutInertiaSubscription.unsubscribe(),this._panToSubscription.unsubscribe(),this._currentNodeSubscription.unsubscribe(),this._moveSubscription.unsubscribe(),this._sequenceEdgesSubscription.unsubscribe(),this._spatialEdgesSubscription.unsubscribe(),this._viewerMouseEventSubscription.unsubscribe(),this._bearingSubscription=null,this._currentNodeSubscription=null,this._moveSubscription=null,this._sequenceEdgesSubscription=null,this._spatialEdgesSubscription=null,this._viewerMouseEventSubscription=null)}unproject$(e){return B_(this._container.renderService.renderCamera$,this._navigator.stateService.reference$,this._navigator.stateService.currentTransform$).pipe(Yy(),w_((([t,i,r])=>this._projection.canvasToUnprojection(e,this._container.element,t,i,r).latLon)))}unprojectBasic$(e){return B_(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$).pipe(Yy(),w_((([t,i])=>this._projection.canvasToBasic(e,this._container.element,t,i))))}setFilter(e){return new Promise(((t,i)=>{this._navigator.setFilter$(e).subscribe((()=>{t(void 0)}),(e=>{i(e)}))}))}_closeTo(e,t,i){return Math.abs(e-t)<=i}_mapMouseEvent$(e,t){return t.pipe(w_((t=>[e,t])))}}class hx{constructor(){this._loadersSubject$=new zv,this._loaders$=this._loadersSubject$.pipe(eb(((e,t)=>(void 0!==t.task&&(e[t.task]=t.loading),e)),{}),wb({}),nb(new d_(1)),Vv())}get loading$(){return this._loaders$.pipe(w_((e=>Dd(e,((e,t)=>e||t),!1))),gy(100),Iy())}taskLoading$(e){return this._loaders$.pipe(w_((t=>!!t[e])),gy(100),Iy())}startLoading(e){this._loadersSubject$.next({loading:!0,task:e})}stopLoading(e){this._loadersSubject$.next({loading:!1,task:e})}}class ux{createFilter(e){return new Function("node","return "+this._compile(e)+";")}_compile(e){if(null==e||e.length<=1)return"true";const t=e[0];return"("+("=="===t?this._compileComparisonOp("===",e[1],e[2],!1):"!="===t?this._compileComparisonOp("!==",e[1],e[2],!1):">"===t||">="===t||"<"===t||"<="===t?this._compileComparisonOp(t,e[1],e[2],!0):"in"===t?this._compileInOp(e[1],e.slice(2)):"!in"===t?this._compileNegation(this._compileInOp(e[1],e.slice(2))):"all"===t?this._compileLogicalOp(e.slice(1),"&&"):"true")+")"}_compare(e,t){return e<t?-1:e>t?1:0}_compileComparisonOp(e,t,i,r){const n=this._compilePropertyReference(t),o=JSON.stringify(i);return(r?"typeof "+n+"===typeof "+o+"&&":"")+n+e+o}_compileInOp(e,t){const i=this._compare;return JSON.stringify(t.sort(i))+".indexOf("+this._compilePropertyReference(e)+")!==-1"}_compileLogicalOp(e,t){const i=this._compile.bind(this);return e.map(i).join(t)}_compileNegation(e){return"!("+e+")"}_compilePropertyReference(e){return"node["+JSON.stringify(e)+"]"}}class lx{constructor(e){this._cache=null,this._core=e,this._fill=null}get assetsCached(){return null!=this._core&&null!=this._fill&&null!=this._cache&&null!=this._cache.image&&null!=this._cache.mesh}get cache(){return this._cache}get alt(){return this._fill.calt}get ca(){return null!=this._fill.cca?this._fill.cca:this._fill.ca}get capturedAt(){return this._fill.captured_at}get computedCA(){return this._fill.cca}get computedLatLon(){return this._core.cl}get focal(){return this._fill.cfocal}get full(){return null!=this._fill}get fullPano(){return null!=this._fill.gpano&&0===this._fill.gpano.CroppedAreaLeftPixels&&0===this._fill.gpano.CroppedAreaTopPixels&&this._fill.gpano.CroppedAreaImageWidthPixels===this._fill.gpano.FullPanoWidthPixels&&this._fill.gpano.CroppedAreaImageHeightPixels===this._fill.gpano.FullPanoHeightPixels}get gpano(){return this._fill.gpano}get height(){return this._fill.height}get image(){return this._cache.image}get key(){return this._core.key}get latLon(){return null!=this._core.l?this._core.l:this._core.cl}get loadStatus(){return this._cache.loadStatus}get merged(){return null!=this._fill&&null!=this._fill.merge_version&&this._fill.merge_version>0}get mergeCC(){return this._fill.merge_cc}get mergeVersion(){return this._fill.merge_version}get mesh(){return this._cache.mesh}get orientation(){return this._fill.orientation}get originalCA(){return this._fill.ca}get originalLatLon(){return this._core.l}get pano(){return null!=this._fill.gpano&&null!=this._fill.gpano.FullPanoWidthPixels}get projectKey(){return null!=this._fill.project?this._fill.project.key:null}get rotation(){return this._fill.c_rotation}get translation(){return this._fill.c_translation}get scale(){return this._fill.atomic_scale}get sequenceKey(){return this._core.sequence.key}get sequenceEdges(){return this._cache.sequenceEdges}get sequenceEdges$(){return this._cache.sequenceEdges$}get spatialEdges(){return this._cache.spatialEdges}get spatialEdges$(){return this._cache.spatialEdges$}get userKey(){return this._fill.user.key}get username(){return this._fill.user.username}get tags(){return this._fill.tags}get width(){return this._fill.width}get date(){return this._fill.date}get floor(){return this._fill.floor}get floorId(){return this._fill.floor.id}get building(){return this._fill.building}cacheAssets$(){return this._cache.cacheAssets$(this.key,this.pano,this.merged).pipe(w_((e=>this)))}cacheImage$(e){return this._cache.cacheImage$(this.key,e).pipe(w_((e=>this)))}cacheSequenceEdges(e){this._cache.cacheSequenceEdges(e)}cacheSpatialEdges(e){this._cache.cacheSpatialEdges(e)}dispose(){null!=this._cache&&(this._cache.dispose(),this._cache=null),this._core=null,this._fill=null}initializeCache(e){if(null!=this._cache)throw new Error(`Node cache already initialized (${this.key}).`);this._cache=e}makeFull(e){if(null==e)throw new Error("Fill can not be null.");this._fill=e}resetSequenceEdges(){this._cache.resetSequenceEdges()}resetSpatialEdges(){this._cache.resetSpatialEdges()}uncache(){null!=this._cache&&(this._cache.dispose(),this._cache=null)}}var px={
|
|
9
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
10
|
+
read:function(e,t,i,r,n){var o,s,a=8*n-r-1,c=(1<<a)-1,h=c>>1,u=-7,l=i?n-1:0,p=i?-1:1,d=e[t+l];for(l+=p,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+l],l+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+e[t+l],l+=p,u-=8);if(0===o)o=1-h;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=h}return(d?-1:1)*s*Math.pow(2,o-r)},write:function(e,t,i,r,n,o){var s,a,c,h=8*o-n-1,u=(1<<h)-1,l=u>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?p/c:p*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=u?(a=0,s=u):s+l>=1?(a=(t*c-1)*Math.pow(2,n),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,n),s=0));n>=8;e[i+d]=255&a,d+=f,a/=256,n-=8);for(s=s<<n|a,h+=n;h>0;e[i+d]=255&s,d+=f,s/=256,h-=8);e[i+d-f]|=128*m}},dx=mx,fx=px;function mx(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}mx.Varint=0,mx.Fixed64=1,mx.Bytes=2,mx.Fixed32=5;var gx=4294967296,vx=1/gx,_x="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function yx(e){return e.type===mx.Bytes?e.readVarint()+e.pos:e.pos+1}function bx(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function xx(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function wx(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function Ax(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function Sx(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function Mx(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function Ex(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function Tx(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function Cx(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Ix(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function Nx(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Px(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Rx(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Ox(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}mx.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Px(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Ox(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Px(this.buf,this.pos)+Px(this.buf,this.pos+4)*gx;return this.pos+=8,e},readSFixed64:function(){var e=Px(this.buf,this.pos)+Ox(this.buf,this.pos+4)*gx;return this.pos+=8,e},readFloat:function(){var e=fx.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=fx.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(n=o[i.pos++],r=(112&n)>>4,n<128)return bx(e,r,t);if(n=o[i.pos++],r|=(127&n)<<3,n<128)return bx(e,r,t);if(n=o[i.pos++],r|=(127&n)<<10,n<128)return bx(e,r,t);if(n=o[i.pos++],r|=(127&n)<<17,n<128)return bx(e,r,t);if(n=o[i.pos++],r|=(127&n)<<24,n<128)return bx(e,r,t);if(n=o[i.pos++],r|=(1&n)<<31,n<128)return bx(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&_x?function(e,t,i){return _x.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){var r="",n=t;for(;n<i;){var o,s,a,c=e[n],h=null,u=c>239?4:c>223?3:c>191?2:1;if(n+u>i)break;1===u?c<128&&(h=c):2===u?128==(192&(o=e[n+1]))&&(h=(31&c)<<6|63&o)<=127&&(h=null):3===u?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&((h=(15&c)<<12|(63&o)<<6|63&s)<=2047||h>=55296&&h<=57343)&&(h=null)):4===u&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&((h=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,u=1):h>65535&&(h-=65536,r+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),r+=String.fromCharCode(h),n+=u}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==mx.Bytes)return e.push(this.readVarint(t));var i=yx(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==mx.Bytes)return e.push(this.readSVarint());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==mx.Bytes)return e.push(this.readBoolean());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==mx.Bytes)return e.push(this.readFloat());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==mx.Bytes)return e.push(this.readDouble());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==mx.Bytes)return e.push(this.readFixed32());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==mx.Bytes)return e.push(this.readSFixed32());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==mx.Bytes)return e.push(this.readFixed64());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==mx.Bytes)return e.push(this.readSFixed64());var t=yx(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===mx.Varint)for(;this.buf[this.pos++]>127;);else if(t===mx.Bytes)this.pos=this.readVarint()+this.pos;else if(t===mx.Fixed32)this.pos+=4;else{if(t!==mx.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Rx(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Rx(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Rx(this.buf,-1&e,this.pos),Rx(this.buf,Math.floor(e*vx),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Rx(this.buf,-1&e,this.pos),Rx(this.buf,Math.floor(e*vx),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos]=127&e}(i,0,t),function(e,t){var i=(7&e)<<4;if(t.buf[t.pos++]|=i|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,n,o=0;o<t.length;o++){if((r=t.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&xx(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),fx.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),fx.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&xx(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,mx.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,wx,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Ax,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Ex,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Sx,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Mx,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Tx,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Cx,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Ix,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Nx,t)},writeBytesField:function(e,t){this.writeTag(e,mx.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,mx.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,mx.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,mx.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,mx.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,mx.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,mx.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,mx.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,mx.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,mx.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var Dx=t({__proto__:null,default:dx},[dx]);class Lx{static read(e){return new Dx(e).readFields(Lx._readMeshField,{faces:[],vertices:[]})}static _readMeshField(e,t,i){1===e?t.vertices.push(i.readFloat()):2===e&&t.faces.push(i.readVarint())}}class kx{constructor(){this._disposed=!1,this._image=null,this._loadStatus={loaded:0,total:0},this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._sequenceEdgesChanged$=new zv,this._sequenceEdges$=this._sequenceEdgesChanged$.pipe(wb(this._sequenceEdges),nb(new d_(1)),Vv()),this._sequenceEdgesSubscription=this._sequenceEdges$.subscribe((()=>{})),this._spatialEdgesChanged$=new zv,this._spatialEdges$=this._spatialEdgesChanged$.pipe(wb(this._spatialEdges),nb(new d_(1)),Vv()),this._spatialEdgesSubscription=this._spatialEdges$.subscribe((()=>{})),this._cachingAssets$=null}get image(){return this._image}get loadStatus(){return this._loadStatus}get mesh(){return this._mesh}get sequenceEdges(){return this._sequenceEdges}get sequenceEdges$(){return this._sequenceEdges$}get spatialEdges(){return this._spatialEdges}get spatialEdges$(){return this._spatialEdges$}cacheAssets$(e,t,i){return null!=this._cachingAssets$||(this._cachingAssets$=B_(this._cacheImage$(e),(e=>(this._loadStatus.loaded=0,this._loadStatus.total=0,this._mesh={faces:[],vertices:[]},e&&(this._image=e.object,this._loadStatus.loaded+=e.loaded.loaded,this._loadStatus.total+=e.loaded.total),this))).pipe(qy((()=>{this._cachingAssets$=null})),nb(new d_(1)),Vv())),this._cachingAssets$}cacheImage$(e,t){return null!=this._image&&t<=Math.max(this._image.width,this._image.height)?a_(this):this._cacheImage$(e).pipe(Yy((e=>null!=e.object)),Ly((e=>{this._disposeImage(),this._image=e.object})),w_((e=>this)))}cacheSequenceEdges(e){this._sequenceEdges={cached:!0,edges:e},this._sequenceEdgesChanged$.next(this._sequenceEdges)}cacheSpatialEdges(e){this._spatialEdges={cached:!0,edges:e},this._spatialEdgesChanged$.next(this._spatialEdges)}dispose(){this._sequenceEdgesSubscription.unsubscribe(),this._spatialEdgesSubscription.unsubscribe(),this._disposeImage(),this._mesh=null,this._loadStatus.loaded=0,this._loadStatus.total=0,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._sequenceEdgesChanged$.next(this._sequenceEdges),this._spatialEdgesChanged$.next(this._spatialEdges),this._disposed=!0,null!=this._imageRequest&&this._imageRequest.abort(),null!=this._meshRequest&&this._meshRequest.abort()}resetSequenceEdges(){this._sequenceEdges={cached:!1,edges:[]},this._sequenceEdgesChanged$.next(this._sequenceEdges)}resetSpatialEdges(){this._spatialEdges={cached:!1,edges:[]},this._spatialEdgesChanged$.next(this._spatialEdges)}_cacheImage$(e){return Dv.create((t=>{let i=new XMLHttpRequest;i.open("GET",Wb.thumbnail(e),!0),i.setRequestHeader("Accept","image/jpeg"),i.custom&&i.custom.xhr&&(i=i.custom.xhr),i.responseType="arraybuffer",i.timeout=15e3,i.onload=r=>{if(200!==i.status)return this._imageRequest=null,void t.error(new Error(`Failed to fetch image (${e}). Status: ${i.status}, ${i.statusText}`));let n=new Image;n.crossOrigin="Anonymous",n.onload=i=>{if(this._imageRequest=null,this._disposed)return window.URL.revokeObjectURL(n.src),void t.error(new Error(`Image load was aborted (${e})`));t.next({loaded:{loaded:r.loaded,total:r.total},object:n}),t.complete()},n.onerror=i=>{this._imageRequest=null,t.error(new Error(`Failed to load image (${e})`))};let o=new Blob([i.response]);n.src=window.URL.createObjectURL(o)},i.onprogress=e=>{this._disposed||t.next({loaded:{loaded:e.loaded,total:e.total},object:null})},i.onerror=i=>{this._imageRequest=null,t.error(new Error(`Failed to fetch image (${e})`))},i.ontimeout=i=>{this._imageRequest=null,t.error(new Error(`Image request timed out (${e})`))},i.onabort=i=>{this._imageRequest=null,t.error(new Error(`Image request was aborted (${e})`))},this._imageRequest=i,i.send(null)}))}_cacheMesh$(e,t){return Dv.create((i=>{if(!t)return i.next(this._createEmptyMeshLoadStatus()),void i.complete();let r=new XMLHttpRequest;r.open("GET",Wb.protoMesh(e),!0),r.setRequestHeader("Accept","application/mesh"),r.custom&&r.custom.xhr&&(r=r.custom.xhr),r.responseType="arraybuffer",r.timeout=15e3,r.onload=e=>{this._meshRequest=null,this._disposed||(200!==r.status||Lx.read(new Buffer(r.response)),i.next({loaded:{loaded:e.loaded,total:e.total},object:{faces:[],vertices:[]}}),i.complete())},r.onprogress=e=>{this._disposed||i.next({loaded:{loaded:e.loaded,total:e.total},object:null})},r.onerror=e=>{this._meshRequest=null,i.next(this._createEmptyMeshLoadStatus()),i.complete()},r.ontimeout=e=>{this._meshRequest=null,i.next(this._createEmptyMeshLoadStatus()),i.complete()},r.onabort=e=>{this._meshRequest=null},this._meshRequest=r,r.send(null)}))}_createEmptyMeshLoadStatus(){return{loaded:{loaded:0,total:0},object:{faces:[],vertices:[]}}}_disposeImage(){null!=this._image&&window.URL.revokeObjectURL(this._image.src),this._image=null}}class Bx{constructor(e){this._key=e.key,this._keys=e.keys,this._country=e.country,this._city=e.city,this._building=e.building,this._floor=e.floor,this._loopLine=e.loop_line}get key(){return this._key}get keys(){return this._keys}get country(){return this._country}get city(){return this._city}get building(){return this._building}get floor(){return this._floor}get floorVersion(){return this._loopLine}dispose(){this._key=null,this._keys=null}findNextKey(e){let t=Cd(this._keys,e);return t+1>=this._keys.length||-1===t?null:this._keys[t+1]}findPrevKey(e){let t=Cd(this._keys,e);return 0===t||-1===t?null:this._keys[t-1]}}var Fx,jx={exports:{}};!function(e){var t={base32:"0123456789bcdefghjkmnpqrstuvwxyz",encode:function(e,i,r){if(void 0===r){for(var n=1;n<=12;n++){var o=t.encode(e,i,n),s=t.decode(o);if(s.lat==e&&s.lon==i)return o}r=12}if(e=Number(e),i=Number(i),r=Number(r),isNaN(e)||isNaN(i)||isNaN(r))throw new Error("Invalid geohash");for(var a=0,c=0,h=!0,u="",l=-90,p=90,d=-180,f=180;u.length<r;){if(h){var m=(d+f)/2;i>=m?(a=2*a+1,d=m):(a*=2,f=m)}else{var g=(l+p)/2;e>=g?(a=2*a+1,l=g):(a*=2,p=g)}h=!h,5==++c&&(u+=t.base32.charAt(a),c=0,a=0)}return u},decode:function(e){var i=t.bounds(e),r=i.sw.lat,n=i.sw.lon,o=i.ne.lat,s=i.ne.lon,a=(r+o)/2,c=(n+s)/2;return a=a.toFixed(Math.floor(2-Math.log(o-r)/Math.LN10)),c=c.toFixed(Math.floor(2-Math.log(s-n)/Math.LN10)),{lat:Number(a),lon:Number(c)}},bounds:function(e){if(0===e.length)throw new Error("Invalid geohash");e=e.toLowerCase();for(var i=!0,r=-90,n=90,o=-180,s=180,a=0;a<e.length;a++){var c=e.charAt(a),h=t.base32.indexOf(c);if(-1==h)throw new Error("Invalid geohash");for(var u=4;u>=0;u--){var l=h>>u&1;if(i){var p=(o+s)/2;1==l?o=p:s=p}else{var d=(r+n)/2;1==l?r=d:n=d}i=!i}}return{sw:{lat:r,lon:o},ne:{lat:n,lon:s}}},adjacent:function(e,i){if(e=e.toLowerCase(),i=i.toLowerCase(),0===e.length)throw new Error("Invalid geohash");if(-1=="nsew".indexOf(i))throw new Error("Invalid direction");var r=e.slice(-1),n=e.slice(0,-1),o=e.length%2;return-1!={n:["prxz","bcfguvyz"],s:["028b","0145hjnp"],e:["bcfguvyz","prxz"],w:["0145hjnp","028b"]}[i][o].indexOf(r)&&""!==n&&(n=t.adjacent(n,i)),n+t.base32.charAt({n:["p0r21436x8zb9dcf5h7kjnmqesgutwvy","bc01fg45238967deuvhjyznpkmstqrwx"],s:["14365h7k9dcfesgujnmqp0r2twvyx8zb","238967debc01fg45kmstqrwxuvhjyznp"],e:["bc01fg45238967deuvhjyznpkmstqrwx","p0r21436x8zb9dcf5h7kjnmqesgutwvy"],w:["238967debc01fg45kmstqrwxuvhjyznp","14365h7k9dcfesgujnmqp0r2twvyx8zb"]}[i][o].indexOf(r))},neighbours:function(e){return{n:t.adjacent(e,"n"),ne:t.adjacent(t.adjacent(e,"n"),"e"),e:t.adjacent(e,"e"),se:t.adjacent(t.adjacent(e,"s"),"e"),s:t.adjacent(e,"s"),sw:t.adjacent(t.adjacent(e,"s"),"w"),w:t.adjacent(e,"w"),nw:t.adjacent(t.adjacent(e,"n"),"w")}}};e.exports&&(e.exports=t)}(jx);class zx{constructor(e){this._geoCoords=null!=e?e:new Uu}encodeH(e,t=7){return jx.exports.encode(e.lat,e.lon,t)}encodeHs(e,t=7,i=20){let r=jx.exports.encode(e.lat,e.lon,t),n=jx.exports.bounds(r),o=n.ne,s=n.sw,a=jx.exports.neighbours(r),c=[0,0,0],h=this._geoCoords.geodeticToEnu(o.lat,o.lon,0,s.lat,s.lon,0),u=this._geoCoords.geodeticToEnu(e.lat,e.lon,0,s.lat,s.lon,0),l=u[0]-c[0]<i,p=h[0]-u[0]<i,d=u[1]-c[1]<i,f=h[1]-u[1]<i,m=[r];return f&&m.push(a.n),f&&l&&m.push(a.nw),l&&m.push(a.w),l&&d&&m.push(a.sw),d&&m.push(a.s),d&&p&&m.push(a.se),p&&m.push(a.e),p&&f&&m.push(a.ne),m}boundingBoxCorners(e,t){let i=this._geoCoords.enuToGeodetic(-t,-t,0,e.lat,e.lon,0),r=this._geoCoords.enuToGeodetic(t,t,0,e.lat,e.lon,0);return[{lat:i[0],lon:i[1]},{lat:r[0],lon:r[1]}]}rotationFromCompass(e,t){let i=0,r=0,n=0;switch(t){case 1:i=Math.PI/2;break;case 3:i=-Math.PI/2,n=Math.PI;break;case 6:r=-Math.PI/2,n=-Math.PI/2;break;case 8:r=Math.PI/2,n=Math.PI/2}let o=(new de).makeRotationZ(n),s=new ge(i,r,e*Math.PI/180,"XYZ"),a=(new de).makeRotationFromEuler(s),c=(new J).setAxisAngleFromRotationMatrix(a.multiply(o));return c.multiplyScalar(c.w).toArray().slice(0,3)}}class $x{constructor(e,t,i,r,n,o){this._api=e,this._cachedPaths={},this._cachedNodes={},this._cachedNodeTiles={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._changed$=new zv,this._defaultAlt=2,this._edgeCalculator=null!=r?r:new ll,this._filterCreator=null!=n?n:new ux,this._filter=this._filterCreator.createFilter(void 0),this._graphCalculator=null!=i?i:new zx,this._configuration=null!=o?o:{maxSequences:50,maxUnusedNodes:100,maxUnusedTiles:20},this._nodes={},this._nodeIndex=null!=t?t:new ul(16),this._nodeIndexTiles={},this._nodeToTile={},this._preStored={},this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._tilePrecision=7,this._tileThreshold=20}get changed$(){return this._changed$}cachePath$(e,t){let i=this.getNode(e);return this._api.buildingByKey$(i.building.id,t).pipe(w_((e=>{let r=i.building.id;return t&&(r+=t),this._cachedPaths[r]=Rp(e).map((e=>e.images)).reduce(((e,t)=>e.concat(t)),[]),this._cachedPaths[r]})))}cacheOutdoorPath$(e,t,i){const r={lon:e,lat:t};return this._api.outdoorByLatLon$(r,200,i).pipe(w_((e=>{let t=[];e.forEach((e=>t=t.concat(e.outdoorImages)));let n=this._graphCalculator.encodeH(r);return i&&(n+=i),this._cachedPaths[n]=t,this._cachedPaths[n]})))}cacheFill$(e){if(e in this._cachingFull$)throw new $u(`Cannot fill node while caching full (${e}).`);if(!this.hasNode(e))throw new $u(`Cannot fill node that does not exist in graph (${e}).`);if(e in this._cachingFill$)return this._cachingFill$[e];let t=this.getNode(e);if(t.full)throw new $u(`Cannot fill node that is already full (${e}).`);return this._cachingFill$[e]=this._api.imageByKeyFill$([e]).pipe(Ly((i=>{t.full||this._makeFull(t,i[e]),delete this._cachingFill$[e]})),w_((e=>this)),qy((()=>{e in this._cachingFill$&&delete this._cachingFill$[e],this._changed$.next(this)})),mb()),this._cachingFill$[e]}cacheFull$(e){if(e in this._cachingFull$)return this._cachingFull$[e];if(this.hasNode(e))throw new $u(`Cannot cache full node that already exist in graph (${e}).`);const t=this._api.imageByKeyFull$([e]).pipe(ly((()=>this._api.imageByKeyFullForOutdoor$([e]))));return this._cachingFull$[e]=t.pipe(Ly((t=>{let i=t[e];if(this.hasNode(e)){let t=this.getNode(e);t.full||this._makeFull(t,i)}else{if(null==i.sequence||null==i.sequence.key)throw new $u(`Node has no sequence (${e}).`);let t=new lx(i);this._makeFull(t,i);let r=this._graphCalculator.encodeH(t.originalLatLon,this._tilePrecision);this._preStore(r,t),this._setNode(t),delete this._cachingFull$[e]}})),w_((e=>this)),qy((()=>{e in this._cachingFull$&&delete this._cachingFull$[e],this._changed$.next(this)})),mb()),this._cachingFull$[e]}cacheNodeSequence$(e){if(!this.hasNode(e))throw new $u(`Cannot cache sequence edges of node that does not exist in graph (${e}).`);let t=this.getNode(e);if(t.sequenceKey in this._sequences)throw new $u(`Sequence already cached (${e}), (${t.sequenceKey}).`);return this._cacheSequence$(t.sequenceKey)}cacheSequence$(e){if(e in this._sequences)throw new $u(`Sequence already cached (${e})`);return this._cacheSequence$(e)}cacheSequenceEdges(e){let t=this.getNode(e);if(!(t.sequenceKey in this._sequences))throw new $u(`Sequence is not cached (${e}), (${t.sequenceKey})`);let i=this._sequences[t.sequenceKey].sequence,r=this._edgeCalculator.computeSequenceEdges(t,i);t.cacheSequenceEdges(r)}cacheSpatialArea$(e){if(!this.hasNode(e))throw new $u(`Cannot cache spatial area of node that does not exist in graph (${e}).`);if(e in this._cachedSpatialEdges)throw new $u(`Node already spatially cached (${e}).`);if(!(e in this._requiredSpatialArea))throw new $u(`Spatial area not determined (${e}).`);let t=this._requiredSpatialArea[e];if(0===Object.keys(t.cacheNodes).length)throw new $u(`Spatial nodes already cached (${e}).`);if(e in this._cachingSpatialArea$)return this._cachingSpatialArea$[e];let i=[];for(;t.cacheKeys.length>0;)i.push(t.cacheKeys.splice(0,200));let r=i.length,n=[];for(let o of i){let i=this._api.imageByKeyFill$(o).pipe(Ly((i=>{for(let e in i){if(!i.hasOwnProperty(e))continue;let r=t.cacheNodes[e];if(r.full){delete t.cacheNodes[e];continue}let n=i[e];this._makeFull(r,n),delete t.cacheNodes[e]}0==--r&&delete this._cachingSpatialArea$[e]})),w_((e=>this)),ly((i=>{for(let e of o)e in t.all&&delete t.all[e],e in t.cacheNodes&&delete t.cacheNodes[e];throw 0==--r&&delete this._cachingSpatialArea$[e],i})),qy((()=>{0===Object.keys(t.cacheNodes).length&&this._changed$.next(this)})),mb());n.push(i)}return this._cachingSpatialArea$[e]=n,n}cacheSpatialEdges(e){if(e in this._cachedSpatialEdges)throw new $u(`Spatial edges already cached (${e}).`);let t=this.getNode(e),i=this._sequences[t.sequenceKey].sequence,r=[],n=i.findPrevKey(t.key);null!=n&&r.push(n);let o=i.findNextKey(t.key);null!=o&&r.push(o);let s=this._requiredSpatialArea[e].all,a=[],c=this._filter;for(let e in s){if(!s.hasOwnProperty(e))continue;let t=s[e];c(t)&&a.push(t)}let h=this._edgeCalculator.getPotentialEdges(t,a,r),u=this._edgeCalculator.computeStepEdges(t,h,n,o);u=u.concat(this._edgeCalculator.computeTurnEdges(t,h)),u=u.concat(this._edgeCalculator.computePanoEdges(t,h)),u=u.concat(this._edgeCalculator.computePerspectiveToPanoEdges(t,h)),u=u.concat(this._edgeCalculator.computeSimilarEdges(t,h)),t.cacheSpatialEdges(u),this._cachedSpatialEdges[e]=t,delete this._requiredSpatialArea[e],delete this._cachedNodeTiles[e]}cacheTiles$(e){if(e in this._cachedNodeTiles)throw new $u(`Tiles already cached (${e}).`);if(e in this._cachedSpatialEdges)throw new $u(`Spatial edges already cached so tiles considered cached (${e}).`);if(!(e in this._requiredNodeTiles))throw new $u(`Tiles have not been determined (${e}).`);let t=this._requiredNodeTiles[e];if(0===t.cache.length&&0===t.caching.length)throw new $u(`Tiles already cached (${e}).`);if(!this.hasNode(e))throw new $u(`Cannot cache tiles of node that does not exist in graph (${e}).`);let i=t.cache.slice();t.caching=this._requiredNodeTiles[e].caching.concat(i),t.cache=[];let r=[];for(let i of t.caching){let n=null;i in this._cachingTiles$?n=this._cachingTiles$[i]:(n=this._api.imagesByH$(i,this.getNode(e).latLon).pipe(Ly((e=>{let t=e[i];if(i in this._cachedTiles)return;this._nodeIndexTiles[i]=[],this._cachedTiles[i]={accessed:(new Date).getTime(),nodes:[]};let r=this._cachedTiles[i].nodes,n=this._removeFromPreStore(i);for(let e in t){if(!t.hasOwnProperty(e))continue;let o,s,a=t[e];if(null==a)break;null!=a.sequence&&null!=a.sequence.key?null!=n&&a.key in n?(o=n[a.key],delete n[a.key],r.push(o),s={lat:o.latLon.lat,lon:o.latLon.lon,node:o},this._nodeIndex.insert(s),this._nodeIndexTiles[i].push(s),this._nodeToTile[o.key]=i):(o=new lx(a),r.push(o),s={lat:o.latLon.lat,lon:o.latLon.lon,node:o},this._nodeIndex.insert(s),this._nodeIndexTiles[i].push(s),this._nodeToTile[o.key]=i,this._setNode(o)):console.warn(`Sequence missing, discarding (${a.key})`)}delete this._cachingTiles$[i]})),w_((e=>this)),ly((e=>{throw delete this._cachingTiles$[i],e})),mb()),this._cachingTiles$[i]=n),r.push(n.pipe(Ly((r=>{let n=t.caching.indexOf(i);n>-1&&t.caching.splice(n,1),0===t.caching.length&&0===t.cache.length&&(delete this._requiredNodeTiles[e],this._cachedNodeTiles[e]=!0)})),qy((()=>{this._changed$.next(this)})),mb()))}return r}initializeCache(e){if(e in this._cachedNodes)throw new $u(`Node already in cache (${e}).`);let t=this.getNode(e);t.initializeCache(new kx);let i=(new Date).getTime();this._cachedNodes[e]={accessed:i,node:t},this._updateCachedTileAccess(e,i)}isCachingFill(e){return e in this._cachingFill$}isCachingFull(e){return e in this._cachingFull$}isCachingNodeSequence(e){return this.getNode(e).sequenceKey in this._cachingSequences$}isCachingSequence(e){return e in this._cachingSequences$}isCachingTiles(e){return e in this._requiredNodeTiles&&0===this._requiredNodeTiles[e].cache.length&&this._requiredNodeTiles[e].caching.length>0}hasInitializedCache(e){return e in this._cachedNodes}hasCachedPaths(e,t){return t&&(e+=t),e in this._cachedPaths}getCachedPaths(e,t){return t&&(e+=t),this._cachedPaths[e]}hasNode(e){let t=(new Date).getTime();return this._updateCachedNodeAccess(e,t),this._updateCachedTileAccess(e,t),e in this._nodes}hasNodeSequence(e){let t=this.getNode(e).sequenceKey,i=t in this._sequences;return i&&(this._sequences[t].accessed=(new Date).getTime()),i}hasSequence(e){let t=e in this._sequences;return t&&(this._sequences[e].accessed=(new Date).getTime()),t}hasSpatialArea(e){if(!this.hasNode(e))throw new $u(`Spatial area nodes cannot be determined if node not in graph (${e}).`);if(e in this._cachedSpatialEdges)return!0;if(e in this._requiredSpatialArea)return 0===Object.keys(this._requiredSpatialArea[e].cacheNodes).length;let t=this.getNode(e),i=this._graphCalculator.boundingBoxCorners(t.latLon,this._tileThreshold),r=this._nodeIndex.search({maxX:i[1].lat,maxY:i[1].lon,minX:i[0].lat,minY:i[0].lon}),n={all:{},cacheKeys:[],cacheNodes:{}};for(let e of r)n.all[e.node.key]=e.node,e.node.full||(n.cacheKeys.push(e.node.key),n.cacheNodes[e.node.key]=e.node);return this._requiredSpatialArea[e]=n,0===n.cacheKeys.length}hasTiles(e){if(e in this._cachedNodeTiles)return!0;if(e in this._cachedSpatialEdges)return!0;if(!this.hasNode(e))throw new $u(`Node does not exist in graph (${e}).`);let t={cache:[],caching:[]};if(e in this._requiredNodeTiles)t=this._requiredNodeTiles[e];else{let i=this.getNode(e);t.cache=this._graphCalculator.encodeHs(i.latLon,this._tilePrecision,this._tileThreshold).filter((e=>!(e in this._cachedTiles))),t.cache.length>0&&(this._requiredNodeTiles[e]=t)}return 0===t.cache.length&&0===t.caching.length}getNode(e){let t=(new Date).getTime();return this._updateCachedNodeAccess(e,t),this._updateCachedTileAccess(e,t),this._nodes[e]}getSequence(e){let t=this._sequences[e];return t.accessed=(new Date).getTime(),t.sequence}resetSpatialEdges(){let e=Object.keys(this._cachedSpatialEdges);for(let t of e){this._cachedSpatialEdges[t].resetSpatialEdges(),delete this._cachedSpatialEdges[t]}}reset(e){const t=[];for(const i of e){if(!this.hasNode(i))throw new Error(`Node does not exist ${i}`);const e=this.getNode(i);e.resetSequenceEdges(),e.resetSpatialEdges(),t.push(e)}for(let t of Object.keys(this._cachedNodes))-1===e.indexOf(t)&&(this._cachedNodes[t].node.dispose(),delete this._cachedNodes[t]);this._cachedNodeTiles={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._nodes={},this._nodeToTile={},this._preStored={};for(const e of t){this._nodes[e.key]=e;const t=this._graphCalculator.encodeH(e.originalLatLon,this._tilePrecision);this._preStore(t,e)}this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._nodeIndexTiles={},this._nodeIndex.clear()}setFilter(e){this._filter=this._filterCreator.createFilter(e)}uncache(e){let t={};this._addNewKeys(t,this._cachingFull$),this._addNewKeys(t,this._cachingFill$),this._addNewKeys(t,this._cachingTiles$),this._addNewKeys(t,this._cachingSpatialArea$),this._addNewKeys(t,this._requiredNodeTiles),this._addNewKeys(t,this._requiredSpatialArea);for(let i of e)i in t||(t[i]=!0);let i={};for(let e in t){if(!t.hasOwnProperty(e))continue;let r=this._nodes[e],n=this._graphCalculator.encodeHs(r.latLon);for(let e of n)e in i||(i[e]=!0)}let r=[];for(let e in this._cachedTiles)this._cachedTiles.hasOwnProperty(e)&&!(e in i)&&r.push([e,this._cachedTiles[e]]);let n=r.sort(((e,t)=>t[1].accessed-e[1].accessed)).slice(this._configuration.maxUnusedTiles).map((e=>e[0]));for(let e of n)this._uncacheTile(e);let o=[];for(let e in this._cachedNodes)this._cachedNodes.hasOwnProperty(e)&&!(e in t)&&o.push(this._cachedNodes[e]);let s=o.sort(((e,t)=>t.accessed-e.accessed)).slice(this._configuration.maxUnusedNodes);for(let e of s){e.node.uncache();let t=e.node.key;delete this._cachedNodes[t],t in this._cachedNodeTiles&&delete this._cachedNodeTiles[t],t in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[t]}let a=[];for(let e in this._sequences)this._sequences.hasOwnProperty(e)&&!(e in this._cachingSequences$)&&a.push(this._sequences[e]);let c=a.sort(((e,t)=>t.accessed-e.accessed)).slice(this._configuration.maxSequences);for(let e of c){let t=e.sequence.key;delete this._sequences[t],e.sequence.dispose()}}_addNewKeys(e,t){for(let i in t)t.hasOwnProperty(i)&&this.hasNode(i)&&(i in e||(e[i]=!0))}_cacheSequence$(e){if(e in this._cachingSequences$)return this._cachingSequences$[e];const t=this._api.sequenceByKey$([e]).pipe(ly((()=>this._api.sequenceByKeyForOutdoor$([e]))));return this._cachingSequences$[e]=t.pipe(Ly((t=>{e in this._sequences||(this._sequences[e]={accessed:(new Date).getTime(),sequence:new Bx(t[e])}),delete this._cachingSequences$[e]})),w_((e=>this)),qy((()=>{e in this._cachingSequences$&&delete this._cachingSequences$[e],this._changed$.next(this)})),mb()),this._cachingSequences$[e]}_makeFull(e,t){null==t.calt&&(t.calt=this._defaultAlt),null==t.c_rotation&&(t.c_rotation=this._graphCalculator.rotationFromCompass(t.ca,t.orientation)),e.makeFull(t)}_preStore(e,t){e in this._preStored||(this._preStored[e]={}),this._preStored[e][t.key]=t}_removeFromPreStore(e){let t=null;return e in this._preStored&&(t=this._preStored[e],delete this._preStored[e]),t}_setNode(e){let t=e.key;this.hasNode(t)||(this._nodes[t]=e)}_uncacheTile(e){for(let t of this._cachedTiles[e].nodes){let e=t.key;delete this._nodes[e],delete this._nodeToTile[e],e in this._cachedNodes&&delete this._cachedNodes[e],e in this._cachedNodeTiles&&delete this._cachedNodeTiles[e],e in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[e],t.dispose()}for(let t of this._nodeIndexTiles[e])this._nodeIndex.remove(t);delete this._nodeIndexTiles[e],delete this._cachedTiles[e]}_updateCachedTileAccess(e,t){e in this._nodeToTile&&(this._cachedTiles[this._nodeToTile[e]].accessed=t)}_updateCachedNodeAccess(e,t){e in this._cachedNodes&&(this._cachedNodes[e].accessed=t)}}class Vx{constructor(e,t){this._graph$=a_(e).pipe(my(e.changed$),nb(new d_(1)),Vv()),this._graph$.subscribe((()=>{})),this._imageLoadingService=t,this._firstGraphSubjects$=[],this._initializeCacheSubscriptions=[],this._sequenceSubscriptions=[],this._spatialSubscriptions=[],this._graphCalculator=new zx}cachePath$(e,t){let i=this._graph$.pipe(Yy(),$_((i=>{const r=i.getNode(e);return r.building?i.hasCachedPaths(r.building.id,t)?a_(i.getCachedPaths(r.building.id,t)):i.cachePath$(e,t):a_([]).pipe(Ay(500))})),nb(new d_(1)),Vv());return i.subscribe((e=>{this._imageLoadingService.loadpath$.next(e)}),(t=>{console.error(`Failed to cache path (${e})`,t)})),i}cacheOutdoorPath$(e,t){let i=this._graph$.pipe(Yy(),$_((i=>{const r=i.getNode(e),n=this._graphCalculator.encodeH(r.latLon);return i.hasCachedPaths(n,t)?a_(i.getCachedPaths(n,t)):i.cacheOutdoorPath$(r.latLon.lon,r.latLon.lat,t)})),nb(new d_(1)),Vv());return i.subscribe((e=>{this._imageLoadingService.loadpathOutdoor$.next(e)}),(t=>{console.error(`Failed to cache path (${e})`,t)})),i}cacheNode$(e){let t=new zv;this._firstGraphSubjects$.push(t);let i,r,n,o=t.pipe(nb(new d_(1)),Vv()),s=o.pipe(w_((t=>t.getNode(e))),$_((e=>e.assetsCached?a_(e):e.cacheAssets$())),nb(new d_(1)),Vv());return s.subscribe(void 0,(t=>{console.error(`Failed to cache node (${e})`,t)})),i=this._graph$.pipe(Yy(),$_((t=>t.isCachingFull(e)||!t.hasNode(e)?t.cacheFull$(e):t.isCachingFill(e)||!t.getNode(e).full?t.cacheFill$(e):a_(t))),Ly((t=>{t.hasInitializedCache(e)||t.initializeCache(e)})),qy((()=>{null!=i&&(this._removeFromArray(i,this._initializeCacheSubscriptions),this._removeFromArray(t,this._firstGraphSubjects$))}))).subscribe((e=>{t.next(e),t.complete()}),(e=>{t.error(e)})),i.closed||this._initializeCacheSubscriptions.push(i),r=o.pipe($_((t=>t.isCachingNodeSequence(e)||!t.hasNodeSequence(e)?t.cacheNodeSequence$(e):a_(t))),Ly((t=>{t.getNode(e).sequenceEdges.cached||t.cacheSequenceEdges(e)})),qy((()=>{null!=r&&this._removeFromArray(r,this._sequenceSubscriptions)}))).subscribe((e=>{}),(t=>{console.error(`Failed to cache sequence edges (${e}).`,t)})),r.closed||this._sequenceSubscriptions.push(r),n=o.pipe(ly((()=>t_)),Uy((t=>t.hasTiles(e)?t_:z_(t.cacheTiles$(e)).pipe($_((t=>t.pipe($_((t=>t.isCachingTiles(e)?t_:a_(t))),ly(((t,i)=>(console.error(`Failed to cache tile data (${e}).`,t),t_))))))))),Jy(),$_((t=>t.hasSpatialArea(e)?a_(t):z_(t.cacheSpatialArea$(e)).pipe($_((t=>t.pipe(ly(((t,i)=>(console.error(`Failed to cache spatial nodes (${e}).`,t),t_))))))))),Jy(),$_((t=>t.hasNodeSequence(e)?a_(t):t.cacheNodeSequence$(e))),Ly((t=>{t.getNode(e).spatialEdges.cached||t.cacheSpatialEdges(e)})),qy((()=>{null!=n&&this._removeFromArray(n,this._spatialSubscriptions)}))).subscribe((e=>{}),(t=>{console.error(`Failed to cache spatial edges (${e}).`,t)})),n.closed||this._spatialSubscriptions.push(n),s.pipe(Yy((e=>e.assetsCached)))}cacheSequence$(e){return this._graph$.pipe(Yy(),$_((t=>t.isCachingSequence(e)||!t.hasSequence(e)?t.cacheSequence$(e):a_(t))),w_((t=>t.getSequence(e))))}setFilter$(e){return this._resetSubscriptions(this._spatialSubscriptions),this._graph$.pipe(Yy(),Ly((t=>{t.resetSpatialEdges(),t.setFilter(e)})))}reset$(e){return this._abortSubjects(this._firstGraphSubjects$),this._resetSubscriptions(this._initializeCacheSubscriptions),this._resetSubscriptions(this._sequenceSubscriptions),this._resetSubscriptions(this._spatialSubscriptions),this._graph$.pipe(Yy(),Ly((t=>{t.reset(e)})))}uncache$(e){return this._graph$.pipe(Yy(),Ly((t=>{t.uncache(e)})))}_abortSubjects(e){for(let t of e.slice())this._removeFromArray(t,e),t.error(new Error("Cache node request was aborted."))}_removeFromArray(e,t){let i=t.indexOf(e);-1!==i&&t.splice(i,1)}_resetSubscriptions(e){for(let t of e.slice())this._removeFromArray(t,e),t.closed||t.unsubscribe()}}class Ux{constructor(){this._loadnode$=new zv,this._loadpath$=new zv,this._loadpathOutdoor$=new zv,this._loadstatus$=this._loadnode$.pipe(eb(((e,t)=>(e[t.key]=t.loadStatus,e)),{}),nb(new d_(1)),Vv()),this._loadpath$.subscribe((()=>{})),this._loadpathOutdoor$.subscribe((()=>{})),this._loadstatus$.subscribe((()=>{}))}get loadpath$(){return this._loadpath$}get loadpathOutdoor$(){return this._loadpathOutdoor$}get loadnode$(){return this._loadnode$}get loadstatus$(){return this._loadstatus$}}class Gx{constructor(e){e.requestAnimationFrame?(this._cancelAnimationFrame=e.cancelAnimationFrame.bind(e),this._requestAnimationFrame=e.requestAnimationFrame.bind(e)):e.mozRequestAnimationFrame?(this._cancelAnimationFrame=e.mozCancelAnimationFrame.bind(e),this._requestAnimationFrame=e.mozRequestAnimationFrame.bind(e)):e.webkitRequestAnimationFrame?(this._cancelAnimationFrame=e.webkitCancelAnimationFrame.bind(e),this._requestAnimationFrame=e.webkitRequestAnimationFrame.bind(e)):e.msRequestAnimationFrame?(this._cancelAnimationFrame=e.msCancelAnimationFrame.bind(e),this._requestAnimationFrame=e.msRequestAnimationFrame.bind(e)):e.oRequestAnimationFrame?(this._cancelAnimationFrame=e.oCancelAnimationFrame.bind(e),this._requestAnimationFrame=e.oRequestAnimationFrame.bind(e)):(this._cancelAnimationFrame=e.clearTimeout.bind(e),this._requestAnimationFrame=t=>e.setTimeout(t,1e3/60))}get cancelAnimationFrame(){return this._cancelAnimationFrame}get requestAnimationFrame(){return this._requestAnimationFrame}}!function(e){e[e.Traversing=0]="Traversing",e[e.Waiting=1]="Waiting"}(Fx||(Fx={}));class Hx{constructor(e){this._spatial=new Hu,this._geoCoords=new Uu,this._referenceThreshold=.01,this._reference=e.reference,this._alpha=e.alpha,this._camera=e.camera.clone(),this._zoom=e.zoom,this._currentIndex=e.currentIndex,this._trajectory=e.trajectory.slice(),this._trajectoryTransforms=[],this._trajectoryCameras=[];for(let e of this._trajectory){let t=this._nodeToTranslation(e),i=new qu(e,e.image,t);this._trajectoryTransforms.push(i),this._trajectoryCameras.push(new Vu(i))}this._currentNode=this._trajectory.length>0?this._trajectory[this._currentIndex]:null,this._previousNode=this._trajectory.length>1&&this.currentIndex>0?this._trajectory[this._currentIndex-1]:null,this._currentCamera=this._trajectoryCameras.length>0?this._trajectoryCameras[this._currentIndex].clone():new Vu,this._previousCamera=this._trajectoryCameras.length>1&&this.currentIndex>0?this._trajectoryCameras[this._currentIndex-1].clone():this._currentCamera.clone()}get reference(){return this._reference}get alpha(){return this._getAlpha()}get camera(){return this._camera}get zoom(){return this._zoom}get trajectory(){return this._trajectory}get currentIndex(){return this._currentIndex}get currentNode(){return this._currentNode}get previousNode(){return this._previousNode}get currentCamera(){return this._currentCamera}get currentTransform(){return this._trajectoryTransforms.length>0?this._trajectoryTransforms[this.currentIndex]:null}get previousTransform(){return this._trajectoryTransforms.length>1&&this.currentIndex>0?this._trajectoryTransforms[this.currentIndex-1]:null}get motionless(){return this._motionless}append(e){if(e.length<1)throw Error("Trajectory can not be empty");this._currentIndex<0?this.set(e):(this._trajectory=this._trajectory.concat(e),this._appendToTrajectories(e))}prepend(e){if(e.length<1)throw Error("Trajectory can not be empty");this._trajectory=e.slice().concat(this._trajectory),this._currentIndex+=e.length,this._setCurrentNode(),this._setReference(this._currentNode)?this._setTrajectories():this._prependToTrajectories(e),this._setCurrentCamera()}remove(e){if(e<0)throw Error("n must be a positive integer");if(this._currentIndex-1<e)throw Error("Current and previous nodes can not be removed");for(let t=0;t<e;t++)this._trajectory.shift(),this._trajectoryTransforms.shift(),this._trajectoryCameras.shift(),this._currentIndex--;this._setCurrentNode()}clearPrior(){this._currentIndex>0&&this.remove(this._currentIndex-1)}clear(){this.cut(),this._currentIndex>0&&this.remove(this._currentIndex-1)}cut(){for(;this._trajectory.length-1>this._currentIndex;)this._trajectory.pop(),this._trajectoryTransforms.pop(),this._trajectoryCameras.pop()}set(e){this._setTrajectory(e),this._setCurrentNode(),this._setReference(this._currentNode),this._setTrajectories(),this._setCurrentCamera()}getCenter(){return null!=this._currentNode?this.currentTransform.projectBasic(this._camera.lookat.toArray()):[.5,.5]}_setCurrent(){this._setCurrentNode(),this._setReference(this._currentNode)&&this._setTrajectories(),this._setCurrentCamera()}_setCurrentCamera(){this._currentCamera=this._trajectoryCameras[this._currentIndex].clone(),this._previousCamera=this._currentIndex>0?this._trajectoryCameras[this._currentIndex-1].clone():this._currentCamera.clone()}_motionlessTransition(){return null!=this._currentNode&&null!=this._previousNode&&!(this._currentNode.merged&&this._previousNode.merged&&this._withinOriginalDistance()&&this._sameConnectedComponent())}_setReference(e){return!(Math.abs(e.latLon.lat-this.reference.lat)<this._referenceThreshold&&Math.abs(e.latLon.lon-this.reference.lon)<this._referenceThreshold)&&(!(null!=this._previousNode&&!this._motionlessTransition())&&(this._reference.lat=e.latLon.lat,this._reference.lon=e.latLon.lon,this._reference.alt=e.alt,!0))}_setCurrentNode(){this._currentNode=this._trajectory.length>0?this._trajectory[this._currentIndex]:null,this._previousNode=this._currentIndex>0?this._trajectory[this._currentIndex-1]:null}_setTrajectory(e){if(e.length<1)throw new zu("Trajectory can not be empty");null!=this._currentNode?(this._trajectory=[this._currentNode].concat(e),this._currentIndex=1):(this._trajectory=e.slice(),this._currentIndex=0)}_setTrajectories(){this._trajectoryTransforms.length=0,this._trajectoryCameras.length=0,this._appendToTrajectories(this._trajectory)}_appendToTrajectories(e){for(let t of e){if(!t.assetsCached)throw new zu("Assets must be cached when node is added to trajectory");let e=this._nodeToTranslation(t),i=new qu(t,t.image,e);this._trajectoryTransforms.push(i),this._trajectoryCameras.push(new Vu(i))}}_prependToTrajectories(e){for(let t of e.reverse()){if(!t.assetsCached)throw new zu("Assets must be cached when added to trajectory");let e=this._nodeToTranslation(t),i=new qu(t,t.image,e);this._trajectoryTransforms.unshift(i),this._trajectoryCameras.unshift(new Vu(i))}}_nodeToTranslation(e){let t=this._geoCoords.geodeticToEnu(e.latLon.lat,e.latLon.lon,e.alt,this._reference.lat,this._reference.lon,this._reference.alt),i=this._spatial.rotate(t,e.rotation);return[-i.x,-i.y,-i.z]}_sameConnectedComponent(){let e=this._currentNode,t=this._previousNode;return!(e&&e.mergeCC&&t&&t.mergeCC)||e.mergeCC===t.mergeCC}_withinOriginalDistance(){let e=this._currentNode,t=this._previousNode;return!e||!t||this._spatial.distanceFromLatLon(e.originalLatLon.lat,e.originalLatLon.lon,t.originalLatLon.lat,t.originalLatLon.lon)<25}}class qx{constructor(e,t){this._phi=e,this._theta=t}get phi(){return this._phi}set phi(e){this._phi=e}get theta(){return this._theta}set theta(e){this._theta=e}get isZero(){return 0===this._phi&&0===this._theta}copy(e){this._phi=e.phi,this._theta=e.theta}lerp(e,t){this._phi=(1-t)*this._phi+t*e.phi,this._theta=(1-t)*this._theta+t*e.theta}multiply(e){this._phi*=e,this._theta*=e}threshold(e){this._phi=Math.abs(this._phi)>e?this._phi:0,this._theta=Math.abs(this._theta)>e?this._theta:0}lengthSquared(){return this._phi*this._phi+this._theta*this._theta}reset(){this._phi=0,this._theta=0}}class Wx extends Hx{constructor(e){super(e),this._adjustCameras(),this._motionless=this._motionlessTransition(),this._baseAlpha=this._alpha,this._animationSpeed=.025,this._useBezier=!1,this._rotationDelta=new qx(0,0),this._requestedRotationDelta=null,this._basicRotation=[0,0],this._requestedBasicRotation=null,this._requestedBasicRotationUnbounded=null,this._rotationAcceleration=.86,this._rotationIncreaseAlpha=.97,this._rotationDecreaseAlpha=.9,this._rotationThreshold=.001,this._unboundedRotationAlpha=.8,this._desiredZoom=e.zoom,this._minZoom=0,this._maxZoom=3,this._lookatDepth=10,this._desiredLookat=null,this._desiredCenter=null}append(e){let t=0===this._trajectory.length;t&&this._resetTransition(),super.append(e),t&&(this._setDesiredCenter(),this._setDesiredZoom())}prepend(e){let t=0===this._trajectory.length;t&&this._resetTransition(),super.prepend(e),t&&(this._setDesiredCenter(),this._setDesiredZoom())}set(e){super.set(e),this._desiredLookat=null,this._resetTransition(),this._clearRotation(),this._setDesiredCenter(),this._setDesiredZoom(),this._trajectory.length<3&&(this._useBezier=!0)}move(e){throw new Error("Not implemented")}moveTo(e){throw new Error("Not implemented")}rotate(e){null!=this._currentNode&&(this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedBasicRotation=null,null!=this._requestedRotationDelta?(this._requestedRotationDelta.phi=this._requestedRotationDelta.phi+e.phi,this._requestedRotationDelta.theta=this._requestedRotationDelta.theta+e.theta):this._requestedRotationDelta=new qx(e.phi,e.theta))}rotateBasic(e){if(null!=this._currentNode)if(this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedRotationDelta=null,null!=this._requestedBasicRotation){this._requestedBasicRotation[0]+=e[0],this._requestedBasicRotation[1]+=e[1];let t=.05/Math.pow(2,this._zoom);this._requestedBasicRotation[0]=this._spatial.clamp(this._requestedBasicRotation[0],-t,t),this._requestedBasicRotation[1]=this._spatial.clamp(this._requestedBasicRotation[1],-t,t)}else this._requestedBasicRotation=e.slice()}rotateBasicUnbounded(e){null!=this._currentNode&&(null!=this._requestedBasicRotationUnbounded?(this._requestedBasicRotationUnbounded[0]+=e[0],this._requestedBasicRotationUnbounded[1]+=e[1]):this._requestedBasicRotationUnbounded=e.slice())}rotateBasicWithoutInertia(e){if(null==this._currentNode)return;this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null;const t=.05/Math.pow(2,this._zoom),i=e.slice();i[0]=this._spatial.clamp(i[0],-t,t),i[1]=this._spatial.clamp(i[1],-t,t),this._applyRotationBasic(i)}rotateToBasic(e){if(null==this._currentNode)return;this._desiredZoom=this._zoom,this._desiredLookat=null,e[0]=this._spatial.clamp(e[0],0,1),e[1]=this._spatial.clamp(e[1],0,1);let t=this.currentTransform.unprojectBasic(e,this._lookatDepth);this._currentCamera.lookat.fromArray(t)}zoomIn(e,t){if(null==this._currentNode)return;this._desiredZoom=Math.max(this._minZoom,Math.min(this._maxZoom,this._desiredZoom+e));let i=this.currentTransform.projectBasic(this._currentCamera.lookat.toArray()),r=i[0],n=i[1],o=Math.pow(2,this._zoom),s=Math.pow(2,this._desiredZoom),a=t[0],c=t[1];null!=this.currentTransform.gpano&&this.currentTransform.gpano.CroppedAreaImageWidthPixels===this.currentTransform.gpano.FullPanoWidthPixels&&(a-r>.5?a-=1:r-a>.5&&(a=1+a));let h=a-o/s*(a-r),u=c-o/s*(c-n),l=this.currentTransform.gpano;this._currentNode.fullPano?(h=this._spatial.wrap(h+this._basicRotation[0],0,1),u=this._spatial.clamp(u+this._basicRotation[1],.05,.95)):null!=l&&this.currentTransform.gpano.CroppedAreaImageWidthPixels===this.currentTransform.gpano.FullPanoWidthPixels?(h=this._spatial.wrap(h+this._basicRotation[0],0,1),u=this._spatial.clamp(u+this._basicRotation[1],0,1)):(h=this._spatial.clamp(h,0,1),u=this._spatial.clamp(u,0,1)),this._desiredLookat=(new oe).fromArray(this.currentTransform.unprojectBasic([h,u],this._lookatDepth))}setCenter(e){this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null,this._desiredZoom=this._zoom;let t=[this._spatial.clamp(e[0],0,1),this._spatial.clamp(e[1],0,1)];if(null==this._currentNode)return void(this._desiredCenter=t);this._desiredCenter=null;let i=(new oe).fromArray(this.currentTransform.unprojectBasic(t,this._lookatDepth)),r=null!=this.previousTransform?this.previousTransform:this.currentTransform,n=(new oe).fromArray(r.unprojectBasic(t,this._lookatDepth));this._currentCamera.lookat.copy(i),this._previousCamera.lookat.copy(n)}setZoom(e){this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null,this._zoom=this._spatial.clamp(e,this._minZoom,this._maxZoom),this._desiredZoom=this._zoom}update(e){1===this._alpha&&this._currentIndex+this._alpha<this._trajectory.length&&(this._currentIndex+=1,this._useBezier=this._trajectory.length<3&&this._currentIndex+1===this._trajectory.length,this._setCurrent(),this._resetTransition(),this._clearRotation(),this._desiredZoom=this._currentNode.fullPano?this._zoom:0,this._desiredLookat=null);let t=this._animationSpeed*(60/e);this._baseAlpha=Math.min(1,this._baseAlpha+t),this._useBezier?this._alpha=W.smootherstep(this._baseAlpha,0,1):this._alpha=this._baseAlpha,this._updateRotation(),this._rotationDelta.isZero||(this._applyRotation(this._previousCamera),this._applyRotation(this._currentCamera)),this._updateRotationBasic(),0===this._basicRotation[0]&&0===this._basicRotation[1]||this._applyRotationBasic(this._basicRotation),this._updateZoom(t),this._updateLookat(t),this._camera.lerpCameras(this._previousCamera,this._currentCamera,this.alpha)}_getAlpha(){return this._motionless?Math.ceil(this._alpha):this._alpha}_setCurrentCamera(){super._setCurrentCamera(),this._adjustCameras()}_adjustCameras(){if(null==this._previousNode)return;let e=this._camera.lookat.clone().sub(this._camera.position);this._previousCamera.lookat.copy(e.clone().add(this._previousCamera.position)),this._currentNode.fullPano&&this._currentCamera.lookat.copy(e.clone().add(this._currentCamera.position))}_resetTransition(){this._alpha=0,this._baseAlpha=0,this._motionless=this._motionlessTransition()}_applyRotation(e){if(null==e)return;let t=(new ie).setFromUnitVectors(e.up,new oe(0,0,1)),i=t.clone().inverse(),r=new oe;r.copy(e.lookat).sub(e.position),r.applyQuaternion(t);let n=r.length(),o=Math.atan2(r.y,r.x);o+=this._rotationDelta.phi;let s=Math.atan2(Math.sqrt(r.x*r.x+r.y*r.y),r.z);s+=this._rotationDelta.theta,s=Math.max(.1,Math.min(Math.PI-.1,s)),r.x=Math.sin(s)*Math.cos(o),r.y=Math.sin(s)*Math.sin(o),r.z=Math.cos(s),r.applyQuaternion(i),e.lookat.copy(e.position).add(r.multiplyScalar(n))}_applyRotationBasic(e){let t=this._currentNode,i=null!=this._previousNode?this.previousNode:this.currentNode,r=this._currentCamera,n=this._previousCamera,o=this.currentTransform,s=null!=this.previousTransform?this.previousTransform:this.currentTransform,a=o.projectBasic(r.lookat.toArray()),c=s.projectBasic(n.lookat.toArray()),h=o.gpano,u=s.gpano;t.fullPano?(a[0]=this._spatial.wrap(a[0]+e[0],0,1),a[1]=this._spatial.clamp(a[1]+e[1],.05,.95)):null!=h&&o.gpano.CroppedAreaImageWidthPixels===o.gpano.FullPanoWidthPixels?(a[0]=this._spatial.wrap(a[0]+e[0],0,1),a[1]=this._spatial.clamp(a[1]+e[1],0,1)):(a[0]=this._spatial.clamp(a[0]+e[0],0,1),a[1]=this._spatial.clamp(a[1]+e[1],0,1)),i.fullPano?(c[0]=this._spatial.wrap(c[0]+e[0],0,1),c[1]=this._spatial.clamp(c[1]+e[1],.05,.95)):null!=u&&s.gpano.CroppedAreaImageWidthPixels===s.gpano.FullPanoWidthPixels?(c[0]=this._spatial.wrap(c[0]+e[0],0,1),c[1]=this._spatial.clamp(c[1]+e[1],0,1)):(c[0]=this._spatial.clamp(c[0]+e[0],0,1),c[1]=this._spatial.clamp(a[1]+e[1],0,1));let l=o.unprojectBasic(a,this._lookatDepth);r.lookat.fromArray(l);let p=s.unprojectBasic(c,this._lookatDepth);n.lookat.fromArray(p)}_updateZoom(e){let t=this._desiredZoom-this._zoom,i=t>0?1:t<0?-1:0;0!==t&&(Math.abs(t)<.002?(this._zoom=this._desiredZoom,null!=this._desiredLookat&&(this._desiredLookat=null)):this._zoom+=i*Math.max(Math.abs(5*e*t),.002))}_updateLookat(e){if(null===this._desiredLookat)return;let t=this._desiredLookat.distanceToSquared(this._currentCamera.lookat);Math.abs(t)<1e-6?(this._currentCamera.lookat.copy(this._desiredLookat),this._desiredLookat=null):this._currentCamera.lookat.lerp(this._desiredLookat,5*e)}_updateRotation(){if(null!=this._requestedRotationDelta){let e=this._rotationDelta.lengthSquared();return this._requestedRotationDelta.lengthSquared()>e?this._rotationDelta.lerp(this._requestedRotationDelta,this._rotationIncreaseAlpha):this._rotationDelta.lerp(this._requestedRotationDelta,this._rotationDecreaseAlpha),void(this._requestedRotationDelta=null)}this._rotationDelta.isZero||(this._rotationDelta.multiply(this._rotationAcceleration),this._rotationDelta.threshold(this._rotationThreshold))}_updateRotationBasic(){if(null!=this._requestedBasicRotation){let e=this._basicRotation[0],t=this._basicRotation[1],i=this._requestedBasicRotation[0],r=this._requestedBasicRotation[1];return Math.abs(i)>Math.abs(e)?this._basicRotation[0]=(1-this._rotationIncreaseAlpha)*e+this._rotationIncreaseAlpha*i:this._basicRotation[0]=(1-this._rotationDecreaseAlpha)*e+this._rotationDecreaseAlpha*i,Math.abs(r)>Math.abs(t)?this._basicRotation[1]=(1-this._rotationIncreaseAlpha)*t+this._rotationIncreaseAlpha*r:this._basicRotation[1]=(1-this._rotationDecreaseAlpha)*t+this._rotationDecreaseAlpha*r,void(this._requestedBasicRotation=null)}if(null!=this._requestedBasicRotationUnbounded){let e=this._requestedBasicRotationUnbounded[0],t=this._requestedBasicRotationUnbounded[1];if(Math.abs(e)>0&&(this._basicRotation[0]=(1-this._unboundedRotationAlpha)*this._basicRotation[0]+this._unboundedRotationAlpha*e),Math.abs(t)>0&&(this._basicRotation[1]=(1-this._unboundedRotationAlpha)*this._basicRotation[1]+this._unboundedRotationAlpha*t),null!=this._desiredLookat){let i=this.currentTransform.projectBasic(this._desiredLookat.toArray());i[0]+=e,i[1]+=t,this._desiredLookat=(new oe).fromArray(this.currentTransform.unprojectBasic(i,this._lookatDepth))}this._requestedBasicRotationUnbounded=null}0===this._basicRotation[0]&&0===this._basicRotation[1]||(this._basicRotation[0]=this._rotationAcceleration*this._basicRotation[0],this._basicRotation[1]=this._rotationAcceleration*this._basicRotation[1],Math.abs(this._basicRotation[0])<this._rotationThreshold/Math.pow(2,this._zoom)&&Math.abs(this._basicRotation[1])<this._rotationThreshold/Math.pow(2,this._zoom)&&(this._basicRotation=[0,0]))}_clearRotation(){this._currentNode.fullPano||(null!=this._requestedRotationDelta&&(this._requestedRotationDelta=null),this._rotationDelta.isZero||this._rotationDelta.reset(),null!=this._requestedBasicRotation&&(this._requestedBasicRotation=null),(this._basicRotation[0]>0||this._basicRotation[1]>0)&&(this._basicRotation=[0,0]))}_setDesiredCenter(){if(null==this._desiredCenter)return;let e=(new oe).fromArray(this.currentTransform.unprojectBasic(this._desiredCenter,this._lookatDepth)).sub(this._currentCamera.position);this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(e)),this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(e)),this._desiredCenter=null}_setDesiredZoom(){this._desiredZoom=this._currentNode.fullPano||null==this._previousNode?this._zoom:0}}class Qx extends Hx{constructor(e){super(e),this._zoom=0,this._adjustCameras(),this._motionless=this._motionlessTransition()}prepend(e){super.prepend(e),this._motionless=this._motionlessTransition()}set(e){super.set(e),this._motionless=this._motionlessTransition()}rotate(e){}rotateBasic(e){}rotateBasicUnbounded(e){}rotateBasicWithoutInertia(e){}rotateToBasic(e){}zoomIn(e,t){}move(e){this._alpha=Math.max(0,Math.min(1,this._alpha+e))}moveTo(e){this._alpha=Math.max(0,Math.min(1,e))}update(e){this._camera.lerpCameras(this._previousCamera,this._currentCamera,this.alpha)}setCenter(e){}setZoom(e){}_getAlpha(){return this._motionless?Math.round(this._alpha):this._alpha}_setCurrentCamera(){super._setCurrentCamera(),this._adjustCameras()}_adjustCameras(){if(null!=this._previousNode){if(this._currentNode.fullPano){let e=this._camera.lookat.clone().sub(this._camera.position);this._currentCamera.lookat.copy(e.clone().add(this._currentCamera.position))}if(this._previousNode.fullPano){let e=this._currentCamera.lookat.clone().sub(this._currentCamera.position);this._previousCamera.lookat.copy(e.clone().add(this._previousCamera.position))}}}}class Yx{constructor(){const e=Fx[Fx.Traversing],t=Fx[Fx.Waiting];this._creators=new Map;const i=this._creators;i.set(e,Wx),i.set(t,Qx),this._transitions=new Map;const r=this._transitions;r.set(e,[t]),r.set(t,[e])}getState(e){if(e instanceof Wx)return Fx.Traversing;if(e instanceof Qx)return Fx.Waiting;throw new Error("Invalid state instance")}generate(e,t){return new(this._creators.get(Fx[e]))(t)}transition(e,t){if(!this.validate(e,t))throw new Error("Invalid transition");return this.generate(t,e)}validate(e,t){const i=Fx[this.getState(e)],r=Fx[t],n=this._transitions;return n.has(i)&&n.get(i).includes(r)}}class Xx{constructor(){this._transitions=new Yx,this._state=this._transitions.generate(Fx.Traversing,{alpha:1,camera:new Vu,currentIndex:-1,reference:{alt:0,lat:0,lon:0},trajectory:[],zoom:0})}get state(){return this._transitions.getState(this._state)}get reference(){return this._state.reference}get alpha(){return this._state.alpha}get camera(){return this._state.camera}get zoom(){return this._state.zoom}get currentNode(){return this._state.currentNode}get previousNode(){return this._state.previousNode}get currentCamera(){return this._state.currentCamera}get currentTransform(){return this._state.currentTransform}get previousTransform(){return this._state.previousTransform}get trajectory(){return this._state.trajectory}get currentIndex(){return this._state.currentIndex}get lastNode(){return this._state.trajectory[this._state.trajectory.length-1]}get nodesAhead(){return this._state.trajectory.length-1-this._state.currentIndex}get motionless(){return this._state.motionless}traverse(){this._transition(Fx.Traversing)}wait(){this._transition(Fx.Waiting)}getCenter(){return this._state.getCenter()}setCenter(e){this._state.setCenter(e)}setZoom(e){this._state.setZoom(e)}update(e){this._state.update(e)}append(e){this._state.append(e)}prepend(e){this._state.prepend(e)}remove(e){this._state.remove(e)}clear(){this._state.clear()}clearPrior(){this._state.clearPrior()}cut(){this._state.cut()}set(e){this._state.set(e)}rotate(e){this._state.rotate(e)}rotateBasic(e){this._state.rotateBasic(e)}rotateBasicUnbounded(e){this._state.rotateBasicUnbounded(e)}rotateBasicWithoutInertia(e){this._state.rotateBasicWithoutInertia(e)}rotateToBasic(e){this._state.rotateToBasic(e)}move(e){this._state.move(e)}moveTo(e){this._state.moveTo(e)}zoomIn(e,t){this._state.zoomIn(e,t)}_transition(e){if(!this._transitions.validate(this._state,e)){const t=this._transitions.getState(this._state);return void console.warn(`Transition not valid (${Fx[t]} - ${Fx[e]})`)}const t=this._transitions.transition(this._state,e);this._state=t}}class Zx{constructor(){this._appendNode$=new zv,this._start$=new zv,this._frame$=new zv,this._fpsSampleRate=30,this._contextOperation$=new Qv((e=>e)),this._context$=this._contextOperation$.pipe(eb(((e,t)=>t(e)),new Xx),lb(1),Vv()),this._state$=this._context$.pipe(w_((e=>e.state)),Iy(),lb(1),Vv()),this._fps$=this._start$.pipe(Ab((()=>this._frame$.pipe(oy(1,this._fpsSampleRate),w_((e=>(new Date).getTime())),sb(),w_((e=>Math.max(20,1e3*this._fpsSampleRate/(e[1]-e[0])))),wb(60)))),mb()),this._currentState$=this._frame$.pipe(Lb(this._fps$,this._context$,((e,t,i)=>[e,t,i])),Ry((e=>null!=e[2].currentNode)),Ly((e=>{e[2].update(e[1])})),w_((e=>({fps:e[1],id:e[0],state:e[2]}))),mb()),this._lastState$=this._currentState$.pipe(lb(1),Vv());let e=this._currentState$.pipe(Iy(void 0,(e=>e.state.currentNode.key)),lb(1),Vv()),t=new zv;e.subscribe(t),this._currentKey$=new Qv(null),t.pipe(w_((e=>e.state.currentNode.key))).subscribe(this._currentKey$),this._currentNode$=t.pipe(w_((e=>e.state.currentNode)),lb(1),Vv()),this._currentCamera$=t.pipe(w_((e=>e.state.currentCamera)),lb(1),Vv()),this._currentTransform$=t.pipe(w_((e=>e.state.currentTransform)),lb(1),Vv()),this._reference$=t.pipe(w_((e=>e.state.reference)),Iy(((e,t)=>e.lat===t.lat&&e.lon===t.lon),(e=>({lat:e.lat,lon:e.lon}))),lb(1),Vv()),this._currentNodeExternal$=e.pipe(w_((e=>e.state.currentNode)),lb(1),Vv()),this._appendNode$.pipe(w_((e=>t=>(t.append([e]),t)))).subscribe(this._contextOperation$),this._inMotionOperation$=new zv,e.pipe(w_((e=>!0))).subscribe(this._inMotionOperation$),this._inMotionOperation$.pipe(Iy(),Ry((e=>e)),Ab((e=>this._currentState$.pipe(Ry((e=>0===e.state.nodesAhead)),w_((e=>[e.state.camera.clone(),e.state.zoom])),sb(),w_((e=>{let t=e[0][0],i=e[1][0],r=e[0][1],n=e[1][1];return t.diff(i)>1e-5||Math.abs(r-n)>1e-5})),Yy((e=>!e)))))).subscribe(this._inMotionOperation$),this._inMotion$=this._inMotionOperation$.pipe(Iy(),lb(1),Vv()),this._inTranslationOperation$=new zv,e.pipe(w_((e=>!0))).subscribe(this._inTranslationOperation$),this._inTranslationOperation$.pipe(Iy(),Ry((e=>e)),Ab((e=>this._currentState$.pipe(Ry((e=>0===e.state.nodesAhead)),w_((e=>e.state.camera.position.clone())),sb(),w_((e=>0!==e[0].distanceToSquared(e[1]))),Yy((e=>!e)))))).subscribe(this._inTranslationOperation$),this._inTranslation$=this._inTranslationOperation$.pipe(Iy(),lb(1),Vv()),this._state$.subscribe((()=>{})),this._currentNode$.subscribe((()=>{})),this._currentCamera$.subscribe((()=>{})),this._currentTransform$.subscribe((()=>{})),this._reference$.subscribe((()=>{})),this._currentNodeExternal$.subscribe((()=>{})),this._lastState$.subscribe((()=>{})),this._inMotion$.subscribe((()=>{})),this._inTranslation$.subscribe((()=>{})),this._frameId=null,this._frameGenerator=new Gx(window)}get currentState$(){return this._currentState$}get currentNode$(){return this._currentNode$}get currentKey$(){return this._currentKey$}get currentNodeExternal$(){return this._currentNodeExternal$}get currentCamera$(){return this._currentCamera$}get currentTransform$(){return this._currentTransform$}get state$(){return this._state$}get reference$(){return this._reference$}get inMotion$(){return this._inMotion$}get inTranslation$(){return this._inTranslation$}get appendNode$(){return this._appendNode$}get currentDate(){return this._currentDate}traverse(){this._inMotionOperation$.next(!0),this._invokeContextOperation((e=>{e.traverse()}))}wait(){this._invokeContextOperation((e=>{e.wait()}))}appendNodes(e){this._invokeContextOperation((t=>{t.append(e)}))}prependNodes(e){this._invokeContextOperation((t=>{t.prepend(e)}))}removeNodes(e){this._invokeContextOperation((t=>{t.remove(e)}))}clearNodes(){this._invokeContextOperation((e=>{e.clear()}))}clearPriorNodes(){this._invokeContextOperation((e=>{e.clearPrior()}))}cutNodes(){this._invokeContextOperation((e=>{e.cut()}))}setNodes(e){this._invokeContextOperation((t=>{t.set(e)}))}rotate(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.rotate(e)}))}rotateBasic(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.rotateBasic(e)}))}rotateBasicUnbounded(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.rotateBasicUnbounded(e)}))}rotateBasicWithoutInertia(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.rotateBasicWithoutInertia(e)}))}rotateToBasic(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.rotateToBasic(e)}))}move(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.move(e)}))}moveTo(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.moveTo(e)}))}zoomIn(e,t){this._inMotionOperation$.next(!0),this._invokeContextOperation((i=>{i.zoomIn(e,t)}))}getCenter(){return this._lastState$.pipe(Yy(),w_((e=>e.state.getCenter())))}getZoom(){return this._lastState$.pipe(Yy(),w_((e=>e.state.zoom)))}setCenter(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.setCenter(e)}))}setZoom(e){this._inMotionOperation$.next(!0),this._invokeContextOperation((t=>{t.setZoom(e)}))}setCurrentDate(e){this._currentDate=e}start(){null==this._frameId&&(this._start$.next(null),this._frameId=this._frameGenerator.requestAnimationFrame(this._frame.bind(this)),this._frame$.next(this._frameId))}stop(){null!=this._frameId&&(this._frameGenerator.cancelAnimationFrame(this._frameId),this._frameId=null)}_invokeContextOperation(e){this._contextOperation$.next((t=>(e(t),t)))}_frame(e){this._frameId=this._frameGenerator.requestAnimationFrame(this._frame.bind(this)),this._frame$.next(this._frameId)}}var Kx={};function Jx(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ew(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tw(e,t,i){return t&&ew(e.prototype,t),i&&ew(e,i),e}Object.defineProperty(Kx,"__esModule",{value:!0}),Kx.Observable=void 0;var iw=function(){return"function"==typeof Symbol},rw=function(e){return iw()&&Boolean(Symbol[e])},nw=function(e){return rw(e)?Symbol[e]:"@@"+e};iw()&&!rw("observable")&&(Symbol.observable=Symbol("observable"));var ow=nw("iterator"),sw=nw("observable"),aw=nw("species");function cw(e,t){var i=e[t];if(null!=i){if("function"!=typeof i)throw new TypeError(i+" is not a function");return i}}function hw(e){var t=e.constructor;return void 0!==t&&null===(t=t[aw])&&(t=void 0),void 0!==t?t:_w}function uw(e){uw.log?uw.log(e):setTimeout((function(){throw e}))}function lw(e){Promise.resolve().then((function(){try{e()}catch(e){uw(e)}}))}function pw(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var i=cw(t,"unsubscribe");i&&i.call(t)}}catch(e){uw(e)}}function dw(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function fw(e,t,i){e._state="running";var r=e._observer;try{var n=cw(r,t);switch(t){case"next":n&&n.call(r,i);break;case"error":if(dw(e),!n)throw i;n.call(r,i);break;case"complete":dw(e),n&&n.call(r)}}catch(e){uw(e)}"closed"===e._state?pw(e):"running"===e._state&&(e._state="ready")}function mw(e,t,i){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:i}],void lw((function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var i=0;i<t.length&&(fw(e,t[i].type,t[i].value),"closed"!==e._state);++i);}}(e)}))):void fw(e,t,i);e._queue.push({type:t,value:i})}}var gw=function(){function e(t,i){Jx(this,e),this._cleanup=void 0,this._observer=t,this._queue=void 0,this._state="initializing";var r=new vw(this);try{this._cleanup=i.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}return tw(e,[{key:"unsubscribe",value:function(){"closed"!==this._state&&(dw(this),pw(this))}},{key:"closed",get:function(){return"closed"===this._state}}]),e}(),vw=function(){function e(t){Jx(this,e),this._subscription=t}return tw(e,[{key:"next",value:function(e){mw(this._subscription,"next",e)}},{key:"error",value:function(e){mw(this._subscription,"error",e)}},{key:"complete",value:function(){mw(this._subscription,"complete")}},{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),_w=function(){function e(t){if(Jx(this,e),!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}return tw(e,[{key:"subscribe",value:function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new gw(e,this._subscriber)}},{key:"forEach",value:function(e){var t=this;return new Promise((function(i,r){if("function"==typeof e)var n=t.subscribe({next:function(t){try{e(t,o)}catch(e){r(e),n.unsubscribe()}},error:r,complete:i});else r(new TypeError(e+" is not a function"));function o(){n.unsubscribe(),i()}}))}},{key:"map",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(hw(this))((function(i){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return i.error(e)}i.next(t)},error:function(e){i.error(e)},complete:function(){i.complete()}})}))}},{key:"filter",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(hw(this))((function(i){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return i.error(e)}i.next(t)},error:function(e){i.error(e)},complete:function(){i.complete()}})}))}},{key:"reduce",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var i=hw(this),r=arguments.length>1,n=!1,o=arguments[1],s=o;return new i((function(i){return t.subscribe({next:function(t){var o=!n;if(n=!0,!o||r)try{s=e(s,t)}catch(e){return i.error(e)}else s=t},error:function(e){i.error(e)},complete:function(){if(!n&&!r)return i.error(new TypeError("Cannot reduce an empty sequence"));i.next(s),i.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var n=hw(this);return new n((function(t){var r,o=0;return function e(s){r=s.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){o===i.length?(r=void 0,t.complete()):e(n.from(i[o++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}}))}},{key:"flatMap",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var i=hw(this);return new i((function(r){var n=[],o=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var o=i.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=n.indexOf(o);e>=0&&n.splice(e,1),s()}});n.push(o)},error:function(e){r.error(e)},complete:function(){s()}});function s(){o.closed&&0===n.length&&r.complete()}return function(){n.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))}},{key:sw,value:function(){return this}}],[{key:"from",value:function(t){var i="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=cw(t,sw);if(r){var n=r.call(t);if(Object(n)!==n)throw new TypeError(n+" is not an object");return function(e){return e instanceof _w}(n)&&n.constructor===i?n:new i((function(e){return n.subscribe(e)}))}if(rw("iterator")&&(r=cw(t,ow)))return new i((function(e){lw((function(){if(!e.closed){var i=!0,n=!1,o=void 0;try{for(var s,a=r.call(t)[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var c=s.value;if(e.next(c),e.closed)return}}catch(e){n=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(n)throw o}}e.complete()}}))}));if(Array.isArray(t))return new i((function(e){lw((function(){if(!e.closed){for(var i=0;i<t.length;++i)if(e.next(t[i]),e.closed)return;e.complete()}}))}));throw new TypeError(t+" is not observable")}},{key:"of",value:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var n="function"==typeof this?this:e;return new n((function(e){lw((function(){if(!e.closed){for(var t=0;t<i.length;++t)if(e.next(i[t]),e.closed)return;e.complete()}}))}))}},{key:aw,get:function(){return this}}]),e}();Kx.Observable=_w,iw()&&Object.defineProperty(_w,Symbol("extensions"),{value:{symbol:sw,hostReportError:uw},configurable:!0});var yw=Kx.Observable,bw="Invariant Violation",xw=Object.setPrototypeOf,ww=void 0===xw?function(e,t){return e.__proto__=t,e}:xw,Aw=function(e){function t(i){void 0===i&&(i=bw);var r=e.call(this,"number"==typeof i?bw+": "+i+" (see https://github.com/apollographql/invariant-packages)":i)||this;return r.framesToPop=1,r.name=bw,ww(r,t.prototype),r}return pv(t,e),t}(Error);function Sw(e,t){if(!e)throw new Aw(t)}function Mw(e){return function(){return console[e].apply(console,arguments)}}!function(e){e.warn=Mw("warn"),e.error=Mw("error")}(Sw||(Sw={}));var Ew={env:{}};if("object"==typeof process)Ew=process;else try{Function("stub","process = stub")(Ew)}catch(e){}var Tw="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):void 0;function Cw(e){return Cw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cw(e)}function Iw(e){return Nw(e,[])}function Nw(e,t){switch(Cw(e)){case"string":return JSON.stringify(e);case"function":return e.name?"[function ".concat(e.name,"]"):"[function]";case"object":return null===e?"null":function(e,t){if(-1!==t.indexOf(e))return"[Circular]";var i=[].concat(t,[e]),r=function(e){var t=e[String(Tw)];if("function"==typeof t)return t;if("function"==typeof e.inspect)return e.inspect}(e);if(void 0!==r){var n=r.call(e);if(n!==e)return"string"==typeof n?n:Nw(n,i)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";for(var i=Math.min(10,e.length),r=e.length-i,n=[],o=0;o<i;++o)n.push(Nw(e[o],t));1===r?n.push("... 1 more item"):r>1&&n.push("... ".concat(r," more items"));return"["+n.join(", ")+"]"}(e,i);return function(e,t){var i=Object.keys(e);if(0===i.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var i=e.constructor.name;if("string"==typeof i&&""!==i)return i}return t}(e)+"]";var r=i.map((function(i){return i+": "+Nw(e[i],t)}));return"{ "+r.join(", ")+" }"}(e,i)}(e,t);default:return String(e)}}var Pw={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Rw=Object.freeze({});function Ow(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Pw,r=void 0,n=Array.isArray(e),o=[e],s=-1,a=[],c=void 0,h=void 0,u=void 0,l=[],p=[],d=e;do{var f=++s===o.length,m=f&&0!==a.length;if(f){if(h=0===p.length?void 0:l[l.length-1],c=u,u=p.pop(),m){if(n)c=c.slice();else{for(var g={},v=0,_=Object.keys(c);v<_.length;v++){var y=_[v];g[y]=c[y]}c=g}for(var b=0,x=0;x<a.length;x++){var w=a[x][0],A=a[x][1];n&&(w-=b),n&&null===A?(c.splice(w,1),b++):c[w]=A}}s=r.index,o=r.keys,a=r.edits,n=r.inArray,r=r.prev}else{if(h=u?n?s:o[s]:void 0,null==(c=u?u[h]:d))continue;u&&l.push(h)}var S=void 0;if(!Array.isArray(c)){if(!Dw(c))throw new Error("Invalid AST Node: "+Iw(c));var M=Lw(t,c.kind,f);if(M){if((S=M.call(t,c,h,u,l,p))===Rw)break;if(!1===S){if(!f){l.pop();continue}}else if(void 0!==S&&(a.push([h,S]),!f)){if(!Dw(S)){l.pop();continue}c=S}}}void 0===S&&m&&a.push([h,c]),f?l.pop():(r={inArray:n,index:s,keys:o,edits:a,prev:r},o=(n=Array.isArray(c))?c:i[c.kind]||[],s=-1,a=[],u&&p.push(u),u=c)}while(void 0!==r);return 0!==a.length&&(d=a[a.length-1][1]),d}function Dw(e){return Boolean(e&&"string"==typeof e.kind)}function Lw(e,t,i){var r=e[t];if(r){if(!i&&"function"==typeof r)return r;var n=i?r.leave:r.enter;if("function"==typeof n)return n}else{var o=i?e.leave:e.enter;if(o){if("function"==typeof o)return o;var s=o[t];if("function"==typeof s)return s}}}var kw=Object.prototype,Bw=kw.toString,Fw=kw.hasOwnProperty,jw=new Map;function zw(e,t){try{return $w(e,t)}finally{jw.clear()}}function $w(e,t){if(e===t)return!0;var i=Bw.call(e);if(i!==Bw.call(t))return!1;switch(i){case"[object Array]":if(e.length!==t.length)return!1;case"[object Object]":if(Vw(e,t))return!0;var r=Object.keys(e),n=Object.keys(t),o=r.length;if(o!==n.length)return!1;for(var s=0;s<o;++s)if(!Fw.call(t,r[s]))return!1;for(s=0;s<o;++s){var a=r[s];if(!$w(e[a],t[a]))return!1}return!0;case"[object Error]":return e.name===t.name&&e.message===t.message;case"[object Number]":if(e!=e)return t!=t;case"[object Boolean]":case"[object Date]":return+e==+t;case"[object RegExp]":case"[object String]":return e==""+t;case"[object Map]":case"[object Set]":if(e.size!==t.size)return!1;if(Vw(e,t))return!0;for(var c=e.entries(),h="[object Map]"===i;;){var u=c.next();if(u.done)break;var l=u.value,p=l[0],d=l[1];if(!t.has(p))return!1;if(h&&!$w(d,t.get(p)))return!1}return!0}return!1}function Vw(e,t){var i=jw.get(e);if(i){if(i.has(t))return!0}else jw.set(e,i=new Set);return i.add(t),!1}function Uw(e,t,i,r){if(function(e){return"IntValue"===e.kind}(i)||function(e){return"FloatValue"===e.kind}(i))e[t.value]=Number(i.value);else if(function(e){return"BooleanValue"===e.kind}(i)||function(e){return"StringValue"===e.kind}(i))e[t.value]=i.value;else if(function(e){return"ObjectValue"===e.kind}(i)){var n={};i.fields.map((function(e){return Uw(n,e.name,e.value,r)})),e[t.value]=n}else if(function(e){return"Variable"===e.kind}(i)){var o=(r||{})[i.name.value];e[t.value]=o}else if(function(e){return"ListValue"===e.kind}(i))e[t.value]=i.values.map((function(e){var i={};return Uw(i,t,e,r),i[t.value]}));else if(function(e){return"EnumValue"===e.kind}(i))e[t.value]=i.value;else{if(!function(e){return"NullValue"===e.kind}(i))throw"production"===process.env.NODE_ENV?new Aw(17):new Aw('The inline argument "'+t.value+'" of kind "'+i.kind+'"is not supported. Use variables instead of inline arguments to overcome this limitation.');e[t.value]=null}}var Gw=["connection","include","skip","client","rest","export"];function Hw(e,t,i){if(i&&i.connection&&i.connection.key){if(i.connection.filter&&i.connection.filter.length>0){var r=i.connection.filter?i.connection.filter:[];r.sort();var n=t,o={};return r.forEach((function(e){o[e]=n[e]})),i.connection.key+"("+JSON.stringify(o)+")"}return i.connection.key}var s=e;if(t){var a=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var i,r="boolean"==typeof t.cycles&&t.cycles,n=t.cmp&&(i=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},o={key:r,value:e[r]};return i(n,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var i,s;if(Array.isArray(t)){for(s="[",i=0;i<t.length;i++)i&&(s+=","),s+=e(t[i])||"null";return s+"]"}if(null===t)return"null";if(-1!==o.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(t)-1,c=Object.keys(t).sort(n&&n(t));for(s="",i=0;i<c.length;i++){var h=c[i],u=e(t[h]);u&&(s&&(s+=","),s+=JSON.stringify(h)+":"+u)}return o.splice(a,1),"{"+s+"}"}}(e)}(t);s+="("+a+")"}return i&&Object.keys(i).forEach((function(e){-1===Gw.indexOf(e)&&(i[e]&&Object.keys(i[e]).length?s+="@"+e+"("+JSON.stringify(i[e])+")":s+="@"+e)})),s}function qw(e,t){if(e.arguments&&e.arguments.length){var i={};return e.arguments.forEach((function(e){var r=e.name,n=e.value;return Uw(i,r,n,t)})),i}return null}function Ww(e){return e.alias?e.alias.value:e.name.value}function Qw(e){return"Field"===e.kind}function Yw(e){return"InlineFragment"===e.kind}function Xw(e){return e&&"id"===e.type&&"boolean"==typeof e.generated}function Zw(e,t){return void 0===t&&(t=!1),dv({type:"id",generated:t},"string"==typeof e?{id:e,typename:void 0}:e)}function Kw(e,t){if(e.directives&&e.directives.length){var i={};return e.directives.forEach((function(e){i[e.name.value]=qw(e,t)})),i}return null}function Jw(e,t){return void 0===t&&(t={}),(i=e.directives,i?i.filter(iA).map((function(e){var t=e.arguments,i=e.name.value;"production"===process.env.NODE_ENV?Sw(t&&1===t.length,14):Sw(t&&1===t.length,"Incorrect number of arguments for the @"+i+" directive.");var r=t[0];"production"===process.env.NODE_ENV?Sw(r.name&&"if"===r.name.value,15):Sw(r.name&&"if"===r.name.value,"Invalid argument for the @"+i+" directive.");var n=r.value;return"production"===process.env.NODE_ENV?Sw(n&&("Variable"===n.kind||"BooleanValue"===n.kind),16):Sw(n&&("Variable"===n.kind||"BooleanValue"===n.kind),"Argument for the @"+i+" directive must be a variable or a boolean value."),{directive:e,ifArgument:r}})):[]).every((function(e){var i=e.directive,r=e.ifArgument,n=!1;return"Variable"===r.value.kind?(n=t[r.value.name.value],"production"===process.env.NODE_ENV?Sw(void 0!==n,13):Sw(void 0!==n,"Invalid variable referenced in @"+i.name.value+" directive.")):n=r.value.value,"skip"===i.name.value?!n:n}));var i}function eA(e,t){return function(e){var t=[];return Ow(e,{Directive:function(e){t.push(e.name.value)}}),t}(t).some((function(t){return e.indexOf(t)>-1}))}function tA(e){return e&&eA(["client"],e)&&eA(["export"],e)}function iA(e){var t=e.name.value;return"skip"===t||"include"===t}function rA(e,t){var i=t,r=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw"production"===process.env.NODE_ENV?new Aw(11):new Aw("Found a "+e.operation+" operation"+(e.name?" named '"+e.name.value+"'":"")+". No operations are allowed when using a fragment as a query. Only fragments are allowed.");"FragmentDefinition"===e.kind&&r.push(e)})),void 0===i&&("production"===process.env.NODE_ENV?Sw(1===r.length,12):Sw(1===r.length,"Found "+r.length+" fragments. `fragmentName` must be provided when there is not exactly 1 fragment."),i=r[0].name.value),dv(dv({},e),{definitions:gv([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:i}}]}}],e.definitions)})}function nA(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];return t.forEach((function(t){null!=t&&Object.keys(t).forEach((function(i){e[i]=t[i]}))})),e}function oA(e){"production"===process.env.NODE_ENV?Sw(e&&"Document"===e.kind,2):Sw(e&&"Document"===e.kind,'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql');var t=e.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})).map((function(e){if("OperationDefinition"!==e.kind)throw"production"===process.env.NODE_ENV?new Aw(3):new Aw('Schema type definitions not allowed in queries. Found: "'+e.kind+'"');return e}));return"production"===process.env.NODE_ENV?Sw(t.length<=1,4):Sw(t.length<=1,"Ambiguous GraphQL document: contains "+t.length+" operations"),e}function sA(e){return oA(e),e.definitions.filter((function(e){return"OperationDefinition"===e.kind}))[0]}function aA(e){return e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&e.name})).map((function(e){return e.name.value}))[0]||null}function cA(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function hA(e){var t;oA(e);for(var i=0,r=e.definitions;i<r.length;i++){var n=r[i];if("OperationDefinition"===n.kind){var o=n.operation;if("query"===o||"mutation"===o||"subscription"===o)return n}"FragmentDefinition"!==n.kind||t||(t=n)}if(t)return t;throw"production"===process.env.NODE_ENV?new Aw(10):new Aw("Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.")}function uA(e){void 0===e&&(e=[]);var t={};return e.forEach((function(e){t[e.name.value]=e})),t}function lA(e){if(e&&e.variableDefinitions&&e.variableDefinitions.length){var t=e.variableDefinitions.filter((function(e){return e.defaultValue})).map((function(e){var t=e.variable,i=e.defaultValue,r={};return Uw(r,t.name,i),r}));return nA.apply(void 0,gv([{}],t))}return{}}function pA(e,t,i){var r=0;return e.forEach((function(i,n){t.call(this,i,n,e)&&(e[r++]=i)}),i),e.length=r,e}var dA={kind:"Field",name:{kind:"Name",value:"__typename"}};function fA(e,t){return e.selectionSet.selections.every((function(e){return"FragmentSpread"===e.kind&&fA(t[e.name.value],t)}))}function mA(e){return fA(sA(e)||function(e){"production"===process.env.NODE_ENV?Sw("Document"===e.kind,7):Sw("Document"===e.kind,'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql'),"production"===process.env.NODE_ENV?Sw(e.definitions.length<=1,8):Sw(e.definitions.length<=1,"Fragment must have exactly one definition.");var t=e.definitions[0];return"production"===process.env.NODE_ENV?Sw("FragmentDefinition"===t.kind,9):Sw("FragmentDefinition"===t.kind,"Must be a fragment definition."),t}(e),uA(cA(e)))?null:e}function gA(e){return function(t){return e.some((function(e){return e.name&&e.name===t.name.value||e.test&&e.test(t)}))}}function vA(e,t){var i=Object.create(null),r=[],n=Object.create(null),o=[],s=mA(Ow(t,{Variable:{enter:function(e,t,r){"VariableDefinition"!==r.kind&&(i[e.name.value]=!0)}},Field:{enter:function(t){if(e&&t.directives&&(e.some((function(e){return e.remove}))&&t.directives&&t.directives.some(gA(e))))return t.arguments&&t.arguments.forEach((function(e){"Variable"===e.value.kind&&r.push({name:e.value.name.value})})),t.selectionSet&&yA(t.selectionSet).forEach((function(e){o.push({name:e.name.value})})),null}},FragmentSpread:{enter:function(e){n[e.name.value]=!0}},Directive:{enter:function(t){if(gA(e)(t))return null}}}));return s&&pA(r,(function(e){return!i[e.name]})).length&&(s=function(e,t){var i=function(e){return function(t){return e.some((function(e){return t.value&&"Variable"===t.value.kind&&t.value.name&&(e.name===t.value.name.value||e.test&&e.test(t))}))}}(e);return mA(Ow(t,{OperationDefinition:{enter:function(t){return dv(dv({},t),{variableDefinitions:t.variableDefinitions.filter((function(t){return!e.some((function(e){return e.name===t.variable.name.value}))}))})}},Field:{enter:function(t){if(e.some((function(e){return e.remove}))){var r=0;if(t.arguments.forEach((function(e){i(e)&&(r+=1)})),1===r)return null}}},Argument:{enter:function(e){if(i(e))return null}}}))}(r,s)),s&&pA(o,(function(e){return!n[e.name]})).length&&(s=function(e,t){function i(t){if(e.some((function(e){return e.name===t.name.value})))return null}return mA(Ow(t,{FragmentSpread:{enter:i},FragmentDefinition:{enter:i}}))}(o,s)),s}var _A={test:function(e){var t="connection"===e.name.value;return t&&(e.arguments&&e.arguments.some((function(e){return"key"===e.name.value}))||"production"===process.env.NODE_ENV||Sw.warn("Removing an @connection directive even though it does not have a key. You may want to use the key parameter to specify a store key.")),t}};function yA(e){var t=[];return e.selections.forEach((function(e){(Qw(e)||Yw(e))&&e.selectionSet?yA(e.selectionSet).forEach((function(e){return t.push(e)})):"FragmentSpread"===e.kind&&t.push(e)})),t}function bA(e){return"query"===hA(e).operation?e:Ow(e,{OperationDefinition:{enter:function(e){return dv(dv({},e),{operation:"query"})}}})}var xA="function"==typeof WeakMap&&!("object"==typeof navigator&&"ReactNative"===navigator.product),wA=Object.prototype.toString;function AA(e){return SA(e,new Map)}function SA(e,t){switch(wA.call(e)){case"[object Array]":if(t.has(e))return t.get(e);var i=e.slice(0);return t.set(e,i),i.forEach((function(e,r){i[r]=SA(e,t)})),i;case"[object Object]":if(t.has(e))return t.get(e);var r=Object.create(Object.getPrototypeOf(e));return t.set(e,r),Object.keys(e).forEach((function(i){r[i]=SA(e[i],t)})),r;default:return e}}function MA(e){return("undefined"!=typeof process&&process.env.NODE_ENV?process.env.NODE_ENV:"development")===e}function EA(){return!0===MA("test")}function TA(e){try{return e()}catch(e){console.error&&console.error(e)}}function CA(e){return e.errors&&e.errors.length}function IA(e){return Object.freeze(e),Object.getOwnPropertyNames(e).forEach((function(t){null===e[t]||"object"!=typeof e[t]&&"function"!=typeof e[t]||Object.isFrozen(e[t])||IA(e[t])})),e}function NA(e){if((!0===MA("development")||EA())&&!("function"==typeof Symbol&&"string"==typeof Symbol("")))return IA(e);return e}var PA=Object.prototype.hasOwnProperty;function RA(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return OA(e)}function OA(e){var t=e[0]||{},i=e.length;if(i>1){var r=[];t=kA(t,r);for(var n=1;n<i;++n)t=LA(t,e[n],r)}return t}function DA(e){return null!==e&&"object"==typeof e}function LA(e,t,i){return DA(t)&&DA(e)?(Object.isExtensible&&!Object.isExtensible(e)&&(e=kA(e,i)),Object.keys(t).forEach((function(r){var n=t[r];if(PA.call(e,r)){var o=e[r];n!==o&&(e[r]=LA(kA(o,i),n,i))}else e[r]=n})),e):t}function kA(e,t){return null!==e&&"object"==typeof e&&t.indexOf(e)<0&&(e=Array.isArray(e)?e.slice(0):dv({__proto__:Object.getPrototypeOf(e)},e),t.push(e)),e}var BA=function(e){function t(t,i){var r=e.call(this,t)||this;return r.link=i,r}return pv(t,e),t}(Error);function FA(e){return e.request.length<=1}function jA(e){return new yw((function(t){t.error(e)}))}function zA(e,t){var i=dv({},e);return Object.defineProperty(t,"setContext",{enumerable:!1,value:function(e){i=dv({},i,"function"==typeof e?e(i):e)}}),Object.defineProperty(t,"getContext",{enumerable:!1,value:function(){return dv({},i)}}),Object.defineProperty(t,"toKey",{enumerable:!1,value:function(){return function(e){var t=e.query,i=e.variables,r=e.operationName;return JSON.stringify([r,t,i])}(t)}}),t}function $A(e,t){return t?t(e):yw.of()}function VA(e){return"function"==typeof e?new WA(e):e}function UA(){return new WA((function(){return yw.of()}))}function GA(e){return 0===e.length?UA():e.map(VA).reduce((function(e,t){return e.concat(t)}))}function HA(e,t,i){var r=VA(t),n=VA(i||new WA($A));return FA(r)&&FA(n)?new WA((function(t){return e(t)?r.request(t)||yw.of():n.request(t)||yw.of()})):new WA((function(t,i){return e(t)?r.request(t,i)||yw.of():n.request(t,i)||yw.of()}))}var qA=function(e,t){var i=VA(e);if(FA(i))return"production"===process.env.NODE_ENV||Sw.warn(new BA("You are calling concat on a terminating link, which will have no effect",i)),i;var r=VA(t);return FA(r)?new WA((function(e){return i.request(e,(function(e){return r.request(e)||yw.of()}))||yw.of()})):new WA((function(e,t){return i.request(e,(function(e){return r.request(e,t)||yw.of()}))||yw.of()}))},WA=function(){function e(e){e&&(this.request=e)}return e.prototype.split=function(t,i,r){return this.concat(HA(t,i,r||new e($A)))},e.prototype.concat=function(e){return qA(this,e)},e.prototype.request=function(e,t){throw"production"===process.env.NODE_ENV?new Aw(1):new Aw("request is not implemented")},e.empty=UA,e.from=GA,e.split=HA,e.execute=QA,e}();function QA(e,t){return e.request(zA(t.context,function(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName="string"!=typeof t.query?aA(t.query):""),t}(function(e){for(var t=["query","operationName","variables","extensions","context"],i=0,r=Object.keys(e);i<r.length;i++){var n=r[i];if(t.indexOf(n)<0)throw"production"===process.env.NODE_ENV?new Aw(2):new Aw("illegal argument: "+n)}return e}(t))))||yw.of()}function YA(e){var t=e.split(/\r\n|[\n\r]/g),i=function(e){for(var t=null,i=1;i<e.length;i++){var r=e[i],n=XA(r);if(n!==r.length&&((null===t||n<t)&&0===(t=n)))break}return null===t?0:t}(t);if(0!==i)for(var r=1;r<t.length;r++)t[r]=t[r].slice(i);for(;t.length>0&&ZA(t[0]);)t.shift();for(;t.length>0&&ZA(t[t.length-1]);)t.pop();return t.join("\n")}function XA(e){for(var t=0;t<e.length&&(" "===e[t]||"\t"===e[t]);)t++;return t}function ZA(e){return XA(e)===e.length}function KA(e){return Ow(e,{leave:JA})}var JA={Name:function(e){return e.value},Variable:function(e){return"$"+e.name},Document:function(e){return tS(e.definitions,"\n\n")+"\n"},OperationDefinition:function(e){var t=e.operation,i=e.name,r=rS("(",tS(e.variableDefinitions,", "),")"),n=tS(e.directives," "),o=e.selectionSet;return i||n||r||"query"!==t?tS([t,tS([i,r]),n,o]," "):o},VariableDefinition:function(e){var t=e.variable,i=e.type,r=e.defaultValue,n=e.directives;return t+": "+i+rS(" = ",r)+rS(" ",tS(n," "))},SelectionSet:function(e){return iS(e.selections)},Field:function(e){var t=e.alias,i=e.name,r=e.arguments,n=e.directives,o=e.selectionSet;return tS([rS("",t,": ")+i+rS("(",tS(r,", "),")"),tS(n," "),o]," ")},Argument:function(e){return e.name+": "+e.value},FragmentSpread:function(e){return"..."+e.name+rS(" ",tS(e.directives," "))},InlineFragment:function(e){var t=e.typeCondition,i=e.directives,r=e.selectionSet;return tS(["...",rS("on ",t),tS(i," "),r]," ")},FragmentDefinition:function(e){var t=e.name,i=e.typeCondition,r=e.variableDefinitions,n=e.directives,o=e.selectionSet;return"fragment ".concat(t).concat(rS("(",tS(r,", "),")")," ")+"on ".concat(i," ").concat(rS("",tS(n," ")," "))+o},IntValue:function(e){return e.value},FloatValue:function(e){return e.value},StringValue:function(e,t){var i=e.value;return e.block?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),n=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],s=!r||o||i,a="";return!s||r&&n||(a+="\n"+t),a+=t?e.replace(/\n/g,"\n"+t):e,s&&(a+="\n"),'"""'+a.replace(/"""/g,'\\"""')+'"""'}(i,"description"===t?"":" "):JSON.stringify(i)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+tS(e.values,", ")+"]"},ObjectValue:function(e){return"{"+tS(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+rS("(",tS(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,i=e.operationTypes;return tS(["schema",tS(t," "),iS(i)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:eS((function(e){return tS(["scalar",e.name,tS(e.directives," ")]," ")})),ObjectTypeDefinition:eS((function(e){var t=e.name,i=e.interfaces,r=e.directives,n=e.fields;return tS(["type",t,rS("implements ",tS(i," & ")),tS(r," "),iS(n)]," ")})),FieldDefinition:eS((function(e){var t=e.name,i=e.arguments,r=e.type,n=e.directives;return t+(sS(i)?rS("(\n",nS(tS(i,"\n")),"\n)"):rS("(",tS(i,", "),")"))+": "+r+rS(" ",tS(n," "))})),InputValueDefinition:eS((function(e){var t=e.name,i=e.type,r=e.defaultValue,n=e.directives;return tS([t+": "+i,rS("= ",r),tS(n," ")]," ")})),InterfaceTypeDefinition:eS((function(e){var t=e.name,i=e.directives,r=e.fields;return tS(["interface",t,tS(i," "),iS(r)]," ")})),UnionTypeDefinition:eS((function(e){var t=e.name,i=e.directives,r=e.types;return tS(["union",t,tS(i," "),r&&0!==r.length?"= "+tS(r," | "):""]," ")})),EnumTypeDefinition:eS((function(e){var t=e.name,i=e.directives,r=e.values;return tS(["enum",t,tS(i," "),iS(r)]," ")})),EnumValueDefinition:eS((function(e){return tS([e.name,tS(e.directives," ")]," ")})),InputObjectTypeDefinition:eS((function(e){var t=e.name,i=e.directives,r=e.fields;return tS(["input",t,tS(i," "),iS(r)]," ")})),DirectiveDefinition:eS((function(e){var t=e.name,i=e.arguments,r=e.repeatable,n=e.locations;return"directive @"+t+(sS(i)?rS("(\n",nS(tS(i,"\n")),"\n)"):rS("(",tS(i,", "),")"))+(r?" repeatable":"")+" on "+tS(n," | ")})),SchemaExtension:function(e){var t=e.directives,i=e.operationTypes;return tS(["extend schema",tS(t," "),iS(i)]," ")},ScalarTypeExtension:function(e){return tS(["extend scalar",e.name,tS(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,i=e.interfaces,r=e.directives,n=e.fields;return tS(["extend type",t,rS("implements ",tS(i," & ")),tS(r," "),iS(n)]," ")},InterfaceTypeExtension:function(e){var t=e.name,i=e.directives,r=e.fields;return tS(["extend interface",t,tS(i," "),iS(r)]," ")},UnionTypeExtension:function(e){var t=e.name,i=e.directives,r=e.types;return tS(["extend union",t,tS(i," "),r&&0!==r.length?"= "+tS(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,i=e.directives,r=e.values;return tS(["extend enum",t,tS(i," "),iS(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,i=e.directives,r=e.fields;return tS(["extend input",t,tS(i," "),iS(r)]," ")}};function eS(e){return function(t){return tS([t.description,e(t)],"\n")}}function tS(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function iS(e){return e&&0!==e.length?"{\n"+nS(tS(e,"\n"))+"\n}":""}function rS(e,t,i){return t?e+t+(i||""):""}function nS(e){return e&&" "+e.replace(/\n/g,"\n ")}function oS(e){return-1!==e.indexOf("\n")}function sS(e){return e&&e.some(oS)}var aS={http:{includeQuery:!0,includeExtensions:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},cS=function(e,t,i){var r=new Error(i);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},hS=function(e,t){var i;try{i=JSON.stringify(e)}catch(e){var r="production"===process.env.NODE_ENV?new Aw(2):new Aw("Network request failed. "+t+" is not serializable: "+e.message);throw r.parseError=e,r}return i},uS=function(e){void 0===e&&(e={});var t=e.uri,i=void 0===t?"/graphql":t,r=e.fetch,n=e.includeExtensions,o=e.useGETForQueries,s=function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i}(e,["uri","fetch","includeExtensions","useGETForQueries"]);!function(e){if(!e&&"undefined"==typeof fetch){var t="unfetch";throw"undefined"==typeof window&&(t="node-fetch"),"production"===process.env.NODE_ENV?new Aw(1):new Aw("\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\nyour environment like https://www.npmjs.com/package/"+t+".\n\nFor example:\nimport fetch from '"+t+"';\nimport { createHttpLink } from 'apollo-link-http';\n\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });")}}(r),r||(r=fetch);var a={http:{includeExtensions:n},options:s.fetchOptions,credentials:s.credentials,headers:s.headers};return new WA((function(e){var t=function(e,t){return e.getContext().uri||("function"==typeof t?t(e):t||"/graphql")}(e,i),n=e.getContext(),s={};if(n.clientAwareness){var c=n.clientAwareness,h=c.name,u=c.version;h&&(s["apollographql-client-name"]=h),u&&(s["apollographql-client-version"]=u)}var l,p=dv({},s,n.headers),d={http:n.http,options:n.fetchOptions,credentials:n.credentials,headers:p},f=function(e,t){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];var n=dv({},t.options,{headers:t.headers,credentials:t.credentials}),o=t.http;i.forEach((function(e){n=dv({},n,e.options,{headers:dv({},n.headers,e.headers)}),e.credentials&&(n.credentials=e.credentials),o=dv({},o,e.http)}));var s=e.operationName,a=e.extensions,c=e.variables,h=e.query,u={operationName:s,variables:c};return o.includeExtensions&&(u.extensions=a),o.includeQuery&&(u.query=KA(h)),{options:n,body:u}}(e,aS,a,d),m=f.options,g=f.body;if(!m.signal){var v=function(){if("undefined"==typeof AbortController)return{controller:!1,signal:!1};var e=new AbortController;return{controller:e,signal:e.signal}}(),_=v.controller,y=v.signal;(l=_)&&(m.signal=y)}if(o&&!e.query.definitions.some((function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation}))&&(m.method="GET"),"GET"===m.method){var b=function(e,t){var i=[],r=function(e,t){i.push(e+"="+encodeURIComponent(t))};"query"in t&&r("query",t.query);t.operationName&&r("operationName",t.operationName);if(t.variables){var n=void 0;try{n=hS(t.variables,"Variables map")}catch(e){return{parseError:e}}r("variables",n)}if(t.extensions){var o=void 0;try{o=hS(t.extensions,"Extensions map")}catch(e){return{parseError:e}}r("extensions",o)}var s="",a=e,c=e.indexOf("#");-1!==c&&(s=e.substr(c),a=e.substr(0,c));var h=-1===a.indexOf("?")?"?":"&";return{newURI:a+h+i.join("&")+s}}(t,g),x=b.newURI,w=b.parseError;if(w)return jA(w);t=x}else try{m.body=hS(g,"Payload")}catch(w){return jA(w)}return new yw((function(i){var n;return r(t,m).then((function(t){return e.setContext({response:t}),t})).then((n=e,function(e){return e.text().then((function(t){try{return JSON.parse(t)}catch(r){var i=r;return i.name="ServerParseError",i.response=e,i.statusCode=e.status,i.bodyText=t,Promise.reject(i)}})).then((function(t){return e.status>=300&&cS(e,t,"Response not successful: Received status code "+e.status),Array.isArray(t)||t.hasOwnProperty("data")||t.hasOwnProperty("errors")||cS(e,t,"Server response was missing for query '"+(Array.isArray(n)?n.map((function(e){return e.operationName})):n.operationName)+"'."),t}))})).then((function(e){return i.next(e),i.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&i.next(e.result),i.error(e))})),function(){l&&l.abort()}}))}))};var lS=function(e){function t(t){return e.call(this,uS(t).request)||this}return pv(t,e),t}(WA);function pS(e){return new WA((function(t,i){return new yw((function(r){var n,o,s;try{n=i(t).subscribe({next:function(n){n.errors&&(s=e({graphQLErrors:n.errors,response:n,operation:t,forward:i}))?o=s.subscribe({next:r.next.bind(r),error:r.error.bind(r),complete:r.complete.bind(r)}):r.next(n)},error:function(n){(s=e({operation:t,networkError:n,graphQLErrors:n&&n.result&&n.result.errors,forward:i}))?o=s.subscribe({next:r.next.bind(r),error:r.error.bind(r),complete:r.complete.bind(r)}):r.error(n)},complete:function(){s||r.complete.bind(r)()}})}catch(n){e({networkError:n,operation:t,forward:i}),r.error(n)}return function(){n&&n.unsubscribe(),o&&n.unsubscribe()}}))}))}!function(e){function t(t){var i=e.call(this)||this;return i.link=pS(t),i}pv(t,e),t.prototype.request=function(e,t){return this.link.request(e,t)}}(WA);var dS,fS=function(e){var t,i=e.Symbol;return"function"==typeof i?i.observable?t=i.observable:(t=i("observable"),i.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")());function mS(e){return e<7}!function(e){e[e.loading=1]="loading",e[e.setVariables=2]="setVariables",e[e.fetchMore=3]="fetchMore",e[e.refetch=4]="refetch",e[e.poll=6]="poll",e[e.ready=7]="ready",e[e.error=8]="error"}(dS||(dS={}));var gS=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return pv(t,e),t.prototype[fS]=function(){return this},t.prototype["@@observable"]=function(){return this},t}(yw);function vS(e){return Array.isArray(e)&&e.length>0}var _S,yS=function(e){function t(i){var r,n,o=i.graphQLErrors,s=i.networkError,a=i.errorMessage,c=i.extraInfo,h=e.call(this,a)||this;return h.graphQLErrors=o||[],h.networkError=s||null,h.message=a||(n="",vS((r=h).graphQLErrors)&&r.graphQLErrors.forEach((function(e){var t=e?e.message:"Error message not found.";n+="GraphQL error: "+t+"\n"})),r.networkError&&(n+="Network error: "+r.networkError.message+"\n"),n=n.replace(/\n$/,"")),h.extraInfo=c,h.__proto__=t.prototype,h}return pv(t,e),t}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}(_S||(_S={}));var bS=function(e){function t(t){var i=t.queryManager,r=t.options,n=t.shouldSubscribe,o=void 0===n||n,s=e.call(this,(function(e){return s.onSubscribe(e)}))||this;s.observers=new Set,s.subscriptions=new Set,s.isTornDown=!1,s.options=r,s.variables=r.variables||{},s.queryId=i.generateQueryId(),s.shouldSubscribe=o;var a=sA(r.query);return s.queryName=a&&a.name&&a.name.value,s.queryManager=i,s}return pv(t,e),t.prototype.result=function(){var e=this;return new Promise((function(t,i){var r={next:function(i){t(i),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){n.unsubscribe()}),0)},error:i},n=e.subscribe(r)}))},t.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},t.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.data||void 0,error:this.lastError,loading:!1,networkStatus:dS.error}}var t,i,r,n=this.queryManager.getCurrentQueryResult(this),o=n.data,s=n.partial,a=this.queryManager.queryStore.get(this.queryId),c=this.options.fetchPolicy,h="network-only"===c||"no-cache"===c;if(a){var u=a.networkStatus;if(i=a,void 0===(r=this.options.errorPolicy)&&(r="none"),i&&(i.networkError||"none"===r&&vS(i.graphQLErrors)))return{data:void 0,loading:!1,networkStatus:u,error:new yS({graphQLErrors:a.graphQLErrors,networkError:a.networkError})};a.variables&&(this.options.variables=dv(dv({},this.options.variables),a.variables),this.variables=this.options.variables),t={data:o,loading:mS(u),networkStatus:u},a.graphQLErrors&&"all"===this.options.errorPolicy&&(t.errors=a.graphQLErrors)}else{var l=h||s&&"cache-only"!==c;t={data:o,loading:l,networkStatus:l?dS.loading:dS.ready}}return s||this.updateLastResult(dv(dv({},t),{stale:!1})),dv(dv({},t),{partial:s})},t.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&zw(t.data,e.data))},t.prototype.getLastResult=function(){return this.lastResult},t.prototype.getLastError=function(){return this.lastError},t.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){var e=this.queryManager.queryStore.get(this.queryId);e&&(e.networkError=null,e.graphQLErrors=[])},t.prototype.refetch=function(e){var t=this.options.fetchPolicy;return"cache-only"===t?Promise.reject("production"===process.env.NODE_ENV?new Aw(1):new Aw("cache-only fetchPolicy option should not be used together with query refetch.")):("no-cache"!==t&&"cache-and-network"!==t&&(t="network-only"),zw(this.variables,e)||(this.variables=dv(dv({},this.variables),e)),zw(this.options.variables,this.variables)||(this.options.variables=dv(dv({},this.options.variables),this.variables)),this.queryManager.fetchQuery(this.queryId,dv(dv({},this.options),{fetchPolicy:t}),_S.refetch))},t.prototype.fetchMore=function(e){var t=this;"production"===process.env.NODE_ENV?Sw(e.updateQuery,2):Sw(e.updateQuery,"updateQuery option is required. This function defines how to update the query data with the new results.");var i=dv(dv({},e.query?e:dv(dv(dv({},this.options),e),{variables:dv(dv({},this.variables),e.variables)})),{fetchPolicy:"network-only"}),r=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(r,i,_S.normal,this.queryId).then((function(n){return t.updateQuery((function(t){return e.updateQuery(t,{fetchMoreResult:n.data,variables:i.variables})})),t.queryManager.stopQuery(r),n}),(function(e){throw t.queryManager.stopQuery(r),e}))},t.prototype.subscribeToMore=function(e){var t=this,i=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(i){var r=e.updateQuery;r&&t.updateQuery((function(e,t){var n=t.variables;return r(e,{subscriptionData:i,variables:n})}))},error:function(t){e.onError?e.onError(t):"production"===process.env.NODE_ENV||Sw.error("Unhandled GraphQL subscription error",t)}});return this.subscriptions.add(i),function(){t.subscriptions.delete(i)&&i.unsubscribe()}},t.prototype.setOptions=function(e){var t=this.options.fetchPolicy;this.options=dv(dv({},this.options),e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var i=e.fetchPolicy;return this.setVariables(this.options.variables,t!==i&&("cache-only"===t||"standby"===t||"network-only"===i),e.fetchResults)},t.prototype.setVariables=function(e,t,i){return void 0===t&&(t=!1),void 0===i&&(i=!0),this.isTornDown=!1,e=e||this.variables,!t&&zw(e,this.variables)?this.observers.size&&i?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,i=t.getQueryWithPreviousResult(this.queryId),r=i.previousResult,n=i.variables,o=i.document,s=TA((function(){return e(r,{variables:n})}));s&&(t.dataStore.markUpdateQueryResult(o,n,s),t.broadcastQueries())},t.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},t.prototype.startPolling=function(e){AS(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},t.prototype.updateLastResult=function(e){var t=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:AA(e),t},t.prototype.onSubscribe=function(e){var t=this;try{var i=e._subscription._observer;i&&!i.error&&(i.error=xS)}catch(e){}var r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},t.prototype.setUpQuery=function(){var e=this,t=this.queryManager,i=this.queryId;this.shouldSubscribe&&t.addObservableQuery(i,this),this.options.pollInterval&&(AS(this),t.startPollingQuery(this.options,i));var r=function(t){e.updateLastResult(dv(dv({},e.lastResult),{errors:t.graphQLErrors,networkStatus:dS.error,loading:!1})),wS(e.observers,"error",e.lastError=t)};t.observeQuery(i,this.options,{next:function(i){if(e.lastError||e.isDifferentFromLastResult(i)){var r=e.updateLastResult(i),n=e.options,o=n.query,s=n.variables,a=n.fetchPolicy;t.transform(o).hasClientExports?t.getLocalState().addExportedVariables(o,s).then((function(n){var s=e.variables;e.variables=e.options.variables=n,!i.loading&&r&&"cache-only"!==a&&t.transform(o).serverQuery&&!zw(s,n)?e.refetch():wS(e.observers,"next",i)})):wS(e.observers,"next",i)}},error:r}).catch(r)},t.prototype.tearDownQuery=function(){var e=this.queryManager;this.isTornDown=!0,e.stopPollingQuery(this.queryId),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),e.removeObservableQuery(this.queryId),e.stopQuery(this.queryId),this.observers.clear()},t}(gS);function xS(e){"production"===process.env.NODE_ENV||Sw.error("Unhandled error",e.message,e.stack)}function wS(e,t,i){var r=[];e.forEach((function(e){return e[t]&&r.push(e)})),r.forEach((function(e){return e[t](i)}))}function AS(e){var t=e.options.fetchPolicy;"production"===process.env.NODE_ENV?Sw("cache-first"!==t&&"cache-only"!==t,3):Sw("cache-first"!==t&&"cache-only"!==t,"Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.")}var SS=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,i){this.store[e]={mutation:t,variables:i||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var i=this.store[e];i&&(i.loading=!1,i.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),MS=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];"production"===process.env.NODE_ENV?Sw(!t||t.document===e.document||zw(t.document,e.document),19):Sw(!t||t.document===e.document||zw(t.document,e.document),"Internal Error: may not update existing query string in store");var i,r=!1,n=null;e.storePreviousVariables&&t&&t.networkStatus!==dS.loading&&(zw(t.variables,e.variables)||(r=!0,n=t.variables)),i=r?dS.setVariables:e.isPoll?dS.poll:e.isRefetch?dS.refetch:dS.loading;var o=[];t&&t.graphQLErrors&&(o=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:n,networkError:null,graphQLErrors:o,networkStatus:i,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=dS.fetchMore)},e.prototype.markQueryResult=function(e,t,i){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=vS(t.errors)?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=dS.ready,"string"==typeof i&&this.store[i]&&(this.store[i].networkStatus=dS.ready))},e.prototype.markQueryError=function(e,t,i){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=dS.error,"string"==typeof i&&this.markQueryResultClient(i,!0))},e.prototype.markQueryResultClient=function(e,t){var i=this.store&&this.store[e];i&&(i.networkError=null,i.previousVariables=null,t&&(i.networkStatus=dS.ready))},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var t=this;Object.keys(this.store).forEach((function(i){e.indexOf(i)<0?t.stopQuery(i):t.store[i].networkStatus=dS.loading}))},e}();var ES=function(){function e(e){var t=e.cache,i=e.client,r=e.resolvers,n=e.fragmentMatcher;this.cache=t,i&&(this.client=i),r&&this.addResolvers(r),n&&this.setFragmentMatcher(n)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=RA(t.resolvers,e)})):this.resolvers=RA(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var t=e.document,i=e.remoteResult,r=e.context,n=e.variables,o=e.onlyRunForcedResolvers,s=void 0!==o&&o;return fv(this,void 0,void 0,(function(){return mv(this,(function(e){return t?[2,this.resolveDocument(t,i.data,r,n,this.fragmentMatcher,s).then((function(e){return dv(dv({},i),{data:e.result})}))]:[2,i]}))}))},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){if(eA(["client"],e)){if(this.resolvers)return e;"production"===process.env.NODE_ENV||Sw.warn("Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.")}return null},e.prototype.serverQuery=function(e){return this.resolvers?function(e){oA(e);var t=vA([{test:function(e){return"client"===e.name.value},remove:!0}],e);return t&&(t=Ow(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet&&e.selectionSet.selections.every((function(e){return Qw(e)&&"__typename"===e.name.value})))return null}}})),t}(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.cache;return dv(dv({},e),{cache:t,getCacheKey:function(e){if(t.config)return t.config.dataIdFromObject(e);"production"===process.env.NODE_ENV?Sw(!1,6):Sw(!1,"To use context.getCacheKey, you need to use a cache that has a configurable dataIdFromObject, like apollo-cache-inmemory.")}})},e.prototype.addExportedVariables=function(e,t,i){return void 0===t&&(t={}),void 0===i&&(i={}),fv(this,void 0,void 0,(function(){return mv(this,(function(r){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(i),t).then((function(e){return dv(dv({},t),e.exportedVariables)}))]:[2,dv({},t)]}))}))},e.prototype.shouldForceResolvers=function(e){var t=!1;return Ow(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return Rw}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:bA(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t,i,r,n,o){return void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n=function(){return!0}),void 0===o&&(o=!1),fv(this,void 0,void 0,(function(){var s,a,c,h,u,l,p,d,f;return mv(this,(function(m){var g;return s=hA(e),a=cA(e),c=uA(a),h=s.operation,u=h?(g=h).charAt(0).toUpperCase()+g.slice(1):"Query",p=(l=this).cache,d=l.client,f={fragmentMap:c,context:dv(dv({},i),{cache:p,client:d}),variables:r,fragmentMatcher:n,defaultOperationType:u,exportedVariables:{},onlyRunForcedResolvers:o},[2,this.resolveSelectionSet(s.selectionSet,t,f).then((function(e){return{result:e,exportedVariables:f.exportedVariables}}))]}))}))},e.prototype.resolveSelectionSet=function(e,t,i){return fv(this,void 0,void 0,(function(){var r,n,o,s,a,c=this;return mv(this,(function(h){return r=i.fragmentMap,n=i.context,o=i.variables,s=[t],a=function(e){return fv(c,void 0,void 0,(function(){var a,c;return mv(this,(function(h){return Jw(e,o)?Qw(e)?[2,this.resolveField(e,t,i).then((function(t){var i;void 0!==t&&s.push(((i={})[Ww(e)]=t,i))}))]:(Yw(e)?a=e:(a=r[e.name.value],"production"===process.env.NODE_ENV?Sw(a,7):Sw(a,"No fragment named "+e.name.value)),a&&a.typeCondition&&(c=a.typeCondition.name.value,i.fragmentMatcher(t,c,n))?[2,this.resolveSelectionSet(a.selectionSet,t,i).then((function(e){s.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(e.selections.map(a)).then((function(){return OA(s)}))]}))}))},e.prototype.resolveField=function(e,t,i){return fv(this,void 0,void 0,(function(){var r,n,o,s,a,c,h,u,l,p=this;return mv(this,(function(d){return r=i.variables,n=e.name.value,o=Ww(e),s=n!==o,a=t[o]||t[n],c=Promise.resolve(a),i.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(h=t.__typename||i.defaultOperationType,(u=this.resolvers&&this.resolvers[h])&&(l=u[s?n:o])&&(c=Promise.resolve(l(t,qw(e,r),i.context,{field:e,fragmentMap:i.fragmentMap})))),[2,c.then((function(t){return void 0===t&&(t=a),e.directives&&e.directives.forEach((function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach((function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(i.exportedVariables[e.value.value]=t)}))})),e.selectionSet?null==t?t:Array.isArray(t)?p.resolveSubSelectedArray(e,t,i):e.selectionSet?p.resolveSelectionSet(e.selectionSet,t,i):void 0:t}))]}))}))},e.prototype.resolveSubSelectedArray=function(e,t,i){var r=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?r.resolveSubSelectedArray(e,t,i):e.selectionSet?r.resolveSelectionSet(e.selectionSet,t,i):void 0})))},e}();function TS(e){var t=new Set,i=null;return new gS((function(r){return t.add(r),i=i||e.subscribe({next:function(e){t.forEach((function(t){return t.next&&t.next(e)}))},error:function(e){t.forEach((function(t){return t.error&&t.error(e)}))},complete:function(){t.forEach((function(e){return e.complete&&e.complete()}))}}),function(){t.delete(r)&&!t.size&&i&&(i.unsubscribe(),i=null)}}))}var CS=Object.prototype.hasOwnProperty,IS=function(){function e(e){var t=e.link,i=e.queryDeduplication,r=void 0!==i&&i,n=e.store,o=e.onBroadcast,s=void 0===o?function(){}:o,a=e.ssrMode,c=void 0!==a&&a,h=e.clientAwareness,u=void 0===h?{}:h,l=e.localState,p=e.assumeImmutableResults;this.mutationStore=new SS,this.queryStore=new MS,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(xA?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.link=t,this.queryDeduplication=r,this.dataStore=n,this.onBroadcast=s,this.clientAwareness=u,this.localState=l||new ES({cache:n.getCache()}),this.ssrMode=c,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach((function(t,i){e.stopQueryNoBroadcast(i)})),this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new Aw(8):new Aw("QueryManager stopped while query was in flight"))}))},e.prototype.mutate=function(e){var t=e.mutation,i=e.variables,r=e.optimisticResponse,n=e.updateQueries,o=e.refetchQueries,s=void 0===o?[]:o,a=e.awaitRefetchQueries,c=void 0!==a&&a,h=e.update,u=e.errorPolicy,l=void 0===u?"none":u,p=e.fetchPolicy,d=e.context,f=void 0===d?{}:d;return fv(this,void 0,void 0,(function(){var e,o,a,u=this;return mv(this,(function(d){switch(d.label){case 0:return"production"===process.env.NODE_ENV?Sw(t,9):Sw(t,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?Sw(!p||"no-cache"===p,10):Sw(!p||"no-cache"===p,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateQueryId(),t=this.transform(t).document,this.setQuery(e,(function(){return{document:t}})),i=this.getVariables(t,i),this.transform(t).hasClientExports?[4,this.localState.addExportedVariables(t,i,f)]:[3,2];case 1:i=d.sent(),d.label=2;case 2:return o=function(){var e={};return n&&u.queries.forEach((function(t,i){var r=t.observableQuery;if(r){var o=r.queryName;o&&CS.call(n,o)&&(e[i]={updater:n[o],query:u.queryStore.get(i)})}})),e},this.mutationStore.initMutation(e,t,i),this.dataStore.markMutationInit({mutationId:e,document:t,variables:i,updateQueries:o(),update:h,optimisticResponse:r}),this.broadcastQueries(),a=this,[2,new Promise((function(n,u){var d,m;a.getObservableFromLink(t,dv(dv({},f),{optimisticResponse:r}),i,!1).subscribe({next:function(r){CA(r)&&"none"===l?m=new yS({graphQLErrors:r.errors}):(a.mutationStore.markMutationResult(e),"no-cache"!==p&&a.dataStore.markMutationResult({mutationId:e,result:r,document:t,variables:i,updateQueries:o(),update:h}),d=r)},error:function(t){a.mutationStore.markMutationError(e,t),a.dataStore.markMutationComplete({mutationId:e,optimisticResponse:r}),a.broadcastQueries(),a.setQuery(e,(function(){return{document:null}})),u(new yS({networkError:t}))},complete:function(){if(m&&a.mutationStore.markMutationError(e,m),a.dataStore.markMutationComplete({mutationId:e,optimisticResponse:r}),a.broadcastQueries(),m)u(m);else{"function"==typeof s&&(s=s(d));var t=[];vS(s)&&s.forEach((function(e){if("string"==typeof e)a.queries.forEach((function(i){var r=i.observableQuery;r&&r.queryName===e&&t.push(r.refetch())}));else{var i={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(i.context=e.context),t.push(a.query(i))}})),Promise.all(c?t:[]).then((function(){a.setQuery(e,(function(){return{document:null}})),"ignore"===l&&d&&CA(d)&&delete d.errors,n(d)}))}}})}))]}}))}))},e.prototype.fetchQuery=function(e,t,i,r){return fv(this,void 0,void 0,(function(){var n,o,s,a,c,h,u,l,p,d,f,m,g,v,_,y,b,x,w=this;return mv(this,(function(A){switch(A.label){case 0:return n=t.metadata,o=void 0===n?null:n,s=t.fetchPolicy,a=void 0===s?"cache-first":s,c=t.context,h=void 0===c?{}:c,u=this.transform(t.query).document,l=this.getVariables(u,t.variables),this.transform(u).hasClientExports?[4,this.localState.addExportedVariables(u,l,h)]:[3,2];case 1:l=A.sent(),A.label=2;case 2:if(t=dv(dv({},t),{variables:l}),f=d="network-only"===a||"no-cache"===a,d||(m=this.dataStore.getCache().diff({query:u,variables:l,returnPartialData:!0,optimistic:!1}),g=m.complete,v=m.result,f=!g||"cache-and-network"===a,p=v),_=f&&"cache-only"!==a&&"standby"!==a,eA(["live"],u)&&(_=!0),y=this.idCounter++,b="no-cache"!==a?this.updateQueryWatch(e,u,t):void 0,this.setQuery(e,(function(){return{document:u,lastRequestId:y,invalidated:!0,cancel:b}})),this.invalidate(r),this.queryStore.initQuery({queryId:e,document:u,storePreviousVariables:_,variables:l,isPoll:i===_S.poll,isRefetch:i===_S.refetch,metadata:o,fetchMoreForQueryId:r}),this.broadcastQueries(),_){if(x=this.fetchRequest({requestId:y,queryId:e,document:u,options:t,fetchMoreForQueryId:r}).catch((function(t){throw t.hasOwnProperty("graphQLErrors")?t:(y>=w.getQuery(e).lastRequestId&&(w.queryStore.markQueryError(e,t,r),w.invalidate(e),w.invalidate(r),w.broadcastQueries()),new yS({networkError:t}))})),"cache-and-network"!==a)return[2,x];x.catch((function(){}))}return this.queryStore.markQueryResultClient(e,!_),this.invalidate(e),this.invalidate(r),this.transform(u).hasForcedResolvers?[2,this.localState.runResolvers({document:u,remoteResult:{data:p},context:h,variables:l,onlyRunForcedResolvers:!0}).then((function(i){return w.markQueryResult(e,i,t,r),w.broadcastQueries(),i}))]:(this.broadcastQueries(),[2,{data:p}])}}))}))},e.prototype.markQueryResult=function(e,t,i,r){var n=i.fetchPolicy,o=i.variables,s=i.errorPolicy;"no-cache"===n?this.setQuery(e,(function(){return{newData:{result:t.data,complete:!0}}})):this.dataStore.markQueryResult(t,this.getQuery(e).document,o,r,"ignore"===s||"all"===s)},e.prototype.queryListenerForObserver=function(e,t,i){var r=this;function n(e,t){if(i[e])try{i[e](t)}catch(e){"production"===process.env.NODE_ENV||Sw.error(e)}else"error"===e&&("production"===process.env.NODE_ENV||Sw.error(t))}return function(i,o){if(r.invalidate(e,!1),i){var s=r.getQuery(e),a=s.observableQuery,c=s.document,h=a?a.options.fetchPolicy:t.fetchPolicy;if("standby"!==h){var u=mS(i.networkStatus),l=a&&a.getLastResult(),p=!(!l||l.networkStatus===i.networkStatus),d=t.returnPartialData||!o&&i.previousVariables||p&&t.notifyOnNetworkStatusChange||"cache-only"===h||"cache-and-network"===h;if(!u||d){var f=vS(i.graphQLErrors),m=a&&a.options.errorPolicy||t.errorPolicy||"none";if("none"===m&&f||i.networkError)return n("error",new yS({graphQLErrors:i.graphQLErrors,networkError:i.networkError}));try{var g=void 0,v=void 0;if(o)"no-cache"!==h&&"network-only"!==h&&r.setQuery(e,(function(){return{newData:null}})),g=o.result,v=!o.complete;else{var _=a&&a.getLastError(),y="none"!==m&&(_&&_.graphQLErrors)!==i.graphQLErrors;if(l&&l.data&&!y)g=l.data,v=!1;else{var b=r.dataStore.getCache().diff({query:c,variables:i.previousVariables||i.variables,returnPartialData:!0,optimistic:!0});g=b.result,v=!b.complete}}var x=v&&!(t.returnPartialData||"cache-only"===h),w={data:x?l&&l.data:g,loading:u,networkStatus:i.networkStatus,stale:x};"all"===m&&f&&(w.errors=i.graphQLErrors),n("next",w)}catch(e){n("error",new yS({networkError:e}))}}}}}},e.prototype.transform=function(e){var t,i=this.transformCache;if(!i.has(e)){var r=this.dataStore.getCache(),n=r.transformDocument(e),o=(t=r.transformForLink(n),vA([_A],oA(t))),s=this.localState.clientQuery(n),a=this.localState.serverQuery(o),c={document:n,hasClientExports:tA(n),hasForcedResolvers:this.localState.shouldForceResolvers(n),clientQuery:s,serverQuery:a,defaultVars:lA(sA(n))},h=function(e){e&&!i.has(e)&&i.set(e,c)};h(e),h(n),h(s),h(a)}return i.get(e)},e.prototype.getVariables=function(e,t){return dv(dv({},this.transform(e).defaultVars),t)},e.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),"production"===process.env.NODE_ENV?Sw("standby"!==e.fetchPolicy,11):Sw("standby"!==e.fetchPolicy,'client.watchQuery cannot be called with fetchPolicy set to "standby"'),e.variables=this.getVariables(e.query,e.variables),void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var i=dv({},e);return new bS({queryManager:this,options:i,shouldSubscribe:t})},e.prototype.query=function(e){var t=this;return"production"===process.env.NODE_ENV?Sw(e.query,12):Sw(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?Sw("Document"===e.query.kind,13):Sw("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?Sw(!e.returnPartialData,14):Sw(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?Sw(!e.pollInterval,15):Sw(!e.pollInterval,"pollInterval option only supported on watchQuery."),new Promise((function(i,r){var n=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+n.queryId,r),n.result().then(i,r).then((function(){return t.fetchQueryRejectFns.delete("query:"+n.queryId)}))}))},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,(function(e){return e.listeners.add(t),{invalidated:!1}}))},e.prototype.updateQueryWatch=function(e,t,i){var r=this,n=this.getQuery(e).cancel;n&&n();return this.dataStore.getCache().watch({query:t,variables:i.variables,optimistic:!0,previousResult:function(){var t=null,i=r.getQuery(e).observableQuery;if(i){var n=i.getLastResult();n&&(t=n.data)}return t},callback:function(t){r.setQuery(e,(function(){return{invalidated:!0,newData:t}}))}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,(function(){return{observableQuery:t}}))},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,(function(){return{observableQuery:null}})),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new Aw(16):new Aw("Store reset while query was in flight (not completed in link chain)"))}));var e=[];return this.queries.forEach((function(t,i){t.observableQuery&&e.push(i)})),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var i=[];return this.queries.forEach((function(r,n){var o=r.observableQuery;if(o){var s=o.options.fetchPolicy;o.resetLastResults(),"cache-only"===s||!e&&"standby"===s||i.push(o.refetch()),t.setQuery(n,(function(){return{newData:null}})),t.invalidate(n)}})),this.broadcastQueries(),Promise.all(i)},e.prototype.observeQuery=function(e,t,i){return this.addQueryListener(e,this.queryListenerForObserver(e,t,i)),this.fetchQuery(e,t)},e.prototype.startQuery=function(e,t,i){return"production"===process.env.NODE_ENV||Sw.warn("The QueryManager.startQuery method has been deprecated"),this.addQueryListener(e,i),this.fetchQuery(e,t).catch((function(){})),e},e.prototype.startGraphQLSubscription=function(e){var t=this,i=e.query,r=e.fetchPolicy,n=e.variables;i=this.transform(i).document,n=this.getVariables(i,n);var o=function(e){return t.getObservableFromLink(i,{},e,!1).map((function(n){if(r&&"no-cache"===r||(t.dataStore.markSubscriptionResult(n,i,e),t.broadcastQueries()),CA(n))throw new yS({graphQLErrors:n.errors});return n}))};if(this.transform(i).hasClientExports){var s=this.localState.addExportedVariables(i,n).then(o);return new gS((function(e){var t=null;return s.then((function(i){return t=i.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return o(n)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach((function(e){return e.unsubscribe()})),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var i=e.options,r=i.variables,n=i.query,o=i.fetchPolicy,s=i.returnPartialData,a=e.getLastResult(),c=this.getQuery(e.queryId).newData;if(c&&c.complete)return{data:c.result,partial:!1};if("no-cache"===o||"network-only"===o)return{data:void 0,partial:!1};var h=this.dataStore.getCache().diff({query:n,variables:r,previousResult:a?a.data:void 0,returnPartialData:!0,optimistic:t}),u=h.result,l=h.complete;return{data:l||s?u:void 0,partial:!l}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var i=this.getQuery(e).observableQuery;"production"===process.env.NODE_ENV?Sw(i,17):Sw(i,"ObservableQuery with this id doesn't exist: "+e),t=i}else t=e;var r=t.options,n=r.variables,o=r.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:n,document:o}},e.prototype.broadcastQueries=function(){var e=this;this.onBroadcast(),this.queries.forEach((function(t,i){t.invalidated&&t.listeners.forEach((function(r){r&&r(e.queryStore.get(i),t.newData)}))}))},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,i,r){var n,o=this;void 0===r&&(r=this.queryDeduplication);var s=this.transform(e).serverQuery;if(s){var a=this.inFlightLinkObservables,c=this.link,h={query:s,variables:i,operationName:aA(s)||void 0,context:this.prepareContext(dv(dv({},t),{forceFetch:!r}))};if(t=h.context,r){var u=a.get(s)||new Map;a.set(s,u);var l=JSON.stringify(i);if(!(n=u.get(l))){u.set(l,n=TS(QA(c,h)));var p=function(){u.delete(l),u.size||a.delete(s),d.unsubscribe()},d=n.subscribe({next:p,error:p,complete:p})}}else n=TS(QA(c,h))}else n=gS.of({data:{}}),t=this.prepareContext(t);var f=this.transform(e).clientQuery;return f&&(n=function(e,t){return new gS((function(i){var r=i.next,n=i.error,o=i.complete,s=0,a=!1,c={next:function(e){++s,new Promise((function(i){i(t(e))})).then((function(e){--s,r&&r.call(i,e),a&&c.complete()}),(function(e){--s,n&&n.call(i,e)}))},error:function(e){n&&n.call(i,e)},complete:function(){a=!0,s||o&&o.call(i)}},h=e.subscribe(c);return function(){return h.unsubscribe()}}))}(n,(function(e){return o.localState.runResolvers({document:f,remoteResult:e,context:t,variables:i})}))),n},e.prototype.fetchRequest=function(e){var t,i,r=this,n=e.requestId,o=e.queryId,s=e.document,a=e.options,c=e.fetchMoreForQueryId,h=a.variables,u=a.errorPolicy,l=void 0===u?"none":u,p=a.fetchPolicy;return new Promise((function(e,u){var d=r.getObservableFromLink(s,a.context,h),f="fetchRequest:"+o;r.fetchQueryRejectFns.set(f,u);var m=function(){r.fetchQueryRejectFns.delete(f),r.setQuery(o,(function(e){e.subscriptions.delete(g)}))},g=d.map((function(e){if(n>=r.getQuery(o).lastRequestId&&(r.markQueryResult(o,e,a,c),r.queryStore.markQueryResult(o,e,c),r.invalidate(o),r.invalidate(c),r.broadcastQueries()),"none"===l&&vS(e.errors))return u(new yS({graphQLErrors:e.errors}));if("all"===l&&(i=e.errors),c||"no-cache"===p)t=e.data;else{var d=r.dataStore.getCache().diff({variables:h,query:s,optimistic:!1,returnPartialData:!0}),f=d.result;(d.complete||a.returnPartialData)&&(t=f)}})).subscribe({error:function(e){m(),u(e)},complete:function(){m(),e({data:t,errors:i,loading:!1,networkStatus:dS.ready,stale:!1})}});r.setQuery(o,(function(e){e.subscriptions.add(g)}))}))},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,t){var i=this.getQuery(e),r=dv(dv({},i),t(i));this.queries.set(e,r)},e.prototype.invalidate=function(e,t){void 0===t&&(t=!0),e&&this.setQuery(e,(function(){return{invalidated:t}}))},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return dv(dv({},t),{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==dS.ready&&t.networkStatus!==dS.error},e.prototype.startPollingQuery=function(e,t,i){var r=this,n=e.pollInterval;if("production"===process.env.NODE_ENV?Sw(n,18):Sw(n,"Attempted to start a polling query without a polling interval."),!this.ssrMode){var o=this.pollingInfoByQueryId.get(t);o||this.pollingInfoByQueryId.set(t,o={}),o.interval=n,o.options=dv(dv({},e),{fetchPolicy:"network-only"});var s=function(){var e=r.pollingInfoByQueryId.get(t);e&&(r.checkInFlight(t)?a():r.fetchQuery(t,e.options,_S.poll).then(a,a))},a=function(){var e=r.pollingInfoByQueryId.get(t);e&&(clearTimeout(e.timeout),e.timeout=setTimeout(s,e.interval))};i&&this.addQueryListener(t,i),a()}return t},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e}(),NS=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,i,r,n){void 0===n&&(n=!1);var o=!CA(e);n&&CA(e)&&e.data&&(o=!0),!r&&o&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:i})},e.prototype.markSubscriptionResult=function(e,t,i){CA(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:i})},e.prototype.markMutationInit=function(e){var t,i=this;e.optimisticResponse&&(t="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse,this.cache.recordOptimisticTransaction((function(r){var n=i.cache;i.cache=r;try{i.markMutationResult({mutationId:e.mutationId,result:{data:t},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{i.cache=n}}),e.mutationId))},e.prototype.markMutationResult=function(e){var t=this;if(!CA(e.result)){var i=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],r=e.updateQueries;r&&Object.keys(r).forEach((function(n){var o=r[n],s=o.query,a=o.updater,c=t.cache.diff({query:s.document,variables:s.variables,returnPartialData:!0,optimistic:!1}),h=c.result;if(c.complete){var u=TA((function(){return a(h,{mutationResult:e.result,queryName:aA(s.document)||void 0,queryVariables:s.variables})}));u&&i.push({result:u,dataId:"ROOT_QUERY",query:s.document,variables:s.variables})}})),this.cache.performTransaction((function(t){i.forEach((function(e){return t.write(e)}));var r=e.update;r&&TA((function(){return r(t,e.result)}))}))}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,i){this.cache.write({result:i,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),PS=!1,RS=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var i=e.cache,r=e.ssrMode,n=void 0!==r&&r,o=e.ssrForceFetchDelay,s=void 0===o?0:o,a=e.connectToDevTools,c=e.queryDeduplication,h=void 0===c||c,u=e.defaultOptions,l=e.assumeImmutableResults,p=void 0!==l&&l,d=e.resolvers,f=e.typeDefs,m=e.fragmentMatcher,g=e.name,v=e.version,_=e.link;if(!_&&d&&(_=WA.empty()),!_||!i)throw"production"===process.env.NODE_ENV?new Aw(4):new Aw("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\nThese options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\nFor more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup");this.link=_,this.cache=i,this.store=new NS(i),this.disableNetworkFetches=n||s>0,this.queryDeduplication=h,this.defaultOptions=u||{},this.typeDefs=f,s&&setTimeout((function(){return t.disableNetworkFetches=!1}),s),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);var y="production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===a?y:a&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),PS||"production"===process.env.NODE_ENV||(PS=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&void 0===window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("Chrome")>-1&&console.debug("Download the Apollo DevTools for a better development experience: https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm")),this.version="2.6.10",this.localState=new ES({cache:i,client:this,resolvers:d,fragmentMatcher:m}),this.queryManager=new IS({link:this.link,store:this.store,queryDeduplication:h,ssrMode:n,clientAwareness:{name:g,version:v},localState:this.localState,assumeImmutableResults:p,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=dv(dv({},this.defaultOptions.watchQuery),e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=dv(dv({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=dv(dv({},this.defaultOptions.query),e)),"production"===process.env.NODE_ENV?Sw("cache-and-network"!==e.fetchPolicy,5):Sw("cache-and-network"!==e.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=dv(dv({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=dv(dv({},this.defaultOptions.mutate),e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return QA(this.link,e)},e.prototype.initQueryManager=function(){return"production"===process.env.NODE_ENV||Sw.warn("Calling the initQueryManager method is no longer necessary, and it will be removed from ApolloClient in version 3.0."),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();function OS(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:DS(e)}]}}function DS(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return DS(e[0]);var t=[];return Object.keys(e).forEach((function(i){var r={kind:"Field",name:{kind:"Name",value:i},selectionSet:DS(e[i])||void 0};t.push(r)})),{kind:"SelectionSet",selections:t}}var LS={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},kS=function(){function e(){}return e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.read({query:rA(e.fragment,e.fragmentName),variables:e.variables,rootId:e.id,optimistic:t})},e.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},e.prototype.writeFragment=function(e){this.write({dataId:e.id,result:e.data,variables:e.variables,query:rA(e.fragment,e.fragmentName)})},e.prototype.writeData=function(e){var t,i,r=e.id,n=e.data;if(void 0!==r){var o=null;try{o=this.read({rootId:r,optimistic:!1,query:LS})}catch(e){}var s=o&&o.__typename||"__ClientData",a=Object.assign({__typename:s},n);this.writeFragment({id:r,fragment:(t=a,i=s,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:i||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:DS(t)}]}),data:a})}else this.writeQuery({query:OS(n),data:n})},e}(),BS=null,FS={},jS=1,zS="@wry/context:Slot",$S=Array,VS=$S[zS]||function(){var e=function(){function e(){this.id=["slot",jS++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=BS;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===FS)break;return e!==BS&&(BS.slots[this.id]=t),!0}return BS&&(BS.slots[this.id]=FS),!1},e.prototype.getValue=function(){if(this.hasValue())return BS.slots[this.id]},e.prototype.withValue=function(e,t,i,r){var n,o=((n={__proto__:null})[this.id]=e,n),s=BS;BS={parent:s,slots:o};try{return t.apply(r,i)}finally{BS=s}},e.bind=function(e){var t=BS;return function(){var i=BS;try{return BS=t,e.apply(this,arguments)}finally{BS=i}}},e.noContext=function(e,t,i){if(!BS)return e.apply(i,t);var r=BS;try{return BS=null,e.apply(i,t)}finally{BS=r}},e}();try{Object.defineProperty($S,zS,{value:$S[zS]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();function US(){}VS.bind,VS.noContext;var GS=function(){function e(e,t){void 0===e&&(e=1/0),void 0===t&&(t=US),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.get=function(e){var t=this.getEntry(e);return t&&t.value},e.prototype.getEntry=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var i=t.older,r=t.newer;r&&(r.older=i),i&&(i.newer=r),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=r)}return t},e.prototype.set=function(e,t){var i=this.getEntry(e);return i?i.value=t:(i={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=i),this.newest=i,this.oldest=this.oldest||i,this.map.set(e,i),i.value)},e.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),HS=new VS,qS=[],WS=[];function QS(e,t){if(!e)throw new Error(t||"assertion failure")}function YS(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var XS=function(){function e(t,i){this.fn=t,this.args=i,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],++e.count}return e.prototype.recompute=function(){if(QS(!this.recomputing,"already recomputing"),function(e){var t=HS.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),KS(e)?tM(t,e):iM(t,e),t}(this)||!nM(this))return KS(this)?function(e){var t=oM(e);HS.withValue(e,ZS,[e]),function(e){if("function"==typeof e.subscribe)try{aM(e),e.unsubscribe=e.subscribe.apply(null,e.args)}catch(t){return e.setDirty(),!1}return!0}(e)&&function(e){if(e.dirty=!1,KS(e))return;eM(e)}(e);return t.forEach(nM),YS(e.value)}(this):YS(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,JS(this),aM(this))},e.prototype.dispose=function(){var e=this;oM(this).forEach(nM),aM(this),this.parents.forEach((function(t){t.setDirty(),sM(t,e)}))},e.count=0,e}();function ZS(e){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,e.args)}catch(t){e.value[1]=t}e.recomputing=!1}function KS(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function JS(e){e.parents.forEach((function(t){return tM(t,e)}))}function eM(e){e.parents.forEach((function(t){return iM(t,e)}))}function tM(e,t){if(QS(e.childValues.has(t)),QS(KS(t)),e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=WS.pop()||new Set;e.dirtyChildren.add(t),JS(e)}function iM(e,t){QS(e.childValues.has(t)),QS(!KS(t));var i,r,n,o=e.childValues.get(t);0===o.length?e.childValues.set(t,t.value.slice(0)):(i=o,r=t.value,(n=i.length)>0&&n===r.length&&i[n-1]===r[n-1]||e.setDirty()),rM(e,t),KS(e)||eM(e)}function rM(e,t){var i=e.dirtyChildren;i&&(i.delete(t),0===i.size&&(WS.length<100&&WS.push(i),e.dirtyChildren=null))}function nM(e){return 0===e.parents.size&&"function"==typeof e.reportOrphan&&!0===e.reportOrphan()}function oM(e){var t=qS;return e.childValues.size>0&&(t=[],e.childValues.forEach((function(i,r){sM(e,r),t.push(r)}))),QS(null===e.dirtyChildren),t}function sM(e,t){t.parents.delete(e),e.childValues.delete(t),rM(e,t)}function aM(e){var t=e.unsubscribe;"function"==typeof t&&(e.unsubscribe=void 0,t())}var cM=function(){function e(e){this.weakness=e}return e.prototype.lookup=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.lookupArray(e)},e.prototype.lookupArray=function(e){var t=this;return e.forEach((function(e){return t=t.getChildTrie(e)})),t.data||(t.data=Object.create(null))},e.prototype.getChildTrie=function(t){var i=this.weakness&&function(e){switch(typeof e){case"object":if(null===e)break;case"function":return!0}return!1}(t)?this.weak||(this.weak=new WeakMap):this.strong||(this.strong=new Map),r=i.get(t);return r||i.set(t,r=new e(this.weakness)),r},e}();var hM=new cM("function"==typeof WeakMap);function uM(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return hM.lookupArray(e)}var lM=new Set;function pM(e,t){void 0===t&&(t=Object.create(null));var i=new GS(t.max||Math.pow(2,16),(function(e){return e.dispose()})),r=!!t.disposable,n=t.makeCacheKey||uM;function o(){if(!r||HS.hasValue()){var o=n.apply(null,arguments);if(void 0===o)return e.apply(null,arguments);var s=Array.prototype.slice.call(arguments),a=i.get(o);a?a.args=s:(a=new XS(e,s),i.set(o,a),a.subscribe=t.subscribe,r&&(a.reportOrphan=function(){return i.delete(o)}));var c=a.recompute();return i.set(o,a),lM.add(i),HS.hasValue()||(lM.forEach((function(e){return e.clean()})),lM.clear()),r?void 0:c}}return o.dirty=function(){var e=n.apply(null,arguments),t=void 0!==e&&i.get(e);t&&t.setDirty()},o}var dM=!1;function fM(){var e=!dM;return EA()||(dM=!0),e}var mM=function(){function e(){}return e.prototype.ensureReady=function(){return Promise.resolve()},e.prototype.canBypassInit=function(){return!0},e.prototype.match=function(e,t,i){var r=i.store.get(e.id),n="ROOT_QUERY"===e.id;if(!r)return n;var o=r.__typename,s=void 0===o?n&&"Query":o;return s?s===t||(fM()&&("production"===process.env.NODE_ENV||Sw.error("You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types. Apollo Client will not be able to accurately map fragments. To make this error go away, use the `IntrospectionFragmentMatcher` as described in the docs: https://www.apollographql.com/docs/react/advanced/fragments.html#fragment-matcher")),"heuristic"):(fM()&&("production"===process.env.NODE_ENV||Sw.warn("You're using fragments in your queries, but either don't have the addTypename:\n true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename.\n Please turn on the addTypename option and include __typename when writing fragments so that Apollo Client\n can accurately match fragments."),"production"===process.env.NODE_ENV||Sw.warn("Could not find __typename on Fragment ",t,r),"production"===process.env.NODE_ENV||Sw.warn("DEPRECATION WARNING: using fragments without __typename is unsupported behavior and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.")),"heuristic")},e}(),gM=Object.prototype.hasOwnProperty,vM=function(){function e(e){var t=this;void 0===e&&(e=Object.create(null)),this.data=e,this.depend=pM((function(e){return t.data[e]}),{disposable:!0,makeCacheKey:function(e){return e}})}return e.prototype.toObject=function(){return this.data},e.prototype.get=function(e){return this.depend(e),this.data[e]},e.prototype.set=function(e,t){t!==this.data[e]&&(this.data[e]=t,this.depend.dirty(e))},e.prototype.delete=function(e){gM.call(this.data,e)&&(delete this.data[e],this.depend.dirty(e))},e.prototype.clear=function(){this.replace(null)},e.prototype.replace=function(e){var t=this;e?(Object.keys(e).forEach((function(i){t.set(i,e[i])})),Object.keys(this.data).forEach((function(i){gM.call(e,i)||t.delete(i)}))):Object.keys(this.data).forEach((function(e){t.delete(e)}))},e}();function _M(e){return new vM(e)}var yM=function(){function e(e){var t=this,i=void 0===e?{}:e,r=i.cacheKeyRoot,n=void 0===r?new cM(xA):r,o=i.freezeResults,s=void 0!==o&&o,a=this,c=a.executeStoreQuery,h=a.executeSelectionSet,u=a.executeSubSelectedArray;this.freezeResults=s,this.executeStoreQuery=pM((function(e){return c.call(t,e)}),{makeCacheKey:function(e){var t=e.query,i=e.rootValue,r=e.contextValue,o=e.variableValues,s=e.fragmentMatcher;if(r.store instanceof vM)return n.lookup(r.store,t,s,JSON.stringify(o),i.id)}}),this.executeSelectionSet=pM((function(e){return h.call(t,e)}),{makeCacheKey:function(e){var t=e.selectionSet,i=e.rootValue,r=e.execContext;if(r.contextValue.store instanceof vM)return n.lookup(r.contextValue.store,t,r.fragmentMatcher,JSON.stringify(r.variableValues),i.id)}}),this.executeSubSelectedArray=pM((function(e){return u.call(t,e)}),{makeCacheKey:function(e){var t=e.field,i=e.array,r=e.execContext;if(r.contextValue.store instanceof vM)return n.lookup(r.contextValue.store,t,i,JSON.stringify(r.variableValues))}})}return e.prototype.readQueryFromStore=function(e){return this.diffQueryAgainstStore(dv(dv({},e),{returnPartialData:!1})).result},e.prototype.diffQueryAgainstStore=function(e){var t,i=e.store,r=e.query,n=e.variables,o=e.previousResult,s=e.returnPartialData,a=void 0===s||s,c=e.rootId,h=void 0===c?"ROOT_QUERY":c,u=e.fragmentMatcherFunction,l=e.config;n=nA({},lA((t=sA(r),"production"===process.env.NODE_ENV?Sw(t&&"query"===t.operation,6):Sw(t&&"query"===t.operation,"Must contain a query definition."),t)),n);var p={store:i,dataIdFromObject:l&&l.dataIdFromObject,cacheRedirects:l&&l.cacheRedirects||{}},d=this.executeStoreQuery({query:r,rootValue:{type:"id",id:h,generated:!0,typename:"Query"},contextValue:p,variableValues:n,fragmentMatcher:u}),f=d.missing&&d.missing.length>0;return f&&!a&&d.missing.forEach((function(e){if(!e.tolerable)throw"production"===process.env.NODE_ENV?new Aw(8):new Aw("Can't find field "+e.fieldName+" on object "+JSON.stringify(e.object,null,2)+".")})),o&&zw(o,d.result)&&(d.result=o),{result:d.result,complete:!f}},e.prototype.executeStoreQuery=function(e){var t=e.query,i=e.rootValue,r=e.contextValue,n=e.variableValues,o=e.fragmentMatcher,s=void 0===o?xM:o,a=hA(t),c={query:t,fragmentMap:uA(cA(t)),contextValue:r,variableValues:n,fragmentMatcher:s};return this.executeSelectionSet({selectionSet:a.selectionSet,rootValue:i,execContext:c})},e.prototype.executeSelectionSet=function(e){var t=this,i=e.selectionSet,r=e.rootValue,n=e.execContext,o=n.fragmentMap,s=n.contextValue,a=n.variableValues,c={result:null},h=[],u=s.store.get(r.id),l=u&&u.__typename||"ROOT_QUERY"===r.id&&"Query"||void 0;function p(e){var t;return e.missing&&(c.missing=c.missing||[],(t=c.missing).push.apply(t,e.missing)),e.result}return i.selections.forEach((function(e){var i;if(Jw(e,a))if(Qw(e)){var c=p(t.executeField(u,l,e,n));void 0!==c&&h.push(((i={})[Ww(e)]=c,i))}else{var d=void 0;if(Yw(e))d=e;else if(!(d=o[e.name.value]))throw"production"===process.env.NODE_ENV?new Aw(9):new Aw("No fragment named "+e.name.value);var f=d.typeCondition&&d.typeCondition.name.value,m=!f||n.fragmentMatcher(r,f,s);if(m){var g=t.executeSelectionSet({selectionSet:d.selectionSet,rootValue:r,execContext:n});"heuristic"===m&&g.missing&&(g=dv(dv({},g),{missing:g.missing.map((function(e){return dv(dv({},e),{tolerable:!0})}))})),h.push(p(g))}}})),c.result=OA(h),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(c.result),c},e.prototype.executeField=function(e,t,i,r){var n=r.variableValues,o=r.contextValue,s=function(e,t,i,r,n,o){o.resultKey;var s=o.directives,a=i;(r||s)&&(a=Hw(a,r,s));var c=void 0;if(e&&void 0===(c=e[a])&&n.cacheRedirects&&"string"==typeof t){var h=n.cacheRedirects[t];if(h){var u=h[i];u&&(c=u(e,r,{getCacheKey:function(e){var t=n.dataIdFromObject(e);return t&&Zw({id:t,typename:e.__typename})}}))}}if(void 0===c)return{result:c,missing:[{object:e,fieldName:a,tolerable:!1}]};l=c,null!=l&&"object"==typeof l&&"json"===l.type&&(c=c.json);var l;return{result:c}}(e,t,i.name.value,qw(i,n),o,{resultKey:Ww(i),directives:Kw(i,n)});return Array.isArray(s.result)?this.combineExecResults(s,this.executeSubSelectedArray({field:i,array:s.result,execContext:r})):i.selectionSet?null==s.result?s:this.combineExecResults(s,this.executeSelectionSet({selectionSet:i.selectionSet,rootValue:s.result,execContext:r})):(bM(i,s.result),this.freezeResults&&"production"!==process.env.NODE_ENV&&NA(s),s)},e.prototype.combineExecResults=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return t.forEach((function(t){t.missing&&(e=e||[]).push.apply(e,t.missing)})),{result:t.pop().result,missing:e}},e.prototype.executeSubSelectedArray=function(e){var t,i=this,r=e.field,n=e.array,o=e.execContext;function s(e){return e.missing&&(t=t||[]).push.apply(t,e.missing),e.result}return n=n.map((function(e){return null===e?null:Array.isArray(e)?s(i.executeSubSelectedArray({field:r,array:e,execContext:o})):r.selectionSet?s(i.executeSelectionSet({selectionSet:r.selectionSet,rootValue:e,execContext:o})):(bM(r,e),e)})),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(n),{result:n,missing:t}},e}();function bM(e,t){if(!e.selectionSet&&Xw(t))throw"production"===process.env.NODE_ENV?new Aw(10):new Aw("Missing selection set for object of type "+t.typename+" returned for query field "+e.name.value)}function xM(){return!0}var wM=function(){function e(e){void 0===e&&(e=Object.create(null)),this.data=e}return e.prototype.toObject=function(){return this.data},e.prototype.get=function(e){return this.data[e]},e.prototype.set=function(e,t){this.data[e]=t},e.prototype.delete=function(e){this.data[e]=void 0},e.prototype.clear=function(){this.data=Object.create(null)},e.prototype.replace=function(e){this.data=e||Object.create(null)},e}(),AM=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="WriteError",t}return pv(t,e),t}(Error);var SM=function(){function e(){}return e.prototype.writeQueryToStore=function(e){var t=e.query,i=e.result,r=e.store,n=void 0===r?_M():r,o=e.variables,s=e.dataIdFromObject,a=e.fragmentMatcherFunction;return this.writeResultToStore({dataId:"ROOT_QUERY",result:i,document:t,store:n,variables:o,dataIdFromObject:s,fragmentMatcherFunction:a})},e.prototype.writeResultToStore=function(e){var t=e.dataId,i=e.result,r=e.document,n=e.store,o=void 0===n?_M():n,s=e.variables,a=e.dataIdFromObject,c=e.fragmentMatcherFunction,h=sA(r);try{return this.writeSelectionSetToStore({result:i,dataId:t,selectionSet:h.selectionSet,context:{store:o,processedData:{},variables:nA({},lA(h),s),dataIdFromObject:a,fragmentMap:uA(cA(r)),fragmentMatcherFunction:c}})}catch(e){throw function(e,t){var i=new AM("Error writing result to store for query:\n "+JSON.stringify(t));return i.message+="\n"+e.message,i.stack=e.stack,i}(e,r)}},e.prototype.writeSelectionSetToStore=function(e){var t=this,i=e.result,r=e.dataId,n=e.selectionSet,o=e.context,s=o.variables,a=o.store,c=o.fragmentMap;return n.selections.forEach((function(e){var n;if(Jw(e,s))if(Qw(e)){var a=Ww(e),h=i[a];if(void 0!==h)t.writeFieldToStore({dataId:r,value:h,field:e,context:o});else{var u=!1,l=!1;e.directives&&e.directives.length&&(u=e.directives.some((function(e){return e.name&&"defer"===e.name.value})),l=e.directives.some((function(e){return e.name&&"client"===e.name.value}))),u||l||!o.fragmentMatcherFunction||"production"===process.env.NODE_ENV||Sw.warn("Missing field "+a+" in "+JSON.stringify(i,null,2).substring(0,100))}}else{var p=void 0;Yw(e)?p=e:(p=(c||{})[e.name.value],"production"===process.env.NODE_ENV?Sw(p,3):Sw(p,"No fragment named "+e.name.value+"."));var d=!0;if(o.fragmentMatcherFunction&&p.typeCondition){var f=r||"self",m=Zw({id:f,typename:void 0}),g={store:new wM((n={},n[f]=i,n)),cacheRedirects:{}},v=o.fragmentMatcherFunction(m,p.typeCondition.name.value,g);!0!==MA("production")&&"heuristic"===v&&("production"===process.env.NODE_ENV||Sw.error("WARNING: heuristic fragment matching going on!")),d=!!v}d&&t.writeSelectionSetToStore({result:i,selectionSet:p.selectionSet,dataId:r,context:o})}})),a},e.prototype.writeFieldToStore=function(e){var t,i,r,n=e.field,o=e.value,s=e.dataId,a=e.context,c=a.variables,h=a.dataIdFromObject,u=a.store,l=function(e,t){var i=null;e.directives&&(i={},e.directives.forEach((function(e){i[e.name.value]={},e.arguments&&e.arguments.forEach((function(r){var n=r.name,o=r.value;return Uw(i[e.name.value],n,o,t)}))})));var r=null;return e.arguments&&e.arguments.length&&(r={},e.arguments.forEach((function(e){var i=e.name,n=e.value;return Uw(r,i,n,t)}))),Hw(e.name.value,r,i)}(n,c);if(n.selectionSet&&null!==o)if(Array.isArray(o)){var p=s+"."+l;i=this.processArrayValue(o,p,n.selectionSet,a)}else{var d=s+"."+l,f=!0;if(MM(d)||(d="$"+d),h){var m=h(o);"production"===process.env.NODE_ENV?Sw(!m||!MM(m),4):Sw(!m||!MM(m),'IDs returned by dataIdFromObject cannot begin with the "$" character.'),(m||"number"==typeof m&&0===m)&&(d=m,f=!1)}TM(d,n,a.processedData)||this.writeSelectionSetToStore({dataId:d,result:o,selectionSet:n.selectionSet,context:a});var g=o.__typename;i=Zw({id:d,typename:g},f);var v=(r=u.get(s))&&r[l];if(v!==i&&Xw(v)){var _=void 0!==v.typename,y=void 0!==g,b=_&&y&&v.typename!==g;"production"===process.env.NODE_ENV?Sw(!f||v.generated||b,5):Sw(!f||v.generated||b,"Store error: the application attempted to write an object with no provided id but the store already contains an id of "+v.id+" for this object. The selectionSet that was trying to be written is:\n"+JSON.stringify(n)),"production"===process.env.NODE_ENV?Sw(!_||y,6):Sw(!_||y,"Store error: the application attempted to write an object with no provided typename but the store already contains an object with typename of "+v.typename+" for the object of id "+v.id+". The selectionSet that was trying to be written is:\n"+JSON.stringify(n)),v.generated&&(b?f||u.delete(v.id):EM(v.id,i.id,u))}}else i=null!=o&&"object"==typeof o?{type:"json",json:o}:o;(r=u.get(s))&&zw(i,r[l])||u.set(s,dv(dv({},r),((t={})[l]=i,t)))},e.prototype.processArrayValue=function(e,t,i,r){var n=this;return e.map((function(e,o){if(null===e)return null;var s=t+"."+o;if(Array.isArray(e))return n.processArrayValue(e,s,i,r);var a=!0;if(r.dataIdFromObject){var c=r.dataIdFromObject(e);c&&(s=c,a=!1)}return TM(s,i,r.processedData)||n.writeSelectionSetToStore({dataId:s,result:e,selectionSet:i,context:r}),Zw({id:s,typename:e.__typename},a)}))},e}();function MM(e){return"$"===e[0]}function EM(e,t,i){if(e===t)return!1;var r=i.get(e),n=i.get(t),o=!1;Object.keys(r).forEach((function(e){var t=r[e],s=n[e];Xw(t)&&MM(t.id)&&Xw(s)&&!zw(t,s)&&EM(t.id,s.id,i)&&(o=!0)})),i.delete(e);var s=dv(dv({},r),n);return zw(s,n)?o:(i.set(t,s),!0)}function TM(e,t,i){if(!i)return!1;if(i[e]){if(i[e].indexOf(t)>=0)return!0;i[e].push(t)}else i[e]=[t];return!1}var CM={fragmentMatcher:new mM,dataIdFromObject:function(e){if(e.__typename){if(void 0!==e.id)return e.__typename+":"+e.id;if(void 0!==e._id)return e.__typename+":"+e._id}return null},addTypename:!0,resultCaching:!0,freezeResults:!1};var IM=Object.prototype.hasOwnProperty,NM=function(e){function t(t,i,r){var n=e.call(this,Object.create(null))||this;return n.optimisticId=t,n.parent=i,n.transaction=r,n}return pv(t,e),t.prototype.toObject=function(){return dv(dv({},this.parent.toObject()),this.data)},t.prototype.get=function(e){return IM.call(this.data,e)?this.data[e]:this.parent.get(e)},t}(wM),PM=function(e){function t(t){void 0===t&&(t={});var i=e.call(this)||this;i.watches=new Set,i.typenameDocumentCache=new Map,i.cacheKeyRoot=new cM(xA),i.silenceBroadcast=!1,i.config=dv(dv({},CM),t),i.config.customResolvers&&("production"===process.env.NODE_ENV||Sw.warn("customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version."),i.config.cacheRedirects=i.config.customResolvers),i.config.cacheResolvers&&("production"===process.env.NODE_ENV||Sw.warn("cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version."),i.config.cacheRedirects=i.config.cacheResolvers),i.addTypename=!!i.config.addTypename,i.data=i.config.resultCaching?new vM:new wM,i.optimisticData=i.data,i.storeWriter=new SM,i.storeReader=new yM({cacheKeyRoot:i.cacheKeyRoot,freezeResults:t.freezeResults});var r=i,n=r.maybeBroadcastWatch;return i.maybeBroadcastWatch=pM((function(e){return n.call(i,e)}),{makeCacheKey:function(e){if(!e.optimistic&&!e.previousResult)return r.data instanceof vM?r.cacheKeyRoot.lookup(e.query,JSON.stringify(e.variables)):void 0}}),i}return pv(t,e),t.prototype.restore=function(e){return e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).toObject()},t.prototype.read=function(e){if("string"==typeof e.rootId&&void 0===this.data.get(e.rootId))return null;var t=this.config.fragmentMatcher,i=t&&t.match;return this.storeReader.readQueryFromStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,rootId:e.rootId,fragmentMatcherFunction:i,previousResult:e.previousResult,config:this.config})||null},t.prototype.write=function(e){var t=this.config.fragmentMatcher,i=t&&t.match;this.storeWriter.writeResultToStore({dataId:e.dataId,result:e.result,variables:e.variables,document:this.transformDocument(e.query),store:this.data,dataIdFromObject:this.config.dataIdFromObject,fragmentMatcherFunction:i}),this.broadcastWatches()},t.prototype.diff=function(e){var t=this.config.fragmentMatcher,i=t&&t.match;return this.storeReader.diffQueryAgainstStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,returnPartialData:e.returnPartialData,previousResult:e.previousResult,fragmentMatcherFunction:i,config:this.config})},t.prototype.watch=function(e){var t=this;return this.watches.add(e),function(){t.watches.delete(e)}},t.prototype.evict=function(e){throw"production"===process.env.NODE_ENV?new Aw(7):new Aw("eviction is not implemented on InMemory Cache")},t.prototype.reset=function(){return this.data.clear(),this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){for(var t=[],i=0,r=this.optimisticData;r instanceof NM;)r.optimisticId===e?++i:t.push(r),r=r.parent;if(i>0){for(this.optimisticData=r;t.length>0;){var n=t.pop();this.performTransaction(n.transaction,n.optimisticId)}this.broadcastWatches()}},t.prototype.performTransaction=function(e,t){var i=this.data,r=this.silenceBroadcast;this.silenceBroadcast=!0,"string"==typeof t&&(this.data=this.optimisticData=new NM(t,this.optimisticData,e));try{e(this)}finally{this.silenceBroadcast=r,this.data=i}this.broadcastWatches()},t.prototype.recordOptimisticTransaction=function(e,t){return this.performTransaction(e,t)},t.prototype.transformDocument=function(e){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=Ow(oA(e),{SelectionSet:{enter:function(e,t,i){if(!i||"OperationDefinition"!==i.kind){var r=e.selections;if(r&&!r.some((function(e){return Qw(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var n=i;if(!(Qw(n)&&n.directives&&n.directives.some((function(e){return"export"===e.name.value}))))return dv(dv({},e),{selections:gv(r,[dA])})}}}}}),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},t.prototype.broadcastWatches=function(){var e=this;this.silenceBroadcast||this.watches.forEach((function(t){return e.maybeBroadcastWatch(t)}))},t.prototype.maybeBroadcastWatch=function(e){e.callback(this.diff({query:e.query,variables:e.variables,previousResult:e.previousResult&&e.previousResult(),optimistic:e.optimistic}))},t}(kS);class RM{}class OM{applyToken(e,t,i,r){let n;switch(i){case"IOS":n={appId:e,secret:t,keyPlatform:i,bundleId:r.bundleId};break;case"ANDROID":n={appId:e,secret:t,keyPlatform:i,packageName:r.packageName,sha1:r.sha1};break;default:n={appId:e,secret:t,keyPlatform:i||"WEB",origin:window.location.hostname}}return RM.appId=e,RM.secret=t,RM.bundleId=r.bundleId,RM.packageName=r.packageName,RM.sha1=r.sha1,fetch(Wb.authUrl,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}}class DM{constructor(e){this._token=e}get token(){return this._token}createGraphQL(){const e=new lS({uri:Wb.graphqlModel()}),t=pS((({networkError:e,operation:t,forward:i})=>{if(e&&[401,403].includes(e.statusCode))return new yw((e=>{(new OM).applyToken(RM.appId,RM.secret,RM.keyPlatform,{bundleId:RM.bundleId,packageName:RM.packageName,sha1:RM.sha1}).then((e=>e.json())).then((e=>{this._token=e.result.idToken,this._setTokenToHeader(t)})).then((()=>{i(t).subscribe({next:e.next.bind(e),error:e.error.bind(e),complete:e.complete.bind(e)})}))}))})),i=new WA(((e,t)=>(this._setTokenToHeader(e),t(e)))).concat(t).concat(e);return new RS({link:i,cache:new PM})}_setTokenToHeader(e){e.setContext({headers:{token:this._token}})}}function LM(e,t){if(!Boolean(e))throw new Error(t)}function kM(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,Tw&&(e.prototype[Tw]=t)}function BM(e){return BM="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},BM(e)}function FM(e,t){for(var i,r=/\r\n|[\n\r]/g,n=1,o=t+1;(i=r.exec(e.body))&&i.index<t;)n+=1,o=t+1-(i.index+i[0].length);return{line:n,column:o}}function jM(e){return zM(e.source,FM(e.source,e.start))}function zM(e,t){var i=e.locationOffset.column-1,r=VM(i)+e.body,n=t.line-1,o=e.locationOffset.line-1,s=t.line+o,a=1===t.line?i:0,c=t.column+a,h="".concat(e.name,":").concat(s,":").concat(c,"\n"),u=r.split(/\r\n|[\n\r]/g),l=u[n];if(l.length>120){for(var p=Math.floor(c/80),d=c%80,f=[],m=0;m<l.length;m+=80)f.push(l.slice(m,m+80));return h+$M([["".concat(s),f[0]]].concat(f.slice(1,p+1).map((function(e){return["",e]})),[[" ",VM(d-1)+"^"],["",f[p+1]]]))}return h+$M([["".concat(s-1),u[n-1]],["".concat(s),l],["",VM(c-1)+"^"],["".concat(s+1),u[n+1]]])}function $M(e){var t=e.filter((function(e){return e[0],void 0!==e[1]})),i=Math.max.apply(Math,t.map((function(e){return e[0].length})));return t.map((function(e){var t,r=e[0],n=e[1];return VM(i-(t=r).length)+t+(n?" | "+n:" |")})).join("\n")}function VM(e){return Array(e+1).join(" ")}function UM(e,t,i,r,n,o,s){var a=Array.isArray(t)?0!==t.length?t:void 0:t?[t]:void 0,c=i;if(!c&&a){var h=a[0];c=h&&h.loc&&h.loc.source}var u,l=r;!l&&a&&(l=a.reduce((function(e,t){return t.loc&&e.push(t.loc.start),e}),[])),l&&0===l.length&&(l=void 0),r&&i?u=r.map((function(e){return FM(i,e)})):a&&(u=a.reduce((function(e,t){return t.loc&&e.push(FM(t.loc.source,t.loc.start)),e}),[]));var p,d=s;if(null==d&&null!=o){var f=o.extensions;"object"==BM(p=f)&&null!==p&&(d=f)}Object.defineProperties(this,{message:{value:e,enumerable:!0,writable:!0},locations:{value:u||void 0,enumerable:Boolean(u)},path:{value:n||void 0,enumerable:Boolean(n)},nodes:{value:a||void 0},source:{value:c||void 0},positions:{value:l||void 0},originalError:{value:o},extensions:{value:d||void 0,enumerable:Boolean(d)}}),o&&o.stack?Object.defineProperty(this,"stack",{value:o.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,UM):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}function GM(e,t,i){return new UM("Syntax Error: ".concat(i),void 0,e,[t])}UM.prototype=Object.create(Error.prototype,{constructor:{value:UM},name:{value:"GraphQLError"},toString:{value:function(){return function(e){var t=e.message;if(e.nodes)for(var i=0,r=e.nodes;i<r.length;i++){var n=r[i];n.loc&&(t+="\n\n"+jM(n.loc))}else if(e.source&&e.locations)for(var o=0,s=e.locations;o<s.length;o++){var a=s[o];t+="\n\n"+zM(e.source,a)}return t}(this)}}});var HM=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});var qM,WM=function(e,t,i){this.body=e,this.name=t||"GraphQL request",this.locationOffset=i||{line:1,column:1},this.locationOffset.line>0||LM(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||LM(0,"column in locationOffset is 1-indexed and must be positive")};qM=WM,"function"==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(qM.prototype,Symbol.toStringTag,{get:function(){return this.constructor.name}});var QM=Object.freeze({SOF:"<SOF>",EOF:"<EOF>",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function YM(){return this.lastToken=this.token,this.token=this.lookahead()}function XM(){var e=this.token;if(e.kind!==QM.EOF)do{e=e.next||(e.next=JM(this,e))}while(e.kind===QM.COMMENT);return e}function ZM(e,t,i,r,n,o,s){this.kind=e,this.start=t,this.end=i,this.line=r,this.column=n,this.value=s,this.prev=o,this.next=null}function KM(e){return isNaN(e)?QM.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function JM(e,t){var i=e.source,r=i.body,n=r.length,o=function(e,t,i){var r=e.length,n=t;for(;n<r;){var o=e.charCodeAt(n);if(9===o||32===o||44===o||65279===o)++n;else if(10===o)++n,++i.line,i.lineStart=n;else{if(13!==o)break;10===e.charCodeAt(n+1)?n+=2:++n,++i.line,i.lineStart=n}}return n}(r,t.end,e),s=e.line,a=1+o-e.lineStart;if(o>=n)return new ZM(QM.EOF,n,n,s,a,t);var c=r.charCodeAt(o);switch(c){case 33:return new ZM(QM.BANG,o,o+1,s,a,t);case 35:return function(e,t,i,r,n){var o,s=e.body,a=t;do{o=s.charCodeAt(++a)}while(!isNaN(o)&&(o>31||9===o));return new ZM(QM.COMMENT,t,a,i,r,n,s.slice(t+1,a))}(i,o,s,a,t);case 36:return new ZM(QM.DOLLAR,o,o+1,s,a,t);case 38:return new ZM(QM.AMP,o,o+1,s,a,t);case 40:return new ZM(QM.PAREN_L,o,o+1,s,a,t);case 41:return new ZM(QM.PAREN_R,o,o+1,s,a,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new ZM(QM.SPREAD,o,o+3,s,a,t);break;case 58:return new ZM(QM.COLON,o,o+1,s,a,t);case 61:return new ZM(QM.EQUALS,o,o+1,s,a,t);case 64:return new ZM(QM.AT,o,o+1,s,a,t);case 91:return new ZM(QM.BRACKET_L,o,o+1,s,a,t);case 93:return new ZM(QM.BRACKET_R,o,o+1,s,a,t);case 123:return new ZM(QM.BRACE_L,o,o+1,s,a,t);case 124:return new ZM(QM.PIPE,o,o+1,s,a,t);case 125:return new ZM(QM.BRACE_R,o,o+1,s,a,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,i,r,n){var o=e.body,s=o.length,a=t+1,c=0;for(;a!==s&&!isNaN(c=o.charCodeAt(a))&&(95===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122);)++a;return new ZM(QM.NAME,t,a,i,r,n,o.slice(t,a))}(i,o,s,a,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,i,r,n,o){var s=e.body,a=i,c=t,h=!1;45===a&&(a=s.charCodeAt(++c));if(48===a){if((a=s.charCodeAt(++c))>=48&&a<=57)throw GM(e,c,"Invalid number, unexpected digit after 0: ".concat(KM(a),"."))}else c=eE(e,c,a),a=s.charCodeAt(c);46===a&&(h=!0,a=s.charCodeAt(++c),c=eE(e,c,a),a=s.charCodeAt(c));69!==a&&101!==a||(h=!0,43!==(a=s.charCodeAt(++c))&&45!==a||(a=s.charCodeAt(++c)),c=eE(e,c,a),a=s.charCodeAt(c));if(46===a||69===a||101===a)throw GM(e,c,"Invalid number, expected digit but got: ".concat(KM(a),"."));return new ZM(h?QM.FLOAT:QM.INT,t,c,r,n,o,s.slice(t,c))}(i,o,c,s,a,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,i,r,n,o){var s=e.body,a=t+3,c=a,h=0,u="";for(;a<s.length&&!isNaN(h=s.charCodeAt(a));){if(34===h&&34===s.charCodeAt(a+1)&&34===s.charCodeAt(a+2))return u+=s.slice(c,a),new ZM(QM.BLOCK_STRING,t,a+3,i,r,n,YA(u));if(h<32&&9!==h&&10!==h&&13!==h)throw GM(e,a,"Invalid character within String: ".concat(KM(h),"."));10===h?(++a,++o.line,o.lineStart=a):13===h?(10===s.charCodeAt(a+1)?a+=2:++a,++o.line,o.lineStart=a):92===h&&34===s.charCodeAt(a+1)&&34===s.charCodeAt(a+2)&&34===s.charCodeAt(a+3)?(u+=s.slice(c,a)+'"""',c=a+=4):++a}throw GM(e,a,"Unterminated string.")}(i,o,s,a,t,e):function(e,t,i,r,n){var o=e.body,s=t+1,a=s,c=0,h="";for(;s<o.length&&!isNaN(c=o.charCodeAt(s))&&10!==c&&13!==c;){if(34===c)return h+=o.slice(a,s),new ZM(QM.STRING,t,s+1,i,r,n,h);if(c<32&&9!==c)throw GM(e,s,"Invalid character within String: ".concat(KM(c),"."));if(++s,92===c){switch(h+=o.slice(a,s-1),c=o.charCodeAt(s)){case 34:h+='"';break;case 47:h+="/";break;case 92:h+="\\";break;case 98:h+="\b";break;case 102:h+="\f";break;case 110:h+="\n";break;case 114:h+="\r";break;case 116:h+="\t";break;case 117:var u=tE(o.charCodeAt(s+1),o.charCodeAt(s+2),o.charCodeAt(s+3),o.charCodeAt(s+4));if(u<0){var l=o.slice(s+1,s+5);throw GM(e,s,"Invalid character escape sequence: \\u".concat(l,"."))}h+=String.fromCharCode(u),s+=4;break;default:throw GM(e,s,"Invalid character escape sequence: \\".concat(String.fromCharCode(c),"."))}a=++s}}throw GM(e,s,"Unterminated string.")}(i,o,s,a,t)}throw GM(i,o,function(e){if(e<32&&9!==e&&10!==e&&13!==e)return"Cannot contain the invalid character ".concat(KM(e),".");if(39===e)return"Unexpected single quote character ('), did you mean to use a double quote (\")?";return"Cannot parse the unexpected character ".concat(KM(e),".")}(c))}function eE(e,t,i){var r=e.body,n=t,o=i;if(o>=48&&o<=57){do{o=r.charCodeAt(++n)}while(o>=48&&o<=57);return n}throw GM(e,n,"Invalid number, expected digit but got: ".concat(KM(o),"."))}function tE(e,t,i,r){return iE(e)<<12|iE(t)<<8|iE(i)<<4|iE(r)}function iE(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}kM(ZM,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var rE=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});var nE=function(){function e(e,t){var i="string"==typeof e?new WM(e):e;i instanceof WM||LM(0,"Must provide Source. Received: ".concat(Iw(i))),this._lexer=function(e,t){var i=new ZM(QM.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:i,token:i,line:1,lineStart:0,advance:YM,lookahead:XM}}(i),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(QM.NAME);return{kind:HM.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:HM.DOCUMENT,definitions:this.many(QM.SOF,this.parseDefinition,QM.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(QM.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(QM.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(QM.BRACE_L))return{kind:HM.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,i=this.parseOperationType();return this.peek(QM.NAME)&&(t=this.parseName()),{kind:HM.OPERATION_DEFINITION,operation:i,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(QM.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(QM.PAREN_L,this.parseVariableDefinition,QM.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:HM.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(QM.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(QM.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(QM.DOLLAR),{kind:HM.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:HM.SELECTION_SET,selections:this.many(QM.BRACE_L,this.parseSelection,QM.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(QM.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,i=this._lexer.token,r=this.parseName();return this.expectOptionalToken(QM.COLON)?(e=r,t=this.parseName()):t=r,{kind:HM.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(QM.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(i)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(QM.PAREN_L,t,QM.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(QM.COLON),{kind:HM.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:HM.ARGUMENT,name:this.parseName(),value:(this.expectToken(QM.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(QM.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(QM.NAME)?{kind:HM.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:HM.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:HM.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:HM.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case QM.BRACKET_L:return this.parseList(e);case QM.BRACE_L:return this.parseObject(e);case QM.INT:return this._lexer.advance(),{kind:HM.INT,value:t.value,loc:this.loc(t)};case QM.FLOAT:return this._lexer.advance(),{kind:HM.FLOAT,value:t.value,loc:this.loc(t)};case QM.STRING:case QM.BLOCK_STRING:return this.parseStringLiteral();case QM.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:HM.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:HM.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:HM.ENUM,value:t.value,loc:this.loc(t)});case QM.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:HM.STRING,value:e.value,block:e.kind===QM.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,i=this._lexer.token;return{kind:HM.LIST,values:this.any(QM.BRACKET_L,(function(){return t.parseValueLiteral(e)}),QM.BRACKET_R),loc:this.loc(i)}},t.parseObject=function(e){var t=this,i=this._lexer.token;return{kind:HM.OBJECT,fields:this.any(QM.BRACE_L,(function(){return t.parseObjectField(e)}),QM.BRACE_R),loc:this.loc(i)}},t.parseObjectField=function(e){var t=this._lexer.token,i=this.parseName();return this.expectToken(QM.COLON),{kind:HM.OBJECT_FIELD,name:i,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(QM.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(QM.AT),{kind:HM.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(QM.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(QM.BRACKET_R),e={kind:HM.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(QM.BANG)?{kind:HM.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:HM.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===QM.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(QM.STRING)||this.peek(QM.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),i=this.many(QM.BRACE_L,this.parseOperationTypeDefinition,QM.BRACE_R);return{kind:HM.SCHEMA_DEFINITION,directives:t,operationTypes:i,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(QM.COLON);var i=this.parseNamedType();return{kind:HM.OPERATION_TYPE_DEFINITION,operation:t,type:i,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var i=this.parseName(),r=this.parseDirectives(!0);return{kind:HM.SCALAR_TYPE_DEFINITION,description:t,name:i,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var i=this.parseName(),r=this.parseImplementsInterfaces(),n=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:HM.OBJECT_TYPE_DEFINITION,description:t,name:i,interfaces:r,directives:n,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(QM.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(QM.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(QM.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(QM.BRACE_L)&&this._lexer.lookahead().kind===QM.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(QM.BRACE_L,this.parseFieldDefinition,QM.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),i=this.parseName(),r=this.parseArgumentDefs();this.expectToken(QM.COLON);var n=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:HM.FIELD_DEFINITION,description:t,name:i,arguments:r,type:n,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(QM.PAREN_L,this.parseInputValueDef,QM.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),i=this.parseName();this.expectToken(QM.COLON);var r,n=this.parseTypeReference();this.expectOptionalToken(QM.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:HM.INPUT_VALUE_DEFINITION,description:t,name:i,type:n,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var i=this.parseName(),r=this.parseDirectives(!0),n=this.parseFieldsDefinition();return{kind:HM.INTERFACE_TYPE_DEFINITION,description:t,name:i,directives:r,fields:n,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var i=this.parseName(),r=this.parseDirectives(!0),n=this.parseUnionMemberTypes();return{kind:HM.UNION_TYPE_DEFINITION,description:t,name:i,directives:r,types:n,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(QM.EQUALS)){this.expectOptionalToken(QM.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(QM.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var i=this.parseName(),r=this.parseDirectives(!0),n=this.parseEnumValuesDefinition();return{kind:HM.ENUM_TYPE_DEFINITION,description:t,name:i,directives:r,values:n,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(QM.BRACE_L,this.parseEnumValueDefinition,QM.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),i=this.parseName(),r=this.parseDirectives(!0);return{kind:HM.ENUM_VALUE_DEFINITION,description:t,name:i,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var i=this.parseName(),r=this.parseDirectives(!0),n=this.parseInputFieldsDefinition();return{kind:HM.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:i,directives:r,fields:n,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(QM.BRACE_L,this.parseInputValueDef,QM.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===QM.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),i=this.optionalMany(QM.BRACE_L,this.parseOperationTypeDefinition,QM.BRACE_R);if(0===t.length&&0===i.length)throw this.unexpected();return{kind:HM.SCHEMA_EXTENSION,directives:t,operationTypes:i,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),i=this.parseDirectives(!0);if(0===i.length)throw this.unexpected();return{kind:HM.SCALAR_TYPE_EXTENSION,name:t,directives:i,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),i=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),n=this.parseFieldsDefinition();if(0===i.length&&0===r.length&&0===n.length)throw this.unexpected();return{kind:HM.OBJECT_TYPE_EXTENSION,name:t,interfaces:i,directives:r,fields:n,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),i=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===i.length&&0===r.length)throw this.unexpected();return{kind:HM.INTERFACE_TYPE_EXTENSION,name:t,directives:i,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),i=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===i.length&&0===r.length)throw this.unexpected();return{kind:HM.UNION_TYPE_EXTENSION,name:t,directives:i,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),i=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===i.length&&0===r.length)throw this.unexpected();return{kind:HM.ENUM_TYPE_EXTENSION,name:t,directives:i,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),i=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===i.length&&0===r.length)throw this.unexpected();return{kind:HM.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:i,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(QM.AT);var i=this.parseName(),r=this.parseArgumentDefs(),n=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:HM.DIRECTIVE_DEFINITION,description:t,name:i,arguments:r,repeatable:n,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(QM.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(QM.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==rE[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new oE(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw GM(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(sE(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==QM.NAME||t.value!==e)throw GM(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(sE(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===QM.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return GM(this._lexer.source,t.start,"Unexpected ".concat(sE(t)))},t.any=function(e,t,i){this.expectToken(e);for(var r=[];!this.expectOptionalToken(i);)r.push(t.call(this));return r},t.optionalMany=function(e,t,i){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(i));return r}return[]},t.many=function(e,t,i){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(i));return r},e}();function oE(e,t,i){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=i}function sE(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}kM(oE,(function(){return{start:this.start,end:this.end}}));var aE=Object.freeze({__proto__:null,parse:function(e,t){return new nE(e,t).parseDocument()},parseValue:function(e,t){var i=new nE(e,t);i.expectToken(QM.SOF);var r=i.parseValueLiteral(!1);return i.expectToken(QM.EOF),r},parseType:function(e,t){var i=new nE(e,t);i.expectToken(QM.SOF);var r=i.parseTypeReference();return i.expectToken(QM.EOF),r}}),cE=vf(aE).parse;function hE(e){return e.replace(/[\s,]+/g," ").trim()}var uE={},lE={};var pE=!0;function dE(e,t){var i=Object.prototype.toString.call(e);if("[object Array]"===i)return e.map((function(e){return dE(e,t)}));if("[object Object]"!==i)throw new Error("Unexpected input.");t&&e.loc&&delete e.loc,e.loc&&(delete e.loc.startToken,delete e.loc.endToken);var r,n,o,s=Object.keys(e);for(r in s)s.hasOwnProperty(r)&&(n=e[s[r]],"[object Object]"!==(o=Object.prototype.toString.call(n))&&"[object Array]"!==o||(e[s[r]]=dE(n,!0)));return e}var fE=!1;function mE(e){var t=hE(e);if(uE[t])return uE[t];var i=cE(e,{experimentalFragmentVariables:fE});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");return i=function(e){for(var t,i={},r=[],n=0;n<e.definitions.length;n++){var o=e.definitions[n];if("FragmentDefinition"===o.kind){var s=o.name.value,a=hE((t=o.loc).source.body.substring(t.start,t.end));lE.hasOwnProperty(s)&&!lE[s][a]?(pE&&console.warn("Warning: fragment with name "+s+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"),lE[s][a]=!0):lE.hasOwnProperty(s)||(lE[s]={},lE[s][a]=!0),i[a]||(i[a]=!0,r.push(o))}else r.push(o)}return e.definitions=r,e}(i),i=dE(i,!1),uE[t]=i,i}function gE(){for(var e=Array.prototype.slice.call(arguments),t=e[0],i="string"==typeof t?t:t[0],r=1;r<e.length;r++)e[r]&&e[r].kind&&"Document"===e[r].kind?i+=e[r].loc.source.body:i+=e[r],i+=t[r];return mE(i)}gE.default=gE,gE.resetCaches=function(){uE={},lE={}},gE.disableFragmentWarnings=function(){pE=!1},gE.enableExperimentalFragmentVariables=function(){fE=!0},gE.disableExperimentalFragmentVariables=function(){fE=!1};var vE=gE,_E=["request","uri","credentials","headers","fetch","fetchOptions","clientState","onError","cacheRedirects","cache","name","version","resolvers","typeDefs","fragmentMatcher"];!function(e){function t(t){void 0===t&&(t={});if(t){var i=Object.keys(t).filter((function(e){return-1===_E.indexOf(e)}));i.length>0&&("production"===process.env.NODE_ENV||Sw.warn("ApolloBoost was initialized with unsupported options: "+i.join(" ")))}var r=t.request,n=t.uri,o=t.credentials,s=t.headers,a=t.fetch,c=t.fetchOptions,h=t.clientState,u=t.cacheRedirects,l=t.onError,p=t.name,d=t.version,f=t.resolvers,m=t.typeDefs,g=t.fragmentMatcher,v=t.cache;"production"===process.env.NODE_ENV?Sw(!v||!u,1):Sw(!v||!u,"Incompatible cache configuration. When not providing `cache`, configure the provided instance with `cacheRedirects` instead."),v||(v=u?new PM({cacheRedirects:u}):new PM);var _=pS(l||function(e){var t=e.graphQLErrors,i=e.networkError;t&&t.forEach((function(e){var t=e.message,i=e.locations,r=e.path;return"production"===process.env.NODE_ENV||Sw.warn("[GraphQL error]: Message: "+t+", Location: "+i+", Path: "+r)})),i&&("production"===process.env.NODE_ENV||Sw.warn("[Network error]: "+i))}),y=!!r&&new WA((function(e,t){return new yw((function(i){var n;return Promise.resolve(e).then((function(e){return r(e)})).then((function(){n=t(e).subscribe({next:i.next.bind(i),error:i.error.bind(i),complete:i.complete.bind(i)})})).catch(i.error.bind(i)),function(){n&&n.unsubscribe()}}))})),b=new lS({uri:n||"/graphql",fetch:a,fetchOptions:c||{},credentials:o||"same-origin",headers:s||{}}),x=WA.from([_,y,b].filter((function(e){return!!e}))),w=f,A=m,S=g;return h&&(h.defaults&&v.writeData({data:h.defaults}),w=h.resolvers,A=h.typeDefs,S=h.fragmentMatcher),e.call(this,{cache:v,link:x,name:p,version:d,resolvers:w,typeDefs:A,fragmentMatcher:S})||this}pv(t,e)}(RS);class yE{constructor(e){this._modelCreator=null!=e?e:new DM,this._model=this._modelCreator.createGraphQL(),this._minCount=0,this._maxCount=50,this._date="{\n key\n }",this._sequence="{\n key\n }",this._gpano="{\n CroppedAreaImageHeightPixels\n CroppedAreaImageWidthPixels\n CroppedAreaLeftPixels\n CroppedAreaTopPixels\n FullPanoHeightPixels\n FullPanoWidthPixels\n ProjectionType\n Software\n valid\n }",this._buildingName="{\n default\n en\n cn\n zh\n }",this._building=`{\n id\n name ${this._buildingName}\n }`,this._floor="{\n id\n code\n sequence\n }",this._coordinate="{\n lat\n lon\n }",this._user="{\n username\n }",this._image=`{\n key\n ca\n floor ${this._floor}\n cl ${this._coordinate}\n l ${this._coordinate}\n sequence ${this._sequence}\n filename\n }`,this._queryImages=`{\n key\n sequence ${this._sequence}\n c_rotation\n c_translation\n cl ${this._coordinate}\n l ${this._coordinate}\n building ${this._building}\n floor ${this._floor}\n loop_line\n ca\n captured_at\n height\n width\n orientation\n date\n merge_version\n gpano ${this._gpano}\n merge_cc\n user ${this._user}\n }`,this._querySequences="{\n key\n keys\n }",this._queryOutdoorImages=`{\n key\n outdoorImages ${this._image}\n }`,this._queryBuilding=`{\n key\n images ${this._image}\n }`}imageByKeyFullForOutdoor$(e){const t=`{\n outdoorImages(keys: [${e.map((e=>`"${e?e.trim():""}"`))}])\n ${this._queryImages}\n }`;return this._wrapPromise$(this._model.query({query:vE`${t}`})).pipe(w_((e=>{let t={};return e.data.outdoorImages.forEach((e=>{t[e.key]=e})),t})))}imageByKeyFull$(e){const t=`{\n images(keys: [${e.map((e=>`"${e?e.trim():""}"`))}])\n ${this._queryImages}\n }`;return this._wrapPromise$(this._model.query({query:vE`${t}`})).pipe(w_((e=>{let t={};return e.data.images.forEach((e=>{t[e.key]=e})),t})))}imageByKeyFill$(e){const t=`{\n images(keys: [${e.map((e=>`"${e?e.trim():""}"`))}])\n ${this._queryImages}\n }`;return this._wrapPromise$(this._model.query({query:vE`${t}`})).pipe(w_((e=>{let t={};return e.data.images.forEach((e=>{t[e.key]=e})),t})))}outdoorByBbox$(e,t){const i=`{\n outdoorByBbox(\n ne_lat: ${e.lat},\n ne_lon: ${e.lon},\n sw_lat: ${t.lat},\n sw_lon: ${t.lon}\n )\n ${this._queryOutdoorImages}\n }`;return this._wrapPromise$(this._model.query({query:vE`${i}`})).pipe(w_((e=>e.data.outdoorByBbox)))}outdoorByLatLon$(e,t=5e3,i){let r=`\n from: ${this._minCount},\n to: ${this._maxCount},\n lat: ${e.lat},\n lon: ${e.lon},\n distance: ${t}\n `;i&&(r+=`, date: ${i}`);const n=`{\n outdoor(${r}) ${this._queryOutdoorImages}\n }`;return this._wrapPromise$(this._model.query({query:vE`${n}`})).pipe(w_((e=>e.data.outdoor)))}outdoorImagesByKeys$(e){const t=`{\n outdoorImages(keys: [${e.map((e=>`"${e?e.trim():""}"`))}])\n ${this._image}\n }`;return this._wrapPromise$(this._model.query({query:vE`${t}`})).pipe(w_((e=>e.data.outdoorImages)))}imagesByH$(e,t){const i=`{\n imagesByH(from: ${this._minCount}, to: ${this._maxCount}, lat: ${t.lat}, lon: ${t.lon})\n ${this._queryImages}\n }`;return this._wrapPromise$(this._model.query({query:vE`${i}`})).pipe(w_((t=>{let i={};return i[e]=t.data.imagesByH,i})))}imageCloseTo$(e,t,i,r,n){let o=`\n from: 0, to: 100,\n lat: ${e.lat},\n lon: ${e.lon},\n floorCode: "${t}"\n `;i&&(o+=`, buildingId: "${i}"`),r&&(o+=`, distance: ${r}`),n&&(o+=`, date: ${n}`);const s=`{\n imagesByH(${o}) ${this._queryImages}\n }`;return this._wrapPromise$(this._model.query({query:vE`${s}`})).pipe(w_((e=>nf(e.data.imagesByH))))}datesByKey(e){const t=`{\n dates(key: "${e}")\n ${this._date}\n }`;return this._wrapPromise$(this._model.query({query:vE`${t}`})).pipe(w_((e=>e.data.dates)))}buildingByKey$(e,t){let i=`key: "${e}"`;t&&(i+=`, date: ${t}`);const r=`{\n building(${i})\n ${this._queryBuilding}\n }`;return this._wrapPromise$(this._model.query({query:vE`${r}`})).pipe(w_((e=>e.data.building)))}sequenceByKeyForOutdoor$(e){const t=`{\n outdoorSequences(keys: [${e.map((e=>`"${e.trim()}"`))}])\n ${this._querySequences}\n }`;return this._wrapPromise$(this._model.query({query:vE`${t}`})).pipe(w_((e=>{let t={};return e.data.outdoorSequences.forEach((e=>{t[e.key]=e})),t})))}sequenceByKey$(e){const t=`{\n sequences(keys: [${e.map((e=>`"${e.trim()}"`))}])\n ${this._querySequences}\n }`;return this._wrapPromise$(this._model.query({query:vE`${t}`})).pipe(w_((e=>{let t={};return e.data.sequences.forEach((e=>{t[e.key]=e})),t})))}_wrapPromise$(e){return t=()=>z_(e),new Dv((function(e){var i;try{i=t()}catch(t){return void e.error(t)}return(i?z_(i):i_()).subscribe(e)}));var t}}class bE{constructor(e,t,i,r,n,o){this._api=null!=e?e:new yE,this._imageLoadingService=null!=i?i:new Ux,this._graphService=null!=t?t:new Vx(new $x(this.api),this._imageLoadingService),this._loadingService=null!=r?r:new hx,this._loadingName="navigator",this._stateService=null!=n?n:new Zx,this._cacheService=null!=o?o:new Zb(this._graphService,this._stateService),this._cacheService.start(),this._keyRequested$=new Qv(null),this._movedToKey$=new Qv(null),this._request$=null,this._requestSubscription=null,this._nodeRequestSubscription=null}get api(){return this._api}get graphService(){return this._graphService}get imageLoadingService(){return this._imageLoadingService}get loadingService(){return this._loadingService}get movedToKey$(){return this._movedToKey$}get stateService(){return this._stateService}moveToKey$(e,t){this._abortRequest(`to key ${e}`),this._loadingService.startLoading(this._loadingName),this._stateService.setCurrentDate(t);const i=this._moveToKey$(e,t);return this._makeRequest$(i)}moveDir$(t){this._abortRequest(`in dir ${e.EdgeDirection[t]}`),this._loadingService.startLoading(this._loadingName);const i=this.stateService.currentNode$.pipe(Yy(),$_((i=>([e.EdgeDirection.Next,e.EdgeDirection.Prev].indexOf(t)>-1?i.sequenceEdges$:i.spatialEdges$).pipe(Yy(),w_((e=>{for(let i of e.edges)if(i.data.direction===t)return i.to;return null}))))),$_((e=>null==e?(this._loadingService.stopLoading(this._loadingName),c_(new Error(`Direction (${t}) does not exist for current node.`))):this._moveToKey$(e))));return this._makeRequest$(i)}moveCloseTo$(e,t,i,r,n,o){this._abortRequest(`to lat ${e}, lon ${t}`),this._loadingService.startLoading(this._loadingName);const s=this.api.imageCloseTo$({lat:e,lon:t},i,r,n,o).pipe($_((i=>null==i?(this._loadingService.stopLoading(this._loadingName),c_(new Error(`No image found close to lat ${e}, lon ${t}.`))):this._moveToKey$(i.key,o))));return this._makeRequest$(s)}setFilter$(e){return this._stateService.clearNodes(),this._movedToKey$.pipe(Yy(),$_((t=>null!=t?this._trajectoryKeys$().pipe($_((t=>this._graphService.setFilter$(e).pipe($_((e=>this._cacheKeys$(t)))))),Jy()):this._keyRequested$.pipe(Yy(),$_((t=>null!=t?this._graphService.setFilter$(e).pipe($_((e=>this._graphService.cacheNode$(t)))):this._graphService.setFilter$(e).pipe(w_((e=>{})))))))),w_((e=>{})))}_cacheKeys$(e){return z_(e.map((e=>this._graphService.cacheNode$(e)))).pipe(G_())}_abortRequest(e){null!=this._requestSubscription&&(this._requestSubscription.unsubscribe(),this._requestSubscription=null),null!=this._nodeRequestSubscription&&(this._nodeRequestSubscription.unsubscribe(),this._nodeRequestSubscription=null),null!=this._request$&&(this._request$.error(new Error(`Request aborted by a subsequent request ${e}.`)),this._request$=null)}_makeRequest$(e){return this._request$=new d_(1),this._requestSubscription=this._request$.subscribe(void 0,(e=>{})),this._nodeRequestSubscription=e.subscribe((e=>{this._request$.next(e),this._request$.complete()}),(e=>{this._request$.error(e)})),this._request$}_moveToKey$(e,t){return this._keyRequested$.next(e),this._graphService.cacheNode$(e).pipe(Ly((i=>{this._graphService.cachePath$(e,t),this._graphService.cacheOutdoorPath$(e,t),this._stateService.setNodes([i]),this._movedToKey$.next(i.key)})),qy((()=>{this._loadingService.stopLoading(this._loadingName)})))}_trajectoryKeys$(){return this._stateService.currentState$.pipe(Yy(),w_((e=>e.state.trajectory.map((e=>e.key)))))}}class xE extends Hb{constructor(e){super(),this._authComplete$=new m_,qb.setOptions(e);(new OM).applyToken(e.appId,e.secret,e.keyPlatform,{bundleId:e.bundleId,packageName:e.packageName,sha1:e.sha1}).then((e=>e.json())).then((t=>{const i=t.result.idToken,r=new DM(i);this._api=new yE(r),this._navigator=new bE(this._api),this._container=new ox(e.container,this._navigator.stateService,e),this._observer=new cx(this,this._navigator,this._container),this._componentController=new Jb(this._container,this._navigator,this._observer,e.imageId,e.component),this._authComplete$.next(e.imageId),this._authComplete$.complete()}))}get isNavigable(){return this._componentController.navigable}renderComplete(e){this._authComplete$.pipe($_((e=>e?this._observer.navigable$:a_("complete")))).subscribe((()=>e()))}searchOutdoorImageByBbox(e,t,i,r){const n={lat:e,lon:t},o={lat:i,lon:r},s=this._api.outdoorByBbox$(n,o).pipe(w_((e=>{let t=[];return e.forEach((e=>t=t.concat(e.outdoorImages))),t})),$_((e=>a_(e))));return new Promise(((e,t)=>{s.subscribe((t=>{e(t)}),(e=>{t(e)}))}))}searchOutdoorByBbox(e,t,i,r){const n={lat:e,lon:t},o={lat:i,lon:r},s=this._api.outdoorByBbox$(n,o);return new Promise(((e,t)=>{s.subscribe((t=>{e(t)}),(e=>{t(e)}))}))}searchBuildingsById(e,t){const i=this._api.buildingByKey$(e,t);return new Promise(((e,t)=>{i.subscribe((t=>{e(t)}),(e=>{t(e)}))}))}searchDatesByBuildingId(e){const t=this._api.datesByKey(e);return new Promise(((e,i)=>{t.subscribe((t=>{e(t)}),(e=>{i(e)}))}))}activateComponent(e){this._componentController.activate(e)}activateCover(){this._componentController.activateCover()}deactivateComponent(e){this._componentController.deactivate(e)}deactivateCover(){this._componentController.deactivateCover()}getFieldOfView(){return new Promise(((e,t)=>{this._container.renderService.renderCamera$.pipe(Yy()).subscribe((t=>{e(t.perspective.fov)}),(e=>{t(e)}))}))}getImage(){return new Promise(((e,t)=>{this._navigator.stateService.currentNode$.pipe(Yy()).subscribe((t=>{e(t)}),(e=>{t(e)}))}))}getPointOfView(){return new Promise(((e,t)=>{B_([this._container.renderService.renderCamera$,this._container.renderService.bearing$]).pipe(Yy()).subscribe((([t,i])=>{e({bearing:i,tilt:t.getTilt()})}),(e=>{t(e)}))}))}getPosition(){return new Promise(((e,t)=>{B_([this._container.renderService.renderCamera$,this._navigator.stateService.reference$]).pipe(Yy()).subscribe((([t,i])=>{e(this._observer.projection.cameraToLngLat(t,i))}),(e=>{t(e)}))}))}getBearing(){return new Promise(((e,t)=>{this._container.renderService.bearing$.pipe(Yy()).subscribe((t=>{e(t)}),(e=>{t(e)}))}))}getCenter(){return new Promise(((e,t)=>{this._navigator.stateService.getCenter().subscribe((t=>{e(t)}),(e=>{t(e)}))}))}getComponent(e){return this._componentController.get(e)}getContainer(){return this._container.element}getZoom(){return new Promise(((e,t)=>{this._navigator.stateService.getZoom().subscribe((t=>{e(t)}),(e=>{t(e)}))}))}moveCloseTo(e,t,i,r,n,o){const s=this.isNavigable?this._navigator.moveCloseTo$(e,t,i,r,n,o):c_(new Error("Calling moveCloseTo is not supported when viewer is not navigable."));return new Promise(((e,t)=>{s.subscribe((t=>{e(t)}),(e=>{t(e)}))}))}moveDir(e){const t=this.isNavigable?this._navigator.moveDir$(e):c_(new Error("Calling moveDir is not supported when viewer is not navigable."));return new Promise(((e,i)=>{t.subscribe((t=>{e(t)}),(e=>{i(e)}))}))}moveToKey(e,t){const i=this.isNavigable?this._navigator.moveToKey$(e,t):c_(new Error("Calling moveToKey is not supported when viewer is not navigable."));return new Promise(((e,t)=>{i.subscribe((t=>{e(t)}),(e=>{t(e)}))}))}projectFromBasic(e){return new Promise(((t,i)=>{this._observer.projectBasic$(e).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}resize(){this._container.renderService.resize$.next(null),this._componentController.resize()}setCenter(e){this._navigator.stateService.setCenter(e)}setFilter(e){return new Promise(((t,i)=>{this._navigator.setFilter$(e).subscribe((()=>{t(void 0)}),(e=>{i(e)}))}))}setRenderMode(e){this._container.renderService.renderMode$.next(e)}setZoom(e){this._navigator.stateService.setZoom(e)}setBearing(e){let t=setInterval((()=>{this.getBearing().then((i=>{Math.floor(Math.abs(i-e))<15?clearInterval(t):this._navigator.stateService.rotateBasicWithoutInertia([1,0])}))}))}panToWithoutInertia(e){this._navigator.stateService.rotateBasicWithoutInertia(e)}panTo(e){this._navigator.stateService.rotateBasic(e)}unproject(e){return new Promise(((t,i)=>{this._observer.unproject$(e).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}unprojectToBasic(e){return new Promise(((t,i)=>{this._observer.unprojectBasic$(e).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}}xE.fov=ax.fov,xE.position=ax.position,xE.pov=ax.pov,xE.bearingchanged=ax.bearingchanged,xE.panwithoutinertiachanged=ax.panwithoutinertiachanged,xE.panchanged=ax.panchanged,xE.contextmenu=ax.contextmenu,xE.dblclick=ax.dblclick,xE.loadingchanged=ax.loadingchanged,xE.mousedown=ax.mousedown,xE.mousemove=ax.mousemove,xE.mouseout=ax.mouseout,xE.mouseover=ax.mouseover,xE.mouseup=ax.mouseup,xE.moveend=ax.moveend,xE.movestart=ax.movestart,xE.navigablechanged=ax.navigablechanged,xE.nodechanged=ax.nodechanged,xE.sequenceedgeschanged=ax.sequenceedgeschanged,xE.spatialedgeschanged=ax.spatialedgeschanged;class wE extends ju{constructor(e){super(null!=e?e:"The provided geometry value is incorrect"),this.name="GeometryTagError"}}class AE{constructor(){this._notifyChanged$=new zv}get changed$(){return this._notifyChanged$}}class SE extends AE{constructor(e){super();let t=e[0],i=e[1];if(t<0||t>1||i<0||i>1)throw new wE("Basic coordinates must be on the interval [0, 1].");this._point=e.slice()}get point(){return this._point}getCentroid2d(){return this._point.slice()}getCentroid3d(e){return e.unprojectBasic(this._point,200)}setCentroid2d(e,t){let i=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))];this._point[0]=i[0],this._point[1]=i[1],this._notifyChanged$.next(this)}}var ME={exports:{}};function EE(e,t,i){i=i||2;var r,n,o,s,a,c,h,u=t&&t.length,l=u?t[0]*i:e.length,p=TE(e,0,l,i,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(e,t,i,r){var n,o,s,a=[];for(n=0,o=t.length;n<o;n++)(s=TE(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1))===s.next&&(s.steiner=!0),a.push(FE(s));for(a.sort(DE),n=0;n<a.length;n++)LE(a[n],i),i=CE(i,i.next);return i}(e,t,p,i)),e.length>80*i){r=o=e[0],n=s=e[1];for(var f=i;f<l;f+=i)(a=e[f])<r&&(r=a),(c=e[f+1])<n&&(n=c),a>o&&(o=a),c>s&&(s=c);h=0!==(h=Math.max(o-r,s-n))?1/h:0}return IE(p,d,i,r,n,h),d}function TE(e,t,i,r,n){var o,s;if(n===ZE(e,t,i,r)>0)for(o=t;o<i;o+=r)s=QE(o,e[o],e[o+1],s);else for(o=i-r;o>=t;o-=r)s=QE(o,e[o],e[o+1],s);return s&&VE(s,s.next)&&(YE(s),s=s.next),s}function CE(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!VE(r,r.next)&&0!==$E(r.prev,r,r.next))r=r.next;else{if(YE(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function IE(e,t,i,r,n,o,s){if(e){!s&&o&&function(e,t,i,r){var n=e;do{null===n.z&&(n.z=BE(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,s,a,c,h=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t<h&&(a++,r=r.nextZ);t++);for(c=h;a>0||c>0&&r;)0!==a&&(0===c||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,c--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,h*=2}while(s>1)}(n)}(e,r,n,o);for(var a,c,h=e;e.prev!==e.next;)if(a=e.prev,c=e.next,o?PE(e,r,n,o):NE(e))t.push(a.i/i),t.push(e.i/i),t.push(c.i/i),YE(e),e=c.next,h=c.next;else if((e=c)===h){s?1===s?IE(e=RE(CE(e),t,i),t,i,r,n,o,2):2===s&&OE(e,t,i,r,n,o):IE(CE(e),t,i,r,n,o,1);break}}}function NE(e){var t=e.prev,i=e,r=e.next;if($E(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(jE(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&$E(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function PE(e,t,i,r){var n=e.prev,o=e,s=e.next;if($E(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,c=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,h=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,u=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,l=BE(a,c,t,i,r),p=BE(h,u,t,i,r),d=e.prevZ,f=e.nextZ;d&&d.z>=l&&f&&f.z<=p;){if(d!==e.prev&&d!==e.next&&jE(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&$E(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==e.prev&&f!==e.next&&jE(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&$E(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=l;){if(d!==e.prev&&d!==e.next&&jE(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&$E(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==e.prev&&f!==e.next&&jE(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&$E(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function RE(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!VE(n,o)&&UE(n,r,r.next,o)&&qE(n,o)&&qE(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),YE(r),YE(r.next),r=e=o),r=r.next}while(r!==e);return CE(r)}function OE(e,t,i,r,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&zE(s,a)){var c=WE(s,a);return s=CE(s,s.next),c=CE(c,c.next),IE(s,t,i,r,n,o),void IE(c,t,i,r,n,o)}a=a.next}s=s.next}while(s!==e)}function DE(e,t){return e.x-t.x}function LE(e,t){if(t=function(e,t){var i,r=t,n=e.x,o=e.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!i)return null;if(n===s)return i;var c,h=i,u=i.x,l=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=u&&n!==r.x&&jE(o<l?n:s,o,u,l,o<l?s:n,o,r.x,r.y)&&(c=Math.abs(o-r.y)/(n-r.x),qE(r,e)&&(c<p||c===p&&(r.x>i.x||r.x===i.x&&kE(i,r)))&&(i=r,p=c)),r=r.next}while(r!==h);return i}(e,t),t){var i=WE(t,e);CE(t,t.next),CE(i,i.next)}}function kE(e,t){return $E(e.prev,e,t.prev)<0&&$E(t.next,e,e.next)<0}function BE(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function FE(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function jE(e,t,i,r,n,o,s,a){return(n-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function zE(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&UE(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(qE(e,t)&&qE(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&($E(e.prev,e,t.prev)||$E(e,t.prev,t))||VE(e,t)&&$E(e.prev,e,e.next)>0&&$E(t.prev,t,t.next)>0)}function $E(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function VE(e,t){return e.x===t.x&&e.y===t.y}function UE(e,t,i,r){var n=HE($E(e,t,i)),o=HE($E(e,t,r)),s=HE($E(i,r,e)),a=HE($E(i,r,t));return n!==o&&s!==a||(!(0!==n||!GE(e,i,t))||(!(0!==o||!GE(e,r,t))||(!(0!==s||!GE(i,e,r))||!(0!==a||!GE(i,t,r)))))}function GE(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function HE(e){return e>0?1:e<0?-1:0}function qE(e,t){return $E(e.prev,e,e.next)<0?$E(e,t,e.next)>=0&&$E(e,e.prev,t)>=0:$E(e,t,e.prev)<0||$E(e,e.next,t)<0}function WE(e,t){var i=new XE(e.i,e.x,e.y),r=new XE(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function QE(e,t,i,r){var n=new XE(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function YE(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 XE(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ZE(e,t,i,r){for(var n=0,o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}ME.exports=EE,ME.exports.default=EE,EE.deviation=function(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(ZE(e,0,o,i));if(n)for(var a=0,c=t.length;a<c;a++){var h=t[a]*i,u=a<c-1?t[a+1]*i:e.length;s-=Math.abs(ZE(e,h,u,i))}var l=0;for(a=0;a<r.length;a+=3){var p=r[a]*i,d=r[a+1]*i,f=r[a+2]*i;l+=Math.abs((e[p]-e[f])*(e[d+1]-e[p+1])-(e[p]-e[d])*(e[f+1]-e[p+1]))}return 0===s&&0===l?0:Math.abs((l-s)/s)},EE.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},r=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var s=0;s<t;s++)i.vertices.push(e[n][o][s]);n>0&&(r+=e[n-1].length,i.holes.push(r))}return i};var KE={exports:{}};function JE(e,t){return e<t?-1:e>t?1:0}var eT,tT,iT=Object.freeze({__proto__:null,default:class{constructor(e=[],t=JE){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e<r;){let r=1+(e<<1),o=t[r];const s=r+1;if(s<this.length&&i(t[s],o)<0&&(r=s,o=t[s]),i(o,n)>=0)break;t[e]=o,e=r}t[e]=n}}}),rT=vf(iT);function nT(e,t,i){var r,n,o,s;t=t||1;for(var a=0;a<e[0].length;a++){var c=e[0][a];(!a||c[0]<r)&&(r=c[0]),(!a||c[1]<n)&&(n=c[1]),(!a||c[0]>o)&&(o=c[0]),(!a||c[1]>s)&&(s=c[1])}var h=o-r,u=s-n,l=Math.min(h,u),p=l/2;if(0===l){var d=[r,n];return d.distance=0,d}for(var f=new rT(void 0,oT),m=r;m<o;m+=l)for(var g=n;g<s;g+=l)f.push(new sT(m+p,g+p,p,e));var v=function(e){for(var t=0,i=0,r=0,n=e[0],o=0,s=n.length,a=s-1;o<s;a=o++){var c=n[o],h=n[a],u=c[0]*h[1]-h[0]*c[1];i+=(c[0]+h[0])*u,r+=(c[1]+h[1])*u,t+=3*u}return 0===t?new sT(n[0][0],n[0][1],0,e):new sT(i/t,r/t,0,e)}(e),_=new sT(r+h/2,n+u/2,0,e);_.d>v.d&&(v=_);for(var y=f.length;f.length;){var b=f.pop();b.d>v.d&&(v=b,i&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,y)),b.max-v.d<=t||(p=b.h/2,f.push(new sT(b.x-p,b.y-p,p,e)),f.push(new sT(b.x+p,b.y-p,p,e)),f.push(new sT(b.x-p,b.y+p,p,e)),f.push(new sT(b.x+p,b.y+p,p,e)),y+=4)}i&&(console.log("num probes: "+y),console.log("best distance: "+v.d));var x=[v.x,v.y];return x.distance=v.d,x}function oT(e,t){return t.max-e.max}function sT(e,t,i,r){this.x=e,this.y=t,this.h=i,this.d=function(e,t,i){for(var r=!1,n=1/0,o=0;o<i.length;o++)for(var s=i[o],a=0,c=s.length,h=c-1;a<c;h=a++){var u=s[a],l=s[h];u[1]>t!=l[1]>t&&e<(l[0]-u[0])*(t-u[1])/(l[1]-u[1])+u[0]&&(r=!r),n=Math.min(n,aT(e,t,u,l))}return 0===n?0:(r?1:-1)*Math.sqrt(n)}(e,t,r),this.max=this.d+this.h*Math.SQRT2}function aT(e,t,i,r){var n=i[0],o=i[1],s=r[0]-n,a=r[1]-o;if(0!==s||0!==a){var c=((e-n)*s+(t-o)*a)/(s*s+a*a);c>1?(n=r[0],o=r[1]):c>0&&(n+=s*c,o+=a*c)}return(s=e-n)*s+(a=t-o)*a}rT.default&&(rT=rT.default),KE.exports=nT,KE.exports.default=nT;class cT extends AE{constructor(){super()}_getPoleOfInaccessibility2d(e){return KE.exports([e],.03)}_triangulate(e,t,i,r){let n=[e.slice(0,-1)];for(let e of null!=i?i:[])n.push(e.slice(0,-1));let o=t.slice(0,-1);for(let e of null!=r?r:[])o=o.concat(e.slice(0,-1));let s=ME.exports.flatten(n),a=ME.exports(s.vertices,s.holes,s.dimensions),c=[];for(let e=0;e<a.length;++e){let t=o[a[e]];c.push(t[0]),c.push(t[1]),c.push(t[2])}return c}}class hT extends cT{constructor(e){if(super(),e[1]>e[3])throw new wE("Basic Y coordinates values can not be inverted.");for(let t of e)if(t<0||t>1)throw new wE("Basic coordinates must be on the interval [0, 1].");this._anchorIndex=void 0,this._rect=e.slice(0,4),this._inverted=this._rect[0]>this._rect[2]}get anchorIndex(){return this._anchorIndex}get inverted(){return this._inverted}get rect(){return this._rect}initializeAnchorIndexing(e){if(void 0!==this._anchorIndex)throw new Error("Anchor indexing is already initialized.");if(e<0||e>3)throw new Error(`Invalid anchor index: ${e}.`);this._anchorIndex=void 0===e?0:e}terminateAnchorIndexing(){this._anchorIndex=void 0}setOppositeVertex2d(e,t){if(void 0===this._anchorIndex)throw new Error("Anchor indexing needs to be initialized.");const i=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))],r=this._rect.slice(),n=0===this._anchorIndex?[r[0],r[3]]:1===this._anchorIndex?[r[0],r[1]]:2===this._anchorIndex?[r[2],r[1]]:[r[2],r[3]];if(t.fullPano){const e=this._anchorIndex<2?i[0]-r[2]:i[0]-r[0];!this._inverted&&this._anchorIndex<2&&i[0]<.25&&r[2]>.75&&e<-.5||!this._inverted&&this._anchorIndex>=2&&i[0]<.25&&r[2]>.75&&e<-.5?(this._inverted=!0,this._anchorIndex=n[1]>i[1]?0:1):this._inverted&&this._anchorIndex>=2&&i[0]<.25&&r[0]>.75&&e<-.5?(this._inverted=!1,this._anchorIndex=n[0]>i[0]?n[1]>i[1]?3:2:n[1]>i[1]?0:1):!this._inverted&&this._anchorIndex>=2&&i[0]>.75&&r[0]<.25&&e>.5||!this._inverted&&this._anchorIndex<2&&i[0]>.75&&r[0]<.25&&e>.5?(this._inverted=!0,this._anchorIndex=n[1]>i[1]?3:2):this._inverted&&this._anchorIndex<2&&i[0]>.75&&r[2]<.25&&e>.5?(this._inverted=!1,this._anchorIndex=n[0]>i[0]?n[1]>i[1]?3:2:n[1]>i[1]?0:1):this._inverted&&this._anchorIndex<2&&i[0]>r[0]?(this._inverted=!1,this._anchorIndex=n[1]>i[1]?0:1):this._inverted&&this._anchorIndex>=2&&i[0]<r[2]?(this._inverted=!1,this._anchorIndex=n[1]>i[1]?3:2):this._inverted?this._anchorIndex<2?this._anchorIndex=n[1]>i[1]?0:1:this._anchorIndex=n[1]>i[1]?3:2:this._anchorIndex=n[0]<=i[0]&&n[1]>i[1]?0:n[0]<=i[0]&&n[1]<=i[1]?1:n[0]>i[0]&&n[1]<=i[1]?2:3;const t=[];0===this._anchorIndex?(t[0]=n[0],t[1]=i[1],t[2]=i[0],t[3]=n[1]):1===this._anchorIndex?(t[0]=n[0],t[1]=n[1],t[2]=i[0],t[3]=i[1]):2===this._anchorIndex?(t[0]=i[0],t[1]=n[1],t[2]=n[0],t[3]=i[1]):(t[0]=i[0],t[1]=i[1],t[2]=n[0],t[3]=n[1]),(!this._inverted&&t[0]>t[2]||this._inverted&&t[0]<t[2])&&(t[0]=r[0],t[2]=r[2]),t[1]>t[3]&&(t[1]=r[1],t[3]=r[3]),this._rect[0]=t[0],this._rect[1]=t[1],this._rect[2]=t[2],this._rect[3]=t[3]}else{this._anchorIndex=n[0]<=i[0]&&n[1]>i[1]?0:n[0]<=i[0]&&n[1]<=i[1]?1:n[0]>i[0]&&n[1]<=i[1]?2:3;const e=[];0===this._anchorIndex?(e[0]=n[0],e[1]=i[1],e[2]=i[0],e[3]=n[1]):1===this._anchorIndex?(e[0]=n[0],e[1]=n[1],e[2]=i[0],e[3]=i[1]):2===this._anchorIndex?(e[0]=i[0],e[1]=n[1],e[2]=n[0],e[3]=i[1]):(e[0]=i[0],e[1]=i[1],e[2]=n[0],e[3]=n[1]),e[0]>e[2]&&(e[0]=r[0],e[2]=r[2]),e[1]>e[3]&&(e[1]=r[1],e[3]=r[3]),this._rect[0]=e[0],this._rect[1]=e[1],this._rect[2]=e[2],this._rect[3]=e[3]}this._notifyChanged$.next(this)}setVertex2d(e,t,i){let r=this._rect.slice(),n=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))],o=[];if(0===e?(o[0]=n[0],o[1]=r[1],o[2]=r[2],o[3]=n[1]):1===e?(o[0]=n[0],o[1]=n[1],o[2]=r[2],o[3]=r[3]):2===e?(o[0]=r[0],o[1]=n[1],o[2]=n[0],o[3]=r[3]):3===e&&(o[0]=r[0],o[1]=r[1],o[2]=n[0],o[3]=n[1]),i.fullPano){let t=e<2&&n[0]>.75&&r[0]<.25||e>=2&&this._inverted&&n[0]>.75&&r[2]<.25,i=e<2&&this._inverted&&n[0]<.25&&r[0]>.75||e>=2&&n[0]<.25&&r[2]>.75;t||i?this._inverted=!this._inverted:(o[0]-r[0]<-.25&&(o[0]=r[0]),o[2]-r[2]>.25&&(o[2]=r[2])),(!this._inverted&&o[0]>o[2]||this._inverted&&o[0]<o[2])&&(o[0]=r[0],o[2]=r[2])}else o[0]>o[2]&&(o[0]=r[0],o[2]=r[2]);o[1]>o[3]&&(o[1]=r[1],o[3]=r[3]),this._rect[0]=o[0],this._rect[1]=o[1],this._rect[2]=o[2],this._rect[3]=o[3],this._notifyChanged$.next(this)}setCentroid2d(e,t){let i=this._rect.slice(),r=i[0],n=this._inverted?i[2]+1:i[2],o=i[1],s=i[3],a=r+(n-r)/2,c=o+(s-o)/2,h=0;if(null!=t.gpano&&t.gpano.CroppedAreaImageWidthPixels===t.gpano.FullPanoWidthPixels)h=this._inverted?e[0]+1-a:e[0]-a;else{let t=-r,i=1-n;h=Math.max(t,Math.min(i,e[0]-a))}let u=-o,l=1-s,p=Math.max(u,Math.min(l,e[1]-c));this._rect[0]=i[0]+h,this._rect[1]=i[1]+p,this._rect[2]=i[2]+h,this._rect[3]=i[3]+p,this._rect[0]<0?(this._rect[0]+=1,this._inverted=!this._inverted):this._rect[0]>1&&(this._rect[0]-=1,this._inverted=!this._inverted),this._rect[2]<0?(this._rect[2]+=1,this._inverted=!this._inverted):this._rect[2]>1&&(this._rect[2]-=1,this._inverted=!this._inverted),this._notifyChanged$.next(this)}getPoints3d(e){return this._getPoints2d(e).map((t=>e.unprojectBasic(t,200)))}getVertex2d(e){return this._rectToVertices2d(this._rect)[e]}getNonAdjustedVertex2d(e){return this._rectToNonAdjustedVertices2d(this._rect)[e]}getVertex3d(e,t){return t.unprojectBasic(this._rectToVertices2d(this._rect)[e],200)}getVertices2d(){return this._rectToVertices2d(this._rect)}getVertices3d(e){return this._rectToVertices2d(this._rect).map((t=>e.unprojectBasic(t,200)))}getCentroid2d(){const e=this._rect,t=e[0],i=this._inverted?e[2]+1:e[2],r=e[1];return[t+(i-t)/2,r+(e[3]-r)/2]}getCentroid3d(e){const t=this.getCentroid2d();return e.unprojectBasic(t,200)}getPoleOfAccessibility2d(){return this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect))}getPoleOfAccessibility3d(e){let t=this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));return e.unprojectBasic(t,200)}getTriangles3d(e){return this._triangulate(this._rectToVertices2d(this._rect),this.getVertices3d(e))}validate(e){let t=this._rect;return!(!this._inverted&&e[0]<t[0]||e[0]-t[2]>.25||e[1]<t[1])}_getPoints2d(e){let t=this._rectToVertices2d(this._rect),i=t.length-1,r=[];for(let e=0;e<i;++e){let i=t[e][0],n=t[e][1],o=(t[e+1][0]-i)/9,s=(t[e+1][1]-n)/9;for(let e=0;e<10;++e){let t=[i+e*o,n+e*s];r.push(t)}}return r}_rectToVertices2d(e){return[[e[0],e[3]],[e[0],e[1]],[this._inverted?e[2]+1:e[2],e[1]],[this._inverted?e[2]+1:e[2],e[3]],[e[0],e[3]]]}_rectToNonAdjustedVertices2d(e){return[[e[0],e[3]],[e[0],e[1]],[e[2],e[1]],[e[2],e[3]],[e[0],e[3]]]}}class uT extends cT{constructor(e,t){super();let i=e.length;if(i<3)throw new wE("A polygon must have three or more positions.");if(e[0][0]!==e[i-1][0]||e[0][1]!==e[i-1][1])throw new wE("First and last positions must be equivalent.");this._polygon=[];for(let t of e){if(t[0]<0||t[0]>1||t[1]<0||t[1]>1)throw new wE("Basic coordinates of polygon must be on the interval [0, 1].");this._polygon.push(t.slice())}if(this._holes=[],null!=t)for(let e=0;e<t.length;e++){let i=t[e],r=i.length;if(r<3)throw new wE("A polygon hole must have three or more positions.");if(i[0][0]!==i[r-1][0]||i[0][1]!==i[r-1][1])throw new wE("First and last positions of hole must be equivalent.");this._holes.push([]);for(let t of i){if(t[0]<0||t[0]>1||t[1]<0||t[1]>1)throw new wE("Basic coordinates of hole must be on the interval [0, 1].");this._holes[e].push(t.slice())}}}get polygon(){return this._polygon}get holes(){return this._holes}addVertex2d(e){let t=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))];this._polygon.splice(this._polygon.length-1,0,t),this._notifyChanged$.next(this)}getVertex2d(e){return this._polygon[e].slice()}removeVertex2d(e){if(e<0||e>=this._polygon.length||this._polygon.length<4)throw new wE("Index for removed vertex must be valid.");if(e>0&&e<this._polygon.length-1)this._polygon.splice(e,1);else{this._polygon.splice(0,1),this._polygon.pop();let e=this._polygon[0].slice();this._polygon.push(e)}this._notifyChanged$.next(this)}setVertex2d(e,t,i){let r=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))];0===e||e===this._polygon.length-1?(this._polygon[0]=r.slice(),this._polygon[this._polygon.length-1]=r.slice()):this._polygon[e]=r.slice(),this._notifyChanged$.next(this)}setCentroid2d(e,t){let i=this._polygon.map((e=>e[0])),r=this._polygon.map((e=>e[1])),n=Math.min.apply(Math,i),o=Math.max.apply(Math,i),s=Math.min.apply(Math,r),a=Math.max.apply(Math,r),c=this.getCentroid2d(),h=-n,u=1-o,l=-s,p=1-a,d=Math.max(h,Math.min(u,e[0]-c[0])),f=Math.max(l,Math.min(p,e[1]-c[1]));for(let e of this._polygon)e[0]+=d,e[1]+=f;this._notifyChanged$.next(this)}getPoints3d(e){return this.getVertices3d(e)}getVertex3d(e,t){return t.unprojectBasic(this._polygon[e],200)}getVertices2d(){return this._polygon.slice()}getVertices3d(e){return this._polygon.map((t=>e.unprojectBasic(t,200)))}getHoleVertices3d(e){let t=[];for(let i of this._holes){let r=i.map((t=>e.unprojectBasic(t,200)));t.push(r)}return t}getCentroid2d(){let e=this._polygon,t=0,i=0,r=0;for(let n=0;n<e.length-1;n++){let o=e[n][0],s=e[n][1],a=e[n+1][0],c=e[n+1][1],h=o*c-a*s;t+=h,i+=(o+a)*h,r+=(s+c)*h}return t/=2,i/=6*t,r/=6*t,[i,r]}getCentroid3d(e){let t=this.getCentroid2d();return e.unprojectBasic(t,200)}getTriangles3d(e){return this._triangulate(this._polygon,this.getPoints3d(e),this._holes,this.getHoleVertices3d(e))}getPoleOfAccessibility2d(){return this._getPoleOfInaccessibility2d(this._polygon.slice())}getPoleOfAccessibility3d(e){let t=this._getPoleOfInaccessibility2d(this._polygon.slice());return e.unprojectBasic(t,200)}}class lT extends Hb{constructor(e,t){super(),this._id=e,this._geometry=t,this._notifyChanged$=new zv,this._notifyChanged$.subscribe((e=>{this.fire(lT.changed,this)})),this._geometry.changed$.subscribe((e=>{this.fire(lT.geometrychanged,this)}))}get id(){return this._id}get geometry(){return this._geometry}get changed$(){return this._notifyChanged$}get geometryChanged$(){return this._geometry.changed$.pipe(w_((e=>this)),mb())}}lT.changed="changed",lT.geometrychanged="geometrychanged";class pT extends lT{constructor(t,i,r){super(t,i),r=r||{},this._editable=null!=r.editable&&r.editable,this._fillColor=null==r.fillColor?16777215:r.fillColor,this._fillOpacity=null==r.fillOpacity?0:r.fillOpacity,this._icon=void 0===r.icon?null:r.icon,this._iconFloat=null==r.iconFloat?e.Alignment.Center:r.iconFloat,this._iconIndex=null==r.iconIndex?3:r.iconIndex,this._indicateVertices=null==r.indicateVertices||r.indicateVertices,this._lineColor=null==r.lineColor?16777215:r.lineColor,this._lineOpacity=null==r.lineOpacity?1:r.lineOpacity,this._lineWidth=null==r.lineWidth?1:r.lineWidth,this._text=void 0===r.text?null:r.text,this._textColor=null==r.textColor?16777215:r.textColor,this._click$=new zv,this._click$.subscribe((e=>{this.fire(pT.click,this)}))}get click$(){return this._click$}get editable(){return this._editable}set editable(e){this._editable=e,this._notifyChanged$.next(this)}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this._notifyChanged$.next(this)}get fillOpacity(){return this._fillOpacity}set fillOpacity(e){this._fillOpacity=e,this._notifyChanged$.next(this)}get geometry(){return this._geometry}get icon(){return this._icon}set icon(e){this._icon=e,this._notifyChanged$.next(this)}get iconFloat(){return this._iconFloat}set iconFloat(e){this._iconFloat=e,this._notifyChanged$.next(this)}get iconIndex(){return this._iconIndex}set iconIndex(e){this._iconIndex=e,this._notifyChanged$.next(this)}get indicateVertices(){return this._indicateVertices}set indicateVertices(e){this._indicateVertices=e,this._notifyChanged$.next(this)}get lineColor(){return this._lineColor}set lineColor(e){this._lineColor=e,this._notifyChanged$.next(this)}get lineOpacity(){return this._lineOpacity}set lineOpacity(e){this._lineOpacity=e,this._notifyChanged$.next(this)}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this._notifyChanged$.next(this)}get text(){return this._text}set text(e){this._text=e,this._notifyChanged$.next(this)}get textColor(){return this._textColor}set textColor(e){this._textColor=e,this._notifyChanged$.next(this)}setOptions(e){this._editable=null==e.editable?this._editable:e.editable,this._icon=void 0===e.icon?this._icon:e.icon,this._iconFloat=null==e.iconFloat?this._iconFloat:e.iconFloat,this._iconIndex=null==e.iconIndex?this._iconIndex:e.iconIndex,this._indicateVertices=null==e.indicateVertices?this._indicateVertices:e.indicateVertices,this._lineColor=null==e.lineColor?this._lineColor:e.lineColor,this._lineWidth=null==e.lineWidth?this._lineWidth:e.lineWidth,this._fillColor=null==e.fillColor?this._fillColor:e.fillColor,this._fillOpacity=null==e.fillOpacity?this._fillOpacity:e.fillOpacity,this._text=void 0===e.text?this._text:e.text,this._textColor=null==e.textColor?this._textColor:e.textColor,this._notifyChanged$.next(this)}}pT.click="click";class dT extends lT{constructor(e,t,i){super(e,t),i=i||{},this._color=null==i.color?16777215:i.color,this._editable=null!=i.editable&&i.editable,this._icon=void 0===i.icon?null:i.icon,this._text=void 0===i.text?null:i.text,this._textColor=null==i.textColor?16777215:i.textColor}get color(){return this._color}set color(e){this._color=e,this._notifyChanged$.next(this)}get editable(){return this._editable}set editable(e){this._editable=e,this._notifyChanged$.next(this)}get icon(){return this._icon}set icon(e){this._icon=e,this._notifyChanged$.next(this)}get text(){return this._text}set text(e){this._text=e,this._notifyChanged$.next(this)}get textColor(){return this._textColor}set textColor(e){this._textColor=e,this._notifyChanged$.next(this)}setOptions(e){this._color=null==e.color?this._color:e.color,this._editable=null==e.editable?this._editable:e.editable,this._icon=void 0===e.icon?this._icon:e.icon,this._text=void 0===e.text?this._text:e.text,this._textColor=null==e.textColor?this._textColor:e.textColor,this._notifyChanged$.next(this)}}class fT extends Hb{constructor(e,t,i){super(),this._activated$=new Qv(!1),this._configurationSubject$=new zv,this._activated=!1,this._container=t,this._name=e,this._navigator=i,this._configuration$=this._configurationSubject$.pipe(wb(this.defaultConfiguration),eb(((e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e})),nb(new d_(1)),Vv()),this._configuration$.subscribe((()=>{}))}get activated(){return this._activated}get activated$(){return this._activated$}get defaultConfiguration(){return this._getDefaultConfiguration()}get configuration$(){return this._configuration$}get name(){return this._name}activate(e){this._activated||(void 0!==e&&this._configurationSubject$.next(e),this._activated=!0,this._activate(),this._activated$.next(!0))}configure(e){this._configurationSubject$.next(e)}deactivate(){this._activated&&(this._activated=!1,this._deactivate(),this._container.domRenderer.clear(this._name),this._container.glRenderer.clear(this._name),this._activated$.next(!1))}resize(){}}fT.componentName="not_worthy";class mT{constructor(e,t,i){this._component=e,this._container=t,this._navigator=i,this._enabled=!1}get isEnabled(){return this._enabled}enable(){!this._enabled&&this._component.activated&&(this._enable(),this._enabled=!0,this._component.configure(this._getConfiguration(!0)))}disable(){this._enabled&&(this._disable(),this._enabled=!1,this._component.activated&&this._component.configure(this._getConfiguration(!1)))}}class gT extends mT{constructor(e,t,i,r){super(e,t,i),this._name=`${this._component.name}-${this._getNameExtension()}`,this._viewportCoords=r}_getConfiguration(e){return{}}_mouseEventToBasic(e,t,i,r,n,o){n=null!=n?n:0,o=null!=o?o:0;const[s,a]=this._viewportCoords.canvasPosition(e,t);return this._viewportCoords.canvasToBasic(s-n,a-o,t,r,i.perspective)}}class vT extends gT{constructor(e,t,i,r,n){super(e,t,i,r),this._tagCreator=n,this._geometryCreated$=new zv}get geometryCreated$(){return this._geometryCreated$}_enable(){this._enableCreate(),this._container.element.classList.add("component-tag-create")}_disable(){this._container.element.classList.remove("component-tag-create"),this._disableCreate()}_validateBasic(e){const t=e[0],i=e[1];return 0<=t&&t<=1&&0<=i&&i<=1}_mouseEventToBasic$(e){return e.pipe(Lb(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$),w_((([e,t,i])=>this._mouseEventToBasic(e,this._container.element,t,i))))}}class _T extends vT{_enableCreate(){this._container.mouseService.deferPixels(this._name,4),this._geometryCreatedSubscription=this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(Ry(this._validateBasic),w_((e=>new SE(e)))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.undeferPixels(this._name),this._geometryCreatedSubscription.unsubscribe()}_getNameExtension(){return"create-point"}}class yT extends vT{_enableCreate(){this._container.mouseService.deferPixels(this._name,4);const e=this._navigator.stateService.currentTransform$.pipe(w_((e=>{})),lb(1),Vv());this._deleteSubscription=e.pipe(gb(1)).subscribe(this._tagCreator.delete$);const t=this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(mb());this._createSubscription=e.pipe(Ab((()=>t.pipe(Ry(this._validateBasic),zy(1))))).subscribe(this._create$),this._setVertexSubscription=this._tagCreator.tag$.pipe(Ab((e=>e?B_(a_(e),X_(this._container.mouseService.mouseMove$,this._container.mouseService.domMouseMove$),this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$):i_()))).subscribe((([e,t,i,r])=>{const n=this._mouseEventToBasic(t,this._container.element,i,r);this._setVertex2d(e,n,r)})),this._addPointSubscription=this._tagCreator.tag$.pipe(Ab((e=>e?B_(a_(e),t):i_()))).subscribe((([e,t])=>{this._addPoint(e,t)})),this._geometryCreateSubscription=this._tagCreator.tag$.pipe(Ab((e=>e?e.created$.pipe(w_((e=>e.geometry))):i_()))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.undeferPixels(this._name),this._tagCreator.delete$.next(null),this._addPointSubscription.unsubscribe(),this._createSubscription.unsubscribe(),this._deleteSubscription.unsubscribe(),this._geometryCreateSubscription.unsubscribe(),this._setVertexSubscription.unsubscribe()}}class bT extends yT{get _create$(){return this._tagCreator.createPolygon$}_addPoint(e,t){e.addPoint(t)}_getNameExtension(){return"create-polygon"}_setVertex2d(e,t,i){e.geometry.setVertex2d(e.geometry.polygon.length-2,t,i)}}class xT extends yT{get _create$(){return this._tagCreator.createRect$}_addPoint(e,t){const i=e.geometry;i.validate(t)||(t=i.getNonAdjustedVertex2d(3)),e.addPoint(t)}_enable(){super._enable(),this._initializeAnchorIndexingSubscription=this._tagCreator.tag$.pipe(Ry((e=>!!e))).subscribe((e=>{e.geometry.initializeAnchorIndexing()}))}_disable(){super._disable(),this._initializeAnchorIndexingSubscription.unsubscribe()}_getNameExtension(){return"create-rect"}_setVertex2d(e,t,i){e.geometry.setOppositeVertex2d(t,i)}}class wT extends vT{_enableCreate(){this._container.mouseService.claimMouse(this._name,2),this._deleteSubscription=this._navigator.stateService.currentTransform$.pipe(w_((e=>null)),gb(1)).subscribe(this._tagCreator.delete$),this._createSubscription=this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$)).pipe(Ry(this._validateBasic)).subscribe(this._tagCreator.createRect$),this._initializeAnchorIndexingSubscription=this._tagCreator.tag$.pipe(Ry((e=>!!e))).subscribe((e=>{e.geometry.initializeAnchorIndexing()}));const e=X_(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseMove$),this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseMove$)).pipe(fy(this._container.renderService.renderCamera$),Lb(this._navigator.stateService.currentTransform$),w_((([[e,t],i])=>this._mouseEventToBasic(e,this._container.element,t,i))));this._setVertexSubscription=this._tagCreator.tag$.pipe(Ab((t=>t?B_(a_(t),e,this._navigator.stateService.currentTransform$):i_()))).subscribe((([e,t,i])=>{e.geometry.setOppositeVertex2d(t,i)}));const t=this._container.mouseService.mouseDragEnd$.pipe(Lb(this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDrag$)).pipe(Ry(this._validateBasic)),((e,t)=>t)),mb());this._addPointSubscription=this._tagCreator.tag$.pipe(Ab((e=>e?B_(a_(e),t):i_()))).subscribe((([e,t])=>{const i=e.geometry;i.validate(t)||(t=i.getNonAdjustedVertex2d(3)),e.addPoint(t)})),this._geometryCreatedSubscription=this._tagCreator.tag$.pipe(Ab((e=>e?e.created$.pipe(w_((e=>e.geometry))):i_()))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.unclaimMouse(this._name),this._tagCreator.delete$.next(null),this._addPointSubscription.unsubscribe(),this._createSubscription.unsubscribe(),this._deleteSubscription.unsubscribe(),this._geometryCreatedSubscription.unsubscribe(),this._initializeAnchorIndexingSubscription.unsubscribe(),this._setVertexSubscription.unsubscribe()}_getNameExtension(){return"create-rect-drag"}}!function(e){e[e.None=0]="None",e[e.Centroid=1]="Centroid",e[e.Vertex=2]="Vertex"}(eT||(eT={}));class AT extends gT{constructor(e,t,i,r,n){super(e,t,i,r),this._tagSet=n}_enable(){const e=this._tagSet.changed$.pipe(w_((e=>e.getAll())),Ab((e=>z_(e).pipe($_((e=>e.interact$))))),Ab((e=>a_(e).pipe(my(this._container.mouseService.documentMouseUp$.pipe(w_((()=>({offsetX:0,offsetY:0,operation:eT.None,tag:null}))),Yy()))))),mb()),t=X_(this._container.mouseService.mouseMove$,this._container.mouseService.domMouseMove$).pipe(mb());this._claimMouseSubscription=e.pipe(Ab((e=>e.tag?this._container.mouseService.domMouseDragStart$:i_()))).subscribe((()=>{this._container.mouseService.claimMouse(this._name,3)})),this._cursorSubscription=e.pipe(w_((e=>e.cursor)),Iy()).subscribe((e=>{const t=["crosshair","move","nesw-resize","nwse-resize"];for(const e of t)this._container.element.classList.remove(`component-tag-edit-${e}`);e&&this._container.element.classList.add(`component-tag-edit-${e}`)})),this._unclaimMouseSubscription=this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseDragEnd$).subscribe((e=>{this._container.mouseService.unclaimMouse(this._name)})),this._preventDefaultSubscription=e.pipe(Ab((e=>e.tag?this._container.mouseService.documentMouseMove$:i_()))).subscribe((e=>{e.preventDefault()})),this._updateGeometrySubscription=e.pipe(Lb(t),Ab((([e,t])=>{if(e.operation===eT.None||!e.tag)return i_();const i=a_(t).pipe(my(this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseDrag$).pipe(Ry((e=>this._viewportCoords.insideElement(e,this._container.element))))));return B_(i,this._container.renderService.renderCamera$).pipe(Lb(a_(e),this._navigator.stateService.currentTransform$,(([e,t],i,r)=>[e,t,i,r])))}))).subscribe((([e,t,i,r])=>{const n=this._mouseEventToBasic(e,this._container.element,t,r,i.offsetX,i.offsetY),o=i.tag.geometry;i.operation===eT.Centroid?o.setCentroid2d(n,r):i.operation===eT.Vertex&&o.setVertex2d(i.vertexIndex,n,r)}))}_disable(){this._claimMouseSubscription.unsubscribe(),this._cursorSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._unclaimMouseSubscription.unsubscribe(),this._updateGeometrySubscription.unsubscribe()}_getNameExtension(){return"edit-vertex"}}class ST{constructor(e,t,i,r){this._geometry=e,this._options={color:null==t.color?16777215:t.color},this._transform=i,this._viewportCoords=r||new Gu,this._outline=this._createOutine(),this._glObjects=[this._outline],this._aborted$=new zv,this._created$=new zv,this._glObjectsChanged$=new zv,this._geometryChangedSubscription=this._geometry.changed$.subscribe((e=>{this._disposeOutline(),this._outline=this._createOutine(),this._glObjects=[this._outline],this._glObjectsChanged$.next(this)}))}get geometry(){return this._geometry}get glObjects(){return this._glObjects}get aborted$(){return this._aborted$}get created$(){return this._created$}get glObjectsChanged$(){return this._glObjectsChanged$}get geometryChanged$(){return this._geometry.changed$.pipe(w_((e=>this)))}dispose(){this._disposeOutline(),this._geometryChangedSubscription.unsubscribe()}getDOMObjects(e,t){const i=[],r={offsetHeight:t.height,offsetWidth:t.width},n=e=>{e.stopPropagation(),this._aborted$.next(this)};if(this._geometry instanceof hT){const t=this._geometry.anchorIndex,o=void 0===t?1:t,[s,a]=this._geometry.getVertex2d(o),c=this._viewportCoords.basicToCanvasSafe(s,a,r,this._transform,e);if(null!=c){const e=this._colorToBackground(this._options.color),t=this._canvasToTransform(c),r={style:{background:e,transform:t}},o={onclick:n,style:{transform:t}};i.push(uv.h("div.TagInteractor",o,[])),i.push(uv.h("div.TagVertex",r,[]))}}else if(this._geometry instanceof uT){const t=this._geometry,[o,s]=t.getVertex2d(0),a=this._viewportCoords.basicToCanvasSafe(o,s,r,this._transform,e);if(null!=a){const e={onclick:t.polygon.length>4?e=>{e.stopPropagation(),t.removeVertex2d(t.polygon.length-2),this._created$.next(this)}:n,style:{transform:this._canvasToTransform(a)}},r=t.polygon.length>4?"TagCompleter":"TagInteractor";i.push(uv.h("div."+r,e,[]))}if(t.polygon.length>3){const[n,o]=t.getVertex2d(t.polygon.length-3),s=this._viewportCoords.basicToCanvasSafe(n,o,r,this._transform,e);if(null!=s){const e={onclick:e=>{e.stopPropagation(),t.removeVertex2d(t.polygon.length-3)},style:{transform:this._canvasToTransform(s)}};i.push(uv.h("div.TagInteractor",e,[]))}}const c=t.polygon.slice();c.splice(-2,2);for(const t of c){const n=this._viewportCoords.basicToCanvasSafe(t[0],t[1],r,this._transform,e);if(null!=n){const e={style:{background:this._colorToBackground(this._options.color),transform:this._canvasToTransform(n)}};i.push(uv.h("div.TagVertex",e,[]))}}}return i}addPoint(e){if(this._geometry instanceof hT){if(!this._geometry.validate(e))return;this._created$.next(this)}else if(this._geometry instanceof uT){this._geometry.addVertex2d(e)}}_canvasToTransform(e){return`translate(-50%,-50%) translate(${Math.round(e[0])}px,${Math.round(e[1])}px)`}_colorToBackground(e){return"#"+("000000"+e.toString(16)).substr(-6)}_createOutine(){const e=this._geometry.getPoints3d(this._transform),t=this._getLinePositions(e),i=new Xt;i.setAttribute("position",new Pt(t,3));return new Do(i,new Co({color:this._options.color,linewidth:1}))}_disposeOutline(){if(null==this._outline)return;const e=this._outline;e.geometry.dispose(),e.material.dispose(),this._outline=null,this._glObjects=[]}_getLinePositions(e){const t=e.length,i=new Float32Array(3*t);for(let r=0;r<t;++r){const t=3*r,n=e[r];i[t]=n[0],i[t+1]=n[1],i[t+2]=n[2]}return i}}class MT{constructor(e,t){this._component=e,this._navigator=t,this._tagOperation$=new zv,this._createPolygon$=new zv,this._createRect$=new zv,this._delete$=new zv,this._tag$=this._tagOperation$.pipe(eb(((e,t)=>t(e)),null),mb()),this._createRect$.pipe(Lb(this._component.configuration$,this._navigator.stateService.currentTransform$),w_((([e,t,i])=>r=>{const n=new hT([e[0],e[1],e[0],e[1]]);return new ST(n,{color:t.createColor},i)}))).subscribe(this._tagOperation$),this._createPolygon$.pipe(Lb(this._component.configuration$,this._navigator.stateService.currentTransform$),w_((([e,t,i])=>r=>{const n=new uT([[e[0],e[1]],[e[0],e[1]],[e[0],e[1]]]);return new ST(n,{color:t.createColor},i)}))).subscribe(this._tagOperation$),this._delete$.pipe(w_((()=>e=>null))).subscribe(this._tagOperation$)}get createRect$(){return this._createRect$}get createPolygon$(){return this._createPolygon$}get delete$(){return this._delete$}get tag$(){return this._tag$}}class ET{render(e,t,i,r,n){let o=[];for(const t of e)o=o.concat(t.getDOMObjects(i,r,n));return null!=t&&(o=o.concat(t.getDOMObjects(r,n))),uv.h("div.TagContainer",{},o)}clear(){return uv.h("div",{},[])}}e.TagMode=void 0,(tT=e.TagMode||(e.TagMode={}))[tT.Default=0]="Default",tT[tT.CreatePoint=1]="CreatePoint",tT[tT.CreatePolygon=2]="CreatePolygon",tT[tT.CreateRect=3]="CreateRect",tT[tT.CreateRectDrag=4]="CreateRectDrag";class TT{constructor(e,t){this._createTag=null,this._needsRender=!1,this._raycaster=t||new Ph,this._scene=e||new Re,this._objectTags={},this._retrievableObjects=[],this._tags={}}get needsRender(){return this._needsRender}add(e){for(let t of e)t.tag.id in this._tags&&this._remove(t.tag.id),this._add(t);this._needsRender=!0}addCreateTag(e){for(const t of e.glObjects)this._scene.add(t);this._createTag={tag:e,objects:e.glObjects},this._needsRender=!0}clear(){for(const e of Object.keys(this._tags))this._remove(e);this._needsRender=!1}get(e){return this.has(e)?this._tags[e].tag:void 0}has(e){return e in this._tags}hasCreateTag(){return null!=this._createTag}intersectObjects([e,t],i){this._raycaster.setFromCamera(new Q(e,t),i);const r=this._raycaster.intersectObjects(this._retrievableObjects),n=[];for(const e of r)e.object.uuid in this._objectTags&&n.push(this._objectTags[e.object.uuid]);return n}remove(e){for(const t of e)this._remove(t);this._needsRender=!0}removeAll(){for(const e of Object.keys(this._tags))this._remove(e);this._needsRender=!0}removeCreateTag(){if(null!=this._createTag){for(const e of this._createTag.objects)this._scene.remove(e);this._createTag.tag.dispose(),this._createTag=null,this._needsRender=!0}}render(e,t){t.render(this._scene,e),this._needsRender=!1}update(){this._needsRender=!0}updateCreateTagObjects(e){if(this._createTag.tag!==e)throw new Error("Create tags do not have the same reference.");for(let e of this._createTag.objects)this._scene.remove(e);for(const t of e.glObjects)this._scene.add(t);this._createTag.objects=e.glObjects,this._needsRender=!0}updateObjects(e){const t=e.tag.id;if(this._tags[t].tag!==e)throw new Error("Tags do not have the same reference.");const i=this._tags[t];this._removeObjects(i),delete this._tags[t],this._add(e),this._needsRender=!0}_add(e){const t=e.tag.id,i={tag:e,objects:[],retrievableObjects:[]};this._tags[t]=i;for(const t of e.getGLObjects())i.objects.push(t),this._scene.add(t);for(const t of e.getRetrievableObjects())i.retrievableObjects.push(t),this._retrievableObjects.push(t),this._objectTags[t.uuid]=e.tag.id}_remove(e){const t=this._tags[e];this._removeObjects(t),t.tag.dispose(),delete this._tags[e]}_removeObjects(e){for(const t of e.objects)this._scene.remove(t);for(const t of e.retrievableObjects){const e=this._retrievableObjects.indexOf(t);-1!==e&&this._retrievableObjects.splice(e,1)}}}class CT{constructor(e,t,i){this._tag=e,this._transform=t,this._viewportCoords=i||new Gu,this._glObjectsChanged$=new zv,this._interact$=new zv}get glObjectsChanged$(){return this._glObjectsChanged$}get interact$(){return this._interact$}get tag(){return this._tag}}class IT extends CT{constructor(e,t){super(e,t),this._fill=t.gpano?null:this._createFill(),this._holes=this._tag.lineWidth>=1?this._createHoles():[],this._outline=this._tag.lineWidth>=1?this._createOutline():null,this._geometryChangedSubscription=this._tag.geometry.changed$.subscribe((e=>{null!=this._fill&&this._updateFillGeometry(),this._holes.length>0&&this._updateHoleGeometries(),null!=this._outline&&this._updateOulineGeometry()})),this._changedSubscription=this._tag.changed$.subscribe((e=>{let t=!1;null!=this._fill&&this._updateFillMaterial(this._fill.material),null==this._outline?this._tag.lineWidth>=1&&(this._holes=this._createHoles(),this._outline=this._createOutline(),t=!0):(this._updateHoleMaterials(),this._updateOutlineMaterial()),t&&this._glObjectsChanged$.next(this)}))}dispose(){this._disposeFill(),this._disposeHoles(),this._disposeOutline(),this._changedSubscription.unsubscribe(),this._geometryChangedSubscription.unsubscribe()}getDOMObjects(e,t,i){const r=[],n=this._tag.geometry instanceof hT,o=!this._transform.gpano,s={offsetHeight:i.height,offsetWidth:i.width};if(null!=this._tag.icon&&(n||o)){const[i,n]=this._tag.geometry instanceof hT?this._tag.geometry.getVertex2d(this._tag.iconIndex):this._tag.geometry.getPoleOfAccessibility2d(),o=this._viewportCoords.basicToCanvasSafe(i,n,s,this._transform,t);if(null!=o){const t=e=>{this._interact$.next({offsetX:0,offsetY:0,operation:eT.None,tag:this._tag})};if(e.loaded){const i=e.getDOMSprite(this._tag.icon,this._tag.iconFloat),n={onclick:e=>{e.stopPropagation(),this._tag.click$.next(this._tag)},onmousedown:t,style:{transform:`translate(${Math.round(o[0])}px,${Math.round(o[1])}px)`}};r.push(uv.h("div.TagSymbol",n,[i]))}}}else if(null!=this._tag.text&&(n||o)){const[e,i]=this._tag.geometry instanceof hT?this._tag.geometry.getVertex2d(3):this._tag.geometry.getPoleOfAccessibility2d(),n=this._viewportCoords.basicToCanvasSafe(e,i,s,this._transform,t);if(null!=n){const e=Math.round(n[0]),t=Math.round(n[1]),i=this._tag.geometry instanceof hT?`translate(${e}px,${t}px)`:`translate(-50%, -50%) translate(${e}px,${t}px)`,o={onmousedown:e=>{this._interact$.next({offsetX:0,offsetY:0,operation:eT.None,tag:this._tag})},style:{color:this._colorToCss(this._tag.textColor),transform:i},textContent:this._tag.text};r.push(uv.h("span.TagSymbol",o,[]))}}if(!this._tag.editable)return r;const a=this._colorToCss(this._tag.lineColor);if(this._tag.geometry instanceof hT){const[e,i]=this._tag.geometry.getCentroid2d(),n=this._viewportCoords.basicToCanvasSafe(e,i,s,this._transform,t);if(null!=n){const e={onmousedown:this._interact(eT.Centroid,"move"),style:{background:a,transform:`translate(-50%, -50%) translate(${Math.round(n[0])}px,${Math.round(n[1])}px)`}};r.push(uv.h("div.TagMover",e,[]))}}const c=this._tag.geometry.getVertices2d();for(let e=0;e<c.length-1;e++){if(n&&(null!=this._tag.icon&&e===this._tag.iconIndex||null==this._tag.icon&&null!=this._tag.text&&3===e))continue;const[i,o]=c[e],h=this._viewportCoords.basicToCanvasSafe(i,o,s,this._transform,t);if(null==h)continue;const u=n?e%2==0?"nesw-resize":"nwse-resize":"crosshair",l=this._interact(eT.Vertex,u,e),p=`translate(-50%, -50%) translate(${Math.round(h[0])}px,${Math.round(h[1])}px)`,d={onmousedown:l,style:{background:a,transform:p,cursor:u}};if(r.push(uv.h("div.TagResizer",d,[])),!this._tag.indicateVertices)continue;const f={style:{background:a,transform:p}};r.push(uv.h("div.TagVertex",f,[]))}return r}getGLObjects(){const e=[];null!=this._fill&&e.push(this._fill);for(const t of this._holes)e.push(t);return null!=this._outline&&e.push(this._outline),e}getRetrievableObjects(){return null!=this._fill?[this._fill]:[]}_colorToCss(e){return"#"+("000000"+e.toString(16)).substr(-6)}_createFill(){let e=this._tag.geometry.getTriangles3d(this._transform),t=new Float32Array(e),i=new Xt;i.setAttribute("position",new Pt(t,3)),i.computeBoundingSphere();let r=new It({side:2,transparent:!0});return this._updateFillMaterial(r),new fi(i,r)}_createHoles(){let e=[];if(this._tag.geometry instanceof uT){let t=this._tag.geometry.getHoleVertices3d(this._transform);for(let i of t){let t=this._createLine(i);e.push(t)}}return e}_createLine(e){let t=this._getLinePositions(e),i=new Xt;i.setAttribute("position",new Pt(t,3)),i.computeBoundingSphere();let r=new Co;this._updateLineBasicMaterial(r);const n=new Do(i,r);return n.renderOrder=1,n}_createOutline(){let e=this._tag.geometry.getPoints3d(this._transform);return this._createLine(e)}_disposeFill(){null!=this._fill&&(this._fill.geometry.dispose(),this._fill.material.dispose(),this._fill=null)}_disposeHoles(){for(let e of this._holes)e.geometry.dispose(),e.material.dispose();this._holes=[]}_disposeOutline(){null!=this._outline&&(this._outline.geometry.dispose(),this._outline.material.dispose(),this._outline=null)}_getLinePositions(e){let t=e.length,i=new Float32Array(3*t);for(let r=0;r<t;++r){let t=3*r,n=e[r];i[t+0]=n[0],i[t+1]=n[1],i[t+2]=n[2]}return i}_interact(e,t,i){return r=>{let n=r.offsetX-r.target.offsetWidth/2,o=r.offsetY-r.target.offsetHeight/2;this._interact$.next({cursor:t,offsetX:n,offsetY:o,operation:e,tag:this._tag,vertexIndex:i})}}_updateFillGeometry(){let e=this._tag.geometry.getTriangles3d(this._transform),t=new Float32Array(e),i=this._fill.geometry,r=i.getAttribute("position");r.array.length===t.length?(r.set(t),r.needsUpdate=!0):(i.deleteAttribute("position"),i.setAttribute("position",new Pt(t,3))),i.computeBoundingSphere()}_updateFillMaterial(e){e.color=new wt(this._tag.fillColor),e.opacity=this._tag.fillOpacity,e.needsUpdate=!0}_updateHoleGeometries(){let e=this._tag.geometry.getHoleVertices3d(this._transform);if(e.length!==this._holes.length)throw new Error("Changing the number of holes is not supported.");for(let t=0;t<this._holes.length;t++){let i=e[t],r=this._holes[t];this._updateLine(r,i)}}_updateHoleMaterials(){for(let e of this._holes){let t=e.material;this._updateLineBasicMaterial(t)}}_updateLine(e,t){let i=this._getLinePositions(t),r=e.geometry,n=r.getAttribute("position");n.set(i),n.needsUpdate=!0,r.computeBoundingSphere()}_updateOulineGeometry(){let e=this._tag.geometry.getPoints3d(this._transform);this._updateLine(this._outline,e)}_updateOutlineMaterial(){let e=this._outline.material;this._updateLineBasicMaterial(e)}_updateLineBasicMaterial(e){e.color=new wt(this._tag.lineColor),e.linewidth=Math.max(this._tag.lineWidth,1),e.visible=this._tag.lineWidth>=1&&this._tag.lineOpacity>0,e.opacity=this._tag.lineOpacity,e.transparent=this._tag.lineOpacity<1,e.needsUpdate=!0}}class NT extends CT{dispose(){}getDOMObjects(t,i,r){const n=this._tag,o={offsetHeight:r.height,offsetWidth:r.width},s=[],[a,c]=n.geometry.getCentroid2d(),h=this._viewportCoords.basicToCanvasSafe(a,c,o,this._transform,i);if(null!=h){const i=e=>{this._interact$.next({offsetX:0,offsetY:0,operation:eT.None,tag:n})},r=Math.round(h[0]),o=Math.round(h[1]);let a;if(null!=n.icon){if(t.loaded){const c=t.getDOMSprite(n.icon,e.Alignment.Bottom);a=`translate(${r}px,${o+8}px)`;const h={onmousedown:i,style:{pointerEvents:"all",transform:a}};s.push(uv.h("div",h,[c]))}}else if(null!=n.text){a=`translate(-50%,0%) translate(${r}px,${o+8}px)`;const e={onmousedown:i,style:{color:this._colorToCss(n.textColor),transform:a},textContent:n.text};s.push(uv.h("span.TagSymbol",e,[]))}const c=this._interact(eT.Centroid,n,"move"),u=this._colorToCss(n.color);if(a=`translate(-50%,-50%) translate(${r}px,${o}px)`,n.editable){let e={onmousedown:c,style:{background:u,transform:a}};s.push(uv.h("div.TagSpotInteractor",e,[]))}const l={style:{background:u,transform:a}};s.push(uv.h("div.TagVertex",l,[]))}return s}getGLObjects(){return[]}getRetrievableObjects(){return[]}_colorToCss(e){return"#"+("000000"+e.toString(16)).substr(-6)}_interact(e,t,i,r){return n=>{const o=n.offsetX-n.target.offsetWidth/2,s=n.offsetY-n.target.offsetHeight/2;this._interact$.next({cursor:i,offsetX:o,offsetY:s,operation:e,tag:t,vertexIndex:r})}}}class PT{constructor(){this._active=!1,this._hash={},this._hashDeactivated={},this._notifyChanged$=new zv}get active(){return this._active}get changed$(){return this._notifyChanged$}activate(e){if(!this._active){for(const t in this._hashDeactivated){if(!this._hashDeactivated.hasOwnProperty(t))continue;const i=this._hashDeactivated[t];this._add(i,e)}this._hashDeactivated={},this._active=!0,this._notifyChanged$.next(this)}}deactivate(){if(this._active){for(const e in this._hash)this._hash.hasOwnProperty(e)&&(this._hashDeactivated[e]=this._hash[e].tag);this._hash={},this._active=!1}}add(e,t){this._assertActivationState(!0);for(const i of e)this._add(i,t);this._notifyChanged$.next(this)}addDeactivated(e){this._assertActivationState(!1);for(const t of e){if(!(t instanceof pT||t instanceof dT))throw new Error("Tag type not supported");this._hashDeactivated[t.id]=t}}get(e){return this.has(e)?this._hash[e]:void 0}getAll(){const e=this._hash;return Object.keys(e).map((t=>e[t]))}getAllDeactivated(){const e=this._hashDeactivated;return Object.keys(e).map((t=>e[t]))}getDeactivated(e){return this.hasDeactivated(e)?this._hashDeactivated[e]:void 0}has(e){return e in this._hash}hasDeactivated(e){return e in this._hashDeactivated}remove(e){this._assertActivationState(!0);const t=this._hash;for(const i of e)i in t&&delete t[i];this._notifyChanged$.next(this)}removeAll(){this._assertActivationState(!0),this._hash={},this._notifyChanged$.next(this)}removeAllDeactivated(){this._assertActivationState(!1),this._hashDeactivated={}}removeDeactivated(e){this._assertActivationState(!1);const t=this._hashDeactivated;for(const i of e)i in t&&delete t[i]}_add(e,t){if(e instanceof pT)this._hash[e.id]=new IT(e,t);else{if(!(e instanceof dT))throw new Error("Tag type not supported");this._hash[e.id]=new NT(e,t)}}_assertActivationState(e){if(e!==this._active)throw new Error("Tag set not in correct state for operation.")}}class RT extends fT{constructor(e,t,i){super(e,t,i),this._tagDomRenderer=new ET,this._tagScene=new TT,this._tagSet=new PT,this._tagCreator=new MT(this,i),this._viewportCoords=new Gu,this._createHandlers={CreatePoint:new _T(this,t,i,this._viewportCoords,this._tagCreator),CreatePolygon:new bT(this,t,i,this._viewportCoords,this._tagCreator),CreateRect:new xT(this,t,i,this._viewportCoords,this._tagCreator),CreateRectDrag:new wT(this,t,i,this._viewportCoords,this._tagCreator),Default:void 0},this._editVertexHandler=new AT(this,t,i,this._viewportCoords,this._tagSet),this._renderTags$=this._tagSet.changed$.pipe(w_((e=>{const t=e.getAll();return t.sort(((e,t)=>{const i=e.tag.id,r=t.tag.id;return i<r?-1:i>r?1:0})),t})),mb()),this._tagChanged$=this._renderTags$.pipe(Ab((e=>z_(e).pipe($_((e=>X_(e.tag.changed$,e.tag.geometryChanged$)))))),mb()),this._renderTagGLChanged$=this._renderTags$.pipe(Ab((e=>z_(e).pipe($_((e=>e.glObjectsChanged$))))),mb()),this._createGeometryChanged$=this._tagCreator.tag$.pipe(Ab((e=>null!=e?e.geometryChanged$:i_())),mb()),this._createGLObjectsChanged$=this._tagCreator.tag$.pipe(Ab((e=>null!=e?e.glObjectsChanged$:i_())),mb()),this._creatingConfiguration$=this._configuration$.pipe(Iy(((e,t)=>e.mode===t.mode),(e=>({createColor:e.createColor,mode:e.mode}))),lb(1),Vv()),this._creatingConfiguration$.subscribe((e=>{this.fire(RT.modechanged,e.mode)}))}add(e){this._activated?this._navigator.stateService.currentTransform$.pipe(Yy()).subscribe((t=>{this._tagSet.add(e,t);const i=e.map((e=>this._tagSet.get(e.id)));this._tagScene.add(i)})):this._tagSet.addDeactivated(e)}changeMode(e){this.configure({mode:e})}get(e){if(this._activated){const t=this._tagSet.get(e);return void 0!==t?t.tag:void 0}return this._tagSet.getDeactivated(e)}getAll(){return this.activated?this._tagSet.getAll().map((e=>e.tag)):this._tagSet.getAllDeactivated()}getTagIdsAt(e){return new Promise(((t,i)=>{this._container.renderService.renderCamera$.pipe(Yy(),w_((t=>{const i=this._viewportCoords.canvasToViewport(e[0],e[1],this._container.element);return this._tagScene.intersectObjects(i,t.perspective)}))).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}has(e){return this._activated?this._tagSet.has(e):this._tagSet.hasDeactivated(e)}remove(e){this._activated?(this._tagSet.remove(e),this._tagScene.remove(e)):this._tagSet.removeDeactivated(e)}removeAll(){this._activated?(this._tagSet.removeAll(),this._tagScene.removeAll()):this._tagSet.removeAllDeactivated()}_activate(){this._editVertexHandler.enable();const t=z_(Object.keys(this._createHandlers)).pipe(w_((e=>this._createHandlers[e])),Ry((e=>!!e)),$_((e=>e.geometryCreated$)),mb());this._fireGeometryCreatedSubscription=t.subscribe((e=>{this.fire(RT.geometrycreated,e)})),this._fireCreateGeometryEventSubscription=this._tagCreator.tag$.pipe(yb((e=>null==e)),Iy()).subscribe((e=>{const t=null!=e?RT.creategeometrystart:RT.creategeometryend;this.fire(t,this)})),this._handlerStopCreateSubscription=t.subscribe((()=>{this.changeMode(e.TagMode.Default)})),this._handlerEnablerSubscription=this._creatingConfiguration$.subscribe((t=>{this._disableCreateHandlers();const i=e.TagMode[t.mode],r=this._createHandlers[i];r&&r.enable()})),this._fireTagsChangedSubscription=this._renderTags$.subscribe((e=>{this.fire(RT.tagschanged,this)})),this._stopCreateSubscription=this._tagCreator.tag$.pipe(Ab((e=>null!=e?e.aborted$.pipe(w_((e=>null))):i_()))).subscribe((()=>{this.changeMode(e.TagMode.Default)})),this._setGLCreateTagSubscription=this._tagCreator.tag$.subscribe((e=>{this._tagScene.hasCreateTag()&&this._tagScene.removeCreateTag(),null!=e&&this._tagScene.addCreateTag(e)})),this._createGLObjectsChangedSubscription=this._createGLObjectsChanged$.subscribe((e=>{this._tagScene.updateCreateTagObjects(e)})),this._updateGLObjectsSubscription=this._renderTagGLChanged$.subscribe((e=>{this._tagScene.updateObjects(e)})),this._updateTagSceneSubscription=this._tagChanged$.subscribe((e=>{this._tagScene.update()})),this._domSubscription=this._renderTags$.pipe(wb([]),Ly((e=>{this._container.domRenderer.render$.next({name:this._name,vnode:this._tagDomRenderer.clear()})})),fy(this._container.renderService.renderCamera$,this._container.spriteService.spriteAtlas$,this._container.renderService.size$,this._tagChanged$.pipe(wb(null)),this._tagCreator.tag$.pipe(rb(this._createGeometryChanged$),wb(null)),((e,t,i,r,n,o)=>[t,i,r,e,n,o])),w_((e=>({name:this._name,vnode:this._tagDomRenderer.render(e[3],e[5],e[1],e[0].perspective,e[2])})))).subscribe(this._container.domRenderer.render$),this._glSubscription=this._navigator.stateService.currentState$.pipe(w_((e=>{const t=this._tagScene;return{name:this._name,render:{frameId:e.id,needsRender:t.needsRender,render:t.render.bind(t),stage:kb.Foreground}}}))).subscribe(this._container.glRenderer.render$),this._navigator.stateService.currentTransform$.pipe(Yy()).subscribe((e=>{this._tagSet.activate(e),this._tagScene.add(this._tagSet.getAll())}))}_deactivate(){this._editVertexHandler.disable(),this._disableCreateHandlers(),this._tagScene.clear(),this._tagSet.deactivate(),this._tagCreator.delete$.next(null),this._updateGLObjectsSubscription.unsubscribe(),this._updateTagSceneSubscription.unsubscribe(),this._stopCreateSubscription.unsubscribe(),this._setGLCreateTagSubscription.unsubscribe(),this._createGLObjectsChangedSubscription.unsubscribe(),this._domSubscription.unsubscribe(),this._glSubscription.unsubscribe(),this._fireCreateGeometryEventSubscription.unsubscribe(),this._fireGeometryCreatedSubscription.unsubscribe(),this._fireTagsChangedSubscription.unsubscribe(),this._handlerStopCreateSubscription.unsubscribe(),this._handlerEnablerSubscription.unsubscribe(),this._container.element.classList.remove("component-tag-create")}_getDefaultConfiguration(){return{createColor:16777215,mode:e.TagMode.Default}}_disableCreateHandlers(){const e=this._createHandlers;for(const t in e){if(!e.hasOwnProperty(t))continue;const i=e[t];i&&i.disable()}}}RT.componentName="tag",RT.creategeometryend="creategeometryend",RT.creategeometrystart="creategeometrystart",RT.modechanged="modechanged",RT.geometrycreated="geometrycreated",RT.tagschanged="tagschanged";class OT{constructor(e,t){this._needsRender=!1,this._interactiveObjects=[],this._markers={},this._objectMarkers={},this._raycaster=t||new Ph,this._scene=e||new Re}get markers(){return this._markers}get needsRender(){return this._needsRender}add(e,t){e.id in this._markers&&this._dispose(e.id),e.createGeometry(t),this._scene.add(e.geometry),this._markers[e.id]=e;for(let t of e.getInteractiveObjects())this._interactiveObjects.push(t),this._objectMarkers[t.uuid]=e.id;this._needsRender=!0}clear(){for(const e in this._markers)this._markers.hasOwnProperty&&this._dispose(e);this._needsRender=!0}get(e){return this._markers[e]}getAll(){return Object.keys(this._markers).map((e=>this._markers[e]))}has(e){return e in this._markers}intersectObjects([e,t],i){this._raycaster.setFromCamera(new Q(e,t),i);const r=this._raycaster.intersectObjects(this._interactiveObjects);for(const e of r)if(e.object.uuid in this._objectMarkers)return this._objectMarkers[e.object.uuid];return null}lerpAltitude(e,t,i){e in this._markers&&(this._markers[e].lerpAltitude(t,i),this._needsRender=!0)}remove(e){e in this._markers&&(this._dispose(e),this._needsRender=!0)}render(e,t){t.render(this._scene,e),this._needsRender=!1}update(e,t,i){if(!(e in this._markers))return;this._markers[e].updatePosition(t,i),this._needsRender=!0}_dispose(e){const t=this._markers[e];this._scene.remove(t.geometry);for(let i of t.getInteractiveObjects()){const t=this._interactiveObjects.indexOf(i);-1!==t?this._interactiveObjects.splice(t,1):console.warn(`Object does not exist (${i.id}) for ${e}`),delete this._objectMarkers[i.uuid]}t.disposeGeometry(),delete this._markers[e]}}class DT{constructor(){this._hash={},this._index=new ul(16),this._indexChanged$=new zv,this._updated$=new zv}get changed$(){return this._indexChanged$}get updated$(){return this._updated$}add(e){const t=[],i=this._hash,r=this._index;for(const n of e){const e=n.id;e in i&&(r.remove(i[e]),t.push(n));const o={lat:n.latLon.lat,lon:n.latLon.lon,marker:n};i[e]=o,r.insert(o)}t.length>0&&this._updated$.next(t),e.length>t.length&&this._indexChanged$.next(this)}has(e){return e in this._hash}get(e){return this.has(e)?this._hash[e].marker:void 0}getAll(){return this._index.all().map((e=>e.marker))}remove(e){const t=this._hash,i=this._index;let r=!1;for(const n of e){if(!(n in t))continue;const e=t[n];i.remove(e),delete t[n],r=!0}r&&this._indexChanged$.next(this)}removeAll(){this._hash={},this._index.clear(),this._indexChanged$.next(this)}search([e,t]){return this._index.search({maxX:t.lon,maxY:t.lat,minX:e.lon,minY:e.lat}).map((e=>e.marker))}update(e){const t=this._hash,i=this._index,r=e.id;if(!(r in t))return;i.remove(t[r]);const n={lat:e.latLon.lat,lon:e.latLon.lon,marker:e};t[r]=n,i.insert(n)}}class LT extends fT{constructor(e,t,i){super(e,t,i),this._relativeGroundAltitude=-2,this._geoCoords=new Uu,this._graphCalculator=new zx,this._markerScene=new OT,this._markerSet=new DT,this._viewportCoords=new Gu}get mouseMove$(){return this._mouseMove$}add(e){this._markerSet.add(e)}get(e){return this._markerSet.get(e)}getAll(){return this._markerSet.getAll()}getMarkerIdAt(e){return new Promise(((t,i)=>{this._container.renderService.renderCamera$.pipe(Yy(),w_((t=>{const i=this._viewportCoords.canvasToViewport(e[0],e[1],this._container.element);return this._markerScene.intersectObjects(i,t.perspective)}))).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}has(e){return this._markerSet.has(e)}remove(e){this._markerSet.remove(e)}removeAll(){this._markerSet.removeAll()}_activate(){const e=this._navigator.stateService.currentState$.pipe(w_((e=>e.state.camera.position.z+this._relativeGroundAltitude)),Iy(((e,t)=>Math.abs(e-t)<.01)),lb(1),Vv()),t=B_(e,this._navigator.stateService.reference$).pipe(Yy(),w_((()=>{})),lb(1),Vv()),i=this._configuration$.pipe(w_((e=>({visibleBBoxSize:Math.max(1,Math.min(200,e.visibleBBoxSize))})))),r=this._navigator.stateService.currentNode$.pipe(w_((e=>e.latLon)),lb(1),Vv()),n=B_(i,r).pipe(w_((([e,t])=>this._graphCalculator.boundingBoxCorners(t,e.visibleBBoxSize/2))),lb(1),Vv()),o=B_(a_(this._markerSet).pipe(my(this._markerSet.changed$)),n).pipe(w_((([e,t])=>e.search(t))));this._setChangedSubscription=t.pipe(Ab((()=>o.pipe(Lb(this._navigator.stateService.reference$,e))))).subscribe((([e,t,i])=>{const r=this._geoCoords,n=this._markerScene,o=n.markers,s=Object.assign({},o);for(const a of e)if(a.id in o)delete s[a.id];else{const e=r.geodeticToEnu(a.latLon.lat,a.latLon.lon,t.alt+i,t.lat,t.lon,t.alt);n.add(a,e)}for(const e in s)s.hasOwnProperty(e)&&n.remove(e)})),this._markersUpdatedSubscription=t.pipe(Ab((()=>this._markerSet.updated$.pipe(Lb(n,this._navigator.stateService.reference$,e))))).subscribe((([e,[t,i],r,n])=>{const o=this._geoCoords,s=this._markerScene;for(const a of e){const e=s.has(a.id),c=a.latLon.lat>t.lat&&a.latLon.lat<i.lat&&a.latLon.lon>t.lon&&a.latLon.lon<i.lon;if(c){const e=o.geodeticToEnu(a.latLon.lat,a.latLon.lon,r.alt+n,r.lat,r.lon,r.alt);s.add(a,e)}else!c&&e&&s.remove(a.id)}})),this._referenceSubscription=this._navigator.stateService.reference$.pipe(gb(1),Lb(e)).subscribe((([e,t])=>{const i=this._geoCoords,r=this._markerScene;for(const n of r.getAll()){const o=i.geodeticToEnu(n.latLon.lat,n.latLon.lon,e.alt+t,e.lat,e.lon,e.alt);r.update(n.id,o)}})),this._adjustHeightSubscription=e.pipe(gb(1),Lb(this._navigator.stateService.reference$,r)).subscribe((([e,t,i])=>{const r=this._geoCoords,n=this._markerScene,o=r.geodeticToEnu(i.lat,i.lon,t.alt+e,t.lat,t.lon,t.alt);for(const i of n.getAll()){const s=r.geodeticToEnu(i.latLon.lat,i.latLon.lon,t.alt+e,t.lat,t.lon,t.alt),a=s[0]-o[0],c=s[1]-o[1],h=Math.sqrt(a*a+c*c);h>50||n.lerpAltitude(i.id,e,Math.min(1,Math.max(0,1.2-1.2*h/50)))}})),this._renderSubscription=this._navigator.stateService.currentState$.pipe(w_((e=>{const t=this._markerScene;return{name:this._name,render:{frameId:e.id,needsRender:t.needsRender,render:t.render.bind(t),stage:kb.Foreground}}}))).subscribe(this._container.glRenderer.render$),this._mouseMove$=B_(this._container.renderService.renderCamera$,this._container.mouseService.mouseMove$).pipe(w_((([e,t])=>{const i=this._container.element,[r,n]=this._viewportCoords.canvasPosition(t,i),o=this._viewportCoords.canvasToViewport(r,n,i);return[t,this._markerScene.intersectObjects(o,e.perspective)]})),lb(1),Vv());const s=this._mouseMove$.pipe(w_((([e,t])=>t)),lb(1),Vv()),a=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$).pipe(w_((e=>!0))),c=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragEnd$).pipe(w_((e=>!1))),h=X_(a,c).pipe(wb(!1));this._dragEventSubscription=a.pipe(Lb(s),rb(B_(c,a_(null))),wb([!1,null]),sb()).subscribe((([e,t])=>{const i=t[0],r=i?LT.dragstart:LT.dragend,n=i?t[1]:e[1],o={marker:this._markerScene.get(n),target:this,type:r};this.fire(r,o)}));const u=X_(this._container.mouseService.mouseDown$.pipe(w_((e=>!0))),this._container.mouseService.documentMouseUp$.pipe(w_((e=>!1)))).pipe(wb(!1));this._mouseClaimSubscription=B_(this._container.mouseService.active$,s.pipe(Iy()),u,h).pipe(w_((([e,t,i,r])=>!e&&null!=t&&i||r)),Iy()).subscribe((e=>{e?(this._container.mouseService.claimMouse(this._name,1),this._container.mouseService.claimWheel(this._name,1)):(this._container.mouseService.unclaimMouse(this._name),this._container.mouseService.unclaimWheel(this._name))}));const l=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$).pipe(Lb(s,this._container.renderService.renderCamera$),w_((([e,t,i])=>{const r=this._markerScene.get(t),n=this._container.element,[o,s]=this._viewportCoords.projectToCanvas(r.geometry.position.toArray(),n,i.perspective),[a,c]=this._viewportCoords.canvasPosition(e,n);return[r,[a-o,c-s],i]})),lb(1),Vv());this._updateMarkerSubscription=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDrag$).pipe(Lb(l,this._navigator.stateService.reference$,i)).subscribe((([e,[t,i,r],n,o])=>{if(!this._markerScene.has(t.id))return;const s=this._container.element,[a,c]=this._viewportCoords.canvasPosition(e,s),h=a-i[0],u=c-i[1],[l,p]=this._viewportCoords.canvasToViewport(h,u,s),d=new oe(l,p,1).unproject(r.perspective).sub(r.perspective.position).normalize(),f=Math.min(this._relativeGroundAltitude/d.z,o.visibleBBoxSize/2-.1);if(f<0)return;const m=d.clone().multiplyScalar(f).add(r.perspective.position);m.z=r.perspective.position.z+this._relativeGroundAltitude;const[g,v]=this._geoCoords.enuToGeodetic(m.x,m.y,m.z,n.lat,n.lon,n.alt);this._markerScene.update(t.id,m.toArray(),{lat:g,lon:v}),this._markerSet.update(t);const _={marker:t,target:this,type:LT.changed};this.fire(LT.changed,_)}))}_deactivate(){this._adjustHeightSubscription.unsubscribe(),this._dragEventSubscription.unsubscribe(),this._markersUpdatedSubscription.unsubscribe(),this._mouseClaimSubscription.unsubscribe(),this._referenceSubscription.unsubscribe(),this._renderSubscription.unsubscribe(),this._setChangedSubscription.unsubscribe(),this._updateMarkerSubscription.unsubscribe(),this._markerScene.clear()}_getDefaultConfiguration(){return{visibleBBoxSize:100}}}LT.componentName="marker",LT.changed="changed",LT.dragstart="dragstart",LT.dragend="dragend";class kT{constructor(e,t){this._id=e,this._latLon=t}get id(){return this._id}get geometry(){return this._geometry}get latLon(){return this._latLon}createGeometry(e){this._geometry||(this._createGeometry(e),this._geometry.updateMatrixWorld(!0))}disposeGeometry(){this._geometry&&(this._disposeGeometry(),this._geometry=void 0)}getInteractiveObjects(){return this._geometry?this._getInteractiveObjects():[]}lerpAltitude(e,t){this._geometry&&(this._geometry.position.z=(1-t)*this._geometry.position.z+t*e)}updatePosition(e,t){t&&(this._latLon.lat=t.lat,this._latLon.lon=t.lon),this._geometry&&(this._geometry.position.fromArray(e),this._geometry.updateMatrixWorld(!0))}}class BT extends kT{constructor(e,t,i){super(e,t),i=i||{},this._color=null!=i.color?i.color:16777215,this._opacity=null!=i.opacity?i.opacity:.4,this._radius=null!=i.radius?i.radius:.4}_createGeometry(e){const t=new fi(new ha(this._radius,100),new It({color:this._color,opacity:this._opacity,transparent:!0}));t.up.fromArray([0,0,1]),t.renderOrder=-1,t.position.z=1e-4;const i=new Pe;i.add(t),i.position.fromArray(e),this._geometry=i}_disposeGeometry(){for(let e of this._geometry.children)e.geometry.dispose(),e.material.dispose()}_getInteractiveObjects(){return[]}}class FT extends kT{constructor(e,t,i){super(e,t),i=i||{},this._offsetFactor=null!=i.offsetFactor?i.offsetFactor:-.1,this._outerColor=null!=i.outerColor?i.outerColor:0}_createGeometry(e){const t=new fi(new ha(.2,100),new It({color:this._outerColor,opacity:.05,transparent:!0,polygonOffset:!0,polygonOffsetFactor:this._offsetFactor})),i=new fi(new ha(.125,100),new It({color:16777215,opacity:.7,transparent:!0,polygonOffset:!0,polygonOffsetFactor:this._offsetFactor-.1}));t.up.fromArray([0,0,1]),t.renderOrder=-1,t.position.z=1e-4,i.position.z=1e-4;const r=new Pe;r.add(t),r.add(i),r.position.fromArray(e),this._geometry=r}_disposeGeometry(){for(let e of this._geometry.children)e.geometry.dispose(),e.material.dispose()}_getInteractiveObjects(){return[]}}class jT extends fT{constructor(e,t,i,r){super(e,t,i),this._dom=r||new Gb,this._popups=[],this._added$=new zv,this._popups$=new zv}add(e){for(const t of e)-1===this._popups.indexOf(t)&&(this._popups.push(t),this._activated&&t.setParentContainer(this._popupContainer));this._added$.next(e),this._popups$.next(this._popups)}getAll(){return this._popups.slice()}remove(e){for(const t of e)this._remove(t);this._popups$.next(this._popups)}removeAll(){for(const e of this._popups.slice())this._remove(e);this._popups$.next(this._popups)}_activate(){this._popupContainer=this._dom.createElement("div","Beeview-js-popup-container",this._container.element);for(const e of this._popups)e.setParentContainer(this._popupContainer);this._updateAllSubscription=B_(this._container.renderService.renderCamera$,this._container.renderService.size$,this._navigator.stateService.currentTransform$).subscribe((([e,t,i])=>{for(const r of this._popups)r.update(e,t,i)}));const e=this._popups$.pipe(wb(this._popups),Ab((e=>z_(e).pipe($_((e=>e.changed$))))),w_((e=>[e])));this._updateAddedChangedSubscription=this._added$.pipe(rb(e),Lb(this._container.renderService.renderCamera$,this._container.renderService.size$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i,r])=>{for(const n of e)n.update(t,i,r)}))}_deactivate(){this._updateAllSubscription.unsubscribe(),this._updateAddedChangedSubscription.unsubscribe();for(const e of this._popups)e.remove();this._container.element.removeChild(this._popupContainer),delete this._popupContainer}_getDefaultConfiguration(){return{}}_remove(e){const t=this._popups.indexOf(e);if(-1===t)return;const i=this._popups.splice(t,1)[0];this._activated&&i.remove()}}jT.componentName="popup";class zT extends fT{constructor(e,t,i){super(e,t,i)}_activate(){this._container.domRenderer.render$.next({name:this._name,vnode:this._getBackgroundNode("The viewer can't display the given photo.")})}_deactivate(){}_getDefaultConfiguration(){return{}}_getBackgroundNode(e){return uv.h("div.BackgroundWrapper",{},[uv.h("p",{textContent:e},[])])}}zT.componentName="background";class $T extends fT{constructor(e,t,i){super(e,t,i),this._spatial=new Hu,this._svgNamespace="http://www.w3.org/2000/svg",this._distinctThreshold=Math.PI/90}_activate(){let e=this._navigator.stateService.currentState$.pipe(Iy(void 0,(e=>e.state.currentNode.key)),w_((e=>{let t,i=e.state.currentNode,r=e.state.currentTransform;if(i.pano)return t=2*Math.PI*i.gpano.CroppedAreaImageWidthPixels/i.gpano.FullPanoWidthPixels,[this._spatial.degToRad(i.ca),t];let n=Math.max(r.basicWidth,r.basicHeight);return n<=0&&console.warn(`Original image size (${r.basicWidth}, ${r.basicHeight}) is invalid (${i.key}. Not showing available fov.`),t=n>0?2*Math.atan(.5*r.basicWidth/(n*r.focal)):0,[this._spatial.degToRad(i.ca),t]})),Iy(((e,t)=>Math.abs(t[0]-e[0])<this._distinctThreshold&&Math.abs(t[1]-e[1])<this._distinctThreshold))),t=this._container.renderService.renderCamera$.pipe(w_((e=>{let t=this._spatial.degToRad(e.perspective.fov),i=e.perspective.aspect===Number.POSITIVE_INFINITY?Math.PI:2*Math.atan(e.perspective.aspect*Math.tan(.5*t));return[this._spatial.azimuthalToBearing(e.rotation.phi),i]})),Iy(((e,t)=>Math.abs(t[0]-e[0])<this._distinctThreshold&&Math.abs(t[1]-e[1])<this._distinctThreshold)));this._renderSubscription=B_(e,t).pipe(w_((e=>{let t=uv.h("div.BearingIndicatorBackground",{oncontextmenu:e=>{e.preventDefault()}},[uv.h("div.BearingIndicatorBackgroundRectangle",{},[]),uv.h("div.BearingIndicatorBackgroundCircle",{},[])]),i=uv.h("div.BearingIndicatorNorth",{},[]),r=this._createCircleSector(e[0][0],e[0][1],"#fff"),n=this._createCircleSector(e[1][0],e[1][1],"#49b1d3"),o=this._createCircleSectorCompass(r,n),s=60*e[1][0],a=uv.h("div.TransformDeg",{attributes:{style:`transform:rotate(${s}deg)`}},[]);return{name:this._name,vnode:uv.h("div.BearingIndicator",{},[t,i,o,a])}}))).subscribe(this._container.domRenderer.render$)}_deactivate(){this._renderSubscription.unsubscribe()}_getDefaultConfiguration(){return{}}_createCircleSectorCompass(e,t){let i=uv.h("g",{attributes:{transform:"translate(1,1)"},namespace:this._svgNamespace},[e,t]),r=uv.h("circle",{attributes:{cx:"1",cy:"1",fill:"#fff",r:"0.291667",stroke:"#fff","stroke-width":"0.0833333"},namespace:this._svgNamespace},[]);return uv.h("svg",{attributes:{viewBox:"0 0 2 2"},namespace:this._svgNamespace,style:{bottom:"4px",height:"48px",left:"4px",position:"absolute",width:"48px"}},[i,r])}_createCircleSector(e,t,i){if(t>2*Math.PI-Math.PI/90)return uv.h("circle",{attributes:{cx:"0",cy:"0",fill:i,r:"1"},namespace:this._svgNamespace},[]);let r=e-t/2-Math.PI/2,n=r+t,o=Math.cos(r),s=Math.sin(r),a=Math.cos(n),c=Math.sin(n),h=`M 0 0 ${o} ${s} A 1 1 0 ${t>=Math.PI?1:0} 1 ${a} ${c}`;return uv.h("path",{attributes:{d:h,fill:i},namespace:this._svgNamespace},[])}}$T.componentName="bearing";class VT extends fT{constructor(e,t,i){super(e,t,i)}setDepth(e){this.configure({depth:e})}_activate(){this._sequenceSubscription=B_(this._navigator.stateService.currentNode$.pipe(Ab((e=>e.sequenceEdges$)),Ry((e=>e.cached))),this._configuration$).pipe(Ab((t=>{let i=t[0],r=t[1],n=Math.max(0,Math.min(4,r.depth.sequence));return X_(this._cache$(i.edges,e.EdgeDirection.Next,n),this._cache$(i.edges,e.EdgeDirection.Prev,n)).pipe(ly(((e,t)=>(console.error("Failed to cache sequence edges.",e),t_))))}))).subscribe((()=>{})),this._spatialSubscription=this._navigator.stateService.currentNode$.pipe(Ab((e=>B_(a_(e),e.spatialEdges$.pipe(Ry((e=>e.cached)))))),fy(this._configuration$,((e,t)=>[e[0],e[1],t])),Ab((t=>{let i=t[0],r=t[1].edges,n=t[2].depth,o=Math.max(0,Math.min(2,n.pano)),s=i.pano?0:Math.max(0,Math.min(3,n.step)),a=i.pano?0:Math.max(0,Math.min(1,n.turn)),c=this._cache$(r,e.EdgeDirection.Pano,o);return X_(this._cache$(r,e.EdgeDirection.StepForward,s),this._cache$(r,e.EdgeDirection.StepBackward,s),this._cache$(r,e.EdgeDirection.StepLeft,s),this._cache$(r,e.EdgeDirection.StepRight,s),c,this._cache$(r,e.EdgeDirection.TurnLeft,a),this._cache$(r,e.EdgeDirection.TurnRight,a),this._cache$(r,e.EdgeDirection.TurnU,a)).pipe(ly(((e,t)=>(console.error("Failed to cache spatial edges.",e),t_))))}))).subscribe((()=>{}))}_deactivate(){this._sequenceSubscription.unsubscribe(),this._spatialSubscription.unsubscribe()}_getDefaultConfiguration(){return{depth:{pano:1,sequence:2,step:1,turn:0}}}_cache$(e,t,i){return K_(a_(e),a_(i)).pipe(Uy((e=>{let i=e[0],r=e[1],n=[];if(r>0)for(let e of i)e.data.direction===t&&n.push(K_(this._navigator.graphService.cacheNode$(e.to).pipe($_((e=>this._nodeToEdges$(e,t)))),a_(r-1)));return z_(n).pipe(G_())})),gb(1))}_nodeToEdges$(t,i){return([e.EdgeDirection.Next,e.EdgeDirection.Prev].indexOf(i)>-1?t.sequenceEdges$:t.spatialEdges$).pipe(Yy((e=>e.cached)),w_((e=>e.edges)))}}VT.componentName="cache";class UT extends fT{constructor(e,t,i){super(e,t,i)}_activate(){this._keyDisposable=this._navigator.stateService.currentNode$.pipe(Lb(this._configuration$,((e,t)=>[e,t])),Ry((([e,t])=>e.key!==t.key)),w_((([e,t])=>e)),w_((e=>({key:e.key,src:e.image.src})))).subscribe(this._configurationSubject$),this._disposable=this._configuration$.pipe(w_((t=>t.key?t.state===e.CoverState.Hidden?{name:this._name,vnode:uv.h("div.Cover.CoverDone",[this._getCoverBackgroundVNode(t)])}:{name:this._name,vnode:this._getCoverButtonVNode(t)}:{name:this._name,vnode:uv.h("div",[])}))).subscribe(this._container.domRenderer.render$)}_deactivate(){this._disposable.unsubscribe(),this._keyDisposable.unsubscribe()}_getDefaultConfiguration(){return{state:e.CoverState.Visible}}_getCoverButtonVNode(t){const i=t.state===e.CoverState.Loading?"div.Cover.CoverLoading":"div.Cover";return uv.h(i,[this._getCoverBackgroundVNode(t),uv.h("button.CoverButton",{onclick:()=>{this.configure({state:e.CoverState.Loading})}},["Explore"]),uv.h("a.CoverLogo",{href:"",target:""},[])])}_getCoverBackgroundVNode(t){let i={style:{backgroundImage:null!=t.src?`url(${t.src})`:Wb.thumbnail(t.key)}},r=[];return t.state===e.CoverState.Loading&&(r.push(uv.h("div.Logo",{},[])),r.push(uv.h("div.LogoText",{},[]))),r.push(uv.h("div.CoverBackgroundGradient",{},[])),uv.h("div.CoverBackground",i,r)}}UT.componentName="cover",Kb.registerCover(UT);class GT extends fT{constructor(e,t,i){super(e,t,i),this._open$=new Qv(!1),this._displaying=!1}_activate(){this._disposable=this._navigator.stateService.currentState$.pipe(fy(this._open$,this._navigator.imageLoadingService.loadstatus$,((e,t,i)=>({name:this._name,vnode:this._getDebugVNode(t,this._getDebugInfo(e,i))})))).subscribe(this._container.domRenderer.render$)}_deactivate(){this._disposable.unsubscribe()}_getDefaultConfiguration(){return{}}_getDebugInfo(e,t){let i=[];i.push(uv.h("h2","Node")),e.state.currentNode&&i.push(uv.h("p",`currentNode: ${e.state.currentNode.key}`)),e.state.previousNode&&i.push(uv.h("p",`previousNode: ${e.state.previousNode.key}`)),i.push(uv.h("h2","Loading"));let r=0,n=0,o=0;for(let e of Rp(t))r+=e.loaded,e.loaded!==e.total?o++:n++;return i.push(uv.h("p",`Loaded Images: ${n}`)),i.push(uv.h("p",`Loading Images: ${o}`)),i.push(uv.h("p",`Total bytes loaded: ${r}`)),i.push(uv.h("h2","Camera")),i.push(uv.h("p",`camera.position.x: ${e.state.camera.position.x}`)),i.push(uv.h("p",`camera.position.y: ${e.state.camera.position.y}`)),i.push(uv.h("p",`camera.position.z: ${e.state.camera.position.z}`)),i.push(uv.h("p",`camera.lookat.x: ${e.state.camera.lookat.x}`)),i.push(uv.h("p",`camera.lookat.y: ${e.state.camera.lookat.y}`)),i.push(uv.h("p",`camera.lookat.z: ${e.state.camera.lookat.z}`)),i.push(uv.h("p",`camera.up.x: ${e.state.camera.up.x}`)),i.push(uv.h("p",`camera.up.y: ${e.state.camera.up.y}`)),i.push(uv.h("p",`camera.up.z: ${e.state.camera.up.z}`)),i}_getDebugVNode(e,t){return e?uv.h("div.Debug",{},[uv.h("h2",{},["Debug"]),this._getDebugVNodeButton(e),uv.h("pre",{},t)]):this._getDebugVNodeButton(e)}_getDebugVNodeButton(e){let t=e?"Disable Debug":"D",i=e?"":".DebugButtonFixed";return e?uv.h(`button.DebugButton${i}`,{onclick:this._closeDebugElement.bind(this)},[t]):uv.h(`button.DebugButton${i}`,{onclick:this._openDebugElement.bind(this)},[t])}_closeDebugElement(e){this._open$.next(!1)}_openDebugElement(){this._open$.next(!0)}}GT.componentName="debug";class HT{constructor(e,t){this._spatial=new Hu,this._minThresholdWidth=320,this._maxThresholdWidth=1480,this._minThresholdHeight=240,this._maxThresholdHeight=820,this._configure(e),this._resize(t),this._reset()}get minWidth(){return this._minWidth}get maxWidth(){return this._maxWidth}get containerWidth(){return this._containerWidth}get containerWidthCss(){return this._containerWidthCss}get containerMarginCss(){return this._containerMarginCss}get containerLeftCss(){return this._containerLeftCss}get containerHeight(){return this._containerHeight}get containerHeightCss(){return this._containerHeightCss}get containerBottomCss(){return this._containerBottomCss}get stepCircleSize(){return this._stepCircleSize}get stepCircleSizeCss(){return this._stepCircleSizeCss}get stepCircleMarginCss(){return this._stepCircleMarginCss}get turnCircleSize(){return this._turnCircleSize}get turnCircleSizeCss(){return this._turnCircleSizeCss}get outerRadius(){return this._outerRadius}get innerRadius(){return this._innerRadius}get shadowOffset(){return this._shadowOffset}configure(e){this._configure(e),this._reset()}resize(e){this._resize(e),this._reset()}angleToCoordinates(e){return[Math.cos(e),Math.sin(e)]}relativeAngleToCoordiantes(e,t){let i=this._spatial.wrapAngle(e-t);return this.angleToCoordinates(i)}_configure(e){this._minWidth=e.minWidth,this._maxWidth=this._getMaxWidth(e.minWidth,e.maxWidth)}_resize(e){this._elementWidth=e.offsetWidth,this._elementHeight=e.offsetHeight}_reset(){this._containerWidth=this._getContainerWidth(this._elementWidth,this._elementHeight),this._containerHeight=this._getContainerHeight(this.containerWidth),this._stepCircleSize=this._getStepCircleDiameter(this._containerHeight),this._turnCircleSize=this._getTurnCircleDiameter(this.containerHeight),this._outerRadius=this._getOuterRadius(this._containerHeight),this._innerRadius=this._getInnerRadius(this._containerHeight),this._shadowOffset=3,this._containerWidthCss=this._numberToCssPixels(this._containerWidth),this._containerMarginCss=this._numberToCssPixels(-.5*this._containerWidth),this._containerLeftCss=this._numberToCssPixels(Math.floor(.5*this._elementWidth)),this._containerHeightCss=this._numberToCssPixels(this._containerHeight),this._containerBottomCss=this._numberToCssPixels(Math.floor(-.08*this._containerHeight)),this._stepCircleSizeCss=this._numberToCssPixels(this._stepCircleSize),this._stepCircleMarginCss=this._numberToCssPixels(-.5*this._stepCircleSize),this._turnCircleSizeCss=this._numberToCssPixels(this._turnCircleSize)}_getContainerWidth(e,t){let i=(e-this._minThresholdWidth)/(this._maxThresholdWidth-this._minThresholdWidth),r=(t-this._minThresholdHeight)/(this._maxThresholdHeight-this._minThresholdHeight),n=Math.max(0,Math.min(1,Math.min(i,r)));return n=.04*Math.round(25*n),this._minWidth+n*(this._maxWidth-this._minWidth)}_getContainerHeight(e){return.77*e}_getStepCircleDiameter(e){return.34*e}_getTurnCircleDiameter(e){return.3*e}_getOuterRadius(e){return.31*e}_getInnerRadius(e){return.125*e}_numberToCssPixels(e){return e+"px"}_getMaxWidth(e,t){return e>t?e:t}}class qT{constructor(t,i){this._isEdge=!1,this._spatial=new Hu,this._calculator=new HT(t,i),this._node=null,this._rotation={phi:0,theta:0},this._epsilon=.5*Math.PI/180,this._highlightKey=null,this._distinguishSequence=!1,this._needsRender=!1,this._stepEdges=[],this._turnEdges=[],this._panoEdges=[],this._sequenceEdgeKeys=[],this._stepDirections=[e.EdgeDirection.StepForward,e.EdgeDirection.StepBackward,e.EdgeDirection.StepLeft,e.EdgeDirection.StepRight],this._turnDirections=[e.EdgeDirection.TurnLeft,e.EdgeDirection.TurnRight,e.EdgeDirection.TurnU],this._turnNames={},this._turnNames[e.EdgeDirection.TurnLeft]="TurnLeft",this._turnNames[e.EdgeDirection.TurnRight]="TurnRight",this._turnNames[e.EdgeDirection.TurnU]="TurnAround";let r=!!document.documentMode;this._isEdge=!r&&!!window.StyleMedia}get needsRender(){return this._needsRender}render(e){this._needsRender=!1;let t=this._rotation,i=[],r=[];return this._node.pano?i=i.concat(this._createPanoArrows(e,t)):(i=i.concat(this._createPerspectiveToPanoArrows(e,t)),i=i.concat(this._createStepArrows(e,t)),r=r.concat(this._createTurnArrows(e))),this._getContainer(i,r,t)}setEdges(e,t){this._setEdges(e,t),this._setNeedsRender()}setNode(e){this._node=e,this._clearEdges(),this._setNeedsRender()}setRenderCamera(e){let t=e.rotation;Math.abs(t.phi-this._rotation.phi)<this._epsilon||(this._rotation=t,this._setNeedsRender())}setConfiguration(e){let t=!1;this._highlightKey===e.highlightKey&&this._distinguishSequence===e.distinguishSequence||(this._highlightKey=e.highlightKey,this._distinguishSequence=e.distinguishSequence,t=!0),this._calculator.minWidth===e.minWidth&&this._calculator.maxWidth===e.maxWidth||(this._calculator.configure(e),t=!0),t&&this._setNeedsRender()}resize(e){this._calculator.resize(e),this._setNeedsRender()}_setNeedsRender(){null!=this._node&&(this._needsRender=!0)}_clearEdges(){this._stepEdges=[],this._turnEdges=[],this._panoEdges=[],this._sequenceEdgeKeys=[]}_setEdges(t,i){this._stepEdges=[],this._turnEdges=[],this._panoEdges=[],this._sequenceEdgeKeys=[];for(let i of t.edges){let t=i.data.direction;this._stepDirections.indexOf(t)>-1?this._stepEdges.push(i):this._turnDirections.indexOf(t)>-1?this._turnEdges.push(i):i.data.direction===e.EdgeDirection.Pano&&this._panoEdges.push(i)}if(this._distinguishSequence&&null!=i){let e=this._panoEdges.concat(this._stepEdges).concat(this._turnEdges);for(let t of e){let e=t.to;for(let t of i.keys)if(t===e){this._sequenceEdgeKeys.push(e);break}}}}_createPanoArrows(e,t){let i=[];for(let r of this._panoEdges)i.push(this._createVNodeByKey(e,r.to,r.data.worldMotionAzimuth,t,this._calculator.outerRadius,"DirectionsArrowPano"));for(let r of this._stepEdges)i.push(this._createPanoToPerspectiveArrow(e,r.to,r.data.worldMotionAzimuth,t,r.data.direction));return i}_createPanoToPerspectiveArrow(t,i,r,n,o){let s=Math.PI/8,a=n.phi;switch(o){case e.EdgeDirection.StepBackward:a=n.phi-Math.PI;break;case e.EdgeDirection.StepLeft:a=n.phi+Math.PI/2;break;case e.EdgeDirection.StepRight:a=n.phi-Math.PI/2}return Math.abs(this._spatial.wrapAngle(r-a))<s?this._createVNodeByKey(t,i,r,n,this._calculator.outerRadius,"DirectionsArrowStep"):this._createVNodeDisabled(i,r,n)}_createPerspectiveToPanoArrows(e,t){let i=[];for(let r of this._panoEdges)i.push(this._createVNodeByKey(e,r.to,r.data.worldMotionAzimuth,t,this._calculator.innerRadius,"DirectionsArrowPano",!0));return i}_createStepArrows(e,t){let i=[];for(let r of this._stepEdges)i.push(this._createVNodeByDirection(e,r.to,r.data.worldMotionAzimuth,t,r.data.direction));return i}_createTurnArrows(e){let t=[];for(let i of this._turnEdges){let r=i.data.direction,n=this._turnNames[r];t.push(this._createVNodeByTurn(e,i.to,n,r))}return t}_createVNodeByKey(e,t,i,r,n,o,s){return this._createVNode(t,i,r,n,o,"DirectionsCircle",(i=>{e.moveToKey$(t).subscribe((e=>{}),(e=>{console.error(e)}))}),s)}_createVNodeByDirection(e,t,i,r,n){return this._createVNode(t,i,r,this._calculator.outerRadius,"DirectionsArrowStep","DirectionsCircle",(t=>{e.moveDir$(n).subscribe((e=>{}),(e=>{console.error(e)}))}))}_createVNodeByTurn(t,i,r,n){let o={height:this._calculator.turnCircleSizeCss,transform:"rotate(0)",width:this._calculator.turnCircleSizeCss};switch(n){case e.EdgeDirection.TurnLeft:o.left="5px",o.top="5px";break;case e.EdgeDirection.TurnRight:o.right="5px",o.top="5px";break;case e.EdgeDirection.TurnU:o.left="5px",o.bottom="5px"}let s={attributes:{"data-key":i},onclick:e=>{t.moveDir$(n).subscribe((e=>{}),(e=>{console.error(e)}))},style:o},a="TurnCircle";this._sequenceEdgeKeys.indexOf(i)>-1&&(a+="Sequence"),this._highlightKey===i&&(a+="Highlight");let c=uv.h(`div.${r}`,{},[]);return uv.h("div."+a,s,[c])}_createVNodeDisabled(e,t,i){return this._createVNode(e,t,i,this._calculator.outerRadius,"DirectionsArrowDisabled","DirectionsCircleDisabled")}_createVNode(e,t,i,r,n,o,s,a){let c=this._calculator.angleToCoordinates(t-i.phi),h=Math.round(-r*c[1]+.5*this._calculator.containerWidth),u=Math.round(-r*c[0]+.5*this._calculator.containerHeight),l=this._calculator.relativeAngleToCoordiantes(t,i.phi),p=this._calculator.shadowOffset,d=`drop-shadow(${-p*l[1]}px ${p*l[0]}px 1px rgba(0,0,0,0.8))`,f={style:{"-webkit-filter":d,filter:d}},m=uv.h("div."+n,f,[]),g=-this._spatial.radToDeg(t-i.phi),v=a?`translate(${h}px, ${u}px) rotate(${g}deg) translateZ(-0.01px)`:`translate(${h}px, ${u}px) rotate(${g}deg)`,_={attributes:{"data-key":e},onclick:s,style:{height:this._calculator.stepCircleSizeCss,marginLeft:this._calculator.stepCircleMarginCss,marginTop:this._calculator.stepCircleMarginCss,transform:v,width:this._calculator.stepCircleSizeCss}};return this._sequenceEdgeKeys.indexOf(e)>-1&&(o+="Sequence"),this._highlightKey===e&&(o+="Highlight"),uv.h("div."+o,_,[m])}_getContainer(e,t,i){let r=this._isEdge?"rotateX(60deg)":`perspective(${this._calculator.containerWidthCss}) rotateX(60deg)`,n={oncontextmenu:e=>{e.preventDefault()},style:{bottom:this._calculator.containerBottomCss,height:this._calculator.containerHeightCss,left:this._calculator.containerLeftCss,marginLeft:this._calculator.containerMarginCss,transform:r,width:this._calculator.containerWidthCss}};return uv.h("div.DirectionsPerspective",n,t.concat(e))}}class WT extends fT{constructor(e,t,i,r){super(e,t,i),this._renderer=r||new qT(this.defaultConfiguration,t.element),this._hoveredKeySubject$=new zv,this._hoveredKey$=this._hoveredKeySubject$.pipe(mb())}get hoveredKey$(){return this._hoveredKey$}setHighlightKey(e){this.configure({highlightKey:e})}setMinWidth(e){this.configure({minWidth:e})}setMaxWidth(e){this.configure({maxWidth:e})}resize(){this._renderer.resize(this._container.element)}_activate(){this._configurationSubscription=this._configuration$.subscribe((e=>{this._renderer.setConfiguration(e)})),this._nodeSubscription=this._navigator.stateService.currentNode$.pipe(Ly((e=>{this._container.domRenderer.render$.next({name:this._name,vnode:uv.h("div",{},[])}),this._renderer.setNode(e)})),Lb(this._configuration$),Ab((([e,t])=>B_(e.spatialEdges$,t.distinguishSequence?this._navigator.graphService.cacheSequence$(e.sequenceKey).pipe(ly(((t,i)=>(console.error(`Failed to cache sequence (${e.sequenceKey})`,t),a_(null))))):a_(null))))).subscribe((([e,t])=>{this._renderer.setEdges(e,t)})),this._renderCameraSubscription=this._container.renderService.renderCameraFrame$.pipe(Ly((e=>{this._renderer.setRenderCamera(e)})),w_((e=>this._renderer)),Ry((e=>e.needsRender)),w_((e=>({name:this._name,vnode:e.render(this._navigator)})))).subscribe(this._container.domRenderer.render$),this._hoveredKeySubscription=B_([this._container.domRenderer.element$,this._container.renderService.renderCamera$,this._container.mouseService.mouseMove$.pipe(wb(null)),this._container.mouseService.mouseUp$.pipe(wb(null))],((e,t,i,r)=>e)).pipe(w_((e=>{let t=e.getElementsByClassName("DirectionsPerspective");for(let e=0;e<t.length;e++){let i=t.item(e).querySelector(":hover");if(null!=i&&i.hasAttribute("data-key"))return i.getAttribute("data-key")}return null})),Iy()).subscribe(this._hoveredKeySubject$)}_deactivate(){this._configurationSubscription.unsubscribe(),this._nodeSubscription.unsubscribe(),this._renderCameraSubscription.unsubscribe(),this._hoveredKeySubscription.unsubscribe()}_getDefaultConfiguration(){return{distinguishSequence:!1,maxWidth:460,minWidth:260}}}WT.componentName="direction";class QT extends fT{constructor(e,t,i,r){super(e,t,i),this._canvasId=`${t.id}-${this._name}`,this._dom=r||new Gb}_activate(){const e=this._container.domRenderer.element$.pipe(w_((e=>this._dom.document.getElementById(this._canvasId))),Ry((e=>!!e)),w_((e=>{const t=e.parentElement,i=t.offsetWidth;return[e,{height:t.offsetHeight,width:i}]})),Iy(((e,t)=>e.height===t.height&&e.width===t.width),(([e,t])=>t)));this.drawSubscription=B_(e,this._navigator.stateService.currentNode$).subscribe((([[e,t],i])=>{e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(i.image,0,0,t.width,t.height)})),this._container.domRenderer.renderAdaptive$.next({name:this._name,vnode:uv.h(`canvas#${this._canvasId}`,[])})}_deactivate(){this.drawSubscription.unsubscribe()}_getDefaultConfiguration(){return{}}}QT.componentName="image";class YT extends mT{constructor(e,t,i,r){super(e,t,i),this._viewportCoords=r}_enable(){this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(Lb(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i])=>{if(e.altKey||e.shiftKey||e.ctrlKey||e.metaKey)return;let r=0;switch(e.key){case"+":r=1;break;case"-":r=-1;break;default:return}e.preventDefault();const n=this._viewportCoords.unprojectFromViewport(0,0,t.perspective),o=i.projectBasic(n.toArray());this._navigator.stateService.zoomIn(r,o)}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(e){return{keyZoom:e}}}class XT extends mT{_enable(){const t=this._navigator.stateService.currentNode$.pipe(Ab((e=>e.sequenceEdges$)));this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(Lb(t)).subscribe((([t,i])=>{let r=null;switch(t.keyCode){case 38:r=e.EdgeDirection.Next;break;case 40:r=e.EdgeDirection.Prev;break;default:return}if(t.preventDefault(),t.altKey&&!t.shiftKey&&i.cached)for(const e of i.edges)if(e.data.direction===r)return void this._navigator.moveToKey$(e.to).subscribe((e=>{}),(e=>{console.error(e)}))}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(e){return{keySequenceNavigation:e}}}class ZT extends mT{constructor(e,t,i,r){super(e,t,i),this._spatial=r}_enable(){const t=this._navigator.stateService.currentNode$.pipe(Ab((e=>e.spatialEdges$)));this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(Lb(t,this._navigator.stateService.currentState$)).subscribe((([t,i,r])=>{let n=r.state.currentNode.pano,o=null;switch(t.keyCode){case 37:o=t.shiftKey&&!n?e.EdgeDirection.TurnLeft:e.EdgeDirection.StepLeft;break;case 38:o=t.shiftKey&&!n?e.EdgeDirection.Pano:e.EdgeDirection.StepForward;break;case 39:o=t.shiftKey&&!n?e.EdgeDirection.TurnRight:e.EdgeDirection.StepRight;break;case 40:o=t.shiftKey&&!n?e.EdgeDirection.TurnU:e.EdgeDirection.StepBackward;break;default:return}if(t.preventDefault(),!(t.altKey||!i.cached||t.shiftKey&&n))if(n){const t={};t[e.EdgeDirection.StepBackward]=Math.PI,t[e.EdgeDirection.StepForward]=0,t[e.EdgeDirection.StepLeft]=Math.PI/2,t[e.EdgeDirection.StepRight]=-Math.PI/2;const n=this._rotationFromCamera(r.state.camera).phi,s=this._spatial.wrapAngle(n+t[o]),a=Math.PI/4,c=i.edges.filter((t=>t.data.direction===e.EdgeDirection.Pano||t.data.direction===o));let h=Number.MAX_VALUE,u=null;for(const e of c){const t=Math.abs(this._spatial.wrapAngle(e.data.worldMotionAzimuth-s));t<Math.min(h,a)&&(h=t,u=e.to)}if(null==u)return;this._moveToKey(u)}else this._moveDir(o,i)}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(e){return{keySpatialNavigation:e}}_moveDir(e,t){for(const i of t.edges)if(i.data.direction===e)return void this._moveToKey(i.to)}_moveToKey(e){this._navigator.moveToKey$(e).subscribe((e=>{}),(e=>{console.error(e)}))}_rotationFromCamera(e){let t=e.lookat.clone().sub(e.position),i=t.clone().dot(e.up),r=t.clone().sub(e.up.clone().multiplyScalar(i));return{phi:Math.atan2(r.y,r.x),theta:Math.PI/2-this._spatial.angleToPlane(t.toArray(),[0,0,1])}}}class KT extends fT{constructor(e,t,i){super(e,t,i),this._keyZoomHandler=new YT(this,t,i,new Gu),this._keySequenceNavigationHandler=new XT(this,t,i),this._keySpatialNavigationHandler=new ZT(this,t,i,new Hu)}get keyZoom(){return this._keyZoomHandler}get keySequenceNavigation(){return this._keySequenceNavigationHandler}get keySpatialNavigation(){return this._keySpatialNavigationHandler}_activate(){this._configurationSubscription=this._configuration$.subscribe((e=>{e.keyZoom?this._keyZoomHandler.enable():this._keyZoomHandler.disable(),e.keySequenceNavigation?this._keySequenceNavigationHandler.enable():this._keySequenceNavigationHandler.disable(),e.keySpatialNavigation?this._keySpatialNavigationHandler.enable():this._keySpatialNavigationHandler.disable()}))}_deactivate(){this._configurationSubscription.unsubscribe()}_getDefaultConfiguration(){return{keySequenceNavigation:!0,keySpatialNavigation:!0,keyZoom:!0}}}KT.componentName="keyboard";class JT extends fT{constructor(e,t,i){super(e,t,i)}_activate(){this._loadingSubscription=this._navigator.loadingService.loading$.pipe(fy(this._navigator.imageLoadingService.loadstatus$,((e,t)=>{if(!e)return{name:"loading",vnode:this._getBarVNode(100)};let i=0,r=0;for(let e of Rp(t))e.loaded!==e.total&&(r+=e.loaded,i+=e.total);let n=100;return 0!==i&&(n=r/i*100),{name:this._name,vnode:this._getBarVNode(n)}}))).subscribe(this._container.domRenderer.render$)}_deactivate(){this._loadingSubscription.unsubscribe()}_getDefaultConfiguration(){return{}}_getBarVNode(e){let t={};return 100!==e?(t.width=e.toFixed(0)+"%",t.opacity="1"):(t.width="100%",t.opacity="0"),uv.h("div.Loading",{style:{}},[uv.h("div.LoadingBar",{style:t},[])])}}JT.componentName="loading";class eC extends mT{constructor(e,t,i,r,n){super(e,t,i),this._spatial=n,this._viewportCoords=r,this._basicDistanceThreshold=.001,this._basicRotationThreshold=.05,this._bounceCoeff=.1}_enable(){const e=this._navigator.stateService.currentState$.pipe(w_((e=>e.state.alpha<1)));this._bounceSubscription=B_(e,this._navigator.stateService.inTranslation$,this._container.mouseService.active$,this._container.touchService.active$).pipe(w_((e=>e[0]||e[1]||e[2]||e[3])),Iy(),Ab((e=>e?i_():B_(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$.pipe(Yy()))))).subscribe((e=>{let t=e[0],i=t.perspective,r=e[1];if(!r.hasValidScale&&t.camera.focal<.1)return;if(0===t.perspective.aspect||t.perspective.aspect===Number.POSITIVE_INFINITY)return;let n=this._basicDistanceThreshold/Math.pow(2,t.zoom),o=this._viewportCoords.viewportToBasic(0,0,r,i);if(Math.abs(o[0]-.5)<n&&Math.abs(o[1]-.5)<n)return;let s=this._viewportCoords.getBasicDistances(r,i),a=0,c=0;if(s[0]<n&&s[1]<n&&s[2]<n&&s[3]<n)return;if(Math.abs(s[0]-s[2])<n&&Math.abs(s[1]-s[3])<n)return;let h=this._bounceCoeff;s[1]>0&&0===s[3]?a=-h*s[1]:0===s[1]&&s[3]>0?a=h*s[3]:s[1]>0&&s[3]>0&&(a=h*(s[3]-s[1])/2),s[0]>0&&0===s[2]?c=h*s[0]:0===s[0]&&s[2]>0?c=-h*s[2]:s[0]>0&&s[2]>0&&(c=h*(s[0]-s[2])/2);let u=this._basicRotationThreshold;a=this._spatial.clamp(a,-u,u),c=this._spatial.clamp(c,-u,u),this._navigator.stateService.rotateBasicUnbounded([a,c])}))}_disable(){this._bounceSubscription.unsubscribe()}_getConfiguration(e){return{}}}class tC extends mT{constructor(e,t,i,r){super(e,t,i),this._viewportCoords=r}_enable(){this._zoomSubscription=X_(this._container.mouseService.filtered$(this._component.name,this._container.mouseService.dblClick$),this._container.touchService.doubleTap$.pipe(w_((e=>{let t=e.touches[0];return{clientX:t.clientX,clientY:t.clientY,shiftKey:e.shiftKey}})))).pipe(Lb(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i])=>{const r=this._container.element,[n,o]=this._viewportCoords.canvasPosition(e,r),s=this._viewportCoords.unprojectFromCanvas(n,o,r,t.perspective),a=i.projectBasic(s.toArray()),c=e.shiftKey?-1:1;this._navigator.stateService.zoomIn(c,a)}))}_disable(){this._zoomSubscription.unsubscribe()}_getConfiguration(e){return{doubleClickZoom:e}}}class iC extends mT{constructor(e,t,i,r,n){super(e,t,i),this._spatial=n,this._viewportCoords=r,this._basicRotationThreshold=.05,this._forceCoeff=.2}_enable(){let e=this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragStart$).pipe(w_((e=>!0))),t=this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragEnd$).pipe(w_((e=>!1)));this._activeMouseSubscription=X_(e,t).subscribe(this._container.mouseService.activate$),this._preventDefaultSubscription=X_(e,t).pipe(Ab((e=>e?this._container.mouseService.documentMouseMove$:i_())),rb(this._container.touchService.touchMove$)).subscribe((e=>{e.preventDefault()}));let i=this._container.touchService.singleTouchDragStart$.pipe(w_((e=>!0))),r=this._container.touchService.singleTouchDragEnd$.pipe(w_((e=>!1)));this._activeTouchSubscription=X_(i,r).subscribe(this._container.touchService.activate$);const n=this._navigator.stateService.currentState$.pipe(w_((e=>e.state.currentNode.fullPano||e.state.nodesAhead<1)),Iy(),Ab((e=>{if(!e)return i_();const t=this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragStart$).pipe(Ab((e=>{return a_(e).pipe(my(this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDrag$)),rb(this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragEnd$).pipe(w_((e=>null)))),(t=e=>!!e,void 0===i&&(i=!1),function(e){return e.lift(new Ib(t,i))}),wb(null));var t,i})),sb(),Ry((e=>null!=e[0]&&null!=e[1]))),i=X_(this._container.touchService.singleTouchDragStart$,this._container.touchService.singleTouchDrag$,this._container.touchService.singleTouchDragEnd$.pipe(w_((e=>null)))).pipe(w_((e=>null!=e&&e.touches.length>0?e.touches[0]:null)),sb(),Ry((e=>null!=e[0]&&null!=e[1])));return X_(t,i)})),Lb(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$,this._navigator.stateService.currentCamera$),w_((([e,t,i,r])=>{let n=r.clone(),o=e[0],s=e[1],a=s.clientX-o.clientX,c=s.clientY-o.clientY,h=this._container.element,[u,l]=this._viewportCoords.canvasPosition(s,h),p=this._viewportCoords.unprojectFromCanvas(u,l,h,t.perspective).sub(t.perspective.position),d=this._viewportCoords.unprojectFromCanvas(u-a,l,h,t.perspective).sub(t.perspective.position),f=this._viewportCoords.unprojectFromCanvas(u,l-c,h,t.perspective).sub(t.perspective.position),m=(a>0?1:-1)*d.angleTo(p),g=(c>0?-1:1)*f.angleTo(p),v=(new ie).setFromUnitVectors(n.up,new oe(0,0,1)),_=v.clone().inverse(),y=new oe;y.copy(n.lookat).sub(n.position),y.applyQuaternion(v);let b=y.length(),x=Math.atan2(y.y,y.x);x+=m;let w=Math.atan2(Math.sqrt(y.x*y.x+y.y*y.y),y.z);w+=g,w=Math.max(.01,Math.min(Math.PI-.01,w)),y.x=Math.sin(w)*Math.cos(x),y.y=Math.sin(w)*Math.sin(x),y.z=Math.cos(w),y.applyQuaternion(_);let A=(new oe).copy(n.position).add(y.multiplyScalar(b)),S=i.projectBasic(A.toArray()),M=i.projectBasic(n.lookat.toArray()),E=S[0]-M[0],T=S[1]-M[1];Math.abs(E)>1?E=0:E>.5?E-=1:E<-.5&&(E+=1);let C=this._basicRotationThreshold;if(E=this._spatial.clamp(E,-C,C),T=this._spatial.clamp(T,-C,C),i.fullPano)return[E,T];let I=this._viewportCoords.getPixelDistances(this._container.element,i,t.perspective),N=this._forceCoeff;return I[0]>0&&T<0&&S[1]<.5&&(T/=Math.max(1,N*I[0])),I[1]>0&&E>0&&S[0]>.5&&(E/=Math.max(1,N*I[1])),I[2]>0&&T>0&&S[1]>.5&&(T/=Math.max(1,N*I[2])),I[3]>0&&E<0&&S[0]<.5&&(E/=Math.max(1,N*I[3])),[E,T]})),mb());var o;this._rotateBasicWithoutInertiaSubscription=n.subscribe((e=>{this._container.renderService.panWithoutInertia$.next(e),this._navigator.stateService.rotateBasicWithoutInertia(e)})),this._rotateBasicSubscription=n.pipe(eb(((e,t)=>(this._drainBuffer(e),e.push([Date.now(),t]),e)),[]),(o=X_(this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragEnd$),this._container.touchService.singleTouchDragEnd$),function(e){return e.lift(new pb(o))}),w_((e=>{const t=this._drainBuffer(e.slice()),i=[0,0];for(const e of t)i[0]+=e[1][0],i[1]+=e[1][1];const r=t.length;return r>0&&(i[0]/=r,i[1]/=r),i}))).subscribe((e=>{this._container.renderService.pan$.next(e),this._navigator.stateService.rotateBasic(e)}))}_disable(){this._activeMouseSubscription.unsubscribe(),this._activeTouchSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._rotateBasicSubscription.unsubscribe(),this._rotateBasicWithoutInertiaSubscription.unsubscribe(),this._activeMouseSubscription=null,this._activeTouchSubscription=null,this._preventDefaultSubscription=null,this._rotateBasicSubscription=null}_getConfiguration(e){return{dragPan:e}}_drainBuffer(e){const t=Date.now();for(;e.length>0&&t-e[0][0]>50;)e.shift();return e}}class rC extends mT{constructor(e,t,i,r){super(e,t,i),this._viewportCoords=r}_enable(){this._container.mouseService.claimWheel(this._component.name,0),this._preventDefaultSubscription=this._container.mouseService.mouseWheel$.subscribe((e=>{e.preventDefault()})),this._zoomSubscription=this._container.mouseService.filteredWheel$(this._component.name,this._container.mouseService.mouseWheel$).pipe(Lb(this._navigator.stateService.currentState$,((e,t)=>[e,t])),Ry((e=>{let t=e[1].state;return t.currentNode.fullPano||t.nodesAhead<1})),w_((e=>e[0])),Lb(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$,((e,t,i)=>[e,t,i]))).subscribe((e=>{let t=e[0],i=e[1],r=e[2],n=this._container.element,[o,s]=this._viewportCoords.canvasPosition(t,n),a=this._viewportCoords.unprojectFromCanvas(o,s,n,i.perspective),c=r.projectBasic(a.toArray()),h=t.deltaY;1===t.deltaMode?h*=40:2===t.deltaMode&&(h*=800);let u=-3*h/this._viewportCoords.containerToCanvas(n)[1];this._navigator.stateService.zoomIn(u,c)}))}_disable(){this._container.mouseService.unclaimWheel(this._component.name),this._preventDefaultSubscription.unsubscribe(),this._zoomSubscription.unsubscribe(),this._preventDefaultSubscription=null,this._zoomSubscription=null}_getConfiguration(e){return{scrollZoom:e}}}class nC extends mT{constructor(e,t,i,r){super(e,t,i),this._viewportCoords=r}_enable(){this._preventDefaultSubscription=this._container.touchService.pinch$.subscribe((e=>{e.originalEvent.preventDefault()}));let e=this._container.touchService.pinchStart$.pipe(w_((e=>!0))),t=this._container.touchService.pinchEnd$.pipe(w_((e=>!1)));this._activeSubscription=X_(e,t).subscribe(this._container.touchService.activate$),this._zoomSubscription=this._container.touchService.pinch$.pipe(Lb(this._navigator.stateService.currentState$),Ry((e=>{let t=e[1].state;return t.currentNode.fullPano||t.nodesAhead<1})),w_((e=>e[0])),Lb(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i])=>{let r=this._container.element,[n,o]=this._viewportCoords.canvasPosition(e,r),s=this._viewportCoords.unprojectFromCanvas(n,o,r,t.perspective),a=i.projectBasic(s.toArray());const[c,h]=this._viewportCoords.containerToCanvas(r);let u=3*e.distanceChange/Math.min(c,h);this._navigator.stateService.zoomIn(u,a)}))}_disable(){this._activeSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._zoomSubscription.unsubscribe(),this._preventDefaultSubscription=null,this._zoomSubscription=null}_getConfiguration(e){return{touchZoom:e}}}class oC extends fT{constructor(e,t,i){super(e,t,i);let r=new Hu,n=new Gu;this._spatial=r,this._viewportCoords=n,this._bounceHandler=new eC(this,t,i,n,r),this._doubleClickZoomHandler=new tC(this,t,i,n),this._dragPanHandler=new iC(this,t,i,n,r),this._scrollZoomHandler=new rC(this,t,i,n),this._touchZoomHandler=new nC(this,t,i,n)}get doubleClickZoom(){return this._doubleClickZoomHandler}get dragPan(){return this._dragPanHandler}get scrollZoom(){return this._scrollZoomHandler}get touchZoom(){return this._touchZoomHandler}_activate(){this._bounceHandler.enable(),this._configurationSubscription=this._configuration$.subscribe((e=>{e.doubleClickZoom?this._doubleClickZoomHandler.enable():this._doubleClickZoomHandler.disable(),e.dragPan?this._dragPanHandler.enable():this._dragPanHandler.disable(),e.scrollZoom?this._scrollZoomHandler.enable():this._scrollZoomHandler.disable(),e.touchZoom?this._touchZoomHandler.enable():this._touchZoomHandler.disable()})),this._container.mouseService.claimMouse(this._name,0)}_deactivate(){this._container.mouseService.unclaimMouse(this._name),this._configurationSubscription.unsubscribe(),this._bounceHandler.disable(),this._doubleClickZoomHandler.disable(),this._dragPanHandler.disable(),this._scrollZoomHandler.disable(),this._touchZoomHandler.disable()}_getDefaultConfiguration(){return{doubleClickZoom:!0,dragPan:!0,scrollZoom:!0,touchZoom:!0}}}oC.componentName="mouse";class sC extends fT{constructor(t,i,r){super(t,i,r),this._seqNames={},this._seqNames[e.EdgeDirection[e.EdgeDirection.Prev]]="Prev",this._seqNames[e.EdgeDirection[e.EdgeDirection.Next]]="Next",this._spaTopNames={},this._spaTopNames[e.EdgeDirection[e.EdgeDirection.TurnLeft]]="Turnleft",this._spaTopNames[e.EdgeDirection[e.EdgeDirection.StepLeft]]="Left",this._spaTopNames[e.EdgeDirection[e.EdgeDirection.StepForward]]="Forward",this._spaTopNames[e.EdgeDirection[e.EdgeDirection.StepRight]]="Right",this._spaTopNames[e.EdgeDirection[e.EdgeDirection.TurnRight]]="Turnright",this._spaBottomNames={},this._spaBottomNames[e.EdgeDirection[e.EdgeDirection.TurnU]]="Turnaround",this._spaBottomNames[e.EdgeDirection[e.EdgeDirection.StepBackward]]="Backward"}_activate(){this._renderSubscription=B_(this._navigator.stateService.currentNode$,this._configuration$).pipe(Ab((([e,t])=>B_(t.sequence?e.sequenceEdges$.pipe(w_((e=>e.edges.map((e=>e.data.direction))))):a_([]),!e.pano&&t.spatial?e.spatialEdges$.pipe(w_((e=>e.edges.map((e=>e.data.direction))))):a_([])).pipe(w_((([e,t])=>e.concat(t)))))),w_((e=>{const t=this._createArrowRow(this._seqNames,e),i=this._createArrowRow(this._spaTopNames,e),r=this._createArrowRow(this._spaBottomNames,e),n=uv.h("div.NavigationSequence",t),o=uv.h("div.NavigationSpatialTop",i),s=uv.h("div.NavigationSpatialBottom",r),a=uv.h("div.NavigationSpatial",[o,s]);return{name:this._name,vnode:uv.h("div.NavigationContainer",[n,a])}}))).subscribe(this._container.domRenderer.render$)}_deactivate(){this._renderSubscription.unsubscribe()}_getDefaultConfiguration(){return{sequence:!0,spatial:!0}}_createArrowRow(t,i){const r=[];for(const n in t){if(!t.hasOwnProperty(n))continue;const o=e.EdgeDirection[n];-1!==i.indexOf(o)?r.push(this._createVNode(o,t[n],"visible")):r.push(this._createVNode(o,t[n],"hidden"))}return r}_createVNode(e,t,i){return uv.h(`span.Direction.Direction${t}`,{onclick:t=>{this._navigator.moveDir$(e).subscribe((e=>{}),(e=>{console.error(e)}))},style:{visibility:i}},[])}}sC.componentName="navigation";class aC{}class cC{}class hC{constructor(){this.nodeInstructions=[],this.nodeInstructionsOrdered=[]}}class uC extends fT{constructor(e,t,i){super(e,t,i)}play(){this.configure({playing:!0})}stop(){this.configure({playing:!1})}_activate(){let e,t;var i,r;e=this._navigator.stateService.currentState$.pipe(Ry((e=>e.id%2==0)),Ry((e=>e.state.nodesAhead<15)),Iy(void 0,(e=>e.state.lastNode.key))),t=this.configuration$.pipe($_((e=>z_(e.paths))),(i=e=>e.sequenceKey,function(e){return e.lift(new Ty(i,r))}),$_((e=>this._navigator.api.sequenceByKey$([e.sequenceKey]).pipe(w_((t=>t[e.sequenceKey]))))),fy(this.configuration$,((e,t)=>{let i=0,r=[];for(let n of t.paths){if(n.sequenceKey===e.key){let t=[],o=!1;for(let i of e.keys){if(n.startKey===i&&(o=!0),o){let e=null;for(let t of n.infoKeys)t.key===i&&(e=t.description);t.push({description:e,key:i})}n.stopKey===i&&(o=!1)}r.push({nodeInstructions:t,place:i})}i++}return r})),eb(((e,t)=>{for(let i of t)e.nodeInstructionsOrdered[i.place]=i.nodeInstructions;return e.nodeInstructions=of(e.nodeInstructionsOrdered),e}),new hC)),this._disposable=e.pipe(fy(t,this.configuration$,((e,t,i)=>({conf:i,frame:e,routeTrack:t}))),eb(((e,t)=>(void 0===t.conf.playing||t.conf.playing?(e.routeTrack=t.routeTrack,e.currentNode=t.frame.state.currentNode,e.lastNode=t.frame.state.lastNode,e.playing=!0):(this._navigator.stateService.cutNodes(),e.playing=!1),e)),new cC),Ry((e=>e.playing)),Ry((e=>{for(let t of e.routeTrack.nodeInstructions)if(t&&t.key===e.lastNode.key)return!0;return!1})),Iy(void 0,(e=>e.lastNode.key)),$_((e=>{let t=0;for(let i of e.routeTrack.nodeInstructions){if(i.key===e.lastNode.key)break;t++}let i=e.routeTrack.nodeInstructions[t+1];return i?this._navigator.graphService.cacheNode$(i.key):a_(null)})),fy(this.configuration$,((e,t)=>({conf:t,node:e}))),Ry((e=>null!==e.node&&e.conf.playing)),hb("node")).subscribe(this._navigator.stateService.appendNode$),this._disposableDescription=this._navigator.stateService.currentNode$.pipe(fy(t,this.configuration$,((e,t,i)=>{if(void 0!==i.playing&&!i.playing)return"quit";let r=null;for(let i of t.nodeInstructions)if(i.key===e.key){r=i.description;break}return r})),eb(((e,t)=>(t!==e.description&&null!==t?(e.description=t,e.showsLeft=6):e.showsLeft--,"quit"===t&&(e.description=null),e)),new aC),w_((e=>e.showsLeft>0&&e.description?{name:this._name,vnode:this._getRouteAnnotationNode(e.description)}:{name:this._name,vnode:uv.h("div",[])}))).subscribe(this._container.domRenderer.render$)}_deactivate(){this._disposable.unsubscribe(),this._disposableDescription.unsubscribe()}_getDefaultConfiguration(){return{}}_getRouteAnnotationNode(e){return uv.h("div.RouteFrame",{},[uv.h("p",{textContent:e},[])])}}uC.componentName="route";class lC{constructor(e){this._minThresholdWidth=320,this._maxThresholdWidth=1480,this._minThresholdHeight=240,this._maxThresholdHeight=820}render(t,i,r,n,o,s){if(!1===i.visible)return uv.h("div.SequenceContainer",{},[]);let a=null,c=null;for(let i of t.edges)i.data.direction===e.EdgeDirection.Next&&(a=i.to),i.data.direction===e.EdgeDirection.Prev&&(c=i.to);let h=this._createPlayingButton(a,c,i,n),u=this._createSequenceArrows(a,c,i,o,s),l={oncontextmenu:e=>{e.preventDefault()},style:{height:.27*r+"px",width:r+"px"}};return uv.h("div.SequenceContainer",l,u.concat([h]))}getContainerWidth(e,t){let i=e.offsetWidth,r=e.offsetHeight,n=t.minWidth,o=t.maxWidth;o<n&&(o=n);let s=(i-this._minThresholdWidth)/(this._maxThresholdWidth-this._minThresholdWidth),a=(r-this._minThresholdHeight)/(this._maxThresholdHeight-this._minThresholdHeight);return n+Math.max(0,Math.min(1,Math.min(s,a)))*(o-n)}_createPlayingButton(t,i,r,n){let o=r.direction===e.EdgeDirection.Next&&null!=t||r.direction===e.EdgeDirection.Prev&&null!=i,s={onclick:r.playing?e=>{n.stop()}:o?e=>{n.play()}:null,style:{}},a=r.playing?"Stop":o?"Play":"PlayDisabled",c=uv.h("div.SequenceComponentIcon",{className:a},[]),h=o?"SequencePlay":"SequencePlayDisabled";return uv.h("div."+h,s,[c])}_createSequenceArrows(t,i,r,n,o){let s={onclick:null!=t?t=>{o.moveDir$(e.EdgeDirection.Next).subscribe((e=>{}),(e=>{console.error(e)}))}:null,onmouseenter:t=>{n.mouseEnterDirection$.next(e.EdgeDirection.Next)},onmouseleave:t=>{n.mouseLeaveDirection$.next(e.EdgeDirection.Next)},style:{}},a={onclick:null!=i?t=>{o.moveDir$(e.EdgeDirection.Prev).subscribe((e=>{}),(e=>{console.error(e)}))}:null,onmouseenter:t=>{n.mouseEnterDirection$.next(e.EdgeDirection.Prev)},onmouseleave:t=>{n.mouseLeaveDirection$.next(e.EdgeDirection.Prev)},style:{}},c=this._getStepClassName(e.EdgeDirection.Next,t,r.highlightKey),h=this._getStepClassName(e.EdgeDirection.Prev,i,r.highlightKey),u=uv.h("div.SequenceComponentIcon",[]),l=uv.h("div.SequenceComponentIcon",[]);return[uv.h("div."+c,s,[u]),uv.h("div."+h,a,[l])]}_getStepClassName(t,i,r){let n=t===e.EdgeDirection.Next?"SequenceStepNext":"SequenceStepPrev";return null==i?n+="Disabled":r===i&&(n+="Highlight"),n}}class pC{constructor(){this._mouseEnterDirection$=new zv,this._mouseLeaveDirection$=new zv}get mouseEnterDirection$(){return this._mouseEnterDirection$}get mouseLeaveDirection$(){return this._mouseLeaveDirection$}}class dC extends fT{constructor(e,t,i){super(e,t,i),this._nodesAhead=5,this._configurationOperation$=new zv,this._sequenceDOMRenderer=new lC(t.element),this._sequenceDOMInteraction=new pC,this._containerWidth$=new zv,this._hoveredKeySubject$=new zv,this._hoveredKey$=this._hoveredKeySubject$.pipe(mb()),this._edgeStatus$=this._navigator.stateService.currentNode$.pipe(Ab((e=>e.sequenceEdges$)),lb(1),Vv())}get hoveredKey$(){return this._hoveredKey$}play(){this.configure({playing:!0})}stop(){this.configure({playing:!1})}setDirection(e){this.configure({direction:e})}setHighlightKey(e){this.configure({highlightKey:e})}setMaxWidth(e){this.configure({maxWidth:e})}setMinWidth(e){this.configure({minWidth:e})}setVisible(e){this.configure({visible:e})}resize(){this._configuration$.pipe(Yy(),w_((e=>this._sequenceDOMRenderer.getContainerWidth(this._container.element,e)))).subscribe((e=>{this._containerWidth$.next(e)}))}_activate(){this._renderSubscription=B_(this._edgeStatus$,this._configuration$,this._containerWidth$).pipe(w_((e=>{let t=e[0],i=e[1],r=e[2],n=this._sequenceDOMRenderer.render(t,i,r,this,this._sequenceDOMInteraction,this._navigator);return{name:this._name,vnode:n}}))).subscribe(this._container.domRenderer.render$),this._containerWidthSubscription=this._configuration$.pipe(Iy(((e,t)=>e[0]===t[0]&&e[1]===t[1]),(e=>[e.minWidth,e.maxWidth])),w_((e=>this._sequenceDOMRenderer.getContainerWidth(this._container.element,e)))).subscribe(this._containerWidth$),this._configurationSubscription=this._configurationOperation$.pipe(eb(((e,t)=>t(e)),{playing:!1}),qy((()=>{null!=this._playingSubscription&&(this._navigator.stateService.cutNodes(),this._stop())}))).subscribe((()=>{})),this._configuration$.pipe(w_((e=>t=>(e.playing!==t.playing&&(this._navigator.stateService.cutNodes(),e.playing?this._play():this._stop()),t.playing=e.playing,t)))).subscribe(this._configurationOperation$),this._stopSubscription=this._configuration$.pipe(Ab((e=>B_(e.playing?this._edgeStatus$:i_(),a_(e.direction)))),w_((e=>{let t=e[0],i=e[1];if(!t.cached)return!0;for(let e of t.edges)if(e.data.direction===i)return!0;return!1})),Ry((e=>!e)),w_((e=>({playing:!1})))).subscribe(this._configurationSubject$),this._hoveredKeySubscription=this._sequenceDOMInteraction.mouseEnterDirection$.pipe(Ab((e=>this._edgeStatus$.pipe(w_((t=>{for(let i of t.edges)if(i.data.direction===e)return i.to;return null})),Eb(this._sequenceDOMInteraction.mouseLeaveDirection$),my(a_(null))))),Iy()).subscribe(this._hoveredKeySubject$)}_deactivate(){this._stopSubscription.unsubscribe(),this._renderSubscription.unsubscribe(),this._configurationSubscription.unsubscribe(),this._containerWidthSubscription.unsubscribe(),this._hoveredKeySubscription.unsubscribe(),this.stop()}_getDefaultConfiguration(){return{direction:e.EdgeDirection.Next,maxWidth:117,minWidth:70,playing:!1,visible:!0}}_play(){this._playingSubscription=this._navigator.stateService.currentState$.pipe(Ry((e=>e.state.nodesAhead<this._nodesAhead)),w_((e=>e.state.lastNode)),Iy(void 0,(e=>e.key)),Lb(this._configuration$,((e,t)=>[e,t.direction])),Ab((t=>([e.EdgeDirection.Next,e.EdgeDirection.Prev].indexOf(t[1])>-1?t[0].sequenceEdges$:t[0].spatialEdges$).pipe(Ry((e=>e.cached)),Vb(a_(t[1]),((e,t)=>[e,t]))))),w_((e=>{let t=e[1];for(let i of e[0].edges)if(i.data.direction===t)return i.to;return null})),Ry((e=>null!=e)),Ab((e=>this._navigator.graphService.cacheNode$(e)))).subscribe((e=>{this._navigator.stateService.appendNodes([e])}),(e=>{console.error(e),this.stop()})),this._clearSubscription=this._navigator.stateService.currentNode$.pipe(oy(1,7)).subscribe((e=>{this._navigator.stateService.clearPriorNodes()})),this.fire(dC.playingchanged,!0)}_stop(){this._playingSubscription.unsubscribe(),this._playingSubscription=null,this._clearSubscription.unsubscribe(),this._clearSubscription=null,this.fire(dC.playingchanged,!1)}}dC.componentName="sequence",dC.playingchanged="playingchanged";class fC{constructor(){this.scene=new Re,this.sceneOld=new Re,this.imagePlanes=[],this.imagePlanesOld=[]}updateImagePlanes(e){this._dispose(this.imagePlanesOld,this.sceneOld);for(let e of this.imagePlanes)this.scene.remove(e),this.sceneOld.add(e);for(let t of e)this.scene.add(t);this.imagePlanesOld=this.imagePlanes,this.imagePlanes=e}addImagePlanes(e){for(let t of e)this.scene.add(t),this.imagePlanes.push(t)}addImagePlanesOld(e){for(let t of e)this.sceneOld.add(t),this.imagePlanesOld.push(t)}setImagePlanes(e){this._clear(),this.addImagePlanes(e)}setImagePlanesOld(e){this._clearOld(),this.addImagePlanesOld(e)}clear(){this._clear(),this._clearOld()}_clear(){this._dispose(this.imagePlanes,this.scene),this.imagePlanes.length=0}_clearOld(){this._dispose(this.imagePlanesOld,this.sceneOld),this.imagePlanesOld.length=0}_dispose(e,t){for(let i of e){t.remove(i),i.geometry.dispose(),i.material.dispose();let e=i.material.uniforms.projectorTex.value;null!=e&&e.dispose()}}}class mC{}mC.equirectangular={fragment:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float phiLength;\nuniform float phiShift;\nuniform float thetaLength;\nuniform float thetaShift;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lon = atan(b.x, b.z);\n float x = (lon - phiShift) / phiLength + 0.5;\n float y = (lat - thetaShift) / thetaLength + 0.5;\n vec4 baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},mC.perspective={fragment:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform vec4 bbox;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.w;\n float y = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if (x > bbox[0] && y > bbox[1] && x < bbox[2] && y < bbox[3]) {\n baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"};class gC{constructor(e,t){this._imagePlaneDepth=null!=e?e:200,this._imageSphereRadius=null!=t?t:200}createMesh(e,t){return e.pano?this._createImageSphere(e,t):this._createImagePlane(e,t)}_createImageSphere(e,t){let i=this._createTexture(e.image),r=new Ei(this._createSphereMaterialParameters(t,i));return this._useMesh(t,e)?new fi(this._getImageSphereGeo(t,e),r):new fi(this._getFlatImageSphereGeo(t),r)}_createImagePlane(e,t){let i=this._createTexture(e.image),r=new Ei(this._createPlaneMaterialParameters(t,i));return new fi(this._useMesh(t,e)?this._getImagePlaneGeo(t,e):this._getFlatImagePlaneGeo(t),r)}_createSphereMaterialParameters(e,t){let i=e.gpano,r=(i.FullPanoWidthPixels-i.CroppedAreaImageWidthPixels)/2,n=2*Math.PI*(i.CroppedAreaLeftPixels-r)/i.FullPanoWidthPixels,o=2*Math.PI*i.CroppedAreaImageWidthPixels/i.FullPanoWidthPixels,s=(i.FullPanoHeightPixels-i.CroppedAreaImageHeightPixels)/2,a=Math.PI*(s-i.CroppedAreaTopPixels)/i.FullPanoHeightPixels,c=Math.PI*i.CroppedAreaImageHeightPixels/i.FullPanoHeightPixels;return{depthWrite:!1,fragmentShader:mC.equirectangular.fragment,side:2,transparent:!0,uniforms:{opacity:{type:"f",value:1},phiLength:{type:"f",value:o},phiShift:{type:"f",value:n},projectorMat:{type:"m4",value:e.rt},projectorTex:{type:"t",value:t},thetaLength:{type:"f",value:c},thetaShift:{type:"f",value:a}},vertexShader:mC.equirectangular.vertex}}_createPlaneMaterialParameters(e,t){return{depthWrite:!1,fragmentShader:mC.perspective.fragment,side:2,transparent:!0,uniforms:{bbox:{type:"v4",value:new J(0,0,1,1)},opacity:{type:"f",value:1},projectorMat:{type:"m4",value:e.projectorMatrix()},projectorTex:{type:"t",value:t}},vertexShader:mC.perspective.vertex}}_createTexture(e){let t=new K(e);return t.minFilter=v,t.needsUpdate=!0,t}_useMesh(e,t){return t.mesh.vertices.length&&e.hasValidScale}_getImageSphereGeo(e,t){let i=new xi,r=t.mesh.vertices,n=t.mesh.faces,o=r.length/3;for(let e=0;e<o;++e){let t=3*e,n=r[t+0],o=r[t+1],s=r[t+2];i.vertices.push(new oe(n,o,s))}let s=n.length/3;for(let e=0;e<s;++e){let t=3*e,r=n[t+0],o=n[t+1],s=n[t+2];i.faces.push(new Et(r,o,s))}return i}_getImagePlaneGeo(e,t){let i=(new de).getInverse(e.srt),r=5*e.scale,n=this._imagePlaneDepth*e.scale,o=t.mesh.vertices,s=o.length/3,a=new Float32Array(o.length);for(let e=0;e<s;++e){let t=3*e,s=o[t+0],c=o[t+1],h=o[t+2],u=Math.max(r,Math.min(h,n)),l=u/h,p=new oe(s*l,c*l,u);p.applyMatrix4(i),a[t+0]=p.x,a[t+1]=p.y,a[t+2]=p.z}let c=t.mesh.faces,h=new Uint16Array(c.length);for(let e=0;e<c.length;++e)h[e]=c[e];let u=new Xt;return u.setAttribute("position",new Pt(a,3)),u.setIndex(new Pt(h,1)),u}_getFlatImageSphereGeo(e){let t=e.gpano,i=2*Math.PI*t.CroppedAreaLeftPixels/t.FullPanoWidthPixels,r=2*Math.PI*t.CroppedAreaImageWidthPixels/t.FullPanoWidthPixels,n=Math.PI*(t.FullPanoHeightPixels-t.CroppedAreaImageHeightPixels-t.CroppedAreaTopPixels)/t.FullPanoHeightPixels,o=Math.PI*t.CroppedAreaImageHeightPixels/t.FullPanoHeightPixels;return new Ys(this._imageSphereRadius,20,40,i-Math.PI/2,r,n,o)}_getFlatImagePlaneGeo(e){let t=e.width,i=e.height,r=Math.max(t,i),n=t/2/r,o=i/2/r,s=[];s.push(e.unprojectSfM([-n,-o],this._imagePlaneDepth)),s.push(e.unprojectSfM([n,-o],this._imagePlaneDepth)),s.push(e.unprojectSfM([n,o],this._imagePlaneDepth)),s.push(e.unprojectSfM([-n,o],this._imagePlaneDepth));let a=new Float32Array(12);for(let e=0;e<s.length;e++){let t=3*e;a[t+0]=s[e][0],a[t+1]=s[e][1],a[t+2]=s[e][2]}let c=new Uint16Array(6);c[0]=0,c[1]=1,c[2]=3,c[3]=1,c[4]=2,c[5]=3;let h=new Xt;return h.setAttribute("position",new Pt(a,3)),h.setIndex(new Pt(c,1)),h}}class vC{constructor(){this._imagePlaneFactory=new gC(200,2e3),this._imagePlaneScene=new fC,this._alpha=0,this._alphaOld=0,this._fadeOutSpeed=.05,this._lastCamera=new Vu,this._epsilon=1e-6,this._currentKey=null,this._previousKey=null,this._providerDisposers={},this._frameId=0,this._needsRender=!1}get frameId(){return this._frameId}get needsRender(){return this._needsRender}indicateNeedsRender(){this._needsRender=!0}updateFrame(e){this._updateFrameId(e.id),this._needsRender=this._updateAlpha(e.state.alpha)||this._needsRender,this._needsRender=this._updateAlphaOld(e.state.alpha)||this._needsRender,this._needsRender=this._updateImagePlanes(e.state)||this._needsRender}setTextureProvider(e,t){if(e!==this._currentKey)return;let i=t.textureCreated$.subscribe((e=>{this._updateTexture(e)})),r=t.textureUpdated$.subscribe((e=>{this._needsRender=!0}));if(e in this._providerDisposers){(0,this._providerDisposers[e])(),delete this._providerDisposers[e]}this._providerDisposers[e]=()=>{i.unsubscribe(),r.unsubscribe(),t.dispose()}}_updateTexture(e){this._needsRender=!0;for(let t of this._imagePlaneScene.imagePlanes){let i=t.material,r=i.uniforms.projectorTex.value;i.uniforms.projectorTex.value=null,r.dispose(),i.uniforms.projectorTex.value=e}}updateTextureImage(e,t){if(this._currentKey===t.key){this._needsRender=!0;for(let t of this._imagePlaneScene.imagePlanes){let i=t.material.uniforms.projectorTex.value;i.image=e,i.needsUpdate=!0}}}render(e,t){let i=this._imagePlaneScene.imagePlanesOld.length?1:this._alpha;for(let e of this._imagePlaneScene.imagePlanes)e.material.uniforms.opacity.value=i;for(let e of this._imagePlaneScene.imagePlanesOld)e.material.uniforms.opacity.value=this._alphaOld;t.render(this._imagePlaneScene.scene,e),t.render(this._imagePlaneScene.sceneOld,e);for(let e of this._imagePlaneScene.imagePlanes)e.material.uniforms.opacity.value=this._alpha;t.render(this._imagePlaneScene.scene,e)}clearNeedsRender(){this._needsRender=!1}dispose(){this._imagePlaneScene.clear()}_updateFrameId(e){this._frameId=e}_updateAlpha(e){return e!==this._alpha&&(this._alpha=e,!0)}_updateAlphaOld(e){return!(e<1||0===this._alphaOld)&&(this._alphaOld=Math.max(0,this._alphaOld-this._fadeOutSpeed),!0)}_updateImagePlanes(e){if(null==e.currentNode||e.currentNode.key===this._currentKey)return!1;let t=null!=e.previousNode?e.previousNode.key:null,i=e.currentNode.key;if(this._previousKey!==t&&this._previousKey!==i&&this._previousKey in this._providerDisposers){(0,this._providerDisposers[this._previousKey])(),delete this._providerDisposers[this._previousKey]}if(null!=t){if(t!==this._currentKey&&t!==this._previousKey){let t=this._imagePlaneFactory.createMesh(e.previousNode,e.previousTransform);this._imagePlaneScene.updateImagePlanes([t])}this._previousKey=t}this._currentKey=i;let r=this._imagePlaneFactory.createMesh(e.currentNode,e.currentTransform);return this._imagePlaneScene.updateImagePlanes([r]),this._alphaOld=1,!0}}class _C{constructor(e,t,i){this._scheme=e,this._host=t,this._origin=null!=i?`?origin=${i}`:""}getTile(e,t,i,r,n,o,s){let a=`/${e}/${t},${i},${r},${n}/${o},${s}/0/default.jpg`,c=this._scheme+"://"+this._host+a+this._origin,h=null;return[Dv.create((o=>{h=new XMLHttpRequest,h.open("GET",c,!0),h.custom&&h.custom.xhr&&(h=h.custom.xhr),h.responseType="arraybuffer",h.timeout=15e3,h.onload=s=>{if(200!==h.status)return void o.error(new Error(`Failed to fetch tile (${e}: ${t},${i},${r},${n}). Status: ${h.status}, ${h.statusText}`));let a=new Image;a.crossOrigin="Anonymous",a.onload=e=>{o.next(a),o.complete()},a.onerror=s=>{o.error(new Error(`Failed to load tile image (${e}: ${t},${i},${r},${n})`))};let c=new Blob([h.response]);a.src=window.URL.createObjectURL(c)},h.onerror=s=>{o.error(new Error(`Failed to fetch tile (${e}: ${t},${i},${r},${n})`))},h.ontimeout=s=>{o.error(new Error(`Tile request timed out (${e}: ${t},${i},${r},${n})`))},h.onabort=s=>{o.error(new Error(`Tile request was aborted (${e}: ${t},${i},${r},${n})`))},h.send(null)})),()=>{null!=h&&h.abort()}]}}class yC{constructor(){this._images={}}addImage(e,t,i){i in this._images||(this._images[i]={}),this._images[i][t]=e}dispose(){for(let e of Object.keys(this._images)){let t=this._images[e];for(let e of Object.keys(t))window.URL.revokeObjectURL(t[e].src),delete t[e];delete this._images[e]}}getImage(e,t){return this._images[t][e]}hasImage(e,t){return t in this._images&&e in this._images[t]}}class bC{constructor(){this._viewportCoords=new Gu}computeRegionOfInterest(e,t,i){let r=this._viewportBoundaryPoints(4),n=this._viewportPointsBoundingBox(r,e,i);this._clipBoundingBox(n);const o=2/t.width,s=2/t.height;let a=[[-.5*o,.5*s],[.5*o,.5*s],[.5*o,-.5*s],[-.5*o,-.5*s]],c=this._viewportPointsBoundingBox(a,e,i);return{bbox:n,pixelHeight:c.maxY-c.minY,pixelWidth:c.maxX-c.minX+(c.minX<c.maxX?0:1)}}_viewportBoundaryPoints(e){let t=[],i=[[-1,1],[1,1],[1,-1],[-1,-1]],r=[[2,0],[0,-2],[-2,0],[0,2]];for(let n=0;n<4;++n){let o=i[n],s=r[n];for(let i=0;i<e;++i)t.push([o[0]+s[0]*i/e,o[1]+s[1]*i/e])}return t}_viewportPointsBoundingBox(e,t,i){let r=e.map((e=>this._viewportCoords.viewportToBasic(e[0],e[1],i,t.perspective)));return null!=i.gpano?this._boundingBoxPano(r):this._boundingBox(r)}_boundingBox(e){let t={maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY};for(let i=0;i<e.length;++i)t.minX=Math.min(t.minX,e[i][0]),t.maxX=Math.max(t.maxX,e[i][0]),t.minY=Math.min(t.minY,e[i][1]),t.maxY=Math.max(t.maxY,e[i][1]);return t}_boundingBoxPano(e){let t=[],i=[];for(let r=0;r<e.length;++r)t.push(e[r][0]),i.push(e[r][1]);t.sort(((e,t)=>this._sign(e-t))),i.sort(((e,t)=>this._sign(e-t)));let r=this._intervalPano(t);return{maxX:r[1],maxY:i[i.length-1],minX:r[0],minY:i[0]}}_intervalPano(e){let t=0,i=-1;for(let r=0;r<e.length-1;++r){let n=e[r+1]-e[r];n>t&&(t=n,i=r)}return e[0]+1-e[e.length-1]>t?[e[0],e[e.length-1]]:[e[i+1],e[i]]}_clipBoundingBox(e){e.minX=Math.max(0,Math.min(1,e.minX)),e.maxX=Math.max(0,Math.min(1,e.maxX)),e.minY=Math.max(0,Math.min(1,e.minY)),e.maxY=Math.max(0,Math.min(1,e.maxY))}_sign(e){return e>0?1:e<0?-1:0}}class xC{constructor(e,t,i,r,n,o,s,a){this._disposed=!1,this._key=e,(t<=0||i<=0)&&console.warn(`Original image size (${t}, ${i}) is invalid (${e}). Tiles will not be loaded.`),this._width=t,this._height=i,this._maxLevel=Math.ceil(Math.log(Math.max(i,t))/Math.log(2)),this._currentLevel=-1,this._tileSize=r,this._updated$=new zv,this._createdSubject$=new zv,this._created$=this._createdSubject$.pipe(lb(1),Vv()),this._createdSubscription=this._created$.subscribe((()=>{})),this._hasSubject$=new zv,this._has$=this._hasSubject$.pipe(wb(!1),lb(1),Vv()),this._hasSubscription=this._has$.subscribe((()=>{})),this._abortFunctions=[],this._tileSubscriptions={},this._renderedCurrentLevelTiles={},this._renderedTiles={},this._background=n,this._camera=null,this._imageTileLoader=o,this._imageTileStore=s,this._renderer=a,this._renderTarget=null,this._roi=null}get disposed(){return this._disposed}get hasTexture$(){return this._has$}get key(){return this._key}get textureUpdated$(){return this._updated$}get textureCreated$(){return this._created$}abort(){for(let e in this._tileSubscriptions)this._tileSubscriptions.hasOwnProperty(e)&&this._tileSubscriptions[e].unsubscribe();this._tileSubscriptions={};for(let e of this._abortFunctions)e();this._abortFunctions=[]}dispose(){this._disposed?console.warn(`Texture already disposed (${this._key})`):(this.abort(),null!=this._renderTarget&&(this._renderTarget.dispose(),this._renderTarget=null),this._imageTileStore.dispose(),this._imageTileStore=null,this._background=null,this._camera=null,this._imageTileLoader=null,this._renderer=null,this._roi=null,this._createdSubscription.unsubscribe(),this._hasSubscription.unsubscribe(),this._disposed=!0)}setRegionOfInterest(e){if(this._width<=0||this._height<=0)return;this._roi=e;let t=1/this._roi.pixelWidth,i=1/this._roi.pixelHeight,r=Math.max(i,t),n=Math.max(0,Math.min(this._maxLevel,Math.ceil(Math.log(r)/Math.log(2))));if(n!==this._currentLevel){this.abort(),this._currentLevel=n,this._currentLevel in this._renderedTiles||(this._renderedTiles[this._currentLevel]=[]),this._renderedCurrentLevelTiles={};for(let e of this._renderedTiles[this._currentLevel])this._renderedCurrentLevelTiles[this._tileKey(this._tileSize,e)]=!0}let o=this._getTileCoords([this._roi.bbox.minX,this._roi.bbox.minY]),s=this._getTileCoords([this._roi.bbox.maxX,this._roi.bbox.maxY]),a=this._getTiles(o,s);if(null==this._camera){this._camera=new Ec(-this._width/2,this._width/2,this._height/2,-this._height/2,-1,1),this._camera.position.z=1;let e=this._renderer.getContext(),t=e.getParameter(e.MAX_TEXTURE_SIZE),i=Math.max(this._width,this._height),r=t>i?1:t/i,n=Math.floor(r*this._width),o=Math.floor(r*this._height);this._renderTarget=new ee(n,o,{depthBuffer:!1,format:M,magFilter:v,minFilter:v,stencilBuffer:!1}),this._renderToTarget(0,0,this._width,this._height,this._background),this._createdSubject$.next(this._renderTarget.texture),this._hasSubject$.next(!0)}this._fetchTiles(a)}setTileSize(e){this._tileSize=e}updateBackground(e){this._background=e}_fetchTile(e,t,i,r,n,o,s,a){let c=this._imageTileLoader.getTile(this._key,i,r,n,o,s,a),h=c[0],u=c[1];this._abortFunctions.push(u);let l=this._tileKey(this._tileSize,e),p=h.subscribe((s=>{this._renderToTarget(i,r,n,o,s),this._removeFromDictionary(l,this._tileSubscriptions),this._removeFromArray(u,this._abortFunctions),this._setTileRendered(e,this._currentLevel),this._imageTileStore.addImage(s,l,t),this._updated$.next(!0)}),(e=>{this._removeFromDictionary(l,this._tileSubscriptions),this._removeFromArray(u,this._abortFunctions),console.error(e)}));p.closed||(this._tileSubscriptions[l]=p)}_fetchTiles(e){let t=this._tileSize*Math.pow(2,this._maxLevel-this._currentLevel);for(let i of e){let e=this._tileKey(this._tileSize,i);if(e in this._renderedCurrentLevelTiles||e in this._tileSubscriptions)continue;let r=t*i[0],n=t*i[1],o=r+t>this._width?this._width-r:t,s=n+t>this._height?this._height-n:t;if(this._imageTileStore.hasImage(e,this._currentLevel)){this._renderToTarget(r,n,o,s,this._imageTileStore.getImage(e,this._currentLevel)),this._setTileRendered(i,this._currentLevel),this._updated$.next(!0);continue}let a=Math.floor(o/t*this._tileSize),c=Math.floor(s/t*this._tileSize);this._fetchTile(i,this._currentLevel,r,n,o,s,a,c)}}_getTileCoords(e){let t=this._tileSize*Math.pow(2,this._maxLevel-this._currentLevel),i=Math.ceil(this._width/t)-1,r=Math.ceil(this._height/t)-1;return[Math.min(Math.floor(this._width*e[0]/t),i),Math.min(Math.floor(this._height*e[1]/t),r)]}_getTiles(e,t){let i=[];if(e[0]>t[0]){let r=this._tileSize*Math.pow(2,this._maxLevel-this._currentLevel),n=Math.ceil(this._width/r)-1;for(let t=e[0];t<=n;t++)i.push(t);for(let e=0;e<=t[0];e++)i.push(e)}else for(let r=e[0];r<=t[0];r++)i.push(r);let r=[];for(let n of i)for(let i=e[1];i<=t[1];i++)r.push([n,i]);return r}_removeFromArray(e,t){let i=t.indexOf(e);-1!==i&&t.splice(i,1)}_removeFromDictionary(e,t){e in t&&delete t[e]}_renderToTarget(e,t,i,r,n){let o=new K(n);o.minFilter=v,o.needsUpdate=!0;let s=new ji(i,r),a=new It({map:o,side:0}),c=new fi(s,a);c.position.x=-this._width/2+e+i/2,c.position.y=this._height/2-t-r/2;let h=new Re;h.add(c);const u=this._renderer.getRenderTarget();this._renderer.setRenderTarget(this._renderTarget),this._renderer.render(h,this._camera),this._renderer.setRenderTarget(u),h.remove(c),s.dispose(),a.dispose(),o.dispose()}_setTileRendered(e,t){let i=Object.keys(this._renderedTiles).map((e=>parseInt(e,10))).filter((e=>e!==t));for(let r of i){let i=Math.pow(2,r-t);if(r<t){let t=Math.floor(i*e[0]),n=Math.floor(i*e[1]);for(let e of this._renderedTiles[r].slice())if(e[0]===t&&e[1]===n){let t=this._renderedTiles[r].indexOf(e);this._renderedTiles[r].splice(t,1)}}else{let t=i*e[0],n=t+i-1,o=i*e[1],s=o+i-1;for(let e of this._renderedTiles[r].slice())if(e[0]>=t&&e[0]<=n&&e[1]>=o&&e[1]<=s){let t=this._renderedTiles[r].indexOf(e);this._renderedTiles[r].splice(t,1)}}0===this._renderedTiles[r].length&&delete this._renderedTiles[r]}this._renderedTiles[t].push(e),this._renderedCurrentLevelTiles[this._tileKey(this._tileSize,e)]=!0}_tileKey(e,t){return e+"-"+t[0]+"-"+t[1]}}class wC extends fT{constructor(e,t,i){super(e,t,i),this._imageTileLoader=new _C(Wb.tileScheme,Wb.tileDomain,Wb.origin),this._roiCalculator=new bC,this._rendererOperation$=new zv,this._rendererCreator$=new zv,this._rendererDisposer$=new zv,this._renderer$=this._rendererOperation$.pipe(eb(((e,t)=>t(e)),null),Ry((e=>null!=e)),Iy(void 0,(e=>e.frameId))),this._rendererCreator$.pipe(w_((()=>e=>{if(null!=e)throw new Error("Multiple image plane states can not be created at the same time");return new vC}))).subscribe(this._rendererOperation$),this._rendererDisposer$.pipe(w_((()=>e=>(e.dispose(),null)))).subscribe(this._rendererOperation$)}_activate(){this._rendererSubscription=this._renderer$.pipe(w_((e=>{let t={name:this._name,render:{frameId:e.frameId,needsRender:e.needsRender,render:e.render.bind(e),stage:kb.Background}};return e.clearNeedsRender(),t}))).subscribe(this._container.glRenderer.render$),this._rendererCreator$.next(null),this._stateSubscription=this._navigator.stateService.currentState$.pipe(w_((e=>t=>(t.updateFrame(e),t)))).subscribe(this._rendererOperation$);let e=this._navigator.stateService.currentState$.pipe(Iy(void 0,(e=>e.state.currentNode.key)),Lb(this._container.glRenderer.webGLRenderer$,this._container.renderService.size$),w_((([e,t,i])=>{let r=e.state,n=Math.max(i.width,i.height),o=r.currentNode,s=r.currentTransform,a=n>2048?2048:n>1024?1024:512;return new xC(o.key,s.basicWidth,s.basicHeight,a,o.image,this._imageTileLoader,new yC,t)})),lb(1),Vv());this._textureProviderSubscription=e.subscribe((()=>{})),this._setTextureProviderSubscription=e.pipe(w_((e=>t=>(t.setTextureProvider(e.key,e),t)))).subscribe(this._rendererOperation$),this._setTileSizeSubscription=this._container.renderService.size$.pipe(Ab((t=>B_(e,a_(t)).pipe(Yy())))).subscribe((([e,t])=>{let i=Math.max(t.width,t.height),r=i>2048?2048:i>1024?1024:512;e.setTileSize(r)})),this._abortTextureProviderSubscription=e.pipe(sb()).subscribe((e=>{e[0].abort()}));let t=B_(this._container.renderService.renderCameraFrame$,this._container.renderService.size$.pipe(gy(250))).pipe(w_((([e,t])=>[e.camera.position.clone(),e.camera.lookat.clone(),e.zoom.valueOf(),t.height.valueOf(),t.width.valueOf()])),sb(),yb((e=>e[1][2]-e[0][2]<0||0===e[1][2])),w_((e=>{let t=e[0][0].equals(e[1][0]),i=e[0][1].equals(e[1][1]),r=e[0][2]===e[1][2],n=e[0][3]===e[1][3],o=e[0][4]===e[1][4];return t&&i&&r&&n&&o})),Iy(),Ry((e=>e)),Ab((e=>this._container.renderService.renderCameraFrame$.pipe(Yy()))),Lb(this._container.renderService.size$,this._navigator.stateService.currentTransform$));this._setRegionOfInterestSubscription=e.pipe(Ab((e=>t.pipe(w_((([t,i,r])=>[this._roiCalculator.computeRegionOfInterest(t,i,r),e]))))),Ry((e=>!e[1].disposed))).subscribe((e=>{let t=e[0];e[1].setRegionOfInterest(t)}));let i=e.pipe(Ab((e=>e.hasTexture$)),wb(!1),lb(1),Vv());this._hasTextureSubscription=i.subscribe((()=>{}));let r=this._navigator.stateService.currentNode$.pipe(gy(1e3),Lb(i),Ry((e=>!e[1])),w_((e=>e[0])),Ry((e=>e.pano?qb.maxImageSize>qb.basePanoramaSize:qb.maxImageSize>qb.baseImageSize)),Ab((e=>{let t=e.pano?qb.basePanoramaSize:qb.baseImageSize;return Math.max(e.image.width,e.image.height)>t?i_():e.cacheImage$(qb.maxImageSize).pipe(w_((e=>[e.image,e]))).pipe(Eb(i.pipe(Ry((e=>e)))),ly(((t,i)=>(console.error(`Failed to fetch high res image (${e.key})`,t),i_()))))})),mb());this._updateBackgroundSubscription=r.pipe(Lb(e)).subscribe((e=>{e[0][1].key!==e[1].key||e[1].disposed||e[1].updateBackground(e[0][0])})),this._updateTextureImageSubscription=r.pipe(w_((e=>t=>(t.updateTextureImage(e[0],e[1]),t)))).subscribe(this._rendererOperation$)}_deactivate(){this._rendererDisposer$.next(null),this._abortTextureProviderSubscription.unsubscribe(),this._hasTextureSubscription.unsubscribe(),this._rendererSubscription.unsubscribe(),this._setRegionOfInterestSubscription.unsubscribe(),this._setTextureProviderSubscription.unsubscribe(),this._setTileSizeSubscription.unsubscribe(),this._stateSubscription.unsubscribe(),this._textureProviderSubscription.unsubscribe(),this._updateBackgroundSubscription.unsubscribe(),this._updateTextureImageSubscription.unsubscribe()}_getDefaultConfiguration(){return{imageTiling:!1}}}wC.componentName="imagePlane";class AC{constructor(){this._imagePlaneFactory=new gC,this._imagePlaneScene=new fC,this._currentKey=null,this._previousKey=null,this._currentPano=!1,this._frameId=0,this._glNeedsRender=!1,this._domNeedsRender=!0,this._curtain=1}get frameId(){return this._frameId}get curtain(){return this._curtain}get glNeedsRender(){return this._glNeedsRender}get domNeedsRender(){return this._domNeedsRender}get sliderVisible(){return this._sliderVisible}set sliderVisible(e){this._sliderVisible=e,this._domNeedsRender=!0}get disabled(){return null==this._currentKey||null==this._previousKey||this._currentPano}update(e){this._updateFrameId(e.id);let t=this._updateImagePlanes(e.state);this._domNeedsRender=t||this._domNeedsRender,t=this._updateCurtain(e.state.alpha)||t,this._glNeedsRender=t||this._glNeedsRender}updateTexture(e,t){let i=t.key===this._currentKey?this._imagePlaneScene.imagePlanes:t.key===this._previousKey?this._imagePlaneScene.imagePlanesOld:[];if(0!==i.length){this._glNeedsRender=!0;for(let t of i){let i=t.material.uniforms.projectorTex.value;i.image=e,i.needsUpdate=!0}}}render(e,t){this.disabled||t.render(this._imagePlaneScene.sceneOld,e),t.render(this._imagePlaneScene.scene,e)}dispose(){this._imagePlaneScene.clear()}clearGLNeedsRender(){this._glNeedsRender=!1}clearDomNeedsRender(){this._domNeedsRender=!1}_updateFrameId(e){this._frameId=e}_updateImagePlanes(e){if(null==e.currentNode)return;let t=!1;return null!=e.previousNode&&this._previousKey!==e.previousNode.key&&(t=!0,this._previousKey=e.previousNode.key,this._imagePlaneScene.setImagePlanesOld([this._imagePlaneFactory.createMesh(e.previousNode,e.previousTransform)])),this._currentKey!==e.currentNode.key&&(t=!0,this._currentKey=e.currentNode.key,this._currentPano=e.currentNode.pano,this._imagePlaneScene.setImagePlanes([this._imagePlaneFactory.createMesh(e.currentNode,e.currentTransform)]),this.disabled||this._updateBbox()),t}_updateCurtain(e){return!(this.disabled||Math.abs(this._curtain-e)<.001)&&(this._curtain=e,this._updateBbox(),!0)}_updateBbox(){for(let e of this._imagePlaneScene.imagePlanes){e.material.uniforms.bbox.value.z=this._curtain}}}class SC extends fT{constructor(e,t,i,r){super(e,t,i),this._dom=r||new Gb,this._sliderStateOperation$=new zv,this._sliderStateCreator$=new zv,this._sliderStateDisposer$=new zv,this._sliderState$=this._sliderStateOperation$.pipe(eb(((e,t)=>t(e)),null),Ry((e=>null!=e)),Iy(void 0,(e=>e.frameId))),this._sliderStateCreator$.pipe(w_((()=>e=>{if(null!=e)throw new Error("Multiple slider states can not be created at the same time");return new AC}))).subscribe(this._sliderStateOperation$),this._sliderStateDisposer$.pipe(w_((()=>e=>(e.dispose(),null)))).subscribe(this._sliderStateOperation$)}setKeys(e){this.configure({keys:e})}setInitialPosition(e){this.configure({initialPosition:e})}setSliderVisible(e){this.configure({sliderVisible:e})}_activate(){this._sliderContainer=this._dom.createElement("div","beeview-js-slider-container",this._container.element),this._sliderWrapper=this._dom.createElement("div","SliderWrapper",this._sliderContainer),this._sliderControl=this._dom.createElement("input","SliderControl",this._sliderWrapper),this._sliderControl.setAttribute("type","range"),this._sliderControl.setAttribute("min","0"),this._sliderControl.setAttribute("max","1000"),this._sliderControl.style.visibility="hidden",this._moveToHandler=e=>{const t=Number(e.target.value)/1e3;this._navigator.stateService.moveTo(t)},this._sliderControl.addEventListener("input",this._moveToHandler),this._sliderControl.addEventListener("change",this._moveToHandler),B_(this._navigator.stateService.state$,this._configuration$).pipe(Yy()).subscribe((([e,t])=>{if(e===Fx.Traversing){this._navigator.stateService.wait();let e=null!=t.initialPosition?t.initialPosition:1;this._sliderControl.value=(1e3*e).toString(),this._navigator.stateService.moveTo(e)}})),this._glRenderSubscription=this._sliderState$.pipe(w_((e=>{let t={name:this._name,render:{frameId:e.frameId,needsRender:e.glNeedsRender,render:e.render.bind(e),stage:kb.Background}};return e.clearGLNeedsRender(),t}))).subscribe(this._container.glRenderer.render$),this._domRenderSubscription=this._sliderState$.pipe(Ry((e=>e.domNeedsRender))).subscribe((e=>{this._sliderControl.value=(1e3*e.curtain).toString();const t=e.disabled||!e.sliderVisible?"hidden":"visible";this._sliderControl.style.visibility=t,e.clearDomNeedsRender()})),this._sliderStateCreator$.next(null),this._stateSubscription=this._navigator.stateService.currentState$.pipe(w_((e=>t=>(t.update(e),t)))).subscribe(this._sliderStateOperation$),this._setSliderVisibleSubscription=this._configuration$.pipe(w_((e=>null==e.sliderVisible||e.sliderVisible)),Iy(),w_((e=>t=>(t.sliderVisible=e,t)))).subscribe(this._sliderStateOperation$),this._setKeysSubscription=this._configuration$.pipe(Ry((e=>null!=e.keys)),Ab((e=>K_(this._catchCacheNode$(e.keys.background),this._catchCacheNode$(e.keys.foreground)).pipe(w_((e=>({background:e[0],foreground:e[1]}))),Vb(this._navigator.stateService.currentState$.pipe(Yy())),w_((e=>({nodes:e[0],state:e[1].state}))))))).subscribe((e=>{null!=e.state.currentNode&&null!=e.state.previousNode&&e.state.currentNode.key===e.nodes.foreground.key&&e.state.previousNode.key===e.nodes.background.key||(e.state.currentNode.key!==e.nodes.background.key?e.state.currentNode.key!==e.nodes.foreground.key||1!==e.state.trajectory.length?(this._navigator.stateService.setNodes([e.nodes.background]),this._navigator.stateService.setNodes([e.nodes.foreground])):this._navigator.stateService.prependNodes([e.nodes.background]):this._navigator.stateService.setNodes([e.nodes.foreground]))}),(e=>{console.error(e)}));let e=this._navigator.stateService.currentState$.pipe(w_((e=>e.state.previousNode)),Ry((e=>null!=e)),Iy(void 0,(e=>e.key)));this._nodeSubscription=X_(e,this._navigator.stateService.currentNode$).pipe(Ry((e=>e.pano?qb.maxImageSize>qb.basePanoramaSize:qb.maxImageSize>qb.baseImageSize)),$_((e=>{let t=e.pano?qb.basePanoramaSize:qb.baseImageSize;return Math.max(e.image.width,e.image.height)>t?i_():e.cacheImage$(qb.maxImageSize).pipe(w_((e=>[e.image,e])),ly(((t,i)=>(console.error(`Failed to fetch high res slider image (${e.key})`,t),i_()))))})),w_((([e,t])=>i=>(i.updateTexture(e,t),i)))).subscribe(this._sliderStateOperation$)}_deactivate(){this._navigator.stateService.state$.pipe(Yy()).subscribe((e=>{e===Fx.Waiting&&this._navigator.stateService.traverse()})),this._sliderStateDisposer$.next(null),this._setKeysSubscription.unsubscribe(),this._setSliderVisibleSubscription.unsubscribe(),this._stateSubscription.unsubscribe(),this._glRenderSubscription.unsubscribe(),this._domRenderSubscription.unsubscribe(),this._nodeSubscription.unsubscribe(),this.configure({keys:null}),this._sliderControl.removeEventListener("input",this._moveToHandler),this._sliderControl.removeEventListener("change",this._moveToHandler),this._container.element.removeChild(this._sliderContainer),this._moveToHandler=null,this._sliderControl=null,this._sliderWrapper=null,this._sliderContainer=null}_getDefaultConfiguration(){return{}}_catchCacheNode$(e){return this._navigator.graphService.cacheNode$(e).pipe(ly(((t,i)=>(console.error(`Failed to cache slider node (${e})`,t),i_()))))}}SC.componentName="slider";class MC{constructor(e,t,i,r,n){this._markerComponent=e,this._pathRender=t,this._pathMarker=i,this._container=r,this._navigator=n,this._projection=new sx,this._movingMarkerId="moving-path",this._activeMarkerId="active-path"}bind(){return this._disposable=X_(this._mapMouseEvent$(ax.mousedown,this._container.mouseService.mouseDown$),this._mapMouseEvent$(ax.mouseup,this._container.mouseService.mouseUp$),this._mapMouseEvent$(ax.mousemove,this._container.mouseService.mouseMove$)).pipe(Lb(this._container.renderService.renderCamera$,this._navigator.stateService.reference$,this._navigator.stateService.currentTransform$),w_((([[e,t],i,r,n])=>{const o=this._projection.eventToUnprojection(t,this._container.element,i,r,n);return{basicPoint:o.basicPoint,latLon:o.latLon,originalEvent:t,pixelPoint:o.pixelPoint,target:null,type:e}}))).subscribe((e=>{switch(e.type){case"mousemove":this._mouseMove(e);break;case"mousedown":this._mouseDownEvent=e;break;case"mouseup":this._mouseUpEvent=e,this._mouseClick(e)}})),this}unbind(){return this._disposable.unsubscribe(),this}_mapMouseEvent$(e,t){return t.pipe(w_((t=>[e,t])))}_isClick(){return yp(this._mouseDownEvent.pixelPoint,this._mouseUpEvent.pixelPoint)}_mouseClick(e){if(this._isClick()){let t=e.latLon;if(e.latLon||(t=this._mousemoveLatLon),t){let i=this._findNearNodeByDistance(t,2);if(i)return void this._markerComponent.getMarkerIdAt(e.pixelPoint).then((()=>this._updateClickState(i.key)));let r=this._findNextNode(t);r&&(MC.currentNode=r,this._navigator.moveToKey$(r.key,this._navigator.stateService.currentDate))}}}_updateClickState(e){null!==e&&e!==this._movingMarkerId&&this._navigator.moveToKey$(e,this._navigator.stateService.currentDate)}_mouseMove(e){null===e.latLon?this._removeMovingMarker():(this._mousemoveLatLon=e.latLon,this._createMovingMarker(e.latLon),this._createActiveMarker(e.latLon))}_createMovingMarker(e){return this._movingMarker=this._pathMarker.createCircleMarker(this._movingMarkerId,e),this._markerComponent.add([this._movingMarker]),this}_createActiveMarker(e){let t=this._findNearNodeByDistance(e,2);return t?(this._activeMarker=this._pathMarker.createHighMarker(this._activeMarkerId,t.l),this._markerComponent.add([this._activeMarker])):this._removeActiveMarker(),this}_removeMovingMarker(){return this._movingMarker=null,this}_removeActiveMarker(){return this._markerComponent.remove([this._activeMarkerId]),this._activeMarker=null,this}_findNearNodeByDistance(e,t){let i=this._pathRender.enableAreaPathNodes.filter((i=>this._pathRender.getDistance(i.l,e)<=t)),r=Ud(i.map((t=>this._pathRender.getDistance(t.l,e))));return i.find((t=>this._pathRender.getDistance(t.l,e)===r))}_findNextNode(e){let t,i,r,n,o;if(Pd(this._pathRender.allAreaPathNodes,(r=>{let n=this._pathRender.getDistance(r.l,e);(!t||t>n)&&(t=n,i=r)})),Pd(this._pathRender.allAreaPathNodes,((e,t)=>{e.key===MC.currentNode.key&&(r=t),e.key===i.key&&(n=t)})),r)return o=r<=n?this._pathRender.allAreaPathNodes[r+1]:this._pathRender.allAreaPathNodes[r-1],o}}class EC{constructor(e,t){this._meter=15,this._markerComponent=e,this._pathMarker=t,this._enableAreaPathNodes=[]}get enableAreaPathNodes(){return this._enableAreaPathNodes}get allAreaPathNodes(){return this._allAreaPathNodes}render(e,t){return MC.currentNode=e,this._enableAreaPathNodes=this._getEnableAreaPathNodes(e,this._filterPathNodes(t)),this._allAreaPathNodes=this._getEnableAreaPathNodes(e,t),this._markerComponent.remove(this._getMarkerIds()),this._markerComponent.add(this._getMarkerArr(this._enableAreaPathNodes)),setTimeout((()=>{this._markerComponent.add([this._pathMarker.createImageMarker("cover-logo",e.latLon)])}),500),this}getDistance(e,t){if(e&&t){const i=6378137,r=this._toRad(e.lat),n=this._toRad(t.lat),o=r-n,s=this._toRad(e.lon)-this._toRad(t.lon);return 2*Math.asin(Math.sqrt(Math.pow(Math.sin(o/2),2)+Math.cos(r)*Math.cos(n)*Math.pow(Math.sin(s/2),2)))*i}return 9999}_getMarkerIds(){return this._markerComponent.getAll().filter((e=>!(e instanceof BT))).map((e=>e.id))}_sortByFilename(e,t){return e.filename>t.filename?1:e.filename<t.filename?-1:0}_filterPathNodes(e){const t=e.reduce(((e,t)=>{const i=t.sequence.key;return e[i]||(e[i]=[]),e[i].push(t),e}),{});let i=[];for(let e in t){const r=t[e];r.sort(this._sortByFilename);const n=r.filter(((e,t)=>t%2==0));i=i.concat(n)}return i}_getEnableAreaPathNodes(e,t){return t.slice().filter((e=>!!e)).filter((t=>t.floor.id===e.floor.id)).filter((t=>{if(this.getDistance(e.latLon,t.l)<this._meter)return t}))}_toRad(e){return e*Math.PI/180}_getMarkerArr(e){return e.map((e=>this._pathMarker.createArrowMarker(e.key,e.l)))}}class TC extends kT{constructor(e,t,i){super(e,t),this._imageBase64=i}_createGeometry(e){const t=new fi(new ha(1.3,300),new It({map:(new Ya).load(this._imageBase64),side:2}));t.up.fromArray([0,0,1]),t.renderOrder=-1,t.position.z=1e-4;const i=new Pe;i.add(t),i.position.fromArray(e),this._geometry=i}_disposeGeometry(){for(let e of this._geometry.children)e.geometry.dispose(),e.material.dispose()}_getInteractiveObjects(){return[]}}class CC{createImageMarker(e,t){return new TC(e,{lat:t.lat,lon:t.lon},"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAMgCAYAAADbcAZoAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAACunSURBVHgB7d0rtCTVGTbg5l9xBE3QBJsEG2AtYgCDCZiJAMwgADOIgAEBJiDAACJjABEMg4nJxMQkWC6WEEuIhdHz/99hFen/5Fx679r1Vvc5z7PWWVzmTF+qqqv3u799uePhhx++vQEAAFje7f+zAQAACBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACIEUAAAIAYAQQAAIgRQAAAgBgBBAAAiBFAAACAGAEEAACI+ckGuDB++tOf/vjzs5/97Oifd95554//vv3/66d8/PHHmw8++GADAJAggMAeOy1QbP/3dqCYQkWLZ555ZvPFF19sPv/88w0AwNIEENgzTz/99Oaxxx7rDhQ9Hn30UQEEAIgwBwT2SAWBqkhMVY2UBx98MPp8AMDlJYDAnqjQUeFjDRU+fv7zn28AAJZmCBazVcP53//+92YpxydQT3Mgbt68uejzplX1o97fWh544AHDsACAxd3x8MMP395Ao7fffvuox3watnPt2rWuxmsN/bn77rv/ZzL18ZWaTlLh4+rVq5vvv/9+c+jq/V6/fn3VYVB1HB9//PENAMCCbquA0GU7fJQKEa1ef/31owDSqxrtVTW4cePG5tDVxPO152DU8//qV79SBQEAFmUOCF2OVx16Gs9zwsekGsyHroJUrXq1D2oYFgDAkgQQhmgNIKN6+y/CxOmqfuyLEaEQAOAsAghdjk/+bg0UoyZb1+OsOXF7rn2qfpR6PRehqgQA7C8BhCHWqoCUQ66C7FP1Y/LLX/5yAwCwFAGELnOXv+2ZtH6aQ20w71v1Y7KPrwkAuDgEEIZoHQY1ctjUoVZA9rH6UQ59WBsAsN8EEFZx2Ydg7Wv1Y1LLGwMALEEAocvxIVhrVkCmjQsPyb5WPyYmogMASxFAWMXoTfcOaR7Ivlc/SgWQtTdGBAAuJgGELnMnoZ/VuP3nP/+5aXVIw7D2vfoxMQwLAFiCAMIQI4dgVbhpDSGHMmToEKofE5sSAgBLEEDo8v333296VfXjrApIBZDPP/9806IqIIcwZOill17aHArDsACAJQggdLl169b//L9dqyDnNWor3FzEYVjVoD+0yd2GYQEAowkgdJlTATkvqFQF5Isvvti0uvfeezf77FDmfmwzDAsAGE0AocucAHLnnXee+efffvvtUQhpfY59roAcYvWjHMrQNgDgcAggDLPrEKxdf+8iTUQ/xOpHqfDxwAMPbAAARhFA6DJ3EvpZpiV+WwNIBZt97K2veRSHvLGfTQkBgJEEELqcFEDuvvvuzS52mQNSWlfCKvvYWH7mmWc2h6zmgRiGBQCMIoDQrbcKct4eIJOeiej7tiN6VT9a90jZNxU+DmmjRwBgvwkgdDseQHbtJT9vD5Dtx2/dcX3fGsqHXv2YmAcCAIwigDDMrgGkpSLQsyHhvlii+tGzOtgIh7J7OwCw/wQQuh2vToyugJTWiej12Psy5GmJ6sfNmze75sbMVcfVZHQAYAQBhGF2CSC7TkCffP3115tW+zAPZKnqx/vvv7/5+9//vlmDYVgAwAgCCN1a52eU8xrlx4cXtVZAyj4Mw1qi+vHBBx8c/fMf//iHYVgAwMESQBhmlwrILrugb6uG9qFtSLhU9eMvf/nL0b/3HJMRDMMCAEb4yQYGGTEE66Se/Zrz0FLVqN+t17JGlaAsWf2Y1DCsNcJADW9bYw7KRVTX6PZnpq7X1DU7Pff0Mz13T1Uzre4h00+ZXvtawTxpmuN2/LpZa3EKDsf0WT/+Hez6YS0CCN16JqHvugv6tp5GRd1k12iMLF39mNRk9BdeeGGTVpsSHg9DF1mdyzqnu7px48apX+QVGCvA1T+nkHySum4r5NU+OKPm+0x7udR7qec/6xqt559ew1rD/bZtH7ddQne97jpu9drPClTTsdjVG2+8sdPvPf3005td1ef4rNdY5216nfVz3gIedd7qvde1MyJMPvHEE02dP3WtvPvuu5u5Wu+jda7Put/X+9h1kZQ6diM7Wep56/l3dd57aXneOo51/s77zJcpwNdPvQYdTSxNAGGYJSahl94NCdcIIInqR6kvi/qCSFdB6suszuEh9JSPUNdRyzmtBuXxBns1Amr+zK7nqo5x/Tz55JNHx7nOc10DPcd8avzUY+3aAJuef5rzU+G39/nnaD1uk6mxXgH9rNdev7PrvKbbt2/vFEDuueeepuulXtdJr62Of523lnlXU1WoOgnKiPN2xx13NM/9qut/TidFHcOXX35559+vc1Ofu9PUe2jprKmFPkY2vu+6667ma2LOd1fv52YaYls/072nwmx1qlyW+z1ZAgjdRk9CP62ndSoP79qAKmtMRE9VPyZrDcOq93mZqiC96tw8//zzs67Fup6qMVE/LQ3KnuBxmun5P/7446PnX7oiMuK4TXqO3ZrqXFUFpc7bXCPeezU+a/W7lvtMvf45vfhPPfVU0+9/+OGHGsibHz43L7300rDvoHqcug4r0E7XEIxkEjrDzL3xnfUlcggT0VPVj0l9ya/BRPTzVeP/7bffHhqEqzG5y2PWn1+/fv3oepwbPrZVY+SPf/zjovvsVPAYfdxKHbu33nprb/YIOkl9rj766KMh4WPb9N57PrdVXXjzzTebQmdVHH7/+99veky997v65ptvjioWl1l9xqfPzRLXdz1m3UuW/uxz+QggdOvpCe2pgJTWAHJ8oubS0tWP6c/XGKd73lj0y656gJean1PXWIWL0xppdR0u1RApNTymGiKjA0INU6n3Nbrxva1e+1nHbk1TYF3qc1XvvR6/ZX7KpBr5rb3f9913X/NzVXBp6cSpcPTiiy9uLrP63NR5XfJzM6lzuu8hnsMigNDt1q1b//P/zvsCPevmdVYFpKehneypT1c/JmtNFGyZmH2Z1BCIJa6Fk57neEO6hsrU2Pmlw2E1eqohMiqELBVqTlLH5qRjt6YlA+txdW32hJAaitV6r6nnaTmnNfSqpXF72YdeVWAb+TncRX1WhRBGEUDodlLF4qzGT88E9EnPRPR77713k1BftOnqx6TnuIwwTXTl/5cMvdvzJOr6a5m4O1eFkNdee232dT+FmXSDpkLIPlzD1XOdCKzbekLI0kOxWifvG3q12Tz33HOrzHWsc9U7xA62CSB0ax2CdV7P7FmP17NHQeLmPE0SHm3XIQ/VK7lGL6BhWOur4//6668f/XPJ4TunGdEQqUbUWr2p+3D9rtGALBVAWsNy71CsXZagbZl4bujVD5+9xLCr09x///1NSwvDSQQQhjqrMXHeF/7xXdCPax0CkOiNXmPux3Gj9opoVUN+WFdde3/+859Xa8RXQ6R3OF7rhGPGqerEFF5b9A7FOuv6bL0ODL26Y1bwnzrz5h7DOq86oZhDAKFbawXk7rvvnvV4rRPRT9r1daS1qx+TtVbD0nhst/3lv0Yjaonn75lT0Drk5jxrHtOEaZO4avzXP0cshTytntSiZyhWDbM7rcHcOvHc0KsfvndaO9fquqkNIh9//PGjnytXrhz9/OY3v9lcvXq1a6+POq+qIMxhHxC6nfQldFbI2GUn1rN8/fXXm1a1kdxSjZJ9qH6U+nJp3SdlhGk377V3yt53dU7rC74qVWdtOrfLbsU9ph3N67o66VzV886pRkwNopae8UceeWTWe633MR3T4x0TLbu+77PpvJ113dR7rLksve+x/n5t4tdy7qahWC3hZRqyU+dsW8vEc0OvfvCLX/yi6ffrXJ0V2urz88477xzt81PntGVulD2hmEMAYZaWhu95v3deUOjZ2Kq+pM/aJbfXUtWP6qXqUY3L9JjgqaG31kpc+27aEbq+2M9S13Xtsl3XVFUTRl1X9fx1PZ0XaOv8Tbut1+Ts1t7V6sWuhuSu10FVP3rf4y7HtH5nek/T57SnSrOWauC/99575w6trOumfuoc965u1XruJnM2KJzu863zGGw4+IOWeUMtFaM6tq+88krTKnH1+aof54UehmAxy/Ee1TmrYJ3Xkz4NQ2ix1CTP6s0b3bNajYDe+RxrDcOyHO/J6gu5hjacFz6O/50KIiN6FKfnb6mm1d+5du1a1/NP1bBdVA9uz2fnq6++6jqm1QCrv3cIjaR6j88++2zzfaDe4+9+97uu99izoMSIoVgVfHZ9XkOvflCBseU7rafzrcLvrue1Xk+NMoAeAghDnfWFctaf7frF2dpTt0QAqcbTEtWGOQ3PaRhWmuV4T1YN+d4GbzW0WhrZx9V1MPf5WxvAUzXsPNVg6fnsVAO0ht/0vqfquJjz9xM+++yzo/DR+znuPUZ1TnrG8vesijUNxXrooYd27mWvsPPqq69uaNdzLX333XdNHRf2BKGXAMIsLV92vZsQbuuZiD46hCwxnGMaMjLHGqth1fFN7n1xCKpRNrehW8Nqeh9jxPNXJaZ1z4dd9t2pz2Lr53FqWM8N2PU4+9qQHfXa6nGqMtGqt5LZsypWbbrYsorTJ5980jX89iKqMNbyOej97qv9pabvpPN+TtqQGHZhDghDnRUyzvqzXW+qPRvvVYl41BfYvqx8dZIqt6+xMlWNBTcP5Ad1HbcuInCaqoK07pBdzz+nerL9OK3zinZp7LROoC0jx/7XEKeq8KQ3/ztLNSpbhr2cpyopdQ20nLvesfzTUKzayb5lGJehV/1arpO6N/ec1+rMWmt5dy4PFRBm2fXGNncC+vbvtX5Rj6yALFH9qBv9iAb8qOU5W1mO979GbgzZM357ZKOhdV7RectsV5WkdcheNUBHBbpJ9ajv08ptc+Z+naZCW2sFq3dfn56hWLvomWdyGbR0ptW8m9qk1Fw99pEAwlCnBY25E9C3tVYzRg0R2reVr47rmaQ/gmFY/zWyEtRzPnsqhKdpnVe0y1jw1s6AakiPVmPcR1SJRqhGdgWi0VrH8Zc5HTU9Q7HOU8dFZfV/ffnll02/X5/Ll19+efPRRx8tsnQ89BJAmGXXVbBGVUBKa6Osbrgj9shYovpRjYSRE2NH9xbvyq7oP+jZq+Ysrdf66EnWIx+vPoMtn8NqnC81DKS1EbeUun8u9R4//fTTpt+fs5rR6GpFVVX2JSTum2lDylbbQWSqiggjrEkAYZZdA8h5wzO+/fbbza56br5zh2Ht89yPbWstx2s1rB+sHQBGP//IilrrZ3DJld3WWjXupNex5GO3vMe5nTQjh2LZ8+N0FfbmVgarYj2Fkfp5/fXXBRLiBBCGSgzB6hlmsssKPWc5hOpHmTZhS5t2w4bT3HnnnU2/P7qatK0acfswvGef3mNrheokI4Zi1X1xrUruoaiFBkYdo7p3VwfSFEiuX79+tCP6UntowUQAYZb0JPRSjezWhvucxvGhVD8ma61eYkMqztIaQJbuAd+HHvalX0NrlWduAJk7FGupCe0XUR3nJUJ0BY9aQa2CiHkjLEkAYajTblQjKyCl9cY7J4AcSvVj0rN60ggqIIy09BCpy7C60hoha06IMPRqdxX2asPRJefKbM8bqarIiLmUMBFAmGXXL/ERu6Bv69mQsKcX59CqH2WtYVgVQPSUwf5Y6/NYq3C12pdhcYemVlGsjUOXDm5VFan9XgzNYhQBhFlO2gX1pLAxOoD0jJ3uGSJ0aNWPyVrDsKyGBZfbPffc07XRY+1F0rJDOv9V3ylVDamOrSW/W+rc1tAsez8xggDCLCdVQE4KGyN2Qd/WszpPa8/NIVY/JlbD4tAt3dO6D9W6JYe0VIO+9T2OGJb21FNPdR/b+++/f/PEE09saFfBo3aNv3LlylEYqVCy1DDDCoqG3DKXAMIsu9zgzltdpecm2bNJW2uD5lCrH6WeY61hWMYJc5L//Oc/Tb9/3tLdc/Q0zpewbyFrboP1oYcemt1pU/fdNc/NRRhGWvf+Gpb1+OOP/zhPZOSS2vX5ee211wy5ZRYBhOGO35RGroC1rbWB3fJlf8jVj8la46lr1RQ4Lrly3XnqnrQPPbhLrhxX97CWBuLcBupdd921ee655zZz1eNcpKFYazfS63ug5olcvXr1KJC88sorQwJJnaclOum4PAQQZtmlUXHeDbg3gPRMRN81hBxy9WPSs1/KCIZhcZK69ls3xlsqJOzLktFL7p/z61//uun351Y/5gy9Om7NoVhz94w6rnX56SXVOa75gVMgqeFa9e+930vV2aTiTS8BhOGOD5047wbcsgv6tp4G9i4Nj2oQHHr1o1TP1xpLWhqGxWlaOg1qmMdS1bR9qdLVe1wiDNXj1qpFLeZ0WNTk5NbnO8/IoVgt98HRFYt93h+pjktVQ7bnjbSo68ycHXoJIMx2Xs/ZUiXo1h7VsksF5CJUPyZWw2Jf9CyzusQmaNVY3qcqXTXgRgf2Rx55pOm41bnpDSDVCH3rrbc2o40cirVW5a2OzaFUhKd5I88++2zT8bIBLb0EEGY7frM6/mW61ByQMnoien3xLDEkYq3dfddaDcsyjZzkyy+/bPr90UuzTpNn98noOQ89y+DO2Tto5NCr40YMxapw1Vp5++1vf7sZYfTeSBVm6t66y0/vAgdfffVV0+aG9gWh1082MNjxwLHUHJBSXywtgaFulvX6TuvhWaL6sfTa7GepRkW91/SQqPOOM5dTz/VYjdD6XI4I8dVY3scGU60eNeI99q5O1NtR0Rp26v21VrXquNTrS3ZUVUO/rpM5E7XrXNT1Nko9Xu1GvuuxqyBR1Ywen3zyyc7n1XBbeqmAMNt5Xwyj9wDZ1tNrd1oDZInqRx2b1nG1o63x/C0T/rk8qje6pXd1Uo2huZ0D9fd7NshLmfse6zNXlZTWz12dk5s3b25atQ69qgZx7VPx5ptvblqMqBD961//avr9qfI2p3Fd4WPk90lrJaeuA3t1sM8EEIZrWYZ3bmWgZ9zyaaucvPTSS5vR6ot9rerHZK1hWJbj5STVu9qjGujVA9zaKKzfr7+3z+Fj0vseq7H59ttvdw197N0zqGXoVTWeX3311aN//+yzz5pD6NyhWFPlrcV99913FLB6hlDVvW+J6611KFlvBaZlBTVVbnoJIMy2ZgWk/v6I/QWWmOy6D9WP0vPlO4LleDnJd9991/25qJWWrl+/vtPyn/XnVVH46KOPhq/QtKTt93jePamCR3Wc1O/3Vhw//PDDTavWoVfHO2LqOVvv23NWxaoA1HPNVQipYLdrZ8oUdl9++eXNElrnUE3DF1tUxanl3I7c4JDLxRwQhmuZhD6iOlAN7Jaev5O+qJfordqH6sekVsNKTwyfVpNZa0NE9lc1QCug9gxxqUbo1MCr67oaQNtLedey39MY/kMdn779HuvzU++x7iW3bt06en/T/iFzhzl+8803XUuvtgy9quc4PrelQmgNxWp5nGko1osvvrjp8emnn3YF0elc1HdEVW6+/vrrH1dgrOtrGm5aq0H1XtO7qmuhflqGVtXrrgBVx+2876N63Aq0LUGvjgf0EECY7axVsJacgD5p7YGZdgienvsiVz8mFYbWWJmqluMVQDhuapRWb/Ec1eC76JW2pVbmK63zMUqtENVyvzyt2jENxWoJBdNQrBs3bmxa9TTet9V7fuGFFzZrqkpOHc/W91AVq6oETsegQsP0vV3f17V3V32OWh+3d/4QFAGE2eYEkBFDg3p6YKrHavpSXKL6sebKVyepkLbGalgVemqnXTiuGpEVUE2UXUcd/9bOgdahV+dVWKZKWOuqWNXobf3u6G2875s5QWp0mJ2qc9DDHBCG227kLrUL+raeG+C0edJlqH6U+rJe44ti5KZeXCzVIKwe+H0K6pdFrUj1zjvvbFrVpOZdOzG2J56fZhqK1WLOqlg9E+D3zb58bqbXAb0EEGY760aYqID0NK6nsdNLVT/20VqhyE65nKZ6yHcZmz5afUb3oZOgXkP6vdcxPy8YnKQ6a1qGcVaVYpf7ck8omDP0rqogh95rP53DNVeg6llIALYJIAy3HTqW3AV9W+tQggogl6X6MbErOvsoHUIqfNR+FPug7lvJ9957rHuGXrV0xLQ2Zufs01FVl2q8J455BZ3eSfPnqSrWtWvXVgkBFS735TPE4RJAmO2sXpjEJPTS2qNVX1xLTCjc1+pHqfO0xoTwugZsSshZpobx0j3TNR9p3xpOqQBWlYbaGbvneVr2/Ch//etfm54nPRQrcb3V8V46IEwBJxlCKnz84Q9/2MBcAgiz1dKQx009U0vuAbKtZ0PC0ROy97n6MallS9dQk43hLNUovHr16iIhvh67GoP7Ov6/Xt+VK1cWeX11n63gVQ3Vnntu69Crei89IS89FGvJ660m+Pce71bTtbN059d0HQkfjCKAMNtJN9ldGvcje22mddnXtM/Vj8laSyaaiM6uqvFaDaoRYb7uCfW5rJ7/Q1gOuhp41SgedW+sY1iP1xtsWode1cTk9957b9MrORRrMl1vIzpn6hqroNszwX+ukZ+b4yoczrmO4CSW4WW23iFYowNDlaPXaugeQvWjTMOw0sepnq8aCWuHxEPTerzWPL4jn7s+T2+88cZReKhrp3rhd71mp0UppmVmT3tdtQLfro3dalin1GuvhuT0vlvnUNX7rfc+YoJ7654f1cExpyHfu0FhLc07Z7nvOk6vvPLK0XutfUZaNnms413HuubYzQ25dZ2dNKJgV3M+N8fVe6mRBRU63LdZwh0PP/xw7s7KhVQ37drkaFv1AtUN7G9/+9upf6++qOqmP0ptataz0+0IddM/hABS6gt2jQ21qlewZwOxtbU0wC7iqjC7vv9qpCzZUJl2nK6f2jhtu9e7nrcCRTXepz1v1lAVgz/96U87/34NZzmvKrm90/a0u/v0M1V+66f2Q7IvwzjT3LV77733x+M9qeNe11sd733/zG9/buq9nPZ5rvcx7fJ+VnCHQW6rgDDbaTfg1AT0Sd001wggh1L9mFRP3RoBpMZqH2IAuexLTe7L+5+qd4cwlGqky/q+11bXff2sNW9uFNcP+8ocEBZxvIfyJKMbNj0T0Uc4hLkf26YerrRpGBYAcLkJIAzRMxF9dIm3Hi/dW3to1Y/JWr1hNSYZALjcBBCGOClMVBXkLDWGdrR0w/rQqh+TtapFvUtmAgAXhwDCImr+x3lzQJaY5JacgHmo1Y+y1uTJaRItAHB5CSAMcVJjNj0HpNQqHimHWv2YrDG5sq4JmxICwOUmgLCIi14BqQrCoVY/JrUa1hpsSggAl5sAwhCtFZClhv9Mm5At7dCrH2Wttd5rHohhWABweQkgLKIamGdVQJacf7D0RPSLtKb6GlWcaWMsAOByEkAY4nhP+nkBZMme96UrIBeh+jFZaxhW7eoMAFxOAghDHA8U6V3Qty25xOxF21G2wtoaw7CWWIIZADgMAgiLWGMC+qTCzVKP/8Ybb2wukjpOydWwKrxdu3bt4CfwAwD9BBCGaK1oLL0HxRLDsKrRvMbeGUtLBJAKOu++++5R+LhIFSQAoN1PNrCCpYfgVAAZvdzrRZr7sa2GrFVAWGplqhs3bmzef//9VYZ6AQD7RwWEIVobl0s3Rkf3sl/U6kepc1GVidHnpM7B1atXN++8847wAQD8SAWEIW7dutX0+0s35kdPRL+o1Y9JVYwqLDz55JNHO5WfN4fnLHVua7jVGjutAwD7TwWEIVp6uJecJD6pxx8Vci5y9WNbvceqVly5cuVosn3re65jXkGtgozwAQCcRgWEIaqxWj+79JzfvHlzk1BzD55//vnNHDWM6KJXP05Soat+Hnvssc2jjz567nyaOk49oQUuku+++65phTfLUQOX1R0PP/zw7Q0MUOGjdrg+bTJz/f8a6pNcBenBBx/snlxdjWkrNv2gAkgFkQok2+p81nArxwkA2NFtAQTYWYXMJ5544ijU1Twb+3kAAI0EEAAAIOa2SegAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQIwAAgAAxAggAABAjAACAADECCAAAECMAAIAAMQIIAAAQMxP/t/P7Q0AAMDybv9fWBY0+xZoU2wAAAAASUVORK5CYII=")}createArrowMarker(e,t){return new FT(e,{lat:t.lat,lon:t.lon},{offsetFactor:-.1})}createCircleMarker(e,t){return new FT(e,{lat:t.lat,lon:t.lon},{outerColor:16777215,offsetFactor:-.5})}createHighMarker(e,t){return new FT(e,{lat:t.lat,lon:t.lon},{offsetFactor:-.3})}}class IC extends fT{constructor(e,t,i){super(e,t,i),this._markerComponent=new LT(e,t,i);const r=new CC;this._pathRender=new EC(this._markerComponent,r),this._pathEvent=new MC(this._markerComponent,this._pathRender,r,t,i)}_activate(){this._markerComponent.activate(),this._pathEvent.bind(),this._disposable=B_(this._navigator.stateService.currentNodeExternal$,this._navigator.imageLoadingService.loadpath$,this._navigator.imageLoadingService.loadpathOutdoor$).pipe(Ly((([e,t,i])=>{this._pathRender.render(e,t.concat(i))}))).subscribe((()=>{}))}_deactivate(){this._disposable.unsubscribe(),this._pathEvent.unbind(),this._markerComponent.deactivate()}_getDefaultConfiguration(){return{}}}IC.componentName="path",Kb.registerCover(UT),Kb.register(zT),Kb.register($T),Kb.register(VT),Kb.register(GT),Kb.register(QT),Kb.register(JT),Kb.register(sC),Kb.register(uC),Kb.register(WT),Kb.register(wC),Kb.register(SC),Kb.register(KT),Kb.register(LT),Kb.register(oC),Kb.register(IC),Kb.register(jT),Kb.register(dC),Kb.register(RT),e.ArrowMarker=class extends kT{constructor(e,t,i){super(e,t),i=i||{},this._color=null!=i.color?i.color:16777215,this._opacity=null!=i.opacity?i.opacity:.4,this._radius=null!=i.radius?i.radius:1,this._interactive=null==i.interactive||i.interactive}_createGeometry(e){const t=new fi(new ha(this._radius,100),new It({color:this._color,opacity:this._opacity,transparent:!0}));t.up.fromArray([0,0,1]),t.renderOrder=-1;const i=new Pe;i.add(t),i.position.fromArray(e),this._geometry=i}_disposeGeometry(){for(let e of this._geometry.children)e.geometry.dispose(),e.material.dispose()}_getInteractiveObjects(){return this._interactive?[this._geometry.children[0]]:[]}},e.CircleMarker=BT,e.DotMarker=FT,e.GeometryTagError=wE,e.MarkerComponent=LT,e.OutlineTag=pT,e.PointGeometry=SE,e.PolygonGeometry=uT,e.Popup=class{constructor(e,t,i){this._options={},e&&(this._options.capturePointer=null==e.capturePointer||e.capturePointer,this._options.clean=e.clean,this._options.float=e.float,this._options.offset=e.offset,this._options.opacity=e.opacity,this._options.position=e.position),this._dom=i||new Gb,this._viewportCoords=t||new Gu,this._notifyChanged$=new zv}get changed$(){return this._notifyChanged$}remove(){this._content&&this._content.parentNode&&this._content.parentNode.removeChild(this._content),this._container&&(this._container.parentNode.removeChild(this._container),delete this._container),this._parentContainer&&delete this._parentContainer}setBasicPoint(e){this._point=e.slice(),this._rect=null,this._notifyChanged$.next(this)}setBasicRect(e){this._rect=e.slice(),this._point=null,this._notifyChanged$.next(this)}setDOMContent(e){this._content&&this._content.parentNode&&this._content.parentNode.removeChild(this._content);const t="beeviewjs-popup-content"+(!0===this._options.clean?"-clean":"")+(!0===this._options.capturePointer?" beeviewjs-popup-capture-pointer":"");this._content=this._dom.createElement("div",t,this._container),this._content.appendChild(e),this._notifyChanged$.next(this)}setHTML(e){const t=this._dom.document.createDocumentFragment(),i=this._dom.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);this.setDOMContent(t)}setText(e){this.setDOMContent(this._dom.document.createTextNode(e))}setParentContainer(e){this._parentContainer=e}update(t,i,r){if(!this._parentContainer||!this._content)return;if(!this._point&&!this._rect)return;if(!this._container){this._container=this._dom.createElement("div","beeviewjs-popup",this._parentContainer);if(!0!==this._options.clean&&this._options.float!==e.Alignment.Center){const e="beeviewjs-popup-tip"+(!0===this._options.capturePointer?" beeviewjs-popup-capture-pointer":"");this._tip=this._dom.createElement("div",e,this._container),this._dom.createElement("div","beeviewjs-popup-tip-inner",this._tip)}this._container.appendChild(this._content),this._parentContainer.appendChild(this._container),null!=this._options.opacity&&(this._container.style.opacity=this._options.opacity.toString())}let n,o=null,s=this._alignmentToPopupAligment(this._options.position),a=this._alignmentToPopupAligment(this._options.float);if(null!=this._point)o=this._viewportCoords.basicToCanvasSafe(this._point[0],this._point[1],{offsetHeight:i.height,offsetWidth:i.width},r,t.perspective);else{n=this._container.classList;const e=["center","top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"];let c=null;for(const t of e)if(n.contains(`beeviewjs-popup-float-${t}`)){c=t;break}[o,s]=this._rectToPixel(this._rect,s,c,t,i,r),a||(a=s)}if(null==o)return void(this._container.style.visibility="hidden");if(this._container.style.visibility="visible",!a){const e=this._container.offsetWidth,t=this._container.offsetHeight,r=this._pixelToFloats(o,i,e,t);a=0===r.length?"top":r.join("-")}const c=this._normalizeOffset(this._options.offset);o=[o[0]+c[a][0],o[1]+c[a][1]],o=[Math.round(o[0]),Math.round(o[1])];const h={bottom:"translate(-50%,0)","bottom-left":"translate(-100%,0)","bottom-right":"translate(0,0)",center:"translate(-50%,-50%)",left:"translate(-100%,-50%)",right:"translate(0,-50%)",top:"translate(-50%,-100%)","top-left":"translate(-100%,-100%)","top-right":"translate(0,-100%)"};n=this._container.classList;for(const e in h)h.hasOwnProperty(e)&&n.remove(`beeviewjs-popup-float-${e}`);n.add(`beeviewjs-popup-float-${a}`),this._container.style.transform=`${h[a]} translate(${o[0]}px,${o[1]}px)`}_rectToPixel(e,t,i,r,n,o){let s;if(!t){const t=this._container.offsetWidth,a=this._container.offsetHeight,c={bottom:[0,a/2],"bottom-left":[-t/2,a/2],"bottom-right":[t/2,a/2],left:[-t/2,0],right:[t/2,0],top:[0,-a/2],"top-left":[-t/2,-a/2],"top-right":[t/2,-a/2]},h=["top","bottom","left","right"];let u=[0,null,null];for(const l of h){s=this._pointFromRectPosition(e,l);const h=this._viewportCoords.basicToCanvasSafe(s[0],s[1],{offsetHeight:n.height,offsetWidth:n.width},o,r.perspective);if(null==h)continue;const p=c[l],d=[h[0]+p[0],h[1]+p[1]],f=null!=i&&i===l?1:.7;if(0===this._pixelToFloats(d,n,t/f,a/(2*f)).length&&h[0]>0&&h[0]<n.width&&h[1]>0&&h[1]<n.height)return[h,l];const m=Math.max(d[0]-t/2,0),g=Math.min(d[0]+t/2,n.width),v=Math.max(d[1]-a/2,0),_=Math.min(d[1]+a/2,n.height),y=f*Math.max(0,g-m)*Math.max(0,_-v);y>u[0]&&(u[0]=y,u[1]=h,u[2]=l)}if(u[0]>0)return[u[1],u[2]]}s=this._pointFromRectPosition(e,t);return[this._viewportCoords.basicToCanvasSafe(s[0],s[1],{offsetHeight:n.height,offsetWidth:n.width},o,r.perspective),null!=t?t:"top"]}_alignmentToPopupAligment(t){switch(t){case e.Alignment.Bottom:return"bottom";case e.Alignment.BottomLeft:return"bottom-left";case e.Alignment.BottomRight:return"bottom-right";case e.Alignment.Center:return"center";case e.Alignment.Left:return"left";case e.Alignment.Right:return"right";case e.Alignment.Top:return"top";case e.Alignment.TopLeft:return"top-left";case e.Alignment.TopRight:return"top-right";default:return null}}_normalizeOffset(e){if(null==e)return this._normalizeOffset(0);if("number"==typeof e){const t=e,i=(t>=0?1:-1)*Math.round(Math.sqrt(.5*Math.pow(t,2)));return{bottom:[0,t],"bottom-left":[-i,i],"bottom-right":[i,i],center:[0,0],left:[-t,0],right:[t,0],top:[0,-t],"top-left":[-i,-i],"top-right":[i,-i]}}return{bottom:e.bottom||[0,0],"bottom-left":e.bottomLeft||[0,0],"bottom-right":e.bottomRight||[0,0],center:e.center||[0,0],left:e.left||[0,0],right:e.right||[0,0],top:e.top||[0,0],"top-left":e.topLeft||[0,0],"top-right":e.topRight||[0,0]}}_pixelToFloats(e,t,i,r){const n=[];return e[1]<r?n.push("bottom"):e[1]>t.height-r&&n.push("top"),e[0]<i/2?n.push("right"):e[0]>t.width-i/2&&n.push("left"),n}_pointFromRectPosition(e,t){switch(t){case"bottom":default:return[(e[0]+e[2])/2,e[3]];case"bottom-left":return[e[0],e[3]];case"bottom-right":return[e[2],e[3]];case"center":return[(e[0]+e[2])/2,(e[1]+e[3])/2];case"left":return[e[0],(e[1]+e[3])/2];case"right":return[e[2],(e[1]+e[3])/2];case"top":return[(e[0]+e[2])/2,e[1]];case"top-left":return[e[0],e[1]];case"top-right":return[e[2],e[1]]}}},e.PopupComponent=jT,e.RectGeometry=hT,e.SimpleMarker=class extends kT{constructor(e,t,i){super(e,t),i=i||{},this._ballColor=null!=i.ballColor?i.ballColor:16711680,this._ballOpacity=null!=i.ballOpacity?i.ballOpacity:.8,this._circleToRayAngle=2,this._color=null!=i.color?i.color:16711680,this._interactive=!!i.interactive,this._opacity=null!=i.opacity?i.opacity:.4,this._radius=null!=i.radius?i.radius:1}_createGeometry(e){const t=this._radius,i=new fi(this._markerGeometry(t,8,8),new It({color:this._color,opacity:this._opacity,transparent:!0}));i.renderOrder=1;const r=new fi(new Ys(t/2,8,8),new It({color:this._ballColor,opacity:this._ballOpacity,transparent:!0}));r.position.z=this._markerHeight(t);const n=new Pe;n.add(r),n.add(i),n.position.fromArray(e),this._geometry=n}_disposeGeometry(){for(let e of this._geometry.children)e.geometry.dispose(),e.material.dispose()}_getInteractiveObjects(){return this._interactive?[this._geometry.children[0]]:[]}_markerHeight(e){let t=Math.tan(Math.PI-this._circleToRayAngle);return e*Math.sqrt(1+t*t)}_markerGeometry(e,t,i){let r=new xi;t=Math.max(3,Math.floor(t)||8),i=Math.max(2,Math.floor(i)||6);let n=this._markerHeight(e),o=[];for(let s=0;s<=i;++s){let a=[];for(let o=0;o<=t;++o){let c,h=o/t*Math.PI*2,u=s/i*Math.PI;if(u<this._circleToRayAngle)c=e;else{let t=Math.tan(u-this._circleToRayAngle);c=e*Math.sqrt(1+t*t)}let l=new oe;l.x=c*Math.cos(h)*Math.sin(u),l.y=c*Math.sin(h)*Math.sin(u),l.z=c*Math.cos(u)+n,r.vertices.push(l),a.push(r.vertices.length-1)}o.push(a)}for(let e=0;e<i;++e)for(let i=0;i<t;++i){let t=o[e][i+1],n=o[e][i],s=o[e+1][i],a=o[e+1][i+1],c=r.vertices[t].clone().normalize(),h=r.vertices[n].clone().normalize(),u=r.vertices[s].clone().normalize(),l=r.vertices[a].clone().normalize();r.faces.push(new Et(t,n,a,[c,h,l])),r.faces.push(new Et(n,s,a,[h.clone(),u,l.clone()]))}return r.computeFaceNormals(),r.boundingSphere=new Ye(new oe,e+n),r}},e.SpotTag=dT,e.TagComponent=RT,e.Viewer=xE,e.isFallbackSupported=n,e.isSupported=function(){return n()&&r()},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
11
|
+
//# sourceMappingURL=mapxus-visual.js.map
|