soonspacejs 2.6.1 → 2.6.2

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/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import*as e from"three";import{Vector3 as t,Euler as n,Box3 as i,Quaternion as r,CubeTextureLoader as s,RGBAFormat as o,Color as a,Texture as l,Source as c,LinearEncoding as u,MathUtils as h,DoubleSide as d,BufferAttribute as f,PropertyBinding as p,InterpolateDiscrete as g,Matrix4 as m,Scene as v,InterpolateLinear as y,NearestFilter as w,NearestMipmapNearestFilter as b,NearestMipmapLinearFilter as x,LinearFilter as A,LinearMipmapNearestFilter as T,LinearMipmapLinearFilter as S,ClampToEdgeWrapping as E,RepeatWrapping as D,MirroredRepeatWrapping as C,sRGBEncoding as I,Vector2 as M,Plane as B,Line3 as R,Triangle as P,Sphere as O,BackSide as _,FrontSide as L,Mesh as k,Ray as N,BoxGeometry as U,MeshStandardMaterial as F,PointLight as j,MeshBasicMaterial as z,DataTextureLoader as H,HalfFloatType as G,FloatType as V,DataUtils as Y,ShaderMaterial as W,UniformsUtils as X,Fog as Q,EdgesGeometry as K,LineSegments as Z,LineBasicMaterial as q,Object3D as J,PerspectiveCamera as $,OrthographicCamera as ee,WebGLRenderer as te,PCFSoftShadowMap as ne,Camera as ie,UnsignedByteType as re,MeshNormalMaterial as se,WebGLRenderTarget as oe,DepthTexture as ae,DepthStencilFormat as le,UnsignedInt248Type as ce,UnsignedIntType as ue,Uniform as he,LoadingManager as de,NoBlending as fe,RGBADepthPacking as pe,REVISION as ge,EventDispatcher as me,MeshDepthMaterial as ve,BasicDepthPacking as ye,DataTexture as we,Vector4 as be,BufferGeometry as xe,Material as Ae,LuminanceFormat as Te,RedFormat as Se,RGFormat as Ee,ShaderChunk as De,WebGLCubeRenderTarget as Ce,CubeCamera as Ie,PMREMGenerator as Me,WebGLMultipleRenderTargets as Be,FramebufferTexture as Re,Matrix3 as Pe,TangentSpaceNormalMap as Oe,GLSL3 as _e,VideoTexture as Le,Frustum as ke,MOUSE as Ne,TOUCH as Ue,Spherical as Fe,CanvasTexture as je,PlaneGeometry as ze,Raycaster as He,Clock as Ge,AnimationMixer as Ve,ACESFilmicToneMapping as Ye,AnimationClip as We,NoToneMapping as Xe,LinearToneMapping as Qe,ReinhardToneMapping as Ke,CineonToneMapping as Ze,EquirectangularReflectionMapping as qe,TextureLoader as Je,Sprite as $e,SpriteMaterial as et,SphereGeometry as tt,CircleGeometry as nt,Float32BufferAttribute as it,ShapeGeometry as rt,Shape as st,UniformsLib as ot,UVMapping as at,AmbientLight as lt,DirectionalLight as ct,HemisphereLight as ut,SpotLight as ht,RectAreaLight as dt,Curve as ft,Loader as pt,LoaderUtils as gt,FileLoader as mt,MeshPhongMaterial as vt,MeshLambertMaterial as yt,Group as wt,Bone as bt,SkinnedMesh as xt,Line as At,Skeleton as Tt,Uint16BufferAttribute as St,VectorKeyframeTrack as Et,QuaternionKeyframeTrack as Dt,NumberKeyframeTrack as Ct,TrianglesDrawMode as It,TriangleFanDrawMode as Mt,TriangleStripDrawMode as Bt,MeshPhysicalMaterial as Rt,InstancedMesh as Pt,ImageBitmapLoader as Ot,InterleavedBuffer as _t,InterleavedBufferAttribute as Lt,PointsMaterial as kt,LineLoop as Nt,Points as Ut,Interpolant as Ft,LinearMipMapLinearFilter as jt,ImageLoader as zt,GridHelper as Ht,AxesHelper as Gt,Box3Helper as Vt,DirectionalLightHelper as Yt,HemisphereLightHelper as Wt,SpotLightHelper as Xt,PointLightHelper as Qt,Box2 as Kt}from"three";export*from"three";var Zt,qt="soonspacejs",Jt="2.6.1",$t={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 1-Math.cos(e*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.cos(Math.PI*e))}},Exponential:{In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))}},Circular:{In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}},Elastic:{In:function(e){return 0===e?0:1===e?1:-Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)},Out:function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(5*(e-.1)*Math.PI)+1},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?-.5*Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)+1}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-$t.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?.5*$t.Bounce.In(2*e):.5*$t.Bounce.Out(2*e-1)+.5}}},en="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},tn=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map((function(t){return e._tweens[t]}))},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){void 0===e&&(e=en()),void 0===t&&(t=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],s=!t;r&&!1===r.update(e,s)&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),nn={Linear:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.Linear;return t<0?s(e[0],e[1],i):t>1?s(e[n],e[n-1],n-i):s(e[r],e[r+1>n?n:r+1],i-r)},Bezier:function(e,t){for(var n=0,i=e.length-1,r=Math.pow,s=nn.Utils.Bernstein,o=0;o<=i;o++)n+=r(1-t,i-o)*r(t,o)*e[o]*s(i,o);return n},CatmullRom:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(r=Math.floor(i=n*(1+t))),s(e[(r-1+n)%n],e[r],e[(r+1)%n],e[(r+2)%n],i-r)):t<0?e[0]-(s(e[0],e[0],e[1],e[1],-i)-e[0]):t>1?e[n]-(s(e[n],e[n],e[n-1],e[n-1],i-n)-e[n]):s(e[r?r-1:0],e[r],e[n<r+1?n:r+1],e[n<r+2?n:r+2],i-r)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=nn.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(Zt=[1],function(e){var t=1;if(Zt[e])return Zt[e];for(var n=e;n>1;n--)t*=n;return Zt[e]=t,t}),CatmullRom:function(e,t,n,i,r){var s=.5*(n-e),o=.5*(i-t),a=r*r;return(2*t-2*n+s+o)*(r*a)+(-3*t+3*n-2*s-o)*a+s*r+t}}},rn=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),sn=new tn,on=function(){function e(e,t){void 0===t&&(t=sn),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=$t.Linear.None,this._interpolationFunction=nn.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=rn.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),void 0!==t&&(this._duration=t),this},e.prototype.duration=function(e){return this._duration=e,this},e.prototype.start=function(e){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var t in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(t),this._valuesStart[t]=this._valuesStartRepeat[t];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==e?"string"==typeof e?en()+parseFloat(e):e:en(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},e.prototype._setupProperties=function(e,t,n,i){for(var r in n){var s=e[r],o=Array.isArray(s),a=o?"array":typeof s,l=!o&&Array.isArray(n[r]);if("undefined"!==a&&"function"!==a){if(l){var c=n[r];if(0===c.length)continue;c=c.map(this._handleRelativeValue.bind(this,s)),n[r]=[s].concat(c)}if("object"!==a&&!o||!s||l)void 0===t[r]&&(t[r]=s),o||(t[r]*=1),i[r]=l?n[r].slice().reverse():t[r]||0;else{for(var u in t[r]=o?[]:{},s)t[r][u]=s[u];i[r]=o?[]:{},this._setupProperties(s,t[r],n[r],i[r])}}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return void 0===e&&(e=en()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this)),this},e.prototype.resume=function(e){return void 0===e&&(e=en()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return this._group=e,this},e.prototype.delay=function(e){return this._delayTime=e,this},e.prototype.repeat=function(e){return this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return this._yoyo=e,this},e.prototype.easing=function(e){return this._easingFunction=e,this},e.prototype.interpolation=function(e){return this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){if(void 0===e&&(e=en()),void 0===t&&(t=!0),this._isPaused)return!0;var n,i,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e)}if(this._goToEnd=!1,e<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(e-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var s=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,s),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,a=this._chainedTweens.length;o<a;o++)this._chainedTweens[o].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(void 0!==t[r]){var s=t[r]||0,o=n[r],a=Array.isArray(e[r]),l=Array.isArray(o);!a&&l?e[r]=this._interpolationFunction(o,i):"object"==typeof o&&o?this._updateProperties(e[r],s,o,i):"number"==typeof(o=this._handleRelativeValue(s,o))&&(e[r]=s+(o-s)*i)}},e.prototype._handleRelativeValue=function(e,t){return"string"!=typeof t?t:"+"===t.charAt(0)||"-"===t.charAt(0)?e+parseFloat(t):parseFloat(t)},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];this._valuesStartRepeat[e]="string"==typeof n?this._valuesStartRepeat[e]+parseFloat(n):this._valuesEnd[e],this._valuesEnd[e]=t},e}(),an=rn.nextId,ln=sn,cn=ln.getAll.bind(ln),un=ln.removeAll.bind(ln),hn=ln.add.bind(ln),dn=ln.remove.bind(ln),fn=ln.update.bind(ln),pn={Easing:$t,Group:tn,Interpolation:nn,now:en,Sequence:rn,nextId:an,Tween:on,VERSION:"18.6.4",getAll:cn,removeAll:un,add:hn,remove:dn,update:fn};const gn="[soonspacejs]: ",mn="In soonspacejs: ",vn=(e,t)=>{let n="";for(const e in t)n+=`${e}: ${t[e]};`;console.log(`%c${e}`,n)},yn=e=>{console.warn(mn+e)};function wn(e){return e instanceof t?e:new t(e.x,e.y,e.z)}function bn(e){return e instanceof n?e:new n(e.x,e.y,e.z)}function xn(e){return new i(new t(0,0,0),new t(500,500,500)).setFromObject(e)}function An(e,t,n){const i=n.clone();return Math.abs(t[e]-n[e])>Math.PI&&(t[e]>n[e]?i[e]+=2*Math.PI:i[e]-=2*Math.PI),i}function Tn(e,t){const i=An("x",e,t),r=An("y",e,t),s=An("z",e,t);return new n(i.x,r.y,s.z,t.order)}function Sn(e){return Math.PI/180*e}function En(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?{position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)}:{position:e.position.clone(),rotation:e.rotation.clone(),scale:e.scale.clone()}}function Dn(e,t){const n=En(t,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);e.position.copy(n.position),e.rotation.copy(n.rotation),e.scale.copy(n.scale)}function Cn(e){return!!e.visible&&(!e.parent||Cn(e.parent))}class In{constructor(){this.min=null,this.roots=[],this.nodes=new Map}shift(){const e=this.min;if(null===e||this.roots.length<1)return this.min=null,e;this.remove(e),this.roots.length>50&&this.consolidate();let t=1/0;const n=this.roots.length;for(let e=0;e<n;e++){const n=this.roots[e],i=this.getDistance(n);i<t&&(t=i,this.min=n)}return e}consolidate(){const e=[[],[],[],[],[],[],[]],t=e.length-1,n=this.roots.length;for(let i=0;i<n;i++){const n=this.roots[i],r=this.nodes.get(n);r&&r.depth<t&&e[r.depth].push(n)}for(let n=0;n<=t;n++)for(;e[n].length>1;){const i=e[n].shift(),r=e[n].shift(),s=n+1;let o=-1;if(void 0!==i&&void 0!==r){const n=this.nodes.get(i),a=this.nodes.get(r);n&&a&&(n.distance<a.distance?(n.depth=s,n.children.push(r),a.parent=i,s<=t&&e[s].push(i),o=this.roots.indexOf(r)):(a.depth=s,a.children.push(i),n.parent=r,s<=t&&e[s].push(r),o=this.roots.indexOf(i)))}o>-1&&this.roots.splice(o,1)}}add(e,t){if(this.nodes.set(e,{nodeIndex:e,distance:t,depth:0,parent:null,children:[]}),null===this.min)this.min=e;else{const n=this.nodes.get(this.min);n&&t<n.distance&&(this.min=e)}this.roots.push(e)}update(e,t){this.remove(e),this.add(e,t)}remove(e){var t,n;if(!this.nodes.has(e))return;const i=null===(t=this.nodes.get(e))||void 0===t?void 0:t.children;if(i&&i.length>0)for(let t=0;t<i.length;t++){const n=i[t],r=this.nodes.get(n),s=this.nodes.get(e);r&&s&&(r.parent=s.parent),r&&null===r.parent&&this.roots.push(n)}let r=null===(n=this.nodes.get(e))||void 0===n?void 0:n.parent;if(null===r){const t=this.roots.indexOf(e);t>-1&&this.roots.splice(t,1)}else for(;r;){const e=this.nodes.get(r);e&&(e.depth--,r=e.parent)}}getDistance(e){const t=this.nodes.get(e);return t?t.distance:1/0}}function Mn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["px.jpg","nx.jpg","py.jpg","ny.jpg","pz.jpg","nz.jpg"];return new Promise((n=>{(new s).setPath(e).load(t,(e=>{e.format=o,n(e)}))}))}function Bn(e){if(!e)return null;const{colors:t,stops:n,size:i=1024}=e,r=document.createElement("canvas"),s=r.getContext("2d");if(!s)return null;r.width=16,r.height=i;const o=s.createLinearGradient(0,0,0,i),c=new a,u=t.map((e=>c.set(e).getStyle()));for(let e=0,t=u.length-1;e<=t;e++)o.addColorStop(n?n[e]:e/t,u[e]);s.fillStyle=o,s.fillRect(0,0,16,i);const h=new l(r);return h.needsUpdate=!0,h}const Rn=e=>{const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)};function Pn(e){return ji(e)?function(e){return e.map((e=>Pn(e)))}(e):zi(e)?function(e){if(zi(e)){const t={};for(const n in e)t[n]=Pn(e[n]);return t}return e}(e):e}const On=(e,t)=>ji(e)?e.map(t):t(e),_n=e=>On(e,(e=>e.clone())),Ln=e=>On(e,(e=>e.dispose()));var kn=function(e,t){return kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},kn(e,t)};var Nn=function(){return Nn=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Nn.apply(this,arguments)};function Un(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function Fn(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}var jn=Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]};function zn(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Hn(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function Gn(e){return this instanceof Gn?(this.v=e,this):new Gn(e)}var Vn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Yn(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Wn(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var Xn=Object.freeze({__proto__:null,get __assign(){return Nn},__asyncDelegator:function(e){var t,n;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(n=!n)?{value:Gn(e[i](t)),done:!1}:r?r(t):t}:r}},__asyncGenerator:function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise((function(n,i){s.push([e,t,n,i])>1||a(e,t)}))})}function a(e,t){try{(n=r[e](t)).value instanceof Gn?Promise.resolve(n.value.v).then(l,c):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=zn(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){(function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)})(i,r,(t=e[n](t)).done,t.value)}))}}},__await:Gn,__awaiter:Fn,__classPrivateFieldGet:Yn,__classPrivateFieldIn:function(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)},__classPrivateFieldSet:Wn,__createBinding:jn,__decorate:function(e,t,n,i){var r,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,n,o):r(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o},__esDecorate:function(e,t,n,i,r,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,l=i.kind,c="getter"===l?"get":"setter"===l?"set":"value",u=!t&&e?i.static?e:e.prototype:null,h=t||(u?Object.getOwnPropertyDescriptor(u,i.name):{}),d=!1,f=n.length-1;f>=0;f--){var p={};for(var g in i)p[g]="access"===g?{}:i[g];for(var g in i.access)p.access[g]=i.access[g];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var m=(0,n[f])("accessor"===l?{get:h.get,set:h.set}:h[c],p);if("accessor"===l){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(a=o(m.get))&&(h.get=a),(a=o(m.set))&&(h.set=a),(a=o(m.init))&&r.push(a)}else(a=o(m))&&("field"===l?r.push(a):h[c]=a)}u&&Object.defineProperty(u,i.name,h),d=!0},__exportStar:function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||jn(t,e,n)},__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}kn(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},__generator:function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&jn(t,e,n);return Vn(t,e),t},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__param:function(e,t){return function(n,i){t(n,i,e)}},__propKey:function(e){return"symbol"==typeof e?e:"".concat(e)},__read:Hn,__rest:Un,__runInitializers:function(e,t,n){for(var i=arguments.length>2,r=0;r<t.length;r++)n=i?t[r].call(e,n):t[r].call(e);return i?n:void 0},__setFunctionName:function(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})},__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Hn(arguments[t]));return e},__spreadArray:function(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r<s;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},__spreadArrays:function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var i=Array(e),r=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i},__values:zn});const Qn=e=>Fn(void 0,void 0,void 0,(function*(){const t=yield fetch(e);if(200===t.status)return t;throw new Error(`Failed to fetch file: ${e}`)})),Kn=e=>{"function"==typeof requestIdleCallback?requestIdleCallback(e):setTimeout(e)};var Zn=function(){function e(){}return e.prototype.toJson=function(e,t){var n=this.xmlStringToXmlDom(e),i=this.xmlToJson(n);return t?(t.removeLineBreaks&&this.removeLineBreaks(i),t.removeComments&&this.removeCommentProperties(i),t.transformTextOnly&&this.transformTextOnly(i),i):i},e.prototype.xmlStringToXmlDom=function(e){return(new DOMParser).parseFromString(e,"text/xml")},e.prototype.removeLineBreaks=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#text"===n&&Array.isArray(e[n])&&delete e[n],"object"==typeof e[n]&&t.removeLineBreaks(e[n])}))},e.prototype.removeCommentProperties=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#comment"===n&&delete e[n],"object"==typeof e[n]&&t.removeCommentProperties(e[n])}))},e.prototype.transformTextOnly=function(e){var t=this;Object.keys(e).forEach((function(n,i){var r=Object.keys(e[n]).length>1,s=Object.keys(e[n])[0];r||"object"==typeof e[n][s]?t.transformTextOnly(e[n]):"object"==typeof e[n]&&e[n]["#text"]&&(e[n]=e[n]["#text"])}))},e.prototype.xmlToJson=function(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t._attributes={};for(var n=0;n<e.attributes.length;n++){var i=e.attributes.item(n);t._attributes[i.nodeName]=i.nodeValue}}}else 3==e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes.item(r),o=s.nodeName;if(void 0===t[o])t[o]=this.xmlToJson(s);else{if(void 0===t[o].push){var a=t[o];t[o]=[],t[o].push(a)}t[o].push(this.xmlToJson(s))}}return t},e}();function qn(e){return Qn(e).then((e=>e.text())).then((e=>Promise.resolve(function(e){return(new Zn).toJson(e,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(e))))}class Jn{constructor(){this.pluginCallbacks=[],this.register((function(e){return new Ii(e)})),this.register((function(e){return new Mi(e)})),this.register((function(e){return new Pi(e)})),this.register((function(e){return new Oi(e)})),this.register((function(e){return new _i(e)})),this.register((function(e){return new Li(e)})),this.register((function(e){return new Bi(e)})),this.register((function(e){return new Ri(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){const r=new Ci,s=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)s.push(this.pluginCallbacks[e](r));r.setPlugins(s),r.write(e,t,i).catch(n)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,i,r,t)}))}}const $n=0,ei=1,ti=2,ni=3,ii=4,ri=5121,si=5123,oi=5126,ai=5125,li=34962,ci=34963,ui=9728,hi=9729,di=9984,fi=9985,pi=9986,gi=9987,mi=33071,vi=33648,yi=10497,wi={};wi[w]=ui,wi[b]=di,wi[x]=pi,wi[A]=hi,wi[T]=fi,wi[S]=gi,wi[E]=mi,wi[D]=yi,wi[C]=vi;const bi={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},xi=new a;function Ai(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}function Ti(e){return 4*Math.ceil(e/4)}function Si(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=Ti(e.byteLength);if(n!==e.byteLength){const i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;r<n;r++)i[r]=t;return i.buffer}return e}function Ei(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function Di(e,t){if(void 0!==e.toBlob)return new Promise((n=>e.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}class Ci{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const o=i.extensionsUsed,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o);if(l.length>0&&(s.extensionsUsed=l),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=a.size),!0===n.binary){const e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){const n=Si(e.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=Si((o=JSON.stringify(s),(new TextEncoder).encode(o).buffer),32);var o;const a=new DataView(new ArrayBuffer(8));a.setUint32(0,r.byteLength,!0),a.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const u=12+a.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,u,!0);const h=new Blob([l,a,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(h),d.onloadend=function(){t(d.result)}}}else if(s.buffers&&s.buffers.length>0){const e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){const n=e.result;s.buffers[0].uri=n,t(s)}}else t(s)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],i[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new t;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);const i=e.clone(),r=new t;for(let e=0,t=i.count;e<t;e++)r.fromBufferAttribute(i,e),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),i.setXYZ(e,r.x,r.y,r.z);return n.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let n=!1;const i={};0===t.offset.x&&0===t.offset.y||(i.offset=t.offset.toArray(),n=!0),0!==t.rotation&&(i.rotation=t.rotation,n=!0),1===t.repeat.x&&1===t.repeat.y||(i.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(e){return e.encoding===I?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");const i=e?e.image:null,r=t?t.image:null,s=Math.max(i?i.width:0,r?r.width:0),o=Math.max(i?i.height:0,r?r.height:0),a=Ei();a.width=s,a.height=o;const l=a.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,s,o);const h=l.getImageData(0,0,s,o);if(i){l.drawImage(i,0,0,s,o);const t=n(e),r=l.getImageData(0,0,s,o).data;for(let e=2;e<r.length;e+=4)h.data[e]=256*t(r[e]/256)}if(r){l.drawImage(r,0,0,s,o);const e=n(t),i=l.getImageData(0,0,s,o).data;for(let t=1;t<i.length;t+=4)h.data[t]=256*e(i[t]/256)}l.putImageData(h,0,0);const d=(e||t).clone();return d.source=new c(a),d.encoding=u,d}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,i,r){const s=this.json;let o;s.bufferViews||(s.bufferViews=[]),o=t===ri?1:t===si?2:4;const a=Ti(i*e.itemSize*o),l=new DataView(new ArrayBuffer(a));let c=0;for(let r=n;r<n+i;r++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?i=e.array[r*e.itemSize+n]:(0===n?i=e.getX(r):1===n?i=e.getY(r):2===n?i=e.getZ(r):3===n&&(i=e.getW(r)),!0===e.normalized&&(i=h.normalize(i,e.array))),t===oi?l.setFloat32(c,i,!0):t===ai?l.setUint32(c,i,!0):t===si?l.setUint16(c,i,!0):t===ri&&l.setUint8(c,i),c+=o}const u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==r&&(u.target=r),r===li&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);return{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){const e=Si(r.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(e,t,n,i){const r=this.json;let s;if(e.array.constructor===Float32Array)s=oi;else if(e.array.constructor===Uint32Array)s=ai;else if(e.array.constructor===Uint16Array)s=si;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");s=ri}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;const o=function(e,t,n){const i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=t;r<t+n;r++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=h.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);let a;void 0!==t&&(a=e===t.index?ci:li);const l=this.processBufferView(e,s,n,i,a),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(null!==e){const r=this,s=r.cache,a=r.json,l=r.options,c=r.pending;s.images.has(e)||s.images.set(e,{});const u=s.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);const d={mimeType:i},f=Ei();f.width=Math.min(e.width,l.maxTextureSize),f.height=Math.min(e.height,l.maxTextureSize);const p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==o&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else p.drawImage(e,0,0,f.width,f.height);!0===l.binary?c.push(Di(f,i).then((e=>r.processBufferViewImage(e))).then((e=>{d.bufferView=e}))):void 0!==f.toDataURL?d.uri=f.toDataURL(i):c.push(Di(f,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{d.uri=e})));const g=a.images.push(d)-1;return u[h]=g,g}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:wi[e.magFilter],minFilter:wi[e.minFilter],wrapS:wi[e.wrapS],wrapT:wi[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||(n.textures=[]);let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");const r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(r.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,r)}));const s=n.textures.push(r)-1;return t.textures.set(e,s),s}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(Ai(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t)};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity),n=Math.max(t.r,t.g,t.b);if(n>1&&(t.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),n>0&&(i.emissiveFactor=t.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===d&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));const s=n.materials.push(i)-1;return t.materials.set(e,s),s}processMesh(e){const t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)i.push(e.material[t].uuid);else i.push(e.material.uuid);const r=i.join(":");if(t.meshes.has(r))return t.meshes.get(r);const s=e.geometry;let o;o=e.isLineSegments?ei:e.isLineLoop?ti:e.isLine?ni:e.isPoints?$n:e.material.wireframe?ei:ii;const a={},l={},c=[],u=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");void 0===d||this.isNormalizedNormalAttribute(d)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let p=null;for(let e in s.attributes){if("morph"===e.slice(0,5))continue;const n=s.attributes[e];e=h[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(n))){l[e]=t.attributes.get(this.getUID(n));continue}p=null;const i=n.array;"JOINTS_0"!==e||i instanceof Uint16Array||i instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new f(new Uint16Array(i),n.itemSize,n.normalized));const r=this.processAccessor(p||n,s);null!==r&&(l[e]=r,t.attributes.set(this.getUID(n),r))}if(void 0!==d&&s.setAttribute("normal",d),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const n=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){const a={};let l=!1;for(const e in s.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}const n=s.morphAttributes[e][o],i=e.toUpperCase(),r=s.attributes[e];if(t.attributes.has(this.getUID(n,!0))){a[i]=t.attributes.get(this.getUID(n,!0));continue}const c=n.clone();if(!s.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)0===t&&c.setX(e,n.getX(e)-r.getX(e)),1===t&&c.setY(e,n.getY(e)-r.getY(e)),2===t&&c.setZ(e,n.getZ(e)-r.getZ(e)),3===t&&c.setW(e,n.getW(e)-r.getW(e));a[i]=this.processAccessor(c,s),t.attributes.set(this.getUID(r,!0),a[i])}u.push(a),n.push(e.morphTargetInfluences[o]),void 0!==e.morphTargetDictionary&&i.push(r[o])}a.weights=n,i.length>0&&(a.extras={},a.extras.targetNames=i)}const g=Array.isArray(e.material);if(g&&0===s.groups.length)return null;const m=g?e.material:[e.material],v=g?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=v.length;e<n;e++){const n={mode:o,attributes:l};if(this.serializeUserData(s,n),u.length>0&&(n.targets=u),null!==s.index){let i=this.getUID(s.index);void 0===v[e].start&&void 0===v[e].count||(i+=":"+v[e].start+":"+v[e].count),t.attributes.has(i)?n.indices=t.attributes.get(i):(n.indices=this.processAccessor(s.index,s,v[e].start,v[e].count),t.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=this.processMaterial(m[v[e].materialIndex]);null!==i&&(n.material=i),c.push(n)}a.primitives=c,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,a)}));const y=n.meshes.push(a)-1;return t.meshes.set(r,y),y}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:h.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(e=Jn.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,s=[],o=[];for(let e=0;e<r.length;++e){const n=r[e],a=p.parseTrackName(n.name);let l=p.findNode(t,a.nodeName);const c=bi[a.propertyName];if("bones"===a.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(a.objectIndex):void 0),!l||!c)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',n.name),null;const u=1;let h,d=n.values.length/n.times.length;c===bi.morphTargetInfluences&&(d/=l.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(h="CUBICSPLINE",d/=3):h=n.getInterpolation()===g?"STEP":"LINEAR",o.push({input:this.processAccessor(new f(n.times,u)),output:this.processAccessor(new f(n.values,d)),interpolation:h}),s.push({sampler:o.length-1,target:{node:i.get(l),path:c}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:s}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,i=t.nodes[n.get(e)],r=e.skeleton;if(void 0===r)return null;const s=e.skeleton.bones[0];if(void 0===s)return null;const o=[],a=new Float32Array(16*r.bones.length),l=new m;for(let t=0;t<r.bones.length;++t)o.push(n.get(r.bones[t])),l.copy(r.boneInverses[t]),l.multiply(e.bindMatrix).toArray(a,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new f(a,16)),joints:o,skeleton:n.get(s)});return i.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const t=e.quaternion.toArray(),n=e.position.toArray(),i=e.scale.toArray();Ai(t,[0,0,0,1])||(r.rotation=t),Ai(n,[0,0,0])||(r.translation=n),Ai(i,[1,1,1])||(r.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Ai(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(r.matrix=e.matrix.elements);if(""!==e.name&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const t=this.processMesh(e);null!==t&&(r.mesh=t)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let i=0,r=e.children.length;i<r;i++){const r=e.children[i];if(r.visible||!1===n.onlyVisible){const e=this.processNode(r);null!==e&&t.push(e)}}t.length>0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));const s=t.nodes.push(r)-1;return i.set(e,s),s}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);const r=[];for(let t=0,i=e.children.length;t<i;t++){const i=e.children[t];if(i.visible||!1===n.onlyVisible){const e=this.processNode(i);null!==e&&r.push(e)}}r.length>0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){const t=new v;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const n=[];for(let t=0;t<e.length;t++)e[t]instanceof v?this.processScene(e[t]):n.push(e[t]);n.length>0&&this.processObjects(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class Ii{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const n=this.writer,i=n.json,r=n.extensionsUsed,s={};e.name&&(s.name=e.name),s.color=e.color.toArray(),s.intensity=e.intensity,e.isDirectionalLight?s.type="directional":e.isPointLight?(s.type="point",e.distance>0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const o=i.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}let Mi=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},Bi=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:n.processTexture(e.clearcoatMap)};n.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:n.processTexture(e.clearcoatRoughnessMap)};n.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:n.processTexture(e.clearcoatNormalMap)};n.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Ri=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:n.processTexture(e.iridescenceMap)};n.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:n.processTexture(e.iridescenceThicknessMap)};n.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Pi=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const t={index:n.processTexture(e.transmissionMap)};n.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Oi=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const t={index:n.processTexture(e.thicknessMap)};n.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},_i=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}},Li=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(xi)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,i=n.extensionsUsed,r={};if(e.specularIntensityMap){const t={index:n.processTexture(e.specularIntensityMap)};n.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){const t={index:n.processTexture(e.specularColorMap)};n.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}};Jn.Utils={insertKeyframe:function(e,t){const n=.001,i=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),s=new e.ValueBufferType(e.values.length+i),o=e.createInterpolant(new e.ValueBufferType(i));let a;if(0===e.times.length){r[0]=t;for(let e=0;e<i;e++)s[e]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;r[0]=t,r.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,i),a=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),a=r.length-1}else for(let l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<n)return l;if(e.times[l]<t&&e.times[l+1]>t){r.set(e.times.slice(0,l+1),0),r[l+1]=t,r.set(e.times.slice(l+1),l+2),s.set(e.values.slice(0,(l+1)*i),0),s.set(o.evaluate(t),(l+1)*i),s.set(e.values.slice((l+1)*i),(l+2)*i),a=l+1;break}}return e.times=r,e.values=s,a},mergeMorphTargetTracks:function(e,t){const n=[],i={},r=e.tracks;for(let e=0;e<r.length;++e){let s=r[e];const o=p.parseTrackName(s.name),a=p.findNode(t,o.nodeName);if("morphTargetInfluences"!==o.propertyName||void 0===o.propertyIndex){n.push(s);continue}if(s.createInterpolant!==s.InterpolantFactoryMethodDiscrete&&s.createInterpolant!==s.InterpolantFactoryMethodLinear){if(s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),s=s.clone(),s.setInterpolation(y)}const l=a.morphTargetInfluences.length,c=a.morphTargetDictionary[o.propertyIndex];if(void 0===c)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(void 0===i[a.uuid]){u=s.clone();const e=new u.ValueBufferType(l*u.times.length);for(let t=0;t<u.times.length;t++)e[t*l+c]=u.values[t];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=e,i[a.uuid]=u,n.push(u);continue}const h=s.createInterpolant(new s.ValueBufferType(1));u=i[a.uuid];for(let e=0;e<u.times.length;e++)u.values[e*l+c]=h.evaluate(u.times[e]);for(let e=0;e<s.times.length;e++){const t=this.insertKeyframe(u,s.times[e]);u.values[t*l+c]=s.values[e]}}return e.tracks=n,e}};const ki=Object.prototype.hasOwnProperty,Ni=e=>"String"===Gi(e),Ui=e=>"Boolean"===Gi(e),Fi=e=>"Number"===Gi(e),ji=Array.isArray,zi=e=>"Object"===Gi(e),Hi=e=>"Function"===Gi(e),Gi=e=>Object.prototype.toString.call(e).slice(8,-1),Vi=(e,t,n)=>String.fromCodePoint(...new Uint8Array(e,t,n)),Yi=()=>gn+Math.random().toString(36).substring(7).split("").join("_"),Wi=e=>{var t;const{pathname:n}=new URL(e,location.origin);return null===(t=n.split(".").pop())||void 0===t?void 0:t.toLowerCase()};var Xi=Object.freeze({__proto__:null,IVector3ToEuler:bn,IVector3ToVector3:wn,MinHeap:In,cloneDeep:Pn,cloneMaterials:_n,deg2Euler:Sn,disposeMaterials:Ln,error:e=>{console.error(mn+e)},euler2Deg:function(e){return e/(Math.PI/180)},exportGltf:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((n,i)=>{(new Jn).parse(e,(e=>n(e)),(e=>i(e)),t)}))},fetchFile:Qn,getAsciiString:Vi,getBoundingBox:xn,getCubeTexture:Mn,getExtension:Wi,getSpaceAttributeFromObject:En,getValueType:Gi,gradientTexture:Bn,hasOwn:(e,t)=>ki.call(e,t),idleTask:Kn,isArray:ji,isBoolean:Ui,isDate:e=>"Date"===Gi(e),isFunction:Hi,isNull:e=>"Null"===Gi(e),isNumber:Fi,isObject:zi,isObjectVisible:Cn,isPromise:e=>"Promise"===Gi(e),isString:Ni,isSymbol:e=>"Symbol"===Gi(e),isUndefined:e=>"Undefined"===Gi(e),log:vn,materialHandle:On,parseFilePath:Rn,randomString:Yi,rotationAFix:Tn,rotationAxisFix:An,sleep:e=>new Promise((t=>setTimeout((()=>t()),e))),syncSpaceAttributeToObject:Dn,warn:yn,xmlToJson:qn});const Qi={"Linear.None":$t.Linear.None,"Quadratic.In":$t.Quadratic.In,"Quadratic.Out":$t.Quadratic.Out,"Quadratic.InOut":$t.Quadratic.InOut,"Cubic.In":$t.Cubic.In,"Cubic.Out":$t.Cubic.Out,"Cubic.InOut":$t.Cubic.InOut,"Quartic.In":$t.Quartic.In,"Quartic.Out":$t.Quartic.Out,"Quartic.InOut":$t.Quartic.InOut,"Quintic.In":$t.Quintic.In,"Quintic.Out":$t.Quintic.Out,"Quintic.InOut":$t.Quintic.InOut,"Sinusoidal.In":$t.Sinusoidal.In,"Sinusoidal.Out":$t.Sinusoidal.Out,"Sinusoidal.InOut":$t.Sinusoidal.InOut,"Exponential.In":$t.Exponential.In,"Exponential.Out":$t.Exponential.Out,"Exponential.InOut":$t.Exponential.InOut,"Circular.In":$t.Circular.In,"Circular.Out":$t.Circular.Out,"Circular.InOut":$t.Circular.InOut,"Elastic.In":$t.Elastic.In,"Elastic.Out":$t.Elastic.Out,"Elastic.InOut":$t.Elastic.InOut,"Back.In":$t.Back.In,"Back.Out":$t.Back.Out,"Back.InOut":$t.Back.InOut,"Bounce.In":$t.Bounce.In,"Bounce.Out":$t.Bounce.Out,"Bounce.InOut":$t.Bounce.InOut};function Ki(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;return new Promise(((o,a)=>{const{duration:l=1e3,delay:c=0,repeat:u=!1,mode:h="Linear.None",yoyo:d=!1}=i,f=Qi[h],p=new on(e).to(t,l).easing(f).delay(c).onUpdate((i=>{e instanceof n&&t instanceof n&&i instanceof n&&(i.order=t.order),null==r||r(i,p)})).onComplete((()=>{o()})).onStop((()=>{a("animation stop")})).onStart((()=>{null==s||s(p)}));Fi(u)?p.repeat(u):Ui(u)&&u&&p.repeat(1/0),p.yoyo(d),p.start()}))}class Zi{constructor(e,t,n){this.target=e,this.points=t,this.speed=1,this.isPaused=!1,this.index=0,this._tween=null,n&&Object.assign(this,n)}get isPlaying(){var e;return!!(null===(e=this._tween)||void 0===e?void 0:e.isPlaying())}play(){return!this.isPlaying&&(this.isPaused=!1,this._play())}_play(){var e,n;return Fn(this,void 0,void 0,(function*(){if(this.isPaused)return!1;const{points:i,target:r}=this,s=null!==(e=this.speed)&&void 0!==e?e:1,o=this.index;let a=i[o];if(!a)return!0;a.isVector3||(a=new t(a.x,a.y,a.z));const l=r.position.distanceTo(a)/s;yield Ki(r.position,a,{duration:l},this.onUpdate,(e=>{var t;0!==o||this._tween||null===(t=this.onStart)||void 0===t||t.call(this,e),this._tween=e})),null===(n=this.onPoint)||void 0===n||n.call(this,o,a),this.index++,this._tween=null,this._play()}))}pause(){var e;this.isPaused=!0,null===(e=this._tween)||void 0===e||e.stop()}}const qi=0,Ji=1,$i=2,er=2,tr=1.25,nr=1,ir=32,rr=65535,sr=Math.pow(2,-24);class or{constructor(){}}function ar(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function lr(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){const r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function cr(e,t){t.set(e)}function ur(e,t,n){let i,r;for(let s=0;s<3;s++){const o=s+3;i=e[s],r=t[s],n[s]=i<r?i:r,i=e[o],r=t[o],n[o]=i>r?i:r}}function hr(e,t,n){for(let i=0;i<3;i++){const r=t[e+2*i],s=t[e+2*i+1],o=r-s,a=r+s;o<n[i]&&(n[i]=o),a>n[i+3]&&(n[i+3]=a)}}function dr(e){const t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function fr(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,g=-1/0,m=-1/0;const v=null!==r;for(let i=6*t,r=6*(t+n);i<r;i+=6){const t=e[i+0],n=e[i+1],r=t-n,y=t+n;r<s&&(s=r),y>l&&(l=y),v&&t<h&&(h=t),v&&t>p&&(p=t);const w=e[i+2],b=e[i+3],x=w-b,A=w+b;x<o&&(o=x),A>c&&(c=A),v&&w<d&&(d=w),v&&w>g&&(g=w);const T=e[i+4],S=e[i+5],E=T-S,D=T+S;E<a&&(a=E),D>u&&(u=D),v&&T<f&&(f=T),v&&T>m&&(m=T)}i[0]=s,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=u,v&&(r[0]=h,r[1]=d,r[2]=f,r[3]=p,r[4]=g,r[5]=m)}const pr=32,gr=(e,t)=>e.candidate-t.candidate,mr=new Array(pr).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),vr=new Float32Array(6);function yr(e,t){function n(e){d&&d(e/p)}function i(t,r,d){let f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!g&&p>=l&&(g=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=u||p>=l)return n(r+d),t.offset=r,t.count=d,t;const m=function(e,t,n,i,r,s){let o=-1,a=0;if(s===qi)o=lr(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(s===Ji)o=lr(e),-1!==o&&(a=function(e,t,n,i){let r=0;for(let s=t,o=t+n;s<o;s++)r+=e[6*s+2*i];return r/n}(n,i,r,o));else if(s===$i){const s=dr(e);let l=tr*r;const c=6*i,u=6*(i+r);for(let e=0;e<3;e++){const i=t[e],h=(t[e+3]-i)/pr;if(r<pr/4){const t=[...mr];t.length=r;let i=0;for(let r=c;r<u;r+=6,i++){const s=t[i];s.candidate=n[r+2*e],s.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:l}=s;for(let e=0;e<3;e++)l[e]=1/0,l[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;hr(r,n,o)}t.sort(gr);let h=r;for(let e=0;e<h;e++){const n=t[e];for(;e+1<h&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),h--}for(let i=c;i<u;i+=6){const r=n[i+2*e];for(let e=0;e<h;e++){const s=t[e];r>=s.candidate?hr(i,n,s.rightCacheBounds):(hr(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n<h;n++){const i=t[n],c=i.count,u=r-i.count,h=i.leftCacheBounds,d=i.rightCacheBounds;let f=0;0!==c&&(f=dr(h)/s);let p=0;0!==u&&(p=dr(d)/s);const g=nr+tr*(f*c+p*u);g<l&&(o=e,l=g,a=i.candidate)}}else{for(let e=0;e<pr;e++){const t=mr[e];t.count=0,t.candidate=i+h+e*h;const n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let t=c;t<u;t+=6){let r=~~((n[t+2*e]-i)/h);r>=pr&&(r=pr-1);const s=mr[r];s.count++,hr(t,n,s.bounds)}const t=mr[pr-1];cr(t.bounds,t.rightCacheBounds);for(let e=pr-2;e>=0;e--){const t=mr[e],n=mr[e+1];ur(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let t=0;t<pr-1;t++){const n=mr[t],i=n.count,c=n.bounds,u=mr[t+1].rightCacheBounds;0!==i&&(0===d?cr(c,vr):ur(c,vr,vr)),d+=i;let h=0,f=0;0!==d&&(h=dr(vr)/s);const p=r-d;0!==p&&(f=dr(u)/s);const g=nr+tr*(h*d+f*p);g<l&&(o=e,l=g,a=n.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}(t.boundingData,f,o,r,d,h);if(-1===m.axis)return n(r+d),t.offset=r,t.count=d,t;const v=function(e,t,n,i,r){let s=n,o=n+i-1;const a=r.pos,l=2*r.axis;for(;;){for(;s<=o&&t[6*s+l]<a;)s++;for(;s<=o&&t[6*o+l]>=a;)o--;if(!(s<o))return s;for(let n=0;n<3;n++){let i=e[3*s+n];e[3*s+n]=e[3*o+n],e[3*o+n]=i;let r=t[6*s+2*n+0];t[6*s+2*n+0]=t[6*o+2*n+0],t[6*o+2*n+0]=r;let a=t[6*s+2*n+1];t[6*s+2*n+1]=t[6*o+2*n+1],t[6*o+2*n+1]=a}s++,o--}}(a,o,r,d,m);if(v===r||v===r+d)n(r+d),t.offset=r,t.count=d;else{t.splitAxis=m.axis;const e=new or,n=r,a=v-r;t.left=e,e.boundingData=new Float32Array(6),fr(o,n,a,e.boundingData,s),i(e,n,a,s,p+1);const l=new or,c=v,u=d-a;t.right=l,l.boundingData=new Float32Array(6),fr(o,c,u,l.boundingData,s),i(l,c,u,s,p+1)}return t}!function(e,t){if(!e.index){const n=e.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;let r;r=n>65535?new Uint32Array(new i(4*n)):new Uint16Array(new i(2*n)),e.setIndex(new f(r,1));for(let e=0;e<n;e++)r[e]=e}}(e,t);const r=new Float32Array(6),s=new Float32Array(6),o=function(e,t){const n=e.attributes.position,i=e.index.array,r=i.length/3,s=new Float32Array(6*r),o=n.normalized,a=n.array,l=n.offset||0;let c=3;n.isInterleavedBufferAttribute&&(c=n.data.stride);const u=["getX","getY","getZ"];for(let e=0;e<r;e++){const r=3*e,h=6*e;let d,f,p;o?(d=i[r+0],f=i[r+1],p=i[r+2]):(d=i[r+0]*c+l,f=i[r+1]*c+l,p=i[r+2]*c+l);for(let e=0;e<3;e++){let i,r,l;o?(i=n[u[e]](d),r=n[u[e]](f),l=n[u[e]](p)):(i=a[d+e],r=a[f+e],l=a[p+e]);let c=i;r<c&&(c=r),l<c&&(c=l);let g=i;r>g&&(g=r),l>g&&(g=l);const m=(g-c)/2,v=2*e;s[h+v+0]=c+m,s[h+v+1]=m+(Math.abs(c)+m)*sr,c<t[e]&&(t[e]=c),g>t[e+3]&&(t[e+3]=g)}}return s}(e,r),a=e.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,p=e.index.count/3;let g=!1;const m=[],v=function(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];const t=[],n=new Set;for(const t of e.groups)n.add(t.start),n.add(t.start+t.count);const i=Array.from(n.values()).sort(((e,t)=>e-t));for(let e=0;e<i.length-1;e++){const n=i[e],r=i[e+1];t.push({offset:n/3,count:(r-n)/3})}return t}(e);if(1===v.length){const e=v[0],t=new or;t.boundingData=r,function(e,t,n,i){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let i=6*t,u=6*(t+n);i<u;i+=6){const t=e[i+0];t<r&&(r=t),t>a&&(a=t);const n=e[i+2];n<s&&(s=n),n>l&&(l=n);const u=e[i+4];u<o&&(o=u),u>c&&(c=u)}i[0]=r,i[1]=s,i[2]=o,i[3]=a,i[4]=l,i[5]=c}(o,e.offset,e.count,s),i(t,e.offset,e.count,s),m.push(t)}else for(let e of v){const t=new or;t.boundingData=new Float32Array(6),fr(o,e.offset,e.count,t.boundingData,s),i(t,e.offset,e.count,s),m.push(t)}return m}class wr{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,s=e.length;r<s;r++){const s=e[r][t];n=s<n?s:n,i=s>i?s:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=e.dot(s);n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}wr.prototype.setFromBox=function(){const e=new t;return function(t,n){const i=n.min,r=n.max;let s=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let a=0;a<=1;a++)for(let l=0;l<=1;l++){e.x=i.x*n+r.x*(1-n),e.y=i.y*a+r.y*(1-a),e.z=i.z*l+r.z*(1-l);const c=t.dot(e);s=Math.min(c,s),o=Math.max(c,o)}this.min=s,this.max=o}}(),function(){const e=new wr}();const br=function(){const e=new t,n=new t,i=new t;return function(t,r,s){const o=t.start,a=e,l=r.start,c=n;i.subVectors(o,l),e.subVectors(t.end,t.start),n.subVectors(r.end,r.start);const u=i.dot(c),h=c.dot(a),d=c.dot(c),f=i.dot(a),p=a.dot(a)*d-h*h;let g,m;g=0!==p?(u*h-f*d)/p:0,m=(u+g*h)/d,s.x=g,s.y=m}}(),xr=function(){const e=new M,n=new t,i=new t;return function(t,r,s,o){br(t,r,e);let a=e.x,l=e.y;if(a>=0&&a<=1&&l>=0&&l<=1)return t.at(a,s),void r.at(l,o);if(a>=0&&a<=1)return l<0?r.at(0,o):r.at(1,o),void t.closestPointToPoint(o,!0,s);if(l>=0&&l<=1)return a<0?t.at(0,s):t.at(1,s),void r.closestPointToPoint(s,!0,o);{let e,c;e=a<0?t.start:t.end,c=l<0?r.start:r.end;const u=n,h=i;return t.closestPointToPoint(c,!0,n),r.closestPointToPoint(e,!0,i),u.distanceToSquared(c)<=h.distanceToSquared(e)?(s.copy(u),void o.copy(c)):(s.copy(e),void o.copy(h))}}}(),Ar=function(){const e=new t,n=new t,i=new B,r=new R;return function(t,s){const{radius:o,center:a}=t,{a:l,b:c,c:u}=s;r.start=l,r.end=c;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=l,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=c,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const h=s.getPlane(i);if(Math.abs(h.distanceToPoint(a))<=o){const e=h.projectPoint(a,n);if(s.containsPoint(e))return!0}return!1}}(),Tr=1e-15;function Sr(e){return Math.abs(e)<Tr}class Er extends P{constructor(){super(...arguments),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new t)),this.satBounds=new Array(4).fill().map((()=>new wr)),this.points=[this.a,this.b,this.c],this.sphere=new O,this.plane=new B,this.needsUpdate=!0}intersectsSphere(e){return Ar(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,o=r[0],a=s[0];this.getNormal(o),a.setFromPoints(o,i);const l=r[1],c=s[1];l.subVectors(e,t),c.setFromPoints(l,i);const u=r[2],h=s[2];u.subVectors(t,n),h.setFromPoints(u,i);const d=r[3],f=s[3];d.subVectors(n,e),f.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Er.prototype.closestPointToSegment=function(){const e=new t,n=new t,i=new R;return function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const{start:o,end:a}=t,l=this.points;let c,u=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(l[o]),i.end.copy(l[a]),xr(i,t,e,n),c=e.distanceToSquared(n),c<u&&(u=c,r&&r.copy(e),s&&s.copy(n))}return this.closestPointToPoint(o,e),c=o.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(o)),this.closestPointToPoint(a,e),c=a.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(a)),Math.sqrt(u)}}(),Er.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new Array(3),r=new wr,s=new wr,o=new t,a=new t,l=new t,c=new t,u=new R,h=new R,d=new R;return function(t){let f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,p=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const g=this.plane,m=t.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){const e=this.satBounds,a=this.satAxes;i[0]=t.a,i[1]=t.b,i[2]=t.c;for(let t=0;t<4;t++){const n=e[t],s=a[t];if(r.setFromPoints(s,i),n.isSeparated(r))return!1}const l=t.satBounds,c=t.satAxes;n[0]=this.a,n[1]=this.b,n[2]=this.c;for(let e=0;e<4;e++){const t=l[e],i=c[e];if(r.setFromPoints(i,n),t.isSeparated(r))return!1}for(let e=0;e<4;e++){const t=a[e];for(let e=0;e<4;e++){const a=c[e];if(o.crossVectors(t,a),r.setFromPoints(o,n),s.setFromPoints(o,i),r.isSeparated(s))return!1}}return f&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),f.start.set(0,0,0),f.end.set(0,0,0)),!0}{const e=this.points;let n=!1,i=0;for(let t=0;t<3;t++){const r=e[t],s=e[(t+1)%3];u.start.copy(r),u.end.copy(s),u.delta(a);const o=n?h.start:h.end,l=Sr(m.distanceToPoint(r));if(Sr(m.normal.dot(a))&&l){h.copy(u),i=2;break}if((m.intersectLine(u,o)||l)&&!Sr(o.distanceTo(s))){if(i++,n)break;n=!0}}if(1===i&&t.containsPoint(h.end))return f&&(f.start.copy(h.end),f.end.copy(h.end)),!0;if(2!==i)return!1;const r=t.points;let s=!1,o=0;for(let e=0;e<3;e++){const t=r[e],n=r[(e+1)%3];u.start.copy(t),u.end.copy(n),u.delta(l);const i=s?d.start:d.end,a=Sr(g.distanceToPoint(t));if(Sr(g.normal.dot(l))&&a){d.copy(u),o=2;break}if((g.intersectLine(u,i)||a)&&!Sr(i.distanceTo(n))){if(o++,s)break;s=!0}}if(1===o&&this.containsPoint(d.end))return f&&(f.start.copy(d.end),f.end.copy(d.end)),!0;if(2!==o)return!1;if(h.delta(a),d.delta(l),a.dot(l)<0){let e=d.start;d.start=d.end,d.end=e}const p=h.start.dot(a),v=h.end.dot(a),y=d.start.dot(a),w=d.end.dot(a);return(p===w||y===v||v<y!==p<w)&&(f&&(c.subVectors(h.start,d.start),c.dot(a)>0?f.start.copy(h.start):f.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?f.end.copy(h.end):f.end.copy(d.end)),!0)}}}(),Er.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Er.prototype.distanceToTriangle=function(){const e=new t,n=new t,i=["a","b","c"],r=new R,s=new R;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const l=o||a?r:null;if(this.intersectsTriangle(t,l))return(o||a)&&(o&&l.getCenter(o),a&&l.getCenter(a)),0;let c=1/0;for(let n=0;n<3;n++){let r;const s=i[n],l=t[s];this.closestPointToPoint(l,e),r=l.distanceToSquared(e),r<c&&(c=r,o&&o.copy(e),a&&a.copy(l));const u=this[s];t.closestPointToPoint(u,e),r=u.distanceToSquared(e),r<c&&(c=r,o&&o.copy(u),a&&a.copy(e))}for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];r.set(this[u],this[h]);for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];s.set(t[u],t[h]),xr(r,s,e,n);const d=e.distanceToSquared(n);d<c&&(c=d,o&&o.copy(e),a&&a.copy(n))}}return Math.sqrt(c)}}();class Dr{constructor(e,n,i){this.isOrientedBox=!0,this.min=new t,this.max=new t,this.matrix=new m,this.invMatrix=new m,this.points=new Array(8).fill().map((()=>new t)),this.satAxes=new Array(3).fill().map((()=>new t)),this.satBounds=new Array(3).fill().map((()=>new wr)),this.alignedSatBounds=new Array(3).fill().map((()=>new wr)),this.needsUpdate=!1,e&&this.min.copy(e),n&&this.max.copy(n),i&&this.matrix.copy(i)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Dr.prototype.update=function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let o=0;o<=1;o++){const a=i[1*r|2*s|4*o];a.x=r?n.x:t.x,a.y=s?n.y:t.y,a.z=o?n.z:t.z,a.applyMatrix4(e)}const r=this.satBounds,s=this.satAxes,o=i[0];for(let e=0;e<3;e++){const t=s[e],n=r[e],a=i[1<<e];t.subVectors(o,a),n.setFromPoints(t,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},Dr.prototype.intersectsBox=function(){const e=new wr;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,r=this.satBounds,s=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=i.x,o[0].isSeparated(e))return!1;if(e.min=n.y,e.max=i.y,o[1].isSeparated(e))return!1;if(e.min=n.z,e.max=i.z,o[2].isSeparated(e))return!1;for(let n=0;n<3;n++){const i=s[n],o=r[n];if(e.setFromBox(i,t),o.isSeparated(e))return!1}return!0}}(),Dr.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new wr,r=new wr,s=new t;return function(t){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const o=this.satBounds,a=this.satAxes;n[0]=t.a,n[1]=t.b,n[2]=t.c;for(let e=0;e<3;e++){const t=o[e],r=a[e];if(i.setFromPoints(r,n),t.isSeparated(i))return!1}const l=t.satBounds,c=t.satAxes,u=this.points;for(let e=0;e<3;e++){const t=l[e],n=c[e];if(i.setFromPoints(n,u),t.isSeparated(i))return!1}for(let e=0;e<3;e++){const t=a[e];for(let e=0;e<4;e++){const o=c[e];if(s.crossVectors(t,o),i.setFromPoints(s,n),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}(),Dr.prototype.closestPointToPoint=function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},Dr.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Dr.prototype.distanceToBox=function(){const e=["x","y","z"],n=new Array(12).fill().map((()=>new R)),i=new Array(12).fill().map((()=>new R)),r=new t,s=new t;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.needsUpdate&&this.update(),this.intersectsBox(t))return(a||l)&&(t.getCenter(s),this.closestPointToPoint(s,r),t.closestPointToPoint(r,s),a&&a.copy(r),l&&l.copy(s)),0;const c=o*o,u=t.min,h=t.max,d=this.points;let f=1/0;for(let e=0;e<8;e++){const t=d[e];s.copy(t).clamp(u,h);const n=t.distanceToSquared(s);if(n<f&&(f=n,a&&a.copy(t),l&&l.copy(s),n<c))return Math.sqrt(n)}let p=0;for(let t=0;t<3;t++)for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){const o=(t+1)%3,a=(t+2)%3,l=1<<t|r<<o|s<<a,c=d[r<<o|s<<a],f=d[l];n[p].set(c,f);const g=e[t],m=e[o],v=e[a],y=i[p],w=y.start,b=y.end;w[g]=u[g],w[m]=r?u[m]:h[m],w[v]=s?u[v]:h[m],b[g]=h[g],b[m]=r?u[m]:h[m],b[v]=s?u[v]:h[m],p++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){s.x=e?h.x:u.x,s.y=t?h.y:u.y,s.z=n?h.z:u.z,this.closestPointToPoint(s,r);const i=s.distanceToSquared(r);if(i<f&&(f=i,a&&a.copy(r),l&&l.copy(s),i<c))return Math.sqrt(i)}for(let e=0;e<12;e++){const t=n[e];for(let e=0;e<12;e++){const n=i[e];xr(t,n,r,s);const o=r.distanceToSquared(s);if(o<f&&(f=o,a&&a.copy(r),l&&l.copy(s),o<c))return Math.sqrt(o)}}return Math.sqrt(f)}}();const Cr=new t,Ir=new t,Mr=new t,Br=new M,Rr=new M,Pr=new M,Or=new t;function _r(e,n,i,r,s,o,a){Cr.fromBufferAttribute(n,r),Ir.fromBufferAttribute(n,s),Mr.fromBufferAttribute(n,o);const l=function(e,t,n,i,r,s){let o;return o=s===_?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,s!==d,r),null===o?null:{distance:e.origin.distanceTo(r),point:r.clone()}}(e,Cr,Ir,Mr,Or,a);if(l){i&&(Br.fromBufferAttribute(i,r),Rr.fromBufferAttribute(i,s),Pr.fromBufferAttribute(i,o),l.uv=P.getUV(Or,Cr,Ir,Mr,Br,Rr,Pr,new M));const e={a:r,b:s,c:o,normal:new t,materialIndex:0};P.getNormal(Cr,Ir,Mr,e.normal),l.face=e,l.faceIndex=r}return l}function Lr(e,t,n,i,r){const s=3*i,o=e.index.getX(s),a=e.index.getX(s+1),l=e.index.getX(s+2),c=_r(n,e.attributes.position,e.attributes.uv,o,a,l,t);return c?(c.faceIndex=i,r&&r.push(c),c):null}function kr(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e.distance<n.near||e.distance>n.far?null:e)}function Nr(e,t,n,i){const r=e.a,s=e.b,o=e.c;let a=t,l=t+1,c=t+2;n&&(a=n.getX(t),l=n.getX(t+1),c=n.getX(t+2)),r.x=i.getX(a),r.y=i.getY(a),r.z=i.getZ(a),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function Ur(e,t,n,i,r,s,o){const a=n.index,l=n.attributes.position;for(let n=e,c=t+e;n<c;n++)if(Nr(o,3*n,a,l),o.needsUpdate=!0,i(o,n,r,s))return!0;return!1}class Fr{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}function jr(e,t){return 65535===t[e+15]}function zr(e,t){return t[e+6]}function Hr(e,t){return t[e+14]}function Gr(e){return e+8}function Vr(e,t){return t[e+6]}const Yr=new i,Wr=new t,Xr=["x","y","z"];function Qr(e,t,n,i,r){let s=2*e,o=ts,a=ns,l=is;if(jr(s,a)){!function(e,t,n,i,r,s){for(let o=i,a=i+r;o<a;o++)Lr(e,t,n,o,s)}(t,n,i,zr(e,l),Hr(s,a),r)}else{const s=Gr(e);Jr(s,o,i,Wr)&&Qr(s,t,n,i,r);const a=Vr(e,l);Jr(a,o,i,Wr)&&Qr(a,t,n,i,r)}}function Kr(e,t,n,i){let r=2*e,s=ts,o=ns,a=is;if(jr(r,o)){return function(e,t,n,i,r){let s=1/0,o=null;for(let a=i,l=i+r;a<l;a++){const i=Lr(e,t,n,a);i&&i.distance<s&&(o=i,s=i.distance)}return o}(t,n,i,zr(e,a),Hr(r,o))}{const r=function(e,t){return t[e+7]}(e,a),o=Xr[r],l=i.direction[o]>=0;let c,u;l?(c=Gr(e),u=Vr(e,a)):(c=Vr(e,a),u=Gr(e));const h=Jr(c,s,i,Wr)?Kr(c,t,n,i):null;if(h){const e=h.point[o];if(l?e<=s[u+r]:e>=s[u+r+3])return h}const d=Jr(u,s,i,Wr)?Kr(u,t,n,i):null;return h&&d?h.distance<=d.distance?h:d:h||d||null}}const Zr=function(){let e,t;const n=[],r=new Fr((()=>new i));return function(){e=r.getPrimitive(),t=r.getPrimitive(),n.push(e,t);const i=s(...arguments);r.releasePrimitive(e),r.releasePrimitive(t),n.pop(),n.pop();const o=n.length;return o>0&&(t=n[o-1],e=n[o-2]),i};function s(n,i,r,o){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;function u(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Gr(e));return zr(e,i)}function h(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Vr(e,i));return zr(e,i)+Hr(t,n)}let d=2*n,f=ts,p=ns,g=is;if(jr(d,p)){const t=zr(n,g),i=Hr(d,p);return ar(n,f,e),o(t,i,!1,c,l+n,e)}{const d=Gr(n),m=Vr(n,g);let v,y,w,b,x=d,A=m;if(a&&(w=e,b=t,ar(x,f,w),ar(A,f,b),v=a(w),y=a(b),y<v)){x=m,A=d;const e=v;v=y,y=e,w=b}w||(w=e,ar(x,f,w));const T=r(w,jr(2*x,p),v,c+1,l+x);let S;if(T===er){const e=u(x);S=o(e,h(x)-e,!0,c+1,l+x,w)}else S=T&&s(x,i,r,o,a,l,c+1);if(S)return!0;b=t,ar(A,f,b);const E=r(b,jr(2*A,p),y,c+1,l+A);let D;if(E===er){const e=u(A);D=o(e,h(A)-e,!0,c+1,l+A,b)}else D=E&&s(A,i,r,o,a,l,c+1);return!!D}}}(),qr=function(){const e=new Er,t=new Er,n=new m,i=new Dr,r=new Dr;return function s(o,a,l,c){let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,h=2*o,d=ts,f=ns,p=is;null===u&&(l.boundingBox||l.computeBoundingBox(),i.set(l.boundingBox.min,l.boundingBox.max,c),u=i);if(!jr(h,f)){const e=o+8,t=p[o+6];ar(e,d,Yr);if(u.intersectsBox(Yr)&&s(e,a,l,c,u))return!0;ar(t,d,Yr);return!!(u.intersectsBox(Yr)&&s(t,a,l,c,u))}{const i=a,s=i.index,u=i.attributes.position,g=l.index,m=l.attributes.position,v=zr(o,p),y=Hr(h,f);if(n.copy(c).invert(),l.boundsTree){ar(o,d,r),r.matrix.copy(n),r.needsUpdate=!0;const e=l.boundsTree.shapecast({intersectsBounds:e=>r.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(c),e.b.applyMatrix4(c),e.c.applyMatrix4(c),e.needsUpdate=!0;for(let n=3*v,i=3*(y+v);n<i;n+=3)if(Nr(t,n,s,u),t.needsUpdate=!0,e.intersectsTriangle(t))return!0;return!1}});return e}for(let i=3*v,r=y+3*v;i<r;i+=3){Nr(e,i,s,u),e.a.applyMatrix4(n),e.b.applyMatrix4(n),e.c.applyMatrix4(n),e.needsUpdate=!0;for(let n=0,i=g.count;n<i;n+=3)if(Nr(t,n,g,m),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}}}();function Jr(e,t,n,i){return ar(e,t,Yr),n.intersectBox(Yr,i)}const $r=[];let es,ts,ns,is;function rs(e){es&&$r.push(es),es=e,ts=new Float32Array(e),ns=new Uint16Array(e),is=new Uint32Array(e)}function ss(){es=null,ts=null,ns=null,is=null,$r.length&&rs($r.pop())}const os=Symbol("skip tree generation"),as=new i,ls=new i,cs=new m,us=new Dr,hs=new Dr,ds=new t,fs=new t,ps=new t,gs=new t,ms=new t,vs=new i,ys=new Fr((()=>new Er));class ws{static serialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),ws.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=n.getIndex();let s;return s=t.cloneBuffers?{roots:i.map((e=>e.slice())),index:r.array.slice()}:{roots:i,index:r.array},s}static deserialize(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("boolean"==typeof n)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),ws.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n={setIndex:!0,...n};const{index:i,roots:r}=e,s=new ws(t,{...n,[os]:!0});if(s._roots=r,n.setIndex){const n=t.getIndex();if(null===n){const n=new f(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return s}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if(t=Object.assign({strategy:qi,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[os]:!1},t),t.useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[os]||(this._roots=function(e,t){const n=yr(e,t);let i,r,s;const o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let e=0;e<n.length;e++){const t=n[e];let u=l(t);const h=new a(ir*u);i=new Float32Array(h),r=new Uint32Array(h),s=new Uint16Array(h),c(0,t),o.push(h)}return o;function l(e){return e.count?1:1+l(e.left)+l(e.right)}function c(e,t){const n=e/4,o=e/2,a=!!t.count,l=t.boundingData;for(let e=0;e<6;e++)i[n+e]=l[e];if(a){const i=t.offset,a=t.count;return r[n+6]=i,s[o+14]=a,s[o+15]=rr,e+ir}{const i=t.left,s=t.right,o=t.splitAxis;let a;if(a=c(e+ir,i),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[n+6]=a/4,a=c(a,s),r[n+7]=o,a}}}(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new i))),this.geometry=e}refit(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e&&Array.isArray(e)&&(e=new Set(e));const t=this.geometry,n=t.index.array,i=t.attributes.position;let r,s,o,a,l=0;const c=this._roots;for(let e=0,t=c.length;e<t;e++)r=c[e],s=new Uint32Array(r),o=new Uint16Array(r),a=new Float32Array(r),u(0,l),l+=r.byteLength;function u(t,r){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const c=2*t;if(o[c+15]===rr){const e=s[t+6];let r=1/0,l=1/0,u=1/0,h=-1/0,d=-1/0,f=-1/0;for(let t=3*e,s=3*(e+o[c+14]);t<s;t++){const e=n[t],s=i.getX(e),o=i.getY(e),a=i.getZ(e);s<r&&(r=s),s>h&&(h=s),o<l&&(l=o),o>d&&(d=o),a<u&&(u=a),a>f&&(f=a)}return(a[t+0]!==r||a[t+1]!==l||a[t+2]!==u||a[t+3]!==h||a[t+4]!==d||a[t+5]!==f)&&(a[t+0]=r,a[t+1]=l,a[t+2]=u,a[t+3]=h,a[t+4]=d,a[t+5]=f,!0)}{const n=t+8,i=s[t+6],o=n+r,c=i+r;let h=l,d=!1,f=!1;e?h||(d=e.has(o),f=e.has(c),h=!d&&!f):(d=!0,f=!0);const p=h||f;let g=!1;(h||d)&&(g=u(n,r,h));let m=!1;p&&(m=u(i,r,h));const v=g||m;if(v)for(let e=0;e<3;e++){const r=n+e,s=i+e,o=a[r],l=a[r+3],c=a[s],u=a[s+3];a[t+e]=o<c?o:c,a[t+e+3]=l>u?l:u}return v}}}traverse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function t(s){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const a=2*s,l=r[a+15]===rr;if(l){const t=i[s+6],c=r[a+14];e(o,l,new Float32Array(n,4*s,6),t,c)}else{const r=s+ir/4,a=i[s+6],c=i[s+7];e(o,l,new Float32Array(n,4*s,6),c)||(t(r,o+1),t(a,o+1))}}(0)}raycast(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=[],s=t.isMaterial,o=Array.isArray(t),a=i.groups,l=s?t.side:t;for(let s=0,c=n.length;s<c;s++){const c=o?t[a[s].materialIndex].side:l,u=r.length;if(rs(n[s]),Qr(0,i,c,e,r),ss(),o){const e=a[s].materialIndex;for(let t=u,n=r.length;t<n;t++)r[t].face.materialIndex=e}}return r}raycastFirst(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=t.isMaterial,s=Array.isArray(t);let o=null;const a=i.groups,l=r?t.side:t;for(let r=0,c=n.length;r<c;r++){const c=s?t[a[r].materialIndex].side:l;rs(n[r]);const u=Kr(0,i,c,e);ss(),null!=u&&(null==o||u.distance<o.distance)&&(o=u,s&&(u.face.materialIndex=a[r].materialIndex))}return o}intersectsGeometry(e,t){const n=this.geometry;let i=!1;for(const r of this._roots)if(rs(r),i=qr(0,n,e,t),ss(),i)break;return i}shapecast(e,t,n){const i=this.geometry;if(e instanceof Function){if(t){const e=t;t=(t,n,i,r)=>{const s=3*n;return e(t,s,s+1,s+2,i,r)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}const r=ys.getPrimitive();let{boundsTraverseOrder:s,intersectsBounds:o,intersectsRange:a,intersectsTriangle:l}=e;if(a&&l){const e=a;a=(t,n,s,o,a)=>!!e(t,n,s,o,a)||Ur(t,n,i,l,s,o,r)}else a||(a=l?(e,t,n,s)=>Ur(e,t,i,l,n,s,r):(e,t,n)=>n);let c=!1,u=0;for(const e of this._roots){if(rs(e),c=Zr(0,i,o,a,s,u),ss(),c)break;u+=e.byteLength}return ys.releasePrimitive(r),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const s=this.geometry.index,o=this.geometry.attributes.position,a=e.geometry.index,l=e.geometry.attributes.position;cs.copy(t).invert();const c=ys.getPrimitive(),u=ys.getPrimitive();if(r){function d(e,n,i,h,d,f,p,g){for(let m=i,v=i+h;m<v;m++){Nr(u,3*m,a,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(Nr(c,3*t,s,o),c.needsUpdate=!0,r(c,u,t,m,d,f,p,g))return!0}return!1}if(i){const f=i;i=function(e,t,n,i,r,s,o,a){return!!f(e,t,n,i,r,s,o,a)||d(e,t,n,i,r,s,o,a)}}else i=d}e.getBoundingBox(ls),ls.applyMatrix4(t);const h=this.shapecast({intersectsBounds:e=>ls.intersectsBox(e),intersectsRange:(t,n,r,s,o,a)=>(as.copy(a),as.applyMatrix4(cs),e.shapecast({intersectsBounds:e=>as.intersectsBox(e),intersectsRange:(e,r,a,l,c)=>i(t,n,e,r,s,o,l,c)}))});return ys.releasePrimitive(c),ys.releasePrimitive(u),h}intersectsBox(e,t){return us.set(e.min,e.max,t),us.needsUpdate=!0,this.shapecast({intersectsBounds:e=>us.intersectsBox(e),intersectsTriangle:e=>us.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1/0;e.boundingBox||e.computeBoundingBox(),us.set(e.boundingBox.min,e.boundingBox.max,t),us.needsUpdate=!0;const o=this.geometry,a=o.attributes.position,l=o.index,c=e.attributes.position,u=e.index,h=ys.getPrimitive(),d=ys.getPrimitive();let f=fs,p=ps,g=null,m=null;i&&(g=gs,m=ms);let v=1/0,y=null,w=null;return cs.copy(t).invert(),hs.matrix.copy(cs),this.shapecast({boundsTraverseOrder:e=>us.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s&&(t&&(hs.min.copy(e.min),hs.max.copy(e.max),hs.needsUpdate=!0),!0),intersectsRange:(n,i)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>hs.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s,intersectsRange:(e,s)=>{for(let o=3*e,b=3*(e+s);o<b;o+=3){Nr(d,o,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let e=3*n,t=3*(n+i);e<t;e+=3){Nr(h,e,l,a),h.needsUpdate=!0;const t=h.distanceToTriangle(d,f,g);if(t<v&&(p.copy(f),m&&m.copy(g),v=t,y=e/3,w=o/3),t<r)return!0}}}});for(let e=0,s=u?u.count:c.count;e<s;e+=3){Nr(d,e,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let t=3*n,s=3*(n+i);t<s;t+=3){Nr(h,t,l,a),h.needsUpdate=!0;const n=h.distanceToTriangle(d,f,g);if(n<v&&(p.copy(f),m&&m.copy(g),v=n,y=t/3,w=e/3),n<r)return!0}}}}),ys.releasePrimitive(h),ys.releasePrimitive(d),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=y,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(cs),p.applyMatrix4(cs),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;const r=n*n,s=i*i;let o=1/0,a=null;if(this.shapecast({boundsTraverseOrder:t=>(ds.copy(e).clamp(t.min,t.max),ds.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n<o&&n<s,intersectsTriangle:(t,n)=>{t.closestPointToPoint(e,ds);const i=e.distanceToSquared(ds);return i<o&&(fs.copy(ds),o=i,a=n),i<r}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(fs):t.point=fs.clone(),t.distance=l,t.faceIndex=a,t}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{ar(0,new Float32Array(t),vs),e.union(vs)})),e}}const bs=new N,xs=new m,As=k.prototype.raycast;class Ts extends v{constructor(){super();const e=new U;e.deleteAttribute("uv");const t=new F({side:_}),n=new F,i=new j(16777215,5,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new k(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new k(e,n);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);const o=new k(e,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const a=new k(e,n);a.position.set(6.167,.857,7.803),a.rotation.set(0,.561,0),a.scale.set(3.927,6.285,3.687),this.add(a);const l=new k(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const c=new k(e,n);c.position.set(2.291,-.756,-2.621),c.rotation.set(0,-.286,0),c.scale.set(1.546,1.552,1.496),this.add(c);const u=new k(e,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const h=new k(e,Ss(50));h.position.set(-16.116,14.37,8.208),h.scale.set(.1,2.428,2.739),this.add(h);const d=new k(e,Ss(50));d.position.set(-16.109,18.021,-8.207),d.scale.set(.1,2.425,2.751),this.add(d);const f=new k(e,Ss(17));f.position.set(14.904,12.198,-1.832),f.scale.set(.15,4.265,6.331),this.add(f);const p=new k(e,Ss(43));p.position.set(-.462,8.89,14.52),p.scale.set(4.38,5.441,.088),this.add(p);const g=new k(e,Ss(20));g.position.set(3.235,11.486,-12.541),g.scale.set(2.5,2,.1),this.add(g);const m=new k(e,Ss(100));m.position.set(0,20,0),m.scale.set(1,.1,1),this.add(m)}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function Ss(e){const t=new z;return t.color.setScalar(e),t}class Es extends H{constructor(e){super(e),this.type=G}parse(e){const t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,r=-1,s=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(r=a.indexOf("\n"))&&s<t&&i<e.byteLength;)o+=a,s+=a.length,i+=128,a+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));return-1<r&&(!1!==n&&(e.pos+=s+r+1),o+a.slice(0,r))},i=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=e[t+0]*s,n[i+1]=e[t+1]*s,n[i+2]=e[t+2]*s,n[i+3]=1},r=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=Y.toHalfFloat(Math.min(e[t+0]*s,65504)),n[i+1]=Y.toHalfFloat(Math.min(e[t+1]*s,65504)),n[i+2]=Y.toHalfFloat(Math.min(e[t+2]*s,65504)),n[i+3]=Y.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;const o=function(e){const i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,a={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(a.valid|=1,a.programtype=c[1],a.string+=l+"\n";l=n(e),!1!==l;)if(a.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(a.gamma=parseFloat(c[1])),(c=l.match(r))&&(a.exposure=parseFloat(c[1])),(c=l.match(s))&&(a.valid|=2,a.format=c[1]),(c=l.match(o))&&(a.valid|=4,a.height=parseInt(c[1],10),a.width=parseInt(c[2],10)),2&a.valid&&4&a.valid)break}else a.comments+=l+"\n";return 2&a.valid?4&a.valid?a:t(3,"missing image size specifier"):t(3,"missing format specifier")}(s);if(-1!==o){const e=o.width,n=o.height,a=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const s=new Uint8Array(4*n*i);if(!s.length)return t(4,"unable to allocate buffer space");let o=0,a=0;const l=4*r,c=new Uint8Array(4),u=new Uint8Array(l);let h=i;for(;h>0&&a<e.byteLength;){if(a+4>e.byteLength)return t(1);if(c[0]=e[a++],c[1]=e[a++],c[2]=e[a++],c[3]=e[a++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=r)return t(3,"bad rgbe scanline format");let n,i=0;for(;i<l&&a<e.byteLength;){n=e[a++];const r=n>128;if(r&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(r){const t=e[a++];for(let e=0;e<n;e++)u[i++]=t}else u.set(e.subarray(a,a+n),i),i+=n,a+=n}const d=r;for(let e=0;e<d;e++){let t=0;s[o]=u[e+t],t+=r,s[o+1]=u[e+t],t+=r,s[o+2]=u[e+t],t+=r,s[o+3]=u[e+t],o+=4}h--}return s}(s.subarray(s.pos),e,n);if(-1!==a){let t,s,l;switch(this.type){case V:l=a.length/4;const e=new Float32Array(4*l);for(let t=0;t<l;t++)i(a,4*t,e,4*t);t=e,s=V;break;case G:l=a.length/4;const n=new Uint16Array(4*l);for(let e=0;e<l;e++)r(a,4*e,n,4*e);t=n,s=G;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:o.string,gamma:o.gamma,exposure:o.exposure,type:s}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,i){return super.load(e,(function(e,n){switch(e.type){case V:case G:e.encoding=u,e.minFilter=A,e.magFilter=A,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,i)}}var Ds=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i<t.children.length;i++)t.children[i].style.display=i===n?"block":"none";e=n}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(n){n.preventDefault(),i(++e%t.children.length)}),!1);var r=(performance||Date).now(),s=r,o=0,a=n(new Ds.Panel("FPS","#0ff","#002")),l=n(new Ds.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Ds.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:t,addPanel:n,showPanel:i,begin:function(){r=(performance||Date).now()},end:function(){o++;var e=(performance||Date).now();if(l.update(e-r,200),e>=s+1e3&&(a.update(1e3*o/(e-s),100),s=e,o=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};Ds.Panel=function(e,t,n){var i=1/0,r=0,s=Math.round,o=s(window.devicePixelRatio||1),a=80*o,l=48*o,c=3*o,u=2*o,h=3*o,d=15*o,f=74*o,p=30*o,g=document.createElement("canvas");g.width=a,g.height=l,g.style.cssText="width:80px;height:48px";var m=g.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,a,l),m.fillStyle=t,m.fillText(e,c,u),m.fillRect(h,d,f,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h,d,f,p),{dom:g,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,a,d),m.fillStyle=t,m.fillText(s(l)+" "+e+" ("+s(i)+"-"+s(r)+")",c,u),m.drawImage(g,h+o,d,f-o,p,h,d,f-o,p),m.fillRect(h+f-o,d,o,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h+f-o,d,o,s((1-l/v)*p))}}};var Cs=Ds;class Is extends k{constructor(){const e=Is.SkyShader,t=new W({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:X.clone(e.uniforms),side:_,depthWrite:!1});super(new U(1,1,1),t),this.isSky=!0}}Is.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new t},up:{value:new t(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\n\t\t}"};var Ms="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Bs(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),n}var Rs={},Ps={},Os=Bs(Xn),_s={},Ls={},ks={},Ns={};Object.defineProperty(Ns,"__esModule",{value:!0});var Us=function(){function e(t,n){if(void 0===n&&(n=null),this.nonEmpty=!1,t||n){if(!t)throw new Error("Parameter head cannot be null.");this.head=t,this.tail=n||e.NIL,this.nonEmpty=!0}else{if(e.NIL)throw new Error("Parameters head and tail are null. Use the NIL element instead.");this.nonEmpty=!1}}return Object.defineProperty(e.prototype,"length",{get:function(){if(!this.nonEmpty)return 0;if(this.tail===e.NIL)return 1;for(var t=0,n=this;n.nonEmpty;)++t,n=n.tail;return t},enumerable:!0,configurable:!0}),e.prototype.prepend=function(t){return new e(t,this)},e.prototype.append=function(t){if(!t)return this;if(!this.nonEmpty)return new e(t);if(this.tail===e.NIL)return new e(t).prepend(this.head);for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;)i=i.tail=new e(r.head),r=r.tail;return i.tail=new e(t),n},e.prototype.insertWithPriority=function(t){if(!this.nonEmpty)return new e(t);var n=t.priority;if(n>this.head.priority)return this.prepend(t);for(var i=new e(this.head),r=i,s=this.tail;s.nonEmpty;){if(n>s.head.priority)return r.tail=s.prepend(t),i;r=r.tail=new e(s.head),s=s.tail}return r.tail=new e(t),i},e.prototype.filterNot=function(t){if(!this.nonEmpty||null==t)return this;if(t===this.head.listener)return this.tail;for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;){if(r.head.listener===t)return i.tail=r.tail,n;i=i.tail=new e(r.head),r=r.tail}return this},e.prototype.contains=function(e){if(!this.nonEmpty)return!1;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return!0;t=t.tail}return!1},e.prototype.find=function(e){if(!this.nonEmpty)return null;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return t.head;t=t.tail}return null},e.prototype.toString=function(){for(var e="",t=this;t.nonEmpty;)e+=t.head+" -> ",t=t.tail;return"[List "+(e+="NIL")+"]"},e.NIL=new e(null,null),e}();Ns.SlotList=Us;var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0});var js=function(){function e(e,t,n,i){void 0===n&&(n=!1),void 0===i&&(i=0),this._enabled=!0,this._once=!1,this._priority=0,this._listener=e,this._once=n,this._signal=t,this._priority=i,this.verifyListener(e)}return e.prototype.execute0=function(){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,this._params):this._listener())},e.prototype.execute1=function(e){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,[e].concat(this._params)):this._listener(e))},e.prototype.execute=function(e){if(this._enabled){this._once&&this.remove(),this._params&&this._params.length&&(e=e.concat(this._params));var t=e.length;0===t?this._listener():1===t?this._listener(e[0]):2===t?this._listener(e[0],e[1]):3===t?this._listener(e[0],e[1],e[2]):this._listener.apply(null,e)}},Object.defineProperty(e.prototype,"listener",{get:function(){return this._listener},set:function(e){if(null==e)throw new Error("Given listener is null.\nDid you want to set enabled to false instead?");this.verifyListener(e),this._listener=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"once",{get:function(){return this._once},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"priority",{get:function(){return this._priority},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"[Slot listener: "+this._listener+", once: "+this._once+", priority: "+this._priority+", enabled: "+this._enabled+"]"},Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"params",{get:function(){return this._params},set:function(e){this._params=e},enumerable:!0,configurable:!0}),e.prototype.remove=function(){this._signal.remove(this._listener)},e.prototype.verifyListener=function(e){if(null==e)throw new Error("Given listener is null.");if(null==this._signal)throw new Error("Internal signal reference has not been set yet.")},e}();Fs.Slot=js,Object.defineProperty(ks,"__esModule",{value:!0});var zs=Ns,Hs=Fs,Gs=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.slots=zs.SlotList.NIL,this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if(!(this._valueClasses[t]instanceof Object))throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+">."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slots.length},enumerable:!0,configurable:!0}),e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){var t=this.slots.find(e);return t?(this.slots=this.slots.filterNot(e),t):null},e.prototype.removeAll=function(){this.slots=zs.SlotList.NIL},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=this.slots;if(s.nonEmpty)for(;s.nonEmpty;)s.head.execute(e),s=s.tail},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.registrationPossible(e,t)){var n=new Hs.Slot(e,this,t);return this.slots=this.slots.prepend(n),n}return this.slots.find(e)},e.prototype.registrationPossible=function(e,t){if(!this.slots.nonEmpty)return!0;var n=this.slots.find(e);if(!n)return!0;if(n.once!==t)throw new Error("You cannot addOnce() then add() the same listener without removing the relationship first.");return!1},e}();ks.OnceSignal=Gs,Object.defineProperty(Ls,"__esModule",{value:!0});var Vs=Os,Ys=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Vs.__extends(t,e),t.prototype.add=function(e){return this.registerListener(e)},t}(ks.OnceSignal);Ls.Signal=Ys,Object.defineProperty(_s,"__esModule",{value:!0});var Ws=Os,Xs=Fs,Qs=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ws.__extends(t,e),t.prototype.addWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!1,t)},t.prototype.addOnceWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!0,t)},t.prototype.registerListener=function(e,t){return void 0===t&&(t=!1),this.registerListenerWithPriority(e,t)},t.prototype.registerListenerWithPriority=function(e,t,n){if(void 0===n&&(n=0),this.registrationPossible(e,t)){var i=new Xs.Slot(e,this,t,n);return this.slots=this.slots.insertWithPriority(i),i}return this.slots.find(e)},t}(Ls.Signal);_s.PrioritySignal=Qs,Object.defineProperty(Ps,"__esModule",{value:!0});var Ks=Os,Zs=function(e){function t(t){void 0===t&&(t=null);for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var r=this;return n=1===n.length&&n[0]instanceof Array?n[0]:n,(r=e.call(this,n)||this)._target=t,r}return Ks.__extends(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){e!==this._target&&(this.removeAll(),this._target=e)},enumerable:!0,configurable:!0}),t.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(null!==e[r]&&e[r].constructor!==this._valueClasses[r])throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=e[0];s&&(s.target&&(s=s.clone(),e[0]=s),s.target=this.target,s.currentTarget=this.target,s.signal=this);for(var o=this.slots;o.nonEmpty;)o.head.execute(e),o=o.tail;if(s&&s.bubbles)for(var a=this.target;a&&a.hasOwnProperty("parent")&&(null===(a=a.parent).onEventBubbled||(s.currentTarget=a,a.onEventBubbled(s))););},t}(_s.PrioritySignal);Ps.DeluxeSignal=Zs;var qs={};Object.defineProperty(qs,"__esModule",{value:!0});var Js=function(){function e(e){void 0===e&&(e=!1),this._bubbles=e}return Object.defineProperty(e.prototype,"signal",{get:function(){return this._signal},set:function(e){this._signal=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(e){this._target=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTarget",{get:function(){return this._currentTarget},set:function(e){this._currentTarget=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bubbles",{get:function(){return this._bubbles},set:function(e){this._bubbles=e},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._bubbles)},e}();qs.GenericEvent=Js;var $s={};Object.defineProperty($s,"__esModule",{value:!0}),$s.IOnceSignal=Symbol("IOnceSignal");var eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.IPrioritySignal=Symbol("IPrioritySignal");var to={};Object.defineProperty(to,"__esModule",{value:!0}),to.ISignal=Symbol("ISignal");var no={};Object.defineProperty(no,"__esModule",{value:!0}),no.ISlot=Symbol("ISlot");var io={};Object.defineProperty(io,"__esModule",{value:!0});var ro=Fs,so=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if("function"!=typeof this._valueClasses[t])throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+"'>."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slot?1:0},enumerable:!0,configurable:!0}),e.prototype.add=function(e){return this.registerListener(e)},e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){if(this.slot&&this.slot.listener===e){var t=this.slot;return this.slot=null,t}return null},e.prototype.removeAll=function(){this.slot&&this.slot.remove()},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");this.slot&&this.slot.execute(e)},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.slot)throw new Error("You cannot add or addOnce with a listener already added, remove the current listener first.");return this.slot=new ro.Slot(e,this,t)},e}();io.MonoSignal=so;var oo={};Object.defineProperty(oo,"__esModule",{value:!0});var ao=Os,lo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ao.__extends(t,e),t.prototype.addOnce=function(t){var n=e.prototype.addOnce.call(this,t);return this.isDispatched&&(n.execute(this.valueObjects),n.remove()),n},t.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(this.isDispatched)throw new Error("You cannot dispatch() a Promise more than once");this.isDispatched=!0,this.valueObjects=t,e.prototype.dispatch.apply(this,t)},t}(ks.OnceSignal);oo.Promise=lo,Object.defineProperty(Rs,"__esModule",{value:!0});var co=Ps;Rs.DeluxeSignal=co.DeluxeSignal;var uo=qs;Rs.GenericEvent=uo.GenericEvent;var ho=$s;Rs.IOnceSignal=ho.IOnceSignal;var fo=eo;Rs.IPrioritySignal=fo.IPrioritySignal;var po=to;Rs.ISignal=po.ISignal;var go=no;Rs.ISlot=go.ISlot;var mo=io;Rs.MonoSignal=mo.MonoSignal;var vo=ks;Rs.OnceSignal=vo.OnceSignal;var yo=_s;Rs.PrioritySignal=yo.PrioritySignal;var wo=oo;Rs.Promise=wo.Promise;var bo=Ls,xo=Rs.Signal=bo.Signal,Ao=Fs;Rs.Slot=Ao.Slot;var To=Ns;Rs.SlotList=To.SlotList;const So=new v;So.name="Scene";class Eo{constructor(e,t){this.signals=e,this.viewportState=t,this.scene=So.clone(),this.scene.castShadow=!0,this.scene.receiveShadow=!0,this.selectedObjects={edge:[],stroke:[],opacity:[],highlight:[],emissive:[]},this.intersectsList={meshOfModelList:[],poiIconList:[],otherObjList:[],getAll:function(){return[...this.meshOfModelList,...this.poiIconList,...this.otherObjList]}}}addObject(e,t){if(this.viewportState.isDisposed)return this.removeObject(e),void yn("Scene is disposed");t?t.add(e):this.scene.add(e),this._triggerObjectAdded(e),this.signals.objectAdded.dispatch(e)}removeObject(e){function t(e){var t;e.map&&((t=e.map)&&t.isTexture&&t.dispose()),e.dispose()}e.traverse((e=>{if("Mesh"===e.type){const n=e;n.geometry.dispose(),On(n.material,t)}e instanceof Fu&&e.element.remove();const{meshOfModelList:n,poiIconList:i,otherObjList:r}=this.intersectsList,s=n.findIndex((t=>t.uuid===e.uuid)),o=i.findIndex((t=>t.uuid===e.uuid)),a=r.findIndex((t=>t.uuid===e.uuid));s>-1&&this.intersectsList.meshOfModelList.splice(s,1),o>-1&&this.intersectsList.poiIconList.splice(o,1),a>-1&&this.intersectsList.otherObjList.splice(a,1)})),e.removeFromParent(),this.signals.objectRemoved.dispatch(e)}openSceneFog(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:t=13426943,near:n=500,far:i=5e4}=e;this.scene.fog=new Q(t,n,i),this.signals.sceneChanged.dispatch()}closeSceneFog(){this.scene.fog=null,this.signals.sceneChanged.dispatch()}edgeShow(e,t){const n=[],i=e=>{-1===this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid))&&n.push(e)};return ji(e)?e.forEach((e=>i(e))):zi(e)&&i(e),this.selectedObjects.edge=[...this.selectedObjects.edge,...n],this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge,options:t}),Promise.resolve()}unEdgeShow(e){e||(e=[...this.selectedObjects.edge]);const t=e=>{const t=this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.edge.splice(t,1),this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge})),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}strokeShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{isOpacityShow:n=!0,color:i=4647927,opacity:r=.2,edgeColor:s=61183,edgeOpacity:o=1}=t,a=e=>{if(-1!==this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid)))return Promise.resolve();if(e.userData.strokeGroup)return Promise.resolve();const t=new Nu({id:e.uuid});return e.traverse((n=>{if(n instanceof k){const i=new K(n.geometry,89),r=new Z(i,new q({color:s,transparent:!0,opacity:o}));Dn(r,n),e.attach(r),t.add(r)}})),e.userData.strokeGroup=t,this.addObject(t,e),this.selectedObjects.stroke.push(e),Promise.resolve()};return n&&this.opacityShow(e,{color:i,opacity:r}),ji(e)?Promise.all(e.map((e=>a(e)))):zi(e)?a(e):Promise.resolve()}unStrokeShow(e){e||(e=[...this.selectedObjects.stroke]);const t=e=>{if(!e.userData.strokeGroup)return Promise.resolve();this.removeObject(e.userData.strokeGroup),Reflect.deleteProperty(e.userData,"strokeGroup");const t=this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.stroke.splice(t,1),this.signals.geometryChanged.dispatch(),this.unOpacityShow(e)),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}opacityShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="#fff",opacity:i=.8}=t;function r(e){return Reflect.construct(e.constructor,[{transparent:!0,depthWrite:!1,side:e.side,color:n,opacity:i}])}const s=e=>(-1!==this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unOpacityShow(e){e||(e=[...this.selectedObjects.opacity]);const t=e=>new Promise((t=>{const n=this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.opacity.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}highlightShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=1}=t;function r(e){e instanceof F&&(e.color=new a(n),e.opacity=i,e.transparent=i<1)}const s=e=>(-1!==this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unHighlightShow(e){e||(e=[...this.selectedObjects.highlight]);const t=e=>new Promise((t=>{const n=this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.highlight.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}emissiveShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=.3,maxOpacity:r=1,minOpacity:s=0,duration:o=1e3}=t;function a(e){e instanceof F&&(e.emissive.set(n),e.emissiveIntensity=i,Ki({emissiveIntensity:r},{emissiveIntensity:s},{duration:o,repeat:!0},(t=>e.emissiveIntensity=t.emissiveIntensity),(t=>e.userData.animation=t)))}const l=e=>(-1!==this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,a)}})),this.selectedObjects.emissive.push(e),this.signals.materialChanged.dispatch()),Promise.resolve());return ji(e)?Promise.all(e.map((e=>l(e)))):zi(e)?l(e):Promise.resolve()}unEmissiveShow(e){function t(e){e.userData.animation&&pn.remove(e.userData.animation)}e||(e=[...this.selectedObjects.emissive]);const n=e=>new Promise((n=>{const i=this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid));-1===i&&n(),this.selectedObjects.emissive.splice(i,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;On(e.material,t),Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),n()}));return ji(e)?Promise.all(e.map((e=>n(e)))):zi(e)?n(e):Promise.resolve()}_triggerObjectAdded(e){if(e instanceof ku)if("Model"===e.stype)e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.meshOfModelList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.meshOfModelList.push(e)}}));else if("Poi"===e.stype){const t=this.intersectsList.poiIconList.findIndex((t=>t.uuid===e.icon.uuid));-1===t&&this.intersectsList.poiIconList.push(e.icon)}else if("BaseMesh"===e.stype){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}else"Group"===e.stype?e.children.forEach((e=>this._triggerObjectAdded(e))):"Object3D"===e.type&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}));else if(e instanceof _u){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}else"Object3D"===e.type&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}))}}class Do extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Do&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let Co,Io;const Mo=new t,Bo=new m,Ro=new m,Po={objects:new WeakMap};function Oo(){const e=new t,n=new t;return function(t,i){return e.setFromMatrixPosition(t.matrixWorld),n.setFromMatrixPosition(i.matrixWorld),e.distanceToSquared(n)}}function _o(e){const t=function(e){const t=[];return e.traverse((function(e){e instanceof Do&&t.push(e)})),t}(e).sort((function(e,t){return Po.objects.get(e).distanceToCameraSquared-Po.objects.get(t).distanceToCameraSquared})),n=t.length;for(let e=0,i=t.length;e<i;e++)t[e].element.style.zIndex=""+(n-e)}class Lo{constructor(e){e||(e=document.createElement("div")),e.style.overflow="hidden",this.domElement=e}setSize(e,t){Co=e/2,Io=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"}renderObject(e,t,n){if(e instanceof Do){Mo.setFromMatrixPosition(e.matrixWorld),Mo.applyMatrix4(Ro);const t=e.element,i="translate(-50%,-100%) translate("+(Mo.x*Co+Co)+"px,"+(-Mo.y*Io+Io)+"px)";t.style.transform=i,t.style.display=Cn(e)&&Mo.z>=-1&&Mo.z<=1?"block":"none";const r={distanceToCameraSquared:Oo()(n,e)};Po.objects.set(e,r),t.parentNode!==this.domElement&&this.domElement.appendChild(t)}for(let i=0,r=e.children.length;i<r;i++)this.renderObject(e.children[i],t,n)}render(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Bo.copy(t.matrixWorldInverse),Ro.multiplyMatrices(t.projectionMatrix,Bo),this.renderObject(e,e,t),_o(e)}}class ko extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof ko&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let No,Uo,Fo,jo;function zo(e){return Math.abs(e)<1e-10?0:e}function Ho(e){const t=e.elements;return"matrix3d("+zo(t[0])+","+zo(-t[1])+","+zo(t[2])+","+zo(t[3])+","+zo(t[4])+","+zo(-t[5])+","+zo(t[6])+","+zo(t[7])+","+zo(t[8])+","+zo(-t[9])+","+zo(t[10])+","+zo(t[11])+","+zo(t[12])+","+zo(-t[13])+","+zo(t[14])+","+zo(t[15])+")"}class Go{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){No=e/2,Uo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,t,n,i){if(e instanceof ko){const t=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+zo(n[0])+","+zo(n[1])+","+zo(n[2])+","+zo(n[3])+","+zo(-n[4])+","+zo(-n[5])+","+zo(-n[6])+","+zo(-n[7])+","+zo(n[8])+","+zo(n[9])+","+zo(n[10])+","+zo(n[11])+","+zo(n[12])+","+zo(n[13])+","+zo(n[14])+","+zo(n[15])+")"}(e.matrixWorld),n=e.element;n.style.transform=t,n.style.display=Cn(e)?"block":"none";const i={style:t,distanceToCameraSquared:0};this.cache.objects.set(e,i),n.parentNode!==this.cameraElement&&this.cameraElement.appendChild(n)}for(let r=0,s=e.children.length;r<s;r++)this.renderObject(e.children[r],t,n,i)}render(e,t){const n=t.projectionMatrix.elements[5]*Uo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+zo(-(t.right+t.left)/2)+"px)"+Ho(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Ho(t.matrixWorldInverse);const r=i+"translate("+No+"px,"+Uo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Vo extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Vo&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}function Yo(e){return Math.abs(e)<1e-10?0:e}function Wo(e){const t=e.elements;return"matrix3d("+Yo(t[0])+","+Yo(-t[1])+","+Yo(t[2])+","+Yo(t[3])+","+Yo(t[4])+","+Yo(-t[5])+","+Yo(t[6])+","+Yo(t[7])+","+Yo(t[8])+","+Yo(-t[9])+","+Yo(t[10])+","+Yo(t[11])+","+Yo(t[12])+","+Yo(-t[13])+","+Yo(t[14])+","+Yo(t[15])+")"}class Xo{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){Fo=e/2,jo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,n,i,r){if(e instanceof Vo){const n=i.quaternion.clone();n.x=-i.quaternion.x,n.z=-i.quaternion.z;const r=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+Yo(n[0])+","+Yo(-n[1])+","+Yo(n[2])+","+Yo(n[3])+","+Yo(n[4])+","+Yo(-n[5])+","+Yo(n[6])+","+Yo(n[7])+","+Yo(n[8])+","+Yo(-n[9])+","+Yo(n[10])+","+Yo(n[11])+","+Yo(n[12])+","+Yo(n[13])+","+Yo(n[14])+","+Yo(n[15])+")"}((new m).compose(e.parent.getWorldPosition(new t(0,0,0)),n,e.parent.scale)),s=e.element;s.style.transform=r,s.style.display=Cn(e)?"block":"none";const o={style:r,distanceToCameraSquared:0};this.cache.objects.set(e,o),s.parentNode!==this.cameraElement&&this.cameraElement.appendChild(s)}for(let t=0,s=e.children.length;t<s;t++)this.renderObject(e.children[t],n,i,r)}render(e,t){const n=t.projectionMatrix.elements[5]*jo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+Yo(-(t.right+t.left)/2)+"px)"+Wo(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Wo(t.matrixWorldInverse);const r=i+"translate("+Fo+"px,"+jo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Qo{constructor(e){this.options=e,this.internalOptions={enableRenderCss2D:!1,enableRenderCss2DHalf:!1,enableRenderCss3D:!1},this.container=this._initContainer(),this.renderer=this._initRenderer(),this.rendererCSS2D=this._initRenderCSS2D(),this.rendererCSS3D=this._initRenderCSS3D(),this.rendererCSS2DHalf=this._initRenderCSS2DHalf(),this.interactiveContainer=this._initInteractiveContainer()}setInternalState(e,t){this.internalOptions[e]=t}getWidth(){return this.renderer.domElement.width}getHeight(){return this.renderer.domElement.height}getMouseRelativeConRatio(e){const t=this.container.getBoundingClientRect();return[(e.offsetX-t.left)/t.width,(e.offsetY-t.top)/t.height]}getMousePoint(e){const t=new M(0,0);return t.fromArray(this.getMouseRelativeConRatio(e)),t}_initContainer(){const e=document.createElement("div");return e.style.position="relative",e.style.width="100%",e.style.height="100%",e}_initRenderer(){const{background:e={},logarithmicDepthBuffer:t}=this.options,{color:n,alpha:i}=e,r=new te({alpha:i,logarithmicDepthBuffer:t,preserveDrawingBuffer:!0,antialias:!1,stencil:!1,depth:!1,powerPreference:"high-performance"}),s=i?0:1,{offsetWidth:o,offsetHeight:a}=this.container;return r.setSize(o,a),r.setClearColor(n||0,s),r.setPixelRatio(self.devicePixelRatio),r.localClippingEnabled=!0,r.sortObjects=!0,r.shadowMap.enabled=!0,r.shadowMap.type=ne,this.container.appendChild(r.domElement),r}_initRenderCSS2D(){const e=new Lo;return e.domElement.id="ssp_view_2DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS3D(){const e=new Go;return e.domElement.id="ssp_view_3DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS2DHalf(){const e=new Xo(this.rendererCSS3D.domElement,this.rendererCSS3D.cameraElement);return e.setSize(this.container.offsetWidth,this.container.offsetHeight),e}_initInteractiveContainer(){return this.rendererCSS3D.domElement}}const Ko=new m,Zo=(e,t)=>{const i=Ko.clone(),r=Ko.clone(),s=Ko.clone();i.makeRotationY(e),r.makeRotationX(t);const o=new n;return s.multiplyMatrices(i,r),o.setFromRotationMatrix(s),o},qo=Zo(-Math.PI/2,-Math.PI/4),Jo=Zo(Math.PI/2,-Math.PI/4),$o=Zo(-Math.PI/4,-Math.PI/4),ea=Zo(Math.PI/4,-Math.PI/4),ta=Zo(1.25*Math.PI,-Math.PI/4),na=Zo(.75*Math.PI,-Math.PI/4),ia={LEFT:new n(0,-Math.PI/2,0),RIGHT:new n(0,Math.PI/2,0),FRONT:new n(0,0,0),BACK:new n(0,Math.PI,0),TOP:new n(-Math.PI/2,0,0),BOTTOM:new n(Math.PI/2,0,0),FRONTTOP:new n(-Math.PI/4,0,0),BACKTOP:new n(Math.PI/4,Math.PI,0),LEFTTOP:new n(qo.x,qo.y,qo.z),RIGHTTOP:new n(Jo.x,Jo.y,Jo.z),LEFTFRONTTOP:new n($o.x,$o.y,$o.z),RIGHTFRONTTOP:new n(ea.x,ea.y,ea.z),LEFTBACKTOP:new n(ta.x,ta.y,ta.z),RIGHTBACKTOP:new n(na.x,na.y,na.z)},ra=e=>Fi(e)?e:e.includes("%")?.01*Number(e.split("%")[0]):isNaN(+e)?0:Number(e),sa=new t,oa=new n,aa=new $(50,1,.1,5e5);aa.position.set(500,1e3,500),aa.lookAt(sa.set(0,0,0)),aa.name="Camera";class la{constructor(e){this.viewport=e,this.mainCamera=aa.clone(),this.mainCamera.name="freeCamera",this.currentCamera=this.mainCamera,this.cameras={}}createCamera(e){const t=aa.clone();return t.name=e,this.cameras[e]=t,t}removeCamera(e){return"fullFreeCamera"!==e&&(delete this.cameras[e],!0)}setCurrentCamera(e){this.currentCamera=this.viewport.camera=e,this.viewport.signals.cameraObjectChange.dispatch()}getMainCamera(){return this.mainCamera}getCameraViewpoint(){if("free"===this.viewport.controls.options.type)return{position:this.currentCamera.position.clone(),rotation:{x:this.currentCamera.rotation.x,y:this.currentCamera.rotation.y,z:this.currentCamera.rotation.z}};{const e=this.viewport.controls.currentControls;return{position:this.currentCamera.position.clone(),target:e.target.clone()}}}setCameraViewpoint(e){if("free"===this.viewport.controls.options.type&&zi(e)){const{position:t,rotation:n}=e;this.currentCamera.position.set(t.x,t.y,t.z),this.currentCamera.rotation.set(n.x,n.y,n.z)}else if(zi(e)){const{position:t,target:n}=e,i=this.viewport.controls.currentControls;this.currentCamera.position.set(t.x,t.y,t.z),i.target.set(n.x,n.y,n.z)}this.viewport.signals.cameraChange.dispatch(this.currentCamera.position.clone())}moveTo(e,t){return Ki(this.currentCamera.position,e,t,(e=>this.viewport.signals.cameraChange.dispatch(e)))}rotateTo(e,t){const n=this.currentCamera.quaternion.clone(),i=(new r).setFromEuler(e);return Ki({t:0},{t:1},t,(e=>{let{t:t}=e;this.currentCamera.quaternion.slerpQuaternions(n,i,t)}))}flyTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(Ni(t)){const e=t.toLocaleUpperCase();"CURRENT"===e?oa.copy(this.currentCamera.rotation):ia[e]&&oa.copy(ia[e])}else t instanceof n?oa.copy(t):zi(t)&&oa.set(t.x,t.y,t.z);oa.copy(Tn(this.currentCamera.rotation,oa.clone())),yield Promise.all([this.moveTo(e,i),this.rotateTo(oa,i)])}))}flyToBoundingBox(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(e.isEmpty())return void yn("target box is empty");const r=this.viewport.controls.options.type,s=new t;if(Ni(n)){if("CURRENT"===n.toLocaleUpperCase())s.copy(this.getMovePosByBBox(e));else{const t=ia[n.toLocaleUpperCase()],i=this.getObjectLabelPos(e,t);s.copy(i)}}else{"orbit"===r&&yn("orbit 控制器不支持 Rotation 类型 的 rotation 参数");const t=bn(n),i=this.getObjectLabelPos(e,t);s.copy(i)}if("orbit"===r){const t=e.getCenter(sa),i=this.viewport.controls.currentControls;i.target.copy(t);const r=new m;r.lookAt(s,t,i.object.up),n=oa.setFromRotationMatrix(r)}yield this.flyTo(s,n,i)}))}flyToObj(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof Gu||e instanceof Fu){const{padding:t=50}=i,r=ra(t);return this.flyToBoundingBox(e.getBoundingBox(r),n,i)}{const{padding:r="30%"}=i,s=xn(e),o=s.getSize(sa);let a=0;if(Ni(r)){const e=Math.max(o.x,o.y,o.z);a=ra(r)*e}else a=r;let l=a,c=a;if(a<0){const e=Math.min(o.x,o.z),t=o.y-1;l=Math.abs(a)>e?-e:a,c=Math.abs(l)>t?-t:l}return 0!==r&&(s.max.add(sa.set(l/2,c/2,l/2)),s.min.sub(sa.set(l/2,c/2,l/2))),s.isEmpty()&&(sa.setFromMatrixPosition(e.matrixWorld),s.setFromCenterAndSize(sa,new t(0,0,0))),this.flyToBoundingBox(s,n,i)}}surroundOnTarget(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{speed:n=1,angle:i=360,onStart:r}=t,s=wn(e),o=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),a=Math.abs(i);return Ki({angle:0},{angle:Math.PI/180*a},{duration:a/360*5e3/n},(e=>{const t=i>0?e.angle:2*Math.PI-e.angle;if(this.currentCamera.position.x=Math.sin(t)*o+s.x,this.currentCamera.position.z=Math.cos(t)*o+s.z,"orbit"===this.viewport.controls.options.type){const e=this.viewport.controls.currentControls;e.target.copy(s),e.update()}else this.currentCamera.lookAt(s)}),r)}surroundOnObject(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(new i).setFromObject(e).getCenter(sa);return this.surroundOnTarget(n,t)}getMovePosByBBox(e){const n=this.currentCamera.position,i=e.getCenter(sa);(new t).subVectors(i,n).normalize();let r=new O;r=e.getBoundingSphere(r);const s=this.currentCamera.fov/2*Math.PI/180,o=Math.sin(s),a=r.radius/o,l=new t;this.currentCamera.getWorldDirection(l);const c=l.clone();return c.multiplyScalar(-a),i.clone().add(c)}getObjectLabelPos(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof ku&&(e=(new i).setFromObject(e)),e.isEmpty())return yn("target box is empty"),new t;const{extendScale:s=1.6,mode:o="scene"}=r;if("scene"===o){const t=e.getCenter(sa),i=e.max.clone().sub(e.min),r=Math.max(i.x,i.y,i.z),o=t.clone(),a=e=>{const t=(s-.5)*Math.abs(r),n=Math.max(t,this.viewport.camera.near);o.add(e.multiplyScalar(n))};let l;return l=Ni(n)?ia[n.toLocaleUpperCase()]:bn(n),a(sa.set(0,0,1).applyEuler(l)),o}return"screen"===o?e.getCenter(sa).clone():new t}}
1
+ import*as e from"three";import{Vector3 as t,Euler as n,Box3 as i,Quaternion as r,CubeTextureLoader as s,RGBAFormat as o,Color as a,Texture as l,Source as c,LinearEncoding as u,MathUtils as h,DoubleSide as d,BufferAttribute as f,PropertyBinding as p,InterpolateDiscrete as g,Matrix4 as m,Scene as v,InterpolateLinear as y,NearestFilter as w,NearestMipmapNearestFilter as b,NearestMipmapLinearFilter as x,LinearFilter as A,LinearMipmapNearestFilter as T,LinearMipmapLinearFilter as S,ClampToEdgeWrapping as E,RepeatWrapping as D,MirroredRepeatWrapping as C,sRGBEncoding as I,Vector2 as M,Plane as B,Line3 as R,Triangle as P,Sphere as O,BackSide as _,FrontSide as L,Mesh as k,Ray as N,BoxGeometry as U,MeshStandardMaterial as F,PointLight as j,MeshBasicMaterial as z,DataTextureLoader as H,HalfFloatType as G,FloatType as V,DataUtils as Y,ShaderMaterial as W,UniformsUtils as X,Fog as Q,EdgesGeometry as K,LineSegments as Z,LineBasicMaterial as q,Object3D as J,PerspectiveCamera as $,OrthographicCamera as ee,WebGLRenderer as te,PCFSoftShadowMap as ne,Camera as ie,UnsignedByteType as re,MeshNormalMaterial as se,WebGLRenderTarget as oe,DepthTexture as ae,DepthStencilFormat as le,UnsignedInt248Type as ce,UnsignedIntType as ue,Uniform as he,LoadingManager as de,NoBlending as fe,RGBADepthPacking as pe,REVISION as ge,EventDispatcher as me,MeshDepthMaterial as ve,BasicDepthPacking as ye,DataTexture as we,Vector4 as be,BufferGeometry as xe,Material as Ae,LuminanceFormat as Te,RedFormat as Se,RGFormat as Ee,ShaderChunk as De,WebGLCubeRenderTarget as Ce,CubeCamera as Ie,PMREMGenerator as Me,WebGLMultipleRenderTargets as Be,FramebufferTexture as Re,Matrix3 as Pe,TangentSpaceNormalMap as Oe,GLSL3 as _e,VideoTexture as Le,Frustum as ke,MOUSE as Ne,TOUCH as Ue,Spherical as Fe,CanvasTexture as je,PlaneGeometry as ze,Raycaster as He,Clock as Ge,AnimationMixer as Ve,ACESFilmicToneMapping as Ye,AnimationClip as We,NoToneMapping as Xe,LinearToneMapping as Qe,ReinhardToneMapping as Ke,CineonToneMapping as Ze,EquirectangularReflectionMapping as qe,TextureLoader as Je,Sprite as $e,SpriteMaterial as et,SphereGeometry as tt,CircleGeometry as nt,Float32BufferAttribute as it,ShapeGeometry as rt,Shape as st,UniformsLib as ot,UVMapping as at,AmbientLight as lt,DirectionalLight as ct,HemisphereLight as ut,SpotLight as ht,RectAreaLight as dt,Curve as ft,Loader as pt,LoaderUtils as gt,FileLoader as mt,MeshPhongMaterial as vt,MeshLambertMaterial as yt,Group as wt,Bone as bt,SkinnedMesh as xt,Line as At,Skeleton as Tt,Uint16BufferAttribute as St,VectorKeyframeTrack as Et,QuaternionKeyframeTrack as Dt,NumberKeyframeTrack as Ct,TrianglesDrawMode as It,TriangleFanDrawMode as Mt,TriangleStripDrawMode as Bt,MeshPhysicalMaterial as Rt,InstancedMesh as Pt,ImageBitmapLoader as Ot,InterleavedBuffer as _t,InterleavedBufferAttribute as Lt,PointsMaterial as kt,LineLoop as Nt,Points as Ut,Interpolant as Ft,LinearMipMapLinearFilter as jt,ImageLoader as zt,GridHelper as Ht,AxesHelper as Gt,Box3Helper as Vt,DirectionalLightHelper as Yt,HemisphereLightHelper as Wt,SpotLightHelper as Xt,PointLightHelper as Qt,Box2 as Kt}from"three";export*from"three";var Zt,qt="soonspacejs",Jt="2.6.2",$t={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 1-Math.cos(e*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.cos(Math.PI*e))}},Exponential:{In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))}},Circular:{In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}},Elastic:{In:function(e){return 0===e?0:1===e?1:-Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)},Out:function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(5*(e-.1)*Math.PI)+1},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?-.5*Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)+1}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-$t.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?.5*$t.Bounce.In(2*e):.5*$t.Bounce.Out(2*e-1)+.5}}},en="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},tn=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map((function(t){return e._tweens[t]}))},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){void 0===e&&(e=en()),void 0===t&&(t=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],s=!t;r&&!1===r.update(e,s)&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),nn={Linear:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.Linear;return t<0?s(e[0],e[1],i):t>1?s(e[n],e[n-1],n-i):s(e[r],e[r+1>n?n:r+1],i-r)},Bezier:function(e,t){for(var n=0,i=e.length-1,r=Math.pow,s=nn.Utils.Bernstein,o=0;o<=i;o++)n+=r(1-t,i-o)*r(t,o)*e[o]*s(i,o);return n},CatmullRom:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(r=Math.floor(i=n*(1+t))),s(e[(r-1+n)%n],e[r],e[(r+1)%n],e[(r+2)%n],i-r)):t<0?e[0]-(s(e[0],e[0],e[1],e[1],-i)-e[0]):t>1?e[n]-(s(e[n],e[n],e[n-1],e[n-1],i-n)-e[n]):s(e[r?r-1:0],e[r],e[n<r+1?n:r+1],e[n<r+2?n:r+2],i-r)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=nn.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(Zt=[1],function(e){var t=1;if(Zt[e])return Zt[e];for(var n=e;n>1;n--)t*=n;return Zt[e]=t,t}),CatmullRom:function(e,t,n,i,r){var s=.5*(n-e),o=.5*(i-t),a=r*r;return(2*t-2*n+s+o)*(r*a)+(-3*t+3*n-2*s-o)*a+s*r+t}}},rn=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),sn=new tn,on=function(){function e(e,t){void 0===t&&(t=sn),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=$t.Linear.None,this._interpolationFunction=nn.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=rn.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),void 0!==t&&(this._duration=t),this},e.prototype.duration=function(e){return this._duration=e,this},e.prototype.start=function(e){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var t in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(t),this._valuesStart[t]=this._valuesStartRepeat[t];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==e?"string"==typeof e?en()+parseFloat(e):e:en(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},e.prototype._setupProperties=function(e,t,n,i){for(var r in n){var s=e[r],o=Array.isArray(s),a=o?"array":typeof s,l=!o&&Array.isArray(n[r]);if("undefined"!==a&&"function"!==a){if(l){var c=n[r];if(0===c.length)continue;c=c.map(this._handleRelativeValue.bind(this,s)),n[r]=[s].concat(c)}if("object"!==a&&!o||!s||l)void 0===t[r]&&(t[r]=s),o||(t[r]*=1),i[r]=l?n[r].slice().reverse():t[r]||0;else{for(var u in t[r]=o?[]:{},s)t[r][u]=s[u];i[r]=o?[]:{},this._setupProperties(s,t[r],n[r],i[r])}}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return void 0===e&&(e=en()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this)),this},e.prototype.resume=function(e){return void 0===e&&(e=en()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return this._group=e,this},e.prototype.delay=function(e){return this._delayTime=e,this},e.prototype.repeat=function(e){return this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return this._yoyo=e,this},e.prototype.easing=function(e){return this._easingFunction=e,this},e.prototype.interpolation=function(e){return this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){if(void 0===e&&(e=en()),void 0===t&&(t=!0),this._isPaused)return!0;var n,i,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e)}if(this._goToEnd=!1,e<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(e-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var s=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,s),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,a=this._chainedTweens.length;o<a;o++)this._chainedTweens[o].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(void 0!==t[r]){var s=t[r]||0,o=n[r],a=Array.isArray(e[r]),l=Array.isArray(o);!a&&l?e[r]=this._interpolationFunction(o,i):"object"==typeof o&&o?this._updateProperties(e[r],s,o,i):"number"==typeof(o=this._handleRelativeValue(s,o))&&(e[r]=s+(o-s)*i)}},e.prototype._handleRelativeValue=function(e,t){return"string"!=typeof t?t:"+"===t.charAt(0)||"-"===t.charAt(0)?e+parseFloat(t):parseFloat(t)},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];this._valuesStartRepeat[e]="string"==typeof n?this._valuesStartRepeat[e]+parseFloat(n):this._valuesEnd[e],this._valuesEnd[e]=t},e}(),an=rn.nextId,ln=sn,cn=ln.getAll.bind(ln),un=ln.removeAll.bind(ln),hn=ln.add.bind(ln),dn=ln.remove.bind(ln),fn=ln.update.bind(ln),pn={Easing:$t,Group:tn,Interpolation:nn,now:en,Sequence:rn,nextId:an,Tween:on,VERSION:"18.6.4",getAll:cn,removeAll:un,add:hn,remove:dn,update:fn};const gn="[soonspacejs]: ",mn="In soonspacejs: ",vn=(e,t)=>{let n="";for(const e in t)n+=`${e}: ${t[e]};`;console.log(`%c${e}`,n)},yn=e=>{console.warn(mn+e)};function wn(e){return e instanceof t?e:new t(e.x,e.y,e.z)}function bn(e){return e instanceof n?e:new n(e.x,e.y,e.z)}function xn(e){return new i(new t(0,0,0),new t(500,500,500)).setFromObject(e)}function An(e,t,n){const i=n.clone();return Math.abs(t[e]-n[e])>Math.PI&&(t[e]>n[e]?i[e]+=2*Math.PI:i[e]-=2*Math.PI),i}function Tn(e,t){const i=An("x",e,t),r=An("y",e,t),s=An("z",e,t);return new n(i.x,r.y,s.z,t.order)}function Sn(e){return Math.PI/180*e}function En(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?{position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)}:{position:e.position.clone(),rotation:e.rotation.clone(),scale:e.scale.clone()}}function Dn(e,t){const n=En(t,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);e.position.copy(n.position),e.rotation.copy(n.rotation),e.scale.copy(n.scale)}function Cn(e){return!!e.visible&&(!e.parent||Cn(e.parent))}class In{constructor(){this.min=null,this.roots=[],this.nodes=new Map}shift(){const e=this.min;if(null===e||this.roots.length<1)return this.min=null,e;this.remove(e),this.roots.length>50&&this.consolidate();let t=1/0;const n=this.roots.length;for(let e=0;e<n;e++){const n=this.roots[e],i=this.getDistance(n);i<t&&(t=i,this.min=n)}return e}consolidate(){const e=[[],[],[],[],[],[],[]],t=e.length-1,n=this.roots.length;for(let i=0;i<n;i++){const n=this.roots[i],r=this.nodes.get(n);r&&r.depth<t&&e[r.depth].push(n)}for(let n=0;n<=t;n++)for(;e[n].length>1;){const i=e[n].shift(),r=e[n].shift(),s=n+1;let o=-1;if(void 0!==i&&void 0!==r){const n=this.nodes.get(i),a=this.nodes.get(r);n&&a&&(n.distance<a.distance?(n.depth=s,n.children.push(r),a.parent=i,s<=t&&e[s].push(i),o=this.roots.indexOf(r)):(a.depth=s,a.children.push(i),n.parent=r,s<=t&&e[s].push(r),o=this.roots.indexOf(i)))}o>-1&&this.roots.splice(o,1)}}add(e,t){if(this.nodes.set(e,{nodeIndex:e,distance:t,depth:0,parent:null,children:[]}),null===this.min)this.min=e;else{const n=this.nodes.get(this.min);n&&t<n.distance&&(this.min=e)}this.roots.push(e)}update(e,t){this.remove(e),this.add(e,t)}remove(e){var t,n;if(!this.nodes.has(e))return;const i=null===(t=this.nodes.get(e))||void 0===t?void 0:t.children;if(i&&i.length>0)for(let t=0;t<i.length;t++){const n=i[t],r=this.nodes.get(n),s=this.nodes.get(e);r&&s&&(r.parent=s.parent),r&&null===r.parent&&this.roots.push(n)}let r=null===(n=this.nodes.get(e))||void 0===n?void 0:n.parent;if(null===r){const t=this.roots.indexOf(e);t>-1&&this.roots.splice(t,1)}else for(;r;){const e=this.nodes.get(r);e&&(e.depth--,r=e.parent)}}getDistance(e){const t=this.nodes.get(e);return t?t.distance:1/0}}function Mn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["px.jpg","nx.jpg","py.jpg","ny.jpg","pz.jpg","nz.jpg"];return new Promise((n=>{(new s).setPath(e).load(t,(e=>{e.format=o,n(e)}))}))}function Bn(e){if(!e)return null;const{colors:t,stops:n,size:i=1024}=e,r=document.createElement("canvas"),s=r.getContext("2d");if(!s)return null;r.width=16,r.height=i;const o=s.createLinearGradient(0,0,0,i),c=new a,u=t.map((e=>c.set(e).getStyle()));for(let e=0,t=u.length-1;e<=t;e++)o.addColorStop(n?n[e]:e/t,u[e]);s.fillStyle=o,s.fillRect(0,0,16,i);const h=new l(r);return h.needsUpdate=!0,h}const Rn=e=>{const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)};function Pn(e){return ji(e)?function(e){return e.map((e=>Pn(e)))}(e):zi(e)?function(e){if(zi(e)){const t={};for(const n in e)t[n]=Pn(e[n]);return t}return e}(e):e}const On=(e,t)=>ji(e)?e.map(t):t(e),_n=e=>On(e,(e=>e.clone())),Ln=e=>On(e,(e=>e.dispose()));var kn=function(e,t){return kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},kn(e,t)};var Nn=function(){return Nn=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Nn.apply(this,arguments)};function Un(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function Fn(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}var jn=Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]};function zn(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Hn(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function Gn(e){return this instanceof Gn?(this.v=e,this):new Gn(e)}var Vn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Yn(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Wn(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var Xn=Object.freeze({__proto__:null,get __assign(){return Nn},__asyncDelegator:function(e){var t,n;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(n=!n)?{value:Gn(e[i](t)),done:!1}:r?r(t):t}:r}},__asyncGenerator:function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise((function(n,i){s.push([e,t,n,i])>1||a(e,t)}))})}function a(e,t){try{(n=r[e](t)).value instanceof Gn?Promise.resolve(n.value.v).then(l,c):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=zn(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){(function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)})(i,r,(t=e[n](t)).done,t.value)}))}}},__await:Gn,__awaiter:Fn,__classPrivateFieldGet:Yn,__classPrivateFieldIn:function(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)},__classPrivateFieldSet:Wn,__createBinding:jn,__decorate:function(e,t,n,i){var r,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,n,o):r(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o},__esDecorate:function(e,t,n,i,r,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,l=i.kind,c="getter"===l?"get":"setter"===l?"set":"value",u=!t&&e?i.static?e:e.prototype:null,h=t||(u?Object.getOwnPropertyDescriptor(u,i.name):{}),d=!1,f=n.length-1;f>=0;f--){var p={};for(var g in i)p[g]="access"===g?{}:i[g];for(var g in i.access)p.access[g]=i.access[g];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var m=(0,n[f])("accessor"===l?{get:h.get,set:h.set}:h[c],p);if("accessor"===l){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(a=o(m.get))&&(h.get=a),(a=o(m.set))&&(h.set=a),(a=o(m.init))&&r.push(a)}else(a=o(m))&&("field"===l?r.push(a):h[c]=a)}u&&Object.defineProperty(u,i.name,h),d=!0},__exportStar:function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||jn(t,e,n)},__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}kn(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},__generator:function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&jn(t,e,n);return Vn(t,e),t},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__param:function(e,t){return function(n,i){t(n,i,e)}},__propKey:function(e){return"symbol"==typeof e?e:"".concat(e)},__read:Hn,__rest:Un,__runInitializers:function(e,t,n){for(var i=arguments.length>2,r=0;r<t.length;r++)n=i?t[r].call(e,n):t[r].call(e);return i?n:void 0},__setFunctionName:function(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})},__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Hn(arguments[t]));return e},__spreadArray:function(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r<s;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},__spreadArrays:function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var i=Array(e),r=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i},__values:zn});const Qn=e=>Fn(void 0,void 0,void 0,(function*(){const t=yield fetch(e);if(200===t.status)return t;throw new Error(`Failed to fetch file: ${e}`)})),Kn=e=>{"function"==typeof requestIdleCallback?requestIdleCallback(e):setTimeout(e)};var Zn=function(){function e(){}return e.prototype.toJson=function(e,t){var n=this.xmlStringToXmlDom(e),i=this.xmlToJson(n);return t?(t.removeLineBreaks&&this.removeLineBreaks(i),t.removeComments&&this.removeCommentProperties(i),t.transformTextOnly&&this.transformTextOnly(i),i):i},e.prototype.xmlStringToXmlDom=function(e){return(new DOMParser).parseFromString(e,"text/xml")},e.prototype.removeLineBreaks=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#text"===n&&Array.isArray(e[n])&&delete e[n],"object"==typeof e[n]&&t.removeLineBreaks(e[n])}))},e.prototype.removeCommentProperties=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#comment"===n&&delete e[n],"object"==typeof e[n]&&t.removeCommentProperties(e[n])}))},e.prototype.transformTextOnly=function(e){var t=this;Object.keys(e).forEach((function(n,i){var r=Object.keys(e[n]).length>1,s=Object.keys(e[n])[0];r||"object"==typeof e[n][s]?t.transformTextOnly(e[n]):"object"==typeof e[n]&&e[n]["#text"]&&(e[n]=e[n]["#text"])}))},e.prototype.xmlToJson=function(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t._attributes={};for(var n=0;n<e.attributes.length;n++){var i=e.attributes.item(n);t._attributes[i.nodeName]=i.nodeValue}}}else 3==e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes.item(r),o=s.nodeName;if(void 0===t[o])t[o]=this.xmlToJson(s);else{if(void 0===t[o].push){var a=t[o];t[o]=[],t[o].push(a)}t[o].push(this.xmlToJson(s))}}return t},e}();function qn(e){return Qn(e).then((e=>e.text())).then((e=>Promise.resolve(function(e){return(new Zn).toJson(e,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(e))))}class Jn{constructor(){this.pluginCallbacks=[],this.register((function(e){return new Ii(e)})),this.register((function(e){return new Mi(e)})),this.register((function(e){return new Pi(e)})),this.register((function(e){return new Oi(e)})),this.register((function(e){return new _i(e)})),this.register((function(e){return new Li(e)})),this.register((function(e){return new Bi(e)})),this.register((function(e){return new Ri(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){const r=new Ci,s=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)s.push(this.pluginCallbacks[e](r));r.setPlugins(s),r.write(e,t,i).catch(n)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,i,r,t)}))}}const $n=0,ei=1,ti=2,ni=3,ii=4,ri=5121,si=5123,oi=5126,ai=5125,li=34962,ci=34963,ui=9728,hi=9729,di=9984,fi=9985,pi=9986,gi=9987,mi=33071,vi=33648,yi=10497,wi={};wi[w]=ui,wi[b]=di,wi[x]=pi,wi[A]=hi,wi[T]=fi,wi[S]=gi,wi[E]=mi,wi[D]=yi,wi[C]=vi;const bi={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},xi=new a;function Ai(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}function Ti(e){return 4*Math.ceil(e/4)}function Si(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=Ti(e.byteLength);if(n!==e.byteLength){const i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;r<n;r++)i[r]=t;return i.buffer}return e}function Ei(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function Di(e,t){if(void 0!==e.toBlob)return new Promise((n=>e.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}class Ci{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const o=i.extensionsUsed,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o);if(l.length>0&&(s.extensionsUsed=l),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=a.size),!0===n.binary){const e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){const n=Si(e.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=Si((o=JSON.stringify(s),(new TextEncoder).encode(o).buffer),32);var o;const a=new DataView(new ArrayBuffer(8));a.setUint32(0,r.byteLength,!0),a.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const u=12+a.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,u,!0);const h=new Blob([l,a,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(h),d.onloadend=function(){t(d.result)}}}else if(s.buffers&&s.buffers.length>0){const e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){const n=e.result;s.buffers[0].uri=n,t(s)}}else t(s)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],i[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new t;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);const i=e.clone(),r=new t;for(let e=0,t=i.count;e<t;e++)r.fromBufferAttribute(i,e),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),i.setXYZ(e,r.x,r.y,r.z);return n.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let n=!1;const i={};0===t.offset.x&&0===t.offset.y||(i.offset=t.offset.toArray(),n=!0),0!==t.rotation&&(i.rotation=t.rotation,n=!0),1===t.repeat.x&&1===t.repeat.y||(i.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(e){return e.encoding===I?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");const i=e?e.image:null,r=t?t.image:null,s=Math.max(i?i.width:0,r?r.width:0),o=Math.max(i?i.height:0,r?r.height:0),a=Ei();a.width=s,a.height=o;const l=a.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,s,o);const h=l.getImageData(0,0,s,o);if(i){l.drawImage(i,0,0,s,o);const t=n(e),r=l.getImageData(0,0,s,o).data;for(let e=2;e<r.length;e+=4)h.data[e]=256*t(r[e]/256)}if(r){l.drawImage(r,0,0,s,o);const e=n(t),i=l.getImageData(0,0,s,o).data;for(let t=1;t<i.length;t+=4)h.data[t]=256*e(i[t]/256)}l.putImageData(h,0,0);const d=(e||t).clone();return d.source=new c(a),d.encoding=u,d}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,i,r){const s=this.json;let o;s.bufferViews||(s.bufferViews=[]),o=t===ri?1:t===si?2:4;const a=Ti(i*e.itemSize*o),l=new DataView(new ArrayBuffer(a));let c=0;for(let r=n;r<n+i;r++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?i=e.array[r*e.itemSize+n]:(0===n?i=e.getX(r):1===n?i=e.getY(r):2===n?i=e.getZ(r):3===n&&(i=e.getW(r)),!0===e.normalized&&(i=h.normalize(i,e.array))),t===oi?l.setFloat32(c,i,!0):t===ai?l.setUint32(c,i,!0):t===si?l.setUint16(c,i,!0):t===ri&&l.setUint8(c,i),c+=o}const u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==r&&(u.target=r),r===li&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);return{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){const e=Si(r.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(e,t,n,i){const r=this.json;let s;if(e.array.constructor===Float32Array)s=oi;else if(e.array.constructor===Uint32Array)s=ai;else if(e.array.constructor===Uint16Array)s=si;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");s=ri}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;const o=function(e,t,n){const i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=t;r<t+n;r++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=h.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);let a;void 0!==t&&(a=e===t.index?ci:li);const l=this.processBufferView(e,s,n,i,a),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(null!==e){const r=this,s=r.cache,a=r.json,l=r.options,c=r.pending;s.images.has(e)||s.images.set(e,{});const u=s.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);const d={mimeType:i},f=Ei();f.width=Math.min(e.width,l.maxTextureSize),f.height=Math.min(e.height,l.maxTextureSize);const p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==o&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else p.drawImage(e,0,0,f.width,f.height);!0===l.binary?c.push(Di(f,i).then((e=>r.processBufferViewImage(e))).then((e=>{d.bufferView=e}))):void 0!==f.toDataURL?d.uri=f.toDataURL(i):c.push(Di(f,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{d.uri=e})));const g=a.images.push(d)-1;return u[h]=g,g}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:wi[e.magFilter],minFilter:wi[e.minFilter],wrapS:wi[e.wrapS],wrapT:wi[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||(n.textures=[]);let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");const r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(r.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,r)}));const s=n.textures.push(r)-1;return t.textures.set(e,s),s}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(Ai(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t)};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity),n=Math.max(t.r,t.g,t.b);if(n>1&&(t.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),n>0&&(i.emissiveFactor=t.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===d&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));const s=n.materials.push(i)-1;return t.materials.set(e,s),s}processMesh(e){const t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)i.push(e.material[t].uuid);else i.push(e.material.uuid);const r=i.join(":");if(t.meshes.has(r))return t.meshes.get(r);const s=e.geometry;let o;o=e.isLineSegments?ei:e.isLineLoop?ti:e.isLine?ni:e.isPoints?$n:e.material.wireframe?ei:ii;const a={},l={},c=[],u=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");void 0===d||this.isNormalizedNormalAttribute(d)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let p=null;for(let e in s.attributes){if("morph"===e.slice(0,5))continue;const n=s.attributes[e];e=h[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(n))){l[e]=t.attributes.get(this.getUID(n));continue}p=null;const i=n.array;"JOINTS_0"!==e||i instanceof Uint16Array||i instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new f(new Uint16Array(i),n.itemSize,n.normalized));const r=this.processAccessor(p||n,s);null!==r&&(l[e]=r,t.attributes.set(this.getUID(n),r))}if(void 0!==d&&s.setAttribute("normal",d),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const n=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){const a={};let l=!1;for(const e in s.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}const n=s.morphAttributes[e][o],i=e.toUpperCase(),r=s.attributes[e];if(t.attributes.has(this.getUID(n,!0))){a[i]=t.attributes.get(this.getUID(n,!0));continue}const c=n.clone();if(!s.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)0===t&&c.setX(e,n.getX(e)-r.getX(e)),1===t&&c.setY(e,n.getY(e)-r.getY(e)),2===t&&c.setZ(e,n.getZ(e)-r.getZ(e)),3===t&&c.setW(e,n.getW(e)-r.getW(e));a[i]=this.processAccessor(c,s),t.attributes.set(this.getUID(r,!0),a[i])}u.push(a),n.push(e.morphTargetInfluences[o]),void 0!==e.morphTargetDictionary&&i.push(r[o])}a.weights=n,i.length>0&&(a.extras={},a.extras.targetNames=i)}const g=Array.isArray(e.material);if(g&&0===s.groups.length)return null;const m=g?e.material:[e.material],v=g?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=v.length;e<n;e++){const n={mode:o,attributes:l};if(this.serializeUserData(s,n),u.length>0&&(n.targets=u),null!==s.index){let i=this.getUID(s.index);void 0===v[e].start&&void 0===v[e].count||(i+=":"+v[e].start+":"+v[e].count),t.attributes.has(i)?n.indices=t.attributes.get(i):(n.indices=this.processAccessor(s.index,s,v[e].start,v[e].count),t.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=this.processMaterial(m[v[e].materialIndex]);null!==i&&(n.material=i),c.push(n)}a.primitives=c,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,a)}));const y=n.meshes.push(a)-1;return t.meshes.set(r,y),y}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:h.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(e=Jn.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,s=[],o=[];for(let e=0;e<r.length;++e){const n=r[e],a=p.parseTrackName(n.name);let l=p.findNode(t,a.nodeName);const c=bi[a.propertyName];if("bones"===a.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(a.objectIndex):void 0),!l||!c)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',n.name),null;const u=1;let h,d=n.values.length/n.times.length;c===bi.morphTargetInfluences&&(d/=l.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(h="CUBICSPLINE",d/=3):h=n.getInterpolation()===g?"STEP":"LINEAR",o.push({input:this.processAccessor(new f(n.times,u)),output:this.processAccessor(new f(n.values,d)),interpolation:h}),s.push({sampler:o.length-1,target:{node:i.get(l),path:c}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:s}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,i=t.nodes[n.get(e)],r=e.skeleton;if(void 0===r)return null;const s=e.skeleton.bones[0];if(void 0===s)return null;const o=[],a=new Float32Array(16*r.bones.length),l=new m;for(let t=0;t<r.bones.length;++t)o.push(n.get(r.bones[t])),l.copy(r.boneInverses[t]),l.multiply(e.bindMatrix).toArray(a,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new f(a,16)),joints:o,skeleton:n.get(s)});return i.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const t=e.quaternion.toArray(),n=e.position.toArray(),i=e.scale.toArray();Ai(t,[0,0,0,1])||(r.rotation=t),Ai(n,[0,0,0])||(r.translation=n),Ai(i,[1,1,1])||(r.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Ai(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(r.matrix=e.matrix.elements);if(""!==e.name&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const t=this.processMesh(e);null!==t&&(r.mesh=t)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let i=0,r=e.children.length;i<r;i++){const r=e.children[i];if(r.visible||!1===n.onlyVisible){const e=this.processNode(r);null!==e&&t.push(e)}}t.length>0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));const s=t.nodes.push(r)-1;return i.set(e,s),s}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);const r=[];for(let t=0,i=e.children.length;t<i;t++){const i=e.children[t];if(i.visible||!1===n.onlyVisible){const e=this.processNode(i);null!==e&&r.push(e)}}r.length>0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){const t=new v;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const n=[];for(let t=0;t<e.length;t++)e[t]instanceof v?this.processScene(e[t]):n.push(e[t]);n.length>0&&this.processObjects(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class Ii{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const n=this.writer,i=n.json,r=n.extensionsUsed,s={};e.name&&(s.name=e.name),s.color=e.color.toArray(),s.intensity=e.intensity,e.isDirectionalLight?s.type="directional":e.isPointLight?(s.type="point",e.distance>0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const o=i.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}let Mi=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},Bi=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:n.processTexture(e.clearcoatMap)};n.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:n.processTexture(e.clearcoatRoughnessMap)};n.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:n.processTexture(e.clearcoatNormalMap)};n.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Ri=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:n.processTexture(e.iridescenceMap)};n.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:n.processTexture(e.iridescenceThicknessMap)};n.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Pi=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const t={index:n.processTexture(e.transmissionMap)};n.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Oi=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const t={index:n.processTexture(e.thicknessMap)};n.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},_i=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}},Li=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(xi)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,i=n.extensionsUsed,r={};if(e.specularIntensityMap){const t={index:n.processTexture(e.specularIntensityMap)};n.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){const t={index:n.processTexture(e.specularColorMap)};n.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}};Jn.Utils={insertKeyframe:function(e,t){const n=.001,i=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),s=new e.ValueBufferType(e.values.length+i),o=e.createInterpolant(new e.ValueBufferType(i));let a;if(0===e.times.length){r[0]=t;for(let e=0;e<i;e++)s[e]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;r[0]=t,r.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,i),a=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),a=r.length-1}else for(let l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<n)return l;if(e.times[l]<t&&e.times[l+1]>t){r.set(e.times.slice(0,l+1),0),r[l+1]=t,r.set(e.times.slice(l+1),l+2),s.set(e.values.slice(0,(l+1)*i),0),s.set(o.evaluate(t),(l+1)*i),s.set(e.values.slice((l+1)*i),(l+2)*i),a=l+1;break}}return e.times=r,e.values=s,a},mergeMorphTargetTracks:function(e,t){const n=[],i={},r=e.tracks;for(let e=0;e<r.length;++e){let s=r[e];const o=p.parseTrackName(s.name),a=p.findNode(t,o.nodeName);if("morphTargetInfluences"!==o.propertyName||void 0===o.propertyIndex){n.push(s);continue}if(s.createInterpolant!==s.InterpolantFactoryMethodDiscrete&&s.createInterpolant!==s.InterpolantFactoryMethodLinear){if(s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),s=s.clone(),s.setInterpolation(y)}const l=a.morphTargetInfluences.length,c=a.morphTargetDictionary[o.propertyIndex];if(void 0===c)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(void 0===i[a.uuid]){u=s.clone();const e=new u.ValueBufferType(l*u.times.length);for(let t=0;t<u.times.length;t++)e[t*l+c]=u.values[t];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=e,i[a.uuid]=u,n.push(u);continue}const h=s.createInterpolant(new s.ValueBufferType(1));u=i[a.uuid];for(let e=0;e<u.times.length;e++)u.values[e*l+c]=h.evaluate(u.times[e]);for(let e=0;e<s.times.length;e++){const t=this.insertKeyframe(u,s.times[e]);u.values[t*l+c]=s.values[e]}}return e.tracks=n,e}};const ki=Object.prototype.hasOwnProperty,Ni=e=>"String"===Gi(e),Ui=e=>"Boolean"===Gi(e),Fi=e=>"Number"===Gi(e),ji=Array.isArray,zi=e=>"Object"===Gi(e),Hi=e=>"Function"===Gi(e),Gi=e=>Object.prototype.toString.call(e).slice(8,-1),Vi=(e,t,n)=>String.fromCodePoint(...new Uint8Array(e,t,n)),Yi=()=>gn+Math.random().toString(36).substring(7).split("").join("_"),Wi=e=>{var t;const{pathname:n}=new URL(e,location.origin);return null===(t=n.split(".").pop())||void 0===t?void 0:t.toLowerCase()};var Xi=Object.freeze({__proto__:null,IVector3ToEuler:bn,IVector3ToVector3:wn,MinHeap:In,cloneDeep:Pn,cloneMaterials:_n,deg2Euler:Sn,disposeMaterials:Ln,error:e=>{console.error(mn+e)},euler2Deg:function(e){return e/(Math.PI/180)},exportGltf:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((n,i)=>{(new Jn).parse(e,(e=>n(e)),(e=>i(e)),t)}))},fetchFile:Qn,getAsciiString:Vi,getBoundingBox:xn,getCubeTexture:Mn,getExtension:Wi,getSpaceAttributeFromObject:En,getValueType:Gi,gradientTexture:Bn,hasOwn:(e,t)=>ki.call(e,t),idleTask:Kn,isArray:ji,isBoolean:Ui,isDate:e=>"Date"===Gi(e),isFunction:Hi,isNull:e=>"Null"===Gi(e),isNumber:Fi,isObject:zi,isObjectVisible:Cn,isPromise:e=>"Promise"===Gi(e),isString:Ni,isSymbol:e=>"Symbol"===Gi(e),isUndefined:e=>"Undefined"===Gi(e),log:vn,materialHandle:On,parseFilePath:Rn,randomString:Yi,rotationAFix:Tn,rotationAxisFix:An,sleep:e=>new Promise((t=>setTimeout((()=>t()),e))),syncSpaceAttributeToObject:Dn,warn:yn,xmlToJson:qn});const Qi={"Linear.None":$t.Linear.None,"Quadratic.In":$t.Quadratic.In,"Quadratic.Out":$t.Quadratic.Out,"Quadratic.InOut":$t.Quadratic.InOut,"Cubic.In":$t.Cubic.In,"Cubic.Out":$t.Cubic.Out,"Cubic.InOut":$t.Cubic.InOut,"Quartic.In":$t.Quartic.In,"Quartic.Out":$t.Quartic.Out,"Quartic.InOut":$t.Quartic.InOut,"Quintic.In":$t.Quintic.In,"Quintic.Out":$t.Quintic.Out,"Quintic.InOut":$t.Quintic.InOut,"Sinusoidal.In":$t.Sinusoidal.In,"Sinusoidal.Out":$t.Sinusoidal.Out,"Sinusoidal.InOut":$t.Sinusoidal.InOut,"Exponential.In":$t.Exponential.In,"Exponential.Out":$t.Exponential.Out,"Exponential.InOut":$t.Exponential.InOut,"Circular.In":$t.Circular.In,"Circular.Out":$t.Circular.Out,"Circular.InOut":$t.Circular.InOut,"Elastic.In":$t.Elastic.In,"Elastic.Out":$t.Elastic.Out,"Elastic.InOut":$t.Elastic.InOut,"Back.In":$t.Back.In,"Back.Out":$t.Back.Out,"Back.InOut":$t.Back.InOut,"Bounce.In":$t.Bounce.In,"Bounce.Out":$t.Bounce.Out,"Bounce.InOut":$t.Bounce.InOut};function Ki(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;return new Promise(((o,a)=>{const{duration:l=1e3,delay:c=0,repeat:u=!1,mode:h="Linear.None",yoyo:d=!1}=i,f=Qi[h],p=new on(e).to(t,l).easing(f).delay(c).onUpdate((i=>{e instanceof n&&t instanceof n&&i instanceof n&&(i.order=t.order),null==r||r(i,p)})).onComplete((()=>{o()})).onStop((()=>{a("animation stop")})).onStart((()=>{null==s||s(p)}));Fi(u)?p.repeat(u):Ui(u)&&u&&p.repeat(1/0),p.yoyo(d),p.start()}))}class Zi{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.target=e,this.points=t,this.speed=1,this.reverse=!1,this.needsRotate=!0,this.index=1,this._tween=null,Object.assign(this,n)}get isPlaying(){var e;return!!(null===(e=this._tween)||void 0===e?void 0:e.isPlaying())}play(){return Fn(this,void 0,void 0,(function*(){if(this.isPlaying)return!1;this.index=1;let e=this.points.slice();return this.reverse&&(e=e.reverse()),this._play(e)}))}_play(e){var t,n;return Fn(this,void 0,void 0,(function*(){const{target:i}=this,r=null!==(t=this.speed)&&void 0!==t?t:1,s=this.index;let o=e[s-1];if(!o)return!0;o.isVector3||(o=wn(o)),o=o.clone();let a=e[s];if(!a)return!0;a.isVector3||(a=wn(a).clone()),a=a.clone();const l=o.distanceTo(a)/r;this.needsRotate&&(1===s&&i.parent&&i.position.copy(i.parent.worldToLocal(o.clone())),i.lookAt(a)),yield Ki(o,a,{duration:l},((e,t)=>{var n;if(i.parent){const t=i.parent.worldToLocal(e.clone());i.position.copy(t)}null===(n=this.onUpdate)||void 0===n||n.call(this,e,t)}),(e=>{var t,n;1===s&&(null===(t=this.onStart)||void 0===t||t.call(this,e)),null===(n=this.onEveryStart)||void 0===n||n.call(this,e),this._tween=e})),null===(n=this.onPoint)||void 0===n||n.call(this,s,a),this.index++,yield this._play(e)}))}pause(){var e;null===(e=this._tween)||void 0===e||e.pause()}resume(){var e;null===(e=this._tween)||void 0===e||e.resume()}stop(){var e;null===(e=this._tween)||void 0===e||e.stop(),this._tween=null}}const qi=0,Ji=1,$i=2,er=2,tr=1.25,nr=1,ir=32,rr=65535,sr=Math.pow(2,-24);class or{constructor(){}}function ar(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function lr(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){const r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function cr(e,t){t.set(e)}function ur(e,t,n){let i,r;for(let s=0;s<3;s++){const o=s+3;i=e[s],r=t[s],n[s]=i<r?i:r,i=e[o],r=t[o],n[o]=i>r?i:r}}function hr(e,t,n){for(let i=0;i<3;i++){const r=t[e+2*i],s=t[e+2*i+1],o=r-s,a=r+s;o<n[i]&&(n[i]=o),a>n[i+3]&&(n[i+3]=a)}}function dr(e){const t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function fr(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,g=-1/0,m=-1/0;const v=null!==r;for(let i=6*t,r=6*(t+n);i<r;i+=6){const t=e[i+0],n=e[i+1],r=t-n,y=t+n;r<s&&(s=r),y>l&&(l=y),v&&t<h&&(h=t),v&&t>p&&(p=t);const w=e[i+2],b=e[i+3],x=w-b,A=w+b;x<o&&(o=x),A>c&&(c=A),v&&w<d&&(d=w),v&&w>g&&(g=w);const T=e[i+4],S=e[i+5],E=T-S,D=T+S;E<a&&(a=E),D>u&&(u=D),v&&T<f&&(f=T),v&&T>m&&(m=T)}i[0]=s,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=u,v&&(r[0]=h,r[1]=d,r[2]=f,r[3]=p,r[4]=g,r[5]=m)}const pr=32,gr=(e,t)=>e.candidate-t.candidate,mr=new Array(pr).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),vr=new Float32Array(6);function yr(e,t){function n(e){d&&d(e/p)}function i(t,r,d){let f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!g&&p>=l&&(g=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=u||p>=l)return n(r+d),t.offset=r,t.count=d,t;const m=function(e,t,n,i,r,s){let o=-1,a=0;if(s===qi)o=lr(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(s===Ji)o=lr(e),-1!==o&&(a=function(e,t,n,i){let r=0;for(let s=t,o=t+n;s<o;s++)r+=e[6*s+2*i];return r/n}(n,i,r,o));else if(s===$i){const s=dr(e);let l=tr*r;const c=6*i,u=6*(i+r);for(let e=0;e<3;e++){const i=t[e],h=(t[e+3]-i)/pr;if(r<pr/4){const t=[...mr];t.length=r;let i=0;for(let r=c;r<u;r+=6,i++){const s=t[i];s.candidate=n[r+2*e],s.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:l}=s;for(let e=0;e<3;e++)l[e]=1/0,l[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;hr(r,n,o)}t.sort(gr);let h=r;for(let e=0;e<h;e++){const n=t[e];for(;e+1<h&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),h--}for(let i=c;i<u;i+=6){const r=n[i+2*e];for(let e=0;e<h;e++){const s=t[e];r>=s.candidate?hr(i,n,s.rightCacheBounds):(hr(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n<h;n++){const i=t[n],c=i.count,u=r-i.count,h=i.leftCacheBounds,d=i.rightCacheBounds;let f=0;0!==c&&(f=dr(h)/s);let p=0;0!==u&&(p=dr(d)/s);const g=nr+tr*(f*c+p*u);g<l&&(o=e,l=g,a=i.candidate)}}else{for(let e=0;e<pr;e++){const t=mr[e];t.count=0,t.candidate=i+h+e*h;const n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let t=c;t<u;t+=6){let r=~~((n[t+2*e]-i)/h);r>=pr&&(r=pr-1);const s=mr[r];s.count++,hr(t,n,s.bounds)}const t=mr[pr-1];cr(t.bounds,t.rightCacheBounds);for(let e=pr-2;e>=0;e--){const t=mr[e],n=mr[e+1];ur(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let t=0;t<pr-1;t++){const n=mr[t],i=n.count,c=n.bounds,u=mr[t+1].rightCacheBounds;0!==i&&(0===d?cr(c,vr):ur(c,vr,vr)),d+=i;let h=0,f=0;0!==d&&(h=dr(vr)/s);const p=r-d;0!==p&&(f=dr(u)/s);const g=nr+tr*(h*d+f*p);g<l&&(o=e,l=g,a=n.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}(t.boundingData,f,o,r,d,h);if(-1===m.axis)return n(r+d),t.offset=r,t.count=d,t;const v=function(e,t,n,i,r){let s=n,o=n+i-1;const a=r.pos,l=2*r.axis;for(;;){for(;s<=o&&t[6*s+l]<a;)s++;for(;s<=o&&t[6*o+l]>=a;)o--;if(!(s<o))return s;for(let n=0;n<3;n++){let i=e[3*s+n];e[3*s+n]=e[3*o+n],e[3*o+n]=i;let r=t[6*s+2*n+0];t[6*s+2*n+0]=t[6*o+2*n+0],t[6*o+2*n+0]=r;let a=t[6*s+2*n+1];t[6*s+2*n+1]=t[6*o+2*n+1],t[6*o+2*n+1]=a}s++,o--}}(a,o,r,d,m);if(v===r||v===r+d)n(r+d),t.offset=r,t.count=d;else{t.splitAxis=m.axis;const e=new or,n=r,a=v-r;t.left=e,e.boundingData=new Float32Array(6),fr(o,n,a,e.boundingData,s),i(e,n,a,s,p+1);const l=new or,c=v,u=d-a;t.right=l,l.boundingData=new Float32Array(6),fr(o,c,u,l.boundingData,s),i(l,c,u,s,p+1)}return t}!function(e,t){if(!e.index){const n=e.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;let r;r=n>65535?new Uint32Array(new i(4*n)):new Uint16Array(new i(2*n)),e.setIndex(new f(r,1));for(let e=0;e<n;e++)r[e]=e}}(e,t);const r=new Float32Array(6),s=new Float32Array(6),o=function(e,t){const n=e.attributes.position,i=e.index.array,r=i.length/3,s=new Float32Array(6*r),o=n.normalized,a=n.array,l=n.offset||0;let c=3;n.isInterleavedBufferAttribute&&(c=n.data.stride);const u=["getX","getY","getZ"];for(let e=0;e<r;e++){const r=3*e,h=6*e;let d,f,p;o?(d=i[r+0],f=i[r+1],p=i[r+2]):(d=i[r+0]*c+l,f=i[r+1]*c+l,p=i[r+2]*c+l);for(let e=0;e<3;e++){let i,r,l;o?(i=n[u[e]](d),r=n[u[e]](f),l=n[u[e]](p)):(i=a[d+e],r=a[f+e],l=a[p+e]);let c=i;r<c&&(c=r),l<c&&(c=l);let g=i;r>g&&(g=r),l>g&&(g=l);const m=(g-c)/2,v=2*e;s[h+v+0]=c+m,s[h+v+1]=m+(Math.abs(c)+m)*sr,c<t[e]&&(t[e]=c),g>t[e+3]&&(t[e+3]=g)}}return s}(e,r),a=e.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,p=e.index.count/3;let g=!1;const m=[],v=function(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];const t=[],n=new Set;for(const t of e.groups)n.add(t.start),n.add(t.start+t.count);const i=Array.from(n.values()).sort(((e,t)=>e-t));for(let e=0;e<i.length-1;e++){const n=i[e],r=i[e+1];t.push({offset:n/3,count:(r-n)/3})}return t}(e);if(1===v.length){const e=v[0],t=new or;t.boundingData=r,function(e,t,n,i){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let i=6*t,u=6*(t+n);i<u;i+=6){const t=e[i+0];t<r&&(r=t),t>a&&(a=t);const n=e[i+2];n<s&&(s=n),n>l&&(l=n);const u=e[i+4];u<o&&(o=u),u>c&&(c=u)}i[0]=r,i[1]=s,i[2]=o,i[3]=a,i[4]=l,i[5]=c}(o,e.offset,e.count,s),i(t,e.offset,e.count,s),m.push(t)}else for(let e of v){const t=new or;t.boundingData=new Float32Array(6),fr(o,e.offset,e.count,t.boundingData,s),i(t,e.offset,e.count,s),m.push(t)}return m}class wr{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,s=e.length;r<s;r++){const s=e[r][t];n=s<n?s:n,i=s>i?s:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=e.dot(s);n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}wr.prototype.setFromBox=function(){const e=new t;return function(t,n){const i=n.min,r=n.max;let s=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let a=0;a<=1;a++)for(let l=0;l<=1;l++){e.x=i.x*n+r.x*(1-n),e.y=i.y*a+r.y*(1-a),e.z=i.z*l+r.z*(1-l);const c=t.dot(e);s=Math.min(c,s),o=Math.max(c,o)}this.min=s,this.max=o}}(),function(){const e=new wr}();const br=function(){const e=new t,n=new t,i=new t;return function(t,r,s){const o=t.start,a=e,l=r.start,c=n;i.subVectors(o,l),e.subVectors(t.end,t.start),n.subVectors(r.end,r.start);const u=i.dot(c),h=c.dot(a),d=c.dot(c),f=i.dot(a),p=a.dot(a)*d-h*h;let g,m;g=0!==p?(u*h-f*d)/p:0,m=(u+g*h)/d,s.x=g,s.y=m}}(),xr=function(){const e=new M,n=new t,i=new t;return function(t,r,s,o){br(t,r,e);let a=e.x,l=e.y;if(a>=0&&a<=1&&l>=0&&l<=1)return t.at(a,s),void r.at(l,o);if(a>=0&&a<=1)return l<0?r.at(0,o):r.at(1,o),void t.closestPointToPoint(o,!0,s);if(l>=0&&l<=1)return a<0?t.at(0,s):t.at(1,s),void r.closestPointToPoint(s,!0,o);{let e,c;e=a<0?t.start:t.end,c=l<0?r.start:r.end;const u=n,h=i;return t.closestPointToPoint(c,!0,n),r.closestPointToPoint(e,!0,i),u.distanceToSquared(c)<=h.distanceToSquared(e)?(s.copy(u),void o.copy(c)):(s.copy(e),void o.copy(h))}}}(),Ar=function(){const e=new t,n=new t,i=new B,r=new R;return function(t,s){const{radius:o,center:a}=t,{a:l,b:c,c:u}=s;r.start=l,r.end=c;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=l,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=c,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const h=s.getPlane(i);if(Math.abs(h.distanceToPoint(a))<=o){const e=h.projectPoint(a,n);if(s.containsPoint(e))return!0}return!1}}(),Tr=1e-15;function Sr(e){return Math.abs(e)<Tr}class Er extends P{constructor(){super(...arguments),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new t)),this.satBounds=new Array(4).fill().map((()=>new wr)),this.points=[this.a,this.b,this.c],this.sphere=new O,this.plane=new B,this.needsUpdate=!0}intersectsSphere(e){return Ar(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,o=r[0],a=s[0];this.getNormal(o),a.setFromPoints(o,i);const l=r[1],c=s[1];l.subVectors(e,t),c.setFromPoints(l,i);const u=r[2],h=s[2];u.subVectors(t,n),h.setFromPoints(u,i);const d=r[3],f=s[3];d.subVectors(n,e),f.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Er.prototype.closestPointToSegment=function(){const e=new t,n=new t,i=new R;return function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const{start:o,end:a}=t,l=this.points;let c,u=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(l[o]),i.end.copy(l[a]),xr(i,t,e,n),c=e.distanceToSquared(n),c<u&&(u=c,r&&r.copy(e),s&&s.copy(n))}return this.closestPointToPoint(o,e),c=o.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(o)),this.closestPointToPoint(a,e),c=a.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(a)),Math.sqrt(u)}}(),Er.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new Array(3),r=new wr,s=new wr,o=new t,a=new t,l=new t,c=new t,u=new R,h=new R,d=new R;return function(t){let f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,p=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const g=this.plane,m=t.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){const e=this.satBounds,a=this.satAxes;i[0]=t.a,i[1]=t.b,i[2]=t.c;for(let t=0;t<4;t++){const n=e[t],s=a[t];if(r.setFromPoints(s,i),n.isSeparated(r))return!1}const l=t.satBounds,c=t.satAxes;n[0]=this.a,n[1]=this.b,n[2]=this.c;for(let e=0;e<4;e++){const t=l[e],i=c[e];if(r.setFromPoints(i,n),t.isSeparated(r))return!1}for(let e=0;e<4;e++){const t=a[e];for(let e=0;e<4;e++){const a=c[e];if(o.crossVectors(t,a),r.setFromPoints(o,n),s.setFromPoints(o,i),r.isSeparated(s))return!1}}return f&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),f.start.set(0,0,0),f.end.set(0,0,0)),!0}{const e=this.points;let n=!1,i=0;for(let t=0;t<3;t++){const r=e[t],s=e[(t+1)%3];u.start.copy(r),u.end.copy(s),u.delta(a);const o=n?h.start:h.end,l=Sr(m.distanceToPoint(r));if(Sr(m.normal.dot(a))&&l){h.copy(u),i=2;break}if((m.intersectLine(u,o)||l)&&!Sr(o.distanceTo(s))){if(i++,n)break;n=!0}}if(1===i&&t.containsPoint(h.end))return f&&(f.start.copy(h.end),f.end.copy(h.end)),!0;if(2!==i)return!1;const r=t.points;let s=!1,o=0;for(let e=0;e<3;e++){const t=r[e],n=r[(e+1)%3];u.start.copy(t),u.end.copy(n),u.delta(l);const i=s?d.start:d.end,a=Sr(g.distanceToPoint(t));if(Sr(g.normal.dot(l))&&a){d.copy(u),o=2;break}if((g.intersectLine(u,i)||a)&&!Sr(i.distanceTo(n))){if(o++,s)break;s=!0}}if(1===o&&this.containsPoint(d.end))return f&&(f.start.copy(d.end),f.end.copy(d.end)),!0;if(2!==o)return!1;if(h.delta(a),d.delta(l),a.dot(l)<0){let e=d.start;d.start=d.end,d.end=e}const p=h.start.dot(a),v=h.end.dot(a),y=d.start.dot(a),w=d.end.dot(a);return(p===w||y===v||v<y!==p<w)&&(f&&(c.subVectors(h.start,d.start),c.dot(a)>0?f.start.copy(h.start):f.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?f.end.copy(h.end):f.end.copy(d.end)),!0)}}}(),Er.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Er.prototype.distanceToTriangle=function(){const e=new t,n=new t,i=["a","b","c"],r=new R,s=new R;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const l=o||a?r:null;if(this.intersectsTriangle(t,l))return(o||a)&&(o&&l.getCenter(o),a&&l.getCenter(a)),0;let c=1/0;for(let n=0;n<3;n++){let r;const s=i[n],l=t[s];this.closestPointToPoint(l,e),r=l.distanceToSquared(e),r<c&&(c=r,o&&o.copy(e),a&&a.copy(l));const u=this[s];t.closestPointToPoint(u,e),r=u.distanceToSquared(e),r<c&&(c=r,o&&o.copy(u),a&&a.copy(e))}for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];r.set(this[u],this[h]);for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];s.set(t[u],t[h]),xr(r,s,e,n);const d=e.distanceToSquared(n);d<c&&(c=d,o&&o.copy(e),a&&a.copy(n))}}return Math.sqrt(c)}}();class Dr{constructor(e,n,i){this.isOrientedBox=!0,this.min=new t,this.max=new t,this.matrix=new m,this.invMatrix=new m,this.points=new Array(8).fill().map((()=>new t)),this.satAxes=new Array(3).fill().map((()=>new t)),this.satBounds=new Array(3).fill().map((()=>new wr)),this.alignedSatBounds=new Array(3).fill().map((()=>new wr)),this.needsUpdate=!1,e&&this.min.copy(e),n&&this.max.copy(n),i&&this.matrix.copy(i)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Dr.prototype.update=function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let o=0;o<=1;o++){const a=i[1*r|2*s|4*o];a.x=r?n.x:t.x,a.y=s?n.y:t.y,a.z=o?n.z:t.z,a.applyMatrix4(e)}const r=this.satBounds,s=this.satAxes,o=i[0];for(let e=0;e<3;e++){const t=s[e],n=r[e],a=i[1<<e];t.subVectors(o,a),n.setFromPoints(t,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},Dr.prototype.intersectsBox=function(){const e=new wr;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,r=this.satBounds,s=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=i.x,o[0].isSeparated(e))return!1;if(e.min=n.y,e.max=i.y,o[1].isSeparated(e))return!1;if(e.min=n.z,e.max=i.z,o[2].isSeparated(e))return!1;for(let n=0;n<3;n++){const i=s[n],o=r[n];if(e.setFromBox(i,t),o.isSeparated(e))return!1}return!0}}(),Dr.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new wr,r=new wr,s=new t;return function(t){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const o=this.satBounds,a=this.satAxes;n[0]=t.a,n[1]=t.b,n[2]=t.c;for(let e=0;e<3;e++){const t=o[e],r=a[e];if(i.setFromPoints(r,n),t.isSeparated(i))return!1}const l=t.satBounds,c=t.satAxes,u=this.points;for(let e=0;e<3;e++){const t=l[e],n=c[e];if(i.setFromPoints(n,u),t.isSeparated(i))return!1}for(let e=0;e<3;e++){const t=a[e];for(let e=0;e<4;e++){const o=c[e];if(s.crossVectors(t,o),i.setFromPoints(s,n),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}(),Dr.prototype.closestPointToPoint=function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},Dr.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Dr.prototype.distanceToBox=function(){const e=["x","y","z"],n=new Array(12).fill().map((()=>new R)),i=new Array(12).fill().map((()=>new R)),r=new t,s=new t;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.needsUpdate&&this.update(),this.intersectsBox(t))return(a||l)&&(t.getCenter(s),this.closestPointToPoint(s,r),t.closestPointToPoint(r,s),a&&a.copy(r),l&&l.copy(s)),0;const c=o*o,u=t.min,h=t.max,d=this.points;let f=1/0;for(let e=0;e<8;e++){const t=d[e];s.copy(t).clamp(u,h);const n=t.distanceToSquared(s);if(n<f&&(f=n,a&&a.copy(t),l&&l.copy(s),n<c))return Math.sqrt(n)}let p=0;for(let t=0;t<3;t++)for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){const o=(t+1)%3,a=(t+2)%3,l=1<<t|r<<o|s<<a,c=d[r<<o|s<<a],f=d[l];n[p].set(c,f);const g=e[t],m=e[o],v=e[a],y=i[p],w=y.start,b=y.end;w[g]=u[g],w[m]=r?u[m]:h[m],w[v]=s?u[v]:h[m],b[g]=h[g],b[m]=r?u[m]:h[m],b[v]=s?u[v]:h[m],p++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){s.x=e?h.x:u.x,s.y=t?h.y:u.y,s.z=n?h.z:u.z,this.closestPointToPoint(s,r);const i=s.distanceToSquared(r);if(i<f&&(f=i,a&&a.copy(r),l&&l.copy(s),i<c))return Math.sqrt(i)}for(let e=0;e<12;e++){const t=n[e];for(let e=0;e<12;e++){const n=i[e];xr(t,n,r,s);const o=r.distanceToSquared(s);if(o<f&&(f=o,a&&a.copy(r),l&&l.copy(s),o<c))return Math.sqrt(o)}}return Math.sqrt(f)}}();const Cr=new t,Ir=new t,Mr=new t,Br=new M,Rr=new M,Pr=new M,Or=new t;function _r(e,n,i,r,s,o,a){Cr.fromBufferAttribute(n,r),Ir.fromBufferAttribute(n,s),Mr.fromBufferAttribute(n,o);const l=function(e,t,n,i,r,s){let o;return o=s===_?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,s!==d,r),null===o?null:{distance:e.origin.distanceTo(r),point:r.clone()}}(e,Cr,Ir,Mr,Or,a);if(l){i&&(Br.fromBufferAttribute(i,r),Rr.fromBufferAttribute(i,s),Pr.fromBufferAttribute(i,o),l.uv=P.getUV(Or,Cr,Ir,Mr,Br,Rr,Pr,new M));const e={a:r,b:s,c:o,normal:new t,materialIndex:0};P.getNormal(Cr,Ir,Mr,e.normal),l.face=e,l.faceIndex=r}return l}function Lr(e,t,n,i,r){const s=3*i,o=e.index.getX(s),a=e.index.getX(s+1),l=e.index.getX(s+2),c=_r(n,e.attributes.position,e.attributes.uv,o,a,l,t);return c?(c.faceIndex=i,r&&r.push(c),c):null}function kr(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e.distance<n.near||e.distance>n.far?null:e)}function Nr(e,t,n,i){const r=e.a,s=e.b,o=e.c;let a=t,l=t+1,c=t+2;n&&(a=n.getX(t),l=n.getX(t+1),c=n.getX(t+2)),r.x=i.getX(a),r.y=i.getY(a),r.z=i.getZ(a),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function Ur(e,t,n,i,r,s,o){const a=n.index,l=n.attributes.position;for(let n=e,c=t+e;n<c;n++)if(Nr(o,3*n,a,l),o.needsUpdate=!0,i(o,n,r,s))return!0;return!1}class Fr{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}function jr(e,t){return 65535===t[e+15]}function zr(e,t){return t[e+6]}function Hr(e,t){return t[e+14]}function Gr(e){return e+8}function Vr(e,t){return t[e+6]}const Yr=new i,Wr=new t,Xr=["x","y","z"];function Qr(e,t,n,i,r){let s=2*e,o=ts,a=ns,l=is;if(jr(s,a)){!function(e,t,n,i,r,s){for(let o=i,a=i+r;o<a;o++)Lr(e,t,n,o,s)}(t,n,i,zr(e,l),Hr(s,a),r)}else{const s=Gr(e);Jr(s,o,i,Wr)&&Qr(s,t,n,i,r);const a=Vr(e,l);Jr(a,o,i,Wr)&&Qr(a,t,n,i,r)}}function Kr(e,t,n,i){let r=2*e,s=ts,o=ns,a=is;if(jr(r,o)){return function(e,t,n,i,r){let s=1/0,o=null;for(let a=i,l=i+r;a<l;a++){const i=Lr(e,t,n,a);i&&i.distance<s&&(o=i,s=i.distance)}return o}(t,n,i,zr(e,a),Hr(r,o))}{const r=function(e,t){return t[e+7]}(e,a),o=Xr[r],l=i.direction[o]>=0;let c,u;l?(c=Gr(e),u=Vr(e,a)):(c=Vr(e,a),u=Gr(e));const h=Jr(c,s,i,Wr)?Kr(c,t,n,i):null;if(h){const e=h.point[o];if(l?e<=s[u+r]:e>=s[u+r+3])return h}const d=Jr(u,s,i,Wr)?Kr(u,t,n,i):null;return h&&d?h.distance<=d.distance?h:d:h||d||null}}const Zr=function(){let e,t;const n=[],r=new Fr((()=>new i));return function(){e=r.getPrimitive(),t=r.getPrimitive(),n.push(e,t);const i=s(...arguments);r.releasePrimitive(e),r.releasePrimitive(t),n.pop(),n.pop();const o=n.length;return o>0&&(t=n[o-1],e=n[o-2]),i};function s(n,i,r,o){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;function u(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Gr(e));return zr(e,i)}function h(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Vr(e,i));return zr(e,i)+Hr(t,n)}let d=2*n,f=ts,p=ns,g=is;if(jr(d,p)){const t=zr(n,g),i=Hr(d,p);return ar(n,f,e),o(t,i,!1,c,l+n,e)}{const d=Gr(n),m=Vr(n,g);let v,y,w,b,x=d,A=m;if(a&&(w=e,b=t,ar(x,f,w),ar(A,f,b),v=a(w),y=a(b),y<v)){x=m,A=d;const e=v;v=y,y=e,w=b}w||(w=e,ar(x,f,w));const T=r(w,jr(2*x,p),v,c+1,l+x);let S;if(T===er){const e=u(x);S=o(e,h(x)-e,!0,c+1,l+x,w)}else S=T&&s(x,i,r,o,a,l,c+1);if(S)return!0;b=t,ar(A,f,b);const E=r(b,jr(2*A,p),y,c+1,l+A);let D;if(E===er){const e=u(A);D=o(e,h(A)-e,!0,c+1,l+A,b)}else D=E&&s(A,i,r,o,a,l,c+1);return!!D}}}(),qr=function(){const e=new Er,t=new Er,n=new m,i=new Dr,r=new Dr;return function s(o,a,l,c){let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,h=2*o,d=ts,f=ns,p=is;null===u&&(l.boundingBox||l.computeBoundingBox(),i.set(l.boundingBox.min,l.boundingBox.max,c),u=i);if(!jr(h,f)){const e=o+8,t=p[o+6];ar(e,d,Yr);if(u.intersectsBox(Yr)&&s(e,a,l,c,u))return!0;ar(t,d,Yr);return!!(u.intersectsBox(Yr)&&s(t,a,l,c,u))}{const i=a,s=i.index,u=i.attributes.position,g=l.index,m=l.attributes.position,v=zr(o,p),y=Hr(h,f);if(n.copy(c).invert(),l.boundsTree){ar(o,d,r),r.matrix.copy(n),r.needsUpdate=!0;const e=l.boundsTree.shapecast({intersectsBounds:e=>r.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(c),e.b.applyMatrix4(c),e.c.applyMatrix4(c),e.needsUpdate=!0;for(let n=3*v,i=3*(y+v);n<i;n+=3)if(Nr(t,n,s,u),t.needsUpdate=!0,e.intersectsTriangle(t))return!0;return!1}});return e}for(let i=3*v,r=y+3*v;i<r;i+=3){Nr(e,i,s,u),e.a.applyMatrix4(n),e.b.applyMatrix4(n),e.c.applyMatrix4(n),e.needsUpdate=!0;for(let n=0,i=g.count;n<i;n+=3)if(Nr(t,n,g,m),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}}}();function Jr(e,t,n,i){return ar(e,t,Yr),n.intersectBox(Yr,i)}const $r=[];let es,ts,ns,is;function rs(e){es&&$r.push(es),es=e,ts=new Float32Array(e),ns=new Uint16Array(e),is=new Uint32Array(e)}function ss(){es=null,ts=null,ns=null,is=null,$r.length&&rs($r.pop())}const os=Symbol("skip tree generation"),as=new i,ls=new i,cs=new m,us=new Dr,hs=new Dr,ds=new t,fs=new t,ps=new t,gs=new t,ms=new t,vs=new i,ys=new Fr((()=>new Er));class ws{static serialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),ws.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=n.getIndex();let s;return s=t.cloneBuffers?{roots:i.map((e=>e.slice())),index:r.array.slice()}:{roots:i,index:r.array},s}static deserialize(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("boolean"==typeof n)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),ws.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n={setIndex:!0,...n};const{index:i,roots:r}=e,s=new ws(t,{...n,[os]:!0});if(s._roots=r,n.setIndex){const n=t.getIndex();if(null===n){const n=new f(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return s}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if(t=Object.assign({strategy:qi,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[os]:!1},t),t.useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[os]||(this._roots=function(e,t){const n=yr(e,t);let i,r,s;const o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let e=0;e<n.length;e++){const t=n[e];let u=l(t);const h=new a(ir*u);i=new Float32Array(h),r=new Uint32Array(h),s=new Uint16Array(h),c(0,t),o.push(h)}return o;function l(e){return e.count?1:1+l(e.left)+l(e.right)}function c(e,t){const n=e/4,o=e/2,a=!!t.count,l=t.boundingData;for(let e=0;e<6;e++)i[n+e]=l[e];if(a){const i=t.offset,a=t.count;return r[n+6]=i,s[o+14]=a,s[o+15]=rr,e+ir}{const i=t.left,s=t.right,o=t.splitAxis;let a;if(a=c(e+ir,i),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[n+6]=a/4,a=c(a,s),r[n+7]=o,a}}}(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new i))),this.geometry=e}refit(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e&&Array.isArray(e)&&(e=new Set(e));const t=this.geometry,n=t.index.array,i=t.attributes.position;let r,s,o,a,l=0;const c=this._roots;for(let e=0,t=c.length;e<t;e++)r=c[e],s=new Uint32Array(r),o=new Uint16Array(r),a=new Float32Array(r),u(0,l),l+=r.byteLength;function u(t,r){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const c=2*t;if(o[c+15]===rr){const e=s[t+6];let r=1/0,l=1/0,u=1/0,h=-1/0,d=-1/0,f=-1/0;for(let t=3*e,s=3*(e+o[c+14]);t<s;t++){const e=n[t],s=i.getX(e),o=i.getY(e),a=i.getZ(e);s<r&&(r=s),s>h&&(h=s),o<l&&(l=o),o>d&&(d=o),a<u&&(u=a),a>f&&(f=a)}return(a[t+0]!==r||a[t+1]!==l||a[t+2]!==u||a[t+3]!==h||a[t+4]!==d||a[t+5]!==f)&&(a[t+0]=r,a[t+1]=l,a[t+2]=u,a[t+3]=h,a[t+4]=d,a[t+5]=f,!0)}{const n=t+8,i=s[t+6],o=n+r,c=i+r;let h=l,d=!1,f=!1;e?h||(d=e.has(o),f=e.has(c),h=!d&&!f):(d=!0,f=!0);const p=h||f;let g=!1;(h||d)&&(g=u(n,r,h));let m=!1;p&&(m=u(i,r,h));const v=g||m;if(v)for(let e=0;e<3;e++){const r=n+e,s=i+e,o=a[r],l=a[r+3],c=a[s],u=a[s+3];a[t+e]=o<c?o:c,a[t+e+3]=l>u?l:u}return v}}}traverse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function t(s){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const a=2*s,l=r[a+15]===rr;if(l){const t=i[s+6],c=r[a+14];e(o,l,new Float32Array(n,4*s,6),t,c)}else{const r=s+ir/4,a=i[s+6],c=i[s+7];e(o,l,new Float32Array(n,4*s,6),c)||(t(r,o+1),t(a,o+1))}}(0)}raycast(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=[],s=t.isMaterial,o=Array.isArray(t),a=i.groups,l=s?t.side:t;for(let s=0,c=n.length;s<c;s++){const c=o?t[a[s].materialIndex].side:l,u=r.length;if(rs(n[s]),Qr(0,i,c,e,r),ss(),o){const e=a[s].materialIndex;for(let t=u,n=r.length;t<n;t++)r[t].face.materialIndex=e}}return r}raycastFirst(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=t.isMaterial,s=Array.isArray(t);let o=null;const a=i.groups,l=r?t.side:t;for(let r=0,c=n.length;r<c;r++){const c=s?t[a[r].materialIndex].side:l;rs(n[r]);const u=Kr(0,i,c,e);ss(),null!=u&&(null==o||u.distance<o.distance)&&(o=u,s&&(u.face.materialIndex=a[r].materialIndex))}return o}intersectsGeometry(e,t){const n=this.geometry;let i=!1;for(const r of this._roots)if(rs(r),i=qr(0,n,e,t),ss(),i)break;return i}shapecast(e,t,n){const i=this.geometry;if(e instanceof Function){if(t){const e=t;t=(t,n,i,r)=>{const s=3*n;return e(t,s,s+1,s+2,i,r)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}const r=ys.getPrimitive();let{boundsTraverseOrder:s,intersectsBounds:o,intersectsRange:a,intersectsTriangle:l}=e;if(a&&l){const e=a;a=(t,n,s,o,a)=>!!e(t,n,s,o,a)||Ur(t,n,i,l,s,o,r)}else a||(a=l?(e,t,n,s)=>Ur(e,t,i,l,n,s,r):(e,t,n)=>n);let c=!1,u=0;for(const e of this._roots){if(rs(e),c=Zr(0,i,o,a,s,u),ss(),c)break;u+=e.byteLength}return ys.releasePrimitive(r),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const s=this.geometry.index,o=this.geometry.attributes.position,a=e.geometry.index,l=e.geometry.attributes.position;cs.copy(t).invert();const c=ys.getPrimitive(),u=ys.getPrimitive();if(r){function d(e,n,i,h,d,f,p,g){for(let m=i,v=i+h;m<v;m++){Nr(u,3*m,a,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(Nr(c,3*t,s,o),c.needsUpdate=!0,r(c,u,t,m,d,f,p,g))return!0}return!1}if(i){const f=i;i=function(e,t,n,i,r,s,o,a){return!!f(e,t,n,i,r,s,o,a)||d(e,t,n,i,r,s,o,a)}}else i=d}e.getBoundingBox(ls),ls.applyMatrix4(t);const h=this.shapecast({intersectsBounds:e=>ls.intersectsBox(e),intersectsRange:(t,n,r,s,o,a)=>(as.copy(a),as.applyMatrix4(cs),e.shapecast({intersectsBounds:e=>as.intersectsBox(e),intersectsRange:(e,r,a,l,c)=>i(t,n,e,r,s,o,l,c)}))});return ys.releasePrimitive(c),ys.releasePrimitive(u),h}intersectsBox(e,t){return us.set(e.min,e.max,t),us.needsUpdate=!0,this.shapecast({intersectsBounds:e=>us.intersectsBox(e),intersectsTriangle:e=>us.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1/0;e.boundingBox||e.computeBoundingBox(),us.set(e.boundingBox.min,e.boundingBox.max,t),us.needsUpdate=!0;const o=this.geometry,a=o.attributes.position,l=o.index,c=e.attributes.position,u=e.index,h=ys.getPrimitive(),d=ys.getPrimitive();let f=fs,p=ps,g=null,m=null;i&&(g=gs,m=ms);let v=1/0,y=null,w=null;return cs.copy(t).invert(),hs.matrix.copy(cs),this.shapecast({boundsTraverseOrder:e=>us.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s&&(t&&(hs.min.copy(e.min),hs.max.copy(e.max),hs.needsUpdate=!0),!0),intersectsRange:(n,i)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>hs.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s,intersectsRange:(e,s)=>{for(let o=3*e,b=3*(e+s);o<b;o+=3){Nr(d,o,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let e=3*n,t=3*(n+i);e<t;e+=3){Nr(h,e,l,a),h.needsUpdate=!0;const t=h.distanceToTriangle(d,f,g);if(t<v&&(p.copy(f),m&&m.copy(g),v=t,y=e/3,w=o/3),t<r)return!0}}}});for(let e=0,s=u?u.count:c.count;e<s;e+=3){Nr(d,e,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let t=3*n,s=3*(n+i);t<s;t+=3){Nr(h,t,l,a),h.needsUpdate=!0;const n=h.distanceToTriangle(d,f,g);if(n<v&&(p.copy(f),m&&m.copy(g),v=n,y=t/3,w=e/3),n<r)return!0}}}}),ys.releasePrimitive(h),ys.releasePrimitive(d),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=y,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(cs),p.applyMatrix4(cs),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;const r=n*n,s=i*i;let o=1/0,a=null;if(this.shapecast({boundsTraverseOrder:t=>(ds.copy(e).clamp(t.min,t.max),ds.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n<o&&n<s,intersectsTriangle:(t,n)=>{t.closestPointToPoint(e,ds);const i=e.distanceToSquared(ds);return i<o&&(fs.copy(ds),o=i,a=n),i<r}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(fs):t.point=fs.clone(),t.distance=l,t.faceIndex=a,t}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{ar(0,new Float32Array(t),vs),e.union(vs)})),e}}const bs=new N,xs=new m,As=k.prototype.raycast;class Ts extends v{constructor(){super();const e=new U;e.deleteAttribute("uv");const t=new F({side:_}),n=new F,i=new j(16777215,5,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new k(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new k(e,n);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);const o=new k(e,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const a=new k(e,n);a.position.set(6.167,.857,7.803),a.rotation.set(0,.561,0),a.scale.set(3.927,6.285,3.687),this.add(a);const l=new k(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const c=new k(e,n);c.position.set(2.291,-.756,-2.621),c.rotation.set(0,-.286,0),c.scale.set(1.546,1.552,1.496),this.add(c);const u=new k(e,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const h=new k(e,Ss(50));h.position.set(-16.116,14.37,8.208),h.scale.set(.1,2.428,2.739),this.add(h);const d=new k(e,Ss(50));d.position.set(-16.109,18.021,-8.207),d.scale.set(.1,2.425,2.751),this.add(d);const f=new k(e,Ss(17));f.position.set(14.904,12.198,-1.832),f.scale.set(.15,4.265,6.331),this.add(f);const p=new k(e,Ss(43));p.position.set(-.462,8.89,14.52),p.scale.set(4.38,5.441,.088),this.add(p);const g=new k(e,Ss(20));g.position.set(3.235,11.486,-12.541),g.scale.set(2.5,2,.1),this.add(g);const m=new k(e,Ss(100));m.position.set(0,20,0),m.scale.set(1,.1,1),this.add(m)}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function Ss(e){const t=new z;return t.color.setScalar(e),t}class Es extends H{constructor(e){super(e),this.type=G}parse(e){const t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,r=-1,s=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(r=a.indexOf("\n"))&&s<t&&i<e.byteLength;)o+=a,s+=a.length,i+=128,a+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));return-1<r&&(!1!==n&&(e.pos+=s+r+1),o+a.slice(0,r))},i=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=e[t+0]*s,n[i+1]=e[t+1]*s,n[i+2]=e[t+2]*s,n[i+3]=1},r=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=Y.toHalfFloat(Math.min(e[t+0]*s,65504)),n[i+1]=Y.toHalfFloat(Math.min(e[t+1]*s,65504)),n[i+2]=Y.toHalfFloat(Math.min(e[t+2]*s,65504)),n[i+3]=Y.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;const o=function(e){const i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,a={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(a.valid|=1,a.programtype=c[1],a.string+=l+"\n";l=n(e),!1!==l;)if(a.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(a.gamma=parseFloat(c[1])),(c=l.match(r))&&(a.exposure=parseFloat(c[1])),(c=l.match(s))&&(a.valid|=2,a.format=c[1]),(c=l.match(o))&&(a.valid|=4,a.height=parseInt(c[1],10),a.width=parseInt(c[2],10)),2&a.valid&&4&a.valid)break}else a.comments+=l+"\n";return 2&a.valid?4&a.valid?a:t(3,"missing image size specifier"):t(3,"missing format specifier")}(s);if(-1!==o){const e=o.width,n=o.height,a=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const s=new Uint8Array(4*n*i);if(!s.length)return t(4,"unable to allocate buffer space");let o=0,a=0;const l=4*r,c=new Uint8Array(4),u=new Uint8Array(l);let h=i;for(;h>0&&a<e.byteLength;){if(a+4>e.byteLength)return t(1);if(c[0]=e[a++],c[1]=e[a++],c[2]=e[a++],c[3]=e[a++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=r)return t(3,"bad rgbe scanline format");let n,i=0;for(;i<l&&a<e.byteLength;){n=e[a++];const r=n>128;if(r&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(r){const t=e[a++];for(let e=0;e<n;e++)u[i++]=t}else u.set(e.subarray(a,a+n),i),i+=n,a+=n}const d=r;for(let e=0;e<d;e++){let t=0;s[o]=u[e+t],t+=r,s[o+1]=u[e+t],t+=r,s[o+2]=u[e+t],t+=r,s[o+3]=u[e+t],o+=4}h--}return s}(s.subarray(s.pos),e,n);if(-1!==a){let t,s,l;switch(this.type){case V:l=a.length/4;const e=new Float32Array(4*l);for(let t=0;t<l;t++)i(a,4*t,e,4*t);t=e,s=V;break;case G:l=a.length/4;const n=new Uint16Array(4*l);for(let e=0;e<l;e++)r(a,4*e,n,4*e);t=n,s=G;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:o.string,gamma:o.gamma,exposure:o.exposure,type:s}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,i){return super.load(e,(function(e,n){switch(e.type){case V:case G:e.encoding=u,e.minFilter=A,e.magFilter=A,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,i)}}var Ds=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i<t.children.length;i++)t.children[i].style.display=i===n?"block":"none";e=n}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(n){n.preventDefault(),i(++e%t.children.length)}),!1);var r=(performance||Date).now(),s=r,o=0,a=n(new Ds.Panel("FPS","#0ff","#002")),l=n(new Ds.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Ds.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:t,addPanel:n,showPanel:i,begin:function(){r=(performance||Date).now()},end:function(){o++;var e=(performance||Date).now();if(l.update(e-r,200),e>=s+1e3&&(a.update(1e3*o/(e-s),100),s=e,o=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};Ds.Panel=function(e,t,n){var i=1/0,r=0,s=Math.round,o=s(window.devicePixelRatio||1),a=80*o,l=48*o,c=3*o,u=2*o,h=3*o,d=15*o,f=74*o,p=30*o,g=document.createElement("canvas");g.width=a,g.height=l,g.style.cssText="width:80px;height:48px";var m=g.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,a,l),m.fillStyle=t,m.fillText(e,c,u),m.fillRect(h,d,f,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h,d,f,p),{dom:g,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,a,d),m.fillStyle=t,m.fillText(s(l)+" "+e+" ("+s(i)+"-"+s(r)+")",c,u),m.drawImage(g,h+o,d,f-o,p,h,d,f-o,p),m.fillRect(h+f-o,d,o,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h+f-o,d,o,s((1-l/v)*p))}}};var Cs=Ds;class Is extends k{constructor(){const e=Is.SkyShader,t=new W({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:X.clone(e.uniforms),side:_,depthWrite:!1});super(new U(1,1,1),t),this.isSky=!0}}Is.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new t},up:{value:new t(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\n\t\t}"};var Ms="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Bs(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),n}var Rs={},Ps={},Os=Bs(Xn),_s={},Ls={},ks={},Ns={};Object.defineProperty(Ns,"__esModule",{value:!0});var Us=function(){function e(t,n){if(void 0===n&&(n=null),this.nonEmpty=!1,t||n){if(!t)throw new Error("Parameter head cannot be null.");this.head=t,this.tail=n||e.NIL,this.nonEmpty=!0}else{if(e.NIL)throw new Error("Parameters head and tail are null. Use the NIL element instead.");this.nonEmpty=!1}}return Object.defineProperty(e.prototype,"length",{get:function(){if(!this.nonEmpty)return 0;if(this.tail===e.NIL)return 1;for(var t=0,n=this;n.nonEmpty;)++t,n=n.tail;return t},enumerable:!0,configurable:!0}),e.prototype.prepend=function(t){return new e(t,this)},e.prototype.append=function(t){if(!t)return this;if(!this.nonEmpty)return new e(t);if(this.tail===e.NIL)return new e(t).prepend(this.head);for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;)i=i.tail=new e(r.head),r=r.tail;return i.tail=new e(t),n},e.prototype.insertWithPriority=function(t){if(!this.nonEmpty)return new e(t);var n=t.priority;if(n>this.head.priority)return this.prepend(t);for(var i=new e(this.head),r=i,s=this.tail;s.nonEmpty;){if(n>s.head.priority)return r.tail=s.prepend(t),i;r=r.tail=new e(s.head),s=s.tail}return r.tail=new e(t),i},e.prototype.filterNot=function(t){if(!this.nonEmpty||null==t)return this;if(t===this.head.listener)return this.tail;for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;){if(r.head.listener===t)return i.tail=r.tail,n;i=i.tail=new e(r.head),r=r.tail}return this},e.prototype.contains=function(e){if(!this.nonEmpty)return!1;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return!0;t=t.tail}return!1},e.prototype.find=function(e){if(!this.nonEmpty)return null;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return t.head;t=t.tail}return null},e.prototype.toString=function(){for(var e="",t=this;t.nonEmpty;)e+=t.head+" -> ",t=t.tail;return"[List "+(e+="NIL")+"]"},e.NIL=new e(null,null),e}();Ns.SlotList=Us;var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0});var js=function(){function e(e,t,n,i){void 0===n&&(n=!1),void 0===i&&(i=0),this._enabled=!0,this._once=!1,this._priority=0,this._listener=e,this._once=n,this._signal=t,this._priority=i,this.verifyListener(e)}return e.prototype.execute0=function(){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,this._params):this._listener())},e.prototype.execute1=function(e){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,[e].concat(this._params)):this._listener(e))},e.prototype.execute=function(e){if(this._enabled){this._once&&this.remove(),this._params&&this._params.length&&(e=e.concat(this._params));var t=e.length;0===t?this._listener():1===t?this._listener(e[0]):2===t?this._listener(e[0],e[1]):3===t?this._listener(e[0],e[1],e[2]):this._listener.apply(null,e)}},Object.defineProperty(e.prototype,"listener",{get:function(){return this._listener},set:function(e){if(null==e)throw new Error("Given listener is null.\nDid you want to set enabled to false instead?");this.verifyListener(e),this._listener=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"once",{get:function(){return this._once},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"priority",{get:function(){return this._priority},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"[Slot listener: "+this._listener+", once: "+this._once+", priority: "+this._priority+", enabled: "+this._enabled+"]"},Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"params",{get:function(){return this._params},set:function(e){this._params=e},enumerable:!0,configurable:!0}),e.prototype.remove=function(){this._signal.remove(this._listener)},e.prototype.verifyListener=function(e){if(null==e)throw new Error("Given listener is null.");if(null==this._signal)throw new Error("Internal signal reference has not been set yet.")},e}();Fs.Slot=js,Object.defineProperty(ks,"__esModule",{value:!0});var zs=Ns,Hs=Fs,Gs=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.slots=zs.SlotList.NIL,this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if(!(this._valueClasses[t]instanceof Object))throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+">."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slots.length},enumerable:!0,configurable:!0}),e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){var t=this.slots.find(e);return t?(this.slots=this.slots.filterNot(e),t):null},e.prototype.removeAll=function(){this.slots=zs.SlotList.NIL},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=this.slots;if(s.nonEmpty)for(;s.nonEmpty;)s.head.execute(e),s=s.tail},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.registrationPossible(e,t)){var n=new Hs.Slot(e,this,t);return this.slots=this.slots.prepend(n),n}return this.slots.find(e)},e.prototype.registrationPossible=function(e,t){if(!this.slots.nonEmpty)return!0;var n=this.slots.find(e);if(!n)return!0;if(n.once!==t)throw new Error("You cannot addOnce() then add() the same listener without removing the relationship first.");return!1},e}();ks.OnceSignal=Gs,Object.defineProperty(Ls,"__esModule",{value:!0});var Vs=Os,Ys=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Vs.__extends(t,e),t.prototype.add=function(e){return this.registerListener(e)},t}(ks.OnceSignal);Ls.Signal=Ys,Object.defineProperty(_s,"__esModule",{value:!0});var Ws=Os,Xs=Fs,Qs=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ws.__extends(t,e),t.prototype.addWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!1,t)},t.prototype.addOnceWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!0,t)},t.prototype.registerListener=function(e,t){return void 0===t&&(t=!1),this.registerListenerWithPriority(e,t)},t.prototype.registerListenerWithPriority=function(e,t,n){if(void 0===n&&(n=0),this.registrationPossible(e,t)){var i=new Xs.Slot(e,this,t,n);return this.slots=this.slots.insertWithPriority(i),i}return this.slots.find(e)},t}(Ls.Signal);_s.PrioritySignal=Qs,Object.defineProperty(Ps,"__esModule",{value:!0});var Ks=Os,Zs=function(e){function t(t){void 0===t&&(t=null);for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var r=this;return n=1===n.length&&n[0]instanceof Array?n[0]:n,(r=e.call(this,n)||this)._target=t,r}return Ks.__extends(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){e!==this._target&&(this.removeAll(),this._target=e)},enumerable:!0,configurable:!0}),t.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(null!==e[r]&&e[r].constructor!==this._valueClasses[r])throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=e[0];s&&(s.target&&(s=s.clone(),e[0]=s),s.target=this.target,s.currentTarget=this.target,s.signal=this);for(var o=this.slots;o.nonEmpty;)o.head.execute(e),o=o.tail;if(s&&s.bubbles)for(var a=this.target;a&&a.hasOwnProperty("parent")&&(null===(a=a.parent).onEventBubbled||(s.currentTarget=a,a.onEventBubbled(s))););},t}(_s.PrioritySignal);Ps.DeluxeSignal=Zs;var qs={};Object.defineProperty(qs,"__esModule",{value:!0});var Js=function(){function e(e){void 0===e&&(e=!1),this._bubbles=e}return Object.defineProperty(e.prototype,"signal",{get:function(){return this._signal},set:function(e){this._signal=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(e){this._target=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTarget",{get:function(){return this._currentTarget},set:function(e){this._currentTarget=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bubbles",{get:function(){return this._bubbles},set:function(e){this._bubbles=e},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._bubbles)},e}();qs.GenericEvent=Js;var $s={};Object.defineProperty($s,"__esModule",{value:!0}),$s.IOnceSignal=Symbol("IOnceSignal");var eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.IPrioritySignal=Symbol("IPrioritySignal");var to={};Object.defineProperty(to,"__esModule",{value:!0}),to.ISignal=Symbol("ISignal");var no={};Object.defineProperty(no,"__esModule",{value:!0}),no.ISlot=Symbol("ISlot");var io={};Object.defineProperty(io,"__esModule",{value:!0});var ro=Fs,so=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if("function"!=typeof this._valueClasses[t])throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+"'>."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slot?1:0},enumerable:!0,configurable:!0}),e.prototype.add=function(e){return this.registerListener(e)},e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){if(this.slot&&this.slot.listener===e){var t=this.slot;return this.slot=null,t}return null},e.prototype.removeAll=function(){this.slot&&this.slot.remove()},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");this.slot&&this.slot.execute(e)},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.slot)throw new Error("You cannot add or addOnce with a listener already added, remove the current listener first.");return this.slot=new ro.Slot(e,this,t)},e}();io.MonoSignal=so;var oo={};Object.defineProperty(oo,"__esModule",{value:!0});var ao=Os,lo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ao.__extends(t,e),t.prototype.addOnce=function(t){var n=e.prototype.addOnce.call(this,t);return this.isDispatched&&(n.execute(this.valueObjects),n.remove()),n},t.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(this.isDispatched)throw new Error("You cannot dispatch() a Promise more than once");this.isDispatched=!0,this.valueObjects=t,e.prototype.dispatch.apply(this,t)},t}(ks.OnceSignal);oo.Promise=lo,Object.defineProperty(Rs,"__esModule",{value:!0});var co=Ps;Rs.DeluxeSignal=co.DeluxeSignal;var uo=qs;Rs.GenericEvent=uo.GenericEvent;var ho=$s;Rs.IOnceSignal=ho.IOnceSignal;var fo=eo;Rs.IPrioritySignal=fo.IPrioritySignal;var po=to;Rs.ISignal=po.ISignal;var go=no;Rs.ISlot=go.ISlot;var mo=io;Rs.MonoSignal=mo.MonoSignal;var vo=ks;Rs.OnceSignal=vo.OnceSignal;var yo=_s;Rs.PrioritySignal=yo.PrioritySignal;var wo=oo;Rs.Promise=wo.Promise;var bo=Ls,xo=Rs.Signal=bo.Signal,Ao=Fs;Rs.Slot=Ao.Slot;var To=Ns;Rs.SlotList=To.SlotList;const So=new v;So.name="Scene";class Eo{constructor(e,t){this.signals=e,this.viewportState=t,this.scene=So.clone(),this.scene.castShadow=!0,this.scene.receiveShadow=!0,this.selectedObjects={edge:[],stroke:[],opacity:[],highlight:[],emissive:[]},this.intersectsList={meshOfModelList:[],poiIconList:[],otherObjList:[],getAll:function(){return[...this.meshOfModelList,...this.poiIconList,...this.otherObjList]}}}addObject(e,t){if(this.viewportState.isDisposed)return this.removeObject(e),void yn("Scene is disposed");t?t.add(e):this.scene.add(e),this._triggerObjectAdded(e),this.signals.objectAdded.dispatch(e)}removeObject(e){function t(e){var t;e.map&&((t=e.map)&&t.isTexture&&t.dispose()),e.dispose()}e.traverse((e=>{if("Mesh"===e.type){const n=e;n.geometry.dispose(),On(n.material,t)}e instanceof Fu&&e.element.remove();const{meshOfModelList:n,poiIconList:i,otherObjList:r}=this.intersectsList,s=n.findIndex((t=>t.uuid===e.uuid)),o=i.findIndex((t=>t.uuid===e.uuid)),a=r.findIndex((t=>t.uuid===e.uuid));s>-1&&this.intersectsList.meshOfModelList.splice(s,1),o>-1&&this.intersectsList.poiIconList.splice(o,1),a>-1&&this.intersectsList.otherObjList.splice(a,1)})),e.removeFromParent(),this.signals.objectRemoved.dispatch(e)}openSceneFog(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:t=13426943,near:n=500,far:i=5e4}=e;this.scene.fog=new Q(t,n,i),this.signals.sceneChanged.dispatch()}closeSceneFog(){this.scene.fog=null,this.signals.sceneChanged.dispatch()}edgeShow(e,t){const n=[],i=e=>{-1===this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid))&&n.push(e)};return ji(e)?e.forEach((e=>i(e))):zi(e)&&i(e),this.selectedObjects.edge=[...this.selectedObjects.edge,...n],this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge,options:t}),Promise.resolve()}unEdgeShow(e){e||(e=[...this.selectedObjects.edge]);const t=e=>{const t=this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.edge.splice(t,1),this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge})),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}strokeShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{isOpacityShow:n=!0,color:i=4647927,opacity:r=.2,edgeColor:s=61183,edgeOpacity:o=1}=t,a=e=>{if(-1!==this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid)))return Promise.resolve();if(e.userData.strokeGroup)return Promise.resolve();const t=new Nu({id:e.uuid});return e.traverse((n=>{if(n instanceof k){const i=new K(n.geometry,89),r=new Z(i,new q({color:s,transparent:!0,opacity:o}));Dn(r,n),e.attach(r),t.add(r)}})),e.userData.strokeGroup=t,this.addObject(t,e),this.selectedObjects.stroke.push(e),Promise.resolve()};return n&&this.opacityShow(e,{color:i,opacity:r}),ji(e)?Promise.all(e.map((e=>a(e)))):zi(e)?a(e):Promise.resolve()}unStrokeShow(e){e||(e=[...this.selectedObjects.stroke]);const t=e=>{if(!e.userData.strokeGroup)return Promise.resolve();this.removeObject(e.userData.strokeGroup),Reflect.deleteProperty(e.userData,"strokeGroup");const t=this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.stroke.splice(t,1),this.signals.geometryChanged.dispatch(),this.unOpacityShow(e)),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}opacityShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="#fff",opacity:i=.8}=t;function r(e){return Reflect.construct(e.constructor,[{transparent:!0,depthWrite:!1,side:e.side,color:n,opacity:i}])}const s=e=>(-1!==this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unOpacityShow(e){e||(e=[...this.selectedObjects.opacity]);const t=e=>new Promise((t=>{const n=this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.opacity.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}highlightShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=1}=t;function r(e){e instanceof F&&(e.color=new a(n),e.opacity=i,e.transparent=i<1)}const s=e=>(-1!==this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unHighlightShow(e){e||(e=[...this.selectedObjects.highlight]);const t=e=>new Promise((t=>{const n=this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.highlight.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}emissiveShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=.3,maxOpacity:r=1,minOpacity:s=0,duration:o=1e3}=t;function a(e){e instanceof F&&(e.emissive.set(n),e.emissiveIntensity=i,0!==o&&Ki({emissiveIntensity:r},{emissiveIntensity:s},{duration:o,repeat:!0},(t=>e.emissiveIntensity=t.emissiveIntensity),(t=>e.userData.animation=t)))}const l=e=>(-1!==this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,a)}})),this.selectedObjects.emissive.push(e),this.signals.materialChanged.dispatch()),Promise.resolve());return ji(e)?Promise.all(e.map((e=>l(e)))):zi(e)?l(e):Promise.resolve()}unEmissiveShow(e){function t(e){e.userData.animation&&pn.remove(e.userData.animation)}e||(e=[...this.selectedObjects.emissive]);const n=e=>new Promise((n=>{const i=this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid));-1===i&&n(),this.selectedObjects.emissive.splice(i,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;On(e.material,t),Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),n()}));return ji(e)?Promise.all(e.map((e=>n(e)))):zi(e)?n(e):Promise.resolve()}_triggerObjectAdded(e){if(e instanceof ku)if("Model"===e.stype)e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.meshOfModelList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.meshOfModelList.push(e)}}));else if("Poi"===e.stype){const t=this.intersectsList.poiIconList.findIndex((t=>t.uuid===e.icon.uuid));-1===t&&this.intersectsList.poiIconList.push(e.icon)}else"Group"===e.stype?e.children.forEach((e=>this._triggerObjectAdded(e))):e.isObject3D&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}));else e.isObject3D&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}))}}class Do extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Do&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let Co,Io;const Mo=new t,Bo=new m,Ro=new m,Po={objects:new WeakMap};function Oo(){const e=new t,n=new t;return function(t,i){return e.setFromMatrixPosition(t.matrixWorld),n.setFromMatrixPosition(i.matrixWorld),e.distanceToSquared(n)}}function _o(e){const t=function(e){const t=[];return e.traverse((function(e){e instanceof Do&&t.push(e)})),t}(e).sort((function(e,t){return Po.objects.get(e).distanceToCameraSquared-Po.objects.get(t).distanceToCameraSquared})),n=t.length;for(let e=0,i=t.length;e<i;e++)t[e].element.style.zIndex=""+(n-e)}class Lo{constructor(e){e||(e=document.createElement("div")),e.style.overflow="hidden",this.domElement=e}setSize(e,t){Co=e/2,Io=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"}renderObject(e,t,n){if(e instanceof Do){Mo.setFromMatrixPosition(e.matrixWorld),Mo.applyMatrix4(Ro);const t=e.element,i="translate(-50%,-100%) translate("+(Mo.x*Co+Co)+"px,"+(-Mo.y*Io+Io)+"px)";t.style.transform=i,t.style.display=Cn(e)&&Mo.z>=-1&&Mo.z<=1?"block":"none";const r={distanceToCameraSquared:Oo()(n,e)};Po.objects.set(e,r),t.parentNode!==this.domElement&&this.domElement.appendChild(t)}for(let i=0,r=e.children.length;i<r;i++)this.renderObject(e.children[i],t,n)}render(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Bo.copy(t.matrixWorldInverse),Ro.multiplyMatrices(t.projectionMatrix,Bo),this.renderObject(e,e,t),_o(e)}}class ko extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof ko&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let No,Uo,Fo,jo;function zo(e){return Math.abs(e)<1e-10?0:e}function Ho(e){const t=e.elements;return"matrix3d("+zo(t[0])+","+zo(-t[1])+","+zo(t[2])+","+zo(t[3])+","+zo(t[4])+","+zo(-t[5])+","+zo(t[6])+","+zo(t[7])+","+zo(t[8])+","+zo(-t[9])+","+zo(t[10])+","+zo(t[11])+","+zo(t[12])+","+zo(-t[13])+","+zo(t[14])+","+zo(t[15])+")"}class Go{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){No=e/2,Uo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,t,n,i){if(e instanceof ko){const t=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+zo(n[0])+","+zo(n[1])+","+zo(n[2])+","+zo(n[3])+","+zo(-n[4])+","+zo(-n[5])+","+zo(-n[6])+","+zo(-n[7])+","+zo(n[8])+","+zo(n[9])+","+zo(n[10])+","+zo(n[11])+","+zo(n[12])+","+zo(n[13])+","+zo(n[14])+","+zo(n[15])+")"}(e.matrixWorld),n=e.element;n.style.transform=t,n.style.display=Cn(e)?"block":"none";const i={style:t,distanceToCameraSquared:0};this.cache.objects.set(e,i),n.parentNode!==this.cameraElement&&this.cameraElement.appendChild(n)}for(let r=0,s=e.children.length;r<s;r++)this.renderObject(e.children[r],t,n,i)}render(e,t){const n=t.projectionMatrix.elements[5]*Uo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+zo(-(t.right+t.left)/2)+"px)"+Ho(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Ho(t.matrixWorldInverse);const r=i+"translate("+No+"px,"+Uo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Vo extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Vo&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}function Yo(e){return Math.abs(e)<1e-10?0:e}function Wo(e){const t=e.elements;return"matrix3d("+Yo(t[0])+","+Yo(-t[1])+","+Yo(t[2])+","+Yo(t[3])+","+Yo(t[4])+","+Yo(-t[5])+","+Yo(t[6])+","+Yo(t[7])+","+Yo(t[8])+","+Yo(-t[9])+","+Yo(t[10])+","+Yo(t[11])+","+Yo(t[12])+","+Yo(-t[13])+","+Yo(t[14])+","+Yo(t[15])+")"}class Xo{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){Fo=e/2,jo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,n,i,r){if(e instanceof Vo){const n=i.quaternion.clone();n.x=-i.quaternion.x,n.z=-i.quaternion.z;const r=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+Yo(n[0])+","+Yo(-n[1])+","+Yo(n[2])+","+Yo(n[3])+","+Yo(n[4])+","+Yo(-n[5])+","+Yo(n[6])+","+Yo(n[7])+","+Yo(n[8])+","+Yo(-n[9])+","+Yo(n[10])+","+Yo(n[11])+","+Yo(n[12])+","+Yo(n[13])+","+Yo(n[14])+","+Yo(n[15])+")"}((new m).compose(e.parent.getWorldPosition(new t(0,0,0)),n,e.parent.scale)),s=e.element;s.style.transform=r,s.style.display=Cn(e)?"block":"none";const o={style:r,distanceToCameraSquared:0};this.cache.objects.set(e,o),s.parentNode!==this.cameraElement&&this.cameraElement.appendChild(s)}for(let t=0,s=e.children.length;t<s;t++)this.renderObject(e.children[t],n,i,r)}render(e,t){const n=t.projectionMatrix.elements[5]*jo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+Yo(-(t.right+t.left)/2)+"px)"+Wo(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Wo(t.matrixWorldInverse);const r=i+"translate("+Fo+"px,"+jo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Qo{constructor(e){this.options=e,this.internalOptions={enableRenderCss2D:!1,enableRenderCss2DHalf:!1,enableRenderCss3D:!1},this.container=this._initContainer(),this.renderer=this._initRenderer(),this.rendererCSS2D=this._initRenderCSS2D(),this.rendererCSS3D=this._initRenderCSS3D(),this.rendererCSS2DHalf=this._initRenderCSS2DHalf(),this.interactiveContainer=this._initInteractiveContainer()}setInternalState(e,t){this.internalOptions[e]=t}getWidth(){return this.renderer.domElement.width}getHeight(){return this.renderer.domElement.height}getMouseRelativeConRatio(e){const t=this.container.getBoundingClientRect();return[(e.offsetX-t.left)/t.width,(e.offsetY-t.top)/t.height]}getMousePoint(e){const t=new M(0,0);return t.fromArray(this.getMouseRelativeConRatio(e)),t}_initContainer(){const e=document.createElement("div");return e.style.position="relative",e.style.width="100%",e.style.height="100%",e}_initRenderer(){const{background:e={},logarithmicDepthBuffer:t}=this.options,{color:n,alpha:i}=e,r=new te({alpha:i,logarithmicDepthBuffer:t,preserveDrawingBuffer:!0,antialias:!1,stencil:!1,depth:!1,powerPreference:"high-performance"}),s=i?0:1,{offsetWidth:o,offsetHeight:a}=this.container;return r.setSize(o,a),r.setClearColor(n||0,s),r.setPixelRatio(self.devicePixelRatio),r.localClippingEnabled=!0,r.sortObjects=!0,r.shadowMap.enabled=!0,r.shadowMap.type=ne,this.container.appendChild(r.domElement),r}_initRenderCSS2D(){const e=new Lo;return e.domElement.id="ssp_view_2DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS3D(){const e=new Go;return e.domElement.id="ssp_view_3DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS2DHalf(){const e=new Xo(this.rendererCSS3D.domElement,this.rendererCSS3D.cameraElement);return e.setSize(this.container.offsetWidth,this.container.offsetHeight),e}_initInteractiveContainer(){return this.rendererCSS3D.domElement}}const Ko=new m,Zo=(e,t)=>{const i=Ko.clone(),r=Ko.clone(),s=Ko.clone();i.makeRotationY(e),r.makeRotationX(t);const o=new n;return s.multiplyMatrices(i,r),o.setFromRotationMatrix(s),o},qo=Zo(-Math.PI/2,-Math.PI/4),Jo=Zo(Math.PI/2,-Math.PI/4),$o=Zo(-Math.PI/4,-Math.PI/4),ea=Zo(Math.PI/4,-Math.PI/4),ta=Zo(1.25*Math.PI,-Math.PI/4),na=Zo(.75*Math.PI,-Math.PI/4),ia={LEFT:new n(0,-Math.PI/2,0),RIGHT:new n(0,Math.PI/2,0),FRONT:new n(0,0,0),BACK:new n(0,Math.PI,0),TOP:new n(-Math.PI/2,0,0),BOTTOM:new n(Math.PI/2,0,0),FRONTTOP:new n(-Math.PI/4,0,0),BACKTOP:new n(Math.PI/4,Math.PI,0),LEFTTOP:new n(qo.x,qo.y,qo.z),RIGHTTOP:new n(Jo.x,Jo.y,Jo.z),LEFTFRONTTOP:new n($o.x,$o.y,$o.z),RIGHTFRONTTOP:new n(ea.x,ea.y,ea.z),LEFTBACKTOP:new n(ta.x,ta.y,ta.z),RIGHTBACKTOP:new n(na.x,na.y,na.z)},ra=e=>Fi(e)?e:e.includes("%")?.01*Number(e.split("%")[0]):isNaN(+e)?0:Number(e),sa=new t,oa=new n,aa=new $(50,1,.1,5e5);aa.position.set(500,1e3,500),aa.lookAt(sa.set(0,0,0)),aa.name="Camera";class la{constructor(e){this.viewport=e,this.mainCamera=aa.clone(),this.mainCamera.name="freeCamera",this.currentCamera=this.mainCamera,this.cameras={}}createCamera(e){const t=aa.clone();return t.name=e,this.cameras[e]=t,t}removeCamera(e){return"fullFreeCamera"!==e&&(delete this.cameras[e],!0)}setCurrentCamera(e){this.currentCamera=this.viewport.camera=e,this.viewport.signals.cameraObjectChange.dispatch()}getMainCamera(){return this.mainCamera}getCameraViewpoint(){if("free"===this.viewport.controls.options.type)return{position:this.currentCamera.position.clone(),rotation:{x:this.currentCamera.rotation.x,y:this.currentCamera.rotation.y,z:this.currentCamera.rotation.z}};{const e=this.viewport.controls.currentControls;return{position:this.currentCamera.position.clone(),target:e.target.clone()}}}setCameraViewpoint(e){if("free"===this.viewport.controls.options.type&&zi(e)){const{position:t,rotation:n}=e;this.currentCamera.position.set(t.x,t.y,t.z),this.currentCamera.rotation.set(n.x,n.y,n.z)}else if(zi(e)){const{position:t,target:n}=e,i=this.viewport.controls.currentControls;this.currentCamera.position.set(t.x,t.y,t.z),i.target.set(n.x,n.y,n.z)}this.viewport.signals.cameraChange.dispatch(this.currentCamera.position.clone())}moveTo(e,t){return Ki(this.currentCamera.position,e,t,(e=>this.viewport.signals.cameraChange.dispatch(e)))}rotateTo(e,t){const n=this.currentCamera.quaternion.clone(),i=(new r).setFromEuler(e);return Ki({t:0},{t:1},t,(e=>{let{t:t}=e;this.currentCamera.quaternion.slerpQuaternions(n,i,t)}))}flyTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(Ni(t)){const e=t.toLocaleUpperCase();"CURRENT"===e?oa.copy(this.currentCamera.rotation):ia[e]&&oa.copy(ia[e])}else t instanceof n?oa.copy(t):zi(t)&&oa.set(t.x,t.y,t.z);oa.copy(Tn(this.currentCamera.rotation,oa.clone())),yield Promise.all([this.moveTo(e,i),this.rotateTo(oa,i)])}))}flyToBoundingBox(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(e.isEmpty())return void yn("target box is empty");const r=this.viewport.controls.options.type,s=new t;if(Ni(n)){if("CURRENT"===n.toLocaleUpperCase())s.copy(this.getMovePosByBBox(e));else{const t=ia[n.toLocaleUpperCase()],i=this.getObjectLabelPos(e,t);s.copy(i)}}else{"orbit"===r&&yn("orbit 控制器不支持 Rotation 类型 的 rotation 参数");const t=bn(n),i=this.getObjectLabelPos(e,t);s.copy(i)}if("orbit"===r){const t=e.getCenter(sa),i=this.viewport.controls.currentControls;i.target.copy(t);const r=new m;r.lookAt(s,t,i.object.up),n=oa.setFromRotationMatrix(r)}yield this.flyTo(s,n,i)}))}flyToObj(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof Gu||e instanceof Fu){const{padding:t=50}=i,r=ra(t);return this.flyToBoundingBox(e.getBoundingBox(r),n,i)}{const{padding:r="30%"}=i,s=xn(e),o=s.getSize(sa);let a=0;if(Ni(r)){const e=Math.max(o.x,o.y,o.z);a=ra(r)*e}else a=r;let l=a,c=a;if(a<0){const e=Math.min(o.x,o.z),t=o.y-1;l=Math.abs(a)>e?-e:a,c=Math.abs(l)>t?-t:l}return 0!==r&&(s.max.add(sa.set(l/2,c/2,l/2)),s.min.sub(sa.set(l/2,c/2,l/2))),s.isEmpty()&&(sa.setFromMatrixPosition(e.matrixWorld),s.setFromCenterAndSize(sa,new t(0,0,0))),this.flyToBoundingBox(s,n,i)}}surroundOnTarget(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{speed:n=1,angle:i=360,onStart:r}=t,s=wn(e),o=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),a=Math.abs(i);return Ki({angle:0},{angle:Math.PI/180*a},{duration:a/360*5e3/n},(e=>{const t=i>0?e.angle:2*Math.PI-e.angle;if(this.currentCamera.position.x=Math.sin(t)*o+s.x,this.currentCamera.position.z=Math.cos(t)*o+s.z,"orbit"===this.viewport.controls.options.type){const e=this.viewport.controls.currentControls;e.target.copy(s),e.update()}else this.currentCamera.lookAt(s)}),r)}surroundOnObject(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(new i).setFromObject(e).getCenter(sa);return this.surroundOnTarget(n,t)}getMovePosByBBox(e){const n=this.currentCamera.position,i=e.getCenter(sa);(new t).subVectors(i,n).normalize();let r=new O;r=e.getBoundingSphere(r);const s=this.currentCamera.fov/2*Math.PI/180,o=Math.sin(s),a=r.radius/o,l=new t;this.currentCamera.getWorldDirection(l);const c=l.clone();return c.multiplyScalar(-a),i.clone().add(c)}getObjectLabelPos(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof ku&&(e=(new i).setFromObject(e)),e.isEmpty())return yn("target box is empty"),new t;const{extendScale:s=1.6,mode:o="scene"}=r;if("scene"===o){const t=e.getCenter(sa),i=e.max.clone().sub(e.min),r=Math.max(i.x,i.y,i.z),o=t.clone(),a=e=>{const t=(s-.5)*Math.abs(r),n=Math.max(t,this.viewport.camera.near);o.add(e.multiplyScalar(n))};let l;return l=Ni(n)?ia[n.toLocaleUpperCase()]:bn(n),a(sa.set(0,0,1).applyEuler(l)),o}return"screen"===o?e.getCenter(sa).clone():new t}}
2
2
  /**
3
3
  * postprocessing v6.29.3 build Thu Feb 09 2023
4
4
  * https://github.com/pmndrs/postprocessing
@@ -25,4 +25,4 @@ fflate - fast JavaScript compression/decompression
25
25
  <https://101arrowz.github.io/fflate>
26
26
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
27
27
  version 0.6.9
28
- */var sh=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(sh(""))}catch(Zn){sh=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var oh=Uint8Array,ah=Uint16Array,lh=Uint32Array,ch=new oh([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),uh=new oh([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hh=new oh([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dh=function(e,t){for(var n=new ah(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new lh(n[30]);for(i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return[n,r]},fh=dh(ch,2),ph=fh[0],gh=fh[1];ph[28]=258,gh[258]=28;for(var mh=dh(uh,0)[0],vh=new ah(32768),yh=0;yh<32768;++yh){var wh=(43690&yh)>>>1|(21845&yh)<<1;wh=(61680&(wh=(52428&wh)>>>2|(13107&wh)<<2))>>>4|(3855&wh)<<4,vh[yh]=((65280&wh)>>>8|(255&wh)<<8)>>>1}var bh=function(e,t,n){for(var i=e.length,r=0,s=new ah(t);r<i;++r)++s[e[r]-1];var o,a=new ah(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;if(n){o=new ah(1<<t);var l=15-t;for(r=0;r<i;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],h=a[e[r]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[vh[h]>>>l]=c}else for(o=new ah(i),r=0;r<i;++r)e[r]&&(o[r]=vh[a[e[r]-1]++]>>>15-e[r]);return o},xh=new oh(288);for(yh=0;yh<144;++yh)xh[yh]=8;for(yh=144;yh<256;++yh)xh[yh]=9;for(yh=256;yh<280;++yh)xh[yh]=7;for(yh=280;yh<288;++yh)xh[yh]=8;var Ah=new oh(32);for(yh=0;yh<32;++yh)Ah[yh]=5;var Th=bh(xh,9,1),Sh=bh(Ah,5,1),Eh=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Dh=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},Ch=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Ih=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new oh(0);var r=!t||n,s=!n||n.i;n||(n={}),t||(t=new oh(3*i));var o,a=function(e){var n=t.length;if(e>n){var i=new oh(Math.max(2*n,e));i.set(t),t=i}},l=n.f||0,c=n.p||0,u=n.b||0,h=n.l,d=n.d,f=n.m,p=n.n,g=8*i;do{if(!h){n.f=l=Dh(e,c,1);var m=Dh(e,c+1,3);if(c+=3,!m){var v=e[(I=((o=c)/8|0)+(7&o&&1)+4)-4]|e[I-3]<<8,y=I+v;if(y>i){if(s)throw"unexpected EOF";break}r&&a(u+v),t.set(e.subarray(I,y),u),n.b=u+=v,n.p=c=8*y;continue}if(1==m)h=Th,d=Sh,f=9,p=5;else{if(2!=m)throw"invalid block type";var w=Dh(e,c,31)+257,b=Dh(e,c+10,15)+4,x=w+Dh(e,c+5,31)+1;c+=14;for(var A=new oh(x),T=new oh(19),S=0;S<b;++S)T[hh[S]]=Dh(e,c+3*S,7);c+=3*b;var E=Eh(T),D=(1<<E)-1,C=bh(T,E,1);for(S=0;S<x;){var I,M=C[Dh(e,c,D)];if(c+=15&M,(I=M>>>4)<16)A[S++]=I;else{var B=0,R=0;for(16==I?(R=3+Dh(e,c,3),c+=2,B=A[S-1]):17==I?(R=3+Dh(e,c,7),c+=3):18==I&&(R=11+Dh(e,c,127),c+=7);R--;)A[S++]=B}}var P=A.subarray(0,w),O=A.subarray(w);f=Eh(P),p=Eh(O),h=bh(P,f,1),d=bh(O,p,1)}if(c>g){if(s)throw"unexpected EOF";break}}r&&a(u+131072);for(var _=(1<<f)-1,L=(1<<p)-1,k=c;;k=c){var N=(B=h[Ch(e,c)&_])>>>4;if((c+=15&B)>g){if(s)throw"unexpected EOF";break}if(!B)throw"invalid length/literal";if(N<256)t[u++]=N;else{if(256==N){k=c,h=null;break}var U=N-254;if(N>264){var F=ch[S=N-257];U=Dh(e,c,(1<<F)-1)+ph[S],c+=F}var j=d[Ch(e,c)&L],z=j>>>4;if(!j)throw"invalid distance";c+=15&j;O=mh[z];if(z>3){F=uh[z];O+=Ch(e,c)&(1<<F)-1,c+=F}if(c>g){if(s)throw"unexpected EOF";break}r&&a(u+131072);for(var H=u+U;u<H;u+=4)t[u]=t[u-O],t[u+1]=t[u+1-O],t[u+2]=t[u+2-O],t[u+3]=t[u+3-O];u=H}}n.l=h,n.p=k,n.b=u,h&&(l=1,n.m=f,n.d=d,n.n=p)}while(!l);return u==t.length?t:function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof ah?ah:e instanceof lh?lh:oh)(n-t);return i.set(e.subarray(t,n)),i}(t,0,u)},Mh=new oh(0),Bh=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};var Rh="undefined"!=typeof TextDecoder&&new TextDecoder;try{Rh.decode(Mh,{stream:!0}),1}catch(Zn){}function Ph(e,t,n){const i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let r=e,s=i,o=Math.floor((r+s)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?s=o:r=o,o=Math.floor((r+s)/2);return o}function Oh(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let i=1;for(let e=2;e<=t;++e)i*=e;for(let n=2;n<=e-t;++n)i*=n;return n/i}function _h(e,n,i,r,s){const o=function(e,t,n,i,r){const s=r<e?r:e,o=[],a=Ph(e,i,t),l=function(e,t,n,i,r){const s=[];for(let e=0;e<=n;++e)s[e]=0;const o=[];for(let e=0;e<=i;++e)o[e]=s.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=s.slice(0);a[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let i=1;i<=n;++i){l[i]=t-r[e+1-i],c[i]=r[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=c[e+1],r=l[i-e];a[i][e]=t+r;const s=a[e][i-1]/a[i][e];a[e][i]=n+t*s,n=r*s}a[i][i]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,r=1;const l=[];for(let e=0;e<=n;++e)l[e]=s.slice(0);l[0][0]=1;for(let s=1;s<=i;++s){let i=0;const c=e-s,u=n-s;e>=s&&(l[r][0]=l[t][0]/a[u+1][c],i=l[r][0]*a[c][u]);const h=e-1<=u?s-1:n-e;for(let e=c>=-1?1:-c;e<=h;++e)l[r][e]=(l[t][e]-l[t][e-1])/a[u+1][c+e],i+=l[r][e]*a[c+e][u];e<=u&&(l[r][s]=-l[t][s-1]/a[u+1][e],i+=l[r][s]*a[e][u]),o[s][e]=i;const d=t;t=r,r=d}}let u=n;for(let e=1;e<=i;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}(a,i,e,s,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),i=t.w;t.x*=i,t.y*=i,t.z*=i,c[e]=t}for(let t=0;t<=s;++t){const n=c[a-e].clone().multiplyScalar(l[t][0]);for(let i=1;i<=e;++i)n.add(c[a-e+i].clone().multiplyScalar(l[t][i]));o[t]=n}for(let e=s+1;e<=r+1;++e)o[e]=new be(0,0,0);return o}(e,n,i,r,s);return function(e){const n=e.length,i=[],r=[];for(let s=0;s<n;++s){const n=e[s];i[s]=new t(n.x,n.y,n.z),r[s]=n.w}const s=[];for(let e=0;e<n;++e){const t=i[e].clone();for(let n=1;n<=e;++n)t.sub(s[e-n].clone().multiplyScalar(Oh(e,n)*r[n]));s[e]=t.divideScalar(r[0])}return s}(o)}class Lh extends ft{constructor(e,t,n,i,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new be(t.x,t.y,t.z,t.w)}}getPoint(e){const n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=function(e,t,n,i){const r=Ph(e,i,t),s=function(e,t,n,i){const r=[],s=[],o=[];r[0]=1;for(let a=1;a<=n;++a){s[a]=t-i[e+1-a],o[a]=i[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],i=s[a-e],l=r[e]/(t+i);r[e]=n+t*l,n=i*l}r[a]=n}return r}(r,i,e,t),o=new be(0,0,0,0);for(let t=0;t<=e;++t){const i=n[r-e+t],a=s[t],l=i.w*a;o.x+=i.x*l,o.y+=i.y*l,o.z+=i.z*l,o.w+=i.w*a}return o}(this.degree,this.knots,this.controlPoints,i);return 1!==r.w&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e){const n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=_h(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}}let kh,Nh,Uh;class Fh extends pt{constructor(e){super(e)}load(e,t,n,i){const r=this,s=""===r.path?gt.extractUrlBase(e):r.path,o=new mt(this.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(n,s))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===nd(e,0,t.length)}(e))kh=(new Vh).parse(e);else{const t=nd(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function i(t){const i=e[t-1];return e=e.slice(n+t),n++,i}for(let e=0;e<t.length;++e){if(i(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Xh(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Xh(t));kh=(new Gh).parse(t)}const n=new Je(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new jh(n,this.manager).parse(kh)}}class jh{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Nh=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=(new zh).parse(i);return this.parseScene(i,r,n),Uh}parseConnections(){const e=new Map;if("Connections"in kh){kh.Connections.connections.forEach((function(t){const n=t[0],i=t[1],r=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const s={ID:i,relationship:r};e.get(n).parents.push(s),e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:n,relationship:r};e.get(i).children.push(o)}))}return e}parseImages(){const e={},t={};if("Video"in kh.Objects){const n=kh.Objects.Video;for(const i in n){const r=n[i];if(e[parseInt(i)]=r.RelativeFilename||r.Filename,"Content"in r){const e=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,s="string"==typeof r.Content&&""!==r.Content;if(e||s){const e=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=e}}}}for(const n in e){const i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(i){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in kh.Objects){const n=kh.Objects.Texture;for(const i in n){const r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,r=e.WrapModeV,s=void 0!==i?i.value:0,o=void 0!==r?r.value:0;if(n.wrapS=0===s?D:E,n.wrapT=0===o?D:E,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,r=Nh.get(e.id).children;let s;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(n=t[r[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const o=e.FileName.slice(-3).toLowerCase();if("tga"===o){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new l):(t.setPath(this.textureLoader.path),s=t.load(n))}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new l):s=this.textureLoader.load(n);return this.textureLoader.setPath(i),s}parseMaterials(e){const t=new Map;if("Material"in kh.Objects){const n=kh.Objects.Material;for(const i in n){const r=this.parseMaterial(n[i],e);null!==r&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!Nh.has(n))return null;const s=this.parseParameters(e,t,n);let o;switch(r.toLowerCase()){case"phong":o=new vt;break;case"lambert":o=new yt;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),o=new vt}return o.setValues(s),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new a).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new a).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new a).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new a).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new a).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new a).fromArray(e.SpecularColor.value));const r=this;return Nh.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":i.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,e.ID),void 0!==i.map&&(i.map.encoding=I);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.encoding=I);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=qe,i.envMap.encoding=I);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.encoding=I);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,e.ID),i.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in kh.Objects&&t in kh.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Nh.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in kh.Objects){const n=kh.Objects.Deformer;for(const i in n){const r=n[i],s=Nh.get(parseInt(i));if("Skin"===r.attrType){const t=this.parseSkeleton(s,n);t.ID=i,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,e[i]=t}else if("BlendShape"===r.attrType){const e={id:i};e.rawTargets=this.parseMorphTargets(s,n),e.id=i,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const i=t[e.ID];if("Cluster"!==i.attrType)return;const r={ID:e.ID,indices:[],weights:[],transformLink:(new m).fromArray(i.TransformLink.a)};"Indexes"in i&&(r.indices=i.Indexes.a,r.weights=i.Weights.a),n.push(r)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const r=e.children[i],s=t[r.ID],o={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;o.geoID=Nh.get(parseInt(r.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(o)}return n}parseScene(e,t,n){Uh=new wt;const i=this.parseModels(e.skeletons,t,n),r=kh.Objects.Model,s=this;i.forEach((function(e){const t=r[e.ID];s.setLookAtProperties(e,t);Nh.get(e.ID).parents.forEach((function(t){const n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&Uh.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),Uh.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=$h(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const o=(new Hh).parse();1===Uh.children.length&&Uh.children[0].isGroup&&(Uh.children[0].animations=o,Uh=Uh.children[0]),Uh.animations=o}parseModels(e,t,n){const i=new Map,r=kh.Objects.Model;for(const s in r){const o=parseInt(s),a=r[s],l=Nh.get(o);let c=this.buildSkeleton(l,e,o,a.attrName);if(!c){switch(a.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new bt;break;default:c=new wt}c.name=a.attrName?p.sanitizeNodeName(a.attrName):"",c.ID=o}this.getTransformData(c,a),i.set(o,c)}return i}buildSkeleton(e,t,n,i){let r=null;return e.parents.forEach((function(e){for(const s in t){const o=t[s];o.rawBones.forEach((function(t,s){if(t.ID===e.ID){const e=r;r=new bt,r.matrixWorld.copy(t.transformLink),r.name=i?p.sanitizeNodeName(i):"",r.ID=n,o.bones[s]=r,null!==e&&r.add(e)}}))}})),r}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=kh.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new J;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let i=1;void 0!==n.NearPlane&&(i=n.NearPlane.value/1e3);let r=1e3;void 0!==n.FarPlane&&(r=n.FarPlane.value/1e3);let s=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,o=n.AspectHeight.value);const a=s/o;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new $(l,a,i,r),null!==c&&t.setFocalLength(c);break;case 1:t=new ee(-s/2,s/2,o/2,-o/2,i,r);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new J}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=kh.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new J;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new a).fromArray(n.Color.value));let r=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(r=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new j(i,r,s,o);break;case 1:t=new ct(i,r);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=h.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=h.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new ht(i,r,s,e,a,o);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new j(i,r)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,r=null,s=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(r=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))})),o.length>1?s=o:o.length>0?s=o[0]:(s=new vt({color:13421772}),o.push(s)),"color"in r.attributes&&o.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new xt(r,s),i.normalizeSkinWeights()):i=new k(r,s),i}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new q({color:3342591,linewidth:1});return new At(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?ed(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,n){if("LookAtProperty"in n){Nh.get(e.ID).children.forEach((function(n){if("LookAtProperty"===n.relationship){const i=kh.Objects.Model[n.ID];if("Lcl_Translation"in i){const n=i.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(n),Uh.add(e.target)):e.lookAt((new t).fromArray(n))}}}))}}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const r in e){const s=e[r];Nh.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;Nh.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Tt(s.bones),i[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in kh.Objects){const t=kh.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new m).fromArray(t.Matrix.a)})):e[i.Node]=(new m).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in kh&&"AmbientColor"in kh.GlobalSettings){const e=kh.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){const e=new a(t,n,i);Uh.add(new lt(e,1))}}}}class zh{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in kh.Objects){const n=kh.Objects.Geometry;for(const i in n){const r=Nh.get(parseInt(i)),s=this.parseGeometry(r,n[i],e);t.set(parseInt(i),s)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,r=[],s=e.parents.map((function(e){return kh.Objects.Model[e.ID]}));if(0===s.length)return;const o=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&r.push(n.morphTargets[e.ID])}));const a=s[0],l={};"RotationOrder"in a&&(l.eulerOrder=ed(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const c=$h(l);return this.genGeometry(t,o,r,c)}genGeometry(e,t,n,i){const r=new xe;e.attrName&&(r.name=e.attrName);const s=this.parseGeoNode(e,t),o=this.genBuffers(s),a=new it(o.vertex,3);if(a.applyMatrix4(i),r.setAttribute("position",a),o.colors.length>0&&r.setAttribute("color",new it(o.colors,3)),t&&(r.setAttribute("skinIndex",new St(o.weightsIndices,4)),r.setAttribute("skinWeight",new it(o.vertexWeights,4)),r.FBX_Deformer=t),o.normal.length>0){const e=(new Pe).getNormalMatrix(i),t=new it(o.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(o.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),r.setAttribute(n,new it(o.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach((function(n,i){n!==e&&(r.addGroup(t,i-t,e),e=n,t=i)})),r.groups.length>0){const t=r.groups[r.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&r.addGroup(n,o.materialIndex.length-n,e)}0===r.groups.length&&r.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,r=!1,s=[],o=[],a=[],l=[],c=[],u=[];const h=this;return e.vertexIndices.forEach((function(d,f){let p,g=!1;d<0&&(d^=-1,g=!0);let m=[],v=[];if(s.push(3*d,3*d+1,3*d+2),e.color){const t=Zh(f,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),m.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,i){let r=n,s=m[i];t.forEach((function(t,n,i){if(r>t){i[n]=r,r=t;const o=e[n];e[n]=s,s=o}}))})),m=e,v=t}for(;v.length<4;)v.push(0),m.push(0);for(let e=0;e<4;++e)c.push(v[e]),u.push(m[e])}if(e.normal){const t=Zh(f,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(p=Zh(f,n,d,e.material)[0],p<0&&(h.negativeMaterialIndices=!0,p=0)),e.uv&&e.uv.forEach((function(e,t){const i=Zh(f,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,g&&(i>4&&console.warn("THREE.FBXLoader: Polygons with more than four sides are not supported. Make sure to triangulate the geometry during export."),h.genFace(t,e,s,p,o,a,l,c,u,i),n++,i=0,s=[],o=[],a=[],l=[],c=[],u=[])})),t}genFace(e,t,n,i,r,s,o,a,l,c){for(let u=2;u<c;u++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(u-1)]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[n[3*u]]),e.vertex.push(t.vertexPositions[n[3*u+1]]),e.vertex.push(t.vertexPositions[n[3*u+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(u-1)]),e.vertexWeights.push(a[4*(u-1)+1]),e.vertexWeights.push(a[4*(u-1)+2]),e.vertexWeights.push(a[4*(u-1)+3]),e.vertexWeights.push(a[4*u]),e.vertexWeights.push(a[4*u+1]),e.vertexWeights.push(a[4*u+2]),e.vertexWeights.push(a[4*u+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(s[0]),e.colors.push(s[1]),e.colors.push(s[2]),e.colors.push(s[3*(u-1)]),e.colors.push(s[3*(u-1)+1]),e.colors.push(s[3*(u-1)+2]),e.colors.push(s[3*u]),e.colors.push(s[3*u+1]),e.colors.push(s[3*u+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[3*(u-1)]),e.normal.push(r[3*(u-1)+1]),e.normal.push(r[3*(u-1)+2]),e.normal.push(r[3*u]),e.normal.push(r[3*u+1]),e.normal.push(r[3*u+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][0]),e.uvs[n].push(o[n][1]),e.uvs[n].push(o[n][2*(u-1)]),e.uvs[n].push(o[n][2*(u-1)+1]),e.uvs[n].push(o[n][2*u]),e.uvs[n].push(o[n][2*u+1])}))}addMorphTargets(e,t,n,i){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=kh.Objects.Geometry[n.geoID];void 0!==s&&r.genMorphGeometry(e,t,s,i,n.name)}))}))}genMorphGeometry(e,t,n,i,r){const s=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],o=void 0!==n.Vertices?n.Vertices.a:[],a=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<a.length;e++){const t=3*a[e];c[t]=o[3*e],c[t+1]=o[3*e+1],c[t+2]=o[3*e+2]}const u={vertexIndices:s,vertexPositions:c},h=this.genBuffers(u),d=new it(h.vertex,3);d.name=r||n.attrName,d.applyMatrix4(i),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let r=[];return"IndexToDirect"===n&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let r=[];return"IndexToDirect"===n&&(r=e.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let r=[];return"IndexToDirect"===n&&(r=e.ColorIndex.a),{dataSize:4,buffer:i,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,r=[];for(let e=0;e<i.length;++e)r.push(e);return{dataSize:1,buffer:i,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new xe;const n=t-1,i=e.KnotVector.a,r=[],s=e.Points.a;for(let e=0,t=s.length;e<t;e+=4)r.push((new be).fromArray(s,e));let o,a;if("Closed"===e.Form)r.push(r[0]);else if("Periodic"===e.Form){o=n,a=i.length-1-o;for(let e=0;e<n;++e)r.push(r[e])}const l=new Lh(n,i,r,o,a).getPoints(12*r.length);return(new xe).setFromPoints(l)}}class Hh{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const i=t[n],r=this.addClip(i);e.push(r)}return e}parseClips(){if(void 0===kh.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=kh.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){const e={id:i.id,attr:i.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=kh.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(Qh),values:t[n].KeyValueFloat.a},r=Nh.get(i.id);if(void 0!==r){const t=r.parents[0].ID,n=r.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=i:n.match(/Y/)?e.get(t).curves.y=i:n.match(/Z/)?e.get(t).curves.z=i:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=i)}}}parseAnimationLayers(e){const t=kh.Objects.AnimationLayer,n=new Map;for(const i in t){const t=[],r=Nh.get(parseInt(i));if(void 0!==r){r.children.forEach((function(n,i){if(e.has(n.ID)){const r=e.get(n.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===t[i]){const e=Nh.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const r=kh.Objects.Model[e.toString()];if(void 0===r)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:r.attrName?p.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Uh.traverse((function(e){e.ID===r.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new m),"PreRotation"in r&&(s.preRotation=r.PreRotation.value),"PostRotation"in r&&(s.postRotation=r.PostRotation.value),t[i]=s}}t[i]&&(t[i][r.attr]=r)}else if(void 0!==r.curves.morph){if(void 0===t[i]){const e=Nh.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=Nh.get(e).parents[0].ID,s=Nh.get(r).parents[0].ID,o=Nh.get(s).parents[0].ID,a=kh.Objects.Model[o],l={modelName:a.attrName?p.sanitizeNodeName(a.attrName):"",morphName:kh.Objects.Deformer[e].attrName};t[i]=l}t[i][r.attr]=r}}})),n.set(parseInt(i),t)}}return n}parseAnimStacks(e){const t=kh.Objects.AnimationStack,n={};for(const i in t){const r=Nh.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new We(e.name,-1,t)}generateTracks(e){const i=[];let s=new t,o=new r,a=new t;if(e.transform&&e.transform.decompose(s,o,a),s=s.toArray(),o=(new n).setFromQuaternion(o,e.eulerOrder).toArray(),a=a.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const t=this.generateVectorTrack(e.modelName,e.T.curves,s,"position");void 0!==t&&i.push(t)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const t=this.generateRotationTrack(e.modelName,e.R.curves,o,e.preRotation,e.postRotation,e.eulerOrder);void 0!==t&&i.push(t)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const t=this.generateVectorTrack(e.modelName,e.S.curves,a,"scale");void 0!==t&&i.push(t)}if(void 0!==e.DeformPercent){const t=this.generateMorphTrack(e);void 0!==t&&i.push(t)}return i}generateVectorTrack(e,t,n,i){const r=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(r,t,n);return new Et(e+"."+i,r,s)}generateRotationTrack(e,t,i,s,o,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(h.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(h.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(h.degToRad));const l=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(l,t,i);void 0!==s&&((s=s.map(h.degToRad)).push(a),s=(new n).fromArray(s),s=(new r).setFromEuler(s)),void 0!==o&&((o=o.map(h.degToRad)).push(a),o=(new n).fromArray(o),o=(new r).setFromEuler(o).invert());const u=new r,d=new n,f=[];for(let e=0;e<c.length;e+=3)d.set(c[e],c[e+1],c[e+2],a),u.setFromEuler(d),void 0!==s&&u.premultiply(s),void 0!==o&&u.multiply(o),u.toArray(f,e/3*4);return new Dt(e+".quaternion",l,f)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=Uh.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Ct(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let i=1;i<t.length;i++){const r=t[i];r!==n&&(t[e]=r,n=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const i=n,r=[];let s=-1,o=-1,a=-1;return e.forEach((function(e){if(t.x&&(s=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==s){const e=t.x.values[s];r.push(e),i[0]=e}else r.push(i[0]);if(-1!==o){const e=t.y.values[o];r.push(e),i[1]=e}else r.push(i[1]);if(-1!==a){const e=t.z.values[a];r.push(e),i[2]=e}else r.push(i[2])})),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],i=e.values[t]-n,r=Math.abs(i);if(r>=180){const s=r/180,o=i/s;let a=n+o;const l=e.times[t-1],c=(e.times[t]-l)/s;let u=l+c;const h=[],d=[];for(;u<e.times[t];)h.push(u),u+=c,d.push(a),a+=o;e.times=id(e.times,t,h),e.values=id(e.values,t,d)}}}}class Gh{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Wh,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,i){const r=e.match(/^[\s\t]*;/),s=e.match(/^[\s\t]*$/);if(r||s)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),r={name:n},s=this.parseNodeAttr(i),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,r):n in o?("PoseNode"===n?o.PoseNode.push(r):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==s.id&&(o[n][s.id]=r)):"number"==typeof s.id?(o[n]={},o[n][s.id]=r):"Properties70"!==n&&(o[n]="PoseNode"===n?[r]:r),"number"==typeof s.id&&(r.id=s.id),""!==s.name&&(r.attrName=s.name),""!==s.type&&(r.attrType=s.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===i){const e=r.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=r.split(",").slice(3);o=o.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",r=[t,n],function(e,t){for(let n=0,i=e.length,r=t.length;n<r;n++,i++)e[i]=t[n]}(r,o),void 0===s[i]&&(s[i]=[])}"Node"===i&&(s.id=r),i in s&&Array.isArray(s[i])?s[i].push(r):"a"!==i?s[i]=r:s.a=r,this.setCurrentProp(s,i),"a"===i&&","!==r.slice(-1)&&(s.a=td(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=td(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=i[0],s=i[1],o=i[2],a=i[3];let l=i[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=td(l)}this.getPrevNode()[r]={type:s,type2:o,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),r)}}class Vh{parse(e){const t=new Yh(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Wh;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),o=e.getString(s);if(0===i)return null;const a=[];for(let t=0;t<r;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){const i=this.parseNode(e,t);null!==i&&this.parseSubNode(o,n,i)}return n.propertyList=a,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==u&&(n.attrType=u),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],i=n.propertyList[1];const r=n.propertyList[2],s=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),o="Color"===i||"ColorRGB"===i||"Vector"===i||"Vector3D"===i||0===i.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:i,type2:r,flag:s,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),r=e.getUint32(),s=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const o=function(e,t){return Ih((Bh(e),e.subarray(2,-4)),t)}(new Uint8Array(e.getArrayBuffer(s))),a=new Yh(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(i);case"d":return a.getFloat64Array(i);case"f":return a.getFloat32Array(i);case"i":return a.getInt32Array(i);case"l":return a.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Yh{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}}class Wh{add(e,t){this[e]=t}}function Xh(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Qh(e){return e/46186158e3}const Kh=[];function Zh(e,t,n,i){let r;switch(i.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=n;break;case"AllSame":r=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(r=i.indices[r]);const s=r*i.dataSize,o=s+i.dataSize;return function(e,t,n,i){for(let r=n,s=0;r<i;r++,s++)e[s]=t[r];return e}(Kh,i.buffer,s,o)}const qh=new n,Jh=new t;function $h(e){const i=new m,r=new m,s=new m,o=new m,a=new m,l=new m,c=new m,u=new m,d=new m,f=new m,p=new m,g=new m,v=e.inheritType?e.inheritType:0;if(e.translation&&i.setPosition(Jh.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(h.degToRad);t.push(e.eulerOrder||n.DEFAULT_ORDER),r.makeRotationFromEuler(qh.fromArray(t))}if(e.rotation){const t=e.rotation.map(h.degToRad);t.push(e.eulerOrder||n.DEFAULT_ORDER),s.makeRotationFromEuler(qh.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(h.degToRad);t.push(e.eulerOrder||n.DEFAULT_ORDER),o.makeRotationFromEuler(qh.fromArray(t)),o.invert()}e.scale&&a.scale(Jh.fromArray(e.scale)),e.scalingOffset&&c.setPosition(Jh.fromArray(e.scalingOffset)),e.scalingPivot&&l.setPosition(Jh.fromArray(e.scalingPivot)),e.rotationOffset&&u.setPosition(Jh.fromArray(e.rotationOffset)),e.rotationPivot&&d.setPosition(Jh.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(p.copy(e.parentMatrix),f.copy(e.parentMatrixWorld));const y=r.clone().multiply(s).multiply(o),w=new m;w.extractRotation(f);const b=new m;b.copyPosition(f);const x=b.clone().invert().multiply(f),A=w.clone().invert().multiply(x),T=a,S=new m;if(0===v)S.copy(w).multiply(y).multiply(A).multiply(T);else if(1===v)S.copy(w).multiply(A).multiply(y).multiply(T);else{const e=(new m).scale((new t).setFromMatrixScale(p)).clone().invert(),n=A.clone().multiply(e);S.copy(w).multiply(y).multiply(n).multiply(T)}const E=d.clone().invert(),D=l.clone().invert();let C=i.clone().multiply(u).multiply(d).multiply(r).multiply(s).multiply(o).multiply(E).multiply(c).multiply(l).multiply(a).multiply(D);const I=(new m).copyPosition(C),M=f.clone().multiply(I);return g.copyPosition(M),C=g.clone().multiply(S),C.premultiply(f.invert()),C}function ed(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function td(e){return e.split(",").map((function(e){return parseFloat(e)}))}function nd(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}function id(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class rd extends H{constructor(e){super(e)}parse(e){const t=0,n=1,i=2,r=3,s=9,o=10,a=11,l=48,c=4,u=0,h=1,d=2,f=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let p=0;const g=new Uint8Array(e),m={id_length:g[p++],colormap_type:g[p++],image_type:g[p++],colormap_index:g[p++]|g[p++]<<8,colormap_length:g[p++]|g[p++]<<8,colormap_size:g[p++],origin:[g[p++]|g[p++]<<8,g[p++]|g[p++]<<8],width:g[p++]|g[p++]<<8,height:g[p++]|g[p++]<<8,pixel_size:g[p++],flags:g[p++]};!function(e){switch(e.image_type){case n:case s:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case i:case r:case o:case a:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(m),m.id_length+p>e.length&&console.error("THREE.TGALoader: No data."),p+=m.id_length;let v=!1,y=!1,w=!1;switch(m.image_type){case s:v=!0,y=!0;break;case n:y=!0;break;case o:v=!0;break;case i:break;case a:v=!0,w=!0;break;case r:w=!0}const b=new Uint8Array(m.width*m.height*4),x=function(e,t,n,i,r){let s,o;const a=n.pixel_size>>3,l=n.width*n.height*a;if(t&&(o=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let o=0;const c=new Uint8Array(a);for(;o<l;)if(e=r[i++],t=1+(127&e),128&e){for(n=0;n<a;++n)c[n]=r[i++];for(n=0;n<t;++n)s.set(c,o+n*a);o+=a*t}else{for(t*=a,n=0;n<t;++n)s[o+n]=r[i++];o+=t}}else s=r.subarray(i,i+=t?n.width*n.height:l);return{pixel_data:s,palettes:o}}(v,y,m,p,g);return function(e,t,n,i,r){let s,o,a,p,g,v;switch((m.flags&l)>>c){default:case d:s=0,a=1,g=t,o=0,p=1,v=n;break;case u:s=0,a=1,g=t,o=n-1,p=-1,v=-1;break;case f:s=t-1,a=-1,g=-1,o=0,p=1,v=n;break;case h:s=t-1,a=-1,g=-1,o=n-1,p=-1,v=-1}if(w)switch(m.pixel_size){case 8:!function(e,t,n,i,r,s,o,a){let l,c,u,h=0;const d=m.width;for(u=t;u!==i;u+=n)for(c=r;c!==o;c+=s,h++)l=a[h],e[4*(c+d*u)+0]=l,e[4*(c+d*u)+1]=l,e[4*(c+d*u)+2]=l,e[4*(c+d*u)+3]=255}(e,o,p,v,s,a,g,i);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,u=0;const h=m.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,u+=2)e[4*(l+h*c)+0]=a[u+0],e[4*(l+h*c)+1]=a[u+0],e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+3]=a[u+1]}(e,o,p,v,s,a,g,i);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(m.pixel_size){case 8:!function(e,t,n,i,r,s,o,a,l){const c=l;let u,h,d,f=0;const p=m.width;for(d=t;d!==i;d+=n)for(h=r;h!==o;h+=s,f++)u=a[f],e[4*(h+p*d)+3]=255,e[4*(h+p*d)+2]=c[3*u+0],e[4*(h+p*d)+1]=c[3*u+1],e[4*(h+p*d)+0]=c[3*u+2]}(e,o,p,v,s,a,g,i,r);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,u,h=0;const d=m.width;for(u=t;u!==i;u+=n)for(c=r;c!==o;c+=s,h+=2)l=a[h+0]+(a[h+1]<<8),e[4*(c+d*u)+0]=(31744&l)>>7,e[4*(c+d*u)+1]=(992&l)>>2,e[4*(c+d*u)+2]=(31&l)<<3,e[4*(c+d*u)+3]=32768&l?0:255}(e,o,p,v,s,a,g,i);break;case 24:!function(e,t,n,i,r,s,o,a){let l,c,u=0;const h=m.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,u+=3)e[4*(l+h*c)+3]=255,e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+1]=a[u+1],e[4*(l+h*c)+0]=a[u+2]}(e,o,p,v,s,a,g,i);break;case 32:!function(e,t,n,i,r,s,o,a){let l,c,u=0;const h=m.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,u+=4)e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+1]=a[u+1],e[4*(l+h*c)+0]=a[u+2],e[4*(l+h*c)+3]=a[u+3]}(e,o,p,v,s,a,g,i);break;default:console.error("THREE.TGALoader: Format not supported.")}}(b,m.width,m.height,x.pixel_data,x.palettes),{data:b,width:m.width,height:m.height,flipY:!0,generateMipmaps:!0,minFilter:S}}}function sd(e,t){if(t===It)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Mt||t===Bt){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(t===Mt)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class od extends pt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new dd(e)})),this.register((function(e){return new wd(e)})),this.register((function(e){return new bd(e)})),this.register((function(e){return new pd(e)})),this.register((function(e){return new gd(e)})),this.register((function(e){return new md(e)})),this.register((function(e){return new vd(e)})),this.register((function(e){return new hd(e)})),this.register((function(e){return new yd(e)})),this.register((function(e){return new fd(e)})),this.register((function(e){return new cd(e)})),this.register((function(e){return new xd(e)})),this.register((function(e){return new Ad(e)}))}load(e,t,n,i){const r=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:gt.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},a=new mt(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{r.parse(n,s,(function(n){t(n),r.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},o={},a=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===Td){try{s[ld.KHR_BINARY_GLTF]=new Dd(e)}catch(e){return void(i&&i(e))}r=JSON.parse(s[ld.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Jd(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);o[t.name]=t,s[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],n=r.extensionsRequired||[];switch(t){case ld.KHR_MATERIALS_UNLIT:s[t]=new ud;break;case ld.KHR_DRACO_MESH_COMPRESSION:s[t]=new Cd(r,this.dracoLoader);break;case ld.KHR_TEXTURE_TRANSFORM:s[t]=new Id;break;case ld.KHR_MESH_QUANTIZATION:s[t]=new Md;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function ad(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const ld={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class cd{constructor(e){this.parser=e,this.name=ld.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const l=new a(16777215);void 0!==s.color&&l.fromArray(s.color);const c=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new ct(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new j(l),o.distance=c;break;case"spot":o=new ht(l),o.distance=c,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,Wd(o,s),void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(o),t.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class ud{constructor(){this.name=ld.KHR_MATERIALS_UNLIT}getMaterialType(){return z}extendParams(e,t,n){const i=[];e.color=new a(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,I))}return Promise.all(i)}}class hd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class dd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new M(e,e)}return Promise.all(r)}}class fd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class pd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new a(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];return void 0!==s.sheenColorFactor&&t.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,I)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class gd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class md{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new a(o[0],o[1],o[2]),Promise.all(r)}}class vd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class yd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new a(o[0],o[1],o[2]),void 0!==s.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,I)),Promise.all(r)}}class wd{constructor(e){this.parser=e,this.name=ld.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class bd{constructor(e){this.parser=e,this.name=ld.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class xd{constructor(e){this.name=ld.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*o);return r.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t}))}))}return null}}class Ad{constructor(e){this.name=ld.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,i=n.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const s=n.meshes[i.mesh];for(const e of s.primitives)if(e.mode!==Od.TRIANGLES&&e.mode!==Od.TRIANGLE_STRIP&&e.mode!==Od.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const e in o)a.push(this.parser.getDependency("accessor",o[e]).then((t=>(l[e]=t,l[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const n=e.pop(),i=n.isGroup?n.children:[n],s=e[0].count,o=[];for(const e of i){const n=new m,i=new t,a=new r,c=new t(1,1,1),u=new Pt(e.geometry,e.material,s);for(let e=0;e<s;e++)l.TRANSLATION&&i.fromBufferAttribute(l.TRANSLATION,e),l.ROTATION&&a.fromBufferAttribute(l.ROTATION,e),l.SCALE&&c.fromBufferAttribute(l.SCALE,e),u.setMatrixAt(e,n.compose(i,a,c));for(const t in l)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,l[t]);J.prototype.copy.call(u,e),u.frustumCulled=!1,this.parser.assignFinalMaterial(u),o.push(u)}return n.isGroup?(n.clear(),n.add(...o),n):o[0]})))}}const Td="glTF",Sd=1313821514,Ed=5130562;class Dd{constructor(e){this.name=ld.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Td)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(e,12);let s=0;for(;s<i;){const t=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Sd){const i=new Uint8Array(e,12+s,t);this.content=n.decode(i)}else if(i===Ed){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Cd{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ld.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=Ud[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const i=Ud[t]||t.toLowerCase();if(void 0!==s[t]){const r=n.accessors[e.attributes[t]],s=_d[r.componentType];l[i]=s.name,a[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=a[t];void 0!==i&&(n.normalized=i)}t(e)}),o,l)}))}))}}class Id{constructor(){this.name=ld.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Md{constructor(){this.name=ld.KHR_MESH_QUANTIZATION}}class Bd extends Ft{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=i-t,u=(n-t)/c,h=u*u,d=h*u,f=e*l,p=f-l,g=-2*d+3*h,m=d-h,v=1-g,y=m-h+u;for(let e=0;e!==o;e++){const t=s[p+e+o],n=s[p+e+a]*c,i=s[f+e+o],l=s[f+e]*c;r[e]=v*t+y*n+g*i+m*l}return r}}const Rd=new r;class Pd extends Bd{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return Rd.fromArray(r).normalize().toArray(r),r}}const Od={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},_d={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ld={9728:w,9729:A,9984:b,9985:T,9986:x,9987:S},kd={33071:E,33648:C,10497:D},Nd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ud={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Fd={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jd={CUBICSPLINE:void 0,LINEAR:y,STEP:g},zd="OPAQUE",Hd="MASK",Gd="BLEND";function Vd(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new F({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:L})),e.DefaultMaterial}function Yd(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function Wd(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Xd(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Qd(e){const t=e.extensions&&e.extensions[ld.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+Kd(t.attributes):e.indices+":"+Kd(e.attributes)+":"+e.mode,n}function Kd(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function Zd(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const qd=new m;class Jd{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ad,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Je(this.options.manager):this.textureLoader=new Ot(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new mt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};Yd(r,s,i),Wd(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!i)throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[ld.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(gt.resolveURL(t.uri,i.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){const e=Nd[i.type],t=_d[i.componentType],n=!0===i.normalized,r=new t(i.count*e);return Promise.resolve(new f(r,e,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],s=Nd[i.type],o=_d[i.componentType],a=o.BYTES_PER_ELEMENT,l=a*s,c=i.byteOffset||0,u=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,h=!0===i.normalized;let d,p;if(u&&u!==l){const e=Math.floor(c/u),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(d=new o(r,e*u,i.count*u/a),l=new _t(d,u/a),t.cache.add(n,l)),p=new Lt(l,s,c%u/a,h)}else d=null===r?new o(i.count*s):new o(r,c,i.count*s),p=new f(d,s,h);if(void 0!==i.sparse){const t=Nd.SCALAR,n=_d[i.sparse.indices.componentType],a=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],a,i.sparse.count*t),u=new o(e[2],l,i.sparse.count*s);null!==r&&(p=new f(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,u[e*s]),s>=2&&p.setY(t,u[e*s+1]),s>=3&&p.setZ(t,u[e*s+2]),s>=4&&p.setW(t,u[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||o.name||"";const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=Ld[n.magFilter]||A,t.minFilter=Ld[n.minFilter]||S,t.wrapS=kd[n.wrapS]||D,t.wrapT=kd[n.wrapT]||D,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",c=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){c=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new l(e);t.needsUpdate=!0,n(t)}),t.load(gt.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===c&&o.revokeObjectURL(a),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),r.extensions[ld.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[ld.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[ld.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.encoding=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new kt,Ae.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new q,Ae.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return F}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let s;const o={},l=[];if((r.extensions||{})[ld.KHR_MATERIALS_UNLIT]){const e=i[ld.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),l.push(e.extendParams(o,r,t))}else{const n=r.pbrMetallicRoughness||{};if(o.color=new a(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.fromArray(e),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,I)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===r.doubleSided&&(o.side=d);const c=r.alphaMode||zd;if(c===Gd?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Hd&&(o.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==z&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new M(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;o.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&s!==z&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(o.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==z&&(o.emissive=(new a).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==z&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,I)),Promise.all(l).then((function(){const n=new s(o);return r.name&&(n.name=r.name),Wd(n,r),t.associations.set(n,{materials:e}),r.extensions&&Yd(i,n,r),n}))}createUniqueName(e){const t=p.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[ld.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return $d(n,e,t)}))}const s=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=Qd(o),l=i[a];if(l)s.push(l.promise);else{let e;e=o.extensions&&o.extensions[ld.KHR_DRACO_MESH_COMPRESSION]?r(o):$d(new xe,o,t),i[a]={primitive:o,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?Vd(this.cache):this.getDependency("material",s[e].material);o.push(t)}return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],u=s[n];let h;const d=o[n];if(u.mode===Od.TRIANGLES||u.mode===Od.TRIANGLE_STRIP||u.mode===Od.TRIANGLE_FAN||void 0===u.mode)h=!0===r.isSkinnedMesh?new xt(c,d):new k(c,d),!0!==h.isSkinnedMesh||h.geometry.attributes.skinWeight.normalized||h.normalizeSkinWeights(),u.mode===Od.TRIANGLE_STRIP?h.geometry=sd(h.geometry,Bt):u.mode===Od.TRIANGLE_FAN&&(h.geometry=sd(h.geometry,Mt));else if(u.mode===Od.LINES)h=new Z(c,d);else if(u.mode===Od.LINE_STRIP)h=new At(c,d);else if(u.mode===Od.LINE_LOOP)h=new Nt(c,d);else{if(u.mode!==Od.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new Ut(c,d)}Object.keys(h.geometry.morphAttributes).length>0&&Xd(h,r),h.name=t.createUniqueName(r.name||"mesh_"+e),Wd(h,r),u.extensions&&Yd(i,h,u),t.assignFinalMaterial(h),l.push(h)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new wt;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new $(h.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new ee(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Wd(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(this.getDependency("node",t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),i=e,r=[],s=[];for(let e=0,o=i.length;e<o;e++){const o=i[e];if(o){r.push(o);const t=new m;null!==n&&t.fromArray(n.array,16*e),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Tt(r,s)}))}loadAnimation(e){const t=this.json.animations[e],n=[],i=[],r=[],s=[],o=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,u=c.node,h=void 0!==t.parameters?t.parameters[l.input]:l.input,d=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",u)),i.push(this.getDependency("accessor",h)),r.push(this.getDependency("accessor",d)),s.push(l),o.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(o)]).then((function(n){const i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=r[e],c=s[e],u=o[e],h=a[e];if(void 0===t)continue;let d;switch(t.updateMatrix(),Fd[h.path]){case Fd.weights:d=Ct;break;case Fd.rotation:d=Dt;break;default:d=Et}const f=t.name?t.name:t.uuid,p=void 0!==u.interpolation?jd[u.interpolation]:y,g=[];Fd[h.path]===Fd.weights?t.traverse((function(e){e.morphTargetInfluences&&g.push(e.name?e.name:e.uuid)})):g.push(f);let m=c.array;if(c.normalized){const e=Zd(m.constructor),t=new Float32Array(m.length);for(let n=0,i=m.length;n<i;n++)t[n]=m[n]*e;m=t}for(let e=0,t=g.length;e<t;e++){const t=new d(g[e]+"."+Fd[h.path],n.array,m,p);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof Dt?Pd:Bd)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new We(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));n&&t.push(n),void 0!==r.camera&&t.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)}));const s=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)s.push(i.getDependency("node",o[e]));const a=void 0===r.skin?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([Promise.all(t),Promise.all(s),a])}().then((function(t){const o=t[0],a=t[1],l=t[2];let c;if(c=!0===r.isBone?new bt:o.length>1?new wt:1===o.length?o[0]:new J,c!==o[0])for(let e=0,t=o.length;e<t;e++)c.add(o[e]);if(r.name&&(c.userData.name=r.name,c.name=s),Wd(c,r),r.extensions&&Yd(n,c,r),void 0!==r.matrix){const e=new m;e.fromArray(r.matrix),c.applyMatrix4(e)}else void 0!==r.translation&&c.position.fromArray(r.translation),void 0!==r.rotation&&c.quaternion.fromArray(r.rotation),void 0!==r.scale&&c.scale.fromArray(r.scale);i.associations.has(c)||i.associations.set(c,{}),i.associations.get(c).nodes=e,null!==l&&c.traverse((function(e){e.isSkinnedMesh&&e.bind(l,qd)}));for(let e=0,t=a.length;e<t;e++)c.add(a[e]);return c}))}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new wt;n.name&&(r.name=i.createUniqueName(n.name)),Wd(r,n),n.extensions&&Yd(t,r,n);const s=n.nodes||[],o=[];for(let e=0,t=s.length;e<t;e++)o.push(i.getDependency("node",s[e]));return Promise.all(o).then((function(e){for(let t=0,n=e.length;t<n;t++)r.add(e[t]);return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof Ae||e instanceof l)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}}function $d(e,n,r){const s=n.attributes,o=[];function a(t,n){return r.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}for(const t in s){const n=Ud[t]||t.toLowerCase();n in e.attributes||o.push(a(s[t],n))}if(void 0!==n.indices&&!e.index){const t=r.getDependency("accessor",n.indices).then((function(t){e.setIndex(t)}));o.push(t)}return Wd(e,n),function(e,n,r){const s=n.attributes,o=new i;if(void 0===s.POSITION)return;{const e=r.json.accessors[s.POSITION],n=e.min,i=e.max;if(void 0===n||void 0===i)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new t(n[0],n[1],n[2]),new t(i[0],i[1],i[2])),e.normalized){const t=Zd(_d[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const a=n.targets;if(void 0!==a){const e=new t,n=new t;for(let t=0,i=a.length;t<i;t++){const i=a[t];if(void 0!==i.POSITION){const t=r.json.accessors[i.POSITION],s=t.min,o=t.max;if(void 0!==s&&void 0!==o){if(n.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),n.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),n.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),t.normalized){const e=Zd(_d[t.componentType]);n.multiplyScalar(e)}e.max(n)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const l=new O;o.getCenter(l.center),l.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=l}(e,n,r),Promise.all(o).then((function(){return void 0!==n.targets?function(e,t,n){let i=!1,r=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(i){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],o=t[1],a=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,n.targets,r):e}))}const ef=new WeakMap;class tf extends pt{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const r=new mt(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.decodeDracoFile(e,t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};return this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){const n=JSON.stringify(t);if(ef.has(e)){const t=ef.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),ef.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new xe;e.index&&t.setIndex(new f(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],r=i.name,s=i.array,o=i.itemSize;t.setAttribute(r,new f(s,o))}return t}_loadLibrary(e,t){const n=new mt(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=nf.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function nf(){let e,t;function n(e,t,n,i,r,s){const o=s.num_components(),a=n.num_points()*o,l=a*r.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,c,l,u);const h=new r(e.HEAPF32.buffer,u,a).slice();return e._free(u),{name:i,array:h,itemSize:o}}onmessage=function(i){const r=i.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=r.buffer,s=r.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,r){const s=r.attributeIDs,o=r.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(i,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const i in s){const l=self[o[i]];let c,h;if(r.useUniqueIDs)h=s[i],c=t.GetAttributeByUniqueId(a,h);else{if(h=t.GetAttributeId(a,e[s[i]]),-1===h)continue;c=t.GetAttribute(a,h)}u.attributes.push(n(e,t,a,i,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const i=n.num_faces(),r=3*i,s=4*r,o=e._malloc(s);t.GetTrianglesUInt32Array(n,s,o);const a=new Uint32Array(e.HEAPF32.buffer,o,r).slice();return e._free(o),{array:a,itemSize:1}}(e,t,a));return e.destroy(a),u}(t,o,a,s),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}function rf(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var sf={};({get exports(){return sf},set exports(e){sf=e}}).exports=function e(t,n,i){function r(o,a){if(!n[o]){if(!t[o]){if(!a&&rf)return rf(o);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};t[o][0].call(c.exports,(function(e){var n=t[o][1][e];return r(n||e)}),c,c.exports,e,t,n,i)}return n[o].exports}for(var s=rf,o=0;o<i.length;o++)r(i[o]);return r}({1:[function(e,t,n){(function(e){var n,i,r=e.MutationObserver||e.WebKitMutationObserver;if(r){var s=0,o=new r(u),a=e.document.createTextNode("");o.observe(a,{characterData:!0}),n=function(){a.data=s=++s%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){u(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(u,0)};else{var l=new e.MessageChannel;l.port1.onmessage=u,n=function(){l.port2.postMessage(0)}}var c=[];function u(){var e,t;i=!0;for(var n=c.length;n;){for(t=c,c=[],e=-1;++e<n;)t[e]();n=c.length}i=!1}function h(e){1!==c.push(e)||i||n()}t.exports=h}).call(this,void 0!==Ms?Ms:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var i=e(1);function r(){}var s={},o=["REJECTED"],a=["FULFILLED"],l=["PENDING"];function c(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==r&&f(this,e)}function u(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function h(e,t,n){i((function(){var i;try{i=t(n)}catch(t){return s.reject(e,t)}i===e?s.reject(e,new TypeError("Cannot resolve promise with itself")):s.resolve(e,i)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var n=!1;function i(t){n||(n=!0,s.reject(e,t))}function r(t){n||(n=!0,s.resolve(e,t))}function o(){t(r,i)}var a=p(o);"error"===a.status&&i(a.value)}function p(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function g(e){return e instanceof this?e:s.resolve(new this(r),e)}function m(e){var t=new this(r);return s.reject(t,e)}function v(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var o=new Array(n),a=0,l=-1,c=new this(r);++l<n;)u(e[l],l);return c;function u(e,r){function l(e){o[r]=e,++a!==n||i||(i=!0,s.resolve(c,o))}t.resolve(e).then(l,(function(e){i||(i=!0,s.reject(c,e))}))}}function y(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var o=-1,a=new this(r);++o<n;)l(e[o]);return a;function l(e){t.resolve(e).then((function(e){i||(i=!0,s.resolve(a,e))}),(function(e){i||(i=!0,s.reject(a,e))}))}}t.exports=c,c.prototype.catch=function(e){return this.then(null,e)},c.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===o)return this;var n=new this.constructor(r);return this.state!==l?h(n,this.state===a?e:t,this.outcome):this.queue.push(new u(n,e,t)),n},u.prototype.callFulfilled=function(e){s.resolve(this.promise,e)},u.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},u.prototype.callRejected=function(e){s.reject(this.promise,e)},u.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},s.resolve=function(e,t){var n=p(d,t);if("error"===n.status)return s.reject(e,n.value);var i=n.value;if(i)f(e,i);else{e.state=a,e.outcome=t;for(var r=-1,o=e.queue.length;++r<o;)e.queue[r].callFulfilled(t)}return e},s.reject=function(e,t){e.state=o,e.outcome=t;for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e},c.resolve=g,c.reject=m,c.all=v,c.race=y},{1:1}],3:[function(e,t,n){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==Ms?Ms:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var o=s();function a(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function l(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(r){if("TypeError"!==r.name)throw r;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)n.append(e[i]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var c=Promise;function u(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function h(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function d(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var p="local-forage-detect-blob-support",g=void 0,m={},v=Object.prototype.toString,y="readonly",w="readwrite";function b(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),r=0;r<t;r++)i[r]=e.charCodeAt(r);return n}function x(e){return new c((function(t){var n=e.transaction(p,w),i=l([""]);n.objectStore(p).put(i,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function A(e){return"boolean"==typeof g?c.resolve(g):x(e).then((function(e){return g=e}))}function T(e){var t=m[e.name],n={};n.promise=new c((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function S(e){var t=m[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function E(e,t){var n=m[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function D(e,t){return new c((function(n,i){if(m[e.name]=m[e.name]||k(),e.db){if(!t)return n(e.db);T(e),e.db.close()}var r=[e.name];t&&r.push(e.version);var s=o.open.apply(o,r);t&&(s.onupgradeneeded=function(t){var n=s.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(p)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),s.onerror=function(e){e.preventDefault(),i(s.error)},s.onsuccess=function(){n(s.result),S(e)}}))}function C(e){return D(e,!1)}function I(e){return D(e,!0)}function M(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,r=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),r||n){if(n){var s=e.db.version+1;s>e.version&&(e.version=s)}return!0}return!1}function B(e){return new c((function(t,n){var i=new FileReader;i.onerror=n,i.onloadend=function(n){var i=btoa(n.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function R(e){return l([b(atob(e.data))],{type:e.type})}function P(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then((function(){var e=m[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return h(n,e,e),n}function _(e){T(e);for(var t=m[e.name],n=t.forages,i=0;i<n.length;i++){var r=n[i];r._dbInfo.db&&(r._dbInfo.db.close(),r._dbInfo.db=null)}return e.db=null,C(e).then((function(t){return e.db=t,M(e)?I(e):t})).then((function(i){e.db=t.db=i;for(var r=0;r<n.length;r++)n[r]._dbInfo.db=i})).catch((function(t){throw E(e,t),t}))}function L(e,t,n,i){void 0===i&&(i=1);try{var r=e.db.transaction(e.storeName,t);n(null,r)}catch(r){if(i>0&&(!e.db||"InvalidStateError"===r.name||"NotFoundError"===r.name))return c.resolve().then((function(){if(!e.db||"NotFoundError"===r.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),I(e)})).then((function(){return _(e).then((function(){L(e,t,n,i-1)}))})).catch(n);n(r)}}function k(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function N(e){var t=this,n={db:null};if(e)for(var i in e)n[i]=e[i];var r=m[n.name];r||(r=k(),m[n.name]=r),r.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O);var s=[];function o(){return c.resolve()}for(var a=0;a<r.forages.length;a++){var l=r.forages[a];l!==t&&s.push(l._initReady().catch(o))}var u=r.forages.slice(0);return c.all(s).then((function(){return n.db=r.db,C(n)})).then((function(e){return n.db=e,M(n,t._defaultConfig.version)?I(n):e})).then((function(e){n.db=r.db=e,t._dbInfo=n;for(var i=0;i<u.length;i++){var s=u[i];s!==t&&(s._dbInfo.db=n.db,s._dbInfo.version=n.version)}}))}function U(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){L(n._dbInfo,y,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName).get(e);o.onsuccess=function(){var e=o.result;void 0===e&&(e=null),P(e)&&(e=R(e)),t(e)},o.onerror=function(){i(o.error)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function F(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){L(n._dbInfo,y,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName).openCursor(),a=1;o.onsuccess=function(){var n=o.result;if(n){var i=n.value;P(i)&&(i=R(i));var r=e(i,n.key,a++);void 0!==r?t(r):n.continue()}else t()},o.onerror=function(){i(o.error)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function j(e,t,n){var i=this;e=d(e);var r=new c((function(n,r){var s;i.ready().then((function(){return s=i._dbInfo,"[object Blob]"===v.call(t)?A(s.db).then((function(e){return e?t:B(t)})):t})).then((function(t){L(i._dbInfo,w,(function(s,o){if(s)return r(s);try{var a=o.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var l=a.put(t,e);o.oncomplete=function(){void 0===t&&(t=null),n(t)},o.onabort=o.onerror=function(){var e=l.error?l.error:l.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return u(r,n),r}function z(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){L(n._dbInfo,w,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName).delete(e);s.oncomplete=function(){t()},s.onerror=function(){i(o.error)},s.onabort=function(){var e=o.error?o.error:o.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function H(e){var t=this,n=new c((function(e,n){t.ready().then((function(){L(t._dbInfo,w,(function(i,r){if(i)return n(i);try{var s=r.objectStore(t._dbInfo.storeName).clear();r.oncomplete=function(){e()},r.onabort=r.onerror=function(){var e=s.error?s.error:s.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return u(n,e),n}function G(e){var t=this,n=new c((function(e,n){t.ready().then((function(){L(t._dbInfo,y,(function(i,r){if(i)return n(i);try{var s=r.objectStore(t._dbInfo.storeName).count();s.onsuccess=function(){e(s.result)},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return u(n,e),n}function V(e,t){var n=this,i=new c((function(t,i){e<0?t(null):n.ready().then((function(){L(n._dbInfo,y,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName),a=!1,l=o.openKeyCursor();l.onsuccess=function(){var n=l.result;n?0===e||a?t(n.key):(a=!0,n.advance(e)):t(null)},l.onerror=function(){i(l.error)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function Y(e){var t=this,n=new c((function(e,n){t.ready().then((function(){L(t._dbInfo,y,(function(i,r){if(i)return n(i);try{var s=r.objectStore(t._dbInfo.storeName).openKeyCursor(),o=[];s.onsuccess=function(){var t=s.result;t?(o.push(t.key),t.continue()):e(o)},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return u(n,e),n}function W(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,r=this;if(e.name){var s=e.name===n.name&&r._dbInfo.db?c.resolve(r._dbInfo.db):C(e).then((function(t){var n=m[e.name],i=n.forages;n.db=t;for(var r=0;r<i.length;r++)i[r]._dbInfo.db=t;return t}));i=e.storeName?s.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;T(e);var i=m[e.name],r=i.forages;t.close();for(var s=0;s<r.length;s++){var a=r[s];a._dbInfo.db=null,a._dbInfo.version=n}var l=new c((function(t,i){var r=o.open(e.name,n);r.onerror=function(e){r.result.close(),i(e)},r.onupgradeneeded=function(){r.result.deleteObjectStore(e.storeName)},r.onsuccess=function(){var e=r.result;e.close(),t(e)}}));return l.then((function(e){i.db=e;for(var t=0;t<r.length;t++){var n=r[t];n._dbInfo.db=e,S(n._dbInfo)}})).catch((function(t){throw(E(e,t)||c.resolve()).catch((function(){})),t}))}})):s.then((function(t){T(e);var n=m[e.name],i=n.forages;t.close();for(var r=0;r<i.length;r++)i[r]._dbInfo.db=null;var s=new c((function(t,n){var i=o.deleteDatabase(e.name);i.onerror=i.onblocked=function(e){var t=i.result;t&&t.close(),n(e)},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}}));return s.then((function(e){n.db=e;for(var t=0;t<i.length;t++)S(i[t]._dbInfo)})).catch((function(t){throw(E(e,t)||c.resolve()).catch((function(){})),t}))}))}else i=c.reject("Invalid arguments");return u(i,t),i}var X={_driver:"asyncStorage",_initStorage:N,_support:a(),iterate:F,getItem:U,setItem:j,removeItem:z,clear:H,length:G,key:V,keys:Y,dropInstance:W};function Q(){return"function"==typeof openDatabase}var K="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Z="~~local_forage_type~",q=/^~~local_forage_type~([^~]+)~/,J="__lfsc__:",$=J.length,ee="arbf",te="blob",ne="si08",ie="ui08",re="uic8",se="si16",oe="si32",ae="ur16",le="ui32",ce="fl32",ue="fl64",he=$+ee.length,de=Object.prototype.toString;function fe(e){var t,n,i,r,s,o=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);var c=new ArrayBuffer(o),u=new Uint8Array(c);for(t=0;t<a;t+=4)n=K.indexOf(e[t]),i=K.indexOf(e[t+1]),r=K.indexOf(e[t+2]),s=K.indexOf(e[t+3]),u[l++]=n<<2|i>>4,u[l++]=(15&i)<<4|r>>2,u[l++]=(3&r)<<6|63&s;return c}function pe(e){var t,n=new Uint8Array(e),i="";for(t=0;t<n.length;t+=3)i+=K[n[t]>>2],i+=K[(3&n[t])<<4|n[t+1]>>4],i+=K[(15&n[t+1])<<2|n[t+2]>>6],i+=K[63&n[t+2]];return n.length%3==2?i=i.substring(0,i.length-1)+"=":n.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function ge(e,t){var n="";if(e&&(n=de.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var i,r=J;e instanceof ArrayBuffer?(i=e,r+=ee):(i=e.buffer,"[object Int8Array]"===n?r+=ne:"[object Uint8Array]"===n?r+=ie:"[object Uint8ClampedArray]"===n?r+=re:"[object Int16Array]"===n?r+=se:"[object Uint16Array]"===n?r+=ae:"[object Int32Array]"===n?r+=oe:"[object Uint32Array]"===n?r+=le:"[object Float32Array]"===n?r+=ce:"[object Float64Array]"===n?r+=ue:t(new Error("Failed to get type for BinaryArray"))),t(r+pe(i))}else if("[object Blob]"===n){var s=new FileReader;s.onload=function(){var n=Z+e.type+"~"+pe(this.result);t(J+te+n)},s.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}}function me(e){if(e.substring(0,$)!==J)return JSON.parse(e);var t,n=e.substring(he),i=e.substring($,he);if(i===te&&q.test(n)){var r=n.match(q);t=r[1],n=n.substring(r[0].length)}var s=fe(n);switch(i){case ee:return s;case te:return l([s],{type:t});case ne:return new Int8Array(s);case ie:return new Uint8Array(s);case re:return new Uint8ClampedArray(s);case se:return new Int16Array(s);case ae:return new Uint16Array(s);case oe:return new Int32Array(s);case le:return new Uint32Array(s);case ce:return new Float32Array(s);case ue:return new Float64Array(s);default:throw new Error("Unkown type: "+i)}}var ve={serialize:ge,deserialize:me,stringToBuffer:fe,bufferToString:pe};function ye(e,t,n,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,i)}function we(e){var t=this,n={db:null};if(e)for(var i in e)n[i]="string"!=typeof e[i]?e[i].toString():e[i];var r=new c((function(e,i){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return i(e)}n.db.transaction((function(r){ye(r,n,(function(){t._dbInfo=n,e()}),(function(e,t){i(t)}))}),i)}));return n.serializer=ve,r}function be(e,t,n,i,r,s){e.executeSql(n,i,r,(function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?s(e,o):ye(e,t,(function(){e.executeSql(n,i,r,s)}),s)}),s):s(e,o)}),s)}function xe(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"SELECT * FROM "+r.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var i=n.rows.length?n.rows.item(0).value:null;i&&(i=r.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function Ae(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"SELECT * FROM "+r.storeName,[],(function(n,i){for(var s=i.rows,o=s.length,a=0;a<o;a++){var l=s.item(a),c=l.value;if(c&&(c=r.serializer.deserialize(c)),void 0!==(c=e(c,l.key,a+1)))return void t(c)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function Te(e,t,n,i){var r=this;e=d(e);var s=new c((function(s,o){r.ready().then((function(){void 0===t&&(t=null);var a=t,l=r._dbInfo;l.serializer.serialize(t,(function(t,c){c?o(c):l.db.transaction((function(n){be(n,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){s(a)}),(function(e,t){o(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void s(Te.apply(r,[e,a,n,i-1]));o(t)}}))}))})).catch(o)}));return u(s,n),s}function Se(e,t,n){return Te.apply(this,[e,t,n,1])}function Ee(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"DELETE FROM "+r.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function De(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){be(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return u(n,e),n}function Ce(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){be(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,n){var i=n.rows.item(0).c;e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return u(n,e),n}function Ie(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"SELECT key FROM "+r.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var i=n.rows.length?n.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function Me(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){be(t,i,"SELECT key FROM "+i.storeName,[],(function(t,n){for(var i=[],r=0;r<n.rows.length;r++)i.push(n.rows.item(r).key);e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return u(n,e),n}function Be(e){return new c((function(t,n){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,i){for(var r=[],s=0;s<i.rows.length;s++)r.push(i.rows.item(s).name);t({db:e,storeNames:r})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}function Re(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,r=this;return i=e.name?new c((function(t){var i;i=e.name===n.name?r._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(Be(i))})).then((function(e){return new c((function(t,n){e.db.transaction((function(i){function r(e){return new c((function(t,n){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var s=[],o=0,a=e.storeNames.length;o<a;o++)s.push(r(e.storeNames[o]));c.all(s).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):c.reject("Invalid arguments"),u(i,t),i}var Pe={_driver:"webSQLStorage",_initStorage:we,_support:Q(),iterate:Ae,getItem:xe,setItem:Se,removeItem:Ee,clear:De,length:Ce,key:Ie,keys:Me,dropInstance:Re};function Oe(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function _e(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function Le(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function ke(){return!Le()||localStorage.length>0}function Ne(e){var t=this,n={};if(e)for(var i in e)n[i]=e[i];return n.keyPrefix=_e(e,t._defaultConfig),ke()?(t._dbInfo=n,n.serializer=ve,c.resolve()):c.reject()}function Ue(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var i=localStorage.key(n);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return u(n,e),n}function Fe(e,t){var n=this;e=d(e);var i=n.ready().then((function(){var t=n._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return u(i,t),i}function je(e,t){var n=this,i=n.ready().then((function(){for(var t=n._dbInfo,i=t.keyPrefix,r=i.length,s=localStorage.length,o=1,a=0;a<s;a++){var l=localStorage.key(a);if(0===l.indexOf(i)){var c=localStorage.getItem(l);if(c&&(c=t.serializer.deserialize(c)),void 0!==(c=e(c,l.substring(r),o++)))return c}}}));return u(i,t),i}function ze(e,t){var n=this,i=n.ready().then((function(){var t,i=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return u(i,t),i}function He(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,i=[],r=0;r<n;r++){var s=localStorage.key(r);0===s.indexOf(e.keyPrefix)&&i.push(s.substring(e.keyPrefix.length))}return i}));return u(n,e),n}function Ge(e){var t=this.keys().then((function(e){return e.length}));return u(t,e),t}function Ve(e,t){var n=this;e=d(e);var i=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return u(i,t),i}function Ye(e,t,n){var i=this;e=d(e);var r=i.ready().then((function(){void 0===t&&(t=null);var n=t;return new c((function(r,s){var o=i._dbInfo;o.serializer.serialize(t,(function(t,i){if(i)s(i);else try{localStorage.setItem(o.keyPrefix+e,t),r(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||s(e),s(e)}}))}))}));return u(r,n),r}function We(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var i,r=this;return i=e.name?new c((function(t){e.storeName?t(_e(e,r._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):c.reject("Invalid arguments"),u(i,t),i}var Xe={_driver:"localStorageWrapper",_initStorage:Ne,_support:Oe(),iterate:je,getItem:Fe,setItem:Ye,removeItem:Ve,clear:Ue,length:Ge,key:ze,keys:He,dropInstance:We},Qe=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Ke=function(e,t){for(var n=e.length,i=0;i<n;){if(Qe(e[i],t))return!0;i++}return!1},Ze=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},qe={},Je={},$e={INDEXEDDB:X,WEBSQL:Pe,LOCALSTORAGE:Xe},et=[$e.INDEXEDDB._driver,$e.WEBSQL._driver,$e.LOCALSTORAGE._driver],tt=["dropInstance"],nt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function rt(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function st(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(Ze(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var ot=function(){function e(t){for(var n in r(this,e),$e)if($e.hasOwnProperty(n)){var i=$e[n],s=i._driver;this[n]=s,qe[s]||this.defineDriver(i)}this._defaultConfig=st({},it),this._config=st({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var i=new c((function(t,n){try{var i=e._driver,r=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(r);for(var s=nt.concat("_initStorage"),o=0,a=s.length;o<a;o++){var l=s[o];if((!Ke(tt,l)||e[l])&&"function"!=typeof e[l])return void n(r)}var h=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=c.reject(t);return u(n,arguments[arguments.length-1]),n}},n=0,i=tt.length;n<i;n++){var r=tt[n];e[r]||(e[r]=t(r))}};h();var d=function(n){qe[i]&&console.info("Redefining LocalForage driver: "+i),qe[i]=e,Je[i]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}));return h(i,t,n),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var i=qe[e]?c.resolve(qe[e]):c.reject(new Error("Driver not found."));return h(i,t,n),i},e.prototype.getSerializer=function(e){var t=c.resolve(ve);return h(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return h(n,e,e),n},e.prototype.setDriver=function(e,t,n){var i=this;Ze(e)||(e=[e]);var r=this._getSupportedDrivers(e);function s(){i._config.driver=i.driver()}function o(e){return i._extend(e),s(),i._ready=i._initStorage(i._config),i._ready}function a(e){return function(){var t=0;function n(){for(;t<e.length;){var r=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(r).then(o).catch(n)}s();var a=new Error("No available storage method found.");return i._driverSet=c.reject(a),i._driverSet}return n()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return c.resolve()})):c.resolve();return this._driverSet=l.then((function(){var e=r[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,s(),i._wrapLibraryMethodsWithReady(),i._initDriver=a(r)}))})).catch((function(){s();var e=new Error("No available storage method found.");return i._driverSet=c.reject(e),i._driverSet})),h(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!Je[e]},e.prototype._extend=function(e){st(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,i=e.length;n<i;n++){var r=e[n];this.supports(r)&&t.push(r)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=nt.length;e<t;e++)rt(this,nt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),at=new ot;t.exports=at},{3:3}]},{},[4])(4);class of{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((n=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const af=()=>{self.noCompressWorker=function(e,t){const[n]=new Uint32Array(e,t,1),i={byteOffset:t+=4,length:3*n},r={byteOffset:t+=3*n*4,length:2*n},s={byteOffset:t+=2*n*4,length:4*n},o={byteOffset:t+=4*n*1,length:3*n};t+=3*n*1;let a=(s.length+o.length)%4;a>0&&(a=4-a,t+=a);const l=new Uint32Array(e,t,1);t+=4;const[c]=l,u={byteOffset:t,length:c};t+=4*c;const h=new Uint32Array(e,t,1);t+=4;const[d]=h,f=[];if(d>0)for(let n=0;n<d;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);f.push({start:n,count:i,uuid:a,alphaMode:r})}return{buffer:e,position:i,normal:o,color:s,texcoord:r,indice:u,sub_mesh:f}}},lf=()=>{self.gzipCompressWorker=function(e){const t=new Uint8Array(e,4,e.byteLength-4),n=new pako.Inflate;n.push(t,!0);const{result:i}=n;if(i instanceof Uint8Array){const{buffer:e}=i;let t=0;const[n]=new Uint32Array(e,t,1);t+=4;const r={byteOffset:t,length:3*n};t+=3*n*4;const s={byteOffset:t,length:2*n};t+=2*n*4;const o={byteOffset:t,length:4*n};t+=4*n*1;const a={byteOffset:t,length:3*n};t+=3*n*1;let l=(o.length+a.length)%4;l>0&&(l=4-l,t+=l);const c=new Uint32Array(e,t,1);t+=4;const[u]=c,h={byteOffset:t,length:u};t+=4*u;const d=new Uint32Array(e,t,1);t+=4;const[f]=d,p=[];if(f>0)for(let n=0;n<f;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);p.push({start:n,count:i,uuid:a,alphaMode:r})}return{buffer:e,position:r,normal:a,color:o,texcoord:s,indice:h,sub_mesh:p}}}},cf=()=>{self.parseChunkWorker=function(e){let t=0;const n=new Int8Array(e,t,128);t+=128,(new TextDecoder).decode(n.slice(0,4));const[i]=n.slice(4,8);if(0===i)return self.noCompressWorker(e,t);if(1===i){const t=e.slice(128);return self.gzipCompressWorker(t)}throw new Error("unknown compress mode [ .sbmx model ]")}},uf="\n onmessage = function ( e ) {\n \n const message = e.data\n\n switch ( message.type ) {\n\n case 'decode': {\n\n const chunkInfo = self.parseChunkWorker( message.data )\n\n if ( chunkInfo ) { \n\n self.postMessage( \n { type: 'decode', data: chunkInfo, }, \n [ chunkInfo.buffer ]\n )\n\n } else {\n\n self.postMessage( { type: 'decode', data: {}, } )\n\n }\n\n break\n \n }\n \n }\n\n }\n\n",hf="textureIndex.json";class df extends pt{constructor(e){super(),this.store=e,this.loadedTextures=new Map,this.loadedMaterialsMap=new Map,this.defaultMaterial=new F({name:"defaultDatMaterial",color:0}),this.loadedMaterials=[this.defaultMaterial],this.dracoDecoderPath=null,this.workerPool=new of(4),this.workerSourceURL="";const t=this._initWorkerCreator();this.workerPool.setWorkerCreator(t)}parseAsync(e,t){return Fn(this,void 0,void 0,(function*(){const[n]=yield Promise.allSettled([this._decodeBuffer(e,t),this._createMaterial(t)]);if("fulfilled"===n.status&&n.value){const e=Rn(t),i=this._createMesh(n.value,e),r=new wt;return r.add(i),r}}))}_decodeBuffer(e,t){return Fn(this,void 0,void 0,(function*(){const n=yield this.store.getItem(`${t}_object`);if(n)return n;const[{data:i}]=yield Promise.all([this.workerPool.postMessage({type:"decode",data:e},[e])]);if(i){const{type:e,data:n}=null!=i?i:{};if("decode"===e&&n){const{buffer:{byteLength:e}}=n;return Fi(e)&&e/1024/1024<=500&&Kn((()=>{this.store.setItem(`${t}_object`,n)})),n}}}))}_initWorkerCreator(){if(!this.workerSourceURL){const e=af.toString(),t=lf.toString(),n=cf.toString(),i=["/* dat decoder */",["/* pako */","\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pako = {}));\n}(this, (function (exports) { 'use strict';\n\n // Note: adler32 takes 12% for level 0 and 2% for level 6.\n // It isn't worth it to make additional optimizations as in original.\n // Small size is preferable.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express ofr implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const adler32 = (adler, buf, len, pos) => {\n let s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n };\n\n\n var adler32_1 = adler32;\n\n // Note: we can't get significant speed boost here.\n // So write code to minimize size - no pregenerated tables\n // and array tools dependencies.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // Use ordinary array, since untyped makes no boost here\n const makeTable = () => {\n let c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n };\n\n // Create table on load. Just 255 signed longs. Not a problem.\n const crcTable = new Uint32Array(makeTable());\n\n\n const crc32 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n\n crc ^= -1;\n\n for (let i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n };\n\n\n var crc32_1 = crc32;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // See state defs from inflate.js\n const BAD$1 = 30; /* got a data error -- remain here until reset */\n const TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n /*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n var inffast = function inflate_fast(strm, start) {\n let _in; /* local strm.input */\n let last; /* have enough input while in < last */\n let _out; /* local strm.output */\n let beg; /* inflate()'s initial strm.output */\n let end; /* while out < end, enough space available */\n //#ifdef INFLATE_STRICT\n let dmax; /* maximum distance from zlib header */\n //#endif\n let wsize; /* window size or zero if not using window */\n let whave; /* valid bytes in the window */\n let wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n let s_window; /* allocated sliding window, if wsize != 0 */\n let hold; /* local strm.hold */\n let bits; /* local strm.bits */\n let lcode; /* local strm.lencode */\n let dcode; /* local strm.distcode */\n let lmask; /* mask for first level of length codes */\n let dmask; /* mask for first level of distance codes */\n let here; /* retrieved table entry */\n let op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n let len; /* match length, unused bytes */\n let dist; /* match distance */\n let from; /* where to copy match from */\n let from_source;\n\n\n let input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n const state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n //#ifdef INFLATE_STRICT\n dmax = state.dmax;\n //#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n //#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n //#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // if (len <= op - whave) {\n // do {\n // output[_out++] = 0;\n // } while (--len);\n // continue top;\n // }\n // len -= op - whave;\n // do {\n // output[_out++] = 0;\n // } while (--op > whave);\n // if (op === 0) {\n // from = _out - dist;\n // do {\n // output[_out++] = output[from++];\n // } while (--len);\n // continue top;\n // }\n //#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const MAXBITS = 15;\n const ENOUGH_LENS$1 = 852;\n const ENOUGH_DISTS$1 = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const CODES$1 = 0;\n const LENS$1 = 1;\n const DISTS$1 = 2;\n\n const lbase = new Uint16Array([ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n ]);\n\n const lext = new Uint8Array([ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n ]);\n\n const dbase = new Uint16Array([ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n ]);\n\n const dext = new Uint8Array([ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n ]);\n\n const inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) =>\n {\n const bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n let len = 0; /* a code's length in bits */\n let sym = 0; /* index of code symbols */\n let min = 0, max = 0; /* minimum and maximum code lengths */\n let root = 0; /* number of index bits for root table */\n let curr = 0; /* number of index bits for current table */\n let drop = 0; /* code bits to drop for sub-table */\n let left = 0; /* number of prefix codes available */\n let used = 0; /* code entries in table used */\n let huff = 0; /* Huffman code */\n let incr; /* for incrementing code, index */\n let fill; /* index for replicating entries */\n let low; /* low bits for current root entry */\n let mask; /* mask for low root bits */\n let next; /* next available space in table */\n let base = null; /* base value table to use */\n let base_index = 0;\n // let shoextra; /* extra bits table to use */\n let end; /* use base and extra for symbol > end */\n const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n let extra = null;\n let extra_index = 0;\n\n let here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n };\n\n\n var inftrees = inflate_table;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var constants$1 = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n\n\n\n\n\n const CODES = 0;\n const LENS = 1;\n const DISTS = 2;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,\n Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,\n Z_DEFLATED\n } = constants$1;\n\n\n /* STATES ====================================================================*/\n /* ===========================================================================*/\n\n\n const HEAD = 1; /* i: waiting for magic header */\n const FLAGS = 2; /* i: waiting for method and flags (gzip) */\n const TIME = 3; /* i: waiting for modification time (gzip) */\n const OS = 4; /* i: waiting for extra flags and operating system (gzip) */\n const EXLEN = 5; /* i: waiting for extra length (gzip) */\n const EXTRA = 6; /* i: waiting for extra bytes (gzip) */\n const NAME = 7; /* i: waiting for end of file name (gzip) */\n const COMMENT = 8; /* i: waiting for end of comment (gzip) */\n const HCRC = 9; /* i: waiting for header crc (gzip) */\n const DICTID = 10; /* i: waiting for dictionary check value */\n const DICT = 11; /* waiting for inflateSetDictionary() call */\n const TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n const TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\n const STORED = 14; /* i: waiting for stored size (length and complement) */\n const COPY_ = 15; /* i/o: same as COPY below, but only first time in */\n const COPY = 16; /* i/o: waiting for input or output to copy stored block */\n const TABLE = 17; /* i: waiting for dynamic block table lengths */\n const LENLENS = 18; /* i: waiting for code length code lengths */\n const CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\n const LEN_ = 20; /* i: same as LEN below, but only first time in */\n const LEN = 21; /* i: waiting for length/lit/eob code */\n const LENEXT = 22; /* i: waiting for length extra bits */\n const DIST = 23; /* i: waiting for distance code */\n const DISTEXT = 24; /* i: waiting for distance extra bits */\n const MATCH = 25; /* o: waiting for output space to copy string */\n const LIT = 26; /* o: waiting for output space to write literal */\n const CHECK = 27; /* i: waiting for 32-bit check value */\n const LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\n const DONE = 29; /* finished check, done -- remain here until reset */\n const BAD = 30; /* got a data error -- remain here until reset */\n const MEM = 31; /* got an inflate() memory error -- remain here until reset */\n const SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n /* ===========================================================================*/\n\n\n\n const ENOUGH_LENS = 852;\n const ENOUGH_DISTS = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const MAX_WBITS = 15;\n /* 32K LZ77 window */\n const DEF_WBITS = MAX_WBITS;\n\n\n const zswap32 = (q) => {\n\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n };\n\n\n function InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Int32Array(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n }\n\n\n const inflateResetKeep = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\"));\n return Z_OK$1;\n };\n\n\n const inflateReset = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n };\n\n\n const inflateReset2 = (strm, windowBits) => {\n let wrap;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n };\n\n\n const inflateInit2 = (strm, windowBits) => {\n\n if (!strm) { return Z_STREAM_ERROR$1; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n const state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n };\n\n\n const inflateInit = (strm) => {\n\n return inflateInit2(strm, DEF_WBITS);\n };\n\n\n /*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\n let virgin = true;\n\n let lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\n\n const fixedtables = (state) => {\n\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n let sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inftrees(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inftrees(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n };\n\n\n /*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\n const updatewindow = (strm, src, end, copy) => {\n\n let dist;\n const state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n };\n\n\n const inflate$1 = (strm, flush) => {\n\n let state;\n let input, output; // input/output buffers\n let next; /* next input INDEX */\n let put; /* next output INDEX */\n let have, left; /* available input and output */\n let hold; /* bit buffer */\n let bits; /* bits in bit buffer */\n let _in, _out; /* save starting available input and output */\n let copy; /* number of stored or match bytes to copy */\n let from; /* where to copy match bytes from */\n let from_source;\n let here = 0; /* current decoding table entry */\n let here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //let last; /* parent table entry */\n let last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n let len; /* length to copy for repeats, bits to drop */\n let ret; /* return code */\n const hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n let opts;\n\n let n; // temporary variable for NEED_BITS\n\n const order = /* permutation of code lengths */\n new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR$1;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK$1;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n\n // !!! pako patch. Force use `options.windowBits` if passed.\n // Required to always use max window size by default.\n state.dmax = 1 << state.wbits;\n //state.dmax = 1 << len;\n\n //Tracev((stderr, \"inflate: zlib header ok\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32_1(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n output.set(input.subarray(next, next + copy), put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n //#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracev((stderr, \"inflate: table sizes ok\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inftrees(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inftrees(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inffast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracevv((stderr, \"inflate: distance %u\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // Trace((stderr, \"inflate.c too far\"));\n // copy -= state.whave;\n // if (copy > state.length) { copy = state.length; }\n // if (copy > left) { copy = left; }\n // left -= copy;\n // state.length -= copy;\n // do {\n // output[put++] = 0;\n // } while (--copy);\n // if (state.length === 0) { state.mode = LEN; }\n // break;\n //#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH$1))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n };\n\n\n const inflateEnd = (strm) => {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR$1;\n }\n\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n };\n\n\n const inflateGetHeader = (strm, head) => {\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK$1;\n };\n\n\n const inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n\n let state;\n let dictid;\n let ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32_1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\"));\n return Z_OK$1;\n };\n\n\n var inflateReset_1 = inflateReset;\n var inflateReset2_1 = inflateReset2;\n var inflateResetKeep_1 = inflateResetKeep;\n var inflateInit_1 = inflateInit;\n var inflateInit2_1 = inflateInit2;\n var inflate_2$1 = inflate$1;\n var inflateEnd_1 = inflateEnd;\n var inflateGetHeader_1 = inflateGetHeader;\n var inflateSetDictionary_1 = inflateSetDictionary;\n var inflateInfo = 'pako inflate (from Nodeca project)';\n\n /* Not implemented\n module.exports.inflateCopy = inflateCopy;\n module.exports.inflateGetDictionary = inflateGetDictionary;\n module.exports.inflateMark = inflateMark;\n module.exports.inflatePrime = inflatePrime;\n module.exports.inflateSync = inflateSync;\n module.exports.inflateSyncPoint = inflateSyncPoint;\n module.exports.inflateUndermine = inflateUndermine;\n */\n\n var inflate_1$1 = {\n \tinflateReset: inflateReset_1,\n \tinflateReset2: inflateReset2_1,\n \tinflateResetKeep: inflateResetKeep_1,\n \tinflateInit: inflateInit_1,\n \tinflateInit2: inflateInit2_1,\n \tinflate: inflate_2$1,\n \tinflateEnd: inflateEnd_1,\n \tinflateGetHeader: inflateGetHeader_1,\n \tinflateSetDictionary: inflateSetDictionary_1,\n \tinflateInfo: inflateInfo\n };\n\n const _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n\n var assign = function (obj /*from1, from2, from3, ...*/) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n };\n\n\n // Join array of chunks to single array.\n var flattenChunks = (chunks) => {\n // calculate data length\n let len = 0;\n\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n const result = new Uint8Array(len);\n\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n };\n\n var common = {\n \tassign: assign,\n \tflattenChunks: flattenChunks\n };\n\n // String encode/decode helpers\n\n\n // Quick check if we can use fast array to bin string conversion\n //\n // - apply(Array) can fail on Android 2.2\n // - apply(Uint8Array) can fail on iOS 5.1 Safari\n //\n let STR_APPLY_UIA_OK = true;\n\n try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n // Table with utf8 lengths (calculated by first byte of sequence)\n // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n // because max possible codepoint is 0x10ffff\n const _utf8len = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n }\n _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n // convert string to array (typed, when possible)\n var string2buf = (str) => {\n if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n };\n\n // Helper\n const buf2binstring = (buf, len) => {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n\n let result = '';\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n\n\n // convert array to string\n var buf2string = (buf, max) => {\n const len = max || buf.length;\n\n if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n\n let i, out;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n const utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n let c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n let c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n };\n\n\n // Calculate max possible position in utf8 buffer,\n // that will not break sequence. If that's not possible\n // - (very small limits) return max size as is.\n //\n // buf[] - utf8 bytes array\n // max - length limit (mandatory);\n var utf8border = (buf, max) => {\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n };\n\n var strings = {\n \tstring2buf: string2buf,\n \tbuf2string: buf2string,\n \tutf8border: utf8border\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n }\n\n var zstream = ZStream;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n }\n\n var gzheader = GZheader;\n\n const toString = Object.prototype.toString;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_NO_FLUSH, Z_FINISH,\n Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR\n } = constants$1;\n\n /* ===========================================================================*/\n\n\n /**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n /* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n /**\n * Inflate.result -> Uint8Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param).\n **/\n\n /**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n /**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n /**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n * const chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])\n * const chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * const inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\n function Inflate(options) {\n this.options = common.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ''\n }, options || {});\n\n const opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new zstream();\n this.strm.avail_out = 0;\n\n let status = inflate_1$1.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n\n this.header = new gzheader();\n\n inflate_1$1.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = inflate_1$1.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n }\n }\n }\n\n /**\n * Inflate#push(data[, flush_mode]) -> Boolean\n * - data (Uint8Array|ArrayBuffer): input data\n * - flush_mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE\n * flush modes. See constants. Skipped or `false` means Z_NO_FLUSH,\n * `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. If end of stream detected,\n * [[Inflate#onEnd]] will be called.\n *\n * `flush_mode` is not needed for normal operation, because end of stream\n * detected automatically. You may try to use it for advanced things, but\n * this functionality was not tested.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\n Inflate.prototype.push = function (data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n\n if (this.ended) return false;\n\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n\n // Convert data if needed\n if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n for (;;) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate_1$1.inflate(strm, _flush_mode);\n\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$1.inflateSetDictionary(strm, dictionary);\n\n if (status === Z_OK) {\n status = inflate_1$1.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n // Replace code with more verbose\n status = Z_NEED_DICT;\n }\n }\n\n // Skip snyc markers if more data follows and not raw mode\n while (strm.avail_in > 0 &&\n status === Z_STREAM_END &&\n strm.state.wrap > 0 &&\n data[strm.next_in] !== 0)\n {\n inflate_1$1.inflateReset(strm);\n status = inflate_1$1.inflate(strm, _flush_mode);\n }\n\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n // Remember real `avail_out` value, because we may patch out buffer content\n // to align utf8 strings boundaries.\n last_avail_out = strm.avail_out;\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n\n if (this.options.to === 'string') {\n\n let next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail & realign counters\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n\n this.onData(utf8str);\n\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n\n // Must repeat iteration if out buffer is full\n if (status === Z_OK && last_avail_out === 0) continue;\n\n // Finalize if end of stream reached.\n if (status === Z_STREAM_END) {\n status = inflate_1$1.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n\n if (strm.avail_in === 0) break;\n }\n\n return true;\n };\n\n\n /**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|String): output data. When string output requested,\n * each chunk will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\n Inflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n };\n\n\n /**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH). By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\n Inflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = common.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n\n\n /**\n * inflate(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako');\n * const input = pako.deflate(new Uint8Array([1,2,3,4,5,6,7,8,9]));\n * let output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err) {\n * console.log(err);\n * }\n * ```\n **/\n function inflate(input, options) {\n const inflator = new Inflate(options);\n\n inflator.push(input);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) throw inflator.msg || messages[inflator.err];\n\n return inflator.result;\n }\n\n\n /**\n * inflateRaw(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n }\n\n\n /**\n * ungzip(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\n var Inflate_1 = Inflate;\n var inflate_2 = inflate;\n var inflateRaw_1 = inflateRaw;\n var ungzip = inflate;\n var constants = constants$1;\n\n var inflate_1 = {\n \tInflate: Inflate_1,\n \tinflate: inflate_2,\n \tinflateRaw: inflateRaw_1,\n \tungzip: ungzip,\n \tconstants: constants\n };\n\n exports.Inflate = Inflate_1;\n exports.constants = constants;\n exports['default'] = inflate_1;\n exports.inflate = inflate_2;\n exports.inflateRaw = inflateRaw_1;\n exports.ungzip = ungzip;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n","/* noCompress */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}")),"/* gzipCompress */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),"/* parseChunk */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n"),"","/* worker */",uf].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}return()=>new Worker(this.workerSourceURL)}_createMesh(e,t){const{buffer:n,position:i,normal:r,texcoord:s,indice:o,sub_mesh:a}=e,l=new Uint32Array(n,o.byteOffset,o.length),c=new Float32Array(n,i.byteOffset,i.length),u=new Int8Array(n,r.byteOffset,r.length),h=new Float32Array(n,s.byteOffset,s.length),d=new xe;d.setIndex(new f(l,1)),d.setAttribute("position",new f(c,3)),d.setAttribute("normal",new f(u,3,!0)),d.setAttribute("uv",new f(h,2));for(let e=0;e<a.length;e++){const{uuid:n,start:i,count:r}=a[e],s=this.loadedMaterialsMap.get(n);if(s){const{materialIndex:e}=s;d.addGroup(i,r,e)}else d.addGroup(i,r,0),yn(`sbmx material: not found uuid: ${n} in file: ${t+hf}`)}const p=new k(d,this.loadedMaterials);return p.castShadow=!0,p.receiveShadow=!0,p}_createMaterial(e){return Fn(this,void 0,void 0,(function*(){const t=Rn(e),n=t+hf,i=this.loadedTextures.get(n);if(i)return i;const r=yield this.store.getItem(`${e}_texture`);let s;if(r)s=r,this.loadedTextures.set(n,Promise.resolve(s));else{const t=this.loadedTextures.get(n);if(t)return t;const i=Qn(n).then((e=>e.json()));this.loadedTextures.set(n,i),s=yield i,Kn((()=>{this.store.setItem(`${e}_texture`,s)}))}Object.entries(s).forEach((e=>{let[n,i]=e;if(this.loadedMaterialsMap.has(n))return;const{name:r,base_map:s,nor_map:o,alphamode:l,color:c={r:1,g:1,b:1,a:1},metallic:u=.5,roughness:h=.5}=i,{r:d,g:f,b:p,a:g}=c,m=0!==l,v=new F({name:r,color:new a(d,f,p),side:L,metalness:u,roughness:h,opacity:g,transparent:m,depthWrite:!m});if(s){const e=t+s;(new Je).load(e,(e=>{e.flipY=!0,e.encoding=I,e.wrapS=D,e.wrapT=D,e.minFilter=jt,e.magFilter=A,e.needsUpdate=!0,v.map=e,v.needsUpdate=!0,Mu.needsUpdate=!0}))}if(o){const e=t+o;(new Je).load(e,(e=>{e.flipY=!0,e.encoding=I,e.wrapS=D,e.wrapT=D,e.needsUpdate=!0,v.normalMap=e,v.needsUpdate=!0,Mu.needsUpdate=!0}))}const y=this.loadedMaterials.push(v)-1;this.loadedMaterialsMap.set(n,{material:v,materialIndex:y})}))}))}dispose(){this.workerPool.dispose(),URL.revokeObjectURL(this.workerSourceURL)}}const ff=new Map,pf=e=>{var t;return null!==(t=null==e?void 0:e.toLowerCase().endsWith(".png"))&&void 0!==t&&t},gf=e=>{if(ff.has(e))return ff.get(e);const t=new l;return ff.set(e,t),(new zt).load(e,(e=>{t.image=e,t.needsUpdate=!0,Mu.needsUpdate=!0})),t.encoding=I,t.wrapS=D,t.wrapT=D,t.flipY=!1,t.anisotropy=16,t.mipmaps=[],t.generateMipmaps=!0,t},mf=(e,t,n,i)=>{const[r,s,o,l,c]=t,u=i||l<1;return new F({name:e,color:new a(r,s,o),opacity:l,transparent:u,depthWrite:!u,alphaTest:.01,map:n,side:c})};class vf extends DataView{constructor(e,t){super(e),this.isLE=!0,this.appKeys=t}byteRevers(e,t){const n=t%this.appKeys.length;return e^this.appKeys[n]}getSoonUint8(e){return this.byteRevers(this.getUint8(e),e)}getSoonUint16(e){const t=new DataView(new Uint8Array(2).buffer);for(let n=0;n<2;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint16(0,this.isLE)}getSoonUint32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint32(0,this.isLE)}getSoonFloat32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getFloat32(0,this.isLE)}}const yf=new TextDecoder;new TextDecoder;class wf{constructor(){this.materials=new Map}parseObject(e,t){const n=new ju(Object.assign(Object.assign({},t),{format:"sbm"})),i=new Nu({id:Yi()});n.add(i);const{materialsCache:r,meshsCache:s}=e;for(const[e,t]of Object.entries(r)){if(this.materials.has(e))continue;const{textureUrl:n,materialInfo:i}=t;let r=null;n&&(r=gf(n));const s=mf(e,i,r,pf(n));this.materials.set(e,s)}for(const[e,t]of Object.entries(s)){const{meshName:n,materialId:r,position:s,uv:o}=t,a=this.materials.get(r.toString());if(a){const t=new xe,r=new Float32Array(s),l=new Float32Array(o);r.length>0&&t.setAttribute("position",new f(r,3)),l.length>0&&t.setAttribute("uv",new f(l,2)),t.computeVertexNormals();const c=new _u(t,a,{id:`${e}_${Yi()}`,name:n||e});i.add(c)}}return n}}var bf=class{constructor(){this.materials=new Map,this.sbmInfo=null}parseBuffer(e,t,n){return Fn(this,void 0,void 0,(function*(){this.sbmInfo=t;const i=new DataView(e);let r=0;const s=[];for(let e=0;e<8;e++)s.push(i.getUint8(r)),r+=1;if("SBK-----"!==String.fromCharCode(...s))return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})格式或数据错误!`);const o=[],a=[],l=[];for(let e=0;e<32;e++)o.push(i.getUint8(r)),r+=1;const c=i.getUint8(r);r+=1;const u=i.getUint8(r);r+=1;for(let e=0;e<32;e++)a.push(i.getUint8(r)),r+=1;for(let e=0;e<64;e++)l.push(i.getUint8(r)),r+=1;const h=[...a,...l,...o],d=[];for(let e=0;e<h.length;e++)(e<=7||e>23&&e<=31||e>39&&e<=55||e>63&&e<=87||e>95&&e<=103)&&d.push(h[e]);if(64!==d.length)return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url} 数据错误!`);if(1===c){const e=i.buffer.slice(r,i.buffer.byteLength),t=new vf(e,d);return 1===u||2===u?this._parseV2(t,n):3===u?this._parseV3(t,n):Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})版本错误!`)}return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})key 错误!`)}))}_parseV2(e,n){let i=0;const r=performance.now();i+=66;const s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const o=new ju(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new Nu({id:Yi()});o.add(a);const l=e.getSoonUint16(i);i+=2;const c=e.getSoonUint16(i);i+=2,s.total=c;const u={};for(let t=0;t<l;++t){const t=e.getSoonUint16(i).toString();i+=2,u[t]={materialInfo:[]},i+=4,i+=4,i+=4,i+=4;const n=e.getSoonFloat32(i);i+=4;const r=e.getSoonFloat32(i);i+=4;const s=e.getSoonFloat32(i);i+=4;const o=e.getSoonFloat32(i);i+=4,i+=4,i+=4,i+=4,i+=4;let a=e.getSoonUint8(i);i+=1,0===a?a=L:1===a?a=_:2===a&&(a=d);const l=e.getSoonUint16(i);i+=2;let c=null;if(l>0){let n="",r="";for(let t=0;t<l;t++){const t=e.getSoonUint8(i);t>127?r=r+"%"+t.toString(16).toUpperCase():r.length>0?(n+=decodeURIComponent(r)+String.fromCharCode(t),r=""):n+=String.fromCharCode(t),i+=1}n=n.replace("\\","/");const{url:s,isPlatform:o}=this.sbmInfo,a=this.getTextureUrl(s,n,o);u[t].textureUrl=a,c=gf(a)}if(!this.materials.has(t)){const e=[n,r,s,o,a],i=mf(t,e,c,pf(u[t].textureUrl));this.materials.set(t,i),u[t].materialInfo=e}}const h={};for(let o=0;o<c;++o){const o=e.getSoonUint16(i);i+=2;const l=e.getSoonUint16(i).toString();i+=2,h[o]={materialId:l,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const c=[],u=[],d=[],p=[],g=e.getSoonUint16(i);if(i+=2,g>0)for(let n=0;n<g;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4,c.push(n)}const m=e.getSoonUint16(i);if(i+=2,m>0)for(let n=0;n<m;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4}const v=e.getSoonUint16(i);if(i+=2,v>0)for(let t=0;t<v;t++){const t=new M;t.setX(e.getSoonFloat32(i)),i+=4,t.setY(e.getSoonFloat32(i)),i+=4,u.push(t)}const y=e.getSoonUint16(i);if(i+=2,y>0)for(let t=0;t<y;t++){const t=e.getSoonUint16(i);i+=2;const n=e.getSoonUint16(i);i+=2;const r=e.getSoonUint16(i);i+=2;const s=[t,n,r];d.push(s),u.length>0&&p.push([u[s[0]],u[s[1]],u[s[2]]])}const w=[],b=[];for(let e=0;e<d.length;e++){const t=d[e],n=c[t[0]],i=c[t[1]],r=c[t[2]];w.push(...n.toArray(),...i.toArray(),...r.toArray());let s=new M,o=new M,a=new M;const l=p[e];void 0!==l&&(s=l[0],o=l[1],a=l[2]),b.push(...s.toArray(),...o.toArray(),...a.toArray())}const x=new Float32Array(w),A=new Float32Array(b);h[o].position=x.buffer,h[o].uv=A.buffer;const T=new xe;x.length>0&&T.setAttribute("position",new f(x,3)),A.length>0&&T.setAttribute("uv",new f(A,2)),T.computeVertexNormals();const S=this.materials.get(l);if(S){const e=new _u(T,S,{id:`${o}_${Yi()}`,name:o.toString()});a.add(e)}s.loaded++,s.timeStamp=performance.now()-r,null==n||n(s)}const p={materialsCache:u,meshsCache:h};return Promise.resolve({model:o,caches:p})}_parseV3(e,n){let i=0;i+=66;const r=performance.now(),s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const o=new ju(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new Nu({id:Yi()});o.add(a);const l=e.getSoonUint16(i);i+=2;const c=e.getSoonUint16(i);i+=2,s.total=c;const u={};for(let t=0;t<l;++t){const t=e.getSoonUint16(i).toString();i+=2,u[t]={materialInfo:[]},i+=4,i+=4,i+=4,i+=4;const n=e.getSoonFloat32(i);i+=4;const r=e.getSoonFloat32(i);i+=4;const s=e.getSoonFloat32(i);i+=4;const o=e.getSoonFloat32(i);i+=4,i+=4,i+=4,i+=4,i+=4;let a=e.getSoonUint8(i);i+=1,0===a?a=L:1===a?a=_:2===a&&(a=d);const l=e.getSoonUint16(i);i+=2;let c=null;if(l>0){let n="",r="";for(let t=0;t<l;t++){const t=e.getSoonUint8(i);t>127?r=r+"%"+t.toString(16).toUpperCase():r.length>0?(n+=decodeURIComponent(r)+String.fromCharCode(t),r=""):n+=String.fromCharCode(t),i+=1}n=n.replace("\\","/");const{url:s,isPlatform:o}=this.sbmInfo,a=this.getTextureUrl(s,n,o);u[t].textureUrl=a,c=gf(a)}if(!this.materials.has(t)){const e=[n,r,s,o,a],i=mf(t,e,c,pf(u[t].textureUrl));this.materials.set(t,i),u[t].materialInfo=e}}const h={};for(let o=0;o<c;++o){const o=e.getSoonUint16(i).toString();i+=2;const l=e.getSoonUint16(i);i+=2;let c="";if(l>0){const t=[];for(let n=0;n<l;n++){const n=e.getSoonUint8(i);t.push(n),i+=1}const n=new Uint8Array(t);c=yf.decode(n)}const u=e.getSoonUint16(i).toString();i+=2,h[o]={meshName:c,materialId:u,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const d=[],p=[],g=[],m=[],v=e.getSoonUint32(i);if(i+=4,v>0)for(let n=0;n<v;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4,d.push(n)}const y=e.getSoonUint32(i);if(i+=4,y>0)for(let n=0;n<y;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4}const w=e.getSoonUint32(i);if(i+=4,w>0)for(let t=0;t<w;t++){const t=new M;t.setX(e.getSoonFloat32(i)),i+=4,t.setY(e.getSoonFloat32(i)),i+=4,p.push(t)}const b=e.getSoonUint32(i);if(i+=4,b>0)for(let t=0;t<b;t++){const t=e.getSoonUint32(i);i+=4;const n=e.getSoonUint32(i);i+=4;const r=e.getSoonUint32(i);i+=4;const s=[t,n,r];g.push(s),p.length>0&&m.push([p[s[0]],p[s[1]],p[s[2]]])}const x=[],A=[];for(let e=0;e<g.length;e++){const t=g[e],n=d[t[0]],i=d[t[1]],r=d[t[2]];x.push(...n.toArray(),...i.toArray(),...r.toArray());let s=new M,o=new M,a=new M;const l=m[e];void 0!==l&&(s=l[0],o=l[1],a=l[2]),A.push(...s.toArray(),...o.toArray(),...a.toArray())}const T=new Float32Array(x),S=new Float32Array(A);h[o].position=T.buffer,h[o].uv=S.buffer;const E=new xe;if(T.length>0&&E.setAttribute("position",new f(T,3)),S.length>0&&E.setAttribute("uv",new f(S,2)),E.computeVertexNormals(),this.materials.has(u)){const e=new _u(E,this.materials.get(u),{id:`${o}_${Yi()}`,name:c});a.add(e)}s.loaded++,s.timeStamp=performance.now()-r,null==n||n(s)}const p={materialsCache:u,meshsCache:h};return Promise.resolve({model:o,caches:p})}getTextureUrl(e,t,n){let i="",r=t;const s=r.lastIndexOf("/");if(-1!==s&&(r=r.substring(s+1)),i=e,n){const e=i.split("/");e.length>1&&(e.splice(e.length-3,e.length),i=e.join("/")+"/Maps/"+r)}else{const e=i.lastIndexOf("/");-1!==e&&(i=i.substring(0,e+1)+"Maps/"+r)}return i}};class xf extends ih{constructor(e,t){super("Model",e,t),this.viewport=e,this.isDisposed=!1,this.modelsPromiseMap=new Map,this.modelsMap=new Map,this.store=sf.createInstance({name:"soonspace",storeName:"modelData"}),this.cacheStore=sf.createInstance({name:"soonspace",storeName:"modelCache"}),this.loadingManager=new de,this.datLoader=new df(this.cacheStore),this.gltfLoader=new od(this.loadingManager),this.fbxLoader=new Fh(this.loadingManager),this.dracoDecoderPath=null,this._initLoadingManager(this.loadingManager)}setDracoDecoderPath(e){this.dracoDecoderPath=e;const t=new tf;t.setDecoderPath(e),this.gltfLoader.setDRACOLoader(t),this.datLoader.dracoDecoderPath=e}load(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.scene;return Fn(this,void 0,void 0,(function*(){const{url:n}=e,i=this.modelsPromiseMap.get(n);if(i){if(yield i,this.isDisposed)return this.dispose(),null;const r=this.modelsMap.get(n);return r?this.clone(r,e,t):null}const r=this._innerLoad(e,t);return this.modelsPromiseMap.set(n,r),r}))}parse(e){return Fn(this,void 0,void 0,(function*(){const{url:t,id:n}=e;if(!t)return yn(`id: ${n} url: ${t} is empty`),null;switch(t.slice(t.lastIndexOf(".")+1).toLocaleUpperCase()){case"SBM":return this._parseSbm(e);case"SBMX":return this._parseSbmx(e);case"DAT":return this._parseDat(e);case"GLB":case"GLTF":return this._parseGltf(e);case"FBX":return this._parseFbx(e);default:return yn(`模型资源( id: ${n}, url: ${t} )格式错误,当前格式支持 sbm、sbmx、fbx、gltf、glb !`),null}}))}clone(e,t,n){return new Promise(((i,r)=>{var s;"Model"!==e.stype&&r("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:o,name:a,level:l,visible:c,position:u,rotation:h,scale:d,onClick:f,onDblClick:p,onRightClick:g,onLoad:m,userData:v}=t;function y(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)y(e.children[i],t.children[i],n)}const w=function(e){const t=new Map,n=new Map,i=e.sClone();return y(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(e instanceof xt){const i=e,r=t.get(e),s=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=s.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)}})),i}(e);w.animations=w.animations.map((e=>e.clone())),o&&(w.sid=o),a&&(w.name=a),l&&(w.level=l),!1===c&&w.hide(),u&&w.position.set(u.x,u.y,u.z),h&&w.rotation.set(h.x,h.y,h.z),d&&w.scale.set(d.x,d.y,d.z),w.onClick=f?f.bind(w):null,w.onDblClick=p?p.bind(w):null,w.onRightClick=g?g.bind(w):null,w.onLoad=m?m.bind(w):null,null===(s=w.onLoad)||void 0===s||s.call(w,w),v&&(w.userData=v),null!==n&&this.viewport.scener.addObject(w,n||this.scene||e.parent),i(w)}))}loadToGroup(e,t){return Fn(this,void 0,void 0,(function*(){const n=this.createGroup(e,null);return yield Promise.allSettled(t.map((e=>this.load(e,null).then((e=>e&&n.add(e))).catch(console.error)))),this.viewport.scener.addObject(n,this.scene),n}))}addForGroup(e,t){return Fn(this,void 0,void 0,(function*(){return e&&(yield Promise.allSettled(t.map((t=>Fn(this,void 0,void 0,(function*(){return this.load(t,null).then((t=>t&&this.viewport.scener.addObject(t,e))).catch(console.error)})))))),e}))}clearIdb(){return Fn(this,void 0,void 0,(function*(){yield this.store.clear(),yield this.cacheStore.clear()}))}dispose(){var e;this.isDisposed=!0,this.modelsPromiseMap.clear(),this.modelsMap.clear(),null===(e=this.gltfLoader.dracoLoader)||void 0===e||e.dispose(),this.datLoader.dispose()}_initLoadingManager(e){e.addHandler(/\.tga$/i,new rd)}_setModelsMap(e,t){this.modelsMap.has(e)||this.modelsMap.set(e,t)}_parseSbm(e){return Fn(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,{url:n}=e,i=t=>Fn(this,void 0,void 0,(function*(){const i=yield(new bf).parseBuffer(t,e),{model:r,caches:s}=i;return s&&Kn((()=>{this.cacheStore.setItem(n,s)})),r})),r=e=>{var t;null===(t=e.onLoad)||void 0===t||t.call(e,e)};if(t){const t=yield this.cacheStore.getItem(n);if(t){const n=(new wf).parseObject(t,e);return r(n),n}{const e=(yield this.store.getItem(n))||(yield this._fetchBuffer(n)),t=yield i(e);return r(t),t}}{const e=yield this._fetchBuffer(n),t=yield i(e);return r(t),t}}))}_parseSbmx(e){return Fn(this,void 0,void 0,(function*(){const{url:t}=e,n=yield this._getBuffer(t),i=Vi(n,0,8),r=new DataView(n.slice(8));switch(i){case"SBMG----":for(let e=0;e<r.byteLength;e++){const t=r.getUint8(e),n=(t>>4&15)+(t<<4&240);r.setUint8(e,n)}return this._parseGltf(e,r.buffer);case"SBMD----":return this._parseDat(e,r.buffer);default:return this._parseGltf(e,r.buffer)}}))}_parseDat(e,t){return Fn(this,void 0,void 0,(function*(){const{url:n}=e,i=t||(yield this._getBuffer(n)),r=new ju(Object.assign(Object.assign({},e),{format:"dat"})),s=yield this.datLoader.parseAsync(i,n);return s&&r.add(s),r}))}_parseGltf(e,t){return Fn(this,void 0,void 0,(function*(){const{url:n}=e,i=Rn(n),r=t||(yield this._getBuffer(n)),s=new ju(Object.assign(Object.assign({},e),{format:"gltf"})),o=yield this.gltfLoader.parseAsync(r,i),{animations:a}=o;return a&&a.length>0&&(s.animations=a),o.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),s.add(o.scene),s}))}_parseFbx(e){return Fn(this,void 0,void 0,(function*(){const{url:t}=e,n=Rn(t),i=yield this._getBuffer(t),r=new ju(Object.assign(Object.assign({},e),{format:"gltf"})),s=this.fbxLoader.parse(i,n),{animations:o}=s;return o&&o.length>0&&(r.animations=o),s.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),r.add(s),r}))}_innerLoad(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.scene;var n;return Fn(this,void 0,void 0,(function*(){const{url:i}=e,r=yield this.parse(e);return r?(null===(n=r.onLoad)||void 0===n||n.call(r,r),this._setModelsMap(i,r),null!==t&&this.viewport.scener.addObject(r,t),r):null}))}_fetchBuffer(e){return Fn(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,n=yield Qn(e),i=yield n.arrayBuffer();return t&&this.store.setItem(e,i),i}))}_getBuffer(e){return Fn(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options;if(t){const t=yield this.store.getItem(e);return t||this._fetchBuffer(e)}return this._fetchBuffer(e)}))}}class Af extends ih{constructor(e,t){super("Poi",e,t),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new Gu(t,e);return this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:i,type:r,name:s,level:o,visible:a,position:l,rotation:c,scale:u,onClick:h,onDblClick:d,onRightClick:f,userData:p}=t,g=e.sClone(!1,r);return this._copyMaterial(g),i&&(g.sid=i),s&&(g.name=s),o&&(g.level=o),Ui(a)&&(g.visible=a),l&&g.position.set(l.x,l.y,l.z),c&&g.rotation.set(c.x,c.y,c.z),u&&g.scale.set(u.x,u.y,u.z),g.onClick=h?h.bind(g):null,g.onDblClick=d?d.bind(g):null,g.onRightClick=f?f.bind(g):null,p&&(g.userData=p),null!==n&&this.viewport.scener.addObject(g,n||this.scene||e.parent),g}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this._createMaterial(e.url),i=new Gu(t,e);n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=this._createMaterial(t.url),i=new Gu(n,t);e.add(i)})),this.viewport.scener.addObject(e,this.scene)),e}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new Je).load(e);t.flipY=!0;const n=new et({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof k||e instanceof $e)&&(ji(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof Ae&&(e.material=e.material.clone()))}))}}class Tf extends ih{constructor(e,t){super("PoiNode",e,t)}create(e){this._openEnableRenderCss(e);const t=new Fu(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new Fu(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{this._openEnableRenderCss(t);const n=new Fu(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class Sf extends ih{constructor(e,t){super("Canvas3D",e,t)}create(e){const t=new $u(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=new $u(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=new $u(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}}class Ef{constructor(){this.graph=new Map,this.queue=null,this.previous=new Map}setGraph(e){if(!(e.length<1))for(const t of e){const[e,n]=t;this.graph.set(e,new Map);for(const t of n){const[n,i]=t,r=this.graph.get(e);null==r||r.set(n,i)}}}getPath(e,t){var n;if(e===t)return[];const i=this.queue=new In;i.add(e,0),this.previous.set(e,null);let r=null;for(;r=i.shift();){if(r===t){const e=[];for(;null!==r&&null!==this.previous.get(r);)e.unshift(r),r=null!==(n=this.previous.get(r))&&void 0!==n?n:null;return e}const e=i.getDistance(r);if(e===1/0)return[];const s=this.graph.get(r);s&&s.forEach(((t,n)=>{const s=i.getDistance(n),o=e+t;o<s&&(i.update(n,o),this.previous.set(n,r))}))}return[]}}class Df extends ih{constructor(e,t){super("Topology",e,t),this.dijkstra=new Ef}createFromGml(e){return Fn(this,void 0,void 0,(function*(){const{url:t,linkWidth:n=20,linkColor:i=65280,renderNode:r=!0,nodeColor:s=255}=e;return qn(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const o=[],a=new Map;let l=[],c=[];const u=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;ji(u)?u.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...u.state],c=[...c,...u.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],i=e.State.topoNode["gml:Node"].node_name;o.push({id:Ni(n)?n:"",name:Ni(i)?i:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),a.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],i=e.Transition.topoEdge["gml:Edge"].restrict["#text"],r=e.Transition.topoEdge["gml:Edge"].passable["#text"],s=a.get(t),l=a.get(n),c=e.Transition._attributes["gml:id"],u=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==s&&void 0!==l&&("2"!==r&&"3"!==r&&o[s].graphs.push({targetNodeId:n,linkInfo:{id:c,name:u},enable:!0,restrict:parseInt(i),passable:parseInt(r)}),"1"!==r&&"3"!==r&&o[l].graphs.push({targetNodeId:t,linkInfo:{id:c,name:u},enable:!0,restrict:parseInt(i),passable:parseInt(r)}))}));const h=new Qu(Object.assign(Object.assign({},e),{type:"network",nodes:o,linkWidth:n,renderLink:!0,linkColor:i,renderNode:r,nodeColor:s}));return this.setDijkstraGraph(h.nodes),this.viewport.scener.addObject(h,this.scene),Promise.resolve(h)}))}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e),n=new Qu(t);return this.setDijkstraGraph(n.nodes),this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},e.info),{nodes:t}));return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e),i=new Qu(t);this.setDijkstraGraph(i.nodes),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&t.forEach((t=>{const n=this.generateLineTopologyInfoNodeGraphs(t),i=new Qu(n);this.setDijkstraGraph(i.nodes),e.add(i)})),e}getShortestPath(e,n){const i=Pn(e.info.nodes),r=wn(n.start),s=wn(n.end);let o=null,a=1/0,l=null,c=1/0;for(let n=0;n<i.length;n++){const u=i[n];if(0===u.graphs.length)continue;const h=e.nodes.find((e=>e.sid===u.id));if(!h)continue;const d=h.getWorldPosition(new t),f=d.distanceTo(r),p=d.distanceTo(s);f<a&&(a=f,o=u),p<c&&(c=p,l=u)}if(!o||!l||o.id===l.id)return null;const u=o.id,h=l.id,d=this.dijkstra.getPath(u,h);if(0===d.length)return null;d.unshift(o.id);const f=[];for(let e=0;e<d.length;e++){const t=i.find((t=>t.id==d[e]));t&&(t.id+=Yi(),t.position.y+=.01,f.push(t))}const p=Object.assign(Object.assign(Object.assign({},n),{type:"line",nodes:f}),e.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(p);const g=new Qu(p);return this.viewport.scener.addObject(g,this.scene),g}getShortestPathByMultipleStartPoints(e,i){const{nodes:s}=e.info,o=[];i.start.forEach((e=>{const t=wn(e),n=wn(i.end);let r=null,a=1/0,l=null,c=1/0;if(s.forEach((e=>{if(e.graphs.length>0){const i=wn(e.position),s=i.distanceTo(t),o=i.distanceTo(n);s<a&&(a=s,r=e.id),o<c&&(c=o,l=e.id)}})),r&&l){let e=0;const i=this.dijkstra.getPath(r,l);if(i.length>0){const r=[{id:"startPoint",position:t,graphs:[]}];i.forEach(((n,i)=>{const o=s.find((e=>e.id==n));o&&(e+=0===i?wn(o.position).distanceTo(t):wn(o.position).distanceTo(wn(r[r.length-1].position)),r.push(o))})),r.push({id:"endPoint",position:n,graphs:[]}),e+=n.distanceTo(wn(r[r.length-1].position)),o.push({nodeInfo:r,pathLength:e})}}}));let a=[],l=1/0;if(o.forEach((e=>{let{nodeInfo:t,pathLength:n}=e;n<l&&(l=n,a=t)})),a.length){for(let e=0;e<a.length;e++)a[e].position.y+=.01;const s=Object.assign(Object.assign({},i),{type:"line",nodes:a,position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)});this.generateLineTopologyInfoNodeGraphs(s);const o=new Qu(s);return this.viewport.scener.addObject(o,this.scene),o}return null}getShortestPathByMultipleEndPoints(e,i){const{nodes:s}=e.info,o=[];i.end.forEach((e=>{const t=wn(i.start),n=wn(e);let r=null,a=1/0,l=null,c=1/0;if(s.forEach((e=>{if(e.graphs.length>0){const i=wn(e.position),s=i.distanceTo(t),o=i.distanceTo(n);s<a&&(a=s,r=e.id),o<c&&(c=o,l=e.id)}})),r&&l){let e=0;const i=this.dijkstra.getPath(r,l);if(i.length>0){const r=[{id:"startPoint",position:t,graphs:[]}];i.forEach(((n,i)=>{const o=s.find((e=>e.id==n));o&&(e+=0===i?wn(o.position).distanceTo(t):wn(o.position).distanceTo(wn(r[r.length-1].position)),r.push(o))})),r.push({id:"endPoint",position:n,graphs:[]}),e+=n.distanceTo(wn(r[r.length-1].position)),o.push({nodeInfo:r,pathLength:e})}}}));let a=[],l=1/0;if(o.forEach((e=>{let{nodeInfo:t,pathLength:n}=e;n<l&&(l=n,a=t)})),a.length){for(let e=0;e<a.length;e++)a[e].position.y+=.01;const s=Object.assign(Object.assign({},i),{type:"line",nodes:a,position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)});this.generateLineTopologyInfoNodeGraphs(s);const o=new Qu(s);return this.viewport.scener.addObject(o,this.scene),o}return null}setDijkstraGraph(e){const n=[];for(let i=0;i<e.length;i++){const r=e[i];if(0===r.graphs.length)continue;const s=[];for(let n=0;n<r.graphs.length;n++){const i=r.graphs[n],o=e.find((e=>e.sid===i.targetNodeId));if(!o)continue;const a=r.getWorldPosition(new t),l=o.getWorldPosition(new t);s.push([i.targetNodeId,a.distanceTo(l)])}n.push([r.sid,s])}n.length>0&&this.dijkstra.setGraph(n)}generateLineTopologyInfoNodeGraphs(e){const{type:t,nodes:n}=e;if("line"===t)for(let t=0;t<n.length;t++)if(t===n.length-1)n[t].graphs=[];else{const i=e.nodes[t],r=e.nodes[t+1];n[t].graphs=[{targetNodeId:r.id,linkInfo:{id:`${i.id}_to_${r.id}`,name:`${i.name||i.id}_to_${r.name||r.id}`},enable:!0,restrict:0,passable:0}]}return Object.assign(Object.assign({},e),{nodes:n})}}class Cf extends At{constructor(e,t){const n=new xe;n.setAttribute("position",new it([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new q({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new xe;i.setAttribute("position",new it([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new k(i,new z({side:_,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class If extends ih{constructor(e,t){super("Helper",e,t)}addGridHelper(e){const{id:t,size:n=1e3,divisions:i=20,color:r="#fff",position:s={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:a={x:1,y:1,z:1}}=e,l=new Ht(n,i,r,r);return l.position.set(s.x,s.y,s.z),l.rotation.set(o.x,o.y,o.z),l.scale.set(a.x,a.y,a.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,i=new Gt(n);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addBoxHelper(e){const{id:t,box:n,color:i="#00ff00"}=e,r=new Vt(n,new a(i));return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPlaneHelper(e){const{id:t,width:n=500,height:i=500,color:r="#00ff00",opacity:s=.2,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new _u(new ze(n,i),new z({color:r,opacity:s,transparent:s<1,side:d}),{id:t,position:o,rotation:a,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:i=500,height:r=500,opacity:s=1,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,u=(new Je).load(t),h=new ze(i,r);h.computeBoundingBox();const f=new F({side:d,map:u,transparent:s<1,opacity:s,roughness:.8});f.map&&(f.map.repeat.set(c.x,c.x),f.map.wrapS=D,f.map.wrapT=D,f.map.version++),a.x-=Math.PI/2,f.version++;const p=new eh(h,f,{id:n,position:o,rotation:a,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(e){const{id:t,light:n,color:i,size:r=50}=e,s=new Yt(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new Wt(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(e){const{id:t,light:n,color:i}=e,r=new Xt(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPointLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new Qt(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addRectAreaLightHelper(e){const{id:t,light:n,color:i}=e,r=new Cf(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}}class Mf extends ih{constructor(e,t){super("PluginObject",e,t)}createObject(e,t){const n=new Uu(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){return e?(this.viewport.scener.addObject(t,e),e):null}}class Bf extends ih{constructor(e,t){super("Group",e,t)}}class Rf{constructor(e){this.viewport=e,this.cache={objects:new Map},this.scene=e.scene,this.store={groupManager:new Bf(e,this.scene),lightManager:new rh(e,this.scene),modelManager:new xf(e,this.scene),poiManager:new Af(e,this.scene),poiNodeManager:new Tf(e,this.scene),canvas3DManager:new Sf(e,this.scene),topologyManager:new Df(e,this.scene),helperManager:new If(e,this.scene),pluginObjectManager:new Mf(e,this.scene)},e.postUpdate.set("ManagerRender",this.update.bind(this)),e.signals.objectAdded.add(this.setObjectCache.bind(this)),e.signals.objectRemoved.add(this.deleteObjectCache.bind(this))}levelUpdate(){const e=(e,t)=>{e.visible!==t&&(e.visible=t,e.matrixAutoUpdate=t,e.autoUpdate=!0)},t=t=>{const{level:n,handleHide:i,autoUpdate:r}=t,{max:s=null,min:o=null}=n;if(r)t.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!i&&(Fi(s)||Fi(o))){const n=this.viewport.camera.position.distanceTo(t.position);Fi(s)&&n>s||Fi(o)&&n<o?e(t,!1):e(t,!0)}};this.scene.traverse((e=>{(e instanceof ku||e instanceof _u)&&t(e)}))}update(){if(0===this.scene.children.length)return;const e=performance.now();this.viewport.options.levelEnabled&&this.levelUpdate(),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}isObjectInScene(e){let t=!1;return e.traverseAncestors((e=>{e===this.scene&&(t=!0)})),t}getObjectById(e){const t=this.getObjectCache(e);if(t){if(this.isObjectInScene(t))return t}return null}getObjectByName(e){return this._getObjectByProps("name",e)}getObjectByUserDataProperty(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&zi(i)&&(i instanceof ku||i instanceof _u||i.userData.stype)&&(Hi(e)&&e(i.userData)||Ni(e)&&i.userData[e]===t)&&n.push(i)})),n}removeObjectById(e){const t=this.getObjectById(e);return!!t&&(this.viewport.scener.removeObject(t),!0)}_getObjectByProps(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&((i instanceof ku||i instanceof _u)&&zi(i)&&i[e]===t||zi(i)&&i.userData.stype&&("name"===e&&i.name===t||"sid"===e&&i.userData.sid===t))&&n.push(i)})),n}getObjectCache(e){return this.cache.objects.get(e)}setObjectCache(e){const t=(e,t)=>{const n=this.cache.objects.get(t);n&&n!==e&&yn(`object id ${t} already exists in scene`)};null==e||e.traverse((n=>{if(n instanceof ku||n instanceof _u){if("string"==typeof n.sid&&n.sid.startsWith(gn))return;t(n,n.sid),this.cache.objects.set(n.sid,n)}else n.userData.sid&&e.userData.stype&&(t(n,n.userData.sid),this.cache.objects.set(n.userData.sid,n))}))}deleteObjectCache(e){null==e||e.traverse((t=>{t instanceof ku||t instanceof _u?this.cache.objects.delete(t.sid):t.userData.sid&&e.userData.stype&&this.cache.objects.delete(t.userData.sid)}))}clearObject(){this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.lightManager.clear()}dispose(){this.store.modelManager.dispose(),this.cache.objects.clear(),this.clear()}}function Pf(e){const t=Of(e),n=new m;n.setFromMatrix3(t);const i=e[0],r=n.clone();r.setPosition(i);const s=r.clone().invert(),o=e.map((e=>{const t=e.clone().applyMatrix4(s);return new M(t.x,t.y)})),a=new st(o),l=new rt(a),c=new Kt;c.setFromPoints(o);const u=_f(c);return l.getAttribute("uv").applyMatrix3(u),l.applyMatrix4(n),{geometry:l,polygonBox:c,modelMatrix:n,planeMatrix:r,projectionMatrix:s,position:i}}function Of(e){const[n,i,r]=e,s=new B;s.setFromCoplanarPoints(i,n,r);const o=s.normal,a=o.clone().cross(new t(0,0,1));a.equals(new t)&&a.set(1,0,0);const l=o.clone().cross(a);a.normalize(),l.normalize(),o.normalize();const c=new Pe;return c.elements=[a.x,a.y,a.z,l.x,l.y,l.z,o.x,o.y,o.z],c}function _f(e){const t=e.min,n=e.getSize(new M),i=new Pe;return i.elements=[n.x,0,0,0,n.y,0,t.x,t.y,1],i.invert()}function Lf(e,t){const n=kf(t);return e.intersectsBox(n)}function kf(e){const n=new i,r=n.min.clone(),s=n.max.clone();if(n.setFromObject(e),n.min.equals(r)&&n.max.equals(s)){const i=new t;e.getWorldPosition(i),n.min.copy(i),n.max.copy(i)}if(e.isInstancedMesh){const{count:t,matrixWorld:i,geometry:r}=e;let s=r.boundingBox;if(s||(r.computeBoundingBox(),s=r.boundingBox),s){const r=i.clone();for(let i=0;i<t;i++){const t=new m;e.getMatrixAt(i,t),t.premultiply(r);const o=s.clone();o.applyMatrix4(r),n.union(o)}}}return n}function Nf(e,t,n){if("string"==typeof e){let i=t?null==n?void 0:n.get(e):null;if(!i){i=(new Je).load(e),null==n||n.set(e,i)}return i}return e instanceof HTMLImageElement?new l(e):e instanceof HTMLCanvasElement?new je(e):new Le(e)}function Uf(e,t,n,i){const r=e.map,s=Nf(t,n,i);if(!r)return e.map=s,s;const o=s.source;return s.copy(r),s.source=o,e.map=s,s}function Ff(e,n){const{top:r,left:s,bottom:o,right:a,front:l,back:c}=e,u=new t(a,r,l),h=new t(s,o,c),d=new i;return function(e){return d.max.addVectors(e,u),d.min.subVectors(e,h),n.filter((e=>Lf(d,e)))}}function jf(e,n){const i=new O(new t,e);return function(e){return i.center.copy(e),n.filter((e=>Lf(i,e)))}}function zf(e,n){const i=e.length-1,r=[];for(let t=0;t<i;t++){const n=e[t],i=e[t+1],s=new R(n,i);r.push(s)}const s=new O(new t,n);return function(e){return e.filter((e=>{const n=kf(e),i=new t;n.getCenter(i);const o=r.filter((e=>{const t=e.closestPointToPointParameter(i);return 0<=t||t>=1}));if(0===o.length)return!1;let a=1/0,l=i;for(const e of o){const n=e.closestPointToPoint(i,!0,new t),r=i.distanceToSquared(n);r<a&&(a=r,l=n)}return s.center.copy(l),s.intersectsBox(n)}))}}function Hf(e,t){const{image:n,color:i,width:r,height:s,position:o,rotation:a,needLight:l,id:c,name:u,userData:h,level:d,visible:f,cache:p}=e,g=Un(e,["image","color","width","height","position","rotation","needLight","id","name","userData","level","visible","cache"]),m=new ze(r,s),v=n?Object.assign(Object.assign({transparent:!0},g),{map:Nf(n,null==p||p,t)}):g,y=l?new vt(v):new z(v),w=new _u(m,y,{id:c,name:u,userData:h,level:d,visible:f});return o&&w.position.set(o.x,o.y,o.z),a&&w.rotation.set(a.x,a.y,a.z),w}function Gf(e,n){const{points:i,image:r,color:s,needLight:o,id:a,name:l,userData:c,level:u,visible:h,cache:d}=e,f=Un(e,["points","image","color","needLight","id","name","userData","level","visible","cache"]),p=i.map((e=>new t(e.x,e.y,e.z))),g=r?Object.assign(Object.assign({transparent:!0},f),{map:Nf(r,null==d||d,n)}):f,m=o?new vt(g):new z(g),{geometry:v,position:y}=Pf(p),w=new _u(v,m,{id:a,name:l,userData:c,level:u,visible:h});return w.position.copy(y),w}class Vf{constructor(t){this.THREE=e,this.TWEEN=pn,this.utils=Xi,this.version=Jt,this.animation=Ki,this.library=th,this.plugins={},this.textureCache=new Map;const{el:n,options:i={},events:r={}}=t;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showStats:!1,showViewHelper:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{type:"free"},hoverEnabled:!1,levelEnabled:!1,closeInfoLog:!1,closeWarnLog:!1,useIndexedDB:!0,logarithmicDepthBuffer:!0}),i),this.viewport=new Ou(this.options),this.signals=this.viewport.signals,this.manager=new Rf(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(r),this._initDefaultSettings()}_init(){const{showGrid:e,background:t,fog:n,controls:i,closeInfoLog:r,closeWarnLog:s,useIndexedDB:o}=this.options;if(!r){vn(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),vn(qt,{color:"#3eaf7c","font-size":"24px"}),vn(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),vn("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),vn("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),vn("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}e&&this.addGridHelper(!0===e?{id:"defaultGridHelper"}:e),(null==t?void 0:t.skyBox)?Ni(null==t?void 0:t.skyBox)?this.setSphereSkyBackground(null==t?void 0:t.skyBox):zi(null==t?void 0:t.skyBox)&&this.setSkyBackground(t.skyBox.dirPath,t.skyBox.fileNames):(null==t?void 0:t.img)?this.setBackgroundImage(t.img):(null==t?void 0:t.color)&&this.setBackgroundColor(t.color),n&&this.openSceneFog(!0===n?void 0:n),i&&this.setControlsOptions(i),s&&(window.console.warn=function(){}),o&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:i,modelRightClick:r,modelDblClick:s,poiHover:o,poiUnHover:a,poiClick:l,poiRightClick:c,poiDblClick:u,selectPosition:h,sceneClick:d,resize:f}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),i&&this.signals.modelClick.add(i),r&&this.signals.modelRightClick.add(r),s&&this.signals.modelDblClick.add(s),o&&this.signals.poiHover.add(o),a&&this.signals.poiUnHover.add(a),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),u&&this.signals.poiDblClick.add(u),h&&this.signals.selectPosition.add(h),d&&this.signals.sceneClick.add(d),f&&this.signals.windowResize.add(f),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultSettings(){this.setEnvironment(),this.setColorSpace("sRGB"),this.setToneMapping({type:"ACESFilmic",exposure:.8})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){const n=this.getObjectById(e);return this.manager.store.pluginObjectManager.addToObject(n,t)}getPluginObjectById(e){return yn("getPluginObjectById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPluginObjectByName(e){return yn("getPluginObjectByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}removePluginObjectById(e){return yn("removePluginObjectById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}setSSR(e){this.viewport.setSSR(e)}setBloom(e){this.viewport.setBloom(e)}setSSAO(e){this.viewport.setSSAO(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setToneMapping(e){this.viewport.setToneMapping(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundColorAlpha(e,t){this.viewport.setBackgroundColorAlpha(e,t)}setBackgroundImage(e){return this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){return this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){return this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){this.manager.dispose(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}getCameraTargetView(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraTargetView(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return"orbit"===this.viewport.controls.options.type&&this.utils.warn("flyTo 方法不适用于 orbit 控制器"),this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"frontTop",t=arguments.length>1?arguments[1]:void 0;return this.flyToObj(this.manager.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}getScreenshot(){return this.screenshot()}screenshot(){return this.viewport.screenshot()}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.lightManager.createAmbientLight(e)}setAmbientLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setAmbientLight(t,e)}createDirectionalLight(e){return this.manager.store.lightManager.createDirectionalLight(e)}setDirectionalLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setDirectionalLight(t,e)}createHemisphereLight(e){return this.manager.store.lightManager.createHemisphereLight(e)}setHemisphereLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setHemisphereLight(t,e)}createSpotLight(e){return this.manager.store.lightManager.createSpotLight(e)}setSpotLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setSpotLight(t,e)}createPointLight(e){return this.manager.store.lightManager.createPointLight(e)}setPointLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setPointLight(t,e)}createRectAreaLight(e){return this.manager.store.lightManager.createRectAreaLight(e)}setRectAreaLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setRectAreaLight(t,e)}getLightById(e){return yn("getLightById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeLightById(e){return yn("removeLightById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}getAllLight(){return this.manager.store.lightManager.getAll()}clearLight(){return this.manager.store.lightManager.clear()}showAllLight(){return this.manager.store.lightManager.showAll()}hideAllLight(){return this.manager.store.lightManager.hideAll()}updateAllShadow(){return this.manager.store.lightManager.updateAllShadow()}getObjectById(e){return this.manager.getObjectById(e)}getObjectByName(e){return this.manager.getObjectByName(e)}getObjectByUserDataProperty(e,t){return this.manager.getObjectByUserDataProperty(e,t)}removeObjectById(e){return this.manager.removeObjectById(e)}createGroup(e){return this.manager.store.groupManager.createGroup(e)}getGroupById(e){return yn("getGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getGroupByName(e){return yn("getGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllGroup(){return this.manager.store.groupManager.getAll()}showAllGroup(){return this.manager.store.groupManager.showAll()}hideAllGroup(){return this.manager.store.groupManager.hideAll()}removeGroupById(e){return yn("removeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}loadSbm(e){return yn("loadSbm is deprecated, use loadModel instead"),this.loadModel(e)}parseSbm(){yn("parseSbm is deprecated!")}cloneSbm(e,t,n){return yn("cloneSbm is deprecated, use cloneModel instead"),this.cloneModel(e,t,n)}getSbmById(e){return yn("getSbmById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmByName(e){return yn("getSbmByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getSbmByUserDataProperty(e,t){return yn("getSbmByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeSbmById(e){return yn("removeSbmById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForSbm(e){return yn("createGroupForSbm is deprecated, use createGroup instead"),this.createGroup(e)}loadSbmToGroup(e,t){return yn("loadSbmToGroup is deprecated, use loadModelToGroup instead"),this.loadModelToGroup(e,t)}addSbmForGroup(e,t){return yn("addSbmForGroup is deprecated, use addModelForGroup instead"),this.addModelForGroup(e,t)}createSbmGroupFromXml(){yn("createGroupForSbm is deprecated!")}getSbmGroupById(e){return yn("getSbmGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmGroupByName(e){return yn("getSbmGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllSbmGroup(){return yn("getAllSbmGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeSbmGroupById(e){return yn("removeSbmGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearSbm(){return yn("clearSbm is deprecated, use clearModel instead"),this.clearModel()}getAllSbm(){return yn("getAllSbm is deprecated, use getAllModel instead"),this.getAllModel()}showAllSbm(){return yn("showAllSbm is deprecated, use showAllModel instead"),this.showAllModel()}hideAllSbm(){return yn("hideAllSbm is deprecated, use hideAllModel instead"),this.hideAllModel()}getSbmModelMaps(){return yn("getSbmModelMaps is deprecated, use getModelsMap instead"),this.getModelsMap()}setSbmModelMaps(e){return yn("setSbmModelMaps is deprecated, use setModelsMap instead"),this.setModelsMap(e)}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return yn("getModelById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelByName(e){return yn("getModelByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getModelByUserDataProperty(e,t){return yn("getModelByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeModelById(e){return yn("removeModelById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForModel(e){return yn("createGroupForModel is deprecated, use createGroup instead"),this.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.modelManager.addForGroup(n,t)}getModelGroupById(e){return yn("getModelGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelGroupByName(e){return yn("getModelGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllModelGroup(){return yn("getAllModelGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeModelGroupById(e){return yn("removeModelGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}computeModelsBoundsTree(e){return this.viewport.bvh.computeModelsBoundsTree(e)}clearIdb(){return this.manager.store.modelManager.clearIdb()}getModelsMap(){return this.manager.store.modelManager.modelsMap}setModelsMap(e){this.manager.store.modelManager.modelsMap=e}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return yn("getPoiById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiByName(e){return yn("getPoiByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiByUserDataProperty(e,t){return yn("getPoiByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiById(e){return yn("removePoiById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoi(e){return yn("createGroupForPoi is deprecated, use createGroup instead"),this.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiManager.addForGroup(n,t)}getPoiGroupById(e){return yn("getPoiGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiGroupByName(e){return yn("getPoiGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiGroup(){return yn("getAllPoiGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiGroupById(e){return yn("removePoiGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return yn("getPoiNodeById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeByName(e){return yn("getPoiNodeByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiNodeByUserDataProperty(e,t){return yn("getPoiNodeByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiNodeById(e){return yn("removePoiNodeById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoiNode(e){return yn("createGroupForPoiNode is deprecated, use createGroup instead"),this.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiNodeManager.addForGroup(n,t)}getPoiNodeGroupById(e){return yn("getPoiNodeGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeGroupByName(e){return yn("getPoiNodeGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiNodeGroup(){return yn("getAllPoiNodeGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiNodeGroupById(e){return yn("removePoiNodeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createPoiMesh(e){const t=Hf(e,this.textureCache);return this.addObject(t),t}createPolygonPoiMesh(e){const t=Gf(e,this.textureCache);return this.addObject(t),t}setTexture(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{cache:i=!0,independ:r=!0}=n||{};let s=e.material;if(r&&(s=s.clone(),e.material=s),null===t)return s.map=null,this.render(),null;const o=Uf(s,t,i,this.textureCache);return this.render(),o}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return yn("getCanvas3DById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DByName(e){return yn("getCanvas3DByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getCanvas3DByUserDataProperty(e,t){return yn("getCanvas3DByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeCanvas3DById(e){return yn("removeCanvas3DById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForCanvas3D(e){return yn("createGroupForCanvas3D is deprecated, use createGroup instead"),this.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.canvas3DManager.addForGroup(n,t)}getCanvas3DGroupById(e){return yn("getCanvas3DGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DGroupByName(e){return yn("getCanvas3DGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllCanvas3DGroup(){return yn("getAllCanvas3DGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeCanvas3DGroupById(e){return yn("removeCanvas3DGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return yn("getTopologyById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyByName(e){return yn("getTopologyByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getTopologyByUserDataProperty(e,t){return yn("getTopologyByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeTopologyById(e){return yn("removeTopologyById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForTopology(e){return yn("createGroupForTopology is deprecated, use createGroup instead"),this.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.topologyManager.addForGroup(n,t)}getTopologyGroupById(e){return yn("getTopologyGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyGroupByName(e){return yn("getTopologyGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllTopologyGroup(){return yn("getAllTopologyGroup is deprecated, use getAllGroups instead"),this.getAllGroup()}removeTopologyGroupById(e){return yn("removeTopologyGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return yn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return yn("getHelperById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeHelperById(e){return yn("removeHelperById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}createFindObjectsInBoxNearPosition(e,t){return Ff(e,t)}createFindObjectsInSphereNearPosition(e,t){return jf(e,t)}createFindObjectsNearPath(e,t){return zf(e,t)}createPathAnimation(e,t,n){return new Zi(e,t,n)}createTopologyAnimation(e,n,i){const r=n.nodes.map((e=>e.getWorldPosition(new t)));return new Zi(e,r,i)}}Vf.THREE=e,Vf.TWEEN=pn,Vf.utils=Xi;export{Vf as SoonSpace,Lf as boundingIsIntersected,Ff as createFindObjectsInBoxNearPosition,jf as createFindObjectsInSphereNearPosition,zf as createFindObjectsNearPath,Of as createPlaneMatrix,Hf as createPoiMesh,Gf as createPolygonPoiMesh,Nf as createTexture,_f as createUVMatrix,Vf as default,kf as getBoundingBox,Pf as getPolygonGeometryInfo,Uf as setTexture};
28
+ */var sh=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(sh(""))}catch(Zn){sh=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var oh=Uint8Array,ah=Uint16Array,lh=Uint32Array,ch=new oh([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),uh=new oh([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hh=new oh([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dh=function(e,t){for(var n=new ah(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new lh(n[30]);for(i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return[n,r]},fh=dh(ch,2),ph=fh[0],gh=fh[1];ph[28]=258,gh[258]=28;for(var mh=dh(uh,0)[0],vh=new ah(32768),yh=0;yh<32768;++yh){var wh=(43690&yh)>>>1|(21845&yh)<<1;wh=(61680&(wh=(52428&wh)>>>2|(13107&wh)<<2))>>>4|(3855&wh)<<4,vh[yh]=((65280&wh)>>>8|(255&wh)<<8)>>>1}var bh=function(e,t,n){for(var i=e.length,r=0,s=new ah(t);r<i;++r)++s[e[r]-1];var o,a=new ah(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;if(n){o=new ah(1<<t);var l=15-t;for(r=0;r<i;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],h=a[e[r]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[vh[h]>>>l]=c}else for(o=new ah(i),r=0;r<i;++r)e[r]&&(o[r]=vh[a[e[r]-1]++]>>>15-e[r]);return o},xh=new oh(288);for(yh=0;yh<144;++yh)xh[yh]=8;for(yh=144;yh<256;++yh)xh[yh]=9;for(yh=256;yh<280;++yh)xh[yh]=7;for(yh=280;yh<288;++yh)xh[yh]=8;var Ah=new oh(32);for(yh=0;yh<32;++yh)Ah[yh]=5;var Th=bh(xh,9,1),Sh=bh(Ah,5,1),Eh=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Dh=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},Ch=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Ih=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new oh(0);var r=!t||n,s=!n||n.i;n||(n={}),t||(t=new oh(3*i));var o,a=function(e){var n=t.length;if(e>n){var i=new oh(Math.max(2*n,e));i.set(t),t=i}},l=n.f||0,c=n.p||0,u=n.b||0,h=n.l,d=n.d,f=n.m,p=n.n,g=8*i;do{if(!h){n.f=l=Dh(e,c,1);var m=Dh(e,c+1,3);if(c+=3,!m){var v=e[(I=((o=c)/8|0)+(7&o&&1)+4)-4]|e[I-3]<<8,y=I+v;if(y>i){if(s)throw"unexpected EOF";break}r&&a(u+v),t.set(e.subarray(I,y),u),n.b=u+=v,n.p=c=8*y;continue}if(1==m)h=Th,d=Sh,f=9,p=5;else{if(2!=m)throw"invalid block type";var w=Dh(e,c,31)+257,b=Dh(e,c+10,15)+4,x=w+Dh(e,c+5,31)+1;c+=14;for(var A=new oh(x),T=new oh(19),S=0;S<b;++S)T[hh[S]]=Dh(e,c+3*S,7);c+=3*b;var E=Eh(T),D=(1<<E)-1,C=bh(T,E,1);for(S=0;S<x;){var I,M=C[Dh(e,c,D)];if(c+=15&M,(I=M>>>4)<16)A[S++]=I;else{var B=0,R=0;for(16==I?(R=3+Dh(e,c,3),c+=2,B=A[S-1]):17==I?(R=3+Dh(e,c,7),c+=3):18==I&&(R=11+Dh(e,c,127),c+=7);R--;)A[S++]=B}}var P=A.subarray(0,w),O=A.subarray(w);f=Eh(P),p=Eh(O),h=bh(P,f,1),d=bh(O,p,1)}if(c>g){if(s)throw"unexpected EOF";break}}r&&a(u+131072);for(var _=(1<<f)-1,L=(1<<p)-1,k=c;;k=c){var N=(B=h[Ch(e,c)&_])>>>4;if((c+=15&B)>g){if(s)throw"unexpected EOF";break}if(!B)throw"invalid length/literal";if(N<256)t[u++]=N;else{if(256==N){k=c,h=null;break}var U=N-254;if(N>264){var F=ch[S=N-257];U=Dh(e,c,(1<<F)-1)+ph[S],c+=F}var j=d[Ch(e,c)&L],z=j>>>4;if(!j)throw"invalid distance";c+=15&j;O=mh[z];if(z>3){F=uh[z];O+=Ch(e,c)&(1<<F)-1,c+=F}if(c>g){if(s)throw"unexpected EOF";break}r&&a(u+131072);for(var H=u+U;u<H;u+=4)t[u]=t[u-O],t[u+1]=t[u+1-O],t[u+2]=t[u+2-O],t[u+3]=t[u+3-O];u=H}}n.l=h,n.p=k,n.b=u,h&&(l=1,n.m=f,n.d=d,n.n=p)}while(!l);return u==t.length?t:function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof ah?ah:e instanceof lh?lh:oh)(n-t);return i.set(e.subarray(t,n)),i}(t,0,u)},Mh=new oh(0),Bh=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};var Rh="undefined"!=typeof TextDecoder&&new TextDecoder;try{Rh.decode(Mh,{stream:!0}),1}catch(Zn){}function Ph(e,t,n){const i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let r=e,s=i,o=Math.floor((r+s)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?s=o:r=o,o=Math.floor((r+s)/2);return o}function Oh(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let i=1;for(let e=2;e<=t;++e)i*=e;for(let n=2;n<=e-t;++n)i*=n;return n/i}function _h(e,n,i,r,s){const o=function(e,t,n,i,r){const s=r<e?r:e,o=[],a=Ph(e,i,t),l=function(e,t,n,i,r){const s=[];for(let e=0;e<=n;++e)s[e]=0;const o=[];for(let e=0;e<=i;++e)o[e]=s.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=s.slice(0);a[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let i=1;i<=n;++i){l[i]=t-r[e+1-i],c[i]=r[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=c[e+1],r=l[i-e];a[i][e]=t+r;const s=a[e][i-1]/a[i][e];a[e][i]=n+t*s,n=r*s}a[i][i]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,r=1;const l=[];for(let e=0;e<=n;++e)l[e]=s.slice(0);l[0][0]=1;for(let s=1;s<=i;++s){let i=0;const c=e-s,u=n-s;e>=s&&(l[r][0]=l[t][0]/a[u+1][c],i=l[r][0]*a[c][u]);const h=e-1<=u?s-1:n-e;for(let e=c>=-1?1:-c;e<=h;++e)l[r][e]=(l[t][e]-l[t][e-1])/a[u+1][c+e],i+=l[r][e]*a[c+e][u];e<=u&&(l[r][s]=-l[t][s-1]/a[u+1][e],i+=l[r][s]*a[e][u]),o[s][e]=i;const d=t;t=r,r=d}}let u=n;for(let e=1;e<=i;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}(a,i,e,s,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),i=t.w;t.x*=i,t.y*=i,t.z*=i,c[e]=t}for(let t=0;t<=s;++t){const n=c[a-e].clone().multiplyScalar(l[t][0]);for(let i=1;i<=e;++i)n.add(c[a-e+i].clone().multiplyScalar(l[t][i]));o[t]=n}for(let e=s+1;e<=r+1;++e)o[e]=new be(0,0,0);return o}(e,n,i,r,s);return function(e){const n=e.length,i=[],r=[];for(let s=0;s<n;++s){const n=e[s];i[s]=new t(n.x,n.y,n.z),r[s]=n.w}const s=[];for(let e=0;e<n;++e){const t=i[e].clone();for(let n=1;n<=e;++n)t.sub(s[e-n].clone().multiplyScalar(Oh(e,n)*r[n]));s[e]=t.divideScalar(r[0])}return s}(o)}class Lh extends ft{constructor(e,t,n,i,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new be(t.x,t.y,t.z,t.w)}}getPoint(e){const n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=function(e,t,n,i){const r=Ph(e,i,t),s=function(e,t,n,i){const r=[],s=[],o=[];r[0]=1;for(let a=1;a<=n;++a){s[a]=t-i[e+1-a],o[a]=i[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],i=s[a-e],l=r[e]/(t+i);r[e]=n+t*l,n=i*l}r[a]=n}return r}(r,i,e,t),o=new be(0,0,0,0);for(let t=0;t<=e;++t){const i=n[r-e+t],a=s[t],l=i.w*a;o.x+=i.x*l,o.y+=i.y*l,o.z+=i.z*l,o.w+=i.w*a}return o}(this.degree,this.knots,this.controlPoints,i);return 1!==r.w&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e){const n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=_h(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}}let kh,Nh,Uh;class Fh extends pt{constructor(e){super(e)}load(e,t,n,i){const r=this,s=""===r.path?gt.extractUrlBase(e):r.path,o=new mt(this.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(n,s))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===nd(e,0,t.length)}(e))kh=(new Vh).parse(e);else{const t=nd(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function i(t){const i=e[t-1];return e=e.slice(n+t),n++,i}for(let e=0;e<t.length;++e){if(i(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Xh(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Xh(t));kh=(new Gh).parse(t)}const n=new Je(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new jh(n,this.manager).parse(kh)}}class jh{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Nh=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=(new zh).parse(i);return this.parseScene(i,r,n),Uh}parseConnections(){const e=new Map;if("Connections"in kh){kh.Connections.connections.forEach((function(t){const n=t[0],i=t[1],r=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const s={ID:i,relationship:r};e.get(n).parents.push(s),e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:n,relationship:r};e.get(i).children.push(o)}))}return e}parseImages(){const e={},t={};if("Video"in kh.Objects){const n=kh.Objects.Video;for(const i in n){const r=n[i];if(e[parseInt(i)]=r.RelativeFilename||r.Filename,"Content"in r){const e=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,s="string"==typeof r.Content&&""!==r.Content;if(e||s){const e=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=e}}}}for(const n in e){const i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(i){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in kh.Objects){const n=kh.Objects.Texture;for(const i in n){const r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,r=e.WrapModeV,s=void 0!==i?i.value:0,o=void 0!==r?r.value:0;if(n.wrapS=0===s?D:E,n.wrapT=0===o?D:E,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,r=Nh.get(e.id).children;let s;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(n=t[r[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const o=e.FileName.slice(-3).toLowerCase();if("tga"===o){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new l):(t.setPath(this.textureLoader.path),s=t.load(n))}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new l):s=this.textureLoader.load(n);return this.textureLoader.setPath(i),s}parseMaterials(e){const t=new Map;if("Material"in kh.Objects){const n=kh.Objects.Material;for(const i in n){const r=this.parseMaterial(n[i],e);null!==r&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!Nh.has(n))return null;const s=this.parseParameters(e,t,n);let o;switch(r.toLowerCase()){case"phong":o=new vt;break;case"lambert":o=new yt;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),o=new vt}return o.setValues(s),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new a).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new a).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new a).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new a).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new a).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new a).fromArray(e.SpecularColor.value));const r=this;return Nh.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":i.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,e.ID),void 0!==i.map&&(i.map.encoding=I);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.encoding=I);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=qe,i.envMap.encoding=I);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.encoding=I);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,e.ID),i.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in kh.Objects&&t in kh.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Nh.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in kh.Objects){const n=kh.Objects.Deformer;for(const i in n){const r=n[i],s=Nh.get(parseInt(i));if("Skin"===r.attrType){const t=this.parseSkeleton(s,n);t.ID=i,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,e[i]=t}else if("BlendShape"===r.attrType){const e={id:i};e.rawTargets=this.parseMorphTargets(s,n),e.id=i,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const i=t[e.ID];if("Cluster"!==i.attrType)return;const r={ID:e.ID,indices:[],weights:[],transformLink:(new m).fromArray(i.TransformLink.a)};"Indexes"in i&&(r.indices=i.Indexes.a,r.weights=i.Weights.a),n.push(r)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const r=e.children[i],s=t[r.ID],o={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;o.geoID=Nh.get(parseInt(r.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(o)}return n}parseScene(e,t,n){Uh=new wt;const i=this.parseModels(e.skeletons,t,n),r=kh.Objects.Model,s=this;i.forEach((function(e){const t=r[e.ID];s.setLookAtProperties(e,t);Nh.get(e.ID).parents.forEach((function(t){const n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&Uh.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),Uh.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=$h(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const o=(new Hh).parse();1===Uh.children.length&&Uh.children[0].isGroup&&(Uh.children[0].animations=o,Uh=Uh.children[0]),Uh.animations=o}parseModels(e,t,n){const i=new Map,r=kh.Objects.Model;for(const s in r){const o=parseInt(s),a=r[s],l=Nh.get(o);let c=this.buildSkeleton(l,e,o,a.attrName);if(!c){switch(a.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new bt;break;default:c=new wt}c.name=a.attrName?p.sanitizeNodeName(a.attrName):"",c.ID=o}this.getTransformData(c,a),i.set(o,c)}return i}buildSkeleton(e,t,n,i){let r=null;return e.parents.forEach((function(e){for(const s in t){const o=t[s];o.rawBones.forEach((function(t,s){if(t.ID===e.ID){const e=r;r=new bt,r.matrixWorld.copy(t.transformLink),r.name=i?p.sanitizeNodeName(i):"",r.ID=n,o.bones[s]=r,null!==e&&r.add(e)}}))}})),r}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=kh.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new J;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let i=1;void 0!==n.NearPlane&&(i=n.NearPlane.value/1e3);let r=1e3;void 0!==n.FarPlane&&(r=n.FarPlane.value/1e3);let s=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,o=n.AspectHeight.value);const a=s/o;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new $(l,a,i,r),null!==c&&t.setFocalLength(c);break;case 1:t=new ee(-s/2,s/2,o/2,-o/2,i,r);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new J}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=kh.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new J;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new a).fromArray(n.Color.value));let r=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(r=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new j(i,r,s,o);break;case 1:t=new ct(i,r);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=h.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=h.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new ht(i,r,s,e,a,o);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new j(i,r)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,r=null,s=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(r=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))})),o.length>1?s=o:o.length>0?s=o[0]:(s=new vt({color:13421772}),o.push(s)),"color"in r.attributes&&o.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new xt(r,s),i.normalizeSkinWeights()):i=new k(r,s),i}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new q({color:3342591,linewidth:1});return new At(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?ed(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,n){if("LookAtProperty"in n){Nh.get(e.ID).children.forEach((function(n){if("LookAtProperty"===n.relationship){const i=kh.Objects.Model[n.ID];if("Lcl_Translation"in i){const n=i.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(n),Uh.add(e.target)):e.lookAt((new t).fromArray(n))}}}))}}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const r in e){const s=e[r];Nh.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;Nh.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Tt(s.bones),i[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in kh.Objects){const t=kh.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new m).fromArray(t.Matrix.a)})):e[i.Node]=(new m).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in kh&&"AmbientColor"in kh.GlobalSettings){const e=kh.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){const e=new a(t,n,i);Uh.add(new lt(e,1))}}}}class zh{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in kh.Objects){const n=kh.Objects.Geometry;for(const i in n){const r=Nh.get(parseInt(i)),s=this.parseGeometry(r,n[i],e);t.set(parseInt(i),s)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,r=[],s=e.parents.map((function(e){return kh.Objects.Model[e.ID]}));if(0===s.length)return;const o=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&r.push(n.morphTargets[e.ID])}));const a=s[0],l={};"RotationOrder"in a&&(l.eulerOrder=ed(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const c=$h(l);return this.genGeometry(t,o,r,c)}genGeometry(e,t,n,i){const r=new xe;e.attrName&&(r.name=e.attrName);const s=this.parseGeoNode(e,t),o=this.genBuffers(s),a=new it(o.vertex,3);if(a.applyMatrix4(i),r.setAttribute("position",a),o.colors.length>0&&r.setAttribute("color",new it(o.colors,3)),t&&(r.setAttribute("skinIndex",new St(o.weightsIndices,4)),r.setAttribute("skinWeight",new it(o.vertexWeights,4)),r.FBX_Deformer=t),o.normal.length>0){const e=(new Pe).getNormalMatrix(i),t=new it(o.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(o.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),r.setAttribute(n,new it(o.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach((function(n,i){n!==e&&(r.addGroup(t,i-t,e),e=n,t=i)})),r.groups.length>0){const t=r.groups[r.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&r.addGroup(n,o.materialIndex.length-n,e)}0===r.groups.length&&r.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,r=!1,s=[],o=[],a=[],l=[],c=[],u=[];const h=this;return e.vertexIndices.forEach((function(d,f){let p,g=!1;d<0&&(d^=-1,g=!0);let m=[],v=[];if(s.push(3*d,3*d+1,3*d+2),e.color){const t=Zh(f,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),m.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,i){let r=n,s=m[i];t.forEach((function(t,n,i){if(r>t){i[n]=r,r=t;const o=e[n];e[n]=s,s=o}}))})),m=e,v=t}for(;v.length<4;)v.push(0),m.push(0);for(let e=0;e<4;++e)c.push(v[e]),u.push(m[e])}if(e.normal){const t=Zh(f,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(p=Zh(f,n,d,e.material)[0],p<0&&(h.negativeMaterialIndices=!0,p=0)),e.uv&&e.uv.forEach((function(e,t){const i=Zh(f,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,g&&(i>4&&console.warn("THREE.FBXLoader: Polygons with more than four sides are not supported. Make sure to triangulate the geometry during export."),h.genFace(t,e,s,p,o,a,l,c,u,i),n++,i=0,s=[],o=[],a=[],l=[],c=[],u=[])})),t}genFace(e,t,n,i,r,s,o,a,l,c){for(let u=2;u<c;u++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(u-1)]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[n[3*u]]),e.vertex.push(t.vertexPositions[n[3*u+1]]),e.vertex.push(t.vertexPositions[n[3*u+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(u-1)]),e.vertexWeights.push(a[4*(u-1)+1]),e.vertexWeights.push(a[4*(u-1)+2]),e.vertexWeights.push(a[4*(u-1)+3]),e.vertexWeights.push(a[4*u]),e.vertexWeights.push(a[4*u+1]),e.vertexWeights.push(a[4*u+2]),e.vertexWeights.push(a[4*u+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(s[0]),e.colors.push(s[1]),e.colors.push(s[2]),e.colors.push(s[3*(u-1)]),e.colors.push(s[3*(u-1)+1]),e.colors.push(s[3*(u-1)+2]),e.colors.push(s[3*u]),e.colors.push(s[3*u+1]),e.colors.push(s[3*u+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[3*(u-1)]),e.normal.push(r[3*(u-1)+1]),e.normal.push(r[3*(u-1)+2]),e.normal.push(r[3*u]),e.normal.push(r[3*u+1]),e.normal.push(r[3*u+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][0]),e.uvs[n].push(o[n][1]),e.uvs[n].push(o[n][2*(u-1)]),e.uvs[n].push(o[n][2*(u-1)+1]),e.uvs[n].push(o[n][2*u]),e.uvs[n].push(o[n][2*u+1])}))}addMorphTargets(e,t,n,i){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=kh.Objects.Geometry[n.geoID];void 0!==s&&r.genMorphGeometry(e,t,s,i,n.name)}))}))}genMorphGeometry(e,t,n,i,r){const s=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],o=void 0!==n.Vertices?n.Vertices.a:[],a=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<a.length;e++){const t=3*a[e];c[t]=o[3*e],c[t+1]=o[3*e+1],c[t+2]=o[3*e+2]}const u={vertexIndices:s,vertexPositions:c},h=this.genBuffers(u),d=new it(h.vertex,3);d.name=r||n.attrName,d.applyMatrix4(i),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let r=[];return"IndexToDirect"===n&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let r=[];return"IndexToDirect"===n&&(r=e.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let r=[];return"IndexToDirect"===n&&(r=e.ColorIndex.a),{dataSize:4,buffer:i,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,r=[];for(let e=0;e<i.length;++e)r.push(e);return{dataSize:1,buffer:i,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new xe;const n=t-1,i=e.KnotVector.a,r=[],s=e.Points.a;for(let e=0,t=s.length;e<t;e+=4)r.push((new be).fromArray(s,e));let o,a;if("Closed"===e.Form)r.push(r[0]);else if("Periodic"===e.Form){o=n,a=i.length-1-o;for(let e=0;e<n;++e)r.push(r[e])}const l=new Lh(n,i,r,o,a).getPoints(12*r.length);return(new xe).setFromPoints(l)}}class Hh{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const i=t[n],r=this.addClip(i);e.push(r)}return e}parseClips(){if(void 0===kh.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=kh.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){const e={id:i.id,attr:i.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=kh.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(Qh),values:t[n].KeyValueFloat.a},r=Nh.get(i.id);if(void 0!==r){const t=r.parents[0].ID,n=r.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=i:n.match(/Y/)?e.get(t).curves.y=i:n.match(/Z/)?e.get(t).curves.z=i:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=i)}}}parseAnimationLayers(e){const t=kh.Objects.AnimationLayer,n=new Map;for(const i in t){const t=[],r=Nh.get(parseInt(i));if(void 0!==r){r.children.forEach((function(n,i){if(e.has(n.ID)){const r=e.get(n.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===t[i]){const e=Nh.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const r=kh.Objects.Model[e.toString()];if(void 0===r)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:r.attrName?p.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Uh.traverse((function(e){e.ID===r.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new m),"PreRotation"in r&&(s.preRotation=r.PreRotation.value),"PostRotation"in r&&(s.postRotation=r.PostRotation.value),t[i]=s}}t[i]&&(t[i][r.attr]=r)}else if(void 0!==r.curves.morph){if(void 0===t[i]){const e=Nh.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=Nh.get(e).parents[0].ID,s=Nh.get(r).parents[0].ID,o=Nh.get(s).parents[0].ID,a=kh.Objects.Model[o],l={modelName:a.attrName?p.sanitizeNodeName(a.attrName):"",morphName:kh.Objects.Deformer[e].attrName};t[i]=l}t[i][r.attr]=r}}})),n.set(parseInt(i),t)}}return n}parseAnimStacks(e){const t=kh.Objects.AnimationStack,n={};for(const i in t){const r=Nh.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new We(e.name,-1,t)}generateTracks(e){const i=[];let s=new t,o=new r,a=new t;if(e.transform&&e.transform.decompose(s,o,a),s=s.toArray(),o=(new n).setFromQuaternion(o,e.eulerOrder).toArray(),a=a.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const t=this.generateVectorTrack(e.modelName,e.T.curves,s,"position");void 0!==t&&i.push(t)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const t=this.generateRotationTrack(e.modelName,e.R.curves,o,e.preRotation,e.postRotation,e.eulerOrder);void 0!==t&&i.push(t)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const t=this.generateVectorTrack(e.modelName,e.S.curves,a,"scale");void 0!==t&&i.push(t)}if(void 0!==e.DeformPercent){const t=this.generateMorphTrack(e);void 0!==t&&i.push(t)}return i}generateVectorTrack(e,t,n,i){const r=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(r,t,n);return new Et(e+"."+i,r,s)}generateRotationTrack(e,t,i,s,o,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(h.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(h.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(h.degToRad));const l=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(l,t,i);void 0!==s&&((s=s.map(h.degToRad)).push(a),s=(new n).fromArray(s),s=(new r).setFromEuler(s)),void 0!==o&&((o=o.map(h.degToRad)).push(a),o=(new n).fromArray(o),o=(new r).setFromEuler(o).invert());const u=new r,d=new n,f=[];for(let e=0;e<c.length;e+=3)d.set(c[e],c[e+1],c[e+2],a),u.setFromEuler(d),void 0!==s&&u.premultiply(s),void 0!==o&&u.multiply(o),u.toArray(f,e/3*4);return new Dt(e+".quaternion",l,f)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=Uh.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Ct(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let i=1;i<t.length;i++){const r=t[i];r!==n&&(t[e]=r,n=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const i=n,r=[];let s=-1,o=-1,a=-1;return e.forEach((function(e){if(t.x&&(s=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==s){const e=t.x.values[s];r.push(e),i[0]=e}else r.push(i[0]);if(-1!==o){const e=t.y.values[o];r.push(e),i[1]=e}else r.push(i[1]);if(-1!==a){const e=t.z.values[a];r.push(e),i[2]=e}else r.push(i[2])})),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],i=e.values[t]-n,r=Math.abs(i);if(r>=180){const s=r/180,o=i/s;let a=n+o;const l=e.times[t-1],c=(e.times[t]-l)/s;let u=l+c;const h=[],d=[];for(;u<e.times[t];)h.push(u),u+=c,d.push(a),a+=o;e.times=id(e.times,t,h),e.values=id(e.values,t,d)}}}}class Gh{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Wh,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,i){const r=e.match(/^[\s\t]*;/),s=e.match(/^[\s\t]*$/);if(r||s)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),r={name:n},s=this.parseNodeAttr(i),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,r):n in o?("PoseNode"===n?o.PoseNode.push(r):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==s.id&&(o[n][s.id]=r)):"number"==typeof s.id?(o[n]={},o[n][s.id]=r):"Properties70"!==n&&(o[n]="PoseNode"===n?[r]:r),"number"==typeof s.id&&(r.id=s.id),""!==s.name&&(r.attrName=s.name),""!==s.type&&(r.attrType=s.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===i){const e=r.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=r.split(",").slice(3);o=o.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",r=[t,n],function(e,t){for(let n=0,i=e.length,r=t.length;n<r;n++,i++)e[i]=t[n]}(r,o),void 0===s[i]&&(s[i]=[])}"Node"===i&&(s.id=r),i in s&&Array.isArray(s[i])?s[i].push(r):"a"!==i?s[i]=r:s.a=r,this.setCurrentProp(s,i),"a"===i&&","!==r.slice(-1)&&(s.a=td(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=td(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=i[0],s=i[1],o=i[2],a=i[3];let l=i[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=td(l)}this.getPrevNode()[r]={type:s,type2:o,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),r)}}class Vh{parse(e){const t=new Yh(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Wh;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),o=e.getString(s);if(0===i)return null;const a=[];for(let t=0;t<r;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){const i=this.parseNode(e,t);null!==i&&this.parseSubNode(o,n,i)}return n.propertyList=a,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==u&&(n.attrType=u),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],i=n.propertyList[1];const r=n.propertyList[2],s=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),o="Color"===i||"ColorRGB"===i||"Vector"===i||"Vector3D"===i||0===i.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:i,type2:r,flag:s,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),r=e.getUint32(),s=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const o=function(e,t){return Ih((Bh(e),e.subarray(2,-4)),t)}(new Uint8Array(e.getArrayBuffer(s))),a=new Yh(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(i);case"d":return a.getFloat64Array(i);case"f":return a.getFloat32Array(i);case"i":return a.getInt32Array(i);case"l":return a.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Yh{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}}class Wh{add(e,t){this[e]=t}}function Xh(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Qh(e){return e/46186158e3}const Kh=[];function Zh(e,t,n,i){let r;switch(i.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=n;break;case"AllSame":r=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(r=i.indices[r]);const s=r*i.dataSize,o=s+i.dataSize;return function(e,t,n,i){for(let r=n,s=0;r<i;r++,s++)e[s]=t[r];return e}(Kh,i.buffer,s,o)}const qh=new n,Jh=new t;function $h(e){const i=new m,r=new m,s=new m,o=new m,a=new m,l=new m,c=new m,u=new m,d=new m,f=new m,p=new m,g=new m,v=e.inheritType?e.inheritType:0;if(e.translation&&i.setPosition(Jh.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(h.degToRad);t.push(e.eulerOrder||n.DEFAULT_ORDER),r.makeRotationFromEuler(qh.fromArray(t))}if(e.rotation){const t=e.rotation.map(h.degToRad);t.push(e.eulerOrder||n.DEFAULT_ORDER),s.makeRotationFromEuler(qh.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(h.degToRad);t.push(e.eulerOrder||n.DEFAULT_ORDER),o.makeRotationFromEuler(qh.fromArray(t)),o.invert()}e.scale&&a.scale(Jh.fromArray(e.scale)),e.scalingOffset&&c.setPosition(Jh.fromArray(e.scalingOffset)),e.scalingPivot&&l.setPosition(Jh.fromArray(e.scalingPivot)),e.rotationOffset&&u.setPosition(Jh.fromArray(e.rotationOffset)),e.rotationPivot&&d.setPosition(Jh.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(p.copy(e.parentMatrix),f.copy(e.parentMatrixWorld));const y=r.clone().multiply(s).multiply(o),w=new m;w.extractRotation(f);const b=new m;b.copyPosition(f);const x=b.clone().invert().multiply(f),A=w.clone().invert().multiply(x),T=a,S=new m;if(0===v)S.copy(w).multiply(y).multiply(A).multiply(T);else if(1===v)S.copy(w).multiply(A).multiply(y).multiply(T);else{const e=(new m).scale((new t).setFromMatrixScale(p)).clone().invert(),n=A.clone().multiply(e);S.copy(w).multiply(y).multiply(n).multiply(T)}const E=d.clone().invert(),D=l.clone().invert();let C=i.clone().multiply(u).multiply(d).multiply(r).multiply(s).multiply(o).multiply(E).multiply(c).multiply(l).multiply(a).multiply(D);const I=(new m).copyPosition(C),M=f.clone().multiply(I);return g.copyPosition(M),C=g.clone().multiply(S),C.premultiply(f.invert()),C}function ed(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function td(e){return e.split(",").map((function(e){return parseFloat(e)}))}function nd(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}function id(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class rd extends H{constructor(e){super(e)}parse(e){const t=0,n=1,i=2,r=3,s=9,o=10,a=11,l=48,c=4,u=0,h=1,d=2,f=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let p=0;const g=new Uint8Array(e),m={id_length:g[p++],colormap_type:g[p++],image_type:g[p++],colormap_index:g[p++]|g[p++]<<8,colormap_length:g[p++]|g[p++]<<8,colormap_size:g[p++],origin:[g[p++]|g[p++]<<8,g[p++]|g[p++]<<8],width:g[p++]|g[p++]<<8,height:g[p++]|g[p++]<<8,pixel_size:g[p++],flags:g[p++]};!function(e){switch(e.image_type){case n:case s:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case i:case r:case o:case a:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(m),m.id_length+p>e.length&&console.error("THREE.TGALoader: No data."),p+=m.id_length;let v=!1,y=!1,w=!1;switch(m.image_type){case s:v=!0,y=!0;break;case n:y=!0;break;case o:v=!0;break;case i:break;case a:v=!0,w=!0;break;case r:w=!0}const b=new Uint8Array(m.width*m.height*4),x=function(e,t,n,i,r){let s,o;const a=n.pixel_size>>3,l=n.width*n.height*a;if(t&&(o=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let o=0;const c=new Uint8Array(a);for(;o<l;)if(e=r[i++],t=1+(127&e),128&e){for(n=0;n<a;++n)c[n]=r[i++];for(n=0;n<t;++n)s.set(c,o+n*a);o+=a*t}else{for(t*=a,n=0;n<t;++n)s[o+n]=r[i++];o+=t}}else s=r.subarray(i,i+=t?n.width*n.height:l);return{pixel_data:s,palettes:o}}(v,y,m,p,g);return function(e,t,n,i,r){let s,o,a,p,g,v;switch((m.flags&l)>>c){default:case d:s=0,a=1,g=t,o=0,p=1,v=n;break;case u:s=0,a=1,g=t,o=n-1,p=-1,v=-1;break;case f:s=t-1,a=-1,g=-1,o=0,p=1,v=n;break;case h:s=t-1,a=-1,g=-1,o=n-1,p=-1,v=-1}if(w)switch(m.pixel_size){case 8:!function(e,t,n,i,r,s,o,a){let l,c,u,h=0;const d=m.width;for(u=t;u!==i;u+=n)for(c=r;c!==o;c+=s,h++)l=a[h],e[4*(c+d*u)+0]=l,e[4*(c+d*u)+1]=l,e[4*(c+d*u)+2]=l,e[4*(c+d*u)+3]=255}(e,o,p,v,s,a,g,i);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,u=0;const h=m.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,u+=2)e[4*(l+h*c)+0]=a[u+0],e[4*(l+h*c)+1]=a[u+0],e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+3]=a[u+1]}(e,o,p,v,s,a,g,i);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(m.pixel_size){case 8:!function(e,t,n,i,r,s,o,a,l){const c=l;let u,h,d,f=0;const p=m.width;for(d=t;d!==i;d+=n)for(h=r;h!==o;h+=s,f++)u=a[f],e[4*(h+p*d)+3]=255,e[4*(h+p*d)+2]=c[3*u+0],e[4*(h+p*d)+1]=c[3*u+1],e[4*(h+p*d)+0]=c[3*u+2]}(e,o,p,v,s,a,g,i,r);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,u,h=0;const d=m.width;for(u=t;u!==i;u+=n)for(c=r;c!==o;c+=s,h+=2)l=a[h+0]+(a[h+1]<<8),e[4*(c+d*u)+0]=(31744&l)>>7,e[4*(c+d*u)+1]=(992&l)>>2,e[4*(c+d*u)+2]=(31&l)<<3,e[4*(c+d*u)+3]=32768&l?0:255}(e,o,p,v,s,a,g,i);break;case 24:!function(e,t,n,i,r,s,o,a){let l,c,u=0;const h=m.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,u+=3)e[4*(l+h*c)+3]=255,e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+1]=a[u+1],e[4*(l+h*c)+0]=a[u+2]}(e,o,p,v,s,a,g,i);break;case 32:!function(e,t,n,i,r,s,o,a){let l,c,u=0;const h=m.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,u+=4)e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+1]=a[u+1],e[4*(l+h*c)+0]=a[u+2],e[4*(l+h*c)+3]=a[u+3]}(e,o,p,v,s,a,g,i);break;default:console.error("THREE.TGALoader: Format not supported.")}}(b,m.width,m.height,x.pixel_data,x.palettes),{data:b,width:m.width,height:m.height,flipY:!0,generateMipmaps:!0,minFilter:S}}}function sd(e,t){if(t===It)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Mt||t===Bt){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(t===Mt)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class od extends pt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new dd(e)})),this.register((function(e){return new wd(e)})),this.register((function(e){return new bd(e)})),this.register((function(e){return new pd(e)})),this.register((function(e){return new gd(e)})),this.register((function(e){return new md(e)})),this.register((function(e){return new vd(e)})),this.register((function(e){return new hd(e)})),this.register((function(e){return new yd(e)})),this.register((function(e){return new fd(e)})),this.register((function(e){return new cd(e)})),this.register((function(e){return new xd(e)})),this.register((function(e){return new Ad(e)}))}load(e,t,n,i){const r=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:gt.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},a=new mt(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{r.parse(n,s,(function(n){t(n),r.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},o={},a=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===Td){try{s[ld.KHR_BINARY_GLTF]=new Dd(e)}catch(e){return void(i&&i(e))}r=JSON.parse(s[ld.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Jd(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);o[t.name]=t,s[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],n=r.extensionsRequired||[];switch(t){case ld.KHR_MATERIALS_UNLIT:s[t]=new ud;break;case ld.KHR_DRACO_MESH_COMPRESSION:s[t]=new Cd(r,this.dracoLoader);break;case ld.KHR_TEXTURE_TRANSFORM:s[t]=new Id;break;case ld.KHR_MESH_QUANTIZATION:s[t]=new Md;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function ad(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const ld={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class cd{constructor(e){this.parser=e,this.name=ld.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const l=new a(16777215);void 0!==s.color&&l.fromArray(s.color);const c=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new ct(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new j(l),o.distance=c;break;case"spot":o=new ht(l),o.distance=c,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,Wd(o,s),void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(o),t.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class ud{constructor(){this.name=ld.KHR_MATERIALS_UNLIT}getMaterialType(){return z}extendParams(e,t,n){const i=[];e.color=new a(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,I))}return Promise.all(i)}}class hd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class dd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new M(e,e)}return Promise.all(r)}}class fd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class pd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new a(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];return void 0!==s.sheenColorFactor&&t.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,I)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class gd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class md{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new a(o[0],o[1],o[2]),Promise.all(r)}}class vd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class yd{constructor(e){this.parser=e,this.name=ld.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Rt:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new a(o[0],o[1],o[2]),void 0!==s.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,I)),Promise.all(r)}}class wd{constructor(e){this.parser=e,this.name=ld.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class bd{constructor(e){this.parser=e,this.name=ld.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class xd{constructor(e){this.name=ld.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*o);return r.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t}))}))}return null}}class Ad{constructor(e){this.name=ld.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,i=n.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const s=n.meshes[i.mesh];for(const e of s.primitives)if(e.mode!==Od.TRIANGLES&&e.mode!==Od.TRIANGLE_STRIP&&e.mode!==Od.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const e in o)a.push(this.parser.getDependency("accessor",o[e]).then((t=>(l[e]=t,l[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const n=e.pop(),i=n.isGroup?n.children:[n],s=e[0].count,o=[];for(const e of i){const n=new m,i=new t,a=new r,c=new t(1,1,1),u=new Pt(e.geometry,e.material,s);for(let e=0;e<s;e++)l.TRANSLATION&&i.fromBufferAttribute(l.TRANSLATION,e),l.ROTATION&&a.fromBufferAttribute(l.ROTATION,e),l.SCALE&&c.fromBufferAttribute(l.SCALE,e),u.setMatrixAt(e,n.compose(i,a,c));for(const t in l)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,l[t]);J.prototype.copy.call(u,e),u.frustumCulled=!1,this.parser.assignFinalMaterial(u),o.push(u)}return n.isGroup?(n.clear(),n.add(...o),n):o[0]})))}}const Td="glTF",Sd=1313821514,Ed=5130562;class Dd{constructor(e){this.name=ld.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Td)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(e,12);let s=0;for(;s<i;){const t=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Sd){const i=new Uint8Array(e,12+s,t);this.content=n.decode(i)}else if(i===Ed){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Cd{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ld.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=Ud[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const i=Ud[t]||t.toLowerCase();if(void 0!==s[t]){const r=n.accessors[e.attributes[t]],s=_d[r.componentType];l[i]=s.name,a[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=a[t];void 0!==i&&(n.normalized=i)}t(e)}),o,l)}))}))}}class Id{constructor(){this.name=ld.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Md{constructor(){this.name=ld.KHR_MESH_QUANTIZATION}}class Bd extends Ft{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=i-t,u=(n-t)/c,h=u*u,d=h*u,f=e*l,p=f-l,g=-2*d+3*h,m=d-h,v=1-g,y=m-h+u;for(let e=0;e!==o;e++){const t=s[p+e+o],n=s[p+e+a]*c,i=s[f+e+o],l=s[f+e]*c;r[e]=v*t+y*n+g*i+m*l}return r}}const Rd=new r;class Pd extends Bd{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return Rd.fromArray(r).normalize().toArray(r),r}}const Od={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},_d={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ld={9728:w,9729:A,9984:b,9985:T,9986:x,9987:S},kd={33071:E,33648:C,10497:D},Nd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ud={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Fd={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jd={CUBICSPLINE:void 0,LINEAR:y,STEP:g},zd="OPAQUE",Hd="MASK",Gd="BLEND";function Vd(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new F({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:L})),e.DefaultMaterial}function Yd(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function Wd(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Xd(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Qd(e){const t=e.extensions&&e.extensions[ld.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+Kd(t.attributes):e.indices+":"+Kd(e.attributes)+":"+e.mode,n}function Kd(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function Zd(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const qd=new m;class Jd{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ad,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Je(this.options.manager):this.textureLoader=new Ot(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new mt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};Yd(r,s,i),Wd(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!i)throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[ld.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(gt.resolveURL(t.uri,i.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){const e=Nd[i.type],t=_d[i.componentType],n=!0===i.normalized,r=new t(i.count*e);return Promise.resolve(new f(r,e,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],s=Nd[i.type],o=_d[i.componentType],a=o.BYTES_PER_ELEMENT,l=a*s,c=i.byteOffset||0,u=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,h=!0===i.normalized;let d,p;if(u&&u!==l){const e=Math.floor(c/u),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(d=new o(r,e*u,i.count*u/a),l=new _t(d,u/a),t.cache.add(n,l)),p=new Lt(l,s,c%u/a,h)}else d=null===r?new o(i.count*s):new o(r,c,i.count*s),p=new f(d,s,h);if(void 0!==i.sparse){const t=Nd.SCALAR,n=_d[i.sparse.indices.componentType],a=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],a,i.sparse.count*t),u=new o(e[2],l,i.sparse.count*s);null!==r&&(p=new f(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,u[e*s]),s>=2&&p.setY(t,u[e*s+1]),s>=3&&p.setZ(t,u[e*s+2]),s>=4&&p.setW(t,u[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||o.name||"";const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=Ld[n.magFilter]||A,t.minFilter=Ld[n.minFilter]||S,t.wrapS=kd[n.wrapS]||D,t.wrapT=kd[n.wrapT]||D,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",c=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){c=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new l(e);t.needsUpdate=!0,n(t)}),t.load(gt.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===c&&o.revokeObjectURL(a),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),r.extensions[ld.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[ld.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[ld.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.encoding=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new kt,Ae.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new q,Ae.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return F}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let s;const o={},l=[];if((r.extensions||{})[ld.KHR_MATERIALS_UNLIT]){const e=i[ld.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),l.push(e.extendParams(o,r,t))}else{const n=r.pbrMetallicRoughness||{};if(o.color=new a(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.fromArray(e),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,I)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===r.doubleSided&&(o.side=d);const c=r.alphaMode||zd;if(c===Gd?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Hd&&(o.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==z&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new M(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;o.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&s!==z&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(o.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==z&&(o.emissive=(new a).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==z&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,I)),Promise.all(l).then((function(){const n=new s(o);return r.name&&(n.name=r.name),Wd(n,r),t.associations.set(n,{materials:e}),r.extensions&&Yd(i,n,r),n}))}createUniqueName(e){const t=p.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[ld.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return $d(n,e,t)}))}const s=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=Qd(o),l=i[a];if(l)s.push(l.promise);else{let e;e=o.extensions&&o.extensions[ld.KHR_DRACO_MESH_COMPRESSION]?r(o):$d(new xe,o,t),i[a]={primitive:o,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?Vd(this.cache):this.getDependency("material",s[e].material);o.push(t)}return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],u=s[n];let h;const d=o[n];if(u.mode===Od.TRIANGLES||u.mode===Od.TRIANGLE_STRIP||u.mode===Od.TRIANGLE_FAN||void 0===u.mode)h=!0===r.isSkinnedMesh?new xt(c,d):new k(c,d),!0!==h.isSkinnedMesh||h.geometry.attributes.skinWeight.normalized||h.normalizeSkinWeights(),u.mode===Od.TRIANGLE_STRIP?h.geometry=sd(h.geometry,Bt):u.mode===Od.TRIANGLE_FAN&&(h.geometry=sd(h.geometry,Mt));else if(u.mode===Od.LINES)h=new Z(c,d);else if(u.mode===Od.LINE_STRIP)h=new At(c,d);else if(u.mode===Od.LINE_LOOP)h=new Nt(c,d);else{if(u.mode!==Od.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new Ut(c,d)}Object.keys(h.geometry.morphAttributes).length>0&&Xd(h,r),h.name=t.createUniqueName(r.name||"mesh_"+e),Wd(h,r),u.extensions&&Yd(i,h,u),t.assignFinalMaterial(h),l.push(h)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new wt;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new $(h.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new ee(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Wd(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(this.getDependency("node",t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),i=e,r=[],s=[];for(let e=0,o=i.length;e<o;e++){const o=i[e];if(o){r.push(o);const t=new m;null!==n&&t.fromArray(n.array,16*e),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Tt(r,s)}))}loadAnimation(e){const t=this.json.animations[e],n=[],i=[],r=[],s=[],o=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,u=c.node,h=void 0!==t.parameters?t.parameters[l.input]:l.input,d=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",u)),i.push(this.getDependency("accessor",h)),r.push(this.getDependency("accessor",d)),s.push(l),o.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(o)]).then((function(n){const i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=r[e],c=s[e],u=o[e],h=a[e];if(void 0===t)continue;let d;switch(t.updateMatrix(),Fd[h.path]){case Fd.weights:d=Ct;break;case Fd.rotation:d=Dt;break;default:d=Et}const f=t.name?t.name:t.uuid,p=void 0!==u.interpolation?jd[u.interpolation]:y,g=[];Fd[h.path]===Fd.weights?t.traverse((function(e){e.morphTargetInfluences&&g.push(e.name?e.name:e.uuid)})):g.push(f);let m=c.array;if(c.normalized){const e=Zd(m.constructor),t=new Float32Array(m.length);for(let n=0,i=m.length;n<i;n++)t[n]=m[n]*e;m=t}for(let e=0,t=g.length;e<t;e++){const t=new d(g[e]+"."+Fd[h.path],n.array,m,p);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof Dt?Pd:Bd)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new We(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));n&&t.push(n),void 0!==r.camera&&t.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)}));const s=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)s.push(i.getDependency("node",o[e]));const a=void 0===r.skin?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([Promise.all(t),Promise.all(s),a])}().then((function(t){const o=t[0],a=t[1],l=t[2];let c;if(c=!0===r.isBone?new bt:o.length>1?new wt:1===o.length?o[0]:new J,c!==o[0])for(let e=0,t=o.length;e<t;e++)c.add(o[e]);if(r.name&&(c.userData.name=r.name,c.name=s),Wd(c,r),r.extensions&&Yd(n,c,r),void 0!==r.matrix){const e=new m;e.fromArray(r.matrix),c.applyMatrix4(e)}else void 0!==r.translation&&c.position.fromArray(r.translation),void 0!==r.rotation&&c.quaternion.fromArray(r.rotation),void 0!==r.scale&&c.scale.fromArray(r.scale);i.associations.has(c)||i.associations.set(c,{}),i.associations.get(c).nodes=e,null!==l&&c.traverse((function(e){e.isSkinnedMesh&&e.bind(l,qd)}));for(let e=0,t=a.length;e<t;e++)c.add(a[e]);return c}))}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new wt;n.name&&(r.name=i.createUniqueName(n.name)),Wd(r,n),n.extensions&&Yd(t,r,n);const s=n.nodes||[],o=[];for(let e=0,t=s.length;e<t;e++)o.push(i.getDependency("node",s[e]));return Promise.all(o).then((function(e){for(let t=0,n=e.length;t<n;t++)r.add(e[t]);return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof Ae||e instanceof l)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}}function $d(e,n,r){const s=n.attributes,o=[];function a(t,n){return r.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}for(const t in s){const n=Ud[t]||t.toLowerCase();n in e.attributes||o.push(a(s[t],n))}if(void 0!==n.indices&&!e.index){const t=r.getDependency("accessor",n.indices).then((function(t){e.setIndex(t)}));o.push(t)}return Wd(e,n),function(e,n,r){const s=n.attributes,o=new i;if(void 0===s.POSITION)return;{const e=r.json.accessors[s.POSITION],n=e.min,i=e.max;if(void 0===n||void 0===i)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new t(n[0],n[1],n[2]),new t(i[0],i[1],i[2])),e.normalized){const t=Zd(_d[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const a=n.targets;if(void 0!==a){const e=new t,n=new t;for(let t=0,i=a.length;t<i;t++){const i=a[t];if(void 0!==i.POSITION){const t=r.json.accessors[i.POSITION],s=t.min,o=t.max;if(void 0!==s&&void 0!==o){if(n.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),n.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),n.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),t.normalized){const e=Zd(_d[t.componentType]);n.multiplyScalar(e)}e.max(n)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const l=new O;o.getCenter(l.center),l.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=l}(e,n,r),Promise.all(o).then((function(){return void 0!==n.targets?function(e,t,n){let i=!1,r=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(i){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],o=t[1],a=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,n.targets,r):e}))}const ef=new WeakMap;class tf extends pt{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const r=new mt(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.decodeDracoFile(e,t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};return this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){const n=JSON.stringify(t);if(ef.has(e)){const t=ef.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),ef.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new xe;e.index&&t.setIndex(new f(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],r=i.name,s=i.array,o=i.itemSize;t.setAttribute(r,new f(s,o))}return t}_loadLibrary(e,t){const n=new mt(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=nf.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function nf(){let e,t;function n(e,t,n,i,r,s){const o=s.num_components(),a=n.num_points()*o,l=a*r.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,c,l,u);const h=new r(e.HEAPF32.buffer,u,a).slice();return e._free(u),{name:i,array:h,itemSize:o}}onmessage=function(i){const r=i.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=r.buffer,s=r.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,r){const s=r.attributeIDs,o=r.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(i,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const i in s){const l=self[o[i]];let c,h;if(r.useUniqueIDs)h=s[i],c=t.GetAttributeByUniqueId(a,h);else{if(h=t.GetAttributeId(a,e[s[i]]),-1===h)continue;c=t.GetAttribute(a,h)}u.attributes.push(n(e,t,a,i,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const i=n.num_faces(),r=3*i,s=4*r,o=e._malloc(s);t.GetTrianglesUInt32Array(n,s,o);const a=new Uint32Array(e.HEAPF32.buffer,o,r).slice();return e._free(o),{array:a,itemSize:1}}(e,t,a));return e.destroy(a),u}(t,o,a,s),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}function rf(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var sf={};({get exports(){return sf},set exports(e){sf=e}}).exports=function e(t,n,i){function r(o,a){if(!n[o]){if(!t[o]){if(!a&&rf)return rf(o);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};t[o][0].call(c.exports,(function(e){var n=t[o][1][e];return r(n||e)}),c,c.exports,e,t,n,i)}return n[o].exports}for(var s=rf,o=0;o<i.length;o++)r(i[o]);return r}({1:[function(e,t,n){(function(e){var n,i,r=e.MutationObserver||e.WebKitMutationObserver;if(r){var s=0,o=new r(u),a=e.document.createTextNode("");o.observe(a,{characterData:!0}),n=function(){a.data=s=++s%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){u(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(u,0)};else{var l=new e.MessageChannel;l.port1.onmessage=u,n=function(){l.port2.postMessage(0)}}var c=[];function u(){var e,t;i=!0;for(var n=c.length;n;){for(t=c,c=[],e=-1;++e<n;)t[e]();n=c.length}i=!1}function h(e){1!==c.push(e)||i||n()}t.exports=h}).call(this,void 0!==Ms?Ms:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var i=e(1);function r(){}var s={},o=["REJECTED"],a=["FULFILLED"],l=["PENDING"];function c(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==r&&f(this,e)}function u(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function h(e,t,n){i((function(){var i;try{i=t(n)}catch(t){return s.reject(e,t)}i===e?s.reject(e,new TypeError("Cannot resolve promise with itself")):s.resolve(e,i)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var n=!1;function i(t){n||(n=!0,s.reject(e,t))}function r(t){n||(n=!0,s.resolve(e,t))}function o(){t(r,i)}var a=p(o);"error"===a.status&&i(a.value)}function p(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function g(e){return e instanceof this?e:s.resolve(new this(r),e)}function m(e){var t=new this(r);return s.reject(t,e)}function v(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var o=new Array(n),a=0,l=-1,c=new this(r);++l<n;)u(e[l],l);return c;function u(e,r){function l(e){o[r]=e,++a!==n||i||(i=!0,s.resolve(c,o))}t.resolve(e).then(l,(function(e){i||(i=!0,s.reject(c,e))}))}}function y(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var o=-1,a=new this(r);++o<n;)l(e[o]);return a;function l(e){t.resolve(e).then((function(e){i||(i=!0,s.resolve(a,e))}),(function(e){i||(i=!0,s.reject(a,e))}))}}t.exports=c,c.prototype.catch=function(e){return this.then(null,e)},c.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===o)return this;var n=new this.constructor(r);return this.state!==l?h(n,this.state===a?e:t,this.outcome):this.queue.push(new u(n,e,t)),n},u.prototype.callFulfilled=function(e){s.resolve(this.promise,e)},u.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},u.prototype.callRejected=function(e){s.reject(this.promise,e)},u.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},s.resolve=function(e,t){var n=p(d,t);if("error"===n.status)return s.reject(e,n.value);var i=n.value;if(i)f(e,i);else{e.state=a,e.outcome=t;for(var r=-1,o=e.queue.length;++r<o;)e.queue[r].callFulfilled(t)}return e},s.reject=function(e,t){e.state=o,e.outcome=t;for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e},c.resolve=g,c.reject=m,c.all=v,c.race=y},{1:1}],3:[function(e,t,n){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==Ms?Ms:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var o=s();function a(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function l(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(r){if("TypeError"!==r.name)throw r;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)n.append(e[i]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var c=Promise;function u(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function h(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function d(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var p="local-forage-detect-blob-support",g=void 0,m={},v=Object.prototype.toString,y="readonly",w="readwrite";function b(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),r=0;r<t;r++)i[r]=e.charCodeAt(r);return n}function x(e){return new c((function(t){var n=e.transaction(p,w),i=l([""]);n.objectStore(p).put(i,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function A(e){return"boolean"==typeof g?c.resolve(g):x(e).then((function(e){return g=e}))}function T(e){var t=m[e.name],n={};n.promise=new c((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function S(e){var t=m[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function E(e,t){var n=m[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function D(e,t){return new c((function(n,i){if(m[e.name]=m[e.name]||k(),e.db){if(!t)return n(e.db);T(e),e.db.close()}var r=[e.name];t&&r.push(e.version);var s=o.open.apply(o,r);t&&(s.onupgradeneeded=function(t){var n=s.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(p)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),s.onerror=function(e){e.preventDefault(),i(s.error)},s.onsuccess=function(){n(s.result),S(e)}}))}function C(e){return D(e,!1)}function I(e){return D(e,!0)}function M(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,r=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),r||n){if(n){var s=e.db.version+1;s>e.version&&(e.version=s)}return!0}return!1}function B(e){return new c((function(t,n){var i=new FileReader;i.onerror=n,i.onloadend=function(n){var i=btoa(n.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function R(e){return l([b(atob(e.data))],{type:e.type})}function P(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then((function(){var e=m[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return h(n,e,e),n}function _(e){T(e);for(var t=m[e.name],n=t.forages,i=0;i<n.length;i++){var r=n[i];r._dbInfo.db&&(r._dbInfo.db.close(),r._dbInfo.db=null)}return e.db=null,C(e).then((function(t){return e.db=t,M(e)?I(e):t})).then((function(i){e.db=t.db=i;for(var r=0;r<n.length;r++)n[r]._dbInfo.db=i})).catch((function(t){throw E(e,t),t}))}function L(e,t,n,i){void 0===i&&(i=1);try{var r=e.db.transaction(e.storeName,t);n(null,r)}catch(r){if(i>0&&(!e.db||"InvalidStateError"===r.name||"NotFoundError"===r.name))return c.resolve().then((function(){if(!e.db||"NotFoundError"===r.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),I(e)})).then((function(){return _(e).then((function(){L(e,t,n,i-1)}))})).catch(n);n(r)}}function k(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function N(e){var t=this,n={db:null};if(e)for(var i in e)n[i]=e[i];var r=m[n.name];r||(r=k(),m[n.name]=r),r.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O);var s=[];function o(){return c.resolve()}for(var a=0;a<r.forages.length;a++){var l=r.forages[a];l!==t&&s.push(l._initReady().catch(o))}var u=r.forages.slice(0);return c.all(s).then((function(){return n.db=r.db,C(n)})).then((function(e){return n.db=e,M(n,t._defaultConfig.version)?I(n):e})).then((function(e){n.db=r.db=e,t._dbInfo=n;for(var i=0;i<u.length;i++){var s=u[i];s!==t&&(s._dbInfo.db=n.db,s._dbInfo.version=n.version)}}))}function U(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){L(n._dbInfo,y,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName).get(e);o.onsuccess=function(){var e=o.result;void 0===e&&(e=null),P(e)&&(e=R(e)),t(e)},o.onerror=function(){i(o.error)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function F(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){L(n._dbInfo,y,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName).openCursor(),a=1;o.onsuccess=function(){var n=o.result;if(n){var i=n.value;P(i)&&(i=R(i));var r=e(i,n.key,a++);void 0!==r?t(r):n.continue()}else t()},o.onerror=function(){i(o.error)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function j(e,t,n){var i=this;e=d(e);var r=new c((function(n,r){var s;i.ready().then((function(){return s=i._dbInfo,"[object Blob]"===v.call(t)?A(s.db).then((function(e){return e?t:B(t)})):t})).then((function(t){L(i._dbInfo,w,(function(s,o){if(s)return r(s);try{var a=o.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var l=a.put(t,e);o.oncomplete=function(){void 0===t&&(t=null),n(t)},o.onabort=o.onerror=function(){var e=l.error?l.error:l.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return u(r,n),r}function z(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){L(n._dbInfo,w,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName).delete(e);s.oncomplete=function(){t()},s.onerror=function(){i(o.error)},s.onabort=function(){var e=o.error?o.error:o.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function H(e){var t=this,n=new c((function(e,n){t.ready().then((function(){L(t._dbInfo,w,(function(i,r){if(i)return n(i);try{var s=r.objectStore(t._dbInfo.storeName).clear();r.oncomplete=function(){e()},r.onabort=r.onerror=function(){var e=s.error?s.error:s.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return u(n,e),n}function G(e){var t=this,n=new c((function(e,n){t.ready().then((function(){L(t._dbInfo,y,(function(i,r){if(i)return n(i);try{var s=r.objectStore(t._dbInfo.storeName).count();s.onsuccess=function(){e(s.result)},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return u(n,e),n}function V(e,t){var n=this,i=new c((function(t,i){e<0?t(null):n.ready().then((function(){L(n._dbInfo,y,(function(r,s){if(r)return i(r);try{var o=s.objectStore(n._dbInfo.storeName),a=!1,l=o.openKeyCursor();l.onsuccess=function(){var n=l.result;n?0===e||a?t(n.key):(a=!0,n.advance(e)):t(null)},l.onerror=function(){i(l.error)}}catch(e){i(e)}}))})).catch(i)}));return u(i,t),i}function Y(e){var t=this,n=new c((function(e,n){t.ready().then((function(){L(t._dbInfo,y,(function(i,r){if(i)return n(i);try{var s=r.objectStore(t._dbInfo.storeName).openKeyCursor(),o=[];s.onsuccess=function(){var t=s.result;t?(o.push(t.key),t.continue()):e(o)},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return u(n,e),n}function W(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,r=this;if(e.name){var s=e.name===n.name&&r._dbInfo.db?c.resolve(r._dbInfo.db):C(e).then((function(t){var n=m[e.name],i=n.forages;n.db=t;for(var r=0;r<i.length;r++)i[r]._dbInfo.db=t;return t}));i=e.storeName?s.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;T(e);var i=m[e.name],r=i.forages;t.close();for(var s=0;s<r.length;s++){var a=r[s];a._dbInfo.db=null,a._dbInfo.version=n}var l=new c((function(t,i){var r=o.open(e.name,n);r.onerror=function(e){r.result.close(),i(e)},r.onupgradeneeded=function(){r.result.deleteObjectStore(e.storeName)},r.onsuccess=function(){var e=r.result;e.close(),t(e)}}));return l.then((function(e){i.db=e;for(var t=0;t<r.length;t++){var n=r[t];n._dbInfo.db=e,S(n._dbInfo)}})).catch((function(t){throw(E(e,t)||c.resolve()).catch((function(){})),t}))}})):s.then((function(t){T(e);var n=m[e.name],i=n.forages;t.close();for(var r=0;r<i.length;r++)i[r]._dbInfo.db=null;var s=new c((function(t,n){var i=o.deleteDatabase(e.name);i.onerror=i.onblocked=function(e){var t=i.result;t&&t.close(),n(e)},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}}));return s.then((function(e){n.db=e;for(var t=0;t<i.length;t++)S(i[t]._dbInfo)})).catch((function(t){throw(E(e,t)||c.resolve()).catch((function(){})),t}))}))}else i=c.reject("Invalid arguments");return u(i,t),i}var X={_driver:"asyncStorage",_initStorage:N,_support:a(),iterate:F,getItem:U,setItem:j,removeItem:z,clear:H,length:G,key:V,keys:Y,dropInstance:W};function Q(){return"function"==typeof openDatabase}var K="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Z="~~local_forage_type~",q=/^~~local_forage_type~([^~]+)~/,J="__lfsc__:",$=J.length,ee="arbf",te="blob",ne="si08",ie="ui08",re="uic8",se="si16",oe="si32",ae="ur16",le="ui32",ce="fl32",ue="fl64",he=$+ee.length,de=Object.prototype.toString;function fe(e){var t,n,i,r,s,o=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);var c=new ArrayBuffer(o),u=new Uint8Array(c);for(t=0;t<a;t+=4)n=K.indexOf(e[t]),i=K.indexOf(e[t+1]),r=K.indexOf(e[t+2]),s=K.indexOf(e[t+3]),u[l++]=n<<2|i>>4,u[l++]=(15&i)<<4|r>>2,u[l++]=(3&r)<<6|63&s;return c}function pe(e){var t,n=new Uint8Array(e),i="";for(t=0;t<n.length;t+=3)i+=K[n[t]>>2],i+=K[(3&n[t])<<4|n[t+1]>>4],i+=K[(15&n[t+1])<<2|n[t+2]>>6],i+=K[63&n[t+2]];return n.length%3==2?i=i.substring(0,i.length-1)+"=":n.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function ge(e,t){var n="";if(e&&(n=de.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var i,r=J;e instanceof ArrayBuffer?(i=e,r+=ee):(i=e.buffer,"[object Int8Array]"===n?r+=ne:"[object Uint8Array]"===n?r+=ie:"[object Uint8ClampedArray]"===n?r+=re:"[object Int16Array]"===n?r+=se:"[object Uint16Array]"===n?r+=ae:"[object Int32Array]"===n?r+=oe:"[object Uint32Array]"===n?r+=le:"[object Float32Array]"===n?r+=ce:"[object Float64Array]"===n?r+=ue:t(new Error("Failed to get type for BinaryArray"))),t(r+pe(i))}else if("[object Blob]"===n){var s=new FileReader;s.onload=function(){var n=Z+e.type+"~"+pe(this.result);t(J+te+n)},s.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}}function me(e){if(e.substring(0,$)!==J)return JSON.parse(e);var t,n=e.substring(he),i=e.substring($,he);if(i===te&&q.test(n)){var r=n.match(q);t=r[1],n=n.substring(r[0].length)}var s=fe(n);switch(i){case ee:return s;case te:return l([s],{type:t});case ne:return new Int8Array(s);case ie:return new Uint8Array(s);case re:return new Uint8ClampedArray(s);case se:return new Int16Array(s);case ae:return new Uint16Array(s);case oe:return new Int32Array(s);case le:return new Uint32Array(s);case ce:return new Float32Array(s);case ue:return new Float64Array(s);default:throw new Error("Unkown type: "+i)}}var ve={serialize:ge,deserialize:me,stringToBuffer:fe,bufferToString:pe};function ye(e,t,n,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,i)}function we(e){var t=this,n={db:null};if(e)for(var i in e)n[i]="string"!=typeof e[i]?e[i].toString():e[i];var r=new c((function(e,i){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return i(e)}n.db.transaction((function(r){ye(r,n,(function(){t._dbInfo=n,e()}),(function(e,t){i(t)}))}),i)}));return n.serializer=ve,r}function be(e,t,n,i,r,s){e.executeSql(n,i,r,(function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?s(e,o):ye(e,t,(function(){e.executeSql(n,i,r,s)}),s)}),s):s(e,o)}),s)}function xe(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"SELECT * FROM "+r.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var i=n.rows.length?n.rows.item(0).value:null;i&&(i=r.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function Ae(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"SELECT * FROM "+r.storeName,[],(function(n,i){for(var s=i.rows,o=s.length,a=0;a<o;a++){var l=s.item(a),c=l.value;if(c&&(c=r.serializer.deserialize(c)),void 0!==(c=e(c,l.key,a+1)))return void t(c)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function Te(e,t,n,i){var r=this;e=d(e);var s=new c((function(s,o){r.ready().then((function(){void 0===t&&(t=null);var a=t,l=r._dbInfo;l.serializer.serialize(t,(function(t,c){c?o(c):l.db.transaction((function(n){be(n,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){s(a)}),(function(e,t){o(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void s(Te.apply(r,[e,a,n,i-1]));o(t)}}))}))})).catch(o)}));return u(s,n),s}function Se(e,t,n){return Te.apply(this,[e,t,n,1])}function Ee(e,t){var n=this;e=d(e);var i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"DELETE FROM "+r.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function De(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){be(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return u(n,e),n}function Ce(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){be(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,n){var i=n.rows.item(0).c;e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return u(n,e),n}function Ie(e,t){var n=this,i=new c((function(t,i){n.ready().then((function(){var r=n._dbInfo;r.db.transaction((function(n){be(n,r,"SELECT key FROM "+r.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var i=n.rows.length?n.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return u(i,t),i}function Me(e){var t=this,n=new c((function(e,n){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){be(t,i,"SELECT key FROM "+i.storeName,[],(function(t,n){for(var i=[],r=0;r<n.rows.length;r++)i.push(n.rows.item(r).key);e(i)}),(function(e,t){n(t)}))}))})).catch(n)}));return u(n,e),n}function Be(e){return new c((function(t,n){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,i){for(var r=[],s=0;s<i.rows.length;s++)r.push(i.rows.item(s).name);t({db:e,storeNames:r})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}function Re(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var i,r=this;return i=e.name?new c((function(t){var i;i=e.name===n.name?r._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(Be(i))})).then((function(e){return new c((function(t,n){e.db.transaction((function(i){function r(e){return new c((function(t,n){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var s=[],o=0,a=e.storeNames.length;o<a;o++)s.push(r(e.storeNames[o]));c.all(s).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):c.reject("Invalid arguments"),u(i,t),i}var Pe={_driver:"webSQLStorage",_initStorage:we,_support:Q(),iterate:Ae,getItem:xe,setItem:Se,removeItem:Ee,clear:De,length:Ce,key:Ie,keys:Me,dropInstance:Re};function Oe(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function _e(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function Le(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function ke(){return!Le()||localStorage.length>0}function Ne(e){var t=this,n={};if(e)for(var i in e)n[i]=e[i];return n.keyPrefix=_e(e,t._defaultConfig),ke()?(t._dbInfo=n,n.serializer=ve,c.resolve()):c.reject()}function Ue(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var i=localStorage.key(n);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return u(n,e),n}function Fe(e,t){var n=this;e=d(e);var i=n.ready().then((function(){var t=n._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return u(i,t),i}function je(e,t){var n=this,i=n.ready().then((function(){for(var t=n._dbInfo,i=t.keyPrefix,r=i.length,s=localStorage.length,o=1,a=0;a<s;a++){var l=localStorage.key(a);if(0===l.indexOf(i)){var c=localStorage.getItem(l);if(c&&(c=t.serializer.deserialize(c)),void 0!==(c=e(c,l.substring(r),o++)))return c}}}));return u(i,t),i}function ze(e,t){var n=this,i=n.ready().then((function(){var t,i=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return u(i,t),i}function He(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,i=[],r=0;r<n;r++){var s=localStorage.key(r);0===s.indexOf(e.keyPrefix)&&i.push(s.substring(e.keyPrefix.length))}return i}));return u(n,e),n}function Ge(e){var t=this.keys().then((function(e){return e.length}));return u(t,e),t}function Ve(e,t){var n=this;e=d(e);var i=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return u(i,t),i}function Ye(e,t,n){var i=this;e=d(e);var r=i.ready().then((function(){void 0===t&&(t=null);var n=t;return new c((function(r,s){var o=i._dbInfo;o.serializer.serialize(t,(function(t,i){if(i)s(i);else try{localStorage.setItem(o.keyPrefix+e,t),r(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||s(e),s(e)}}))}))}));return u(r,n),r}function We(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var i,r=this;return i=e.name?new c((function(t){e.storeName?t(_e(e,r._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):c.reject("Invalid arguments"),u(i,t),i}var Xe={_driver:"localStorageWrapper",_initStorage:Ne,_support:Oe(),iterate:je,getItem:Fe,setItem:Ye,removeItem:Ve,clear:Ue,length:Ge,key:ze,keys:He,dropInstance:We},Qe=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Ke=function(e,t){for(var n=e.length,i=0;i<n;){if(Qe(e[i],t))return!0;i++}return!1},Ze=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},qe={},Je={},$e={INDEXEDDB:X,WEBSQL:Pe,LOCALSTORAGE:Xe},et=[$e.INDEXEDDB._driver,$e.WEBSQL._driver,$e.LOCALSTORAGE._driver],tt=["dropInstance"],nt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function rt(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function st(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(Ze(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var ot=function(){function e(t){for(var n in r(this,e),$e)if($e.hasOwnProperty(n)){var i=$e[n],s=i._driver;this[n]=s,qe[s]||this.defineDriver(i)}this._defaultConfig=st({},it),this._config=st({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var i=new c((function(t,n){try{var i=e._driver,r=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(r);for(var s=nt.concat("_initStorage"),o=0,a=s.length;o<a;o++){var l=s[o];if((!Ke(tt,l)||e[l])&&"function"!=typeof e[l])return void n(r)}var h=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=c.reject(t);return u(n,arguments[arguments.length-1]),n}},n=0,i=tt.length;n<i;n++){var r=tt[n];e[r]||(e[r]=t(r))}};h();var d=function(n){qe[i]&&console.info("Redefining LocalForage driver: "+i),qe[i]=e,Je[i]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}));return h(i,t,n),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var i=qe[e]?c.resolve(qe[e]):c.reject(new Error("Driver not found."));return h(i,t,n),i},e.prototype.getSerializer=function(e){var t=c.resolve(ve);return h(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return h(n,e,e),n},e.prototype.setDriver=function(e,t,n){var i=this;Ze(e)||(e=[e]);var r=this._getSupportedDrivers(e);function s(){i._config.driver=i.driver()}function o(e){return i._extend(e),s(),i._ready=i._initStorage(i._config),i._ready}function a(e){return function(){var t=0;function n(){for(;t<e.length;){var r=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(r).then(o).catch(n)}s();var a=new Error("No available storage method found.");return i._driverSet=c.reject(a),i._driverSet}return n()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return c.resolve()})):c.resolve();return this._driverSet=l.then((function(){var e=r[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,s(),i._wrapLibraryMethodsWithReady(),i._initDriver=a(r)}))})).catch((function(){s();var e=new Error("No available storage method found.");return i._driverSet=c.reject(e),i._driverSet})),h(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!Je[e]},e.prototype._extend=function(e){st(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,i=e.length;n<i;n++){var r=e[n];this.supports(r)&&t.push(r)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=nt.length;e<t;e++)rt(this,nt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),at=new ot;t.exports=at},{3:3}]},{},[4])(4);class of{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((n=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const af=()=>{self.noCompressWorker=function(e,t){const[n]=new Uint32Array(e,t,1),i={byteOffset:t+=4,length:3*n},r={byteOffset:t+=3*n*4,length:2*n},s={byteOffset:t+=2*n*4,length:4*n},o={byteOffset:t+=4*n*1,length:3*n};t+=3*n*1;let a=(s.length+o.length)%4;a>0&&(a=4-a,t+=a);const l=new Uint32Array(e,t,1);t+=4;const[c]=l,u={byteOffset:t,length:c};t+=4*c;const h=new Uint32Array(e,t,1);t+=4;const[d]=h,f=[];if(d>0)for(let n=0;n<d;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);f.push({start:n,count:i,uuid:a,alphaMode:r})}return{buffer:e,position:i,normal:o,color:s,texcoord:r,indice:u,sub_mesh:f}}},lf=()=>{self.gzipCompressWorker=function(e){const t=new Uint8Array(e,4,e.byteLength-4),n=new pako.Inflate;n.push(t,!0);const{result:i}=n;if(i instanceof Uint8Array){const{buffer:e}=i;let t=0;const[n]=new Uint32Array(e,t,1);t+=4;const r={byteOffset:t,length:3*n};t+=3*n*4;const s={byteOffset:t,length:2*n};t+=2*n*4;const o={byteOffset:t,length:4*n};t+=4*n*1;const a={byteOffset:t,length:3*n};t+=3*n*1;let l=(o.length+a.length)%4;l>0&&(l=4-l,t+=l);const c=new Uint32Array(e,t,1);t+=4;const[u]=c,h={byteOffset:t,length:u};t+=4*u;const d=new Uint32Array(e,t,1);t+=4;const[f]=d,p=[];if(f>0)for(let n=0;n<f;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);p.push({start:n,count:i,uuid:a,alphaMode:r})}return{buffer:e,position:r,normal:a,color:o,texcoord:s,indice:h,sub_mesh:p}}}},cf=()=>{self.parseChunkWorker=function(e){let t=0;const n=new Int8Array(e,t,128);t+=128,(new TextDecoder).decode(n.slice(0,4));const[i]=n.slice(4,8);if(0===i)return self.noCompressWorker(e,t);if(1===i){const t=e.slice(128);return self.gzipCompressWorker(t)}throw new Error("unknown compress mode [ .sbmx model ]")}},uf="\n onmessage = function ( e ) {\n \n const message = e.data\n\n switch ( message.type ) {\n\n case 'decode': {\n\n const chunkInfo = self.parseChunkWorker( message.data )\n\n if ( chunkInfo ) { \n\n self.postMessage( \n { type: 'decode', data: chunkInfo, }, \n [ chunkInfo.buffer ]\n )\n\n } else {\n\n self.postMessage( { type: 'decode', data: {}, } )\n\n }\n\n break\n \n }\n \n }\n\n }\n\n",hf="textureIndex.json";class df extends pt{constructor(e){super(),this.store=e,this.loadedTextures=new Map,this.loadedMaterialsMap=new Map,this.defaultMaterial=new F({name:"defaultDatMaterial",color:0}),this.loadedMaterials=[this.defaultMaterial],this.dracoDecoderPath=null,this.workerPool=new of(4),this.workerSourceURL="";const t=this._initWorkerCreator();this.workerPool.setWorkerCreator(t)}parseAsync(e,t){return Fn(this,void 0,void 0,(function*(){const[n]=yield Promise.allSettled([this._decodeBuffer(e,t),this._createMaterial(t)]);if("fulfilled"===n.status&&n.value){const e=Rn(t),i=this._createMesh(n.value,e),r=new wt;return r.add(i),r}}))}_decodeBuffer(e,t){return Fn(this,void 0,void 0,(function*(){const n=yield this.store.getItem(`${t}_object`);if(n)return n;const[{data:i}]=yield Promise.all([this.workerPool.postMessage({type:"decode",data:e},[e])]);if(i){const{type:e,data:n}=null!=i?i:{};if("decode"===e&&n){const{buffer:{byteLength:e}}=n;return Fi(e)&&e/1024/1024<=500&&Kn((()=>{this.store.setItem(`${t}_object`,n)})),n}}}))}_initWorkerCreator(){if(!this.workerSourceURL){const e=af.toString(),t=lf.toString(),n=cf.toString(),i=["/* dat decoder */",["/* pako */","\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pako = {}));\n}(this, (function (exports) { 'use strict';\n\n // Note: adler32 takes 12% for level 0 and 2% for level 6.\n // It isn't worth it to make additional optimizations as in original.\n // Small size is preferable.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express ofr implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const adler32 = (adler, buf, len, pos) => {\n let s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n };\n\n\n var adler32_1 = adler32;\n\n // Note: we can't get significant speed boost here.\n // So write code to minimize size - no pregenerated tables\n // and array tools dependencies.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // Use ordinary array, since untyped makes no boost here\n const makeTable = () => {\n let c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n };\n\n // Create table on load. Just 255 signed longs. Not a problem.\n const crcTable = new Uint32Array(makeTable());\n\n\n const crc32 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n\n crc ^= -1;\n\n for (let i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n };\n\n\n var crc32_1 = crc32;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // See state defs from inflate.js\n const BAD$1 = 30; /* got a data error -- remain here until reset */\n const TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n /*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n var inffast = function inflate_fast(strm, start) {\n let _in; /* local strm.input */\n let last; /* have enough input while in < last */\n let _out; /* local strm.output */\n let beg; /* inflate()'s initial strm.output */\n let end; /* while out < end, enough space available */\n //#ifdef INFLATE_STRICT\n let dmax; /* maximum distance from zlib header */\n //#endif\n let wsize; /* window size or zero if not using window */\n let whave; /* valid bytes in the window */\n let wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n let s_window; /* allocated sliding window, if wsize != 0 */\n let hold; /* local strm.hold */\n let bits; /* local strm.bits */\n let lcode; /* local strm.lencode */\n let dcode; /* local strm.distcode */\n let lmask; /* mask for first level of length codes */\n let dmask; /* mask for first level of distance codes */\n let here; /* retrieved table entry */\n let op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n let len; /* match length, unused bytes */\n let dist; /* match distance */\n let from; /* where to copy match from */\n let from_source;\n\n\n let input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n const state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n //#ifdef INFLATE_STRICT\n dmax = state.dmax;\n //#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n //#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n //#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // if (len <= op - whave) {\n // do {\n // output[_out++] = 0;\n // } while (--len);\n // continue top;\n // }\n // len -= op - whave;\n // do {\n // output[_out++] = 0;\n // } while (--op > whave);\n // if (op === 0) {\n // from = _out - dist;\n // do {\n // output[_out++] = output[from++];\n // } while (--len);\n // continue top;\n // }\n //#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const MAXBITS = 15;\n const ENOUGH_LENS$1 = 852;\n const ENOUGH_DISTS$1 = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const CODES$1 = 0;\n const LENS$1 = 1;\n const DISTS$1 = 2;\n\n const lbase = new Uint16Array([ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n ]);\n\n const lext = new Uint8Array([ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n ]);\n\n const dbase = new Uint16Array([ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n ]);\n\n const dext = new Uint8Array([ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n ]);\n\n const inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) =>\n {\n const bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n let len = 0; /* a code's length in bits */\n let sym = 0; /* index of code symbols */\n let min = 0, max = 0; /* minimum and maximum code lengths */\n let root = 0; /* number of index bits for root table */\n let curr = 0; /* number of index bits for current table */\n let drop = 0; /* code bits to drop for sub-table */\n let left = 0; /* number of prefix codes available */\n let used = 0; /* code entries in table used */\n let huff = 0; /* Huffman code */\n let incr; /* for incrementing code, index */\n let fill; /* index for replicating entries */\n let low; /* low bits for current root entry */\n let mask; /* mask for low root bits */\n let next; /* next available space in table */\n let base = null; /* base value table to use */\n let base_index = 0;\n // let shoextra; /* extra bits table to use */\n let end; /* use base and extra for symbol > end */\n const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n let extra = null;\n let extra_index = 0;\n\n let here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n };\n\n\n var inftrees = inflate_table;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var constants$1 = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n\n\n\n\n\n const CODES = 0;\n const LENS = 1;\n const DISTS = 2;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,\n Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,\n Z_DEFLATED\n } = constants$1;\n\n\n /* STATES ====================================================================*/\n /* ===========================================================================*/\n\n\n const HEAD = 1; /* i: waiting for magic header */\n const FLAGS = 2; /* i: waiting for method and flags (gzip) */\n const TIME = 3; /* i: waiting for modification time (gzip) */\n const OS = 4; /* i: waiting for extra flags and operating system (gzip) */\n const EXLEN = 5; /* i: waiting for extra length (gzip) */\n const EXTRA = 6; /* i: waiting for extra bytes (gzip) */\n const NAME = 7; /* i: waiting for end of file name (gzip) */\n const COMMENT = 8; /* i: waiting for end of comment (gzip) */\n const HCRC = 9; /* i: waiting for header crc (gzip) */\n const DICTID = 10; /* i: waiting for dictionary check value */\n const DICT = 11; /* waiting for inflateSetDictionary() call */\n const TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n const TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\n const STORED = 14; /* i: waiting for stored size (length and complement) */\n const COPY_ = 15; /* i/o: same as COPY below, but only first time in */\n const COPY = 16; /* i/o: waiting for input or output to copy stored block */\n const TABLE = 17; /* i: waiting for dynamic block table lengths */\n const LENLENS = 18; /* i: waiting for code length code lengths */\n const CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\n const LEN_ = 20; /* i: same as LEN below, but only first time in */\n const LEN = 21; /* i: waiting for length/lit/eob code */\n const LENEXT = 22; /* i: waiting for length extra bits */\n const DIST = 23; /* i: waiting for distance code */\n const DISTEXT = 24; /* i: waiting for distance extra bits */\n const MATCH = 25; /* o: waiting for output space to copy string */\n const LIT = 26; /* o: waiting for output space to write literal */\n const CHECK = 27; /* i: waiting for 32-bit check value */\n const LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\n const DONE = 29; /* finished check, done -- remain here until reset */\n const BAD = 30; /* got a data error -- remain here until reset */\n const MEM = 31; /* got an inflate() memory error -- remain here until reset */\n const SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n /* ===========================================================================*/\n\n\n\n const ENOUGH_LENS = 852;\n const ENOUGH_DISTS = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const MAX_WBITS = 15;\n /* 32K LZ77 window */\n const DEF_WBITS = MAX_WBITS;\n\n\n const zswap32 = (q) => {\n\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n };\n\n\n function InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Int32Array(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n }\n\n\n const inflateResetKeep = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\"));\n return Z_OK$1;\n };\n\n\n const inflateReset = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n };\n\n\n const inflateReset2 = (strm, windowBits) => {\n let wrap;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n };\n\n\n const inflateInit2 = (strm, windowBits) => {\n\n if (!strm) { return Z_STREAM_ERROR$1; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n const state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n };\n\n\n const inflateInit = (strm) => {\n\n return inflateInit2(strm, DEF_WBITS);\n };\n\n\n /*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\n let virgin = true;\n\n let lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\n\n const fixedtables = (state) => {\n\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n let sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inftrees(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inftrees(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n };\n\n\n /*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\n const updatewindow = (strm, src, end, copy) => {\n\n let dist;\n const state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n };\n\n\n const inflate$1 = (strm, flush) => {\n\n let state;\n let input, output; // input/output buffers\n let next; /* next input INDEX */\n let put; /* next output INDEX */\n let have, left; /* available input and output */\n let hold; /* bit buffer */\n let bits; /* bits in bit buffer */\n let _in, _out; /* save starting available input and output */\n let copy; /* number of stored or match bytes to copy */\n let from; /* where to copy match bytes from */\n let from_source;\n let here = 0; /* current decoding table entry */\n let here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //let last; /* parent table entry */\n let last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n let len; /* length to copy for repeats, bits to drop */\n let ret; /* return code */\n const hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n let opts;\n\n let n; // temporary variable for NEED_BITS\n\n const order = /* permutation of code lengths */\n new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR$1;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK$1;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n\n // !!! pako patch. Force use `options.windowBits` if passed.\n // Required to always use max window size by default.\n state.dmax = 1 << state.wbits;\n //state.dmax = 1 << len;\n\n //Tracev((stderr, \"inflate: zlib header ok\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32_1(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n output.set(input.subarray(next, next + copy), put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n //#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracev((stderr, \"inflate: table sizes ok\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inftrees(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inftrees(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inffast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracevv((stderr, \"inflate: distance %u\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // Trace((stderr, \"inflate.c too far\"));\n // copy -= state.whave;\n // if (copy > state.length) { copy = state.length; }\n // if (copy > left) { copy = left; }\n // left -= copy;\n // state.length -= copy;\n // do {\n // output[put++] = 0;\n // } while (--copy);\n // if (state.length === 0) { state.mode = LEN; }\n // break;\n //#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH$1))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n };\n\n\n const inflateEnd = (strm) => {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR$1;\n }\n\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n };\n\n\n const inflateGetHeader = (strm, head) => {\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK$1;\n };\n\n\n const inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n\n let state;\n let dictid;\n let ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32_1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\"));\n return Z_OK$1;\n };\n\n\n var inflateReset_1 = inflateReset;\n var inflateReset2_1 = inflateReset2;\n var inflateResetKeep_1 = inflateResetKeep;\n var inflateInit_1 = inflateInit;\n var inflateInit2_1 = inflateInit2;\n var inflate_2$1 = inflate$1;\n var inflateEnd_1 = inflateEnd;\n var inflateGetHeader_1 = inflateGetHeader;\n var inflateSetDictionary_1 = inflateSetDictionary;\n var inflateInfo = 'pako inflate (from Nodeca project)';\n\n /* Not implemented\n module.exports.inflateCopy = inflateCopy;\n module.exports.inflateGetDictionary = inflateGetDictionary;\n module.exports.inflateMark = inflateMark;\n module.exports.inflatePrime = inflatePrime;\n module.exports.inflateSync = inflateSync;\n module.exports.inflateSyncPoint = inflateSyncPoint;\n module.exports.inflateUndermine = inflateUndermine;\n */\n\n var inflate_1$1 = {\n \tinflateReset: inflateReset_1,\n \tinflateReset2: inflateReset2_1,\n \tinflateResetKeep: inflateResetKeep_1,\n \tinflateInit: inflateInit_1,\n \tinflateInit2: inflateInit2_1,\n \tinflate: inflate_2$1,\n \tinflateEnd: inflateEnd_1,\n \tinflateGetHeader: inflateGetHeader_1,\n \tinflateSetDictionary: inflateSetDictionary_1,\n \tinflateInfo: inflateInfo\n };\n\n const _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n\n var assign = function (obj /*from1, from2, from3, ...*/) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n };\n\n\n // Join array of chunks to single array.\n var flattenChunks = (chunks) => {\n // calculate data length\n let len = 0;\n\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n const result = new Uint8Array(len);\n\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n };\n\n var common = {\n \tassign: assign,\n \tflattenChunks: flattenChunks\n };\n\n // String encode/decode helpers\n\n\n // Quick check if we can use fast array to bin string conversion\n //\n // - apply(Array) can fail on Android 2.2\n // - apply(Uint8Array) can fail on iOS 5.1 Safari\n //\n let STR_APPLY_UIA_OK = true;\n\n try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n // Table with utf8 lengths (calculated by first byte of sequence)\n // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n // because max possible codepoint is 0x10ffff\n const _utf8len = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n }\n _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n // convert string to array (typed, when possible)\n var string2buf = (str) => {\n if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n };\n\n // Helper\n const buf2binstring = (buf, len) => {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n\n let result = '';\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n\n\n // convert array to string\n var buf2string = (buf, max) => {\n const len = max || buf.length;\n\n if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n\n let i, out;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n const utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n let c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n let c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n };\n\n\n // Calculate max possible position in utf8 buffer,\n // that will not break sequence. If that's not possible\n // - (very small limits) return max size as is.\n //\n // buf[] - utf8 bytes array\n // max - length limit (mandatory);\n var utf8border = (buf, max) => {\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n };\n\n var strings = {\n \tstring2buf: string2buf,\n \tbuf2string: buf2string,\n \tutf8border: utf8border\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n }\n\n var zstream = ZStream;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n }\n\n var gzheader = GZheader;\n\n const toString = Object.prototype.toString;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_NO_FLUSH, Z_FINISH,\n Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR\n } = constants$1;\n\n /* ===========================================================================*/\n\n\n /**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n /* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n /**\n * Inflate.result -> Uint8Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param).\n **/\n\n /**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n /**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n /**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n * const chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])\n * const chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * const inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\n function Inflate(options) {\n this.options = common.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ''\n }, options || {});\n\n const opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new zstream();\n this.strm.avail_out = 0;\n\n let status = inflate_1$1.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n\n this.header = new gzheader();\n\n inflate_1$1.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = inflate_1$1.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n }\n }\n }\n\n /**\n * Inflate#push(data[, flush_mode]) -> Boolean\n * - data (Uint8Array|ArrayBuffer): input data\n * - flush_mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE\n * flush modes. See constants. Skipped or `false` means Z_NO_FLUSH,\n * `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. If end of stream detected,\n * [[Inflate#onEnd]] will be called.\n *\n * `flush_mode` is not needed for normal operation, because end of stream\n * detected automatically. You may try to use it for advanced things, but\n * this functionality was not tested.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\n Inflate.prototype.push = function (data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n\n if (this.ended) return false;\n\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n\n // Convert data if needed\n if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n for (;;) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate_1$1.inflate(strm, _flush_mode);\n\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$1.inflateSetDictionary(strm, dictionary);\n\n if (status === Z_OK) {\n status = inflate_1$1.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n // Replace code with more verbose\n status = Z_NEED_DICT;\n }\n }\n\n // Skip snyc markers if more data follows and not raw mode\n while (strm.avail_in > 0 &&\n status === Z_STREAM_END &&\n strm.state.wrap > 0 &&\n data[strm.next_in] !== 0)\n {\n inflate_1$1.inflateReset(strm);\n status = inflate_1$1.inflate(strm, _flush_mode);\n }\n\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n // Remember real `avail_out` value, because we may patch out buffer content\n // to align utf8 strings boundaries.\n last_avail_out = strm.avail_out;\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n\n if (this.options.to === 'string') {\n\n let next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail & realign counters\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n\n this.onData(utf8str);\n\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n\n // Must repeat iteration if out buffer is full\n if (status === Z_OK && last_avail_out === 0) continue;\n\n // Finalize if end of stream reached.\n if (status === Z_STREAM_END) {\n status = inflate_1$1.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n\n if (strm.avail_in === 0) break;\n }\n\n return true;\n };\n\n\n /**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|String): output data. When string output requested,\n * each chunk will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\n Inflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n };\n\n\n /**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH). By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\n Inflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = common.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n\n\n /**\n * inflate(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako');\n * const input = pako.deflate(new Uint8Array([1,2,3,4,5,6,7,8,9]));\n * let output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err) {\n * console.log(err);\n * }\n * ```\n **/\n function inflate(input, options) {\n const inflator = new Inflate(options);\n\n inflator.push(input);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) throw inflator.msg || messages[inflator.err];\n\n return inflator.result;\n }\n\n\n /**\n * inflateRaw(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n }\n\n\n /**\n * ungzip(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\n var Inflate_1 = Inflate;\n var inflate_2 = inflate;\n var inflateRaw_1 = inflateRaw;\n var ungzip = inflate;\n var constants = constants$1;\n\n var inflate_1 = {\n \tInflate: Inflate_1,\n \tinflate: inflate_2,\n \tinflateRaw: inflateRaw_1,\n \tungzip: ungzip,\n \tconstants: constants\n };\n\n exports.Inflate = Inflate_1;\n exports.constants = constants;\n exports['default'] = inflate_1;\n exports.inflate = inflate_2;\n exports.inflateRaw = inflateRaw_1;\n exports.ungzip = ungzip;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n","/* noCompress */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}")),"/* gzipCompress */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),"/* parseChunk */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n"),"","/* worker */",uf].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}return()=>new Worker(this.workerSourceURL)}_createMesh(e,t){const{buffer:n,position:i,normal:r,texcoord:s,indice:o,sub_mesh:a}=e,l=new Uint32Array(n,o.byteOffset,o.length),c=new Float32Array(n,i.byteOffset,i.length),u=new Int8Array(n,r.byteOffset,r.length),h=new Float32Array(n,s.byteOffset,s.length),d=new xe;d.setIndex(new f(l,1)),d.setAttribute("position",new f(c,3)),d.setAttribute("normal",new f(u,3,!0)),d.setAttribute("uv",new f(h,2));for(let e=0;e<a.length;e++){const{uuid:n,start:i,count:r}=a[e],s=this.loadedMaterialsMap.get(n);if(s){const{materialIndex:e}=s;d.addGroup(i,r,e)}else d.addGroup(i,r,0),yn(`sbmx material: not found uuid: ${n} in file: ${t+hf}`)}const p=new k(d,this.loadedMaterials);return p.castShadow=!0,p.receiveShadow=!0,p}_createMaterial(e){return Fn(this,void 0,void 0,(function*(){const t=Rn(e),n=t+hf,i=this.loadedTextures.get(n);if(i)return i;const r=yield this.store.getItem(`${e}_texture`);let s;if(r)s=r,this.loadedTextures.set(n,Promise.resolve(s));else{const t=this.loadedTextures.get(n);if(t)return t;const i=Qn(n).then((e=>e.json()));this.loadedTextures.set(n,i),s=yield i,Kn((()=>{this.store.setItem(`${e}_texture`,s)}))}Object.entries(s).forEach((e=>{let[n,i]=e;if(this.loadedMaterialsMap.has(n))return;const{name:r,base_map:s,nor_map:o,alphamode:l,color:c={r:1,g:1,b:1,a:1},metallic:u=.5,roughness:h=.5}=i,{r:d,g:f,b:p,a:g}=c,m=0!==l,v=new F({name:r,color:new a(d,f,p),side:L,metalness:u,roughness:h,opacity:g,transparent:m,depthWrite:!m});if(s){const e=t+s;(new Je).load(e,(e=>{e.flipY=!0,e.encoding=I,e.wrapS=D,e.wrapT=D,e.minFilter=jt,e.magFilter=A,e.needsUpdate=!0,v.map=e,v.needsUpdate=!0,Mu.needsUpdate=!0}))}if(o){const e=t+o;(new Je).load(e,(e=>{e.flipY=!0,e.encoding=I,e.wrapS=D,e.wrapT=D,e.needsUpdate=!0,v.normalMap=e,v.needsUpdate=!0,Mu.needsUpdate=!0}))}const y=this.loadedMaterials.push(v)-1;this.loadedMaterialsMap.set(n,{material:v,materialIndex:y})}))}))}dispose(){this.workerPool.dispose(),URL.revokeObjectURL(this.workerSourceURL)}}const ff=new Map,pf=e=>{var t;return null!==(t=null==e?void 0:e.toLowerCase().endsWith(".png"))&&void 0!==t&&t},gf=e=>{if(ff.has(e))return ff.get(e);const t=new l;return ff.set(e,t),(new zt).load(e,(e=>{t.image=e,t.needsUpdate=!0,Mu.needsUpdate=!0})),t.encoding=I,t.wrapS=D,t.wrapT=D,t.flipY=!1,t.anisotropy=16,t.mipmaps=[],t.generateMipmaps=!0,t},mf=(e,t,n,i)=>{const[r,s,o,l,c]=t,u=i||l<1;return new F({name:e,color:new a(r,s,o),opacity:l,transparent:u,depthWrite:!u,alphaTest:.01,map:n,side:c})};class vf extends DataView{constructor(e,t){super(e),this.isLE=!0,this.appKeys=t}byteRevers(e,t){const n=t%this.appKeys.length;return e^this.appKeys[n]}getSoonUint8(e){return this.byteRevers(this.getUint8(e),e)}getSoonUint16(e){const t=new DataView(new Uint8Array(2).buffer);for(let n=0;n<2;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint16(0,this.isLE)}getSoonUint32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getUint32(0,this.isLE)}getSoonFloat32(e){const t=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)t.setUint8(n,this.getSoonUint8(e+n));return t.getFloat32(0,this.isLE)}}const yf=new TextDecoder;new TextDecoder;class wf{constructor(){this.materials=new Map}parseObject(e,t){const n=new ju(Object.assign(Object.assign({},t),{format:"sbm"})),i=new Nu({id:Yi()});n.add(i);const{materialsCache:r,meshsCache:s}=e;for(const[e,t]of Object.entries(r)){if(this.materials.has(e))continue;const{textureUrl:n,materialInfo:i}=t;let r=null;n&&(r=gf(n));const s=mf(e,i,r,pf(n));this.materials.set(e,s)}for(const[e,t]of Object.entries(s)){const{meshName:n,materialId:r,position:s,uv:o}=t,a=this.materials.get(r.toString());if(a){const t=new xe,r=new Float32Array(s),l=new Float32Array(o);r.length>0&&t.setAttribute("position",new f(r,3)),l.length>0&&t.setAttribute("uv",new f(l,2)),t.computeVertexNormals();const c=new _u(t,a,{id:`${e}_${Yi()}`,name:n||e});i.add(c)}}return n}}var bf=class{constructor(){this.materials=new Map,this.sbmInfo=null}parseBuffer(e,t,n){return Fn(this,void 0,void 0,(function*(){this.sbmInfo=t;const i=new DataView(e);let r=0;const s=[];for(let e=0;e<8;e++)s.push(i.getUint8(r)),r+=1;if("SBK-----"!==String.fromCharCode(...s))return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})格式或数据错误!`);const o=[],a=[],l=[];for(let e=0;e<32;e++)o.push(i.getUint8(r)),r+=1;const c=i.getUint8(r);r+=1;const u=i.getUint8(r);r+=1;for(let e=0;e<32;e++)a.push(i.getUint8(r)),r+=1;for(let e=0;e<64;e++)l.push(i.getUint8(r)),r+=1;const h=[...a,...l,...o],d=[];for(let e=0;e<h.length;e++)(e<=7||e>23&&e<=31||e>39&&e<=55||e>63&&e<=87||e>95&&e<=103)&&d.push(h[e]);if(64!==d.length)return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url} 数据错误!`);if(1===c){const e=i.buffer.slice(r,i.buffer.byteLength),t=new vf(e,d);return 1===u||2===u?this._parseV2(t,n):3===u?this._parseV3(t,n):Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})版本错误!`)}return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})key 错误!`)}))}_parseV2(e,n){let i=0;const r=performance.now();i+=66;const s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const o=new ju(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new Nu({id:Yi()});o.add(a);const l=e.getSoonUint16(i);i+=2;const c=e.getSoonUint16(i);i+=2,s.total=c;const u={};for(let t=0;t<l;++t){const t=e.getSoonUint16(i).toString();i+=2,u[t]={materialInfo:[]},i+=4,i+=4,i+=4,i+=4;const n=e.getSoonFloat32(i);i+=4;const r=e.getSoonFloat32(i);i+=4;const s=e.getSoonFloat32(i);i+=4;const o=e.getSoonFloat32(i);i+=4,i+=4,i+=4,i+=4,i+=4;let a=e.getSoonUint8(i);i+=1,0===a?a=L:1===a?a=_:2===a&&(a=d);const l=e.getSoonUint16(i);i+=2;let c=null;if(l>0){let n="",r="";for(let t=0;t<l;t++){const t=e.getSoonUint8(i);t>127?r=r+"%"+t.toString(16).toUpperCase():r.length>0?(n+=decodeURIComponent(r)+String.fromCharCode(t),r=""):n+=String.fromCharCode(t),i+=1}n=n.replace("\\","/");const{url:s,isPlatform:o}=this.sbmInfo,a=this.getTextureUrl(s,n,o);u[t].textureUrl=a,c=gf(a)}if(!this.materials.has(t)){const e=[n,r,s,o,a],i=mf(t,e,c,pf(u[t].textureUrl));this.materials.set(t,i),u[t].materialInfo=e}}const h={};for(let o=0;o<c;++o){const o=e.getSoonUint16(i);i+=2;const l=e.getSoonUint16(i).toString();i+=2,h[o]={materialId:l,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const c=[],u=[],d=[],p=[],g=e.getSoonUint16(i);if(i+=2,g>0)for(let n=0;n<g;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4,c.push(n)}const m=e.getSoonUint16(i);if(i+=2,m>0)for(let n=0;n<m;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4}const v=e.getSoonUint16(i);if(i+=2,v>0)for(let t=0;t<v;t++){const t=new M;t.setX(e.getSoonFloat32(i)),i+=4,t.setY(e.getSoonFloat32(i)),i+=4,u.push(t)}const y=e.getSoonUint16(i);if(i+=2,y>0)for(let t=0;t<y;t++){const t=e.getSoonUint16(i);i+=2;const n=e.getSoonUint16(i);i+=2;const r=e.getSoonUint16(i);i+=2;const s=[t,n,r];d.push(s),u.length>0&&p.push([u[s[0]],u[s[1]],u[s[2]]])}const w=[],b=[];for(let e=0;e<d.length;e++){const t=d[e],n=c[t[0]],i=c[t[1]],r=c[t[2]];w.push(...n.toArray(),...i.toArray(),...r.toArray());let s=new M,o=new M,a=new M;const l=p[e];void 0!==l&&(s=l[0],o=l[1],a=l[2]),b.push(...s.toArray(),...o.toArray(),...a.toArray())}const x=new Float32Array(w),A=new Float32Array(b);h[o].position=x.buffer,h[o].uv=A.buffer;const T=new xe;x.length>0&&T.setAttribute("position",new f(x,3)),A.length>0&&T.setAttribute("uv",new f(A,2)),T.computeVertexNormals();const S=this.materials.get(l);if(S){const e=new _u(T,S,{id:`${o}_${Yi()}`,name:o.toString()});a.add(e)}s.loaded++,s.timeStamp=performance.now()-r,null==n||n(s)}const p={materialsCache:u,meshsCache:h};return Promise.resolve({model:o,caches:p})}_parseV3(e,n){let i=0;i+=66;const r=performance.now(),s={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const o=new ju(Object.assign(Object.assign({},this.sbmInfo),{format:"sbm"})),a=new Nu({id:Yi()});o.add(a);const l=e.getSoonUint16(i);i+=2;const c=e.getSoonUint16(i);i+=2,s.total=c;const u={};for(let t=0;t<l;++t){const t=e.getSoonUint16(i).toString();i+=2,u[t]={materialInfo:[]},i+=4,i+=4,i+=4,i+=4;const n=e.getSoonFloat32(i);i+=4;const r=e.getSoonFloat32(i);i+=4;const s=e.getSoonFloat32(i);i+=4;const o=e.getSoonFloat32(i);i+=4,i+=4,i+=4,i+=4,i+=4;let a=e.getSoonUint8(i);i+=1,0===a?a=L:1===a?a=_:2===a&&(a=d);const l=e.getSoonUint16(i);i+=2;let c=null;if(l>0){let n="",r="";for(let t=0;t<l;t++){const t=e.getSoonUint8(i);t>127?r=r+"%"+t.toString(16).toUpperCase():r.length>0?(n+=decodeURIComponent(r)+String.fromCharCode(t),r=""):n+=String.fromCharCode(t),i+=1}n=n.replace("\\","/");const{url:s,isPlatform:o}=this.sbmInfo,a=this.getTextureUrl(s,n,o);u[t].textureUrl=a,c=gf(a)}if(!this.materials.has(t)){const e=[n,r,s,o,a],i=mf(t,e,c,pf(u[t].textureUrl));this.materials.set(t,i),u[t].materialInfo=e}}const h={};for(let o=0;o<c;++o){const o=e.getSoonUint16(i).toString();i+=2;const l=e.getSoonUint16(i);i+=2;let c="";if(l>0){const t=[];for(let n=0;n<l;n++){const n=e.getSoonUint8(i);t.push(n),i+=1}const n=new Uint8Array(t);c=yf.decode(n)}const u=e.getSoonUint16(i).toString();i+=2,h[o]={meshName:c,materialId:u,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const d=[],p=[],g=[],m=[],v=e.getSoonUint32(i);if(i+=4,v>0)for(let n=0;n<v;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4,d.push(n)}const y=e.getSoonUint32(i);if(i+=4,y>0)for(let n=0;n<y;n++){const n=new t;n.setX(e.getSoonFloat32(i)),i+=4,n.setY(e.getSoonFloat32(i)),i+=4,n.setZ(e.getSoonFloat32(i)),i+=4}const w=e.getSoonUint32(i);if(i+=4,w>0)for(let t=0;t<w;t++){const t=new M;t.setX(e.getSoonFloat32(i)),i+=4,t.setY(e.getSoonFloat32(i)),i+=4,p.push(t)}const b=e.getSoonUint32(i);if(i+=4,b>0)for(let t=0;t<b;t++){const t=e.getSoonUint32(i);i+=4;const n=e.getSoonUint32(i);i+=4;const r=e.getSoonUint32(i);i+=4;const s=[t,n,r];g.push(s),p.length>0&&m.push([p[s[0]],p[s[1]],p[s[2]]])}const x=[],A=[];for(let e=0;e<g.length;e++){const t=g[e],n=d[t[0]],i=d[t[1]],r=d[t[2]];x.push(...n.toArray(),...i.toArray(),...r.toArray());let s=new M,o=new M,a=new M;const l=m[e];void 0!==l&&(s=l[0],o=l[1],a=l[2]),A.push(...s.toArray(),...o.toArray(),...a.toArray())}const T=new Float32Array(x),S=new Float32Array(A);h[o].position=T.buffer,h[o].uv=S.buffer;const E=new xe;if(T.length>0&&E.setAttribute("position",new f(T,3)),S.length>0&&E.setAttribute("uv",new f(S,2)),E.computeVertexNormals(),this.materials.has(u)){const e=new _u(E,this.materials.get(u),{id:`${o}_${Yi()}`,name:c});a.add(e)}s.loaded++,s.timeStamp=performance.now()-r,null==n||n(s)}const p={materialsCache:u,meshsCache:h};return Promise.resolve({model:o,caches:p})}getTextureUrl(e,t,n){let i="",r=t;const s=r.lastIndexOf("/");if(-1!==s&&(r=r.substring(s+1)),i=e,n){const e=i.split("/");e.length>1&&(e.splice(e.length-3,e.length),i=e.join("/")+"/Maps/"+r)}else{const e=i.lastIndexOf("/");-1!==e&&(i=i.substring(0,e+1)+"Maps/"+r)}return i}};class xf extends ih{constructor(e,t){super("Model",e,t),this.viewport=e,this.isDisposed=!1,this.modelsPromiseMap=new Map,this.modelsMap=new Map,this.store=sf.createInstance({name:"soonspace",storeName:"modelData"}),this.cacheStore=sf.createInstance({name:"soonspace",storeName:"modelCache"}),this.loadingManager=new de,this.datLoader=new df(this.cacheStore),this.gltfLoader=new od(this.loadingManager),this.fbxLoader=new Fh(this.loadingManager),this.dracoDecoderPath=null,this._initLoadingManager(this.loadingManager)}setDracoDecoderPath(e){this.dracoDecoderPath=e;const t=new tf;t.setDecoderPath(e),this.gltfLoader.setDRACOLoader(t),this.datLoader.dracoDecoderPath=e}load(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.scene;return Fn(this,void 0,void 0,(function*(){const{url:n}=e,i=this.modelsPromiseMap.get(n);if(i){if(yield i,this.isDisposed)return this.dispose(),null;const r=this.modelsMap.get(n);return r?this.clone(r,e,t):null}const r=this._innerLoad(e,t);return this.modelsPromiseMap.set(n,r),r}))}parse(e){return Fn(this,void 0,void 0,(function*(){const{url:t,id:n}=e;if(!t)return yn(`id: ${n} url: ${t} is empty`),null;switch(t.slice(t.lastIndexOf(".")+1).toLocaleUpperCase()){case"SBM":return this._parseSbm(e);case"SBMX":return this._parseSbmx(e);case"DAT":return this._parseDat(e);case"GLB":case"GLTF":return this._parseGltf(e);case"FBX":return this._parseFbx(e);default:return yn(`模型资源( id: ${n}, url: ${t} )格式错误,当前格式支持 sbm、sbmx、fbx、gltf、glb !`),null}}))}clone(e,t,n){return new Promise(((i,r)=>{var s;"Model"!==e.stype&&r("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:o,name:a,level:l,visible:c,position:u,rotation:h,scale:d,onClick:f,onDblClick:p,onRightClick:g,onLoad:m,userData:v}=t;function y(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)y(e.children[i],t.children[i],n)}const w=function(e){const t=new Map,n=new Map,i=e.sClone();return y(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(e instanceof xt){const i=e,r=t.get(e),s=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=s.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)}})),i}(e);w.animations=w.animations.map((e=>e.clone())),o&&(w.sid=o),a&&(w.name=a),l&&(w.level=l),!1===c&&w.hide(),u&&w.position.set(u.x,u.y,u.z),h&&w.rotation.set(h.x,h.y,h.z),d&&w.scale.set(d.x,d.y,d.z),w.onClick=f?f.bind(w):null,w.onDblClick=p?p.bind(w):null,w.onRightClick=g?g.bind(w):null,w.onLoad=m?m.bind(w):null,null===(s=w.onLoad)||void 0===s||s.call(w,w),v&&(w.userData=v),null!==n&&this.viewport.scener.addObject(w,n||this.scene||e.parent),i(w)}))}loadToGroup(e,t){return Fn(this,void 0,void 0,(function*(){const n=this.createGroup(e,null);return yield Promise.allSettled(t.map((e=>this.load(e,null).then((e=>e&&n.add(e))).catch(console.error)))),this.viewport.scener.addObject(n,this.scene),n}))}addForGroup(e,t){return Fn(this,void 0,void 0,(function*(){return e&&(yield Promise.allSettled(t.map((t=>Fn(this,void 0,void 0,(function*(){return this.load(t,null).then((t=>t&&this.viewport.scener.addObject(t,e))).catch(console.error)})))))),e}))}clearIdb(){return Fn(this,void 0,void 0,(function*(){yield this.store.clear(),yield this.cacheStore.clear()}))}dispose(){var e;this.isDisposed=!0,this.modelsPromiseMap.clear(),this.modelsMap.clear(),null===(e=this.gltfLoader.dracoLoader)||void 0===e||e.dispose(),this.datLoader.dispose()}_initLoadingManager(e){e.addHandler(/\.tga$/i,new rd)}_setModelsMap(e,t){this.modelsMap.has(e)||this.modelsMap.set(e,t)}_parseSbm(e){return Fn(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,{url:n}=e,i=t=>Fn(this,void 0,void 0,(function*(){const i=yield(new bf).parseBuffer(t,e),{model:r,caches:s}=i;return s&&Kn((()=>{this.cacheStore.setItem(n,s)})),r})),r=e=>{var t;null===(t=e.onLoad)||void 0===t||t.call(e,e)};if(t){const t=yield this.cacheStore.getItem(n);if(t){const n=(new wf).parseObject(t,e);return r(n),n}{const e=(yield this.store.getItem(n))||(yield this._fetchBuffer(n)),t=yield i(e);return r(t),t}}{const e=yield this._fetchBuffer(n),t=yield i(e);return r(t),t}}))}_parseSbmx(e){return Fn(this,void 0,void 0,(function*(){const{url:t}=e,n=yield this._getBuffer(t),i=Vi(n,0,8),r=new DataView(n.slice(8));switch(i){case"SBMG----":for(let e=0;e<r.byteLength;e++){const t=r.getUint8(e),n=(t>>4&15)+(t<<4&240);r.setUint8(e,n)}return this._parseGltf(e,r.buffer);case"SBMD----":return this._parseDat(e,r.buffer);default:return this._parseGltf(e,r.buffer)}}))}_parseDat(e,t){return Fn(this,void 0,void 0,(function*(){const{url:n}=e,i=t||(yield this._getBuffer(n)),r=new ju(Object.assign(Object.assign({},e),{format:"dat"})),s=yield this.datLoader.parseAsync(i,n);return s&&r.add(s),r}))}_parseGltf(e,t){return Fn(this,void 0,void 0,(function*(){const{url:n}=e,i=Rn(n),r=t||(yield this._getBuffer(n)),s=new ju(Object.assign(Object.assign({},e),{format:"gltf"})),o=yield this.gltfLoader.parseAsync(r,i),{animations:a}=o;return a&&a.length>0&&(s.animations=a),o.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),s.add(o.scene),s}))}_parseFbx(e){return Fn(this,void 0,void 0,(function*(){const{url:t}=e,n=Rn(t),i=yield this._getBuffer(t),r=new ju(Object.assign(Object.assign({},e),{format:"gltf"})),s=this.fbxLoader.parse(i,n),{animations:o}=s;return o&&o.length>0&&(r.animations=o),s.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),r.add(s),r}))}_innerLoad(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.scene;var n;return Fn(this,void 0,void 0,(function*(){const{url:i}=e,r=yield this.parse(e);return r?(null===(n=r.onLoad)||void 0===n||n.call(r,r),this._setModelsMap(i,r.sClone()),null!==t&&this.viewport.scener.addObject(r,t),r):null}))}_fetchBuffer(e){return Fn(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options,n=yield Qn(e),i=yield n.arrayBuffer();return t&&this.store.setItem(e,i),i}))}_getBuffer(e){return Fn(this,void 0,void 0,(function*(){const{useIndexedDB:t}=this.viewport.options;if(t){const t=yield this.store.getItem(e);return t||this._fetchBuffer(e)}return this._fetchBuffer(e)}))}}class Af extends ih{constructor(e,t){super("Poi",e,t),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new Gu(t,e);return this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:i,type:r,name:s,level:o,visible:a,position:l,rotation:c,scale:u,onClick:h,onDblClick:d,onRightClick:f,userData:p}=t,g=e.sClone(!1,r);return this._copyMaterial(g),i&&(g.sid=i),s&&(g.name=s),o&&(g.level=o),Ui(a)&&(g.visible=a),l&&g.position.set(l.x,l.y,l.z),c&&g.rotation.set(c.x,c.y,c.z),u&&g.scale.set(u.x,u.y,u.z),g.onClick=h?h.bind(g):null,g.onDblClick=d?d.bind(g):null,g.onRightClick=f?f.bind(g):null,p&&(g.userData=p),null!==n&&this.viewport.scener.addObject(g,n||this.scene||e.parent),g}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this._createMaterial(e.url),i=new Gu(t,e);n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=this._createMaterial(t.url),i=new Gu(n,t);e.add(i)})),this.viewport.scener.addObject(e,this.scene)),e}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new Je).load(e);t.flipY=!0;const n=new et({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof k||e instanceof $e)&&(ji(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof Ae&&(e.material=e.material.clone()))}))}}class Tf extends ih{constructor(e,t){super("PoiNode",e,t)}create(e){this._openEnableRenderCss(e);const t=new Fu(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new Fu(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{this._openEnableRenderCss(t);const n=new Fu(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class Sf extends ih{constructor(e,t){super("Canvas3D",e,t)}create(e){const t=new $u(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=new $u(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&(t.forEach((t=>{const n=new $u(t);e.add(n)})),this.viewport.scener.addObject(e,this.scene)),e}}class Ef{constructor(){this.graph=new Map,this.queue=null,this.previous=new Map}setGraph(e){if(!(e.length<1))for(const t of e){const[e,n]=t;this.graph.set(e,new Map);for(const t of n){const[n,i]=t,r=this.graph.get(e);null==r||r.set(n,i)}}}getPath(e,t){var n;if(e===t)return[];const i=this.queue=new In;i.add(e,0),this.previous.set(e,null);let r=null;for(;r=i.shift();){if(r===t){const e=[];for(;null!==r&&null!==this.previous.get(r);)e.unshift(r),r=null!==(n=this.previous.get(r))&&void 0!==n?n:null;return e}const e=i.getDistance(r);if(e===1/0)return[];const s=this.graph.get(r);s&&s.forEach(((t,n)=>{const s=i.getDistance(n),o=e+t;o<s&&(i.update(n,o),this.previous.set(n,r))}))}return[]}}class Df extends ih{constructor(e,t){super("Topology",e,t),this.dijkstra=new Ef}createFromGml(e){return Fn(this,void 0,void 0,(function*(){const{url:t,linkWidth:n=20,linkColor:i=65280,renderNode:r=!0,nodeColor:s=255}=e;return qn(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const o=[],a=new Map;let l=[],c=[];const u=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;ji(u)?u.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...u.state],c=[...c,...u.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],i=e.State.topoNode["gml:Node"].node_name;o.push({id:Ni(n)?n:"",name:Ni(i)?i:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),a.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],i=e.Transition.topoEdge["gml:Edge"].restrict["#text"],r=e.Transition.topoEdge["gml:Edge"].passable["#text"],s=a.get(t),l=a.get(n),c=e.Transition._attributes["gml:id"],u=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==s&&void 0!==l&&("2"!==r&&"3"!==r&&o[s].graphs.push({targetNodeId:n,linkInfo:{id:c,name:u},enable:!0,restrict:parseInt(i),passable:parseInt(r)}),"1"!==r&&"3"!==r&&o[l].graphs.push({targetNodeId:t,linkInfo:{id:c,name:u},enable:!0,restrict:parseInt(i),passable:parseInt(r)}))}));const h=new Qu(Object.assign(Object.assign({},e),{type:"network",nodes:o,linkWidth:n,renderLink:!0,linkColor:i,renderNode:r,nodeColor:s}));return this.setDijkstraGraph(h.nodes),this.viewport.scener.addObject(h,this.scene),Promise.resolve(h)}))}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e),n=new Qu(t);return this.setDijkstraGraph(n.nodes),this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},e.info),{nodes:t}));return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e),i=new Qu(t);this.setDijkstraGraph(i.nodes),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){return e&&t.forEach((t=>{const n=this.generateLineTopologyInfoNodeGraphs(t),i=new Qu(n);this.setDijkstraGraph(i.nodes),e.add(i)})),e}getShortestPath(e,n){const i=Pn(e.info.nodes),r=wn(n.start),s=wn(n.end);let o=null,a=1/0,l=null,c=1/0;for(let n=0;n<i.length;n++){const u=i[n];if(0===u.graphs.length)continue;const h=e.nodes.find((e=>e.sid===u.id));if(!h)continue;const d=h.getWorldPosition(new t),f=d.distanceTo(r),p=d.distanceTo(s);f<a&&(a=f,o=u),p<c&&(c=p,l=u)}if(!o||!l||o.id===l.id)return null;const u=o.id,h=l.id,d=this.dijkstra.getPath(u,h);if(0===d.length)return null;d.unshift(o.id);const f=[];for(let e=0;e<d.length;e++){const t=i.find((t=>t.id==d[e]));t&&(t.id+=Yi(),t.position.y+=.01,f.push(t))}const p=Object.assign(Object.assign(Object.assign({},n),{type:"line",nodes:f}),e.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(p);const g=new Qu(p);return this.viewport.scener.addObject(g,this.scene),g}getShortestPathByMultipleStartPoints(e,i){const{nodes:s}=e.info,o=[];i.start.forEach((e=>{const t=wn(e),n=wn(i.end);let r=null,a=1/0,l=null,c=1/0;if(s.forEach((e=>{if(e.graphs.length>0){const i=wn(e.position),s=i.distanceTo(t),o=i.distanceTo(n);s<a&&(a=s,r=e.id),o<c&&(c=o,l=e.id)}})),r&&l){let e=0;const i=this.dijkstra.getPath(r,l);if(i.length>0){const r=[{id:"startPoint",position:t,graphs:[]}];i.forEach(((n,i)=>{const o=s.find((e=>e.id==n));o&&(e+=0===i?wn(o.position).distanceTo(t):wn(o.position).distanceTo(wn(r[r.length-1].position)),r.push(o))})),r.push({id:"endPoint",position:n,graphs:[]}),e+=n.distanceTo(wn(r[r.length-1].position)),o.push({nodeInfo:r,pathLength:e})}}}));let a=[],l=1/0;if(o.forEach((e=>{let{nodeInfo:t,pathLength:n}=e;n<l&&(l=n,a=t)})),a.length){for(let e=0;e<a.length;e++)a[e].position.y+=.01;const s=Object.assign(Object.assign({},i),{type:"line",nodes:a,position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)});this.generateLineTopologyInfoNodeGraphs(s);const o=new Qu(s);return this.viewport.scener.addObject(o,this.scene),o}return null}getShortestPathByMultipleEndPoints(e,i){const{nodes:s}=e.info,o=[];i.end.forEach((e=>{const t=wn(i.start),n=wn(e);let r=null,a=1/0,l=null,c=1/0;if(s.forEach((e=>{if(e.graphs.length>0){const i=wn(e.position),s=i.distanceTo(t),o=i.distanceTo(n);s<a&&(a=s,r=e.id),o<c&&(c=o,l=e.id)}})),r&&l){let e=0;const i=this.dijkstra.getPath(r,l);if(i.length>0){const r=[{id:"startPoint",position:t,graphs:[]}];i.forEach(((n,i)=>{const o=s.find((e=>e.id==n));o&&(e+=0===i?wn(o.position).distanceTo(t):wn(o.position).distanceTo(wn(r[r.length-1].position)),r.push(o))})),r.push({id:"endPoint",position:n,graphs:[]}),e+=n.distanceTo(wn(r[r.length-1].position)),o.push({nodeInfo:r,pathLength:e})}}}));let a=[],l=1/0;if(o.forEach((e=>{let{nodeInfo:t,pathLength:n}=e;n<l&&(l=n,a=t)})),a.length){for(let e=0;e<a.length;e++)a[e].position.y+=.01;const s=Object.assign(Object.assign({},i),{type:"line",nodes:a,position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)});this.generateLineTopologyInfoNodeGraphs(s);const o=new Qu(s);return this.viewport.scener.addObject(o,this.scene),o}return null}setDijkstraGraph(e){const n=[];for(let i=0;i<e.length;i++){const r=e[i];if(0===r.graphs.length)continue;const s=[];for(let n=0;n<r.graphs.length;n++){const i=r.graphs[n],o=e.find((e=>e.sid===i.targetNodeId));if(!o)continue;const a=r.getWorldPosition(new t),l=o.getWorldPosition(new t);s.push([i.targetNodeId,a.distanceTo(l)])}n.push([r.sid,s])}n.length>0&&this.dijkstra.setGraph(n)}generateLineTopologyInfoNodeGraphs(e){const{type:t,nodes:n}=e;if("line"===t)for(let t=0;t<n.length;t++)if(t===n.length-1)n[t].graphs=[];else{const i=e.nodes[t],r=e.nodes[t+1];n[t].graphs=[{targetNodeId:r.id,linkInfo:{id:`${i.id}_to_${r.id}`,name:`${i.name||i.id}_to_${r.name||r.id}`},enable:!0,restrict:0,passable:0}]}return Object.assign(Object.assign({},e),{nodes:n})}}class Cf extends At{constructor(e,t){const n=new xe;n.setAttribute("position",new it([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new q({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new xe;i.setAttribute("position",new it([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new k(i,new z({side:_,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class If extends ih{constructor(e,t){super("Helper",e,t)}addGridHelper(e){const{id:t,size:n=1e3,divisions:i=20,color:r="#fff",position:s={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:a={x:1,y:1,z:1}}=e,l=new Ht(n,i,r,r);return l.position.set(s.x,s.y,s.z),l.rotation.set(o.x,o.y,o.z),l.scale.set(a.x,a.y,a.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,i=new Gt(n);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addBoxHelper(e){const{id:t,box:n,color:i="#00ff00"}=e,r=new Vt(n,new a(i));return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPlaneHelper(e){const{id:t,width:n=500,height:i=500,color:r="#00ff00",opacity:s=.2,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new _u(new ze(n,i),new z({color:r,opacity:s,transparent:s<1,side:d}),{id:t,position:o,rotation:a,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:i=500,height:r=500,opacity:s=1,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,u=(new Je).load(t),h=new ze(i,r);h.computeBoundingBox();const f=new F({side:d,map:u,transparent:s<1,opacity:s,roughness:.8});f.map&&(f.map.repeat.set(c.x,c.x),f.map.wrapS=D,f.map.wrapT=D,f.map.version++),a.x-=Math.PI/2,f.version++;const p=new eh(h,f,{id:n,position:o,rotation:a,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(e){const{id:t,light:n,color:i,size:r=50}=e,s=new Yt(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new Wt(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(e){const{id:t,light:n,color:i}=e,r=new Xt(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPointLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new Qt(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addRectAreaLightHelper(e){const{id:t,light:n,color:i}=e,r=new Cf(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}}class Mf extends ih{constructor(e,t){super("PluginObject",e,t)}createObject(e,t){const n=new Uu(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){return e?(this.viewport.scener.addObject(t,e),e):null}}class Bf extends ih{constructor(e,t){super("Group",e,t)}}class Rf{constructor(e){this.viewport=e,this.cache={objects:new Map},this.scene=e.scene,this.store={groupManager:new Bf(e,this.scene),lightManager:new rh(e,this.scene),modelManager:new xf(e,this.scene),poiManager:new Af(e,this.scene),poiNodeManager:new Tf(e,this.scene),canvas3DManager:new Sf(e,this.scene),topologyManager:new Df(e,this.scene),helperManager:new If(e,this.scene),pluginObjectManager:new Mf(e,this.scene)},e.postUpdate.set("ManagerRender",this.update.bind(this)),e.signals.objectAdded.add(this.setObjectCache.bind(this)),e.signals.objectRemoved.add(this.deleteObjectCache.bind(this))}levelUpdate(){const e=(e,t)=>{e.visible!==t&&(e.visible=t,e.matrixAutoUpdate=t,e.autoUpdate=!0)},t=t=>{const{level:n,handleHide:i,autoUpdate:r}=t,{max:s=null,min:o=null}=n;if(r)t.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!i&&(Fi(s)||Fi(o))){const n=this.viewport.camera.position.distanceTo(t.position);Fi(s)&&n>s||Fi(o)&&n<o?e(t,!1):e(t,!0)}};this.scene.traverse((e=>{(e instanceof ku||e instanceof _u)&&t(e)}))}update(){if(0===this.scene.children.length)return;const e=performance.now();this.viewport.options.levelEnabled&&this.levelUpdate(),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}isObjectInScene(e){let t=!1;return e.traverseAncestors((e=>{e===this.scene&&(t=!0)})),t}getObjectById(e){const t=this.getObjectCache(e);if(t){if(this.isObjectInScene(t))return t}return null}getObjectByName(e){return this._getObjectByProps("name",e)}getObjectByUserDataProperty(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&zi(i)&&(i instanceof ku||i instanceof _u||i.userData.stype)&&(Hi(e)&&e(i.userData)||Ni(e)&&i.userData[e]===t)&&n.push(i)})),n}removeObjectById(e){const t=this.getObjectById(e);return!!t&&(this.viewport.scener.removeObject(t),!0)}_getObjectByProps(e,t){const n=[];return this.cache.objects.forEach((i=>{this.isObjectInScene(i)&&((i instanceof ku||i instanceof _u)&&zi(i)&&i[e]===t||zi(i)&&i.userData.stype&&("name"===e&&i.name===t||"sid"===e&&i.userData.sid===t))&&n.push(i)})),n}getObjectCache(e){return this.cache.objects.get(e)}setObjectCache(e){const t=(e,t)=>{const n=this.cache.objects.get(t);n&&n!==e&&yn(`object id ${t} already exists in scene`)};null==e||e.traverse((n=>{if(n instanceof ku||n instanceof _u){if("string"==typeof n.sid&&n.sid.startsWith(gn))return;t(n,n.sid),this.cache.objects.set(n.sid,n)}else n.userData.sid&&e.userData.stype&&(t(n,n.userData.sid),this.cache.objects.set(n.userData.sid,n))}))}deleteObjectCache(e){null==e||e.traverse((t=>{t instanceof ku||t instanceof _u?this.cache.objects.delete(t.sid):t.userData.sid&&e.userData.stype&&this.cache.objects.delete(t.userData.sid)}))}clearObject(){this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.lightManager.clear()}dispose(){this.store.modelManager.dispose(),this.cache.objects.clear(),this.clear()}}function Pf(e){const t=Of(e),n=new m;n.setFromMatrix3(t);const i=e[0],r=n.clone();r.setPosition(i);const s=r.clone().invert(),o=e.map((e=>{const t=e.clone().applyMatrix4(s);return new M(t.x,t.y)})),a=new st(o),l=new rt(a),c=new Kt;c.setFromPoints(o);const u=_f(c);return l.getAttribute("uv").applyMatrix3(u),l.applyMatrix4(n),{geometry:l,polygonBox:c,modelMatrix:n,planeMatrix:r,projectionMatrix:s,position:i}}function Of(e){const[n,i,r]=e,s=new B;s.setFromCoplanarPoints(i,n,r);const o=s.normal,a=o.clone().cross(new t(0,0,1));a.equals(new t)&&a.set(1,0,0);const l=o.clone().cross(a);a.normalize(),l.normalize(),o.normalize();const c=new Pe;return c.elements=[a.x,a.y,a.z,l.x,l.y,l.z,o.x,o.y,o.z],c}function _f(e){const t=e.min,n=e.getSize(new M),i=new Pe;return i.elements=[n.x,0,0,0,n.y,0,t.x,t.y,1],i.invert()}function Lf(e,t){const n=kf(t);return e.intersectsBox(n)}function kf(e){const n=new i,r=n.min.clone(),s=n.max.clone();if(n.setFromObject(e),n.min.equals(r)&&n.max.equals(s)){const i=new t;e.getWorldPosition(i),n.min.copy(i),n.max.copy(i)}if(e.isInstancedMesh){const{count:t,matrixWorld:i,geometry:r}=e;let s=r.boundingBox;if(s||(r.computeBoundingBox(),s=r.boundingBox),s){const r=i.clone();for(let i=0;i<t;i++){const t=new m;e.getMatrixAt(i,t),t.premultiply(r);const o=s.clone();o.applyMatrix4(r),n.union(o)}}}return n}function Nf(e,t,n){if("string"==typeof e){let i=t?null==n?void 0:n.get(e):null;if(!i){i=(new Je).load(e),null==n||n.set(e,i)}return i}return e instanceof HTMLImageElement?new l(e):e instanceof HTMLCanvasElement?new je(e):new Le(e)}function Uf(e,t,n,i){const r=e.map,s=Nf(t,n,i);if(!r)return e.map=s,s;const o=s.source;return s.copy(r),s.source=o,e.map=s,s}function Ff(e,n){const{top:r,left:s,bottom:o,right:a,front:l,back:c}=e,u=new t(a,r,l),h=new t(s,o,c),d=new i;return function(e){return d.max.addVectors(e,u),d.min.subVectors(e,h),n.filter((e=>Lf(d,e)))}}function jf(e,n){const i=new O(new t,e);return function(e){return i.center.copy(e),n.filter((e=>Lf(i,e)))}}function zf(e,n){const i=e.length-1,r=[];for(let t=0;t<i;t++){const n=e[t],i=e[t+1],s=new R(n,i);r.push(s)}const s=new O(new t,n);return function(e){return e.filter((e=>{const n=kf(e),i=new t;n.getCenter(i);const o=r.filter((e=>{const t=e.closestPointToPointParameter(i);return 0<=t||t>=1}));if(0===o.length)return!1;let a=1/0,l=i;for(const e of o){const n=e.closestPointToPoint(i,!0,new t),r=i.distanceToSquared(n);r<a&&(a=r,l=n)}return s.center.copy(l),s.intersectsBox(n)}))}}function Hf(e,t){const{image:n,color:i,width:r,height:s,position:o,rotation:a,needLight:l,id:c,name:u,userData:h,level:d,visible:f,cache:p}=e,g=Un(e,["image","color","width","height","position","rotation","needLight","id","name","userData","level","visible","cache"]),m=new ze(r,s),v=n?Object.assign(Object.assign({transparent:!0},g),{map:Nf(n,null==p||p,t)}):g,y=l?new vt(v):new z(v),w=new _u(m,y,{id:c,name:u,userData:h,level:d,visible:f});return o&&w.position.set(o.x,o.y,o.z),a&&w.rotation.set(a.x,a.y,a.z),w}function Gf(e,n){const{points:i,image:r,color:s,needLight:o,id:a,name:l,userData:c,level:u,visible:h,cache:d}=e,f=Un(e,["points","image","color","needLight","id","name","userData","level","visible","cache"]),p=i.map((e=>new t(e.x,e.y,e.z))),g=r?Object.assign(Object.assign({transparent:!0},f),{map:Nf(r,null==d||d,n)}):f,m=o?new vt(g):new z(g),{geometry:v,position:y}=Pf(p),w=new _u(v,m,{id:a,name:l,userData:c,level:u,visible:h});return w.position.copy(y),w}class Vf{constructor(t){this.THREE=e,this.TWEEN=pn,this.utils=Xi,this.version=Jt,this.animation=Ki,this.library=th,this.plugins={},this.textureCache=new Map;const{el:n,options:i={},events:r={}}=t;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showStats:!1,showViewHelper:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{type:"free"},hoverEnabled:!1,levelEnabled:!1,closeInfoLog:!1,closeWarnLog:!1,useIndexedDB:!0,logarithmicDepthBuffer:!0}),i),this.viewport=new Ou(this.options),this.signals=this.viewport.signals,this.manager=new Rf(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(r),this._initDefaultSettings()}_init(){const{showGrid:e,background:t,fog:n,controls:i,closeInfoLog:r,closeWarnLog:s,useIndexedDB:o}=this.options;if(!r){vn(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),vn(qt,{color:"#3eaf7c","font-size":"24px"}),vn(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),vn("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),vn("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),vn("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}e&&this.addGridHelper(!0===e?{id:"defaultGridHelper"}:e),(null==t?void 0:t.skyBox)?Ni(null==t?void 0:t.skyBox)?this.setSphereSkyBackground(null==t?void 0:t.skyBox):zi(null==t?void 0:t.skyBox)&&this.setSkyBackground(t.skyBox.dirPath,t.skyBox.fileNames):(null==t?void 0:t.img)?this.setBackgroundImage(t.img):(null==t?void 0:t.color)&&this.setBackgroundColor(t.color),n&&this.openSceneFog(!0===n?void 0:n),i&&this.setControlsOptions(i),s&&(window.console.warn=function(){}),o&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:i,modelRightClick:r,modelDblClick:s,poiHover:o,poiUnHover:a,poiClick:l,poiRightClick:c,poiDblClick:u,selectPosition:h,sceneClick:d,resize:f}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),i&&this.signals.modelClick.add(i),r&&this.signals.modelRightClick.add(r),s&&this.signals.modelDblClick.add(s),o&&this.signals.poiHover.add(o),a&&this.signals.poiUnHover.add(a),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),u&&this.signals.poiDblClick.add(u),h&&this.signals.selectPosition.add(h),d&&this.signals.sceneClick.add(d),f&&this.signals.windowResize.add(f),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultSettings(){this.setEnvironment(),this.setColorSpace("sRGB"),this.setToneMapping({type:"ACESFilmic",exposure:.8})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){const n=this.getObjectById(e);return this.manager.store.pluginObjectManager.addToObject(n,t)}getPluginObjectById(e){return yn("getPluginObjectById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPluginObjectByName(e){return yn("getPluginObjectByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}removePluginObjectById(e){return yn("removePluginObjectById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}setSSR(e){this.viewport.setSSR(e)}setBloom(e){this.viewport.setBloom(e)}setSSAO(e){this.viewport.setSSAO(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setToneMapping(e){this.viewport.setToneMapping(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundColorAlpha(e,t){this.viewport.setBackgroundColorAlpha(e,t)}setBackgroundImage(e){return this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){return this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){return this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){this.manager.dispose(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}getCameraTargetView(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraTargetView(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return"orbit"===this.viewport.controls.options.type&&this.utils.warn("flyTo 方法不适用于 orbit 控制器"),this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"frontTop",t=arguments.length>1?arguments[1]:void 0;return this.flyToObj(this.manager.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",n=arguments.length>2?arguments[2]:void 0;return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}getScreenshot(){return this.screenshot()}screenshot(){return this.viewport.screenshot()}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.lightManager.createAmbientLight(e)}setAmbientLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setAmbientLight(t,e)}createDirectionalLight(e){return this.manager.store.lightManager.createDirectionalLight(e)}setDirectionalLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setDirectionalLight(t,e)}createHemisphereLight(e){return this.manager.store.lightManager.createHemisphereLight(e)}setHemisphereLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setHemisphereLight(t,e)}createSpotLight(e){return this.manager.store.lightManager.createSpotLight(e)}setSpotLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setSpotLight(t,e)}createPointLight(e){return this.manager.store.lightManager.createPointLight(e)}setPointLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setPointLight(t,e)}createRectAreaLight(e){return this.manager.store.lightManager.createRectAreaLight(e)}setRectAreaLight(e){const t=this.getObjectById(e.id);return this.manager.store.lightManager.setRectAreaLight(t,e)}getLightById(e){return yn("getLightById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeLightById(e){return yn("removeLightById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}getAllLight(){return this.manager.store.lightManager.getAll()}clearLight(){return this.manager.store.lightManager.clear()}showAllLight(){return this.manager.store.lightManager.showAll()}hideAllLight(){return this.manager.store.lightManager.hideAll()}updateAllShadow(){return this.manager.store.lightManager.updateAllShadow()}getObjectById(e){return this.manager.getObjectById(e)}getObjectByName(e){return this.manager.getObjectByName(e)}getObjectByUserDataProperty(e,t){return this.manager.getObjectByUserDataProperty(e,t)}removeObjectById(e){return this.manager.removeObjectById(e)}createGroup(e){return this.manager.store.groupManager.createGroup(e)}getGroupById(e){return yn("getGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getGroupByName(e){return yn("getGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllGroup(){return this.manager.store.groupManager.getAll()}showAllGroup(){return this.manager.store.groupManager.showAll()}hideAllGroup(){return this.manager.store.groupManager.hideAll()}removeGroupById(e){return yn("removeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}loadSbm(e){return yn("loadSbm is deprecated, use loadModel instead"),this.loadModel(e)}parseSbm(){yn("parseSbm is deprecated!")}cloneSbm(e,t,n){return yn("cloneSbm is deprecated, use cloneModel instead"),this.cloneModel(e,t,n)}getSbmById(e){return yn("getSbmById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmByName(e){return yn("getSbmByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getSbmByUserDataProperty(e,t){return yn("getSbmByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeSbmById(e){return yn("removeSbmById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForSbm(e){return yn("createGroupForSbm is deprecated, use createGroup instead"),this.createGroup(e)}loadSbmToGroup(e,t){return yn("loadSbmToGroup is deprecated, use loadModelToGroup instead"),this.loadModelToGroup(e,t)}addSbmForGroup(e,t){return yn("addSbmForGroup is deprecated, use addModelForGroup instead"),this.addModelForGroup(e,t)}createSbmGroupFromXml(){yn("createGroupForSbm is deprecated!")}getSbmGroupById(e){return yn("getSbmGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getSbmGroupByName(e){return yn("getSbmGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllSbmGroup(){return yn("getAllSbmGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeSbmGroupById(e){return yn("removeSbmGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearSbm(){return yn("clearSbm is deprecated, use clearModel instead"),this.clearModel()}getAllSbm(){return yn("getAllSbm is deprecated, use getAllModel instead"),this.getAllModel()}showAllSbm(){return yn("showAllSbm is deprecated, use showAllModel instead"),this.showAllModel()}hideAllSbm(){return yn("hideAllSbm is deprecated, use hideAllModel instead"),this.hideAllModel()}getSbmModelMaps(){return yn("getSbmModelMaps is deprecated, use getModelsMap instead"),this.getModelsMap()}setSbmModelMaps(e){return yn("setSbmModelMaps is deprecated, use setModelsMap instead"),this.setModelsMap(e)}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return yn("getModelById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelByName(e){return yn("getModelByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getModelByUserDataProperty(e,t){return yn("getModelByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeModelById(e){return yn("removeModelById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForModel(e){return yn("createGroupForModel is deprecated, use createGroup instead"),this.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.modelManager.addForGroup(n,t)}getModelGroupById(e){return yn("getModelGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getModelGroupByName(e){return yn("getModelGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllModelGroup(){return yn("getAllModelGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeModelGroupById(e){return yn("removeModelGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}computeModelsBoundsTree(e){return this.viewport.bvh.computeModelsBoundsTree(e)}clearIdb(){return this.manager.store.modelManager.clearIdb()}getModelsMap(){return this.manager.store.modelManager.modelsMap}setModelsMap(e){this.manager.store.modelManager.modelsMap=e}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return yn("getPoiById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiByName(e){return yn("getPoiByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiByUserDataProperty(e,t){return yn("getPoiByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiById(e){return yn("removePoiById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoi(e){return yn("createGroupForPoi is deprecated, use createGroup instead"),this.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiManager.addForGroup(n,t)}getPoiGroupById(e){return yn("getPoiGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiGroupByName(e){return yn("getPoiGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiGroup(){return yn("getAllPoiGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiGroupById(e){return yn("removePoiGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return yn("getPoiNodeById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeByName(e){return yn("getPoiNodeByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getPoiNodeByUserDataProperty(e,t){return yn("getPoiNodeByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removePoiNodeById(e){return yn("removePoiNodeById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForPoiNode(e){return yn("createGroupForPoiNode is deprecated, use createGroup instead"),this.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.poiNodeManager.addForGroup(n,t)}getPoiNodeGroupById(e){return yn("getPoiNodeGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getPoiNodeGroupByName(e){return yn("getPoiNodeGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllPoiNodeGroup(){return yn("getAllPoiNodeGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiNodeGroupById(e){return yn("removePoiNodeGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createPoiMesh(e){const t=Hf(e,this.textureCache);return this.addObject(t),t}createPolygonPoiMesh(e){const t=Gf(e,this.textureCache);return this.addObject(t),t}setTexture(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{cache:i=!0,independ:r=!0}=n||{};let s=e.material;if(r&&(s=s.clone(),e.material=s),null===t)return s.map=null,this.render(),null;const o=Uf(s,t,i,this.textureCache);return this.render(),o}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return yn("getCanvas3DById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DByName(e){return yn("getCanvas3DByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getCanvas3DByUserDataProperty(e,t){return yn("getCanvas3DByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeCanvas3DById(e){return yn("removeCanvas3DById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForCanvas3D(e){return yn("createGroupForCanvas3D is deprecated, use createGroup instead"),this.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.canvas3DManager.addForGroup(n,t)}getCanvas3DGroupById(e){return yn("getCanvas3DGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getCanvas3DGroupByName(e){return yn("getCanvas3DGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllCanvas3DGroup(){return yn("getAllCanvas3DGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeCanvas3DGroupById(e){return yn("removeCanvas3DGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return yn("getTopologyById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyByName(e){return yn("getTopologyByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getTopologyByUserDataProperty(e,t){return yn("getTopologyByUserDataProperty is deprecated, use getObjectByUserDataProperty instead"),this.getObjectByUserDataProperty(e,t)}removeTopologyById(e){return yn("removeTopologyById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}createGroupForTopology(e){return yn("createGroupForTopology is deprecated, use createGroup instead"),this.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){const n=this.getObjectById(e);return this.manager.store.topologyManager.addForGroup(n,t)}getTopologyGroupById(e){return yn("getTopologyGroupById is deprecated, use getObjectById instead"),this.getObjectById(e)}getTopologyGroupByName(e){return yn("getTopologyGroupByName is deprecated, use getObjectByName instead"),this.getObjectByName(e)}getAllTopologyGroup(){return yn("getAllTopologyGroup is deprecated, use getAllGroups instead"),this.getAllGroup()}removeTopologyGroupById(e){return yn("removeTopologyGroupById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return yn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return yn("getHelperById is deprecated, use getObjectById instead"),this.getObjectById(e)}removeHelperById(e){return yn("removeHelperById is deprecated, use removeObjectById instead"),this.removeObjectById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}createFindObjectsInBoxNearPosition(e,t){return Ff(e,t)}createFindObjectsInSphereNearPosition(e,t){return jf(e,t)}createFindObjectsNearPath(e,t){return zf(e,t)}createPathAnimation(e,t,n){return new Zi(e,t,n)}createTopologyAnimation(e,n,i){const r=n.nodes.map((e=>e.getWorldPosition(new t)));return new Zi(e,r,i)}}Vf.THREE=e,Vf.TWEEN=pn,Vf.utils=Xi;export{Vf as SoonSpace,Lf as boundingIsIntersected,Ff as createFindObjectsInBoxNearPosition,jf as createFindObjectsInSphereNearPosition,zf as createFindObjectsNearPath,Of as createPlaneMatrix,Hf as createPoiMesh,Gf as createPolygonPoiMesh,Nf as createTexture,_f as createUVMatrix,Vf as default,kf as getBoundingBox,Pf as getPolygonGeometryInfo,Uf as setTexture};